mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-19 22:45:40 +00:00
BREAKING: Rename Call & Event (#11981)
* rename Event to RuntimeEvent * rename Call * rename in runtimes * small fix * rename Event * small fix & rename RuntimeCall back to Call for now * small fixes * more renaming * a bit more renaming * fmt * small fix * commit * prep for renaming associated types * fix * rename associated Event type * rename to RuntimeEvent * commit * merge conflict fixes & fmt * additional renaming * fix. * fix decl_event * rename in tests * remove warnings * remove accidental rename * . * commit * update .stderr * fix in test * update .stderr * TRYBUILD=overwrite * docs * fmt * small change in docs * rename PalletEvent to Event * rename Call to RuntimeCall * renamed at wrong places :P * rename Call * rename * rename associated type * fix * fix & fmt * commit * frame-support-test * passing tests * update docs * rustdoc fix * update .stderr * wrong code in docs * merge fix * fix in error message * update .stderr * docs & error message * . * merge fix * merge fix * fmt * fmt * merge fix * more fixing * fmt * remove unused * fmt * fix Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
This commit is contained in:
@@ -218,7 +218,8 @@ pub mod pallet {
|
||||
type DustRemoval: OnUnbalanced<NegativeImbalance<Self, I>>;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self, I>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
type RuntimeEvent: From<Event<Self, I>>
|
||||
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The minimum amount required to keep an account open.
|
||||
#[pallet::constant]
|
||||
|
||||
@@ -38,15 +38,15 @@ macro_rules! decl_tests {
|
||||
const ID_1: LockIdentifier = *b"1 ";
|
||||
const ID_2: LockIdentifier = *b"2 ";
|
||||
|
||||
pub const CALL: &<$test as frame_system::Config>::Call =
|
||||
&Call::Balances(pallet_balances::Call::transfer { dest: 0, value: 0 });
|
||||
pub const CALL: &<$test as frame_system::Config>::RuntimeCall =
|
||||
&RuntimeCall::Balances(pallet_balances::Call::transfer { dest: 0, value: 0 });
|
||||
|
||||
/// create a transaction info struct from weight. Handy to avoid building the whole struct.
|
||||
pub fn info_from_weight(w: Weight) -> DispatchInfo {
|
||||
DispatchInfo { weight: w, ..Default::default() }
|
||||
}
|
||||
|
||||
fn events() -> Vec<Event> {
|
||||
fn events() -> Vec<RuntimeEvent> {
|
||||
let evt = System::events().into_iter().map(|evt| evt.event).collect::<Vec<_>>();
|
||||
|
||||
System::reset_events();
|
||||
@@ -314,7 +314,7 @@ macro_rules! decl_tests {
|
||||
<$ext_builder>::default().monied(true).build().execute_with(|| {
|
||||
assert_eq!(Balances::total_balance(&1), 10);
|
||||
assert_ok!(Balances::deposit_into_existing(&1, 10).map(drop));
|
||||
System::assert_last_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 10 }));
|
||||
System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 10 }));
|
||||
assert_eq!(Balances::total_balance(&1), 20);
|
||||
assert_eq!(<TotalIssuance<$test>>::get(), 120);
|
||||
});
|
||||
@@ -342,7 +342,7 @@ macro_rules! decl_tests {
|
||||
fn balance_works() {
|
||||
<$ext_builder>::default().build().execute_with(|| {
|
||||
let _ = Balances::deposit_creating(&1, 42);
|
||||
System::assert_has_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 42 }));
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 42 }));
|
||||
assert_eq!(Balances::free_balance(1), 42);
|
||||
assert_eq!(Balances::reserved_balance(1), 0);
|
||||
assert_eq!(Balances::total_balance(&1), 42);
|
||||
@@ -444,7 +444,7 @@ macro_rules! decl_tests {
|
||||
let _ = Balances::withdraw(
|
||||
&2, 11, WithdrawReasons::TRANSFER, ExistenceRequirement::KeepAlive
|
||||
);
|
||||
System::assert_last_event(Event::Balances(crate::Event::Withdraw { who: 2, amount: 11 }));
|
||||
System::assert_last_event(RuntimeEvent::Balances(crate::Event::Withdraw { who: 2, amount: 11 }));
|
||||
assert_eq!(Balances::free_balance(2), 100);
|
||||
assert_eq!(<TotalIssuance<$test>>::get(), 100);
|
||||
});
|
||||
@@ -505,7 +505,7 @@ macro_rules! decl_tests {
|
||||
assert_ok!(Balances::reserve(&1, 110));
|
||||
assert_ok!(Balances::repatriate_reserved(&1, &2, 41, Status::Free), 0);
|
||||
System::assert_last_event(
|
||||
Event::Balances(crate::Event::ReserveRepatriated { from: 1, to: 2, amount: 41, destination_status: Status::Free })
|
||||
RuntimeEvent::Balances(crate::Event::ReserveRepatriated { from: 1, to: 2, amount: 41, destination_status: Status::Free })
|
||||
);
|
||||
assert_eq!(Balances::reserved_balance(1), 69);
|
||||
assert_eq!(Balances::free_balance(1), 0);
|
||||
@@ -740,18 +740,18 @@ macro_rules! decl_tests {
|
||||
System::set_block_number(2);
|
||||
assert_ok!(Balances::reserve(&1, 10));
|
||||
|
||||
System::assert_last_event(Event::Balances(crate::Event::Reserved { who: 1, amount: 10 }));
|
||||
System::assert_last_event(RuntimeEvent::Balances(crate::Event::Reserved { who: 1, amount: 10 }));
|
||||
|
||||
System::set_block_number(3);
|
||||
assert!(Balances::unreserve(&1, 5).is_zero());
|
||||
|
||||
System::assert_last_event(Event::Balances(crate::Event::Unreserved { who: 1, amount: 5 }));
|
||||
System::assert_last_event(RuntimeEvent::Balances(crate::Event::Unreserved { who: 1, amount: 5 }));
|
||||
|
||||
System::set_block_number(4);
|
||||
assert_eq!(Balances::unreserve(&1, 6), 1);
|
||||
|
||||
// should only unreserve 5
|
||||
System::assert_last_event(Event::Balances(crate::Event::Unreserved { who: 1, amount: 5 }));
|
||||
System::assert_last_event(RuntimeEvent::Balances(crate::Event::Unreserved { who: 1, amount: 5 }));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -766,9 +766,9 @@ macro_rules! decl_tests {
|
||||
assert_eq!(
|
||||
events(),
|
||||
[
|
||||
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 }),
|
||||
RuntimeEvent::System(system::Event::NewAccount { account: 1 }),
|
||||
RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }),
|
||||
RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -778,9 +778,9 @@ macro_rules! decl_tests {
|
||||
assert_eq!(
|
||||
events(),
|
||||
[
|
||||
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 }),
|
||||
RuntimeEvent::System(system::Event::KilledAccount { account: 1 }),
|
||||
RuntimeEvent::Balances(crate::Event::DustLost { account: 1, amount: 99 }),
|
||||
RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 1 }),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -797,9 +797,9 @@ macro_rules! decl_tests {
|
||||
assert_eq!(
|
||||
events(),
|
||||
[
|
||||
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 }),
|
||||
RuntimeEvent::System(system::Event::NewAccount { account: 1 }),
|
||||
RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }),
|
||||
RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -809,8 +809,8 @@ macro_rules! decl_tests {
|
||||
assert_eq!(
|
||||
events(),
|
||||
[
|
||||
Event::System(system::Event::KilledAccount { account: 1 }),
|
||||
Event::Balances(crate::Event::Slashed { who: 1, amount: 100 }),
|
||||
RuntimeEvent::System(system::Event::KilledAccount { account: 1 }),
|
||||
RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 100 }),
|
||||
]
|
||||
);
|
||||
});
|
||||
@@ -830,7 +830,7 @@ macro_rules! decl_tests {
|
||||
assert_eq!(Balances::slash(&1, 900), (NegativeImbalance::new(900), 0));
|
||||
// Account is still alive
|
||||
assert!(System::account_exists(&1));
|
||||
System::assert_last_event(Event::Balances(crate::Event::Slashed { who: 1, amount: 900 }));
|
||||
System::assert_last_event(RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 900 }));
|
||||
|
||||
// SCENARIO: Slash will kill account because not enough balance left.
|
||||
assert_ok!(Balances::set_balance(Origin::root(), 1, 1_000, 0));
|
||||
|
||||
@@ -57,13 +57,13 @@ impl frame_system::Config for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Call = Call;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Hash = H256;
|
||||
type Hashing = ::sp_runtime::traits::BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = ConstU64<250>;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
@@ -77,7 +77,7 @@ impl frame_system::Config for Test {
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Test {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
|
||||
type OperationalFeeMultiplier = ConstU8<5>;
|
||||
type WeightToFee = IdentityFee<u64>;
|
||||
@@ -88,7 +88,7 @@ impl pallet_transaction_payment::Config for Test {
|
||||
impl Config for Test {
|
||||
type Balance = u64;
|
||||
type DustRemoval = ();
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = frame_system::Pallet<Test>;
|
||||
type MaxLocks = ();
|
||||
|
||||
@@ -58,13 +58,13 @@ impl frame_system::Config for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Call = Call;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Hash = H256;
|
||||
type Hashing = ::sp_runtime::traits::BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = ConstU64<250>;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
@@ -78,7 +78,7 @@ impl frame_system::Config for Test {
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Test {
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type OnChargeTransaction = CurrencyAdapter<Pallet<Test>, ()>;
|
||||
type OperationalFeeMultiplier = ConstU8<5>;
|
||||
type WeightToFee = IdentityFee<u64>;
|
||||
@@ -89,7 +89,7 @@ impl pallet_transaction_payment::Config for Test {
|
||||
impl Config for Test {
|
||||
type Balance = u64;
|
||||
type DustRemoval = ();
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore =
|
||||
StorageMapShim<super::Account<Test>, system::Provider<Test>, u64, super::AccountData<u64>>;
|
||||
@@ -158,9 +158,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() {
|
||||
assert_eq!(
|
||||
events(),
|
||||
[
|
||||
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 }),
|
||||
RuntimeEvent::System(system::Event::NewAccount { account: 1 }),
|
||||
RuntimeEvent::Balances(crate::Event::Endowed { account: 1, free_balance: 100 }),
|
||||
RuntimeEvent::Balances(crate::Event::BalanceSet { who: 1, free: 100, reserved: 0 }),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -168,7 +168,10 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() {
|
||||
assert_eq!(res, (NegativeImbalance::new(98), 0));
|
||||
|
||||
// no events
|
||||
assert_eq!(events(), [Event::Balances(crate::Event::Slashed { who: 1, amount: 98 })]);
|
||||
assert_eq!(
|
||||
events(),
|
||||
[RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 98 })]
|
||||
);
|
||||
|
||||
let res = Balances::slash(&1, 1);
|
||||
assert_eq!(res, (NegativeImbalance::new(1), 0));
|
||||
@@ -176,9 +179,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() {
|
||||
assert_eq!(
|
||||
events(),
|
||||
[
|
||||
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 })
|
||||
RuntimeEvent::System(system::Event::KilledAccount { account: 1 }),
|
||||
RuntimeEvent::Balances(crate::Event::DustLost { account: 1, amount: 1 }),
|
||||
RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 1 })
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
@@ -62,13 +62,13 @@ impl frame_system::Config for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Call = Call;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type Hash = H256;
|
||||
type Hashing = ::sp_runtime::traits::BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type BlockHashCount = ConstU64<250>;
|
||||
type Version = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
@@ -91,7 +91,7 @@ impl OnUnbalanced<NegativeImbalance<Test>> for OnDustRemoval {
|
||||
impl Config for Test {
|
||||
type Balance = u64;
|
||||
type DustRemoval = OnDustRemoval;
|
||||
type Event = Event;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore =
|
||||
StorageMapShim<super::Account<Test>, system::Provider<Test>, u64, super::AccountData<u64>>;
|
||||
@@ -157,16 +157,19 @@ fn transfer_dust_removal_tst1_should_work() {
|
||||
// Verify the events
|
||||
assert_eq!(System::events().len(), 12);
|
||||
|
||||
System::assert_has_event(Event::Balances(crate::Event::Transfer {
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer {
|
||||
from: 2,
|
||||
to: 3,
|
||||
amount: 450,
|
||||
}));
|
||||
System::assert_has_event(Event::Balances(crate::Event::DustLost {
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost {
|
||||
account: 2,
|
||||
amount: 50,
|
||||
}));
|
||||
System::assert_has_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 50 }));
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit {
|
||||
who: 1,
|
||||
amount: 50,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -192,16 +195,19 @@ fn transfer_dust_removal_tst2_should_work() {
|
||||
// Verify the events
|
||||
assert_eq!(System::events().len(), 10);
|
||||
|
||||
System::assert_has_event(Event::Balances(crate::Event::Transfer {
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer {
|
||||
from: 2,
|
||||
to: 1,
|
||||
amount: 450,
|
||||
}));
|
||||
System::assert_has_event(Event::Balances(crate::Event::DustLost {
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost {
|
||||
account: 2,
|
||||
amount: 50,
|
||||
}));
|
||||
System::assert_has_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 50 }));
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit {
|
||||
who: 1,
|
||||
amount: 50,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -236,18 +242,21 @@ fn repatriating_reserved_balance_dust_removal_should_work() {
|
||||
// Verify the events
|
||||
assert_eq!(System::events().len(), 11);
|
||||
|
||||
System::assert_has_event(Event::Balances(crate::Event::ReserveRepatriated {
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::ReserveRepatriated {
|
||||
from: 2,
|
||||
to: 1,
|
||||
amount: 450,
|
||||
destination_status: Status::Free,
|
||||
}));
|
||||
|
||||
System::assert_has_event(Event::Balances(crate::Event::DustLost {
|
||||
System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost {
|
||||
account: 2,
|
||||
amount: 50,
|
||||
}));
|
||||
|
||||
System::assert_last_event(Event::Balances(crate::Event::Deposit { who: 1, amount: 50 }));
|
||||
System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit {
|
||||
who: 1,
|
||||
amount: 50,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user