Add pallet names to Events (#10296)

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: add pallet names to events

* chore: formatted pallet name changes in events

* chore: formatted pallet name changes in events

* chore: formatted pallet name changes in events

* chore: formatted pallet name changes in events

* chore: formatted pallet name changes in events

* chore: formatted pallet name changes in events

* chore: formatted pallet name changes in events

* chore: formatted pallet name changes in events

* chore: formatted pallet name changes in events

* fix: add fix to tests for event variants

* chore: modified comments for event variants

* chore: modified comments for event variants

* chore: modified comments for event variants

* chore: modified comments for event variants

* chore: modified system pallet event variants

* chore: modified system pallet event variants

* chore: modified system pallet event variants

* chore: modified system pallet event variants

* chore: modified system pallet event variants

* chore: modified system pallet event variants

* chore: modified system pallet event variants

* chore: modified system pallet event variants

* chore: modified system pallet event variants

* chore: updated transaction-storage pallet event variants

* chore: updated transaction-storage pallet event variants

* chore: formatted contracts pallet

* chore: update treasury event variants
This commit is contained in:
Enoch Chejieh
2021-11-30 21:03:06 +01:00
committed by GitHub
parent b5ed64684d
commit d58aeb040a
15 changed files with 209 additions and 184 deletions
+26 -25
View File
@@ -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 {
@@ -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![],
},
];
@@ -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 {
@@ -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 {
@@ -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![],
},
];
+4 -4
View File
@@ -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 }),
]
@@ -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 }),
]
@@ -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 }),
]
@@ -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 }),
]
);
+2 -2
View File
@@ -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 }),
]
@@ -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 })
]
+8 -2
View File
@@ -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![],
},]
);
@@ -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 {
+7 -3
View File
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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(),
+23 -19
View File
@@ -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]
@@ -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 {
@@ -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))
}
@@ -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)?
@@ -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))
}
@@ -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)
}
@@ -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)?
@@ -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));
+52 -49
View File
@@ -475,42 +475,41 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> {
/// The society is founded by the given identity. \[founder\]
Founded(T::AccountId),
/// The society is founded by the given identity.
Founded { founder: T::AccountId },
/// A membership bid just happened. The given account is the candidate's ID and their offer
/// is the second. \[candidate_id, offer\]
Bid(T::AccountId, BalanceOf<T, I>),
/// is the second.
Bid { candidate_id: T::AccountId, offer: BalanceOf<T, I> },
/// A membership bid just happened by vouching. The given account is the candidate's ID and
/// their offer is the second. The vouching party is the third. \[candidate_id, offer,
/// vouching\]
Vouch(T::AccountId, BalanceOf<T, I>, T::AccountId),
/// A \[candidate\] was dropped (due to an excess of bids in the system).
AutoUnbid(T::AccountId),
/// A \[candidate\] was dropped (by their request).
Unbid(T::AccountId),
/// A \[candidate\] was dropped (by request of who vouched for them).
Unvouch(T::AccountId),
/// their offer is the second. The vouching party is the third.
Vouch { candidate_id: T::AccountId, offer: BalanceOf<T, I>, vouching: T::AccountId },
/// A candidate was dropped (due to an excess of bids in the system).
AutoUnbid { candidate: T::AccountId },
/// A candidate was dropped (by their request).
Unbid { candidate: T::AccountId },
/// A candidate was dropped (by request of who vouched for them).
Unvouch { candidate: T::AccountId },
/// A group of candidates have been inducted. The batch's primary is the first value, the
/// batch in full is the second. \[primary, candidates\]
Inducted(T::AccountId, Vec<T::AccountId>),
/// A suspended member has been judged. \[who, judged\]
SuspendedMemberJudgement(T::AccountId, bool),
/// A \[candidate\] has been suspended
CandidateSuspended(T::AccountId),
/// A \[member\] has been suspended
MemberSuspended(T::AccountId),
/// A \[member\] has been challenged
Challenged(T::AccountId),
/// A vote has been placed \[candidate, voter, vote\]
Vote(T::AccountId, T::AccountId, bool),
/// A vote has been placed for a defending member \[voter, vote\]
DefenderVote(T::AccountId, bool),
/// batch in full is the second.
Inducted { primary: T::AccountId, candidates: Vec<T::AccountId> },
/// A suspended member has been judged.
SuspendedMemberJudgement { who: T::AccountId, judged: bool },
/// A candidate has been suspended
CandidateSuspended { candidate: T::AccountId },
/// A member has been suspended
MemberSuspended { member: T::AccountId },
/// A member has been challenged
Challenged { member: T::AccountId },
/// A vote has been placed
Vote { candidate: T::AccountId, voter: T::AccountId, vote: bool },
/// A vote has been placed for a defending member
DefenderVote { voter: T::AccountId, vote: bool },
/// A new \[max\] member count has been set
NewMaxMembers(u32),
/// Society is unfounded. \[founder\]
Unfounded(T::AccountId),
/// Some funds were deposited into the society account. \[value\]
Deposit(BalanceOf<T, I>),
NewMaxMembers { max: u32 },
/// Society is unfounded.
Unfounded { founder: T::AccountId },
/// Some funds were deposited into the society account.
Deposit { value: BalanceOf<T, I> },
}
/// Old name generated by `decl_event`.
@@ -729,7 +728,7 @@ pub mod pallet {
T::Currency::reserve(&who, deposit)?;
Self::put_bid(bids, &who, value.clone(), BidKind::Deposit(deposit));
Self::deposit_event(Event::<T, I>::Bid(who, value));
Self::deposit_event(Event::<T, I>::Bid { candidate_id: who, offer: value });
Ok(())
}
@@ -771,7 +770,7 @@ pub mod pallet {
<Vouching<T, I>>::remove(&voucher);
},
}
Self::deposit_event(Event::<T, I>::Unbid(who));
Self::deposit_event(Event::<T, I>::Unbid { candidate: who });
Ok(())
} else {
Err(Error::<T, I>::BadPosition)?
@@ -849,7 +848,11 @@ pub mod pallet {
<Vouching<T, I>>::insert(&voucher, VouchingStatus::Vouching);
Self::put_bid(bids, &who, value.clone(), BidKind::Vouch(voucher.clone(), tip));
Self::deposit_event(Event::<T, I>::Vouch(who, value, voucher));
Self::deposit_event(Event::<T, I>::Vouch {
candidate_id: who,
offer: value,
vouching: voucher,
});
Ok(())
}
@@ -884,7 +887,7 @@ pub mod pallet {
b[pos].kind.check_voucher(&voucher)?;
<Vouching<T, I>>::remove(&voucher);
let who = b.remove(pos).who;
Self::deposit_event(Event::<T, I>::Unvouch(who));
Self::deposit_event(Event::<T, I>::Unvouch { candidate: who });
Ok(())
} else {
Err(Error::<T, I>::BadPosition)?
@@ -927,7 +930,7 @@ pub mod pallet {
let vote = if approve { Vote::Approve } else { Vote::Reject };
<Votes<T, I>>::insert(&candidate, &voter, vote);
Self::deposit_event(Event::<T, I>::Vote(candidate, voter, approve));
Self::deposit_event(Event::<T, I>::Vote { candidate, voter, vote: approve });
Ok(())
}
@@ -956,7 +959,7 @@ pub mod pallet {
let vote = if approve { Vote::Approve } else { Vote::Reject };
<DefenderVotes<T, I>>::insert(&voter, vote);
Self::deposit_event(Event::<T, I>::DefenderVote(voter, approve));
Self::deposit_event(Event::<T, I>::DefenderVote { voter, vote: approve });
Ok(())
}
@@ -1039,7 +1042,7 @@ pub mod pallet {
<Head<T, I>>::put(&founder);
<Founder<T, I>>::put(&founder);
Rules::<T, I>::put(T::Hashing::hash(&rules));
Self::deposit_event(Event::<T, I>::Founded(founder));
Self::deposit_event(Event::<T, I>::Founded { founder });
Ok(())
}
@@ -1068,7 +1071,7 @@ pub mod pallet {
Rules::<T, I>::kill();
Candidates::<T, I>::kill();
SuspendedCandidates::<T, I>::remove_all(None);
Self::deposit_event(Event::<T, I>::Unfounded(founder));
Self::deposit_event(Event::<T, I>::Unfounded { founder });
Ok(())
}
@@ -1125,14 +1128,14 @@ pub mod pallet {
if let Some(pos) = bids.iter().position(|b| b.kind.check_voucher(&who).is_ok()) {
// Remove the bid, and emit an event
let vouched = bids.remove(pos).who;
Self::deposit_event(Event::<T, I>::Unvouch(vouched));
Self::deposit_event(Event::<T, I>::Unvouch { candidate: vouched });
}
);
}
}
<SuspendedMembers<T, I>>::remove(&who);
Self::deposit_event(Event::<T, I>::SuspendedMemberJudgement(who, forgive));
Self::deposit_event(Event::<T, I>::SuspendedMemberJudgement { who, judged: forgive });
Ok(())
}
@@ -1253,7 +1256,7 @@ pub mod pallet {
ensure_root(origin)?;
ensure!(max > 1, Error::<T, I>::MaxMembers);
MaxMembers::<T, I>::put(max);
Self::deposit_event(Event::<T, I>::NewMaxMembers(max));
Self::deposit_event(Event::<T, I>::NewMaxMembers { max });
Ok(())
}
}
@@ -1339,7 +1342,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
<Vouching<T, I>>::remove(&voucher);
},
}
Self::deposit_event(Event::<T, I>::AutoUnbid(popped));
Self::deposit_event(Event::<T, I>::AutoUnbid { candidate: popped });
}
<Bids<T, I>>::put(bids);
@@ -1504,7 +1507,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
} else {
// Suspend Candidate
<SuspendedCandidates<T, I>>::insert(&candidate, (value, kind));
Self::deposit_event(Event::<T, I>::CandidateSuspended(candidate));
Self::deposit_event(Event::<T, I>::CandidateSuspended { candidate });
None
}
})
@@ -1573,7 +1576,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
<Head<T, I>>::put(&primary);
T::MembershipChanged::change_members_sorted(&accounts, &[], &members);
Self::deposit_event(Event::<T, I>::Inducted(primary, accounts));
Self::deposit_event(Event::<T, I>::Inducted { primary, candidates: accounts });
}
// Bump the pot by at most PeriodSpend, but less if there's not very much left in our
@@ -1638,7 +1641,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
if Self::remove_member(&who).is_ok() {
<SuspendedMembers<T, I>>::insert(who, true);
<Strikes<T, I>>::remove(who);
Self::deposit_event(Event::<T, I>::MemberSuspended(who.clone()));
Self::deposit_event(Event::<T, I>::MemberSuspended { member: who.clone() });
}
}
@@ -1716,7 +1719,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let chosen = pick_item(&mut rng, &members[1..members.len() - 1])
.expect("exited if members empty; qed");
<Defender<T, I>>::put(&chosen);
Self::deposit_event(Event::<T, I>::Challenged(chosen.clone()));
Self::deposit_event(Event::<T, I>::Challenged { member: chosen.clone() });
} else {
<Defender<T, I>>::kill();
}
@@ -1820,6 +1823,6 @@ impl<T: Config<I>, I: 'static> OnUnbalanced<NegativeImbalanceOf<T, I>> for Palle
// Must resolve into existing but better to be safe.
let _ = T::Currency::resolve_creating(&Self::account_id(), amount);
Self::deposit_event(Event::<T, I>::Deposit(numeric_amount));
Self::deposit_event(Event::<T, I>::Deposit { value: numeric_amount });
}
}
+15 -15
View File
@@ -458,7 +458,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
let hash = T::Hashing::hash(&remark[..]);
Self::deposit_event(Event::Remarked(who, hash));
Self::deposit_event(Event::Remarked { sender: who, hash });
Ok(().into())
}
}
@@ -466,18 +466,18 @@ pub mod pallet {
/// Event for the System pallet.
#[pallet::event]
pub enum Event<T: Config> {
/// An extrinsic completed successfully. \[info\]
ExtrinsicSuccess(DispatchInfo),
/// An extrinsic failed. \[error, info\]
ExtrinsicFailed(DispatchError, DispatchInfo),
/// An extrinsic completed successfully.
ExtrinsicSuccess { dispatch_info: DispatchInfo },
/// An extrinsic failed.
ExtrinsicFailed { dispatch_error: DispatchError, dispatch_info: DispatchInfo },
/// `:code` was updated.
CodeUpdated,
/// A new \[account\] was created.
NewAccount(T::AccountId),
/// An \[account\] was reaped.
KilledAccount(T::AccountId),
/// On on-chain remark happened. \[origin, remark_hash\]
Remarked(T::AccountId, T::Hash),
/// A new account was created.
NewAccount { account: T::AccountId },
/// An account was reaped.
KilledAccount { account: T::AccountId },
/// On on-chain remark happened.
Remarked { sender: T::AccountId, hash: T::Hash },
}
/// Old name generated by `decl_event`.
@@ -1486,7 +1486,7 @@ impl<T: Config> Pallet<T> {
pub fn note_applied_extrinsic(r: &DispatchResultWithPostInfo, mut info: DispatchInfo) {
info.weight = extract_actual_weight(r, &info);
Self::deposit_event(match r {
Ok(_) => Event::ExtrinsicSuccess(info),
Ok(_) => Event::ExtrinsicSuccess { dispatch_info: info },
Err(err) => {
log::trace!(
target: "runtime::system",
@@ -1494,7 +1494,7 @@ impl<T: Config> Pallet<T> {
Self::block_number(),
err,
);
Event::ExtrinsicFailed(err.error, info)
Event::ExtrinsicFailed { dispatch_error: err.error, dispatch_info: info }
},
});
@@ -1522,13 +1522,13 @@ impl<T: Config> Pallet<T> {
/// An account is being created.
pub fn on_created_account(who: T::AccountId, _a: &mut AccountInfo<T::Index, T::AccountData>) {
T::OnNewAccount::on_new_account(&who);
Self::deposit_event(Event::NewAccount(who));
Self::deposit_event(Event::NewAccount { account: who });
}
/// Do anything that needs to be done after an account has been killed.
fn on_killed_account(who: T::AccountId) {
T::OnKilledAccount::on_killed_account(&who);
Self::deposit_event(Event::KilledAccount(who));
Self::deposit_event(Event::KilledAccount { account: who });
}
/// Determine whether or not it is possible to update the code.
+30 -33
View File
@@ -168,44 +168,44 @@ fn deposit_event_should_work() {
);
System::initialize(&2, &[0u8; 32].into(), &Default::default(), InitKind::Full);
System::deposit_event(SysEvent::NewAccount(32));
System::deposit_event(SysEvent::NewAccount { account: 32 });
System::note_finished_initialize();
System::deposit_event(SysEvent::KilledAccount(42));
System::deposit_event(SysEvent::KilledAccount { account: 42 });
System::note_applied_extrinsic(&Ok(().into()), Default::default());
System::note_applied_extrinsic(&Err(DispatchError::BadOrigin.into()), Default::default());
System::note_finished_extrinsics();
System::deposit_event(SysEvent::NewAccount(3));
System::deposit_event(SysEvent::NewAccount { account: 3 });
System::finalize();
assert_eq!(
System::events(),
vec![
EventRecord {
phase: Phase::Initialization,
event: SysEvent::NewAccount(32).into(),
event: SysEvent::NewAccount { account: 32 }.into(),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: SysEvent::KilledAccount(42).into(),
event: SysEvent::KilledAccount { account: 42 }.into(),
topics: vec![]
},
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: SysEvent::ExtrinsicSuccess(Default::default()).into(),
event: SysEvent::ExtrinsicSuccess { dispatch_info: Default::default() }.into(),
topics: vec![]
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: SysEvent::ExtrinsicFailed(
DispatchError::BadOrigin.into(),
Default::default()
)
event: SysEvent::ExtrinsicFailed {
dispatch_error: DispatchError::BadOrigin.into(),
dispatch_info: Default::default()
}
.into(),
topics: vec![]
},
EventRecord {
phase: Phase::Finalization,
event: SysEvent::NewAccount(3).into(),
event: SysEvent::NewAccount { account: 3 }.into(),
topics: vec![]
},
]
@@ -234,37 +234,34 @@ fn deposit_event_uses_actual_weight() {
vec![
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: SysEvent::ExtrinsicSuccess(DispatchInfo {
weight: 300,
..Default::default()
},)
event: SysEvent::ExtrinsicSuccess {
dispatch_info: DispatchInfo { weight: 300, ..Default::default() },
}
.into(),
topics: vec![]
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: SysEvent::ExtrinsicSuccess(DispatchInfo {
weight: 1000,
..Default::default()
},)
event: SysEvent::ExtrinsicSuccess {
dispatch_info: DispatchInfo { weight: 1000, ..Default::default() },
}
.into(),
topics: vec![]
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: SysEvent::ExtrinsicSuccess(DispatchInfo {
weight: 1000,
..Default::default()
},)
event: SysEvent::ExtrinsicSuccess {
dispatch_info: DispatchInfo { weight: 1000, ..Default::default() },
}
.into(),
topics: vec![]
},
EventRecord {
phase: Phase::ApplyExtrinsic(3),
event: SysEvent::ExtrinsicFailed(
DispatchError::BadOrigin.into(),
DispatchInfo { weight: 999, ..Default::default() },
)
event: SysEvent::ExtrinsicFailed {
dispatch_error: DispatchError::BadOrigin.into(),
dispatch_info: DispatchInfo { weight: 999, ..Default::default() },
}
.into(),
topics: vec![]
},
@@ -284,9 +281,9 @@ fn deposit_event_topics() {
let topics = vec![H256::repeat_byte(1), H256::repeat_byte(2), H256::repeat_byte(3)];
// We deposit a few events with different sets of topics.
System::deposit_event_indexed(&topics[0..3], SysEvent::NewAccount(1).into());
System::deposit_event_indexed(&topics[0..1], SysEvent::NewAccount(2).into());
System::deposit_event_indexed(&topics[1..2], SysEvent::NewAccount(3).into());
System::deposit_event_indexed(&topics[0..3], SysEvent::NewAccount { account: 1 }.into());
System::deposit_event_indexed(&topics[0..1], SysEvent::NewAccount { account: 2 }.into());
System::deposit_event_indexed(&topics[1..2], SysEvent::NewAccount { account: 3 }.into());
System::finalize();
@@ -296,17 +293,17 @@ fn deposit_event_topics() {
vec![
EventRecord {
phase: Phase::Finalization,
event: SysEvent::NewAccount(1).into(),
event: SysEvent::NewAccount { account: 1 }.into(),
topics: topics[0..3].to_vec(),
},
EventRecord {
phase: Phase::Finalization,
event: SysEvent::NewAccount(2).into(),
event: SysEvent::NewAccount { account: 2 }.into(),
topics: topics[0..1].to_vec(),
},
EventRecord {
phase: Phase::Finalization,
event: SysEvent::NewAccount(3).into(),
event: SysEvent::NewAccount { account: 3 }.into(),
topics: topics[1..2].to_vec(),
}
]
@@ -1369,7 +1369,9 @@ mod tests {
amount: 80,
}));
// Killed Event
System::assert_has_event(Event::System(system::Event::KilledAccount(2)));
System::assert_has_event(Event::System(system::Event::KilledAccount {
account: 2,
}));
});
}
@@ -109,7 +109,7 @@ benchmarks! {
}: _(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize])
verify {
assert!(!BlockTransactions::<T>::get().is_empty());
assert_last_event::<T>(Event::Stored(0).into());
assert_last_event::<T>(Event::Stored { index: 0 }.into());
}
renew {
@@ -122,7 +122,7 @@ benchmarks! {
run_to_block::<T>(1u32.into());
}: _(RawOrigin::Signed(caller.clone()), T::BlockNumber::zero(), 0)
verify {
assert_last_event::<T>(Event::Renewed(0).into());
assert_last_event::<T>(Event::Renewed { index: 0 }.into());
}
check_proof_max {
@@ -210,7 +210,7 @@ pub mod pallet {
});
Ok(())
})?;
Self::deposit_event(Event::Stored(index));
Self::deposit_event(Event::Stored { index });
Ok(())
}
@@ -251,7 +251,7 @@ pub mod pallet {
});
Ok(())
})?;
Self::deposit_event(Event::Renewed(index));
Self::deposit_event(Event::Renewed { index });
Ok(().into())
}
@@ -313,9 +313,9 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Stored data under specified index.
Stored(u32),
Stored { index: u32 },
/// Renewed data under specified index.
Renewed(u32),
Renewed { index: u32 },
/// Storage proof was successfully checked.
ProofChecked,
}
+27 -21
View File
@@ -255,21 +255,20 @@ pub mod pallet {
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> {
/// New proposal. \[proposal_index\]
Proposed(ProposalIndex),
/// We have ended a spend period and will now allocate funds. \[budget_remaining\]
Spending(BalanceOf<T, I>),
/// Some funds have been allocated. \[proposal_index, award, beneficiary\]
Awarded(ProposalIndex, BalanceOf<T, I>, T::AccountId),
/// A proposal was rejected; funds were slashed. \[proposal_index, slashed\]
Rejected(ProposalIndex, BalanceOf<T, I>),
/// Some of our funds have been burnt. \[burn\]
Burnt(BalanceOf<T, I>),
/// New proposal.
Proposed { proposal_index: ProposalIndex },
/// We have ended a spend period and will now allocate funds.
Spending { budget_remaining: BalanceOf<T, I> },
/// Some funds have been allocated.
Awarded { proposal_index: ProposalIndex, award: BalanceOf<T, I>, account: T::AccountId },
/// A proposal was rejected; funds were slashed.
Rejected { proposal_index: ProposalIndex, slashed: BalanceOf<T, I> },
/// Some of our funds have been burnt.
Burnt { burnt_funds: BalanceOf<T, I> },
/// Spending has finished; this is the amount that rolls over until next spend.
/// \[budget_remaining\]
Rollover(BalanceOf<T, I>),
/// Some funds have been deposited. \[deposit\]
Deposit(BalanceOf<T, I>),
Rollover { rollover_balance: BalanceOf<T, I> },
/// Some funds have been deposited.
Deposit { value: BalanceOf<T, I> },
}
/// Old name generated by `decl_event`.
@@ -334,7 +333,7 @@ pub mod pallet {
<ProposalCount<T, I>>::put(c + 1);
<Proposals<T, I>>::insert(c, Proposal { proposer, value, beneficiary, bond });
Self::deposit_event(Event::Proposed(c));
Self::deposit_event(Event::Proposed { proposal_index: c });
Ok(())
}
@@ -360,7 +359,10 @@ pub mod pallet {
let imbalance = T::Currency::slash_reserved(&proposal.proposer, value).0;
T::OnSlash::on_unbalanced(imbalance);
Self::deposit_event(Event::<T, I>::Rejected(proposal_id, value));
Self::deposit_event(Event::<T, I>::Rejected {
proposal_index: proposal_id,
slashed: value,
});
Ok(())
}
@@ -410,7 +412,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let mut total_weight: Weight = Zero::zero();
let mut budget_remaining = Self::pot();
Self::deposit_event(Event::Spending(budget_remaining));
Self::deposit_event(Event::Spending { budget_remaining });
let account_id = Self::account_id();
let mut missed_any = false;
@@ -431,7 +433,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
// provide the allocation.
imbalance.subsume(T::Currency::deposit_creating(&p.beneficiary, p.value));
Self::deposit_event(Event::Awarded(index, p.value, p.beneficiary));
Self::deposit_event(Event::Awarded {
proposal_index: index,
award: p.value,
account: p.beneficiary,
});
false
} else {
missed_any = true;
@@ -462,7 +468,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let (debit, credit) = T::Currency::pair(burn);
imbalance.subsume(debit);
T::BurnDestination::on_unbalanced(credit);
Self::deposit_event(Event::Burnt(burn))
Self::deposit_event(Event::Burnt { burnt_funds: burn })
}
// Must never be an error, but better to be safe.
@@ -477,7 +483,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
drop(problem);
}
Self::deposit_event(Event::Rollover(budget_remaining));
Self::deposit_event(Event::Rollover { rollover_balance: budget_remaining });
total_weight
}
@@ -498,6 +504,6 @@ impl<T: Config<I>, I: 'static> OnUnbalanced<NegativeImbalanceOf<T, I>> for Palle
// Must resolve into existing but better to be safe.
let _ = T::Currency::resolve_creating(&Self::account_id(), amount);
Self::deposit_event(Event::Deposit(numeric_amount));
Self::deposit_event(Event::Deposit { value: numeric_amount });
}
}
+5 -3
View File
@@ -115,8 +115,8 @@ pub mod pallet {
BatchCompleted,
/// A single item within a Batch of dispatches has completed with no error.
ItemCompleted,
/// A call was dispatched. \[result\]
DispatchedAs(DispatchResult),
/// A call was dispatched.
DispatchedAs { result: DispatchResult },
}
// Align the call size to 1KB. As we are currently compiling the runtime for native/wasm
@@ -380,7 +380,9 @@ pub mod pallet {
let res = call.dispatch_bypass_filter((*as_origin).into());
Self::deposit_event(Event::DispatchedAs(res.map(|_| ()).map_err(|e| e.error)));
Self::deposit_event(Event::DispatchedAs {
result: res.map(|_| ()).map_err(|e| e.error),
});
Ok(())
}
}