Run cargo fmt on the whole code base (#9394)

* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
+24 -21
View File
@@ -52,36 +52,35 @@
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]
mod tests;
mod benchmarking;
mod tests;
pub mod weights;
use sp_std::prelude::*;
use codec::{Encode, Decode};
use codec::{Decode, Encode};
use frame_support::{
dispatch::PostDispatchInfo,
traits::{IsSubType, OriginTrait, UnfilteredDispatchable},
transactional,
weights::{extract_actual_weight, GetDispatchInfo},
};
use sp_core::TypeId;
use sp_io::hashing::blake2_256;
use frame_support::{
transactional,
traits::{OriginTrait, UnfilteredDispatchable, IsSubType},
weights::{GetDispatchInfo, extract_actual_weight},
dispatch::PostDispatchInfo,
};
use sp_runtime::traits::Dispatchable;
use sp_std::prelude::*;
pub use weights::WeightInfo;
pub use pallet::*;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use super::*;
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);
/// Configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config {
@@ -89,9 +88,11 @@ pub mod pallet {
type Event: From<Event> + IsType<<Self as frame_system::Config>::Event>;
/// The overarching call type.
type Call: Parameter + Dispatchable<Origin=Self::Origin, PostInfo=PostDispatchInfo>
+ GetDispatchInfo + From<frame_system::Call<Self>>
+ UnfilteredDispatchable<Origin=Self::Origin>
type Call: Parameter
+ Dispatchable<Origin = Self::Origin, PostInfo = PostDispatchInfo>
+ GetDispatchInfo
+ From<frame_system::Call<Self>>
+ UnfilteredDispatchable<Origin = Self::Origin>
+ IsSubType<Call<Self>>
+ IsType<<Self as frame_system::Config>::Call>;
@@ -170,7 +171,7 @@ pub mod pallet {
// Take the weight of this function itself into account.
let base_weight = T::WeightInfo::batch(index.saturating_add(1) as u32);
// Return the actual used weight + base_weight of this call.
return Ok(Some(base_weight + weight).into());
return Ok(Some(base_weight + weight).into())
}
}
Self::deposit_event(Event::BatchCompleted);
@@ -213,13 +214,16 @@ pub mod pallet {
let info = call.get_dispatch_info();
let result = call.dispatch(origin);
// Always take into account the base weight of this call.
let mut weight = T::WeightInfo::as_derivative().saturating_add(T::DbWeight::get().reads_writes(1, 1));
let mut weight = T::WeightInfo::as_derivative()
.saturating_add(T::DbWeight::get().reads_writes(1, 1));
// Add the real weight of the dispatch.
weight = weight.saturating_add(extract_actual_weight(&result, &info));
result.map_err(|mut err| {
err.post_info = Some(weight).into();
err
}).map(|_| Some(weight).into())
result
.map_err(|mut err| {
err.post_info = Some(weight).into();
err
})
.map(|_| Some(weight).into())
}
/// Send a batch of dispatch calls and atomically execute them.
@@ -291,7 +295,6 @@ pub mod pallet {
Ok(Some(base_weight + weight).into())
}
}
}
/// A pallet identifier. These are per pallet and should be stored in a registry somewhere.