Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add field names to pallet Event variants #10184

1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2157,10 +2157,10 @@ mod tests {
},
EventRecord {
phase: Phase::Initialization,
event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted(
1,
frame_system::Error::<Test>::CallFiltered.into()
),),
event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted {
index: 1,
error: frame_system::Error::<Test>::CallFiltered.into()
},),
topics: vec![],
},
]
Expand Down
6 changes: 4 additions & 2 deletions frame/proxy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ 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(),
]);

Expand All @@ -387,7 +388,8 @@ 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(),
]);

Expand Down
52 changes: 26 additions & 26 deletions frame/uniques/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ benchmarks_instance_pallet! {
T::Currency::make_free_balance_be(&caller, DepositBalanceOf::<T, I>::max_value());
}: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup)
verify {
assert_last_event::<T, I>(Event::Created(Default::default(), caller.clone(), caller).into());
assert_last_event::<T, I>(Event::Created { class: Default::default(), creator: caller.clone(), owner: caller }.into());
}

force_create {
let caller: T::AccountId = whitelisted_caller();
let caller_lookup = T::Lookup::unlookup(caller.clone());
}: _(SystemOrigin::Root, Default::default(), caller_lookup, true)
verify {
assert_last_event::<T, I>(Event::ForceCreated(Default::default(), caller).into());
assert_last_event::<T, I>(Event::ForceCreated { class: Default::default(), owner: caller }.into());
}

destroy {
Expand All @@ -171,23 +171,23 @@ benchmarks_instance_pallet! {
let witness = Class::<T, I>::get(class).unwrap().destroy_witness();
}: _(SystemOrigin::Signed(caller), class, witness)
verify {
assert_last_event::<T, I>(Event::Destroyed(class).into());
assert_last_event::<T, I>(Event::Destroyed { class: class }.into());
}

mint {
let (class, caller, caller_lookup) = create_class::<T, I>();
let instance = Default::default();
}: _(SystemOrigin::Signed(caller.clone()), class, instance, caller_lookup)
verify {
assert_last_event::<T, I>(Event::Issued(class, instance, caller).into());
assert_last_event::<T, I>(Event::Issued { class, instance, owner: caller }.into());
}

burn {
let (class, caller, caller_lookup) = create_class::<T, I>();
let (instance, ..) = mint_instance::<T, I>(0);
}: _(SystemOrigin::Signed(caller.clone()), class, instance, Some(caller_lookup))
verify {
assert_last_event::<T, I>(Event::Burned(class, instance, caller).into());
assert_last_event::<T, I>(Event::Burned { class, instance, owner: caller }.into());
}

transfer {
Expand All @@ -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::<T, I>(Event::Transferred(class, instance, caller, target).into());
assert_last_event::<T, I>(Event::Transferred { class, instance, from: caller, to: target }.into());
}

redeposit {
Expand All @@ -217,15 +217,15 @@ benchmarks_instance_pallet! {
)?;
}: _(SystemOrigin::Signed(caller.clone()), class, instances.clone())
verify {
assert_last_event::<T, I>(Event::Redeposited(class, instances).into());
assert_last_event::<T, I>(Event::Redeposited { class, successful_instances: instances }.into());
}

freeze {
let (class, caller, caller_lookup) = create_class::<T, I>();
let (instance, ..) = mint_instance::<T, I>(Default::default());
}: _(SystemOrigin::Signed(caller.clone()), Default::default(), Default::default())
verify {
assert_last_event::<T, I>(Event::Frozen(Default::default(), Default::default()).into());
assert_last_event::<T, I>(Event::Frozen { class: Default::default(), instance: Default::default() }.into());
}

thaw {
Expand All @@ -238,14 +238,14 @@ benchmarks_instance_pallet! {
)?;
}: _(SystemOrigin::Signed(caller.clone()), class, instance)
verify {
assert_last_event::<T, I>(Event::Thawed(class, instance).into());
assert_last_event::<T, I>(Event::Thawed { class, instance }.into());
}

freeze_class {
let (class, caller, caller_lookup) = create_class::<T, I>();
}: _(SystemOrigin::Signed(caller.clone()), class)
verify {
assert_last_event::<T, I>(Event::ClassFrozen(class).into());
assert_last_event::<T, I>(Event::ClassFrozen { class }.into());
}

thaw_class {
Expand All @@ -254,7 +254,7 @@ benchmarks_instance_pallet! {
Uniques::<T, I>::freeze_class(origin, class)?;
}: _(SystemOrigin::Signed(caller.clone()), class)
verify {
assert_last_event::<T, I>(Event::ClassThawed(class).into());
assert_last_event::<T, I>(Event::ClassThawed { class }.into());
}

transfer_ownership {
Expand All @@ -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::<T, I>(Event::OwnerChanged(class, target).into());
assert_last_event::<T, I>(Event::OwnerChanged { class, new_owner: target }.into());
}

set_team {
Expand All @@ -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::<T, I>(Event::TeamChanged(
assert_last_event::<T, I>(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 {
Expand All @@ -296,7 +296,7 @@ benchmarks_instance_pallet! {
};
}: { call.dispatch_bypass_filter(origin)? }
verify {
assert_last_event::<T, I>(Event::AssetStatusChanged(class).into());
assert_last_event::<T, I>(Event::AssetStatusChanged { class }.into());
}

set_attribute {
Expand All @@ -308,7 +308,7 @@ benchmarks_instance_pallet! {
add_instance_metadata::<T, I>(instance);
}: _(SystemOrigin::Signed(caller), class, Some(instance), key.clone(), value.clone())
verify {
assert_last_event::<T, I>(Event::AttributeSet(class, Some(instance), key, value).into());
assert_last_event::<T, I>(Event::AttributeSet { class, maybe_instance: Some(instance), key, value }.into());
}

clear_attribute {
Expand All @@ -318,7 +318,7 @@ benchmarks_instance_pallet! {
let (key, ..) = add_instance_attribute::<T, I>(instance);
}: _(SystemOrigin::Signed(caller), class, Some(instance), key.clone())
verify {
assert_last_event::<T, I>(Event::AttributeCleared(class, Some(instance), key).into());
assert_last_event::<T, I>(Event::AttributeCleared { class, maybe_instance: Some(instance), key }.into());
}

set_metadata {
Expand All @@ -328,7 +328,7 @@ benchmarks_instance_pallet! {
let (instance, ..) = mint_instance::<T, I>(0);
}: _(SystemOrigin::Signed(caller), class, instance, data.clone(), false)
verify {
assert_last_event::<T, I>(Event::MetadataSet(class, instance, data, false).into());
assert_last_event::<T, I>(Event::MetadataSet { class, instance, data, is_frozen: false }.into());
}

clear_metadata {
Expand All @@ -337,7 +337,7 @@ benchmarks_instance_pallet! {
add_instance_metadata::<T, I>(instance);
}: _(SystemOrigin::Signed(caller), class, instance)
verify {
assert_last_event::<T, I>(Event::MetadataCleared(class, instance).into());
assert_last_event::<T, I>(Event::MetadataCleared { class, instance }.into());
}

set_class_metadata {
Expand All @@ -346,15 +346,15 @@ benchmarks_instance_pallet! {
let (class, caller, _) = create_class::<T, I>();
}: _(SystemOrigin::Signed(caller), class, data.clone(), false)
verify {
assert_last_event::<T, I>(Event::ClassMetadataSet(class, data, false).into());
assert_last_event::<T, I>(Event::ClassMetadataSet { class, data, is_frozen: false }.into());
}

clear_class_metadata {
let (class, caller, _) = create_class::<T, I>();
add_class_metadata::<T, I>();
}: _(SystemOrigin::Signed(caller), class)
verify {
assert_last_event::<T, I>(Event::ClassMetadataCleared(class).into());
assert_last_event::<T, I>(Event::ClassMetadataCleared { class }.into());
}

approve_transfer {
Expand All @@ -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::<T, I>(Event::ApprovedTransfer(class, instance, caller, delegate).into());
assert_last_event::<T, I>(Event::ApprovedTransfer { class, instance, owner: caller, delegate }.into());
}

cancel_approval {
Expand All @@ -376,7 +376,7 @@ benchmarks_instance_pallet! {
Uniques::<T, I>::approve_transfer(origin, class, instance, delegate_lookup.clone())?;
}: _(SystemOrigin::Signed(caller.clone()), class, instance, Some(delegate_lookup))
verify {
assert_last_event::<T, I>(Event::ApprovalCancelled(class, instance, caller, delegate).into());
assert_last_event::<T, I>(Event::ApprovalCancelled { class, instance, owner: caller, delegate }.into());
}

impl_benchmark_test_suite!(Uniques, crate::mock::new_test_ext(), crate::mock::Test);
Expand Down
13 changes: 9 additions & 4 deletions frame/uniques/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
details.owner = dest;
Asset::<T, I>::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(())
}

Expand Down Expand Up @@ -105,7 +110,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Attribute::<T, I>::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,
Expand Down Expand Up @@ -146,7 +151,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Ok(())
})?;

Self::deposit_event(Event::Issued(class, instance, owner));
Self::deposit_event(Event::Issued { class, instance, owner });
Ok(())
}

Expand Down Expand Up @@ -174,7 +179,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Asset::<T, I>::remove(&class, &instance);
Account::<T, I>::remove((&owner, &class, &instance));

Self::deposit_event(Event::Burned(class, instance, owner));
Self::deposit_event(Event::Burned { class, instance, owner });
Ok(())
}
}
2 changes: 1 addition & 1 deletion frame/uniques/src/impl_nonfungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl<T: Config<I>, I: 'static> Create<<T as SystemConfig>::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() },
)
}
}
Expand Down
Loading