mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +00:00
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:
@@ -17,7 +17,7 @@
|
||||
|
||||
mod pallet_old {
|
||||
use frame_support::{
|
||||
decl_storage, decl_error, decl_event, decl_module, weights::Weight, traits::Get, Parameter
|
||||
decl_error, decl_event, decl_module, decl_storage, traits::Get, weights::Weight, Parameter,
|
||||
};
|
||||
use frame_system::ensure_root;
|
||||
|
||||
@@ -39,7 +39,10 @@ mod pallet_old {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T, I = DefaultInstance> where Balance = <T as Config<I>>::Balance {
|
||||
pub enum Event<T, I = DefaultInstance>
|
||||
where
|
||||
Balance = <T as Config<I>>::Balance,
|
||||
{
|
||||
/// Dummy event, just here so there's a generic type that's used.
|
||||
Dummy(Balance),
|
||||
}
|
||||
@@ -83,12 +86,15 @@ mod pallet_old {
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use frame_support::pallet_prelude::*;
|
||||
use frame_system::pallet_prelude::*;
|
||||
use frame_system::ensure_root;
|
||||
use frame_system::{ensure_root, pallet_prelude::*};
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config<I: 'static = ()>: frame_system::Config {
|
||||
type Balance: Parameter + codec::HasCompact + From<u32> + Into<Weight> + Default
|
||||
type Balance: Parameter
|
||||
+ codec::HasCompact
|
||||
+ From<u32>
|
||||
+ Into<Weight>
|
||||
+ Default
|
||||
+ MaybeSerializeDeserialize;
|
||||
#[pallet::constant]
|
||||
type SomeConst: Get<Self::Balance>;
|
||||
@@ -115,7 +121,7 @@ pub mod pallet {
|
||||
#[pallet::weight(<T::Balance as Into<Weight>>::into(new_value.clone()))]
|
||||
pub fn set_dummy(
|
||||
origin: OriginFor<T>,
|
||||
#[pallet::compact] new_value: T::Balance
|
||||
#[pallet::compact] new_value: T::Balance,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -151,12 +157,14 @@ pub mod pallet {
|
||||
#[pallet::storage]
|
||||
type Foo<T: Config<I>, I: 'static = ()> =
|
||||
StorageValue<_, T::Balance, ValueQuery, OnFooEmpty<T, I>>;
|
||||
#[pallet::type_value] pub fn OnFooEmpty<T: Config<I>, I: 'static>() -> T::Balance { 3.into() }
|
||||
#[pallet::type_value]
|
||||
pub fn OnFooEmpty<T: Config<I>, I: 'static>() -> T::Balance {
|
||||
3.into()
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
type Double<T, I = ()> = StorageDoubleMap<
|
||||
_, Blake2_128Concat, u32, Twox64Concat, u64, u16, ValueQuery
|
||||
>;
|
||||
type Double<T, I = ()> =
|
||||
StorageDoubleMap<_, Blake2_128Concat, u32, Twox64Concat, u64, u16, ValueQuery>;
|
||||
|
||||
#[pallet::genesis_config]
|
||||
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
|
||||
@@ -272,9 +280,7 @@ frame_support::construct_runtime!(
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::Runtime;
|
||||
use super::pallet;
|
||||
use super::pallet_old;
|
||||
use super::{pallet, pallet_old, Runtime};
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
#[test]
|
||||
@@ -288,11 +294,11 @@ mod test {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
for i in vec![1, 3, 5].into_iter() {
|
||||
pretty_assertions::assert_eq!(modules[i].storage, modules[i+1].storage);
|
||||
pretty_assertions::assert_eq!(modules[i].calls, modules[i+1].calls);
|
||||
pretty_assertions::assert_eq!(modules[i].event, modules[i+1].event);
|
||||
pretty_assertions::assert_eq!(modules[i].constants, modules[i+1].constants);
|
||||
pretty_assertions::assert_eq!(modules[i].errors, modules[i+1].errors);
|
||||
pretty_assertions::assert_eq!(modules[i].storage, modules[i + 1].storage);
|
||||
pretty_assertions::assert_eq!(modules[i].calls, modules[i + 1].calls);
|
||||
pretty_assertions::assert_eq!(modules[i].event, modules[i + 1].event);
|
||||
pretty_assertions::assert_eq!(modules[i].constants, modules[i + 1].constants);
|
||||
pretty_assertions::assert_eq!(modules[i].errors, modules[i + 1].errors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,14 +307,16 @@ mod test {
|
||||
assert_eq!(
|
||||
pallet_old::Event::<Runtime>::decode(
|
||||
&mut &pallet::Event::<Runtime>::Dummy(10).encode()[..]
|
||||
).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
pallet_old::Event::<Runtime>::Dummy(10),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
pallet_old::Call::<Runtime>::decode(
|
||||
&mut &pallet::Call::<Runtime>::set_dummy(10).encode()[..]
|
||||
).unwrap(),
|
||||
)
|
||||
.unwrap(),
|
||||
pallet_old::Call::<Runtime>::set_dummy(10),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user