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![ let events = vec![
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(0), phase: Phase::ApplyExtrinsic(0),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo { event: Event::System(frame_system::Event::ExtrinsicSuccess {
weight: timestamp_weight, dispatch_info: DispatchInfo {
class: DispatchClass::Mandatory, weight: timestamp_weight,
..Default::default() class: DispatchClass::Mandatory,
})), ..Default::default()
},
}),
topics: vec![], topics: vec![],
}, },
EventRecord { EventRecord {
@@ -412,15 +414,14 @@ fn full_native_block_import_works() {
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(1), 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![], topics: vec![],
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(1), phase: Phase::ApplyExtrinsic(1),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo { event: Event::System(frame_system::Event::ExtrinsicSuccess {
weight: transfer_weight, dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() },
..Default::default() }),
})),
topics: vec![], topics: vec![],
}, },
]; ];
@@ -448,11 +449,13 @@ fn full_native_block_import_works() {
let events = vec![ let events = vec![
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(0), phase: Phase::ApplyExtrinsic(0),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo { event: Event::System(frame_system::Event::ExtrinsicSuccess {
weight: timestamp_weight, dispatch_info: DispatchInfo {
class: DispatchClass::Mandatory, weight: timestamp_weight,
..Default::default() class: DispatchClass::Mandatory,
})), ..Default::default()
},
}),
topics: vec![], topics: vec![],
}, },
EventRecord { EventRecord {
@@ -482,15 +485,14 @@ fn full_native_block_import_works() {
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(1), 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![], topics: vec![],
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(1), phase: Phase::ApplyExtrinsic(1),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo { event: Event::System(frame_system::Event::ExtrinsicSuccess {
weight: transfer_weight, dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() },
..Default::default() }),
})),
topics: vec![], topics: vec![],
}, },
EventRecord { EventRecord {
@@ -520,15 +522,14 @@ fn full_native_block_import_works() {
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(2), 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![], topics: vec![],
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(2), phase: Phase::ApplyExtrinsic(2),
event: Event::System(frame_system::Event::ExtrinsicSuccess(DispatchInfo { event: Event::System(frame_system::Event::ExtrinsicSuccess {
weight: transfer_weight, dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() },
..Default::default() }),
})),
topics: vec![], topics: vec![],
}, },
]; ];
+4 -4
View File
@@ -750,7 +750,7 @@ macro_rules! decl_tests {
assert_eq!( assert_eq!(
events(), 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::Endowed { account: 1, free_balance: 100 }),
Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }),
] ]
@@ -762,7 +762,7 @@ macro_rules! decl_tests {
assert_eq!( assert_eq!(
events(), 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::DustLost { account: 1, amount: 99 }),
Event::Balances(crate::Event::Slashed { who: 1, amount: 1 }), Event::Balances(crate::Event::Slashed { who: 1, amount: 1 }),
] ]
@@ -781,7 +781,7 @@ macro_rules! decl_tests {
assert_eq!( assert_eq!(
events(), 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::Endowed { account: 1, free_balance: 100 }),
Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }),
] ]
@@ -793,7 +793,7 @@ macro_rules! decl_tests {
assert_eq!( assert_eq!(
events(), events(),
[ [
Event::System(system::Event::KilledAccount(1)), Event::System(system::Event::KilledAccount { account: 1 }),
Event::Balances(crate::Event::Slashed { who: 1, amount: 100 }), 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!( assert_eq!(
events(), 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::Endowed { account: 1, free_balance: 100 }),
Event::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }), 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!( assert_eq!(
events(), 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::DustLost { account: 1, amount: 1 }),
Event::Balances(crate::Event::Slashed { who: 1, amount: 1 }) Event::Balances(crate::Event::Slashed { who: 1, amount: 1 })
] ]
+8 -2
View File
@@ -2089,7 +2089,10 @@ mod tests {
System::events(), System::events(),
vec![EventRecord { vec![EventRecord {
phase: Phase::Initialization, 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![], topics: vec![],
},] },]
); );
@@ -2147,7 +2150,10 @@ mod tests {
vec![ vec![
EventRecord { EventRecord {
phase: Phase::Initialization, 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![], topics: vec![],
}, },
EventRecord { EventRecord {
+7 -3
View File
@@ -455,7 +455,9 @@ fn instantiate_and_call_and_deposit_event() {
}, },
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::System(frame_system::Event::NewAccount(ALICE.clone())), event: Event::System(frame_system::Event::NewAccount {
account: ALICE.clone()
}),
topics: vec![], topics: vec![],
}, },
EventRecord { EventRecord {
@@ -468,7 +470,7 @@ fn instantiate_and_call_and_deposit_event() {
}, },
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::System(frame_system::Event::NewAccount(addr.clone())), event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }),
topics: vec![], topics: vec![],
}, },
EventRecord { EventRecord {
@@ -767,7 +769,9 @@ fn self_destruct_works() {
vec![ vec![
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: Event::System(frame_system::Event::KilledAccount(addr.clone())), event: Event::System(frame_system::Event::KilledAccount {
account: addr.clone()
}),
topics: vec![], topics: vec![],
}, },
EventRecord { EventRecord {
@@ -342,7 +342,7 @@ benchmarks! {
let mut reward_events = reporters.clone().into_iter() let mut reward_events = reporters.clone().into_iter()
.flat_map(|reporter| vec![ .flat_map(|reporter| vec![
balance_deposit(reporter.clone(), reward.into()).into(), 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( <T as BalancesConfig>::Event::from(
pallet_balances::Event::<T>::Endowed{account: reporter.clone(), free_balance: reward.into()} pallet_balances::Event::<T>::Endowed{account: reporter.clone(), free_balance: reward.into()}
).into(), ).into(),
+23 -19
View File
@@ -203,12 +203,16 @@ pub mod pallet {
#[pallet::event] #[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> { pub enum Event<T: Config> {
/// Scheduled some task. \[when, index\] /// Scheduled some task.
Scheduled(T::BlockNumber, u32), Scheduled { when: T::BlockNumber, index: u32 },
/// Canceled some task. \[when, index\] /// Canceled some task.
Canceled(T::BlockNumber, u32), Canceled { when: T::BlockNumber, index: u32 },
/// Dispatched some task. \[task, id, result\] /// Dispatched some task.
Dispatched(TaskAddress<T::BlockNumber>, Option<Vec<u8>>, DispatchResult), Dispatched {
task: TaskAddress<T::BlockNumber>,
id: Option<Vec<u8>>,
result: DispatchResult,
},
} }
#[pallet::error] #[pallet::error]
@@ -319,11 +323,11 @@ pub mod pallet {
Lookup::<T>::remove(id); Lookup::<T>::remove(id);
} }
} }
Self::deposit_event(Event::Dispatched( Self::deposit_event(Event::Dispatched {
(now, index), task: (now, index),
maybe_id, id: maybe_id,
r.map(|_| ()).map_err(|e| e.error), result: r.map(|_| ()).map_err(|e| e.error),
)); });
total_weight = cumulative_weight; total_weight = cumulative_weight;
None None
} else { } else {
@@ -563,7 +567,7 @@ impl<T: Config> Pallet<T> {
expected from the runtime configuration. An update might be needed.", 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)) Ok((when, index))
} }
@@ -592,7 +596,7 @@ impl<T: Config> Pallet<T> {
if let Some(id) = s.maybe_id { if let Some(id) = s.maybe_id {
Lookup::<T>::remove(id); Lookup::<T>::remove(id);
} }
Self::deposit_event(Event::Canceled(when, index)); Self::deposit_event(Event::Canceled { when, index });
Ok(()) Ok(())
} else { } else {
Err(Error::<T>::NotFound)? 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; 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::Canceled { when, index });
Self::deposit_event(Event::Scheduled(new_time, new_index)); Self::deposit_event(Event::Scheduled { when: new_time, index: new_index });
Ok((new_time, new_index)) Ok((new_time, new_index))
} }
@@ -663,7 +667,7 @@ impl<T: Config> Pallet<T> {
} }
let address = (when, index); let address = (when, index);
Lookup::<T>::insert(&id, &address); Lookup::<T>::insert(&id, &address);
Self::deposit_event(Event::Scheduled(when, index)); Self::deposit_event(Event::Scheduled { when, index });
Ok(address) Ok(address)
} }
@@ -686,7 +690,7 @@ impl<T: Config> Pallet<T> {
} }
Ok(()) Ok(())
})?; })?;
Self::deposit_event(Event::Canceled(when, index)); Self::deposit_event(Event::Canceled { when, index });
Ok(()) Ok(())
} else { } else {
Err(Error::<T>::NotFound)? 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; 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::Canceled { when, index });
Self::deposit_event(Event::Scheduled(new_time, new_index)); Self::deposit_event(Event::Scheduled { when: new_time, index: new_index });
*lookup = Some((new_time, new_index)); *lookup = Some((new_time, new_index));
+52 -49
View File
@@ -475,42 +475,41 @@ pub mod pallet {
#[pallet::event] #[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> { pub enum Event<T: Config<I>, I: 'static = ()> {
/// The society is founded by the given identity. \[founder\] /// The society is founded by the given identity.
Founded(T::AccountId), Founded { founder: T::AccountId },
/// A membership bid just happened. The given account is the candidate's ID and their offer /// A membership bid just happened. The given account is the candidate's ID and their offer
/// is the second. \[candidate_id, offer\] /// is the second.
Bid(T::AccountId, BalanceOf<T, I>), 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 /// 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, /// their offer is the second. The vouching party is the third.
/// vouching\] Vouch { candidate_id: T::AccountId, offer: BalanceOf<T, I>, vouching: T::AccountId },
Vouch(T::AccountId, BalanceOf<T, I>, T::AccountId), /// A candidate was dropped (due to an excess of bids in the system).
/// A \[candidate\] was dropped (due to an excess of bids in the system). AutoUnbid { candidate: T::AccountId },
AutoUnbid(T::AccountId), /// A candidate was dropped (by their request).
/// A \[candidate\] was dropped (by their request). Unbid { candidate: T::AccountId },
Unbid(T::AccountId), /// A candidate was dropped (by request of who vouched for them).
/// A \[candidate\] was dropped (by request of who vouched for them). Unvouch { candidate: T::AccountId },
Unvouch(T::AccountId),
/// A group of candidates have been inducted. The batch's primary is the first value, the /// A group of candidates have been inducted. The batch's primary is the first value, the
/// batch in full is the second. \[primary, candidates\] /// batch in full is the second.
Inducted(T::AccountId, Vec<T::AccountId>), Inducted { primary: T::AccountId, candidates: Vec<T::AccountId> },
/// A suspended member has been judged. \[who, judged\] /// A suspended member has been judged.
SuspendedMemberJudgement(T::AccountId, bool), SuspendedMemberJudgement { who: T::AccountId, judged: bool },
/// A \[candidate\] has been suspended /// A candidate has been suspended
CandidateSuspended(T::AccountId), CandidateSuspended { candidate: T::AccountId },
/// A \[member\] has been suspended /// A member has been suspended
MemberSuspended(T::AccountId), MemberSuspended { member: T::AccountId },
/// A \[member\] has been challenged /// A member has been challenged
Challenged(T::AccountId), Challenged { member: T::AccountId },
/// A vote has been placed \[candidate, voter, vote\] /// A vote has been placed
Vote(T::AccountId, T::AccountId, bool), Vote { candidate: T::AccountId, voter: T::AccountId, vote: bool },
/// A vote has been placed for a defending member \[voter, vote\] /// A vote has been placed for a defending member
DefenderVote(T::AccountId, bool), DefenderVote { voter: T::AccountId, vote: bool },
/// A new \[max\] member count has been set /// A new \[max\] member count has been set
NewMaxMembers(u32), NewMaxMembers { max: u32 },
/// Society is unfounded. \[founder\] /// Society is unfounded.
Unfounded(T::AccountId), Unfounded { founder: T::AccountId },
/// Some funds were deposited into the society account. \[value\] /// Some funds were deposited into the society account.
Deposit(BalanceOf<T, I>), Deposit { value: BalanceOf<T, I> },
} }
/// Old name generated by `decl_event`. /// Old name generated by `decl_event`.
@@ -729,7 +728,7 @@ pub mod pallet {
T::Currency::reserve(&who, deposit)?; T::Currency::reserve(&who, deposit)?;
Self::put_bid(bids, &who, value.clone(), BidKind::Deposit(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(()) Ok(())
} }
@@ -771,7 +770,7 @@ pub mod pallet {
<Vouching<T, I>>::remove(&voucher); <Vouching<T, I>>::remove(&voucher);
}, },
} }
Self::deposit_event(Event::<T, I>::Unbid(who)); Self::deposit_event(Event::<T, I>::Unbid { candidate: who });
Ok(()) Ok(())
} else { } else {
Err(Error::<T, I>::BadPosition)? Err(Error::<T, I>::BadPosition)?
@@ -849,7 +848,11 @@ pub mod pallet {
<Vouching<T, I>>::insert(&voucher, VouchingStatus::Vouching); <Vouching<T, I>>::insert(&voucher, VouchingStatus::Vouching);
Self::put_bid(bids, &who, value.clone(), BidKind::Vouch(voucher.clone(), tip)); 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(()) Ok(())
} }
@@ -884,7 +887,7 @@ pub mod pallet {
b[pos].kind.check_voucher(&voucher)?; b[pos].kind.check_voucher(&voucher)?;
<Vouching<T, I>>::remove(&voucher); <Vouching<T, I>>::remove(&voucher);
let who = b.remove(pos).who; let who = b.remove(pos).who;
Self::deposit_event(Event::<T, I>::Unvouch(who)); Self::deposit_event(Event::<T, I>::Unvouch { candidate: who });
Ok(()) Ok(())
} else { } else {
Err(Error::<T, I>::BadPosition)? Err(Error::<T, I>::BadPosition)?
@@ -927,7 +930,7 @@ pub mod pallet {
let vote = if approve { Vote::Approve } else { Vote::Reject }; let vote = if approve { Vote::Approve } else { Vote::Reject };
<Votes<T, I>>::insert(&candidate, &voter, vote); <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(()) Ok(())
} }
@@ -956,7 +959,7 @@ pub mod pallet {
let vote = if approve { Vote::Approve } else { Vote::Reject }; let vote = if approve { Vote::Approve } else { Vote::Reject };
<DefenderVotes<T, I>>::insert(&voter, vote); <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(()) Ok(())
} }
@@ -1039,7 +1042,7 @@ pub mod pallet {
<Head<T, I>>::put(&founder); <Head<T, I>>::put(&founder);
<Founder<T, I>>::put(&founder); <Founder<T, I>>::put(&founder);
Rules::<T, I>::put(T::Hashing::hash(&rules)); 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(()) Ok(())
} }
@@ -1068,7 +1071,7 @@ pub mod pallet {
Rules::<T, I>::kill(); Rules::<T, I>::kill();
Candidates::<T, I>::kill(); Candidates::<T, I>::kill();
SuspendedCandidates::<T, I>::remove_all(None); SuspendedCandidates::<T, I>::remove_all(None);
Self::deposit_event(Event::<T, I>::Unfounded(founder)); Self::deposit_event(Event::<T, I>::Unfounded { founder });
Ok(()) Ok(())
} }
@@ -1125,14 +1128,14 @@ pub mod pallet {
if let Some(pos) = bids.iter().position(|b| b.kind.check_voucher(&who).is_ok()) { if let Some(pos) = bids.iter().position(|b| b.kind.check_voucher(&who).is_ok()) {
// Remove the bid, and emit an event // Remove the bid, and emit an event
let vouched = bids.remove(pos).who; 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); <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(()) Ok(())
} }
@@ -1253,7 +1256,7 @@ pub mod pallet {
ensure_root(origin)?; ensure_root(origin)?;
ensure!(max > 1, Error::<T, I>::MaxMembers); ensure!(max > 1, Error::<T, I>::MaxMembers);
MaxMembers::<T, I>::put(max); MaxMembers::<T, I>::put(max);
Self::deposit_event(Event::<T, I>::NewMaxMembers(max)); Self::deposit_event(Event::<T, I>::NewMaxMembers { max });
Ok(()) Ok(())
} }
} }
@@ -1339,7 +1342,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
<Vouching<T, I>>::remove(&voucher); <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); <Bids<T, I>>::put(bids);
@@ -1504,7 +1507,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
} else { } else {
// Suspend Candidate // Suspend Candidate
<SuspendedCandidates<T, I>>::insert(&candidate, (value, kind)); <SuspendedCandidates<T, I>>::insert(&candidate, (value, kind));
Self::deposit_event(Event::<T, I>::CandidateSuspended(candidate)); Self::deposit_event(Event::<T, I>::CandidateSuspended { candidate });
None None
} }
}) })
@@ -1573,7 +1576,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
<Head<T, I>>::put(&primary); <Head<T, I>>::put(&primary);
T::MembershipChanged::change_members_sorted(&accounts, &[], &members); 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 // 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() { if Self::remove_member(&who).is_ok() {
<SuspendedMembers<T, I>>::insert(who, true); <SuspendedMembers<T, I>>::insert(who, true);
<Strikes<T, I>>::remove(who); <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]) let chosen = pick_item(&mut rng, &members[1..members.len() - 1])
.expect("exited if members empty; qed"); .expect("exited if members empty; qed");
<Defender<T, I>>::put(&chosen); <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 { } else {
<Defender<T, I>>::kill(); <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. // Must resolve into existing but better to be safe.
let _ = T::Currency::resolve_creating(&Self::account_id(), amount); 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 { ) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
let hash = T::Hashing::hash(&remark[..]); let hash = T::Hashing::hash(&remark[..]);
Self::deposit_event(Event::Remarked(who, hash)); Self::deposit_event(Event::Remarked { sender: who, hash });
Ok(().into()) Ok(().into())
} }
} }
@@ -466,18 +466,18 @@ pub mod pallet {
/// Event for the System pallet. /// Event for the System pallet.
#[pallet::event] #[pallet::event]
pub enum Event<T: Config> { pub enum Event<T: Config> {
/// An extrinsic completed successfully. \[info\] /// An extrinsic completed successfully.
ExtrinsicSuccess(DispatchInfo), ExtrinsicSuccess { dispatch_info: DispatchInfo },
/// An extrinsic failed. \[error, info\] /// An extrinsic failed.
ExtrinsicFailed(DispatchError, DispatchInfo), ExtrinsicFailed { dispatch_error: DispatchError, dispatch_info: DispatchInfo },
/// `:code` was updated. /// `:code` was updated.
CodeUpdated, CodeUpdated,
/// A new \[account\] was created. /// A new account was created.
NewAccount(T::AccountId), NewAccount { account: T::AccountId },
/// An \[account\] was reaped. /// An account was reaped.
KilledAccount(T::AccountId), KilledAccount { account: T::AccountId },
/// On on-chain remark happened. \[origin, remark_hash\] /// On on-chain remark happened.
Remarked(T::AccountId, T::Hash), Remarked { sender: T::AccountId, hash: T::Hash },
} }
/// Old name generated by `decl_event`. /// 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) { pub fn note_applied_extrinsic(r: &DispatchResultWithPostInfo, mut info: DispatchInfo) {
info.weight = extract_actual_weight(r, &info); info.weight = extract_actual_weight(r, &info);
Self::deposit_event(match r { Self::deposit_event(match r {
Ok(_) => Event::ExtrinsicSuccess(info), Ok(_) => Event::ExtrinsicSuccess { dispatch_info: info },
Err(err) => { Err(err) => {
log::trace!( log::trace!(
target: "runtime::system", target: "runtime::system",
@@ -1494,7 +1494,7 @@ impl<T: Config> Pallet<T> {
Self::block_number(), Self::block_number(),
err, 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. /// An account is being created.
pub fn on_created_account(who: T::AccountId, _a: &mut AccountInfo<T::Index, T::AccountData>) { pub fn on_created_account(who: T::AccountId, _a: &mut AccountInfo<T::Index, T::AccountData>) {
T::OnNewAccount::on_new_account(&who); 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. /// Do anything that needs to be done after an account has been killed.
fn on_killed_account(who: T::AccountId) { fn on_killed_account(who: T::AccountId) {
T::OnKilledAccount::on_killed_account(&who); 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. /// 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::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::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(&Ok(().into()), Default::default());
System::note_applied_extrinsic(&Err(DispatchError::BadOrigin.into()), Default::default()); System::note_applied_extrinsic(&Err(DispatchError::BadOrigin.into()), Default::default());
System::note_finished_extrinsics(); System::note_finished_extrinsics();
System::deposit_event(SysEvent::NewAccount(3)); System::deposit_event(SysEvent::NewAccount { account: 3 });
System::finalize(); System::finalize();
assert_eq!( assert_eq!(
System::events(), System::events(),
vec![ vec![
EventRecord { EventRecord {
phase: Phase::Initialization, phase: Phase::Initialization,
event: SysEvent::NewAccount(32).into(), event: SysEvent::NewAccount { account: 32 }.into(),
topics: vec![], topics: vec![],
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(0), phase: Phase::ApplyExtrinsic(0),
event: SysEvent::KilledAccount(42).into(), event: SysEvent::KilledAccount { account: 42 }.into(),
topics: vec![] topics: vec![]
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(0), phase: Phase::ApplyExtrinsic(0),
event: SysEvent::ExtrinsicSuccess(Default::default()).into(), event: SysEvent::ExtrinsicSuccess { dispatch_info: Default::default() }.into(),
topics: vec![] topics: vec![]
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(1), phase: Phase::ApplyExtrinsic(1),
event: SysEvent::ExtrinsicFailed( event: SysEvent::ExtrinsicFailed {
DispatchError::BadOrigin.into(), dispatch_error: DispatchError::BadOrigin.into(),
Default::default() dispatch_info: Default::default()
) }
.into(), .into(),
topics: vec![] topics: vec![]
}, },
EventRecord { EventRecord {
phase: Phase::Finalization, phase: Phase::Finalization,
event: SysEvent::NewAccount(3).into(), event: SysEvent::NewAccount { account: 3 }.into(),
topics: vec![] topics: vec![]
}, },
] ]
@@ -234,37 +234,34 @@ fn deposit_event_uses_actual_weight() {
vec![ vec![
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(0), phase: Phase::ApplyExtrinsic(0),
event: SysEvent::ExtrinsicSuccess(DispatchInfo { event: SysEvent::ExtrinsicSuccess {
weight: 300, dispatch_info: DispatchInfo { weight: 300, ..Default::default() },
..Default::default() }
},)
.into(), .into(),
topics: vec![] topics: vec![]
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(1), phase: Phase::ApplyExtrinsic(1),
event: SysEvent::ExtrinsicSuccess(DispatchInfo { event: SysEvent::ExtrinsicSuccess {
weight: 1000, dispatch_info: DispatchInfo { weight: 1000, ..Default::default() },
..Default::default() }
},)
.into(), .into(),
topics: vec![] topics: vec![]
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(2), phase: Phase::ApplyExtrinsic(2),
event: SysEvent::ExtrinsicSuccess(DispatchInfo { event: SysEvent::ExtrinsicSuccess {
weight: 1000, dispatch_info: DispatchInfo { weight: 1000, ..Default::default() },
..Default::default() }
},)
.into(), .into(),
topics: vec![] topics: vec![]
}, },
EventRecord { EventRecord {
phase: Phase::ApplyExtrinsic(3), phase: Phase::ApplyExtrinsic(3),
event: SysEvent::ExtrinsicFailed( event: SysEvent::ExtrinsicFailed {
DispatchError::BadOrigin.into(), dispatch_error: DispatchError::BadOrigin.into(),
DispatchInfo { weight: 999, ..Default::default() }, dispatch_info: DispatchInfo { weight: 999, ..Default::default() },
) }
.into(), .into(),
topics: vec![] 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)]; 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. // 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..3], SysEvent::NewAccount { account: 1 }.into());
System::deposit_event_indexed(&topics[0..1], SysEvent::NewAccount(2).into()); System::deposit_event_indexed(&topics[0..1], SysEvent::NewAccount { account: 2 }.into());
System::deposit_event_indexed(&topics[1..2], SysEvent::NewAccount(3).into()); System::deposit_event_indexed(&topics[1..2], SysEvent::NewAccount { account: 3 }.into());
System::finalize(); System::finalize();
@@ -296,17 +293,17 @@ fn deposit_event_topics() {
vec![ vec![
EventRecord { EventRecord {
phase: Phase::Finalization, phase: Phase::Finalization,
event: SysEvent::NewAccount(1).into(), event: SysEvent::NewAccount { account: 1 }.into(),
topics: topics[0..3].to_vec(), topics: topics[0..3].to_vec(),
}, },
EventRecord { EventRecord {
phase: Phase::Finalization, phase: Phase::Finalization,
event: SysEvent::NewAccount(2).into(), event: SysEvent::NewAccount { account: 2 }.into(),
topics: topics[0..1].to_vec(), topics: topics[0..1].to_vec(),
}, },
EventRecord { EventRecord {
phase: Phase::Finalization, phase: Phase::Finalization,
event: SysEvent::NewAccount(3).into(), event: SysEvent::NewAccount { account: 3 }.into(),
topics: topics[1..2].to_vec(), topics: topics[1..2].to_vec(),
} }
] ]
@@ -1369,7 +1369,9 @@ mod tests {
amount: 80, amount: 80,
})); }));
// Killed Event // 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]) }: _(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize])
verify { verify {
assert!(!BlockTransactions::<T>::get().is_empty()); assert!(!BlockTransactions::<T>::get().is_empty());
assert_last_event::<T>(Event::Stored(0).into()); assert_last_event::<T>(Event::Stored { index: 0 }.into());
} }
renew { renew {
@@ -122,7 +122,7 @@ benchmarks! {
run_to_block::<T>(1u32.into()); run_to_block::<T>(1u32.into());
}: _(RawOrigin::Signed(caller.clone()), T::BlockNumber::zero(), 0) }: _(RawOrigin::Signed(caller.clone()), T::BlockNumber::zero(), 0)
verify { verify {
assert_last_event::<T>(Event::Renewed(0).into()); assert_last_event::<T>(Event::Renewed { index: 0 }.into());
} }
check_proof_max { check_proof_max {
@@ -210,7 +210,7 @@ pub mod pallet {
}); });
Ok(()) Ok(())
})?; })?;
Self::deposit_event(Event::Stored(index)); Self::deposit_event(Event::Stored { index });
Ok(()) Ok(())
} }
@@ -251,7 +251,7 @@ pub mod pallet {
}); });
Ok(()) Ok(())
})?; })?;
Self::deposit_event(Event::Renewed(index)); Self::deposit_event(Event::Renewed { index });
Ok(().into()) Ok(().into())
} }
@@ -313,9 +313,9 @@ pub mod pallet {
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> { pub enum Event<T: Config> {
/// Stored data under specified index. /// Stored data under specified index.
Stored(u32), Stored { index: u32 },
/// Renewed data under specified index. /// Renewed data under specified index.
Renewed(u32), Renewed { index: u32 },
/// Storage proof was successfully checked. /// Storage proof was successfully checked.
ProofChecked, ProofChecked,
} }
+27 -21
View File
@@ -255,21 +255,20 @@ pub mod pallet {
#[pallet::event] #[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config<I>, I: 'static = ()> { pub enum Event<T: Config<I>, I: 'static = ()> {
/// New proposal. \[proposal_index\] /// New proposal.
Proposed(ProposalIndex), Proposed { proposal_index: ProposalIndex },
/// We have ended a spend period and will now allocate funds. \[budget_remaining\] /// We have ended a spend period and will now allocate funds.
Spending(BalanceOf<T, I>), Spending { budget_remaining: BalanceOf<T, I> },
/// Some funds have been allocated. \[proposal_index, award, beneficiary\] /// Some funds have been allocated.
Awarded(ProposalIndex, BalanceOf<T, I>, T::AccountId), Awarded { proposal_index: ProposalIndex, award: BalanceOf<T, I>, account: T::AccountId },
/// A proposal was rejected; funds were slashed. \[proposal_index, slashed\] /// A proposal was rejected; funds were slashed.
Rejected(ProposalIndex, BalanceOf<T, I>), Rejected { proposal_index: ProposalIndex, slashed: BalanceOf<T, I> },
/// Some of our funds have been burnt. \[burn\] /// Some of our funds have been burnt.
Burnt(BalanceOf<T, I>), Burnt { burnt_funds: BalanceOf<T, I> },
/// Spending has finished; this is the amount that rolls over until next spend. /// Spending has finished; this is the amount that rolls over until next spend.
/// \[budget_remaining\] Rollover { rollover_balance: BalanceOf<T, I> },
Rollover(BalanceOf<T, I>), /// Some funds have been deposited.
/// Some funds have been deposited. \[deposit\] Deposit { value: BalanceOf<T, I> },
Deposit(BalanceOf<T, I>),
} }
/// Old name generated by `decl_event`. /// Old name generated by `decl_event`.
@@ -334,7 +333,7 @@ pub mod pallet {
<ProposalCount<T, I>>::put(c + 1); <ProposalCount<T, I>>::put(c + 1);
<Proposals<T, I>>::insert(c, Proposal { proposer, value, beneficiary, bond }); <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(()) Ok(())
} }
@@ -360,7 +359,10 @@ pub mod pallet {
let imbalance = T::Currency::slash_reserved(&proposal.proposer, value).0; let imbalance = T::Currency::slash_reserved(&proposal.proposer, value).0;
T::OnSlash::on_unbalanced(imbalance); 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(()) Ok(())
} }
@@ -410,7 +412,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let mut total_weight: Weight = Zero::zero(); let mut total_weight: Weight = Zero::zero();
let mut budget_remaining = Self::pot(); 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 account_id = Self::account_id();
let mut missed_any = false; let mut missed_any = false;
@@ -431,7 +433,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
// provide the allocation. // provide the allocation.
imbalance.subsume(T::Currency::deposit_creating(&p.beneficiary, p.value)); 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 false
} else { } else {
missed_any = true; missed_any = true;
@@ -462,7 +468,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
let (debit, credit) = T::Currency::pair(burn); let (debit, credit) = T::Currency::pair(burn);
imbalance.subsume(debit); imbalance.subsume(debit);
T::BurnDestination::on_unbalanced(credit); 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. // 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); drop(problem);
} }
Self::deposit_event(Event::Rollover(budget_remaining)); Self::deposit_event(Event::Rollover { rollover_balance: budget_remaining });
total_weight 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. // Must resolve into existing but better to be safe.
let _ = T::Currency::resolve_creating(&Self::account_id(), amount); 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, BatchCompleted,
/// A single item within a Batch of dispatches has completed with no error. /// A single item within a Batch of dispatches has completed with no error.
ItemCompleted, ItemCompleted,
/// A call was dispatched. \[result\] /// A call was dispatched.
DispatchedAs(DispatchResult), DispatchedAs { result: DispatchResult },
} }
// Align the call size to 1KB. As we are currently compiling the runtime for native/wasm // 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()); 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(()) Ok(())
} }
} }