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
+2 -7
View File
@@ -20,8 +20,8 @@
#![cfg(feature = "runtime-benchmarks")]
use super::*;
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_system::RawOrigin;
use frame_benchmarking::{benchmarks, account, whitelisted_caller, impl_benchmark_test_suite};
use sp_runtime::traits::Bounded;
use crate::Pallet as Indices;
@@ -93,9 +93,4 @@ benchmarks! {
// TODO in another PR: lookup and unlookup trait weights (not critical)
}
impl_benchmark_test_suite!(
Indices,
crate::mock::new_test_ext(),
crate::mock::Test,
);
impl_benchmark_test_suite!(Indices, crate::mock::new_test_ext(), crate::mock::Test,);
+21 -21
View File
@@ -20,36 +20,43 @@
#![cfg_attr(not(feature = "std"), no_std)]
mod benchmarking;
mod mock;
mod tests;
mod benchmarking;
pub mod weights;
use sp_std::prelude::*;
use codec::Codec;
use sp_runtime::MultiAddress;
use sp_runtime::traits::{
StaticLookup, LookupError, Zero, Saturating, AtLeast32Bit
use frame_support::traits::{BalanceStatus::Reserved, Currency, ReservableCurrency};
use sp_runtime::{
traits::{AtLeast32Bit, LookupError, Saturating, StaticLookup, Zero},
MultiAddress,
};
use frame_support::traits::{Currency, ReservableCurrency, BalanceStatus::Reserved};
use sp_std::prelude::*;
pub use weights::WeightInfo;
type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
pub use pallet::*;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use super::*;
/// The module's config trait.
#[pallet::config]
pub trait Config: frame_system::Config {
/// Type used for storing an account's index; implies the maximum number of accounts the system
/// can hold.
type AccountIndex: Parameter + Member + MaybeSerializeDeserialize + Codec + Default + AtLeast32Bit + Copy;
type AccountIndex: Parameter
+ Member
+ MaybeSerializeDeserialize
+ Codec
+ Default
+ AtLeast32Bit
+ Copy;
/// The currency trait.
type Currency: ReservableCurrency<Self::AccountId>;
@@ -263,7 +270,7 @@ pub mod pallet {
}
/// Old name generated by `decl_event`.
#[deprecated(note="use `Event` instead")]
#[deprecated(note = "use `Event` instead")]
pub type RawEvent<T> = Event<T>;
#[pallet::error]
@@ -282,11 +289,8 @@ pub mod pallet {
/// The lookup from index to account.
#[pallet::storage]
pub type Accounts<T: Config> = StorageMap<
_, Blake2_128Concat,
T::AccountIndex,
(T::AccountId, BalanceOf<T>, bool)
>;
pub type Accounts<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountIndex, (T::AccountId, BalanceOf<T>, bool)>;
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
@@ -296,9 +300,7 @@ pub mod pallet {
#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
Self {
indices: Default::default(),
}
Self { indices: Default::default() }
}
}
@@ -321,9 +323,7 @@ impl<T: Config> Pallet<T> {
}
/// Lookup an address to get an Id, if there's one there.
pub fn lookup_address(
a: MultiAddress<T::AccountId, T::AccountIndex>
) -> Option<T::AccountId> {
pub fn lookup_address(a: MultiAddress<T::AccountId, T::AccountIndex>) -> Option<T::AccountId> {
match a {
MultiAddress::Id(i) => Some(i),
MultiAddress::Index(i) => Self::lookup_index(i),
+7 -5
View File
@@ -19,10 +19,10 @@
#![cfg(test)]
use sp_runtime::testing::Header;
use sp_core::H256;
use frame_support::parameter_types;
use crate::{self as pallet_indices, Config};
use frame_support::parameter_types;
use sp_core::H256;
use sp_runtime::testing::Header;
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>;
@@ -101,8 +101,10 @@ impl Config for Test {
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
pallet_balances::GenesisConfig::<Test>{
pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
}.assimilate_storage(&mut t).unwrap();
}
.assimilate_storage(&mut t)
.unwrap();
t.into()
}
+6 -4
View File
@@ -19,15 +19,17 @@
#![cfg(test)]
use super::*;
use super::mock::*;
use frame_support::{assert_ok, assert_noop};
use super::{mock::*, *};
use frame_support::{assert_noop, assert_ok};
use pallet_balances::Error as BalancesError;
#[test]
fn claiming_should_work() {
new_test_ext().execute_with(|| {
assert_noop!(Indices::claim(Some(0).into(), 0), BalancesError::<Test, _>::InsufficientBalance);
assert_noop!(
Indices::claim(Some(0).into(), 0),
BalancesError::<Test, _>::InsufficientBalance
);
assert_ok!(Indices::claim(Some(1).into(), 0));
assert_noop!(Indices::claim(Some(2).into(), 0), Error::<Test>::InUse);
assert_eq!(Balances::reserved_balance(1), 1);
+1
View File
@@ -36,6 +36,7 @@
// --template=./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]