From 26cfa940950d4e04c4ba30cd12e99a1aea41fcba Mon Sep 17 00:00:00 2001 From: Ayevbeosa Iyamu Date: Wed, 3 Nov 2021 06:59:35 +0100 Subject: [PATCH 1/6] Changed named fields to struct variants --- Cargo.lock | 1 + frame/contracts/src/exec.rs | 8 +- frame/proxy/src/tests.rs | 4 +- frame/uniques/src/benchmarking.rs | 52 ++++++------ frame/uniques/src/functions.rs | 8 +- frame/uniques/src/impl_nonfungibles.rs | 2 +- frame/uniques/src/lib.rs | 90 ++++++++++----------- frame/utility/src/lib.rs | 4 +- frame/utility/src/tests.rs | 16 ++-- frame/vesting/src/lib.rs | 22 ++--- utils/frame/remote-externalities/Cargo.toml | 2 + 11 files changed, 107 insertions(+), 102 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6325304bfceec..12119827f6c1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7203,6 +7203,7 @@ name = "remote-externalities" version = "0.10.0-dev" dependencies = [ "env_logger 0.9.0", + "frame-support", "jsonrpsee-proc-macros", "jsonrpsee-ws-client", "log 0.4.14", diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 7fa0b0b274449..c225122cce712 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -2155,10 +2155,10 @@ mod tests { }, EventRecord { phase: Phase::Initialization, - event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted( - 1, - BadOrigin.into() - ),), + event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted { + index: 1, + error: BadOrigin.into() + },), topics: vec![], }, ] diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index d319ebb1a5ab0..2bf69af510c90 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -358,7 +358,7 @@ fn filtering_works() { System::assert_last_event(ProxyEvent::ProxyExecuted(Err(DispatchError::BadOrigin)).into()); assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone())); expect_events(vec![ - UtilityEvent::BatchInterrupted(0, DispatchError::BadOrigin).into(), + UtilityEvent::BatchInterrupted { index: 0, error: DispatchError::BadOrigin }.into(), ProxyEvent::ProxyExecuted(Ok(())).into(), ]); @@ -374,7 +374,7 @@ fn filtering_works() { System::assert_last_event(ProxyEvent::ProxyExecuted(Err(DispatchError::BadOrigin)).into()); assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone())); expect_events(vec![ - UtilityEvent::BatchInterrupted(0, DispatchError::BadOrigin).into(), + UtilityEvent::BatchInterrupted { index: 0, error: DispatchError::BadOrigin }.into(), ProxyEvent::ProxyExecuted(Ok(())).into(), ]); diff --git a/frame/uniques/src/benchmarking.rs b/frame/uniques/src/benchmarking.rs index 0e161bf7bfe85..513509bda70ea 100644 --- a/frame/uniques/src/benchmarking.rs +++ b/frame/uniques/src/benchmarking.rs @@ -141,7 +141,7 @@ benchmarks_instance_pallet! { T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup) verify { - assert_last_event::(Event::Created(Default::default(), caller.clone(), caller).into()); + assert_last_event::(Event::Created { class: Default::default(), creator: caller.clone(), owner: caller }.into()); } force_create { @@ -149,7 +149,7 @@ benchmarks_instance_pallet! { let caller_lookup = T::Lookup::unlookup(caller.clone()); }: _(SystemOrigin::Root, Default::default(), caller_lookup, true) verify { - assert_last_event::(Event::ForceCreated(Default::default(), caller).into()); + assert_last_event::(Event::ForceCreated { class: Default::default(), owner: caller }.into()); } destroy { @@ -171,7 +171,7 @@ benchmarks_instance_pallet! { let witness = Class::::get(class).unwrap().destroy_witness(); }: _(SystemOrigin::Signed(caller), class, witness) verify { - assert_last_event::(Event::Destroyed(class).into()); + assert_last_event::(Event::Destroyed { class: class }.into()); } mint { @@ -179,7 +179,7 @@ benchmarks_instance_pallet! { let instance = Default::default(); }: _(SystemOrigin::Signed(caller.clone()), class, instance, caller_lookup) verify { - assert_last_event::(Event::Issued(class, instance, caller).into()); + assert_last_event::(Event::Issued { class, instance, owner: caller }.into()); } burn { @@ -187,7 +187,7 @@ benchmarks_instance_pallet! { let (instance, ..) = mint_instance::(0); }: _(SystemOrigin::Signed(caller.clone()), class, instance, Some(caller_lookup)) verify { - assert_last_event::(Event::Burned(class, instance, caller).into()); + assert_last_event::(Event::Burned { class, instance, owner: caller }.into()); } transfer { @@ -198,7 +198,7 @@ benchmarks_instance_pallet! { let target_lookup = T::Lookup::unlookup(target.clone()); }: _(SystemOrigin::Signed(caller.clone()), class, instance, target_lookup) verify { - assert_last_event::(Event::Transferred(class, instance, caller, target).into()); + assert_last_event::(Event::Transferred { class, instance, from: caller, to: target }.into()); } redeposit { @@ -217,7 +217,7 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), class, instances.clone()) verify { - assert_last_event::(Event::Redeposited(class, instances).into()); + assert_last_event::(Event::Redeposited { class, successful_instances: instances }.into()); } freeze { @@ -225,7 +225,7 @@ benchmarks_instance_pallet! { let (instance, ..) = mint_instance::(Default::default()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), Default::default()) verify { - assert_last_event::(Event::Frozen(Default::default(), Default::default()).into()); + assert_last_event::(Event::Frozen { class: Default::default(), instance: Default::default() }.into()); } thaw { @@ -238,14 +238,14 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), class, instance) verify { - assert_last_event::(Event::Thawed(class, instance).into()); + assert_last_event::(Event::Thawed { class, instance }.into()); } freeze_class { let (class, caller, caller_lookup) = create_class::(); }: _(SystemOrigin::Signed(caller.clone()), class) verify { - assert_last_event::(Event::ClassFrozen(class).into()); + assert_last_event::(Event::ClassFrozen { class }.into()); } thaw_class { @@ -254,7 +254,7 @@ benchmarks_instance_pallet! { Uniques::::freeze_class(origin, class)?; }: _(SystemOrigin::Signed(caller.clone()), class) verify { - assert_last_event::(Event::ClassThawed(class).into()); + assert_last_event::(Event::ClassThawed { class }.into()); } transfer_ownership { @@ -264,7 +264,7 @@ benchmarks_instance_pallet! { T::Currency::make_free_balance_be(&target, T::Currency::minimum_balance()); }: _(SystemOrigin::Signed(caller), class, target_lookup) verify { - assert_last_event::(Event::OwnerChanged(class, target).into()); + assert_last_event::(Event::OwnerChanged { class, new_owner: target }.into()); } set_team { @@ -274,12 +274,12 @@ benchmarks_instance_pallet! { let target2 = T::Lookup::unlookup(account("target", 2, SEED)); }: _(SystemOrigin::Signed(caller), Default::default(), target0.clone(), target1.clone(), target2.clone()) verify { - assert_last_event::(Event::TeamChanged( + assert_last_event::(Event::TeamChanged{ class, - account("target", 0, SEED), - account("target", 1, SEED), - account("target", 2, SEED), - ).into()); + issuer: account("target", 0, SEED), + admin: account("target", 1, SEED), + freezer: account("target", 2, SEED), + }.into()); } force_asset_status { @@ -296,7 +296,7 @@ benchmarks_instance_pallet! { }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(Event::AssetStatusChanged(class).into()); + assert_last_event::(Event::AssetStatusChanged { class }.into()); } set_attribute { @@ -308,7 +308,7 @@ benchmarks_instance_pallet! { add_instance_metadata::(instance); }: _(SystemOrigin::Signed(caller), class, Some(instance), key.clone(), value.clone()) verify { - assert_last_event::(Event::AttributeSet(class, Some(instance), key, value).into()); + assert_last_event::(Event::AttributeSet { class, maybe_instance: Some(instance), key, value }.into()); } clear_attribute { @@ -318,7 +318,7 @@ benchmarks_instance_pallet! { let (key, ..) = add_instance_attribute::(instance); }: _(SystemOrigin::Signed(caller), class, Some(instance), key.clone()) verify { - assert_last_event::(Event::AttributeCleared(class, Some(instance), key).into()); + assert_last_event::(Event::AttributeCleared { class, maybe_instance: Some(instance), key }.into()); } set_metadata { @@ -328,7 +328,7 @@ benchmarks_instance_pallet! { let (instance, ..) = mint_instance::(0); }: _(SystemOrigin::Signed(caller), class, instance, data.clone(), false) verify { - assert_last_event::(Event::MetadataSet(class, instance, data, false).into()); + assert_last_event::(Event::MetadataSet { class, instance, data, is_frozen: false }.into()); } clear_metadata { @@ -337,7 +337,7 @@ benchmarks_instance_pallet! { add_instance_metadata::(instance); }: _(SystemOrigin::Signed(caller), class, instance) verify { - assert_last_event::(Event::MetadataCleared(class, instance).into()); + assert_last_event::(Event::MetadataCleared { class, instance }.into()); } set_class_metadata { @@ -346,7 +346,7 @@ benchmarks_instance_pallet! { let (class, caller, _) = create_class::(); }: _(SystemOrigin::Signed(caller), class, data.clone(), false) verify { - assert_last_event::(Event::ClassMetadataSet(class, data, false).into()); + assert_last_event::(Event::ClassMetadataSet { class, data, is_frozen: false }.into()); } clear_class_metadata { @@ -354,7 +354,7 @@ benchmarks_instance_pallet! { add_class_metadata::(); }: _(SystemOrigin::Signed(caller), class) verify { - assert_last_event::(Event::ClassMetadataCleared(class).into()); + assert_last_event::(Event::ClassMetadataCleared { class }.into()); } approve_transfer { @@ -364,7 +364,7 @@ benchmarks_instance_pallet! { let delegate_lookup = T::Lookup::unlookup(delegate.clone()); }: _(SystemOrigin::Signed(caller.clone()), class, instance, delegate_lookup) verify { - assert_last_event::(Event::ApprovedTransfer(class, instance, caller, delegate).into()); + assert_last_event::(Event::ApprovedTransfer { class, instance, owner: caller, delegate }.into()); } cancel_approval { @@ -376,7 +376,7 @@ benchmarks_instance_pallet! { Uniques::::approve_transfer(origin, class, instance, delegate_lookup.clone())?; }: _(SystemOrigin::Signed(caller.clone()), class, instance, Some(delegate_lookup)) verify { - assert_last_event::(Event::ApprovalCancelled(class, instance, caller, delegate).into()); + assert_last_event::(Event::ApprovalCancelled { class, instance, owner: caller, delegate }.into()); } impl_benchmark_test_suite!(Uniques, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/frame/uniques/src/functions.rs b/frame/uniques/src/functions.rs index 68acf7f1879fb..f2a87e661e6a0 100644 --- a/frame/uniques/src/functions.rs +++ b/frame/uniques/src/functions.rs @@ -44,7 +44,7 @@ impl, I: 'static> Pallet { details.owner = dest; Asset::::insert(&class, &instance, &details); - Self::deposit_event(Event::Transferred(class, instance, origin, details.owner)); + Self::deposit_event(Event::Transferred { class, instance, from: origin, to: details.owner }); Ok(()) } @@ -105,7 +105,7 @@ impl, I: 'static> Pallet { Attribute::::remove_prefix((&class,), None); T::Currency::unreserve(&class_details.owner, class_details.total_deposit); - Self::deposit_event(Event::Destroyed(class)); + Self::deposit_event(Event::Destroyed { class }); Ok(DestroyWitness { instances: class_details.instances, @@ -146,7 +146,7 @@ impl, I: 'static> Pallet { Ok(()) })?; - Self::deposit_event(Event::Issued(class, instance, owner)); + Self::deposit_event(Event::Issued { class, instance, owner }); Ok(()) } @@ -174,7 +174,7 @@ impl, I: 'static> Pallet { Asset::::remove(&class, &instance); Account::::remove((&owner, &class, &instance)); - Self::deposit_event(Event::Burned(class, instance, owner)); + Self::deposit_event(Event::Burned { class, instance, owner }); Ok(()) } } diff --git a/frame/uniques/src/impl_nonfungibles.rs b/frame/uniques/src/impl_nonfungibles.rs index e68d2d4deecda..822a2a35b5027 100644 --- a/frame/uniques/src/impl_nonfungibles.rs +++ b/frame/uniques/src/impl_nonfungibles.rs @@ -98,7 +98,7 @@ impl, I: 'static> Create<::AccountId> for Pallet admin.clone(), T::ClassDeposit::get(), false, - Event::Created(class.clone(), who.clone(), admin.clone()), + Event::Created { class: class.clone(), creator: who.clone(), owner: admin.clone() }, ) } } diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index 1bf220e4a7876..d4a75a304badf 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -192,62 +192,62 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { /// An asset class was created. \[ class, creator, owner \] - Created(T::ClassId, T::AccountId, T::AccountId), + Created { class: T::ClassId, creator: T::AccountId, owner: T::AccountId }, /// An asset class was force-created. \[ class, owner \] - ForceCreated(T::ClassId, T::AccountId), + ForceCreated { class: T::ClassId, owner: T::AccountId }, /// An asset `class` was destroyed. \[ class \] - Destroyed(T::ClassId), + Destroyed { class: T::ClassId }, /// An asset `instance` was issued. \[ class, instance, owner \] - Issued(T::ClassId, T::InstanceId, T::AccountId), + Issued { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId }, /// An asset `instance` was transferred. \[ class, instance, from, to \] - Transferred(T::ClassId, T::InstanceId, T::AccountId, T::AccountId), + Transferred { class: T::ClassId, instance: T::InstanceId, from: T::AccountId, to: T::AccountId }, /// An asset `instance` was destroyed. \[ class, instance, owner \] - Burned(T::ClassId, T::InstanceId, T::AccountId), + Burned { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId }, /// Some asset `instance` was frozen. \[ class, instance \] - Frozen(T::ClassId, T::InstanceId), + Frozen { class: T::ClassId, instance: T::InstanceId }, /// Some asset `instance` was thawed. \[ class, instance \] - Thawed(T::ClassId, T::InstanceId), + Thawed { class: T::ClassId, instance: T::InstanceId }, /// Some asset `class` was frozen. \[ class \] - ClassFrozen(T::ClassId), + ClassFrozen { class: T::ClassId }, /// Some asset `class` was thawed. \[ class \] - ClassThawed(T::ClassId), + ClassThawed { class: T::ClassId }, /// The owner changed \[ class, new_owner \] - OwnerChanged(T::ClassId, T::AccountId), + OwnerChanged { class: T::ClassId, new_owner: T::AccountId }, /// The management team changed \[ class, issuer, admin, freezer \] - TeamChanged(T::ClassId, T::AccountId, T::AccountId, T::AccountId), + TeamChanged { class: T::ClassId, issuer: T::AccountId, admin: T::AccountId, freezer: T::AccountId }, /// An `instance` of an asset `class` has been approved by the `owner` for transfer by a /// `delegate`. /// \[ class, instance, owner, delegate \] - ApprovedTransfer(T::ClassId, T::InstanceId, T::AccountId, T::AccountId), + ApprovedTransfer { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId, delegate: T::AccountId }, /// An approval for a `delegate` account to transfer the `instance` of an asset `class` was /// cancelled by its `owner`. /// \[ class, instance, owner, delegate \] - ApprovalCancelled(T::ClassId, T::InstanceId, T::AccountId, T::AccountId), + ApprovalCancelled { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId, delegate: T::AccountId }, /// An asset `class` has had its attributes changed by the `Force` origin. /// \[ class \] - AssetStatusChanged(T::ClassId), + AssetStatusChanged { class: T::ClassId }, /// New metadata has been set for an asset class. \[ class, data, is_frozen \] - ClassMetadataSet(T::ClassId, BoundedVec, bool), + ClassMetadataSet { class: T::ClassId, data: BoundedVec, is_frozen: bool }, /// Metadata has been cleared for an asset class. \[ class \] - ClassMetadataCleared(T::ClassId), + ClassMetadataCleared { class: T::ClassId }, /// New metadata has been set for an asset instance. /// \[ class, instance, data, is_frozen \] - MetadataSet(T::ClassId, T::InstanceId, BoundedVec, bool), + MetadataSet { class: T::ClassId, instance: T::InstanceId, data: BoundedVec, is_frozen: bool }, /// Metadata has been cleared for an asset instance. \[ class, instance \] - MetadataCleared(T::ClassId, T::InstanceId), + MetadataCleared { class: T::ClassId, instance: T::InstanceId }, /// Metadata has been cleared for an asset instance. \[ class, successful_instances \] - Redeposited(T::ClassId, Vec), + Redeposited { class: T::ClassId, successful_instances: Vec < T::InstanceId > }, /// New attribute metadata has been set for an asset class or instance. /// \[ class, maybe_instance, key, value \] - AttributeSet( - T::ClassId, - Option, - BoundedVec, - BoundedVec, - ), + AttributeSet { + class: T::ClassId, + maybe_instance: Option, + key: BoundedVec, + value: BoundedVec, + }, /// Attribute metadata has been cleared for an asset class or instance. /// \[ class, maybe_instance, key, maybe_value \] - AttributeCleared(T::ClassId, Option, BoundedVec), + AttributeCleared { class: T::ClassId, maybe_instance: Option, key: BoundedVec }, } #[pallet::error] @@ -317,7 +317,7 @@ pub mod pallet { admin.clone(), T::ClassDeposit::get(), false, - Event::Created(class, owner, admin), + Event::Created { class, creator: owner, owner: admin }, ) } @@ -353,7 +353,7 @@ pub mod pallet { owner.clone(), Zero::zero(), free_holding, - Event::ForceCreated(class, owner), + Event::ForceCreated { class, owner }, ) } @@ -549,7 +549,7 @@ pub mod pallet { } Class::::insert(&class, &class_details); - Self::deposit_event(Event::::Redeposited(class, successful)); + Self::deposit_event(Event::::Redeposited { class, successful_instances: successful }); Ok(()) } @@ -580,7 +580,7 @@ pub mod pallet { details.is_frozen = true; Asset::::insert(&class, &instance, &details); - Self::deposit_event(Event::::Frozen(class, instance)); + Self::deposit_event(Event::::Frozen { class, instance }); Ok(()) } @@ -610,7 +610,7 @@ pub mod pallet { details.is_frozen = false; Asset::::insert(&class, &instance, &details); - Self::deposit_event(Event::::Thawed(class, instance)); + Self::deposit_event(Event::::Thawed { class, instance }); Ok(()) } @@ -636,7 +636,7 @@ pub mod pallet { details.is_frozen = true; - Self::deposit_event(Event::::ClassFrozen(class)); + Self::deposit_event(Event::::ClassFrozen { class }); Ok(()) }) } @@ -663,7 +663,7 @@ pub mod pallet { details.is_frozen = false; - Self::deposit_event(Event::::ClassThawed(class)); + Self::deposit_event(Event::::ClassThawed { class }); Ok(()) }) } @@ -703,7 +703,7 @@ pub mod pallet { )?; details.owner = owner.clone(); - Self::deposit_event(Event::OwnerChanged(class, owner)); + Self::deposit_event(Event::OwnerChanged { class, new_owner: owner }); Ok(()) }) } @@ -741,7 +741,7 @@ pub mod pallet { details.admin = admin.clone(); details.freezer = freezer.clone(); - Self::deposit_event(Event::TeamChanged(class, issuer, admin, freezer)); + Self::deposit_event(Event::TeamChanged { class, issuer, admin, freezer }); Ok(()) }) } @@ -783,7 +783,7 @@ pub mod pallet { Asset::::insert(&class, &instance, &details); let delegate = details.approved.expect("set as Some above; qed"); - Self::deposit_event(Event::ApprovedTransfer(class, instance, details.owner, delegate)); + Self::deposit_event(Event::ApprovedTransfer { class, instance, owner: details.owner, delegate }); Ok(()) } @@ -829,7 +829,7 @@ pub mod pallet { } Asset::::insert(&class, &instance, &details); - Self::deposit_event(Event::ApprovalCancelled(class, instance, details.owner, old)); + Self::deposit_event(Event::ApprovalCancelled { class, instance, owner: details.owner, delegate: old }); Ok(()) } @@ -874,7 +874,7 @@ pub mod pallet { asset.is_frozen = is_frozen; *maybe_asset = Some(asset); - Self::deposit_event(Event::AssetStatusChanged(class)); + Self::deposit_event(Event::AssetStatusChanged { class }); Ok(()) }) } @@ -940,7 +940,7 @@ pub mod pallet { Attribute::::insert((&class, maybe_instance, &key), (&value, deposit)); Class::::insert(class, &class_details); - Self::deposit_event(Event::AttributeSet(class, maybe_instance, key, value)); + Self::deposit_event(Event::AttributeSet { class, maybe_instance, key, value }); Ok(()) } @@ -988,7 +988,7 @@ pub mod pallet { class_details.total_deposit.saturating_reduce(deposit); T::Currency::unreserve(&class_details.owner, deposit); Class::::insert(class, &class_details); - Self::deposit_event(Event::AttributeCleared(class, maybe_instance, key)); + Self::deposit_event(Event::AttributeCleared { class, maybe_instance, key }); } Ok(()) } @@ -1053,7 +1053,7 @@ pub mod pallet { *metadata = Some(InstanceMetadata { deposit, data: data.clone(), is_frozen }); Class::::insert(&class, &class_details); - Self::deposit_event(Event::MetadataSet(class, instance, data, is_frozen)); + Self::deposit_event(Event::MetadataSet { class, instance, data, is_frozen }); Ok(()) }) } @@ -1098,7 +1098,7 @@ pub mod pallet { class_details.total_deposit.saturating_reduce(deposit); Class::::insert(&class, &class_details); - Self::deposit_event(Event::MetadataCleared(class, instance)); + Self::deposit_event(Event::MetadataCleared { class, instance }); Ok(()) }) } @@ -1158,7 +1158,7 @@ pub mod pallet { *metadata = Some(ClassMetadata { deposit, data: data.clone(), is_frozen }); - Self::deposit_event(Event::ClassMetadataSet(class, data, is_frozen)); + Self::deposit_event(Event::ClassMetadataSet { class, data, is_frozen }); Ok(()) }) } @@ -1195,7 +1195,7 @@ pub mod pallet { let deposit = metadata.take().ok_or(Error::::Unknown)?.deposit; T::Currency::unreserve(&details.owner, deposit); - Self::deposit_event(Event::ClassMetadataCleared(class)); + Self::deposit_event(Event::ClassMetadataCleared { class }); Ok(()) }) } diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 54de87c4740c8..fb9e17e76a5fd 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -105,7 +105,7 @@ pub mod pallet { pub enum Event { /// Batch of dispatches did not complete fully. Index of first failing dispatch given, as /// well as the error. \[index, error\] - BatchInterrupted(u32, DispatchError), + BatchInterrupted { index: u32, error: DispatchError }, /// Batch of dispatches completed fully with no error. BatchCompleted, /// A single item within a Batch of dispatches has completed with no error. @@ -191,7 +191,7 @@ pub mod pallet { // Add the weight of this call. weight = weight.saturating_add(extract_actual_weight(&result, &info)); if let Err(e) = result { - Self::deposit_event(Event::BatchInterrupted(index as u32, e.error)); + Self::deposit_event(Event::BatchInterrupted { index: index as u32, error: e.error }); // 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. diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index bbfbb417e23d1..3bd4b6841e95b 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -151,6 +151,7 @@ parameter_types! { impl example::Config for Test {} pub struct TestBaseCallFilter; + impl Contains for TestBaseCallFilter { fn contains(c: &Call) -> bool { match *c { @@ -165,6 +166,7 @@ impl Contains for TestBaseCallFilter { } } } + impl Config for Test { type Event = Event; type Call = Call; @@ -182,8 +184,8 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], } - .assimilate_storage(&mut t) - .unwrap(); + .assimilate_storage(&mut t) + .unwrap(); let mut ext = sp_io::TestExternalities::new(t); ext.execute_with(|| System::set_block_number(1)); ext @@ -338,7 +340,7 @@ fn batch_with_signed_filters() { vec![Call::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })] ),); System::assert_last_event( - utility::Event::BatchInterrupted(0, DispatchError::BadOrigin).into(), + utility::Event::BatchInterrupted { index: 0, error: DispatchError::BadOrigin }.into(), ); }); } @@ -409,7 +411,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted(1, DispatchError::Other("")).into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); // No weight is refunded assert_eq!(extract_actual_weight(&result, &info), info.weight); @@ -424,7 +426,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted(1, DispatchError::Other("")).into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); assert_eq!(extract_actual_weight(&result, &info), info.weight - diff * batch_len); @@ -437,7 +439,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted(1, DispatchError::Other("")).into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); assert_eq!( extract_actual_weight(&result, &info), @@ -585,7 +587,7 @@ fn batch_all_does_not_nest() { // and balances. assert_ok!(Utility::batch_all(Origin::signed(1), vec![batch_nested])); System::assert_has_event( - utility::Event::BatchInterrupted(0, DispatchError::BadOrigin).into(), + utility::Event::BatchInterrupted { index: 0, error: DispatchError::BadOrigin }.into(), ); assert_eq!(Balances::free_balance(1), 10); assert_eq!(Balances::free_balance(2), 10); diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 27862a5ca4b72..e7983ea6b61aa 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -104,9 +104,9 @@ enum VestingAction { /// Do not actively remove any schedules. Passive, /// Remove the schedule specified by the index. - Remove(usize), + Remove { index: usize }, /// Remove the two schedules, specified by index, so they can be merged. - Merge(usize, usize), + Merge { index1: usize, index2: usize }, } impl VestingAction { @@ -114,8 +114,8 @@ impl VestingAction { fn should_remove(&self, index: usize) -> bool { match self { Self::Passive => false, - Self::Remove(index1) => *index1 == index, - Self::Merge(index1, index2) => *index1 == index || *index2 == index, + Self::Remove { index: index1} => *index1 == index, + Self::Merge { index1, index2 } => *index1 == index || *index2 == index, } } @@ -276,9 +276,9 @@ pub mod pallet { /// The amount vested has been updated. This could indicate a change in funds available. /// The balance given is the amount which is left unvested (and thus locked). /// \[account, unvested\] - VestingUpdated(T::AccountId, BalanceOf), + VestingUpdated { account: T::AccountId, unvested: BalanceOf < T > }, /// An \[account\] has become fully vested. - VestingCompleted(T::AccountId), + VestingCompleted { account: T::AccountId }, } /// Error for the vesting pallet. @@ -446,7 +446,7 @@ pub mod pallet { let schedule2_index = schedule2_index as usize; let schedules = Self::vesting(&who).ok_or(Error::::NotVesting)?; - let merge_action = VestingAction::Merge(schedule1_index, schedule2_index); + let merge_action = VestingAction::Merge { index1: schedule1_index, index2: schedule2_index }; let (schedules, locked_now) = Self::exec_action(schedules.to_vec(), merge_action)?; @@ -586,11 +586,11 @@ impl Pallet { fn write_lock(who: &T::AccountId, total_locked_now: BalanceOf) { if total_locked_now.is_zero() { T::Currency::remove_lock(VESTING_ID, who); - Self::deposit_event(Event::::VestingCompleted(who.clone())); + Self::deposit_event(Event::::VestingCompleted { account: who.clone() }); } else { let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE; T::Currency::set_lock(VESTING_ID, who, total_locked_now, reasons); - Self::deposit_event(Event::::VestingUpdated(who.clone(), total_locked_now)); + Self::deposit_event(Event::::VestingUpdated { account: who.clone(), unvested: total_locked_now }); }; } @@ -633,7 +633,7 @@ impl Pallet { action: VestingAction, ) -> Result<(Vec, T::BlockNumber>>, BalanceOf), DispatchError> { let (schedules, locked_now) = match action { - VestingAction::Merge(idx1, idx2) => { + VestingAction::Merge { index1: idx1, index2: idx2 } => { // The schedule index is based off of the schedule ordering prior to filtering out // any schedules that may be ending at this block. let schedule1 = *schedules.get(idx1).ok_or(Error::::ScheduleIndexOutOfBounds)?; @@ -758,7 +758,7 @@ where /// Remove a vesting schedule for a given account. fn remove_vesting_schedule(who: &T::AccountId, schedule_index: u32) -> DispatchResult { let schedules = Self::vesting(who).ok_or(Error::::NotVesting)?; - let remove_action = VestingAction::Remove(schedule_index as usize); + let remove_action = VestingAction::Remove { index: schedule_index as usize }; let (schedules, locked_now) = Self::exec_action(schedules.to_vec(), remove_action)?; diff --git a/utils/frame/remote-externalities/Cargo.toml b/utils/frame/remote-externalities/Cargo.toml index 2b35402f8f63f..5a51b3a5432bc 100644 --- a/utils/frame/remote-externalities/Cargo.toml +++ b/utils/frame/remote-externalities/Cargo.toml @@ -29,6 +29,8 @@ sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" } sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" } sp-version = { version = "4.0.0-dev", path = "../../../primitives/version" } +frame-support = { version = "4.0.0-dev", path = "../../../frame/support" } + [dev-dependencies] tokio = { version = "1.10", features = ["macros", "rt-multi-thread"] } pallet-elections-phragmen = { path = "../../../frame/elections-phragmen", version = "5.0.0-dev" } From e92d3a0481d8d871914b722b74ec9e3b3cc1d0ca Mon Sep 17 00:00:00 2001 From: Ayevbeosa Iyamu Date: Thu, 4 Nov 2021 20:29:18 +0100 Subject: [PATCH 2/6] Fixed errors. --- frame/contracts/src/exec.rs | 8 ++++---- frame/proxy/src/tests.rs | 4 ++-- frame/utility/src/tests.rs | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 7ef1aec2dfc60..c6b7bd889a7d2 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -2157,10 +2157,10 @@ mod tests { }, EventRecord { phase: Phase::Initialization, - event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted( - 1, - frame_system::Error::::CallFiltered.into() - ),), + event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted { + index: 1, + error: frame_system::Error:: < Test>::CallFiltered.into() + },), topics: vec![], }, ] diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 20efd085fe882..ec6943e4696a3 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -368,7 +368,7 @@ fn filtering_works() { ); assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone())); expect_events(vec![ - UtilityEvent::BatchInterrupted(0, SystemError::CallFiltered.into()).into(), + UtilityEvent::BatchInterrupted { index: 0, error: SystemError::CallFiltered.into() }.into(), ProxyEvent::ProxyExecuted(Ok(())).into(), ]); @@ -386,7 +386,7 @@ fn filtering_works() { ); assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone())); expect_events(vec![ - UtilityEvent::BatchInterrupted(0, SystemError::CallFiltered.into()).into(), + UtilityEvent::BatchInterrupted { index: 0, error: SystemError::CallFiltered.into() }.into(), ProxyEvent::ProxyExecuted(Ok(())).into(), ]); diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index cb7a3d9a21e29..eb3f0b1bd6c8b 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -338,7 +338,7 @@ fn batch_with_signed_filters() { vec![Call::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })] ),); System::assert_last_event( - utility::Event::BatchInterrupted(0, frame_system::Error::::CallFiltered.into()) + utility::Event::BatchInterrupted { index: 0, error: frame_system::Error:: < Test>::CallFiltered.into() } .into(), ); }); @@ -410,7 +410,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted(1, DispatchError::Other("")).into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); // No weight is refunded assert_eq!(extract_actual_weight(&result, &info), info.weight); @@ -425,7 +425,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted(1, DispatchError::Other("")).into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); assert_eq!(extract_actual_weight(&result, &info), info.weight - diff * batch_len); @@ -438,7 +438,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted(1, DispatchError::Other("")).into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); assert_eq!( extract_actual_weight(&result, &info), @@ -586,7 +586,7 @@ fn batch_all_does_not_nest() { // and balances. assert_ok!(Utility::batch_all(Origin::signed(1), vec![batch_nested])); System::assert_has_event( - utility::Event::BatchInterrupted(0, frame_system::Error::::CallFiltered.into()) + utility::Event::BatchInterrupted { index: 0, error: frame_system::Error:: < Test>::CallFiltered.into() } .into(), ); assert_eq!(Balances::free_balance(1), 10); From 23139955400b1c4e67e00c201674fd79d281f9e9 Mon Sep 17 00:00:00 2001 From: Ayevbeosa Iyamu Date: Fri, 5 Nov 2021 09:59:56 +0100 Subject: [PATCH 3/6] Made adjustments as per `cargo +nightly fmt`. --- frame/contracts/src/exec.rs | 2 +- frame/proxy/src/tests.rs | 6 ++- frame/uniques/src/functions.rs | 7 +++- frame/uniques/src/lib.rs | 68 ++++++++++++++++++++++++++++------ frame/utility/src/lib.rs | 5 ++- frame/utility/src/tests.rs | 14 +++++-- frame/vesting/src/lib.rs | 12 ++++-- 7 files changed, 90 insertions(+), 24 deletions(-) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index c6b7bd889a7d2..90a640418bcc0 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -2159,7 +2159,7 @@ mod tests { phase: Phase::Initialization, event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted { index: 1, - error: frame_system::Error:: < Test>::CallFiltered.into() + error: frame_system::Error::::CallFiltered.into() },), topics: vec![], }, diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index ec6943e4696a3..ce8f54fdd3e89 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -368,7 +368,8 @@ fn filtering_works() { ); assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone())); expect_events(vec![ - UtilityEvent::BatchInterrupted { index: 0, error: SystemError::CallFiltered.into() }.into(), + UtilityEvent::BatchInterrupted { index: 0, error: SystemError::CallFiltered.into() } + .into(), ProxyEvent::ProxyExecuted(Ok(())).into(), ]); @@ -386,7 +387,8 @@ fn filtering_works() { ); assert_ok!(Proxy::proxy(Origin::signed(4), 1, None, call.clone())); expect_events(vec![ - UtilityEvent::BatchInterrupted { index: 0, error: SystemError::CallFiltered.into() }.into(), + UtilityEvent::BatchInterrupted { index: 0, error: SystemError::CallFiltered.into() } + .into(), ProxyEvent::ProxyExecuted(Ok(())).into(), ]); diff --git a/frame/uniques/src/functions.rs b/frame/uniques/src/functions.rs index f2a87e661e6a0..43d634ad569e7 100644 --- a/frame/uniques/src/functions.rs +++ b/frame/uniques/src/functions.rs @@ -44,7 +44,12 @@ impl, I: 'static> Pallet { details.owner = dest; Asset::::insert(&class, &instance, &details); - Self::deposit_event(Event::Transferred { class, instance, from: origin, to: details.owner }); + Self::deposit_event(Event::Transferred { + class, + instance, + from: origin, + to: details.owner, + }); Ok(()) } diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index d4a75a304badf..df35b2a579074 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -200,7 +200,12 @@ pub mod pallet { /// An asset `instance` was issued. \[ class, instance, owner \] Issued { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId }, /// An asset `instance` was transferred. \[ class, instance, from, to \] - Transferred { class: T::ClassId, instance: T::InstanceId, from: T::AccountId, to: T::AccountId }, + Transferred { + class: T::ClassId, + instance: T::InstanceId, + from: T::AccountId, + to: T::AccountId, + }, /// An asset `instance` was destroyed. \[ class, instance, owner \] Burned { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId }, /// Some asset `instance` was frozen. \[ class, instance \] @@ -214,29 +219,53 @@ pub mod pallet { /// The owner changed \[ class, new_owner \] OwnerChanged { class: T::ClassId, new_owner: T::AccountId }, /// The management team changed \[ class, issuer, admin, freezer \] - TeamChanged { class: T::ClassId, issuer: T::AccountId, admin: T::AccountId, freezer: T::AccountId }, + TeamChanged { + class: T::ClassId, + issuer: T::AccountId, + admin: T::AccountId, + freezer: T::AccountId, + }, /// An `instance` of an asset `class` has been approved by the `owner` for transfer by a /// `delegate`. /// \[ class, instance, owner, delegate \] - ApprovedTransfer { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId, delegate: T::AccountId }, + ApprovedTransfer { + class: T::ClassId, + instance: T::InstanceId, + owner: T::AccountId, + delegate: T::AccountId, + }, /// An approval for a `delegate` account to transfer the `instance` of an asset `class` was /// cancelled by its `owner`. /// \[ class, instance, owner, delegate \] - ApprovalCancelled { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId, delegate: T::AccountId }, + ApprovalCancelled { + class: T::ClassId, + instance: T::InstanceId, + owner: T::AccountId, + delegate: T::AccountId, + }, /// An asset `class` has had its attributes changed by the `Force` origin. /// \[ class \] AssetStatusChanged { class: T::ClassId }, /// New metadata has been set for an asset class. \[ class, data, is_frozen \] - ClassMetadataSet { class: T::ClassId, data: BoundedVec, is_frozen: bool }, + ClassMetadataSet { + class: T::ClassId, + data: BoundedVec, + is_frozen: bool, + }, /// Metadata has been cleared for an asset class. \[ class \] ClassMetadataCleared { class: T::ClassId }, /// New metadata has been set for an asset instance. /// \[ class, instance, data, is_frozen \] - MetadataSet { class: T::ClassId, instance: T::InstanceId, data: BoundedVec, is_frozen: bool }, + MetadataSet { + class: T::ClassId, + instance: T::InstanceId, + data: BoundedVec, + is_frozen: bool, + }, /// Metadata has been cleared for an asset instance. \[ class, instance \] MetadataCleared { class: T::ClassId, instance: T::InstanceId }, /// Metadata has been cleared for an asset instance. \[ class, successful_instances \] - Redeposited { class: T::ClassId, successful_instances: Vec < T::InstanceId > }, + Redeposited { class: T::ClassId, successful_instances: Vec }, /// New attribute metadata has been set for an asset class or instance. /// \[ class, maybe_instance, key, value \] AttributeSet { @@ -247,7 +276,11 @@ pub mod pallet { }, /// Attribute metadata has been cleared for an asset class or instance. /// \[ class, maybe_instance, key, maybe_value \] - AttributeCleared { class: T::ClassId, maybe_instance: Option, key: BoundedVec }, + AttributeCleared { + class: T::ClassId, + maybe_instance: Option, + key: BoundedVec, + }, } #[pallet::error] @@ -549,7 +582,10 @@ pub mod pallet { } Class::::insert(&class, &class_details); - Self::deposit_event(Event::::Redeposited { class, successful_instances: successful }); + Self::deposit_event(Event::::Redeposited { + class, + successful_instances: successful, + }); Ok(()) } @@ -783,7 +819,12 @@ pub mod pallet { Asset::::insert(&class, &instance, &details); let delegate = details.approved.expect("set as Some above; qed"); - Self::deposit_event(Event::ApprovedTransfer { class, instance, owner: details.owner, delegate }); + Self::deposit_event(Event::ApprovedTransfer { + class, + instance, + owner: details.owner, + delegate, + }); Ok(()) } @@ -829,7 +870,12 @@ pub mod pallet { } Asset::::insert(&class, &instance, &details); - Self::deposit_event(Event::ApprovalCancelled { class, instance, owner: details.owner, delegate: old }); + Self::deposit_event(Event::ApprovalCancelled { + class, + instance, + owner: details.owner, + delegate: old, + }); Ok(()) } diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 9a0203f0c2b0f..7c96174f348bf 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -210,7 +210,10 @@ pub mod pallet { // Add the weight of this call. weight = weight.saturating_add(extract_actual_weight(&result, &info)); if let Err(e) = result { - Self::deposit_event(Event::BatchInterrupted { index: index as u32, error: e.error }); + Self::deposit_event(Event::BatchInterrupted { + index: index as u32, + error: e.error, + }); // 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. diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index eb3f0b1bd6c8b..76e8d9eebfb9c 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -338,8 +338,11 @@ fn batch_with_signed_filters() { vec![Call::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })] ),); System::assert_last_event( - utility::Event::BatchInterrupted { index: 0, error: frame_system::Error:: < Test>::CallFiltered.into() } - .into(), + utility::Event::BatchInterrupted { + index: 0, + error: frame_system::Error::::CallFiltered.into(), + } + .into(), ); }); } @@ -586,8 +589,11 @@ fn batch_all_does_not_nest() { // and balances. assert_ok!(Utility::batch_all(Origin::signed(1), vec![batch_nested])); System::assert_has_event( - utility::Event::BatchInterrupted { index: 0, error: frame_system::Error:: < Test>::CallFiltered.into() } - .into(), + utility::Event::BatchInterrupted { + index: 0, + error: frame_system::Error::::CallFiltered.into(), + } + .into(), ); assert_eq!(Balances::free_balance(1), 10); assert_eq!(Balances::free_balance(2), 10); diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index ed6a7cacfdf85..a3fe35c9e8513 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -114,7 +114,7 @@ impl VestingAction { fn should_remove(&self, index: usize) -> bool { match self { Self::Passive => false, - Self::Remove { index: index1} => *index1 == index, + Self::Remove { index: index1 } => *index1 == index, Self::Merge { index1, index2 } => *index1 == index || *index2 == index, } } @@ -280,7 +280,7 @@ pub mod pallet { /// The amount vested has been updated. This could indicate a change in funds available. /// The balance given is the amount which is left unvested (and thus locked). /// \[account, unvested\] - VestingUpdated { account: T::AccountId, unvested: BalanceOf < T > }, + VestingUpdated { account: T::AccountId, unvested: BalanceOf }, /// An \[account\] has become fully vested. VestingCompleted { account: T::AccountId }, } @@ -450,7 +450,8 @@ pub mod pallet { let schedule2_index = schedule2_index as usize; let schedules = Self::vesting(&who).ok_or(Error::::NotVesting)?; - let merge_action = VestingAction::Merge { index1: schedule1_index, index2: schedule2_index }; + let merge_action = + VestingAction::Merge { index1: schedule1_index, index2: schedule2_index }; let (schedules, locked_now) = Self::exec_action(schedules.to_vec(), merge_action)?; @@ -594,7 +595,10 @@ impl Pallet { } else { let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE; T::Currency::set_lock(VESTING_ID, who, total_locked_now, reasons); - Self::deposit_event(Event::::VestingUpdated { account: who.clone(), unvested: total_locked_now }); + Self::deposit_event(Event::::VestingUpdated { + account: who.clone(), + unvested: total_locked_now, + }); }; } From d04680da666ba059e179a627df11399a78513d94 Mon Sep 17 00:00:00 2001 From: Ayevbeosa Iyamu Date: Fri, 5 Nov 2021 10:23:37 +0100 Subject: [PATCH 4/6] Update frame/uniques/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Alexander Theißen --- frame/uniques/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index df35b2a579074..0f92930ef3d98 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -191,7 +191,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event, I: 'static = ()> { - /// An asset class was created. \[ class, creator, owner \] + /// An asset class was created. Created { class: T::ClassId, creator: T::AccountId, owner: T::AccountId }, /// An asset class was force-created. \[ class, owner \] ForceCreated { class: T::ClassId, owner: T::AccountId }, From 49d25edc4073d29758273ce9a4a5881cfaeacc4f Mon Sep 17 00:00:00 2001 From: Ayevbeosa Iyamu Date: Fri, 5 Nov 2021 10:41:29 +0100 Subject: [PATCH 5/6] Removed redundant comments for structs. --- frame/uniques/src/lib.rs | 36 +++++++++++++++--------------------- frame/utility/src/lib.rs | 2 +- frame/vesting/src/lib.rs | 1 - 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index 0f92930ef3d98..7e380459252e7 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -193,32 +193,32 @@ pub mod pallet { pub enum Event, I: 'static = ()> { /// An asset class was created. Created { class: T::ClassId, creator: T::AccountId, owner: T::AccountId }, - /// An asset class was force-created. \[ class, owner \] + /// An asset class was force-created. ForceCreated { class: T::ClassId, owner: T::AccountId }, - /// An asset `class` was destroyed. \[ class \] + /// An asset `class` was destroyed. Destroyed { class: T::ClassId }, - /// An asset `instance` was issued. \[ class, instance, owner \] + /// An asset `instance` was issued. Issued { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId }, - /// An asset `instance` was transferred. \[ class, instance, from, to \] + /// An asset `instance` was transferred. Transferred { class: T::ClassId, instance: T::InstanceId, from: T::AccountId, to: T::AccountId, }, - /// An asset `instance` was destroyed. \[ class, instance, owner \] + /// An asset `instance` was destroyed. Burned { class: T::ClassId, instance: T::InstanceId, owner: T::AccountId }, - /// Some asset `instance` was frozen. \[ class, instance \] + /// Some asset `instance` was frozen. Frozen { class: T::ClassId, instance: T::InstanceId }, - /// Some asset `instance` was thawed. \[ class, instance \] + /// Some asset `instance` was thawed. Thawed { class: T::ClassId, instance: T::InstanceId }, - /// Some asset `class` was frozen. \[ class \] + /// Some asset `class` was frozen. ClassFrozen { class: T::ClassId }, - /// Some asset `class` was thawed. \[ class \] + /// Some asset `class` was thawed. ClassThawed { class: T::ClassId }, - /// The owner changed \[ class, new_owner \] + /// The owner changed. OwnerChanged { class: T::ClassId, new_owner: T::AccountId }, - /// The management team changed \[ class, issuer, admin, freezer \] + /// The management team changed. TeamChanged { class: T::ClassId, issuer: T::AccountId, @@ -227,7 +227,6 @@ pub mod pallet { }, /// An `instance` of an asset `class` has been approved by the `owner` for transfer by a /// `delegate`. - /// \[ class, instance, owner, delegate \] ApprovedTransfer { class: T::ClassId, instance: T::InstanceId, @@ -236,7 +235,6 @@ pub mod pallet { }, /// An approval for a `delegate` account to transfer the `instance` of an asset `class` was /// cancelled by its `owner`. - /// \[ class, instance, owner, delegate \] ApprovalCancelled { class: T::ClassId, instance: T::InstanceId, @@ -244,30 +242,27 @@ pub mod pallet { delegate: T::AccountId, }, /// An asset `class` has had its attributes changed by the `Force` origin. - /// \[ class \] AssetStatusChanged { class: T::ClassId }, - /// New metadata has been set for an asset class. \[ class, data, is_frozen \] + /// New metadata has been set for an asset class. ClassMetadataSet { class: T::ClassId, data: BoundedVec, is_frozen: bool, }, - /// Metadata has been cleared for an asset class. \[ class \] + /// Metadata has been cleared for an asset class. ClassMetadataCleared { class: T::ClassId }, /// New metadata has been set for an asset instance. - /// \[ class, instance, data, is_frozen \] MetadataSet { class: T::ClassId, instance: T::InstanceId, data: BoundedVec, is_frozen: bool, }, - /// Metadata has been cleared for an asset instance. \[ class, instance \] + /// Metadata has been cleared for an asset instance. MetadataCleared { class: T::ClassId, instance: T::InstanceId }, - /// Metadata has been cleared for an asset instance. \[ class, successful_instances \] + /// Metadata has been cleared for an asset instance. Redeposited { class: T::ClassId, successful_instances: Vec }, /// New attribute metadata has been set for an asset class or instance. - /// \[ class, maybe_instance, key, value \] AttributeSet { class: T::ClassId, maybe_instance: Option, @@ -275,7 +270,6 @@ pub mod pallet { value: BoundedVec, }, /// Attribute metadata has been cleared for an asset class or instance. - /// \[ class, maybe_instance, key, maybe_value \] AttributeCleared { class: T::ClassId, maybe_instance: Option, diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 4bd6e334a1c76..14d8a66514e36 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -109,7 +109,7 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// Batch of dispatches did not complete fully. Index of first failing dispatch given, as - /// well as the error. \[index, error\] + /// well as the error. BatchInterrupted { index: u32, error: DispatchError }, /// Batch of dispatches completed fully with no error. BatchCompleted, diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index a3fe35c9e8513..6857918bc9a1c 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -279,7 +279,6 @@ pub mod pallet { pub enum Event { /// The amount vested has been updated. This could indicate a change in funds available. /// The balance given is the amount which is left unvested (and thus locked). - /// \[account, unvested\] VestingUpdated { account: T::AccountId, unvested: BalanceOf }, /// An \[account\] has become fully vested. VestingCompleted { account: T::AccountId }, From 48c4b5fc20bead8ba7f588f8bbdff3cf8aa96797 Mon Sep 17 00:00:00 2001 From: Ayevbeosa Iyamu Date: Fri, 5 Nov 2021 11:48:31 +0100 Subject: [PATCH 6/6] Moved frame-support to dev dependencies --- utils/frame/remote-externalities/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/frame/remote-externalities/Cargo.toml b/utils/frame/remote-externalities/Cargo.toml index f4dad538353b5..9c9025d934aab 100644 --- a/utils/frame/remote-externalities/Cargo.toml +++ b/utils/frame/remote-externalities/Cargo.toml @@ -29,11 +29,10 @@ sp-core = { version = "4.0.0-dev", path = "../../../primitives/core" } sp-runtime = { version = "4.0.0-dev", path = "../../../primitives/runtime" } sp-version = { version = "4.0.0-dev", path = "../../../primitives/version" } -frame-support = { version = "4.0.0-dev", path = "../../../frame/support" } - [dev-dependencies] tokio = { version = "1.10", features = ["macros", "rt-multi-thread"] } pallet-elections-phragmen = { path = "../../../frame/elections-phragmen", version = "5.0.0-dev" } +frame-support = { path = "../../../frame/support", version = "4.0.0-dev" } [features] remote-test = []