mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 20:57:59 +00:00
Add field names to pallet Event variants (#10184)
* Changed named fields to struct variants * Fixed errors. * Made adjustments as per `cargo +nightly fmt`. * Update frame/uniques/src/lib.rs Co-authored-by: Alexander Theißen <alex.theissen@me.com> * Removed redundant comments for structs. * Moved frame-support to dev dependencies Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -109,8 +109,8 @@ 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\]
|
||||
BatchInterrupted(u32, DispatchError),
|
||||
/// well as the error.
|
||||
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.
|
||||
@@ -217,7 +217,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 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.
|
||||
|
||||
@@ -339,8 +339,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(0, frame_system::Error::<Test>::CallFiltered.into())
|
||||
.into(),
|
||||
utility::Event::BatchInterrupted {
|
||||
index: 0,
|
||||
error: frame_system::Error::<Test>::CallFiltered.into(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -411,7 +414,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);
|
||||
@@ -426,7 +429,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);
|
||||
|
||||
@@ -439,7 +442,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),
|
||||
@@ -587,8 +590,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(0, frame_system::Error::<Test>::CallFiltered.into())
|
||||
.into(),
|
||||
utility::Event::BatchInterrupted {
|
||||
index: 0,
|
||||
error: frame_system::Error::<Test>::CallFiltered.into(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
assert_eq!(Balances::free_balance(1), 10);
|
||||
assert_eq!(Balances::free_balance(2), 10);
|
||||
|
||||
Reference in New Issue
Block a user