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

Add pallet names to Events #10296

Merged
merged 46 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8f5729d
chore: add pallet names to events
ECJ222 Nov 17, 2021
aae0f77
chore: add pallet names to events
ECJ222 Nov 17, 2021
311d77e
chore: add pallet names to events
ECJ222 Nov 17, 2021
823aece
chore: add pallet names to events
ECJ222 Nov 17, 2021
b57d7bc
chore: add pallet names to events
ECJ222 Nov 17, 2021
63454ca
chore: add pallet names to events
ECJ222 Nov 17, 2021
e73f0fd
chore: add pallet names to events
ECJ222 Nov 17, 2021
a34bed3
chore: add pallet names to events
ECJ222 Nov 17, 2021
843f192
chore: add pallet names to events
ECJ222 Nov 17, 2021
a4ccf2e
chore: add pallet names to events
ECJ222 Nov 17, 2021
5261768
chore: add pallet names to events
ECJ222 Nov 17, 2021
683ec95
chore: add pallet names to events
ECJ222 Nov 17, 2021
b772b90
chore: add pallet names to events
ECJ222 Nov 17, 2021
6db94cb
chore: add pallet names to events
ECJ222 Nov 17, 2021
6d56f9b
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
e63f00c
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
89dc501
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
10d5c1d
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
656c1e7
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
4a1c11a
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
cf84a29
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
525276a
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
0c7e8c6
chore: formatted pallet name changes in events
ECJ222 Nov 17, 2021
52ccf3b
Merge branch 'paritytech:master' into add-pallet-event-field-names
ECJ222 Nov 18, 2021
2f03714
fix: add fix to tests for event variants
ECJ222 Nov 18, 2021
0a31c76
chore: modified comments for event variants
ECJ222 Nov 18, 2021
ca9c2a3
chore: modified comments for event variants
ECJ222 Nov 18, 2021
63bb12b
chore: modified comments for event variants
ECJ222 Nov 18, 2021
78457a7
chore: modified comments for event variants
ECJ222 Nov 18, 2021
cd07885
Merge branch 'paritytech:master' into add-pallet-event-field-names
ECJ222 Nov 19, 2021
54cb4a1
Merge branch 'paritytech:master' into add-pallet-event-field-names
ECJ222 Nov 21, 2021
6c0490f
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
5691a6a
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
0b0873d
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
ce14af3
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
72c0c3d
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
856bef8
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
ac57d08
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
9491534
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
e69ef47
chore: modified system pallet event variants
ECJ222 Nov 21, 2021
07d7d36
Merge branch 'paritytech:master' into add-pallet-event-field-names
ECJ222 Nov 23, 2021
9cc1c6e
chore: updated transaction-storage pallet event variants
ECJ222 Nov 23, 2021
099e926
chore: updated transaction-storage pallet event variants
ECJ222 Nov 23, 2021
8121415
chore: formatted contracts pallet
ECJ222 Nov 24, 2021
1822a57
Merge branch 'paritytech:master' into add-pallet-event-field-names
ECJ222 Nov 26, 2021
7b7b3b5
chore: update treasury event variants
ECJ222 Nov 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,13 @@ fn full_native_block_import_works() {
let events = vec![
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo {
weight: timestamp_weight,
class: DispatchClass::Mandatory,
..Default::default()
})),
event: Event::System(frame_system::Event::ExtrinsicSuccess {
dispatch_info: DispatchInfo {
weight: timestamp_weight,
class: DispatchClass::Mandatory,
..Default::default()
},
}),
topics: vec![],
},
EventRecord {
Expand Down Expand Up @@ -412,15 +414,14 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::Treasury(pallet_treasury::Event::Deposit(fees * 8 / 10)),
event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo {
weight: transfer_weight,
..Default::default()
})),
event: Event::System(frame_system::Event::ExtrinsicSuccess {
dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() },
}),
topics: vec![],
},
];
Expand Down Expand Up @@ -448,11 +449,13 @@ fn full_native_block_import_works() {
let events = vec![
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo {
weight: timestamp_weight,
class: DispatchClass::Mandatory,
..Default::default()
})),
event: Event::System(frame_system::Event::ExtrinsicSuccess {
dispatch_info: DispatchInfo {
weight: timestamp_weight,
class: DispatchClass::Mandatory,
..Default::default()
},
}),
topics: vec![],
},
EventRecord {
Expand Down Expand Up @@ -482,15 +485,14 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::Treasury(pallet_treasury::Event::Deposit(fees * 8 / 10)),
event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo {
weight: transfer_weight,
..Default::default()
})),
event: Event::System(frame_system::Event::ExtrinsicSuccess {
dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() },
}),
topics: vec![],
},
EventRecord {
Expand Down Expand Up @@ -520,15 +522,14 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: Event::Treasury(pallet_treasury::Event::Deposit(fees * 8 / 10)),
event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo {
weight: transfer_weight,
..Default::default()
})),
event: Event::System(frame_system::Event::ExtrinsicSuccess {
dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() },
}),
topics: vec![],
},
];
Expand Down
8 changes: 4 additions & 4 deletions frame/balances/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ macro_rules! decl_tests {
assert_eq!(
events(),
[
Event::System(system::Event::NewAccount(1)),
Event::System(system::Event::NewAccount { account: 1 }),
Event::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }),
Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }),
]
Expand All @@ -762,7 +762,7 @@ macro_rules! decl_tests {
assert_eq!(
events(),
[
Event::System(system::Event::KilledAccount(1)),
Event::System(system::Event::KilledAccount { account: 1 }),
Event::Balances(crate::Event::DustLost { account: 1, amount: 99 }),
Event::Balances(crate::Event::Slashed { who: 1, amount: 1 }),
]
Expand All @@ -781,7 +781,7 @@ macro_rules! decl_tests {
assert_eq!(
events(),
[
Event::System(system::Event::NewAccount(1)),
Event::System(system::Event::NewAccount { account: 1 }),
Event::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }),
Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }),
]
Expand All @@ -793,7 +793,7 @@ macro_rules! decl_tests {
assert_eq!(
events(),
[
Event::System(system::Event::KilledAccount(1)),
Event::System(system::Event::KilledAccount { account: 1 }),
Event::Balances(crate::Event::Slashed { who: 1, amount: 100 }),
]
);
Expand Down
4 changes: 2 additions & 2 deletions frame/balances/src/tests_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() {
assert_eq!(
events(),
[
Event::System(system::Event::NewAccount(1)),
Event::System(system::Event::NewAccount { account: 1 }),
Event::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }),
Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }),
]
Expand All @@ -181,7 +181,7 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() {
assert_eq!(
events(),
[
Event::System(system::Event::KilledAccount(1)),
Event::System(system::Event::KilledAccount { account: 1 }),
Event::Balances(crate::Event::DustLost { account: 1, amount: 1 }),
Event::Balances(crate::Event::Slashed { who: 1, amount: 1 })
]
Expand Down
10 changes: 8 additions & 2 deletions frame/contracts/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,10 @@ mod tests {
System::events(),
vec![EventRecord {
phase: Phase::Initialization,
event: MetaEvent::System(frame_system::Event::Remarked(BOB, remark_hash)),
event: MetaEvent::System(frame_system::Event::Remarked {
sender: BOB,
hash: remark_hash
}),
topics: vec![],
},]
);
Expand Down Expand Up @@ -2147,7 +2150,10 @@ mod tests {
vec![
EventRecord {
phase: Phase::Initialization,
event: MetaEvent::System(frame_system::Event::Remarked(BOB, remark_hash)),
event: MetaEvent::System(frame_system::Event::Remarked {
sender: BOB,
hash: remark_hash
}),
topics: vec![],
},
EventRecord {
Expand Down
10 changes: 7 additions & 3 deletions frame/contracts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,9 @@ fn instantiate_and_call_and_deposit_event() {
},
EventRecord {
phase: Phase::Initialization,
event: Event::System(frame_system::Event::NewAccount(ALICE.clone())),
event: Event::System(frame_system::Event::NewAccount {
account: ALICE.clone()
}),
topics: vec![],
},
EventRecord {
Expand All @@ -468,7 +470,7 @@ fn instantiate_and_call_and_deposit_event() {
},
EventRecord {
phase: Phase::Initialization,
event: Event::System(frame_system::Event::NewAccount(addr.clone())),
event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }),
topics: vec![],
},
EventRecord {
Expand Down Expand Up @@ -767,7 +769,9 @@ fn self_destruct_works() {
vec![
EventRecord {
phase: Phase::Initialization,
event: Event::System(frame_system::Event::KilledAccount(addr.clone())),
event: Event::System(frame_system::Event::KilledAccount {
account: addr.clone()
}),
topics: vec![],
},
EventRecord {
Expand Down
2 changes: 1 addition & 1 deletion frame/offences/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ benchmarks! {
let mut reward_events = reporters.clone().into_iter()
.flat_map(|reporter| vec![
balance_deposit(reporter.clone(), reward.into()).into(),
frame_system::Event::<T>::NewAccount(reporter.clone()).into(),
frame_system::Event::<T>::NewAccount { account: reporter.clone() }.into(),
<T as BalancesConfig>::Event::from(
pallet_balances::Event::<T>::Endowed{account: reporter.clone(), free_balance: reward.into()}
).into(),
Expand Down
42 changes: 23 additions & 19 deletions frame/scheduler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,16 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Scheduled some task. \[when, index\]
Scheduled(T::BlockNumber, u32),
/// Canceled some task. \[when, index\]
Canceled(T::BlockNumber, u32),
/// Dispatched some task. \[task, id, result\]
Dispatched(TaskAddress<T::BlockNumber>, Option<Vec<u8>>, DispatchResult),
/// Scheduled some task.
Scheduled { when: T::BlockNumber, index: u32 },
/// Canceled some task.
Canceled { when: T::BlockNumber, index: u32 },
/// Dispatched some task.
Dispatched {
task: TaskAddress<T::BlockNumber>,
id: Option<Vec<u8>>,
result: DispatchResult,
},
}

#[pallet::error]
Expand Down Expand Up @@ -319,11 +323,11 @@ pub mod pallet {
Lookup::<T>::remove(id);
}
}
Self::deposit_event(Event::Dispatched(
(now, index),
maybe_id,
r.map(|_| ()).map_err(|e| e.error),
));
Self::deposit_event(Event::Dispatched {
task: (now, index),
id: maybe_id,
result: r.map(|_| ()).map_err(|e| e.error),
});
total_weight = cumulative_weight;
None
} else {
Expand Down Expand Up @@ -563,7 +567,7 @@ impl<T: Config> Pallet<T> {
expected from the runtime configuration. An update might be needed.",
);
}
Self::deposit_event(Event::Scheduled(when, index));
Self::deposit_event(Event::Scheduled { when, index });

Ok((when, index))
}
Expand Down Expand Up @@ -592,7 +596,7 @@ impl<T: Config> Pallet<T> {
if let Some(id) = s.maybe_id {
Lookup::<T>::remove(id);
}
Self::deposit_event(Event::Canceled(when, index));
Self::deposit_event(Event::Canceled { when, index });
Ok(())
} else {
Err(Error::<T>::NotFound)?
Expand All @@ -617,8 +621,8 @@ impl<T: Config> Pallet<T> {
})?;

let new_index = Agenda::<T>::decode_len(new_time).unwrap_or(1) as u32 - 1;
Self::deposit_event(Event::Canceled(when, index));
Self::deposit_event(Event::Scheduled(new_time, new_index));
Self::deposit_event(Event::Canceled { when, index });
Self::deposit_event(Event::Scheduled { when: new_time, index: new_index });

Ok((new_time, new_index))
}
Expand Down Expand Up @@ -663,7 +667,7 @@ impl<T: Config> Pallet<T> {
}
let address = (when, index);
Lookup::<T>::insert(&id, &address);
Self::deposit_event(Event::Scheduled(when, index));
Self::deposit_event(Event::Scheduled { when, index });

Ok(address)
}
Expand All @@ -686,7 +690,7 @@ impl<T: Config> Pallet<T> {
}
Ok(())
})?;
Self::deposit_event(Event::Canceled(when, index));
Self::deposit_event(Event::Canceled { when, index });
Ok(())
} else {
Err(Error::<T>::NotFound)?
Expand Down Expand Up @@ -718,8 +722,8 @@ impl<T: Config> Pallet<T> {
})?;

let new_index = Agenda::<T>::decode_len(new_time).unwrap_or(1) as u32 - 1;
Self::deposit_event(Event::Canceled(when, index));
Self::deposit_event(Event::Scheduled(new_time, new_index));
Self::deposit_event(Event::Canceled { when, index });
Self::deposit_event(Event::Scheduled { when: new_time, index: new_index });

*lookup = Some((new_time, new_index));

Expand Down
Loading