diff --git a/bin/node/executor/tests/fees.rs b/bin/node/executor/tests/fees.rs index 379cdda5b76a3..4c7593bdb3ab2 100644 --- a/bin/node/executor/tests/fees.rs +++ b/bin/node/executor/tests/fees.rs @@ -241,7 +241,10 @@ fn block_weight_capacity_report() { let mut xts = (0..num_transfers) .map(|i| CheckedExtrinsic { signed: Some((charlie(), signed_extra(nonce + i as Index, 0))), - function: Call::Balances(pallet_balances::Call::transfer(bob().into(), 0)), + function: Call::Balances(pallet_balances::Call::transfer { + dest: bob().into(), + value: 0, + }), }) .collect::>(); @@ -249,7 +252,7 @@ fn block_weight_capacity_report() { 0, CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }), }, ); @@ -319,7 +322,7 @@ fn block_length_capacity_report() { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set(time * 1000)), + function: Call::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(nonce, 0))), diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 427455849bb00..5f8e6fc0cc13a 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -150,7 +150,7 @@ pub mod pallet { ensure!(sender == Self::key(), Error::::RequireSudo); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - Self::deposit_event(Event::Sudid(res.map(|_| ()).map_err(|e| e.error))); + Self::deposit_event(Event::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) }); // Sudo user does not pay a fee. Ok(Pays::No.into()) } @@ -176,7 +176,7 @@ pub mod pallet { ensure!(sender == Self::key(), Error::::RequireSudo); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - Self::deposit_event(Event::Sudid(res.map(|_| ()).map_err(|e| e.error))); + Self::deposit_event(Event::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) }); // Sudo user does not pay a fee. Ok(Pays::No.into()) } @@ -201,7 +201,7 @@ pub mod pallet { ensure!(sender == Self::key(), Error::::RequireSudo); let new = T::Lookup::lookup(new)?; - Self::deposit_event(Event::KeyChanged(Self::key())); + Self::deposit_event(Event::KeyChanged { new_sudoer: Self::key() }); >::put(new); // Sudo user does not pay a fee. Ok(Pays::No.into()) @@ -241,7 +241,9 @@ pub mod pallet { let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Signed(who).into()); - Self::deposit_event(Event::SudoAsDone(res.map(|_| ()).map_err(|e| e.error))); + Self::deposit_event(Event::SudoAsDone { + sudo_result: res.map(|_| ()).map_err(|e| e.error), + }); // Sudo user does not pay a fee. Ok(Pays::No.into()) } @@ -251,11 +253,11 @@ pub mod pallet { #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { /// A sudo just took place. \[result\] - Sudid(DispatchResult), + Sudid { sudo_result: DispatchResult }, /// The \[sudoer\] just switched identity; the old key is supplied. - KeyChanged(T::AccountId), + KeyChanged { new_sudoer: T::AccountId }, /// A sudo just took place. \[result\] - SudoAsDone(DispatchResult), + SudoAsDone { sudo_result: DispatchResult }, } #[pallet::error] diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index dad17384d5603..bfbed0d38ab34 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -58,7 +58,7 @@ pub mod logger { // Ensure that the `origin` is `Root`. ensure_root(origin)?; >::append(i); - Self::deposit_event(Event::AppendI32(i, weight)); + Self::deposit_event(Event::AppendI32 { value: i, weight }); Ok(().into()) } @@ -72,7 +72,7 @@ pub mod logger { let sender = ensure_signed(origin)?; >::append(i); >::append(sender.clone()); - Self::deposit_event(Event::AppendI32AndAccount(sender, i, weight)); + Self::deposit_event(Event::AppendI32AndAccount { sender, value: i, weight }); Ok(().into()) } } @@ -80,8 +80,8 @@ pub mod logger { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - AppendI32(i32, Weight), - AppendI32AndAccount(T::AccountId, i32, Weight), + AppendI32 { value: i32, weight: Weight }, + AppendI32AndAccount { sender: T::AccountId, value: i32, weight: Weight }, } #[pallet::storage] diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index 2eb558e9471c4..3fd199a1c8ca3 100644 --- a/frame/sudo/src/tests.rs +++ b/frame/sudo/src/tests.rs @@ -58,7 +58,7 @@ fn sudo_emits_events_correctly() { // Should emit event to indicate success when called with the root `key` and `call` is `Ok`. let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); assert_ok!(Sudo::sudo(Origin::signed(1), call)); - System::assert_has_event(TestEvent::Sudo(Event::Sudid(Ok(())))); + System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) })); }) } @@ -96,7 +96,7 @@ fn sudo_unchecked_weight_emits_events_correctly() { // Should emit event to indicate success when called with the root `key` and `call` is `Ok`. let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); assert_ok!(Sudo::sudo_unchecked_weight(Origin::signed(1), call, 1_000)); - System::assert_has_event(TestEvent::Sudo(Event::Sudid(Ok(())))); + System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) })); }) } @@ -123,10 +123,10 @@ fn set_key_emits_events_correctly() { // A root `key` can change the root `key`. assert_ok!(Sudo::set_key(Origin::signed(1), 2)); - System::assert_has_event(TestEvent::Sudo(Event::KeyChanged(1))); + System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { new_sudoer: 1 })); // Double check. assert_ok!(Sudo::set_key(Origin::signed(2), 4)); - System::assert_has_event(TestEvent::Sudo(Event::KeyChanged(2))); + System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { new_sudoer: 2 })); }); } @@ -161,6 +161,6 @@ fn sudo_as_emits_events_correctly() { // A non-privileged function will work when passed to `sudo_as` with the root `key`. let call = Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); - System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone(Ok(())))); + System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone { sudo_result: Ok(()) })); }); } diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index f4a4edb7b3999..5aad9af346603 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -179,16 +179,16 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - /// A new tip suggestion has been opened. \[tip_hash\] - NewTip(T::Hash), - /// A tip suggestion has reached threshold and is closing. \[tip_hash\] - TipClosing(T::Hash), - /// A tip suggestion has been closed. \[tip_hash, who, payout\] - TipClosed(T::Hash, T::AccountId, BalanceOf), - /// A tip suggestion has been retracted. \[tip_hash\] - TipRetracted(T::Hash), - /// A tip suggestion has been slashed. \[tip_hash, finder, deposit\] - TipSlashed(T::Hash, T::AccountId, BalanceOf), + /// A new tip suggestion has been opened. + NewTip { tip_hash: T::Hash }, + /// A tip suggestion has reached threshold and is closing. + TipClosing { tip_hash: T::Hash }, + /// A tip suggestion has been closed. + TipClosed { tip_hash: T::Hash, who: T::AccountId, payout: BalanceOf }, + /// A tip suggestion has been retracted. + TipRetracted { tip_hash: T::Hash }, + /// A tip suggestion has been slashed. + TipSlashed { tip_hash: T::Hash, finder: T::AccountId, deposit: BalanceOf }, } /// Old name generated by `decl_event`. @@ -265,7 +265,7 @@ pub mod pallet { finders_fee: true, }; Tips::::insert(&hash, tip); - Self::deposit_event(Event::NewTip(hash)); + Self::deposit_event(Event::NewTip { tip_hash: hash }); Ok(()) } @@ -300,7 +300,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&who, tip.deposit); debug_assert!(err_amount.is_zero()); } - Self::deposit_event(Event::TipRetracted(hash)); + Self::deposit_event(Event::TipRetracted { tip_hash: hash }); Ok(()) } @@ -340,7 +340,7 @@ pub mod pallet { let hash = T::Hashing::hash_of(&(&reason_hash, &who)); Reasons::::insert(&reason_hash, &reason); - Self::deposit_event(Event::NewTip(hash.clone())); + Self::deposit_event(Event::NewTip { tip_hash: hash.clone() }); let tips = vec![(tipper.clone(), tip_value)]; let tip = OpenTip { reason: reason_hash, @@ -390,7 +390,7 @@ pub mod pallet { let mut tip = Tips::::get(hash).ok_or(Error::::UnknownTip)?; if Self::insert_tip_and_check_closing(&mut tip, tipper, tip_value) { - Self::deposit_event(Event::TipClosing(hash.clone())); + Self::deposit_event(Event::TipClosing { tip_hash: hash.clone() }); } Tips::::insert(&hash, tip); Ok(()) @@ -449,7 +449,11 @@ pub mod pallet { T::OnSlash::on_unbalanced(imbalance); } Reasons::::remove(&tip.reason); - Self::deposit_event(Event::TipSlashed(hash, tip.finder, tip.deposit)); + Self::deposit_event(Event::TipSlashed { + tip_hash: hash, + finder: tip.finder, + deposit: tip.deposit, + }); Ok(()) } } @@ -544,7 +548,7 @@ impl Pallet { // same as above: best-effort only. let res = T::Currency::transfer(&treasury, &tip.who, payout, KeepAlive); debug_assert!(res.is_ok()); - Self::deposit_event(Event::TipClosed(hash, tip.who, payout)); + Self::deposit_event(Event::TipClosed { tip_hash: hash, who: tip.who, payout }); } pub fn migrate_retract_tip_for_tip_new(module: &[u8], item: &[u8]) { diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 7ea80d78c5532..2aac22ffe18ca 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -267,7 +267,7 @@ fn close_tip_works() { let h = tip_hash(); - assert_eq!(last_event(), TipEvent::NewTip(h)); + assert_eq!(last_event(), TipEvent::NewTip { tip_hash: h }); assert_ok!(Tips::tip(Origin::signed(11), h.clone(), 10)); @@ -275,7 +275,7 @@ fn close_tip_works() { assert_ok!(Tips::tip(Origin::signed(12), h.clone(), 10)); - assert_eq!(last_event(), TipEvent::TipClosing(h)); + assert_eq!(last_event(), TipEvent::TipClosing { tip_hash: h }); assert_noop!(Tips::close_tip(Origin::signed(0), h.into()), Error::::Premature); @@ -284,7 +284,7 @@ fn close_tip_works() { assert_ok!(Tips::close_tip(Origin::signed(0), h.into())); assert_eq!(Balances::free_balance(3), 10); - assert_eq!(last_event(), TipEvent::TipClosed(h, 3, 10)); + assert_eq!(last_event(), TipEvent::TipClosed { tip_hash: h, who: 3, payout: 10 }); assert_noop!(Tips::close_tip(Origin::signed(100), h.into()), Error::::UnknownTip); }); @@ -306,14 +306,14 @@ fn slash_tip_works() { assert_eq!(Balances::free_balance(0), 88); let h = tip_hash(); - assert_eq!(last_event(), TipEvent::NewTip(h)); + assert_eq!(last_event(), TipEvent::NewTip { tip_hash: h }); // can't remove from any origin assert_noop!(Tips::slash_tip(Origin::signed(0), h.clone()), BadOrigin); // can remove from root. assert_ok!(Tips::slash_tip(Origin::root(), h.clone())); - assert_eq!(last_event(), TipEvent::TipSlashed(h, 0, 12)); + assert_eq!(last_event(), TipEvent::TipSlashed { tip_hash: h, finder: 0, deposit: 12 }); // tipper slashed assert_eq!(Balances::reserved_balance(0), 0); diff --git a/utils/frame/remote-externalities/Cargo.toml b/utils/frame/remote-externalities/Cargo.toml index f2482f9c423db..56f797343c0f4 100644 --- a/utils/frame/remote-externalities/Cargo.toml +++ b/utils/frame/remote-externalities/Cargo.toml @@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] jsonrpsee = { version = "0.4.1", features = ["ws-client", "macros"] } env_logger = "0.9" +frame-support = { path = "../../../frame/support", optional = true } log = "0.4.11" codec = { package = "parity-scale-codec", version = "2.0.0" } serde_json = "1.0" @@ -32,4 +33,4 @@ pallet-elections-phragmen = { path = "../../../frame/elections-phragmen", versio frame-support = { path = "../../../frame/support", version = "4.0.0-dev" } [features] -remote-test = [] +remote-test = ["frame-support"]