From af009b3ca095770d35a0f080bc2d07804edc0517 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 5 Aug 2022 08:56:16 +0200 Subject: [PATCH 01/63] rename Event to RuntimeEvent --- bin/node-template/runtime/src/lib.rs | 12 +-- bin/node/runtime/src/lib.rs | 92 +++++++++---------- frame/bags-list/src/mock.rs | 4 +- .../src/construct_runtime/expand/event.rs | 8 +- frame/support/test/compile_pass/src/lib.rs | 2 +- 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index a2f595f571a90..6deaf5d222c35 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -170,7 +170,7 @@ impl frame_system::Config for Runtime { /// The header type. type Header = generic::Header; /// The ubiquitous event type. - type Event = Event; + type Event = RuntimeEvent; /// The ubiquitous origin type. type Origin = Origin; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). @@ -207,7 +207,7 @@ impl pallet_aura::Config for Runtime { } impl pallet_grandpa::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type KeyOwnerProofSystem = (); @@ -244,7 +244,7 @@ impl pallet_balances::Config for Runtime { /// The type for recording an account's balance. type Balance = Balance; /// The ubiquitous event type. - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU128; type AccountStore = System; @@ -252,7 +252,7 @@ impl pallet_balances::Config for Runtime { } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; @@ -261,13 +261,13 @@ impl pallet_transaction_payment::Config for Runtime { } impl pallet_sudo::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; } /// Configure the pallet-template in pallets/template. impl pallet_template::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 037211155cf0e..e796f41024ae5 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -213,7 +213,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = Indices; type Header = generic::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; type PalletInfo = PalletInfo; @@ -229,7 +229,7 @@ impl frame_system::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_utility::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = pallet_utility::weights::SubstrateWeight; @@ -243,7 +243,7 @@ parameter_types! { } impl pallet_multisig::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type Currency = Balances; type DepositBase = DepositBase; @@ -319,7 +319,7 @@ impl InstanceFilter for ProxyType { } impl pallet_proxy::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type Currency = Balances; type ProxyType = ProxyType; @@ -341,7 +341,7 @@ parameter_types! { } impl pallet_scheduler::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; @@ -363,7 +363,7 @@ parameter_types! { impl pallet_preimage::Config for Runtime { type WeightInfo = pallet_preimage::weights::SubstrateWeight; - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; type MaxSize = PreimageMaxSize; @@ -413,7 +413,7 @@ impl pallet_indices::Config for Runtime { type AccountIndex = AccountIndex; type Currency = Balances; type Deposit = IndexDeposit; - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = pallet_indices::weights::SubstrateWeight; } @@ -431,7 +431,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; type Balance = Balance; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = frame_system::Pallet; type WeightInfo = pallet_balances::weights::SubstrateWeight; @@ -446,7 +446,7 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = IdentityFee; @@ -495,7 +495,7 @@ impl_opaque_keys! { } impl pallet_session::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = Babe; @@ -545,7 +545,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = Timestamp; type CurrencyToVote = U128CurrencyToVote; type RewardRemainder = Treasury; - type Event = Event; + type Event = RuntimeEvent; type Slash = Treasury; // send the slashed funds to the treasury. type Reward = (); // rewards are minted from the void type SessionsPerEra = SessionsPerEra; @@ -685,7 +685,7 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime { } impl pallet_election_provider_multi_phase::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type EstimateCallFee = TransactionPayment; type SignedPhase = SignedPhase; @@ -720,7 +720,7 @@ parameter_types! { } impl pallet_bags_list::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type ScoreProvider = Staking; type WeightInfo = pallet_bags_list::weights::SubstrateWeight; type BagThresholds = BagThresholds; @@ -749,7 +749,7 @@ impl Convert for U256ToBalance { impl pallet_nomination_pools::Config for Runtime { type WeightInfo = (); - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type CurrencyBalance = Balance; type RewardCounter = FixedU128; @@ -769,7 +769,7 @@ parameter_types! { impl pallet_conviction_voting::Config for Runtime { type WeightInfo = pallet_conviction_voting::weights::SubstrateWeight; - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type VoteLockingPeriod = VoteLockingPeriod; type MaxVotes = ConstU32<512>; @@ -827,7 +827,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type Call = Call; - type Event = Event; + type Event = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; type SubmitOrigin = EnsureSigned; @@ -846,7 +846,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type Call = Call; - type Event = Event; + type Event = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; type SubmitOrigin = EnsureSigned; @@ -864,7 +864,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_ranked_collective::Config for Runtime { type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight; - type Event = Event; + type Event = RuntimeEvent; type PromoteOrigin = EnsureRootWithSuccess>; type DemoteOrigin = EnsureRootWithSuccess>; type Polls = RankedPolls; @@ -874,7 +874,7 @@ impl pallet_ranked_collective::Config for Runtime { impl pallet_remark::Config for Runtime { type WeightInfo = pallet_remark::weights::SubstrateWeight; - type Event = Event; + type Event = RuntimeEvent; } parameter_types! { @@ -889,7 +889,7 @@ parameter_types! { impl pallet_democracy::Config for Runtime { type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; @@ -948,7 +948,7 @@ type CouncilCollective = pallet_collective::Instance1; impl pallet_collective::Config for Runtime { type Origin = Origin; type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type MotionDuration = CouncilMotionDuration; type MaxProposals = CouncilMaxProposals; type MaxMembers = CouncilMaxMembers; @@ -972,7 +972,7 @@ parameter_types! { const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); impl pallet_elections_phragmen::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type PalletId = ElectionsPhragmenPalletId; type Currency = Balances; type ChangeMembers = Council; @@ -1001,7 +1001,7 @@ type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { type Origin = Origin; type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type MotionDuration = TechnicalMotionDuration; type MaxProposals = TechnicalMaxProposals; type MaxMembers = TechnicalMaxMembers; @@ -1014,7 +1014,7 @@ type EnsureRootOrHalfCouncil = EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, >; impl pallet_membership::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type AddOrigin = EnsureRootOrHalfCouncil; type RemoveOrigin = EnsureRootOrHalfCouncil; type SwapOrigin = EnsureRootOrHalfCouncil; @@ -1051,7 +1051,7 @@ impl pallet_treasury::Config for Runtime { EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; - type Event = Event; + type Event = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ProposalBondMinimum; @@ -1077,7 +1077,7 @@ parameter_types! { } impl pallet_bounties::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type BountyDepositBase = BountyDepositBase; type BountyDepositPayoutDelay = BountyDepositPayoutDelay; type BountyUpdatePeriod = BountyUpdatePeriod; @@ -1096,14 +1096,14 @@ parameter_types! { } impl pallet_child_bounties::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type MaxActiveChildBountyCount = ConstU32<5>; type ChildBountyValueMinimum = ChildBountyValueMinimum; type WeightInfo = pallet_child_bounties::weights::SubstrateWeight; } impl pallet_tips::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type DataDepositPerByte = DataDepositPerByte; type MaximumReasonLength = MaximumReasonLength; type Tippers = Elections; @@ -1131,7 +1131,7 @@ impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; type Currency = Balances; - type Event = Event; + type Event = RuntimeEvent; type Call = Call; /// The safest default is to allow no calls at all. /// @@ -1157,7 +1157,7 @@ impl pallet_contracts::Config for Runtime { } impl pallet_sudo::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; } @@ -1228,7 +1228,7 @@ where impl pallet_im_online::Config for Runtime { type AuthorityId = ImOnlineId; - type Event = Event; + type Event = RuntimeEvent; type NextSessionRotation = Babe; type ValidatorSet = Historical; type ReportUnresponsiveness = Offences; @@ -1240,7 +1240,7 @@ impl pallet_im_online::Config for Runtime { } impl pallet_offences::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } @@ -1250,7 +1250,7 @@ impl pallet_authority_discovery::Config for Runtime { } impl pallet_grandpa::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type KeyOwnerProofSystem = Historical; @@ -1283,7 +1283,7 @@ parameter_types! { } impl pallet_identity::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type BasicDeposit = BasicDeposit; type FieldDeposit = FieldDeposit; @@ -1305,7 +1305,7 @@ parameter_types! { } impl pallet_recovery::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = pallet_recovery::weights::SubstrateWeight; type Call = Call; type Currency = Balances; @@ -1328,7 +1328,7 @@ parameter_types! { } impl pallet_society::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type PalletId = SocietyPalletId; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; @@ -1351,7 +1351,7 @@ parameter_types! { } impl pallet_vesting::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = ConvertInto; type MinVestedTransfer = MinVestedTransfer; @@ -1381,7 +1381,7 @@ impl pallet_lottery::Config for Runtime { type Call = Call; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; - type Event = Event; + type Event = RuntimeEvent; type ManagerOrigin = EnsureRoot; type MaxCalls = MaxCalls; type ValidateCall = Lottery; @@ -1398,7 +1398,7 @@ parameter_types! { } impl pallet_assets::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Balance = u128; type AssetId = u32; type Currency = Balances; @@ -1426,7 +1426,7 @@ parameter_types! { } impl pallet_gilt::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type CurrencyBalance = Balance; type AdminOrigin = frame_system::EnsureRoot; @@ -1451,7 +1451,7 @@ parameter_types! { } impl pallet_uniques::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type CollectionId = u32; type ItemId = u32; type Currency = Balances; @@ -1472,7 +1472,7 @@ impl pallet_uniques::Config for Runtime { } impl pallet_transaction_storage::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type Call = Call; type FeeDestination = (); @@ -1484,7 +1484,7 @@ impl pallet_transaction_storage::Config for Runtime { } impl pallet_whitelist::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; @@ -1499,7 +1499,7 @@ parameter_types! { } impl pallet_state_trie_migration::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type ControlOrigin = EnsureRoot; type Currency = Balances; type MaxKeyLen = MigrationMaxKeyLen; @@ -1523,7 +1523,7 @@ type AllianceCollective = pallet_collective::Instance3; impl pallet_collective::Config for Runtime { type Origin = Origin; type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type MotionDuration = AllianceMotionDuration; type MaxProposals = AllianceMaxProposals; type MaxMembers = AllianceMaxMembers; @@ -1539,7 +1539,7 @@ parameter_types! { } impl pallet_alliance::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Proposal = Call; type AdminOrigin = EitherOfDiverse< EnsureRoot, diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index 961bf2b83552f..5284a030cb414 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); type BlockLength = (); @@ -78,7 +78,7 @@ parameter_types! { } impl bags_list::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type BagThresholds = BagThresholds; type ScoreProvider = StakingMock; diff --git a/frame/support/procedural/src/construct_runtime/expand/event.rs b/frame/support/procedural/src/construct_runtime/expand/event.rs index b242f9641562c..5ab155fe7bf73 100644 --- a/frame/support/procedural/src/construct_runtime/expand/event.rs +++ b/frame/support/procedural/src/construct_runtime/expand/event.rs @@ -79,7 +79,7 @@ pub fn expand_outer_event( #scrate::RuntimeDebug, )] #[allow(non_camel_case_types)] - pub enum Event { + pub enum RuntimeEvent { #event_variants } @@ -122,12 +122,12 @@ fn expand_event_conversion( let variant_name = &pallet.name; quote! { - impl From<#pallet_event> for Event { + impl From<#pallet_event> for RuntimeEvent { fn from(x: #pallet_event) -> Self { - Event::#variant_name(x) + RuntimeEvent::#variant_name(x) } } - impl TryInto<#pallet_event> for Event { + impl TryInto<#pallet_event> for RuntimeEvent { type Error = (); fn try_into(self) -> #scrate::sp_std::result::Result<#pallet_event, Self::Error> { diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 7850726048546..723eadb85fed2 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -68,7 +68,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = AccountId; - type Event = Event; + type Event = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); From 077acdea2d526cf8e6810a0b134ea07aeb448417 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 5 Aug 2022 11:06:27 +0200 Subject: [PATCH 02/63] rename Call --- .../src/construct_runtime/expand/call.rs | 22 +++++++++---------- frame/support/test/compile_pass/src/lib.rs | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/expand/call.rs b/frame/support/procedural/src/construct_runtime/expand/call.rs index c8c5d5ff0ee43..e357c966be234 100644 --- a/frame/support/procedural/src/construct_runtime/expand/call.rs +++ b/frame/support/procedural/src/construct_runtime/expand/call.rs @@ -42,7 +42,7 @@ pub fn expand_outer_dispatch( variant_defs.extend( quote!(#[codec(index = #index)] #name( #scrate::dispatch::CallableCallFor<#name, #runtime> ),), ); - variant_patterns.push(quote!(Call::#name(call))); + variant_patterns.push(quote!(RuntimeCall::#name(call))); pallet_names.push(name); query_call_part_macros.push(quote! { #path::__substrate_call_check::is_call_part_defined!(#name); @@ -59,11 +59,11 @@ pub fn expand_outer_dispatch( #scrate::scale_info::TypeInfo, #scrate::RuntimeDebug, )] - pub enum Call { + pub enum RuntimeCall { #variant_defs } #[cfg(test)] - impl Call { + impl RuntimeCall { /// Return a list of the module names together with their size in memory. pub const fn sizes() -> &'static [( &'static str, usize )] { use #scrate::dispatch::Callable; @@ -98,14 +98,14 @@ pub fn expand_outer_dispatch( } } } - impl #scrate::dispatch::GetDispatchInfo for Call { + impl #scrate::dispatch::GetDispatchInfo for RuntimeCall { fn get_dispatch_info(&self) -> #scrate::dispatch::DispatchInfo { match self { #( #variant_patterns => call.get_dispatch_info(), )* } } } - impl #scrate::dispatch::GetCallMetadata for Call { + impl #scrate::dispatch::GetCallMetadata for RuntimeCall { fn get_call_metadata(&self) -> #scrate::dispatch::CallMetadata { use #scrate::dispatch::GetCallName; match self { @@ -137,9 +137,9 @@ pub fn expand_outer_dispatch( } } } - impl #scrate::dispatch::Dispatchable for Call { + impl #scrate::dispatch::Dispatchable for RuntimeCall { type Origin = Origin; - type Config = Call; + type Config = RuntimeCall; type Info = #scrate::weights::DispatchInfo; type PostInfo = #scrate::weights::PostDispatchInfo; fn dispatch(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo { @@ -152,7 +152,7 @@ pub fn expand_outer_dispatch( #scrate::traits::UnfilteredDispatchable::dispatch_bypass_filter(self, origin) } } - impl #scrate::traits::UnfilteredDispatchable for Call { + impl #scrate::traits::UnfilteredDispatchable for RuntimeCall { type Origin = Origin; fn dispatch_bypass_filter(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo { match self { @@ -163,7 +163,7 @@ pub fn expand_outer_dispatch( } } } - impl #scrate::traits::DispatchableWithStorageLayer for Call { + impl #scrate::traits::DispatchableWithStorageLayer for RuntimeCall { type Origin = Origin; fn dispatch_with_storage_layer(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo { #scrate::storage::with_storage_layer(|| { @@ -178,7 +178,7 @@ pub fn expand_outer_dispatch( } #( - impl #scrate::traits::IsSubType<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for Call { + impl #scrate::traits::IsSubType<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for RuntimeCall { #[allow(unreachable_patterns)] fn is_sub_type(&self) -> Option<&#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> { match self { @@ -189,7 +189,7 @@ pub fn expand_outer_dispatch( } } - impl From<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for Call { + impl From<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for RuntimeCall { fn from(call: #scrate::dispatch::CallableCallFor<#pallet_names, #runtime>) -> Self { #variant_patterns } diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 723eadb85fed2..7a54294bfc52e 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -70,7 +70,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Event = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = Call; + type Call = RuntimeCall; type DbWeight = (); type OnNewAccount = (); type OnKilledAccount = (); @@ -82,6 +82,7 @@ impl frame_system::Config for Runtime { pub type Header = generic::Header; pub type Block = generic::Block; +pub type Call = RuntimeCall; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; construct_runtime!( From 6f7d309793d8466daa3f9989dd2b19ebb643ed04 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 5 Aug 2022 11:16:52 +0200 Subject: [PATCH 03/63] rename in runtimes --- bin/node-template/runtime/src/lib.rs | 7 ++- bin/node/runtime/src/lib.rs | 82 +++++++++++++++------------- 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 6deaf5d222c35..82ff44291c878 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -156,7 +156,7 @@ impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The aggregated dispatch type that is available for extrinsics. - type Call = Call; + type Call = RuntimeCall; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. @@ -208,7 +208,7 @@ impl pallet_aura::Config for Runtime { impl pallet_grandpa::Config for Runtime { type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type KeyOwnerProofSystem = (); @@ -262,7 +262,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; } /// Configure the pallet-template in pallets/template. @@ -307,6 +307,7 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, ); +type Call = RuntimeCall; /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// The payload being signed in transactions. diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e796f41024ae5..e944ed3285c61 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -205,7 +205,7 @@ impl frame_system::Config for Runtime { type BlockLength = RuntimeBlockLength; type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = Index; type BlockNumber = BlockNumber; type Hash = Hash; @@ -230,7 +230,7 @@ impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_utility::Config for Runtime { type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = pallet_utility::weights::SubstrateWeight; } @@ -244,7 +244,7 @@ parameter_types! { impl pallet_multisig::Config for Runtime { type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -286,25 +286,28 @@ impl Default for ProxyType { Self::Any } } -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { match self { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - Call::Balances(..) | - Call::Assets(..) | Call::Uniques(..) | - Call::Vesting(pallet_vesting::Call::vested_transfer { .. }) | - Call::Indices(pallet_indices::Call::transfer { .. }) + RuntimeCall::Balances(..) | + RuntimeCall::Assets(..) | + RuntimeCall::Uniques(..) | + RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) | + RuntimeCall::Indices(pallet_indices::Call::transfer { .. }) ), ProxyType::Governance => matches!( c, - Call::Democracy(..) | - Call::Council(..) | Call::Society(..) | - Call::TechnicalCommittee(..) | - Call::Elections(..) | Call::Treasury(..) + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | + RuntimeCall::Society(..) | + RuntimeCall::TechnicalCommittee(..) | + RuntimeCall::Elections(..) | + RuntimeCall::Treasury(..) ), - ProxyType::Staking => matches!(c, Call::Staking(..)), + ProxyType::Staking => matches!(c, RuntimeCall::Staking(..)), } } fn is_superset(&self, o: &Self) -> bool { @@ -320,7 +323,7 @@ impl InstanceFilter for ProxyType { impl pallet_proxy::Config for Runtime { type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -344,7 +347,7 @@ impl pallet_scheduler::Config for Runtime { type Event = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = Call; + type Call = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<50>; @@ -826,7 +829,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; - type Call = Call; + type Call = RuntimeCall; type Event = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -845,7 +848,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; - type Call = Call; + type Call = RuntimeCall; type Event = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -888,7 +891,7 @@ parameter_types! { } impl pallet_democracy::Config for Runtime { - type Proposal = Call; + type Proposal = RuntimeCall; type Event = RuntimeEvent; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; @@ -947,7 +950,7 @@ parameter_types! { type CouncilCollective = pallet_collective::Instance1; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type Event = RuntimeEvent; type MotionDuration = CouncilMotionDuration; type MaxProposals = CouncilMaxProposals; @@ -1000,7 +1003,7 @@ parameter_types! { type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type Event = RuntimeEvent; type MotionDuration = TechnicalMotionDuration; type MaxProposals = TechnicalMaxProposals; @@ -1132,7 +1135,7 @@ impl pallet_contracts::Config for Runtime { type Randomness = RandomnessCollectiveFlip; type Currency = Balances; type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; /// The safest default is to allow no calls at all. /// /// Runtimes should whitelist dispatchables that are allowed to be called from contracts @@ -1158,7 +1161,7 @@ impl pallet_contracts::Config for Runtime { impl pallet_sudo::Config for Runtime { type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; } parameter_types! { @@ -1173,14 +1176,14 @@ parameter_types! { impl frame_system::offchain::CreateSignedTransaction for Runtime where - Call: From, + RuntimeCall: From, { fn create_transaction>( - call: Call, + call: RuntimeCall, public: ::Signer, account: AccountId, nonce: Index, - ) -> Option<(Call, ::SignaturePayload)> { + ) -> Option<(RuntimeCall, ::SignaturePayload)> { let tip = 0; // take the biggest period possible. let period = @@ -1220,10 +1223,10 @@ impl frame_system::offchain::SigningTypes for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - Call: From, + RuntimeCall: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } impl pallet_im_online::Config for Runtime { @@ -1251,7 +1254,7 @@ impl pallet_authority_discovery::Config for Runtime { impl pallet_grandpa::Config for Runtime { type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type KeyOwnerProofSystem = Historical; @@ -1307,7 +1310,7 @@ parameter_types! { impl pallet_recovery::Config for Runtime { type Event = RuntimeEvent; type WeightInfo = pallet_recovery::weights::SubstrateWeight; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; @@ -1378,7 +1381,7 @@ parameter_types! { impl pallet_lottery::Config for Runtime { type PalletId = LotteryPalletId; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; type Event = RuntimeEvent; @@ -1474,7 +1477,7 @@ impl pallet_uniques::Config for Runtime { impl pallet_transaction_storage::Config for Runtime { type Event = RuntimeEvent; type Currency = Balances; - type Call = Call; + type Call = RuntimeCall; type FeeDestination = (); type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight; type MaxBlockTransactions = @@ -1485,7 +1488,7 @@ impl pallet_transaction_storage::Config for Runtime { impl pallet_whitelist::Config for Runtime { type Event = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type PreimageProvider = Preimage; @@ -1522,7 +1525,7 @@ parameter_types! { type AllianceCollective = pallet_collective::Instance3; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type Event = RuntimeEvent; type MotionDuration = AllianceMotionDuration; type MaxProposals = AllianceMaxProposals; @@ -1540,7 +1543,7 @@ parameter_types! { impl pallet_alliance::Config for Runtime { type Event = RuntimeEvent; - type Proposal = Call; + type Proposal = RuntimeCall; type AdminOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, @@ -1664,12 +1667,13 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_asset_tx_payment::ChargeAssetTxPayment, ); +type Call = RuntimeCall; /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; +pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -2141,7 +2145,7 @@ mod tests { fn validate_transaction_submitter_bounds() { fn is_submit_signed_transaction() where - T: CreateSignedTransaction, + T: CreateSignedTransaction, { } @@ -2161,7 +2165,7 @@ mod tests { #[test] fn call_size() { - let size = core::mem::size_of::(); + let size = core::mem::size_of::(); assert!( size <= 208, "size of Call {} is more than 208 bytes: some calls have too big arguments, use Box to reduce the From cf619fcf9c8c4df81a9ed92cec44f9c98b80130b Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 5 Aug 2022 11:48:57 +0200 Subject: [PATCH 04/63] small fix --- bin/node/runtime/src/lib.rs | 2 +- frame/bags-list/src/mock.rs | 2 +- frame/system/src/mock.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index a0af13ad1255f..cd1d687e3712e 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -459,7 +459,7 @@ impl pallet_transaction_payment::Config for Runtime { } impl pallet_asset_tx_payment::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Fungibles = Assets; type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter< pallet_assets::BalanceToAssetBalance, diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index 5284a030cb414..b9b48ff0df933 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index f3f542aa83a9a..b44f89a2ee372 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -95,7 +95,7 @@ impl Config for Test { type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; From 6ab11ffaff594d90297b22f3f6401aac80bde8dc Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sat, 6 Aug 2022 11:51:14 +0200 Subject: [PATCH 05/63] rename Event --- bin/node-template/pallets/template/src/mock.rs | 4 ++-- frame/alliance/src/mock.rs | 10 +++++----- frame/assets/src/mock.rs | 6 +++--- frame/atomic-swap/src/tests.rs | 6 +++--- frame/aura/src/mock.rs | 2 +- frame/authority-discovery/src/lib.rs | 4 ++-- frame/authorship/src/lib.rs | 2 +- frame/babe/src/mock.rs | 10 +++++----- frame/balances/src/tests_composite.rs | 6 +++--- frame/balances/src/tests_local.rs | 6 +++--- frame/balances/src/tests_reentrancy.rs | 4 ++-- frame/beefy-mmr/src/mock.rs | 4 ++-- frame/beefy/src/mock.rs | 4 ++-- frame/benchmarking/src/baseline.rs | 2 +- frame/benchmarking/src/tests.rs | 2 +- frame/benchmarking/src/tests_instance.rs | 4 ++-- frame/bounties/src/tests.rs | 12 ++++++------ frame/child-bounties/src/tests.rs | 10 +++++----- frame/collective/src/tests.rs | 10 +++++----- frame/contracts/src/tests.rs | 8 ++++---- frame/conviction-voting/src/tests.rs | 6 +++--- frame/democracy/src/tests.rs | 8 ++++---- frame/election-provider-multi-phase/src/mock.rs | 6 +++--- frame/elections-phragmen/src/lib.rs | 6 +++--- frame/examples/basic/src/tests.rs | 6 +++--- frame/examples/offchain-worker/src/tests.rs | 4 ++-- frame/examples/parallel/src/tests.rs | 2 +- frame/executive/src/lib.rs | 6 +++--- frame/gilt/src/mock.rs | 6 +++--- frame/grandpa/src/mock.rs | 12 ++++++------ frame/identity/src/tests.rs | 6 +++--- frame/im-online/src/mock.rs | 6 +++--- frame/indices/src/mock.rs | 6 +++--- frame/lottery/src/mock.rs | 6 +++--- frame/membership/src/lib.rs | 4 ++-- frame/merkle-mountain-range/src/mock.rs | 2 +- frame/multisig/src/tests.rs | 6 +++--- frame/nicks/src/lib.rs | 6 +++--- frame/node-authorization/src/mock.rs | 4 ++-- frame/nomination-pools/benchmarking/src/mock.rs | 10 +++++----- frame/nomination-pools/src/mock.rs | 6 +++--- frame/nomination-pools/test-staking/src/mock.rs | 10 +++++----- frame/offences/benchmarking/src/mock.rs | 12 ++++++------ frame/offences/src/mock.rs | 4 ++-- frame/preimage/src/mock.rs | 6 +++--- frame/proxy/src/tests.rs | 8 ++++---- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/ranked-collective/src/tests.rs | 4 ++-- frame/recovery/src/mock.rs | 6 +++--- frame/referenda/src/mock.rs | 10 +++++----- frame/remark/src/mock.rs | 4 ++-- frame/scheduler/src/mock.rs | 8 ++++---- frame/scored-pool/src/mock.rs | 6 +++--- frame/session/benchmarking/src/mock.rs | 8 ++++---- frame/session/src/mock.rs | 4 ++-- frame/society/src/mock.rs | 6 +++--- frame/staking/src/mock.rs | 10 +++++----- frame/state-trie-migration/src/lib.rs | 6 +++--- frame/sudo/src/mock.rs | 6 +++--- frame/support/test/tests/construct_runtime.rs | 2 +- .../construct_runtime_ui/no_std_genesis_config.rs | 2 +- .../construct_runtime_ui/pallet_error_too_large.rs | 2 +- .../construct_runtime_ui/undefined_call_part.rs | 2 +- .../construct_runtime_ui/undefined_event_part.rs | 2 +- .../undefined_genesis_config_part.rs | 2 +- .../undefined_inherent_part.rs | 2 +- .../construct_runtime_ui/undefined_origin_part.rs | 2 +- .../undefined_validate_unsigned_part.rs | 2 +- frame/support/test/tests/instance.rs | 14 +++++++------- frame/support/test/tests/issue2219.rs | 2 +- frame/support/test/tests/origin.rs | 2 +- frame/support/test/tests/pallet.rs | 6 +++--- frame/support/test/tests/pallet_compatibility.rs | 6 +++--- .../test/tests/pallet_compatibility_instance.rs | 14 +++++++------- frame/support/test/tests/pallet_instance.rs | 10 +++++----- frame/support/test/tests/storage_layers.rs | 2 +- frame/system/benches/bench.rs | 4 ++-- frame/system/benchmarking/src/mock.rs | 2 +- frame/system/src/mock.rs | 2 +- frame/timestamp/src/mock.rs | 2 +- frame/tips/src/tests.rs | 12 ++++++------ .../asset-tx-payment/src/tests.rs | 10 +++++----- frame/transaction-payment/src/lib.rs | 6 +++--- frame/transaction-storage/src/mock.rs | 6 +++--- frame/treasury/src/tests.rs | 6 +++--- frame/uniques/src/mock.rs | 6 +++--- frame/utility/src/tests.rs | 6 +++--- frame/vesting/src/mock.rs | 6 +++--- frame/whitelist/src/mock.rs | 8 ++++---- test-utils/runtime/src/lib.rs | 2 +- 90 files changed, 256 insertions(+), 256 deletions(-) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index e03f37b2eea69..4de39b77dc92b 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -36,7 +36,7 @@ impl system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -50,7 +50,7 @@ impl system::Config for Test { } impl pallet_template::Config for Test { - type Event = Event; + type Event = RuntimeEvent; } // Build genesis storage according to the mock runtime. diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 91986300aa2e1..1fed55b9c30ed 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -53,7 +53,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); @@ -74,7 +74,7 @@ parameter_types! { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); @@ -92,7 +92,7 @@ type AllianceCollective = pallet_collective::Instance1; impl pallet_collective::Config for Test { type Origin = Origin; type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type MotionDuration = MotionDuration; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; @@ -119,7 +119,7 @@ type EnsureOneOrRoot = EitherOfDiverse, EnsureSignedBy type EnsureTwoOrRoot = EitherOfDiverse, EnsureSignedBy>; impl pallet_identity::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type BasicDeposit = BasicDeposit; type FieldDeposit = FieldDeposit; @@ -201,7 +201,7 @@ parameter_types! { pub const AllyDeposit: u64 = 25; } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Proposal = Call; type AdminOrigin = EnsureSignedBy; type MembershipManager = EnsureSignedBy; diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index 67690e2b28ec1..e7bdf143bf4a7 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -75,7 +75,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -85,7 +85,7 @@ impl pallet_balances::Config for Test { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Balance = u64; type AssetId = u32; type Currency = Balances; diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 2352e7852d090..b1c812f2cdd93 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -46,7 +46,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -65,14 +65,14 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type SwapAction = BalanceSwapAction; type ProofLimit = ConstU32<1024>; } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 636a28692ba28..e76ec7e54045a 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index a56d8e785f6ac..bcd782458155b 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -209,7 +209,7 @@ mod tests { type Keys = UintAuthorityId; type ShouldEndSession = pallet_session::PeriodicSessions; type SessionHandler = TestSessionHandler; - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = AuthorityId; type ValidatorIdOf = ConvertInto; type NextSessionRotation = pallet_session::PeriodicSessions; @@ -244,7 +244,7 @@ mod tests { type AccountId = AuthorityId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 8ddccfd9cf939..9d6f05ec6051d 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -477,7 +477,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index c2ba3c2be06d8..43e1351db90f2 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -84,7 +84,7 @@ impl frame_system::Config for Test { type AccountId = DummyValidatorId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -111,7 +111,7 @@ impl_opaque_keys! { } impl pallet_session::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = Babe; @@ -147,7 +147,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u128; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); @@ -184,7 +184,7 @@ impl pallet_staking::Config for Test { type MaxNominations = ConstU32<16>; type RewardRemainder = (); type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type CurrencyBalance = ::Balance; type Slash = (); @@ -209,7 +209,7 @@ impl pallet_staking::Config for Test { } impl pallet_offences::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs index 4ab913cf1411a..79ab0cbcb7d72 100644 --- a/frame/balances/src/tests_composite.rs +++ b/frame/balances/src/tests_composite.rs @@ -63,7 +63,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = 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 Event = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter, ()>; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; @@ -88,7 +88,7 @@ impl pallet_transaction_payment::Config for Test { impl Config for Test { type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = frame_system::Pallet; type MaxLocks = (); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 48c6574c3b39f..155d75b521bcb 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -64,7 +64,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = 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 Event = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter, ()>; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; @@ -89,7 +89,7 @@ impl pallet_transaction_payment::Config for Test { impl Config for Test { type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = StorageMapShim, system::Provider, u64, super::AccountData>; diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index 4c028840d553c..4ff10f3f69bc3 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -68,7 +68,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -91,7 +91,7 @@ impl OnUnbalanced> for OnDustRemoval { impl Config for Test { type Balance = u64; type DustRemoval = OnDustRemoval; - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = StorageMapShim, system::Provider, u64, super::AccountData>; diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 8a673c9d4e914..213776c8e10db 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -76,7 +76,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -90,7 +90,7 @@ impl frame_system::Config for Test { } impl pallet_session::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 3bb59c7c39485..792e257edf351 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -95,7 +95,7 @@ parameter_types! { } impl pallet_session::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 1ceb9a4f8904c..f13ee526406fb 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -185,7 +185,7 @@ pub mod mock { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 06f2b5bdc4916..12d50b6e1113e 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -98,7 +98,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index ef8351d37e957..9bd33a903207c 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -100,7 +100,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -114,7 +114,7 @@ impl frame_system::Config for Test { } impl pallet_test::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type LowerBound = ConstU32<1>; type UpperBound = ConstU32<100>; } diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index b4ce039b35fbc..c38c97ba9ea8d 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -78,7 +78,7 @@ impl frame_system::Config for Test { type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -96,7 +96,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -117,7 +117,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = Event; + type Event = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -136,7 +136,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = Event; + type Event = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -159,7 +159,7 @@ parameter_types! { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type BountyDepositBase = ConstU64<80>; type BountyDepositPayoutDelay = ConstU64<3>; type BountyUpdatePeriod = ConstU64<20>; @@ -174,7 +174,7 @@ impl Config for Test { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type BountyDepositBase = ConstU64<80>; type BountyDepositPayoutDelay = ConstU64<3>; type BountyUpdatePeriod = ConstU64<20>; diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 2584445071471..bd19f16b65f63 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -81,7 +81,7 @@ impl frame_system::Config for Test { type AccountId = u128; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -99,7 +99,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -119,7 +119,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = Event; + type Event = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -140,7 +140,7 @@ parameter_types! { } impl pallet_bounties::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type BountyDepositBase = ConstU64<80>; type BountyDepositPayoutDelay = ConstU64<3>; type BountyUpdatePeriod = ConstU64<10>; @@ -154,7 +154,7 @@ impl pallet_bounties::Config for Test { type ChildBountyManager = ChildBounties; } impl pallet_child_bounties::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type MaxActiveChildBountyCount = ConstU32<2>; type ChildBountyValueMinimum = ConstU64<1>; type WeightInfo = (); diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 063479e42fe77..e1b726acf9c98 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -105,7 +105,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -120,7 +120,7 @@ impl frame_system::Config for Test { impl Config for Test { type Origin = Origin; type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; @@ -130,7 +130,7 @@ impl Config for Test { impl Config for Test { type Origin = Origin; type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; @@ -138,13 +138,13 @@ impl Config for Test { type WeightInfo = (); } impl mock_democracy::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type ExternalMajorityOrigin = EnsureProportionAtLeast; } impl Config for Test { type Origin = Origin; type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 0febfec929b6e..6889fd770a40d 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -281,7 +281,7 @@ impl frame_system::Config for Test { type AccountId = AccountId32; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -299,7 +299,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -313,7 +313,7 @@ impl pallet_timestamp::Config for Test { type WeightInfo = (); } impl pallet_utility::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = (); @@ -359,7 +359,7 @@ impl Config for Test { type Time = Timestamp; type Randomness = Randomness; type Currency = Balances; - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type CallFilter = TestFilter; type CallStack = [Frame; 31]; diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 9eb7f679efca3..6c06e2b5dcba9 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -73,7 +73,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -91,7 +91,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type MaxLocks = ConstU32<10>; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -186,7 +186,7 @@ impl Polling> for TestPolls { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Currency = pallet_balances::Pallet; type VoteLockingPeriod = ConstU64<3>; type MaxVotes = ConstU32<3>; diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 0fe83a07610d1..b110f82967b77 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -94,7 +94,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -110,7 +110,7 @@ parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; } impl pallet_scheduler::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; @@ -128,7 +128,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type MaxLocks = ConstU32<10>; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -157,7 +157,7 @@ impl SortedMembers for OneToFive { impl Config for Test { type Proposal = Call; - type Event = Event; + type Event = RuntimeEvent; type Currency = pallet_balances::Pallet; type EnactmentPeriod = ConstU64<2>; type LaunchPeriod = ConstU64<2>; diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 7eff70b47eba5..32a9ce4ed3bc0 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -207,7 +207,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); type BlockLength = (); @@ -231,7 +231,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -359,7 +359,7 @@ impl MinerConfig for Runtime { } impl crate::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type EstimateCallFee = frame_support::traits::ConstU32<8>; type SignedPhase = SignedPhase; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 28fed28f18e5c..14a399cbae8bd 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1184,7 +1184,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -1199,7 +1199,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = frame_system::Pallet; @@ -1270,7 +1270,7 @@ mod tests { impl Config for Test { type PalletId = ElectionsPhragmenPalletId; - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type ChangeMembers = TestChangeMembers; diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 0f659e12fb443..b16fa822a90af 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -68,7 +68,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -95,7 +95,7 @@ impl pallet_balances::Config for Test { impl Config for Test { type MagicNumber = ConstU64<1_000_000_000>; - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); } diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index e5bd9fabc629b..919afe71e5da5 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -69,7 +69,7 @@ impl frame_system::Config for Test { type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -117,7 +117,7 @@ parameter_types! { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type AuthorityId = crypto::TestAuthId; type Call = Call; type GracePeriod = ConstU64<5>; diff --git a/frame/examples/parallel/src/tests.rs b/frame/examples/parallel/src/tests.rs index 67d823d8b204b..fa5535cac57d8 100644 --- a/frame/examples/parallel/src/tests.rs +++ b/frame/examples/parallel/src/tests.rs @@ -55,7 +55,7 @@ impl frame_system::Config for Test { type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU64<250>; type DbWeight = (); type BlockWeights = (); diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index cd3e1c500db26..54da4fafbb988 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -744,7 +744,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = RuntimeVersion; type PalletInfo = PalletInfo; @@ -760,7 +760,7 @@ mod tests { type Balance = u64; impl pallet_balances::Config for Runtime { type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -774,7 +774,7 @@ mod tests { pub const TransactionByteFee: Balance = 0; } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; diff --git a/frame/gilt/src/mock.rs b/frame/gilt/src/mock.rs index 369b34ba77f44..288eec2af4517 100644 --- a/frame/gilt/src/mock.rs +++ b/frame/gilt/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -75,7 +75,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = frame_support::traits::ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -92,7 +92,7 @@ ord_parameter_types! { } impl pallet_gilt::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type CurrencyBalance = ::Balance; type AdminOrigin = frame_system::EnsureSignedBy; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 5e6c955c441c5..0ca63e9a611cb 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -88,7 +88,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -116,7 +116,7 @@ parameter_types! { /// Custom `SessionHandler` since we use `TestSessionKeys` as `Keys`. impl pallet_session::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; @@ -145,7 +145,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u128; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); @@ -188,7 +188,7 @@ impl pallet_staking::Config for Test { type MaxNominations = ConstU32<16>; type RewardRemainder = (); type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type CurrencyBalance = ::Balance; type Slash = (); @@ -213,7 +213,7 @@ impl pallet_staking::Config for Test { } impl pallet_offences::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } @@ -224,7 +224,7 @@ parameter_types! { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type KeyOwnerProofSystem = Historical; diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 6066f176a6106..44e5706e8315b 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -81,7 +81,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -103,7 +103,7 @@ ord_parameter_types! { type EnsureOneOrRoot = EitherOfDiverse, EnsureSignedBy>; type EnsureTwoOrRoot = EitherOfDiverse, EnsureSignedBy>; impl pallet_identity::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type Slashed = (); type BasicDeposit = ConstU64<10>; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 2459f7e748941..a6450138fa354 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -140,7 +140,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -166,7 +166,7 @@ impl pallet_session::Config for Runtime { type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type Keys = UintAuthorityId; - type Event = Event; + type Event = RuntimeEvent; type NextSessionRotation = pallet_session::PeriodicSessions; type WeightInfo = (); } @@ -220,7 +220,7 @@ impl frame_support::traits::EstimateNextSessionRotation for TestNextSession impl Config for Runtime { type AuthorityId = UintAuthorityId; - type Event = Event; + type Event = RuntimeEvent; type ValidatorSet = Historical; type NextSessionRotation = TestNextSessionRotation; type ReportUnresponsiveness = OffenceHandler; diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 6bd79708c3dd2..b5b2d190c456a 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = Indices; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -80,7 +80,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -90,7 +90,7 @@ impl Config for Test { type AccountIndex = u64; type Currency = Balances; type Deposit = ConstU64<1>; - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); } diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 592551fb6b93f..755a043a86fc2 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -84,7 +84,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -100,7 +100,7 @@ impl Config for Test { type Call = Call; type Currency = Balances; type Randomness = TestRandomness; - type Event = Event; + type Event = RuntimeEvent; type ManagerOrigin = EnsureRoot; type MaxCalls = ConstU32<2>; type ValidateCall = Lottery; diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 24ecfd5333c66..91390c64fcd68 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -535,7 +535,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -584,7 +584,7 @@ mod tests { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type AddOrigin = EnsureSignedBy; type RemoveOrigin = EnsureSignedBy; type SwapOrigin = EnsureSignedBy; diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index b2b6821fcd054..4063406d7fac8 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -53,7 +53,7 @@ impl frame_system::Config for Test { type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type BlockWeights = (); diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index d67d06e1bce05..48ba1856c3039 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -84,7 +84,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -103,7 +103,7 @@ impl Contains for TestBaseCallFilter { } } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type Currency = Balances; type DepositBase = ConstU64<1>; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 5da06a24df3e5..350b44a06cc67 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -291,7 +291,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -309,7 +309,7 @@ mod tests { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -320,7 +320,7 @@ mod tests { pub const One: u64 = 1; } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type ReservationFee = ConstU64<2>; type Slashed = (); diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index d959d1b8610f5..ae90317987d97 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -82,7 +82,7 @@ ord_parameter_types! { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type MaxWellKnownNodes = ConstU32<4>; type MaxPeerIdLength = ConstU32<2>; type AddOrigin = EnsureSignedBy; diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index d239d4f072b80..9ea7622c6bfb1 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -41,7 +41,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -69,7 +69,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -96,7 +96,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); - type Event = Event; + type Event = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = (); @@ -123,7 +123,7 @@ parameter_types! { } impl pallet_bags_list::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type BagThresholds = BagThresholds; type ScoreProvider = Staking; @@ -151,7 +151,7 @@ parameter_types! { } impl pallet_nomination_pools::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type Currency = Balances; type CurrencyBalance = Balance; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 5138c55afccac..41aa70c379547 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -136,7 +136,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); type BlockLength = (); @@ -160,7 +160,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -188,7 +188,7 @@ parameter_types! { pub const PoolsPalletId: PalletId = PalletId(*b"py/nopls"); } impl pools::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type Currency = Balances; type CurrencyBalance = Balance; diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 055ba7b4b3c06..74cb62c34a83d 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -81,7 +81,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -111,7 +111,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); - type Event = Event; + type Event = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = (); @@ -138,7 +138,7 @@ parameter_types! { } impl pallet_bags_list::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type BagThresholds = BagThresholds; type ScoreProvider = Staking; @@ -165,7 +165,7 @@ parameter_types! { } impl pallet_nomination_pools::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type Currency = Balances; type CurrencyBalance = Balance; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index d51a81b1212c0..8d8f032abec62 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -57,7 +57,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -75,7 +75,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<10>; type AccountStore = System; @@ -126,7 +126,7 @@ impl pallet_session::Config for Test { type ShouldEndSession = pallet_session::PeriodicSessions; type NextSessionRotation = pallet_session::PeriodicSessions; type SessionHandler = TestSessionHandler; - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; type WeightInfo = (); @@ -163,7 +163,7 @@ impl pallet_staking::Config for Test { type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); - type Event = Event; + type Event = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = (); @@ -186,7 +186,7 @@ impl pallet_staking::Config for Test { impl pallet_im_online::Config for Test { type AuthorityId = UintAuthorityId; - type Event = Event; + type Event = RuntimeEvent; type ValidatorSet = Historical; type NextSessionRotation = pallet_session::PeriodicSessions; type ReportUnresponsiveness = Offences; @@ -198,7 +198,7 @@ impl pallet_im_online::Config for Test { } impl pallet_offences::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index d9ecf44ad8734..4931588293f56 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -102,7 +102,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -116,7 +116,7 @@ impl frame_system::Config for Runtime { } impl Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type IdentificationTuple = u64; type OnOffenceHandler = OnOffenceHandler; } diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 109806049a0fd..5962aff69331b 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -81,7 +81,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<5>; type AccountStore = System; @@ -102,7 +102,7 @@ ord_parameter_types! { impl Config for Test { type WeightInfo = (); - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureSignedBy; type MaxSize = ConstU32<1024>; diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index a0807f1d3d0b6..11d8e190452cf 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -70,7 +70,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -88,14 +88,14 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } impl pallet_utility::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = (); @@ -150,7 +150,7 @@ impl Contains for BaseFilter { } } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type Currency = Balances; type ProxyType = ProxyType; diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index f709578f6941a..45d9432d71648 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -206,7 +206,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index 4344a1be730fb..674382b046d9f 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -170,7 +170,7 @@ impl Polling> for TestPolls { impl Config for Test { type WeightInfo = (); - type Event = Event; + type Event = RuntimeEvent; type PromoteOrigin = EitherOf< // Root can promote arbitrarily. frame_system::EnsureRootWithSuccess>, diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 44fc4d72a4a5f..b72450ddb8dc7 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -64,7 +64,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u128; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); @@ -102,7 +102,7 @@ parameter_types! { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type Call = Call; type Currency = Balances; diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index 1a24911603990..a043b39dc5ee9 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -78,7 +78,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -91,7 +91,7 @@ impl frame_system::Config for Test { type MaxConsumers = ConstU32<16>; } impl pallet_preimage::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type Currency = Balances; type ManagerOrigin = EnsureRoot; @@ -100,7 +100,7 @@ impl pallet_preimage::Config for Test { type ByteDeposit = (); } impl pallet_scheduler::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; @@ -117,7 +117,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type MaxLocks = ConstU32<10>; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -212,7 +212,7 @@ impl TracksInfo for TestTracksInfo { impl Config for Test { type WeightInfo = (); type Call = Call; - type Event = Event; + type Event = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; type SubmitOrigin = frame_system::EnsureSigned; diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 67a0399e9c386..91d3c010aa507 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -54,7 +54,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -69,7 +69,7 @@ impl frame_system::Config for Test { } impl pallet_remark::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); } diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 008105dc737ea..cffd15c6cc5b1 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -135,7 +135,7 @@ impl system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -148,7 +148,7 @@ impl system::Config for Test { type MaxConsumers = ConstU32<16>; } impl logger::Config for Test { - type Event = Event; + type Event = RuntimeEvent; } parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; @@ -159,7 +159,7 @@ ord_parameter_types! { } impl pallet_preimage::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type Currency = (); type ManagerOrigin = EnsureRoot; @@ -169,7 +169,7 @@ impl pallet_preimage::Config for Test { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 4fef5385eb2c5..bc85568754b5f 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -89,7 +89,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -124,7 +124,7 @@ impl InitializeMembers for TestChangeMembers { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type KickOrigin = EnsureSignedBy; type MembershipInitialized = TestChangeMembers; type MembershipChanged = TestChangeMembers; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 2181493f72947..204240a030b77 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -79,7 +79,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<10>; type AccountStore = System; @@ -125,7 +125,7 @@ impl pallet_session::Config for Test { type ShouldEndSession = pallet_session::PeriodicSessions<(), ()>; type NextSessionRotation = pallet_session::PeriodicSessions<(), ()>; type SessionHandler = TestSessionHandler; - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; type WeightInfo = (); @@ -159,7 +159,7 @@ impl pallet_staking::Config for Test { type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); - type Event = Event; + type Event = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = (); diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 7c6cc02c9e785..b3f80c067da4b 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -256,7 +256,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -298,7 +298,7 @@ impl Config for Test { type ValidatorId = u64; type ValidatorIdOf = TestValidatorIdOf; type Keys = MockSessionKeys; - type Event = Event; + type Event = RuntimeEvent; type NextSessionRotation = (); type WeightInfo = (); } diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 04ea705eed556..8da82a089895b 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -72,7 +72,7 @@ impl frame_system::Config for Test { type AccountId = u128; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -90,7 +90,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -98,7 +98,7 @@ impl pallet_balances::Config for Test { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Currency = pallet_balances::Pallet; type Randomness = TestRandomness; type CandidateDeposit = ConstU64<25>; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index d9dc97f9c1127..380aae485bbd0 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -141,7 +141,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -158,7 +158,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -175,7 +175,7 @@ impl pallet_session::Config for Test { type Keys = SessionKeys; type ShouldEndSession = pallet_session::PeriodicSessions; type SessionHandler = (OtherSessionHandler,); - type Event = Event; + type Event = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = crate::StashOf; type NextSessionRotation = pallet_session::PeriodicSessions; @@ -242,7 +242,7 @@ parameter_types! { } impl pallet_bags_list::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); type ScoreProvider = Staking; type BagThresholds = BagThresholds; @@ -282,7 +282,7 @@ impl crate::pallet::pallet::Config for Test { type UnixTime = Timestamp; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = RewardRemainderMock; - type Event = Event; + type Event = RuntimeEvent; type Slash = (); type Reward = MockReward; type SessionsPerEra = SessionsPerEra; diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 94f6c1f223b9c..b2a5f0f3c11cf 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1086,7 +1086,7 @@ mod mock { type AccountId = u64; type Lookup = IdentityLookup; type Header = sp_runtime::generic::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU32<250>; type DbWeight = (); type Version = (); @@ -1108,7 +1108,7 @@ mod mock { impl pallet_balances::Config for Test { type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -1146,7 +1146,7 @@ mod mock { } impl pallet_state_trie_migration::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type ControlOrigin = EnsureRoot; type Currency = Balances; type MaxKeyLen = MigrationMaxKeyLen; diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 2e2a4abafcd98..7aecb634fbbef 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -133,7 +133,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -148,12 +148,12 @@ impl frame_system::Config for Test { // Implement the logger module's `Config` on the Test runtime. impl logger::Config for Test { - type Event = Event; + type Event = RuntimeEvent; } // Implement the sudo module's `Config` on the Test runtime. impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; } diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 63747a9d560dc..73c8d327a5c48 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -248,7 +248,7 @@ impl system::Config for Runtime { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = AccountId; - type Event = Event; + type Event = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs index c06333795e3c5..ddbc10aa53dac 100644 --- a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs +++ b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs @@ -21,7 +21,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index 827d8a58af733..cd6f724358727 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -55,7 +55,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index 1653e830f0b4f..414187f5bf6ad 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index b8f91cf4bc690..60fec30f0ec03 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index a61d545b3279e..55de9aadf0dd4 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index 6e4764286ab41..a5314cd7bd5ab 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index 9233404a865b9..9d5110f625898 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index 621683aca3754..51c38401e4bbf 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 75a96f628245a..860aba42c8b82 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -233,35 +233,35 @@ mod module3 { } impl module1::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; type SomeParameter = ConstU32<100>; type GenericType = u32; } impl module1::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; type SomeParameter = ConstU32<100>; type GenericType = u32; } impl module2::Config for Runtime { type Amount = u16; - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; } impl module2::Config for Runtime { type Amount = u32; - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; } impl module2::Config for Runtime { type Amount = u32; - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; } impl module2::Config for Runtime { type Amount = u64; - type Event = Event; + type Event = RuntimeEvent; type Origin = Origin; } impl module3::Config for Runtime { @@ -280,7 +280,7 @@ impl system::Config for Runtime { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = AccountId; - type Event = Event; + type Event = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index d7e3d2cb5b135..19737a5e1d6e6 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -163,7 +163,7 @@ impl system::Config for Runtime { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = AccountId; - type Event = Event; + type Event = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index cff531ff2e529..ce7d107302a3e 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -149,7 +149,7 @@ impl system::Config for RuntimeOriginTest { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = u32; - type Event = Event; + type Event = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 6b72327eb4989..a5d890f7c123c 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -558,7 +558,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); @@ -574,7 +574,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type MyGetParam = ConstU32<10>; type MyGetParam2 = ConstU32<11>; type MyGetParam3 = MyGetParam3; @@ -582,7 +582,7 @@ impl pallet::Config for Runtime { } impl pallet2::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; } impl pallet4::Config for Runtime {} diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index 9327f5b6a3304..b28d85f588465 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -235,7 +235,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); @@ -251,12 +251,12 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 3de45df223674..d2d16bdd6c1a5 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -218,7 +218,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU32<250>; type Version = (); type PalletInfo = PalletInfo; @@ -231,32 +231,32 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 360a73e5ea2a3..c6e879075ded8 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -258,7 +258,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); @@ -274,20 +274,20 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type MyGetParam = ConstU32<10>; type Balance = u64; } impl pallet::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type MyGetParam = ConstU32<10>; type Balance = u64; } impl pallet2::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; } impl pallet2::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; } pub type Header = sp_runtime::generic::Header; diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index 05ed60fe90196..c6e9a26e44db7 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -95,7 +95,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU32<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 0bc34fcbc5be2..3c056da69e2eb 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -82,7 +82,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -96,7 +96,7 @@ impl frame_system::Config for Runtime { } impl module::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; } fn new_test_ext() -> sp_io::TestExternalities { diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 08b043ae62741..6edb6a1dfed75 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index b44f89a2ee372..bfd4b5a3ae5dc 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -103,7 +103,7 @@ impl Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<10>; type DbWeight = DbWeight; type Version = Version; diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index 9536414c54db6..b132d797756d4 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 194ecc60d9890..54e45ade06d0e 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -76,7 +76,7 @@ impl frame_system::Config for Test { type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -94,7 +94,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -136,7 +136,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = Event; + type Event = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -155,7 +155,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = Event; + type Event = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -179,7 +179,7 @@ impl Config for Test { type TipFindersFee = TipFindersFee; type TipReportDepositBase = ConstU64<1>; type DataDepositPerByte = ConstU64<1>; - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); } @@ -190,7 +190,7 @@ impl Config for Test { type TipFindersFee = TipFindersFee; type TipReportDepositBase = ConstU64<1>; type DataDepositPerByte = ConstU64<1>; - type Event = Event; + type Event = RuntimeEvent; type WeightInfo = (); } diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index 08b17a6bf459c..abfca86484380 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -96,7 +96,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -115,7 +115,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<10>; type AccountStore = System; @@ -143,7 +143,7 @@ impl WeightToFeeT for TransactionByteFee { } impl pallet_transaction_payment::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type WeightToFee = WeightToFee; type LengthToFee = TransactionByteFee; @@ -152,7 +152,7 @@ impl pallet_transaction_payment::Config for Runtime { } impl pallet_assets::Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Balance = Balance; type AssetId = u32; type Currency = Balances; @@ -198,7 +198,7 @@ impl HandleCredit for CreditToBlockAuthor { } impl Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type Fungibles = Assets; type OnChargeAssetTransaction = FungiblesAdapter< pallet_assets::BalanceToAssetBalance, diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index fe37acb214452..3e6b6b0c1186c 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -848,7 +848,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -863,7 +863,7 @@ mod tests { impl pallet_balances::Config for Runtime { type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -911,7 +911,7 @@ mod tests { } impl Config for Runtime { - type Event = Event; + type Event = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = WeightToFee; diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 771387ef705be..ecfc9bef36d3b 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -60,7 +60,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -77,7 +77,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { } impl pallet_transaction_storage::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type Currency = Balances; type FeeDestination = (); diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 61eafb652427b..a62bcfdfcb3ab 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -88,7 +88,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -126,7 +126,7 @@ impl Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = Event; + type Event = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index ff7b791de4950..8a915986e3256 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -75,7 +75,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -85,7 +85,7 @@ impl pallet_balances::Config for Test { } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type CollectionId = u32; type ItemId = u32; type Currency = Balances; diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 6368473ac8708..ba9bd7e69d0c9 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -115,7 +115,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -134,7 +134,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -163,7 +163,7 @@ impl Contains for TestBaseCallFilter { } } impl Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = (); diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 9ad8e57500e89..3c5a4282ee7b1 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -57,7 +57,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type Call = Call; type DbWeight = (); - type Event = Event; + type Event = RuntimeEvent; type Hash = H256; type Hashing = BlakeTwo256; type Header = Header; @@ -78,7 +78,7 @@ impl pallet_balances::Config for Test { type AccountStore = System; type Balance = u64; type DustRemoval = (); - type Event = Event; + type Event = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type MaxLocks = ConstU32<10>; type MaxReserves = (); @@ -92,7 +92,7 @@ parameter_types! { impl Config for Test { type BlockNumberToBalance = Identity; type Currency = Balances; - type Event = Event; + type Event = RuntimeEvent; const MAX_VESTING_SCHEDULES: u32 = 3; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = (); diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 634db53a09a4e..c0f764ddd3313 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -67,7 +67,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -85,7 +85,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = Event; + type Event = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -93,7 +93,7 @@ impl pallet_balances::Config for Test { } impl pallet_preimage::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; type MaxSize = ConstU32<{ 4096 * 1024 }>; // PreimageMaxSize Taken from Polkadot as reference. @@ -103,7 +103,7 @@ impl pallet_preimage::Config for Test { } impl pallet_whitelist::Config for Test { - type Event = Event; + type Event = RuntimeEvent; type Call = Call; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index e5cfae49da56d..08e0fca5e306a 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -592,7 +592,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type Event = RuntimeEvent; type BlockHashCount = ConstU64<2400>; type DbWeight = (); type Version = (); From 7f14aca63643312ef6f8d593e942c9b571f7ef58 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sat, 6 Aug 2022 12:07:28 +0200 Subject: [PATCH 06/63] small fix & rename RuntimeCall back to Call for now --- bin/node-template/runtime/src/lib.rs | 8 +- bin/node/runtime/src/lib.rs | 83 +++++++++---------- frame/bags-list/src/mock.rs | 2 +- frame/staking/src/mock.rs | 2 +- frame/staking/src/tests.rs | 15 ++-- .../src/construct_runtime/expand/call.rs | 20 ++--- frame/support/test/compile_pass/src/lib.rs | 3 +- frame/system/src/mock.rs | 2 +- test-utils/runtime/src/lib.rs | 2 +- 9 files changed, 64 insertions(+), 73 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index c63d856bd45e5..baae4c503fbba 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -156,7 +156,7 @@ impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The aggregated dispatch type that is available for extrinsics. - type Call = RuntimeCall; + type Call = Call; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. @@ -208,7 +208,7 @@ impl pallet_aura::Config for Runtime { impl pallet_grandpa::Config for Runtime { type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; type KeyOwnerProofSystem = (); @@ -262,7 +262,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; } /// Configure the pallet-template in pallets/template. @@ -308,7 +308,7 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, ); -type Call = RuntimeCall; + /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// The payload being signed in transactions. diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index cd1d687e3712e..61320c56f526a 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -205,7 +205,7 @@ impl frame_system::Config for Runtime { type BlockLength = RuntimeBlockLength; type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = RuntimeCall; + type Call = Call; type Index = Index; type BlockNumber = BlockNumber; type Hash = Hash; @@ -230,7 +230,7 @@ impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_utility::Config for Runtime { type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = pallet_utility::weights::SubstrateWeight; } @@ -244,7 +244,7 @@ parameter_types! { impl pallet_multisig::Config for Runtime { type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -286,28 +286,25 @@ impl Default for ProxyType { Self::Any } } -impl InstanceFilter for ProxyType { - fn filter(&self, c: &RuntimeCall) -> bool { +impl InstanceFilter for ProxyType { + fn filter(&self, c: &Call) -> bool { match self { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - RuntimeCall::Balances(..) | - RuntimeCall::Assets(..) | - RuntimeCall::Uniques(..) | - RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) | - RuntimeCall::Indices(pallet_indices::Call::transfer { .. }) + Call::Balances(..) | + Call::Assets(..) | Call::Uniques(..) | + Call::Vesting(pallet_vesting::Call::vested_transfer { .. }) | + Call::Indices(pallet_indices::Call::transfer { .. }) ), ProxyType::Governance => matches!( c, - RuntimeCall::Democracy(..) | - RuntimeCall::Council(..) | - RuntimeCall::Society(..) | - RuntimeCall::TechnicalCommittee(..) | - RuntimeCall::Elections(..) | - RuntimeCall::Treasury(..) + Call::Democracy(..) | + Call::Council(..) | Call::Society(..) | + Call::TechnicalCommittee(..) | + Call::Elections(..) | Call::Treasury(..) ), - ProxyType::Staking => matches!(c, RuntimeCall::Staking(..)), + ProxyType::Staking => matches!(c, Call::Staking(..)), } } fn is_superset(&self, o: &Self) -> bool { @@ -323,7 +320,7 @@ impl InstanceFilter for ProxyType { impl pallet_proxy::Config for Runtime { type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -347,7 +344,7 @@ impl pallet_scheduler::Config for Runtime { type Event = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = RuntimeCall; + type Call = Call; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<50>; @@ -830,7 +827,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; - type Call = RuntimeCall; + type Call = Call; type Event = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -849,7 +846,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; - type Call = RuntimeCall; + type Call = Call; type Event = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -892,7 +889,7 @@ parameter_types! { } impl pallet_democracy::Config for Runtime { - type Proposal = RuntimeCall; + type Proposal = Call; type Event = RuntimeEvent; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; @@ -951,7 +948,7 @@ parameter_types! { type CouncilCollective = pallet_collective::Instance1; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = RuntimeCall; + type Proposal = Call; type Event = RuntimeEvent; type MotionDuration = CouncilMotionDuration; type MaxProposals = CouncilMaxProposals; @@ -1004,7 +1001,7 @@ parameter_types! { type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = RuntimeCall; + type Proposal = Call; type Event = RuntimeEvent; type MotionDuration = TechnicalMotionDuration; type MaxProposals = TechnicalMaxProposals; @@ -1136,7 +1133,7 @@ impl pallet_contracts::Config for Runtime { type Randomness = RandomnessCollectiveFlip; type Currency = Balances; type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; /// The safest default is to allow no calls at all. /// /// Runtimes should whitelist dispatchables that are allowed to be called from contracts @@ -1162,7 +1159,7 @@ impl pallet_contracts::Config for Runtime { impl pallet_sudo::Config for Runtime { type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; } parameter_types! { @@ -1177,14 +1174,14 @@ parameter_types! { impl frame_system::offchain::CreateSignedTransaction for Runtime where - RuntimeCall: From, + Call: From, { fn create_transaction>( - call: RuntimeCall, + call: Call, public: ::Signer, account: AccountId, nonce: Index, - ) -> Option<(RuntimeCall, ::SignaturePayload)> { + ) -> Option<(Call, ::SignaturePayload)> { let tip = 0; // take the biggest period possible. let period = @@ -1224,10 +1221,10 @@ impl frame_system::offchain::SigningTypes for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - RuntimeCall: From, + Call: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = RuntimeCall; + type OverarchingCall = Call; } impl pallet_im_online::Config for Runtime { @@ -1255,7 +1252,7 @@ impl pallet_authority_discovery::Config for Runtime { impl pallet_grandpa::Config for Runtime { type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; type KeyOwnerProofSystem = Historical; @@ -1311,7 +1308,7 @@ parameter_types! { impl pallet_recovery::Config for Runtime { type Event = RuntimeEvent; type WeightInfo = pallet_recovery::weights::SubstrateWeight; - type Call = RuntimeCall; + type Call = Call; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; @@ -1382,7 +1379,7 @@ parameter_types! { impl pallet_lottery::Config for Runtime { type PalletId = LotteryPalletId; - type Call = RuntimeCall; + type Call = Call; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; type Event = RuntimeEvent; @@ -1478,7 +1475,7 @@ impl pallet_uniques::Config for Runtime { impl pallet_transaction_storage::Config for Runtime { type Event = RuntimeEvent; type Currency = Balances; - type Call = RuntimeCall; + type Call = Call; type FeeDestination = (); type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight; type MaxBlockTransactions = @@ -1489,7 +1486,7 @@ impl pallet_transaction_storage::Config for Runtime { impl pallet_whitelist::Config for Runtime { type Event = RuntimeEvent; - type Call = RuntimeCall; + type Call = Call; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type PreimageProvider = Preimage; @@ -1526,7 +1523,7 @@ parameter_types! { type AllianceCollective = pallet_collective::Instance3; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = RuntimeCall; + type Proposal = Call; type Event = RuntimeEvent; type MotionDuration = AllianceMotionDuration; type MaxProposals = AllianceMaxProposals; @@ -1544,7 +1541,7 @@ parameter_types! { impl pallet_alliance::Config for Runtime { type Event = RuntimeEvent; - type Proposal = RuntimeCall; + type Proposal = Call; type AdminOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, @@ -1668,13 +1665,13 @@ pub type SignedExtra = ( frame_system::CheckWeight, pallet_asset_tx_payment::ChargeAssetTxPayment, ); -type Call = RuntimeCall; + /// Unchecked extrinsic type as expected by this runtime. pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; +pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -2146,7 +2143,7 @@ mod tests { fn validate_transaction_submitter_bounds() { fn is_submit_signed_transaction() where - T: CreateSignedTransaction, + T: CreateSignedTransaction, { } @@ -2166,7 +2163,7 @@ mod tests { #[test] fn call_size() { - let size = core::mem::size_of::(); + let size = core::mem::size_of::(); assert!( size <= 208, "size of Call {} is more than 208 bytes: some calls have too big arguments, use Box to reduce the diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index b9b48ff0df933..5284a030cb414 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type Call = Call; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 380aae485bbd0..38634466b4569 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -305,7 +305,7 @@ impl crate::pallet::pallet::Config for Test { } pub(crate) type StakingCall = crate::Call; -pub(crate) type TestRuntimeCall = ::Call; +pub(crate) type TestCall = ::Call; pub struct ExtBuilder { nominate: bool, diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index d14d8c4a75f2e..a5e16ccd35421 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -3785,8 +3785,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(2); // Collect payouts when there are no nominators - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 1 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 1 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3799,8 +3798,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(3); // Collect payouts for an era where the validator did not receive any points. - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 2 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 2 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3813,8 +3811,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(4); // Collect payouts when the validator has `half_max_nom_rewarded` nominators. - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 3 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 3 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3837,16 +3834,14 @@ fn payout_stakers_handles_weight_refund() { start_active_era(6); // Collect payouts when the validator had `half_max_nom_rewarded` nominators. - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); assert_eq!(extract_actual_weight(&result, &info), max_nom_rewarded_weight); // Try and collect payouts for an era that has already been collected. - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert!(result.is_err()); diff --git a/frame/support/procedural/src/construct_runtime/expand/call.rs b/frame/support/procedural/src/construct_runtime/expand/call.rs index bce550b37cb60..801b69035121d 100644 --- a/frame/support/procedural/src/construct_runtime/expand/call.rs +++ b/frame/support/procedural/src/construct_runtime/expand/call.rs @@ -42,7 +42,7 @@ pub fn expand_outer_dispatch( variant_defs.extend( quote!(#[codec(index = #index)] #name( #scrate::dispatch::CallableCallFor<#name, #runtime> ),), ); - variant_patterns.push(quote!(RuntimeCall::#name(call))); + variant_patterns.push(quote!(Call::#name(call))); pallet_names.push(name); query_call_part_macros.push(quote! { #path::__substrate_call_check::is_call_part_defined!(#name); @@ -59,11 +59,11 @@ pub fn expand_outer_dispatch( #scrate::scale_info::TypeInfo, #scrate::RuntimeDebug, )] - pub enum RuntimeCall { + pub enum Call { #variant_defs } #[cfg(test)] - impl RuntimeCall { + impl Call { /// Return a list of the module names together with their size in memory. pub const fn sizes() -> &'static [( &'static str, usize )] { use #scrate::dispatch::Callable; @@ -98,14 +98,14 @@ pub fn expand_outer_dispatch( } } } - impl #scrate::dispatch::GetDispatchInfo for RuntimeCall { + impl #scrate::dispatch::GetDispatchInfo for Call { fn get_dispatch_info(&self) -> #scrate::dispatch::DispatchInfo { match self { #( #variant_patterns => call.get_dispatch_info(), )* } } } - impl #scrate::dispatch::GetCallMetadata for RuntimeCall { + impl #scrate::dispatch::GetCallMetadata for Call { fn get_call_metadata(&self) -> #scrate::dispatch::CallMetadata { use #scrate::dispatch::GetCallName; match self { @@ -137,9 +137,9 @@ pub fn expand_outer_dispatch( } } } - impl #scrate::dispatch::Dispatchable for RuntimeCall { + impl #scrate::dispatch::Dispatchable for Call { type Origin = Origin; - type Config = RuntimeCall; + type Config = Call; type Info = #scrate::weights::DispatchInfo; type PostInfo = #scrate::weights::PostDispatchInfo; fn dispatch(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo { @@ -152,7 +152,7 @@ pub fn expand_outer_dispatch( #scrate::traits::UnfilteredDispatchable::dispatch_bypass_filter(self, origin) } } - impl #scrate::traits::UnfilteredDispatchable for RuntimeCall { + impl #scrate::traits::UnfilteredDispatchable for Call { type Origin = Origin; fn dispatch_bypass_filter(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo { match self { @@ -165,7 +165,7 @@ pub fn expand_outer_dispatch( } #( - impl #scrate::traits::IsSubType<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for RuntimeCall { + impl #scrate::traits::IsSubType<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for Call { #[allow(unreachable_patterns)] fn is_sub_type(&self) -> Option<&#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> { match self { @@ -176,7 +176,7 @@ pub fn expand_outer_dispatch( } } - impl From<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for RuntimeCall { + impl From<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for Call { fn from(call: #scrate::dispatch::CallableCallFor<#pallet_names, #runtime>) -> Self { #variant_patterns } diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 7a54294bfc52e..723eadb85fed2 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -70,7 +70,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Event = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = RuntimeCall; + type Call = Call; type DbWeight = (); type OnNewAccount = (); type OnKilledAccount = (); @@ -82,7 +82,6 @@ impl frame_system::Config for Runtime { pub type Header = generic::Header; pub type Block = generic::Block; -pub type Call = RuntimeCall; pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; construct_runtime!( diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index bfd4b5a3ae5dc..714f6cf5ecdcf 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -95,7 +95,7 @@ impl Config for Test { type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; - type Call = RuntimeCall; + type Call = Call; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 08e0fca5e306a..e5cfae49da56d 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -592,7 +592,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type Event = Event; type BlockHashCount = ConstU64<2400>; type DbWeight = (); type Version = (); From c9b7f0839b4a8a3c82cc5193a9b2dc5f2e70948c Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sat, 6 Aug 2022 12:18:46 +0200 Subject: [PATCH 07/63] small fixes --- frame/benchmarking/src/tests_instance.rs | 2 +- frame/sudo/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 9bd33a903207c..7fc4208c9872f 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -120,7 +120,7 @@ impl pallet_test::Config for Test { } impl pallet_test::OtherConfig for Test { - type OtherEvent = Event; + type OtherEvent = RuntimeEvent; } fn new_test_ext() -> sp_io::TestExternalities { diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index 84c8e0c5c254e..4a5730088b21b 100644 --- a/frame/sudo/src/tests.rs +++ b/frame/sudo/src/tests.rs @@ -20,7 +20,7 @@ use super::*; use frame_support::{assert_noop, assert_ok}; use mock::{ - new_test_ext, Call, Event as TestEvent, Logger, LoggerCall, Origin, Sudo, SudoCall, System, + new_test_ext, Call, RuntimeEvent as TestEvent, Logger, LoggerCall, Origin, Sudo, SudoCall, System, Test, }; From bb71d3755bbd5f6f0e5b42464e55a3e00abe0384 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 7 Aug 2022 08:27:55 +0200 Subject: [PATCH 08/63] more renaming --- frame/alliance/src/tests.rs | 34 ++--- frame/balances/src/tests.rs | 40 +++--- frame/balances/src/tests_local.rs | 14 +- frame/balances/src/tests_reentrancy.rs | 18 +-- frame/bounties/src/tests.rs | 2 +- frame/child-bounties/src/tests.rs | 2 +- frame/collective/src/tests.rs | 120 +++++++++--------- frame/contracts/src/exec.rs | 2 +- frame/contracts/src/tests.rs | 112 ++++++++-------- .../election-provider-multi-phase/src/mock.rs | 2 +- frame/elections-phragmen/src/lib.rs | 10 +- frame/nomination-pools/src/mock.rs | 4 +- .../nomination-pools/test-staking/src/mock.rs | 4 +- frame/offences/src/tests.rs | 6 +- frame/proxy/src/tests.rs | 4 +- frame/staking/src/mock.rs | 4 +- frame/support/test/tests/construct_runtime.rs | 22 ++-- frame/support/test/tests/pallet.rs | 28 ++-- frame/support/test/tests/pallet_instance.rs | 16 +-- frame/tips/src/tests.rs | 2 +- frame/transaction-payment/src/lib.rs | 6 +- frame/uniques/src/tests.rs | 2 +- 22 files changed, 227 insertions(+), 227 deletions(-) diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index 85c91b451d351..de546446321b0 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -52,7 +52,7 @@ fn propose_works() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: mock::Event::AllianceMotion(AllianceMotionEvent::Proposed { + event: mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, @@ -82,13 +82,13 @@ fn vote_works() { assert_eq!( System::events(), vec![ - record(mock::Event::AllianceMotion(AllianceMotionEvent::Proposed { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash.clone(), threshold: 3 })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Voted { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted { account: 2, proposal_hash: hash.clone(), voted: true, @@ -140,19 +140,19 @@ fn veto_works() { assert_eq!( System::events(), vec![ - record(mock::Event::AllianceMotion(AllianceMotionEvent::Proposed { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash.clone(), threshold: 3 })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Proposed { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed { account: 1, proposal_index: 1, proposal_hash: vetoable_hash.clone(), threshold: 3 })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Disapproved { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Disapproved { proposal_hash: vetoable_hash.clone() })), ] @@ -188,42 +188,42 @@ fn close_works() { assert_eq!( System::events(), vec![ - record(mock::Event::AllianceMotion(AllianceMotionEvent::Proposed { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash.clone(), threshold: 3 })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Voted { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted { account: 1, proposal_hash: hash.clone(), voted: true, yes: 1, no: 0, })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Voted { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted { account: 2, proposal_hash: hash.clone(), voted: true, yes: 2, no: 0, })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Voted { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Voted { account: 3, proposal_hash: hash.clone(), voted: true, yes: 3, no: 0, })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Closed { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Closed { proposal_hash: hash.clone(), yes: 3, no: 0, })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Approved { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Approved { proposal_hash: hash.clone() })), - record(mock::Event::AllianceMotion(AllianceMotionEvent::Executed { + record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Executed { proposal_hash: hash.clone(), result: Err(DispatchError::BadOrigin), })) @@ -239,7 +239,7 @@ fn set_rule_works() { assert_ok!(Alliance::set_rule(Origin::signed(1), cid.clone())); assert_eq!(Alliance::rule(), Some(cid.clone())); - System::assert_last_event(mock::Event::Alliance(crate::Event::NewRuleSet { rule: cid })); + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::NewRuleSet { rule: cid })); }); } @@ -250,7 +250,7 @@ fn announce_works() { assert_ok!(Alliance::announce(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![cid.clone()]); - System::assert_last_event(mock::Event::Alliance(crate::Event::Announced { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced { announcement: cid, })); }); @@ -262,7 +262,7 @@ fn remove_announcement_works() { let cid = test_cid(); assert_ok!(Alliance::announce(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![cid.clone()]); - System::assert_last_event(mock::Event::Alliance(crate::Event::Announced { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced { announcement: cid.clone(), })); @@ -270,7 +270,7 @@ fn remove_announcement_works() { assert_ok!(Alliance::remove_announcement(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![]); - System::assert_last_event(mock::Event::Alliance(crate::Event::AnnouncementRemoved { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::AnnouncementRemoved { announcement: cid, })); }); diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 8f5470ae3cac2..0c59bc6d9d499 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -46,7 +46,7 @@ macro_rules! decl_tests { DispatchInfo { weight: w, ..Default::default() } } - fn events() -> Vec { + fn events() -> Vec { let evt = System::events().into_iter().map(|evt| evt.event).collect::>(); 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!(>::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!(>::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); @@ -724,18 +724,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 })); }); } @@ -750,9 +750,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 }), ] ); @@ -762,9 +762,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 }), ] ); }); @@ -781,9 +781,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 }), ] ); @@ -793,8 +793,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 }), ] ); }); @@ -814,7 +814,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)); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 155d75b521bcb..22fb377759fa3 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -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,7 @@ 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 +176,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 }) ] ); }); diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index 4ff10f3f69bc3..95861ef88115d 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -157,16 +157,16 @@ 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 +192,16 @@ 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 +236,18 @@ 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 })); }); } diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index c38c97ba9ea8d..55a83c67c04c6 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -208,7 +208,7 @@ fn last_event() -> BountiesEvent { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::Bounties(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let RuntimeEvent::Bounties(inner) = e { Some(inner) } else { None }) .last() .unwrap() } diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index bd19f16b65f63..5937a1295116d 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -176,7 +176,7 @@ fn last_event() -> ChildBountiesEvent { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::ChildBounties(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let RuntimeEvent::ChildBounties(inner) = e { Some(inner) } else { None }) .last() .unwrap() } diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index e1b726acf9c98..bb0ce465f3088 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -175,7 +175,7 @@ fn make_proposal(value: u64) -> Call { Call::System(frame_system::Call::remark_with_event { remark: value.to_be_bytes().to_vec() }) } -fn record(event: Event) -> EventRecord { +fn record(event: RuntimeEvent) -> EventRecord { EventRecord { phase: Phase::Initialization, event, topics: vec![] } } @@ -216,32 +216,32 @@ fn close_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 3 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: true, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Closed { + record(RuntimeEvent::Collective(CollectiveEvent::Closed { proposal_hash: hash, yes: 2, no: 1 })), - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) ] ); }); @@ -336,32 +336,32 @@ fn close_with_prime_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 3 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: true, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Closed { + record(RuntimeEvent::Collective(CollectiveEvent::Closed { proposal_hash: hash, yes: 2, no: 1 })), - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) ] ); }); @@ -396,33 +396,33 @@ fn close_with_voting_prime_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 3 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: true, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Closed { + record(RuntimeEvent::Collective(CollectiveEvent::Closed { proposal_hash: hash, yes: 3, no: 0 })), - record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::Collective(CollectiveEvent::Executed { + record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Executed { proposal_hash: hash, result: Err(DispatchError::BadOrigin) })) @@ -467,42 +467,42 @@ fn close_with_no_prime_but_majority_works() { assert_eq!( System::events(), vec![ - record(Event::CollectiveMajority(CollectiveEvent::Proposed { + record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 5 })), - record(Event::CollectiveMajority(CollectiveEvent::Voted { + record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::CollectiveMajority(CollectiveEvent::Voted { + record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: true, yes: 2, no: 0 })), - record(Event::CollectiveMajority(CollectiveEvent::Voted { + record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Voted { account: 3, proposal_hash: hash, voted: true, yes: 3, no: 0 })), - record(Event::CollectiveMajority(CollectiveEvent::Closed { + record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Closed { proposal_hash: hash, yes: 5, no: 0 })), - record(Event::CollectiveMajority(CollectiveEvent::Approved { + record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::CollectiveMajority(CollectiveEvent::Executed { + record(RuntimeEvent::CollectiveMajority(CollectiveEvent::Executed { proposal_hash: hash, result: Err(DispatchError::BadOrigin) })) @@ -629,7 +629,7 @@ fn propose_works() { assert_eq!( System::events(), - vec![record(Event::Collective(CollectiveEvent::Proposed { + vec![record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, @@ -793,20 +793,20 @@ fn motions_vote_after_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 2 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: false, @@ -926,33 +926,33 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 2 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: true, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Closed { + record(RuntimeEvent::Collective(CollectiveEvent::Closed { proposal_hash: hash, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::Collective(CollectiveEvent::Executed { + record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Executed { proposal_hash: hash, result: Err(DispatchError::BadOrigin) })), @@ -975,41 +975,41 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 1, proposal_hash: hash, threshold: 2 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: true, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 3, proposal_hash: hash, voted: true, yes: 3, no: 0 })), - record(Event::Collective(CollectiveEvent::Closed { + record(RuntimeEvent::Collective(CollectiveEvent::Closed { proposal_hash: hash, yes: 3, no: 0 })), - record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::Democracy(mock_democracy::pallet::Event::::ExternalProposed)), - record(Event::Collective(CollectiveEvent::Executed { + record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), + record(RuntimeEvent::Democracy(mock_democracy::pallet::Event::::ExternalProposed)), + record(RuntimeEvent::Collective(CollectiveEvent::Executed { proposal_hash: hash, result: Ok(()) })), @@ -1038,32 +1038,32 @@ fn motions_disapproval_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 3 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: false, yes: 1, no: 1 })), - record(Event::Collective(CollectiveEvent::Closed { + record(RuntimeEvent::Collective(CollectiveEvent::Closed { proposal_hash: hash, yes: 1, no: 1 })), - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })), ] ); }); @@ -1089,33 +1089,33 @@ fn motions_approval_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 2 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: true, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Closed { + record(RuntimeEvent::Collective(CollectiveEvent::Closed { proposal_hash: hash, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(Event::Collective(CollectiveEvent::Executed { + record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Executed { proposal_hash: hash, result: Err(DispatchError::BadOrigin) })), @@ -1139,7 +1139,7 @@ fn motion_with_no_votes_closes_with_disapproval() { )); assert_eq!( System::events()[0], - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, @@ -1163,7 +1163,7 @@ fn motion_with_no_votes_closes_with_disapproval() { // Events show that the close ended in a disapproval. assert_eq!( System::events()[1], - record(Event::Collective(CollectiveEvent::Closed { + record(RuntimeEvent::Collective(CollectiveEvent::Closed { proposal_hash: hash, yes: 0, no: 3 @@ -1171,7 +1171,7 @@ fn motion_with_no_votes_closes_with_disapproval() { ); assert_eq!( System::events()[2], - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) ); }) } @@ -1231,27 +1231,27 @@ fn disapprove_proposal_works() { assert_eq!( System::events(), vec![ - record(Event::Collective(CollectiveEvent::Proposed { + record(RuntimeEvent::Collective(CollectiveEvent::Proposed { account: 1, proposal_index: 0, proposal_hash: hash, threshold: 2 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 1, proposal_hash: hash, voted: true, yes: 1, no: 0 })), - record(Event::Collective(CollectiveEvent::Voted { + record(RuntimeEvent::Collective(CollectiveEvent::Voted { account: 2, proposal_hash: hash, voted: true, yes: 2, no: 0 })), - record(Event::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })), ] ); }) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 5ca74e681e5dd..2b47c9988f5c5 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1348,7 +1348,7 @@ mod tests { storage::Storage, tests::{ test_utils::{get_balance, place_contract, set_balance}, - Call, Event as MetaEvent, ExtBuilder, Test, TestFilter, ALICE, BOB, CHARLIE, GAS_LIMIT, + Call, RuntimeEvent as MetaEvent, ExtBuilder, Test, TestFilter, ALICE, BOB, CHARLIE, GAS_LIMIT, }, Error, }; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 6889fd770a40d..c6592c46ca0ec 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -516,12 +516,12 @@ fn instantiate_and_call_and_deposit_event() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -529,7 +529,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -538,7 +538,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance, }), @@ -546,7 +546,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: value, @@ -555,7 +555,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::ContractEmitted { + event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { contract: addr.clone(), data: vec![1, 2, 3, 4] }), @@ -563,7 +563,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Instantiated { + event: RuntimeEvent::Contracts(crate::Event::Instantiated { deployer: ALICE, contract: addr.clone() }), @@ -808,14 +808,14 @@ fn deploy_and_call_other_contract() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: callee_addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: callee_addr.clone(), free_balance: min_balance, }), @@ -823,7 +823,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: callee_addr.clone(), amount: min_balance, @@ -832,7 +832,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: callee_addr.clone(), amount: min_balance, }), @@ -840,7 +840,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: caller_addr.clone(), to: callee_addr.clone(), amount: 32768, // hard coded in wasm @@ -849,7 +849,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Instantiated { + event: RuntimeEvent::Contracts(crate::Event::Instantiated { deployer: caller_addr.clone(), contract: callee_addr.clone(), }), @@ -857,7 +857,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: caller_addr.clone(), to: callee_addr.clone(), amount: 32768, @@ -1057,7 +1057,7 @@ fn cannot_self_destruct_by_refund_after_slash() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Slashed { + event: RuntimeEvent::Balances(pallet_balances::Event::Slashed { who: addr.clone(), amount: 90, }), @@ -1065,7 +1065,7 @@ fn cannot_self_destruct_by_refund_after_slash() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::ReserveRepatriated { + event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { from: addr.clone(), to: ALICE, amount: 10, @@ -1157,7 +1157,7 @@ fn self_destruct_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: addr.clone(), to: DJANGO, amount: 100_000, @@ -1166,7 +1166,7 @@ fn self_destruct_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Terminated { + event: RuntimeEvent::Contracts(crate::Event::Terminated { contract: addr.clone(), beneficiary: DJANGO }), @@ -1174,14 +1174,14 @@ fn self_destruct_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::KilledAccount { + event: RuntimeEvent::System(frame_system::Event::KilledAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::ReserveRepatriated { + event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { from: addr.clone(), to: ALICE, amount: 1_000, @@ -2607,7 +2607,7 @@ fn upload_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2615,7 +2615,7 @@ fn upload_code_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, ] @@ -2686,7 +2686,7 @@ fn remove_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2694,12 +2694,12 @@ fn remove_code_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Unreserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Unreserved { who: ALICE, amount: 240, }), @@ -2707,7 +2707,7 @@ fn remove_code_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeRemoved { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeRemoved { code_hash }), topics: vec![], }, ] @@ -2741,7 +2741,7 @@ fn remove_code_wrong_origin() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2749,7 +2749,7 @@ fn remove_code_wrong_origin() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, ] @@ -2842,12 +2842,12 @@ fn instantiate_with_zero_balance_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -2855,7 +2855,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -2864,7 +2864,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance, }), @@ -2872,7 +2872,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2880,12 +2880,12 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Instantiated { + event: RuntimeEvent::Contracts(crate::Event::Instantiated { deployer: ALICE, contract: addr.clone(), }), @@ -2933,12 +2933,12 @@ fn instantiate_with_below_existential_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -2946,7 +2946,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -2955,7 +2955,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance, }), @@ -2963,7 +2963,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: 50, @@ -2972,7 +2972,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2980,12 +2980,12 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Instantiated { + event: RuntimeEvent::Contracts(crate::Event::Instantiated { deployer: ALICE, contract: addr.clone(), }), @@ -3062,7 +3062,7 @@ fn storage_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: 42, @@ -3071,7 +3071,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: charged0, @@ -3080,7 +3080,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: charged0, }), @@ -3088,7 +3088,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: charged1, @@ -3097,7 +3097,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: charged1, }), @@ -3105,7 +3105,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::ReserveRepatriated { + event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { from: addr.clone(), to: ALICE, amount: refunded0, @@ -3187,7 +3187,7 @@ fn set_code_extrinsic() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: Event::Contracts(pallet_contracts::Event::ContractCodeUpdated { + event: RuntimeEvent::Contracts(pallet_contracts::Event::ContractCodeUpdated { contract: addr, new_code_hash, old_code_hash: code_hash, @@ -3266,14 +3266,14 @@ fn call_after_killed_account_needs_funding() { vec![ EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::KilledAccount { + event: RuntimeEvent::System(frame_system::Event::KilledAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Slashed { + event: RuntimeEvent::Balances(pallet_balances::Event::Slashed { who: addr.clone(), amount: min_balance + 700 }), @@ -3281,12 +3281,12 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: Event::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: addr.clone(), free_balance: min_balance }), @@ -3294,7 +3294,7 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: min_balance @@ -3475,7 +3475,7 @@ fn set_code_hash() { System::events().pop().unwrap(), EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::ContractCodeUpdated { + event: RuntimeEvent::Contracts(crate::Event::ContractCodeUpdated { contract: contract_addr.clone(), new_code_hash: new_code_hash.clone(), old_code_hash: code_hash.clone(), diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 32a9ce4ed3bc0..7585daa449816 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -85,7 +85,7 @@ pub(crate) fn multi_phase_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::MultiPhase(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let RuntimeEvent::MultiPhase(inner) = e { Some(inner) } else { None }) .collect::>() } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 14a399cbae8bd..517b487c783d2 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -2193,7 +2193,7 @@ mod tests { System::set_block_number(5); Elections::on_initialize(System::block_number()); - System::assert_last_event(Event::Elections(super::Event::EmptyTerm)); + System::assert_last_event(RuntimeEvent::Elections(super::Event::EmptyTerm)); }) } @@ -2209,7 +2209,7 @@ mod tests { System::set_block_number(5); Elections::on_initialize(System::block_number()); - System::assert_last_event(Event::Elections(super::Event::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { new_members: vec![(4, 35), (5, 45)], })); @@ -2222,7 +2222,7 @@ mod tests { System::set_block_number(10); Elections::on_initialize(System::block_number()); - System::assert_last_event(Event::Elections(super::Event::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { new_members: vec![], })); @@ -2294,7 +2294,7 @@ mod tests { assert_eq!(Elections::election_rounds(), 1); assert!(members_ids().is_empty()); - System::assert_last_event(Event::Elections(super::Event::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { new_members: vec![], })); }); @@ -2602,7 +2602,7 @@ mod tests { // 5 is an outgoing loser. will also get slashed. assert_eq!(balances(&5), (45, 2)); - System::assert_has_event(Event::Elections(super::Event::NewTerm { + System::assert_has_event(RuntimeEvent::Elections(super::Event::NewTerm { new_members: vec![(4, 35), (5, 45)], })); }) diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 41aa70c379547..3547878e49ee5 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -328,7 +328,7 @@ pub(crate) fn pool_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::Pools(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let RuntimeEvent::Pools(inner) = e { Some(inner) } else { None }) .collect::>(); let already_seen = PoolsEvents::get(); PoolsEvents::set(&(events.len() as u32)); @@ -340,7 +340,7 @@ pub(crate) fn balances_events_since_last_call() -> Vec>(); let already_seen = BalancesEvents::get(); BalancesEvents::set(&(events.len() as u32)); diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 74cb62c34a83d..f0ac954ef96c4 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -248,7 +248,7 @@ pub(crate) fn pool_events_since_last_call() -> Vec>(); let already_seen = ObservedEventsPools::get(); ObservedEventsPools::set(events.len()); @@ -259,7 +259,7 @@ pub(crate) fn staking_events_since_last_call() -> Vec>(); let already_seen = ObservedEventsStaking::get(); ObservedEventsStaking::set(events.len()); diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index 49bd2fb5a6923..8c1f4dfcf5f79 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -21,7 +21,7 @@ use super::*; use crate::mock::{ - new_test_ext, offence_reports, report_id, with_on_offence_fractions, Event, Offence, Offences, + new_test_ext, offence_reports, report_id, with_on_offence_fractions, RuntimeEvent, Offence, Offences, System, KIND, }; use frame_system::{EventRecord, Phase}; @@ -114,7 +114,7 @@ fn should_deposit_event() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: Event::Offences(crate::Event::Offence { + event: RuntimeEvent::Offences(crate::Event::Offence { kind: KIND, timeslot: time_slot.encode() }), @@ -148,7 +148,7 @@ fn doesnt_deposit_event_for_dups() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: Event::Offences(crate::Event::Offence { + event: RuntimeEvent::Offences(crate::Event::Offence { kind: KIND, timeslot: time_slot.encode() }), diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 11d8e190452cf..d3d2e7c585a82 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -183,7 +183,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { ext } -fn last_events(n: usize) -> Vec { +fn last_events(n: usize) -> Vec { system::Pallet::::events() .into_iter() .rev() @@ -193,7 +193,7 @@ fn last_events(n: usize) -> Vec { .collect() } -fn expect_events(e: Vec) { +fn expect_events(e: Vec) { assert_eq!(last_events(e.len()), e); } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 38634466b4569..4023be22bdec8 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -872,7 +872,7 @@ pub(crate) fn staking_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::Staking(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let RuntimeEvent::Staking(inner) = e { Some(inner) } else { None }) .collect() } @@ -883,7 +883,7 @@ parameter_types! { pub(crate) fn staking_events_since_last_call() -> Vec> { let all: Vec<_> = System::events() .into_iter() - .filter_map(|r| if let Event::Staking(inner) = r.event { Some(inner) } else { None }) + .filter_map(|r| if let RuntimeEvent::Staking(inner) = r.event { Some(inner) } else { None }) .collect(); let seen = StakingEventsIndex::get(); StakingEventsIndex::set(all.len()); diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 73c8d327a5c48..13973377a5d9c 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -418,37 +418,37 @@ fn event_codec() { use codec::Encode; let event = system::Event::::ExtrinsicSuccess; - assert_eq!(Event::from(event).encode()[0], 30); + assert_eq!(RuntimeEvent::from(event).encode()[0], 30); let event = module1::Event::::A(test_pub()); - assert_eq!(Event::from(event).encode()[0], 31); + assert_eq!(RuntimeEvent::from(event).encode()[0], 31); let event = module2::Event::A; - assert_eq!(Event::from(event).encode()[0], 32); + assert_eq!(RuntimeEvent::from(event).encode()[0], 32); let event = module1::Event::::A(test_pub()); - assert_eq!(Event::from(event).encode()[0], 33); + assert_eq!(RuntimeEvent::from(event).encode()[0], 33); let event = nested::module3::Event::A; - assert_eq!(Event::from(event).encode()[0], 34); + assert_eq!(RuntimeEvent::from(event).encode()[0], 34); let event = module3::Event::A; - assert_eq!(Event::from(event).encode()[0], 35); + assert_eq!(RuntimeEvent::from(event).encode()[0], 35); let event = module1::Event::::A(test_pub()); - assert_eq!(Event::from(event).encode()[0], 4); + assert_eq!(RuntimeEvent::from(event).encode()[0], 4); let event = module1::Event::::A(test_pub()); - assert_eq!(Event::from(event).encode()[0], 1); + assert_eq!(RuntimeEvent::from(event).encode()[0], 1); let event = module1::Event::::A(test_pub()); - assert_eq!(Event::from(event).encode()[0], 2); + assert_eq!(RuntimeEvent::from(event).encode()[0], 2); let event = module1::Event::::A(test_pub()); - assert_eq!(Event::from(event).encode()[0], 12); + assert_eq!(RuntimeEvent::from(event).encode()[0], 12); let event = module1::Event::::A(test_pub()); - assert_eq!(Event::from(event).encode()[0], 13); + assert_eq!(RuntimeEvent::from(event).encode()[0], 13); } #[test] diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index a5d890f7c123c..beefc69b596a3 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -631,7 +631,7 @@ fn transactional_works() { .iter() .map(|e| &e.event) .collect::>(), - vec![&Event::Example(pallet::Event::Something(0))], + vec![&RuntimeEvent::Example(pallet::Event::Something(0))], ); }) } @@ -887,7 +887,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example(pallet::Event::Something(3)), + RuntimeEvent::Example(pallet::Event::Something(3)), ); }) } @@ -994,27 +994,27 @@ fn pallet_hooks_expand() { assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example(pallet::Event::Something(10)), + RuntimeEvent::Example(pallet::Event::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - Event::Example2(pallet2::Event::Something(11)), + RuntimeEvent::Example2(pallet2::Event::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - Event::Example(pallet::Event::Something(20)), + RuntimeEvent::Example(pallet::Event::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - Event::Example2(pallet2::Event::Something(21)), + RuntimeEvent::Example2(pallet2::Event::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - Event::Example(pallet::Event::Something(30)), + RuntimeEvent::Example(pallet::Event::Something(30)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - Event::Example2(pallet2::Event::Something(31)), + RuntimeEvent::Example2(pallet2::Event::Something(31)), ); }) } @@ -1034,27 +1034,27 @@ fn all_pallets_type_reversed_order_is_correct() { assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example2(pallet2::Event::Something(11)), + RuntimeEvent::Example2(pallet2::Event::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - Event::Example(pallet::Event::Something(10)), + RuntimeEvent::Example(pallet::Event::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - Event::Example2(pallet2::Event::Something(21)), + RuntimeEvent::Example2(pallet2::Event::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - Event::Example(pallet::Event::Something(20)), + RuntimeEvent::Example(pallet::Event::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - Event::Example2(pallet2::Event::Something(31)), + RuntimeEvent::Example2(pallet2::Event::Something(31)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - Event::Example(pallet::Event::Something(30)), + RuntimeEvent::Example(pallet::Event::Something(30)), ); }) } diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index c6e879075ded8..3422b53776b9b 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -387,7 +387,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example(pallet::Event::Something(3)), + RuntimeEvent::Example(pallet::Event::Something(3)), ); }); @@ -398,7 +398,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Instance1Example(pallet::Event::Something(3)), + RuntimeEvent::Instance1Example(pallet::Event::Something(3)), ); }); } @@ -564,27 +564,27 @@ fn pallet_hooks_expand() { assert_eq!( frame_system::Pallet::::events()[0].event, - Event::Example(pallet::Event::Something(10)), + RuntimeEvent::Example(pallet::Event::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - Event::Instance1Example(pallet::Event::Something(11)), + RuntimeEvent::Instance1Example(pallet::Event::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - Event::Example(pallet::Event::Something(20)), + RuntimeEvent::Example(pallet::Event::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - Event::Instance1Example(pallet::Event::Something(21)), + RuntimeEvent::Instance1Example(pallet::Event::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - Event::Example(pallet::Event::Something(30)), + RuntimeEvent::Example(pallet::Event::Something(30)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - Event::Instance1Example(pallet::Event::Something(31)), + RuntimeEvent::Instance1Example(pallet::Event::Something(31)), ); }) } diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 54e45ade06d0e..61c9981671329 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -212,7 +212,7 @@ fn last_event() -> TipEvent { System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let Event::Tips(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let RuntimeEvent::Tips(inner) = e { Some(inner) } else { None }) .last() .unwrap() } diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 3e6b6b0c1186c..04c2adb9f85cf 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -1359,13 +1359,13 @@ mod tests { )); assert_eq!(Balances::free_balance(2), 0); // Transfer Event - System::assert_has_event(Event::Balances(pallet_balances::Event::Transfer { + System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: 2, to: 3, amount: 80, })); // Killed Event - System::assert_has_event(Event::System(system::Event::KilledAccount { + System::assert_has_event(RuntimeEvent::System(system::Event::KilledAccount { account: 2, })); }); @@ -1421,7 +1421,7 @@ mod tests { )); assert_eq!(Balances::total_balance(&user), 0); // TransactionFeePaid Event - System::assert_has_event(Event::TransactionPayment( + System::assert_has_event(RuntimeEvent::TransactionPayment( pallet_transaction_payment::Event::TransactionFeePaid { who: user, actual_fee: 0, diff --git a/frame/uniques/src/tests.rs b/frame/uniques/src/tests.rs index bd3a2b032945e..daa5c93af6ad5 100644 --- a/frame/uniques/src/tests.rs +++ b/frame/uniques/src/tests.rs @@ -74,7 +74,7 @@ fn events() -> Vec> { let result = System::events() .into_iter() .map(|r| r.event) - .filter_map(|e| if let mock::Event::Uniques(inner) = e { Some(inner) } else { None }) + .filter_map(|e| if let mock::RuntimeEvent::Uniques(inner) = e { Some(inner) } else { None }) .collect::>(); System::reset_events(); From c9b7f2f91db5b73eab23698aca8a01d0681f551f Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 8 Aug 2022 09:05:58 +0200 Subject: [PATCH 09/63] a bit more renaming --- bin/node/executor/tests/basic.rs | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index 27e848a281097..97d721c377e2b 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -28,7 +28,7 @@ use sp_runtime::{ use kitchensink_runtime::{ constants::{currency::*, time::SLOT_DURATION}, - Balances, Call, CheckedExtrinsic, Event, Header, Runtime, System, TransactionPayment, + Balances, Call, CheckedExtrinsic, RuntimeEvent, Header, Runtime, System, TransactionPayment, UncheckedExtrinsic, }; use node_primitives::{Balance, Hash}; @@ -378,7 +378,7 @@ fn full_native_block_import_works() { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: Event::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: timestamp_weight, class: DispatchClass::Mandatory, @@ -389,7 +389,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who: alice().into(), amount: fees, }), @@ -397,7 +397,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: alice().into(), to: bob().into(), amount: 69 * DOLLARS, @@ -406,7 +406,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Deposit { + event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -414,12 +414,12 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::TransactionPayment( + event: RuntimeEvent::TransactionPayment( pallet_transaction_payment::Event::TransactionFeePaid { who: alice().into(), actual_fee: fees, @@ -430,7 +430,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], @@ -460,7 +460,7 @@ fn full_native_block_import_works() { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: Event::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: timestamp_weight, class: DispatchClass::Mandatory, @@ -471,7 +471,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who: bob().into(), amount: fees, }), @@ -479,7 +479,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: bob().into(), to: alice().into(), amount: 5 * DOLLARS, @@ -488,7 +488,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Balances(pallet_balances::Event::Deposit { + event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -496,12 +496,12 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::TransactionPayment( + event: RuntimeEvent::TransactionPayment( pallet_transaction_payment::Event::TransactionFeePaid { who: bob().into(), actual_fee: fees, @@ -512,14 +512,14 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: Event::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::Balances(pallet_balances::Event::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who: alice().into(), amount: fees, }), @@ -527,7 +527,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: alice().into(), to: bob().into(), amount: 15 * DOLLARS, @@ -536,7 +536,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::Balances(pallet_balances::Event::Deposit { + event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -544,12 +544,12 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::TransactionPayment( + event: RuntimeEvent::TransactionPayment( pallet_transaction_payment::Event::TransactionFeePaid { who: alice().into(), actual_fee: fees, @@ -560,7 +560,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: Event::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], From 7b84a0d68df0f60886f747fb4fca84effdb0259f Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 8 Aug 2022 09:10:11 +0200 Subject: [PATCH 10/63] fmt --- bin/node/executor/tests/basic.rs | 14 ++++++++++---- frame/alliance/src/tests.rs | 10 ++++++---- frame/balances/src/tests_local.rs | 5 ++++- frame/balances/src/tests_reentrancy.rs | 15 ++++++++++++--- frame/collective/src/tests.rs | 20 +++++++++++++++----- frame/contracts/src/exec.rs | 3 ++- frame/contracts/src/tests.rs | 16 ++++++++++++---- frame/offences/src/tests.rs | 4 ++-- frame/sudo/src/tests.rs | 4 ++-- frame/transaction-payment/src/lib.rs | 8 +++----- 10 files changed, 68 insertions(+), 31 deletions(-) diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index 97d721c377e2b..f504a99eb3ad1 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -28,7 +28,7 @@ use sp_runtime::{ use kitchensink_runtime::{ constants::{currency::*, time::SLOT_DURATION}, - Balances, Call, CheckedExtrinsic, RuntimeEvent, Header, Runtime, System, TransactionPayment, + Balances, Call, CheckedExtrinsic, Header, Runtime, RuntimeEvent, System, TransactionPayment, UncheckedExtrinsic, }; use node_primitives::{Balance, Hash}; @@ -414,7 +414,9 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { + value: fees * 8 / 10, + }), topics: vec![], }, EventRecord { @@ -496,7 +498,9 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { + value: fees * 8 / 10, + }), topics: vec![], }, EventRecord { @@ -544,7 +548,9 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10 }), + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { + value: fees * 8 / 10, + }), topics: vec![], }, EventRecord { diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index de546446321b0..f97ee950e54f5 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -239,7 +239,9 @@ fn set_rule_works() { assert_ok!(Alliance::set_rule(Origin::signed(1), cid.clone())); assert_eq!(Alliance::rule(), Some(cid.clone())); - System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::NewRuleSet { rule: cid })); + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::NewRuleSet { + rule: cid, + })); }); } @@ -270,9 +272,9 @@ fn remove_announcement_works() { assert_ok!(Alliance::remove_announcement(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![]); - System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::AnnouncementRemoved { - announcement: cid, - })); + System::assert_last_event(mock::RuntimeEvent::Alliance( + crate::Event::AnnouncementRemoved { announcement: cid }, + )); }); } diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 22fb377759fa3..4afd8b4f0df28 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -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(), [RuntimeEvent::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)); diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index 95861ef88115d..c422581ce4dbb 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -166,7 +166,10 @@ fn transfer_dust_removal_tst1_should_work() { account: 2, amount: 50, })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 50 })); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { + who: 1, + amount: 50, + })); }); } @@ -201,7 +204,10 @@ fn transfer_dust_removal_tst2_should_work() { account: 2, amount: 50, })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 50 })); + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { + who: 1, + amount: 50, + })); }); } @@ -248,6 +254,9 @@ fn repatriating_reserved_balance_dust_removal_should_work() { amount: 50, })); - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 50 })); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit { + who: 1, + amount: 50, + })); }); } diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index bb0ce465f3088..e7953475b5f69 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -241,7 +241,9 @@ fn close_works() { yes: 2, no: 1 })), - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { + proposal_hash: hash + })) ] ); }); @@ -361,7 +363,9 @@ fn close_with_prime_works() { yes: 2, no: 1 })), - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })) + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { + proposal_hash: hash + })) ] ); }); @@ -1008,7 +1012,9 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { no: 0 })), record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), - record(RuntimeEvent::Democracy(mock_democracy::pallet::Event::::ExternalProposed)), + record(RuntimeEvent::Democracy( + mock_democracy::pallet::Event::::ExternalProposed + )), record(RuntimeEvent::Collective(CollectiveEvent::Executed { proposal_hash: hash, result: Ok(()) @@ -1063,7 +1069,9 @@ fn motions_disapproval_works() { yes: 1, no: 1 })), - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { + proposal_hash: hash + })), ] ); }); @@ -1251,7 +1259,9 @@ fn disapprove_proposal_works() { yes: 2, no: 0 })), - record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { proposal_hash: hash })), + record(RuntimeEvent::Collective(CollectiveEvent::Disapproved { + proposal_hash: hash + })), ] ); }) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 2b47c9988f5c5..8c8aeaea20bfe 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1348,7 +1348,8 @@ mod tests { storage::Storage, tests::{ test_utils::{get_balance, place_contract, set_balance}, - Call, RuntimeEvent as MetaEvent, ExtBuilder, Test, TestFilter, ALICE, BOB, CHARLIE, GAS_LIMIT, + Call, ExtBuilder, RuntimeEvent as MetaEvent, Test, TestFilter, ALICE, BOB, CHARLIE, + GAS_LIMIT, }, Error, }; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index c6592c46ca0ec..db4f018355833 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -516,7 +516,9 @@ fn instantiate_and_call_and_deposit_event() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { + account: addr.clone() + }), topics: vec![], }, EventRecord { @@ -2842,7 +2844,9 @@ fn instantiate_with_zero_balance_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { + account: addr.clone() + }), topics: vec![], }, EventRecord { @@ -2933,7 +2937,9 @@ fn instantiate_with_below_existential_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { + account: addr.clone() + }), topics: vec![], }, EventRecord { @@ -3281,7 +3287,9 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { + account: addr.clone() + }), topics: vec![], }, EventRecord { diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index 8c1f4dfcf5f79..266e05debf050 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -21,8 +21,8 @@ use super::*; use crate::mock::{ - new_test_ext, offence_reports, report_id, with_on_offence_fractions, RuntimeEvent, Offence, Offences, - System, KIND, + new_test_ext, offence_reports, report_id, with_on_offence_fractions, Offence, Offences, + RuntimeEvent, System, KIND, }; use frame_system::{EventRecord, Phase}; use sp_runtime::Perbill; diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index 4a5730088b21b..8175f2ad810b2 100644 --- a/frame/sudo/src/tests.rs +++ b/frame/sudo/src/tests.rs @@ -20,8 +20,8 @@ use super::*; use frame_support::{assert_noop, assert_ok}; use mock::{ - new_test_ext, Call, RuntimeEvent as TestEvent, Logger, LoggerCall, Origin, Sudo, SudoCall, System, - Test, + new_test_ext, Call, Logger, LoggerCall, Origin, RuntimeEvent as TestEvent, Sudo, SudoCall, + System, Test, }; #[test] diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 04c2adb9f85cf..c4ba8462a00f2 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -1359,11 +1359,9 @@ mod tests { )); assert_eq!(Balances::free_balance(2), 0); // Transfer Event - System::assert_has_event(RuntimeEvent::Balances(pallet_balances::Event::Transfer { - from: 2, - to: 3, - amount: 80, - })); + System::assert_has_event(RuntimeEvent::Balances( + pallet_balances::Event::Transfer { from: 2, to: 3, amount: 80 }, + )); // Killed Event System::assert_has_event(RuntimeEvent::System(system::Event::KilledAccount { account: 2, From ec65df51c103bd174fff4b1730e2a37db0be3566 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 8 Aug 2022 09:55:50 +0200 Subject: [PATCH 11/63] small fix --- .../test/tests/construct_runtime_ui/undefined_event_part.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index 60fec30f0ec03..d5f2015314bc3 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -53,7 +53,7 @@ construct_runtime! { UncheckedExtrinsic = UncheckedExtrinsic { System: frame_system::{Pallet, Call, Storage, Config, Event}, - Pallet: pallet::{Pallet, Event}, + Pallet: pallet::{Pallet, RuntimeEvent}, } } From 7613696a2e8a2087b71ffd360994d285d7f81832 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 8 Aug 2022 10:28:03 +0200 Subject: [PATCH 12/63] commit --- .../test/tests/construct_runtime_ui/undefined_event_part.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index d5f2015314bc3..60fec30f0ec03 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -53,7 +53,7 @@ construct_runtime! { UncheckedExtrinsic = UncheckedExtrinsic { System: frame_system::{Pallet, Call, Storage, Config, Event}, - Pallet: pallet::{Pallet, RuntimeEvent}, + Pallet: pallet::{Pallet, Event}, } } From 02b5ea28c201d0177f0681f59044107e6ade2c73 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 8 Aug 2022 18:48:19 +0200 Subject: [PATCH 13/63] prep for renaming associated types --- frame/session/src/lib.rs | 2 +- .../procedural/src/pallet/parse/config.rs | 15 +++++++------- .../procedural/src/pallet/parse/mod.rs | 20 +++++++++---------- frame/system/src/lib.rs | 18 ++++++++--------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 71ee9d1e0758a..7d568719477b7 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -379,7 +379,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From + IsType<::Event>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// A stable ID for a validator. type ValidatorId: Member diff --git a/frame/support/procedural/src/pallet/parse/config.rs b/frame/support/procedural/src/pallet/parse/config.rs index 60888fc5dd357..a7b48c49b2a0d 100644 --- a/frame/support/procedural/src/pallet/parse/config.rs +++ b/frame/support/procedural/src/pallet/parse/config.rs @@ -28,6 +28,7 @@ mod keyword { syn::custom_keyword!(I); syn::custom_keyword!(config); syn::custom_keyword!(IsType); + syn::custom_keyword!(RuntimeEvent); syn::custom_keyword!(Event); syn::custom_keyword!(constant); syn::custom_keyword!(frame_system); @@ -159,7 +160,7 @@ impl syn::parse::Parse for ConfigBoundParse { } } -/// Parse for `IsType<::Event>` and retrieve `$ident` +/// Parse for `IsType<::RuntimeEvent>` and retrieve `$ident` pub struct IsTypeBoundEventParse(syn::Ident); impl syn::parse::Parse for IsTypeBoundEventParse { @@ -174,7 +175,7 @@ impl syn::parse::Parse for IsTypeBoundEventParse { input.parse::()?; input.parse::]>()?; input.parse::()?; - input.parse::()?; + input.parse::()?; input.parse::]>()?; Ok(Self(ident)) @@ -220,10 +221,10 @@ fn check_event_type( trait_has_instance: bool, ) -> syn::Result { if let syn::TraitItem::Type(type_) = trait_item { - if type_.ident == "Event" { + if type_.ident == "RuntimeEvent" { // Check event has no generics if !type_.generics.params.is_empty() || type_.generics.where_clause.is_some() { - let msg = "Invalid `type Event`, associated type `Event` is reserved and must have\ + let msg = "Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must have\ no generics nor where_clause"; return Err(syn::Error::new(trait_item.span(), msg)) } @@ -236,8 +237,8 @@ fn check_event_type( if !has_is_type_bound { let msg = format!( - "Invalid `type Event`, associated type `Event` is reserved and must \ - bound: `IsType<::Event>`", + "Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must \ + bound: `IsType<::RuntimeEvent>`", frame_system, ); return Err(syn::Error::new(type_.span(), msg)) @@ -251,7 +252,7 @@ fn check_event_type( let from_event_bound = if let Some(b) = from_event_bound { b } else { - let msg = "Invalid `type Event`, associated type `Event` is reserved and must \ + let msg = "Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must \ bound: `From` or `From>` or `From>`"; return Err(syn::Error::new(type_.span(), msg)) }; diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index a436f7e09c1d7..763daa2c07421 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -109,7 +109,7 @@ impl Def { call = Some(call::CallDef::try_from(span, index, item)?), Some(PalletAttr::Error(span)) if error.is_none() => error = Some(error::ErrorDef::try_from(span, index, item)?), - Some(PalletAttr::Event(span)) if event.is_none() => + Some(PalletAttr::RuntimeEvent(span)) if event.is_none() => event = Some(event::EventDef::try_from(span, index, item)?), Some(PalletAttr::GenesisConfig(_)) if genesis_config.is_none() => { let g = genesis_config::GenesisConfigDef::try_from(index, item)?; @@ -186,15 +186,15 @@ impl Def { fn check_event_usage(&self) -> syn::Result<()> { match (self.config.has_event_type, self.event.is_some()) { (true, false) => { - let msg = "Invalid usage of Event, `Config` contains associated type `Event`, \ - but enum `Event` is not declared (i.e. no use of `#[pallet::event]`). \ - Note that type `Event` in trait is reserved to work alongside pallet event."; + let msg = "Invalid usage of RuntimeEvent, `Config` contains associated type `RuntimeEvent`, \ + but enum `RuntimeEvent` is not declared (i.e. no use of `#[pallet::event]`). \ + Note that type `RuntimeEvent` in trait is reserved to work alongside pallet event."; Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) }, (false, true) => { - let msg = "Invalid usage of Event, `Config` contains no associated type \ - `Event`, but enum `Event` is declared (in use of `#[pallet::event]`). \ - An Event associated type must be declare on trait `Config`."; + let msg = "Invalid usage of RuntimeEvent, `Config` contains no associated type \ + `RuntimeEvent`, but enum `RuntimeEvent` is declared (in use of `#[pallet::event]`). \ + An RuntimeEvent associated type must be declare on trait `Config`."; Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) }, _ => Ok(()), @@ -393,7 +393,7 @@ enum PalletAttr { Hooks(proc_macro2::Span), Call(proc_macro2::Span), Error(proc_macro2::Span), - Event(proc_macro2::Span), + RuntimeEvent(proc_macro2::Span), Origin(proc_macro2::Span), Inherent(proc_macro2::Span), Storage(proc_macro2::Span), @@ -412,7 +412,7 @@ impl PalletAttr { Self::Hooks(span) => *span, Self::Call(span) => *span, Self::Error(span) => *span, - Self::Event(span) => *span, + Self::RuntimeEvent(span) => *span, Self::Origin(span) => *span, Self::Inherent(span) => *span, Self::Storage(span) => *span, @@ -445,7 +445,7 @@ impl syn::parse::Parse for PalletAttr { } else if lookahead.peek(keyword::error) { Ok(PalletAttr::Error(content.parse::()?.span())) } else if lookahead.peek(keyword::event) { - Ok(PalletAttr::Event(content.parse::()?.span())) + Ok(PalletAttr::RuntimeEvent(content.parse::()?.span())) } else if lookahead.peek(keyword::origin) { Ok(PalletAttr::Origin(content.parse::()?.span())) } else if lookahead.peek(keyword::inherent) { diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 94605c2da59bd..8eebca88eff70 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -292,11 +292,11 @@ pub mod pallet { type Header: Parameter + traits::Header; /// The aggregated event type of the runtime. - type Event: Parameter + type RuntimeEvent: Parameter + Member + From> + Debug - + IsType<::Event>; + + IsType<::RuntimeEvent>; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). #[pallet::constant] @@ -605,7 +605,7 @@ pub mod pallet { /// just in case someone still reads them from within the runtime. #[pallet::storage] pub(super) type Events = - StorageValue<_, Vec>>, ValueQuery>; + StorageValue<_, Vec>>, ValueQuery>; /// The number of events in the `Events` list. #[pallet::storage] @@ -1211,7 +1211,7 @@ impl Pallet { } /// Deposits an event into this block's event record. - pub fn deposit_event(event: impl Into) { + pub fn deposit_event(event: impl Into) { Self::deposit_event_indexed(&[], event.into()); } @@ -1220,7 +1220,7 @@ impl Pallet { /// /// This will update storage entries that correspond to the specified topics. /// It is expected that light-clients could subscribe to this topics. - pub fn deposit_event_indexed(topics: &[T::Hash], event: T::Event) { + pub fn deposit_event_indexed(topics: &[T::Hash], event: T::RuntimeEvent) { let block_number = Self::block_number(); // Don't populate events on genesis. if block_number.is_zero() { @@ -1409,7 +1409,7 @@ impl Pallet { /// impact on the PoV size of a block. Users should use alternative and well bounded storage /// items for any behavior like this. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] - pub fn events() -> Vec> { + pub fn events() -> Vec> { // Dereferencing the events here is fine since we are not in the // memory-restricted runtime. Self::read_events_no_consensus().into_iter().map(|e| *e).collect() @@ -1419,7 +1419,7 @@ impl Pallet { /// /// Should only be called if you know what you are doing and outside of the runtime block /// execution else it can have a large impact on the PoV size of a block. - pub fn read_events_no_consensus() -> Vec>> { + pub fn read_events_no_consensus() -> Vec>> { Events::::get() } @@ -1464,13 +1464,13 @@ impl Pallet { /// Assert the given `event` exists. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] - pub fn assert_has_event(event: T::Event) { + pub fn assert_has_event(event: T::RuntimeEvent) { assert!(Self::events().iter().any(|record| record.event == event)) } /// Assert the last event equal to the given `event`. #[cfg(any(feature = "std", feature = "runtime-benchmarks", test))] - pub fn assert_last_event(event: T::Event) { + pub fn assert_last_event(event: T::RuntimeEvent) { assert_eq!(Self::events().last().expect("events expected").event, event); } From 44101486da1e608fab49351851c684de87f7f483 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 8 Aug 2022 19:10:23 +0200 Subject: [PATCH 14/63] fix --- frame/support/procedural/src/pallet/expand/event.rs | 6 +++--- frame/support/src/dispatch.rs | 2 +- frame/support/test/tests/system.rs | 2 +- frame/system/src/mock.rs | 2 +- test-utils/runtime/src/lib.rs | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/event.rs b/frame/support/procedural/src/pallet/expand/event.rs index 791f930302207..eaae04faeb47f 100644 --- a/frame/support/procedural/src/pallet/expand/event.rs +++ b/frame/support/procedural/src/pallet/expand/event.rs @@ -136,13 +136,13 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { impl<#type_impl_gen> Pallet<#type_use_gen> #completed_where_clause { #fn_vis fn deposit_event(event: Event<#event_use_gen>) { let event = < - ::Event as + ::RuntimeEvent as From> >::from(event); let event = < - ::Event as - Into<::Event> + ::RuntimeEvent as + Into<::RuntimeEvent> >::into(event); <#frame_system::Pallet>::deposit_event(event) diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 2b05478e0b02a..97b2858b5b3fd 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -1497,7 +1497,7 @@ macro_rules! decl_module { { /// Deposits an event using `frame_system::Pallet::deposit_event`. $vis fn deposit_event( - event: impl Into<< $trait_instance as $trait_name $(<$instance>)? >::Event> + event: impl Into<< $trait_instance as $trait_name $(<$instance>)? >::RuntimeEvent> ) { <$system::Pallet<$trait_instance>>::deposit_event(event.into()) } diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index b30fd8d5ec561..9d5d4765f9ade 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -43,7 +43,7 @@ frame_support::decl_module! { } impl Module { - pub fn deposit_event(_event: impl Into) {} + pub fn deposit_event(_event: impl Into) {} } frame_support::decl_event!( diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 714f6cf5ecdcf..fb140b24a8689 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -103,7 +103,7 @@ impl Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<10>; type DbWeight = DbWeight; type Version = Version; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index e5cfae49da56d..24eef63bb4bc6 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -500,9 +500,9 @@ impl frame_support::traits::OriginTrait for Origin { } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] -pub struct Event; +pub struct RuntimeEvent; -impl From> for Event { +impl From> for RuntimeEvent { fn from(_evt: frame_system::Event) -> Self { unimplemented!("Not required in tests!") } @@ -592,7 +592,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = Event; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<2400>; type DbWeight = (); type Version = (); From f814ecbdb45086edfc8cb1eb1eb0e5832e5e916d Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 8 Aug 2022 19:27:35 +0200 Subject: [PATCH 15/63] rename associated Event type --- bin/node-template/pallets/template/src/lib.rs | 2 +- .../pallets/template/src/mock.rs | 4 +- bin/node-template/runtime/src/lib.rs | 12 +-- bin/node/runtime/src/lib.rs | 94 +++++++++---------- frame/alliance/src/lib.rs | 3 +- frame/alliance/src/mock.rs | 10 +- frame/assets/src/lib.rs | 3 +- frame/assets/src/mock.rs | 6 +- frame/atomic-swap/src/lib.rs | 2 +- frame/atomic-swap/src/tests.rs | 6 +- frame/aura/src/mock.rs | 2 +- frame/authority-discovery/src/lib.rs | 4 +- frame/authorship/src/lib.rs | 2 +- frame/babe/src/mock.rs | 10 +- frame/bags-list/src/lib.rs | 3 +- frame/bags-list/src/mock.rs | 4 +- frame/balances/src/lib.rs | 3 +- frame/balances/src/tests_composite.rs | 6 +- frame/balances/src/tests_local.rs | 6 +- frame/balances/src/tests_reentrancy.rs | 4 +- frame/beefy-mmr/src/mock.rs | 4 +- frame/beefy/src/mock.rs | 4 +- frame/benchmarking/src/baseline.rs | 2 +- frame/benchmarking/src/tests.rs | 2 +- frame/benchmarking/src/tests_instance.rs | 4 +- frame/bounties/src/lib.rs | 3 +- frame/bounties/src/tests.rs | 12 +-- frame/child-bounties/src/lib.rs | 2 +- frame/child-bounties/src/tests.rs | 10 +- frame/collective/src/lib.rs | 3 +- frame/collective/src/tests.rs | 13 +-- frame/contracts/src/lib.rs | 2 +- frame/contracts/src/tests.rs | 8 +- frame/conviction-voting/src/lib.rs | 3 +- frame/conviction-voting/src/tests.rs | 6 +- frame/democracy/src/lib.rs | 2 +- frame/democracy/src/tests.rs | 8 +- .../election-provider-multi-phase/src/lib.rs | 4 +- .../election-provider-multi-phase/src/mock.rs | 6 +- frame/elections-phragmen/src/lib.rs | 8 +- frame/examples/basic/src/lib.rs | 2 +- frame/examples/basic/src/tests.rs | 6 +- frame/examples/offchain-worker/src/lib.rs | 2 +- frame/examples/offchain-worker/src/tests.rs | 4 +- frame/examples/parallel/src/tests.rs | 2 +- frame/executive/src/lib.rs | 6 +- frame/gilt/src/lib.rs | 2 +- frame/gilt/src/mock.rs | 6 +- frame/grandpa/src/lib.rs | 6 +- frame/grandpa/src/mock.rs | 12 +-- frame/identity/src/lib.rs | 2 +- frame/identity/src/tests.rs | 6 +- frame/im-online/src/lib.rs | 2 +- frame/im-online/src/mock.rs | 6 +- frame/indices/src/lib.rs | 2 +- frame/indices/src/mock.rs | 6 +- frame/lottery/src/lib.rs | 2 +- frame/lottery/src/mock.rs | 6 +- frame/membership/src/lib.rs | 7 +- frame/merkle-mountain-range/src/mock.rs | 2 +- frame/multisig/src/lib.rs | 2 +- frame/multisig/src/tests.rs | 6 +- frame/nicks/src/lib.rs | 8 +- frame/node-authorization/src/lib.rs | 2 +- frame/node-authorization/src/mock.rs | 4 +- .../nomination-pools/benchmarking/src/mock.rs | 10 +- frame/nomination-pools/src/lib.rs | 2 +- frame/nomination-pools/src/mock.rs | 6 +- .../nomination-pools/test-staking/src/mock.rs | 10 +- frame/offences/benchmarking/src/mock.rs | 12 +-- frame/offences/src/lib.rs | 2 +- frame/offences/src/mock.rs | 4 +- frame/preimage/src/lib.rs | 2 +- frame/preimage/src/mock.rs | 6 +- frame/proxy/src/lib.rs | 2 +- frame/proxy/src/tests.rs | 8 +- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/ranked-collective/src/lib.rs | 3 +- frame/ranked-collective/src/tests.rs | 4 +- frame/recovery/src/lib.rs | 2 +- frame/recovery/src/mock.rs | 6 +- frame/referenda/src/lib.rs | 3 +- frame/referenda/src/mock.rs | 10 +- frame/remark/src/lib.rs | 2 +- frame/remark/src/mock.rs | 4 +- frame/scheduler/src/lib.rs | 2 +- frame/scheduler/src/mock.rs | 10 +- frame/scored-pool/src/lib.rs | 3 +- frame/scored-pool/src/mock.rs | 6 +- frame/session/benchmarking/src/mock.rs | 8 +- frame/session/src/mock.rs | 4 +- frame/society/src/lib.rs | 3 +- frame/society/src/mock.rs | 6 +- frame/staking/src/mock.rs | 10 +- frame/staking/src/pallet/mod.rs | 2 +- frame/state-trie-migration/src/lib.rs | 8 +- frame/sudo/src/lib.rs | 2 +- frame/sudo/src/mock.rs | 8 +- frame/support/src/lib.rs | 4 +- frame/support/test/compile_pass/src/lib.rs | 2 +- frame/support/test/tests/construct_runtime.rs | 2 +- .../no_std_genesis_config.rs | 2 +- .../pallet_error_too_large.rs | 2 +- .../undefined_call_part.rs | 2 +- .../undefined_event_part.rs | 2 +- .../undefined_genesis_config_part.rs | 2 +- .../undefined_inherent_part.rs | 2 +- .../undefined_origin_part.rs | 2 +- .../undefined_validate_unsigned_part.rs | 2 +- frame/support/test/tests/instance.rs | 18 ++-- frame/support/test/tests/issue2219.rs | 2 +- frame/support/test/tests/origin.rs | 2 +- frame/support/test/tests/pallet.rs | 10 +- .../test/tests/pallet_compatibility.rs | 10 +- .../tests/pallet_compatibility_instance.rs | 19 ++-- frame/support/test/tests/pallet_instance.rs | 16 ++-- .../tests/pallet_ui/event_field_not_member.rs | 2 +- .../pallet_ui/event_type_invalid_bound_2.rs | 2 +- .../tests/pallet_with_name_trait_is_valid.rs | 2 +- frame/support/test/tests/storage_layers.rs | 2 +- frame/support/test/tests/system.rs | 2 +- frame/system/benches/bench.rs | 6 +- frame/system/benchmarking/src/mock.rs | 2 +- frame/timestamp/src/mock.rs | 2 +- frame/tips/src/lib.rs | 3 +- frame/tips/src/tests.rs | 12 +-- .../asset-tx-payment/src/lib.rs | 2 +- .../asset-tx-payment/src/tests.rs | 10 +- frame/transaction-payment/src/lib.rs | 8 +- frame/transaction-storage/src/lib.rs | 2 +- frame/transaction-storage/src/mock.rs | 6 +- frame/treasury/src/lib.rs | 3 +- frame/treasury/src/tests.rs | 6 +- frame/uniques/src/lib.rs | 3 +- frame/uniques/src/mock.rs | 6 +- frame/utility/src/lib.rs | 2 +- frame/utility/src/tests.rs | 6 +- frame/vesting/src/lib.rs | 2 +- frame/vesting/src/mock.rs | 6 +- frame/whitelist/src/lib.rs | 2 +- frame/whitelist/src/mock.rs | 8 +- 141 files changed, 401 insertions(+), 382 deletions(-) diff --git a/bin/node-template/pallets/template/src/lib.rs b/bin/node-template/pallets/template/src/lib.rs index f1519efe062bd..c9874eb9d55d9 100644 --- a/bin/node-template/pallets/template/src/lib.rs +++ b/bin/node-template/pallets/template/src/lib.rs @@ -27,7 +27,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } // The pallet's runtime storage items. diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index 4de39b77dc92b..f506be56a84d6 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -36,7 +36,7 @@ impl system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -50,7 +50,7 @@ impl system::Config for Test { } impl pallet_template::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } // Build genesis storage according to the mock runtime. diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index baae4c503fbba..f7c62e0e27dff 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -170,7 +170,7 @@ impl frame_system::Config for Runtime { /// The header type. type Header = generic::Header; /// The ubiquitous event type. - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. type Origin = Origin; /// Maximum number of block number to block hash mappings to keep (oldest pruned first). @@ -207,7 +207,7 @@ impl pallet_aura::Config for Runtime { } impl pallet_grandpa::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type KeyOwnerProofSystem = (); @@ -244,7 +244,7 @@ impl pallet_balances::Config for Runtime { /// The type for recording an account's balance. type Balance = Balance; /// The ubiquitous event type. - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU128; type AccountStore = System; @@ -252,7 +252,7 @@ impl pallet_balances::Config for Runtime { } impl pallet_transaction_payment::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; @@ -261,13 +261,13 @@ impl pallet_transaction_payment::Config for Runtime { } impl pallet_sudo::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; } /// Configure the pallet-template in pallets/template. impl pallet_template::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } // Create the runtime by composing the FRAME pallets that were previously configured. diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 61320c56f526a..283cba29a8aa2 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -213,7 +213,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = Indices; type Header = generic::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type Version = Version; type PalletInfo = PalletInfo; @@ -229,7 +229,7 @@ impl frame_system::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_utility::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = pallet_utility::weights::SubstrateWeight; @@ -243,7 +243,7 @@ parameter_types! { } impl pallet_multisig::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type Currency = Balances; type DepositBase = DepositBase; @@ -319,7 +319,7 @@ impl InstanceFilter for ProxyType { } impl pallet_proxy::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type Currency = Balances; type ProxyType = ProxyType; @@ -341,7 +341,7 @@ parameter_types! { } impl pallet_scheduler::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; @@ -363,7 +363,7 @@ parameter_types! { impl pallet_preimage::Config for Runtime { type WeightInfo = pallet_preimage::weights::SubstrateWeight; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; type MaxSize = PreimageMaxSize; @@ -413,7 +413,7 @@ impl pallet_indices::Config for Runtime { type AccountIndex = AccountIndex; type Currency = Balances; type Deposit = IndexDeposit; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = pallet_indices::weights::SubstrateWeight; } @@ -431,7 +431,7 @@ impl pallet_balances::Config for Runtime { type ReserveIdentifier = [u8; 8]; type Balance = Balance; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = frame_system::Pallet; type WeightInfo = pallet_balances::weights::SubstrateWeight; @@ -446,7 +446,7 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = IdentityFee; @@ -456,7 +456,7 @@ impl pallet_transaction_payment::Config for Runtime { } impl pallet_asset_tx_payment::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Fungibles = Assets; type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter< pallet_assets::BalanceToAssetBalance, @@ -496,7 +496,7 @@ impl_opaque_keys! { } impl pallet_session::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = Babe; @@ -546,7 +546,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = Timestamp; type CurrencyToVote = U128CurrencyToVote; type RewardRemainder = Treasury; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Slash = Treasury; // send the slashed funds to the treasury. type Reward = (); // rewards are minted from the void type SessionsPerEra = SessionsPerEra; @@ -686,7 +686,7 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime { } impl pallet_election_provider_multi_phase::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EstimateCallFee = TransactionPayment; type SignedPhase = SignedPhase; @@ -721,7 +721,7 @@ parameter_types! { } impl pallet_bags_list::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ScoreProvider = Staking; type WeightInfo = pallet_bags_list::weights::SubstrateWeight; type BagThresholds = BagThresholds; @@ -750,7 +750,7 @@ impl Convert for U256ToBalance { impl pallet_nomination_pools::Config for Runtime { type WeightInfo = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = Balance; type RewardCounter = FixedU128; @@ -770,7 +770,7 @@ parameter_types! { impl pallet_conviction_voting::Config for Runtime { type WeightInfo = pallet_conviction_voting::weights::SubstrateWeight; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type VoteLockingPeriod = VoteLockingPeriod; type MaxVotes = ConstU32<512>; @@ -828,7 +828,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type Call = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; type SubmitOrigin = EnsureSigned; @@ -847,7 +847,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; type Call = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; type SubmitOrigin = EnsureSigned; @@ -865,7 +865,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_ranked_collective::Config for Runtime { type WeightInfo = pallet_ranked_collective::weights::SubstrateWeight; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PromoteOrigin = EnsureRootWithSuccess>; type DemoteOrigin = EnsureRootWithSuccess>; type Polls = RankedPolls; @@ -875,7 +875,7 @@ impl pallet_ranked_collective::Config for Runtime { impl pallet_remark::Config for Runtime { type WeightInfo = pallet_remark::weights::SubstrateWeight; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } parameter_types! { @@ -890,7 +890,7 @@ parameter_types! { impl pallet_democracy::Config for Runtime { type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; type LaunchPeriod = LaunchPeriod; @@ -949,7 +949,7 @@ type CouncilCollective = pallet_collective::Instance1; impl pallet_collective::Config for Runtime { type Origin = Origin; type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MotionDuration = CouncilMotionDuration; type MaxProposals = CouncilMaxProposals; type MaxMembers = CouncilMaxMembers; @@ -973,7 +973,7 @@ parameter_types! { const_assert!(DesiredMembers::get() <= CouncilMaxMembers::get()); impl pallet_elections_phragmen::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PalletId = ElectionsPhragmenPalletId; type Currency = Balances; type ChangeMembers = Council; @@ -1002,7 +1002,7 @@ type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { type Origin = Origin; type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MotionDuration = TechnicalMotionDuration; type MaxProposals = TechnicalMaxProposals; type MaxMembers = TechnicalMaxMembers; @@ -1015,7 +1015,7 @@ type EnsureRootOrHalfCouncil = EitherOfDiverse< pallet_collective::EnsureProportionMoreThan, >; impl pallet_membership::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type AddOrigin = EnsureRootOrHalfCouncil; type RemoveOrigin = EnsureRootOrHalfCouncil; type SwapOrigin = EnsureRootOrHalfCouncil; @@ -1052,7 +1052,7 @@ impl pallet_treasury::Config for Runtime { EnsureRoot, pallet_collective::EnsureProportionMoreThan, >; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ProposalBondMinimum; @@ -1078,7 +1078,7 @@ parameter_types! { } impl pallet_bounties::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BountyDepositBase = BountyDepositBase; type BountyDepositPayoutDelay = BountyDepositPayoutDelay; type BountyUpdatePeriod = BountyUpdatePeriod; @@ -1097,14 +1097,14 @@ parameter_types! { } impl pallet_child_bounties::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MaxActiveChildBountyCount = ConstU32<5>; type ChildBountyValueMinimum = ChildBountyValueMinimum; type WeightInfo = pallet_child_bounties::weights::SubstrateWeight; } impl pallet_tips::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DataDepositPerByte = DataDepositPerByte; type MaximumReasonLength = MaximumReasonLength; type Tippers = Elections; @@ -1132,7 +1132,7 @@ impl pallet_contracts::Config for Runtime { type Time = Timestamp; type Randomness = RandomnessCollectiveFlip; type Currency = Balances; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; /// The safest default is to allow no calls at all. /// @@ -1158,7 +1158,7 @@ impl pallet_contracts::Config for Runtime { } impl pallet_sudo::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; } @@ -1229,7 +1229,7 @@ where impl pallet_im_online::Config for Runtime { type AuthorityId = ImOnlineId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type NextSessionRotation = Babe; type ValidatorSet = Historical; type ReportUnresponsiveness = Offences; @@ -1241,7 +1241,7 @@ impl pallet_im_online::Config for Runtime { } impl pallet_offences::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } @@ -1251,7 +1251,7 @@ impl pallet_authority_discovery::Config for Runtime { } impl pallet_grandpa::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type KeyOwnerProofSystem = Historical; @@ -1284,7 +1284,7 @@ parameter_types! { } impl pallet_identity::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BasicDeposit = BasicDeposit; type FieldDeposit = FieldDeposit; @@ -1306,7 +1306,7 @@ parameter_types! { } impl pallet_recovery::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = pallet_recovery::weights::SubstrateWeight; type Call = Call; type Currency = Balances; @@ -1329,7 +1329,7 @@ parameter_types! { } impl pallet_society::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PalletId = SocietyPalletId; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; @@ -1352,7 +1352,7 @@ parameter_types! { } impl pallet_vesting::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BlockNumberToBalance = ConvertInto; type MinVestedTransfer = MinVestedTransfer; @@ -1382,7 +1382,7 @@ impl pallet_lottery::Config for Runtime { type Call = Call; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ManagerOrigin = EnsureRoot; type MaxCalls = MaxCalls; type ValidateCall = Lottery; @@ -1399,7 +1399,7 @@ parameter_types! { } impl pallet_assets::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Balance = u128; type AssetId = u32; type Currency = Balances; @@ -1427,7 +1427,7 @@ parameter_types! { } impl pallet_gilt::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = Balance; type AdminOrigin = frame_system::EnsureRoot; @@ -1452,7 +1452,7 @@ parameter_types! { } impl pallet_uniques::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type CollectionId = u32; type ItemId = u32; type Currency = Balances; @@ -1473,7 +1473,7 @@ impl pallet_uniques::Config for Runtime { } impl pallet_transaction_storage::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Call = Call; type FeeDestination = (); @@ -1485,7 +1485,7 @@ impl pallet_transaction_storage::Config for Runtime { } impl pallet_whitelist::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; @@ -1500,7 +1500,7 @@ parameter_types! { } impl pallet_state_trie_migration::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ControlOrigin = EnsureRoot; type Currency = Balances; type MaxKeyLen = MigrationMaxKeyLen; @@ -1524,7 +1524,7 @@ type AllianceCollective = pallet_collective::Instance3; impl pallet_collective::Config for Runtime { type Origin = Origin; type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MotionDuration = AllianceMotionDuration; type MaxProposals = AllianceMaxProposals; type MaxMembers = AllianceMaxMembers; @@ -1540,7 +1540,7 @@ parameter_types! { } impl pallet_alliance::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Proposal = Call; type AdminOrigin = EitherOfDiverse< EnsureRoot, diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 111ea5dc6e507..03190c5fccc69 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -221,7 +221,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The outer call dispatch type. type Proposal: Parameter diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 1fed55b9c30ed..6805686cd115b 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -53,7 +53,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = BlockHashCount; type DbWeight = (); type Version = (); @@ -74,7 +74,7 @@ parameter_types! { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); @@ -92,7 +92,7 @@ type AllianceCollective = pallet_collective::Instance1; impl pallet_collective::Config for Test { type Origin = Origin; type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MotionDuration = MotionDuration; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; @@ -119,7 +119,7 @@ type EnsureOneOrRoot = EitherOfDiverse, EnsureSignedBy type EnsureTwoOrRoot = EitherOfDiverse, EnsureSignedBy>; impl pallet_identity::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type BasicDeposit = BasicDeposit; type FieldDeposit = FieldDeposit; @@ -201,7 +201,7 @@ parameter_types! { pub const AllyDeposit: u64 = 25; } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Proposal = Call; type AdminOrigin = EnsureSignedBy; type MembershipManager = EnsureSignedBy; diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index e0b00c5642c81..239628e68d5c9 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -178,7 +178,8 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The units in which we record balances. type Balance: Member diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index e7bdf143bf4a7..cc44014411a40 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -75,7 +75,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -85,7 +85,7 @@ impl pallet_balances::Config for Test { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Balance = u64; type AssetId = u32; type Currency = Balances; diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 1ddf3888d3c96..52720e310a774 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -166,7 +166,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Swap action. type SwapAction: SwapAction + Parameter + MaxEncodedLen; /// Limit of proof size. diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index b1c812f2cdd93..ed6066655f6b0 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -46,7 +46,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -65,14 +65,14 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SwapAction = BalanceSwapAction; type ProofLimit = ConstU32<1024>; } diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index e76ec7e54045a..c5de7c5ea0899 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index bcd782458155b..6b1956e7d2fdb 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -209,7 +209,7 @@ mod tests { type Keys = UintAuthorityId; type ShouldEndSession = pallet_session::PeriodicSessions; type SessionHandler = TestSessionHandler; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AuthorityId; type ValidatorIdOf = ConvertInto; type NextSessionRotation = pallet_session::PeriodicSessions; @@ -244,7 +244,7 @@ mod tests { type AccountId = AuthorityId; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index 9d6f05ec6051d..f82a665671779 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -477,7 +477,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 43e1351db90f2..8352f65ebe8d2 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -84,7 +84,7 @@ impl frame_system::Config for Test { type AccountId = DummyValidatorId; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type PalletInfo = PalletInfo; type AccountData = pallet_balances::AccountData; @@ -111,7 +111,7 @@ impl_opaque_keys! { } impl pallet_session::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = Babe; @@ -147,7 +147,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u128; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); @@ -184,7 +184,7 @@ impl pallet_staking::Config for Test { type MaxNominations = ConstU32<16>; type RewardRemainder = (); type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = ::Balance; type Slash = (); @@ -209,7 +209,7 @@ impl pallet_staking::Config for Test { } impl pallet_offences::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } diff --git a/frame/bags-list/src/lib.rs b/frame/bags-list/src/lib.rs index 7eee8fdfa23d8..51ceae51da368 100644 --- a/frame/bags-list/src/lib.rs +++ b/frame/bags-list/src/lib.rs @@ -103,7 +103,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: weights::WeightInfo; diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index 5284a030cb414..1c887d77dd3ee 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); type BlockLength = (); @@ -78,7 +78,7 @@ parameter_types! { } impl bags_list::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type BagThresholds = BagThresholds; type ScoreProvider = StakingMock; diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 683ebce2b1693..8640b44cdc06c 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -216,7 +216,8 @@ pub mod pallet { type DustRemoval: OnUnbalanced>; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The minimum amount required to keep an account open. #[pallet::constant] diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs index 79ab0cbcb7d72..e53dfbd8c91a0 100644 --- a/frame/balances/src/tests_composite.rs +++ b/frame/balances/src/tests_composite.rs @@ -63,7 +63,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + 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 = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter, ()>; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; @@ -88,7 +88,7 @@ impl pallet_transaction_payment::Config for Test { impl Config for Test { type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = frame_system::Pallet; type MaxLocks = (); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 4afd8b4f0df28..bdfc1fb2a0aeb 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -64,7 +64,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + 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 = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter, ()>; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; @@ -89,7 +89,7 @@ impl pallet_transaction_payment::Config for Test { impl Config for Test { type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = StorageMapShim, system::Provider, u64, super::AccountData>; diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index c422581ce4dbb..cef058f7efb4e 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -68,7 +68,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -91,7 +91,7 @@ impl OnUnbalanced> for OnDustRemoval { impl Config for Test { type Balance = u64; type DustRemoval = OnDustRemoval; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = StorageMapShim, system::Provider, u64, super::AccountData>; diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 213776c8e10db..9b0e1d01abdf9 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -76,7 +76,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -90,7 +90,7 @@ impl frame_system::Config for Test { } impl pallet_session::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 792e257edf351..348f8649d97a0 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -95,7 +95,7 @@ parameter_types! { } impl pallet_session::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index f13ee526406fb..5638eca54c188 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -185,7 +185,7 @@ pub mod mock { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 12d50b6e1113e..93979bd122ad0 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -98,7 +98,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 7fc4208c9872f..8fdea8ae852a0 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -100,7 +100,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -114,7 +114,7 @@ impl frame_system::Config for Test { } impl pallet_test::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type LowerBound = ConstU32<1>; type UpperBound = ConstU32<100>; } diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index fca758fd96b8e..f4c1a3c949bac 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -228,7 +228,8 @@ pub mod pallet { type DataDepositPerByte: Get>; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Maximum acceptable reason length. /// diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 55a83c67c04c6..fe0bc31604526 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -78,7 +78,7 @@ impl frame_system::Config for Test { type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -96,7 +96,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -117,7 +117,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -136,7 +136,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -159,7 +159,7 @@ parameter_types! { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BountyDepositBase = ConstU64<80>; type BountyDepositPayoutDelay = ConstU64<3>; type BountyUpdatePeriod = ConstU64<20>; @@ -174,7 +174,7 @@ impl Config for Test { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BountyDepositBase = ConstU64<80>; type BountyDepositPayoutDelay = ConstU64<3>; type BountyUpdatePeriod = ConstU64<20>; diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index 4f25fdcf8903a..1d9f13ec4f358 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -145,7 +145,7 @@ pub mod pallet { type ChildBountyValueMinimum: Get>; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 5937a1295116d..7189f0f41dc40 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -81,7 +81,7 @@ impl frame_system::Config for Test { type AccountId = u128; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -99,7 +99,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -119,7 +119,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -140,7 +140,7 @@ parameter_types! { } impl pallet_bounties::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BountyDepositBase = ConstU64<80>; type BountyDepositPayoutDelay = ConstU64<3>; type BountyUpdatePeriod = ConstU64<10>; @@ -154,7 +154,7 @@ impl pallet_bounties::Config for Test { type ChildBountyManager = ChildBounties; } impl pallet_child_bounties::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MaxActiveChildBountyCount = ConstU32<2>; type ChildBountyValueMinimum = ConstU64<1>; type WeightInfo = (); diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 0323be1382392..bc3976a249b53 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -187,7 +187,8 @@ pub mod pallet { + GetDispatchInfo; /// The outer event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The time-out for council motions. type MotionDuration: Get; diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index e7953475b5f69..7d7c3eee1e522 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -61,7 +61,8 @@ mod mock_democracy { #[pallet::config] pub trait Config: frame_system::Config + Sized { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; type ExternalMajorityOrigin: EnsureOrigin; } @@ -105,7 +106,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -120,7 +121,7 @@ impl frame_system::Config for Test { impl Config for Test { type Origin = Origin; type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; @@ -130,7 +131,7 @@ impl Config for Test { impl Config for Test { type Origin = Origin; type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; @@ -138,13 +139,13 @@ impl Config for Test { type WeightInfo = (); } impl mock_democracy::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExternalMajorityOrigin = EnsureProportionAtLeast; } impl Config for Test { type Origin = Origin; type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; type MaxMembers = MaxMembers; diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 319bacaab7789..f9c488727331b 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -242,7 +242,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Dispatchable diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index db4f018355833..3450774af60b1 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -281,7 +281,7 @@ impl frame_system::Config for Test { type AccountId = AccountId32; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -299,7 +299,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -313,7 +313,7 @@ impl pallet_timestamp::Config for Test { type WeightInfo = (); } impl pallet_utility::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = (); @@ -359,7 +359,7 @@ impl Config for Test { type Time = Timestamp; type Randomness = Randomness; type Currency = Balances; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type CallFilter = TestFilter; type CallStack = [Frame; 31]; diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index 54fc1156d1f47..e618d0dffc8c3 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -97,7 +97,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { // System level stuff. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; /// Currency type with which voting happens. diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 6c06e2b5dcba9..38d1efd4e63d6 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -73,7 +73,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -91,7 +91,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type MaxLocks = ConstU32<10>; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -186,7 +186,7 @@ impl Polling> for TestPolls { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = pallet_balances::Pallet; type VoteLockingPeriod = ConstU64<3>; type MaxVotes = ConstU32<3>; diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 443b8579116d0..ef4295486fcb6 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -253,7 +253,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { type Proposal: Parameter + Dispatchable + From>; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Currency type for this pallet. type Currency: ReservableCurrency diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index b110f82967b77..e6611e6d7f68f 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -94,7 +94,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -110,7 +110,7 @@ parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; } impl pallet_scheduler::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; @@ -128,7 +128,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type MaxLocks = ConstU32<10>; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -157,7 +157,7 @@ impl SortedMembers for OneToFive { impl Config for Test { type Proposal = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = pallet_balances::Pallet; type EnactmentPeriod = ConstU64<2>; type LaunchPeriod = ConstU64<2>; diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index e1d3cb8ed5dee..3cdc69d31e5e0 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -569,8 +569,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + SendTransactionTypes> { - type Event: From> - + IsType<::Event> + type RuntimeEvent: From> + + IsType<::RuntimeEvent> + TryInto>; /// Currency type. diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 7585daa449816..b1bced53cc756 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -207,7 +207,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); type BlockLength = (); @@ -231,7 +231,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -359,7 +359,7 @@ impl MinerConfig for Runtime { } impl crate::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EstimateCallFee = frame_support::traits::ConstU32<8>; type SignedPhase = SignedPhase; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 517b487c783d2..fadc5134d924b 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -204,7 +204,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Identifier for the elections-phragmen pallet's lock #[pallet::constant] @@ -1184,7 +1184,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -1199,7 +1199,7 @@ mod tests { impl pallet_balances::Config for Test { type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = frame_system::Pallet; @@ -1270,7 +1270,7 @@ mod tests { impl Config for Test { type PalletId = ElectionsPhragmenPalletId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type ChangeMembers = TestChangeMembers; diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index 03dc2c613c01e..cdd0b1cea0cd0 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -370,7 +370,7 @@ pub mod pallet { type MagicNumber: Get; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Type representing the weight of this pallet type WeightInfo: WeightInfo; diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index b16fa822a90af..64373646ee9c6 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -68,7 +68,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -95,7 +95,7 @@ impl pallet_balances::Config for Test { impl Config for Test { type MagicNumber = ConstU64<1_000_000_000>; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index b40311051594b..e9e4d3c7ca50e 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -126,7 +126,7 @@ pub mod pallet { type AuthorityId: AppCrypto; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching dispatch call type. type Call: From>; diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 919afe71e5da5..13177d6465925 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -69,7 +69,7 @@ impl frame_system::Config for Test { type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -117,7 +117,7 @@ parameter_types! { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type AuthorityId = crypto::TestAuthId; type Call = Call; type GracePeriod = ConstU64<5>; diff --git a/frame/examples/parallel/src/tests.rs b/frame/examples/parallel/src/tests.rs index fa5535cac57d8..888b5077bb502 100644 --- a/frame/examples/parallel/src/tests.rs +++ b/frame/examples/parallel/src/tests.rs @@ -55,7 +55,7 @@ impl frame_system::Config for Test { type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU64<250>; type DbWeight = (); type BlockWeights = (); diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 54da4fafbb988..98a9fc2724658 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -744,7 +744,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = RuntimeVersion; type PalletInfo = PalletInfo; @@ -760,7 +760,7 @@ mod tests { type Balance = u64; impl pallet_balances::Config for Runtime { type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -774,7 +774,7 @@ mod tests { pub const TransactionByteFee: Balance = 0; } impl pallet_transaction_payment::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = ConstU8<5>; type WeightToFee = IdentityFee; diff --git a/frame/gilt/src/lib.rs b/frame/gilt/src/lib.rs index 59522f9a106f2..bab25bf96e066 100644 --- a/frame/gilt/src/lib.rs +++ b/frame/gilt/src/lib.rs @@ -98,7 +98,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Currency type that this works on. type Currency: ReservableCurrency; diff --git a/frame/gilt/src/mock.rs b/frame/gilt/src/mock.rs index 288eec2af4517..52dea595a5bde 100644 --- a/frame/gilt/src/mock.rs +++ b/frame/gilt/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -75,7 +75,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = frame_support::traits::ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -92,7 +92,7 @@ ord_parameter_types! { } impl pallet_gilt::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = ::Balance; type AdminOrigin = frame_system::EnsureSignedBy; diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 1781f0a8e40a2..f71fbaea0833c 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -87,9 +87,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The event type of this module. - type Event: From - + Into<::Event> - + IsType<::Event>; + type RuntimeEvent: From + + Into<::RuntimeEvent> + + IsType<::RuntimeEvent>; /// The function call. type Call: From>; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 0ca63e9a611cb..597b6ac145352 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -88,7 +88,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -116,7 +116,7 @@ parameter_types! { /// Custom `SessionHandler` since we use `TestSessionKeys` as `Keys`. impl pallet_session::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = u64; type ValidatorIdOf = pallet_staking::StashOf; type ShouldEndSession = pallet_session::PeriodicSessions, ConstU64<0>>; @@ -145,7 +145,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u128; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU128<1>; type AccountStore = System; type WeightInfo = (); @@ -188,7 +188,7 @@ impl pallet_staking::Config for Test { type MaxNominations = ConstU32<16>; type RewardRemainder = (); type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type CurrencyBalance = ::Balance; type Slash = (); @@ -213,7 +213,7 @@ impl pallet_staking::Config for Test { } impl pallet_offences::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } @@ -224,7 +224,7 @@ parameter_types! { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type KeyOwnerProofSystem = Historical; diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index 46f847606903d..9712d43c4e826 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -104,7 +104,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: ReservableCurrency; diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 44e5706e8315b..33251ea07302f 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -81,7 +81,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -103,7 +103,7 @@ ord_parameter_types! { type EnsureOneOrRoot = EitherOfDiverse, EnsureSignedBy>; type EnsureTwoOrRoot = EitherOfDiverse, EnsureSignedBy>; impl pallet_identity::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type Slashed = (); type BasicDeposit = ConstU64<10>; diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 34c1c70d79f75..342522ff29b19 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -337,7 +337,7 @@ pub mod pallet { type MaxPeerDataEncodingSize: Get; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A type for retrieving the validators supposed to be online in a session. type ValidatorSet: ValidatorSetWithIdentification; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index a6450138fa354..b6b7295f60d34 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -140,7 +140,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -166,7 +166,7 @@ impl pallet_session::Config for Runtime { type ValidatorId = u64; type ValidatorIdOf = ConvertInto; type Keys = UintAuthorityId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type NextSessionRotation = pallet_session::PeriodicSessions; type WeightInfo = (); } @@ -220,7 +220,7 @@ impl frame_support::traits::EstimateNextSessionRotation for TestNextSession impl Config for Runtime { type AuthorityId = UintAuthorityId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorSet = Historical; type NextSessionRotation = TestNextSessionRotation; type ReportUnresponsiveness = OffenceHandler; diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index ddc03c94b1233..497fb0c43668a 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -67,7 +67,7 @@ pub mod pallet { type Deposit: Get>; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index b5b2d190c456a..68a704f5b4153 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = Indices; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -80,7 +80,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -90,7 +90,7 @@ impl Config for Test { type AccountIndex = u64; type Currency = Balances; type Deposit = ConstU64<1>; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 02df65a3336bf..c8989665768e4 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -146,7 +146,7 @@ pub mod pallet { type Randomness: Randomness; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The manager origin. type ManagerOrigin: EnsureOrigin; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 755a043a86fc2..65650b28da650 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -84,7 +84,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -100,7 +100,7 @@ impl Config for Test { type Call = Call; type Currency = Balances; type Randomness = TestRandomness; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ManagerOrigin = EnsureRoot; type MaxCalls = ConstU32<2>; type ValidateCall = Lottery; diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 91390c64fcd68..0140353481f70 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -52,7 +52,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Required origin for adding a member (though can always be Root). type AddOrigin: EnsureOrigin; @@ -535,7 +536,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -584,7 +585,7 @@ mod tests { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type AddOrigin = EnsureSignedBy; type RemoveOrigin = EnsureSignedBy; type SwapOrigin = EnsureSignedBy; diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index 4063406d7fac8..70fd748912b5b 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -53,7 +53,7 @@ impl frame_system::Config for Test { type AccountId = sp_core::sr25519::Public; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type BlockWeights = (); diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index d4ea041e5820e..b49ad7720f8b5 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -117,7 +117,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index 48ba1856c3039..d1c57ab734628 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -84,7 +84,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -103,7 +103,7 @@ impl Contains for TestBaseCallFilter { } } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type Currency = Balances; type DepositBase = ConstU64<1>; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 350b44a06cc67..efcc4d1b026ca 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -57,7 +57,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: ReservableCurrency; @@ -291,7 +291,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -309,7 +309,7 @@ mod tests { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -320,7 +320,7 @@ mod tests { pub const One: u64 = 1; } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ReservationFee = ConstU64<2>; type Slashed = (); diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index 07f2e9de37dde..b502b7681606d 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -64,7 +64,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The maximum number of well known nodes that are allowed to set #[pallet::constant] diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index ae90317987d97..fb6bbc8b8a6f6 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -82,7 +82,7 @@ ord_parameter_types! { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MaxWellKnownNodes = ConstU32<4>; type MaxPeerIdLength = ConstU32<2>; type AddOrigin = EnsureSignedBy; diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 9ea7622c6bfb1..9323b03a50d85 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -41,7 +41,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -69,7 +69,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -96,7 +96,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = (); @@ -123,7 +123,7 @@ parameter_types! { } impl pallet_bags_list::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type BagThresholds = BagThresholds; type ScoreProvider = Staking; @@ -151,7 +151,7 @@ parameter_types! { } impl pallet_nomination_pools::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type Currency = Balances; type CurrencyBalance = Balance; diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 09f1746b8e5ba..2f51d82081654 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -1146,7 +1146,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: weights::WeightInfo; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index 3547878e49ee5..f2d9156d60117 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -136,7 +136,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type DbWeight = (); type BlockLength = (); @@ -160,7 +160,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -188,7 +188,7 @@ parameter_types! { pub const PoolsPalletId: PalletId = PalletId(*b"py/nopls"); } impl pools::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type Currency = Balances; type CurrencyBalance = Balance; diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index f0ac954ef96c4..90b9be0568f5a 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -81,7 +81,7 @@ impl pallet_balances::Config for Runtime { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -111,7 +111,7 @@ impl pallet_staking::Config for Runtime { type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = (); @@ -138,7 +138,7 @@ parameter_types! { } impl pallet_bags_list::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type BagThresholds = BagThresholds; type ScoreProvider = Staking; @@ -165,7 +165,7 @@ parameter_types! { } impl pallet_nomination_pools::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type Currency = Balances; type CurrencyBalance = Balance; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 8d8f032abec62..7158e8d1ff8b0 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -57,7 +57,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -75,7 +75,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<10>; type AccountStore = System; @@ -126,7 +126,7 @@ impl pallet_session::Config for Test { type ShouldEndSession = pallet_session::PeriodicSessions; type NextSessionRotation = pallet_session::PeriodicSessions; type SessionHandler = TestSessionHandler; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; type WeightInfo = (); @@ -163,7 +163,7 @@ impl pallet_staking::Config for Test { type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = (); @@ -186,7 +186,7 @@ impl pallet_staking::Config for Test { impl pallet_im_online::Config for Test { type AuthorityId = UintAuthorityId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorSet = Historical; type NextSessionRotation = pallet_session::PeriodicSessions; type ReportUnresponsiveness = Offences; @@ -198,7 +198,7 @@ impl pallet_im_online::Config for Test { } impl pallet_offences::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = pallet_session::historical::IdentificationTuple; type OnOffenceHandler = Staking; } diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index ae454d6b06740..7858b02719c4c 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -57,7 +57,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From + IsType<::Event>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// Full identification of the validator. type IdentificationTuple: Parameter; /// A handler called for every offence report. diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 4931588293f56..7466b7e4adc40 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -102,7 +102,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -116,7 +116,7 @@ impl frame_system::Config for Runtime { } impl Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type IdentificationTuple = u64; type OnOffenceHandler = OnOffenceHandler; } diff --git a/frame/preimage/src/lib.rs b/frame/preimage/src/lib.rs index 09f6ecd52f9ad..e4616078b0761 100644 --- a/frame/preimage/src/lib.rs +++ b/frame/preimage/src/lib.rs @@ -76,7 +76,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Weight information for this pallet. type WeightInfo: weights::WeightInfo; diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 5962aff69331b..8c78d897e1aca 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -81,7 +81,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<5>; type AccountStore = System; @@ -102,7 +102,7 @@ ord_parameter_types! { impl Config for Test { type WeightInfo = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureSignedBy; type MaxSize = ConstU32<1024>; diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 9945626efbeb1..bfcc8a48c8056 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -108,7 +108,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index d3d2e7c585a82..37ff624cb6721 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -70,7 +70,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -88,14 +88,14 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); } impl pallet_utility::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = (); @@ -150,7 +150,7 @@ impl Contains for BaseFilter { } } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type Currency = Balances; type ProxyType = ProxyType; diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 45d9432d71648..08cc2ddfd408a 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -206,7 +206,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 7ea43a9017445..3339fdab20a47 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -305,7 +305,8 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The outer event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The origin required to add or promote a mmember. The success value indicates the /// maximum rank *to which* the promotion may be. diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index 674382b046d9f..73a047f9130a3 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -170,7 +170,7 @@ impl Polling> for TestPolls { impl Config for Test { type WeightInfo = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PromoteOrigin = EitherOf< // Root can promote arbitrarily. frame_system::EnsureRootWithSuccess>, diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index b839d25e32b47..21f86d713c8d1 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -225,7 +225,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index b72450ddb8dc7..ef777dedb0613 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -64,7 +64,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u128; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; type WeightInfo = (); @@ -102,7 +102,7 @@ parameter_types! { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type Call = Call; type Currency = Balances; diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 15c5562d64c84..ae446f0c7ab21 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -124,7 +124,8 @@ pub mod pallet { pub trait Config: frame_system::Config + Sized { // System level stuff. type Call: Parameter + Dispatchable + From>; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; /// The Scheduler. diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index a043b39dc5ee9..7cf465c07552a 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -78,7 +78,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -91,7 +91,7 @@ impl frame_system::Config for Test { type MaxConsumers = ConstU32<16>; } impl pallet_preimage::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type Currency = Balances; type ManagerOrigin = EnsureRoot; @@ -100,7 +100,7 @@ impl pallet_preimage::Config for Test { type ByteDeposit = (); } impl pallet_scheduler::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; @@ -117,7 +117,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type MaxLocks = ConstU32<10>; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -212,7 +212,7 @@ impl TracksInfo for TestTracksInfo { impl Config for Test { type WeightInfo = (); type Call = Call; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; type SubmitOrigin = frame_system::EnsureSigned; diff --git a/frame/remark/src/lib.rs b/frame/remark/src/lib.rs index c69f95907019f..b61c79f7f273d 100644 --- a/frame/remark/src/lib.rs +++ b/frame/remark/src/lib.rs @@ -43,7 +43,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; } diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 91d3c010aa507..dee6a293d6583 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -54,7 +54,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -69,7 +69,7 @@ impl frame_system::Config for Test { } impl pallet_remark::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index a005c051a1abc..b46df64d7608d 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -198,7 +198,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The aggregated origin which the dispatch will take. type Origin: OriginTrait diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index cffd15c6cc5b1..b97c8eeb385b7 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -59,7 +59,7 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::event] @@ -135,7 +135,7 @@ impl system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -148,7 +148,7 @@ impl system::Config for Test { type MaxConsumers = ConstU32<16>; } impl logger::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block; @@ -159,7 +159,7 @@ ord_parameter_types! { } impl pallet_preimage::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type Currency = (); type ManagerOrigin = EnsureRoot; @@ -169,7 +169,7 @@ impl pallet_preimage::Config for Test { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; type Call = Call; diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index abdb9b2acc9b5..65835cf967617 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -148,7 +148,8 @@ pub mod pallet { + scale_info::TypeInfo; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; // The deposit which is reserved from candidates if they want to // start a candidacy. The deposit gets returned when the candidacy is diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index bc85568754b5f..28f63b320420e 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -89,7 +89,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -124,7 +124,7 @@ impl InitializeMembers for TestChangeMembers { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type KickOrigin = EnsureSignedBy; type MembershipInitialized = TestChangeMembers; type MembershipChanged = TestChangeMembers; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 204240a030b77..6094a43d00c5b 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; @@ -79,7 +79,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<10>; type AccountStore = System; @@ -125,7 +125,7 @@ impl pallet_session::Config for Test { type ShouldEndSession = pallet_session::PeriodicSessions<(), ()>; type NextSessionRotation = pallet_session::PeriodicSessions<(), ()>; type SessionHandler = TestSessionHandler; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = pallet_staking::StashOf; type WeightInfo = (); @@ -159,7 +159,7 @@ impl pallet_staking::Config for Test { type UnixTime = pallet_timestamp::Pallet; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Slash = (); type Reward = (); type SessionsPerEra = (); diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index b3f80c067da4b..587d646158524 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -256,7 +256,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -298,7 +298,7 @@ impl Config for Test { type ValidatorId = u64; type ValidatorIdOf = TestValidatorIdOf; type Keys = MockSessionKeys; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type NextSessionRotation = (); type WeightInfo = (); } diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 2a6428e754b9d..22460cbab14ec 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -377,7 +377,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The societies's pallet id #[pallet::constant] diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 8da82a089895b..fea87049fe1d3 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -72,7 +72,7 @@ impl frame_system::Config for Test { type AccountId = u128; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -90,7 +90,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -98,7 +98,7 @@ impl pallet_balances::Config for Test { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = pallet_balances::Pallet; type Randomness = TestRandomness; type CandidateDeposit = ConstU64<25>; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 4023be22bdec8..ee3a0c18942ed 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -141,7 +141,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -158,7 +158,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; type AccountStore = System; @@ -175,7 +175,7 @@ impl pallet_session::Config for Test { type Keys = SessionKeys; type ShouldEndSession = pallet_session::PeriodicSessions; type SessionHandler = (OtherSessionHandler,); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ValidatorId = AccountId; type ValidatorIdOf = crate::StashOf; type NextSessionRotation = pallet_session::PeriodicSessions; @@ -242,7 +242,7 @@ parameter_types! { } impl pallet_bags_list::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); type ScoreProvider = Staking; type BagThresholds = BagThresholds; @@ -282,7 +282,7 @@ impl crate::pallet::pallet::Config for Test { type UnixTime = Timestamp; type CurrencyToVote = frame_support::traits::SaturatingCurrencyToVote; type RewardRemainder = RewardRemainderMock; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Slash = (); type Reward = MockReward; type SessionsPerEra = SessionsPerEra; diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 4ce96ab68b11a..b6a5ec82b4e11 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -129,7 +129,7 @@ pub mod pallet { type RewardRemainder: OnUnbalanced>; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for the unbalanced reduction when slashing a staker. type Slash: OnUnbalanced>; diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index b2a5f0f3c11cf..4f3d7049595e5 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -449,7 +449,7 @@ pub mod pallet { type SignedFilter: EnsureOrigin; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency provider type. type Currency: Currency; @@ -1086,7 +1086,7 @@ mod mock { type AccountId = u64; type Lookup = IdentityLookup; type Header = sp_runtime::generic::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type DbWeight = (); type Version = (); @@ -1108,7 +1108,7 @@ mod mock { impl pallet_balances::Config for Test { type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -1146,7 +1146,7 @@ mod mock { } impl pallet_state_trie_migration::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ControlOrigin = EnsureRoot; type Currency = Balances; type MaxKeyLen = MigrationMaxKeyLen; diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index a47b5a79bd017..456cdef8f03b8 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -113,7 +113,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A sudo-able call. type Call: Parameter + UnfilteredDispatchable + GetDispatchInfo; diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 7aecb634fbbef..047b07b7bb64b 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -39,7 +39,7 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -133,7 +133,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -148,12 +148,12 @@ impl frame_system::Config for Test { // Implement the logger module's `Config` on the Test runtime. impl logger::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } // Implement the sudo module's `Config` on the Test runtime. impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 8e43df82a284c..377709ec9ef89 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2028,7 +2028,7 @@ pub mod pallet_prelude { /// #[pallet::constant] // put the constant in metadata /// type MyGetParam: Get; /// type Balance: Parameter + MaxEncodedLen + From; -/// type Event: From> + IsType<::Event>; +/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// } /// /// // Define some additional constant to put into the constant metadata. @@ -2217,7 +2217,7 @@ pub mod pallet_prelude { /// #[pallet::constant] /// type MyGetParam: Get; /// type Balance: Parameter + MaxEncodedLen + From; -/// type Event: From> + IsType<::Event>; +/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// } /// /// #[pallet::extra_constants] diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index 723eadb85fed2..ff1013348c94f 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -68,7 +68,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = AccountId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 13973377a5d9c..af1d351b28025 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -248,7 +248,7 @@ impl system::Config for Runtime { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = AccountId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs index ddbc10aa53dac..623a30e23d73f 100644 --- a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs +++ b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs @@ -21,7 +21,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index cd6f724358727..a14519930066c 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -55,7 +55,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index 414187f5bf6ad..bdfea120369b2 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index 60fec30f0ec03..bea30a73bab7d 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index 55de9aadf0dd4..4309e749290d5 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index a5314cd7bd5ab..176de187c713c 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index 9d5110f625898..2f880097ba3ee 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index 51c38401e4bbf..8c0d231122f93 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -30,7 +30,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = frame_support::traits::ConstU32<250>; type BlockWeights = (); type BlockLength = (); diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 860aba42c8b82..dcb18869c911e 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -50,7 +50,7 @@ mod module1 { where ::BlockNumber: From, { - type Event: From> + Into<::Event>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; type Origin: From>; type SomeParameter: Get; type GenericType: Default + Clone + Codec + EncodeLike + TypeInfo; @@ -154,7 +154,7 @@ mod module2 { pub trait Config: system::Config { type Amount: Parameter + Default; - type Event: From> + Into<::Event>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; type Origin: From>; } @@ -233,35 +233,35 @@ mod module3 { } impl module1::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; type SomeParameter = ConstU32<100>; type GenericType = u32; } impl module1::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; type SomeParameter = ConstU32<100>; type GenericType = u32; } impl module2::Config for Runtime { type Amount = u16; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; } impl module2::Config for Runtime { type Amount = u32; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; } impl module2::Config for Runtime { type Amount = u32; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; } impl module2::Config for Runtime { type Amount = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Origin = Origin; } impl module3::Config for Runtime { @@ -280,7 +280,7 @@ impl system::Config for Runtime { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = AccountId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 19737a5e1d6e6..22045779fd7a1 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -163,7 +163,7 @@ impl system::Config for Runtime { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = AccountId; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index ce7d107302a3e..bd2da6b9911fa 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -149,7 +149,7 @@ impl system::Config for RuntimeOriginTest { type Origin = Origin; type BlockNumber = BlockNumber; type AccountId = u32; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; type Call = Call; type DbWeight = (); diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index beefc69b596a3..1652222dda478 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -125,7 +125,7 @@ pub mod pallet { type Balance: Parameter + Default + TypeInfo; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::extra_constants] @@ -452,7 +452,7 @@ pub mod pallet2 { where ::AccountId: From + SomeAssociation1, { - type Event: From + IsType<::Event>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -558,7 +558,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); @@ -574,7 +574,7 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MyGetParam = ConstU32<10>; type MyGetParam2 = ConstU32<11>; type MyGetParam3 = MyGetParam3; @@ -582,7 +582,7 @@ impl pallet::Config for Runtime { } impl pallet2::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } impl pallet4::Config for Runtime {} diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index b28d85f588465..bcc4689668999 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -43,7 +43,7 @@ mod pallet_old { + Into + Default + SomeAssociation; - type Event: From> + Into<::Event>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } decl_storage! { @@ -120,7 +120,7 @@ pub mod pallet { + scale_info::StaticTypeInfo; #[pallet::constant] type SomeConst: Get; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -235,7 +235,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); @@ -251,12 +251,12 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index d2d16bdd6c1a5..89ed9ad8fbe4d 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -30,7 +30,7 @@ mod pallet_old { pub trait Config: frame_system::Config { type SomeConst: Get; type Balance: Parameter + codec::HasCompact + From + Into + Default; - type Event: From> + Into<::Event>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } decl_storage! { @@ -105,7 +105,8 @@ pub mod pallet { + scale_info::StaticTypeInfo; #[pallet::constant] type SomeConst: Get; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -218,7 +219,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type Version = (); type PalletInfo = PalletInfo; @@ -231,32 +232,32 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } impl pallet_old::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type SomeConst = ConstU64<10>; type Balance = u64; } diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 3422b53776b9b..3dadc80e6787a 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -42,7 +42,8 @@ pub mod pallet { #[pallet::constant] type MyGetParam: Get; type Balance: Parameter + Default + scale_info::StaticTypeInfo; - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -217,7 +218,8 @@ pub mod pallet2 { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -258,7 +260,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type BlockWeights = (); type BlockLength = (); @@ -274,20 +276,20 @@ impl frame_system::Config for Runtime { type MaxConsumers = ConstU32<16>; } impl pallet::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MyGetParam = ConstU32<10>; type Balance = u64; } impl pallet::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type MyGetParam = ConstU32<10>; type Balance = u64; } impl pallet2::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } impl pallet2::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } pub type Header = sp_runtime::generic::Header; diff --git a/frame/support/test/tests/pallet_ui/event_field_not_member.rs b/frame/support/test/tests/pallet_ui/event_field_not_member.rs index 0ecde4c130878..2b45a971788fb 100644 --- a/frame/support/test/tests/pallet_ui/event_field_not_member.rs +++ b/frame/support/test/tests/pallet_ui/event_field_not_member.rs @@ -6,7 +6,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar; - type Event: IsType<::Event> + From>; + type RuntimeEvent: IsType<::RuntimeEvent> + From>; } #[pallet::pallet] diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs index 564a539b89f57..99df89d67278c 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs @@ -6,7 +6,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar; - type Event: IsType<::Event>; + type RuntimeEvent: IsType<::RuntimeEvent>; } #[pallet::pallet] diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 7ed8454668327..738f9f83ccabb 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -18,7 +18,7 @@ pub trait Trait: frame_system::Config { type Balance: frame_support::dispatch::Parameter; /// The overarching event type. - type Event: From> + Into<::Event>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } frame_support::decl_storage! { diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index c6e9a26e44db7..d5ba8873a6df4 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -95,7 +95,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU32<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index 9d5d4765f9ade..ca9e001ca0a7f 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -30,7 +30,7 @@ pub trait Config: 'static + Eq + Clone { type Hash; type AccountId: Encode + EncodeLike + Decode + scale_info::TypeInfo; type Call; - type Event: From>; + type RuntimeEvent: From>; type PalletInfo: frame_support::traits::PalletInfo; type DbWeight: Get; } diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 3c056da69e2eb..19350e728fc3c 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -34,7 +34,7 @@ mod module { #[pallet::config] pub trait Config: frame_system::Config { - type Event: From + IsType<::Event>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; } #[pallet::event] @@ -82,7 +82,7 @@ impl frame_system::Config for Runtime { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -96,7 +96,7 @@ impl frame_system::Config for Runtime { } impl module::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; } fn new_test_ext() -> sp_io::TestExternalities { diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 6edb6a1dfed75..f53b5e2bec9be 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Test { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = (); type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index b132d797756d4..0e96c2176f33a 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 71af87b42b55b..9101195065489 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -126,7 +126,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_treasury::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Maximum acceptable reason length. /// diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 61c9981671329..0f566d73d54b8 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -76,7 +76,7 @@ impl frame_system::Config for Test { type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -94,7 +94,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -136,7 +136,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -155,7 +155,7 @@ impl pallet_treasury::Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; @@ -179,7 +179,7 @@ impl Config for Test { type TipFindersFee = TipFindersFee; type TipReportDepositBase = ConstU64<1>; type DataDepositPerByte = ConstU64<1>; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } @@ -190,7 +190,7 @@ impl Config for Test { type TipFindersFee = TipFindersFee; type TipReportDepositBase = ConstU64<1>; type DataDepositPerByte = ConstU64<1>; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } diff --git a/frame/transaction-payment/asset-tx-payment/src/lib.rs b/frame/transaction-payment/asset-tx-payment/src/lib.rs index 08561375247ae..768d556bcb6a3 100644 --- a/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -114,7 +114,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_transaction_payment::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The fungibles instance used to pay for transactions in assets. type Fungibles: Balanced; /// The actual transaction charging logic that charges the fees. diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index abfca86484380..589b195a8a247 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -96,7 +96,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -115,7 +115,7 @@ parameter_types! { impl pallet_balances::Config for Runtime { type Balance = Balance; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<10>; type AccountStore = System; @@ -143,7 +143,7 @@ impl WeightToFeeT for TransactionByteFee { } impl pallet_transaction_payment::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type WeightToFee = WeightToFee; type LengthToFee = TransactionByteFee; @@ -152,7 +152,7 @@ impl pallet_transaction_payment::Config for Runtime { } impl pallet_assets::Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Balance = Balance; type AssetId = u32; type Currency = Balances; @@ -198,7 +198,7 @@ impl HandleCredit for CreditToBlockAuthor { } impl Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Fungibles = Assets; type OnChargeAssetTransaction = FungiblesAdapter< pallet_assets::BalanceToAssetBalance, diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index c4ba8462a00f2..e3ab3f5c1b67c 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -250,7 +250,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for withdrawing, refunding and depositing the transaction fee. /// Transaction fees are withdrawn before the transaction is executed. @@ -848,7 +848,7 @@ mod tests { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -863,7 +863,7 @@ mod tests { impl pallet_balances::Config for Runtime { type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -911,7 +911,7 @@ mod tests { } impl Config for Runtime { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnChargeTransaction = CurrencyAdapter; type OperationalFeeMultiplier = OperationalFeeMultiplier; type WeightToFee = WeightToFee; diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index f16b8f029662b..c1f7c12b9a2f9 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -92,7 +92,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A dispatchable call. type Call: Parameter + Dispatchable diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index ecfc9bef36d3b..e901aa4e510b7 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -60,7 +60,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -77,7 +77,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -87,7 +87,7 @@ impl pallet_balances::Config for Test { } impl pallet_transaction_storage::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type Currency = Balances; type FeeDestination = (); diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 6730f985b16e0..4adb9cbcde9bc 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -154,7 +154,8 @@ pub mod pallet { type RejectOrigin: EnsureOrigin; /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Handler for the unbalanced decrease when slashing for a rejected proposal or bounty. type OnSlash: OnUnbalanced>; diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index a62bcfdfcb3ab..92fec60ad0d9d 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -88,7 +88,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -126,7 +126,7 @@ impl Config for Test { type Currency = pallet_balances::Pallet; type ApproveOrigin = frame_system::EnsureRoot; type RejectOrigin = frame_system::EnsureRoot; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type OnSlash = (); type ProposalBond = ProposalBond; type ProposalBondMinimum = ConstU64<1>; diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index b25fb2f87ea97..294ed57b935ae 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -89,7 +89,8 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Identifier for the collection of item. type CollectionId: Member diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index 8a915986e3256..f258c7236d641 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type DbWeight = (); type Version = (); @@ -75,7 +75,7 @@ impl frame_system::Config for Test { impl pallet_balances::Config for Test { type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -85,7 +85,7 @@ impl pallet_balances::Config for Test { } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type CollectionId = u32; type ItemId = u32; type Currency = Balances; diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 0aae2615702dd..057cda8cafb55 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -84,7 +84,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From + IsType<::Event>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index ba9bd7e69d0c9..fe82af3b20bdc 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -115,7 +115,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -134,7 +134,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ConstU64<1>; type AccountStore = System; type WeightInfo = (); @@ -163,7 +163,7 @@ impl Contains for TestBaseCallFilter { } } impl Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type PalletsOrigin = OriginCaller; type WeightInfo = (); diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 9fb7eb8037916..2c2813fab0aa6 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -154,7 +154,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: LockableCurrency; diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 3c5a4282ee7b1..108d2244a31ab 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -57,7 +57,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type Call = Call; type DbWeight = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Hash = H256; type Hashing = BlakeTwo256; type Header = Header; @@ -78,7 +78,7 @@ impl pallet_balances::Config for Test { type AccountStore = System; type Balance = u64; type DustRemoval = (); - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type ExistentialDeposit = ExistentialDeposit; type MaxLocks = ConstU32<10>; type MaxReserves = (); @@ -92,7 +92,7 @@ parameter_types! { impl Config for Test { type BlockNumberToBalance = Identity; type Currency = Balances; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; const MAX_VESTING_SCHEDULES: u32 = 3; type MinVestedTransfer = MinVestedTransfer; type WeightInfo = (); diff --git a/frame/whitelist/src/lib.rs b/frame/whitelist/src/lib.rs index 239f0fd280160..64bdaa3a43151 100644 --- a/frame/whitelist/src/lib.rs +++ b/frame/whitelist/src/lib.rs @@ -61,7 +61,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type Event: From> + IsType<::Event>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: IsType<::Call> diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index c0f764ddd3313..82d1f95416395 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -67,7 +67,7 @@ impl frame_system::Config for Test { type AccountId = u64; type Lookup = IdentityLookup; type Header = Header; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type BlockHashCount = ConstU64<250>; type Version = (); type PalletInfo = PalletInfo; @@ -85,7 +85,7 @@ impl pallet_balances::Config for Test { type MaxReserves = (); type ReserveIdentifier = [u8; 8]; type Balance = u64; - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ConstU64<1>; type AccountStore = System; @@ -93,7 +93,7 @@ impl pallet_balances::Config for Test { } impl pallet_preimage::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Currency = Balances; type ManagerOrigin = EnsureRoot; type MaxSize = ConstU32<{ 4096 * 1024 }>; // PreimageMaxSize Taken from Polkadot as reference. @@ -103,7 +103,7 @@ impl pallet_preimage::Config for Test { } impl pallet_whitelist::Config for Test { - type Event = RuntimeEvent; + type RuntimeEvent = RuntimeEvent; type Call = Call; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; From ca9d2a436000c24aed4abca23a5dfd8b031b8e2b Mon Sep 17 00:00:00 2001 From: Szegoo Date: Tue, 9 Aug 2022 08:32:11 +0200 Subject: [PATCH 16/63] rename to RuntimeEvent --- frame/alliance/src/benchmarking.rs | 2 +- frame/assets/src/benchmarking.rs | 4 ++-- frame/benchmarking/src/tests_instance.rs | 12 ++++++------ frame/bounties/src/benchmarking.rs | 2 +- frame/child-bounties/src/benchmarking.rs | 2 +- frame/collective/src/benchmarking.rs | 2 +- frame/contracts/src/exec.rs | 2 +- frame/democracy/src/benchmarking.rs | 2 +- frame/election-provider-support/src/onchain.rs | 2 +- frame/identity/src/benchmarking.rs | 2 +- frame/membership/src/lib.rs | 2 +- frame/offences/benchmarking/src/lib.rs | 14 +++++++------- frame/proxy/src/benchmarking.rs | 2 +- frame/ranked-collective/src/benchmarking.rs | 2 +- frame/recovery/src/benchmarking.rs | 2 +- frame/referenda/src/benchmarking.rs | 2 +- frame/remark/src/benchmarking.rs | 4 ++-- frame/remark/src/tests.rs | 2 +- .../support/procedural/src/pallet/parse/config.rs | 2 +- frame/support/src/lib.rs | 4 ++-- .../pallet_ui/event_type_invalid_bound.stderr | 2 +- .../pallet_ui/event_type_invalid_bound_2.stderr | 2 +- .../test/tests/pallet_with_name_trait_is_valid.rs | 4 ++-- frame/transaction-storage/src/benchmarking.rs | 4 ++-- frame/treasury/src/benchmarking.rs | 2 +- frame/uniques/src/benchmarking.rs | 4 ++-- frame/utility/src/benchmarking.rs | 2 +- 27 files changed, 44 insertions(+), 44 deletions(-) diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 527c35b58a5d8..f0a291abcde28 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -34,7 +34,7 @@ const SEED: u32 = 0; const MAX_BYTES: u32 = 1_024; -fn assert_last_event, I: 'static>(generic_event: >::Event) { +fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index ca88899edf842..df5ad858f6e78 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -140,11 +140,11 @@ fn add_approvals, I: 'static>(minter: T::AccountId, n: u32) { } } -fn assert_last_event, I: 'static>(generic_event: >::Event) { +fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } -fn assert_event, I: 'static>(generic_event: >::Event) { +fn assert_event, I: 'static>(generic_event: >::RuntimeEvent) { frame_system::Pallet::::assert_has_event(generic_event.into()); } diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 8fdea8ae852a0..991eab17ba6f3 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -33,7 +33,7 @@ mod pallet_test { frame_support::decl_storage! { trait Store for Module, I: Instance = DefaultInstance> as Test where - ::OtherEvent: Into<>::Event> + ::OtherEvent: Into<>::RuntimeEvent> { pub Value get(fn value): Option; } @@ -41,7 +41,7 @@ mod pallet_test { frame_support::decl_module! { pub struct Module, I: Instance = DefaultInstance> for enum Call where - origin: T::Origin, ::OtherEvent: Into<>::Event> + origin: T::Origin, ::OtherEvent: Into<>::RuntimeEvent> { #[weight = 0] fn set_value(origin, n: u32) -> frame_support::dispatch::DispatchResult { @@ -64,9 +64,9 @@ mod pallet_test { pub trait Config: frame_system::Config + OtherConfig where - Self::OtherEvent: Into<>::Event>, + Self::OtherEvent: Into<>::RuntimeEvent>, { - type Event; + type RuntimeEvent; type LowerBound: Get; type UpperBound: Get; } @@ -142,8 +142,8 @@ mod benchmarks { where_clause { where ::OtherEvent: Clone - + Into<>::Event>, - >::Event: Clone, + + Into<>::RuntimeEvent>, + >::RuntimeEvent: Clone, } set_value { diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index 7566c32f6e9a1..8b9967fbee3cd 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -85,7 +85,7 @@ fn setup_pot_account, I: 'static>() { let _ = T::Currency::make_free_balance_be(&pot_account, value); } -fn assert_last_event, I: 'static>(generic_event: >::Event) { +fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index ca5af50276b9d..697ed40e0071f 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -160,7 +160,7 @@ fn setup_pot_account() { let _ = T::Currency::make_free_balance_be(&pot_account, value); } -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 076afcd203030..dea68e1088ce0 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -30,7 +30,7 @@ const SEED: u32 = 0; const MAX_BYTES: u32 = 1_024; -fn assert_last_event, I: 'static>(generic_event: >::Event) { +fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 8c8aeaea20bfe..297dd8b8d221e 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1316,7 +1316,7 @@ where fn deposit_event(topics: Vec, event: Event) { >::deposit_event_indexed( &topics, - ::Event::from(event).into(), + ::RuntimeEvent::from(event).into(), ) } diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index c51fde8a3de8b..9b52379286a01 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -37,7 +37,7 @@ const MAX_REFERENDUMS: u32 = 99; const MAX_SECONDERS: u32 = 100; const MAX_BYTES: u32 = 16_384; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 62e76c3888822..eb6d683bdf8cd 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -220,7 +220,7 @@ mod tests { type AccountId = AccountId; type Lookup = sp_runtime::traits::IdentityLookup; type Header = sp_runtime::testing::Header; - type Event = (); + type RuntimeEvent = (); type BlockHashCount = (); type DbWeight = (); type BlockLength = (); diff --git a/frame/identity/src/benchmarking.rs b/frame/identity/src/benchmarking.rs index b225db4edfa91..4b093959fa12f 100644 --- a/frame/identity/src/benchmarking.rs +++ b/frame/identity/src/benchmarking.rs @@ -29,7 +29,7 @@ use sp_runtime::traits::Bounded; const SEED: u32 = 0; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 0140353481f70..b42369968af64 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -145,7 +145,7 @@ pub mod pallet { /// One of the members' keys changed. KeyChanged, /// Phantom member, never used. - Dummy { _phantom_data: PhantomData<(T::AccountId, >::Event)> }, + Dummy { _phantom_data: PhantomData<(T::AccountId, >::RuntimeEvent)> }, } #[pallet::error] diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index b793bd8d2699a..96c6f9c2bdfc3 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -216,7 +216,7 @@ fn make_offenders_im_online( } #[cfg(test)] -fn check_events::Event>>(expected: I) { +fn check_events::RuntimeEvent>>(expected: I) { let events = System::::events() .into_iter() .map(|frame_system::EventRecord { event, .. }| event) @@ -308,16 +308,16 @@ benchmarks! { let reward_amount = slash_amount * (1 + n) / 2; let reward = reward_amount / r; let slash = |id| core::iter::once( - ::Event::from(StakingEvent::::Slashed(id, BalanceOf::::from(slash_amount))) + ::RuntimeEvent::from(StakingEvent::::Slashed(id, BalanceOf::::from(slash_amount))) ); let balance_slash = |id| core::iter::once( - ::Event::from(pallet_balances::Event::::Slashed{who: id, amount: slash_amount.into()}) + ::RuntimeEvent::from(pallet_balances::Event::::Slashed{who: id, amount: slash_amount.into()}) ); let chill = |id| core::iter::once( - ::Event::from(StakingEvent::::Chilled(id)) + ::RuntimeEvent::from(StakingEvent::::Chilled(id)) ); let balance_deposit = |id, amount: u32| - ::Event::from(pallet_balances::Event::::Deposit{who: id, amount: amount.into()}); + ::RuntimeEvent::from(pallet_balances::Event::::Deposit{who: id, amount: amount.into()}); let mut first = true; let slash_events = raw_offenders.into_iter() .flat_map(|offender| { @@ -339,7 +339,7 @@ benchmarks! { .flat_map(|reporter| vec![ balance_deposit(reporter.clone(), reward).into(), frame_system::Event::::NewAccount { account: reporter.clone() }.into(), - ::Event::from( + ::RuntimeEvent::from( pallet_balances::Event::::Endowed{account: reporter, free_balance: reward.into()} ).into(), ]) @@ -366,7 +366,7 @@ benchmarks! { check_events::( std::iter::empty() .chain(slash_events.into_iter().map(Into::into)) - .chain(std::iter::once(::Event::from( + .chain(std::iter::once(::RuntimeEvent::from( pallet_offences::Event::Offence{ kind: UnresponsivenessOffence::::ID, timeslot: 0_u32.to_le_bytes().to_vec(), diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 87017290a3ab9..c760a8a713b55 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -27,7 +27,7 @@ use sp_runtime::traits::Bounded; const SEED: u32 = 0; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/ranked-collective/src/benchmarking.rs b/frame/ranked-collective/src/benchmarking.rs index ab1a5dc283ca5..1ba9344aa3be7 100644 --- a/frame/ranked-collective/src/benchmarking.rs +++ b/frame/ranked-collective/src/benchmarking.rs @@ -27,7 +27,7 @@ use frame_system::RawOrigin as SystemOrigin; const SEED: u32 = 0; -fn assert_last_event, I: 'static>(generic_event: >::Event) { +fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/recovery/src/benchmarking.rs b/frame/recovery/src/benchmarking.rs index 5354de6d10b51..5edc851641080 100644 --- a/frame/recovery/src/benchmarking.rs +++ b/frame/recovery/src/benchmarking.rs @@ -28,7 +28,7 @@ use sp_runtime::traits::Bounded; const SEED: u32 = 0; const DEFAULT_DELAY: u32 = 0; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/referenda/src/benchmarking.rs b/frame/referenda/src/benchmarking.rs index 9abd3768f780c..2a73628d01931 100644 --- a/frame/referenda/src/benchmarking.rs +++ b/frame/referenda/src/benchmarking.rs @@ -31,7 +31,7 @@ use sp_runtime::traits::{Bounded, Hash}; const SEED: u32 = 0; #[allow(dead_code)] -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/remark/src/benchmarking.rs b/frame/remark/src/benchmarking.rs index d30a8aa5df07d..c0db8d5d3d59b 100644 --- a/frame/remark/src/benchmarking.rs +++ b/frame/remark/src/benchmarking.rs @@ -27,9 +27,9 @@ use sp_std::*; #[cfg(test)] use crate::Pallet as Remark; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { let events = System::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); let EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); } diff --git a/frame/remark/src/tests.rs b/frame/remark/src/tests.rs index eac006054c1d5..6e297524844ee 100644 --- a/frame/remark/src/tests.rs +++ b/frame/remark/src/tests.rs @@ -31,7 +31,7 @@ fn generates_event() { assert_ok!(Remark::::store(RawOrigin::Signed(caller.clone()).into(), data.clone(),)); let events = System::events(); // this one we create as we expect it - let system_event: ::Event = Event::Stored { + let system_event: ::RuntimeEvent = Event::Stored { content_hash: sp_io::hashing::blake2_256(&data).into(), sender: caller, } diff --git a/frame/support/procedural/src/pallet/parse/config.rs b/frame/support/procedural/src/pallet/parse/config.rs index a7b48c49b2a0d..7795f359cebf5 100644 --- a/frame/support/procedural/src/pallet/parse/config.rs +++ b/frame/support/procedural/src/pallet/parse/config.rs @@ -44,7 +44,7 @@ pub struct ConfigDef { /// Const associated type. pub consts_metadata: Vec, /// Whether the trait has the associated type `Event`, note that those bounds are checked: - /// * `IsType::Event` + /// * `IsType::RuntimeEvent` /// * `From` or `From>` or `From>` pub has_event_type: bool, /// The where clause on trait definition but modified so `Self` is `T`. diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 377709ec9ef89..a80be4e93121e 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -1420,7 +1420,7 @@ pub mod pallet_prelude { /// optionally other supertrait and where clause. /// /// The associated type `Event` is reserved, if defined it must bounds `From` and -/// `IsType<::Event>`, see `#[pallet::event]` for more +/// `IsType<::RuntimeEvent>`, see `#[pallet::event]` for more /// information. /// /// To put `Get` associated type into metadatas, use the attribute `#[pallet::constant]`, e.g.: @@ -2373,7 +2373,7 @@ pub mod pallet_prelude { /// ``` /// 5. **migrate Config**: move trait into the module with /// * all const in decl_module to `#[pallet::constant]` -/// * add bound `IsType<::Event>` to `type Event` +/// * add bound `IsType<::RuntimeEvent>` to `type Event` /// 7. **migrate decl_module**: write: /// ```ignore /// #[pallet::hooks] diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr index 1f58a37576d0d..ea4fb7b88a512 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr @@ -1,4 +1,4 @@ -error: Invalid `type Event`, associated type `Event` is reserved and must bound: `IsType<::Event>` +error: Invalid `type Event`, associated type `Event` is reserved and must bound: `IsType<::RuntimeEvent>` --> $DIR/event_type_invalid_bound.rs:9:3 | 9 | type Event; diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr index 8b8946f3b25eb..8f3d272489abf 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr @@ -1,5 +1,5 @@ error: Invalid `type Event`, associated type `Event` is reserved and must bound: `From` or `From>` or `From>` --> $DIR/event_type_invalid_bound_2.rs:9:3 | -9 | type Event: IsType<::Event>; +9 | type Event: IsType<::RuntimeEvent>; | ^^^^ diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 738f9f83ccabb..6f2f099514883 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -135,7 +135,7 @@ mod tests { type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; type Header = TestHeader; - type Event = (); + type RuntimeEvent = (); type BlockHashCount = ConstU64<250>; type DbWeight = (); type BlockWeights = (); @@ -153,6 +153,6 @@ mod tests { impl pallet_test::Trait for Runtime { type Balance = u32; - type Event = (); + type RuntimeEvent = (); } } diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index 83dd37922a31f..cab4c92317bb5 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -105,9 +105,9 @@ const PROOF: &[u8] = &hex_literal::hex!( type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { let events = System::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); let EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); } diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index ddb952383370d..ed58480d95511 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -61,7 +61,7 @@ fn setup_pot_account, I: 'static>() { let _ = T::Currency::make_free_balance_be(&pot_account, value); } -fn assert_last_event, I: 'static>(generic_event: >::Event) { +fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } diff --git a/frame/uniques/src/benchmarking.rs b/frame/uniques/src/benchmarking.rs index 86247fb964ff5..0b5077005cd23 100644 --- a/frame/uniques/src/benchmarking.rs +++ b/frame/uniques/src/benchmarking.rs @@ -124,9 +124,9 @@ fn add_item_attribute, I: 'static>( (key, caller, caller_lookup) } -fn assert_last_event, I: 'static>(generic_event: >::Event) { +fn assert_last_event, I: 'static>(generic_event: >::RuntimeEvent) { let events = frame_system::Pallet::::events(); - let system_event: ::Event = generic_event.into(); + let system_event: ::RuntimeEvent = generic_event.into(); // compare to the last event record let frame_system::EventRecord { event, .. } = &events[events.len() - 1]; assert_eq!(event, &system_event); diff --git a/frame/utility/src/benchmarking.rs b/frame/utility/src/benchmarking.rs index 018280f69baeb..fbbd6f2b378c7 100644 --- a/frame/utility/src/benchmarking.rs +++ b/frame/utility/src/benchmarking.rs @@ -25,7 +25,7 @@ use frame_system::RawOrigin; const SEED: u32 = 0; -fn assert_last_event(generic_event: ::Event) { +fn assert_last_event(generic_event: ::RuntimeEvent) { frame_system::Pallet::::assert_last_event(generic_event.into()); } From e917961c3fddd382d4ec2d90cb3051dcb9962e43 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 16:57:20 +0200 Subject: [PATCH 17/63] commit --- bin/node-template/pallets/template/src/lib.rs | 6 +- bin/node/executor/tests/basic.rs | 40 +- frame/alliance/src/benchmarking.rs | 22 +- frame/alliance/src/lib.rs | 26 +- frame/alliance/src/tests.rs | 10 +- frame/assets/README.md | 2 +- frame/assets/src/benchmarking.rs | 46 +- frame/assets/src/functions.rs | 14 +- frame/assets/src/lib.rs | 30 +- frame/atomic-swap/src/lib.rs | 10 +- frame/bags-list/src/lib.rs | 8 +- frame/balances/src/lib.rs | 38 +- frame/balances/src/tests.rs | 38 +- frame/balances/src/tests_local.rs | 14 +- frame/balances/src/tests_reentrancy.rs | 18 +- frame/beefy-mmr/src/mock.rs | 2 +- frame/bounties/src/benchmarking.rs | 6 +- frame/bounties/src/lib.rs | 18 +- frame/child-bounties/src/benchmarking.rs | 8 +- frame/child-bounties/src/lib.rs | 12 +- frame/collective/src/benchmarking.rs | 16 +- frame/collective/src/lib.rs | 26 +- frame/collective/src/tests.rs | 8 +- frame/contracts/src/exec.rs | 24 +- frame/contracts/src/lib.rs | 6 +- frame/contracts/src/tests.rs | 114 +-- frame/contracts/src/wasm/code_cache.rs | 6 +- frame/conviction-voting/src/lib.rs | 8 +- frame/democracy/src/benchmarking.rs | 2 +- frame/democracy/src/lib.rs | 46 +- frame/democracy/src/tests/public_proposals.rs | 2 +- .../election-provider-multi-phase/src/lib.rs | 46 +- .../election-provider-multi-phase/src/mock.rs | 2 +- .../src/signed.rs | 4 +- frame/elections-phragmen/src/lib.rs | 34 +- frame/examples/basic/src/lib.rs | 8 +- frame/examples/offchain-worker/src/lib.rs | 6 +- frame/executive/src/lib.rs | 4 +- frame/gilt/src/lib.rs | 12 +- frame/grandpa/src/lib.rs | 10 +- frame/grandpa/src/mock.rs | 6 +- frame/grandpa/src/tests.rs | 6 +- frame/identity/src/benchmarking.rs | 8 +- frame/identity/src/lib.rs | 24 +- frame/im-online/src/lib.rs | 10 +- frame/im-online/src/mock.rs | 2 +- frame/indices/src/lib.rs | 14 +- frame/lottery/src/lib.rs | 12 +- frame/membership/src/lib.rs | 14 +- frame/multisig/src/lib.rs | 12 +- frame/multisig/src/tests.rs | 2 +- frame/nicks/src/lib.rs | 14 +- frame/node-authorization/src/lib.rs | 22 +- frame/nomination-pools/src/lib.rs | 30 +- frame/nomination-pools/src/migration.rs | 2 +- frame/nomination-pools/src/mock.rs | 4 +- frame/nomination-pools/src/tests.rs | 680 +++++++++--------- .../nomination-pools/test-staking/src/lib.rs | 4 +- .../nomination-pools/test-staking/src/mock.rs | 4 +- frame/offences/benchmarking/src/lib.rs | 12 +- frame/offences/benchmarking/src/mock.rs | 4 +- frame/offences/src/lib.rs | 6 +- frame/offences/src/mock.rs | 2 +- frame/offences/src/tests.rs | 4 +- frame/preimage/src/lib.rs | 12 +- frame/proxy/src/benchmarking.rs | 8 +- frame/proxy/src/lib.rs | 14 +- frame/proxy/src/tests.rs | 8 +- frame/ranked-collective/src/benchmarking.rs | 12 +- frame/ranked-collective/src/lib.rs | 16 +- frame/recovery/src/benchmarking.rs | 14 +- frame/recovery/src/lib.rs | 18 +- frame/referenda/src/lib.rs | 30 +- frame/remark/src/benchmarking.rs | 2 +- frame/remark/src/lib.rs | 6 +- frame/remark/src/tests.rs | 4 +- frame/scheduler/src/lib.rs | 22 +- frame/scheduler/src/mock.rs | 8 +- frame/scored-pool/src/lib.rs | 14 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/session/src/lib.rs | 6 +- frame/session/src/mock.rs | 4 +- frame/society/src/lib.rs | 38 +- frame/staking/src/lib.rs | 2 +- frame/staking/src/mock.rs | 6 +- frame/staking/src/pallet/impls.rs | 18 +- frame/staking/src/pallet/mod.rs | 18 +- frame/staking/src/slashing.rs | 2 +- frame/staking/src/tests.rs | 54 +- frame/state-trie-migration/src/lib.rs | 26 +- frame/sudo/src/lib.rs | 12 +- frame/sudo/src/mock.rs | 8 +- frame/sudo/src/tests.rs | 10 +- .../src/construct_runtime/expand/event.rs | 16 +- .../src/construct_runtime/expand/metadata.rs | 8 +- .../procedural/src/construct_runtime/parse.rs | 4 +- frame/support/procedural/src/lib.rs | 2 +- .../procedural/src/pallet/expand/event.rs | 6 +- .../procedural/src/pallet/parse/config.rs | 20 +- .../procedural/src/pallet/parse/event.rs | 16 +- frame/support/src/event.rs | 12 +- frame/support/src/lib.rs | 14 +- frame/support/test/tests/construct_runtime.rs | 52 +- .../undefined_event_part.rs | 2 +- .../undefined_event_part.stderr | 4 +- frame/support/test/tests/instance.rs | 10 +- frame/support/test/tests/origin.rs | 4 +- frame/support/test/tests/pallet.rs | 54 +- .../test/tests/pallet_compatibility.rs | 14 +- .../tests/pallet_compatibility_instance.rs | 16 +- frame/support/test/tests/pallet_instance.rs | 44 +- .../tests/pallet_ui/event_field_not_member.rs | 4 +- .../tests/pallet_ui/event_not_in_trait.rs | 2 +- .../pallet_ui/event_type_invalid_bound.rs | 2 +- .../pallet_ui/event_type_invalid_bound_2.rs | 2 +- .../event_type_invalid_bound_2.stderr | 2 +- .../tests/pallet_with_name_trait_is_valid.rs | 2 +- frame/support/test/tests/system.rs | 2 +- frame/system/benches/bench.rs | 8 +- frame/system/src/lib.rs | 16 +- frame/system/src/mock.rs | 2 +- frame/tips/src/lib.rs | 16 +- frame/tips/src/tests.rs | 2 +- .../asset-tx-payment/src/lib.rs | 6 +- frame/transaction-payment/src/lib.rs | 12 +- frame/transaction-storage/src/benchmarking.rs | 6 +- frame/transaction-storage/src/lib.rs | 10 +- frame/treasury/src/benchmarking.rs | 2 +- frame/treasury/src/lib.rs | 20 +- frame/uniques/src/benchmarking.rs | 54 +- frame/uniques/src/functions.rs | 18 +- frame/uniques/src/impl_nonfungibles.rs | 2 +- frame/uniques/src/lib.rs | 46 +- frame/uniques/src/tests.rs | 16 +- frame/utility/src/benchmarking.rs | 6 +- frame/utility/src/lib.rs | 24 +- frame/utility/src/tests.rs | 20 +- frame/vesting/src/lib.rs | 8 +- frame/whitelist/src/lib.rs | 10 +- test-utils/runtime/src/lib.rs | 4 +- 140 files changed, 1333 insertions(+), 1333 deletions(-) diff --git a/bin/node-template/pallets/template/src/lib.rs b/bin/node-template/pallets/template/src/lib.rs index c9874eb9d55d9..c5ebca2349478 100644 --- a/bin/node-template/pallets/template/src/lib.rs +++ b/bin/node-template/pallets/template/src/lib.rs @@ -27,7 +27,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } // The pallet's runtime storage items. @@ -42,7 +42,7 @@ pub mod pallet { // https://docs.substrate.io/main-docs/build/events-errors/ #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Event documentation should end with an array that provides descriptive names for event /// parameters. [something, who] SomethingStored(u32, T::AccountId), @@ -75,7 +75,7 @@ pub mod pallet { >::put(something); // Emit an event. - Self::deposit_event(Event::SomethingStored(something, who)); + Self::deposit_event(PalletEvent::SomethingStored(something, who)); // Return a successful DispatchResultWithPostInfo Ok(()) } diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index f504a99eb3ad1..aff6d7fffe63d 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -378,7 +378,7 @@ fn full_native_block_import_works() { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: timestamp_weight, class: DispatchClass::Mandatory, @@ -389,7 +389,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Withdraw { who: alice().into(), amount: fees, }), @@ -397,7 +397,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: alice().into(), to: bob().into(), amount: 69 * DOLLARS, @@ -406,7 +406,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -414,7 +414,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { + event: RuntimeEvent::Treasury(pallet_treasury::PalletEvent::Deposit { value: fees * 8 / 10, }), topics: vec![], @@ -422,7 +422,7 @@ fn full_native_block_import_works() { EventRecord { phase: Phase::ApplyExtrinsic(1), event: RuntimeEvent::TransactionPayment( - pallet_transaction_payment::Event::TransactionFeePaid { + pallet_transaction_payment::PalletEvent::TransactionFeePaid { who: alice().into(), actual_fee: fees, tip: 0, @@ -432,7 +432,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], @@ -462,7 +462,7 @@ fn full_native_block_import_works() { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: timestamp_weight, class: DispatchClass::Mandatory, @@ -473,7 +473,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Withdraw { who: bob().into(), amount: fees, }), @@ -481,7 +481,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: bob().into(), to: alice().into(), amount: 5 * DOLLARS, @@ -490,7 +490,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -498,7 +498,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { + event: RuntimeEvent::Treasury(pallet_treasury::PalletEvent::Deposit { value: fees * 8 / 10, }), topics: vec![], @@ -506,7 +506,7 @@ fn full_native_block_import_works() { EventRecord { phase: Phase::ApplyExtrinsic(1), event: RuntimeEvent::TransactionPayment( - pallet_transaction_payment::Event::TransactionFeePaid { + pallet_transaction_payment::PalletEvent::TransactionFeePaid { who: bob().into(), actual_fee: fees, tip: 0, @@ -516,14 +516,14 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Withdraw { who: alice().into(), amount: fees, }), @@ -531,7 +531,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: alice().into(), to: bob().into(), amount: 15 * DOLLARS, @@ -540,7 +540,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -548,7 +548,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { + event: RuntimeEvent::Treasury(pallet_treasury::PalletEvent::Deposit { value: fees * 8 / 10, }), topics: vec![], @@ -556,7 +556,7 @@ fn full_native_block_import_works() { EventRecord { phase: Phase::ApplyExtrinsic(2), event: RuntimeEvent::TransactionPayment( - pallet_transaction_payment::Event::TransactionFeePaid { + pallet_transaction_payment::PalletEvent::TransactionFeePaid { who: alice().into(), actual_fee: fees, tip: 0, @@ -566,7 +566,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index f0a291abcde28..71bbb8364a8e5 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -583,7 +583,7 @@ benchmarks_instance_pallet! { founders.sort(); fellows.sort(); allies.sort(); - assert_last_event::(Event::MembersInitialized { + assert_last_event::(PalletEvent::MembersInitialized { founders: founders.clone(), fellows: fellows.clone(), allies: allies.clone(), @@ -603,7 +603,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert_eq!(Alliance::::rule(), Some(rule.clone())); - assert_last_event::(Event::NewRuleSet { rule }.into()); + assert_last_event::(PalletEvent::NewRuleSet { rule }.into()); } announce { @@ -616,7 +616,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert!(Alliance::::announcements().contains(&announcement)); - assert_last_event::(Event::Announced { announcement }.into()); + assert_last_event::(PalletEvent::Announced { announcement }.into()); } remove_announcement { @@ -631,7 +631,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert!(Alliance::::announcements().is_empty()); - assert_last_event::(Event::AnnouncementRemoved { announcement }.into()); + assert_last_event::(PalletEvent::AnnouncementRemoved { announcement }.into()); } join_alliance { @@ -645,7 +645,7 @@ benchmarks_instance_pallet! { assert!(Alliance::::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally assert_eq!(DepositOf::::get(&outsider), Some(T::AllyDeposit::get())); // with a deposit assert!(!Alliance::::has_voting_rights(&outsider)); // allies don't have voting rights - assert_last_event::(Event::NewAllyJoined { + assert_last_event::(PalletEvent::NewAllyJoined { ally: outsider, nominator: None, reserved: Some(T::AllyDeposit::get()) @@ -668,7 +668,7 @@ benchmarks_instance_pallet! { assert!(Alliance::::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally assert_eq!(DepositOf::::get(&outsider), None); // without a deposit assert!(!Alliance::::has_voting_rights(&outsider)); // allies don't have voting rights - assert_last_event::(Event::NewAllyJoined { + assert_last_event::(PalletEvent::NewAllyJoined { ally: outsider, nominator: Some(founder1), reserved: None @@ -688,7 +688,7 @@ benchmarks_instance_pallet! { verify { assert!(!Alliance::::is_ally(&ally1)); assert!(Alliance::::is_fellow(&ally1)); - assert_last_event::(Event::AllyElevated { ally: ally1 }.into()); + assert_last_event::(PalletEvent::AllyElevated { ally: ally1 }.into()); } retire { @@ -703,7 +703,7 @@ benchmarks_instance_pallet! { verify { assert!(!Alliance::::is_member(&fellow2)); assert_eq!(DepositOf::::get(&fellow2), None); - assert_last_event::(Event::MemberRetired { + assert_last_event::(PalletEvent::MemberRetired { member: fellow2, unreserved: Some(T::AllyDeposit::get()) }.into()); @@ -727,7 +727,7 @@ benchmarks_instance_pallet! { verify { assert!(!Alliance::::is_member(&fellow2)); assert_eq!(DepositOf::::get(&fellow2), None); - assert_last_event::(Event::MemberKicked { + assert_last_event::(PalletEvent::MemberKicked { member: fellow2, slashed: Some(T::AllyDeposit::get()) }.into()); @@ -754,7 +754,7 @@ benchmarks_instance_pallet! { let origin = T::AnnouncementOrigin::successful_origin(); }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(Event::UnscrupulousItemAdded { items: unscrupulous_list }.into()); + assert_last_event::(PalletEvent::UnscrupulousItemAdded { items: unscrupulous_list }.into()); } remove_unscrupulous_items { @@ -784,7 +784,7 @@ benchmarks_instance_pallet! { let origin = T::AnnouncementOrigin::successful_origin(); }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(Event::UnscrupulousItemRemoved { items: unscrupulous_list }.into()); + assert_last_event::(PalletEvent::UnscrupulousItemRemoved { items: unscrupulous_list }.into()); } impl_benchmark_test_suite!(Alliance, crate::mock::new_bench_ext(), crate::mock::Test); diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 03190c5fccc69..4d17987a0f694 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -221,7 +221,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The outer call dispatch type. @@ -360,7 +360,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// A new rule has been set. NewRuleSet { rule: Cid }, /// A new announcement has been proposed. @@ -656,7 +656,7 @@ pub mod pallet { founders, fellows, allies ); - Self::deposit_event(Event::MembersInitialized { + Self::deposit_event(PalletEvent::MembersInitialized { founders: founders.into(), fellows: fellows.into(), allies: allies.into(), @@ -671,7 +671,7 @@ pub mod pallet { Rule::::put(&rule); - Self::deposit_event(Event::NewRuleSet { rule }); + Self::deposit_event(PalletEvent::NewRuleSet { rule }); Ok(()) } @@ -686,7 +686,7 @@ pub mod pallet { .map_err(|_| Error::::TooManyAnnouncements)?; >::put(announcements); - Self::deposit_event(Event::Announced { announcement }); + Self::deposit_event(PalletEvent::Announced { announcement }); Ok(()) } @@ -703,7 +703,7 @@ pub mod pallet { announcements.remove(pos); >::put(announcements); - Self::deposit_event(Event::AnnouncementRemoved { announcement }); + Self::deposit_event(PalletEvent::AnnouncementRemoved { announcement }); Ok(()) } @@ -734,7 +734,7 @@ pub mod pallet { Self::add_member(&who, MemberRole::Ally)?; - Self::deposit_event(Event::NewAllyJoined { + Self::deposit_event(PalletEvent::NewAllyJoined { ally: who, nominator: None, reserved: Some(deposit), @@ -762,7 +762,7 @@ pub mod pallet { Self::add_member(&who, MemberRole::Ally)?; - Self::deposit_event(Event::NewAllyJoined { + Self::deposit_event(PalletEvent::NewAllyJoined { ally: who, nominator: Some(nominator), reserved: None, @@ -784,7 +784,7 @@ pub mod pallet { Self::remove_member(&ally, MemberRole::Ally)?; Self::add_member(&ally, MemberRole::Fellow)?; - Self::deposit_event(Event::AllyElevated { ally }); + Self::deposit_event(PalletEvent::AllyElevated { ally }); Ok(()) } @@ -802,7 +802,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&who, deposit); debug_assert!(err_amount.is_zero()); } - Self::deposit_event(Event::MemberRetired { member: who, unreserved: deposit }); + Self::deposit_event(PalletEvent::MemberRetired { member: who, unreserved: deposit }); Ok(()) } @@ -824,7 +824,7 @@ pub mod pallet { >::remove(&member); - Self::deposit_event(Event::MemberKicked { member, slashed: deposit }); + Self::deposit_event(PalletEvent::MemberKicked { member, slashed: deposit }); Ok(()) } @@ -853,7 +853,7 @@ pub mod pallet { } Self::do_add_unscrupulous_items(&mut accounts, &mut webs)?; - Self::deposit_event(Event::UnscrupulousItemAdded { items }); + Self::deposit_event(PalletEvent::UnscrupulousItemAdded { items }); Ok(()) } @@ -876,7 +876,7 @@ pub mod pallet { } } Self::do_remove_unscrupulous_items(&mut accounts, &mut webs)?; - Self::deposit_event(Event::UnscrupulousItemRemoved { items }); + Self::deposit_event(PalletEvent::UnscrupulousItemRemoved { items }); Ok(()) } } diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index f97ee950e54f5..29816a71cd27b 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -25,7 +25,7 @@ use frame_system::{EventRecord, Phase}; use super::*; use crate::mock::*; -type AllianceMotionEvent = pallet_collective::Event; +type AllianceMotionEvent = pallet_collective::PalletEvent; #[test] fn propose_works() { @@ -239,7 +239,7 @@ fn set_rule_works() { assert_ok!(Alliance::set_rule(Origin::signed(1), cid.clone())); assert_eq!(Alliance::rule(), Some(cid.clone())); - System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::NewRuleSet { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::PalletEvent::NewRuleSet { rule: cid, })); }); @@ -252,7 +252,7 @@ fn announce_works() { assert_ok!(Alliance::announce(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![cid.clone()]); - System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::PalletEvent::Announced { announcement: cid, })); }); @@ -264,7 +264,7 @@ fn remove_announcement_works() { let cid = test_cid(); assert_ok!(Alliance::announce(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![cid.clone()]); - System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::PalletEvent::Announced { announcement: cid.clone(), })); @@ -273,7 +273,7 @@ fn remove_announcement_works() { assert_ok!(Alliance::remove_announcement(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![]); System::assert_last_event(mock::RuntimeEvent::Alliance( - crate::Event::AnnouncementRemoved { announcement: cid }, + crate::PalletEvent::AnnouncementRemoved { announcement: cid }, )); }); } diff --git a/frame/assets/README.md b/frame/assets/README.md index aae5244953e50..d7d6a715908df 100644 --- a/frame/assets/README.md +++ b/frame/assets/README.md @@ -102,7 +102,7 @@ pub mod pallet { >::insert((asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); >::insert(asset_id, TOKENS_FIXED_SUPPLY); - Self::deposit_event(Event::Issued(asset_id, sender, TOKENS_FIXED_SUPPLY)); + Self::deposit_event(PalletEvent::Issued(asset_id, sender, TOKENS_FIXED_SUPPLY)); Ok(()) } } diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index df5ad858f6e78..ca3c461e242de 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -155,7 +155,7 @@ benchmarks_instance_pallet! { T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup, 1u32.into()) verify { - assert_last_event::(Event::Created { asset_id: Default::default(), creator: caller.clone(), owner: caller }.into()); + assert_last_event::(PalletEvent::Created { asset_id: Default::default(), creator: caller.clone(), owner: caller }.into()); } force_create { @@ -163,7 +163,7 @@ benchmarks_instance_pallet! { let caller_lookup = T::Lookup::unlookup(caller.clone()); }: _(SystemOrigin::Root, Default::default(), caller_lookup, true, 1u32.into()) verify { - assert_last_event::(Event::ForceCreated { asset_id: Default::default(), owner: caller }.into()); + assert_last_event::(PalletEvent::ForceCreated { asset_id: Default::default(), owner: caller }.into()); } destroy { @@ -177,7 +177,7 @@ benchmarks_instance_pallet! { let witness = Asset::::get(T::AssetId::default()).unwrap().destroy_witness(); }: _(SystemOrigin::Signed(caller), Default::default(), witness) verify { - assert_last_event::(Event::Destroyed { asset_id: Default::default() }.into()); + assert_last_event::(PalletEvent::Destroyed { asset_id: Default::default() }.into()); } mint { @@ -185,7 +185,7 @@ benchmarks_instance_pallet! { let amount = T::Balance::from(100u32); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup, amount) verify { - assert_last_event::(Event::Issued { asset_id: Default::default(), owner: caller, total_supply: amount }.into()); + assert_last_event::(PalletEvent::Issued { asset_id: Default::default(), owner: caller, total_supply: amount }.into()); } burn { @@ -193,7 +193,7 @@ benchmarks_instance_pallet! { let (caller, caller_lookup) = create_default_minted_asset::(true, amount); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup, amount) verify { - assert_last_event::(Event::Burned { asset_id: Default::default(), owner: caller, balance: amount }.into()); + assert_last_event::(PalletEvent::Burned { asset_id: Default::default(), owner: caller, balance: amount }.into()); } transfer { @@ -203,7 +203,7 @@ benchmarks_instance_pallet! { let target_lookup = T::Lookup::unlookup(target.clone()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), target_lookup, amount) verify { - assert_last_event::(Event::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into()); + assert_last_event::(PalletEvent::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into()); } transfer_keep_alive { @@ -215,7 +215,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller.clone()), Default::default(), target_lookup, amount) verify { assert!(frame_system::Pallet::::account_exists(&caller)); - assert_last_event::(Event::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into()); + assert_last_event::(PalletEvent::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into()); } force_transfer { @@ -226,7 +226,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup, target_lookup, amount) verify { assert_last_event::( - Event::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into() + PalletEvent::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into() ); } @@ -234,7 +234,7 @@ benchmarks_instance_pallet! { let (caller, caller_lookup) = create_default_minted_asset::(true, 100u32.into()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup) verify { - assert_last_event::(Event::Frozen { asset_id: Default::default(), who: caller }.into()); + assert_last_event::(PalletEvent::Frozen { asset_id: Default::default(), who: caller }.into()); } thaw { @@ -246,14 +246,14 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup) verify { - assert_last_event::(Event::Thawed { asset_id: Default::default(), who: caller }.into()); + assert_last_event::(PalletEvent::Thawed { asset_id: Default::default(), who: caller }.into()); } freeze_asset { let (caller, caller_lookup) = create_default_minted_asset::(true, 100u32.into()); }: _(SystemOrigin::Signed(caller.clone()), Default::default()) verify { - assert_last_event::(Event::AssetFrozen { asset_id: Default::default() }.into()); + assert_last_event::(PalletEvent::AssetFrozen { asset_id: Default::default() }.into()); } thaw_asset { @@ -264,7 +264,7 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), Default::default()) verify { - assert_last_event::(Event::AssetThawed { asset_id: Default::default() }.into()); + assert_last_event::(PalletEvent::AssetThawed { asset_id: Default::default() }.into()); } transfer_ownership { @@ -273,7 +273,7 @@ benchmarks_instance_pallet! { let target_lookup = T::Lookup::unlookup(target.clone()); }: _(SystemOrigin::Signed(caller), Default::default(), target_lookup) verify { - assert_last_event::(Event::OwnerChanged { asset_id: Default::default(), owner: target }.into()); + assert_last_event::(PalletEvent::OwnerChanged { asset_id: Default::default(), owner: target }.into()); } set_team { @@ -283,7 +283,7 @@ benchmarks_instance_pallet! { let target2 = T::Lookup::unlookup(account("target", 2, SEED)); }: _(SystemOrigin::Signed(caller), Default::default(), target0, target1, target2) verify { - assert_last_event::(Event::TeamChanged { + assert_last_event::(PalletEvent::TeamChanged { asset_id: Default::default(), issuer: account("target", 0, SEED), admin: account("target", 1, SEED), @@ -304,7 +304,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller), Default::default(), name.clone(), symbol.clone(), decimals) verify { let id = Default::default(); - assert_last_event::(Event::MetadataSet { asset_id: id, name, symbol, decimals, is_frozen: false }.into()); + assert_last_event::(PalletEvent::MetadataSet { asset_id: id, name, symbol, decimals, is_frozen: false }.into()); } clear_metadata { @@ -315,7 +315,7 @@ benchmarks_instance_pallet! { Assets::::set_metadata(origin, Default::default(), dummy.clone(), dummy, 12)?; }: _(SystemOrigin::Signed(caller), Default::default()) verify { - assert_last_event::(Event::MetadataCleared { asset_id: Default::default() }.into()); + assert_last_event::(PalletEvent::MetadataCleared { asset_id: Default::default() }.into()); } force_set_metadata { @@ -339,7 +339,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { let id = Default::default(); - assert_last_event::(Event::MetadataSet { asset_id: id, name, symbol, decimals, is_frozen: false }.into()); + assert_last_event::(PalletEvent::MetadataSet { asset_id: id, name, symbol, decimals, is_frozen: false }.into()); } force_clear_metadata { @@ -353,7 +353,7 @@ benchmarks_instance_pallet! { let call = Call::::force_clear_metadata { id: Default::default() }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(Event::MetadataCleared { asset_id: Default::default() }.into()); + assert_last_event::(PalletEvent::MetadataCleared { asset_id: Default::default() }.into()); } force_asset_status { @@ -372,7 +372,7 @@ benchmarks_instance_pallet! { }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(Event::AssetStatusChanged { asset_id: Default::default() }.into()); + assert_last_event::(PalletEvent::AssetStatusChanged { asset_id: Default::default() }.into()); } approve_transfer { @@ -385,7 +385,7 @@ benchmarks_instance_pallet! { let amount = 100u32.into(); }: _(SystemOrigin::Signed(caller.clone()), id, delegate_lookup, amount) verify { - assert_last_event::(Event::ApprovedTransfer { asset_id: id, source: caller, delegate, amount }.into()); + assert_last_event::(PalletEvent::ApprovedTransfer { asset_id: id, source: caller, delegate, amount }.into()); } transfer_approved { @@ -405,7 +405,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(delegate.clone()), id, owner_lookup, dest_lookup, amount) verify { assert!(T::Currency::reserved_balance(&owner).is_zero()); - assert_event::(Event::Transferred { asset_id: id, from: owner, to: dest, amount }.into()); + assert_event::(PalletEvent::Transferred { asset_id: id, from: owner, to: dest, amount }.into()); } cancel_approval { @@ -420,7 +420,7 @@ benchmarks_instance_pallet! { Assets::::approve_transfer(origin, id, delegate_lookup.clone(), amount)?; }: _(SystemOrigin::Signed(caller.clone()), id, delegate_lookup) verify { - assert_last_event::(Event::ApprovalCancelled { asset_id: id, owner: caller, delegate }.into()); + assert_last_event::(PalletEvent::ApprovalCancelled { asset_id: id, owner: caller, delegate }.into()); } force_cancel_approval { @@ -435,7 +435,7 @@ benchmarks_instance_pallet! { Assets::::approve_transfer(origin, id, delegate_lookup.clone(), amount)?; }: _(SystemOrigin::Signed(caller.clone()), id, caller_lookup, delegate_lookup) verify { - assert_last_event::(Event::ApprovalCancelled { asset_id: id, owner: caller, delegate }.into()); + assert_last_event::(PalletEvent::ApprovalCancelled { asset_id: id, owner: caller, delegate }.into()); } impl_benchmark_test_suite!(Assets, crate::mock::new_test_ext(), crate::mock::Test) diff --git a/frame/assets/src/functions.rs b/frame/assets/src/functions.rs index 0f8e7096e80c1..f247b3cc2fd59 100644 --- a/frame/assets/src/functions.rs +++ b/frame/assets/src/functions.rs @@ -361,7 +361,7 @@ impl, I: 'static> Pallet { details.supply = details.supply.saturating_add(amount); Ok(()) })?; - Self::deposit_event(Event::Issued { + Self::deposit_event(PalletEvent::Issued { asset_id: id, owner: beneficiary.clone(), total_supply: amount, @@ -441,7 +441,7 @@ impl, I: 'static> Pallet { Ok(()) })?; - Self::deposit_event(Event::Burned { asset_id: id, owner: target.clone(), balance: actual }); + Self::deposit_event(PalletEvent::Burned { asset_id: id, owner: target.clone(), balance: actual }); Ok(actual) } @@ -611,7 +611,7 @@ impl, I: 'static> Pallet { Ok(()) })?; - Self::deposit_event(Event::Transferred { + Self::deposit_event(PalletEvent::Transferred { asset_id: id, from: source.clone(), to: dest.clone(), @@ -654,7 +654,7 @@ impl, I: 'static> Pallet { is_frozen: false, }, ); - Self::deposit_event(Event::ForceCreated { asset_id: id, owner }); + Self::deposit_event(PalletEvent::ForceCreated { asset_id: id, owner }); Ok(()) } @@ -702,7 +702,7 @@ impl, I: 'static> Pallet { for ((owner, _), approval) in Approvals::::drain_prefix((&id,)) { T::Currency::unreserve(&owner, approval.deposit); } - Self::deposit_event(Event::Destroyed { asset_id: id }); + Self::deposit_event(PalletEvent::Destroyed { asset_id: id }); Ok(DestroyWitness { accounts: details.accounts, @@ -754,7 +754,7 @@ impl, I: 'static> Pallet { }, )?; Asset::::insert(id, d); - Self::deposit_event(Event::ApprovedTransfer { + Self::deposit_event(PalletEvent::ApprovedTransfer { asset_id: id, source: owner.clone(), delegate: delegate.clone(), @@ -850,7 +850,7 @@ impl, I: 'static> Pallet { is_frozen: false, }); - Self::deposit_event(Event::MetadataSet { + Self::deposit_event(PalletEvent::MetadataSet { asset_id: id, name, symbol, diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 239628e68d5c9..97c5c92e9ae42 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -178,7 +178,7 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The units in which we record balances. @@ -374,7 +374,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// Some asset class was created. Created { asset_id: T::AssetId, creator: T::AccountId, owner: T::AccountId }, /// Some assets were issued. @@ -531,7 +531,7 @@ pub mod pallet { is_frozen: false, }, ); - Self::deposit_event(Event::Created { asset_id: id, creator: owner, owner: admin }); + Self::deposit_event(PalletEvent::Created { asset_id: id, creator: owner, owner: admin }); Ok(()) } @@ -789,7 +789,7 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(Event::::Frozen { asset_id: id, who }); + Self::deposit_event(PalletEvent::::Frozen { asset_id: id, who }); Ok(()) } @@ -820,7 +820,7 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(Event::::Thawed { asset_id: id, who }); + Self::deposit_event(PalletEvent::::Thawed { asset_id: id, who }); Ok(()) } @@ -846,7 +846,7 @@ pub mod pallet { d.is_frozen = true; - Self::deposit_event(Event::::AssetFrozen { asset_id: id }); + Self::deposit_event(PalletEvent::::AssetFrozen { asset_id: id }); Ok(()) }) } @@ -873,7 +873,7 @@ pub mod pallet { d.is_frozen = false; - Self::deposit_event(Event::::AssetThawed { asset_id: id }); + Self::deposit_event(PalletEvent::::AssetThawed { asset_id: id }); Ok(()) }) } @@ -912,7 +912,7 @@ pub mod pallet { details.owner = owner.clone(); - Self::deposit_event(Event::OwnerChanged { asset_id: id, owner }); + Self::deposit_event(PalletEvent::OwnerChanged { asset_id: id, owner }); Ok(()) }) } @@ -950,7 +950,7 @@ pub mod pallet { details.admin = admin.clone(); details.freezer = freezer.clone(); - Self::deposit_event(Event::TeamChanged { asset_id: id, issuer, admin, freezer }); + Self::deposit_event(PalletEvent::TeamChanged { asset_id: id, issuer, admin, freezer }); Ok(()) }) } @@ -1007,7 +1007,7 @@ pub mod pallet { Metadata::::try_mutate_exists(id, |metadata| { let deposit = metadata.take().ok_or(Error::::Unknown)?.deposit; T::Currency::unreserve(&d.owner, deposit); - Self::deposit_event(Event::MetadataCleared { asset_id: id }); + Self::deposit_event(PalletEvent::MetadataCleared { asset_id: id }); Ok(()) }) } @@ -1054,7 +1054,7 @@ pub mod pallet { is_frozen, }); - Self::deposit_event(Event::MetadataSet { + Self::deposit_event(PalletEvent::MetadataSet { asset_id: id, name, symbol, @@ -1087,7 +1087,7 @@ pub mod pallet { Metadata::::try_mutate_exists(id, |metadata| { let deposit = metadata.take().ok_or(Error::::Unknown)?.deposit; T::Currency::unreserve(&d.owner, deposit); - Self::deposit_event(Event::MetadataCleared { asset_id: id }); + Self::deposit_event(PalletEvent::MetadataCleared { asset_id: id }); Ok(()) }) } @@ -1139,7 +1139,7 @@ pub mod pallet { asset.is_frozen = is_frozen; *maybe_asset = Some(asset); - Self::deposit_event(Event::AssetStatusChanged { asset_id: id }); + Self::deposit_event(PalletEvent::AssetStatusChanged { asset_id: id }); Ok(()) }) } @@ -1205,7 +1205,7 @@ pub mod pallet { d.approvals.saturating_dec(); Asset::::insert(id, d); - Self::deposit_event(Event::ApprovalCancelled { asset_id: id, owner, delegate }); + Self::deposit_event(PalletEvent::ApprovalCancelled { asset_id: id, owner, delegate }); Ok(()) } @@ -1247,7 +1247,7 @@ pub mod pallet { d.approvals.saturating_dec(); Asset::::insert(id, d); - Self::deposit_event(Event::ApprovalCancelled { asset_id: id, owner, delegate }); + Self::deposit_event(PalletEvent::ApprovalCancelled { asset_id: id, owner, delegate }); Ok(()) } diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 52720e310a774..3a66836dc5adb 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -166,7 +166,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Swap action. type SwapAction: SwapAction + Parameter + MaxEncodedLen; /// Limit of proof size. @@ -220,7 +220,7 @@ pub mod pallet { /// Event of atomic swap pallet. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Swap created. NewSwap { account: T::AccountId, proof: HashedProof, swap: PendingSwap }, /// Swap claimed. The last parameter indicates whether the execution succeeds. @@ -266,7 +266,7 @@ pub mod pallet { }; PendingSwaps::::insert(target.clone(), hashed_proof, swap.clone()); - Self::deposit_event(Event::NewSwap { account: target, proof: hashed_proof, swap }); + Self::deposit_event(PalletEvent::NewSwap { account: target, proof: hashed_proof, swap }); Ok(()) } @@ -302,7 +302,7 @@ pub mod pallet { PendingSwaps::::remove(target.clone(), hashed_proof); - Self::deposit_event(Event::SwapClaimed { + Self::deposit_event(PalletEvent::SwapClaimed { account: target, proof: hashed_proof, success: succeeded, @@ -335,7 +335,7 @@ pub mod pallet { swap.action.cancel(&swap.source); PendingSwaps::::remove(&target, hashed_proof.clone()); - Self::deposit_event(Event::SwapCancelled { account: target, proof: hashed_proof }); + Self::deposit_event(PalletEvent::SwapCancelled { account: target, proof: hashed_proof }); Ok(()) } diff --git a/frame/bags-list/src/lib.rs b/frame/bags-list/src/lib.rs index 51ceae51da368..faeea7a848840 100644 --- a/frame/bags-list/src/lib.rs +++ b/frame/bags-list/src/lib.rs @@ -103,7 +103,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. @@ -190,7 +190,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// Moved an account from one bag to another. Rebagged { who: T::AccountId, from: T::Score, to: T::Score }, /// Updated the score of some account to the given amount. @@ -272,9 +272,9 @@ impl, I: 'static> Pallet { let node = list::Node::::get(&account).ok_or(ListError::NodeNotFound)?; let maybe_movement = List::update_position_for(node, new_score); if let Some((from, to)) = maybe_movement { - Self::deposit_event(Event::::Rebagged { who: account.clone(), from, to }); + Self::deposit_event(PalletEvent::::Rebagged { who: account.clone(), from, to }); }; - Self::deposit_event(Event::::ScoreUpdated { who: account.clone(), new_score }); + Self::deposit_event(PalletEvent::::ScoreUpdated { who: account.clone(), new_score }); Ok(maybe_movement) } diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 8640b44cdc06c..09542164fe0ce 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -216,7 +216,7 @@ pub mod pallet { type DustRemoval: OnUnbalanced>; /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The minimum amount required to keep an account open. @@ -341,7 +341,7 @@ pub mod pallet { mem::drop(NegativeImbalance::::new(old_reserved - new_reserved)); } - Self::deposit_event(Event::BalanceSet { who, free: new_free, reserved: new_reserved }); + Self::deposit_event(PalletEvent::BalanceSet { who, free: new_free, reserved: new_reserved }); Ok(().into()) } @@ -438,7 +438,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// An account was created with some free balance. Endowed { account: T::AccountId, free_balance: T::Balance }, /// An account was removed whose balance was non-zero but below ExistentialDeposit, @@ -737,7 +737,7 @@ pub struct DustCleaner, I: 'static = ()>( impl, I: 'static> Drop for DustCleaner { fn drop(&mut self) { if let Some((who, dust)) = self.0.take() { - Pallet::::deposit_event(Event::DustLost { account: who, amount: dust.peek() }); + Pallet::::deposit_event(PalletEvent::DustLost { account: who, amount: dust.peek() }); T::DustRemoval::on_unbalanced(dust); } } @@ -935,7 +935,7 @@ impl, I: 'static> Pallet { }); result.map(|(maybe_endowed, maybe_dust, result)| { if let Some(endowed) = maybe_endowed { - Self::deposit_event(Event::Endowed { account: who.clone(), free_balance: endowed }); + Self::deposit_event(PalletEvent::Endowed { account: who.clone(), free_balance: endowed }); } let dust_cleaner = DustCleaner(maybe_dust.map(|dust| (who.clone(), dust))); (result, dust_cleaner) @@ -1045,7 +1045,7 @@ impl, I: 'static> Pallet { }, )?; - Self::deposit_event(Event::ReserveRepatriated { + Self::deposit_event(PalletEvent::ReserveRepatriated { from: slashed.clone(), to: beneficiary.clone(), amount: actual, @@ -1103,7 +1103,7 @@ impl, I: 'static> fungible::Mutate for Pallet { Ok(()) })?; TotalIssuance::::mutate(|t| *t += amount); - Self::deposit_event(Event::Deposit { who: who.clone(), amount }); + Self::deposit_event(PalletEvent::Deposit { who: who.clone(), amount }); Ok(()) } @@ -1124,7 +1124,7 @@ impl, I: 'static> fungible::Mutate for Pallet { }, )?; TotalIssuance::::mutate(|t| *t -= actual); - Self::deposit_event(Event::Withdraw { who: who.clone(), amount }); + Self::deposit_event(PalletEvent::Withdraw { who: who.clone(), amount }); Ok(actual) } } @@ -1145,7 +1145,7 @@ impl, I: 'static> fungible::Unbalanced for Pallet DispatchResult { Self::mutate_account(who, |account| { account.free = amount; - Self::deposit_event(Event::BalanceSet { + Self::deposit_event(PalletEvent::BalanceSet { who: who.clone(), free: account.free, reserved: account.reserved, @@ -1529,7 +1529,7 @@ where )?; // Emit transfer event. - Self::deposit_event(Event::Transfer { + Self::deposit_event(PalletEvent::Transfer { from: transactor.clone(), to: dest.clone(), amount: value, @@ -1597,7 +1597,7 @@ where }, ) { Ok((imbalance, not_slashed)) => { - Self::deposit_event(Event::Slashed { + Self::deposit_event(PalletEvent::Slashed { who: who.clone(), amount: value.saturating_sub(not_slashed), }); @@ -1627,7 +1627,7 @@ where |account, is_new| -> Result { ensure!(!is_new, Error::::DeadAccount); account.free = account.free.checked_add(&value).ok_or(ArithmeticError::Overflow)?; - Self::deposit_event(Event::Deposit { who: who.clone(), amount: value }); + Self::deposit_event(PalletEvent::Deposit { who: who.clone(), amount: value }); Ok(PositiveImbalance::new(value)) }, ) @@ -1660,7 +1660,7 @@ where None => return Ok(Self::PositiveImbalance::zero()), }; - Self::deposit_event(Event::Deposit { who: who.clone(), amount: value }); + Self::deposit_event(PalletEvent::Deposit { who: who.clone(), amount: value }); Ok(PositiveImbalance::new(value)) }, ) @@ -1696,7 +1696,7 @@ where account.free = new_free_account; - Self::deposit_event(Event::Withdraw { who: who.clone(), amount: value }); + Self::deposit_event(PalletEvent::Withdraw { who: who.clone(), amount: value }); Ok(NegativeImbalance::new(value)) }, ) @@ -1729,7 +1729,7 @@ where SignedImbalance::Negative(NegativeImbalance::new(account.free - value)) }; account.free = value; - Self::deposit_event(Event::BalanceSet { + Self::deposit_event(PalletEvent::BalanceSet { who: who.clone(), free: account.free, reserved: account.reserved, @@ -1777,7 +1777,7 @@ where Self::ensure_can_withdraw(&who, value, WithdrawReasons::RESERVE, account.free) })?; - Self::deposit_event(Event::Reserved { who: who.clone(), amount: value }); + Self::deposit_event(PalletEvent::Reserved { who: who.clone(), amount: value }); Ok(()) } @@ -1809,7 +1809,7 @@ where }, }; - Self::deposit_event(Event::Unreserved { who: who.clone(), amount: actual }); + Self::deposit_event(PalletEvent::Unreserved { who: who.clone(), amount: actual }); value - actual } @@ -1850,7 +1850,7 @@ where (NegativeImbalance::new(actual), value - actual) }) { Ok((imbalance, not_slashed)) => { - Self::deposit_event(Event::Slashed { + Self::deposit_event(PalletEvent::Slashed { who: who.clone(), amount: value.saturating_sub(not_slashed), }); @@ -1996,7 +1996,7 @@ where // `actual <= to_change` and `to_change <= amount`; qed; reserves[index].amount -= actual; - Self::deposit_event(Event::Slashed { who: who.clone(), amount: actual }); + Self::deposit_event(PalletEvent::Slashed { who: who.clone(), amount: actual }); (imb, value - actual) }, Err(_) => (NegativeImbalance::zero(), value), diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 0c59bc6d9d499..0b8497fd21ac4 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -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(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 10 })); + System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::Deposit { who: 1, amount: 10 })); assert_eq!(Balances::total_balance(&1), 20); assert_eq!(>::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(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 42 })); + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::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(RuntimeEvent::Balances(crate::Event::Withdraw { who: 2, amount: 11 })); + System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::Withdraw { who: 2, amount: 11 })); assert_eq!(Balances::free_balance(2), 100); assert_eq!(>::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( - RuntimeEvent::Balances(crate::Event::ReserveRepatriated { from: 1, to: 2, amount: 41, destination_status: Status::Free }) + RuntimeEvent::Balances(crate::PalletEvent::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); @@ -724,18 +724,18 @@ macro_rules! decl_tests { System::set_block_number(2); assert_ok!(Balances::reserve(&1, 10)); - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Reserved { who: 1, amount: 10 })); + System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::Reserved { who: 1, amount: 10 })); System::set_block_number(3); assert!(Balances::unreserve(&1, 5).is_zero()); - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Unreserved { who: 1, amount: 5 })); + System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::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(RuntimeEvent::Balances(crate::Event::Unreserved { who: 1, amount: 5 })); + System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::Unreserved { who: 1, amount: 5 })); }); } @@ -750,9 +750,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - 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 }), + RuntimeEvent::System(system::PalletEvent::NewAccount { account: 1 }), + RuntimeEvent::Balances(crate::PalletEvent::Endowed { account: 1, free_balance: 100 }), + RuntimeEvent::Balances(crate::PalletEvent::BalanceSet { who: 1, free: 100, reserved: 0 }), ] ); @@ -762,9 +762,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - 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 }), + RuntimeEvent::System(system::PalletEvent::KilledAccount { account: 1 }), + RuntimeEvent::Balances(crate::PalletEvent::DustLost { account: 1, amount: 99 }), + RuntimeEvent::Balances(crate::PalletEvent::Slashed { who: 1, amount: 1 }), ] ); }); @@ -781,9 +781,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - 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 }), + RuntimeEvent::System(system::PalletEvent::NewAccount { account: 1 }), + RuntimeEvent::Balances(crate::PalletEvent::Endowed { account: 1, free_balance: 100 }), + RuntimeEvent::Balances(crate::PalletEvent::BalanceSet { who: 1, free: 100, reserved: 0 }), ] ); @@ -793,8 +793,8 @@ macro_rules! decl_tests { assert_eq!( events(), [ - RuntimeEvent::System(system::Event::KilledAccount { account: 1 }), - RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 100 }), + RuntimeEvent::System(system::PalletEvent::KilledAccount { account: 1 }), + RuntimeEvent::Balances(crate::PalletEvent::Slashed { who: 1, amount: 100 }), ] ); }); @@ -814,7 +814,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(RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 900 })); + System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::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)); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index bdfc1fb2a0aeb..63044adfa5e2a 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -158,9 +158,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { assert_eq!( events(), [ - 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 }), + RuntimeEvent::System(system::PalletEvent::NewAccount { account: 1 }), + RuntimeEvent::Balances(crate::PalletEvent::Endowed { account: 1, free_balance: 100 }), + RuntimeEvent::Balances(crate::PalletEvent::BalanceSet { who: 1, free: 100, reserved: 0 }), ] ); @@ -170,7 +170,7 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { // no events assert_eq!( events(), - [RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 98 })] + [RuntimeEvent::Balances(crate::PalletEvent::Slashed { who: 1, amount: 98 })] ); let res = Balances::slash(&1, 1); @@ -179,9 +179,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { assert_eq!( events(), [ - 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 }) + RuntimeEvent::System(system::PalletEvent::KilledAccount { account: 1 }), + RuntimeEvent::Balances(crate::PalletEvent::DustLost { account: 1, amount: 1 }), + RuntimeEvent::Balances(crate::PalletEvent::Slashed { who: 1, amount: 1 }) ] ); }); diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index cef058f7efb4e..d8e7cadc5255d 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -157,16 +157,16 @@ fn transfer_dust_removal_tst1_should_work() { // Verify the events assert_eq!(System::events().len(), 12); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::Transfer { from: 2, to: 3, amount: 450, })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::DustLost { account: 2, amount: 50, })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::Deposit { who: 1, amount: 50, })); @@ -195,16 +195,16 @@ fn transfer_dust_removal_tst2_should_work() { // Verify the events assert_eq!(System::events().len(), 10); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::Transfer { from: 2, to: 1, amount: 450, })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::DustLost { account: 2, amount: 50, })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::Deposit { who: 1, amount: 50, })); @@ -242,19 +242,19 @@ fn repatriating_reserved_balance_dust_removal_should_work() { // Verify the events assert_eq!(System::events().len(), 11); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::ReserveRepatriated { + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::ReserveRepatriated { from: 2, to: 1, amount: 450, destination_status: Status::Free, })); - System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { + System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::DustLost { account: 2, amount: 50, })); - System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit { + System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::Deposit { who: 1, amount: 50, })); diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 9b0e1d01abdf9..15e33ac60025a 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -55,7 +55,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, Mmr: pallet_mmr::{Pallet, Storage}, Beefy: pallet_beefy::{Pallet, Config, Storage}, BeefyMmr: pallet_beefy_mmr::{Pallet, Storage}, diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index 8b9967fbee3cd..6e68e9576eb61 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -178,7 +178,7 @@ benchmarks_instance_pallet! { let bounty_id = BountyCount::::get() - 1; }: close_bounty(RawOrigin::Root, bounty_id) verify { - assert_last_event::(Event::BountyCanceled { index: bounty_id }.into()) + assert_last_event::(PalletEvent::BountyCanceled { index: bounty_id }.into()) } extend_bounty_expiry { @@ -190,7 +190,7 @@ benchmarks_instance_pallet! { let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; }: _(RawOrigin::Signed(curator), bounty_id, Vec::new()) verify { - assert_last_event::(Event::BountyExtended { index: bounty_id }.into()) + assert_last_event::(PalletEvent::BountyExtended { index: bounty_id }.into()) } spend_funds { @@ -213,7 +213,7 @@ benchmarks_instance_pallet! { verify { ensure!(budget_remaining < BalanceOf::::max_value(), "Budget not used"); ensure!(missed_any == false, "Missed some"); - assert_last_event::(Event::BountyBecameActive { index: b - 1 }.into()) + assert_last_event::(PalletEvent::BountyBecameActive { index: b - 1 }.into()) } impl_benchmark_test_suite!(Bounties, crate::tests::new_test_ext(), crate::tests::Test) diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index f4c1a3c949bac..649ef7c6c8dea 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -228,7 +228,7 @@ pub mod pallet { type DataDepositPerByte: Get>; /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Maximum acceptable reason length. @@ -273,7 +273,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// New bounty proposal. BountyProposed { index: BountyIndex }, /// A bounty proposal was rejected; funds were slashed. @@ -584,7 +584,7 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(Event::::BountyAwarded { index: bounty_id, beneficiary }); + Self::deposit_event(PalletEvent::::BountyAwarded { index: bounty_id, beneficiary }); Ok(()) } @@ -637,7 +637,7 @@ pub mod pallet { BountyDescriptions::::remove(bounty_id); - Self::deposit_event(Event::::BountyClaimed { + Self::deposit_event(PalletEvent::::BountyClaimed { index: bounty_id, payout, beneficiary, @@ -688,7 +688,7 @@ pub mod pallet { T::OnSlash::on_unbalanced(imbalance); *maybe_bounty = None; - Self::deposit_event(Event::::BountyRejected { + Self::deposit_event(PalletEvent::::BountyRejected { index: bounty_id, bond: value, }); @@ -735,7 +735,7 @@ pub mod pallet { debug_assert!(res.is_ok()); *maybe_bounty = None; - Self::deposit_event(Event::::BountyCanceled { index: bounty_id }); + Self::deposit_event(PalletEvent::::BountyCanceled { index: bounty_id }); Ok(Some(>::WeightInfo::close_bounty_active()).into()) }, ) @@ -775,7 +775,7 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(Event::::BountyExtended { index: bounty_id }); + Self::deposit_event(PalletEvent::::BountyExtended { index: bounty_id }); Ok(()) } } @@ -842,7 +842,7 @@ impl, I: 'static> Pallet { Bounties::::insert(index, &bounty); BountyDescriptions::::insert(index, bounded_description); - Self::deposit_event(Event::::BountyProposed { index }); + Self::deposit_event(PalletEvent::::BountyProposed { index }); Ok(()) } @@ -876,7 +876,7 @@ impl, I: 'static> pallet_treasury::SpendFunds for Pallet::BountyBecameActive { index }); + Self::deposit_event(PalletEvent::::BountyBecameActive { index }); false } else { *missed_any = true; diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index 697ed40e0071f..cf6c7e9e66596 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -172,7 +172,7 @@ benchmarks! { }: _(RawOrigin::Signed(bounty_setup.curator), bounty_setup.bounty_id, bounty_setup.child_bounty_value, bounty_setup.reason.clone()) verify { - assert_last_event::(Event::Added { + assert_last_event::(PalletEvent::Added { index: bounty_setup.bounty_id, child_index: bounty_setup.child_bounty_id, }.into()) @@ -235,7 +235,7 @@ benchmarks! { }: _(RawOrigin::Signed(bounty_setup.child_curator), bounty_setup.bounty_id, bounty_setup.child_bounty_id, beneficiary) verify { - assert_last_event::(Event::Awarded { + assert_last_event::(PalletEvent::Awarded { index: bounty_setup.bounty_id, child_index: bounty_setup.child_bounty_id, beneficiary: beneficiary_account @@ -285,7 +285,7 @@ benchmarks! { }: close_child_bounty(RawOrigin::Root, bounty_setup.bounty_id, bounty_setup.child_bounty_id) verify { - assert_last_event::(Event::Canceled { + assert_last_event::(PalletEvent::Canceled { index: bounty_setup.bounty_id, child_index: bounty_setup.child_bounty_id }.into()) @@ -298,7 +298,7 @@ benchmarks! { Treasury::::on_initialize(T::BlockNumber::zero()); }: close_child_bounty(RawOrigin::Root, bounty_setup.bounty_id, bounty_setup.child_bounty_id) verify { - assert_last_event::(Event::Canceled { + assert_last_event::(PalletEvent::Canceled { index: bounty_setup.bounty_id, child_index: bounty_setup.child_bounty_id, }.into()) diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index 1d9f13ec4f358..026ecf57e56e6 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -145,7 +145,7 @@ pub mod pallet { type ChildBountyValueMinimum: Get>; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -163,7 +163,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A child-bounty is added. Added { index: BountyIndex, child_index: BountyIndex }, /// A child-bounty is awarded to a beneficiary. @@ -610,7 +610,7 @@ pub mod pallet { )?; // Trigger the event Awarded. - Self::deposit_event(Event::::Awarded { + Self::deposit_event(PalletEvent::::Awarded { index: parent_bounty_id, child_index: child_bounty_id, beneficiary, @@ -696,7 +696,7 @@ pub mod pallet { debug_assert!(payout_transfer_result.is_ok()); // Trigger the Claimed event. - Self::deposit_event(Event::::Claimed { + Self::deposit_event(PalletEvent::::Claimed { index: parent_bounty_id, child_index: child_bounty_id, payout, @@ -804,7 +804,7 @@ impl Pallet { }; ChildBounties::::insert(parent_bounty_id, child_bounty_id, &child_bounty); ChildBountyDescriptions::::insert(child_bounty_id, description); - Self::deposit_event(Event::Added { index: parent_bounty_id, child_index: child_bounty_id }); + Self::deposit_event(PalletEvent::Added { index: parent_bounty_id, child_index: child_bounty_id }); } fn ensure_bounty_active( @@ -877,7 +877,7 @@ impl Pallet { *maybe_child_bounty = None; - Self::deposit_event(Event::::Canceled { + Self::deposit_event(PalletEvent::::Canceled { index: parent_bounty_id, child_index: child_bounty_id, }); diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index dea68e1088ce0..26adb0697d106 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -128,7 +128,7 @@ benchmarks_instance_pallet! { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin assert_last_event::( - Event::MemberExecuted { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() + PalletEvent::MemberExecuted { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() ); } @@ -159,7 +159,7 @@ benchmarks_instance_pallet! { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin assert_last_event::( - Event::Executed { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() + PalletEvent::Executed { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() ); } @@ -203,7 +203,7 @@ benchmarks_instance_pallet! { // New proposal is recorded assert_eq!(Collective::::proposals().len(), p as usize); let proposal_hash = T::Hashing::hash_of(&proposal); - assert_last_event::(Event::Proposed { account: caller, proposal_index: p - 1, proposal_hash, threshold }.into()); + assert_last_event::(PalletEvent::Proposed { account: caller, proposal_index: p - 1, proposal_hash, threshold }.into()); } vote { @@ -359,7 +359,7 @@ benchmarks_instance_pallet! { verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + assert_last_event::(PalletEvent::Disapproved { proposal_hash: last_hash }.into()); } close_early_approved { @@ -440,7 +440,7 @@ benchmarks_instance_pallet! { verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); + assert_last_event::(PalletEvent::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); } close_disapproved { @@ -514,7 +514,7 @@ benchmarks_instance_pallet! { }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::max_value(), bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + assert_last_event::(PalletEvent::Disapproved { proposal_hash: last_hash }.into()); } close_approved { @@ -586,7 +586,7 @@ benchmarks_instance_pallet! { }: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::max_value(), bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); + assert_last_event::(PalletEvent::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); } disapprove_proposal { @@ -634,7 +634,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Root, last_hash) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); + assert_last_event::(PalletEvent::Disapproved { proposal_hash: last_hash }.into()); } impl_benchmark_test_suite!(Collective, crate::tests::new_test_ext(), crate::tests::Test); diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index bc3976a249b53..435e85ccb5931 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -187,7 +187,7 @@ pub mod pallet { + GetDispatchInfo; /// The outer event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The time-out for council motions. @@ -278,7 +278,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// A motion (given hash) has been proposed (by given account) with a threshold (given /// `MemberCount`). Proposed { @@ -444,7 +444,7 @@ pub mod pallet { let proposal_hash = T::Hashing::hash_of(&proposal); let result = proposal.dispatch(RawOrigin::Member(who).into()); - Self::deposit_event(Event::MemberExecuted { + Self::deposit_event(PalletEvent::MemberExecuted { proposal_hash, result: result.map(|_| ()).map_err(|e| e.error), }); @@ -688,7 +688,7 @@ impl, I: 'static> Pallet { let seats = Self::members().len() as MemberCount; let result = proposal.dispatch(RawOrigin::Members(1, seats).into()); - Self::deposit_event(Event::Executed { + Self::deposit_event(PalletEvent::Executed { proposal_hash, result: result.map(|_| ()).map_err(|e| e.error), }); @@ -723,7 +723,7 @@ impl, I: 'static> Pallet { }; >::insert(proposal_hash, votes); - Self::deposit_event(Event::Proposed { + Self::deposit_event(PalletEvent::Proposed { account: who, proposal_index: index, proposal_hash, @@ -771,7 +771,7 @@ impl, I: 'static> Pallet { let yes_votes = voting.ayes.len() as MemberCount; let no_votes = voting.nays.len() as MemberCount; - Self::deposit_event(Event::Voted { + Self::deposit_event(PalletEvent::Voted { account: who, proposal_hash: proposal, voted: approve, @@ -806,7 +806,7 @@ impl, I: 'static> Pallet { length_bound, proposal_weight_bound, )?; - Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(PalletEvent::Closed { proposal_hash, yes: yes_votes, no: no_votes }); let (proposal_weight, proposal_count) = Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal); return Ok(( @@ -818,7 +818,7 @@ impl, I: 'static> Pallet { ) .into()) } else if disapproved { - Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(PalletEvent::Closed { proposal_hash, yes: yes_votes, no: no_votes }); let proposal_count = Self::do_disapprove_proposal(proposal_hash); return Ok(( Some(T::WeightInfo::close_early_disapproved(seats, proposal_count)), @@ -848,7 +848,7 @@ impl, I: 'static> Pallet { length_bound, proposal_weight_bound, )?; - Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(PalletEvent::Closed { proposal_hash, yes: yes_votes, no: no_votes }); let (proposal_weight, proposal_count) = Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal); Ok(( @@ -860,7 +860,7 @@ impl, I: 'static> Pallet { ) .into()) } else { - Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(PalletEvent::Closed { proposal_hash, yes: yes_votes, no: no_votes }); let proposal_count = Self::do_disapprove_proposal(proposal_hash); Ok((Some(T::WeightInfo::close_disapproved(seats, proposal_count)), Pays::No).into()) } @@ -906,12 +906,12 @@ impl, I: 'static> Pallet { proposal_hash: T::Hash, proposal: >::Proposal, ) -> (Weight, u32) { - Self::deposit_event(Event::Approved { proposal_hash }); + Self::deposit_event(PalletEvent::Approved { proposal_hash }); let dispatch_weight = proposal.get_dispatch_info().weight; let origin = RawOrigin::Members(yes_votes, seats).into(); let result = proposal.dispatch(origin); - Self::deposit_event(Event::Executed { + Self::deposit_event(PalletEvent::Executed { proposal_hash, result: result.map(|_| ()).map_err(|e| e.error), }); @@ -925,7 +925,7 @@ impl, I: 'static> Pallet { /// Removes a proposal from the pallet, and deposit the `Disapproved` event. pub fn do_disapprove_proposal(proposal_hash: T::Hash) -> u32 { // disapproved - Self::deposit_event(Event::Disapproved { proposal_hash }); + Self::deposit_event(PalletEvent::Disapproved { proposal_hash }); Self::remove_proposal(proposal_hash) } diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 7d7c3eee1e522..d60b71927c7a3 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -61,7 +61,7 @@ mod mock_democracy { #[pallet::config] pub trait Config: frame_system::Config + Sized { - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type ExternalMajorityOrigin: EnsureOrigin; } @@ -71,14 +71,14 @@ mod mock_democracy { #[pallet::weight(0)] pub fn external_propose_majority(origin: OriginFor) -> DispatchResult { T::ExternalMajorityOrigin::ensure_origin(origin)?; - Self::deposit_event(Event::::ExternalProposed); + Self::deposit_event(PalletEvent::::ExternalProposed); Ok(()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { ExternalProposed, } } @@ -1014,7 +1014,7 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { })), record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), record(RuntimeEvent::Democracy( - mock_democracy::pallet::Event::::ExternalProposed + mock_democracy::pallet::PalletEvent::::ExternalProposed )), record(RuntimeEvent::Collective(CollectiveEvent::Executed { proposal_hash: hash, diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 297dd8b8d221e..562d27211d4c7 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -18,7 +18,7 @@ use crate::{ gas::GasMeter, storage::{self, Storage, WriteOutcome}, - BalanceOf, CodeHash, Config, ContractInfo, ContractInfoOf, Error, Event, Nonce, + BalanceOf, CodeHash, Config, ContractInfo, ContractInfoOf, Error, PalletEvent, Nonce, Pallet as Contracts, Schedule, }; use frame_support::{ @@ -817,7 +817,7 @@ where // Deposit an instantiation event. deposit_event::( vec![], - Event::Instantiated { + PalletEvent::Instantiated { deployer: self.caller().clone(), contract: frame.account_id.clone(), }, @@ -1134,7 +1134,7 @@ where )?; ContractInfoOf::::remove(&frame.account_id); E::remove_user(info.code_hash); - Contracts::::deposit_event(Event::Terminated { + Contracts::::deposit_event(PalletEvent::Terminated { contract: frame.account_id.clone(), beneficiary: beneficiary.clone(), }); @@ -1244,7 +1244,7 @@ where fn deposit_event(&mut self, topics: Vec, data: Vec) { deposit_event::( topics, - Event::ContractEmitted { contract: self.top_frame().account_id.clone(), data }, + PalletEvent::ContractEmitted { contract: self.top_frame().account_id.clone(), data }, ); } @@ -1304,7 +1304,7 @@ where let prev_hash = top_frame.contract_info().code_hash; E::remove_user(prev_hash); top_frame.contract_info().code_hash = hash; - Contracts::::deposit_event(Event::ContractCodeUpdated { + Contracts::::deposit_event(PalletEvent::ContractCodeUpdated { contract: top_frame.account_id.clone(), new_code_hash: hash, old_code_hash: prev_hash, @@ -1313,7 +1313,7 @@ where } } -fn deposit_event(topics: Vec, event: Event) { +fn deposit_event(topics: Vec, event: PalletEvent) { >::deposit_event_indexed( &topics, ::RuntimeEvent::from(event).into(), @@ -2143,7 +2143,7 @@ mod tests { ); assert_eq!( &events(), - &[Event::Instantiated { deployer: ALICE, contract: instantiated_contract_address }] + &[PalletEvent::Instantiated { deployer: ALICE, contract: instantiated_contract_address }] ); }); } @@ -2244,7 +2244,7 @@ mod tests { ); assert_eq!( &events(), - &[Event::Instantiated { deployer: BOB, contract: instantiated_contract_address }] + &[PalletEvent::Instantiated { deployer: BOB, contract: instantiated_contract_address }] ); }); } @@ -2601,7 +2601,7 @@ mod tests { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: MetaEvent::System(frame_system::Event::Remarked { + event: MetaEvent::System(frame_system::PalletEvent::Remarked { sender: BOB, hash: remark_hash }), @@ -2673,7 +2673,7 @@ mod tests { vec![ EventRecord { phase: Phase::Initialization, - event: MetaEvent::System(frame_system::Event::Remarked { + event: MetaEvent::System(frame_system::PalletEvent::Remarked { sender: BOB, hash: remark_hash }), @@ -2681,12 +2681,12 @@ mod tests { }, EventRecord { phase: Phase::Initialization, - event: MetaEvent::Utility(pallet_utility::Event::ItemCompleted), + event: MetaEvent::Utility(pallet_utility::PalletEvent::ItemCompleted), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted { + event: MetaEvent::Utility(pallet_utility::PalletEvent::BatchInterrupted { index: 1, error: frame_system::Error::::CallFiltered.into() },), diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index f9c488727331b..630e1c13773c3 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -242,7 +242,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Dispatchable @@ -630,7 +630,7 @@ pub mod pallet { }; >::add_user(code_hash)?; >::remove_user(contract.code_hash); - Self::deposit_event(Event::ContractCodeUpdated { + Self::deposit_event(PalletEvent::ContractCodeUpdated { contract: dest.clone(), new_code_hash: code_hash, old_code_hash: contract.code_hash, @@ -643,7 +643,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Contract deployed by address at the specified address. Instantiated { deployer: T::AccountId, contract: T::AccountId }, diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 3450774af60b1..a5cc66d40e8ac 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -67,7 +67,7 @@ frame_support::construct_runtime!( Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Randomness: pallet_randomness_collective_flip::{Pallet, Storage}, - Utility: pallet_utility::{Pallet, Call, Storage, Event}, + Utility: pallet_utility::{Pallet, Call, Storage, PalletEvent}, Contracts: pallet_contracts::{Pallet, Call, Storage, Event}, } ); @@ -516,14 +516,14 @@ fn instantiate_and_call_and_deposit_event() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { + event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -531,7 +531,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -540,7 +540,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: addr.clone(), amount: min_balance, }), @@ -548,7 +548,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: value, @@ -557,7 +557,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { + event: RuntimeEvent::Contracts(crate::PalletEvent::ContractEmitted { contract: addr.clone(), data: vec![1, 2, 3, 4] }), @@ -565,7 +565,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::Instantiated { + event: RuntimeEvent::Contracts(crate::PalletEvent::Instantiated { deployer: ALICE, contract: addr.clone() }), @@ -810,14 +810,14 @@ fn deploy_and_call_other_contract() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { + event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { account: callee_addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { account: callee_addr.clone(), free_balance: min_balance, }), @@ -825,7 +825,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: callee_addr.clone(), amount: min_balance, @@ -834,7 +834,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: callee_addr.clone(), amount: min_balance, }), @@ -842,7 +842,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: caller_addr.clone(), to: callee_addr.clone(), amount: 32768, // hard coded in wasm @@ -851,7 +851,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::Instantiated { + event: RuntimeEvent::Contracts(crate::PalletEvent::Instantiated { deployer: caller_addr.clone(), contract: callee_addr.clone(), }), @@ -859,7 +859,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: caller_addr.clone(), to: callee_addr.clone(), amount: 32768, @@ -1059,7 +1059,7 @@ fn cannot_self_destruct_by_refund_after_slash() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Slashed { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Slashed { who: addr.clone(), amount: 90, }), @@ -1067,7 +1067,7 @@ fn cannot_self_destruct_by_refund_after_slash() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::ReserveRepatriated { from: addr.clone(), to: ALICE, amount: 10, @@ -1159,7 +1159,7 @@ fn self_destruct_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: addr.clone(), to: DJANGO, amount: 100_000, @@ -1168,7 +1168,7 @@ fn self_destruct_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::Terminated { + event: RuntimeEvent::Contracts(crate::PalletEvent::Terminated { contract: addr.clone(), beneficiary: DJANGO }), @@ -1176,14 +1176,14 @@ fn self_destruct_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::KilledAccount { + event: RuntimeEvent::System(frame_system::PalletEvent::KilledAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::ReserveRepatriated { from: addr.clone(), to: ALICE, amount: 1_000, @@ -2609,7 +2609,7 @@ fn upload_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: ALICE, amount: 240, }), @@ -2617,7 +2617,7 @@ fn upload_code_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), topics: vec![], }, ] @@ -2688,7 +2688,7 @@ fn remove_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: ALICE, amount: 240, }), @@ -2696,12 +2696,12 @@ fn remove_code_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Unreserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Unreserved { who: ALICE, amount: 240, }), @@ -2709,7 +2709,7 @@ fn remove_code_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeRemoved { code_hash }), + event: RuntimeEvent::Contracts(crate::PalletEvent::CodeRemoved { code_hash }), topics: vec![], }, ] @@ -2743,7 +2743,7 @@ fn remove_code_wrong_origin() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: ALICE, amount: 240, }), @@ -2751,7 +2751,7 @@ fn remove_code_wrong_origin() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), topics: vec![], }, ] @@ -2844,14 +2844,14 @@ fn instantiate_with_zero_balance_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { + event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -2859,7 +2859,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -2868,7 +2868,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: addr.clone(), amount: min_balance, }), @@ -2876,7 +2876,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: ALICE, amount: 240, }), @@ -2884,12 +2884,12 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::Instantiated { + event: RuntimeEvent::Contracts(crate::PalletEvent::Instantiated { deployer: ALICE, contract: addr.clone(), }), @@ -2937,14 +2937,14 @@ fn instantiate_with_below_existential_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { + event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -2952,7 +2952,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -2961,7 +2961,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: addr.clone(), amount: min_balance, }), @@ -2969,7 +2969,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: 50, @@ -2978,7 +2978,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: ALICE, amount: 240, }), @@ -2986,12 +2986,12 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::Instantiated { + event: RuntimeEvent::Contracts(crate::PalletEvent::Instantiated { deployer: ALICE, contract: addr.clone(), }), @@ -3068,7 +3068,7 @@ fn storage_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: 42, @@ -3077,7 +3077,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: charged0, @@ -3086,7 +3086,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: addr.clone(), amount: charged0, }), @@ -3094,7 +3094,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: charged1, @@ -3103,7 +3103,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { who: addr.clone(), amount: charged1, }), @@ -3111,7 +3111,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::ReserveRepatriated { from: addr.clone(), to: ALICE, amount: refunded0, @@ -3193,7 +3193,7 @@ fn set_code_extrinsic() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(pallet_contracts::Event::ContractCodeUpdated { + event: RuntimeEvent::Contracts(pallet_contracts::PalletEvent::ContractCodeUpdated { contract: addr, new_code_hash, old_code_hash: code_hash, @@ -3272,14 +3272,14 @@ fn call_after_killed_account_needs_funding() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::KilledAccount { + event: RuntimeEvent::System(frame_system::PalletEvent::KilledAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Slashed { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Slashed { who: addr.clone(), amount: min_balance + 700 }), @@ -3287,14 +3287,14 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { + event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { account: addr.clone(), free_balance: min_balance }), @@ -3302,7 +3302,7 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { + event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { from: ALICE, to: addr.clone(), amount: min_balance @@ -3483,7 +3483,7 @@ fn set_code_hash() { System::events().pop().unwrap(), EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::Event::ContractCodeUpdated { + event: RuntimeEvent::Contracts(crate::PalletEvent::ContractCodeUpdated { contract: contract_addr.clone(), new_code_hash: new_code_hash.clone(), old_code_hash: code_hash.clone(), diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 10de436bfb155..d9bc2e0bce287 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -32,7 +32,7 @@ use crate::{ gas::{GasMeter, Token}, wasm::{prepare, PrefabWasmModule}, weights::WeightInfo, - CodeHash, CodeStorage, Config, Error, Event, OwnerInfoOf, Pallet, PristineCode, Schedule, + CodeHash, CodeStorage, Config, Error, PalletEvent, OwnerInfoOf, Pallet, PristineCode, Schedule, Weight, }; use frame_support::{ @@ -96,7 +96,7 @@ where >::insert(&code_hash, orig_code); >::insert(&code_hash, owner_info); *existing = Some(module); - >::deposit_event(Event::CodeStored { code_hash }); + >::deposit_event(PalletEvent::CodeStored { code_hash }); Ok(()) }, }) @@ -142,7 +142,7 @@ pub fn try_remove(origin: &T::AccountId, code_hash: CodeHash) -> D *existing = None; >::remove(&code_hash); >::remove(&code_hash); - >::deposit_event(Event::CodeRemoved { code_hash }); + >::deposit_event(PalletEvent::CodeRemoved { code_hash }); Ok(()) } else { Err(>::CodeNotFound.into()) diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index e618d0dffc8c3..35fbad6dd381c 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -97,7 +97,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { // System level stuff. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -160,7 +160,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// An account has delegated their vote to another account. \[who, target\] Delegated(T::AccountId, T::AccountId), /// An \[account\] has cancelled a previous delegation operation. @@ -569,7 +569,7 @@ impl, I: 'static> Pallet { Self::extend_lock(&who, &class, balance); Ok(votes) })?; - Self::deposit_event(Event::::Delegated(who, target)); + Self::deposit_event(PalletEvent::::Delegated(who, target)); Ok(votes) } @@ -608,7 +608,7 @@ impl, I: 'static> Pallet { Voting::Casting(_) => Err(Error::::NotDelegating.into()), } })?; - Self::deposit_event(Event::::Undelegated(who)); + Self::deposit_event(PalletEvent::::Undelegated(who)); Ok(votes) } diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 9b52379286a01..db473de60ebdb 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -779,7 +779,7 @@ benchmarks! { }: enact_proposal(RawOrigin::Root, proposal_hash, 0) verify { // Fails due to mismatched origin - assert_last_event::(Event::::Executed { ref_index: 0, result: Err(BadOrigin.into()) }.into()); + assert_last_event::(PalletEvent::::Executed { ref_index: 0, result: Err(BadOrigin.into()) }.into()); } #[extra] diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index ef4295486fcb6..c3afd4c8c925d 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -253,7 +253,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { type Proposal: Parameter + Dispatchable + From>; - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Currency type for this pallet. type Currency: ReservableCurrency @@ -493,7 +493,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A motion has been proposed by a public account. Proposed { proposal_index: PropIndex, deposit: BalanceOf }, /// A public proposal has been tabled for referendum vote. @@ -652,7 +652,7 @@ pub mod pallet { >::append((index, proposal_hash, who)); - Self::deposit_event(Event::::Proposed { proposal_index: index, deposit: value }); + Self::deposit_event(PalletEvent::::Proposed { proposal_index: index, deposit: value }); Ok(()) } @@ -680,7 +680,7 @@ pub mod pallet { T::Currency::reserve(&who, deposit.1)?; deposit.0.push(who.clone()); >::insert(proposal, deposit); - Self::deposit_event(Event::::Seconded { seconder: who, prop_index: proposal }); + Self::deposit_event(PalletEvent::::Seconded { seconder: who, prop_index: proposal }); Ok(()) } @@ -882,7 +882,7 @@ pub mod pallet { >::block_number().saturating_add(T::CooloffPeriod::get()); >::insert(&proposal_hash, (until, existing_vetoers)); - Self::deposit_event(Event::::Vetoed { who, proposal_hash, until }); + Self::deposit_event(PalletEvent::::Vetoed { who, proposal_hash, until }); >::kill(); Ok(()) } @@ -1107,7 +1107,7 @@ pub mod pallet { T::Currency::repatriate_reserved(&provider, &who, deposit, BalanceStatus::Free); debug_assert!(res.is_ok()); >::remove(&proposal_hash); - Self::deposit_event(Event::::PreimageReaped { + Self::deposit_event(PalletEvent::::PreimageReaped { proposal_hash, provider, deposit, @@ -1257,7 +1257,7 @@ pub mod pallet { } } - Self::deposit_event(Event::::Blacklisted { proposal_hash }); + Self::deposit_event(PalletEvent::::Blacklisted { proposal_hash }); Ok(()) } @@ -1282,7 +1282,7 @@ pub mod pallet { } } - Self::deposit_event(Event::::ProposalCanceled { prop_index }); + Self::deposit_event(PalletEvent::::ProposalCanceled { prop_index }); Ok(()) } } @@ -1339,7 +1339,7 @@ impl Pallet { /// Remove a referendum. pub fn internal_cancel_referendum(ref_index: ReferendumIndex) { - Self::deposit_event(Event::::Cancelled { ref_index }); + Self::deposit_event(PalletEvent::::Cancelled { ref_index }); ReferendumInfoOf::::remove(ref_index); } @@ -1389,7 +1389,7 @@ impl Pallet { votes.insert(i, (ref_index, vote)); }, } - Self::deposit_event(Event::::Voted { voter: who.clone(), ref_index, vote }); + Self::deposit_event(PalletEvent::::Voted { voter: who.clone(), ref_index, vote }); // Shouldn't be possible to fail, but we handle it gracefully. status.tally.add(vote).ok_or(ArithmeticError::Overflow)?; if let Some(approve) = vote.as_standard() { @@ -1551,7 +1551,7 @@ impl Pallet { T::Currency::extend_lock(DEMOCRACY_ID, &who, balance, WithdrawReasons::TRANSFER); Ok(votes) })?; - Self::deposit_event(Event::::Delegated { who, target }); + Self::deposit_event(PalletEvent::::Delegated { who, target }); Ok(votes) } @@ -1579,7 +1579,7 @@ impl Pallet { Voting::Direct { .. } => Err(Error::::NotDelegating.into()), } })?; - Self::deposit_event(Event::::Undelegated { account: who }); + Self::deposit_event(PalletEvent::::Undelegated { account: who }); Ok(votes) } @@ -1610,7 +1610,7 @@ impl Pallet { ReferendumStatus { end, proposal_hash, threshold, delay, tally: Default::default() }; let item = ReferendumInfo::Ongoing(status); >::insert(ref_index, item); - Self::deposit_event(Event::::Started { ref_index, threshold }); + Self::deposit_event(PalletEvent::::Started { ref_index, threshold }); ref_index } @@ -1628,7 +1628,7 @@ impl Pallet { fn launch_external(now: T::BlockNumber) -> DispatchResult { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::::put(true); - Self::deposit_event(Event::::ExternalTabled); + Self::deposit_event(PalletEvent::::ExternalTabled); Self::inject_referendum( now.saturating_add(T::VotingPeriod::get()), proposal, @@ -1656,7 +1656,7 @@ impl Pallet { for d in &depositors { T::Currency::unreserve(d, deposit); } - Self::deposit_event(Event::::Tabled { + Self::deposit_event(PalletEvent::::Tabled { proposal_index: prop_index, deposit, depositors, @@ -1680,25 +1680,25 @@ impl Pallet { if let Ok(proposal) = T::Proposal::decode(&mut &data[..]) { let err_amount = T::Currency::unreserve(&provider, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(Event::::PreimageUsed { proposal_hash, provider, deposit }); + Self::deposit_event(PalletEvent::::PreimageUsed { proposal_hash, provider, deposit }); let res = proposal .dispatch(frame_system::RawOrigin::Root.into()) .map(|_| ()) .map_err(|e| e.error); - Self::deposit_event(Event::::Executed { ref_index: index, result: res }); + Self::deposit_event(PalletEvent::::Executed { ref_index: index, result: res }); Ok(()) } else { T::Slash::on_unbalanced(T::Currency::slash_reserved(&provider, deposit).0); - Self::deposit_event(Event::::PreimageInvalid { + Self::deposit_event(PalletEvent::::PreimageInvalid { proposal_hash, ref_index: index, }); Err(Error::::PreimageInvalid.into()) } } else { - Self::deposit_event(Event::::PreimageMissing { proposal_hash, ref_index: index }); + Self::deposit_event(PalletEvent::::PreimageMissing { proposal_hash, ref_index: index }); Err(Error::::PreimageMissing.into()) } } @@ -1712,7 +1712,7 @@ impl Pallet { let approved = status.threshold.approved(status.tally, total_issuance); if approved { - Self::deposit_event(Event::::Passed { ref_index: index }); + Self::deposit_event(PalletEvent::::Passed { ref_index: index }); if status.delay.is_zero() { let _ = Self::do_enact_proposal(status.proposal_hash, index); } else { @@ -1741,7 +1741,7 @@ impl Pallet { } } } else { - Self::deposit_event(Event::::NotPassed { ref_index: index }); + Self::deposit_event(PalletEvent::::NotPassed { ref_index: index }); } approved @@ -1896,7 +1896,7 @@ impl Pallet { }; >::insert(proposal_hash, a); - Self::deposit_event(Event::::PreimageNoted { proposal_hash, who, deposit }); + Self::deposit_event(PalletEvent::::PreimageNoted { proposal_hash, who, deposit }); Ok(()) } @@ -1922,7 +1922,7 @@ impl Pallet { }; >::insert(proposal_hash, a); - Self::deposit_event(Event::::PreimageNoted { proposal_hash, who, deposit: free }); + Self::deposit_event(PalletEvent::::PreimageNoted { proposal_hash, who, deposit: free }); Ok(()) } diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index db06696ca5c95..8d9029aa6a458 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -100,7 +100,7 @@ fn cancel_proposal_should_work() { assert_ok!(propose_set_balance_and_note(1, 4, 4)); assert_noop!(Democracy::cancel_proposal(Origin::signed(1), 0), BadOrigin); assert_ok!(Democracy::cancel_proposal(Origin::root(), 0)); - System::assert_last_event(crate::Event::ProposalCanceled { prop_index: 0 }.into()); + System::assert_last_event(crate::PalletEvent::ProposalCanceled { prop_index: 0 }.into()); assert_eq!(Democracy::backing_for(0), None); assert_eq!(Democracy::backing_for(1), Some(4)); }); diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 3cdc69d31e5e0..7594bda257778 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -569,9 +569,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + SendTransactionTypes> { - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent> - + TryInto>; + + TryInto>; /// Currency type. type Currency: ReservableCurrency + Currency; @@ -900,7 +900,7 @@ pub mod pallet { log!(info, "queued unsigned solution with score {:?}", ready.score); let ejected_a_solution = >::exists(); >::put(ready); - Self::deposit_event(Event::SolutionStored { + Self::deposit_event(PalletEvent::SolutionStored { election_compute: ElectionCompute::Unsigned, prev_ejected: ejected_a_solution, }); @@ -948,7 +948,7 @@ pub mod pallet { compute: ElectionCompute::Emergency, }; - Self::deposit_event(Event::SolutionStored { + Self::deposit_event(PalletEvent::SolutionStored { election_compute: ElectionCompute::Emergency, prev_ejected: QueuedSolution::::exists(), }); @@ -1024,7 +1024,7 @@ pub mod pallet { } signed_submissions.put(); - Self::deposit_event(Event::SolutionStored { + Self::deposit_event(PalletEvent::SolutionStored { election_compute: ElectionCompute::Signed, prev_ejected: ejected_a_solution, }); @@ -1062,7 +1062,7 @@ pub mod pallet { compute: ElectionCompute::Fallback, }; - Self::deposit_event(Event::SolutionStored { + Self::deposit_event(PalletEvent::SolutionStored { election_compute: ElectionCompute::Fallback, prev_ejected: QueuedSolution::::exists(), }); @@ -1074,7 +1074,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A solution was stored with the given compute. /// /// If the solution is signed, this means that it hasn't yet been processed. If the @@ -1303,7 +1303,7 @@ impl Pallet { pub fn on_initialize_open_signed() { log!(info, "Starting signed phase round {}.", Self::round()); >::put(Phase::Signed); - Self::deposit_event(Event::SignedPhaseStarted { round: Self::round() }); + Self::deposit_event(PalletEvent::SignedPhaseStarted { round: Self::round() }); } /// Logic for `>::on_initialize` when unsigned phase is being opened. @@ -1311,7 +1311,7 @@ impl Pallet { let round = Self::round(); log!(info, "Starting unsigned phase round {} enabled {}.", round, enabled); >::put(Phase::Unsigned((enabled, now))); - Self::deposit_event(Event::UnsignedPhaseStarted { round }); + Self::deposit_event(PalletEvent::UnsignedPhaseStarted { round }); } /// Parts of [`create_snapshot`] that happen inside of this pallet. @@ -1540,14 +1540,14 @@ impl Pallet { |ReadySolution { supports, compute, .. }| Ok((supports, compute)), ) .map(|(supports, compute)| { - Self::deposit_event(Event::ElectionFinalized { election_compute: Some(compute) }); + Self::deposit_event(PalletEvent::ElectionFinalized { election_compute: Some(compute) }); if Self::round() != 1 { log!(info, "Finalized election round with compute {:?}.", compute); } supports }) .map_err(|err| { - Self::deposit_event(Event::ElectionFinalized { election_compute: None }); + Self::deposit_event(PalletEvent::ElectionFinalized { election_compute: None }); if Self::round() != 1 { log!(warn, "Failed to finalize election round. reason {:?}", err); } @@ -1828,7 +1828,7 @@ mod tests { roll_to(15); assert_eq!(MultiPhase::current_phase(), Phase::Signed); - assert_eq!(multi_phase_events(), vec![Event::SignedPhaseStarted { round: 1 }]); + assert_eq!(multi_phase_events(), vec![PalletEvent::SignedPhaseStarted { round: 1 }]); assert!(MultiPhase::snapshot().is_some()); assert_eq!(MultiPhase::round(), 1); @@ -1842,8 +1842,8 @@ mod tests { assert_eq!( multi_phase_events(), vec![ - Event::SignedPhaseStarted { round: 1 }, - Event::UnsignedPhaseStarted { round: 1 } + PalletEvent::SignedPhaseStarted { round: 1 }, + PalletEvent::UnsignedPhaseStarted { round: 1 } ], ); assert!(MultiPhase::snapshot().is_some()); @@ -1955,7 +1955,7 @@ mod tests { assert_eq!(MultiPhase::current_phase(), Phase::Off); roll_to(15); - assert_eq!(multi_phase_events(), vec![Event::SignedPhaseStarted { round: 1 }]); + assert_eq!(multi_phase_events(), vec![PalletEvent::SignedPhaseStarted { round: 1 }]); assert_eq!(MultiPhase::current_phase(), Phase::Signed); assert_eq!(MultiPhase::round(), 1); @@ -1967,8 +1967,8 @@ mod tests { assert_eq!( multi_phase_events(), vec![ - Event::SignedPhaseStarted { round: 1 }, - Event::ElectionFinalized { election_compute: Some(ElectionCompute::Fallback) } + PalletEvent::SignedPhaseStarted { round: 1 }, + PalletEvent::ElectionFinalized { election_compute: Some(ElectionCompute::Fallback) } ], ); // All storage items must be cleared. @@ -1990,7 +1990,7 @@ mod tests { assert_eq!(MultiPhase::current_phase(), Phase::Off); roll_to(15); - assert_eq!(multi_phase_events(), vec![Event::SignedPhaseStarted { round: 1 }]); + assert_eq!(multi_phase_events(), vec![PalletEvent::SignedPhaseStarted { round: 1 }]); assert_eq!(MultiPhase::current_phase(), Phase::Signed); assert_eq!(MultiPhase::round(), 1); @@ -2079,14 +2079,14 @@ mod tests { assert_eq!( multi_phase_events(), vec![ - Event::SignedPhaseStarted { round: 1 }, - Event::UnsignedPhaseStarted { round: 1 }, - Event::ElectionFinalized { election_compute: None }, - Event::SolutionStored { + PalletEvent::SignedPhaseStarted { round: 1 }, + PalletEvent::UnsignedPhaseStarted { round: 1 }, + PalletEvent::ElectionFinalized { election_compute: None }, + PalletEvent::SolutionStored { election_compute: ElectionCompute::Fallback, prev_ejected: false }, - Event::ElectionFinalized { election_compute: Some(ElectionCompute::Fallback) } + PalletEvent::ElectionFinalized { election_compute: Some(ElectionCompute::Fallback) } ] ); }) diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index b1bced53cc756..7783005422345 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -81,7 +81,7 @@ frame_election_provider_support::generate_solution_type!( ); /// All events of this pallet. -pub(crate) fn multi_phase_events() -> Vec> { +pub(crate) fn multi_phase_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index eca75139f925a..b6d9abaaef5ac 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -461,7 +461,7 @@ impl Pallet { let reward = T::SignedRewardBase::get(); // emit reward event - Self::deposit_event(crate::Event::Rewarded { account: who.clone(), value: reward }); + Self::deposit_event(crate::PalletEvent::Rewarded { account: who.clone(), value: reward }); // Unreserve deposit. let _remaining = T::Currency::unreserve(who, deposit); @@ -479,7 +479,7 @@ impl Pallet { /// /// Infallible pub fn finalize_signed_phase_reject_solution(who: &T::AccountId, deposit: BalanceOf) { - Self::deposit_event(crate::Event::Slashed { account: who.clone(), value: deposit }); + Self::deposit_event(crate::PalletEvent::Slashed { account: who.clone(), value: deposit }); let (negative_imbalance, _remaining) = T::Currency::slash_reserved(who, deposit); debug_assert!(_remaining.is_zero()); T::SlashHandler::on_unbalanced(negative_imbalance); diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index fadc5134d924b..0dc00c9c17224 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -204,7 +204,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Identifier for the elections-phragmen pallet's lock #[pallet::constant] @@ -443,7 +443,7 @@ pub mod pallet { Renouncing::Member => { let _ = Self::remove_and_replace_member(&who, false) .map_err(|_| Error::::InvalidRenouncing)?; - Self::deposit_event(Event::Renounced { candidate: who }); + Self::deposit_event(PalletEvent::Renounced { candidate: who }); }, Renouncing::RunnerUp => { >::try_mutate::<_, Error, _>(|runners_up| { @@ -455,7 +455,7 @@ pub mod pallet { let SeatHolder { deposit, .. } = runners_up.remove(index); let _remainder = T::Currency::unreserve(&who, deposit); debug_assert!(_remainder.is_zero()); - Self::deposit_event(Event::Renounced { candidate: who }); + Self::deposit_event(PalletEvent::Renounced { candidate: who }); Ok(()) })?; }, @@ -468,7 +468,7 @@ pub mod pallet { let (_removed, deposit) = candidates.remove(index); let _remainder = T::Currency::unreserve(&who, deposit); debug_assert!(_remainder.is_zero()); - Self::deposit_event(Event::Renounced { candidate: who }); + Self::deposit_event(PalletEvent::Renounced { candidate: who }); Ok(()) })?; }, @@ -509,7 +509,7 @@ pub mod pallet { let who = T::Lookup::lookup(who)?; let _ = Self::remove_and_replace_member(&who, slash_bond)?; - Self::deposit_event(Event::MemberKicked { member: who }); + Self::deposit_event(PalletEvent::MemberKicked { member: who }); if rerun_election { Self::do_phragmen(); @@ -546,7 +546,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A new term with new_members. This indicates that enough candidates existed to run /// the election, not that enough have has been elected. The inner value must be examined /// for this purpose. A `NewTerm(\[\])` indicates that some candidates got their bond @@ -761,7 +761,7 @@ impl Pallet { let (imbalance, _remainder) = T::Currency::slash_reserved(who, removed.deposit); debug_assert!(_remainder.is_zero()); T::LoserCandidate::on_unbalanced(imbalance); - Self::deposit_event(Event::SeatHolderSlashed { + Self::deposit_event(PalletEvent::SeatHolderSlashed { seat_holder: who.clone(), amount: removed.deposit, }); @@ -898,7 +898,7 @@ impl Pallet { candidates_and_deposit.append(&mut Self::implicit_candidates_with_deposit()); if candidates_and_deposit.len().is_zero() { - Self::deposit_event(Event::EmptyTerm); + Self::deposit_event(PalletEvent::EmptyTerm); return T::DbWeight::get().reads(3) } @@ -929,7 +929,7 @@ impl Pallet { target: "runtime::elections-phragmen", "Failed to run election. Number of voters exceeded", ); - Self::deposit_event(Event::ElectionError); + Self::deposit_event(PalletEvent::ElectionError); return T::DbWeight::get().reads(3 + MAX_VOTERS as u64) }, } @@ -1042,7 +1042,7 @@ impl Pallet { { let (imbalance, _) = T::Currency::slash_reserved(c, *d); T::LoserCandidate::on_unbalanced(imbalance); - Self::deposit_event(Event::CandidateSlashed { + Self::deposit_event(PalletEvent::CandidateSlashed { candidate: c.clone(), amount: *d, }); @@ -1086,7 +1086,7 @@ impl Pallet { // clean candidates. >::kill(); - Self::deposit_event(Event::NewTerm { new_members: new_members_sorted_by_id }); + Self::deposit_event(PalletEvent::NewTerm { new_members: new_members_sorted_by_id }); >::mutate(|v| *v += 1); }) .map_err(|e| { @@ -1095,7 +1095,7 @@ impl Pallet { "Failed to run election [{:?}].", e, ); - Self::deposit_event(Event::ElectionError); + Self::deposit_event(PalletEvent::ElectionError); }); T::WeightInfo::election_phragmen(weight_candidates, weight_voters, weight_edges) @@ -2193,7 +2193,7 @@ mod tests { System::set_block_number(5); Elections::on_initialize(System::block_number()); - System::assert_last_event(RuntimeEvent::Elections(super::Event::EmptyTerm)); + System::assert_last_event(RuntimeEvent::Elections(super::PalletEvent::EmptyTerm)); }) } @@ -2209,7 +2209,7 @@ mod tests { System::set_block_number(5); Elections::on_initialize(System::block_number()); - System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::PalletEvent::NewTerm { new_members: vec![(4, 35), (5, 45)], })); @@ -2222,7 +2222,7 @@ mod tests { System::set_block_number(10); Elections::on_initialize(System::block_number()); - System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::PalletEvent::NewTerm { new_members: vec![], })); @@ -2294,7 +2294,7 @@ mod tests { assert_eq!(Elections::election_rounds(), 1); assert!(members_ids().is_empty()); - System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::PalletEvent::NewTerm { new_members: vec![], })); }); @@ -2602,7 +2602,7 @@ mod tests { // 5 is an outgoing loser. will also get slashed. assert_eq!(balances(&5), (45, 2)); - System::assert_has_event(RuntimeEvent::Elections(super::Event::NewTerm { + System::assert_has_event(RuntimeEvent::Elections(super::PalletEvent::NewTerm { new_members: vec![(4, 35), (5, 45)], })); }) diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index cdd0b1cea0cd0..75599a4c8d6cd 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -370,7 +370,7 @@ pub mod pallet { type MagicNumber: Get; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Type representing the weight of this pallet type WeightInfo: WeightInfo; @@ -525,7 +525,7 @@ pub mod pallet { }); // Let's deposit an event to let the outside world know this happened. - Self::deposit_event(Event::AccumulateDummy { balance: increase_by }); + Self::deposit_event(PalletEvent::AccumulateDummy { balance: increase_by }); // All good, no refund. Ok(()) @@ -557,7 +557,7 @@ pub mod pallet { // Put the new value into storage. >::put(new_value); - Self::deposit_event(Event::SetDummy { balance: new_value }); + Self::deposit_event(PalletEvent::SetDummy { balance: new_value }); // All good, no refund. Ok(()) @@ -571,7 +571,7 @@ pub mod pallet { /// This attribute generate the function `deposit_event` to deposit one of this pallet event, /// it is optional, it is also possible to provide a custom implementation. #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { // Just a normal `enum`, here's a dummy event to ensure it compiles. /// Dummy event, just here so there's a generic type that's used. AccumulateDummy { diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index e9e4d3c7ca50e..07b5edf8b76b3 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -126,7 +126,7 @@ pub mod pallet { type AuthorityId: AppCrypto; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching dispatch call type. type Call: From>; @@ -293,7 +293,7 @@ pub mod pallet { /// Events for the pallet. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Event generated when new price is accepted to contribute to the average. NewPrice { price: u32, maybe_who: Option }, } @@ -657,7 +657,7 @@ impl Pallet { .expect("The average is not empty, because it was just mutated; qed"); log::info!("Current average price is: {}", average); // here we are raising the NewPrice event - Self::deposit_event(Event::NewPrice { price, maybe_who }); + Self::deposit_event(PalletEvent::NewPrice { price, maybe_who }); } /// Calculate current average price. diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 98a9fc2724658..a6c5d395d0bc0 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -813,7 +813,7 @@ mod tests { fn on_runtime_upgrade() -> Weight { sp_io::storage::set(TEST_KEY, "custom_upgrade".as_bytes()); sp_io::storage::set(CUSTOM_ON_RUNTIME_KEY, &true.encode()); - System::deposit_event(frame_system::Event::CodeUpdated); + System::deposit_event(frame_system::PalletEvent::CodeUpdated); 100 } } @@ -1302,7 +1302,7 @@ mod tests { Digest::default(), )); - System::assert_last_event(frame_system::Event::::CodeUpdated.into()); + System::assert_last_event(frame_system::PalletEvent::::CodeUpdated.into()); }); } diff --git a/frame/gilt/src/lib.rs b/frame/gilt/src/lib.rs index bab25bf96e066..fa27105f420cc 100644 --- a/frame/gilt/src/lib.rs +++ b/frame/gilt/src/lib.rs @@ -98,7 +98,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Currency type that this works on. type Currency: ReservableCurrency; @@ -287,7 +287,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A bid was successfully placed. BidPlaced { who: T::AccountId, amount: BalanceOf, duration: u32 }, /// A bid was successfully removed (before being accepted as a gilt). @@ -399,7 +399,7 @@ pub mod pallet { qs[queue_index].0 += net.0; qs[queue_index].1 = qs[queue_index].1.saturating_add(net.1); }); - Self::deposit_event(Event::BidPlaced { who, amount, duration }); + Self::deposit_event(PalletEvent::BidPlaced { who, amount, duration }); Ok(().into()) } @@ -437,7 +437,7 @@ pub mod pallet { }); T::Currency::unreserve(&bid.who, bid.amount); - Self::deposit_event(Event::BidRetracted { who: bid.who, amount: bid.amount, duration }); + Self::deposit_event(PalletEvent::BidRetracted { who: bid.who, amount: bid.amount, duration }); Ok(().into()) } @@ -516,7 +516,7 @@ pub mod pallet { debug_assert!(err_amt.is_zero()); } - let e = Event::GiltThawed { + let e = PalletEvent::GiltThawed { index, who: gilt.who, original_amount: gilt.amount, @@ -636,7 +636,7 @@ pub mod pallet { totals.proportion.defensive_saturating_add(proportion); totals.index += 1; let e = - Event::GiltIssued { index, expiry, who: who.clone(), amount }; + PalletEvent::GiltIssued { index, expiry, who: who.clone(), amount }; Self::deposit_event(e); let gilt = ActiveGilt { amount, proportion, who, expiry }; Active::::insert(index, gilt); diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index f71fbaea0833c..aa82e58b42225 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -87,7 +87,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The event type of this module. - type RuntimeEvent: From + type RuntimeEvent: From + Into<::RuntimeEvent> + IsType<::RuntimeEvent>; @@ -152,7 +152,7 @@ pub mod pallet { // enact the change if we've reached the enacting block if block_number == pending_change.scheduled_at + pending_change.delay { Self::set_grandpa_authorities(&pending_change.next_authorities); - Self::deposit_event(Event::NewAuthorities { + Self::deposit_event(PalletEvent::NewAuthorities { authority_set: pending_change.next_authorities.to_vec(), }); >::kill(); @@ -170,7 +170,7 @@ pub mod pallet { // enact change to paused state if block_number == scheduled_at + delay { >::put(StoredState::Paused); - Self::deposit_event(Event::Paused); + Self::deposit_event(PalletEvent::Paused); } }, StoredState::PendingResume { scheduled_at, delay } => { @@ -182,7 +182,7 @@ pub mod pallet { // enact change to live state if block_number == scheduled_at + delay { >::put(StoredState::Live); - Self::deposit_event(Event::Resumed); + Self::deposit_event(PalletEvent::Resumed); } }, _ => {}, @@ -258,7 +258,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// New authority set has been applied. NewAuthorities { authority_set: AuthorityList }, /// Current authority set has been paused. diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 597b6ac145352..5fb7326fc2803 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -56,9 +56,9 @@ frame_support::construct_runtime!( Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned}, - Offences: pallet_offences::{Pallet, Storage, Event}, + Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, PalletEvent, ValidateUnsigned}, + Offences: pallet_offences::{Pallet, Storage, PalletEvent}, Historical: pallet_session_historical::{Pallet}, } ); diff --git a/frame/grandpa/src/tests.rs b/frame/grandpa/src/tests.rs index ab0a9c677b00e..de4d33e221b5e 100644 --- a/frame/grandpa/src/tests.rs +++ b/frame/grandpa/src/tests.rs @@ -19,7 +19,7 @@ #![cfg(test)] -use super::{Call, Event, *}; +use super::{Call, PalletEvent, *}; use crate::mock::*; use codec::Encode; use fg_primitives::ScheduledChange; @@ -57,7 +57,7 @@ fn authorities_change_logged() { System::events(), vec![EventRecord { phase: Phase::Finalization, - event: Event::NewAuthorities { + event: PalletEvent::NewAuthorities { authority_set: to_authorities(vec![(4, 1), (5, 1), (6, 1)]) } .into(), @@ -96,7 +96,7 @@ fn authorities_change_logged_after_delay() { System::events(), vec![EventRecord { phase: Phase::Finalization, - event: Event::NewAuthorities { + event: PalletEvent::NewAuthorities { authority_set: to_authorities(vec![(4, 1), (5, 1), (6, 1)]) } .into(), diff --git a/frame/identity/src/benchmarking.rs b/frame/identity/src/benchmarking.rs index 4b093959fa12f..baad75e0e9b25 100644 --- a/frame/identity/src/benchmarking.rs +++ b/frame/identity/src/benchmarking.rs @@ -147,7 +147,7 @@ benchmarks! { }; }: _(RawOrigin::Signed(caller.clone()), Box::new(create_identity_info::(x))) verify { - assert_last_event::(Event::::IdentitySet { who: caller }.into()); + assert_last_event::(PalletEvent::::IdentitySet { who: caller }.into()); } // We need to split `set_subs` into two benchmarks to accurately isolate the potential @@ -231,7 +231,7 @@ benchmarks! { }; }: _(RawOrigin::Signed(caller.clone()), r - 1, 10u32.into()) verify { - assert_last_event::(Event::::JudgementRequested { who: caller, registrar_index: r-1 }.into()); + assert_last_event::(PalletEvent::::JudgementRequested { who: caller, registrar_index: r-1 }.into()); } cancel_request { @@ -251,7 +251,7 @@ benchmarks! { Identity::::request_judgement(caller_origin, r - 1, 10u32.into())?; }: _(RawOrigin::Signed(caller.clone()), r - 1) verify { - assert_last_event::(Event::::JudgementUnrequested { who: caller, registrar_index: r-1 }.into()); + assert_last_event::(PalletEvent::::JudgementUnrequested { who: caller, registrar_index: r-1 }.into()); } set_fee { @@ -322,7 +322,7 @@ benchmarks! { Identity::::request_judgement(user_origin, r, 10u32.into())?; }: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable) verify { - assert_last_event::(Event::::JudgementGiven { target: user, registrar_index: r }.into()) + assert_last_event::(PalletEvent::::JudgementGiven { target: user, registrar_index: r }.into()) } kill_identity { diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index 9712d43c4e826..3685241a2cc2f 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -104,7 +104,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: ReservableCurrency; @@ -239,7 +239,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A name was set or reset (which will remove all judgements). IdentitySet { who: T::AccountId }, /// A name was cleared, and the given balance returned. @@ -299,7 +299,7 @@ pub mod pallet { }, )?; - Self::deposit_event(Event::RegistrarAdded { registrar_index: i }); + Self::deposit_event(PalletEvent::RegistrarAdded { registrar_index: i }); Ok(Some(T::WeightInfo::add_registrar(registrar_count as u32)).into()) } @@ -362,7 +362,7 @@ pub mod pallet { let judgements = id.judgements.len(); >::insert(&sender, id); - Self::deposit_event(Event::IdentitySet { who: sender }); + Self::deposit_event(PalletEvent::IdentitySet { who: sender }); Ok(Some(T::WeightInfo::set_identity( judgements as u32, // R @@ -487,7 +487,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&sender, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(Event::IdentityCleared { who: sender, deposit }); + Self::deposit_event(PalletEvent::IdentityCleared { who: sender, deposit }); Ok(Some(T::WeightInfo::clear_identity( id.judgements.len() as u32, // R @@ -556,7 +556,7 @@ pub mod pallet { let extra_fields = id.info.additional.len(); >::insert(&sender, id); - Self::deposit_event(Event::JudgementRequested { + Self::deposit_event(PalletEvent::JudgementRequested { who: sender, registrar_index: reg_index, }); @@ -609,7 +609,7 @@ pub mod pallet { let extra_fields = id.info.additional.len(); >::insert(&sender, id); - Self::deposit_event(Event::JudgementUnrequested { + Self::deposit_event(PalletEvent::JudgementUnrequested { who: sender, registrar_index: reg_index, }); @@ -795,7 +795,7 @@ pub mod pallet { let judgements = id.judgements.len(); let extra_fields = id.info.additional.len(); >::insert(&target, id); - Self::deposit_event(Event::JudgementGiven { target, registrar_index: reg_index }); + Self::deposit_event(PalletEvent::JudgementGiven { target, registrar_index: reg_index }); Ok(Some(T::WeightInfo::provide_judgement(judgements as u32, extra_fields as u32)) .into()) @@ -843,7 +843,7 @@ pub mod pallet { // Slash their deposit from them. T::Slashed::on_unbalanced(T::Currency::slash_reserved(&target, deposit).0); - Self::deposit_event(Event::IdentityKilled { who: target, deposit }); + Self::deposit_event(PalletEvent::IdentityKilled { who: target, deposit }); Ok(Some(T::WeightInfo::kill_identity( id.judgements.len() as u32, // R @@ -886,7 +886,7 @@ pub mod pallet { sub_ids.try_push(sub.clone()).expect("sub ids length checked above; qed"); *subs_deposit = subs_deposit.saturating_add(deposit); - Self::deposit_event(Event::SubIdentityAdded { sub, main: sender.clone(), deposit }); + Self::deposit_event(PalletEvent::SubIdentityAdded { sub, main: sender.clone(), deposit }); Ok(()) }) } @@ -933,7 +933,7 @@ pub mod pallet { *subs_deposit -= deposit; let err_amount = T::Currency::unreserve(&sender, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(Event::SubIdentityRemoved { sub, main: sender, deposit }); + Self::deposit_event(PalletEvent::SubIdentityRemoved { sub, main: sender, deposit }); }); Ok(()) } @@ -958,7 +958,7 @@ pub mod pallet { *subs_deposit -= deposit; let _ = T::Currency::repatriate_reserved(&sup, &sender, deposit, BalanceStatus::Free); - Self::deposit_event(Event::SubIdentityRevoked { + Self::deposit_event(PalletEvent::SubIdentityRevoked { sub: sender, main: sup.clone(), deposit, diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 342522ff29b19..7c4ce33913775 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -337,7 +337,7 @@ pub mod pallet { type MaxPeerDataEncodingSize: Get; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A type for retrieving the validators supposed to be online in a session. type ValidatorSet: ValidatorSetWithIdentification; @@ -371,7 +371,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A new heartbeat was received from `AuthorityId`. HeartbeatReceived { authority_id: T::AuthorityId }, /// At the end of the session, no offence was committed. @@ -493,7 +493,7 @@ pub mod pallet { let keys = Keys::::get(); let public = keys.get(heartbeat.authority_index as usize); if let (false, Some(public)) = (exists, public) { - Self::deposit_event(Event::::HeartbeatReceived { authority_id: public.clone() }); + Self::deposit_event(PalletEvent::::HeartbeatReceived { authority_id: public.clone() }); let network_state_bounded = BoundedOpaqueNetworkState::< T::MaxPeerDataEncodingSize, @@ -906,9 +906,9 @@ impl OneSessionHandler for Pallet { AuthoredBlocks::::remove_prefix(&T::ValidatorSet::session_index(), None); if offenders.is_empty() { - Self::deposit_event(Event::::AllGood); + Self::deposit_event(PalletEvent::::AllGood); } else { - Self::deposit_event(Event::::SomeOffline { offline: offenders.clone() }); + Self::deposit_event(PalletEvent::::SomeOffline { offline: offenders.clone() }); let validator_set_count = keys.len() as u32; let offence = UnresponsivenessOffence { session_index, validator_set_count, offenders }; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index b6b7295f60d34..24f87066a4f74 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -51,7 +51,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, ImOnline: imonline::{Pallet, Call, Storage, Config, Event}, Historical: pallet_session_historical::{Pallet}, } diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index 497fb0c43668a..5f5b15e6bd23c 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -67,7 +67,7 @@ pub mod pallet { type Deposit: Get>; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -106,7 +106,7 @@ pub mod pallet { *maybe_value = Some((who.clone(), T::Deposit::get(), false)); T::Currency::reserve(&who, T::Deposit::get()) })?; - Self::deposit_event(Event::IndexAssigned { who, index }); + Self::deposit_event(PalletEvent::IndexAssigned { who, index }); Ok(()) } @@ -147,7 +147,7 @@ pub mod pallet { *maybe_value = Some((new.clone(), amount.saturating_sub(lost), false)); Ok(()) })?; - Self::deposit_event(Event::IndexAssigned { who: new, index }); + Self::deposit_event(PalletEvent::IndexAssigned { who: new, index }); Ok(()) } @@ -180,7 +180,7 @@ pub mod pallet { T::Currency::unreserve(&who, amount); Ok(()) })?; - Self::deposit_event(Event::IndexFreed { index }); + Self::deposit_event(PalletEvent::IndexFreed { index }); Ok(()) } @@ -220,7 +220,7 @@ pub mod pallet { } *maybe_value = Some((new.clone(), Zero::zero(), freeze)); }); - Self::deposit_event(Event::IndexAssigned { who: new, index }); + Self::deposit_event(PalletEvent::IndexAssigned { who: new, index }); Ok(()) } @@ -254,14 +254,14 @@ pub mod pallet { *maybe_value = Some((account, Zero::zero(), true)); Ok(()) })?; - Self::deposit_event(Event::IndexFrozen { index, who }); + Self::deposit_event(PalletEvent::IndexFrozen { index, who }); Ok(()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A account index was assigned. IndexAssigned { who: T::AccountId, index: T::AccountIndex }, /// A account index has been freed up (unassigned). diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index c8989665768e4..583b3ed587729 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -146,7 +146,7 @@ pub mod pallet { type Randomness: Randomness; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The manager origin. type ManagerOrigin: EnsureOrigin; @@ -174,7 +174,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A lottery has been started! LotteryStarted, /// A new set of calls have been set! @@ -258,7 +258,7 @@ pub mod pallet { ); debug_assert!(res.is_ok()); - Self::deposit_event(Event::::Winner { winner, lottery_balance }); + Self::deposit_event(PalletEvent::::Winner { winner, lottery_balance }); TicketsCount::::kill(); @@ -324,7 +324,7 @@ pub mod pallet { let indices = Self::calls_to_indices(&calls)?; CallIndices::::put(indices); } - Self::deposit_event(Event::::CallsUpdated); + Self::deposit_event(PalletEvent::::CallsUpdated); Ok(()) } @@ -362,7 +362,7 @@ pub mod pallet { if T::Currency::total_balance(&lottery_account).is_zero() { T::Currency::deposit_creating(&lottery_account, T::Currency::minimum_balance()); } - Self::deposit_event(Event::::LotteryStarted); + Self::deposit_event(PalletEvent::::LotteryStarted); Ok(()) } @@ -462,7 +462,7 @@ impl Pallet { }, )?; - Self::deposit_event(Event::::TicketBought { who: caller.clone(), call_index }); + Self::deposit_event(PalletEvent::::TicketBought { who: caller.clone(), call_index }); Ok(()) } diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index b42369968af64..b1e22705a15e3 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -52,7 +52,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Required origin for adding a member (though can always be Root). @@ -133,7 +133,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// The given member was added; see the transaction for who. MemberAdded, /// The given member was removed; see the transaction for who. @@ -177,7 +177,7 @@ pub mod pallet { T::MembershipChanged::change_members_sorted(&[who], &[], &members[..]); - Self::deposit_event(Event::MemberAdded); + Self::deposit_event(PalletEvent::MemberAdded); Ok(()) } @@ -197,7 +197,7 @@ pub mod pallet { T::MembershipChanged::change_members_sorted(&[], &[who], &members[..]); Self::rejig_prime(&members); - Self::deposit_event(Event::MemberRemoved); + Self::deposit_event(PalletEvent::MemberRemoved); Ok(()) } @@ -229,7 +229,7 @@ pub mod pallet { T::MembershipChanged::change_members_sorted(&[add], &[remove], &members[..]); Self::rejig_prime(&members); - Self::deposit_event(Event::MembersSwapped); + Self::deposit_event(PalletEvent::MembersSwapped); Ok(()) } @@ -250,7 +250,7 @@ pub mod pallet { *m = members; }); - Self::deposit_event(Event::MembersReset); + Self::deposit_event(PalletEvent::MembersReset); Ok(()) } @@ -285,7 +285,7 @@ pub mod pallet { } } - Self::deposit_event(Event::KeyChanged); + Self::deposit_event(PalletEvent::KeyChanged); Ok(()) } diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index b49ad7720f8b5..c2a73bac94e21 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -117,7 +117,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter @@ -205,7 +205,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A new multisig operation has begun. NewMultisig { approving: T::AccountId, multisig: T::AccountId, call_hash: CallHash }, /// A multisig operation has been approved by someone. @@ -490,7 +490,7 @@ pub mod pallet { >::remove(&id, &call_hash); Self::clear_call(&call_hash); - Self::deposit_event(Event::MultisigCancelled { + Self::deposit_event(PalletEvent::MultisigCancelled { cancelling: who, timepoint, multisig: id, @@ -572,7 +572,7 @@ impl Pallet { T::Currency::unreserve(&m.depositor, m.deposit); let result = call.dispatch(RawOrigin::Signed(id.clone()).into()); - Self::deposit_event(Event::MultisigExecuted { + Self::deposit_event(PalletEvent::MultisigExecuted { approving: who, timepoint, multisig: id, @@ -609,7 +609,7 @@ impl Pallet { // Record approval. m.approvals.insert(pos, who.clone()); >::insert(&id, call_hash, m); - Self::deposit_event(Event::MultisigApproval { + Self::deposit_event(PalletEvent::MultisigApproval { approving: who, timepoint, multisig: id, @@ -658,7 +658,7 @@ impl Pallet { approvals: vec![who.clone()], }, ); - Self::deposit_event(Event::NewMultisig { approving: who, multisig: id, call_hash }); + Self::deposit_event(PalletEvent::NewMultisig { approving: who, multisig: id, call_hash }); let final_weight = if stored { T::WeightInfo::as_multi_create_store(other_signatories_len as u32, call_len as u32) diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index d1c57ab734628..7319a3a9c761c 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -703,7 +703,7 @@ fn multisig_2_of_3_cannot_reissue_same_call() { let err = DispatchError::from(BalancesError::::InsufficientBalance).stripped(); System::assert_last_event( - pallet_multisig::Event::MultisigExecuted { + pallet_multisig::PalletEvent::MultisigExecuted { approving: 3, timepoint: now(), multisig: multi, diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index efcc4d1b026ca..623430387f8d1 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -57,7 +57,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: ReservableCurrency; @@ -83,7 +83,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A name was set. NameSet { who: T::AccountId }, /// A name was forcibly set. @@ -143,12 +143,12 @@ pub mod pallet { ensure!(bounded_name.len() >= T::MinLength::get() as usize, Error::::TooShort); let deposit = if let Some((_, deposit)) = >::get(&sender) { - Self::deposit_event(Event::::NameChanged { who: sender.clone() }); + Self::deposit_event(PalletEvent::::NameChanged { who: sender.clone() }); deposit } else { let deposit = T::ReservationFee::get(); T::Currency::reserve(&sender, deposit)?; - Self::deposit_event(Event::::NameSet { who: sender.clone() }); + Self::deposit_event(PalletEvent::::NameSet { who: sender.clone() }); deposit }; @@ -175,7 +175,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&sender, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(Event::::NameCleared { who: sender, deposit }); + Self::deposit_event(PalletEvent::::NameCleared { who: sender, deposit }); Ok(()) } @@ -206,7 +206,7 @@ pub mod pallet { // Slash their deposit from them. T::Slashed::on_unbalanced(T::Currency::slash_reserved(&target, deposit).0); - Self::deposit_event(Event::::NameKilled { target, deposit }); + Self::deposit_event(PalletEvent::::NameKilled { target, deposit }); Ok(()) } @@ -236,7 +236,7 @@ pub mod pallet { let deposit = >::get(&target).map(|x| x.1).unwrap_or_else(Zero::zero); >::insert(&target, (bounded_name, deposit)); - Self::deposit_event(Event::::NameForced { target }); + Self::deposit_event(PalletEvent::::NameForced { target }); Ok(()) } } diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index b502b7681606d..7dc95f94c2662 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -64,7 +64,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The maximum number of well known nodes that are allowed to set #[pallet::constant] @@ -127,7 +127,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// The given well known node was added. NodeAdded { peer_id: PeerId, who: T::AccountId }, /// The given well known node was removed. @@ -225,7 +225,7 @@ pub mod pallet { WellKnownNodes::::put(&nodes); >::insert(&node, &owner); - Self::deposit_event(Event::NodeAdded { peer_id: node, who: owner }); + Self::deposit_event(PalletEvent::NodeAdded { peer_id: node, who: owner }); Ok(()) } @@ -249,7 +249,7 @@ pub mod pallet { >::remove(&node); AdditionalConnections::::remove(&node); - Self::deposit_event(Event::NodeRemoved { peer_id: node }); + Self::deposit_event(PalletEvent::NodeRemoved { peer_id: node }); Ok(()) } @@ -285,7 +285,7 @@ pub mod pallet { Owners::::swap(&remove, &add); AdditionalConnections::::swap(&remove, &add); - Self::deposit_event(Event::NodeSwapped { removed: remove, added: add }); + Self::deposit_event(PalletEvent::NodeSwapped { removed: remove, added: add }); Ok(()) } @@ -306,7 +306,7 @@ pub mod pallet { Self::initialize_nodes(&nodes); - Self::deposit_event(Event::NodesReset { nodes }); + Self::deposit_event(PalletEvent::NodesReset { nodes }); Ok(()) } @@ -322,7 +322,7 @@ pub mod pallet { ensure!(!Owners::::contains_key(&node), Error::::AlreadyClaimed); Owners::::insert(&node, &sender); - Self::deposit_event(Event::NodeClaimed { peer_id: node, who: sender }); + Self::deposit_event(PalletEvent::NodeClaimed { peer_id: node, who: sender }); Ok(()) } @@ -343,7 +343,7 @@ pub mod pallet { Owners::::remove(&node); AdditionalConnections::::remove(&node); - Self::deposit_event(Event::ClaimRemoved { peer_id: node, who: sender }); + Self::deposit_event(PalletEvent::ClaimRemoved { peer_id: node, who: sender }); Ok(()) } @@ -365,7 +365,7 @@ pub mod pallet { Owners::::insert(&node, &owner); - Self::deposit_event(Event::NodeTransferred { peer_id: node, target: owner }); + Self::deposit_event(PalletEvent::NodeTransferred { peer_id: node, target: owner }); Ok(()) } @@ -396,7 +396,7 @@ pub mod pallet { AdditionalConnections::::insert(&node, nodes); - Self::deposit_event(Event::ConnectionsAdded { + Self::deposit_event(PalletEvent::ConnectionsAdded { peer_id: node, allowed_connections: connections, }); @@ -427,7 +427,7 @@ pub mod pallet { AdditionalConnections::::insert(&node, nodes); - Self::deposit_event(Event::ConnectionsRemoved { + Self::deposit_event(PalletEvent::ConnectionsRemoved { peer_id: node, allowed_connections: connections, }); diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 2f51d82081654..fde7eea96ac98 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -904,7 +904,7 @@ impl BondedPool { fn set_state(&mut self, state: PoolState) { if self.state != state { self.state = state; - Pallet::::deposit_event(Event::::StateChanged { + Pallet::::deposit_event(PalletEvent::::StateChanged { pool_id: self.id, new_state: state, }); @@ -1146,7 +1146,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: weights::WeightInfo; @@ -1335,7 +1335,7 @@ pub mod pallet { /// Events of this pallet. #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A pool has been created. Created { depositor: T::AccountId, pool_id: PoolId }, /// A member has became bonded in a pool. @@ -1517,7 +1517,7 @@ pub mod pallet { }, ); - Self::deposit_event(Event::::Bonded { + Self::deposit_event(PalletEvent::::Bonded { member: who, pool_id, bonded: amount, @@ -1568,7 +1568,7 @@ pub mod pallet { bonded_pool.ok_to_be_open(bonded)?; member.points = member.points.saturating_add(points_issued); - Self::deposit_event(Event::::Bonded { + Self::deposit_event(PalletEvent::::Bonded { member: who.clone(), pool_id: member.pool_id, bonded, @@ -1679,7 +1679,7 @@ pub mod pallet { // Try and unbond in the member map. member.try_unbond(unbonding_points, points_unbonded, unbond_era)?; - Self::deposit_event(Event::::Unbonded { + Self::deposit_event(PalletEvent::::Unbonded { member: member_account.clone(), pool_id: member.pool_id, points: points_unbonded, @@ -1808,7 +1808,7 @@ pub mod pallet { ) .defensive()?; - Self::deposit_event(Event::::Withdrawn { + Self::deposit_event(PalletEvent::::Withdrawn { member: member_account.clone(), pool_id: member.pool_id, points: sum_unlocked_points, @@ -1818,7 +1818,7 @@ pub mod pallet { let post_info_weight = if member.total_points().is_zero() { // member being reaped. PoolMembers::::remove(&member_account); - Self::deposit_event(Event::::MemberRemoved { + Self::deposit_event(PalletEvent::::MemberRemoved { pool_id: member.pool_id, member: member_account.clone(), }); @@ -1920,12 +1920,12 @@ pub mod pallet { ); ReversePoolIdLookup::::insert(bonded_pool.bonded_account(), pool_id); - Self::deposit_event(Event::::Created { + Self::deposit_event(PalletEvent::::Created { depositor: who.clone(), pool_id: pool_id.clone(), }); - Self::deposit_event(Event::::Bonded { + Self::deposit_event(PalletEvent::::Bonded { member: who, pool_id, bonded: amount, @@ -2102,7 +2102,7 @@ pub mod pallet { ConfigOp::Set(v) => bonded_pool.roles.state_toggler = Some(v), }; - Self::deposit_event(Event::::RolesUpdated { + Self::deposit_event(PalletEvent::::RolesUpdated { root: bonded_pool.roles.root.clone(), nominator: bonded_pool.roles.nominator.clone(), state_toggler: bonded_pool.roles.state_toggler.clone(), @@ -2212,7 +2212,7 @@ impl Pallet { T::Currency::make_free_balance_be(&reward_account, Zero::zero()); T::Currency::make_free_balance_be(&bonded_pool.bonded_account(), Zero::zero()); - Self::deposit_event(Event::::Destroyed { pool_id: bonded_pool.id }); + Self::deposit_event(PalletEvent::::Destroyed { pool_id: bonded_pool.id }); bonded_pool.remove(); } @@ -2335,7 +2335,7 @@ impl Pallet { ExistenceRequirement::AllowDeath, )?; - Self::deposit_event(Event::::PaidOut { + Self::deposit_event(PalletEvent::::PaidOut { member: member_account.clone(), pool_id: member.pool_id, payout: pending_rewards, @@ -2484,7 +2484,7 @@ impl OnStakerSlash> for Pallet { for (era, slashed_balance) in slashed_unlocking.iter() { if let Some(pool) = sub_pools.with_era.get_mut(era) { pool.balance = *slashed_balance; - Self::deposit_event(Event::::UnbondingPoolSlashed { + Self::deposit_event(PalletEvent::::UnbondingPoolSlashed { era: *era, pool_id, balance: *slashed_balance, @@ -2492,7 +2492,7 @@ impl OnStakerSlash> for Pallet { } } - Self::deposit_event(Event::::PoolSlashed { pool_id, balance: slashed_bonded }); + Self::deposit_event(PalletEvent::::PoolSlashed { pool_id, balance: slashed_bonded }); SubPoolsStorage::::insert(pool_id, sub_pools); } } diff --git a/frame/nomination-pools/src/migration.rs b/frame/nomination-pools/src/migration.rs index f2abfe29dfbf7..78182c9f553eb 100644 --- a/frame/nomination-pools/src/migration.rs +++ b/frame/nomination-pools/src/migration.rs @@ -278,7 +278,7 @@ pub mod v2 { sum_paid_out = sum_paid_out.saturating_add(last_claim); } - Pallet::::deposit_event(Event::::PaidOut { + Pallet::::deposit_event(PalletEvent::::PaidOut { member: who.clone(), pool_id: id, payout: last_claim, diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index f2d9156d60117..af4d30c97aab6 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -324,7 +324,7 @@ parameter_types! { } /// All events of this pallet. -pub(crate) fn pool_events_since_last_call() -> Vec> { +pub(crate) fn pool_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) @@ -336,7 +336,7 @@ pub(crate) fn pool_events_since_last_call() -> Vec> { } /// All events of the `Balances` pallet. -pub(crate) fn balances_events_since_last_call() -> Vec> { +pub(crate) fn balances_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index 5aa8e97266e0d..e170b004f18f1 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -16,7 +16,7 @@ // limitations under the License. use super::*; -use crate::{mock::*, Event}; +use crate::{mock::*, PalletEvent}; use frame_support::{assert_err, assert_noop, assert_ok, assert_storage_noop, bounded_btree_map}; use pallet_balances::Event as BEvent; use sp_runtime::traits::Dispatchable; @@ -449,9 +449,9 @@ mod join { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 11, pool_id: 1, bonded: 2, joined: true }, + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 11, pool_id: 1, bonded: 2, joined: true }, ] ); @@ -475,7 +475,7 @@ mod join { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::Bonded { member: 12, pool_id: 1, bonded: 12, joined: true }] + vec![PalletEvent::Bonded { member: 12, pool_id: 1, bonded: 12, joined: true }] ); assert_eq!( @@ -599,10 +599,10 @@ mod join { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 101, pool_id: 1, bonded: 100, joined: true }, - Event::Bonded { member: 102, pool_id: 1, bonded: 100, joined: true } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 101, pool_id: 1, bonded: 100, joined: true }, + PalletEvent::Bonded { member: 102, pool_id: 1, bonded: 100, joined: true } ] ); @@ -627,8 +627,8 @@ mod join { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 104, pool_id: 2 }, - Event::Bonded { member: 104, pool_id: 2, bonded: 100, joined: true } + PalletEvent::Created { depositor: 104, pool_id: 2 }, + PalletEvent::Bonded { member: 104, pool_id: 2, bonded: 100, joined: true } ] ); @@ -696,7 +696,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 10 },] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 },] ); // last recorded reward counter at the time of this member's payout is 1 assert_eq!(PoolMembers::::get(10).unwrap(), del(10, 1)); @@ -712,7 +712,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 40, pool_id: 1, payout: 40 }] + vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 40 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del(40, 1)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 50)); @@ -725,7 +725,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] + vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del(50, 1)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 100)); @@ -741,7 +741,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del_float(10, 1.5)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 105)); @@ -754,7 +754,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 40, pool_id: 1, payout: 20 }] + vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 20 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del_float(40, 1.5)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 125)); @@ -771,7 +771,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] + vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del_float(50, 2.0)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 175)); @@ -784,7 +784,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del(10, 2)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 180)); @@ -801,7 +801,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 40 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 40 }] ); // We expect a payout of 40 @@ -820,7 +820,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 2 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 2 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del_float(10, 6.2)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 222)); @@ -833,7 +833,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 40, pool_id: 1, payout: 188 }] + vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 188 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del_float(40, 6.2)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 410)); @@ -846,7 +846,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 50, pool_id: 1, payout: 210 }] + vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 210 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del_float(50, 6.2)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 620)); @@ -866,10 +866,10 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 11, pool_id: 1, bonded: 11, joined: true }, - Event::Unbonded { member: 11, pool_id: 1, points: 11, balance: 11, era: 3 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 11, pool_id: 1, bonded: 11, joined: true }, + PalletEvent::Unbonded { member: 11, pool_id: 1, points: 11, balance: 11, era: 3 } ] ); }); @@ -905,9 +905,9 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 5 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 } ] ); assert_eq!(payout, 5); @@ -925,7 +925,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 10 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }] ); assert_eq!(payout, 10); assert_eq!(reward_pool, rew(0, 0, 15)); @@ -962,10 +962,10 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, - Event::Bonded { member: 50, pool_id: 1, bonded: 50, joined: true } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, + PalletEvent::Bonded { member: 50, pool_id: 1, bonded: 50, joined: true } ] ); @@ -984,7 +984,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 10 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }] ); assert_eq!(payout, 10); assert_eq!(del_10, del(10, 1)); @@ -998,7 +998,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 40, pool_id: 1, payout: 40 }] + vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 40 }] ); assert_eq!(payout, 40); assert_eq!(del_40, del(40, 1)); @@ -1012,7 +1012,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] + vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(payout, 50); assert_eq!(del_50, del(50, 1)); @@ -1029,7 +1029,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(payout, 5); assert_eq!(del_10, del_float(10, 1.5)); @@ -1043,7 +1043,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 40, pool_id: 1, payout: 20 }] + vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 20 }] ); assert_eq!(payout, 20); assert_eq!(del_40, del_float(40, 1.5)); @@ -1060,7 +1060,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] + vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(payout, 50); assert_eq!(del_50, del_float(50, 2.0)); @@ -1074,7 +1074,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(payout, 5); assert_eq!(del_10, del_float(10, 2.0)); @@ -1091,7 +1091,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 40 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 40 }] ); assert_eq!(payout, 40); assert_eq!(del_10, del_float(10, 6.0)); @@ -1151,11 +1151,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 20 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 10 }, + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 10 }, ] ); @@ -1168,8 +1168,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 10 }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 10 }, ] ); }); @@ -1194,11 +1194,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 3 + 3 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 3 }, + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 3 + 3 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 3 }, ] ); @@ -1211,8 +1211,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 10, pool_id: 1, payout: 4 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 4 }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 4 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 4 }, ] ); @@ -1225,8 +1225,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 10, pool_id: 1, payout: 3 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 3 }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 3 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 3 }, ] ); }); @@ -1257,13 +1257,13 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 30 + 100 / 2 + 60 / 3 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 100 / 2 + 60 / 3 }, - Event::PaidOut { member: 30, pool_id: 1, payout: 60 / 3 }, + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 30 + 100 / 2 + 60 / 3 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 100 / 2 + 60 / 3 }, + PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 60 / 3 }, ] ); @@ -1277,9 +1277,9 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 10 }, - Event::PaidOut { member: 30, pool_id: 1, payout: 10 }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 10 }, + PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 10 }, ] ); }); @@ -1305,13 +1305,13 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 20 }, - Event::PaidOut { member: 30, pool_id: 1, payout: 10 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 20 }, + PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 10 } ] ); @@ -1328,10 +1328,10 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: false }, - Event::PaidOut { member: 10, pool_id: 1, payout: 20 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 40 }, - Event::PaidOut { member: 30, pool_id: 1, payout: 40 } + PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: false }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 40 }, + PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 40 } ] ); }); @@ -1354,11 +1354,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 20 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 20 } ] ); @@ -1374,9 +1374,9 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Unbonded { member: 20, pool_id: 1, balance: 10, points: 10, era: 3 }, - Event::PaidOut { member: 10, pool_id: 1, payout: 50 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 50 }, + PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 10, points: 10, era: 3 }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 50 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 50 }, ] ); }); @@ -1402,12 +1402,12 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 20 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 20 } ] ); @@ -1421,8 +1421,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 10, pool_id: 1, payout: 20 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 40 } + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 40 } ] ); @@ -1436,8 +1436,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 10, pool_id: 1, payout: 20 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 40 } + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 40 } ] ); @@ -1446,7 +1446,7 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 30, pool_id: 1, payout: 10 + 20 + 20 }] + vec![PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 10 + 20 + 20 }] ); }); } @@ -1468,10 +1468,10 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 10 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 } ] ); @@ -1489,9 +1489,9 @@ mod claim_payout { pool_events_since_last_call(), vec![ // 20 + 40, which means the extra amount they bonded did not impact us. - Event::PaidOut { member: 20, pool_id: 1, payout: 60 }, - Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: false }, - Event::PaidOut { member: 10, pool_id: 1, payout: 20 } + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 60 }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: false }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 } ] ); @@ -1505,8 +1505,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 10, pool_id: 1, payout: 15 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 45 } + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 15 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 45 } ] ); }); @@ -1567,13 +1567,13 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Created { depositor: 20, pool_id: 2 }, - Event::Bonded { member: 20, pool_id: 2, bonded: 10, joined: true }, - Event::Created { depositor: 30, pool_id: 3 }, - Event::Bonded { member: 30, pool_id: 3, bonded: 10, joined: true }, - Event::PaidOut { member: 30, pool_id: 3, payout: 10 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Created { depositor: 20, pool_id: 2 }, + PalletEvent::Bonded { member: 20, pool_id: 2, bonded: 10, joined: true }, + PalletEvent::Created { depositor: 30, pool_id: 3 }, + PalletEvent::Bonded { member: 30, pool_id: 3, bonded: 10, joined: true }, + PalletEvent::PaidOut { member: 30, pool_id: 3, payout: 10 } ] ); }) @@ -1636,11 +1636,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 40, pool_id: 1, bonded: 10, joined: true } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 10, joined: true } ] ); }) @@ -1707,14 +1707,14 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, - Event::PaidOut { member: 10, pool_id: 1, payout: 15 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, - Event::PaidOut { member: 20, pool_id: 1, payout: 15 }, - Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: false } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 15 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 15 }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: false } ] ); }) @@ -1804,17 +1804,17 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::Bonded { member: 30, pool_id: 1, bonded: 20, joined: true }, - Event::Unbonded { member: 20, pool_id: 1, balance: 10, points: 10, era: 3 }, - Event::PaidOut { member: 30, pool_id: 1, payout: 15 }, - Event::Unbonded { member: 30, pool_id: 1, balance: 10, points: 10, era: 3 }, - Event::Unbonded { member: 30, pool_id: 1, balance: 5, points: 5, era: 3 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 7 }, - Event::Unbonded { member: 20, pool_id: 1, balance: 5, points: 5, era: 3 }, - Event::PaidOut { member: 10, pool_id: 1, payout: 7 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 10, points: 10, era: 3 }, + PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 15 }, + PalletEvent::Unbonded { member: 30, pool_id: 1, balance: 10, points: 10, era: 3 }, + PalletEvent::Unbonded { member: 30, pool_id: 1, balance: 5, points: 5, era: 3 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 7 }, + PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 5, points: 5, era: 3 }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 7 } ] ); }) @@ -1842,11 +1842,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 13 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 26 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 13 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 26 } ] ); @@ -1864,14 +1864,14 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, - Event::Unbonded { member: 20, pool_id: 1, balance: 20, points: 20, era: 3 }, - Event::Withdrawn { member: 20, pool_id: 1, balance: 20, points: 20 }, - Event::MemberRemoved { pool_id: 1, member: 20 }, - Event::Unbonded { member: 10, pool_id: 1, balance: 10, points: 10, era: 6 }, - Event::Withdrawn { member: 10, pool_id: 1, balance: 10, points: 10 }, - Event::MemberRemoved { pool_id: 1, member: 10 }, - Event::Destroyed { pool_id: 1 } + PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, + PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 20, points: 20, era: 3 }, + PalletEvent::Withdrawn { member: 20, pool_id: 1, balance: 20, points: 20 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 20 }, + PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 10, points: 10, era: 6 }, + PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 10, points: 10 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, + PalletEvent::Destroyed { pool_id: 1 } ] ); @@ -1905,35 +1905,35 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 1000000000000000, joined: true }, - Event::Bonded { + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 1500000000000000, joined: true }, - Event::Bonded { + PalletEvent::Bonded { member: 21, pool_id: 1, bonded: 2500000000000000, joined: true }, - Event::Bonded { + PalletEvent::Bonded { member: 22, pool_id: 1, bonded: 5000000000000000, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 100000000 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 150000000 }, - Event::PaidOut { member: 21, pool_id: 1, payout: 250000000 }, - Event::PaidOut { member: 22, pool_id: 1, payout: 500000000 } + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 100000000 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 150000000 }, + PalletEvent::PaidOut { member: 21, pool_id: 1, payout: 250000000 }, + PalletEvent::PaidOut { member: 22, pool_id: 1, payout: 500000000 } ] ); }) @@ -2264,12 +2264,12 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, - Event::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, - Event::PaidOut { member: 40, pool_id: 1, payout: 40 }, - Event::Unbonded { member: 40, pool_id: 1, points: 6, balance: 6, era: 3 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, + PalletEvent::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, + PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 40 }, + PalletEvent::Unbonded { member: 40, pool_id: 1, points: 6, balance: 6, era: 3 } ] ); @@ -2310,8 +2310,8 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 550, pool_id: 1, payout: 550 }, - Event::Unbonded { + PalletEvent::PaidOut { member: 550, pool_id: 1, payout: 550 }, + PalletEvent::Unbonded { member: 550, pool_id: 1, points: 92, @@ -2350,12 +2350,12 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::Withdrawn { member: 40, pool_id: 1, points: 6, balance: 6 }, - Event::MemberRemoved { pool_id: 1, member: 40 }, - Event::Withdrawn { member: 550, pool_id: 1, points: 92, balance: 92 }, - Event::MemberRemoved { pool_id: 1, member: 550 }, - Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, - Event::Unbonded { member: 10, pool_id: 1, points: 2, balance: 2, era: 6 } + PalletEvent::Withdrawn { member: 40, pool_id: 1, points: 6, balance: 6 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 40 }, + PalletEvent::Withdrawn { member: 550, pool_id: 1, points: 92, balance: 92 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 550 }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, + PalletEvent::Unbonded { member: 10, pool_id: 1, points: 2, balance: 2, era: 6 } ] ); }); @@ -2399,9 +2399,9 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Unbonded { member: 10, pool_id: 1, points: 10, balance: 10, era: 9 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Unbonded { member: 10, pool_id: 1, points: 10, balance: 10, era: 9 } ] ); }); @@ -2432,11 +2432,11 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - Event::Bonded { member: 200, pool_id: 1, bonded: 200, joined: true }, - Event::Unbonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + PalletEvent::Bonded { member: 200, pool_id: 1, bonded: 200, joined: true }, + PalletEvent::Unbonded { member: 100, pool_id: 1, points: 100, @@ -2451,7 +2451,7 @@ mod unbond { assert_eq!( pool_events_since_last_call(), - vec![Event::Unbonded { + vec![PalletEvent::Unbonded { member: 200, pool_id: 1, points: 200, @@ -2523,10 +2523,10 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - Event::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + PalletEvent::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 } ] ); @@ -2675,9 +2675,9 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 3 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 3 } ] ); @@ -2703,7 +2703,7 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![Event::Unbonded { member: 10, pool_id: 1, points: 5, balance: 5, era: 3 }] + vec![PalletEvent::Unbonded { member: 10, pool_id: 1, points: 5, balance: 5, era: 3 }] ); // when: casual further unbond, next era. @@ -2730,7 +2730,7 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![Event::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 4 }] + vec![PalletEvent::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 4 }] ); // when: unbonding more than our active: error @@ -2765,7 +2765,7 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![Event::Unbonded { member: 10, pool_id: 1, points: 3, balance: 3, era: 4 }] + vec![PalletEvent::Unbonded { member: 10, pool_id: 1, points: 3, balance: 3, era: 4 }] ); }); } @@ -2807,12 +2807,12 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::Unbonded { member: 20, pool_id: 1, points: 2, balance: 2, era: 3 }, - Event::Unbonded { member: 20, pool_id: 1, points: 3, balance: 3, era: 4 }, - Event::Unbonded { member: 20, pool_id: 1, points: 1, balance: 1, era: 5 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::Unbonded { member: 20, pool_id: 1, points: 2, balance: 2, era: 3 }, + PalletEvent::Unbonded { member: 20, pool_id: 1, points: 3, balance: 3, era: 4 }, + PalletEvent::Unbonded { member: 20, pool_id: 1, points: 1, balance: 1, era: 5 } ] ); }) @@ -2843,9 +2843,9 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Unbonded { member: 10, pool_id: 1, points: 3, balance: 3, era: 3 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Unbonded { member: 10, pool_id: 1, points: 3, balance: 3, era: 3 } ] ); }); @@ -2887,11 +2887,11 @@ mod unbond { pool_events_since_last_call(), vec![ // 2/3 of ed, which is 20's share. - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::PaidOut { member: 20, pool_id: 1, payout: 10 }, - Event::Unbonded { member: 20, pool_id: 1, balance: 2, points: 2, era: 3 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 10 }, + PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 2, points: 2, era: 3 } ] ); @@ -2906,8 +2906,8 @@ mod unbond { pool_events_since_last_call(), vec![ // 2/3 of ed, which is 20's share. - Event::PaidOut { member: 20, pool_id: 1, payout: 6 }, - Event::Unbonded { member: 20, pool_id: 1, points: 3, balance: 3, era: 4 } + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 6 }, + PalletEvent::Unbonded { member: 20, pool_id: 1, points: 3, balance: 3, era: 4 } ] ); @@ -2921,8 +2921,8 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 20, pool_id: 1, payout: 3 }, - Event::Unbonded { member: 20, pool_id: 1, points: 5, balance: 5, era: 5 } + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 3 }, + PalletEvent::Unbonded { member: 20, pool_id: 1, points: 5, balance: 5, era: 5 } ] ); @@ -3024,18 +3024,18 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, - Event::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, - Event::Unbonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, + PalletEvent::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, + PalletEvent::Unbonded { member: 550, pool_id: 1, points: 550, balance: 550, era: 3 }, - Event::Unbonded { member: 40, pool_id: 1, points: 40, balance: 40, era: 3 }, + PalletEvent::Unbonded { member: 40, pool_id: 1, points: 40, balance: 40, era: 3 }, ] ); assert_eq!( @@ -3058,8 +3058,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Withdrawn { member: 550, pool_id: 1, balance: 275, points: 550 }, - Event::MemberRemoved { pool_id: 1, member: 550 } + PalletEvent::Withdrawn { member: 550, pool_id: 1, balance: 275, points: 550 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 550 } ] ); assert_eq!( @@ -3079,8 +3079,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Withdrawn { member: 40, pool_id: 1, balance: 20, points: 40 }, - Event::MemberRemoved { pool_id: 1, member: 40 } + PalletEvent::Withdrawn { member: 40, pool_id: 1, balance: 20, points: 40 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 40 } ] ); assert_eq!( @@ -3100,10 +3100,10 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Unbonded { member: 10, pool_id: 1, balance: 5, points: 5, era: 9 }, - Event::Withdrawn { member: 10, pool_id: 1, balance: 5, points: 5 }, - Event::MemberRemoved { pool_id: 1, member: 10 }, - Event::Destroyed { pool_id: 1 } + PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 5, points: 5, era: 9 }, + PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 5, points: 5 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, + PalletEvent::Destroyed { pool_id: 1 } ] ); assert_eq!( @@ -3141,12 +3141,12 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, - Event::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, - Event::Unbonded { member: 40, pool_id: 1, balance: 20, points: 20, era: 3 }, - Event::Unbonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, + PalletEvent::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, + PalletEvent::Unbonded { member: 40, pool_id: 1, balance: 20, points: 20, era: 3 }, + PalletEvent::Unbonded { member: 550, pool_id: 1, balance: 275, @@ -3177,8 +3177,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Withdrawn { member: 40, pool_id: 1, balance: 20, points: 20 }, - Event::MemberRemoved { pool_id: 1, member: 40 } + PalletEvent::Withdrawn { member: 40, pool_id: 1, balance: 20, points: 20 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 40 } ] ); @@ -3198,8 +3198,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Withdrawn { member: 550, pool_id: 1, balance: 275, points: 275 }, - Event::MemberRemoved { pool_id: 1, member: 550 } + PalletEvent::Withdrawn { member: 550, pool_id: 1, balance: 275, points: 275 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 550 } ] ); assert!(SubPoolsStorage::::get(&1).unwrap().with_era.is_empty()); @@ -3228,10 +3228,10 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Unbonded { member: 10, pool_id: 1, points: 5, balance: 5, era: 6 }, - Event::Withdrawn { member: 10, pool_id: 1, points: 5, balance: 5 }, - Event::MemberRemoved { pool_id: 1, member: 10 }, - Event::Destroyed { pool_id: 1 } + PalletEvent::Unbonded { member: 10, pool_id: 1, points: 5, balance: 5, era: 6 }, + PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 5, balance: 5 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, + PalletEvent::Destroyed { pool_id: 1 } ] ); assert_eq!( @@ -3338,18 +3338,18 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - Event::Bonded { member: 200, pool_id: 1, bonded: 200, joined: true }, - Event::Unbonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + PalletEvent::Bonded { member: 200, pool_id: 1, bonded: 200, joined: true }, + PalletEvent::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 }, - Event::Unbonded { + PalletEvent::Unbonded { member: 200, pool_id: 1, points: 200, @@ -3382,10 +3382,10 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, - Event::MemberRemoved { pool_id: 1, member: 100 }, - Event::Withdrawn { member: 200, pool_id: 1, points: 200, balance: 200 }, - Event::MemberRemoved { pool_id: 1, member: 200 } + PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 100 }, + PalletEvent::Withdrawn { member: 200, pool_id: 1, points: 200, balance: 200 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 200 } ] ); }); @@ -3429,12 +3429,12 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - Event::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 }, - Event::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, - Event::MemberRemoved { pool_id: 1, member: 100 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + PalletEvent::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 }, + PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 100 } ] ); }); @@ -3469,11 +3469,11 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, - Event::Unbonded { member: 10, pool_id: 1, points: 6, balance: 6, era: 3 }, - Event::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 4 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, + PalletEvent::Unbonded { member: 10, pool_id: 1, points: 6, balance: 6, era: 3 }, + PalletEvent::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 4 } ] ); @@ -3504,7 +3504,7 @@ mod withdraw_unbonded { ); assert_eq!( pool_events_since_last_call(), - vec![Event::Withdrawn { member: 10, pool_id: 1, points: 6, balance: 6 }] + vec![PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 6, balance: 6 }] ); // when @@ -3519,7 +3519,7 @@ mod withdraw_unbonded { assert_eq!(SubPoolsStorage::::get(1).unwrap(), Default::default()); assert_eq!( pool_events_since_last_call(), - vec![Event::Withdrawn { member: 10, pool_id: 1, points: 1, balance: 1 },] + vec![PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 1, balance: 1 },] ); // when repeating: @@ -3556,11 +3556,11 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 11, pool_id: 1, bonded: 10, joined: true }, - Event::Unbonded { member: 11, pool_id: 1, points: 6, balance: 6, era: 3 }, - Event::Unbonded { member: 11, pool_id: 1, points: 1, balance: 1, era: 4 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 11, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Unbonded { member: 11, pool_id: 1, points: 6, balance: 6, era: 3 }, + PalletEvent::Unbonded { member: 11, pool_id: 1, points: 1, balance: 1, era: 4 } ] ); @@ -3591,7 +3591,7 @@ mod withdraw_unbonded { ); assert_eq!( pool_events_since_last_call(), - vec![Event::Withdrawn { member: 11, pool_id: 1, points: 6, balance: 6 }] + vec![PalletEvent::Withdrawn { member: 11, pool_id: 1, points: 6, balance: 6 }] ); // when @@ -3606,7 +3606,7 @@ mod withdraw_unbonded { assert_eq!(SubPoolsStorage::::get(1).unwrap(), Default::default()); assert_eq!( pool_events_since_last_call(), - vec![Event::Withdrawn { member: 11, pool_id: 1, points: 1, balance: 1 }] + vec![PalletEvent::Withdrawn { member: 11, pool_id: 1, points: 1, balance: 1 }] ); // when repeating: @@ -3646,12 +3646,12 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - Event::Unbonded { member: 100, pool_id: 1, points: 75, balance: 75, era: 3 }, - Event::Unbonded { member: 100, pool_id: 1, points: 25, balance: 25, era: 4 }, - Event::Withdrawn { member: 100, pool_id: 1, points: 75, balance: 75 }, + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + PalletEvent::Unbonded { member: 100, pool_id: 1, points: 75, balance: 75, era: 3 }, + PalletEvent::Unbonded { member: 100, pool_id: 1, points: 25, balance: 25, era: 4 }, + PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 75, balance: 75 }, ] ); assert_eq!( @@ -3665,8 +3665,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Withdrawn { member: 100, pool_id: 1, points: 25, balance: 25 }, - Event::MemberRemoved { pool_id: 1, member: 100 } + PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 25, balance: 25 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 100 } ] ); }) @@ -3718,13 +3718,13 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, - Event::Unbonded { member: 10, pool_id: 1, balance: 7, points: 7, era: 3 }, - Event::Unbonded { member: 10, pool_id: 1, balance: 3, points: 3, era: 4 }, - Event::Unbonded { member: 10, pool_id: 1, balance: 10, points: 10, era: 4 }, - Event::Withdrawn { member: 10, pool_id: 1, balance: 7, points: 7 } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, + PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 7, points: 7, era: 3 }, + PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 3, points: 3, era: 4 }, + PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 10, points: 10, era: 4 }, + PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 7, points: 7 } ] ); assert_eq!( @@ -3739,9 +3739,9 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - Event::Withdrawn { member: 10, pool_id: 1, points: 13, balance: 13 }, - Event::MemberRemoved { pool_id: 1, member: 10 }, - Event::Destroyed { pool_id: 1 }, + PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 13, balance: 13 }, + PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, + PalletEvent::Destroyed { pool_id: 1 }, ] ); }) @@ -3810,10 +3810,10 @@ mod create { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Created { depositor: 11, pool_id: 2 }, - Event::Bonded { member: 11, pool_id: 2, bonded: 10, joined: true } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Created { depositor: 11, pool_id: 2 }, + PalletEvent::Bonded { member: 11, pool_id: 2, bonded: 10, joined: true } ] ); }); @@ -3944,9 +3944,9 @@ mod set_state { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::StateChanged { pool_id: 1, new_state: PoolState::Blocked } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Blocked } ] ); @@ -3997,9 +3997,9 @@ mod set_state { assert_eq!( pool_events_since_last_call(), vec![ - Event::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, - Event::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, - Event::StateChanged { pool_id: 1, new_state: PoolState::Destroying } + PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, + PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, + PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying } ] ); }); @@ -4116,9 +4116,9 @@ mod bond_extra { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false } ] ); @@ -4132,7 +4132,7 @@ mod bond_extra { assert_eq!( pool_events_since_last_call(), - vec![Event::Bonded { member: 10, pool_id: 1, bonded: 20, joined: false }] + vec![PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 20, joined: false }] ); }) } @@ -4162,10 +4162,10 @@ mod bond_extra { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: claimable_reward }, - Event::Bonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: claimable_reward }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: claimable_reward, @@ -4216,13 +4216,13 @@ mod bond_extra { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 1, joined: false }, - Event::PaidOut { member: 20, pool_id: 1, payout: 2 }, - Event::Bonded { member: 20, pool_id: 1, bonded: 2, joined: false } + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 1, joined: false }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 2 }, + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 2, joined: false } ] ); }) @@ -4304,9 +4304,9 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - Event::RolesUpdated { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + PalletEvent::RolesUpdated { root: Some(5), state_toggler: Some(7), nominator: Some(6) @@ -4334,7 +4334,7 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), - vec![Event::RolesUpdated { + vec![PalletEvent::RolesUpdated { root: Some(1), state_toggler: Some(3), nominator: Some(2) @@ -4361,7 +4361,7 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), - vec![Event::RolesUpdated { + vec![PalletEvent::RolesUpdated { root: Some(11), state_toggler: Some(3), nominator: Some(2) @@ -4389,7 +4389,7 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), - vec![Event::RolesUpdated { root: Some(69), state_toggler: None, nominator: None }] + vec![PalletEvent::RolesUpdated { root: Some(69), state_toggler: None, nominator: None }] ); assert_eq!( @@ -4440,8 +4440,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 1173908528796953165005, @@ -4469,7 +4469,7 @@ mod reward_counter_precision { assert_ok!(Pools::claim_payout(Origin::signed(10))); assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 1173 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 1173 }] ); }) } @@ -4482,8 +4482,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 12_968_712_300_500_000_000, @@ -4506,7 +4506,7 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), - vec![Event::Bonded { + vec![PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 12_968_712_300_500_000_000, @@ -4519,7 +4519,7 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 15937424600999999996 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 15937424600999999996 }] ); // now let a small member join with 10 DOTs. @@ -4533,9 +4533,9 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::Bonded { member: 30, pool_id: 1, bonded: 100000000000, joined: true }, + PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 100000000000, joined: true }, // quite small, but working fine. - Event::PaidOut { member: 30, pool_id: 1, payout: 38 } + PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 38 } ] ); }) @@ -4549,8 +4549,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 12_968_712_300_500_000_000, @@ -4581,8 +4581,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 2500000000000000000, @@ -4606,13 +4606,13 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::Bonded { + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 100000000000, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 9999997 } + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 9999997 } ] ); @@ -4625,7 +4625,7 @@ mod reward_counter_precision { assert_ok!(Pools::claim_payout(Origin::signed(10))); assert_eq!( pool_events_since_last_call(), - vec![Event::PaidOut { member: 10, pool_id: 1, payout: 10000000 }] + vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10000000 }] ); // earn some more rewards, this time 20 can also claim. @@ -4638,8 +4638,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::PaidOut { member: 10, pool_id: 1, payout: 10000000 }, - Event::PaidOut { member: 20, pool_id: 1, payout: 1 } + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10000000 }, + PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 1 } ] ); }); @@ -4655,8 +4655,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::Created { depositor: 10, pool_id: 1 }, - Event::Bonded { + PalletEvent::Created { depositor: 10, pool_id: 1 }, + PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 2500000000000000000, @@ -4682,13 +4682,13 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - Event::Bonded { + PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 100000000000, joined: true }, - Event::PaidOut { member: 10, pool_id: 1, payout: 9999997 } + PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 9999997 } ] ); diff --git a/frame/nomination-pools/test-staking/src/lib.rs b/frame/nomination-pools/test-staking/src/lib.rs index 5a7cd494362ca..53bacabc34cb8 100644 --- a/frame/nomination-pools/test-staking/src/lib.rs +++ b/frame/nomination-pools/test-staking/src/lib.rs @@ -22,10 +22,10 @@ mod mock; use frame_support::{assert_noop, assert_ok, bounded_btree_map, traits::Currency}; use mock::*; use pallet_nomination_pools::{ - BondedPools, Error as PoolsError, Event as PoolsEvent, LastPoolId, PoolMember, PoolMembers, + BondedPools, Error as PoolsError, PalletEvent as PoolsEvent, LastPoolId, PoolMember, PoolMembers, PoolState, }; -use pallet_staking::{CurrentEra, Event as StakingEvent, Payee, RewardDestination}; +use pallet_staking::{CurrentEra, PalletEvent as StakingEvent, Payee, RewardDestination}; use sp_runtime::traits::Zero; #[test] diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 90b9be0568f5a..2ba66128085d0 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -244,7 +244,7 @@ parameter_types! { static ObservedEventsBalances: usize = 0; } -pub(crate) fn pool_events_since_last_call() -> Vec> { +pub(crate) fn pool_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) @@ -255,7 +255,7 @@ pub(crate) fn pool_events_since_last_call() -> Vec Vec> { +pub(crate) fn staking_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index 96c6f9c2bdfc3..23c6563bdef6b 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -43,7 +43,7 @@ use pallet_session::{ Config as SessionConfig, SessionManager, }; use pallet_staking::{ - Config as StakingConfig, Event as StakingEvent, Exposure, IndividualExposure, + Config as StakingConfig, PalletEvent as StakingEvent, Exposure, IndividualExposure, Pallet as Staking, RewardDestination, ValidatorPrefs, }; @@ -311,13 +311,13 @@ benchmarks! { ::RuntimeEvent::from(StakingEvent::::Slashed(id, BalanceOf::::from(slash_amount))) ); let balance_slash = |id| core::iter::once( - ::RuntimeEvent::from(pallet_balances::Event::::Slashed{who: id, amount: slash_amount.into()}) + ::RuntimeEvent::from(pallet_balances::PalletEvent::::Slashed{who: id, amount: slash_amount.into()}) ); let chill = |id| core::iter::once( ::RuntimeEvent::from(StakingEvent::::Chilled(id)) ); let balance_deposit = |id, amount: u32| - ::RuntimeEvent::from(pallet_balances::Event::::Deposit{who: id, amount: amount.into()}); + ::RuntimeEvent::from(pallet_balances::PalletEvent::::Deposit{who: id, amount: amount.into()}); let mut first = true; let slash_events = raw_offenders.into_iter() .flat_map(|offender| { @@ -338,9 +338,9 @@ benchmarks! { let mut reward_events = reporters.clone().into_iter() .flat_map(|reporter| vec![ balance_deposit(reporter.clone(), reward).into(), - frame_system::Event::::NewAccount { account: reporter.clone() }.into(), + frame_system::PalletEvent::::NewAccount { account: reporter.clone() }.into(), ::RuntimeEvent::from( - pallet_balances::Event::::Endowed{account: reporter, free_balance: reward.into()} + pallet_balances::PalletEvent::::Endowed{account: reporter, free_balance: reward.into()} ).into(), ]) .collect::>(); @@ -367,7 +367,7 @@ benchmarks! { std::iter::empty() .chain(slash_events.into_iter().map(Into::into)) .chain(std::iter::once(::RuntimeEvent::from( - pallet_offences::Event::Offence{ + pallet_offences::PalletEvent::Offence{ kind: UnresponsivenessOffence::::ID, timeslot: 0_u32.to_le_bytes().to_vec(), } diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 7158e8d1ff8b0..1d34220fd2d9c 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -225,9 +225,9 @@ frame_support::construct_runtime!( System: system::{Pallet, Call, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config}, - Offences: pallet_offences::{Pallet, Storage, Event}, + Offences: pallet_offences::{Pallet, Storage, PalletEvent}, Historical: pallet_session_historical::{Pallet}, } ); diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index 7858b02719c4c..32af60d6f6fd3 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -57,7 +57,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// Full identification of the validator. type IdentificationTuple: Parameter; /// A handler called for every offence report. @@ -104,7 +104,7 @@ pub mod pallet { /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// There is an offence reported of the given `kind` happened at the `session_index` and /// (kind-specific) time slot. This event is not deposited for duplicate slashes. /// \[kind, timeslot\]. @@ -145,7 +145,7 @@ where ); // Deposit the event. - Self::deposit_event(Event::Offence { kind: O::ID, timeslot: time_slot.encode() }); + Self::deposit_event(PalletEvent::Offence { kind: O::ID, timeslot: time_slot.encode() }); Ok(()) } diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 7466b7e4adc40..2b1505451f7a3 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -80,7 +80,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Offences: offences::{Pallet, Storage, Event}, + Offences: offences::{Pallet, Storage, PalletEvent}, } ); diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index 266e05debf050..7efe5946e2d74 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -114,7 +114,7 @@ fn should_deposit_event() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Offences(crate::Event::Offence { + event: RuntimeEvent::Offences(crate::PalletEvent::Offence { kind: KIND, timeslot: time_slot.encode() }), @@ -148,7 +148,7 @@ fn doesnt_deposit_event_for_dups() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Offences(crate::Event::Offence { + event: RuntimeEvent::Offences(crate::PalletEvent::Offence { kind: KIND, timeslot: time_slot.encode() }), diff --git a/frame/preimage/src/lib.rs b/frame/preimage/src/lib.rs index e4616078b0761..ac68b54048db5 100644 --- a/frame/preimage/src/lib.rs +++ b/frame/preimage/src/lib.rs @@ -76,7 +76,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Weight information for this pallet. type WeightInfo: weights::WeightInfo; @@ -104,7 +104,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A preimage has been noted. Noted { hash: T::Hash }, /// A preimage has been requested. @@ -233,7 +233,7 @@ impl Pallet { }; PreimageFor::::insert(hash, preimage); - Self::deposit_event(Event::Noted { hash }); + Self::deposit_event(PalletEvent::Noted { hash }); Ok(was_requested) } @@ -257,7 +257,7 @@ impl Pallet { }); StatusFor::::insert(hash, RequestStatus::Requested(count)); if count == 1 { - Self::deposit_event(Event::Requested { hash: *hash }); + Self::deposit_event(PalletEvent::Requested { hash: *hash }); } } @@ -281,7 +281,7 @@ impl Pallet { } StatusFor::::remove(hash); PreimageFor::::remove(hash); - Self::deposit_event(Event::Cleared { hash: *hash }); + Self::deposit_event(PalletEvent::Cleared { hash: *hash }); Ok(()) } @@ -296,7 +296,7 @@ impl Pallet { debug_assert!(count == 1, "preimage request counter at zero?"); PreimageFor::::remove(hash); StatusFor::::remove(hash); - Self::deposit_event(Event::Cleared { hash: *hash }); + Self::deposit_event(PalletEvent::Cleared { hash: *hash }); }, RequestStatus::Unrequested(_) => return Err(Error::::NotRequested.into()), } diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index c760a8a713b55..8b6b4baa72ac4 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -86,7 +86,7 @@ benchmarks! { let call: ::Call = frame_system::Call::::remark { remark: vec![] }.into(); }: _(RawOrigin::Signed(caller), real, Some(T::ProxyType::default()), Box::new(call)) verify { - assert_last_event::(Event::ProxyExecuted { result: Ok(()) }.into()) + assert_last_event::(PalletEvent::ProxyExecuted { result: Ok(()) }.into()) } proxy_announced { @@ -107,7 +107,7 @@ benchmarks! { add_announcements::(a, Some(delegate.clone()), None)?; }: _(RawOrigin::Signed(caller), delegate, real, Some(T::ProxyType::default()), Box::new(call)) verify { - assert_last_event::(Event::ProxyExecuted { result: Ok(()) }.into()) + assert_last_event::(PalletEvent::ProxyExecuted { result: Ok(()) }.into()) } remove_announcement { @@ -165,7 +165,7 @@ benchmarks! { let call_hash = T::CallHasher::hash_of(&call); }: _(RawOrigin::Signed(caller.clone()), real.clone(), call_hash) verify { - assert_last_event::(Event::Announced { real, proxy: caller, call_hash }.into()); + assert_last_event::(PalletEvent::Announced { real, proxy: caller, call_hash }.into()); } add_proxy { @@ -216,7 +216,7 @@ benchmarks! { ) verify { let anon_account = Pallet::::anonymous_account(&caller, &T::ProxyType::default(), 0, None); - assert_last_event::(Event::AnonymousCreated { + assert_last_event::(PalletEvent::AnonymousCreated { anonymous: anon_account, who: caller, proxy_type: T::ProxyType::default(), diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index bfcc8a48c8056..9e2489e3347ed 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -108,7 +108,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter @@ -326,7 +326,7 @@ pub mod pallet { T::Currency::reserve(&who, deposit)?; Proxies::::insert(&anonymous, (bounded_proxies, deposit)); - Self::deposit_event(Event::AnonymousCreated { + Self::deposit_event(PalletEvent::AnonymousCreated { anonymous, who, proxy_type, @@ -431,7 +431,7 @@ pub mod pallet { }) .map(|d| *deposit = d) })?; - Self::deposit_event(Event::Announced { real, proxy: who, call_hash }); + Self::deposit_event(PalletEvent::Announced { real, proxy: who, call_hash }); Ok(()) } @@ -552,7 +552,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A proxy was executed correctly, with the given. ProxyExecuted { result: DispatchResult }, /// Anonymous account has been created by new proxy with given @@ -691,7 +691,7 @@ impl Pallet { T::Currency::unreserve(delegator, *deposit - new_deposit); } *deposit = new_deposit; - Self::deposit_event(Event::::ProxyAdded { + Self::deposit_event(PalletEvent::::ProxyAdded { delegator: delegator.clone(), delegatee, proxy_type, @@ -733,7 +733,7 @@ impl Pallet { if !proxies.is_empty() { *x = Some((proxies, new_deposit)) } - Self::deposit_event(Event::::ProxyRemoved { + Self::deposit_event(PalletEvent::::ProxyRemoved { delegator: delegator.clone(), delegatee, proxy_type, @@ -829,6 +829,6 @@ impl Pallet { } }); let e = call.dispatch(origin); - Self::deposit_event(Event::ProxyExecuted { result: e.map(|_| ()).map_err(|e| e.error) }); + Self::deposit_event(PalletEvent::ProxyExecuted { result: e.map(|_| ()).map_err(|e| e.error) }); } } diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 37ff624cb6721..590da9a5fb857 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -48,7 +48,7 @@ frame_support::construct_runtime!( System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Proxy: proxy::{Pallet, Call, Storage, Event}, - Utility: pallet_utility::{Pallet, Call, Event}, + Utility: pallet_utility::{Pallet, Call, PalletEvent}, } ); @@ -164,10 +164,10 @@ impl Config for Test { type AnnouncementDepositFactor = ConstU64<1>; } -use super::{Call as ProxyCall, Event as ProxyEvent}; +use super::{Call as ProxyCall, PalletEvent as ProxyEvent}; use frame_system::Call as SystemCall; -use pallet_balances::{Call as BalancesCall, Error as BalancesError, Event as BalancesEvent}; -use pallet_utility::{Call as UtilityCall, Event as UtilityEvent}; +use pallet_balances::{Call as BalancesCall, Error as BalancesError, PalletEvent as BalancesEvent}; +use pallet_utility::{Call as UtilityCall, PalletEvent as UtilityEvent}; type SystemError = frame_system::Error; diff --git a/frame/ranked-collective/src/benchmarking.rs b/frame/ranked-collective/src/benchmarking.rs index 1ba9344aa3be7..59b1dfceb3031 100644 --- a/frame/ranked-collective/src/benchmarking.rs +++ b/frame/ranked-collective/src/benchmarking.rs @@ -51,7 +51,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert_eq!(MemberCount::::get(0), 1); - assert_last_event::(Event::MemberAdded { who }.into()); + assert_last_event::(PalletEvent::MemberAdded { who }.into()); } remove_member { @@ -69,7 +69,7 @@ benchmarks_instance_pallet! { assert_eq!(MemberCount::::get(r), 2); assert_ne!(last_index[r as usize], IdToIndex::::get(r, &last).unwrap()); } - assert_last_event::(Event::MemberRemoved { who, rank }.into()); + assert_last_event::(PalletEvent::MemberRemoved { who, rank }.into()); } promote_member { @@ -81,7 +81,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert_eq!(Members::::get(&who).unwrap().rank, rank + 1); - assert_last_event::(Event::RankChanged { who, rank: rank + 1 }.into()); + assert_last_event::(PalletEvent::RankChanged { who, rank: rank + 1 }.into()); } demote_member { @@ -99,8 +99,8 @@ benchmarks_instance_pallet! { assert_eq!(MemberCount::::get(rank), 2); assert_ne!(last_index, IdToIndex::::get(rank, &last).unwrap()); assert_last_event::(match rank { - 0 => Event::MemberRemoved { who, rank: 0 }, - r => Event::RankChanged { who, rank: r - 1 }, + 0 => PalletEvent::MemberRemoved { who, rank: 0 }, + r => PalletEvent::RankChanged { who, rank: r - 1 }, }.into()); } @@ -124,7 +124,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller.clone()), poll, false) verify { let tally = Tally::from_parts(0, 0, 1); - let ev = Event::Voted { who: caller, poll, vote: VoteRecord::Nay(1), tally }; + let ev = PalletEvent::Voted { who: caller, poll, vote: VoteRecord::Nay(1), tally }; assert_last_event::(ev.into()); } diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 3339fdab20a47..1b8d9e5f004a2 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -305,7 +305,7 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The outer event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The origin required to add or promote a mmember. The success value indicates the @@ -370,7 +370,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// A member `who` has been added. MemberAdded { who: T::AccountId }, /// The member `who`'s rank has been changed to the given `rank`. @@ -424,7 +424,7 @@ pub mod pallet { IdToIndex::::insert(0, &who, index); IndexToId::::insert(0, index, &who); MemberCount::::insert(0, count); - Self::deposit_event(Event::MemberAdded { who }); + Self::deposit_event(PalletEvent::MemberAdded { who }); Ok(()) } @@ -446,7 +446,7 @@ pub mod pallet { IdToIndex::::insert(rank, &who, index); IndexToId::::insert(rank, index, &who); Members::::insert(&who, MemberRecord { rank }); - Self::deposit_event(Event::RankChanged { who, rank }); + Self::deposit_event(PalletEvent::RankChanged { who, rank }); Ok(()) } @@ -470,12 +470,12 @@ pub mod pallet { match maybe_rank { None => { Members::::remove(&who); - Self::deposit_event(Event::MemberRemoved { who, rank: 0 }); + Self::deposit_event(PalletEvent::MemberRemoved { who, rank: 0 }); }, Some(rank) => { record.rank = rank; Members::::insert(&who, &record); - Self::deposit_event(Event::RankChanged { who, rank }); + Self::deposit_event(PalletEvent::RankChanged { who, rank }); }, } Ok(()) @@ -503,7 +503,7 @@ pub mod pallet { Self::remove_from_rank(&who, r)?; } Members::::remove(&who); - Self::deposit_event(Event::MemberRemoved { who, rank }); + Self::deposit_event(PalletEvent::MemberRemoved { who, rank }); Ok(PostDispatchInfo { actual_weight: Some(T::WeightInfo::remove_member(rank as u32)), pays_fee: Pays::Yes, @@ -563,7 +563,7 @@ pub mod pallet { } }, )?; - Self::deposit_event(Event::Voted { who, poll, vote, tally }); + Self::deposit_event(PalletEvent::Voted { who, poll, vote, tally }); Ok(pays.into()) } diff --git a/frame/recovery/src/benchmarking.rs b/frame/recovery/src/benchmarking.rs index 5edc851641080..d826fbd37dfa7 100644 --- a/frame/recovery/src/benchmarking.rs +++ b/frame/recovery/src/benchmarking.rs @@ -124,7 +124,7 @@ benchmarks! { rescuer.clone() ) verify { assert_last_event::( - Event::AccountRecovered { + PalletEvent::AccountRecovered { lost_account: lost, rescuer_account: rescuer, }.into() @@ -145,7 +145,7 @@ benchmarks! { n as u16, DEFAULT_DELAY.into() ) verify { - assert_last_event::(Event::RecoveryCreated { account: caller }.into()); + assert_last_event::(PalletEvent::RecoveryCreated { account: caller }.into()); } initiate_recovery { @@ -160,7 +160,7 @@ benchmarks! { lost_account.clone() ) verify { assert_last_event::( - Event::RecoveryInitiated { + PalletEvent::RecoveryInitiated { lost_account: lost_account, rescuer_account: caller, }.into() @@ -210,7 +210,7 @@ benchmarks! { rescuer_account.clone() ) verify { assert_last_event::( - Event::RecoveryVouched { + PalletEvent::RecoveryVouched { lost_account: lost_account, rescuer_account: rescuer_account, sender: caller, @@ -260,7 +260,7 @@ benchmarks! { lost_account.clone() ) verify { assert_last_event::( - Event::AccountRecovered { + PalletEvent::AccountRecovered { lost_account: lost_account, rescuer_account: caller, }.into() @@ -310,7 +310,7 @@ benchmarks! { rescuer_account.clone() ) verify { assert_last_event::( - Event::RecoveryClosed { + PalletEvent::RecoveryClosed { lost_account: caller, rescuer_account: rescuer_account, }.into() @@ -347,7 +347,7 @@ benchmarks! { RawOrigin::Signed(caller.clone()) ) verify { assert_last_event::( - Event::RecoveryRemoved { + PalletEvent::RecoveryRemoved { lost_account: caller }.into() ); diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index 21f86d713c8d1..7586778fc47f8 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -225,7 +225,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -277,7 +277,7 @@ pub mod pallet { /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A recovery process has been set up for an account. RecoveryCreated { account: T::AccountId }, /// A recovery process has been initiated for lost account by rescuer account. @@ -411,7 +411,7 @@ pub mod pallet { ensure_root(origin)?; // Create the recovery storage item. >::insert(&rescuer, &lost); - Self::deposit_event(Event::::AccountRecovered { + Self::deposit_event(PalletEvent::::AccountRecovered { lost_account: lost, rescuer_account: rescuer, }); @@ -470,7 +470,7 @@ pub mod pallet { // Create the recovery configuration storage item >::insert(&who, recovery_config); - Self::deposit_event(Event::::RecoveryCreated { account: who }); + Self::deposit_event(PalletEvent::::RecoveryCreated { account: who }); Ok(()) } @@ -506,7 +506,7 @@ pub mod pallet { }; // Create the active recovery storage item >::insert(&account, &who, recovery_status); - Self::deposit_event(Event::::RecoveryInitiated { + Self::deposit_event(PalletEvent::::RecoveryInitiated { lost_account: account, rescuer_account: who, }); @@ -549,7 +549,7 @@ pub mod pallet { } // Update storage with the latest details >::insert(&lost, &rescuer, active_recovery); - Self::deposit_event(Event::::RecoveryVouched { + Self::deposit_event(PalletEvent::::RecoveryVouched { lost_account: lost, rescuer_account: rescuer, sender: who, @@ -591,7 +591,7 @@ pub mod pallet { frame_system::Pallet::::inc_consumers(&who).map_err(|_| Error::::BadState)?; // Create the recovery storage item Proxy::::insert(&who, &account); - Self::deposit_event(Event::::AccountRecovered { + Self::deposit_event(PalletEvent::::AccountRecovered { lost_account: account, rescuer_account: who, }); @@ -624,7 +624,7 @@ pub mod pallet { BalanceStatus::Free, ); debug_assert!(res.is_ok()); - Self::deposit_event(Event::::RecoveryClosed { + Self::deposit_event(PalletEvent::::RecoveryClosed { lost_account: who, rescuer_account: rescuer, }); @@ -653,7 +653,7 @@ pub mod pallet { // Unreserve the initial deposit for the recovery configuration. T::Currency::unreserve(&who, recovery_config.deposit); - Self::deposit_event(Event::::RecoveryRemoved { lost_account: who }); + Self::deposit_event(PalletEvent::::RecoveryRemoved { lost_account: who }); Ok(()) } diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index ae446f0c7ab21..8b8acf49d1ec5 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -124,7 +124,7 @@ pub mod pallet { pub trait Config: frame_system::Config + Sized { // System level stuff. type Call: Parameter + Dispatchable + From>; - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -220,7 +220,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// A referendum has being submitted. Submitted { /// Index of the referendum. @@ -387,7 +387,7 @@ pub mod pallet { }; ReferendumInfoFor::::insert(index, ReferendumInfo::Ongoing(status)); - Self::deposit_event(Event::::Submitted { index, track, proposal_hash }); + Self::deposit_event(PalletEvent::::Submitted { index, track, proposal_hash }); Ok(()) } @@ -414,7 +414,7 @@ pub mod pallet { let (info, _, branch) = Self::service_referendum(now, index, status); ReferendumInfoFor::::insert(index, info); let e = - Event::::DecisionDepositPlaced { index, who, amount: track.decision_deposit }; + PalletEvent::::DecisionDepositPlaced { index, who, amount: track.decision_deposit }; Self::deposit_event(e); Ok(branch.weight_of_deposit::().into()) } @@ -440,7 +440,7 @@ pub mod pallet { .ok_or(Error::::NoDeposit)?; Self::refund_deposit(Some(deposit.clone())); ReferendumInfoFor::::insert(index, info); - let e = Event::::DecisionDepositRefunded { + let e = PalletEvent::::DecisionDepositRefunded { index, who: deposit.who, amount: deposit.amount, @@ -463,7 +463,7 @@ pub mod pallet { let _ = T::Scheduler::cancel(last_alarm); } Self::note_one_fewer_deciding(status.track); - Self::deposit_event(Event::::Cancelled { index, tally: status.tally }); + Self::deposit_event(PalletEvent::::Cancelled { index, tally: status.tally }); let info = ReferendumInfo::Cancelled( frame_system::Pallet::::block_number(), status.submission_deposit, @@ -487,7 +487,7 @@ pub mod pallet { let _ = T::Scheduler::cancel(last_alarm); } Self::note_one_fewer_deciding(status.track); - Self::deposit_event(Event::::Killed { index, tally: status.tally }); + Self::deposit_event(PalletEvent::::Killed { index, tally: status.tally }); Self::slash_deposit(Some(status.submission_deposit.clone())); Self::slash_deposit(status.decision_deposit.clone()); let info = ReferendumInfo::Killed(frame_system::Pallet::::block_number()); @@ -740,14 +740,14 @@ impl, I: 'static> Pallet { status.track, ); status.in_queue = false; - Self::deposit_event(Event::::DecisionStarted { + Self::deposit_event(PalletEvent::::DecisionStarted { index, tally: status.tally.clone(), proposal_hash: status.proposal_hash, track: status.track, }); let confirming = if is_passing { - Self::deposit_event(Event::::ConfirmStarted { index }); + Self::deposit_event(PalletEvent::::ConfirmStarted { index }); Some(now.saturating_add(track.confirm_period)) } else { None @@ -926,7 +926,7 @@ impl, I: 'static> Pallet { if status.deciding.is_none() && now >= timeout { // Too long without being decided - end it. Self::ensure_no_alarm(&mut status); - Self::deposit_event(Event::::TimedOut { index, tally: status.tally }); + Self::deposit_event(PalletEvent::::TimedOut { index, tally: status.tally }); return ( ReferendumInfo::TimedOut( now, @@ -961,7 +961,7 @@ impl, I: 'static> Pallet { status.origin, call_hash, ); - Self::deposit_event(Event::::Confirmed { + Self::deposit_event(PalletEvent::::Confirmed { index, tally: status.tally, }); @@ -980,7 +980,7 @@ impl, I: 'static> Pallet { // Start confirming dirty = true; deciding.confirming = Some(now.saturating_add(track.confirm_period)); - Self::deposit_event(Event::::ConfirmStarted { index }); + Self::deposit_event(PalletEvent::::ConfirmStarted { index }); ServiceBranch::BeginConfirming }, } @@ -989,7 +989,7 @@ impl, I: 'static> Pallet { // Failed! Self::ensure_no_alarm(&mut status); Self::note_one_fewer_deciding(status.track); - Self::deposit_event(Event::::Rejected { index, tally: status.tally }); + Self::deposit_event(PalletEvent::::Rejected { index, tally: status.tally }); return ( ReferendumInfo::Rejected( now, @@ -1004,7 +1004,7 @@ impl, I: 'static> Pallet { // Stop confirming dirty = true; deciding.confirming = None; - Self::deposit_event(Event::::ConfirmAborted { index }); + Self::deposit_event(PalletEvent::::ConfirmAborted { index }); ServiceBranch::EndConfirming } else { ServiceBranch::ContinueNotConfirming @@ -1065,7 +1065,7 @@ impl, I: 'static> Pallet { fn slash_deposit(deposit: Option>>) { if let Some(Deposit { who, amount }) = deposit { T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0); - Self::deposit_event(Event::::DepositSlashed { who, amount }); + Self::deposit_event(PalletEvent::::DepositSlashed { who, amount }); } } diff --git a/frame/remark/src/benchmarking.rs b/frame/remark/src/benchmarking.rs index c0db8d5d3d59b..77f2693cd5a86 100644 --- a/frame/remark/src/benchmarking.rs +++ b/frame/remark/src/benchmarking.rs @@ -40,7 +40,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); }: _(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize]) verify { - assert_last_event::(Event::Stored { sender: caller, content_hash: sp_io::hashing::blake2_256(&vec![0u8; l as usize]).into() }.into()); + assert_last_event::(PalletEvent::Stored { sender: caller, content_hash: sp_io::hashing::blake2_256(&vec![0u8; l as usize]).into() }.into()); } impl_benchmark_test_suite!(Remark, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/frame/remark/src/lib.rs b/frame/remark/src/lib.rs index b61c79f7f273d..4aa587ccb6743 100644 --- a/frame/remark/src/lib.rs +++ b/frame/remark/src/lib.rs @@ -43,7 +43,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; } @@ -70,14 +70,14 @@ pub mod pallet { let extrinsic_index = >::extrinsic_index() .ok_or_else(|| Error::::BadContext)?; sp_io::transaction_index::index(extrinsic_index, remark.len() as u32, content_hash); - Self::deposit_event(Event::Stored { sender, content_hash: content_hash.into() }); + Self::deposit_event(PalletEvent::Stored { sender, content_hash: content_hash.into() }); Ok(().into()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Stored data off chain. Stored { sender: T::AccountId, content_hash: sp_core::H256 }, } diff --git a/frame/remark/src/tests.rs b/frame/remark/src/tests.rs index 6e297524844ee..cf0225a9bae6f 100644 --- a/frame/remark/src/tests.rs +++ b/frame/remark/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for remarks pallet. -use super::{Error, Event, Pallet as Remark}; +use super::{Error, PalletEvent, Pallet as Remark}; use crate::mock::*; use frame_support::{assert_noop, assert_ok}; use frame_system::RawOrigin; @@ -31,7 +31,7 @@ fn generates_event() { assert_ok!(Remark::::store(RawOrigin::Signed(caller.clone()).into(), data.clone(),)); let events = System::events(); // this one we create as we expect it - let system_event: ::RuntimeEvent = Event::Stored { + let system_event: ::RuntimeEvent = PalletEvent::Stored { content_hash: sp_io::hashing::blake2_256(&data).into(), sender: caller, } diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index b46df64d7608d..e4b6f1b1e1d6c 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -198,7 +198,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The aggregated origin which the dispatch will take. type Origin: OriginTrait @@ -259,7 +259,7 @@ pub mod pallet { /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Scheduled some task. Scheduled { when: T::BlockNumber, index: u32 }, /// Canceled some task. @@ -393,7 +393,7 @@ pub mod pallet { total_weight.saturating_accrue(item_weight); total_weight.saturating_accrue(actual_call_weight); - Self::deposit_event(Event::Dispatched { + Self::deposit_event(PalletEvent::Dispatched { task: (now, index), id: s.maybe_id.clone(), result, @@ -696,7 +696,7 @@ impl Pallet { }); Agenda::::append(when, s); let index = Agenda::::decode_len(when).unwrap_or(1) as u32 - 1; - Self::deposit_event(Event::Scheduled { when, index }); + Self::deposit_event(PalletEvent::Scheduled { when, index }); Ok((when, index)) } @@ -726,7 +726,7 @@ impl Pallet { if let Some(id) = s.maybe_id { Lookup::::remove(id); } - Self::deposit_event(Event::Canceled { when, index }); + Self::deposit_event(PalletEvent::Canceled { when, index }); Ok(()) } else { return Err(Error::::NotFound.into()) @@ -751,8 +751,8 @@ impl Pallet { })?; let new_index = Agenda::::decode_len(new_time).unwrap_or(1) as u32 - 1; - Self::deposit_event(Event::Canceled { when, index }); - Self::deposit_event(Event::Scheduled { when: new_time, index: new_index }); + Self::deposit_event(PalletEvent::Canceled { when, index }); + Self::deposit_event(PalletEvent::Scheduled { when: new_time, index: new_index }); Ok((new_time, new_index)) } @@ -792,7 +792,7 @@ impl Pallet { let index = Agenda::::decode_len(when).unwrap_or(1) as u32 - 1; let address = (when, index); Lookup::::insert(&id, &address); - Self::deposit_event(Event::Scheduled { when, index }); + Self::deposit_event(PalletEvent::Scheduled { when, index }); Ok(address) } @@ -816,7 +816,7 @@ impl Pallet { } Ok(()) })?; - Self::deposit_event(Event::Canceled { when, index }); + Self::deposit_event(PalletEvent::Canceled { when, index }); Ok(()) } else { return Err(Error::::NotFound.into()) @@ -848,8 +848,8 @@ impl Pallet { })?; let new_index = Agenda::::decode_len(new_time).unwrap_or(1) as u32 - 1; - Self::deposit_event(Event::Canceled { when, index }); - Self::deposit_event(Event::Scheduled { when: new_time, index: new_index }); + Self::deposit_event(PalletEvent::Canceled { when, index }); + Self::deposit_event(PalletEvent::Scheduled { when: new_time, index: new_index }); *lookup = Some((new_time, new_index)); diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index b97c8eeb385b7..9d91adaa6daca 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -59,12 +59,12 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { Logged(u32, Weight), } @@ -75,7 +75,7 @@ pub mod logger { { #[pallet::weight(*weight)] pub fn log(origin: OriginFor, i: u32, weight: Weight) -> DispatchResult { - Self::deposit_event(Event::Logged(i, weight)); + Self::deposit_event(PalletEvent::Logged(i, weight)); LOG.with(|log| { log.borrow_mut().push((origin.caller().clone(), i)); }); @@ -84,7 +84,7 @@ pub mod logger { #[pallet::weight(*weight)] pub fn log_without_filter(origin: OriginFor, i: u32, weight: Weight) -> DispatchResult { - Self::deposit_event(Event::Logged(i, weight)); + Self::deposit_event(PalletEvent::Logged(i, weight)); LOG.with(|log| { log.borrow_mut().push((origin.caller().clone(), i)); }); diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index 65835cf967617..36a41bea593da 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -148,7 +148,7 @@ pub mod pallet { + scale_info::TypeInfo; /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; // The deposit which is reserved from candidates if they want to @@ -183,7 +183,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// The given member was removed. See the transaction for who. MemberRemoved, /// An entity has issued a candidacy. See the transaction for who. @@ -312,7 +312,7 @@ pub mod pallet { >::insert(&who, true); - Self::deposit_event(Event::::CandidateAdded); + Self::deposit_event(PalletEvent::::CandidateAdded); Ok(()) } @@ -334,7 +334,7 @@ pub mod pallet { Self::ensure_index(&pool, &who, index)?; Self::remove_member(pool, who, index)?; - Self::deposit_event(Event::::CandidateWithdrew); + Self::deposit_event(PalletEvent::::CandidateWithdrew); Ok(()) } @@ -358,7 +358,7 @@ pub mod pallet { Self::ensure_index(&pool, &who, index)?; Self::remove_member(pool, who, index)?; - Self::deposit_event(Event::::CandidateKicked); + Self::deposit_event(PalletEvent::::CandidateKicked); Ok(()) } @@ -397,7 +397,7 @@ pub mod pallet { pool.insert(location, item); >::put(&pool); - Self::deposit_event(Event::::CandidateScored); + Self::deposit_event(PalletEvent::::CandidateScored); Ok(()) } @@ -472,7 +472,7 @@ impl, I: 'static> Pallet { T::Currency::unreserve(&remove, T::CandidateDeposit::get()); - Self::deposit_event(Event::::MemberRemoved); + Self::deposit_event(PalletEvent::::MemberRemoved); Ok(()) } diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 6094a43d00c5b..901588de29cee 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -43,7 +43,7 @@ frame_support::construct_runtime!( System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, } ); diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 7d568719477b7..31d60ea57d3e9 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -379,7 +379,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// A stable ID for a validator. type ValidatorId: Member @@ -541,7 +541,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// New session has happened. Note that the argument is the session index, not the /// block number as the type might suggest. NewSession { session_index: SessionIndex }, @@ -708,7 +708,7 @@ impl Pallet { >::put(next_changed); // Record that this happened. - Self::deposit_event(Event::NewSession { session_index }); + Self::deposit_event(PalletEvent::NewSession { session_index }); // Tell everyone about the new session keys. T::SessionHandler::on_new_session::(changed, &session_keys, &queued_amalgamated); diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 587d646158524..4b22e117cb3af 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -86,7 +86,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, Historical: pallet_session_historical::{Pallet}, } ); @@ -99,7 +99,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, } ); diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 22460cbab14ec..cb47f4a893f00 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -377,7 +377,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The societies's pallet id @@ -476,7 +476,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// 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 @@ -726,7 +726,7 @@ pub mod pallet { T::Currency::reserve(&who, deposit)?; Self::put_bid(bids, &who, value, BidKind::Deposit(deposit)); - Self::deposit_event(Event::::Bid { candidate_id: who, offer: value }); + Self::deposit_event(PalletEvent::::Bid { candidate_id: who, offer: value }); Ok(()) } @@ -768,7 +768,7 @@ pub mod pallet { >::remove(&voucher); }, } - Self::deposit_event(Event::::Unbid { candidate: who }); + Self::deposit_event(PalletEvent::::Unbid { candidate: who }); Ok(()) } else { Err(Error::::BadPosition.into()) @@ -846,7 +846,7 @@ pub mod pallet { >::insert(&voucher, VouchingStatus::Vouching); Self::put_bid(bids, &who, value, BidKind::Vouch(voucher.clone(), tip)); - Self::deposit_event(Event::::Vouch { + Self::deposit_event(PalletEvent::::Vouch { candidate_id: who, offer: value, vouching: voucher, @@ -885,7 +885,7 @@ pub mod pallet { b[pos].kind.check_voucher(&voucher)?; >::remove(&voucher); let who = b.remove(pos).who; - Self::deposit_event(Event::::Unvouch { candidate: who }); + Self::deposit_event(PalletEvent::::Unvouch { candidate: who }); Ok(()) } else { Err(Error::::BadPosition.into()) @@ -928,7 +928,7 @@ pub mod pallet { let vote = if approve { Vote::Approve } else { Vote::Reject }; >::insert(&candidate, &voter, vote); - Self::deposit_event(Event::::Vote { candidate, voter, vote: approve }); + Self::deposit_event(PalletEvent::::Vote { candidate, voter, vote: approve }); Ok(()) } @@ -957,7 +957,7 @@ pub mod pallet { let vote = if approve { Vote::Approve } else { Vote::Reject }; >::insert(&voter, vote); - Self::deposit_event(Event::::DefenderVote { voter, vote: approve }); + Self::deposit_event(PalletEvent::::DefenderVote { voter, vote: approve }); Ok(()) } @@ -1040,7 +1040,7 @@ pub mod pallet { >::put(&founder); >::put(&founder); Rules::::put(T::Hashing::hash(&rules)); - Self::deposit_event(Event::::Founded { founder }); + Self::deposit_event(PalletEvent::::Founded { founder }); Ok(()) } @@ -1070,7 +1070,7 @@ pub mod pallet { Candidates::::kill(); #[allow(deprecated)] SuspendedCandidates::::remove_all(None); - Self::deposit_event(Event::::Unfounded { founder }); + Self::deposit_event(PalletEvent::::Unfounded { founder }); Ok(()) } @@ -1127,14 +1127,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::::Unvouch { candidate: vouched }); + Self::deposit_event(PalletEvent::::Unvouch { candidate: vouched }); } ); } } >::remove(&who); - Self::deposit_event(Event::::SuspendedMemberJudgement { who, judged: forgive }); + Self::deposit_event(PalletEvent::::SuspendedMemberJudgement { who, judged: forgive }); Ok(()) } @@ -1255,7 +1255,7 @@ pub mod pallet { ensure_root(origin)?; ensure!(max > 1, Error::::MaxMembers); MaxMembers::::put(max); - Self::deposit_event(Event::::NewMaxMembers { max }); + Self::deposit_event(PalletEvent::::NewMaxMembers { max }); Ok(()) } } @@ -1341,7 +1341,7 @@ impl, I: 'static> Pallet { >::remove(&voucher); }, } - Self::deposit_event(Event::::AutoUnbid { candidate: popped }); + Self::deposit_event(PalletEvent::::AutoUnbid { candidate: popped }); } >::put(bids); @@ -1506,7 +1506,7 @@ impl, I: 'static> Pallet { } else { // Suspend Candidate >::insert(&candidate, (value, kind)); - Self::deposit_event(Event::::CandidateSuspended { candidate }); + Self::deposit_event(PalletEvent::::CandidateSuspended { candidate }); None } }) @@ -1576,7 +1576,7 @@ impl, I: 'static> Pallet { >::put(&primary); T::MembershipChanged::change_members_sorted(&accounts, &[], members); - Self::deposit_event(Event::::Inducted { primary, candidates: accounts }); + Self::deposit_event(PalletEvent::::Inducted { primary, candidates: accounts }); } // Bump the pot by at most PeriodSpend, but less if there's not very much left in our @@ -1641,7 +1641,7 @@ impl, I: 'static> Pallet { if Self::remove_member(who).is_ok() { >::insert(who, true); >::remove(who); - Self::deposit_event(Event::::MemberSuspended { member: who.clone() }); + Self::deposit_event(PalletEvent::::MemberSuspended { member: who.clone() }); } } @@ -1718,7 +1718,7 @@ impl, I: 'static> Pallet { let chosen = pick_item(&mut rng, &members[1..members.len() - 1]) .expect("exited if members empty; qed"); >::put(&chosen); - Self::deposit_event(Event::::Challenged { member: chosen.clone() }); + Self::deposit_event(PalletEvent::::Challenged { member: chosen.clone() }); } else { >::kill(); } @@ -1822,6 +1822,6 @@ impl, I: 'static> OnUnbalanced> 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 { value: numeric_amount }); + Self::deposit_event(PalletEvent::::Deposit { value: numeric_amount }); } } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index ab0ab685e6911..306e6b31fc9f6 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -932,7 +932,7 @@ where if bonded_eras.first().filter(|(_, start)| offence_session >= *start).is_some() { R::report_offence(reporters, offence) } else { - >::deposit_event(Event::::OldSlashingReportDiscarded(offence_session)); + >::deposit_event(PalletEvent::::OldSlashingReportDiscarded(offence_session)); Ok(()) } } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index ee3a0c18942ed..054ba81e0a1f0 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -98,7 +98,7 @@ frame_support::construct_runtime!( Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, Historical: pallet_session::historical::{Pallet, Storage}, BagsList: pallet_bags_list::{Pallet, Call, Storage, Event}, } @@ -868,7 +868,7 @@ macro_rules! assert_session_era { }; } -pub(crate) fn staking_events() -> Vec> { +pub(crate) fn staking_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) @@ -880,7 +880,7 @@ parameter_types! { static StakingEventsIndex: usize = 0; } -pub(crate) fn staking_events_since_last_call() -> Vec> { +pub(crate) fn staking_events_since_last_call() -> Vec> { let all: Vec<_> = System::events() .into_iter() .filter_map(|r| if let RuntimeEvent::Staking(inner) = r.event { Some(inner) } else { None }) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 68aa97db8a324..9f5397fa8b281 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -173,14 +173,14 @@ impl Pallet { let validator_exposure_part = Perbill::from_rational(exposure.own, exposure.total); let validator_staking_payout = validator_exposure_part * validator_leftover_payout; - Self::deposit_event(Event::::PayoutStarted(era, ledger.stash.clone())); + Self::deposit_event(PalletEvent::::PayoutStarted(era, ledger.stash.clone())); let mut total_imbalance = PositiveImbalanceOf::::zero(); // We can now make total validator payout: if let Some(imbalance) = Self::make_payout(&ledger.stash, validator_staking_payout + validator_commission_payout) { - Self::deposit_event(Event::::Rewarded(ledger.stash, imbalance.peek())); + Self::deposit_event(PalletEvent::::Rewarded(ledger.stash, imbalance.peek())); total_imbalance.subsume(imbalance); } @@ -200,7 +200,7 @@ impl Pallet { if let Some(imbalance) = Self::make_payout(&nominator.who, nominator_reward) { // Note: this logic does not count payouts for `RewardDestination::None`. nominator_payout_count += 1; - let e = Event::::Rewarded(nominator.who.clone(), imbalance.peek()); + let e = PalletEvent::::Rewarded(nominator.who.clone(), imbalance.peek()); Self::deposit_event(e); total_imbalance.subsume(imbalance); } @@ -224,7 +224,7 @@ impl Pallet { let chilled_as_validator = Self::do_remove_validator(stash); let chilled_as_nominator = Self::do_remove_nominator(stash); if chilled_as_validator || chilled_as_nominator { - Self::deposit_event(Event::::Chilled(stash.clone())); + Self::deposit_event(PalletEvent::::Chilled(stash.clone())); } } @@ -385,7 +385,7 @@ impl Pallet { let issuance = T::Currency::total_issuance(); let (validator_payout, rest) = T::EraPayout::era_payout(staked, issuance, era_duration); - Self::deposit_event(Event::::EraPaid(active_era.index, validator_payout, rest)); + Self::deposit_event(PalletEvent::::EraPaid(active_era.index, validator_payout, rest)); // Set ending era reward. >::insert(&active_era.index, validator_payout); @@ -437,12 +437,12 @@ impl Pallet { let election_result = if is_genesis { T::GenesisElectionProvider::elect().map_err(|e| { log!(warn, "genesis election provider failed due to {:?}", e); - Self::deposit_event(Event::StakingElectionFailed); + Self::deposit_event(PalletEvent::StakingElectionFailed); }) } else { T::ElectionProvider::elect().map_err(|e| { log!(warn, "election provider failed due to {:?}", e); - Self::deposit_event(Event::StakingElectionFailed); + Self::deposit_event(PalletEvent::StakingElectionFailed); }) } .ok()?; @@ -470,11 +470,11 @@ impl Pallet { _ => (), } - Self::deposit_event(Event::StakingElectionFailed); + Self::deposit_event(PalletEvent::StakingElectionFailed); return None } - Self::deposit_event(Event::StakersElected); + Self::deposit_event(PalletEvent::StakersElected); Some(Self::trigger_new_era(start_session_index, exposures)) } diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index b6a5ec82b4e11..1a48bab1f9a7e 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -129,7 +129,7 @@ pub mod pallet { type RewardRemainder: OnUnbalanced>; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for the unbalanced reduction when slashing a staker. type Slash: OnUnbalanced>; @@ -609,7 +609,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// The era payout has been set; the first balance is the validator-payout; the second is /// the remainder from the maximum amount of reward. /// \[era_index, validator_payout, remainder\] @@ -802,7 +802,7 @@ pub mod pallet { let stash_balance = T::Currency::free_balance(&stash); let value = value.min(stash_balance); - Self::deposit_event(Event::::Bonded(stash.clone(), value)); + Self::deposit_event(PalletEvent::::Bonded(stash.clone(), value)); let item = StakingLedger { stash, total: value, @@ -859,7 +859,7 @@ pub mod pallet { debug_assert_eq!(T::VoterList::sanity_check(), Ok(())); } - Self::deposit_event(Event::::Bonded(stash, extra)); + Self::deposit_event(PalletEvent::::Bonded(stash, extra)); } Ok(()) } @@ -942,7 +942,7 @@ pub mod pallet { .defensive(); } - Self::deposit_event(Event::::Unbonded(ledger.stash, value)); + Self::deposit_event(PalletEvent::::Unbonded(ledger.stash, value)); } Ok(()) } @@ -998,7 +998,7 @@ pub mod pallet { if ledger.total < old_total { // Already checked that this won't overflow by entry condition. let value = old_total - ledger.total; - Self::deposit_event(Event::::Withdrawn(stash, value)); + Self::deposit_event(PalletEvent::::Withdrawn(stash, value)); } Ok(post_info_weight.into()) @@ -1036,7 +1036,7 @@ pub mod pallet { Self::do_remove_nominator(stash); Self::do_add_validator(stash, prefs.clone()); - Self::deposit_event(Event::::ValidatorPrefsSet(ledger.stash, prefs)); + Self::deposit_event(PalletEvent::::ValidatorPrefsSet(ledger.stash, prefs)); Ok(()) } @@ -1419,7 +1419,7 @@ pub mod pallet { // Last check: the new active amount of ledger must be more than ED. ensure!(ledger.active >= T::Currency::minimum_balance(), Error::::InsufficientBond); - Self::deposit_event(Event::::Bonded(ledger.stash.clone(), rebonded_value)); + Self::deposit_event(PalletEvent::::Bonded(ledger.stash.clone(), rebonded_value)); // NOTE: ledger must be updated prior to calling `Self::weight_of`. Self::update_ledger(&controller, &ledger); @@ -1539,7 +1539,7 @@ pub mod pallet { if let Some(ref mut nom) = maybe_nom { if let Some(pos) = nom.targets.iter().position(|v| v == stash) { nom.targets.swap_remove(pos); - Self::deposit_event(Event::::Kicked( + Self::deposit_event(PalletEvent::::Kicked( nom_stash.clone(), stash.clone(), )); diff --git a/frame/staking/src/slashing.rs b/frame/staking/src/slashing.rs index 7372c4390f816..d8c3213a3b18b 100644 --- a/frame/staking/src/slashing.rs +++ b/frame/staking/src/slashing.rs @@ -626,7 +626,7 @@ pub fn do_slash( >::update_ledger(&controller, &ledger); // trigger the event - >::deposit_event(super::Event::::Slashed(stash.clone(), value)); + >::deposit_event(super::PalletEvent::::Slashed(stash.clone(), value)); } } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index a5e16ccd35421..3812c911b9e48 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for the module. -use super::{ConfigOp, Event, MaxUnlockingChunks, *}; +use super::{ConfigOp, PalletEvent, MaxUnlockingChunks, *}; use frame_election_provider_support::{ElectionProvider, SortedListProvider, Support}; use frame_support::{ assert_noop, assert_ok, assert_storage_noop, bounded_vec, @@ -307,7 +307,7 @@ fn rewards_should_work() { ); assert_eq!( *mock::staking_events().last().unwrap(), - Event::EraPaid(0, total_payout_0, maximum_payout - total_payout_0) + PalletEvent::EraPaid(0, total_payout_0, maximum_payout - total_payout_0) ); mock::make_all_reward_payment(0); @@ -345,7 +345,7 @@ fn rewards_should_work() { ); assert_eq!( *mock::staking_events().last().unwrap(), - Event::EraPaid(1, total_payout_1, maximum_payout - total_payout_1) + PalletEvent::EraPaid(1, total_payout_1, maximum_payout - total_payout_1) ); mock::make_all_reward_payment(1); @@ -517,7 +517,7 @@ fn no_candidate_emergency_condition() { // try trigger new era mock::run_to_block(20); - assert_eq!(*staking_events().last().unwrap(), Event::StakingElectionFailed); + assert_eq!(*staking_events().last().unwrap(), PalletEvent::StakingElectionFailed); // No new era is created assert_eq!(current_era, CurrentEra::::get()); @@ -1613,7 +1613,7 @@ fn rebond_emits_right_value_in_event() { }) ); // Event emitted should be correct - assert_eq!(*staking_events().last().unwrap(), Event::Bonded(11, 100)); + assert_eq!(*staking_events().last().unwrap(), PalletEvent::Bonded(11, 100)); // Re-bond way more than available Staking::rebond(Origin::signed(10), 100_000).unwrap(); @@ -1628,7 +1628,7 @@ fn rebond_emits_right_value_in_event() { }) ); // Event emitted should be correct, only 800 - assert_eq!(*staking_events().last().unwrap(), Event::Bonded(11, 800)); + assert_eq!(*staking_events().last().unwrap(), PalletEvent::Bonded(11, 800)); }); } @@ -2789,10 +2789,10 @@ fn deferred_slashes_are_deferred() { assert_eq!( staking_events_since_last_call(), vec![ - Event::StakersElected, - Event::EraPaid(3, 11075, 33225), - Event::Slashed(11, 100), - Event::Slashed(101, 12) + PalletEvent::StakersElected, + PalletEvent::EraPaid(3, 11075, 33225), + PalletEvent::Slashed(11, 100), + PalletEvent::Slashed(101, 12) ] ); }) @@ -2820,10 +2820,10 @@ fn retroactive_deferred_slashes_two_eras_before() { assert_eq!( staking_events_since_last_call(), vec![ - Event::StakersElected, - Event::EraPaid(3, 7100, 21300), - Event::Slashed(11, 100), - Event::Slashed(101, 12) + PalletEvent::StakersElected, + PalletEvent::EraPaid(3, 7100, 21300), + PalletEvent::Slashed(11, 100), + PalletEvent::Slashed(101, 12) ] ); }) @@ -2854,7 +2854,7 @@ fn retroactive_deferred_slashes_one_before() { mock::start_active_era(4); assert_eq!( staking_events_since_last_call(), - vec![Event::StakersElected, Event::EraPaid(3, 11075, 33225)] + vec![PalletEvent::StakersElected, PalletEvent::EraPaid(3, 11075, 33225)] ); assert_eq!(Staking::ledger(10).unwrap().total, 1000); @@ -2863,10 +2863,10 @@ fn retroactive_deferred_slashes_one_before() { assert_eq!( staking_events_since_last_call(), vec![ - Event::StakersElected, - Event::EraPaid(4, 11075, 33225), - Event::Slashed(11, 100), - Event::Slashed(101, 12) + PalletEvent::StakersElected, + PalletEvent::EraPaid(4, 11075, 33225), + PalletEvent::Slashed(11, 100), + PalletEvent::Slashed(101, 12) ] ); @@ -3007,10 +3007,10 @@ fn remove_deferred() { assert_eq!( staking_events_since_last_call(), vec![ - Event::StakersElected, - Event::EraPaid(3, 11075, 33225), - Event::Slashed(11, 50), - Event::Slashed(101, 7) + PalletEvent::StakersElected, + PalletEvent::EraPaid(3, 11075, 33225), + PalletEvent::Slashed(11, 50), + PalletEvent::Slashed(101, 7) ] ); @@ -4438,7 +4438,7 @@ mod election_data_provider { run_to_block(20); assert_eq!(Staking::next_election_prediction(System::block_number()), 45); assert_eq!(staking_events().len(), 1); - assert_eq!(*staking_events().last().unwrap(), Event::StakersElected); + assert_eq!(*staking_events().last().unwrap(), PalletEvent::StakersElected); for b in 21..45 { run_to_block(b); @@ -4449,7 +4449,7 @@ mod election_data_provider { run_to_block(45); assert_eq!(Staking::next_election_prediction(System::block_number()), 70); assert_eq!(staking_events().len(), 3); - assert_eq!(*staking_events().last().unwrap(), Event::StakersElected); + assert_eq!(*staking_events().last().unwrap(), PalletEvent::StakersElected); Staking::force_no_eras(Origin::root()).unwrap(); assert_eq!(Staking::next_election_prediction(System::block_number()), u64::MAX); @@ -4472,7 +4472,7 @@ mod election_data_provider { run_to_block(55); assert_eq!(Staking::next_election_prediction(System::block_number()), 55 + 25); assert_eq!(staking_events().len(), 6); - assert_eq!(*staking_events().last().unwrap(), Event::StakersElected); + assert_eq!(*staking_events().last().unwrap(), PalletEvent::StakersElected); // The new era has been planned, forcing is changed from `ForceNew` to `NotForcing`. assert_eq!(ForceEra::::get(), Forcing::NotForcing); }) @@ -4806,7 +4806,7 @@ fn min_commission_works() { // event emitted should be correct assert_eq!( *staking_events().last().unwrap(), - Event::ValidatorPrefsSet( + PalletEvent::ValidatorPrefsSet( 11, ValidatorPrefs { commission: Perbill::from_percent(5), blocked: false } ) diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 4f3d7049595e5..707cf65dd8e4e 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -422,7 +422,7 @@ pub mod pallet { /// Inner events of this pallet. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Given number of `(top, child)` keys were migrated respectively, with the given /// `compute`. Migrated { top: u32, child: u32, compute: MigrationCompute }, @@ -449,7 +449,7 @@ pub mod pallet { type SignedFilter: EnsureOrigin; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency provider type. type Currency: Currency; @@ -615,12 +615,12 @@ pub mod pallet { if real_size_upper < task.dyn_size { // let the imbalance burn. let (_imbalance, _remainder) = T::Currency::slash(&who, deposit); - Self::deposit_event(Event::::Slashed { who, amount: deposit }); + Self::deposit_event(PalletEvent::::Slashed { who, amount: deposit }); debug_assert!(_remainder.is_zero()); return Err(Error::::SizeUpperBoundExceeded.into()) } - Self::deposit_event(Event::::Migrated { + Self::deposit_event(PalletEvent::::Migrated { top: task.dyn_top_items, child: task.dyn_child_items, compute: MigrationCompute::Signed, @@ -677,11 +677,11 @@ pub mod pallet { if dyn_size > witness_size { let (_imbalance, _remainder) = T::Currency::slash(&who, deposit); - Self::deposit_event(Event::::Slashed { who, amount: deposit }); + Self::deposit_event(PalletEvent::::Slashed { who, amount: deposit }); debug_assert!(_remainder.is_zero()); Err("wrong witness data".into()) } else { - Self::deposit_event(Event::::Migrated { + Self::deposit_event(PalletEvent::::Migrated { top: keys.len() as u32, child: 0, compute: MigrationCompute::Signed, @@ -740,7 +740,7 @@ pub mod pallet { if dyn_size != total_size { let (_imbalance, _remainder) = T::Currency::slash(&who, deposit); debug_assert!(_remainder.is_zero()); - Self::deposit_event(Event::::Slashed { who, amount: deposit }); + Self::deposit_event(PalletEvent::::Slashed { who, amount: deposit }); Err(DispatchErrorWithPostInfo { error: "bad witness".into(), post_info: PostDispatchInfo { @@ -749,7 +749,7 @@ pub mod pallet { }, }) } else { - Self::deposit_event(Event::::Migrated { + Self::deposit_event(PalletEvent::::Migrated { top: 0, child: child_keys.len() as u32, compute: MigrationCompute::Signed, @@ -819,10 +819,10 @@ pub mod pallet { ); if task.finished() { - Self::deposit_event(Event::::AutoMigrationFinished); + Self::deposit_event(PalletEvent::::AutoMigrationFinished); AutoLimits::::kill(); } else { - Self::deposit_event(Event::::Migrated { + Self::deposit_event(PalletEvent::::Migrated { top: task.dyn_top_items, child: task.dyn_child_items, compute: MigrationCompute::Auto, @@ -852,7 +852,7 @@ pub mod pallet { fn halt(msg: &E) { log!(error, "migration halted due to: {:?}", msg); AutoLimits::::kill(); - Self::deposit_event(Event::::Halted); + Self::deposit_event(PalletEvent::::Halted); } /// Convert a child root key, aka. "Child-bearing top key" into the proper format. @@ -1296,7 +1296,7 @@ mod test { Some(2000000), ); // The auto migration halted. - System::assert_last_event(crate::Event::Halted {}.into()); + System::assert_last_event(crate::PalletEvent::Halted {}.into()); // Limits are killed. assert!(AutoLimits::::get().is_none()); @@ -1333,7 +1333,7 @@ mod test { Some(2000000), ); // The auto migration halted. - System::assert_last_event(crate::Event::Halted {}.into()); + System::assert_last_event(crate::PalletEvent::Halted {}.into()); // Limits are killed. assert!(AutoLimits::::get().is_none()); diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 456cdef8f03b8..a49b1a688a951 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -113,7 +113,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A sudo-able call. type Call: Parameter + UnfilteredDispatchable + GetDispatchInfo; @@ -148,7 +148,7 @@ pub mod pallet { ensure!(Self::key().map_or(false, |k| sender == k), Error::::RequireSudo); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - Self::deposit_event(Event::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) }); + Self::deposit_event(PalletEvent::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) }); // Sudo user does not pay a fee. Ok(Pays::No.into()) } @@ -174,7 +174,7 @@ pub mod pallet { ensure!(Self::key().map_or(false, |k| sender == k), Error::::RequireSudo); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - Self::deposit_event(Event::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) }); + Self::deposit_event(PalletEvent::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) }); // Sudo user does not pay a fee. Ok(Pays::No.into()) } @@ -199,7 +199,7 @@ pub mod pallet { ensure!(Self::key().map_or(false, |k| sender == k), Error::::RequireSudo); let new = T::Lookup::lookup(new)?; - Self::deposit_event(Event::KeyChanged { old_sudoer: Key::::get() }); + Self::deposit_event(PalletEvent::KeyChanged { old_sudoer: Key::::get() }); Key::::put(&new); // Sudo user does not pay a fee. Ok(Pays::No.into()) @@ -239,7 +239,7 @@ pub mod pallet { let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Signed(who).into()); - Self::deposit_event(Event::SudoAsDone { + Self::deposit_event(PalletEvent::SudoAsDone { sudo_result: res.map(|_| ()).map_err(|e| e.error), }); // Sudo user does not pay a fee. @@ -249,7 +249,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A sudo just took place. \[result\] Sudid { sudo_result: DispatchResult }, /// The \[sudoer\] just switched identity; the old key is supplied if one existed. diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 047b07b7bb64b..4ea06c0ac29fc 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -39,7 +39,7 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -58,7 +58,7 @@ pub mod logger { // Ensure that the `origin` is `Root`. ensure_root(origin)?; >::append(i); - Self::deposit_event(Event::AppendI32 { value: i, weight }); + Self::deposit_event(PalletEvent::AppendI32 { value: i, weight }); Ok(().into()) } @@ -72,14 +72,14 @@ pub mod logger { let sender = ensure_signed(origin)?; >::append(i); >::append(sender.clone()); - Self::deposit_event(Event::AppendI32AndAccount { sender, value: i, weight }); + Self::deposit_event(PalletEvent::AppendI32AndAccount { sender, value: i, weight }); Ok(().into()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { AppendI32 { value: i32, weight: Weight }, AppendI32AndAccount { sender: T::AccountId, value: i32, weight: Weight }, } diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index 8175f2ad810b2..ba6b32b670c3a 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 { sudo_result: Ok(()) })); + System::assert_has_event(TestEvent::Sudo(PalletEvent::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 { sudo_result: Ok(()) })); + System::assert_has_event(TestEvent::Sudo(PalletEvent::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 { old_sudoer: Some(1) })); + System::assert_has_event(TestEvent::Sudo(PalletEvent::KeyChanged { old_sudoer: Some(1) })); // Double check. assert_ok!(Sudo::set_key(Origin::signed(2), 4)); - System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { old_sudoer: Some(2) })); + System::assert_has_event(TestEvent::Sudo(PalletEvent::KeyChanged { old_sudoer: Some(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 { sudo_result: Ok(()) })); + System::assert_has_event(TestEvent::Sudo(PalletEvent::SudoAsDone { sudo_result: Ok(()) })); }); } diff --git a/frame/support/procedural/src/construct_runtime/expand/event.rs b/frame/support/procedural/src/construct_runtime/expand/event.rs index 5ab155fe7bf73..7a706d7ab9587 100644 --- a/frame/support/procedural/src/construct_runtime/expand/event.rs +++ b/frame/support/procedural/src/construct_runtime/expand/event.rs @@ -48,10 +48,10 @@ pub fn expand_outer_event( let part_is_generic = !generics.params.is_empty(); let pallet_event = match (instance, part_is_generic) { - (Some(inst), true) => quote!(#path::Event::<#runtime, #path::#inst>), - (Some(inst), false) => quote!(#path::Event::<#path::#inst>), - (None, true) => quote!(#path::Event::<#runtime>), - (None, false) => quote!(#path::Event), + (Some(inst), true) => quote!(#path::PalletEvent::<#runtime, #path::#inst>), + (Some(inst), false) => quote!(#path::PalletEvent::<#path::#inst>), + (None, true) => quote!(#path::PalletEvent::<#runtime>), + (None, false) => quote!(#path::PalletEvent), }; event_variants.extend(expand_event_variant( @@ -100,16 +100,16 @@ fn expand_event_variant( match instance { Some(inst) if part_is_generic => { - quote!(#[codec(index = #index)] #variant_name(#path::Event<#runtime, #path::#inst>),) + quote!(#[codec(index = #index)] #variant_name(#path::PalletEvent<#runtime, #path::#inst>),) }, Some(inst) => { - quote!(#[codec(index = #index)] #variant_name(#path::Event<#path::#inst>),) + quote!(#[codec(index = #index)] #variant_name(#path::PalletEvent<#path::#inst>),) }, None if part_is_generic => { - quote!(#[codec(index = #index)] #variant_name(#path::Event<#runtime>),) + quote!(#[codec(index = #index)] #variant_name(#path::PalletEvent<#runtime>),) }, None => { - quote!(#[codec(index = #index)] #variant_name(#path::Event),) + quote!(#[codec(index = #index)] #variant_name(#path::PalletEvent),) }, } } diff --git a/frame/support/procedural/src/construct_runtime/expand/metadata.rs b/frame/support/procedural/src/construct_runtime/expand/metadata.rs index 6e2dd5fc002c6..c0d54b5041e6f 100644 --- a/frame/support/procedural/src/construct_runtime/expand/metadata.rs +++ b/frame/support/procedural/src/construct_runtime/expand/metadata.rs @@ -139,10 +139,10 @@ fn expand_pallet_metadata_events( .params .is_empty(); let pallet_event = match (decl.instance.as_ref(), part_is_generic) { - (Some(inst), true) => quote!(#path::Event::<#runtime, #path::#inst>), - (Some(inst), false) => quote!(#path::Event::<#path::#inst>), - (None, true) => quote!(#path::Event::<#runtime>), - (None, false) => quote!(#path::Event), + (Some(inst), true) => quote!(#path::PalletEvent::<#runtime, #path::#inst>), + (Some(inst), false) => quote!(#path::PalletEvent::<#path::#inst>), + (None, true) => quote!(#path::PalletEvent::<#runtime>), + (None, false) => quote!(#path::PalletEvent), }; quote! { diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index 711da85c10cfc..4e461850cfef7 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -338,7 +338,7 @@ impl quote::ToTokens for PalletPath { /// Parse [`PalletPart`]'s from a braces enclosed list that is split by commas, e.g. /// -/// `{ Call, Event }` +/// `{ Call, PalletEvent }` fn parse_pallet_parts(input: ParseStream) -> Result> { let pallet_parts: ext::Braces> = input.parse()?; @@ -503,7 +503,7 @@ impl Parse for PalletPartNoGeneric { /// Parse [`PalletPartNoGeneric`]'s from a braces enclosed list that is split by commas, e.g. /// -/// `{ Call, Event }` +/// `{ Call, PalletEvent }` fn parse_pallet_parts_no_generic(input: ParseStream) -> Result> { let pallet_parts: ext::Braces> = input.parse()?; diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 00204b7a4d906..213e7fa611d0a 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -312,7 +312,7 @@ pub fn decl_storage(input: TokenStream) -> TokenStream { /// Test: path::to::test::{Pallet, Call} = 1, /// /// // Pallets with instances -/// Test2_Instance1: test2::::{Pallet, Call, Storage, Event, Config, Origin}, +/// Test2_Instance1: test2::::{Pallet, Call, Storage, PalletEvent, Config, Origin}, /// Test2_DefaultInstance: test2::{Pallet, Call, Storage, Event, Config, Origin} = 4, /// /// // Pallets declared with `pallet` attribute macro: no need to define the parts diff --git a/frame/support/procedural/src/pallet/expand/event.rs b/frame/support/procedural/src/pallet/expand/event.rs index eaae04faeb47f..45fa7e0389c77 100644 --- a/frame/support/procedural/src/pallet/expand/event.rs +++ b/frame/support/procedural/src/pallet/expand/event.rs @@ -61,7 +61,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { let event_where_clause = &event.where_clause; // NOTE: actually event where clause must be a subset of config where clause because of - // `type Event: From>`. But we merge either way for potential better error message + // `type Event: From>`. But we merge either way for potential better error message let completed_where_clause = super::merge_where_clauses(&[&event.where_clause, &def.config.where_clause]); @@ -134,10 +134,10 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { quote::quote_spanned!(*fn_span => impl<#type_impl_gen> Pallet<#type_use_gen> #completed_where_clause { - #fn_vis fn deposit_event(event: Event<#event_use_gen>) { + #fn_vis fn deposit_event(event: PalletEvent<#event_use_gen>) { let event = < ::RuntimeEvent as - From> + From> >::from(event); let event = < diff --git a/frame/support/procedural/src/pallet/parse/config.rs b/frame/support/procedural/src/pallet/parse/config.rs index 7795f359cebf5..942fc66e5b5df 100644 --- a/frame/support/procedural/src/pallet/parse/config.rs +++ b/frame/support/procedural/src/pallet/parse/config.rs @@ -29,7 +29,7 @@ mod keyword { syn::custom_keyword!(config); syn::custom_keyword!(IsType); syn::custom_keyword!(RuntimeEvent); - syn::custom_keyword!(Event); + syn::custom_keyword!(PalletEvent); syn::custom_keyword!(constant); syn::custom_keyword!(frame_system); syn::custom_keyword!(disable_frame_system_supertrait_check); @@ -43,9 +43,9 @@ pub struct ConfigDef { pub has_instance: bool, /// Const associated type. pub consts_metadata: Vec, - /// Whether the trait has the associated type `Event`, note that those bounds are checked: + /// Whether the trait has the associated type `PalletEvent`, note that those bounds are checked: /// * `IsType::RuntimeEvent` - /// * `From` or `From>` or `From>` + /// * `From` or `From>` or `From>` pub has_event_type: bool, /// The where clause on trait definition but modified so `Self` is `T`. pub where_clause: Option, @@ -182,7 +182,7 @@ impl syn::parse::Parse for IsTypeBoundEventParse { } } -/// Parse for `From` or `From>` or `From>` +/// Parse for `From` or `From>` or `From>` pub struct FromEventParse { is_generic: bool, has_instance: bool, @@ -195,7 +195,7 @@ impl syn::parse::Parse for FromEventParse { input.parse::()?; input.parse::()?; - input.parse::()?; + input.parse::()?; if input.peek(syn::Token![<]) { is_generic = true; input.parse::()?; @@ -213,8 +213,8 @@ impl syn::parse::Parse for FromEventParse { } } -/// Check if trait_item is `type Event`, if so checks its bounds are those expected. -/// (Event type is reserved type) +/// Check if trait_item is `type PalletEvent`, if so checks its bounds are those expected. +/// (PalletEvent type is reserved type) fn check_event_type( frame_system: &syn::Ident, trait_item: &syn::TraitItem, @@ -253,14 +253,14 @@ fn check_event_type( b } else { let msg = "Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must \ - bound: `From` or `From>` or `From>`"; + bound: `From` or `From>` or `From>`"; return Err(syn::Error::new(type_.span(), msg)) }; if from_event_bound.is_generic && (from_event_bound.has_instance != trait_has_instance) { - let msg = "Invalid `type Event`, associated type `Event` bounds inconsistent \ - `From`. Config and generic Event must be both with instance or \ + let msg = "Invalid `type PalletEvent`, associated type `PalletEvent` bounds inconsistent \ + `From`. Config and generic PalletEvent must be both with instance or \ without instance"; return Err(syn::Error::new(type_.span(), msg)) } diff --git a/frame/support/procedural/src/pallet/parse/event.rs b/frame/support/procedural/src/pallet/parse/event.rs index e046cacac88e8..11559353c327b 100644 --- a/frame/support/procedural/src/pallet/parse/event.rs +++ b/frame/support/procedural/src/pallet/parse/event.rs @@ -21,7 +21,7 @@ use syn::spanned::Spanned; /// List of additional token to be used for parsing. mod keyword { - syn::custom_keyword!(Event); + syn::custom_keyword!(PalletEvent); syn::custom_keyword!(pallet); syn::custom_keyword!(generate_deposit); syn::custom_keyword!(deposit_event); @@ -31,11 +31,11 @@ mod keyword { pub struct EventDef { /// The index of event item in pallet module. pub index: usize, - /// The keyword Event used (contains span). - pub event: keyword::Event, + /// The keyword PalletEvent used (contains span). + pub event: keyword::PalletEvent, /// A set of usage of instance, must be check for consistency with trait. pub instances: Vec, - /// The kind of generic the type `Event` has. + /// The kind of generic the type `PalletEvent` has. pub gen_kind: super::GenericKind, /// Whether the function `deposit_event` must be generated. pub deposit_event: Option, @@ -45,7 +45,7 @@ pub struct EventDef { pub attr_span: proc_macro2::Span, } -/// Attribute for a pallet's Event. +/// Attribute for a pallet's PalletEvent. /// /// Syntax is: /// * `#[pallet::generate_deposit($vis fn deposit_event)]` @@ -113,14 +113,14 @@ impl EventDef { let deposit_event = attr_info.deposit_event; if !matches!(item.vis, syn::Visibility::Public(_)) { - let msg = "Invalid pallet::event, `Event` must be public"; + let msg = "Invalid pallet::event, `PalletEvent` must be public"; return Err(syn::Error::new(item.span(), msg)) } let where_clause = item.generics.where_clause.clone(); let mut instances = vec![]; - // NOTE: Event is not allowed to be only generic on I because it is not supported + // NOTE: PalletEvent is not allowed to be only generic on I because it is not supported // by construct_runtime. if let Some(u) = helper::check_type_def_optional_gen(&item.generics, item.ident.span())? { instances.push(u); @@ -134,7 +134,7 @@ impl EventDef { let gen_kind = super::GenericKind::from_gens(has_config, has_instance) .expect("Checked by `helper::check_type_def_optional_gen` above"); - let event = syn::parse2::(item.ident.to_token_stream())?; + let event = syn::parse2::(item.ident.to_token_stream())?; Ok(EventDef { attr_span, index, instances, deposit_event, event, gen_kind, where_clause }) } diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index dc45f2bf69d94..cee8293f060a8 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -27,7 +27,7 @@ /// /// ```rust /// frame_support::decl_event!( -/// pub enum Event { +/// pub enum PalletEvent { /// Success, /// Failure(String), /// } @@ -91,7 +91,7 @@ /// /// // For module with instances, DefaultInstance is optional /// frame_support::decl_event!( -/// pub enum Event where +/// pub enum PalletEvent where /// ::Balance, /// ::Token /// { @@ -104,7 +104,7 @@ macro_rules! decl_event { ( $(#[$attr:meta])* - pub enum Event<$evt_generic_param:ident $(, $instance:ident $(: $instantiable:ident)? $( = $event_default_instance:path)? )?> where + pub enum PalletEvent<$evt_generic_param:ident $(, $instance:ident $(: $instantiable:ident)? $( = $event_default_instance:path)? )?> where $( $tt:tt )* ) => { $crate::__decl_generic_event!( @@ -116,7 +116,7 @@ macro_rules! decl_event { }; ( $(#[$attr:meta])* - pub enum Event { + pub enum PalletEvent { $( $events:tt )* @@ -134,12 +134,12 @@ macro_rules! decl_event { /// Events for this module. /// $(#[$attr])* - pub enum Event { + pub enum PalletEvent { $( $events )* } - impl From for () { + impl From for () { fn from(_: Event) -> () { () } } } diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index a80be4e93121e..f0576579dc5bb 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -1419,7 +1419,7 @@ pub mod pallet_prelude { /// I.e. a regular trait definition named `Config`, with supertrait `frame_system::Config`, /// optionally other supertrait and where clause. /// -/// The associated type `Event` is reserved, if defined it must bounds `From` and +/// The associated type `Event` is reserved, if defined it must bounds `From` and /// `IsType<::RuntimeEvent>`, see `#[pallet::event]` for more /// information. /// @@ -1699,7 +1699,7 @@ pub mod pallet_prelude { /// ```ignore /// #[pallet::event] /// #[pallet::generate_deposit($visibility fn deposit_event)] // Optional -/// pub enum Event<$some_generic> $optional_where_clause { +/// pub enum PalletEvent<$some_generic> $optional_where_clause { /// /// Some doc /// $SomeName($SomeType, $YetanotherType, ...), /// ... @@ -1727,7 +1727,7 @@ pub mod pallet_prelude { /// * `#[derive(codec::Decode)]`, /// * `#[derive(frame_support::RuntimeDebugNoBound)]` /// -/// Macro implements `From>` for (). +/// Macro implements `From>` for (). /// /// Macro implements metadata function on `Event` returning the `EventMetadata`. /// @@ -2028,7 +2028,7 @@ pub mod pallet_prelude { /// #[pallet::constant] // put the constant in metadata /// type MyGetParam: Get; /// type Balance: Parameter + MaxEncodedLen + From; -/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; +/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// } /// /// // Define some additional constant to put into the constant metadata. @@ -2090,7 +2090,7 @@ pub mod pallet_prelude { /// #[pallet::event] /// // Generate a funciton on Pallet to deposit an event. /// #[pallet::generate_deposit(pub(super) fn deposit_event)] -/// pub enum Event { +/// pub enum PalletEvent { /// /// doc comment put in metadata /// // `::AccountId` is not defined in metadata list, the last /// // Thus the metadata is `::AccountId`. @@ -2217,7 +2217,7 @@ pub mod pallet_prelude { /// #[pallet::constant] /// type MyGetParam: Get; /// type Balance: Parameter + MaxEncodedLen + From; -/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; +/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// } /// /// #[pallet::extra_constants] @@ -2252,7 +2252,7 @@ pub mod pallet_prelude { /// /// #[pallet::event] /// #[pallet::generate_deposit(pub(super) fn deposit_event)] -/// pub enum Event, I: 'static = ()> { +/// pub enum PalletEvent, I: 'static = ()> { /// /// doc comment put in metadata /// Proposed(::AccountId), /// /// doc diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index af1d351b28025..b6fe57e2a7144 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -62,7 +62,7 @@ mod module1 { pub struct Origin(pub core::marker::PhantomData<(T, I)>); frame_support::decl_event! { - pub enum Event where + pub enum PalletEvent where ::AccountId { A(AccountId), @@ -106,7 +106,7 @@ mod module2 { pub struct Origin; frame_support::decl_event! { - pub enum Event { + pub enum PalletEvent { A, } } @@ -151,7 +151,7 @@ mod nested { pub struct Origin; frame_support::decl_event! { - pub enum Event { + pub enum PalletEvent { A, } } @@ -209,7 +209,7 @@ pub mod module3 { pub struct Origin(pub core::marker::PhantomData); frame_support::decl_event! { - pub enum Event { + pub enum PalletEvent { A, } } @@ -262,10 +262,10 @@ frame_support::construct_runtime!( { System: system::{Pallet, Call, Event, Origin} = 30, Module1_1: module1::::{Pallet, Call, Storage, Event, Origin}, - Module2: module2::{Pallet, Call, Storage, Event, Origin}, + Module2: module2::{Pallet, Call, Storage, PalletEvent, Origin}, Module1_2: module1::::{Pallet, Call, Storage, Event, Origin}, - NestedModule3: nested::module3::{Pallet, Call, Config, Storage, Event, Origin}, - Module3: self::module3::{Pallet, Call, Config, Storage, Event, Origin}, + NestedModule3: nested::module3::{Pallet, Call, Config, Storage, PalletEvent, Origin}, + Module3: self::module3::{Pallet, Call, Config, Storage, PalletEvent, Origin}, Module1_3: module1::::{Pallet, Storage} = 6, Module1_4: module1::::{Pallet, Call} = 3, Module1_5: module1::::{Pallet, Event}, @@ -417,37 +417,37 @@ fn origin_codec() { fn event_codec() { use codec::Encode; - let event = system::Event::::ExtrinsicSuccess; + let event = system::PalletEvent::::ExtrinsicSuccess; assert_eq!(RuntimeEvent::from(event).encode()[0], 30); - let event = module1::Event::::A(test_pub()); + let event = module1::PalletEvent::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 31); - let event = module2::Event::A; + let event = module2::PalletEvent::A; assert_eq!(RuntimeEvent::from(event).encode()[0], 32); - let event = module1::Event::::A(test_pub()); + let event = module1::PalletEvent::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 33); - let event = nested::module3::Event::A; + let event = nested::module3::PalletEvent::A; assert_eq!(RuntimeEvent::from(event).encode()[0], 34); - let event = module3::Event::A; + let event = module3::PalletEvent::A; assert_eq!(RuntimeEvent::from(event).encode()[0], 35); - let event = module1::Event::::A(test_pub()); + let event = module1::PalletEvent::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 4); - let event = module1::Event::::A(test_pub()); + let event = module1::PalletEvent::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 1); - let event = module1::Event::::A(test_pub()); + let event = module1::PalletEvent::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 2); - let event = module1::Event::::A(test_pub()); + let event = module1::PalletEvent::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 12); - let event = module1::Event::::A(test_pub()); + let event = module1::PalletEvent::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 13); } @@ -583,7 +583,7 @@ fn test_metadata() { name: "System", storage: None, calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 30, @@ -592,7 +592,7 @@ fn test_metadata() { name: "Module1_1", storage: Some(PalletStorageMetadata { prefix: "Instance1Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 31, @@ -610,7 +610,7 @@ fn test_metadata() { name: "Module1_2", storage: Some(PalletStorageMetadata { prefix: "Instance2Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 33, @@ -655,7 +655,7 @@ fn test_metadata() { name: "Module1_5", storage: None, calls: None, - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 4, @@ -664,7 +664,7 @@ fn test_metadata() { name: "Module1_6", storage: Some(PalletStorageMetadata { prefix: "Instance6Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 1, @@ -674,7 +674,7 @@ fn test_metadata() { storage: Some(PalletStorageMetadata { prefix: "Instance7Module", entries: vec![] }), calls: Some(meta_type::>().into()), event: Some(PalletEventMetadata { - ty: meta_type::>(), + ty: meta_type::>(), }), constants: vec![], error: None, @@ -684,7 +684,7 @@ fn test_metadata() { name: "Module1_8", storage: Some(PalletStorageMetadata { prefix: "Instance8Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 12, @@ -693,7 +693,7 @@ fn test_metadata() { name: "Module1_9", storage: Some(PalletStorageMetadata { prefix: "Instance9Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 13, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index bea30a73bab7d..30d8462122219 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -53,7 +53,7 @@ construct_runtime! { UncheckedExtrinsic = UncheckedExtrinsic { System: frame_system::{Pallet, Call, Storage, Config, Event}, - Pallet: pallet::{Pallet, Event}, + Pallet: pallet::{Pallet, PalletEvent}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index 2af4d3fb15000..ec75a9dcdb61e 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -41,7 +41,7 @@ help: if you import `Event`, refer to it directly 53 - UncheckedExtrinsic = UncheckedExtrinsic 54 - { 55 - System: frame_system::{Pallet, Call, Storage, Config, Event}, -56 - Pallet: pallet::{Pallet, Event}, +56 - Pallet: pallet::{Pallet, PalletEvent}, 57 - } 58 - } | @@ -74,7 +74,7 @@ help: if you import `Event`, refer to it directly 53 - UncheckedExtrinsic = UncheckedExtrinsic 54 - { 55 - System: frame_system::{Pallet, Call, Storage, Config, Event}, -56 - Pallet: pallet::{Pallet, Event}, +56 - Pallet: pallet::{Pallet, PalletEvent}, 57 - } 58 - } | diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index dcb18869c911e..268f7690174ca 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -41,7 +41,7 @@ pub trait Currency {} // Test for: // * No default instance -// * Origin, Inherent, Event +// * Origin, Inherent, PalletEvent mod module1 { use super::*; use sp_std::ops::Add; @@ -50,7 +50,7 @@ mod module1 { where ::BlockNumber: From, { - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; type Origin: From>; type SomeParameter: Get; type GenericType: Default + Clone + Codec + EncodeLike + TypeInfo; @@ -102,7 +102,7 @@ mod module1 { } frame_support::decl_event! { - pub enum Event where Phantom = std::marker::PhantomData { + pub enum PalletEvent where Phantom = std::marker::PhantomData { _Phantom(Phantom), AnotherVariant(u32), } @@ -154,7 +154,7 @@ mod module2 { pub trait Config: system::Config { type Amount: Parameter + Default; - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; type Origin: From>; } @@ -178,7 +178,7 @@ mod module2 { } frame_support::decl_event! { - pub enum Event where Amount = >::Amount { + pub enum PalletEvent where Amount = >::Amount { Variant(Amount), } } diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index bd2da6b9911fa..505a01f3a98c1 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -53,7 +53,7 @@ mod nested { pub struct Origin; frame_support::decl_event! { - pub enum Event { + pub enum PalletEvent { A, } } @@ -111,7 +111,7 @@ pub mod module { pub struct Origin(pub core::marker::PhantomData); frame_support::decl_event! { - pub enum Event { + pub enum PalletEvent { A, } } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 1652222dda478..ec46c66448478 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -125,7 +125,7 @@ pub mod pallet { type Balance: Parameter + Default + TypeInfo; - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::extra_constants] @@ -164,18 +164,18 @@ pub mod pallet { fn on_initialize(_: BlockNumberFor) -> Weight { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType2); // Test for where clause - Self::deposit_event(Event::Something(10)); + Self::deposit_event(PalletEvent::Something(10)); 10 } fn on_finalize(_: BlockNumberFor) { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType2); // Test for where clause - Self::deposit_event(Event::Something(20)); + Self::deposit_event(PalletEvent::Something(20)); } fn on_runtime_upgrade() -> Weight { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType2); // Test for where clause - Self::deposit_event(Event::Something(30)); + Self::deposit_event(PalletEvent::Something(30)); 30 } fn integrity_test() { @@ -199,7 +199,7 @@ pub mod pallet { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType3); // Test for where clause let _ = origin; - Self::deposit_event(Event::Something(3)); + Self::deposit_event(PalletEvent::Something(3)); Ok(().into()) } @@ -209,7 +209,7 @@ pub mod pallet { _origin: OriginFor, #[pallet::compact] foo: u32, ) -> DispatchResultWithPostInfo { - Self::deposit_event(Event::Something(0)); + Self::deposit_event(PalletEvent::Something(0)); if foo == 0 { Err(Error::::InsufficientProposersBalance)?; } @@ -237,7 +237,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum Event + pub enum PalletEvent where T::AccountId: SomeAssociation1 + From, { @@ -452,7 +452,7 @@ pub mod pallet2 { where ::AccountId: From + SomeAssociation1, { - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -466,14 +466,14 @@ pub mod pallet2 { T::AccountId: From + SomeAssociation1, { fn on_initialize(_: BlockNumberFor) -> Weight { - Self::deposit_event(Event::Something(11)); + Self::deposit_event(PalletEvent::Something(11)); 0 } fn on_finalize(_: BlockNumberFor) { - Self::deposit_event(Event::Something(21)); + Self::deposit_event(PalletEvent::Something(21)); } fn on_runtime_upgrade() -> Weight { - Self::deposit_event(Event::Something(31)); + Self::deposit_event(PalletEvent::Something(31)); 0 } } @@ -490,7 +490,7 @@ pub mod pallet2 { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Something Something(u32), } @@ -631,7 +631,7 @@ fn transactional_works() { .iter() .map(|e| &e.event) .collect::>(), - vec![&RuntimeEvent::Example(pallet::Event::Something(0))], + vec![&RuntimeEvent::Example(pallet::PalletEvent::Something(0))], ); }) } @@ -887,7 +887,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example(pallet::Event::Something(3)), + RuntimeEvent::Example(pallet::PalletEvent::Something(3)), ); }) } @@ -994,27 +994,27 @@ fn pallet_hooks_expand() { assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example(pallet::Event::Something(10)), + RuntimeEvent::Example(pallet::PalletEvent::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - RuntimeEvent::Example2(pallet2::Event::Something(11)), + RuntimeEvent::Example2(pallet2::PalletEvent::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - RuntimeEvent::Example(pallet::Event::Something(20)), + RuntimeEvent::Example(pallet::PalletEvent::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - RuntimeEvent::Example2(pallet2::Event::Something(21)), + RuntimeEvent::Example2(pallet2::PalletEvent::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - RuntimeEvent::Example(pallet::Event::Something(30)), + RuntimeEvent::Example(pallet::PalletEvent::Something(30)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - RuntimeEvent::Example2(pallet2::Event::Something(31)), + RuntimeEvent::Example2(pallet2::PalletEvent::Something(31)), ); }) } @@ -1034,27 +1034,27 @@ fn all_pallets_type_reversed_order_is_correct() { assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example2(pallet2::Event::Something(11)), + RuntimeEvent::Example2(pallet2::PalletEvent::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - RuntimeEvent::Example(pallet::Event::Something(10)), + RuntimeEvent::Example(pallet::PalletEvent::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - RuntimeEvent::Example2(pallet2::Event::Something(21)), + RuntimeEvent::Example2(pallet2::PalletEvent::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - RuntimeEvent::Example(pallet::Event::Something(20)), + RuntimeEvent::Example(pallet::PalletEvent::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - RuntimeEvent::Example2(pallet2::Event::Something(31)), + RuntimeEvent::Example2(pallet2::PalletEvent::Something(31)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - RuntimeEvent::Example(pallet::Event::Something(30)), + RuntimeEvent::Example(pallet::PalletEvent::Something(30)), ); }) } @@ -1302,7 +1302,7 @@ fn metadata() { ], }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![ PalletConstantMetadata { name: "MyGetParam", diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index bcc4689668999..3ed046ad58a33 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -43,7 +43,7 @@ mod pallet_old { + Into + Default + SomeAssociation; - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } decl_storage! { @@ -120,7 +120,7 @@ pub mod pallet { + scale_info::StaticTypeInfo; #[pallet::constant] type SomeConst: Get; - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -149,7 +149,7 @@ pub mod pallet { ensure_root(origin)?; >::put(&new_value); - Self::deposit_event(Event::Dummy(new_value)); + Self::deposit_event(PalletEvent::Dummy(new_value)); Ok(().into()) } @@ -163,7 +163,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Dummy event, just here so there's a generic type that's used. Dummy(T::Balance), } @@ -352,11 +352,11 @@ mod test { #[test] fn types() { assert_eq!( - pallet_old::Event::::decode( - &mut &pallet::Event::::Dummy(10).encode()[..] + pallet_old::PalletEvent::::decode( + &mut &pallet::PalletEvent::::Dummy(10).encode()[..] ) .unwrap(), - pallet_old::Event::::Dummy(10), + pallet_old::PalletEvent::::Dummy(10), ); assert_eq!( diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 89ed9ad8fbe4d..7c0654f09454b 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -30,7 +30,7 @@ mod pallet_old { pub trait Config: frame_system::Config { type SomeConst: Get; type Balance: Parameter + codec::HasCompact + From + Into + Default; - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } decl_storage! { @@ -45,7 +45,7 @@ mod pallet_old { } decl_event!( - pub enum Event + pub enum PalletEvent where Balance = >::Balance, { @@ -105,7 +105,7 @@ pub mod pallet { + scale_info::StaticTypeInfo; #[pallet::constant] type SomeConst: Get; - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -135,7 +135,7 @@ pub mod pallet { ensure_root(origin)?; >::put(&new_value); - Self::deposit_event(Event::Dummy(new_value)); + Self::deposit_event(PalletEvent::Dummy(new_value)); Ok(().into()) } @@ -149,7 +149,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// Dummy event, just here so there's a generic type that's used. Dummy(T::Balance), } @@ -352,11 +352,11 @@ mod test { #[test] fn types() { assert_eq!( - pallet_old::Event::::decode( - &mut &pallet::Event::::Dummy(10).encode()[..] + pallet_old::PalletEvent::::decode( + &mut &pallet::PalletEvent::::Dummy(10).encode()[..] ) .unwrap(), - pallet_old::Event::::Dummy(10), + pallet_old::PalletEvent::::Dummy(10), ); assert_eq!( diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 3dadc80e6787a..5b64358decf70 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -42,7 +42,7 @@ pub mod pallet { #[pallet::constant] type MyGetParam: Get; type Balance: Parameter + Default + scale_info::StaticTypeInfo; - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -54,26 +54,26 @@ pub mod pallet { impl, I: 'static> Hooks> for Pallet { fn on_initialize(_: BlockNumberFor) -> Weight { if TypeId::of::() == TypeId::of::<()>() { - Self::deposit_event(Event::Something(10)); + Self::deposit_event(PalletEvent::Something(10)); 10 } else { - Self::deposit_event(Event::Something(11)); + Self::deposit_event(PalletEvent::Something(11)); 11 } } fn on_finalize(_: BlockNumberFor) { if TypeId::of::() == TypeId::of::<()>() { - Self::deposit_event(Event::Something(20)); + Self::deposit_event(PalletEvent::Something(20)); } else { - Self::deposit_event(Event::Something(21)); + Self::deposit_event(PalletEvent::Something(21)); } } fn on_runtime_upgrade() -> Weight { if TypeId::of::() == TypeId::of::<()>() { - Self::deposit_event(Event::Something(30)); + Self::deposit_event(PalletEvent::Something(30)); 30 } else { - Self::deposit_event(Event::Something(31)); + Self::deposit_event(PalletEvent::Something(31)); 31 } } @@ -89,7 +89,7 @@ pub mod pallet { #[pallet::compact] _foo: u32, ) -> DispatchResultWithPostInfo { let _ = origin; - Self::deposit_event(Event::Something(3)); + Self::deposit_event(PalletEvent::Something(3)); Ok(().into()) } @@ -112,7 +112,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// doc comment put in metadata Proposed(::AccountId), /// doc @@ -218,7 +218,7 @@ pub mod pallet2 { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -227,7 +227,7 @@ pub mod pallet2 { pub struct Pallet(PhantomData<(T, I)>); #[pallet::event] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// Something Something(u32), } @@ -389,7 +389,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example(pallet::Event::Something(3)), + RuntimeEvent::Example(pallet::PalletEvent::Something(3)), ); }); @@ -400,7 +400,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Instance1Example(pallet::Event::Something(3)), + RuntimeEvent::Instance1Example(pallet::PalletEvent::Something(3)), ); }); } @@ -566,27 +566,27 @@ fn pallet_hooks_expand() { assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example(pallet::Event::Something(10)), + RuntimeEvent::Example(pallet::PalletEvent::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - RuntimeEvent::Instance1Example(pallet::Event::Something(11)), + RuntimeEvent::Instance1Example(pallet::PalletEvent::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - RuntimeEvent::Example(pallet::Event::Something(20)), + RuntimeEvent::Example(pallet::PalletEvent::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - RuntimeEvent::Instance1Example(pallet::Event::Something(21)), + RuntimeEvent::Instance1Example(pallet::PalletEvent::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - RuntimeEvent::Example(pallet::Event::Something(30)), + RuntimeEvent::Example(pallet::PalletEvent::Something(30)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - RuntimeEvent::Instance1Example(pallet::Event::Something(31)), + RuntimeEvent::Instance1Example(pallet::PalletEvent::Something(31)), ); }) } @@ -610,7 +610,7 @@ fn metadata() { storage: None, // The storage metadatas have been excluded. calls: Some(scale_info::meta_type::>().into()), event: Some(PalletEventMetadata { - ty: scale_info::meta_type::>(), + ty: scale_info::meta_type::>(), }), constants: vec![ PalletConstantMetadata { @@ -737,7 +737,7 @@ fn metadata() { ], }), calls: Some(scale_info::meta_type::>().into()), - event: Some(PalletEventMetadata { ty: scale_info::meta_type::>() }), + event: Some(PalletEventMetadata { ty: scale_info::meta_type::>() }), constants: vec![PalletConstantMetadata { name: "MyGetParam", ty: scale_info::meta_type::(), @@ -758,7 +758,7 @@ fn metadata() { } match example_pallet_instance1_metadata.event { Some(ref mut event_meta) => { - event_meta.ty = scale_info::meta_type::>(); + event_meta.ty = scale_info::meta_type::>(); }, _ => unreachable!(), } diff --git a/frame/support/test/tests/pallet_ui/event_field_not_member.rs b/frame/support/test/tests/pallet_ui/event_field_not_member.rs index 2b45a971788fb..1bb003b2e8e71 100644 --- a/frame/support/test/tests/pallet_ui/event_field_not_member.rs +++ b/frame/support/test/tests/pallet_ui/event_field_not_member.rs @@ -6,7 +6,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar; - type RuntimeEvent: IsType<::RuntimeEvent> + From>; + type RuntimeEvent: IsType<::RuntimeEvent> + From>; } #[pallet::pallet] @@ -19,7 +19,7 @@ mod pallet { impl Pallet {} #[pallet::event] - pub enum Event { + pub enum PalletEvent { B { b: T::Bar }, } } diff --git a/frame/support/test/tests/pallet_ui/event_not_in_trait.rs b/frame/support/test/tests/pallet_ui/event_not_in_trait.rs index 94151ba4c3d9d..881032756c529 100644 --- a/frame/support/test/tests/pallet_ui/event_not_in_trait.rs +++ b/frame/support/test/tests/pallet_ui/event_not_in_trait.rs @@ -18,7 +18,7 @@ mod pallet { impl Pallet {} #[pallet::event] - pub enum Event { + pub enum PalletEvent { B { b: T::Bar }, } } diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs index fa3bf04d3530d..e6cd29cac08bb 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs @@ -19,7 +19,7 @@ mod pallet { impl Pallet {} #[pallet::event] - pub enum Event { + pub enum PalletEvent { B { b: T::Bar }, } } diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs index 99df89d67278c..8e49adbf38960 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs @@ -19,7 +19,7 @@ mod pallet { impl Pallet {} #[pallet::event] - pub enum Event { + pub enum PalletEvent { B { b: T::Bar }, } } diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr index 8f3d272489abf..fc7272f3905ee 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr @@ -1,4 +1,4 @@ -error: Invalid `type Event`, associated type `Event` is reserved and must bound: `From` or `From>` or `From>` +error: Invalid `type Event`, associated type `Event` is reserved and must bound: `From` or `From>` or `From>` --> $DIR/event_type_invalid_bound_2.rs:9:3 | 9 | type Event: IsType<::RuntimeEvent>; diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 6f2f099514883..19171e1b8e4fa 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -18,7 +18,7 @@ pub trait Trait: frame_system::Config { type Balance: frame_support::dispatch::Parameter; /// The overarching event type. - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } frame_support::decl_storage! { diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index ca9e001ca0a7f..d660e791a59f9 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -30,7 +30,7 @@ pub trait Config: 'static + Eq + Clone { type Hash; type AccountId: Encode + EncodeLike + Decode + scale_info::TypeInfo; type Call; - type RuntimeEvent: From>; + type RuntimeEvent: From>; type PalletInfo: frame_support::traits::PalletInfo; type DbWeight: Get; } diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 19350e728fc3c..f11874fd21f86 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -34,12 +34,12 @@ mod module { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { Complex(Vec, u32, u16, u128), } } @@ -54,7 +54,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Module: module::{Pallet, Event}, + Module: module::{Pallet, PalletEvent}, } ); @@ -110,7 +110,7 @@ fn deposit_events(n: usize) { let mut t = new_test_ext(); t.execute_with(|| { for _ in 0..n { - module::Pallet::::deposit_event(module::Event::Complex( + module::Pallet::::deposit_event(module::PalletEvent::Complex( vec![1, 2, 3], 2, 3, diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 8eebca88eff70..fdb42bd73c5ed 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -294,7 +294,7 @@ pub mod pallet { /// The aggregated event type of the runtime. type RuntimeEvent: Parameter + Member - + From> + + From> + Debug + IsType<::RuntimeEvent>; @@ -498,14 +498,14 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let hash = T::Hashing::hash(&remark[..]); - Self::deposit_event(Event::Remarked { sender: who, hash }); + Self::deposit_event(PalletEvent::Remarked { sender: who, hash }); Ok(().into()) } } /// Event for the System pallet. #[pallet::event] - pub enum Event { + pub enum PalletEvent { /// An extrinsic completed successfully. ExtrinsicSuccess { dispatch_info: DispatchInfo }, /// An extrinsic failed. @@ -988,7 +988,7 @@ impl Pallet { pub fn update_code_in_storage(code: &[u8]) -> DispatchResult { storage::unhashed::put_raw(well_known_keys::CODE, code); Self::deposit_log(generic::DigestItem::RuntimeEnvironmentUpdated); - Self::deposit_event(Event::CodeUpdated); + Self::deposit_event(PalletEvent::CodeUpdated); Ok(()) } @@ -1502,7 +1502,7 @@ impl Pallet { info.weight = extract_actual_weight(r, &info); info.pays_fee = extract_actual_pays_fee(r, &info); Self::deposit_event(match r { - Ok(_) => Event::ExtrinsicSuccess { dispatch_info: info }, + Ok(_) => PalletEvent::ExtrinsicSuccess { dispatch_info: info }, Err(err) => { log::trace!( target: "runtime::system", @@ -1510,7 +1510,7 @@ impl Pallet { Self::block_number(), err, ); - Event::ExtrinsicFailed { dispatch_error: err.error, dispatch_info: info } + PalletEvent::ExtrinsicFailed { dispatch_error: err.error, dispatch_info: info } }, }); @@ -1538,13 +1538,13 @@ impl Pallet { /// An account is being created. pub fn on_created_account(who: T::AccountId, _a: &mut AccountInfo) { T::OnNewAccount::on_new_account(&who); - Self::deposit_event(Event::NewAccount { account: who }); + Self::deposit_event(PalletEvent::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 { account: who }); + Self::deposit_event(PalletEvent::KilledAccount { account: who }); } /// Determine whether or not it is possible to update the code. diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index fb140b24a8689..1885363341c66 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -117,7 +117,7 @@ impl Config for Test { type MaxConsumers = ConstU32<16>; } -pub type SysEvent = frame_system::Event; +pub type SysEvent = frame_system::PalletEvent; /// A simple call, which one doesn't matter. pub const CALL: &::Call = diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 9101195065489..63c82289c2cbf 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -126,7 +126,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_treasury::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Maximum acceptable reason length. @@ -184,7 +184,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// A new tip suggestion has been opened. NewTip { tip_hash: T::Hash }, /// A tip suggestion has reached threshold and is closing. @@ -267,7 +267,7 @@ pub mod pallet { finders_fee: true, }; Tips::::insert(&hash, tip); - Self::deposit_event(Event::NewTip { tip_hash: hash }); + Self::deposit_event(PalletEvent::NewTip { tip_hash: hash }); Ok(()) } @@ -302,7 +302,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&who, tip.deposit); debug_assert!(err_amount.is_zero()); } - Self::deposit_event(Event::TipRetracted { tip_hash: hash }); + Self::deposit_event(PalletEvent::TipRetracted { tip_hash: hash }); Ok(()) } @@ -342,7 +342,7 @@ pub mod pallet { let hash = T::Hashing::hash_of(&(&reason_hash, &who)); Reasons::::insert(&reason_hash, &reason); - Self::deposit_event(Event::NewTip { tip_hash: hash }); + Self::deposit_event(PalletEvent::NewTip { tip_hash: hash }); let tips = vec![(tipper.clone(), tip_value)]; let tip = OpenTip { reason: reason_hash, @@ -392,7 +392,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 { tip_hash: hash }); + Self::deposit_event(PalletEvent::TipClosing { tip_hash: hash }); } Tips::::insert(&hash, tip); Ok(()) @@ -451,7 +451,7 @@ pub mod pallet { T::OnSlash::on_unbalanced(imbalance); } Reasons::::remove(&tip.reason); - Self::deposit_event(Event::TipSlashed { + Self::deposit_event(PalletEvent::TipSlashed { tip_hash: hash, finder: tip.finder, deposit: tip.deposit, @@ -550,7 +550,7 @@ impl, I: 'static> 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 { tip_hash: hash, who: tip.who, payout }); + Self::deposit_event(PalletEvent::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 0f566d73d54b8..671fcf30c686b 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -39,7 +39,7 @@ use frame_support::{ }; use super::*; -use crate::{self as pallet_tips, Event as TipEvent}; +use crate::{self as pallet_tips, PalletEvent as TipEvent}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/frame/transaction-payment/asset-tx-payment/src/lib.rs b/frame/transaction-payment/asset-tx-payment/src/lib.rs index 768d556bcb6a3..de5d6d5962998 100644 --- a/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -114,7 +114,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_transaction_payment::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The fungibles instance used to pay for transactions in assets. type Fungibles: Balanced; /// The actual transaction charging logic that charges the fees. @@ -127,7 +127,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee, /// has been paid by `who` in an asset `asset_id`. AssetTxFeePaid { @@ -290,7 +290,7 @@ where tip.into(), already_withdrawn.into(), )?; - Pallet::::deposit_event(Event::::AssetTxFeePaid { + Pallet::::deposit_event(PalletEvent::::AssetTxFeePaid { who, actual_fee, tip, diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index e3ab3f5c1b67c..0f5b1680f2612 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -250,7 +250,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for withdrawing, refunding and depositing the transaction fee. /// Transaction fees are withdrawn before the transaction is executed. @@ -326,7 +326,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee, /// has been paid by `who`. TransactionFeePaid { who: T::AccountId, actual_fee: BalanceOf, tip: BalanceOf }, @@ -745,7 +745,7 @@ where T::OnChargeTransaction::correct_and_deposit_fee( &who, info, post_info, actual_fee, tip, imbalance, )?; - Pallet::::deposit_event(Event::::TransactionFeePaid { who, actual_fee, tip }); + Pallet::::deposit_event(PalletEvent::::TransactionFeePaid { who, actual_fee, tip }); } Ok(()) } @@ -1360,10 +1360,10 @@ mod tests { assert_eq!(Balances::free_balance(2), 0); // Transfer Event System::assert_has_event(RuntimeEvent::Balances( - pallet_balances::Event::Transfer { from: 2, to: 3, amount: 80 }, + pallet_balances::PalletEvent::Transfer { from: 2, to: 3, amount: 80 }, )); // Killed Event - System::assert_has_event(RuntimeEvent::System(system::Event::KilledAccount { + System::assert_has_event(RuntimeEvent::System(system::PalletEvent::KilledAccount { account: 2, })); }); @@ -1420,7 +1420,7 @@ mod tests { assert_eq!(Balances::total_balance(&user), 0); // TransactionFeePaid Event System::assert_has_event(RuntimeEvent::TransactionPayment( - pallet_transaction_payment::Event::TransactionFeePaid { + pallet_transaction_payment::PalletEvent::TransactionFeePaid { who: user, actual_fee: 0, tip: 0, diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index cab4c92317bb5..8b32ed028436c 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -132,7 +132,7 @@ benchmarks! { }: _(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize]) verify { assert!(!BlockTransactions::::get().is_empty()); - assert_last_event::(Event::Stored { index: 0 }.into()); + assert_last_event::(PalletEvent::Stored { index: 0 }.into()); } renew { @@ -145,7 +145,7 @@ benchmarks! { run_to_block::(1u32.into()); }: _(RawOrigin::Signed(caller.clone()), T::BlockNumber::zero(), 0) verify { - assert_last_event::(Event::Renewed { index: 0 }.into()); + assert_last_event::(PalletEvent::Renewed { index: 0 }.into()); } check_proof_max { @@ -163,7 +163,7 @@ benchmarks! { let proof = TransactionStorageProof::decode(&mut encoded_proof).unwrap(); }: check_proof(RawOrigin::None, proof) verify { - assert_last_event::(Event::ProofChecked.into()); + assert_last_event::(PalletEvent::ProofChecked.into()); } impl_benchmark_test_suite!(TransactionStorage, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index c1f7c12b9a2f9..5aad37208e031 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -92,7 +92,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A dispatchable call. type Call: Parameter + Dispatchable @@ -225,7 +225,7 @@ pub mod pallet { .map_err(|_| Error::::TooManyTransactions)?; Ok(()) })?; - Self::deposit_event(Event::Stored { index }); + Self::deposit_event(PalletEvent::Stored { index }); Ok(()) } @@ -267,7 +267,7 @@ pub mod pallet { }) .map_err(|_| Error::::TooManyTransactions) })?; - Self::deposit_event(Event::Renewed { index }); + Self::deposit_event(PalletEvent::Renewed { index }); Ok(().into()) } @@ -320,14 +320,14 @@ pub mod pallet { Error::::InvalidProof ); ProofChecked::::put(true); - Self::deposit_event(Event::ProofChecked); + Self::deposit_event(PalletEvent::ProofChecked); Ok(().into()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Stored data under specified index. Stored { index: u32 }, /// Renewed data under specified index. diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index ed58480d95511..62d98425371fb 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -80,7 +80,7 @@ benchmarks_instance_pallet! { } verify { if origin.is_ok() { - assert_last_event::(Event::SpendApproved { proposal_index: 0, amount: value, beneficiary }.into()) + assert_last_event::(PalletEvent::SpendApproved { proposal_index: 0, amount: value, beneficiary }.into()) } } diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 4adb9cbcde9bc..e8a0f47bf9b6c 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -154,7 +154,7 @@ pub mod pallet { type RejectOrigin: EnsureOrigin; /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for the unbalanced decrease when slashing for a rejected proposal or bounty. @@ -266,7 +266,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// New proposal. Proposed { proposal_index: ProposalIndex }, /// We have ended a spend period and will now allocate funds. @@ -352,7 +352,7 @@ pub mod pallet { >::put(c + 1); >::insert(c, Proposal { proposer, value, beneficiary, bond }); - Self::deposit_event(Event::Proposed { proposal_index: c }); + Self::deposit_event(PalletEvent::Proposed { proposal_index: c }); Ok(()) } @@ -378,7 +378,7 @@ pub mod pallet { let imbalance = T::Currency::slash_reserved(&proposal.proposer, value).0; T::OnSlash::on_unbalanced(imbalance); - Self::deposit_event(Event::::Rejected { + Self::deposit_event(PalletEvent::::Rejected { proposal_index: proposal_id, slashed: value, }); @@ -438,7 +438,7 @@ pub mod pallet { Proposals::::insert(proposal_index, proposal); ProposalCount::::put(proposal_index + 1); - Self::deposit_event(Event::SpendApproved { proposal_index, amount, beneficiary }); + Self::deposit_event(PalletEvent::SpendApproved { proposal_index, amount, beneficiary }); Ok(()) } @@ -503,7 +503,7 @@ impl, I: 'static> Pallet { let mut total_weight: Weight = Zero::zero(); let mut budget_remaining = Self::pot(); - Self::deposit_event(Event::Spending { budget_remaining }); + Self::deposit_event(PalletEvent::Spending { budget_remaining }); let account_id = Self::account_id(); let mut missed_any = false; @@ -524,7 +524,7 @@ impl, I: 'static> Pallet { // provide the allocation. imbalance.subsume(T::Currency::deposit_creating(&p.beneficiary, p.value)); - Self::deposit_event(Event::Awarded { + Self::deposit_event(PalletEvent::Awarded { proposal_index: index, award: p.value, account: p.beneficiary, @@ -559,7 +559,7 @@ impl, I: 'static> Pallet { let (debit, credit) = T::Currency::pair(burn); imbalance.subsume(debit); T::BurnDestination::on_unbalanced(credit); - Self::deposit_event(Event::Burnt { burnt_funds: burn }) + Self::deposit_event(PalletEvent::Burnt { burnt_funds: burn }) } // Must never be an error, but better to be safe. @@ -574,7 +574,7 @@ impl, I: 'static> Pallet { drop(problem); } - Self::deposit_event(Event::Rollover { rollover_balance: budget_remaining }); + Self::deposit_event(PalletEvent::Rollover { rollover_balance: budget_remaining }); total_weight } @@ -595,6 +595,6 @@ impl, I: 'static> OnUnbalanced> 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 { value: numeric_amount }); + Self::deposit_event(PalletEvent::Deposit { value: numeric_amount }); } } diff --git a/frame/uniques/src/benchmarking.rs b/frame/uniques/src/benchmarking.rs index 0b5077005cd23..d4ce22972bc33 100644 --- a/frame/uniques/src/benchmarking.rs +++ b/frame/uniques/src/benchmarking.rs @@ -143,7 +143,7 @@ benchmarks_instance_pallet! { let call = Call::::create { admin }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(Event::Created { collection: T::Helper::collection(0), creator: caller.clone(), owner: caller }.into()); + assert_last_event::(PalletEvent::Created { collection: T::Helper::collection(0), creator: caller.clone(), owner: caller }.into()); } force_create { @@ -151,7 +151,7 @@ benchmarks_instance_pallet! { let caller_lookup = T::Lookup::unlookup(caller.clone()); }: _(SystemOrigin::Root, caller_lookup, true) verify { - assert_last_event::(Event::ForceCreated { collection: T::Helper::collection(0), owner: caller }.into()); + assert_last_event::(PalletEvent::ForceCreated { collection: T::Helper::collection(0), owner: caller }.into()); } destroy { @@ -173,7 +173,7 @@ benchmarks_instance_pallet! { let witness = Collection::::get(collection).unwrap().destroy_witness(); }: _(SystemOrigin::Signed(caller), collection, witness) verify { - assert_last_event::(Event::Destroyed { collection }.into()); + assert_last_event::(PalletEvent::Destroyed { collection }.into()); } mint { @@ -181,7 +181,7 @@ benchmarks_instance_pallet! { let item = T::Helper::item(0); }: _(SystemOrigin::Signed(caller.clone()), collection, item, caller_lookup) verify { - assert_last_event::(Event::Issued { collection, item, owner: caller }.into()); + assert_last_event::(PalletEvent::Issued { collection, item, owner: caller }.into()); } burn { @@ -189,7 +189,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(caller_lookup)) verify { - assert_last_event::(Event::Burned { collection, item, owner: caller }.into()); + assert_last_event::(PalletEvent::Burned { collection, item, owner: caller }.into()); } transfer { @@ -200,7 +200,7 @@ benchmarks_instance_pallet! { let target_lookup = T::Lookup::unlookup(target.clone()); }: _(SystemOrigin::Signed(caller.clone()), collection, item, target_lookup) verify { - assert_last_event::(Event::Transferred { collection, item, from: caller, to: target }.into()); + assert_last_event::(PalletEvent::Transferred { collection, item, from: caller, to: target }.into()); } redeposit { @@ -219,7 +219,7 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), collection, items.clone()) verify { - assert_last_event::(Event::Redeposited { collection, successful_items: items }.into()); + assert_last_event::(PalletEvent::Redeposited { collection, successful_items: items }.into()); } freeze { @@ -227,7 +227,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); }: _(SystemOrigin::Signed(caller.clone()), T::Helper::collection(0), T::Helper::item(0)) verify { - assert_last_event::(Event::Frozen { collection: T::Helper::collection(0), item: T::Helper::item(0) }.into()); + assert_last_event::(PalletEvent::Frozen { collection: T::Helper::collection(0), item: T::Helper::item(0) }.into()); } thaw { @@ -240,14 +240,14 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), collection, item) verify { - assert_last_event::(Event::Thawed { collection, item }.into()); + assert_last_event::(PalletEvent::Thawed { collection, item }.into()); } freeze_collection { let (collection, caller, caller_lookup) = create_collection::(); }: _(SystemOrigin::Signed(caller.clone()), collection) verify { - assert_last_event::(Event::CollectionFrozen { collection }.into()); + assert_last_event::(PalletEvent::CollectionFrozen { collection }.into()); } thaw_collection { @@ -256,7 +256,7 @@ benchmarks_instance_pallet! { Uniques::::freeze_collection(origin, collection)?; }: _(SystemOrigin::Signed(caller.clone()), collection) verify { - assert_last_event::(Event::CollectionThawed { collection }.into()); + assert_last_event::(PalletEvent::CollectionThawed { collection }.into()); } transfer_ownership { @@ -268,7 +268,7 @@ benchmarks_instance_pallet! { Uniques::::set_accept_ownership(origin, Some(collection))?; }: _(SystemOrigin::Signed(caller), collection, target_lookup) verify { - assert_last_event::(Event::OwnerChanged { collection, new_owner: target }.into()); + assert_last_event::(PalletEvent::OwnerChanged { collection, new_owner: target }.into()); } set_team { @@ -278,7 +278,7 @@ benchmarks_instance_pallet! { let target2 = T::Lookup::unlookup(account("target", 2, SEED)); }: _(SystemOrigin::Signed(caller), collection, target0, target1, target2) verify { - assert_last_event::(Event::TeamChanged{ + assert_last_event::(PalletEvent::TeamChanged{ collection, issuer: account("target", 0, SEED), admin: account("target", 1, SEED), @@ -300,7 +300,7 @@ benchmarks_instance_pallet! { }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(Event::ItemStatusChanged { collection }.into()); + assert_last_event::(PalletEvent::ItemStatusChanged { collection }.into()); } set_attribute { @@ -312,7 +312,7 @@ benchmarks_instance_pallet! { add_item_metadata::(item); }: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone(), value.clone()) verify { - assert_last_event::(Event::AttributeSet { collection, maybe_item: Some(item), key, value }.into()); + assert_last_event::(PalletEvent::AttributeSet { collection, maybe_item: Some(item), key, value }.into()); } clear_attribute { @@ -322,7 +322,7 @@ benchmarks_instance_pallet! { let (key, ..) = add_item_attribute::(item); }: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone()) verify { - assert_last_event::(Event::AttributeCleared { collection, maybe_item: Some(item), key }.into()); + assert_last_event::(PalletEvent::AttributeCleared { collection, maybe_item: Some(item), key }.into()); } set_metadata { @@ -332,7 +332,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); }: _(SystemOrigin::Signed(caller), collection, item, data.clone(), false) verify { - assert_last_event::(Event::MetadataSet { collection, item, data, is_frozen: false }.into()); + assert_last_event::(PalletEvent::MetadataSet { collection, item, data, is_frozen: false }.into()); } clear_metadata { @@ -341,7 +341,7 @@ benchmarks_instance_pallet! { add_item_metadata::(item); }: _(SystemOrigin::Signed(caller), collection, item) verify { - assert_last_event::(Event::MetadataCleared { collection, item }.into()); + assert_last_event::(PalletEvent::MetadataCleared { collection, item }.into()); } set_collection_metadata { @@ -350,7 +350,7 @@ benchmarks_instance_pallet! { let (collection, caller, _) = create_collection::(); }: _(SystemOrigin::Signed(caller), collection, data.clone(), false) verify { - assert_last_event::(Event::CollectionMetadataSet { collection, data, is_frozen: false }.into()); + assert_last_event::(PalletEvent::CollectionMetadataSet { collection, data, is_frozen: false }.into()); } clear_collection_metadata { @@ -358,7 +358,7 @@ benchmarks_instance_pallet! { add_collection_metadata::(); }: _(SystemOrigin::Signed(caller), collection) verify { - assert_last_event::(Event::CollectionMetadataCleared { collection }.into()); + assert_last_event::(PalletEvent::CollectionMetadataCleared { collection }.into()); } approve_transfer { @@ -368,7 +368,7 @@ benchmarks_instance_pallet! { let delegate_lookup = T::Lookup::unlookup(delegate.clone()); }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup) verify { - assert_last_event::(Event::ApprovedTransfer { collection, item, owner: caller, delegate }.into()); + assert_last_event::(PalletEvent::ApprovedTransfer { collection, item, owner: caller, delegate }.into()); } cancel_approval { @@ -380,7 +380,7 @@ benchmarks_instance_pallet! { Uniques::::approve_transfer(origin, collection, item, delegate_lookup.clone())?; }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(delegate_lookup)) verify { - assert_last_event::(Event::ApprovalCancelled { collection, item, owner: caller, delegate }.into()); + assert_last_event::(PalletEvent::ApprovalCancelled { collection, item, owner: caller, delegate }.into()); } set_accept_ownership { @@ -389,7 +389,7 @@ benchmarks_instance_pallet! { let collection = T::Helper::collection(0); }: _(SystemOrigin::Signed(caller.clone()), Some(collection)) verify { - assert_last_event::(Event::OwnershipAcceptanceChanged { + assert_last_event::(PalletEvent::OwnershipAcceptanceChanged { who: caller, maybe_collection: Some(collection), }.into()); @@ -399,7 +399,7 @@ benchmarks_instance_pallet! { let (collection, caller, _) = create_collection::(); }: _(SystemOrigin::Signed(caller.clone()), collection, u32::MAX) verify { - assert_last_event::(Event::CollectionMaxSupplySet { + assert_last_event::(PalletEvent::CollectionMaxSupplySet { collection, max_supply: u32::MAX, }.into()); @@ -410,7 +410,7 @@ benchmarks_instance_pallet! { Uniques::::set_next_id(0); }: _(SystemOrigin::Signed(caller.clone())) verify { - assert_last_event::(Event::NextCollectionIdIncremented { + assert_last_event::(PalletEvent::NextCollectionIdIncremented { next_id: 1u32.into() }.into()); } @@ -423,7 +423,7 @@ benchmarks_instance_pallet! { let price = ItemPrice::::from(100u32); }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(price), Some(delegate_lookup)) verify { - assert_last_event::(Event::ItemPriceSet { + assert_last_event::(PalletEvent::ItemPriceSet { collection, item, price, @@ -442,7 +442,7 @@ benchmarks_instance_pallet! { T::Currency::make_free_balance_be(&buyer, DepositBalanceOf::::max_value()); }: _(SystemOrigin::Signed(buyer.clone()), collection, item, price.clone()) verify { - assert_last_event::(Event::ItemBought { + assert_last_event::(PalletEvent::ItemBought { collection, item, price, diff --git a/frame/uniques/src/functions.rs b/frame/uniques/src/functions.rs index dcbb1f27973d7..877ab003c050d 100644 --- a/frame/uniques/src/functions.rs +++ b/frame/uniques/src/functions.rs @@ -51,7 +51,7 @@ impl, I: 'static> Pallet { Item::::insert(&collection, &item, &details); ItemPriceOf::::remove(&collection, &item); - Self::deposit_event(Event::Transferred { + Self::deposit_event(PalletEvent::Transferred { collection, item, from: origin, @@ -66,7 +66,7 @@ impl, I: 'static> Pallet { admin: T::AccountId, deposit: DepositBalanceOf, free_holding: bool, - event: Event, + event: PalletEvent, ) -> DispatchResult { ensure!(!Collection::::contains_key(collection), Error::::InUse); @@ -93,7 +93,7 @@ impl, I: 'static> Pallet { CollectionAccount::::insert(&owner, &collection, ()); NextCollectionId::::set(next_id); - Self::deposit_event(Event::NextCollectionIdIncremented { next_id }); + Self::deposit_event(PalletEvent::NextCollectionIdIncremented { next_id }); Self::deposit_event(event); Ok(()) } @@ -130,7 +130,7 @@ impl, I: 'static> Pallet { T::Currency::unreserve(&collection_details.owner, collection_details.total_deposit); CollectionMaxSupply::::remove(&collection); - Self::deposit_event(Event::Destroyed { collection }); + Self::deposit_event(PalletEvent::Destroyed { collection }); Ok(DestroyWitness { items: collection_details.items, @@ -179,7 +179,7 @@ impl, I: 'static> Pallet { }, )?; - Self::deposit_event(Event::Issued { collection, item, owner }); + Self::deposit_event(PalletEvent::Issued { collection, item, owner }); Ok(()) } @@ -209,7 +209,7 @@ impl, I: 'static> Pallet { Account::::remove((&owner, &collection, &item)); ItemPriceOf::::remove(&collection, &item); - Self::deposit_event(Event::Burned { collection, item, owner }); + Self::deposit_event(PalletEvent::Burned { collection, item, owner }); Ok(()) } @@ -239,7 +239,7 @@ impl, I: 'static> Pallet { &item, (price.clone(), whitelisted_buyer.clone()), ); - Self::deposit_event(Event::ItemPriceSet { + Self::deposit_event(PalletEvent::ItemPriceSet { collection, item, price: price.clone(), @@ -247,7 +247,7 @@ impl, I: 'static> Pallet { }); } else { ItemPriceOf::::remove(&collection, &item); - Self::deposit_event(Event::ItemPriceRemoved { collection, item }); + Self::deposit_event(PalletEvent::ItemPriceRemoved { collection, item }); } Ok(()) @@ -282,7 +282,7 @@ impl, I: 'static> Pallet { Self::do_transfer(collection, item, buyer.clone(), |_, _| Ok(()))?; - Self::deposit_event(Event::ItemBought { + Self::deposit_event(PalletEvent::ItemBought { collection, item, price: price_info.0, diff --git a/frame/uniques/src/impl_nonfungibles.rs b/frame/uniques/src/impl_nonfungibles.rs index cead6f562ab58..abb1b57ea2ade 100644 --- a/frame/uniques/src/impl_nonfungibles.rs +++ b/frame/uniques/src/impl_nonfungibles.rs @@ -98,7 +98,7 @@ impl, I: 'static> Create<::AccountId> for Pallet admin.clone(), T::CollectionDeposit::get(), false, - Event::Created { collection: *collection, creator: who.clone(), owner: admin.clone() }, + PalletEvent::Created { collection: *collection, creator: who.clone(), owner: admin.clone() }, ) } } diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index 294ed57b935ae..a37319976cdce 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -89,7 +89,7 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Identifier for the collection of item. @@ -280,7 +280,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event, I: 'static = ()> { + pub enum PalletEvent, I: 'static = ()> { /// A `collection` was created. Created { collection: T::CollectionId, creator: T::AccountId, owner: T::AccountId }, /// A `collection` was force-created. @@ -479,7 +479,7 @@ pub mod pallet { admin.clone(), T::CollectionDeposit::get(), false, - Event::Created { collection, creator: owner, owner: admin }, + PalletEvent::Created { collection, creator: owner, owner: admin }, ) } @@ -516,7 +516,7 @@ pub mod pallet { owner.clone(), Zero::zero(), free_holding, - Event::ForceCreated { collection, owner }, + PalletEvent::ForceCreated { collection, owner }, ) } @@ -541,7 +541,7 @@ pub mod pallet { let next_id = NextCollectionId::::get().saturating_add(1u32.into()); NextCollectionId::::set(next_id); - Self::deposit_event(Event::NextCollectionIdIncremented { next_id }); + Self::deposit_event(PalletEvent::NextCollectionIdIncremented { next_id }); Ok(()) } @@ -738,7 +738,7 @@ pub mod pallet { } Collection::::insert(&collection, &collection_details); - Self::deposit_event(Event::::Redeposited { + Self::deposit_event(PalletEvent::::Redeposited { collection, successful_items: successful, }); @@ -773,7 +773,7 @@ pub mod pallet { details.is_frozen = true; Item::::insert(&collection, &item, &details); - Self::deposit_event(Event::::Frozen { collection, item }); + Self::deposit_event(PalletEvent::::Frozen { collection, item }); Ok(()) } @@ -804,7 +804,7 @@ pub mod pallet { details.is_frozen = false; Item::::insert(&collection, &item, &details); - Self::deposit_event(Event::::Thawed { collection, item }); + Self::deposit_event(PalletEvent::::Thawed { collection, item }); Ok(()) } @@ -830,7 +830,7 @@ pub mod pallet { details.is_frozen = true; - Self::deposit_event(Event::::CollectionFrozen { collection }); + Self::deposit_event(PalletEvent::::CollectionFrozen { collection }); Ok(()) }) } @@ -857,7 +857,7 @@ pub mod pallet { details.is_frozen = false; - Self::deposit_event(Event::::CollectionThawed { collection }); + Self::deposit_event(PalletEvent::::CollectionThawed { collection }); Ok(()) }) } @@ -904,7 +904,7 @@ pub mod pallet { details.owner = owner.clone(); OwnershipAcceptance::::remove(&owner); - Self::deposit_event(Event::OwnerChanged { collection, new_owner: owner }); + Self::deposit_event(PalletEvent::OwnerChanged { collection, new_owner: owner }); Ok(()) }) } @@ -942,7 +942,7 @@ pub mod pallet { details.admin = admin.clone(); details.freezer = freezer.clone(); - Self::deposit_event(Event::TeamChanged { collection, issuer, admin, freezer }); + Self::deposit_event(PalletEvent::TeamChanged { collection, issuer, admin, freezer }); Ok(()) }) } @@ -985,7 +985,7 @@ pub mod pallet { Item::::insert(&collection, &item, &details); let delegate = details.approved.expect("set as Some above; qed"); - Self::deposit_event(Event::ApprovedTransfer { + Self::deposit_event(PalletEvent::ApprovedTransfer { collection, item, owner: details.owner, @@ -1037,7 +1037,7 @@ pub mod pallet { } Item::::insert(&collection, &item, &details); - Self::deposit_event(Event::ApprovalCancelled { + Self::deposit_event(PalletEvent::ApprovalCancelled { collection, item, owner: details.owner, @@ -1090,7 +1090,7 @@ pub mod pallet { CollectionAccount::::remove(&old_owner, &collection); CollectionAccount::::insert(&new_owner, &collection, ()); - Self::deposit_event(Event::ItemStatusChanged { collection }); + Self::deposit_event(PalletEvent::ItemStatusChanged { collection }); Ok(()) }) } @@ -1156,7 +1156,7 @@ pub mod pallet { Attribute::::insert((&collection, maybe_item, &key), (&value, deposit)); Collection::::insert(collection, &collection_details); - Self::deposit_event(Event::AttributeSet { collection, maybe_item, key, value }); + Self::deposit_event(PalletEvent::AttributeSet { collection, maybe_item, key, value }); Ok(()) } @@ -1201,7 +1201,7 @@ pub mod pallet { collection_details.total_deposit.saturating_reduce(deposit); T::Currency::unreserve(&collection_details.owner, deposit); Collection::::insert(collection, &collection_details); - Self::deposit_event(Event::AttributeCleared { collection, maybe_item, key }); + Self::deposit_event(PalletEvent::AttributeCleared { collection, maybe_item, key }); } Ok(()) } @@ -1267,7 +1267,7 @@ pub mod pallet { *metadata = Some(ItemMetadata { deposit, data: data.clone(), is_frozen }); Collection::::insert(&collection, &collection_details); - Self::deposit_event(Event::MetadataSet { collection, item, data, is_frozen }); + Self::deposit_event(PalletEvent::MetadataSet { collection, item, data, is_frozen }); Ok(()) }) } @@ -1313,7 +1313,7 @@ pub mod pallet { collection_details.total_deposit.saturating_reduce(deposit); Collection::::insert(&collection, &collection_details); - Self::deposit_event(Event::MetadataCleared { collection, item }); + Self::deposit_event(PalletEvent::MetadataCleared { collection, item }); Ok(()) }) } @@ -1374,7 +1374,7 @@ pub mod pallet { *metadata = Some(CollectionMetadata { deposit, data: data.clone(), is_frozen }); - Self::deposit_event(Event::CollectionMetadataSet { collection, data, is_frozen }); + Self::deposit_event(PalletEvent::CollectionMetadataSet { collection, data, is_frozen }); Ok(()) }) } @@ -1412,7 +1412,7 @@ pub mod pallet { let deposit = metadata.take().ok_or(Error::::UnknownCollection)?.deposit; T::Currency::unreserve(&details.owner, deposit); - Self::deposit_event(Event::CollectionMetadataCleared { collection }); + Self::deposit_event(PalletEvent::CollectionMetadataCleared { collection }); Ok(()) }) } @@ -1448,7 +1448,7 @@ pub mod pallet { } else { OwnershipAcceptance::::remove(&who); } - Self::deposit_event(Event::OwnershipAcceptanceChanged { who, maybe_collection }); + Self::deposit_event(PalletEvent::OwnershipAcceptanceChanged { who, maybe_collection }); Ok(()) } @@ -1487,7 +1487,7 @@ pub mod pallet { ensure!(details.items <= max_supply, Error::::MaxSupplyTooSmall); CollectionMaxSupply::::insert(&collection, max_supply); - Self::deposit_event(Event::CollectionMaxSupplySet { collection, max_supply }); + Self::deposit_event(PalletEvent::CollectionMaxSupplySet { collection, max_supply }); Ok(()) } diff --git a/frame/uniques/src/tests.rs b/frame/uniques/src/tests.rs index daa5c93af6ad5..984fa4d21beaf 100644 --- a/frame/uniques/src/tests.rs +++ b/frame/uniques/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for Uniques pallet. -use crate::{mock::*, Event, *}; +use crate::{mock::*, PalletEvent, *}; use frame_support::{assert_noop, assert_ok, dispatch::Dispatchable, traits::Currency}; use pallet_balances::Error as BalancesError; use sp_std::prelude::*; @@ -663,7 +663,7 @@ fn max_supply_should_work() { )); assert_eq!(CollectionMaxSupply::::get(collection_id).unwrap(), max_supply); - assert!(events().contains(&Event::::CollectionMaxSupplySet { + assert!(events().contains(&PalletEvent::::CollectionMaxSupplySet { collection: collection_id, max_supply, })); @@ -703,9 +703,9 @@ fn try_increment_id_works() { // create two collections & check for events. assert_ok!(Uniques::force_create(Origin::root(), 1, true)); - assert!(events().contains(&Event::::NextCollectionIdIncremented { next_id: 1 })); + assert!(events().contains(&PalletEvent::::NextCollectionIdIncremented { next_id: 1 })); assert_ok!(Uniques::force_create(Origin::root(), 1, true)); - assert!(events().contains(&Event::::NextCollectionIdIncremented { next_id: 2 })); + assert!(events().contains(&PalletEvent::::NextCollectionIdIncremented { next_id: 2 })); // there are now two collections. assert_eq!(Uniques::get_next_id(), 2); @@ -716,7 +716,7 @@ fn try_increment_id_works() { assert_ok!(Uniques::try_increment_id(Origin::signed(2))); // `try_increment_id` should emit an event when successful. - assert!(events().contains(&Event::::NextCollectionIdIncremented { next_id: 1 })); + assert!(events().contains(&PalletEvent::::NextCollectionIdIncremented { next_id: 1 })); // because reset, the collections count should be now 1 assert_eq!(Uniques::get_next_id(), 1); @@ -765,7 +765,7 @@ fn set_price_should_work() { assert_eq!(item.0, 2); assert_eq!(item.1, Some(3)); - assert!(events().contains(&Event::::ItemPriceSet { + assert!(events().contains(&PalletEvent::::ItemPriceSet { collection: collection_id, item: item_1, price: 1, @@ -774,7 +774,7 @@ fn set_price_should_work() { // validate we can unset the price assert_ok!(Uniques::set_price(Origin::signed(user_id), collection_id, item_2, None, None)); - assert!(events().contains(&Event::::ItemPriceRemoved { + assert!(events().contains(&PalletEvent::::ItemPriceRemoved { collection: collection_id, item: item_2 })); @@ -852,7 +852,7 @@ fn buy_item_should_work() { // can buy when I'm a whitelisted buyer assert_ok!(Uniques::buy_item(Origin::signed(user_3), collection_id, item_2, price_2,)); - assert!(events().contains(&Event::::ItemBought { + assert!(events().contains(&PalletEvent::::ItemBought { collection: collection_id, item: item_2, price: price_2, diff --git a/frame/utility/src/benchmarking.rs b/frame/utility/src/benchmarking.rs index fbbd6f2b378c7..78a0598e74d6d 100644 --- a/frame/utility/src/benchmarking.rs +++ b/frame/utility/src/benchmarking.rs @@ -41,7 +41,7 @@ benchmarks! { let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), calls) verify { - assert_last_event::(Event::BatchCompleted.into()) + assert_last_event::(PalletEvent::BatchCompleted.into()) } as_derivative { @@ -62,7 +62,7 @@ benchmarks! { let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), calls) verify { - assert_last_event::(Event::BatchCompleted.into()) + assert_last_event::(PalletEvent::BatchCompleted.into()) } dispatch_as { @@ -83,7 +83,7 @@ benchmarks! { let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), calls) verify { - assert_last_event::(Event::BatchCompleted.into()) + assert_last_event::(PalletEvent::BatchCompleted.into()) } impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 057cda8cafb55..96bbf5ac6f54c 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -84,7 +84,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter @@ -106,7 +106,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// Batch of dispatches did not complete fully. Index of first failing dispatch given, as /// well as the error. BatchInterrupted { index: u32, error: DispatchError }, @@ -220,7 +220,7 @@ pub mod pallet { // Add the weight of this call. weight = weight.saturating_add(extract_actual_weight(&result, &info)); if let Err(e) = result { - Self::deposit_event(Event::BatchInterrupted { + Self::deposit_event(PalletEvent::BatchInterrupted { index: index as u32, error: e.error, }); @@ -229,9 +229,9 @@ pub mod pallet { // Return the actual used weight + base_weight of this call. return Ok(Some(base_weight + weight).into()) } - Self::deposit_event(Event::ItemCompleted); + Self::deposit_event(PalletEvent::ItemCompleted); } - Self::deposit_event(Event::BatchCompleted); + Self::deposit_event(PalletEvent::BatchCompleted); let base_weight = T::WeightInfo::batch(calls_len as u32); Ok(Some(base_weight + weight).into()) } @@ -348,9 +348,9 @@ pub mod pallet { err.post_info = Some(base_weight + weight).into(); err })?; - Self::deposit_event(Event::ItemCompleted); + Self::deposit_event(PalletEvent::ItemCompleted); } - Self::deposit_event(Event::BatchCompleted); + Self::deposit_event(PalletEvent::BatchCompleted); let base_weight = T::WeightInfo::batch_all(calls_len as u32); Ok(Some(base_weight + weight).into()) } @@ -382,7 +382,7 @@ pub mod pallet { let res = call.dispatch_bypass_filter((*as_origin).into()); - Self::deposit_event(Event::DispatchedAs { + Self::deposit_event(PalletEvent::DispatchedAs { result: res.map(|_| ()).map_err(|e| e.error), }); Ok(()) @@ -444,15 +444,15 @@ pub mod pallet { weight = weight.saturating_add(extract_actual_weight(&result, &info)); if let Err(e) = result { has_error = true; - Self::deposit_event(Event::ItemFailed { error: e.error }); + Self::deposit_event(PalletEvent::ItemFailed { error: e.error }); } else { - Self::deposit_event(Event::ItemCompleted); + Self::deposit_event(PalletEvent::ItemCompleted); } } if has_error { - Self::deposit_event(Event::BatchCompletedWithErrors); + Self::deposit_event(PalletEvent::BatchCompletedWithErrors); } else { - Self::deposit_event(Event::BatchCompleted); + Self::deposit_event(PalletEvent::BatchCompleted); } let base_weight = T::WeightInfo::batch(calls_len as u32); Ok(Some(base_weight + weight).into()) diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index fe82af3b20bdc..83a520b10532b 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -92,7 +92,7 @@ frame_support::construct_runtime!( { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Utility: utility::{Pallet, Call, Event}, + Utility: utility::{Pallet, Call, PalletEvent}, Example: example::{Pallet, Call}, } ); @@ -336,7 +336,7 @@ fn batch_with_signed_filters() { vec![Call::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })] ),); System::assert_last_event( - utility::Event::BatchInterrupted { + utility::PalletEvent::BatchInterrupted { index: 0, error: frame_system::Error::::CallFiltered.into(), } @@ -411,7 +411,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), + utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); // No weight is refunded assert_eq!(extract_actual_weight(&result, &info), info.weight); @@ -426,7 +426,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), + utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); assert_eq!(extract_actual_weight(&result, &info), info.weight - diff * batch_len); @@ -439,7 +439,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), + utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); assert_eq!( extract_actual_weight(&result, &info), @@ -587,7 +587,7 @@ fn batch_all_does_not_nest() { // and balances. assert_ok!(Utility::batch_all(Origin::signed(1), vec![batch_nested])); System::assert_has_event( - utility::Event::BatchInterrupted { + utility::PalletEvent::BatchInterrupted { index: 0, error: frame_system::Error::::CallFiltered.into(), } @@ -621,9 +621,9 @@ fn force_batch_works() { call_transfer(2, 5), ] ),); - System::assert_last_event(utility::Event::BatchCompletedWithErrors.into()); + System::assert_last_event(utility::PalletEvent::BatchCompletedWithErrors.into()); System::assert_has_event( - utility::Event::ItemFailed { error: DispatchError::Other("") }.into(), + utility::PalletEvent::ItemFailed { error: DispatchError::Other("") }.into(), ); assert_eq!(Balances::free_balance(1), 0); assert_eq!(Balances::free_balance(2), 20); @@ -632,9 +632,9 @@ fn force_batch_works() { Origin::signed(2), vec![call_transfer(1, 5), call_transfer(1, 5),] ),); - System::assert_last_event(utility::Event::BatchCompleted.into()); + System::assert_last_event(utility::PalletEvent::BatchCompleted.into()); assert_ok!(Utility::force_batch(Origin::signed(1), vec![call_transfer(2, 50),]),); - System::assert_last_event(utility::Event::BatchCompletedWithErrors.into()); + System::assert_last_event(utility::PalletEvent::BatchCompletedWithErrors.into()); }); } diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 2c2813fab0aa6..16a4ae7605a15 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -154,7 +154,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: LockableCurrency; @@ -256,7 +256,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { /// The amount vested has been updated. This could indicate a change in funds available. /// The balance given is the amount which is left unvested (and thus locked). VestingUpdated { account: T::AccountId, unvested: BalanceOf }, @@ -569,11 +569,11 @@ impl Pallet { fn write_lock(who: &T::AccountId, total_locked_now: BalanceOf) { if total_locked_now.is_zero() { T::Currency::remove_lock(VESTING_ID, who); - Self::deposit_event(Event::::VestingCompleted { account: who.clone() }); + Self::deposit_event(PalletEvent::::VestingCompleted { account: who.clone() }); } else { let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE; T::Currency::set_lock(VESTING_ID, who, total_locked_now, reasons); - Self::deposit_event(Event::::VestingUpdated { + Self::deposit_event(PalletEvent::::VestingUpdated { account: who.clone(), unvested: total_locked_now, }); diff --git a/frame/whitelist/src/lib.rs b/frame/whitelist/src/lib.rs index 64bdaa3a43151..ae8887ca6951a 100644 --- a/frame/whitelist/src/lib.rs +++ b/frame/whitelist/src/lib.rs @@ -61,7 +61,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: IsType<::Call> @@ -92,7 +92,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum PalletEvent { CallWhitelisted { call_hash: T::Hash }, WhitelistedCallRemoved { call_hash: T::Hash }, WhitelistedCallDispatched { call_hash: T::Hash, result: DispatchResultWithPostInfo }, @@ -129,7 +129,7 @@ pub mod pallet { WhitelistedCall::::insert(call_hash, ()); T::PreimageProvider::request_preimage(&call_hash); - Self::deposit_event(Event::::CallWhitelisted { call_hash }); + Self::deposit_event(PalletEvent::::CallWhitelisted { call_hash }); Ok(()) } @@ -142,7 +142,7 @@ pub mod pallet { T::PreimageProvider::unrequest_preimage(&call_hash); - Self::deposit_event(Event::::WhitelistedCallRemoved { call_hash }); + Self::deposit_event(PalletEvent::::WhitelistedCallRemoved { call_hash }); Ok(()) } @@ -228,7 +228,7 @@ impl Pallet { Err(call_err) => call_err.post_info.actual_weight, }; - Self::deposit_event(Event::::WhitelistedCallDispatched { call_hash, result }); + Self::deposit_event(PalletEvent::::WhitelistedCallDispatched { call_hash, result }); call_actual_weight } diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 24eef63bb4bc6..573a1a4e821f2 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -502,8 +502,8 @@ impl frame_support::traits::OriginTrait for Origin { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct RuntimeEvent; -impl From> for RuntimeEvent { - fn from(_evt: frame_system::Event) -> Self { +impl From> for RuntimeEvent { + fn from(_evt: frame_system::PalletEvent) -> Self { unimplemented!("Not required in tests!") } } From afb5a9e9d6601877b58ba310db6ac64a87d234ce Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 17:21:06 +0200 Subject: [PATCH 18/63] merge conflict fixes & fmt --- bin/node-template/pallets/template/src/lib.rs | 3 +- frame/assets/src/functions.rs | 6 +- frame/assets/src/lib.rs | 13 +- frame/atomic-swap/src/lib.rs | 14 +- frame/balances/src/lib.rs | 16 +- frame/balances/src/tests_local.rs | 11 +- frame/bounties/src/lib.rs | 5 +- frame/child-bounties/src/lib.rs | 8 +- frame/collective/src/lib.rs | 24 +- frame/contracts/src/exec.rs | 14 +- frame/contracts/src/lib.rs | 3 +- frame/contracts/src/tests.rs | 54 +++-- frame/contracts/src/wasm/code_cache.rs | 2 +- frame/democracy/src/lib.rs | 25 +- .../election-provider-multi-phase/src/lib.rs | 12 +- frame/elections-phragmen/src/lib.rs | 7 +- frame/examples/basic/src/lib.rs | 3 +- frame/examples/offchain-worker/src/lib.rs | 3 +- frame/gilt/src/lib.rs | 17 +- frame/identity/src/lib.rs | 9 +- frame/im-online/src/lib.rs | 7 +- frame/indices/src/lib.rs | 3 +- frame/lottery/src/lib.rs | 3 +- frame/multisig/src/lib.rs | 9 +- frame/nicks/src/lib.rs | 3 +- frame/node-authorization/src/lib.rs | 3 +- frame/nomination-pools/src/lib.rs | 8 +- frame/nomination-pools/src/tests.rs | 225 +++++++++++++++--- .../nomination-pools/test-staking/src/lib.rs | 4 +- frame/offences/benchmarking/src/lib.rs | 4 +- frame/preimage/src/lib.rs | 3 +- frame/proxy/src/lib.rs | 7 +- frame/ranked-collective/src/lib.rs | 4 +- frame/recovery/src/lib.rs | 3 +- frame/referenda/src/lib.rs | 17 +- frame/remark/src/lib.rs | 3 +- frame/remark/src/tests.rs | 2 +- frame/scheduler/src/lib.rs | 3 +- frame/scheduler/src/mock.rs | 3 +- frame/society/src/lib.rs | 10 +- frame/staking/src/lib.rs | 4 +- frame/staking/src/pallet/impls.rs | 6 +- frame/staking/src/pallet/mod.rs | 3 +- frame/staking/src/tests.rs | 2 +- frame/state-trie-migration/src/lib.rs | 5 +- frame/sudo/src/lib.rs | 11 +- frame/sudo/src/mock.rs | 3 +- .../procedural/src/pallet/expand/event.rs | 3 +- .../procedural/src/pallet/parse/config.rs | 3 +- frame/support/test/tests/pallet.rs | 3 +- .../test/tests/pallet_compatibility.rs | 6 +- .../tests/pallet_compatibility_instance.rs | 3 +- frame/support/test/tests/pallet_instance.rs | 7 +- .../asset-tx-payment/src/lib.rs | 3 +- frame/transaction-payment/src/lib.rs | 15 +- frame/transaction-storage/src/lib.rs | 3 +- frame/uniques/src/impl_nonfungibles.rs | 6 +- frame/uniques/src/lib.rs | 13 +- frame/utility/src/tests.rs | 9 +- frame/vesting/src/lib.rs | 3 +- frame/whitelist/src/lib.rs | 3 +- 61 files changed, 526 insertions(+), 161 deletions(-) diff --git a/bin/node-template/pallets/template/src/lib.rs b/bin/node-template/pallets/template/src/lib.rs index c5ebca2349478..6282fda13709a 100644 --- a/bin/node-template/pallets/template/src/lib.rs +++ b/bin/node-template/pallets/template/src/lib.rs @@ -27,7 +27,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } // The pallet's runtime storage items. diff --git a/frame/assets/src/functions.rs b/frame/assets/src/functions.rs index f247b3cc2fd59..1d89393e448d8 100644 --- a/frame/assets/src/functions.rs +++ b/frame/assets/src/functions.rs @@ -441,7 +441,11 @@ impl, I: 'static> Pallet { Ok(()) })?; - Self::deposit_event(PalletEvent::Burned { asset_id: id, owner: target.clone(), balance: actual }); + Self::deposit_event(PalletEvent::Burned { + asset_id: id, + owner: target.clone(), + balance: actual, + }); Ok(actual) } diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index 24993d32191cf..df8148fb47f66 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -533,7 +533,11 @@ pub mod pallet { is_frozen: false, }, ); - Self::deposit_event(PalletEvent::Created { asset_id: id, creator: owner, owner: admin }); + Self::deposit_event(PalletEvent::Created { + asset_id: id, + creator: owner, + owner: admin, + }); Ok(()) } @@ -952,7 +956,12 @@ pub mod pallet { details.admin = admin.clone(); details.freezer = freezer.clone(); - Self::deposit_event(PalletEvent::TeamChanged { asset_id: id, issuer, admin, freezer }); + Self::deposit_event(PalletEvent::TeamChanged { + asset_id: id, + issuer, + admin, + freezer, + }); Ok(()) }) } diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index 510c1773900ef..caf5e497fefb7 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -166,7 +166,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Swap action. type SwapAction: SwapAction + Parameter + MaxEncodedLen; /// Limit of proof size. @@ -266,7 +267,11 @@ pub mod pallet { }; PendingSwaps::::insert(target.clone(), hashed_proof, swap.clone()); - Self::deposit_event(PalletEvent::NewSwap { account: target, proof: hashed_proof, swap }); + Self::deposit_event(PalletEvent::NewSwap { + account: target, + proof: hashed_proof, + swap, + }); Ok(()) } @@ -335,7 +340,10 @@ pub mod pallet { swap.action.cancel(&swap.source); PendingSwaps::::remove(&target, hashed_proof); - Self::deposit_event(PalletEvent::SwapCancelled { account: target, proof: hashed_proof }); + Self::deposit_event(PalletEvent::SwapCancelled { + account: target, + proof: hashed_proof, + }); Ok(()) } diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index 273d60aa1b40c..e2c6c423b7f27 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -343,7 +343,11 @@ pub mod pallet { mem::drop(NegativeImbalance::::new(old_reserved - new_reserved)); } - Self::deposit_event(PalletEvent::BalanceSet { who, free: new_free, reserved: new_reserved }); + Self::deposit_event(PalletEvent::BalanceSet { + who, + free: new_free, + reserved: new_reserved, + }); Ok(().into()) } @@ -739,7 +743,10 @@ pub struct DustCleaner, I: 'static = ()>( impl, I: 'static> Drop for DustCleaner { fn drop(&mut self) { if let Some((who, dust)) = self.0.take() { - Pallet::::deposit_event(PalletEvent::DustLost { account: who, amount: dust.peek() }); + Pallet::::deposit_event(PalletEvent::DustLost { + account: who, + amount: dust.peek(), + }); T::DustRemoval::on_unbalanced(dust); } } @@ -937,7 +944,10 @@ impl, I: 'static> Pallet { }); result.map(|(maybe_endowed, maybe_dust, result)| { if let Some(endowed) = maybe_endowed { - Self::deposit_event(PalletEvent::Endowed { account: who.clone(), free_balance: endowed }); + Self::deposit_event(PalletEvent::Endowed { + account: who.clone(), + free_balance: endowed, + }); } let dust_cleaner = DustCleaner(maybe_dust.map(|dust| (who.clone(), dust))); (result, dust_cleaner) diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 63044adfa5e2a..8496fdf303939 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -159,8 +159,15 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { events(), [ RuntimeEvent::System(system::PalletEvent::NewAccount { account: 1 }), - RuntimeEvent::Balances(crate::PalletEvent::Endowed { account: 1, free_balance: 100 }), - RuntimeEvent::Balances(crate::PalletEvent::BalanceSet { who: 1, free: 100, reserved: 0 }), + RuntimeEvent::Balances(crate::PalletEvent::Endowed { + account: 1, + free_balance: 100 + }), + RuntimeEvent::Balances(crate::PalletEvent::BalanceSet { + who: 1, + free: 100, + reserved: 0 + }), ] ); diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index 39a3b464b79f7..386ea25d7b83c 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -586,7 +586,10 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(PalletEvent::::BountyAwarded { index: bounty_id, beneficiary }); + Self::deposit_event(PalletEvent::::BountyAwarded { + index: bounty_id, + beneficiary, + }); Ok(()) } diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index e08594f7d8a13..303b47363c6cc 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -146,7 +146,8 @@ pub mod pallet { type ChildBountyValueMinimum: Get>; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -805,7 +806,10 @@ impl Pallet { }; ChildBounties::::insert(parent_bounty_id, child_bounty_id, &child_bounty); ChildBountyDescriptions::::insert(child_bounty_id, description); - Self::deposit_event(PalletEvent::Added { index: parent_bounty_id, child_index: child_bounty_id }); + Self::deposit_event(PalletEvent::Added { + index: parent_bounty_id, + child_index: child_bounty_id, + }); } fn ensure_bounty_active( diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 435e85ccb5931..fcab36c170734 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -806,7 +806,11 @@ impl, I: 'static> Pallet { length_bound, proposal_weight_bound, )?; - Self::deposit_event(PalletEvent::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(PalletEvent::Closed { + proposal_hash, + yes: yes_votes, + no: no_votes, + }); let (proposal_weight, proposal_count) = Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal); return Ok(( @@ -818,7 +822,11 @@ impl, I: 'static> Pallet { ) .into()) } else if disapproved { - Self::deposit_event(PalletEvent::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(PalletEvent::Closed { + proposal_hash, + yes: yes_votes, + no: no_votes, + }); let proposal_count = Self::do_disapprove_proposal(proposal_hash); return Ok(( Some(T::WeightInfo::close_early_disapproved(seats, proposal_count)), @@ -848,7 +856,11 @@ impl, I: 'static> Pallet { length_bound, proposal_weight_bound, )?; - Self::deposit_event(PalletEvent::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(PalletEvent::Closed { + proposal_hash, + yes: yes_votes, + no: no_votes, + }); let (proposal_weight, proposal_count) = Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal); Ok(( @@ -860,7 +872,11 @@ impl, I: 'static> Pallet { ) .into()) } else { - Self::deposit_event(PalletEvent::Closed { proposal_hash, yes: yes_votes, no: no_votes }); + Self::deposit_event(PalletEvent::Closed { + proposal_hash, + yes: yes_votes, + no: no_votes, + }); let proposal_count = Self::do_disapprove_proposal(proposal_hash); Ok((Some(T::WeightInfo::close_disapproved(seats, proposal_count)), Pays::No).into()) } diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 62c7cecf4196b..a419bb7641e15 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -18,8 +18,8 @@ use crate::{ gas::GasMeter, storage::{self, Storage, WriteOutcome}, - BalanceOf, CodeHash, Config, ContractInfo, ContractInfoOf, Error, PalletEvent, Nonce, - Pallet as Contracts, Schedule, + BalanceOf, CodeHash, Config, ContractInfo, ContractInfoOf, Error, Nonce, Pallet as Contracts, + PalletEvent, Schedule, }; use frame_support::{ crypto::ecdsa::ECDSAExt, @@ -2138,7 +2138,10 @@ mod tests { ); assert_eq!( &events(), - &[PalletEvent::Instantiated { deployer: ALICE, contract: instantiated_contract_address }] + &[PalletEvent::Instantiated { + deployer: ALICE, + contract: instantiated_contract_address + }] ); }); } @@ -2238,7 +2241,10 @@ mod tests { ); assert_eq!( &events(), - &[PalletEvent::Instantiated { deployer: BOB, contract: instantiated_contract_address }] + &[PalletEvent::Instantiated { + deployer: BOB, + contract: instantiated_contract_address + }] ); }); } diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 874537a2cf454..e63be9f41f123 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -243,7 +243,8 @@ pub mod pallet { type Currency: ReservableCurrency; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Dispatchable diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index a6d09b1ffd31c..77bf5be9ce2b0 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -1067,12 +1067,14 @@ fn cannot_self_destruct_by_refund_after_slash() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: 10, - destination_status: BalanceStatus::Free, - }), + event: RuntimeEvent::Balances( + pallet_balances::PalletEvent::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: 10, + destination_status: BalanceStatus::Free, + } + ), topics: vec![], }, ] @@ -1183,12 +1185,14 @@ fn self_destruct_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: 1_000, - destination_status: BalanceStatus::Free, - }), + event: RuntimeEvent::Balances( + pallet_balances::PalletEvent::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: 1_000, + destination_status: BalanceStatus::Free, + } + ), topics: vec![], }, ], @@ -3112,12 +3116,14 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: refunded0, - destination_status: BalanceStatus::Free, - }), + event: RuntimeEvent::Balances( + pallet_balances::PalletEvent::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: refunded0, + destination_status: BalanceStatus::Free, + } + ), topics: vec![], }, ] @@ -3194,11 +3200,13 @@ fn set_code_extrinsic() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(pallet_contracts::PalletEvent::ContractCodeUpdated { - contract: addr, - new_code_hash, - old_code_hash: code_hash, - }), + event: RuntimeEvent::Contracts( + pallet_contracts::PalletEvent::ContractCodeUpdated { + contract: addr, + new_code_hash, + old_code_hash: code_hash, + } + ), topics: vec![], },] ); diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 3c8ad30cfc795..73395f888bdf6 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -32,7 +32,7 @@ use crate::{ gas::{GasMeter, Token}, wasm::{prepare, PrefabWasmModule}, weights::WeightInfo, - CodeHash, CodeStorage, Config, Error, PalletEvent, OwnerInfoOf, Pallet, PristineCode, Schedule, + CodeHash, CodeStorage, Config, Error, OwnerInfoOf, Pallet, PalletEvent, PristineCode, Schedule, Weight, }; use frame_support::{ diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index ce792b4d04c81..07d3c3a75c869 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -254,7 +254,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { type Proposal: Parameter + Dispatchable + From>; - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Currency type for this pallet. type Currency: ReservableCurrency @@ -653,7 +654,10 @@ pub mod pallet { >::append((index, proposal_hash, who)); - Self::deposit_event(PalletEvent::::Proposed { proposal_index: index, deposit: value }); + Self::deposit_event(PalletEvent::::Proposed { + proposal_index: index, + deposit: value, + }); Ok(()) } @@ -1393,7 +1397,11 @@ impl Pallet { votes.insert(i, (ref_index, vote)); }, } - Self::deposit_event(PalletEvent::::Voted { voter: who.clone(), ref_index, vote }); + Self::deposit_event(PalletEvent::::Voted { + voter: who.clone(), + ref_index, + vote, + }); // Shouldn't be possible to fail, but we handle it gracefully. status.tally.add(vote).ok_or(ArithmeticError::Overflow)?; if let Some(approve) = vote.as_standard() { @@ -1684,7 +1692,11 @@ impl Pallet { if let Ok(proposal) = T::Proposal::decode(&mut &data[..]) { let err_amount = T::Currency::unreserve(&provider, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(PalletEvent::::PreimageUsed { proposal_hash, provider, deposit }); + Self::deposit_event(PalletEvent::::PreimageUsed { + proposal_hash, + provider, + deposit, + }); let res = proposal .dispatch(frame_system::RawOrigin::Root.into()) @@ -1702,7 +1714,10 @@ impl Pallet { Err(Error::::PreimageInvalid.into()) } } else { - Self::deposit_event(PalletEvent::::PreimageMissing { proposal_hash, ref_index: index }); + Self::deposit_event(PalletEvent::::PreimageMissing { + proposal_hash, + ref_index: index, + }); Err(Error::::PreimageMissing.into()) } } diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 7594bda257778..43f725d9d2941 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -1540,7 +1540,9 @@ impl Pallet { |ReadySolution { supports, compute, .. }| Ok((supports, compute)), ) .map(|(supports, compute)| { - Self::deposit_event(PalletEvent::ElectionFinalized { election_compute: Some(compute) }); + Self::deposit_event(PalletEvent::ElectionFinalized { + election_compute: Some(compute), + }); if Self::round() != 1 { log!(info, "Finalized election round with compute {:?}.", compute); } @@ -1968,7 +1970,9 @@ mod tests { multi_phase_events(), vec![ PalletEvent::SignedPhaseStarted { round: 1 }, - PalletEvent::ElectionFinalized { election_compute: Some(ElectionCompute::Fallback) } + PalletEvent::ElectionFinalized { + election_compute: Some(ElectionCompute::Fallback) + } ], ); // All storage items must be cleared. @@ -2086,7 +2090,9 @@ mod tests { election_compute: ElectionCompute::Fallback, prev_ejected: false }, - PalletEvent::ElectionFinalized { election_compute: Some(ElectionCompute::Fallback) } + PalletEvent::ElectionFinalized { + election_compute: Some(ElectionCompute::Fallback) + } ] ); }) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 7ec842bd6526a..73f51176eebd1 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -195,7 +195,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Identifier for the elections-phragmen pallet's lock #[pallet::constant] @@ -1096,7 +1097,9 @@ impl Pallet { // clean candidates. >::kill(); - Self::deposit_event(PalletEvent::NewTerm { new_members: new_members_sorted_by_id }); + Self::deposit_event(PalletEvent::NewTerm { + new_members: new_members_sorted_by_id, + }); >::mutate(|v| *v += 1); }) .map_err(|e| { diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index 75599a4c8d6cd..1e6ffa35cadcd 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -370,7 +370,8 @@ pub mod pallet { type MagicNumber: Get; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Type representing the weight of this pallet type WeightInfo: WeightInfo; diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 07b5edf8b76b3..0a980811d5956 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -126,7 +126,8 @@ pub mod pallet { type AuthorityId: AppCrypto; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The overarching dispatch call type. type Call: From>; diff --git a/frame/gilt/src/lib.rs b/frame/gilt/src/lib.rs index fa27105f420cc..b8bb68a5e3024 100644 --- a/frame/gilt/src/lib.rs +++ b/frame/gilt/src/lib.rs @@ -98,7 +98,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Currency type that this works on. type Currency: ReservableCurrency; @@ -437,7 +438,11 @@ pub mod pallet { }); T::Currency::unreserve(&bid.who, bid.amount); - Self::deposit_event(PalletEvent::BidRetracted { who: bid.who, amount: bid.amount, duration }); + Self::deposit_event(PalletEvent::BidRetracted { + who: bid.who, + amount: bid.amount, + duration, + }); Ok(().into()) } @@ -635,8 +640,12 @@ pub mod pallet { totals.proportion = totals.proportion.defensive_saturating_add(proportion); totals.index += 1; - let e = - PalletEvent::GiltIssued { index, expiry, who: who.clone(), amount }; + let e = PalletEvent::GiltIssued { + index, + expiry, + who: who.clone(), + amount, + }; Self::deposit_event(e); let gilt = ActiveGilt { amount, proportion, who, expiry }; Active::::insert(index, gilt); diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index e71a3fcf76c9c..294e4824b29c4 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -105,7 +105,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The currency trait. type Currency: ReservableCurrency; @@ -889,7 +890,11 @@ pub mod pallet { sub_ids.try_push(sub.clone()).expect("sub ids length checked above; qed"); *subs_deposit = subs_deposit.saturating_add(deposit); - Self::deposit_event(PalletEvent::SubIdentityAdded { sub, main: sender.clone(), deposit }); + Self::deposit_event(PalletEvent::SubIdentityAdded { + sub, + main: sender.clone(), + deposit, + }); Ok(()) }) } diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 7c4ce33913775..26fdd6090cf6f 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -337,7 +337,8 @@ pub mod pallet { type MaxPeerDataEncodingSize: Get; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// A type for retrieving the validators supposed to be online in a session. type ValidatorSet: ValidatorSetWithIdentification; @@ -493,7 +494,9 @@ pub mod pallet { let keys = Keys::::get(); let public = keys.get(heartbeat.authority_index as usize); if let (false, Some(public)) = (exists, public) { - Self::deposit_event(PalletEvent::::HeartbeatReceived { authority_id: public.clone() }); + Self::deposit_event(PalletEvent::::HeartbeatReceived { + authority_id: public.clone(), + }); let network_state_bounded = BoundedOpaqueNetworkState::< T::MaxPeerDataEncodingSize, diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index fd499f2445eb4..2a8b7197a6030 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -68,7 +68,8 @@ pub mod pallet { type Deposit: Get>; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 583b3ed587729..fd97b17ce61f8 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -146,7 +146,8 @@ pub mod pallet { type Randomness: Randomness; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The manager origin. type ManagerOrigin: EnsureOrigin; diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index c2a73bac94e21..79eb5baa8b5d1 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -117,7 +117,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter @@ -658,7 +659,11 @@ impl Pallet { approvals: vec![who.clone()], }, ); - Self::deposit_event(PalletEvent::NewMultisig { approving: who, multisig: id, call_hash }); + Self::deposit_event(PalletEvent::NewMultisig { + approving: who, + multisig: id, + call_hash, + }); let final_weight = if stored { T::WeightInfo::as_multi_create_store(other_signatories_len as u32, call_len as u32) diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index f691220e8e815..484bf58c6843a 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -58,7 +58,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The currency trait. type Currency: ReservableCurrency; diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index 6614b98ed292c..a73982e89e047 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -67,7 +67,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The maximum number of well known nodes that are allowed to set #[pallet::constant] diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 6c42643d8fdd2..5e2dac454da53 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -1151,7 +1151,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: weights::WeightInfo; @@ -1930,10 +1931,7 @@ pub mod pallet { ); ReversePoolIdLookup::::insert(bonded_pool.bonded_account(), pool_id); - Self::deposit_event(PalletEvent::::Created { - depositor: who.clone(), - pool_id: pool_id, - }); + Self::deposit_event(PalletEvent::::Created { depositor: who.clone(), pool_id }); Self::deposit_event(PalletEvent::::Bonded { member: who, diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index e170b004f18f1..f52025ced7646 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -869,7 +869,13 @@ mod claim_payout { PalletEvent::Created { depositor: 10, pool_id: 1 }, PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, PalletEvent::Bonded { member: 11, pool_id: 1, bonded: 11, joined: true }, - PalletEvent::Unbonded { member: 11, pool_id: 1, points: 11, balance: 11, era: 3 } + PalletEvent::Unbonded { + member: 11, + pool_id: 1, + points: 11, + balance: 11, + era: 3 + } ] ); }); @@ -1374,7 +1380,13 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 10, points: 10, era: 3 }, + PalletEvent::Unbonded { + member: 20, + pool_id: 1, + balance: 10, + points: 10, + era: 3 + }, PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 50 }, PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 50 }, ] @@ -1808,12 +1820,36 @@ mod claim_payout { PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 10, points: 10, era: 3 }, + PalletEvent::Unbonded { + member: 20, + pool_id: 1, + balance: 10, + points: 10, + era: 3 + }, PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 15 }, - PalletEvent::Unbonded { member: 30, pool_id: 1, balance: 10, points: 10, era: 3 }, - PalletEvent::Unbonded { member: 30, pool_id: 1, balance: 5, points: 5, era: 3 }, + PalletEvent::Unbonded { + member: 30, + pool_id: 1, + balance: 10, + points: 10, + era: 3 + }, + PalletEvent::Unbonded { + member: 30, + pool_id: 1, + balance: 5, + points: 5, + era: 3 + }, PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 7 }, - PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 5, points: 5, era: 3 }, + PalletEvent::Unbonded { + member: 20, + pool_id: 1, + balance: 5, + points: 5, + era: 3 + }, PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 7 } ] ); @@ -1865,10 +1901,22 @@ mod claim_payout { pool_events_since_last_call(), vec![ PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, - PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 20, points: 20, era: 3 }, + PalletEvent::Unbonded { + member: 20, + pool_id: 1, + balance: 20, + points: 20, + era: 3 + }, PalletEvent::Withdrawn { member: 20, pool_id: 1, balance: 20, points: 20 }, PalletEvent::MemberRemoved { pool_id: 1, member: 20 }, - PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 10, points: 10, era: 6 }, + PalletEvent::Unbonded { + member: 10, + pool_id: 1, + balance: 10, + points: 10, + era: 6 + }, PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 10, points: 10 }, PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, PalletEvent::Destroyed { pool_id: 1 } @@ -2269,7 +2317,13 @@ mod unbond { PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, PalletEvent::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 40 }, - PalletEvent::Unbonded { member: 40, pool_id: 1, points: 6, balance: 6, era: 3 } + PalletEvent::Unbonded { + member: 40, + pool_id: 1, + points: 6, + balance: 6, + era: 3 + } ] ); @@ -2355,7 +2409,13 @@ mod unbond { PalletEvent::Withdrawn { member: 550, pool_id: 1, points: 92, balance: 92 }, PalletEvent::MemberRemoved { pool_id: 1, member: 550 }, PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, - PalletEvent::Unbonded { member: 10, pool_id: 1, points: 2, balance: 2, era: 6 } + PalletEvent::Unbonded { + member: 10, + pool_id: 1, + points: 2, + balance: 2, + era: 6 + } ] ); }); @@ -2401,7 +2461,13 @@ mod unbond { vec![ PalletEvent::Created { depositor: 10, pool_id: 1 }, PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Unbonded { member: 10, pool_id: 1, points: 10, balance: 10, era: 9 } + PalletEvent::Unbonded { + member: 10, + pool_id: 1, + points: 10, + balance: 10, + era: 9 + } ] ); }); @@ -2526,7 +2592,13 @@ mod unbond { PalletEvent::Created { depositor: 10, pool_id: 1 }, PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 } + PalletEvent::Unbonded { + member: 100, + pool_id: 1, + points: 100, + balance: 100, + era: 3 + } ] ); @@ -2703,7 +2775,13 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Unbonded { member: 10, pool_id: 1, points: 5, balance: 5, era: 3 }] + vec![PalletEvent::Unbonded { + member: 10, + pool_id: 1, + points: 5, + balance: 5, + era: 3 + }] ); // when: casual further unbond, next era. @@ -2730,7 +2808,13 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 4 }] + vec![PalletEvent::Unbonded { + member: 10, + pool_id: 1, + points: 1, + balance: 1, + era: 4 + }] ); // when: unbonding more than our active: error @@ -2765,7 +2849,13 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Unbonded { member: 10, pool_id: 1, points: 3, balance: 3, era: 4 }] + vec![PalletEvent::Unbonded { + member: 10, + pool_id: 1, + points: 3, + balance: 3, + era: 4 + }] ); }); } @@ -3035,7 +3125,13 @@ mod withdraw_unbonded { balance: 550, era: 3 }, - PalletEvent::Unbonded { member: 40, pool_id: 1, points: 40, balance: 40, era: 3 }, + PalletEvent::Unbonded { + member: 40, + pool_id: 1, + points: 40, + balance: 40, + era: 3 + }, ] ); assert_eq!( @@ -3058,7 +3154,12 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { member: 550, pool_id: 1, balance: 275, points: 550 }, + PalletEvent::Withdrawn { + member: 550, + pool_id: 1, + balance: 275, + points: 550 + }, PalletEvent::MemberRemoved { pool_id: 1, member: 550 } ] ); @@ -3100,7 +3201,13 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 5, points: 5, era: 9 }, + PalletEvent::Unbonded { + member: 10, + pool_id: 1, + balance: 5, + points: 5, + era: 9 + }, PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 5, points: 5 }, PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, PalletEvent::Destroyed { pool_id: 1 } @@ -3145,7 +3252,13 @@ mod withdraw_unbonded { PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, PalletEvent::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, - PalletEvent::Unbonded { member: 40, pool_id: 1, balance: 20, points: 20, era: 3 }, + PalletEvent::Unbonded { + member: 40, + pool_id: 1, + balance: 20, + points: 20, + era: 3 + }, PalletEvent::Unbonded { member: 550, pool_id: 1, @@ -3198,7 +3311,12 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { member: 550, pool_id: 1, balance: 275, points: 275 }, + PalletEvent::Withdrawn { + member: 550, + pool_id: 1, + balance: 275, + points: 275 + }, PalletEvent::MemberRemoved { pool_id: 1, member: 550 } ] ); @@ -3228,7 +3346,13 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Unbonded { member: 10, pool_id: 1, points: 5, balance: 5, era: 6 }, + PalletEvent::Unbonded { + member: 10, + pool_id: 1, + points: 5, + balance: 5, + era: 6 + }, PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 5, balance: 5 }, PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, PalletEvent::Destroyed { pool_id: 1 } @@ -3382,9 +3506,19 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, + PalletEvent::Withdrawn { + member: 100, + pool_id: 1, + points: 100, + balance: 100 + }, PalletEvent::MemberRemoved { pool_id: 1, member: 100 }, - PalletEvent::Withdrawn { member: 200, pool_id: 1, points: 200, balance: 200 }, + PalletEvent::Withdrawn { + member: 200, + pool_id: 1, + points: 200, + balance: 200 + }, PalletEvent::MemberRemoved { pool_id: 1, member: 200 } ] ); @@ -3432,7 +3566,13 @@ mod withdraw_unbonded { PalletEvent::Created { depositor: 10, pool_id: 1 }, PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 }, + PalletEvent::Unbonded { + member: 100, + pool_id: 1, + points: 100, + balance: 100, + era: 3 + }, PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, PalletEvent::MemberRemoved { pool_id: 1, member: 100 } ] @@ -3649,8 +3789,20 @@ mod withdraw_unbonded { PalletEvent::Created { depositor: 10, pool_id: 1 }, PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Unbonded { member: 100, pool_id: 1, points: 75, balance: 75, era: 3 }, - PalletEvent::Unbonded { member: 100, pool_id: 1, points: 25, balance: 25, era: 4 }, + PalletEvent::Unbonded { + member: 100, + pool_id: 1, + points: 75, + balance: 75, + era: 3 + }, + PalletEvent::Unbonded { + member: 100, + pool_id: 1, + points: 25, + balance: 25, + era: 4 + }, PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 75, balance: 75 }, ] ); @@ -3723,7 +3875,13 @@ mod withdraw_unbonded { PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 7, points: 7, era: 3 }, PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 3, points: 3, era: 4 }, - PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 10, points: 10, era: 4 }, + PalletEvent::Unbonded { + member: 10, + pool_id: 1, + balance: 10, + points: 10, + era: 4 + }, PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 7, points: 7 } ] ); @@ -4389,7 +4547,11 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::RolesUpdated { root: Some(69), state_toggler: None, nominator: None }] + vec![PalletEvent::RolesUpdated { + root: Some(69), + state_toggler: None, + nominator: None + }] ); assert_eq!( @@ -4533,7 +4695,12 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 100000000000, joined: true }, + PalletEvent::Bonded { + member: 30, + pool_id: 1, + bonded: 100000000000, + joined: true + }, // quite small, but working fine. PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 38 } ] diff --git a/frame/nomination-pools/test-staking/src/lib.rs b/frame/nomination-pools/test-staking/src/lib.rs index 53bacabc34cb8..1ef91a6fddcb0 100644 --- a/frame/nomination-pools/test-staking/src/lib.rs +++ b/frame/nomination-pools/test-staking/src/lib.rs @@ -22,8 +22,8 @@ mod mock; use frame_support::{assert_noop, assert_ok, bounded_btree_map, traits::Currency}; use mock::*; use pallet_nomination_pools::{ - BondedPools, Error as PoolsError, PalletEvent as PoolsEvent, LastPoolId, PoolMember, PoolMembers, - PoolState, + BondedPools, Error as PoolsError, LastPoolId, PalletEvent as PoolsEvent, PoolMember, + PoolMembers, PoolState, }; use pallet_staking::{CurrentEra, PalletEvent as StakingEvent, Payee, RewardDestination}; use sp_runtime::traits::Zero; diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index 9ec22d222132a..c04e0bc86aaf7 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -43,8 +43,8 @@ use pallet_session::{ Config as SessionConfig, SessionManager, }; use pallet_staking::{ - Config as StakingConfig, PalletEvent as StakingEvent, Exposure, IndividualExposure, - Pallet as Staking, RewardDestination, ValidatorPrefs, + Config as StakingConfig, Exposure, IndividualExposure, Pallet as Staking, + PalletEvent as StakingEvent, RewardDestination, ValidatorPrefs, }; const SEED: u32 = 0; diff --git a/frame/preimage/src/lib.rs b/frame/preimage/src/lib.rs index ac68b54048db5..6cbb92d575f89 100644 --- a/frame/preimage/src/lib.rs +++ b/frame/preimage/src/lib.rs @@ -76,7 +76,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The Weight information for this pallet. type WeightInfo: weights::WeightInfo; diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 1ad47cf5c7184..855e7dff01217 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -110,7 +110,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter @@ -840,6 +841,8 @@ impl Pallet { } }); let e = call.dispatch(origin); - Self::deposit_event(PalletEvent::ProxyExecuted { result: e.map(|_| ()).map_err(|e| e.error) }); + Self::deposit_event(PalletEvent::ProxyExecuted { + result: e.map(|_| ()).map_err(|e| e.error), + }); } } diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 4163cf81a41f3..214c66c62f6f5 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -682,7 +682,7 @@ pub mod pallet { IdToIndex::::insert(0, &who, index); IndexToId::::insert(0, index, &who); MemberCount::::insert(0, count); - Self::deposit_event(Event::MemberAdded { who }); + Self::deposit_event(PalletEvent::MemberAdded { who }); Ok(()) } @@ -704,7 +704,7 @@ pub mod pallet { IdToIndex::::insert(rank, &who, index); IndexToId::::insert(rank, index, &who); Members::::insert(&who, MemberRecord { rank }); - Self::deposit_event(Event::RankChanged { who, rank }); + Self::deposit_event(PalletEvent::RankChanged { who, rank }); Ok(()) } diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index 7b9ba6e8c38f9..7e8b0bec41b57 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -226,7 +226,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index f72f86c6e691a..38bda3f2a8d63 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -413,8 +413,11 @@ pub mod pallet { let now = frame_system::Pallet::::block_number(); let (info, _, branch) = Self::service_referendum(now, index, status); ReferendumInfoFor::::insert(index, info); - let e = - PalletEvent::::DecisionDepositPlaced { index, who, amount: track.decision_deposit }; + let e = PalletEvent::::DecisionDepositPlaced { + index, + who, + amount: track.decision_deposit, + }; Self::deposit_event(e); Ok(branch.weight_of_deposit::().into()) } @@ -928,7 +931,10 @@ impl, I: 'static> Pallet { if status.deciding.is_none() && now >= timeout { // Too long without being decided - end it. Self::ensure_no_alarm(&mut status); - Self::deposit_event(PalletEvent::::TimedOut { index, tally: status.tally }); + Self::deposit_event(PalletEvent::::TimedOut { + index, + tally: status.tally, + }); return ( ReferendumInfo::TimedOut( now, @@ -991,7 +997,10 @@ impl, I: 'static> Pallet { // Failed! Self::ensure_no_alarm(&mut status); Self::note_one_fewer_deciding(status.track); - Self::deposit_event(PalletEvent::::Rejected { index, tally: status.tally }); + Self::deposit_event(PalletEvent::::Rejected { + index, + tally: status.tally, + }); return ( ReferendumInfo::Rejected( now, diff --git a/frame/remark/src/lib.rs b/frame/remark/src/lib.rs index 4aa587ccb6743..a6c938dac51ad 100644 --- a/frame/remark/src/lib.rs +++ b/frame/remark/src/lib.rs @@ -43,7 +43,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; } diff --git a/frame/remark/src/tests.rs b/frame/remark/src/tests.rs index 8013291d19248..13af160894bff 100644 --- a/frame/remark/src/tests.rs +++ b/frame/remark/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for remarks pallet. -use super::{Error, PalletEvent, Pallet as Remark}; +use super::{Error, Pallet as Remark, PalletEvent}; use crate::mock::*; use frame_support::{assert_noop, assert_ok}; use frame_system::RawOrigin; diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index e4b6f1b1e1d6c..0254f523536f7 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -198,7 +198,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The aggregated origin which the dispatch will take. type Origin: OriginTrait diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 9d91adaa6daca..d6f00a293fd21 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -59,7 +59,8 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } #[pallet::event] diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index ef999ecc68710..5a63166cf8166 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -1138,7 +1138,10 @@ pub mod pallet { } >::remove(&who); - Self::deposit_event(PalletEvent::::SuspendedMemberJudgement { who, judged: forgive }); + Self::deposit_event(PalletEvent::::SuspendedMemberJudgement { + who, + judged: forgive, + }); Ok(()) } @@ -1581,7 +1584,10 @@ impl, I: 'static> Pallet { >::put(&primary); T::MembershipChanged::change_members_sorted(&accounts, &[], members); - Self::deposit_event(PalletEvent::::Inducted { primary, candidates: accounts }); + Self::deposit_event(PalletEvent::::Inducted { + primary, + candidates: accounts, + }); } // Bump the pot by at most PeriodSpend, but less if there's not very much left in our diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index d950601fa89be..2c1a9c0f7645d 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -934,7 +934,9 @@ where if bonded_eras.first().filter(|(_, start)| offence_session >= *start).is_some() { R::report_offence(reporters, offence) } else { - >::deposit_event(PalletEvent::::OldSlashingReportDiscarded(offence_session)); + >::deposit_event(PalletEvent::::OldSlashingReportDiscarded( + offence_session, + )); Ok(()) } } diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index 9f5397fa8b281..bba7584d7a8a7 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -385,7 +385,11 @@ impl Pallet { let issuance = T::Currency::total_issuance(); let (validator_payout, rest) = T::EraPayout::era_payout(staked, issuance, era_duration); - Self::deposit_event(PalletEvent::::EraPaid(active_era.index, validator_payout, rest)); + Self::deposit_event(PalletEvent::::EraPaid( + active_era.index, + validator_payout, + rest, + )); // Set ending era reward. >::insert(&active_era.index, validator_payout); diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 014a321ee7f19..73f859776b6a6 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -129,7 +129,8 @@ pub mod pallet { type RewardRemainder: OnUnbalanced>; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Handler for the unbalanced reduction when slashing a staker. type Slash: OnUnbalanced>; diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 61f0d27375a83..841a549804729 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for the module. -use super::{ConfigOp, PalletEvent, MaxUnlockingChunks, *}; +use super::{ConfigOp, MaxUnlockingChunks, PalletEvent, *}; use frame_election_provider_support::{ElectionProvider, SortedListProvider, Support}; use frame_support::{ assert_noop, assert_ok, assert_storage_noop, bounded_vec, diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 8f477174c1fc2..0bf3a04e4a595 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -452,7 +452,8 @@ pub mod pallet { type SignedFilter: EnsureOrigin; /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The currency provider type. type Currency: Currency; @@ -963,7 +964,7 @@ mod benchmarks { ); frame_system::Pallet::::assert_last_event( - ::Event::from(crate::Event::Slashed { + ::RuntimeEvent::from(crate::PalletEvent::Slashed { who: caller.clone(), amount: T::SignedDepositBase::get() .saturating_add(T::SignedDepositPerItem::get().saturating_mul(1u32.into())), diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 17b95abd2e0c4..c0c25cba5728f 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -115,7 +115,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// A sudo-able call. type Call: Parameter + UnfilteredDispatchable + GetDispatchInfo; @@ -150,7 +151,9 @@ pub mod pallet { ensure!(Self::key().map_or(false, |k| sender == k), Error::::RequireSudo); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - Self::deposit_event(PalletEvent::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) }); + Self::deposit_event(PalletEvent::Sudid { + sudo_result: res.map(|_| ()).map_err(|e| e.error), + }); // Sudo user does not pay a fee. Ok(Pays::No.into()) } @@ -176,7 +179,9 @@ pub mod pallet { ensure!(Self::key().map_or(false, |k| sender == k), Error::::RequireSudo); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - Self::deposit_event(PalletEvent::Sudid { sudo_result: res.map(|_| ()).map_err(|e| e.error) }); + Self::deposit_event(PalletEvent::Sudid { + sudo_result: res.map(|_| ()).map_err(|e| e.error), + }); // Sudo user does not pay a fee. Ok(Pays::No.into()) } diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 9dab2d77d6b0e..026533aedf8d3 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -39,7 +39,8 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } #[pallet::pallet] diff --git a/frame/support/procedural/src/pallet/expand/event.rs b/frame/support/procedural/src/pallet/expand/event.rs index 45fa7e0389c77..0b46372cf4232 100644 --- a/frame/support/procedural/src/pallet/expand/event.rs +++ b/frame/support/procedural/src/pallet/expand/event.rs @@ -61,7 +61,8 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { let event_where_clause = &event.where_clause; // NOTE: actually event where clause must be a subset of config where clause because of - // `type Event: From>`. But we merge either way for potential better error message + // `type Event: From>`. But we merge either way for potential better error + // message let completed_where_clause = super::merge_where_clauses(&[&event.where_clause, &def.config.where_clause]); diff --git a/frame/support/procedural/src/pallet/parse/config.rs b/frame/support/procedural/src/pallet/parse/config.rs index 942fc66e5b5df..ac937c0505533 100644 --- a/frame/support/procedural/src/pallet/parse/config.rs +++ b/frame/support/procedural/src/pallet/parse/config.rs @@ -43,7 +43,8 @@ pub struct ConfigDef { pub has_instance: bool, /// Const associated type. pub consts_metadata: Vec, - /// Whether the trait has the associated type `PalletEvent`, note that those bounds are checked: + /// Whether the trait has the associated type `PalletEvent`, note that those bounds are + /// checked: /// * `IsType::RuntimeEvent` /// * `From` or `From>` or `From>` pub has_event_type: bool, diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 79b44e72c6bc5..6ad4531d1c6c0 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -125,7 +125,8 @@ pub mod pallet { type Balance: Parameter + Default + TypeInfo; - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } #[pallet::extra_constants] diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index 3ed046ad58a33..eb36e74ed2994 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -43,7 +43,8 @@ mod pallet_old { + Into + Default + SomeAssociation; - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + + Into<::RuntimeEvent>; } decl_storage! { @@ -120,7 +121,8 @@ pub mod pallet { + scale_info::StaticTypeInfo; #[pallet::constant] type SomeConst: Get; - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; } #[pallet::pallet] diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 7c0654f09454b..1bd9ee1adae79 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -30,7 +30,8 @@ mod pallet_old { pub trait Config: frame_system::Config { type SomeConst: Get; type Balance: Parameter + codec::HasCompact + From + Into + Default; - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + + Into<::RuntimeEvent>; } decl_storage! { diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 5b64358decf70..3061375e217cd 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -737,7 +737,9 @@ fn metadata() { ], }), calls: Some(scale_info::meta_type::>().into()), - event: Some(PalletEventMetadata { ty: scale_info::meta_type::>() }), + event: Some(PalletEventMetadata { + ty: scale_info::meta_type::>(), + }), constants: vec![PalletConstantMetadata { name: "MyGetParam", ty: scale_info::meta_type::(), @@ -758,7 +760,8 @@ fn metadata() { } match example_pallet_instance1_metadata.event { Some(ref mut event_meta) => { - event_meta.ty = scale_info::meta_type::>(); + event_meta.ty = + scale_info::meta_type::>(); }, _ => unreachable!(), } diff --git a/frame/transaction-payment/asset-tx-payment/src/lib.rs b/frame/transaction-payment/asset-tx-payment/src/lib.rs index de5d6d5962998..827a9635f2692 100644 --- a/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -114,7 +114,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_transaction_payment::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The fungibles instance used to pay for transactions in assets. type Fungibles: Balanced; /// The actual transaction charging logic that charges the fees. diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index befb4b25645e9..24625cad40394 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -250,7 +250,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// Handler for withdrawing, refunding and depositing the transaction fee. /// Transaction fees are withdrawn before the transaction is executed. @@ -771,7 +772,11 @@ where T::OnChargeTransaction::correct_and_deposit_fee( &who, info, post_info, actual_fee, tip, imbalance, )?; - Pallet::::deposit_event(PalletEvent::::TransactionFeePaid { who, actual_fee, tip }); + Pallet::::deposit_event(PalletEvent::::TransactionFeePaid { + who, + actual_fee, + tip, + }); } Ok(()) } @@ -1426,9 +1431,9 @@ mod tests { pallet_balances::PalletEvent::Transfer { from: 2, to: 3, amount: 80 }, )); // Killed Event - System::assert_has_event(RuntimeEvent::System(system::PalletEvent::KilledAccount { - account: 2, - })); + System::assert_has_event(RuntimeEvent::System( + system::PalletEvent::KilledAccount { account: 2 }, + )); }); } diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index c9e296408fc88..fb7b5694d5419 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -92,7 +92,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// A dispatchable call. type Call: Parameter + Dispatchable diff --git a/frame/uniques/src/impl_nonfungibles.rs b/frame/uniques/src/impl_nonfungibles.rs index abb1b57ea2ade..a5e20dd9c2f0c 100644 --- a/frame/uniques/src/impl_nonfungibles.rs +++ b/frame/uniques/src/impl_nonfungibles.rs @@ -98,7 +98,11 @@ impl, I: 'static> Create<::AccountId> for Pallet admin.clone(), T::CollectionDeposit::get(), false, - PalletEvent::Created { collection: *collection, creator: who.clone(), owner: admin.clone() }, + PalletEvent::Created { + collection: *collection, + creator: who.clone(), + owner: admin.clone(), + }, ) } } diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index 75de1aff374dc..b5632ec12623d 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -902,7 +902,12 @@ pub mod pallet { details.admin = admin.clone(); details.freezer = freezer.clone(); - Self::deposit_event(PalletEvent::TeamChanged { collection, issuer, admin, freezer }); + Self::deposit_event(PalletEvent::TeamChanged { + collection, + issuer, + admin, + freezer, + }); Ok(()) }) } @@ -1334,7 +1339,11 @@ pub mod pallet { *metadata = Some(CollectionMetadata { deposit, data: data.clone(), is_frozen }); - Self::deposit_event(PalletEvent::CollectionMetadataSet { collection, data, is_frozen }); + Self::deposit_event(PalletEvent::CollectionMetadataSet { + collection, + data, + is_frozen, + }); Ok(()) }) } diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 83a520b10532b..b6be9c3bbcef8 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -411,7 +411,8 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), + utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") } + .into(), ); // No weight is refunded assert_eq!(extract_actual_weight(&result, &info), info.weight); @@ -426,7 +427,8 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), + utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") } + .into(), ); assert_eq!(extract_actual_weight(&result, &info), info.weight - diff * batch_len); @@ -439,7 +441,8 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), + utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") } + .into(), ); assert_eq!( extract_actual_weight(&result, &info), diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 6e9cac1177489..1da057f124a21 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -155,7 +155,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The currency trait. type Currency: LockableCurrency; diff --git a/frame/whitelist/src/lib.rs b/frame/whitelist/src/lib.rs index 4d026a2e99ba5..da822d6e06cb0 100644 --- a/frame/whitelist/src/lib.rs +++ b/frame/whitelist/src/lib.rs @@ -61,7 +61,8 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + + IsType<::RuntimeEvent>; /// The overarching call type. type Call: IsType<::Call> From 9892a96628a39e122d5ae7fac0201062cc8c3df2 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 17:59:56 +0200 Subject: [PATCH 19/63] additional renaming --- bin/node/cli/tests/websocket_server.rs | 2 +- frame/beefy-mmr/src/mock.rs | 2 +- frame/collective/src/tests.rs | 2 +- frame/contracts/src/exec.rs | 2 +- frame/contracts/src/tests.rs | 37 ++-- frame/grandpa/src/mock.rs | 6 +- frame/im-online/src/mock.rs | 2 +- frame/nomination-pools/src/tests.rs | 4 +- frame/offences/benchmarking/src/mock.rs | 4 +- frame/offences/src/mock.rs | 2 +- frame/proxy/src/tests.rs | 4 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/session/src/mock.rs | 4 +- frame/staking/src/mock.rs | 4 +- frame/support/src/event.rs | 6 +- frame/support/test/tests/construct_runtime.rs | 184 +++++++++--------- frame/support/test/tests/pallet.rs | 2 +- .../test/tests/pallet_compatibility.rs | 2 +- .../tests/pallet_with_name_trait_is_valid.rs | 2 +- frame/support/test/tests/system.rs | 2 +- frame/system/benches/bench.rs | 2 +- frame/uniques/src/tests.rs | 2 +- frame/utility/src/tests.rs | 2 +- 23 files changed, 139 insertions(+), 142 deletions(-) diff --git a/bin/node/cli/tests/websocket_server.rs b/bin/node/cli/tests/websocket_server.rs index 513497c6cddb5..dc03aaf72f63f 100644 --- a/bin/node/cli/tests/websocket_server.rs +++ b/bin/node/cli/tests/websocket_server.rs @@ -242,7 +242,7 @@ impl WsServer { /// Event that has happened on a [`WsServer`]. #[derive(Debug)] -pub enum Event { +pub enum PalletEvent { /// A new TCP connection has arrived on the listening socket. /// /// The connection *must* be accepted or rejected using [`WsServer::accept`] or diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 15e33ac60025a..9b0e1d01abdf9 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -55,7 +55,7 @@ construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, Mmr: pallet_mmr::{Pallet, Storage}, Beefy: pallet_beefy::{Pallet, Config, Storage}, BeefyMmr: pallet_beefy_mmr::{Pallet, Storage}, diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index d60b71927c7a3..148627aaf26da 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{Event as CollectiveEvent, *}; +use super::{PalletEvent as CollectiveEvent, *}; use crate as pallet_collective; use frame_support::{ assert_noop, assert_ok, parameter_types, diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index a419bb7641e15..812d5a2acc7e4 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1376,7 +1376,7 @@ mod tests { static LOADER: RefCell = RefCell::new(MockLoader::default()); } - fn events() -> Vec> { + fn events() -> Vec> { System::events() .into_iter() .filter_map(|meta| match meta.event { diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 77bf5be9ce2b0..733b6eae519e0 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -67,7 +67,7 @@ frame_support::construct_runtime!( Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Randomness: pallet_randomness_collective_flip::{Pallet, Storage}, - Utility: pallet_utility::{Pallet, Call, Storage, PalletEvent}, + Utility: pallet_utility::{Pallet, Call, Storage, Event}, Contracts: pallet_contracts::{Pallet, Call, Storage, Event}, } ); @@ -139,7 +139,7 @@ impl TestExtension { } fn last_seen_inputs() -> (u32, u32, u32, u32) { - TEST_EXTENSION.with(|e| e.borrow().last_seen_inputs) + TEST_EXTENSION.with(|e| e.borrow().last_seen_inputs.clone()) } } @@ -158,14 +158,14 @@ impl ChainExtension for TestExtension { let func_id = env.func_id(); let id = env.ext_id() as u32 | func_id as u32; match func_id { - 0x8000 => { + 0 => { let mut env = env.buf_in_buf_out(); let input = env.read(8)?; env.write(&input, false, None)?; TEST_EXTENSION.with(|e| e.borrow_mut().last_seen_buffer = input); Ok(RetVal::Converging(id)) }, - 0x8001 => { + 1 => { let env = env.only_in(); TEST_EXTENSION.with(|e| { e.borrow_mut().last_seen_inputs = @@ -173,13 +173,13 @@ impl ChainExtension for TestExtension { }); Ok(RetVal::Converging(id)) }, - 0x8002 => { + 2 => { let mut env = env.buf_in_buf_out(); let weight = env.read(5)?[4].into(); env.charge_weight(weight)?; Ok(RetVal::Converging(id)) }, - 0x8003 => Ok(RetVal::Diverging { flags: ReturnFlags::REVERT, data: vec![42, 99] }), + 3 => Ok(RetVal::Diverging { flags: ReturnFlags::REVERT, data: vec![42, 99] }), _ => { panic!("Passed unknown id to test chain extension: {}", func_id); }, @@ -1652,22 +1652,21 @@ fn chain_extension_works() { ),); let addr = Contracts::contract_address(&ALICE, &hash, &[]); - // 0x8000 = read input buffer and pass it through as output - let input: Vec = - ExtensionInput { extension_id: 0, func_id: 0x8000, extra: &[99] }.into(); + // 0 = read input buffer and pass it through as output + let input: Vec = ExtensionInput { extension_id: 0, func_id: 0, extra: &[99] }.into(); let result = Contracts::bare_call(ALICE, addr.clone(), 0, GAS_LIMIT, None, input.clone(), false); assert_eq!(TestExtension::last_seen_buffer(), input); assert_eq!(result.result.unwrap().data, Bytes(input)); - // 0x8001 = treat inputs as integer primitives and store the supplied integers + // 1 = treat inputs as integer primitives and store the supplied integers Contracts::bare_call( ALICE, addr.clone(), 0, GAS_LIMIT, None, - ExtensionInput { extension_id: 0, func_id: 0x8001, extra: &[] }.into(), + ExtensionInput { extension_id: 0, func_id: 1, extra: &[] }.into(), false, ) .result @@ -1675,14 +1674,14 @@ fn chain_extension_works() { // those values passed in the fixture assert_eq!(TestExtension::last_seen_inputs(), (4, 4, 16, 12)); - // 0x8002 = charge some extra weight (amount supplied in the fifth byte) + // 2 = charge some extra weight (amount supplied in the fifth byte) let result = Contracts::bare_call( ALICE, addr.clone(), 0, GAS_LIMIT, None, - ExtensionInput { extension_id: 0, func_id: 0x8002, extra: &[0] }.into(), + ExtensionInput { extension_id: 0, func_id: 2, extra: &[0] }.into(), false, ); assert_ok!(result.result); @@ -1693,7 +1692,7 @@ fn chain_extension_works() { 0, GAS_LIMIT, None, - ExtensionInput { extension_id: 0, func_id: 0x8002, extra: &[42] }.into(), + ExtensionInput { extension_id: 0, func_id: 2, extra: &[42] }.into(), false, ); assert_ok!(result.result); @@ -1704,20 +1703,20 @@ fn chain_extension_works() { 0, GAS_LIMIT, None, - ExtensionInput { extension_id: 0, func_id: 0x8002, extra: &[95] }.into(), + ExtensionInput { extension_id: 0, func_id: 2, extra: &[95] }.into(), false, ); assert_ok!(result.result); assert_eq!(result.gas_consumed, gas_consumed + 95); - // 0x8003 = diverging chain extension call that sets flags to 0x1 and returns a fixed buffer + // 3 = diverging chain extension call that sets flags to 0x1 and returns a fixed buffer let result = Contracts::bare_call( ALICE, addr.clone(), 0, GAS_LIMIT, None, - ExtensionInput { extension_id: 0, func_id: 0x8003, extra: &[] }.into(), + ExtensionInput { extension_id: 0, func_id: 3, extra: &[] }.into(), false, ) .result @@ -3494,8 +3493,8 @@ fn set_code_hash() { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::PalletEvent::ContractCodeUpdated { contract: contract_addr.clone(), - new_code_hash, - old_code_hash: code_hash, + new_code_hash: new_code_hash.clone(), + old_code_hash: code_hash.clone(), }), topics: vec![], }, diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 5fb7326fc2803..597b6ac145352 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -56,9 +56,9 @@ frame_support::construct_runtime!( Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, - Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, PalletEvent, ValidateUnsigned}, - Offences: pallet_offences::{Pallet, Storage, PalletEvent}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, + Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned}, + Offences: pallet_offences::{Pallet, Storage, Event}, Historical: pallet_session_historical::{Pallet}, } ); diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 24f87066a4f74..b6b7295f60d34 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -51,7 +51,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, ImOnline: imonline::{Pallet, Call, Storage, Config, Event}, Historical: pallet_session_historical::{Pallet}, } diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index f52025ced7646..88b6a4fd0b473 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -18,7 +18,7 @@ use super::*; use crate::{mock::*, PalletEvent}; use frame_support::{assert_err, assert_noop, assert_ok, assert_storage_noop, bounded_btree_map}; -use pallet_balances::Event as BEvent; +use pallet_balances::PalletEvent as BEvent; use sp_runtime::traits::Dispatchable; macro_rules! unbonding_pools_with_era { @@ -4250,7 +4250,7 @@ mod set_configs { mod bond_extra { use super::*; - use crate::Event; + use crate::PalletEvent; #[test] fn bond_extra_from_free_balance_creator() { diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 1d34220fd2d9c..7158e8d1ff8b0 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -225,9 +225,9 @@ frame_support::construct_runtime!( System: system::{Pallet, Call, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, ImOnline: pallet_im_online::{Pallet, Call, Storage, Event, ValidateUnsigned, Config}, - Offences: pallet_offences::{Pallet, Storage, PalletEvent}, + Offences: pallet_offences::{Pallet, Storage, Event}, Historical: pallet_session_historical::{Pallet}, } ); diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 2b1505451f7a3..7466b7e4adc40 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -80,7 +80,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Offences: offences::{Pallet, Storage, PalletEvent}, + Offences: offences::{Pallet, Storage, Event}, } ); diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index a6d1e91f7cbc4..06fd9399dd4ff 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -48,7 +48,7 @@ frame_support::construct_runtime!( System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Proxy: proxy::{Pallet, Call, Storage, Event}, - Utility: pallet_utility::{Pallet, Call, PalletEvent}, + Utility: pallet_utility::{Pallet, Call, Event}, } ); @@ -543,7 +543,7 @@ fn anonymous_works() { let anon = Proxy::anonymous_account(&1, &ProxyType::Any, 0, None); System::assert_last_event( ProxyEvent::AnonymousCreated { - anonymous: anon, + anonymous: anon.clone(), who: 1, proxy_type: ProxyType::Any, disambiguation_index: 0, diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 901588de29cee..6094a43d00c5b 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -43,7 +43,7 @@ frame_support::construct_runtime!( System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } ); diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 4b22e117cb3af..587d646158524 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -86,7 +86,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, Historical: pallet_session_historical::{Pallet}, } ); @@ -99,7 +99,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, } ); diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index cef4e1bb069fc..0212c2a92cd46 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -98,7 +98,7 @@ frame_support::construct_runtime!( Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, Staking: pallet_staking::{Pallet, Call, Config, Storage, Event}, - Session: pallet_session::{Pallet, Call, Storage, PalletEvent, Config}, + Session: pallet_session::{Pallet, Call, Storage, Event, Config}, Historical: pallet_session::historical::{Pallet, Storage}, BagsList: pallet_bags_list::{Pallet, Call, Storage, Event}, } @@ -826,7 +826,7 @@ pub(crate) fn on_offence_now( pub(crate) fn add_slash(who: &AccountId) { on_offence_now( &[OffenceDetails { - offender: (*who, Staking::eras_stakers(active_era(), *who)), + offender: (who.clone(), Staking::eras_stakers(active_era(), who.clone())), reporters: vec![], }], &[Perbill::from_percent(10)], diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index cee8293f060a8..9040c29b69ddf 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -47,7 +47,7 @@ /// mod event1 { /// // Event that specifies the generic parameter explicitly (`Balance`). /// frame_support::decl_event!( -/// pub enum Event where Balance = ::Balance { +/// pub enum PalletEvent where Balance = ::Balance { /// Message(Balance), /// } /// ); @@ -58,7 +58,7 @@ /// // If no name for the generic parameter is specified explicitly, /// // the name will be taken from the type name of the trait. /// frame_support::decl_event!( -/// pub enum Event where ::Balance { +/// pub enum PalletEvent where ::Balance { /// Message(Balance), /// } /// ); @@ -67,7 +67,7 @@ /// mod event3 { /// // And we even support declaring multiple generic parameters! /// frame_support::decl_event!( -/// pub enum Event where ::Balance, ::Token { +/// pub enum PalletEvent where ::Balance, ::Token { /// Message(Balance, Token), /// } /// ); diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index adb79449ee446..87c7bc9a85a5f 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -262,10 +262,10 @@ frame_support::construct_runtime!( { System: system::{Pallet, Call, Event, Origin} = 30, Module1_1: module1::::{Pallet, Call, Storage, Event, Origin}, - Module2: module2::{Pallet, Call, Storage, PalletEvent, Origin}, + Module2: module2::{Pallet, Call, Storage, Event, Origin}, Module1_2: module1::::{Pallet, Call, Storage, Event, Origin}, - NestedModule3: nested::module3::{Pallet, Call, Config, Storage, PalletEvent, Origin}, - Module3: self::module3::{Pallet, Call, Config, Storage, PalletEvent, Origin}, + NestedModule3: nested::module3::{Pallet, Call, Config, Storage, Event, Origin}, + Module3: self::module3::{Pallet, Call, Config, Storage, Event, Origin}, Module1_3: module1::::{Pallet, Storage} = 6, Module1_4: module1::::{Pallet, Call} = 3, Module1_5: module1::::{Pallet, Event}, @@ -282,96 +282,94 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 31, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module2::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 32, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_2::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 33, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - NestedModule3::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 34, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_3::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 6, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_4::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 3, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_5::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 4, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_6::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 1, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_7::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 2, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_8::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 12, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_9::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 13, - error: [0; 4], - message: Some("Something") - })), - ); - }); + assert_eq!( + Module1_1::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 31, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module2::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 32, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_2::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 33, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + NestedModule3::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 34, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_3::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 6, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_4::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 3, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_5::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 4, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_6::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 1, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_7::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 2, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_8::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 12, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_9::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 13, + error: [0; 4], + message: Some("Something") + })), + ); } #[test] diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 6ad4531d1c6c0..017aa5750d0a8 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -1378,7 +1378,7 @@ fn metadata() { ], }), calls: None, - event: Some(PalletEventMetadata { ty: meta_type::() }), + event: Some(PalletEventMetadata { ty: meta_type::() }), constants: vec![], error: None, }, diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index eb36e74ed2994..a4940607b7ea0 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -61,7 +61,7 @@ mod pallet_old { } decl_event!( - pub enum Event + pub enum PalletEvent where Balance = ::Balance, { diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 19171e1b8e4fa..3184aed5bd54b 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -28,7 +28,7 @@ frame_support::decl_storage! { } frame_support::decl_event!( - pub enum Event + pub enum PalletEvent where B = ::Balance, { diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index d660e791a59f9..8e5dbf05548c8 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -47,7 +47,7 @@ impl Module { } frame_support::decl_event!( - pub enum Event + pub enum PalletEvent where BlockNumber = ::BlockNumber, { diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index f11874fd21f86..3790abcd22fcf 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -54,7 +54,7 @@ frame_support::construct_runtime!( UncheckedExtrinsic = UncheckedExtrinsic, { System: frame_system::{Pallet, Call, Config, Storage, Event}, - Module: module::{Pallet, PalletEvent}, + Module: module::{Pallet, Event}, } ); diff --git a/frame/uniques/src/tests.rs b/frame/uniques/src/tests.rs index d3a57a9384479..6e7fbc9da1330 100644 --- a/frame/uniques/src/tests.rs +++ b/frame/uniques/src/tests.rs @@ -70,7 +70,7 @@ fn attributes(collection: u32) -> Vec<(Option, Vec, Vec)> { s } -fn events() -> Vec> { +fn events() -> Vec> { let result = System::events() .into_iter() .map(|r| r.event) diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index b6be9c3bbcef8..2f3df4b58d5f2 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -92,7 +92,7 @@ frame_support::construct_runtime!( { System: frame_system::{Pallet, Call, Config, Storage, Event}, Balances: pallet_balances::{Pallet, Call, Storage, Config, Event}, - Utility: utility::{Pallet, Call, PalletEvent}, + Utility: utility::{Pallet, Call, Event}, Example: example::{Pallet, Call}, } ); From d4c28cf17fa07874a824173ab7c0ba600898e4c9 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 18:02:50 +0200 Subject: [PATCH 20/63] fix. --- frame/bounties/src/tests.rs | 2 +- frame/child-bounties/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index fe0bc31604526..6eca4cf918ad7 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -38,7 +38,7 @@ use sp_runtime::{ BuildStorage, Perbill, Storage, }; -use super::Event as BountiesEvent; +use super::PalletEvent as BountiesEvent; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 7189f0f41dc40..0b1e14cebd5cd 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -39,7 +39,7 @@ use sp_runtime::{ Perbill, Permill, }; -use super::Event as ChildBountiesEvent; +use super::PalletEvent as ChildBountiesEvent; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; From dffa487d792dbd359d41849a879343fc415b85f8 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 19:07:39 +0200 Subject: [PATCH 21/63] fix decl_event --- frame/support/procedural/src/pallet/parse/config.rs | 2 +- frame/support/src/event.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/support/procedural/src/pallet/parse/config.rs b/frame/support/procedural/src/pallet/parse/config.rs index ac937c0505533..b14809fcdc53f 100644 --- a/frame/support/procedural/src/pallet/parse/config.rs +++ b/frame/support/procedural/src/pallet/parse/config.rs @@ -46,7 +46,7 @@ pub struct ConfigDef { /// Whether the trait has the associated type `PalletEvent`, note that those bounds are /// checked: /// * `IsType::RuntimeEvent` - /// * `From` or `From>` or `From>` + /// * `From` or `From>` or `From>` pub has_event_type: bool, /// The where clause on trait definition but modified so `Self` is `T`. pub where_clause: Option, diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index 9040c29b69ddf..78d0f37cefd61 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -140,7 +140,7 @@ macro_rules! decl_event { )* } impl From for () { - fn from(_: Event) -> () { () } + fn from(_: PalletEvent) -> () { () } } } } @@ -259,7 +259,7 @@ macro_rules! __decl_generic_event { /// /// [`RawEvent`]: enum.RawEvent.html /// [`Config`]: trait.Config.html - pub type Event<$event_generic_param $(, $instance $( = $event_default_instance)? )?> = RawEvent<$( $generic_type ),* $(, $instance)? >; + pub type PalletEvent<$event_generic_param $(, $instance $( = $event_default_instance)? )?> = RawEvent<$( $generic_type ),* $(, $instance)? >; #[derive( Clone, PartialEq, Eq, From 100c7e4d984451a5cf2ce4d2b6b086f27c6a10e2 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 19:14:40 +0200 Subject: [PATCH 22/63] rename in tests --- frame/support/test/tests/construct_runtime.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 87c7bc9a85a5f..801eb448141ce 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -601,7 +601,7 @@ fn test_metadata() { name: "Module2", storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::().into()), constants: vec![], error: None, index: 32, @@ -619,7 +619,7 @@ fn test_metadata() { name: "NestedModule3", storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::().into()), constants: vec![], error: None, index: 34, @@ -628,7 +628,7 @@ fn test_metadata() { name: "Module3", storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::().into()), constants: vec![], error: None, index: 35, From 19035044a2a955c87d933ebe4b5685883a0a6dde Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 19:19:50 +0200 Subject: [PATCH 23/63] remove warnings --- frame/contracts/src/tests.rs | 6 +++--- frame/proxy/src/tests.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 733b6eae519e0..1386dba04a16b 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -139,7 +139,7 @@ impl TestExtension { } fn last_seen_inputs() -> (u32, u32, u32, u32) { - TEST_EXTENSION.with(|e| e.borrow().last_seen_inputs.clone()) + TEST_EXTENSION.with(|e| e.borrow().last_seen_inputs) } } @@ -3493,8 +3493,8 @@ fn set_code_hash() { phase: Phase::Initialization, event: RuntimeEvent::Contracts(crate::PalletEvent::ContractCodeUpdated { contract: contract_addr.clone(), - new_code_hash: new_code_hash.clone(), - old_code_hash: code_hash.clone(), + new_code_hash, + old_code_hash: code_hash, }), topics: vec![], }, diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 06fd9399dd4ff..ce892f53cca30 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -543,7 +543,7 @@ fn anonymous_works() { let anon = Proxy::anonymous_account(&1, &ProxyType::Any, 0, None); System::assert_last_event( ProxyEvent::AnonymousCreated { - anonymous: anon.clone(), + anonymous: anon, who: 1, proxy_type: ProxyType::Any, disambiguation_index: 0, From 6a33348cea5a069fb67080e7d733ca0b97f36a4c Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 19:25:57 +0200 Subject: [PATCH 24/63] remove accidental rename --- bin/node/cli/tests/websocket_server.rs | 2 +- frame/staking/src/mock.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/node/cli/tests/websocket_server.rs b/bin/node/cli/tests/websocket_server.rs index dc03aaf72f63f..513497c6cddb5 100644 --- a/bin/node/cli/tests/websocket_server.rs +++ b/bin/node/cli/tests/websocket_server.rs @@ -242,7 +242,7 @@ impl WsServer { /// Event that has happened on a [`WsServer`]. #[derive(Debug)] -pub enum PalletEvent { +pub enum Event { /// A new TCP connection has arrived on the listening socket. /// /// The connection *must* be accepted or rejected using [`WsServer::accept`] or diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 0212c2a92cd46..1efc116e29b10 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -826,7 +826,7 @@ pub(crate) fn on_offence_now( pub(crate) fn add_slash(who: &AccountId) { on_offence_now( &[OffenceDetails { - offender: (who.clone(), Staking::eras_stakers(active_era(), who.clone())), + offender: (*who, Staking::eras_stakers(active_era(), who.clone())), reporters: vec![], }], &[Perbill::from_percent(10)], From 8df4b49423a735a902f9324978fb33379148c3d0 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 19:29:12 +0200 Subject: [PATCH 25/63] . --- frame/staking/src/mock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 1efc116e29b10..ebdef4d247e4d 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -826,7 +826,7 @@ pub(crate) fn on_offence_now( pub(crate) fn add_slash(who: &AccountId) { on_offence_now( &[OffenceDetails { - offender: (*who, Staking::eras_stakers(active_era(), who.clone())), + offender: (*who, Staking::eras_stakers(active_era(), *who)), reporters: vec![], }], &[Perbill::from_percent(10)], From b040a45cf10fce378dfc4d1d486b8f5a8a17c696 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 21 Aug 2022 20:23:52 +0200 Subject: [PATCH 26/63] commit --- frame/support/test/tests/construct_runtime.rs | 178 +++++++++--------- 1 file changed, 90 insertions(+), 88 deletions(-) diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 801eb448141ce..aa9962c7af05e 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -282,94 +282,96 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 31, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module2::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 32, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_2::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 33, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - NestedModule3::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 34, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_3::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 6, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_4::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 3, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_5::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 4, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_6::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 1, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_7::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 2, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_8::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 12, - error: [0; 4], - message: Some("Something") - })), - ); - assert_eq!( - Module1_9::fail(system::Origin::::Root.into()), - Err(DispatchError::Module(ModuleError { - index: 13, - error: [0; 4], - message: Some("Something") - })), - ); + sp_io::TestExternalities::default().execute_with(|| { + assert_eq!( + Module1_1::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 31, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module2::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 32, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_2::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 33, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + NestedModule3::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 34, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_3::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 6, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_4::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 3, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_5::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 4, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_6::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 1, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_7::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 2, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_8::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 12, + error: [0; 4], + message: Some("Something") + })), + ); + assert_eq!( + Module1_9::fail(system::Origin::::Root.into()), + Err(DispatchError::Module(ModuleError { + index: 13, + error: [0; 4], + message: Some("Something") + })), + ); + }) } #[test] From e52ced1c0e56a9e80a9d0229fffff3eeb9e23428 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 22 Aug 2022 08:50:59 +0200 Subject: [PATCH 27/63] update .stderr --- frame/support/test/tests/pallet_ui/event_not_in_trait.stderr | 2 +- .../support/test/tests/pallet_ui/event_type_invalid_bound.rs | 2 +- .../test/tests/pallet_ui/event_type_invalid_bound.stderr | 4 ++-- .../test/tests/pallet_ui/event_type_invalid_bound_2.stderr | 4 ++-- .../support/test/tests/pallet_ui/event_wrong_item_name.stderr | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr b/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr index e3126ad6a85dc..709ef4fda2d82 100644 --- a/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr +++ b/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr @@ -1,4 +1,4 @@ -error: Invalid usage of Event, `Config` contains no associated type `Event`, but enum `Event` is declared (in use of `#[pallet::event]`). An Event associated type must be declare on trait `Config`. +error: Invalid usage of RuntimeEvent, `Config` contains no associated type `RuntimeEvent`, but enum `RuntimeEvent` is declared (in use of `#[pallet::event]`). An RuntimeEvent associated type must be declare on trait `Config`. --> $DIR/event_not_in_trait.rs:1:1 | 1 | #[frame_support::pallet] diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs index e6cd29cac08bb..1f10d2d4e357a 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs @@ -6,7 +6,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar; - type Event; + type RuntimeEvent; } #[pallet::pallet] diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr index ea4fb7b88a512..d54149d719a3b 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.stderr @@ -1,5 +1,5 @@ -error: Invalid `type Event`, associated type `Event` is reserved and must bound: `IsType<::RuntimeEvent>` +error: Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must bound: `IsType<::RuntimeEvent>` --> $DIR/event_type_invalid_bound.rs:9:3 | -9 | type Event; +9 | type RuntimeEvent; | ^^^^ diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr index fc7272f3905ee..d54fa85196051 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr @@ -1,5 +1,5 @@ -error: Invalid `type Event`, associated type `Event` is reserved and must bound: `From` or `From>` or `From>` +error: Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must bound: `From` or `From>` or `From>` --> $DIR/event_type_invalid_bound_2.rs:9:3 | -9 | type Event: IsType<::RuntimeEvent>; +9 | type RuntimeEvent: IsType<::RuntimeEvent>; | ^^^^ diff --git a/frame/support/test/tests/pallet_ui/event_wrong_item_name.stderr b/frame/support/test/tests/pallet_ui/event_wrong_item_name.stderr index 14e8615c56199..9636144366657 100644 --- a/frame/support/test/tests/pallet_ui/event_wrong_item_name.stderr +++ b/frame/support/test/tests/pallet_ui/event_wrong_item_name.stderr @@ -1,4 +1,4 @@ -error: expected `Event` +error: expected `PalletEvent` --> $DIR/event_wrong_item_name.rs:19:11 | 19 | pub enum Foo {} From e95fecb724db1f1473be5c9292c3450da1901ce2 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 22 Aug 2022 09:06:57 +0200 Subject: [PATCH 28/63] fix in test --- .../test/tests/construct_runtime_ui/undefined_event_part.rs | 2 +- .../tests/construct_runtime_ui/undefined_event_part.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index 30d8462122219..bea30a73bab7d 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -53,7 +53,7 @@ construct_runtime! { UncheckedExtrinsic = UncheckedExtrinsic { System: frame_system::{Pallet, Call, Storage, Config, Event}, - Pallet: pallet::{Pallet, PalletEvent}, + Pallet: pallet::{Pallet, Event}, } } diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index ec75a9dcdb61e..2af4d3fb15000 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -41,7 +41,7 @@ help: if you import `Event`, refer to it directly 53 - UncheckedExtrinsic = UncheckedExtrinsic 54 - { 55 - System: frame_system::{Pallet, Call, Storage, Config, Event}, -56 - Pallet: pallet::{Pallet, PalletEvent}, +56 - Pallet: pallet::{Pallet, Event}, 57 - } 58 - } | @@ -74,7 +74,7 @@ help: if you import `Event`, refer to it directly 53 - UncheckedExtrinsic = UncheckedExtrinsic 54 - { 55 - System: frame_system::{Pallet, Call, Storage, Config, Event}, -56 - Pallet: pallet::{Pallet, PalletEvent}, +56 - Pallet: pallet::{Pallet, Event}, 57 - } 58 - } | From 13727221d67372de5a38f88bffd9b3dc4ea564cf Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 22 Aug 2022 09:27:26 +0200 Subject: [PATCH 29/63] update .stderr --- .../undefined_event_part.stderr | 40 ++----------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index 2af4d3fb15000..6102092ecbdd0 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -14,8 +14,7 @@ error: `Pallet` does not have #[pallet::event] defined, perhaps you should remov | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_event_check::is_event_part_defined` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0412]: cannot find type `Event` in module `pallet` +error[E0412]: cannot find type `PalletEvent` in module `pallet` --> tests/construct_runtime_ui/undefined_event_part.rs:49:1 | 49 | / construct_runtime! { @@ -30,42 +29,9 @@ error[E0412]: cannot find type `Event` in module `pallet` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this enum | -1 | use frame_system::Event; +1 | use frame_system::PalletEvent; | -help: if you import `Event`, refer to it directly - | -49 - construct_runtime! { -50 - pub enum Runtime where -51 - Block = Block, -52 - NodeBlock = Block, -53 - UncheckedExtrinsic = UncheckedExtrinsic -54 - { -55 - System: frame_system::{Pallet, Call, Storage, Config, Event}, -56 - Pallet: pallet::{Pallet, Event}, -57 - } -58 - } - | - -error[E0412]: cannot find type `Event` in module `pallet` - --> tests/construct_runtime_ui/undefined_event_part.rs:49:1 - | -49 | / construct_runtime! { -50 | | pub enum Runtime where -51 | | Block = Block, -52 | | NodeBlock = Block, -... | -57 | | } -58 | | } - | |_^ not found in `pallet` - | - = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) -help: consider importing one of these items - | -1 | use crate::Event; - | -1 | use frame_system::Event; - | -help: if you import `Event`, refer to it directly +help: if you import `PalletEvent`, refer to it directly | 49 - construct_runtime! { 50 - pub enum Runtime where From 29a85b33a7f78fb5a9ee731696da9d1545190665 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 22 Aug 2022 14:17:20 +0200 Subject: [PATCH 30/63] TRYBUILD=overwrite --- .../test/tests/construct_runtime_ui/undefined_event_part.stderr | 1 + 1 file changed, 1 insertion(+) diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index 6102092ecbdd0..fc9691d32bba4 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -14,6 +14,7 @@ error: `Pallet` does not have #[pallet::event] defined, perhaps you should remov | |_- in this macro invocation | = note: this error originates in the macro `pallet::__substrate_event_check::is_event_part_defined` (in Nightly builds, run with -Z macro-backtrace for more info) + error[E0412]: cannot find type `PalletEvent` in module `pallet` --> tests/construct_runtime_ui/undefined_event_part.rs:49:1 | From add05af9f1815d0435ae660b71d25dffd7683bfd Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 22 Aug 2022 17:09:50 +0200 Subject: [PATCH 31/63] docs --- frame/support/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index f7fe0f51b4f7c..c821c43d596fd 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -1429,7 +1429,7 @@ pub mod pallet_prelude { /// I.e. a regular trait definition named `Config`, with supertrait `frame_system::Config`, /// optionally other supertrait and where clause. /// -/// The associated type `Event` is reserved, if defined it must bounds `From` and +/// The associated type `RuntimeEvent` is reserved, if defined it must bounds `From` and /// `IsType<::RuntimeEvent>`, see `#[pallet::event]` for more /// information. /// From f0bb9892fe08cf18bc32db734ca4a3ad2e86c76c Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 22 Aug 2022 17:11:34 +0200 Subject: [PATCH 32/63] fmt --- frame/support/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index c821c43d596fd..48f277749956c 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -1429,9 +1429,9 @@ pub mod pallet_prelude { /// I.e. a regular trait definition named `Config`, with supertrait `frame_system::Config`, /// optionally other supertrait and where clause. /// -/// The associated type `RuntimeEvent` is reserved, if defined it must bounds `From` and -/// `IsType<::RuntimeEvent>`, see `#[pallet::event]` for more -/// information. +/// The associated type `RuntimeEvent` is reserved, if defined it must bounds +/// `From` and `IsType<::RuntimeEvent>`, see +/// `#[pallet::event]` for more information. /// /// To put `Get` associated type into metadatas, use the attribute `#[pallet::constant]`, e.g.: /// ```ignore From 9a9e5f9a65fe01e4a9edc8224633b248071b5dee Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 22 Aug 2022 19:14:58 +0200 Subject: [PATCH 33/63] small change in docs --- frame/support/src/event.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index 78d0f37cefd61..99073edbb10e5 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -36,7 +36,7 @@ /// # fn main() {} /// ``` /// -/// # Generic Event Example: +/// # Generic PalletEvent Example: /// /// ```rust /// trait Config { From 53f67595605fddaed544f1c0a03cd59f4754c4bc Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 08:38:40 +0200 Subject: [PATCH 34/63] rename PalletEvent to Event --- bin/node-template/pallets/template/src/lib.rs | 7 +- bin/node/executor/tests/basic.rs | 40 +- frame/alliance/src/benchmarking.rs | 22 +- frame/alliance/src/lib.rs | 26 +- frame/alliance/src/tests.rs | 10 +- frame/assets/README.md | 2 +- frame/assets/src/benchmarking.rs | 46 +- frame/assets/src/functions.rs | 18 +- frame/assets/src/lib.rs | 39 +- frame/atomic-swap/src/lib.rs | 18 +- frame/bags-list/src/lib.rs | 8 +- frame/balances/src/lib.rs | 48 +- frame/balances/src/tests.rs | 38 +- frame/balances/src/tests_local.rs | 21 +- frame/balances/src/tests_reentrancy.rs | 18 +- frame/bounties/src/benchmarking.rs | 6 +- frame/bounties/src/lib.rs | 21 +- frame/bounties/src/tests.rs | 2 +- frame/child-bounties/src/benchmarking.rs | 8 +- frame/child-bounties/src/lib.rs | 16 +- frame/child-bounties/src/tests.rs | 2 +- frame/collective/src/benchmarking.rs | 16 +- frame/collective/src/lib.rs | 42 +- frame/collective/src/tests.rs | 10 +- frame/contracts/src/exec.rs | 34 +- frame/contracts/src/lib.rs | 7 +- frame/contracts/src/tests.rs | 158 ++-- frame/contracts/src/wasm/code_cache.rs | 6 +- frame/conviction-voting/src/lib.rs | 8 +- frame/democracy/src/benchmarking.rs | 2 +- frame/democracy/src/lib.rs | 61 +- frame/democracy/src/tests/public_proposals.rs | 2 +- .../election-provider-multi-phase/src/lib.rs | 52 +- .../election-provider-multi-phase/src/mock.rs | 2 +- .../src/signed.rs | 4 +- frame/elections-phragmen/src/lib.rs | 37 +- frame/examples/basic/src/lib.rs | 9 +- frame/examples/offchain-worker/src/lib.rs | 7 +- frame/executive/src/lib.rs | 4 +- frame/gilt/src/lib.rs | 23 +- frame/grandpa/src/lib.rs | 10 +- frame/grandpa/src/tests.rs | 6 +- frame/identity/src/benchmarking.rs | 8 +- frame/identity/src/lib.rs | 29 +- frame/im-online/src/lib.rs | 13 +- frame/indices/src/lib.rs | 15 +- frame/lottery/src/lib.rs | 13 +- frame/membership/src/lib.rs | 14 +- frame/multisig/src/lib.rs | 17 +- frame/multisig/src/tests.rs | 2 +- frame/nicks/src/lib.rs | 15 +- frame/node-authorization/src/lib.rs | 23 +- frame/nomination-pools/src/lib.rs | 31 +- frame/nomination-pools/src/migration.rs | 2 +- frame/nomination-pools/src/mock.rs | 4 +- frame/nomination-pools/src/tests.rs | 851 +++++++----------- .../nomination-pools/test-staking/src/lib.rs | 6 +- .../nomination-pools/test-staking/src/mock.rs | 4 +- frame/offences/benchmarking/src/lib.rs | 14 +- frame/offences/src/lib.rs | 6 +- frame/offences/src/tests.rs | 4 +- frame/preimage/src/lib.rs | 13 +- frame/proxy/src/benchmarking.rs | 8 +- frame/proxy/src/lib.rs | 17 +- frame/proxy/src/tests.rs | 6 +- frame/ranked-collective/src/benchmarking.rs | 12 +- frame/ranked-collective/src/lib.rs | 16 +- frame/recovery/src/benchmarking.rs | 14 +- frame/recovery/src/lib.rs | 19 +- frame/referenda/src/lib.rs | 41 +- frame/remark/src/benchmarking.rs | 2 +- frame/remark/src/lib.rs | 7 +- frame/remark/src/tests.rs | 4 +- frame/scheduler/src/lib.rs | 23 +- frame/scheduler/src/mock.rs | 9 +- frame/scored-pool/src/lib.rs | 14 +- frame/session/src/lib.rs | 6 +- frame/society/src/lib.rs | 44 +- frame/staking/src/lib.rs | 4 +- frame/staking/src/mock.rs | 4 +- frame/staking/src/pallet/impls.rs | 22 +- frame/staking/src/pallet/mod.rs | 19 +- frame/staking/src/slashing.rs | 2 +- frame/staking/src/tests.rs | 54 +- frame/state-trie-migration/src/lib.rs | 29 +- frame/sudo/src/lib.rs | 17 +- frame/sudo/src/mock.rs | 9 +- frame/sudo/src/tests.rs | 10 +- .../src/construct_runtime/expand/event.rs | 16 +- .../src/construct_runtime/expand/metadata.rs | 8 +- .../procedural/src/construct_runtime/parse.rs | 4 +- frame/support/procedural/src/lib.rs | 2 +- .../procedural/src/pallet/expand/event.rs | 6 +- .../procedural/src/pallet/parse/config.rs | 20 +- .../procedural/src/pallet/parse/event.rs | 16 +- frame/support/src/event.rs | 24 +- frame/support/src/lib.rs | 14 +- frame/support/test/tests/construct_runtime.rs | 52 +- .../undefined_event_part.stderr | 6 +- frame/support/test/tests/instance.rs | 10 +- frame/support/test/tests/origin.rs | 4 +- frame/support/test/tests/pallet.rs | 57 +- .../test/tests/pallet_compatibility.rs | 18 +- .../tests/pallet_compatibility_instance.rs | 17 +- frame/support/test/tests/pallet_instance.rs | 47 +- .../tests/pallet_ui/event_field_not_member.rs | 4 +- .../tests/pallet_ui/event_not_in_trait.rs | 2 +- .../pallet_ui/event_type_invalid_bound.rs | 2 +- .../pallet_ui/event_type_invalid_bound_2.rs | 2 +- .../event_type_invalid_bound_2.stderr | 2 +- .../pallet_ui/event_wrong_item_name.stderr | 2 +- .../tests/pallet_with_name_trait_is_valid.rs | 4 +- frame/support/test/tests/system.rs | 4 +- frame/system/benches/bench.rs | 6 +- frame/system/src/lib.rs | 16 +- frame/system/src/mock.rs | 2 +- frame/tips/src/lib.rs | 16 +- frame/tips/src/tests.rs | 2 +- .../asset-tx-payment/src/lib.rs | 7 +- frame/transaction-payment/src/lib.rs | 21 +- frame/transaction-storage/src/benchmarking.rs | 6 +- frame/transaction-storage/src/lib.rs | 11 +- frame/treasury/src/benchmarking.rs | 2 +- frame/treasury/src/lib.rs | 20 +- frame/uniques/src/benchmarking.rs | 52 +- frame/uniques/src/functions.rs | 16 +- frame/uniques/src/impl_nonfungibles.rs | 6 +- frame/uniques/src/lib.rs | 53 +- frame/uniques/src/tests.rs | 12 +- frame/utility/src/benchmarking.rs | 6 +- frame/utility/src/lib.rs | 24 +- frame/utility/src/tests.rs | 21 +- frame/vesting/src/lib.rs | 9 +- frame/whitelist/src/lib.rs | 11 +- test-utils/runtime/src/lib.rs | 4 +- 135 files changed, 1356 insertions(+), 1722 deletions(-) diff --git a/bin/node-template/pallets/template/src/lib.rs b/bin/node-template/pallets/template/src/lib.rs index 6282fda13709a..c9874eb9d55d9 100644 --- a/bin/node-template/pallets/template/src/lib.rs +++ b/bin/node-template/pallets/template/src/lib.rs @@ -27,8 +27,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Because this pallet emits events, it depends on the runtime's definition of an event. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } // The pallet's runtime storage items. @@ -43,7 +42,7 @@ pub mod pallet { // https://docs.substrate.io/main-docs/build/events-errors/ #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Event documentation should end with an array that provides descriptive names for event /// parameters. [something, who] SomethingStored(u32, T::AccountId), @@ -76,7 +75,7 @@ pub mod pallet { >::put(something); // Emit an event. - Self::deposit_event(PalletEvent::SomethingStored(something, who)); + Self::deposit_event(Event::SomethingStored(something, who)); // Return a successful DispatchResultWithPostInfo Ok(()) } diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index a8c18b7f23507..235cb8d5ab98f 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -378,7 +378,7 @@ fn full_native_block_import_works() { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: timestamp_weight, class: DispatchClass::Mandatory, @@ -389,7 +389,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who: alice().into(), amount: fees, }), @@ -397,7 +397,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: alice().into(), to: bob().into(), amount: 69 * DOLLARS, @@ -406,7 +406,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Deposit { + event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -414,7 +414,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Treasury(pallet_treasury::PalletEvent::Deposit { + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10, }), topics: vec![], @@ -422,7 +422,7 @@ fn full_native_block_import_works() { EventRecord { phase: Phase::ApplyExtrinsic(1), event: RuntimeEvent::TransactionPayment( - pallet_transaction_payment::PalletEvent::TransactionFeePaid { + pallet_transaction_payment::Event::TransactionFeePaid { who: alice().into(), actual_fee: fees, tip: 0, @@ -432,7 +432,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], @@ -462,7 +462,7 @@ fn full_native_block_import_works() { let events = vec![ EventRecord { phase: Phase::ApplyExtrinsic(0), - event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: timestamp_weight, class: DispatchClass::Mandatory, @@ -473,7 +473,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who: bob().into(), amount: fees, }), @@ -481,7 +481,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: bob().into(), to: alice().into(), amount: 5 * DOLLARS, @@ -490,7 +490,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Deposit { + event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -498,7 +498,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::Treasury(pallet_treasury::PalletEvent::Deposit { + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10, }), topics: vec![], @@ -506,7 +506,7 @@ fn full_native_block_import_works() { EventRecord { phase: Phase::ApplyExtrinsic(1), event: RuntimeEvent::TransactionPayment( - pallet_transaction_payment::PalletEvent::TransactionFeePaid { + pallet_transaction_payment::Event::TransactionFeePaid { who: bob().into(), actual_fee: fees, tip: 0, @@ -516,14 +516,14 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(1), - event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Withdraw { + event: RuntimeEvent::Balances(pallet_balances::Event::Withdraw { who: alice().into(), amount: fees, }), @@ -531,7 +531,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: alice().into(), to: bob().into(), amount: 15 * DOLLARS, @@ -540,7 +540,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Deposit { + event: RuntimeEvent::Balances(pallet_balances::Event::Deposit { who: pallet_treasury::Pallet::::account_id(), amount: fees * 8 / 10, }), @@ -548,7 +548,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::Treasury(pallet_treasury::PalletEvent::Deposit { + event: RuntimeEvent::Treasury(pallet_treasury::Event::Deposit { value: fees * 8 / 10, }), topics: vec![], @@ -556,7 +556,7 @@ fn full_native_block_import_works() { EventRecord { phase: Phase::ApplyExtrinsic(2), event: RuntimeEvent::TransactionPayment( - pallet_transaction_payment::PalletEvent::TransactionFeePaid { + pallet_transaction_payment::Event::TransactionFeePaid { who: alice().into(), actual_fee: fees, tip: 0, @@ -566,7 +566,7 @@ fn full_native_block_import_works() { }, EventRecord { phase: Phase::ApplyExtrinsic(2), - event: RuntimeEvent::System(frame_system::PalletEvent::ExtrinsicSuccess { + event: RuntimeEvent::System(frame_system::Event::ExtrinsicSuccess { dispatch_info: DispatchInfo { weight: transfer_weight, ..Default::default() }, }), topics: vec![], diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index bb29027573187..e875366f3b6f2 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -583,7 +583,7 @@ benchmarks_instance_pallet! { founders.sort(); fellows.sort(); allies.sort(); - assert_last_event::(PalletEvent::MembersInitialized { + assert_last_event::(Event::MembersInitialized { founders: founders.clone(), fellows: fellows.clone(), allies: allies.clone(), @@ -603,7 +603,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert_eq!(Alliance::::rule(), Some(rule.clone())); - assert_last_event::(PalletEvent::NewRuleSet { rule }.into()); + assert_last_event::(Event::NewRuleSet { rule }.into()); } announce { @@ -616,7 +616,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert!(Alliance::::announcements().contains(&announcement)); - assert_last_event::(PalletEvent::Announced { announcement }.into()); + assert_last_event::(Event::Announced { announcement }.into()); } remove_announcement { @@ -631,7 +631,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert!(Alliance::::announcements().is_empty()); - assert_last_event::(PalletEvent::AnnouncementRemoved { announcement }.into()); + assert_last_event::(Event::AnnouncementRemoved { announcement }.into()); } join_alliance { @@ -645,7 +645,7 @@ benchmarks_instance_pallet! { assert!(Alliance::::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally assert_eq!(DepositOf::::get(&outsider), Some(T::AllyDeposit::get())); // with a deposit assert!(!Alliance::::has_voting_rights(&outsider)); // allies don't have voting rights - assert_last_event::(PalletEvent::NewAllyJoined { + assert_last_event::(Event::NewAllyJoined { ally: outsider, nominator: None, reserved: Some(T::AllyDeposit::get()) @@ -668,7 +668,7 @@ benchmarks_instance_pallet! { assert!(Alliance::::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally assert_eq!(DepositOf::::get(&outsider), None); // without a deposit assert!(!Alliance::::has_voting_rights(&outsider)); // allies don't have voting rights - assert_last_event::(PalletEvent::NewAllyJoined { + assert_last_event::(Event::NewAllyJoined { ally: outsider, nominator: Some(founder1), reserved: None @@ -688,7 +688,7 @@ benchmarks_instance_pallet! { verify { assert!(!Alliance::::is_ally(&ally1)); assert!(Alliance::::is_fellow(&ally1)); - assert_last_event::(PalletEvent::AllyElevated { ally: ally1 }.into()); + assert_last_event::(Event::AllyElevated { ally: ally1 }.into()); } retire { @@ -703,7 +703,7 @@ benchmarks_instance_pallet! { verify { assert!(!Alliance::::is_member(&fellow2)); assert_eq!(DepositOf::::get(&fellow2), None); - assert_last_event::(PalletEvent::MemberRetired { + assert_last_event::(Event::MemberRetired { member: fellow2, unreserved: Some(T::AllyDeposit::get()) }.into()); @@ -727,7 +727,7 @@ benchmarks_instance_pallet! { verify { assert!(!Alliance::::is_member(&fellow2)); assert_eq!(DepositOf::::get(&fellow2), None); - assert_last_event::(PalletEvent::MemberKicked { + assert_last_event::(Event::MemberKicked { member: fellow2, slashed: Some(T::AllyDeposit::get()) }.into()); @@ -754,7 +754,7 @@ benchmarks_instance_pallet! { let origin = T::AnnouncementOrigin::successful_origin(); }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(PalletEvent::UnscrupulousItemAdded { items: unscrupulous_list }.into()); + assert_last_event::(Event::UnscrupulousItemAdded { items: unscrupulous_list }.into()); } remove_unscrupulous_items { @@ -784,7 +784,7 @@ benchmarks_instance_pallet! { let origin = T::AnnouncementOrigin::successful_origin(); }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(PalletEvent::UnscrupulousItemRemoved { items: unscrupulous_list }.into()); + assert_last_event::(Event::UnscrupulousItemRemoved { items: unscrupulous_list }.into()); } impl_benchmark_test_suite!(Alliance, crate::mock::new_bench_ext(), crate::mock::Test); diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 0928d14b27f55..c263121fefe8b 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -223,7 +223,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The outer call dispatch type. @@ -362,7 +362,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// A new rule has been set. NewRuleSet { rule: Cid }, /// A new announcement has been proposed. @@ -658,7 +658,7 @@ pub mod pallet { founders, fellows, allies ); - Self::deposit_event(PalletEvent::MembersInitialized { + Self::deposit_event(Event::MembersInitialized { founders: founders.into(), fellows: fellows.into(), allies: allies.into(), @@ -673,7 +673,7 @@ pub mod pallet { Rule::::put(&rule); - Self::deposit_event(PalletEvent::NewRuleSet { rule }); + Self::deposit_event(Event::NewRuleSet { rule }); Ok(()) } @@ -688,7 +688,7 @@ pub mod pallet { .map_err(|_| Error::::TooManyAnnouncements)?; >::put(announcements); - Self::deposit_event(PalletEvent::Announced { announcement }); + Self::deposit_event(Event::Announced { announcement }); Ok(()) } @@ -705,7 +705,7 @@ pub mod pallet { announcements.remove(pos); >::put(announcements); - Self::deposit_event(PalletEvent::AnnouncementRemoved { announcement }); + Self::deposit_event(Event::AnnouncementRemoved { announcement }); Ok(()) } @@ -736,7 +736,7 @@ pub mod pallet { Self::add_member(&who, MemberRole::Ally)?; - Self::deposit_event(PalletEvent::NewAllyJoined { + Self::deposit_event(Event::NewAllyJoined { ally: who, nominator: None, reserved: Some(deposit), @@ -761,7 +761,7 @@ pub mod pallet { Self::add_member(&who, MemberRole::Ally)?; - Self::deposit_event(PalletEvent::NewAllyJoined { + Self::deposit_event(Event::NewAllyJoined { ally: who, nominator: Some(nominator), reserved: None, @@ -780,7 +780,7 @@ pub mod pallet { Self::remove_member(&ally, MemberRole::Ally)?; Self::add_member(&ally, MemberRole::Fellow)?; - Self::deposit_event(PalletEvent::AllyElevated { ally }); + Self::deposit_event(Event::AllyElevated { ally }); Ok(()) } @@ -798,7 +798,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&who, deposit); debug_assert!(err_amount.is_zero()); } - Self::deposit_event(PalletEvent::MemberRetired { member: who, unreserved: deposit }); + Self::deposit_event(Event::MemberRetired { member: who, unreserved: deposit }); Ok(()) } @@ -817,7 +817,7 @@ pub mod pallet { >::remove(&member); - Self::deposit_event(PalletEvent::MemberKicked { member, slashed: deposit }); + Self::deposit_event(Event::MemberKicked { member, slashed: deposit }); Ok(()) } @@ -846,7 +846,7 @@ pub mod pallet { } Self::do_add_unscrupulous_items(&mut accounts, &mut webs)?; - Self::deposit_event(PalletEvent::UnscrupulousItemAdded { items }); + Self::deposit_event(Event::UnscrupulousItemAdded { items }); Ok(()) } @@ -869,7 +869,7 @@ pub mod pallet { } } Self::do_remove_unscrupulous_items(&mut accounts, &mut webs)?; - Self::deposit_event(PalletEvent::UnscrupulousItemRemoved { items }); + Self::deposit_event(Event::UnscrupulousItemRemoved { items }); Ok(()) } } diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index b3fc8058d0a47..9786fe86c8773 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -25,7 +25,7 @@ use frame_system::{EventRecord, Phase}; use super::*; use crate::mock::*; -type AllianceMotionEvent = pallet_collective::PalletEvent; +type AllianceMotionEvent = pallet_collective::Event; #[test] fn propose_works() { @@ -233,7 +233,7 @@ fn set_rule_works() { assert_ok!(Alliance::set_rule(Origin::signed(1), cid.clone())); assert_eq!(Alliance::rule(), Some(cid.clone())); - System::assert_last_event(mock::RuntimeEvent::Alliance(crate::PalletEvent::NewRuleSet { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::NewRuleSet { rule: cid, })); }); @@ -246,7 +246,7 @@ fn announce_works() { assert_ok!(Alliance::announce(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![cid.clone()]); - System::assert_last_event(mock::RuntimeEvent::Alliance(crate::PalletEvent::Announced { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced { announcement: cid, })); }); @@ -258,7 +258,7 @@ fn remove_announcement_works() { let cid = test_cid(); assert_ok!(Alliance::announce(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![cid.clone()]); - System::assert_last_event(mock::RuntimeEvent::Alliance(crate::PalletEvent::Announced { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::Announced { announcement: cid.clone(), })); @@ -267,7 +267,7 @@ fn remove_announcement_works() { assert_ok!(Alliance::remove_announcement(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![]); System::assert_last_event(mock::RuntimeEvent::Alliance( - crate::PalletEvent::AnnouncementRemoved { announcement: cid }, + crate::Event::AnnouncementRemoved { announcement: cid }, )); }); } diff --git a/frame/assets/README.md b/frame/assets/README.md index d7d6a715908df..aae5244953e50 100644 --- a/frame/assets/README.md +++ b/frame/assets/README.md @@ -102,7 +102,7 @@ pub mod pallet { >::insert((asset_id, &ACCOUNT_BOB), TOKENS_FIXED_SUPPLY / COUNT_AIRDROP_RECIPIENTS); >::insert(asset_id, TOKENS_FIXED_SUPPLY); - Self::deposit_event(PalletEvent::Issued(asset_id, sender, TOKENS_FIXED_SUPPLY)); + Self::deposit_event(Event::Issued(asset_id, sender, TOKENS_FIXED_SUPPLY)); Ok(()) } } diff --git a/frame/assets/src/benchmarking.rs b/frame/assets/src/benchmarking.rs index 4f4a8fe4c11c7..ca891c2f42e4a 100644 --- a/frame/assets/src/benchmarking.rs +++ b/frame/assets/src/benchmarking.rs @@ -155,7 +155,7 @@ benchmarks_instance_pallet! { T::Currency::make_free_balance_be(&caller, DepositBalanceOf::::max_value()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup, 1u32.into()) verify { - assert_last_event::(PalletEvent::Created { asset_id: Default::default(), creator: caller.clone(), owner: caller }.into()); + assert_last_event::(Event::Created { asset_id: Default::default(), creator: caller.clone(), owner: caller }.into()); } force_create { @@ -163,7 +163,7 @@ benchmarks_instance_pallet! { let caller_lookup = T::Lookup::unlookup(caller.clone()); }: _(SystemOrigin::Root, Default::default(), caller_lookup, true, 1u32.into()) verify { - assert_last_event::(PalletEvent::ForceCreated { asset_id: Default::default(), owner: caller }.into()); + assert_last_event::(Event::ForceCreated { asset_id: Default::default(), owner: caller }.into()); } destroy { @@ -177,7 +177,7 @@ benchmarks_instance_pallet! { let witness = Asset::::get(T::AssetId::default()).unwrap().destroy_witness(); }: _(SystemOrigin::Signed(caller), Default::default(), witness) verify { - assert_last_event::(PalletEvent::Destroyed { asset_id: Default::default() }.into()); + assert_last_event::(Event::Destroyed { asset_id: Default::default() }.into()); } mint { @@ -185,7 +185,7 @@ benchmarks_instance_pallet! { let amount = T::Balance::from(100u32); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup, amount) verify { - assert_last_event::(PalletEvent::Issued { asset_id: Default::default(), owner: caller, total_supply: amount }.into()); + assert_last_event::(Event::Issued { asset_id: Default::default(), owner: caller, total_supply: amount }.into()); } burn { @@ -193,7 +193,7 @@ benchmarks_instance_pallet! { let (caller, caller_lookup) = create_default_minted_asset::(true, amount); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup, amount) verify { - assert_last_event::(PalletEvent::Burned { asset_id: Default::default(), owner: caller, balance: amount }.into()); + assert_last_event::(Event::Burned { asset_id: Default::default(), owner: caller, balance: amount }.into()); } transfer { @@ -203,7 +203,7 @@ benchmarks_instance_pallet! { let target_lookup = T::Lookup::unlookup(target.clone()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), target_lookup, amount) verify { - assert_last_event::(PalletEvent::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into()); + assert_last_event::(Event::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into()); } transfer_keep_alive { @@ -215,7 +215,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller.clone()), Default::default(), target_lookup, amount) verify { assert!(frame_system::Pallet::::account_exists(&caller)); - assert_last_event::(PalletEvent::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into()); + assert_last_event::(Event::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into()); } force_transfer { @@ -226,7 +226,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup, target_lookup, amount) verify { assert_last_event::( - PalletEvent::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into() + Event::Transferred { asset_id: Default::default(), from: caller, to: target, amount }.into() ); } @@ -234,7 +234,7 @@ benchmarks_instance_pallet! { let (caller, caller_lookup) = create_default_minted_asset::(true, 100u32.into()); }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup) verify { - assert_last_event::(PalletEvent::Frozen { asset_id: Default::default(), who: caller }.into()); + assert_last_event::(Event::Frozen { asset_id: Default::default(), who: caller }.into()); } thaw { @@ -246,14 +246,14 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), Default::default(), caller_lookup) verify { - assert_last_event::(PalletEvent::Thawed { asset_id: Default::default(), who: caller }.into()); + assert_last_event::(Event::Thawed { asset_id: Default::default(), who: caller }.into()); } freeze_asset { let (caller, caller_lookup) = create_default_minted_asset::(true, 100u32.into()); }: _(SystemOrigin::Signed(caller.clone()), Default::default()) verify { - assert_last_event::(PalletEvent::AssetFrozen { asset_id: Default::default() }.into()); + assert_last_event::(Event::AssetFrozen { asset_id: Default::default() }.into()); } thaw_asset { @@ -264,7 +264,7 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), Default::default()) verify { - assert_last_event::(PalletEvent::AssetThawed { asset_id: Default::default() }.into()); + assert_last_event::(Event::AssetThawed { asset_id: Default::default() }.into()); } transfer_ownership { @@ -273,7 +273,7 @@ benchmarks_instance_pallet! { let target_lookup = T::Lookup::unlookup(target.clone()); }: _(SystemOrigin::Signed(caller), Default::default(), target_lookup) verify { - assert_last_event::(PalletEvent::OwnerChanged { asset_id: Default::default(), owner: target }.into()); + assert_last_event::(Event::OwnerChanged { asset_id: Default::default(), owner: target }.into()); } set_team { @@ -283,7 +283,7 @@ benchmarks_instance_pallet! { let target2 = T::Lookup::unlookup(account("target", 2, SEED)); }: _(SystemOrigin::Signed(caller), Default::default(), target0, target1, target2) verify { - assert_last_event::(PalletEvent::TeamChanged { + assert_last_event::(Event::TeamChanged { asset_id: Default::default(), issuer: account("target", 0, SEED), admin: account("target", 1, SEED), @@ -304,7 +304,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller), Default::default(), name.clone(), symbol.clone(), decimals) verify { let id = Default::default(); - assert_last_event::(PalletEvent::MetadataSet { asset_id: id, name, symbol, decimals, is_frozen: false }.into()); + assert_last_event::(Event::MetadataSet { asset_id: id, name, symbol, decimals, is_frozen: false }.into()); } clear_metadata { @@ -315,7 +315,7 @@ benchmarks_instance_pallet! { Assets::::set_metadata(origin, Default::default(), dummy.clone(), dummy, 12)?; }: _(SystemOrigin::Signed(caller), Default::default()) verify { - assert_last_event::(PalletEvent::MetadataCleared { asset_id: Default::default() }.into()); + assert_last_event::(Event::MetadataCleared { asset_id: Default::default() }.into()); } force_set_metadata { @@ -339,7 +339,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { let id = Default::default(); - assert_last_event::(PalletEvent::MetadataSet { asset_id: id, name, symbol, decimals, is_frozen: false }.into()); + assert_last_event::(Event::MetadataSet { asset_id: id, name, symbol, decimals, is_frozen: false }.into()); } force_clear_metadata { @@ -353,7 +353,7 @@ benchmarks_instance_pallet! { let call = Call::::force_clear_metadata { id: Default::default() }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(PalletEvent::MetadataCleared { asset_id: Default::default() }.into()); + assert_last_event::(Event::MetadataCleared { asset_id: Default::default() }.into()); } force_asset_status { @@ -372,7 +372,7 @@ benchmarks_instance_pallet! { }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(PalletEvent::AssetStatusChanged { asset_id: Default::default() }.into()); + assert_last_event::(Event::AssetStatusChanged { asset_id: Default::default() }.into()); } approve_transfer { @@ -385,7 +385,7 @@ benchmarks_instance_pallet! { let amount = 100u32.into(); }: _(SystemOrigin::Signed(caller.clone()), id, delegate_lookup, amount) verify { - assert_last_event::(PalletEvent::ApprovedTransfer { asset_id: id, source: caller, delegate, amount }.into()); + assert_last_event::(Event::ApprovedTransfer { asset_id: id, source: caller, delegate, amount }.into()); } transfer_approved { @@ -405,7 +405,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(delegate.clone()), id, owner_lookup, dest_lookup, amount) verify { assert!(T::Currency::reserved_balance(&owner).is_zero()); - assert_event::(PalletEvent::Transferred { asset_id: id, from: owner, to: dest, amount }.into()); + assert_event::(Event::Transferred { asset_id: id, from: owner, to: dest, amount }.into()); } cancel_approval { @@ -420,7 +420,7 @@ benchmarks_instance_pallet! { Assets::::approve_transfer(origin, id, delegate_lookup.clone(), amount)?; }: _(SystemOrigin::Signed(caller.clone()), id, delegate_lookup) verify { - assert_last_event::(PalletEvent::ApprovalCancelled { asset_id: id, owner: caller, delegate }.into()); + assert_last_event::(Event::ApprovalCancelled { asset_id: id, owner: caller, delegate }.into()); } force_cancel_approval { @@ -435,7 +435,7 @@ benchmarks_instance_pallet! { Assets::::approve_transfer(origin, id, delegate_lookup.clone(), amount)?; }: _(SystemOrigin::Signed(caller.clone()), id, caller_lookup, delegate_lookup) verify { - assert_last_event::(PalletEvent::ApprovalCancelled { asset_id: id, owner: caller, delegate }.into()); + assert_last_event::(Event::ApprovalCancelled { asset_id: id, owner: caller, delegate }.into()); } impl_benchmark_test_suite!(Assets, crate::mock::new_test_ext(), crate::mock::Test) diff --git a/frame/assets/src/functions.rs b/frame/assets/src/functions.rs index 1d89393e448d8..0f8e7096e80c1 100644 --- a/frame/assets/src/functions.rs +++ b/frame/assets/src/functions.rs @@ -361,7 +361,7 @@ impl, I: 'static> Pallet { details.supply = details.supply.saturating_add(amount); Ok(()) })?; - Self::deposit_event(PalletEvent::Issued { + Self::deposit_event(Event::Issued { asset_id: id, owner: beneficiary.clone(), total_supply: amount, @@ -441,11 +441,7 @@ impl, I: 'static> Pallet { Ok(()) })?; - Self::deposit_event(PalletEvent::Burned { - asset_id: id, - owner: target.clone(), - balance: actual, - }); + Self::deposit_event(Event::Burned { asset_id: id, owner: target.clone(), balance: actual }); Ok(actual) } @@ -615,7 +611,7 @@ impl, I: 'static> Pallet { Ok(()) })?; - Self::deposit_event(PalletEvent::Transferred { + Self::deposit_event(Event::Transferred { asset_id: id, from: source.clone(), to: dest.clone(), @@ -658,7 +654,7 @@ impl, I: 'static> Pallet { is_frozen: false, }, ); - Self::deposit_event(PalletEvent::ForceCreated { asset_id: id, owner }); + Self::deposit_event(Event::ForceCreated { asset_id: id, owner }); Ok(()) } @@ -706,7 +702,7 @@ impl, I: 'static> Pallet { for ((owner, _), approval) in Approvals::::drain_prefix((&id,)) { T::Currency::unreserve(&owner, approval.deposit); } - Self::deposit_event(PalletEvent::Destroyed { asset_id: id }); + Self::deposit_event(Event::Destroyed { asset_id: id }); Ok(DestroyWitness { accounts: details.accounts, @@ -758,7 +754,7 @@ impl, I: 'static> Pallet { }, )?; Asset::::insert(id, d); - Self::deposit_event(PalletEvent::ApprovedTransfer { + Self::deposit_event(Event::ApprovedTransfer { asset_id: id, source: owner.clone(), delegate: delegate.clone(), @@ -854,7 +850,7 @@ impl, I: 'static> Pallet { is_frozen: false, }); - Self::deposit_event(PalletEvent::MetadataSet { + Self::deposit_event(Event::MetadataSet { asset_id: id, name, symbol, diff --git a/frame/assets/src/lib.rs b/frame/assets/src/lib.rs index df8148fb47f66..fbb4a3ea1568b 100644 --- a/frame/assets/src/lib.rs +++ b/frame/assets/src/lib.rs @@ -180,7 +180,7 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The units in which we record balances. @@ -376,7 +376,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// Some asset class was created. Created { asset_id: T::AssetId, creator: T::AccountId, owner: T::AccountId }, /// Some assets were issued. @@ -533,11 +533,7 @@ pub mod pallet { is_frozen: false, }, ); - Self::deposit_event(PalletEvent::Created { - asset_id: id, - creator: owner, - owner: admin, - }); + Self::deposit_event(Event::Created { asset_id: id, creator: owner, owner: admin }); Ok(()) } @@ -795,7 +791,7 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(PalletEvent::::Frozen { asset_id: id, who }); + Self::deposit_event(Event::::Frozen { asset_id: id, who }); Ok(()) } @@ -826,7 +822,7 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(PalletEvent::::Thawed { asset_id: id, who }); + Self::deposit_event(Event::::Thawed { asset_id: id, who }); Ok(()) } @@ -852,7 +848,7 @@ pub mod pallet { d.is_frozen = true; - Self::deposit_event(PalletEvent::::AssetFrozen { asset_id: id }); + Self::deposit_event(Event::::AssetFrozen { asset_id: id }); Ok(()) }) } @@ -879,7 +875,7 @@ pub mod pallet { d.is_frozen = false; - Self::deposit_event(PalletEvent::::AssetThawed { asset_id: id }); + Self::deposit_event(Event::::AssetThawed { asset_id: id }); Ok(()) }) } @@ -918,7 +914,7 @@ pub mod pallet { details.owner = owner.clone(); - Self::deposit_event(PalletEvent::OwnerChanged { asset_id: id, owner }); + Self::deposit_event(Event::OwnerChanged { asset_id: id, owner }); Ok(()) }) } @@ -956,12 +952,7 @@ pub mod pallet { details.admin = admin.clone(); details.freezer = freezer.clone(); - Self::deposit_event(PalletEvent::TeamChanged { - asset_id: id, - issuer, - admin, - freezer, - }); + Self::deposit_event(Event::TeamChanged { asset_id: id, issuer, admin, freezer }); Ok(()) }) } @@ -1018,7 +1009,7 @@ pub mod pallet { Metadata::::try_mutate_exists(id, |metadata| { let deposit = metadata.take().ok_or(Error::::Unknown)?.deposit; T::Currency::unreserve(&d.owner, deposit); - Self::deposit_event(PalletEvent::MetadataCleared { asset_id: id }); + Self::deposit_event(Event::MetadataCleared { asset_id: id }); Ok(()) }) } @@ -1065,7 +1056,7 @@ pub mod pallet { is_frozen, }); - Self::deposit_event(PalletEvent::MetadataSet { + Self::deposit_event(Event::MetadataSet { asset_id: id, name, symbol, @@ -1098,7 +1089,7 @@ pub mod pallet { Metadata::::try_mutate_exists(id, |metadata| { let deposit = metadata.take().ok_or(Error::::Unknown)?.deposit; T::Currency::unreserve(&d.owner, deposit); - Self::deposit_event(PalletEvent::MetadataCleared { asset_id: id }); + Self::deposit_event(Event::MetadataCleared { asset_id: id }); Ok(()) }) } @@ -1150,7 +1141,7 @@ pub mod pallet { asset.is_frozen = is_frozen; *maybe_asset = Some(asset); - Self::deposit_event(PalletEvent::AssetStatusChanged { asset_id: id }); + Self::deposit_event(Event::AssetStatusChanged { asset_id: id }); Ok(()) }) } @@ -1216,7 +1207,7 @@ pub mod pallet { d.approvals.saturating_dec(); Asset::::insert(id, d); - Self::deposit_event(PalletEvent::ApprovalCancelled { asset_id: id, owner, delegate }); + Self::deposit_event(Event::ApprovalCancelled { asset_id: id, owner, delegate }); Ok(()) } @@ -1258,7 +1249,7 @@ pub mod pallet { d.approvals.saturating_dec(); Asset::::insert(id, d); - Self::deposit_event(PalletEvent::ApprovalCancelled { asset_id: id, owner, delegate }); + Self::deposit_event(Event::ApprovalCancelled { asset_id: id, owner, delegate }); Ok(()) } diff --git a/frame/atomic-swap/src/lib.rs b/frame/atomic-swap/src/lib.rs index caf5e497fefb7..5d8e2f7d25dd4 100644 --- a/frame/atomic-swap/src/lib.rs +++ b/frame/atomic-swap/src/lib.rs @@ -166,8 +166,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Swap action. type SwapAction: SwapAction + Parameter + MaxEncodedLen; /// Limit of proof size. @@ -221,7 +220,7 @@ pub mod pallet { /// Event of atomic swap pallet. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Swap created. NewSwap { account: T::AccountId, proof: HashedProof, swap: PendingSwap }, /// Swap claimed. The last parameter indicates whether the execution succeeds. @@ -267,11 +266,7 @@ pub mod pallet { }; PendingSwaps::::insert(target.clone(), hashed_proof, swap.clone()); - Self::deposit_event(PalletEvent::NewSwap { - account: target, - proof: hashed_proof, - swap, - }); + Self::deposit_event(Event::NewSwap { account: target, proof: hashed_proof, swap }); Ok(()) } @@ -307,7 +302,7 @@ pub mod pallet { PendingSwaps::::remove(target.clone(), hashed_proof); - Self::deposit_event(PalletEvent::SwapClaimed { + Self::deposit_event(Event::SwapClaimed { account: target, proof: hashed_proof, success: succeeded, @@ -340,10 +335,7 @@ pub mod pallet { swap.action.cancel(&swap.source); PendingSwaps::::remove(&target, hashed_proof); - Self::deposit_event(PalletEvent::SwapCancelled { - account: target, - proof: hashed_proof, - }); + Self::deposit_event(Event::SwapCancelled { account: target, proof: hashed_proof }); Ok(()) } diff --git a/frame/bags-list/src/lib.rs b/frame/bags-list/src/lib.rs index 912f02d6d096b..583fc275b4beb 100644 --- a/frame/bags-list/src/lib.rs +++ b/frame/bags-list/src/lib.rs @@ -105,7 +105,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. @@ -192,7 +192,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// Moved an account from one bag to another. Rebagged { who: T::AccountId, from: T::Score, to: T::Score }, /// Updated the score of some account to the given amount. @@ -279,9 +279,9 @@ impl, I: 'static> Pallet { let node = list::Node::::get(&account).ok_or(ListError::NodeNotFound)?; let maybe_movement = List::update_position_for(node, new_score); if let Some((from, to)) = maybe_movement { - Self::deposit_event(PalletEvent::::Rebagged { who: account.clone(), from, to }); + Self::deposit_event(Event::::Rebagged { who: account.clone(), from, to }); }; - Self::deposit_event(PalletEvent::::ScoreUpdated { who: account.clone(), new_score }); + Self::deposit_event(Event::::ScoreUpdated { who: account.clone(), new_score }); Ok(maybe_movement) } diff --git a/frame/balances/src/lib.rs b/frame/balances/src/lib.rs index e2c6c423b7f27..51745edc3f54d 100644 --- a/frame/balances/src/lib.rs +++ b/frame/balances/src/lib.rs @@ -218,7 +218,7 @@ pub mod pallet { type DustRemoval: OnUnbalanced>; /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The minimum amount required to keep an account open. @@ -343,11 +343,7 @@ pub mod pallet { mem::drop(NegativeImbalance::::new(old_reserved - new_reserved)); } - Self::deposit_event(PalletEvent::BalanceSet { - who, - free: new_free, - reserved: new_reserved, - }); + Self::deposit_event(Event::BalanceSet { who, free: new_free, reserved: new_reserved }); Ok(().into()) } @@ -444,7 +440,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// An account was created with some free balance. Endowed { account: T::AccountId, free_balance: T::Balance }, /// An account was removed whose balance was non-zero but below ExistentialDeposit, @@ -743,10 +739,7 @@ pub struct DustCleaner, I: 'static = ()>( impl, I: 'static> Drop for DustCleaner { fn drop(&mut self) { if let Some((who, dust)) = self.0.take() { - Pallet::::deposit_event(PalletEvent::DustLost { - account: who, - amount: dust.peek(), - }); + Pallet::::deposit_event(Event::DustLost { account: who, amount: dust.peek() }); T::DustRemoval::on_unbalanced(dust); } } @@ -944,10 +937,7 @@ impl, I: 'static> Pallet { }); result.map(|(maybe_endowed, maybe_dust, result)| { if let Some(endowed) = maybe_endowed { - Self::deposit_event(PalletEvent::Endowed { - account: who.clone(), - free_balance: endowed, - }); + Self::deposit_event(Event::Endowed { account: who.clone(), free_balance: endowed }); } let dust_cleaner = DustCleaner(maybe_dust.map(|dust| (who.clone(), dust))); (result, dust_cleaner) @@ -1057,7 +1047,7 @@ impl, I: 'static> Pallet { }, )?; - Self::deposit_event(PalletEvent::ReserveRepatriated { + Self::deposit_event(Event::ReserveRepatriated { from: slashed.clone(), to: beneficiary.clone(), amount: actual, @@ -1115,7 +1105,7 @@ impl, I: 'static> fungible::Mutate for Pallet { Ok(()) })?; TotalIssuance::::mutate(|t| *t += amount); - Self::deposit_event(PalletEvent::Deposit { who: who.clone(), amount }); + Self::deposit_event(Event::Deposit { who: who.clone(), amount }); Ok(()) } @@ -1136,7 +1126,7 @@ impl, I: 'static> fungible::Mutate for Pallet { }, )?; TotalIssuance::::mutate(|t| *t -= actual); - Self::deposit_event(PalletEvent::Withdraw { who: who.clone(), amount }); + Self::deposit_event(Event::Withdraw { who: who.clone(), amount }); Ok(actual) } } @@ -1157,7 +1147,7 @@ impl, I: 'static> fungible::Unbalanced for Pallet DispatchResult { Self::mutate_account(who, |account| { account.free = amount; - Self::deposit_event(PalletEvent::BalanceSet { + Self::deposit_event(Event::BalanceSet { who: who.clone(), free: account.free, reserved: account.reserved, @@ -1541,7 +1531,7 @@ where )?; // Emit transfer event. - Self::deposit_event(PalletEvent::Transfer { + Self::deposit_event(Event::Transfer { from: transactor.clone(), to: dest.clone(), amount: value, @@ -1609,7 +1599,7 @@ where }, ) { Ok((imbalance, not_slashed)) => { - Self::deposit_event(PalletEvent::Slashed { + Self::deposit_event(Event::Slashed { who: who.clone(), amount: value.saturating_sub(not_slashed), }); @@ -1639,7 +1629,7 @@ where |account, is_new| -> Result { ensure!(!is_new, Error::::DeadAccount); account.free = account.free.checked_add(&value).ok_or(ArithmeticError::Overflow)?; - Self::deposit_event(PalletEvent::Deposit { who: who.clone(), amount: value }); + Self::deposit_event(Event::Deposit { who: who.clone(), amount: value }); Ok(PositiveImbalance::new(value)) }, ) @@ -1672,7 +1662,7 @@ where None => return Ok(Self::PositiveImbalance::zero()), }; - Self::deposit_event(PalletEvent::Deposit { who: who.clone(), amount: value }); + Self::deposit_event(Event::Deposit { who: who.clone(), amount: value }); Ok(PositiveImbalance::new(value)) }, ) @@ -1708,7 +1698,7 @@ where account.free = new_free_account; - Self::deposit_event(PalletEvent::Withdraw { who: who.clone(), amount: value }); + Self::deposit_event(Event::Withdraw { who: who.clone(), amount: value }); Ok(NegativeImbalance::new(value)) }, ) @@ -1741,7 +1731,7 @@ where SignedImbalance::Negative(NegativeImbalance::new(account.free - value)) }; account.free = value; - Self::deposit_event(PalletEvent::BalanceSet { + Self::deposit_event(Event::BalanceSet { who: who.clone(), free: account.free, reserved: account.reserved, @@ -1789,7 +1779,7 @@ where Self::ensure_can_withdraw(&who, value, WithdrawReasons::RESERVE, account.free) })?; - Self::deposit_event(PalletEvent::Reserved { who: who.clone(), amount: value }); + Self::deposit_event(Event::Reserved { who: who.clone(), amount: value }); Ok(()) } @@ -1821,7 +1811,7 @@ where }, }; - Self::deposit_event(PalletEvent::Unreserved { who: who.clone(), amount: actual }); + Self::deposit_event(Event::Unreserved { who: who.clone(), amount: actual }); value - actual } @@ -1862,7 +1852,7 @@ where (NegativeImbalance::new(actual), value - actual) }) { Ok((imbalance, not_slashed)) => { - Self::deposit_event(PalletEvent::Slashed { + Self::deposit_event(Event::Slashed { who: who.clone(), amount: value.saturating_sub(not_slashed), }); @@ -2008,7 +1998,7 @@ where // `actual <= to_change` and `to_change <= amount`; qed; reserves[index].amount -= actual; - Self::deposit_event(PalletEvent::Slashed { who: who.clone(), amount: actual }); + Self::deposit_event(Event::Slashed { who: who.clone(), amount: actual }); (imb, value - actual) }, Err(_) => (NegativeImbalance::zero(), value), diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 0b8497fd21ac4..0c59bc6d9d499 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -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(RuntimeEvent::Balances(crate::PalletEvent::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!(>::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(RuntimeEvent::Balances(crate::PalletEvent::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(RuntimeEvent::Balances(crate::PalletEvent::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!(>::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( - RuntimeEvent::Balances(crate::PalletEvent::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); @@ -724,18 +724,18 @@ macro_rules! decl_tests { System::set_block_number(2); assert_ok!(Balances::reserve(&1, 10)); - System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::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(RuntimeEvent::Balances(crate::PalletEvent::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(RuntimeEvent::Balances(crate::PalletEvent::Unreserved { who: 1, amount: 5 })); + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Unreserved { who: 1, amount: 5 })); }); } @@ -750,9 +750,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - RuntimeEvent::System(system::PalletEvent::NewAccount { account: 1 }), - RuntimeEvent::Balances(crate::PalletEvent::Endowed { account: 1, free_balance: 100 }), - RuntimeEvent::Balances(crate::PalletEvent::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 }), ] ); @@ -762,9 +762,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - RuntimeEvent::System(system::PalletEvent::KilledAccount { account: 1 }), - RuntimeEvent::Balances(crate::PalletEvent::DustLost { account: 1, amount: 99 }), - RuntimeEvent::Balances(crate::PalletEvent::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 }), ] ); }); @@ -781,9 +781,9 @@ macro_rules! decl_tests { assert_eq!( events(), [ - RuntimeEvent::System(system::PalletEvent::NewAccount { account: 1 }), - RuntimeEvent::Balances(crate::PalletEvent::Endowed { account: 1, free_balance: 100 }), - RuntimeEvent::Balances(crate::PalletEvent::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 }), ] ); @@ -793,8 +793,8 @@ macro_rules! decl_tests { assert_eq!( events(), [ - RuntimeEvent::System(system::PalletEvent::KilledAccount { account: 1 }), - RuntimeEvent::Balances(crate::PalletEvent::Slashed { who: 1, amount: 100 }), + RuntimeEvent::System(system::Event::KilledAccount { account: 1 }), + RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 100 }), ] ); }); @@ -814,7 +814,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(RuntimeEvent::Balances(crate::PalletEvent::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)); diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 8496fdf303939..bdfc1fb2a0aeb 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -158,16 +158,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { assert_eq!( events(), [ - RuntimeEvent::System(system::PalletEvent::NewAccount { account: 1 }), - RuntimeEvent::Balances(crate::PalletEvent::Endowed { - account: 1, - free_balance: 100 - }), - RuntimeEvent::Balances(crate::PalletEvent::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 }), ] ); @@ -177,7 +170,7 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { // no events assert_eq!( events(), - [RuntimeEvent::Balances(crate::PalletEvent::Slashed { who: 1, amount: 98 })] + [RuntimeEvent::Balances(crate::Event::Slashed { who: 1, amount: 98 })] ); let res = Balances::slash(&1, 1); @@ -186,9 +179,9 @@ fn emit_events_with_no_existential_deposit_suicide_with_dust() { assert_eq!( events(), [ - RuntimeEvent::System(system::PalletEvent::KilledAccount { account: 1 }), - RuntimeEvent::Balances(crate::PalletEvent::DustLost { account: 1, amount: 1 }), - RuntimeEvent::Balances(crate::PalletEvent::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 }) ] ); }); diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index d8e7cadc5255d..cef058f7efb4e 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -157,16 +157,16 @@ fn transfer_dust_removal_tst1_should_work() { // Verify the events assert_eq!(System::events().len(), 12); - System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::Transfer { + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { from: 2, to: 3, amount: 450, })); - System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::DustLost { + System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { account: 2, amount: 50, })); - System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::Deposit { + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 50, })); @@ -195,16 +195,16 @@ fn transfer_dust_removal_tst2_should_work() { // Verify the events assert_eq!(System::events().len(), 10); - System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::Transfer { + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Transfer { from: 2, to: 1, amount: 450, })); - System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::DustLost { + System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { account: 2, amount: 50, })); - System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::Deposit { + System::assert_has_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 50, })); @@ -242,19 +242,19 @@ fn repatriating_reserved_balance_dust_removal_should_work() { // Verify the events assert_eq!(System::events().len(), 11); - System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::ReserveRepatriated { + System::assert_has_event(RuntimeEvent::Balances(crate::Event::ReserveRepatriated { from: 2, to: 1, amount: 450, destination_status: Status::Free, })); - System::assert_has_event(RuntimeEvent::Balances(crate::PalletEvent::DustLost { + System::assert_has_event(RuntimeEvent::Balances(crate::Event::DustLost { account: 2, amount: 50, })); - System::assert_last_event(RuntimeEvent::Balances(crate::PalletEvent::Deposit { + System::assert_last_event(RuntimeEvent::Balances(crate::Event::Deposit { who: 1, amount: 50, })); diff --git a/frame/bounties/src/benchmarking.rs b/frame/bounties/src/benchmarking.rs index 940bb1034ee83..9dc920f6cca28 100644 --- a/frame/bounties/src/benchmarking.rs +++ b/frame/bounties/src/benchmarking.rs @@ -181,7 +181,7 @@ benchmarks_instance_pallet! { let approve_origin = T::ApproveOrigin::successful_origin(); }: close_bounty(approve_origin, bounty_id) verify { - assert_last_event::(PalletEvent::BountyCanceled { index: bounty_id }.into()) + assert_last_event::(Event::BountyCanceled { index: bounty_id }.into()) } extend_bounty_expiry { @@ -193,7 +193,7 @@ benchmarks_instance_pallet! { let curator = T::Lookup::lookup(curator_lookup).map_err(<&str>::from)?; }: _(RawOrigin::Signed(curator), bounty_id, Vec::new()) verify { - assert_last_event::(PalletEvent::BountyExtended { index: bounty_id }.into()) + assert_last_event::(Event::BountyExtended { index: bounty_id }.into()) } spend_funds { @@ -216,7 +216,7 @@ benchmarks_instance_pallet! { verify { ensure!(budget_remaining < BalanceOf::::max_value(), "Budget not used"); ensure!(missed_any == false, "Missed some"); - assert_last_event::(PalletEvent::BountyBecameActive { index: b - 1 }.into()) + assert_last_event::(Event::BountyBecameActive { index: b - 1 }.into()) } impl_benchmark_test_suite!(Bounties, crate::tests::new_test_ext(), crate::tests::Test) diff --git a/frame/bounties/src/lib.rs b/frame/bounties/src/lib.rs index 386ea25d7b83c..b95940a2835ce 100644 --- a/frame/bounties/src/lib.rs +++ b/frame/bounties/src/lib.rs @@ -230,7 +230,7 @@ pub mod pallet { type DataDepositPerByte: Get>; /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Maximum acceptable reason length. @@ -275,7 +275,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// New bounty proposal. BountyProposed { index: BountyIndex }, /// A bounty proposal was rejected; funds were slashed. @@ -586,10 +586,7 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(PalletEvent::::BountyAwarded { - index: bounty_id, - beneficiary, - }); + Self::deposit_event(Event::::BountyAwarded { index: bounty_id, beneficiary }); Ok(()) } @@ -642,7 +639,7 @@ pub mod pallet { BountyDescriptions::::remove(bounty_id); - Self::deposit_event(PalletEvent::::BountyClaimed { + Self::deposit_event(Event::::BountyClaimed { index: bounty_id, payout, beneficiary, @@ -693,7 +690,7 @@ pub mod pallet { T::OnSlash::on_unbalanced(imbalance); *maybe_bounty = None; - Self::deposit_event(PalletEvent::::BountyRejected { + Self::deposit_event(Event::::BountyRejected { index: bounty_id, bond: value, }); @@ -740,7 +737,7 @@ pub mod pallet { debug_assert!(res.is_ok()); *maybe_bounty = None; - Self::deposit_event(PalletEvent::::BountyCanceled { index: bounty_id }); + Self::deposit_event(Event::::BountyCanceled { index: bounty_id }); Ok(Some(>::WeightInfo::close_bounty_active()).into()) }, ) @@ -780,7 +777,7 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(PalletEvent::::BountyExtended { index: bounty_id }); + Self::deposit_event(Event::::BountyExtended { index: bounty_id }); Ok(()) } } @@ -847,7 +844,7 @@ impl, I: 'static> Pallet { Bounties::::insert(index, &bounty); BountyDescriptions::::insert(index, bounded_description); - Self::deposit_event(PalletEvent::::BountyProposed { index }); + Self::deposit_event(Event::::BountyProposed { index }); Ok(()) } @@ -881,7 +878,7 @@ impl, I: 'static> pallet_treasury::SpendFunds for Pallet::BountyBecameActive { index }); + Self::deposit_event(Event::::BountyBecameActive { index }); false } else { *missed_any = true; diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 6eca4cf918ad7..fe0bc31604526 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -38,7 +38,7 @@ use sp_runtime::{ BuildStorage, Perbill, Storage, }; -use super::PalletEvent as BountiesEvent; +use super::Event as BountiesEvent; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/frame/child-bounties/src/benchmarking.rs b/frame/child-bounties/src/benchmarking.rs index cf6c7e9e66596..697ed40e0071f 100644 --- a/frame/child-bounties/src/benchmarking.rs +++ b/frame/child-bounties/src/benchmarking.rs @@ -172,7 +172,7 @@ benchmarks! { }: _(RawOrigin::Signed(bounty_setup.curator), bounty_setup.bounty_id, bounty_setup.child_bounty_value, bounty_setup.reason.clone()) verify { - assert_last_event::(PalletEvent::Added { + assert_last_event::(Event::Added { index: bounty_setup.bounty_id, child_index: bounty_setup.child_bounty_id, }.into()) @@ -235,7 +235,7 @@ benchmarks! { }: _(RawOrigin::Signed(bounty_setup.child_curator), bounty_setup.bounty_id, bounty_setup.child_bounty_id, beneficiary) verify { - assert_last_event::(PalletEvent::Awarded { + assert_last_event::(Event::Awarded { index: bounty_setup.bounty_id, child_index: bounty_setup.child_bounty_id, beneficiary: beneficiary_account @@ -285,7 +285,7 @@ benchmarks! { }: close_child_bounty(RawOrigin::Root, bounty_setup.bounty_id, bounty_setup.child_bounty_id) verify { - assert_last_event::(PalletEvent::Canceled { + assert_last_event::(Event::Canceled { index: bounty_setup.bounty_id, child_index: bounty_setup.child_bounty_id }.into()) @@ -298,7 +298,7 @@ benchmarks! { Treasury::::on_initialize(T::BlockNumber::zero()); }: close_child_bounty(RawOrigin::Root, bounty_setup.bounty_id, bounty_setup.child_bounty_id) verify { - assert_last_event::(PalletEvent::Canceled { + assert_last_event::(Event::Canceled { index: bounty_setup.bounty_id, child_index: bounty_setup.child_bounty_id, }.into()) diff --git a/frame/child-bounties/src/lib.rs b/frame/child-bounties/src/lib.rs index 303b47363c6cc..2dfe0660ad68e 100644 --- a/frame/child-bounties/src/lib.rs +++ b/frame/child-bounties/src/lib.rs @@ -146,8 +146,7 @@ pub mod pallet { type ChildBountyValueMinimum: Get>; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -165,7 +164,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A child-bounty is added. Added { index: BountyIndex, child_index: BountyIndex }, /// A child-bounty is awarded to a beneficiary. @@ -612,7 +611,7 @@ pub mod pallet { )?; // Trigger the event Awarded. - Self::deposit_event(PalletEvent::::Awarded { + Self::deposit_event(Event::::Awarded { index: parent_bounty_id, child_index: child_bounty_id, beneficiary, @@ -698,7 +697,7 @@ pub mod pallet { debug_assert!(payout_transfer_result.is_ok()); // Trigger the Claimed event. - Self::deposit_event(PalletEvent::::Claimed { + Self::deposit_event(Event::::Claimed { index: parent_bounty_id, child_index: child_bounty_id, payout, @@ -806,10 +805,7 @@ impl Pallet { }; ChildBounties::::insert(parent_bounty_id, child_bounty_id, &child_bounty); ChildBountyDescriptions::::insert(child_bounty_id, description); - Self::deposit_event(PalletEvent::Added { - index: parent_bounty_id, - child_index: child_bounty_id, - }); + Self::deposit_event(Event::Added { index: parent_bounty_id, child_index: child_bounty_id }); } fn ensure_bounty_active( @@ -882,7 +878,7 @@ impl Pallet { *maybe_child_bounty = None; - Self::deposit_event(PalletEvent::::Canceled { + Self::deposit_event(Event::::Canceled { index: parent_bounty_id, child_index: child_bounty_id, }); diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 0b1e14cebd5cd..7189f0f41dc40 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -39,7 +39,7 @@ use sp_runtime::{ Perbill, Permill, }; -use super::PalletEvent as ChildBountiesEvent; +use super::Event as ChildBountiesEvent; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 26adb0697d106..dea68e1088ce0 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -128,7 +128,7 @@ benchmarks_instance_pallet! { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin assert_last_event::( - PalletEvent::MemberExecuted { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() + Event::MemberExecuted { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() ); } @@ -159,7 +159,7 @@ benchmarks_instance_pallet! { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin assert_last_event::( - PalletEvent::Executed { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() + Event::Executed { proposal_hash, result: Err(DispatchError::BadOrigin) }.into() ); } @@ -203,7 +203,7 @@ benchmarks_instance_pallet! { // New proposal is recorded assert_eq!(Collective::::proposals().len(), p as usize); let proposal_hash = T::Hashing::hash_of(&proposal); - assert_last_event::(PalletEvent::Proposed { account: caller, proposal_index: p - 1, proposal_hash, threshold }.into()); + assert_last_event::(Event::Proposed { account: caller, proposal_index: p - 1, proposal_hash, threshold }.into()); } vote { @@ -359,7 +359,7 @@ benchmarks_instance_pallet! { verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(PalletEvent::Disapproved { proposal_hash: last_hash }.into()); + assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); } close_early_approved { @@ -440,7 +440,7 @@ benchmarks_instance_pallet! { verify { // The last proposal is removed. assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(PalletEvent::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); + assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); } close_disapproved { @@ -514,7 +514,7 @@ benchmarks_instance_pallet! { }: close(SystemOrigin::Signed(caller), last_hash, index, Weight::max_value(), bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(PalletEvent::Disapproved { proposal_hash: last_hash }.into()); + assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); } close_approved { @@ -586,7 +586,7 @@ benchmarks_instance_pallet! { }: close(SystemOrigin::Signed(caller), last_hash, p - 1, Weight::max_value(), bytes_in_storage) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(PalletEvent::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); + assert_last_event::(Event::Executed { proposal_hash: last_hash, result: Err(DispatchError::BadOrigin) }.into()); } disapprove_proposal { @@ -634,7 +634,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Root, last_hash) verify { assert_eq!(Collective::::proposals().len(), (p - 1) as usize); - assert_last_event::(PalletEvent::Disapproved { proposal_hash: last_hash }.into()); + assert_last_event::(Event::Disapproved { proposal_hash: last_hash }.into()); } impl_benchmark_test_suite!(Collective, crate::tests::new_test_ext(), crate::tests::Test); diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index fcab36c170734..bc3976a249b53 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -187,7 +187,7 @@ pub mod pallet { + GetDispatchInfo; /// The outer event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The time-out for council motions. @@ -278,7 +278,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// A motion (given hash) has been proposed (by given account) with a threshold (given /// `MemberCount`). Proposed { @@ -444,7 +444,7 @@ pub mod pallet { let proposal_hash = T::Hashing::hash_of(&proposal); let result = proposal.dispatch(RawOrigin::Member(who).into()); - Self::deposit_event(PalletEvent::MemberExecuted { + Self::deposit_event(Event::MemberExecuted { proposal_hash, result: result.map(|_| ()).map_err(|e| e.error), }); @@ -688,7 +688,7 @@ impl, I: 'static> Pallet { let seats = Self::members().len() as MemberCount; let result = proposal.dispatch(RawOrigin::Members(1, seats).into()); - Self::deposit_event(PalletEvent::Executed { + Self::deposit_event(Event::Executed { proposal_hash, result: result.map(|_| ()).map_err(|e| e.error), }); @@ -723,7 +723,7 @@ impl, I: 'static> Pallet { }; >::insert(proposal_hash, votes); - Self::deposit_event(PalletEvent::Proposed { + Self::deposit_event(Event::Proposed { account: who, proposal_index: index, proposal_hash, @@ -771,7 +771,7 @@ impl, I: 'static> Pallet { let yes_votes = voting.ayes.len() as MemberCount; let no_votes = voting.nays.len() as MemberCount; - Self::deposit_event(PalletEvent::Voted { + Self::deposit_event(Event::Voted { account: who, proposal_hash: proposal, voted: approve, @@ -806,11 +806,7 @@ impl, I: 'static> Pallet { length_bound, proposal_weight_bound, )?; - Self::deposit_event(PalletEvent::Closed { - proposal_hash, - yes: yes_votes, - no: no_votes, - }); + Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); let (proposal_weight, proposal_count) = Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal); return Ok(( @@ -822,11 +818,7 @@ impl, I: 'static> Pallet { ) .into()) } else if disapproved { - Self::deposit_event(PalletEvent::Closed { - proposal_hash, - yes: yes_votes, - no: no_votes, - }); + Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); let proposal_count = Self::do_disapprove_proposal(proposal_hash); return Ok(( Some(T::WeightInfo::close_early_disapproved(seats, proposal_count)), @@ -856,11 +848,7 @@ impl, I: 'static> Pallet { length_bound, proposal_weight_bound, )?; - Self::deposit_event(PalletEvent::Closed { - proposal_hash, - yes: yes_votes, - no: no_votes, - }); + Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); let (proposal_weight, proposal_count) = Self::do_approve_proposal(seats, yes_votes, proposal_hash, proposal); Ok(( @@ -872,11 +860,7 @@ impl, I: 'static> Pallet { ) .into()) } else { - Self::deposit_event(PalletEvent::Closed { - proposal_hash, - yes: yes_votes, - no: no_votes, - }); + Self::deposit_event(Event::Closed { proposal_hash, yes: yes_votes, no: no_votes }); let proposal_count = Self::do_disapprove_proposal(proposal_hash); Ok((Some(T::WeightInfo::close_disapproved(seats, proposal_count)), Pays::No).into()) } @@ -922,12 +906,12 @@ impl, I: 'static> Pallet { proposal_hash: T::Hash, proposal: >::Proposal, ) -> (Weight, u32) { - Self::deposit_event(PalletEvent::Approved { proposal_hash }); + Self::deposit_event(Event::Approved { proposal_hash }); let dispatch_weight = proposal.get_dispatch_info().weight; let origin = RawOrigin::Members(yes_votes, seats).into(); let result = proposal.dispatch(origin); - Self::deposit_event(PalletEvent::Executed { + Self::deposit_event(Event::Executed { proposal_hash, result: result.map(|_| ()).map_err(|e| e.error), }); @@ -941,7 +925,7 @@ impl, I: 'static> Pallet { /// Removes a proposal from the pallet, and deposit the `Disapproved` event. pub fn do_disapprove_proposal(proposal_hash: T::Hash) -> u32 { // disapproved - Self::deposit_event(PalletEvent::Disapproved { proposal_hash }); + Self::deposit_event(Event::Disapproved { proposal_hash }); Self::remove_proposal(proposal_hash) } diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 148627aaf26da..7d7c3eee1e522 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{PalletEvent as CollectiveEvent, *}; +use super::{Event as CollectiveEvent, *}; use crate as pallet_collective; use frame_support::{ assert_noop, assert_ok, parameter_types, @@ -61,7 +61,7 @@ mod mock_democracy { #[pallet::config] pub trait Config: frame_system::Config + Sized { - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; type ExternalMajorityOrigin: EnsureOrigin; } @@ -71,14 +71,14 @@ mod mock_democracy { #[pallet::weight(0)] pub fn external_propose_majority(origin: OriginFor) -> DispatchResult { T::ExternalMajorityOrigin::ensure_origin(origin)?; - Self::deposit_event(PalletEvent::::ExternalProposed); + Self::deposit_event(Event::::ExternalProposed); Ok(()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { ExternalProposed, } } @@ -1014,7 +1014,7 @@ fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { })), record(RuntimeEvent::Collective(CollectiveEvent::Approved { proposal_hash: hash })), record(RuntimeEvent::Democracy( - mock_democracy::pallet::PalletEvent::::ExternalProposed + mock_democracy::pallet::Event::::ExternalProposed )), record(RuntimeEvent::Collective(CollectiveEvent::Executed { proposal_hash: hash, diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 812d5a2acc7e4..eb6c3b11dd756 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -18,8 +18,8 @@ use crate::{ gas::GasMeter, storage::{self, Storage, WriteOutcome}, - BalanceOf, CodeHash, Config, ContractInfo, ContractInfoOf, Error, Nonce, Pallet as Contracts, - PalletEvent, Schedule, + BalanceOf, CodeHash, Config, ContractInfo, ContractInfoOf, Error, Event, Nonce, + Pallet as Contracts, Schedule, }; use frame_support::{ crypto::ecdsa::ECDSAExt, @@ -817,7 +817,7 @@ where // Deposit an instantiation event. deposit_event::( vec![], - PalletEvent::Instantiated { + Event::Instantiated { deployer: self.caller().clone(), contract: frame.account_id.clone(), }, @@ -1134,7 +1134,7 @@ where )?; ContractInfoOf::::remove(&frame.account_id); E::remove_user(info.code_hash); - Contracts::::deposit_event(PalletEvent::Terminated { + Contracts::::deposit_event(Event::Terminated { contract: frame.account_id.clone(), beneficiary: beneficiary.clone(), }); @@ -1244,7 +1244,7 @@ where fn deposit_event(&mut self, topics: Vec, data: Vec) { deposit_event::( topics, - PalletEvent::ContractEmitted { contract: self.top_frame().account_id.clone(), data }, + Event::ContractEmitted { contract: self.top_frame().account_id.clone(), data }, ); } @@ -1304,7 +1304,7 @@ where let prev_hash = top_frame.contract_info().code_hash; E::remove_user(prev_hash); top_frame.contract_info().code_hash = hash; - Contracts::::deposit_event(PalletEvent::ContractCodeUpdated { + Contracts::::deposit_event(Event::ContractCodeUpdated { contract: top_frame.account_id.clone(), new_code_hash: hash, old_code_hash: prev_hash, @@ -1313,7 +1313,7 @@ where } } -fn deposit_event(topics: Vec, event: PalletEvent) { +fn deposit_event(topics: Vec, event: Event) { >::deposit_event_indexed( &topics, ::RuntimeEvent::from(event).into(), @@ -1376,7 +1376,7 @@ mod tests { static LOADER: RefCell = RefCell::new(MockLoader::default()); } - fn events() -> Vec> { + fn events() -> Vec> { System::events() .into_iter() .filter_map(|meta| match meta.event { @@ -2138,10 +2138,7 @@ mod tests { ); assert_eq!( &events(), - &[PalletEvent::Instantiated { - deployer: ALICE, - contract: instantiated_contract_address - }] + &[Event::Instantiated { deployer: ALICE, contract: instantiated_contract_address }] ); }); } @@ -2241,10 +2238,7 @@ mod tests { ); assert_eq!( &events(), - &[PalletEvent::Instantiated { - deployer: BOB, - contract: instantiated_contract_address - }] + &[Event::Instantiated { deployer: BOB, contract: instantiated_contract_address }] ); }); } @@ -2600,7 +2594,7 @@ mod tests { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: MetaEvent::System(frame_system::PalletEvent::Remarked { + event: MetaEvent::System(frame_system::Event::Remarked { sender: BOB, hash: remark_hash }), @@ -2672,7 +2666,7 @@ mod tests { vec![ EventRecord { phase: Phase::Initialization, - event: MetaEvent::System(frame_system::PalletEvent::Remarked { + event: MetaEvent::System(frame_system::Event::Remarked { sender: BOB, hash: remark_hash }), @@ -2680,12 +2674,12 @@ mod tests { }, EventRecord { phase: Phase::Initialization, - event: MetaEvent::Utility(pallet_utility::PalletEvent::ItemCompleted), + event: MetaEvent::Utility(pallet_utility::Event::ItemCompleted), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: MetaEvent::Utility(pallet_utility::PalletEvent::BatchInterrupted { + event: MetaEvent::Utility(pallet_utility::Event::BatchInterrupted { index: 1, error: frame_system::Error::::CallFiltered.into() },), diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index e63be9f41f123..838445edd5947 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -243,8 +243,7 @@ pub mod pallet { type Currency: ReservableCurrency; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Dispatchable @@ -632,7 +631,7 @@ pub mod pallet { }; >::add_user(code_hash)?; >::remove_user(contract.code_hash); - Self::deposit_event(PalletEvent::ContractCodeUpdated { + Self::deposit_event(Event::ContractCodeUpdated { contract: dest.clone(), new_code_hash: code_hash, old_code_hash: contract.code_hash, @@ -645,7 +644,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Contract deployed by address at the specified address. Instantiated { deployer: T::AccountId, contract: T::AccountId }, diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 1386dba04a16b..f884b83f78e11 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -516,14 +516,14 @@ fn instantiate_and_call_and_deposit_event() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -531,7 +531,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -540,7 +540,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance, }), @@ -548,7 +548,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: value, @@ -557,7 +557,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::ContractEmitted { + event: RuntimeEvent::Contracts(crate::Event::ContractEmitted { contract: addr.clone(), data: vec![1, 2, 3, 4] }), @@ -565,7 +565,7 @@ fn instantiate_and_call_and_deposit_event() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::Instantiated { + event: RuntimeEvent::Contracts(crate::Event::Instantiated { deployer: ALICE, contract: addr.clone() }), @@ -810,14 +810,14 @@ fn deploy_and_call_other_contract() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: callee_addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: callee_addr.clone(), free_balance: min_balance, }), @@ -825,7 +825,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: callee_addr.clone(), amount: min_balance, @@ -834,7 +834,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: callee_addr.clone(), amount: min_balance, }), @@ -842,7 +842,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: caller_addr.clone(), to: callee_addr.clone(), amount: 32768, // hard coded in wasm @@ -851,7 +851,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::Instantiated { + event: RuntimeEvent::Contracts(crate::Event::Instantiated { deployer: caller_addr.clone(), contract: callee_addr.clone(), }), @@ -859,7 +859,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: caller_addr.clone(), to: callee_addr.clone(), amount: 32768, @@ -1059,7 +1059,7 @@ fn cannot_self_destruct_by_refund_after_slash() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Slashed { + event: RuntimeEvent::Balances(pallet_balances::Event::Slashed { who: addr.clone(), amount: 90, }), @@ -1067,14 +1067,12 @@ fn cannot_self_destruct_by_refund_after_slash() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances( - pallet_balances::PalletEvent::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: 10, - destination_status: BalanceStatus::Free, - } - ), + event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: 10, + destination_status: BalanceStatus::Free, + }), topics: vec![], }, ] @@ -1161,7 +1159,7 @@ fn self_destruct_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: addr.clone(), to: DJANGO, amount: 100_000, @@ -1170,7 +1168,7 @@ fn self_destruct_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::Terminated { + event: RuntimeEvent::Contracts(crate::Event::Terminated { contract: addr.clone(), beneficiary: DJANGO }), @@ -1178,21 +1176,19 @@ fn self_destruct_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::PalletEvent::KilledAccount { + event: RuntimeEvent::System(frame_system::Event::KilledAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances( - pallet_balances::PalletEvent::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: 1_000, - destination_status: BalanceStatus::Free, - } - ), + event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: 1_000, + destination_status: BalanceStatus::Free, + }), topics: vec![], }, ], @@ -2613,7 +2609,7 @@ fn upload_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2621,7 +2617,7 @@ fn upload_code_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, ] @@ -2692,7 +2688,7 @@ fn remove_code_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2700,12 +2696,12 @@ fn remove_code_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Unreserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Unreserved { who: ALICE, amount: 240, }), @@ -2713,7 +2709,7 @@ fn remove_code_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::CodeRemoved { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeRemoved { code_hash }), topics: vec![], }, ] @@ -2747,7 +2743,7 @@ fn remove_code_wrong_origin() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2755,7 +2751,7 @@ fn remove_code_wrong_origin() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, ] @@ -2848,14 +2844,14 @@ fn instantiate_with_zero_balance_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -2863,7 +2859,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -2872,7 +2868,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance, }), @@ -2880,7 +2876,7 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2888,12 +2884,12 @@ fn instantiate_with_zero_balance_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::Instantiated { + event: RuntimeEvent::Contracts(crate::Event::Instantiated { deployer: ALICE, contract: addr.clone(), }), @@ -2941,14 +2937,14 @@ fn instantiate_with_below_existential_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: addr.clone(), free_balance: min_balance, }), @@ -2956,7 +2952,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: min_balance, @@ -2965,7 +2961,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: min_balance, }), @@ -2973,7 +2969,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: 50, @@ -2982,7 +2978,7 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: ALICE, amount: 240, }), @@ -2990,12 +2986,12 @@ fn instantiate_with_below_existential_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::CodeStored { code_hash }), + event: RuntimeEvent::Contracts(crate::Event::CodeStored { code_hash }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::Instantiated { + event: RuntimeEvent::Contracts(crate::Event::Instantiated { deployer: ALICE, contract: addr.clone(), }), @@ -3072,7 +3068,7 @@ fn storage_deposit_works() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: 42, @@ -3081,7 +3077,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: charged0, @@ -3090,7 +3086,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: charged0, }), @@ -3098,7 +3094,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: charged1, @@ -3107,7 +3103,7 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Reserved { + event: RuntimeEvent::Balances(pallet_balances::Event::Reserved { who: addr.clone(), amount: charged1, }), @@ -3115,14 +3111,12 @@ fn storage_deposit_works() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances( - pallet_balances::PalletEvent::ReserveRepatriated { - from: addr.clone(), - to: ALICE, - amount: refunded0, - destination_status: BalanceStatus::Free, - } - ), + event: RuntimeEvent::Balances(pallet_balances::Event::ReserveRepatriated { + from: addr.clone(), + to: ALICE, + amount: refunded0, + destination_status: BalanceStatus::Free, + }), topics: vec![], }, ] @@ -3199,13 +3193,11 @@ fn set_code_extrinsic() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts( - pallet_contracts::PalletEvent::ContractCodeUpdated { - contract: addr, - new_code_hash, - old_code_hash: code_hash, - } - ), + event: RuntimeEvent::Contracts(pallet_contracts::Event::ContractCodeUpdated { + contract: addr, + new_code_hash, + old_code_hash: code_hash, + }), topics: vec![], },] ); @@ -3280,14 +3272,14 @@ fn call_after_killed_account_needs_funding() { vec![ EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::PalletEvent::KilledAccount { + event: RuntimeEvent::System(frame_system::Event::KilledAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Slashed { + event: RuntimeEvent::Balances(pallet_balances::Event::Slashed { who: addr.clone(), amount: min_balance + 700 }), @@ -3295,14 +3287,14 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::PalletEvent::NewAccount { + event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), topics: vec![], }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Endowed { + event: RuntimeEvent::Balances(pallet_balances::Event::Endowed { account: addr.clone(), free_balance: min_balance }), @@ -3310,7 +3302,7 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Balances(pallet_balances::PalletEvent::Transfer { + event: RuntimeEvent::Balances(pallet_balances::Event::Transfer { from: ALICE, to: addr.clone(), amount: min_balance @@ -3491,7 +3483,7 @@ fn set_code_hash() { System::events().pop().unwrap(), EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Contracts(crate::PalletEvent::ContractCodeUpdated { + event: RuntimeEvent::Contracts(crate::Event::ContractCodeUpdated { contract: contract_addr.clone(), new_code_hash, old_code_hash: code_hash, diff --git a/frame/contracts/src/wasm/code_cache.rs b/frame/contracts/src/wasm/code_cache.rs index 73395f888bdf6..61826c7c323aa 100644 --- a/frame/contracts/src/wasm/code_cache.rs +++ b/frame/contracts/src/wasm/code_cache.rs @@ -32,7 +32,7 @@ use crate::{ gas::{GasMeter, Token}, wasm::{prepare, PrefabWasmModule}, weights::WeightInfo, - CodeHash, CodeStorage, Config, Error, OwnerInfoOf, Pallet, PalletEvent, PristineCode, Schedule, + CodeHash, CodeStorage, Config, Error, Event, OwnerInfoOf, Pallet, PristineCode, Schedule, Weight, }; use frame_support::{ @@ -96,7 +96,7 @@ where >::insert(&code_hash, orig_code); >::insert(&code_hash, owner_info); *existing = Some(module); - >::deposit_event(PalletEvent::CodeStored { code_hash }); + >::deposit_event(Event::CodeStored { code_hash }); Ok(()) }, }) @@ -142,7 +142,7 @@ pub fn try_remove(origin: &T::AccountId, code_hash: CodeHash) -> D *existing = None; >::remove(&code_hash); >::remove(&code_hash); - >::deposit_event(PalletEvent::CodeRemoved { code_hash }); + >::deposit_event(Event::CodeRemoved { code_hash }); Ok(()) } else { Err(>::CodeNotFound.into()) diff --git a/frame/conviction-voting/src/lib.rs b/frame/conviction-voting/src/lib.rs index d3e70103226fc..534941d6f7f66 100644 --- a/frame/conviction-voting/src/lib.rs +++ b/frame/conviction-voting/src/lib.rs @@ -98,7 +98,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { // System level stuff. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -161,7 +161,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// An account has delegated their vote to another account. \[who, target\] Delegated(T::AccountId, T::AccountId), /// An \[account\] has cancelled a previous delegation operation. @@ -573,7 +573,7 @@ impl, I: 'static> Pallet { Self::extend_lock(&who, &class, balance); Ok(votes) })?; - Self::deposit_event(PalletEvent::::Delegated(who, target)); + Self::deposit_event(Event::::Delegated(who, target)); Ok(votes) } @@ -612,7 +612,7 @@ impl, I: 'static> Pallet { Voting::Casting(_) => Err(Error::::NotDelegating.into()), } })?; - Self::deposit_event(PalletEvent::::Undelegated(who)); + Self::deposit_event(Event::::Undelegated(who)); Ok(votes) } diff --git a/frame/democracy/src/benchmarking.rs b/frame/democracy/src/benchmarking.rs index 1f9dbfe567958..ab4075bc82fc5 100644 --- a/frame/democracy/src/benchmarking.rs +++ b/frame/democracy/src/benchmarking.rs @@ -789,7 +789,7 @@ benchmarks! { }: enact_proposal(RawOrigin::Root, proposal_hash, 0) verify { // Fails due to mismatched origin - assert_last_event::(PalletEvent::::Executed { ref_index: 0, result: Err(BadOrigin.into()) }.into()); + assert_last_event::(Event::::Executed { ref_index: 0, result: Err(BadOrigin.into()) }.into()); } #[extra] diff --git a/frame/democracy/src/lib.rs b/frame/democracy/src/lib.rs index 07d3c3a75c869..6ca237330ce30 100644 --- a/frame/democracy/src/lib.rs +++ b/frame/democracy/src/lib.rs @@ -254,8 +254,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { type Proposal: Parameter + Dispatchable + From>; - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Currency type for this pallet. type Currency: ReservableCurrency @@ -495,7 +494,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A motion has been proposed by a public account. Proposed { proposal_index: PropIndex, deposit: BalanceOf }, /// A public proposal has been tabled for referendum vote. @@ -654,10 +653,7 @@ pub mod pallet { >::append((index, proposal_hash, who)); - Self::deposit_event(PalletEvent::::Proposed { - proposal_index: index, - deposit: value, - }); + Self::deposit_event(Event::::Proposed { proposal_index: index, deposit: value }); Ok(()) } @@ -685,7 +681,7 @@ pub mod pallet { T::Currency::reserve(&who, deposit.1)?; deposit.0.push(who.clone()); >::insert(proposal, deposit); - Self::deposit_event(PalletEvent::::Seconded { seconder: who, prop_index: proposal }); + Self::deposit_event(Event::::Seconded { seconder: who, prop_index: proposal }); Ok(()) } @@ -887,7 +883,7 @@ pub mod pallet { >::block_number().saturating_add(T::CooloffPeriod::get()); >::insert(&proposal_hash, (until, existing_vetoers)); - Self::deposit_event(PalletEvent::::Vetoed { who, proposal_hash, until }); + Self::deposit_event(Event::::Vetoed { who, proposal_hash, until }); >::kill(); Ok(()) } @@ -1113,7 +1109,7 @@ pub mod pallet { T::Currency::repatriate_reserved(&provider, &who, deposit, BalanceStatus::Free); debug_assert!(res.is_ok()); >::remove(&proposal_hash); - Self::deposit_event(PalletEvent::::PreimageReaped { + Self::deposit_event(Event::::PreimageReaped { proposal_hash, provider, deposit, @@ -1265,7 +1261,7 @@ pub mod pallet { } } - Self::deposit_event(PalletEvent::::Blacklisted { proposal_hash }); + Self::deposit_event(Event::::Blacklisted { proposal_hash }); Ok(()) } @@ -1290,7 +1286,7 @@ pub mod pallet { } } - Self::deposit_event(PalletEvent::::ProposalCanceled { prop_index }); + Self::deposit_event(Event::::ProposalCanceled { prop_index }); Ok(()) } } @@ -1347,7 +1343,7 @@ impl Pallet { /// Remove a referendum. pub fn internal_cancel_referendum(ref_index: ReferendumIndex) { - Self::deposit_event(PalletEvent::::Cancelled { ref_index }); + Self::deposit_event(Event::::Cancelled { ref_index }); ReferendumInfoOf::::remove(ref_index); } @@ -1397,11 +1393,7 @@ impl Pallet { votes.insert(i, (ref_index, vote)); }, } - Self::deposit_event(PalletEvent::::Voted { - voter: who.clone(), - ref_index, - vote, - }); + Self::deposit_event(Event::::Voted { voter: who.clone(), ref_index, vote }); // Shouldn't be possible to fail, but we handle it gracefully. status.tally.add(vote).ok_or(ArithmeticError::Overflow)?; if let Some(approve) = vote.as_standard() { @@ -1563,7 +1555,7 @@ impl Pallet { T::Currency::extend_lock(DEMOCRACY_ID, &who, balance, WithdrawReasons::TRANSFER); Ok(votes) })?; - Self::deposit_event(PalletEvent::::Delegated { who, target }); + Self::deposit_event(Event::::Delegated { who, target }); Ok(votes) } @@ -1591,7 +1583,7 @@ impl Pallet { Voting::Direct { .. } => Err(Error::::NotDelegating.into()), } })?; - Self::deposit_event(PalletEvent::::Undelegated { account: who }); + Self::deposit_event(Event::::Undelegated { account: who }); Ok(votes) } @@ -1622,7 +1614,7 @@ impl Pallet { ReferendumStatus { end, proposal_hash, threshold, delay, tally: Default::default() }; let item = ReferendumInfo::Ongoing(status); >::insert(ref_index, item); - Self::deposit_event(PalletEvent::::Started { ref_index, threshold }); + Self::deposit_event(Event::::Started { ref_index, threshold }); ref_index } @@ -1640,7 +1632,7 @@ impl Pallet { fn launch_external(now: T::BlockNumber) -> DispatchResult { if let Some((proposal, threshold)) = >::take() { LastTabledWasExternal::::put(true); - Self::deposit_event(PalletEvent::::ExternalTabled); + Self::deposit_event(Event::::ExternalTabled); Self::inject_referendum( now.saturating_add(T::VotingPeriod::get()), proposal, @@ -1668,7 +1660,7 @@ impl Pallet { for d in &depositors { T::Currency::unreserve(d, deposit); } - Self::deposit_event(PalletEvent::::Tabled { + Self::deposit_event(Event::::Tabled { proposal_index: prop_index, deposit, depositors, @@ -1692,32 +1684,25 @@ impl Pallet { if let Ok(proposal) = T::Proposal::decode(&mut &data[..]) { let err_amount = T::Currency::unreserve(&provider, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(PalletEvent::::PreimageUsed { - proposal_hash, - provider, - deposit, - }); + Self::deposit_event(Event::::PreimageUsed { proposal_hash, provider, deposit }); let res = proposal .dispatch(frame_system::RawOrigin::Root.into()) .map(|_| ()) .map_err(|e| e.error); - Self::deposit_event(PalletEvent::::Executed { ref_index: index, result: res }); + Self::deposit_event(Event::::Executed { ref_index: index, result: res }); Ok(()) } else { T::Slash::on_unbalanced(T::Currency::slash_reserved(&provider, deposit).0); - Self::deposit_event(PalletEvent::::PreimageInvalid { + Self::deposit_event(Event::::PreimageInvalid { proposal_hash, ref_index: index, }); Err(Error::::PreimageInvalid.into()) } } else { - Self::deposit_event(PalletEvent::::PreimageMissing { - proposal_hash, - ref_index: index, - }); + Self::deposit_event(Event::::PreimageMissing { proposal_hash, ref_index: index }); Err(Error::::PreimageMissing.into()) } } @@ -1731,7 +1716,7 @@ impl Pallet { let approved = status.threshold.approved(status.tally, total_issuance); if approved { - Self::deposit_event(PalletEvent::::Passed { ref_index: index }); + Self::deposit_event(Event::::Passed { ref_index: index }); if status.delay.is_zero() { let _ = Self::do_enact_proposal(status.proposal_hash, index); } else { @@ -1760,7 +1745,7 @@ impl Pallet { } } } else { - Self::deposit_event(PalletEvent::::NotPassed { ref_index: index }); + Self::deposit_event(Event::::NotPassed { ref_index: index }); } approved @@ -1915,7 +1900,7 @@ impl Pallet { }; >::insert(proposal_hash, a); - Self::deposit_event(PalletEvent::::PreimageNoted { proposal_hash, who, deposit }); + Self::deposit_event(Event::::PreimageNoted { proposal_hash, who, deposit }); Ok(()) } @@ -1941,7 +1926,7 @@ impl Pallet { }; >::insert(proposal_hash, a); - Self::deposit_event(PalletEvent::::PreimageNoted { proposal_hash, who, deposit: free }); + Self::deposit_event(Event::::PreimageNoted { proposal_hash, who, deposit: free }); Ok(()) } diff --git a/frame/democracy/src/tests/public_proposals.rs b/frame/democracy/src/tests/public_proposals.rs index a33c24da0f42b..65e5466857dc1 100644 --- a/frame/democracy/src/tests/public_proposals.rs +++ b/frame/democracy/src/tests/public_proposals.rs @@ -100,7 +100,7 @@ fn cancel_proposal_should_work() { assert_ok!(propose_set_balance_and_note(1, 4, 4)); assert_noop!(Democracy::cancel_proposal(Origin::signed(1), 0), BadOrigin); assert_ok!(Democracy::cancel_proposal(Origin::root(), 0)); - System::assert_last_event(crate::PalletEvent::ProposalCanceled { prop_index: 0 }.into()); + System::assert_last_event(crate::Event::ProposalCanceled { prop_index: 0 }.into()); assert_eq!(Democracy::backing_for(0), None); assert_eq!(Democracy::backing_for(1), Some(4)); }); diff --git a/frame/election-provider-multi-phase/src/lib.rs b/frame/election-provider-multi-phase/src/lib.rs index 43f725d9d2941..3cdc69d31e5e0 100644 --- a/frame/election-provider-multi-phase/src/lib.rs +++ b/frame/election-provider-multi-phase/src/lib.rs @@ -569,9 +569,9 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + SendTransactionTypes> { - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent> - + TryInto>; + + TryInto>; /// Currency type. type Currency: ReservableCurrency + Currency; @@ -900,7 +900,7 @@ pub mod pallet { log!(info, "queued unsigned solution with score {:?}", ready.score); let ejected_a_solution = >::exists(); >::put(ready); - Self::deposit_event(PalletEvent::SolutionStored { + Self::deposit_event(Event::SolutionStored { election_compute: ElectionCompute::Unsigned, prev_ejected: ejected_a_solution, }); @@ -948,7 +948,7 @@ pub mod pallet { compute: ElectionCompute::Emergency, }; - Self::deposit_event(PalletEvent::SolutionStored { + Self::deposit_event(Event::SolutionStored { election_compute: ElectionCompute::Emergency, prev_ejected: QueuedSolution::::exists(), }); @@ -1024,7 +1024,7 @@ pub mod pallet { } signed_submissions.put(); - Self::deposit_event(PalletEvent::SolutionStored { + Self::deposit_event(Event::SolutionStored { election_compute: ElectionCompute::Signed, prev_ejected: ejected_a_solution, }); @@ -1062,7 +1062,7 @@ pub mod pallet { compute: ElectionCompute::Fallback, }; - Self::deposit_event(PalletEvent::SolutionStored { + Self::deposit_event(Event::SolutionStored { election_compute: ElectionCompute::Fallback, prev_ejected: QueuedSolution::::exists(), }); @@ -1074,7 +1074,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A solution was stored with the given compute. /// /// If the solution is signed, this means that it hasn't yet been processed. If the @@ -1303,7 +1303,7 @@ impl Pallet { pub fn on_initialize_open_signed() { log!(info, "Starting signed phase round {}.", Self::round()); >::put(Phase::Signed); - Self::deposit_event(PalletEvent::SignedPhaseStarted { round: Self::round() }); + Self::deposit_event(Event::SignedPhaseStarted { round: Self::round() }); } /// Logic for `>::on_initialize` when unsigned phase is being opened. @@ -1311,7 +1311,7 @@ impl Pallet { let round = Self::round(); log!(info, "Starting unsigned phase round {} enabled {}.", round, enabled); >::put(Phase::Unsigned((enabled, now))); - Self::deposit_event(PalletEvent::UnsignedPhaseStarted { round }); + Self::deposit_event(Event::UnsignedPhaseStarted { round }); } /// Parts of [`create_snapshot`] that happen inside of this pallet. @@ -1540,16 +1540,14 @@ impl Pallet { |ReadySolution { supports, compute, .. }| Ok((supports, compute)), ) .map(|(supports, compute)| { - Self::deposit_event(PalletEvent::ElectionFinalized { - election_compute: Some(compute), - }); + Self::deposit_event(Event::ElectionFinalized { election_compute: Some(compute) }); if Self::round() != 1 { log!(info, "Finalized election round with compute {:?}.", compute); } supports }) .map_err(|err| { - Self::deposit_event(PalletEvent::ElectionFinalized { election_compute: None }); + Self::deposit_event(Event::ElectionFinalized { election_compute: None }); if Self::round() != 1 { log!(warn, "Failed to finalize election round. reason {:?}", err); } @@ -1830,7 +1828,7 @@ mod tests { roll_to(15); assert_eq!(MultiPhase::current_phase(), Phase::Signed); - assert_eq!(multi_phase_events(), vec![PalletEvent::SignedPhaseStarted { round: 1 }]); + assert_eq!(multi_phase_events(), vec![Event::SignedPhaseStarted { round: 1 }]); assert!(MultiPhase::snapshot().is_some()); assert_eq!(MultiPhase::round(), 1); @@ -1844,8 +1842,8 @@ mod tests { assert_eq!( multi_phase_events(), vec![ - PalletEvent::SignedPhaseStarted { round: 1 }, - PalletEvent::UnsignedPhaseStarted { round: 1 } + Event::SignedPhaseStarted { round: 1 }, + Event::UnsignedPhaseStarted { round: 1 } ], ); assert!(MultiPhase::snapshot().is_some()); @@ -1957,7 +1955,7 @@ mod tests { assert_eq!(MultiPhase::current_phase(), Phase::Off); roll_to(15); - assert_eq!(multi_phase_events(), vec![PalletEvent::SignedPhaseStarted { round: 1 }]); + assert_eq!(multi_phase_events(), vec![Event::SignedPhaseStarted { round: 1 }]); assert_eq!(MultiPhase::current_phase(), Phase::Signed); assert_eq!(MultiPhase::round(), 1); @@ -1969,10 +1967,8 @@ mod tests { assert_eq!( multi_phase_events(), vec![ - PalletEvent::SignedPhaseStarted { round: 1 }, - PalletEvent::ElectionFinalized { - election_compute: Some(ElectionCompute::Fallback) - } + Event::SignedPhaseStarted { round: 1 }, + Event::ElectionFinalized { election_compute: Some(ElectionCompute::Fallback) } ], ); // All storage items must be cleared. @@ -1994,7 +1990,7 @@ mod tests { assert_eq!(MultiPhase::current_phase(), Phase::Off); roll_to(15); - assert_eq!(multi_phase_events(), vec![PalletEvent::SignedPhaseStarted { round: 1 }]); + assert_eq!(multi_phase_events(), vec![Event::SignedPhaseStarted { round: 1 }]); assert_eq!(MultiPhase::current_phase(), Phase::Signed); assert_eq!(MultiPhase::round(), 1); @@ -2083,16 +2079,14 @@ mod tests { assert_eq!( multi_phase_events(), vec![ - PalletEvent::SignedPhaseStarted { round: 1 }, - PalletEvent::UnsignedPhaseStarted { round: 1 }, - PalletEvent::ElectionFinalized { election_compute: None }, - PalletEvent::SolutionStored { + Event::SignedPhaseStarted { round: 1 }, + Event::UnsignedPhaseStarted { round: 1 }, + Event::ElectionFinalized { election_compute: None }, + Event::SolutionStored { election_compute: ElectionCompute::Fallback, prev_ejected: false }, - PalletEvent::ElectionFinalized { - election_compute: Some(ElectionCompute::Fallback) - } + Event::ElectionFinalized { election_compute: Some(ElectionCompute::Fallback) } ] ); }) diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 7783005422345..b1bced53cc756 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -81,7 +81,7 @@ frame_election_provider_support::generate_solution_type!( ); /// All events of this pallet. -pub(crate) fn multi_phase_events() -> Vec> { +pub(crate) fn multi_phase_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) diff --git a/frame/election-provider-multi-phase/src/signed.rs b/frame/election-provider-multi-phase/src/signed.rs index b6d9abaaef5ac..eca75139f925a 100644 --- a/frame/election-provider-multi-phase/src/signed.rs +++ b/frame/election-provider-multi-phase/src/signed.rs @@ -461,7 +461,7 @@ impl Pallet { let reward = T::SignedRewardBase::get(); // emit reward event - Self::deposit_event(crate::PalletEvent::Rewarded { account: who.clone(), value: reward }); + Self::deposit_event(crate::Event::Rewarded { account: who.clone(), value: reward }); // Unreserve deposit. let _remaining = T::Currency::unreserve(who, deposit); @@ -479,7 +479,7 @@ impl Pallet { /// /// Infallible pub fn finalize_signed_phase_reject_solution(who: &T::AccountId, deposit: BalanceOf) { - Self::deposit_event(crate::PalletEvent::Slashed { account: who.clone(), value: deposit }); + Self::deposit_event(crate::Event::Slashed { account: who.clone(), value: deposit }); let (negative_imbalance, _remaining) = T::Currency::slash_reserved(who, deposit); debug_assert!(_remaining.is_zero()); T::SlashHandler::on_unbalanced(negative_imbalance); diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 73f51176eebd1..f96c23df1f4cd 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -195,8 +195,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Identifier for the elections-phragmen pallet's lock #[pallet::constant] @@ -453,7 +452,7 @@ pub mod pallet { Renouncing::Member => { let _ = Self::remove_and_replace_member(&who, false) .map_err(|_| Error::::InvalidRenouncing)?; - Self::deposit_event(PalletEvent::Renounced { candidate: who }); + Self::deposit_event(Event::Renounced { candidate: who }); }, Renouncing::RunnerUp => { >::try_mutate::<_, Error, _>(|runners_up| { @@ -465,7 +464,7 @@ pub mod pallet { let SeatHolder { deposit, .. } = runners_up.remove(index); let _remainder = T::Currency::unreserve(&who, deposit); debug_assert!(_remainder.is_zero()); - Self::deposit_event(PalletEvent::Renounced { candidate: who }); + Self::deposit_event(Event::Renounced { candidate: who }); Ok(()) })?; }, @@ -478,7 +477,7 @@ pub mod pallet { let (_removed, deposit) = candidates.remove(index); let _remainder = T::Currency::unreserve(&who, deposit); debug_assert!(_remainder.is_zero()); - Self::deposit_event(PalletEvent::Renounced { candidate: who }); + Self::deposit_event(Event::Renounced { candidate: who }); Ok(()) })?; }, @@ -519,7 +518,7 @@ pub mod pallet { let who = T::Lookup::lookup(who)?; let _ = Self::remove_and_replace_member(&who, slash_bond)?; - Self::deposit_event(PalletEvent::MemberKicked { member: who }); + Self::deposit_event(Event::MemberKicked { member: who }); if rerun_election { Self::do_phragmen(); @@ -556,7 +555,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A new term with new_members. This indicates that enough candidates existed to run /// the election, not that enough have has been elected. The inner value must be examined /// for this purpose. A `NewTerm(\[\])` indicates that some candidates got their bond @@ -771,7 +770,7 @@ impl Pallet { let (imbalance, _remainder) = T::Currency::slash_reserved(who, removed.deposit); debug_assert!(_remainder.is_zero()); T::LoserCandidate::on_unbalanced(imbalance); - Self::deposit_event(PalletEvent::SeatHolderSlashed { + Self::deposit_event(Event::SeatHolderSlashed { seat_holder: who.clone(), amount: removed.deposit, }); @@ -908,7 +907,7 @@ impl Pallet { candidates_and_deposit.append(&mut Self::implicit_candidates_with_deposit()); if candidates_and_deposit.len().is_zero() { - Self::deposit_event(PalletEvent::EmptyTerm); + Self::deposit_event(Event::EmptyTerm); return T::DbWeight::get().reads(3) } @@ -940,7 +939,7 @@ impl Pallet { target: "runtime::elections-phragmen", "Failed to run election. Number of voters exceeded", ); - Self::deposit_event(PalletEvent::ElectionError); + Self::deposit_event(Event::ElectionError); return T::DbWeight::get().reads(3 + max_voters as u64) }, } @@ -1053,7 +1052,7 @@ impl Pallet { { let (imbalance, _) = T::Currency::slash_reserved(c, *d); T::LoserCandidate::on_unbalanced(imbalance); - Self::deposit_event(PalletEvent::CandidateSlashed { + Self::deposit_event(Event::CandidateSlashed { candidate: c.clone(), amount: *d, }); @@ -1097,9 +1096,7 @@ impl Pallet { // clean candidates. >::kill(); - Self::deposit_event(PalletEvent::NewTerm { - new_members: new_members_sorted_by_id, - }); + Self::deposit_event(Event::NewTerm { new_members: new_members_sorted_by_id }); >::mutate(|v| *v += 1); }) .map_err(|e| { @@ -1108,7 +1105,7 @@ impl Pallet { "Failed to run election [{:?}].", e, ); - Self::deposit_event(PalletEvent::ElectionError); + Self::deposit_event(Event::ElectionError); }); T::WeightInfo::election_phragmen(weight_candidates, weight_voters, weight_edges) @@ -2207,7 +2204,7 @@ mod tests { System::set_block_number(5); Elections::on_initialize(System::block_number()); - System::assert_last_event(RuntimeEvent::Elections(super::PalletEvent::EmptyTerm)); + System::assert_last_event(RuntimeEvent::Elections(super::Event::EmptyTerm)); }) } @@ -2223,7 +2220,7 @@ mod tests { System::set_block_number(5); Elections::on_initialize(System::block_number()); - System::assert_last_event(RuntimeEvent::Elections(super::PalletEvent::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { new_members: vec![(4, 35), (5, 45)], })); @@ -2236,7 +2233,7 @@ mod tests { System::set_block_number(10); Elections::on_initialize(System::block_number()); - System::assert_last_event(RuntimeEvent::Elections(super::PalletEvent::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { new_members: vec![], })); @@ -2308,7 +2305,7 @@ mod tests { assert_eq!(Elections::election_rounds(), 1); assert!(members_ids().is_empty()); - System::assert_last_event(RuntimeEvent::Elections(super::PalletEvent::NewTerm { + System::assert_last_event(RuntimeEvent::Elections(super::Event::NewTerm { new_members: vec![], })); }); @@ -2616,7 +2613,7 @@ mod tests { // 5 is an outgoing loser. will also get slashed. assert_eq!(balances(&5), (45, 2)); - System::assert_has_event(RuntimeEvent::Elections(super::PalletEvent::NewTerm { + System::assert_has_event(RuntimeEvent::Elections(super::Event::NewTerm { new_members: vec![(4, 35), (5, 45)], })); }) diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index 1e6ffa35cadcd..cdd0b1cea0cd0 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -370,8 +370,7 @@ pub mod pallet { type MagicNumber: Get; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Type representing the weight of this pallet type WeightInfo: WeightInfo; @@ -526,7 +525,7 @@ pub mod pallet { }); // Let's deposit an event to let the outside world know this happened. - Self::deposit_event(PalletEvent::AccumulateDummy { balance: increase_by }); + Self::deposit_event(Event::AccumulateDummy { balance: increase_by }); // All good, no refund. Ok(()) @@ -558,7 +557,7 @@ pub mod pallet { // Put the new value into storage. >::put(new_value); - Self::deposit_event(PalletEvent::SetDummy { balance: new_value }); + Self::deposit_event(Event::SetDummy { balance: new_value }); // All good, no refund. Ok(()) @@ -572,7 +571,7 @@ pub mod pallet { /// This attribute generate the function `deposit_event` to deposit one of this pallet event, /// it is optional, it is also possible to provide a custom implementation. #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { // Just a normal `enum`, here's a dummy event to ensure it compiles. /// Dummy event, just here so there's a generic type that's used. AccumulateDummy { diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 0a980811d5956..e9e4d3c7ca50e 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -126,8 +126,7 @@ pub mod pallet { type AuthorityId: AppCrypto; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching dispatch call type. type Call: From>; @@ -294,7 +293,7 @@ pub mod pallet { /// Events for the pallet. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Event generated when new price is accepted to contribute to the average. NewPrice { price: u32, maybe_who: Option }, } @@ -658,7 +657,7 @@ impl Pallet { .expect("The average is not empty, because it was just mutated; qed"); log::info!("Current average price is: {}", average); // here we are raising the NewPrice event - Self::deposit_event(PalletEvent::NewPrice { price, maybe_who }); + Self::deposit_event(Event::NewPrice { price, maybe_who }); } /// Calculate current average price. diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index a6c5d395d0bc0..98a9fc2724658 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -813,7 +813,7 @@ mod tests { fn on_runtime_upgrade() -> Weight { sp_io::storage::set(TEST_KEY, "custom_upgrade".as_bytes()); sp_io::storage::set(CUSTOM_ON_RUNTIME_KEY, &true.encode()); - System::deposit_event(frame_system::PalletEvent::CodeUpdated); + System::deposit_event(frame_system::Event::CodeUpdated); 100 } } @@ -1302,7 +1302,7 @@ mod tests { Digest::default(), )); - System::assert_last_event(frame_system::PalletEvent::::CodeUpdated.into()); + System::assert_last_event(frame_system::Event::::CodeUpdated.into()); }); } diff --git a/frame/gilt/src/lib.rs b/frame/gilt/src/lib.rs index b8bb68a5e3024..bab25bf96e066 100644 --- a/frame/gilt/src/lib.rs +++ b/frame/gilt/src/lib.rs @@ -98,8 +98,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// Overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Currency type that this works on. type Currency: ReservableCurrency; @@ -288,7 +287,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A bid was successfully placed. BidPlaced { who: T::AccountId, amount: BalanceOf, duration: u32 }, /// A bid was successfully removed (before being accepted as a gilt). @@ -400,7 +399,7 @@ pub mod pallet { qs[queue_index].0 += net.0; qs[queue_index].1 = qs[queue_index].1.saturating_add(net.1); }); - Self::deposit_event(PalletEvent::BidPlaced { who, amount, duration }); + Self::deposit_event(Event::BidPlaced { who, amount, duration }); Ok(().into()) } @@ -438,11 +437,7 @@ pub mod pallet { }); T::Currency::unreserve(&bid.who, bid.amount); - Self::deposit_event(PalletEvent::BidRetracted { - who: bid.who, - amount: bid.amount, - duration, - }); + Self::deposit_event(Event::BidRetracted { who: bid.who, amount: bid.amount, duration }); Ok(().into()) } @@ -521,7 +516,7 @@ pub mod pallet { debug_assert!(err_amt.is_zero()); } - let e = PalletEvent::GiltThawed { + let e = Event::GiltThawed { index, who: gilt.who, original_amount: gilt.amount, @@ -640,12 +635,8 @@ pub mod pallet { totals.proportion = totals.proportion.defensive_saturating_add(proportion); totals.index += 1; - let e = PalletEvent::GiltIssued { - index, - expiry, - who: who.clone(), - amount, - }; + let e = + Event::GiltIssued { index, expiry, who: who.clone(), amount }; Self::deposit_event(e); let gilt = ActiveGilt { amount, proportion, who, expiry }; Active::::insert(index, gilt); diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index aa82e58b42225..f71fbaea0833c 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -87,7 +87,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The event type of this module. - type RuntimeEvent: From + type RuntimeEvent: From + Into<::RuntimeEvent> + IsType<::RuntimeEvent>; @@ -152,7 +152,7 @@ pub mod pallet { // enact the change if we've reached the enacting block if block_number == pending_change.scheduled_at + pending_change.delay { Self::set_grandpa_authorities(&pending_change.next_authorities); - Self::deposit_event(PalletEvent::NewAuthorities { + Self::deposit_event(Event::NewAuthorities { authority_set: pending_change.next_authorities.to_vec(), }); >::kill(); @@ -170,7 +170,7 @@ pub mod pallet { // enact change to paused state if block_number == scheduled_at + delay { >::put(StoredState::Paused); - Self::deposit_event(PalletEvent::Paused); + Self::deposit_event(Event::Paused); } }, StoredState::PendingResume { scheduled_at, delay } => { @@ -182,7 +182,7 @@ pub mod pallet { // enact change to live state if block_number == scheduled_at + delay { >::put(StoredState::Live); - Self::deposit_event(PalletEvent::Resumed); + Self::deposit_event(Event::Resumed); } }, _ => {}, @@ -258,7 +258,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// New authority set has been applied. NewAuthorities { authority_set: AuthorityList }, /// Current authority set has been paused. diff --git a/frame/grandpa/src/tests.rs b/frame/grandpa/src/tests.rs index de4d33e221b5e..ab0a9c677b00e 100644 --- a/frame/grandpa/src/tests.rs +++ b/frame/grandpa/src/tests.rs @@ -19,7 +19,7 @@ #![cfg(test)] -use super::{Call, PalletEvent, *}; +use super::{Call, Event, *}; use crate::mock::*; use codec::Encode; use fg_primitives::ScheduledChange; @@ -57,7 +57,7 @@ fn authorities_change_logged() { System::events(), vec![EventRecord { phase: Phase::Finalization, - event: PalletEvent::NewAuthorities { + event: Event::NewAuthorities { authority_set: to_authorities(vec![(4, 1), (5, 1), (6, 1)]) } .into(), @@ -96,7 +96,7 @@ fn authorities_change_logged_after_delay() { System::events(), vec![EventRecord { phase: Phase::Finalization, - event: PalletEvent::NewAuthorities { + event: Event::NewAuthorities { authority_set: to_authorities(vec![(4, 1), (5, 1), (6, 1)]) } .into(), diff --git a/frame/identity/src/benchmarking.rs b/frame/identity/src/benchmarking.rs index 4f32bd9bb8555..3f84fd63597c9 100644 --- a/frame/identity/src/benchmarking.rs +++ b/frame/identity/src/benchmarking.rs @@ -154,7 +154,7 @@ benchmarks! { }; }: _(RawOrigin::Signed(caller.clone()), Box::new(create_identity_info::(x))) verify { - assert_last_event::(PalletEvent::::IdentitySet { who: caller }.into()); + assert_last_event::(Event::::IdentitySet { who: caller }.into()); } // We need to split `set_subs` into two benchmarks to accurately isolate the potential @@ -238,7 +238,7 @@ benchmarks! { }; }: _(RawOrigin::Signed(caller.clone()), r - 1, 10u32.into()) verify { - assert_last_event::(PalletEvent::::JudgementRequested { who: caller, registrar_index: r-1 }.into()); + assert_last_event::(Event::::JudgementRequested { who: caller, registrar_index: r-1 }.into()); } cancel_request { @@ -258,7 +258,7 @@ benchmarks! { Identity::::request_judgement(caller_origin, r - 1, 10u32.into())?; }: _(RawOrigin::Signed(caller.clone()), r - 1) verify { - assert_last_event::(PalletEvent::::JudgementUnrequested { who: caller, registrar_index: r-1 }.into()); + assert_last_event::(Event::::JudgementUnrequested { who: caller, registrar_index: r-1 }.into()); } set_fee { @@ -338,7 +338,7 @@ benchmarks! { Identity::::request_judgement(user_origin, r, 10u32.into())?; }: _(RawOrigin::Signed(caller), r, user_lookup, Judgement::Reasonable) verify { - assert_last_event::(PalletEvent::::JudgementGiven { target: user, registrar_index: r }.into()) + assert_last_event::(Event::::JudgementGiven { target: user, registrar_index: r }.into()) } kill_identity { diff --git a/frame/identity/src/lib.rs b/frame/identity/src/lib.rs index 294e4824b29c4..a16ea2d08f2c5 100644 --- a/frame/identity/src/lib.rs +++ b/frame/identity/src/lib.rs @@ -105,8 +105,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: ReservableCurrency; @@ -241,7 +240,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A name was set or reset (which will remove all judgements). IdentitySet { who: T::AccountId }, /// A name was cleared, and the given balance returned. @@ -302,7 +301,7 @@ pub mod pallet { }, )?; - Self::deposit_event(PalletEvent::RegistrarAdded { registrar_index: i }); + Self::deposit_event(Event::RegistrarAdded { registrar_index: i }); Ok(Some(T::WeightInfo::add_registrar(registrar_count as u32)).into()) } @@ -365,7 +364,7 @@ pub mod pallet { let judgements = id.judgements.len(); >::insert(&sender, id); - Self::deposit_event(PalletEvent::IdentitySet { who: sender }); + Self::deposit_event(Event::IdentitySet { who: sender }); Ok(Some(T::WeightInfo::set_identity( judgements as u32, // R @@ -490,7 +489,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&sender, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(PalletEvent::IdentityCleared { who: sender, deposit }); + Self::deposit_event(Event::IdentityCleared { who: sender, deposit }); Ok(Some(T::WeightInfo::clear_identity( id.judgements.len() as u32, // R @@ -559,7 +558,7 @@ pub mod pallet { let extra_fields = id.info.additional.len(); >::insert(&sender, id); - Self::deposit_event(PalletEvent::JudgementRequested { + Self::deposit_event(Event::JudgementRequested { who: sender, registrar_index: reg_index, }); @@ -612,7 +611,7 @@ pub mod pallet { let extra_fields = id.info.additional.len(); >::insert(&sender, id); - Self::deposit_event(PalletEvent::JudgementUnrequested { + Self::deposit_event(Event::JudgementUnrequested { who: sender, registrar_index: reg_index, }); @@ -799,7 +798,7 @@ pub mod pallet { let judgements = id.judgements.len(); let extra_fields = id.info.additional.len(); >::insert(&target, id); - Self::deposit_event(PalletEvent::JudgementGiven { target, registrar_index: reg_index }); + Self::deposit_event(Event::JudgementGiven { target, registrar_index: reg_index }); Ok(Some(T::WeightInfo::provide_judgement(judgements as u32, extra_fields as u32)) .into()) @@ -847,7 +846,7 @@ pub mod pallet { // Slash their deposit from them. T::Slashed::on_unbalanced(T::Currency::slash_reserved(&target, deposit).0); - Self::deposit_event(PalletEvent::IdentityKilled { who: target, deposit }); + Self::deposit_event(Event::IdentityKilled { who: target, deposit }); Ok(Some(T::WeightInfo::kill_identity( id.judgements.len() as u32, // R @@ -890,11 +889,7 @@ pub mod pallet { sub_ids.try_push(sub.clone()).expect("sub ids length checked above; qed"); *subs_deposit = subs_deposit.saturating_add(deposit); - Self::deposit_event(PalletEvent::SubIdentityAdded { - sub, - main: sender.clone(), - deposit, - }); + Self::deposit_event(Event::SubIdentityAdded { sub, main: sender.clone(), deposit }); Ok(()) }) } @@ -938,7 +933,7 @@ pub mod pallet { *subs_deposit -= deposit; let err_amount = T::Currency::unreserve(&sender, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(PalletEvent::SubIdentityRemoved { sub, main: sender, deposit }); + Self::deposit_event(Event::SubIdentityRemoved { sub, main: sender, deposit }); }); Ok(()) } @@ -963,7 +958,7 @@ pub mod pallet { *subs_deposit -= deposit; let _ = T::Currency::repatriate_reserved(&sup, &sender, deposit, BalanceStatus::Free); - Self::deposit_event(PalletEvent::SubIdentityRevoked { + Self::deposit_event(Event::SubIdentityRevoked { sub: sender, main: sup.clone(), deposit, diff --git a/frame/im-online/src/lib.rs b/frame/im-online/src/lib.rs index 26fdd6090cf6f..342522ff29b19 100644 --- a/frame/im-online/src/lib.rs +++ b/frame/im-online/src/lib.rs @@ -337,8 +337,7 @@ pub mod pallet { type MaxPeerDataEncodingSize: Get; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A type for retrieving the validators supposed to be online in a session. type ValidatorSet: ValidatorSetWithIdentification; @@ -372,7 +371,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A new heartbeat was received from `AuthorityId`. HeartbeatReceived { authority_id: T::AuthorityId }, /// At the end of the session, no offence was committed. @@ -494,9 +493,7 @@ pub mod pallet { let keys = Keys::::get(); let public = keys.get(heartbeat.authority_index as usize); if let (false, Some(public)) = (exists, public) { - Self::deposit_event(PalletEvent::::HeartbeatReceived { - authority_id: public.clone(), - }); + Self::deposit_event(Event::::HeartbeatReceived { authority_id: public.clone() }); let network_state_bounded = BoundedOpaqueNetworkState::< T::MaxPeerDataEncodingSize, @@ -909,9 +906,9 @@ impl OneSessionHandler for Pallet { AuthoredBlocks::::remove_prefix(&T::ValidatorSet::session_index(), None); if offenders.is_empty() { - Self::deposit_event(PalletEvent::::AllGood); + Self::deposit_event(Event::::AllGood); } else { - Self::deposit_event(PalletEvent::::SomeOffline { offline: offenders.clone() }); + Self::deposit_event(Event::::SomeOffline { offline: offenders.clone() }); let validator_set_count = keys.len() as u32; let offence = UnresponsivenessOffence { session_index, validator_set_count, offenders }; diff --git a/frame/indices/src/lib.rs b/frame/indices/src/lib.rs index 2a8b7197a6030..41893254c3c97 100644 --- a/frame/indices/src/lib.rs +++ b/frame/indices/src/lib.rs @@ -68,8 +68,7 @@ pub mod pallet { type Deposit: Get>; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -108,7 +107,7 @@ pub mod pallet { *maybe_value = Some((who.clone(), T::Deposit::get(), false)); T::Currency::reserve(&who, T::Deposit::get()) })?; - Self::deposit_event(PalletEvent::IndexAssigned { who, index }); + Self::deposit_event(Event::IndexAssigned { who, index }); Ok(()) } @@ -150,7 +149,7 @@ pub mod pallet { *maybe_value = Some((new.clone(), amount.saturating_sub(lost), false)); Ok(()) })?; - Self::deposit_event(PalletEvent::IndexAssigned { who: new, index }); + Self::deposit_event(Event::IndexAssigned { who: new, index }); Ok(()) } @@ -183,7 +182,7 @@ pub mod pallet { T::Currency::unreserve(&who, amount); Ok(()) })?; - Self::deposit_event(PalletEvent::IndexFreed { index }); + Self::deposit_event(Event::IndexFreed { index }); Ok(()) } @@ -224,7 +223,7 @@ pub mod pallet { } *maybe_value = Some((new.clone(), Zero::zero(), freeze)); }); - Self::deposit_event(PalletEvent::IndexAssigned { who: new, index }); + Self::deposit_event(Event::IndexAssigned { who: new, index }); Ok(()) } @@ -258,14 +257,14 @@ pub mod pallet { *maybe_value = Some((account, Zero::zero(), true)); Ok(()) })?; - Self::deposit_event(PalletEvent::IndexFrozen { index, who }); + Self::deposit_event(Event::IndexFrozen { index, who }); Ok(()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A account index was assigned. IndexAssigned { who: T::AccountId, index: T::AccountIndex }, /// A account index has been freed up (unassigned). diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index fd97b17ce61f8..c8989665768e4 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -146,8 +146,7 @@ pub mod pallet { type Randomness: Randomness; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The manager origin. type ManagerOrigin: EnsureOrigin; @@ -175,7 +174,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A lottery has been started! LotteryStarted, /// A new set of calls have been set! @@ -259,7 +258,7 @@ pub mod pallet { ); debug_assert!(res.is_ok()); - Self::deposit_event(PalletEvent::::Winner { winner, lottery_balance }); + Self::deposit_event(Event::::Winner { winner, lottery_balance }); TicketsCount::::kill(); @@ -325,7 +324,7 @@ pub mod pallet { let indices = Self::calls_to_indices(&calls)?; CallIndices::::put(indices); } - Self::deposit_event(PalletEvent::::CallsUpdated); + Self::deposit_event(Event::::CallsUpdated); Ok(()) } @@ -363,7 +362,7 @@ pub mod pallet { if T::Currency::total_balance(&lottery_account).is_zero() { T::Currency::deposit_creating(&lottery_account, T::Currency::minimum_balance()); } - Self::deposit_event(PalletEvent::::LotteryStarted); + Self::deposit_event(Event::::LotteryStarted); Ok(()) } @@ -463,7 +462,7 @@ impl Pallet { }, )?; - Self::deposit_event(PalletEvent::::TicketBought { who: caller.clone(), call_index }); + Self::deposit_event(Event::::TicketBought { who: caller.clone(), call_index }); Ok(()) } diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index dc6fff6e81273..56ec705f606dc 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -55,7 +55,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Required origin for adding a member (though can always be Root). @@ -136,7 +136,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// The given member was added; see the transaction for who. MemberAdded, /// The given member was removed; see the transaction for who. @@ -181,7 +181,7 @@ pub mod pallet { T::MembershipChanged::change_members_sorted(&[who], &[], &members[..]); - Self::deposit_event(PalletEvent::MemberAdded); + Self::deposit_event(Event::MemberAdded); Ok(()) } @@ -202,7 +202,7 @@ pub mod pallet { T::MembershipChanged::change_members_sorted(&[], &[who], &members[..]); Self::rejig_prime(&members); - Self::deposit_event(PalletEvent::MemberRemoved); + Self::deposit_event(Event::MemberRemoved); Ok(()) } @@ -236,7 +236,7 @@ pub mod pallet { T::MembershipChanged::change_members_sorted(&[add], &[remove], &members[..]); Self::rejig_prime(&members); - Self::deposit_event(PalletEvent::MembersSwapped); + Self::deposit_event(Event::MembersSwapped); Ok(()) } @@ -257,7 +257,7 @@ pub mod pallet { *m = members; }); - Self::deposit_event(PalletEvent::MembersReset); + Self::deposit_event(Event::MembersReset); Ok(()) } @@ -293,7 +293,7 @@ pub mod pallet { } } - Self::deposit_event(PalletEvent::KeyChanged); + Self::deposit_event(Event::KeyChanged); Ok(()) } diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index 79eb5baa8b5d1..b49ad7720f8b5 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -117,8 +117,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter @@ -206,7 +205,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A new multisig operation has begun. NewMultisig { approving: T::AccountId, multisig: T::AccountId, call_hash: CallHash }, /// A multisig operation has been approved by someone. @@ -491,7 +490,7 @@ pub mod pallet { >::remove(&id, &call_hash); Self::clear_call(&call_hash); - Self::deposit_event(PalletEvent::MultisigCancelled { + Self::deposit_event(Event::MultisigCancelled { cancelling: who, timepoint, multisig: id, @@ -573,7 +572,7 @@ impl Pallet { T::Currency::unreserve(&m.depositor, m.deposit); let result = call.dispatch(RawOrigin::Signed(id.clone()).into()); - Self::deposit_event(PalletEvent::MultisigExecuted { + Self::deposit_event(Event::MultisigExecuted { approving: who, timepoint, multisig: id, @@ -610,7 +609,7 @@ impl Pallet { // Record approval. m.approvals.insert(pos, who.clone()); >::insert(&id, call_hash, m); - Self::deposit_event(PalletEvent::MultisigApproval { + Self::deposit_event(Event::MultisigApproval { approving: who, timepoint, multisig: id, @@ -659,11 +658,7 @@ impl Pallet { approvals: vec![who.clone()], }, ); - Self::deposit_event(PalletEvent::NewMultisig { - approving: who, - multisig: id, - call_hash, - }); + Self::deposit_event(Event::NewMultisig { approving: who, multisig: id, call_hash }); let final_weight = if stored { T::WeightInfo::as_multi_create_store(other_signatories_len as u32, call_len as u32) diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index d8bace6b9382b..ccb59a41c2b24 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -643,7 +643,7 @@ fn multisig_2_of_3_cannot_reissue_same_call() { let err = DispatchError::from(BalancesError::::InsufficientBalance).stripped(); System::assert_last_event( - pallet_multisig::PalletEvent::MultisigExecuted { + pallet_multisig::Event::MultisigExecuted { approving: 3, timepoint: now(), multisig: multi, diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 484bf58c6843a..812cacb69c786 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -58,8 +58,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: ReservableCurrency; @@ -85,7 +84,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A name was set. NameSet { who: T::AccountId }, /// A name was forcibly set. @@ -145,12 +144,12 @@ pub mod pallet { ensure!(bounded_name.len() >= T::MinLength::get() as usize, Error::::TooShort); let deposit = if let Some((_, deposit)) = >::get(&sender) { - Self::deposit_event(PalletEvent::::NameChanged { who: sender.clone() }); + Self::deposit_event(Event::::NameChanged { who: sender.clone() }); deposit } else { let deposit = T::ReservationFee::get(); T::Currency::reserve(&sender, deposit)?; - Self::deposit_event(PalletEvent::::NameSet { who: sender.clone() }); + Self::deposit_event(Event::::NameSet { who: sender.clone() }); deposit }; @@ -177,7 +176,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&sender, deposit); debug_assert!(err_amount.is_zero()); - Self::deposit_event(PalletEvent::::NameCleared { who: sender, deposit }); + Self::deposit_event(Event::::NameCleared { who: sender, deposit }); Ok(()) } @@ -205,7 +204,7 @@ pub mod pallet { // Slash their deposit from them. T::Slashed::on_unbalanced(T::Currency::slash_reserved(&target, deposit).0); - Self::deposit_event(PalletEvent::::NameKilled { target, deposit }); + Self::deposit_event(Event::::NameKilled { target, deposit }); Ok(()) } @@ -235,7 +234,7 @@ pub mod pallet { let deposit = >::get(&target).map(|x| x.1).unwrap_or_else(Zero::zero); >::insert(&target, (bounded_name, deposit)); - Self::deposit_event(PalletEvent::::NameForced { target }); + Self::deposit_event(Event::::NameForced { target }); Ok(()) } } diff --git a/frame/node-authorization/src/lib.rs b/frame/node-authorization/src/lib.rs index a73982e89e047..42f1fcf7b55e6 100644 --- a/frame/node-authorization/src/lib.rs +++ b/frame/node-authorization/src/lib.rs @@ -67,8 +67,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The maximum number of well known nodes that are allowed to set #[pallet::constant] @@ -131,7 +130,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// The given well known node was added. NodeAdded { peer_id: PeerId, who: T::AccountId }, /// The given well known node was removed. @@ -230,7 +229,7 @@ pub mod pallet { WellKnownNodes::::put(&nodes); >::insert(&node, &owner); - Self::deposit_event(PalletEvent::NodeAdded { peer_id: node, who: owner }); + Self::deposit_event(Event::NodeAdded { peer_id: node, who: owner }); Ok(()) } @@ -254,7 +253,7 @@ pub mod pallet { >::remove(&node); AdditionalConnections::::remove(&node); - Self::deposit_event(PalletEvent::NodeRemoved { peer_id: node }); + Self::deposit_event(Event::NodeRemoved { peer_id: node }); Ok(()) } @@ -290,7 +289,7 @@ pub mod pallet { Owners::::swap(&remove, &add); AdditionalConnections::::swap(&remove, &add); - Self::deposit_event(PalletEvent::NodeSwapped { removed: remove, added: add }); + Self::deposit_event(Event::NodeSwapped { removed: remove, added: add }); Ok(()) } @@ -311,7 +310,7 @@ pub mod pallet { Self::initialize_nodes(&nodes); - Self::deposit_event(PalletEvent::NodesReset { nodes }); + Self::deposit_event(Event::NodesReset { nodes }); Ok(()) } @@ -327,7 +326,7 @@ pub mod pallet { ensure!(!Owners::::contains_key(&node), Error::::AlreadyClaimed); Owners::::insert(&node, &sender); - Self::deposit_event(PalletEvent::NodeClaimed { peer_id: node, who: sender }); + Self::deposit_event(Event::NodeClaimed { peer_id: node, who: sender }); Ok(()) } @@ -348,7 +347,7 @@ pub mod pallet { Owners::::remove(&node); AdditionalConnections::::remove(&node); - Self::deposit_event(PalletEvent::ClaimRemoved { peer_id: node, who: sender }); + Self::deposit_event(Event::ClaimRemoved { peer_id: node, who: sender }); Ok(()) } @@ -371,7 +370,7 @@ pub mod pallet { Owners::::insert(&node, &owner); - Self::deposit_event(PalletEvent::NodeTransferred { peer_id: node, target: owner }); + Self::deposit_event(Event::NodeTransferred { peer_id: node, target: owner }); Ok(()) } @@ -402,7 +401,7 @@ pub mod pallet { AdditionalConnections::::insert(&node, nodes); - Self::deposit_event(PalletEvent::ConnectionsAdded { + Self::deposit_event(Event::ConnectionsAdded { peer_id: node, allowed_connections: connections, }); @@ -433,7 +432,7 @@ pub mod pallet { AdditionalConnections::::insert(&node, nodes); - Self::deposit_event(PalletEvent::ConnectionsRemoved { + Self::deposit_event(Event::ConnectionsRemoved { peer_id: node, allowed_connections: connections, }); diff --git a/frame/nomination-pools/src/lib.rs b/frame/nomination-pools/src/lib.rs index 5e2dac454da53..64d6d11840a52 100644 --- a/frame/nomination-pools/src/lib.rs +++ b/frame/nomination-pools/src/lib.rs @@ -909,7 +909,7 @@ impl BondedPool { fn set_state(&mut self, state: PoolState) { if self.state != state { self.state = state; - Pallet::::deposit_event(PalletEvent::::StateChanged { + Pallet::::deposit_event(Event::::StateChanged { pool_id: self.id, new_state: state, }); @@ -1151,8 +1151,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: weights::WeightInfo; @@ -1341,7 +1340,7 @@ pub mod pallet { /// Events of this pallet. #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A pool has been created. Created { depositor: T::AccountId, pool_id: PoolId }, /// A member has became bonded in a pool. @@ -1523,7 +1522,7 @@ pub mod pallet { }, ); - Self::deposit_event(PalletEvent::::Bonded { + Self::deposit_event(Event::::Bonded { member: who, pool_id, bonded: amount, @@ -1574,7 +1573,7 @@ pub mod pallet { bonded_pool.ok_to_be_open(bonded)?; member.points = member.points.saturating_add(points_issued); - Self::deposit_event(PalletEvent::::Bonded { + Self::deposit_event(Event::::Bonded { member: who.clone(), pool_id: member.pool_id, bonded, @@ -1686,7 +1685,7 @@ pub mod pallet { // Try and unbond in the member map. member.try_unbond(unbonding_points, points_unbonded, unbond_era)?; - Self::deposit_event(PalletEvent::::Unbonded { + Self::deposit_event(Event::::Unbonded { member: member_account.clone(), pool_id: member.pool_id, points: points_unbonded, @@ -1816,7 +1815,7 @@ pub mod pallet { ) .defensive()?; - Self::deposit_event(PalletEvent::::Withdrawn { + Self::deposit_event(Event::::Withdrawn { member: member_account.clone(), pool_id: member.pool_id, points: sum_unlocked_points, @@ -1826,7 +1825,7 @@ pub mod pallet { let post_info_weight = if member.total_points().is_zero() { // member being reaped. PoolMembers::::remove(&member_account); - Self::deposit_event(PalletEvent::::MemberRemoved { + Self::deposit_event(Event::::MemberRemoved { pool_id: member.pool_id, member: member_account.clone(), }); @@ -1931,9 +1930,9 @@ pub mod pallet { ); ReversePoolIdLookup::::insert(bonded_pool.bonded_account(), pool_id); - Self::deposit_event(PalletEvent::::Created { depositor: who.clone(), pool_id }); + Self::deposit_event(Event::::Created { depositor: who.clone(), pool_id }); - Self::deposit_event(PalletEvent::::Bonded { + Self::deposit_event(Event::::Bonded { member: who, pool_id, bonded: amount, @@ -2110,7 +2109,7 @@ pub mod pallet { ConfigOp::Set(v) => bonded_pool.roles.state_toggler = Some(v), }; - Self::deposit_event(PalletEvent::::RolesUpdated { + Self::deposit_event(Event::::RolesUpdated { root: bonded_pool.roles.root.clone(), nominator: bonded_pool.roles.nominator.clone(), state_toggler: bonded_pool.roles.state_toggler.clone(), @@ -2220,7 +2219,7 @@ impl Pallet { T::Currency::make_free_balance_be(&reward_account, Zero::zero()); T::Currency::make_free_balance_be(&bonded_pool.bonded_account(), Zero::zero()); - Self::deposit_event(PalletEvent::::Destroyed { pool_id: bonded_pool.id }); + Self::deposit_event(Event::::Destroyed { pool_id: bonded_pool.id }); bonded_pool.remove(); } @@ -2343,7 +2342,7 @@ impl Pallet { ExistenceRequirement::AllowDeath, )?; - Self::deposit_event(PalletEvent::::PaidOut { + Self::deposit_event(Event::::PaidOut { member: member_account.clone(), pool_id: member.pool_id, payout: pending_rewards, @@ -2493,7 +2492,7 @@ impl OnStakerSlash> for Pallet { for (era, slashed_balance) in slashed_unlocking.iter() { if let Some(pool) = sub_pools.with_era.get_mut(era) { pool.balance = *slashed_balance; - Self::deposit_event(PalletEvent::::UnbondingPoolSlashed { + Self::deposit_event(Event::::UnbondingPoolSlashed { era: *era, pool_id, balance: *slashed_balance, @@ -2501,7 +2500,7 @@ impl OnStakerSlash> for Pallet { } } - Self::deposit_event(PalletEvent::::PoolSlashed { pool_id, balance: slashed_bonded }); + Self::deposit_event(Event::::PoolSlashed { pool_id, balance: slashed_bonded }); SubPoolsStorage::::insert(pool_id, sub_pools); } } diff --git a/frame/nomination-pools/src/migration.rs b/frame/nomination-pools/src/migration.rs index 0942a61c4a276..243e5489b5445 100644 --- a/frame/nomination-pools/src/migration.rs +++ b/frame/nomination-pools/src/migration.rs @@ -278,7 +278,7 @@ pub mod v2 { sum_paid_out = sum_paid_out.saturating_add(last_claim); } - Pallet::::deposit_event(PalletEvent::::PaidOut { + Pallet::::deposit_event(Event::::PaidOut { member: who.clone(), pool_id: id, payout: last_claim, diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index af4d30c97aab6..f2d9156d60117 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -324,7 +324,7 @@ parameter_types! { } /// All events of this pallet. -pub(crate) fn pool_events_since_last_call() -> Vec> { +pub(crate) fn pool_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) @@ -336,7 +336,7 @@ pub(crate) fn pool_events_since_last_call() -> Vec> } /// All events of the `Balances` pallet. -pub(crate) fn balances_events_since_last_call() -> Vec> { +pub(crate) fn balances_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index 88b6a4fd0b473..5aa8e97266e0d 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -16,9 +16,9 @@ // limitations under the License. use super::*; -use crate::{mock::*, PalletEvent}; +use crate::{mock::*, Event}; use frame_support::{assert_err, assert_noop, assert_ok, assert_storage_noop, bounded_btree_map}; -use pallet_balances::PalletEvent as BEvent; +use pallet_balances::Event as BEvent; use sp_runtime::traits::Dispatchable; macro_rules! unbonding_pools_with_era { @@ -449,9 +449,9 @@ mod join { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 11, pool_id: 1, bonded: 2, joined: true }, + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 11, pool_id: 1, bonded: 2, joined: true }, ] ); @@ -475,7 +475,7 @@ mod join { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Bonded { member: 12, pool_id: 1, bonded: 12, joined: true }] + vec![Event::Bonded { member: 12, pool_id: 1, bonded: 12, joined: true }] ); assert_eq!( @@ -599,10 +599,10 @@ mod join { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 101, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Bonded { member: 102, pool_id: 1, bonded: 100, joined: true } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 101, pool_id: 1, bonded: 100, joined: true }, + Event::Bonded { member: 102, pool_id: 1, bonded: 100, joined: true } ] ); @@ -627,8 +627,8 @@ mod join { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 104, pool_id: 2 }, - PalletEvent::Bonded { member: 104, pool_id: 2, bonded: 100, joined: true } + Event::Created { depositor: 104, pool_id: 2 }, + Event::Bonded { member: 104, pool_id: 2, bonded: 100, joined: true } ] ); @@ -696,7 +696,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 },] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 10 },] ); // last recorded reward counter at the time of this member's payout is 1 assert_eq!(PoolMembers::::get(10).unwrap(), del(10, 1)); @@ -712,7 +712,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 40 }] + vec![Event::PaidOut { member: 40, pool_id: 1, payout: 40 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del(40, 1)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 50)); @@ -725,7 +725,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 50 }] + vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del(50, 1)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 100)); @@ -741,7 +741,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del_float(10, 1.5)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 105)); @@ -754,7 +754,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 20 }] + vec![Event::PaidOut { member: 40, pool_id: 1, payout: 20 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del_float(40, 1.5)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 125)); @@ -771,7 +771,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 50 }] + vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del_float(50, 2.0)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 175)); @@ -784,7 +784,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del(10, 2)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 180)); @@ -801,7 +801,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 40 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 40 }] ); // We expect a payout of 40 @@ -820,7 +820,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 2 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 2 }] ); assert_eq!(PoolMembers::::get(10).unwrap(), del_float(10, 6.2)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 222)); @@ -833,7 +833,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 188 }] + vec![Event::PaidOut { member: 40, pool_id: 1, payout: 188 }] ); assert_eq!(PoolMembers::::get(40).unwrap(), del_float(40, 6.2)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 410)); @@ -846,7 +846,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 210 }] + vec![Event::PaidOut { member: 50, pool_id: 1, payout: 210 }] ); assert_eq!(PoolMembers::::get(50).unwrap(), del_float(50, 6.2)); assert_eq!(RewardPools::::get(&1).unwrap(), rew(0, 0, 620)); @@ -866,16 +866,10 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 11, pool_id: 1, bonded: 11, joined: true }, - PalletEvent::Unbonded { - member: 11, - pool_id: 1, - points: 11, - balance: 11, - era: 3 - } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 11, pool_id: 1, bonded: 11, joined: true }, + Event::Unbonded { member: 11, pool_id: 1, points: 11, balance: 11, era: 3 } ] ); }); @@ -911,9 +905,9 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 5 } ] ); assert_eq!(payout, 5); @@ -931,7 +925,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 10 }] ); assert_eq!(payout, 10); assert_eq!(reward_pool, rew(0, 0, 15)); @@ -968,10 +962,10 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, - PalletEvent::Bonded { member: 50, pool_id: 1, bonded: 50, joined: true } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, + Event::Bonded { member: 50, pool_id: 1, bonded: 50, joined: true } ] ); @@ -990,7 +984,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 10 }] ); assert_eq!(payout, 10); assert_eq!(del_10, del(10, 1)); @@ -1004,7 +998,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 40 }] + vec![Event::PaidOut { member: 40, pool_id: 1, payout: 40 }] ); assert_eq!(payout, 40); assert_eq!(del_40, del(40, 1)); @@ -1018,7 +1012,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 50 }] + vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(payout, 50); assert_eq!(del_50, del(50, 1)); @@ -1035,7 +1029,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(payout, 5); assert_eq!(del_10, del_float(10, 1.5)); @@ -1049,7 +1043,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 20 }] + vec![Event::PaidOut { member: 40, pool_id: 1, payout: 20 }] ); assert_eq!(payout, 20); assert_eq!(del_40, del_float(40, 1.5)); @@ -1066,7 +1060,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 50, pool_id: 1, payout: 50 }] + vec![Event::PaidOut { member: 50, pool_id: 1, payout: 50 }] ); assert_eq!(payout, 50); assert_eq!(del_50, del_float(50, 2.0)); @@ -1080,7 +1074,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 5 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 5 }] ); assert_eq!(payout, 5); assert_eq!(del_10, del_float(10, 2.0)); @@ -1097,7 +1091,7 @@ mod claim_payout { // Then assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 40 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 40 }] ); assert_eq!(payout, 40); assert_eq!(del_10, del_float(10, 6.0)); @@ -1157,11 +1151,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 10 }, + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 20 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 10 }, ] ); @@ -1174,8 +1168,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 10 }, + Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 10 }, ] ); }); @@ -1200,11 +1194,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 3 + 3 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 3 }, + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 3 + 3 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 3 }, ] ); @@ -1217,8 +1211,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 4 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 4 }, + Event::PaidOut { member: 10, pool_id: 1, payout: 4 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 4 }, ] ); @@ -1231,8 +1225,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 3 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 3 }, + Event::PaidOut { member: 10, pool_id: 1, payout: 3 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 3 }, ] ); }); @@ -1263,13 +1257,13 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 30 + 100 / 2 + 60 / 3 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 100 / 2 + 60 / 3 }, - PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 60 / 3 }, + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 30 + 100 / 2 + 60 / 3 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 100 / 2 + 60 / 3 }, + Event::PaidOut { member: 30, pool_id: 1, payout: 60 / 3 }, ] ); @@ -1283,9 +1277,9 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 10 }, - PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 10 }, + Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 10 }, + Event::PaidOut { member: 30, pool_id: 1, payout: 10 }, ] ); }); @@ -1311,13 +1305,13 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 20 }, - PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 10 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 20 }, + Event::PaidOut { member: 30, pool_id: 1, payout: 10 } ] ); @@ -1334,10 +1328,10 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: false }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 40 }, - PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 40 } + Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: false }, + Event::PaidOut { member: 10, pool_id: 1, payout: 20 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 40 }, + Event::PaidOut { member: 30, pool_id: 1, payout: 40 } ] ); }); @@ -1360,11 +1354,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 20 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 20 } ] ); @@ -1380,15 +1374,9 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Unbonded { - member: 20, - pool_id: 1, - balance: 10, - points: 10, - era: 3 - }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 50 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 50 }, + Event::Unbonded { member: 20, pool_id: 1, balance: 10, points: 10, era: 3 }, + Event::PaidOut { member: 10, pool_id: 1, payout: 50 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 50 }, ] ); }); @@ -1414,12 +1402,12 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 20 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 20 } ] ); @@ -1433,8 +1421,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 40 } + Event::PaidOut { member: 10, pool_id: 1, payout: 20 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 40 } ] ); @@ -1448,8 +1436,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 40 } + Event::PaidOut { member: 10, pool_id: 1, payout: 20 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 40 } ] ); @@ -1458,7 +1446,7 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 10 + 20 + 20 }] + vec![Event::PaidOut { member: 30, pool_id: 1, payout: 10 + 20 + 20 }] ); }); } @@ -1480,10 +1468,10 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 10 } ] ); @@ -1501,9 +1489,9 @@ mod claim_payout { pool_events_since_last_call(), vec![ // 20 + 40, which means the extra amount they bonded did not impact us. - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 60 }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: false }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 20 } + Event::PaidOut { member: 20, pool_id: 1, payout: 60 }, + Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: false }, + Event::PaidOut { member: 10, pool_id: 1, payout: 20 } ] ); @@ -1517,8 +1505,8 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 15 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 45 } + Event::PaidOut { member: 10, pool_id: 1, payout: 15 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 45 } ] ); }); @@ -1579,13 +1567,13 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Created { depositor: 20, pool_id: 2 }, - PalletEvent::Bonded { member: 20, pool_id: 2, bonded: 10, joined: true }, - PalletEvent::Created { depositor: 30, pool_id: 3 }, - PalletEvent::Bonded { member: 30, pool_id: 3, bonded: 10, joined: true }, - PalletEvent::PaidOut { member: 30, pool_id: 3, payout: 10 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Created { depositor: 20, pool_id: 2 }, + Event::Bonded { member: 20, pool_id: 2, bonded: 10, joined: true }, + Event::Created { depositor: 30, pool_id: 3 }, + Event::Bonded { member: 30, pool_id: 3, bonded: 10, joined: true }, + Event::PaidOut { member: 30, pool_id: 3, payout: 10 } ] ); }) @@ -1648,11 +1636,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 10, joined: true } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 30, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 40, pool_id: 1, bonded: 10, joined: true } ] ); }) @@ -1719,14 +1707,14 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 15 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 15 }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 10, joined: false } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, + Event::PaidOut { member: 10, pool_id: 1, payout: 15 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, + Event::PaidOut { member: 20, pool_id: 1, payout: 15 }, + Event::Bonded { member: 20, pool_id: 1, bonded: 10, joined: false } ] ); }) @@ -1816,41 +1804,17 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::Bonded { member: 30, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::Unbonded { - member: 20, - pool_id: 1, - balance: 10, - points: 10, - era: 3 - }, - PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 15 }, - PalletEvent::Unbonded { - member: 30, - pool_id: 1, - balance: 10, - points: 10, - era: 3 - }, - PalletEvent::Unbonded { - member: 30, - pool_id: 1, - balance: 5, - points: 5, - era: 3 - }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 7 }, - PalletEvent::Unbonded { - member: 20, - pool_id: 1, - balance: 5, - points: 5, - era: 3 - }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 7 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::Bonded { member: 30, pool_id: 1, bonded: 20, joined: true }, + Event::Unbonded { member: 20, pool_id: 1, balance: 10, points: 10, era: 3 }, + Event::PaidOut { member: 30, pool_id: 1, payout: 15 }, + Event::Unbonded { member: 30, pool_id: 1, balance: 10, points: 10, era: 3 }, + Event::Unbonded { member: 30, pool_id: 1, balance: 5, points: 5, era: 3 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 7 }, + Event::Unbonded { member: 20, pool_id: 1, balance: 5, points: 5, era: 3 }, + Event::PaidOut { member: 10, pool_id: 1, payout: 7 } ] ); }) @@ -1878,11 +1842,11 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 13 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 26 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 13 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 26 } ] ); @@ -1900,26 +1864,14 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, - PalletEvent::Unbonded { - member: 20, - pool_id: 1, - balance: 20, - points: 20, - era: 3 - }, - PalletEvent::Withdrawn { member: 20, pool_id: 1, balance: 20, points: 20 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 20 }, - PalletEvent::Unbonded { - member: 10, - pool_id: 1, - balance: 10, - points: 10, - era: 6 - }, - PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 10, points: 10 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, - PalletEvent::Destroyed { pool_id: 1 } + Event::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, + Event::Unbonded { member: 20, pool_id: 1, balance: 20, points: 20, era: 3 }, + Event::Withdrawn { member: 20, pool_id: 1, balance: 20, points: 20 }, + Event::MemberRemoved { pool_id: 1, member: 20 }, + Event::Unbonded { member: 10, pool_id: 1, balance: 10, points: 10, era: 6 }, + Event::Withdrawn { member: 10, pool_id: 1, balance: 10, points: 10 }, + Event::MemberRemoved { pool_id: 1, member: 10 }, + Event::Destroyed { pool_id: 1 } ] ); @@ -1953,35 +1905,35 @@ mod claim_payout { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 1000000000000000, joined: true }, - PalletEvent::Bonded { + Event::Bonded { member: 20, pool_id: 1, bonded: 1500000000000000, joined: true }, - PalletEvent::Bonded { + Event::Bonded { member: 21, pool_id: 1, bonded: 2500000000000000, joined: true }, - PalletEvent::Bonded { + Event::Bonded { member: 22, pool_id: 1, bonded: 5000000000000000, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 100000000 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 150000000 }, - PalletEvent::PaidOut { member: 21, pool_id: 1, payout: 250000000 }, - PalletEvent::PaidOut { member: 22, pool_id: 1, payout: 500000000 } + Event::PaidOut { member: 10, pool_id: 1, payout: 100000000 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 150000000 }, + Event::PaidOut { member: 21, pool_id: 1, payout: 250000000 }, + Event::PaidOut { member: 22, pool_id: 1, payout: 500000000 } ] ); }) @@ -2312,18 +2264,12 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, - PalletEvent::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, - PalletEvent::PaidOut { member: 40, pool_id: 1, payout: 40 }, - PalletEvent::Unbonded { - member: 40, - pool_id: 1, - points: 6, - balance: 6, - era: 3 - } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, + Event::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, + Event::PaidOut { member: 40, pool_id: 1, payout: 40 }, + Event::Unbonded { member: 40, pool_id: 1, points: 6, balance: 6, era: 3 } ] ); @@ -2364,8 +2310,8 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 550, pool_id: 1, payout: 550 }, - PalletEvent::Unbonded { + Event::PaidOut { member: 550, pool_id: 1, payout: 550 }, + Event::Unbonded { member: 550, pool_id: 1, points: 92, @@ -2404,18 +2350,12 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { member: 40, pool_id: 1, points: 6, balance: 6 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 40 }, - PalletEvent::Withdrawn { member: 550, pool_id: 1, points: 92, balance: 92 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 550 }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10 }, - PalletEvent::Unbonded { - member: 10, - pool_id: 1, - points: 2, - balance: 2, - era: 6 - } + Event::Withdrawn { member: 40, pool_id: 1, points: 6, balance: 6 }, + Event::MemberRemoved { pool_id: 1, member: 40 }, + Event::Withdrawn { member: 550, pool_id: 1, points: 92, balance: 92 }, + Event::MemberRemoved { pool_id: 1, member: 550 }, + Event::PaidOut { member: 10, pool_id: 1, payout: 10 }, + Event::Unbonded { member: 10, pool_id: 1, points: 2, balance: 2, era: 6 } ] ); }); @@ -2459,15 +2399,9 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Unbonded { - member: 10, - pool_id: 1, - points: 10, - balance: 10, - era: 9 - } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Unbonded { member: 10, pool_id: 1, points: 10, balance: 10, era: 9 } ] ); }); @@ -2498,11 +2432,11 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Bonded { member: 200, pool_id: 1, bonded: 200, joined: true }, - PalletEvent::Unbonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + Event::Bonded { member: 200, pool_id: 1, bonded: 200, joined: true }, + Event::Unbonded { member: 100, pool_id: 1, points: 100, @@ -2517,7 +2451,7 @@ mod unbond { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Unbonded { + vec![Event::Unbonded { member: 200, pool_id: 1, points: 200, @@ -2589,16 +2523,10 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Unbonded { - member: 100, - pool_id: 1, - points: 100, - balance: 100, - era: 3 - } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + Event::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 } ] ); @@ -2747,9 +2675,9 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 3 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 3 } ] ); @@ -2775,13 +2703,7 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Unbonded { - member: 10, - pool_id: 1, - points: 5, - balance: 5, - era: 3 - }] + vec![Event::Unbonded { member: 10, pool_id: 1, points: 5, balance: 5, era: 3 }] ); // when: casual further unbond, next era. @@ -2808,13 +2730,7 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Unbonded { - member: 10, - pool_id: 1, - points: 1, - balance: 1, - era: 4 - }] + vec![Event::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 4 }] ); // when: unbonding more than our active: error @@ -2849,13 +2765,7 @@ mod unbond { ); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Unbonded { - member: 10, - pool_id: 1, - points: 3, - balance: 3, - era: 4 - }] + vec![Event::Unbonded { member: 10, pool_id: 1, points: 3, balance: 3, era: 4 }] ); }); } @@ -2897,12 +2807,12 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::Unbonded { member: 20, pool_id: 1, points: 2, balance: 2, era: 3 }, - PalletEvent::Unbonded { member: 20, pool_id: 1, points: 3, balance: 3, era: 4 }, - PalletEvent::Unbonded { member: 20, pool_id: 1, points: 1, balance: 1, era: 5 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::Unbonded { member: 20, pool_id: 1, points: 2, balance: 2, era: 3 }, + Event::Unbonded { member: 20, pool_id: 1, points: 3, balance: 3, era: 4 }, + Event::Unbonded { member: 20, pool_id: 1, points: 1, balance: 1, era: 5 } ] ); }) @@ -2933,9 +2843,9 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Unbonded { member: 10, pool_id: 1, points: 3, balance: 3, era: 3 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Unbonded { member: 10, pool_id: 1, points: 3, balance: 3, era: 3 } ] ); }); @@ -2977,11 +2887,11 @@ mod unbond { pool_events_since_last_call(), vec![ // 2/3 of ed, which is 20's share. - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 10 }, - PalletEvent::Unbonded { member: 20, pool_id: 1, balance: 2, points: 2, era: 3 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::PaidOut { member: 20, pool_id: 1, payout: 10 }, + Event::Unbonded { member: 20, pool_id: 1, balance: 2, points: 2, era: 3 } ] ); @@ -2996,8 +2906,8 @@ mod unbond { pool_events_since_last_call(), vec![ // 2/3 of ed, which is 20's share. - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 6 }, - PalletEvent::Unbonded { member: 20, pool_id: 1, points: 3, balance: 3, era: 4 } + Event::PaidOut { member: 20, pool_id: 1, payout: 6 }, + Event::Unbonded { member: 20, pool_id: 1, points: 3, balance: 3, era: 4 } ] ); @@ -3011,8 +2921,8 @@ mod unbond { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 3 }, - PalletEvent::Unbonded { member: 20, pool_id: 1, points: 5, balance: 5, era: 5 } + Event::PaidOut { member: 20, pool_id: 1, payout: 3 }, + Event::Unbonded { member: 20, pool_id: 1, points: 5, balance: 5, era: 5 } ] ); @@ -3114,24 +3024,18 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, - PalletEvent::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, - PalletEvent::Unbonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, + Event::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, + Event::Unbonded { member: 550, pool_id: 1, points: 550, balance: 550, era: 3 }, - PalletEvent::Unbonded { - member: 40, - pool_id: 1, - points: 40, - balance: 40, - era: 3 - }, + Event::Unbonded { member: 40, pool_id: 1, points: 40, balance: 40, era: 3 }, ] ); assert_eq!( @@ -3154,13 +3058,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { - member: 550, - pool_id: 1, - balance: 275, - points: 550 - }, - PalletEvent::MemberRemoved { pool_id: 1, member: 550 } + Event::Withdrawn { member: 550, pool_id: 1, balance: 275, points: 550 }, + Event::MemberRemoved { pool_id: 1, member: 550 } ] ); assert_eq!( @@ -3180,8 +3079,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { member: 40, pool_id: 1, balance: 20, points: 40 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 40 } + Event::Withdrawn { member: 40, pool_id: 1, balance: 20, points: 40 }, + Event::MemberRemoved { pool_id: 1, member: 40 } ] ); assert_eq!( @@ -3201,16 +3100,10 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Unbonded { - member: 10, - pool_id: 1, - balance: 5, - points: 5, - era: 9 - }, - PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 5, points: 5 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, - PalletEvent::Destroyed { pool_id: 1 } + Event::Unbonded { member: 10, pool_id: 1, balance: 5, points: 5, era: 9 }, + Event::Withdrawn { member: 10, pool_id: 1, balance: 5, points: 5 }, + Event::MemberRemoved { pool_id: 1, member: 10 }, + Event::Destroyed { pool_id: 1 } ] ); assert_eq!( @@ -3248,18 +3141,12 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, - PalletEvent::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, - PalletEvent::Unbonded { - member: 40, - pool_id: 1, - balance: 20, - points: 20, - era: 3 - }, - PalletEvent::Unbonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 40, pool_id: 1, bonded: 40, joined: true }, + Event::Bonded { member: 550, pool_id: 1, bonded: 550, joined: true }, + Event::Unbonded { member: 40, pool_id: 1, balance: 20, points: 20, era: 3 }, + Event::Unbonded { member: 550, pool_id: 1, balance: 275, @@ -3290,8 +3177,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { member: 40, pool_id: 1, balance: 20, points: 20 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 40 } + Event::Withdrawn { member: 40, pool_id: 1, balance: 20, points: 20 }, + Event::MemberRemoved { pool_id: 1, member: 40 } ] ); @@ -3311,13 +3198,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { - member: 550, - pool_id: 1, - balance: 275, - points: 275 - }, - PalletEvent::MemberRemoved { pool_id: 1, member: 550 } + Event::Withdrawn { member: 550, pool_id: 1, balance: 275, points: 275 }, + Event::MemberRemoved { pool_id: 1, member: 550 } ] ); assert!(SubPoolsStorage::::get(&1).unwrap().with_era.is_empty()); @@ -3346,16 +3228,10 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Unbonded { - member: 10, - pool_id: 1, - points: 5, - balance: 5, - era: 6 - }, - PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 5, balance: 5 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, - PalletEvent::Destroyed { pool_id: 1 } + Event::Unbonded { member: 10, pool_id: 1, points: 5, balance: 5, era: 6 }, + Event::Withdrawn { member: 10, pool_id: 1, points: 5, balance: 5 }, + Event::MemberRemoved { pool_id: 1, member: 10 }, + Event::Destroyed { pool_id: 1 } ] ); assert_eq!( @@ -3462,18 +3338,18 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Bonded { member: 200, pool_id: 1, bonded: 200, joined: true }, - PalletEvent::Unbonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + Event::Bonded { member: 200, pool_id: 1, bonded: 200, joined: true }, + Event::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 }, - PalletEvent::Unbonded { + Event::Unbonded { member: 200, pool_id: 1, points: 200, @@ -3506,20 +3382,10 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { - member: 100, - pool_id: 1, - points: 100, - balance: 100 - }, - PalletEvent::MemberRemoved { pool_id: 1, member: 100 }, - PalletEvent::Withdrawn { - member: 200, - pool_id: 1, - points: 200, - balance: 200 - }, - PalletEvent::MemberRemoved { pool_id: 1, member: 200 } + Event::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, + Event::MemberRemoved { pool_id: 1, member: 100 }, + Event::Withdrawn { member: 200, pool_id: 1, points: 200, balance: 200 }, + Event::MemberRemoved { pool_id: 1, member: 200 } ] ); }); @@ -3563,18 +3429,12 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Unbonded { - member: 100, - pool_id: 1, - points: 100, - balance: 100, - era: 3 - }, - PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 100 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + Event::Unbonded { member: 100, pool_id: 1, points: 100, balance: 100, era: 3 }, + Event::Withdrawn { member: 100, pool_id: 1, points: 100, balance: 100 }, + Event::MemberRemoved { pool_id: 1, member: 100 } ] ); }); @@ -3609,11 +3469,11 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, - PalletEvent::Unbonded { member: 10, pool_id: 1, points: 6, balance: 6, era: 3 }, - PalletEvent::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 4 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, + Event::Unbonded { member: 10, pool_id: 1, points: 6, balance: 6, era: 3 }, + Event::Unbonded { member: 10, pool_id: 1, points: 1, balance: 1, era: 4 } ] ); @@ -3644,7 +3504,7 @@ mod withdraw_unbonded { ); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 6, balance: 6 }] + vec![Event::Withdrawn { member: 10, pool_id: 1, points: 6, balance: 6 }] ); // when @@ -3659,7 +3519,7 @@ mod withdraw_unbonded { assert_eq!(SubPoolsStorage::::get(1).unwrap(), Default::default()); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 1, balance: 1 },] + vec![Event::Withdrawn { member: 10, pool_id: 1, points: 1, balance: 1 },] ); // when repeating: @@ -3696,11 +3556,11 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 11, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Unbonded { member: 11, pool_id: 1, points: 6, balance: 6, era: 3 }, - PalletEvent::Unbonded { member: 11, pool_id: 1, points: 1, balance: 1, era: 4 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 11, pool_id: 1, bonded: 10, joined: true }, + Event::Unbonded { member: 11, pool_id: 1, points: 6, balance: 6, era: 3 }, + Event::Unbonded { member: 11, pool_id: 1, points: 1, balance: 1, era: 4 } ] ); @@ -3731,7 +3591,7 @@ mod withdraw_unbonded { ); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Withdrawn { member: 11, pool_id: 1, points: 6, balance: 6 }] + vec![Event::Withdrawn { member: 11, pool_id: 1, points: 6, balance: 6 }] ); // when @@ -3746,7 +3606,7 @@ mod withdraw_unbonded { assert_eq!(SubPoolsStorage::::get(1).unwrap(), Default::default()); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Withdrawn { member: 11, pool_id: 1, points: 1, balance: 1 }] + vec![Event::Withdrawn { member: 11, pool_id: 1, points: 1, balance: 1 }] ); // when repeating: @@ -3786,24 +3646,12 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, - PalletEvent::Unbonded { - member: 100, - pool_id: 1, - points: 75, - balance: 75, - era: 3 - }, - PalletEvent::Unbonded { - member: 100, - pool_id: 1, - points: 25, - balance: 25, - era: 4 - }, - PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 75, balance: 75 }, + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 100, pool_id: 1, bonded: 100, joined: true }, + Event::Unbonded { member: 100, pool_id: 1, points: 75, balance: 75, era: 3 }, + Event::Unbonded { member: 100, pool_id: 1, points: 25, balance: 25, era: 4 }, + Event::Withdrawn { member: 100, pool_id: 1, points: 75, balance: 75 }, ] ); assert_eq!( @@ -3817,8 +3665,8 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { member: 100, pool_id: 1, points: 25, balance: 25 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 100 } + Event::Withdrawn { member: 100, pool_id: 1, points: 25, balance: 25 }, + Event::MemberRemoved { pool_id: 1, member: 100 } ] ); }) @@ -3870,19 +3718,13 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, - PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 7, points: 7, era: 3 }, - PalletEvent::Unbonded { member: 10, pool_id: 1, balance: 3, points: 3, era: 4 }, - PalletEvent::Unbonded { - member: 10, - pool_id: 1, - balance: 10, - points: 10, - era: 4 - }, - PalletEvent::Withdrawn { member: 10, pool_id: 1, balance: 7, points: 7 } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false }, + Event::Unbonded { member: 10, pool_id: 1, balance: 7, points: 7, era: 3 }, + Event::Unbonded { member: 10, pool_id: 1, balance: 3, points: 3, era: 4 }, + Event::Unbonded { member: 10, pool_id: 1, balance: 10, points: 10, era: 4 }, + Event::Withdrawn { member: 10, pool_id: 1, balance: 7, points: 7 } ] ); assert_eq!( @@ -3897,9 +3739,9 @@ mod withdraw_unbonded { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Withdrawn { member: 10, pool_id: 1, points: 13, balance: 13 }, - PalletEvent::MemberRemoved { pool_id: 1, member: 10 }, - PalletEvent::Destroyed { pool_id: 1 }, + Event::Withdrawn { member: 10, pool_id: 1, points: 13, balance: 13 }, + Event::MemberRemoved { pool_id: 1, member: 10 }, + Event::Destroyed { pool_id: 1 }, ] ); }) @@ -3968,10 +3810,10 @@ mod create { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Created { depositor: 11, pool_id: 2 }, - PalletEvent::Bonded { member: 11, pool_id: 2, bonded: 10, joined: true } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Created { depositor: 11, pool_id: 2 }, + Event::Bonded { member: 11, pool_id: 2, bonded: 10, joined: true } ] ); }); @@ -4102,9 +3944,9 @@ mod set_state { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Blocked } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::StateChanged { pool_id: 1, new_state: PoolState::Blocked } ] ); @@ -4155,9 +3997,9 @@ mod set_state { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, - PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, - PalletEvent::StateChanged { pool_id: 1, new_state: PoolState::Destroying } + Event::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, + Event::StateChanged { pool_id: 1, new_state: PoolState::Destroying }, + Event::StateChanged { pool_id: 1, new_state: PoolState::Destroying } ] ); }); @@ -4250,7 +4092,7 @@ mod set_configs { mod bond_extra { use super::*; - use crate::PalletEvent; + use crate::Event; #[test] fn bond_extra_from_free_balance_creator() { @@ -4274,9 +4116,9 @@ mod bond_extra { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: false } ] ); @@ -4290,7 +4132,7 @@ mod bond_extra { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 20, joined: false }] + vec![Event::Bonded { member: 10, pool_id: 1, bonded: 20, joined: false }] ); }) } @@ -4320,10 +4162,10 @@ mod bond_extra { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: claimable_reward }, - PalletEvent::Bonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: claimable_reward }, + Event::Bonded { member: 10, pool_id: 1, bonded: claimable_reward, @@ -4374,13 +4216,13 @@ mod bond_extra { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 1, joined: false }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 2 }, - PalletEvent::Bonded { member: 20, pool_id: 1, bonded: 2, joined: false } + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::Bonded { member: 20, pool_id: 1, bonded: 20, joined: true }, + Event::PaidOut { member: 10, pool_id: 1, payout: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 1, joined: false }, + Event::PaidOut { member: 20, pool_id: 1, payout: 2 }, + Event::Bonded { member: 20, pool_id: 1, bonded: 2, joined: false } ] ); }) @@ -4462,9 +4304,9 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, - PalletEvent::RolesUpdated { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 10, joined: true }, + Event::RolesUpdated { root: Some(5), state_toggler: Some(7), nominator: Some(6) @@ -4492,7 +4334,7 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::RolesUpdated { + vec![Event::RolesUpdated { root: Some(1), state_toggler: Some(3), nominator: Some(2) @@ -4519,7 +4361,7 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::RolesUpdated { + vec![Event::RolesUpdated { root: Some(11), state_toggler: Some(3), nominator: Some(2) @@ -4547,11 +4389,7 @@ mod update_roles { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::RolesUpdated { - root: Some(69), - state_toggler: None, - nominator: None - }] + vec![Event::RolesUpdated { root: Some(69), state_toggler: None, nominator: None }] ); assert_eq!( @@ -4602,8 +4440,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 1173908528796953165005, @@ -4631,7 +4469,7 @@ mod reward_counter_precision { assert_ok!(Pools::claim_payout(Origin::signed(10))); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 1173 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 1173 }] ); }) } @@ -4644,8 +4482,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 12_968_712_300_500_000_000, @@ -4668,7 +4506,7 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::Bonded { + vec![Event::Bonded { member: 20, pool_id: 1, bonded: 12_968_712_300_500_000_000, @@ -4681,7 +4519,7 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 15937424600999999996 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 15937424600999999996 }] ); // now let a small member join with 10 DOTs. @@ -4695,14 +4533,9 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Bonded { - member: 30, - pool_id: 1, - bonded: 100000000000, - joined: true - }, + Event::Bonded { member: 30, pool_id: 1, bonded: 100000000000, joined: true }, // quite small, but working fine. - PalletEvent::PaidOut { member: 30, pool_id: 1, payout: 38 } + Event::PaidOut { member: 30, pool_id: 1, payout: 38 } ] ); }) @@ -4716,8 +4549,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 12_968_712_300_500_000_000, @@ -4748,8 +4581,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 2500000000000000000, @@ -4773,13 +4606,13 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Bonded { + Event::Bonded { member: 20, pool_id: 1, bonded: 100000000000, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 9999997 } + Event::PaidOut { member: 10, pool_id: 1, payout: 9999997 } ] ); @@ -4792,7 +4625,7 @@ mod reward_counter_precision { assert_ok!(Pools::claim_payout(Origin::signed(10))); assert_eq!( pool_events_since_last_call(), - vec![PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10000000 }] + vec![Event::PaidOut { member: 10, pool_id: 1, payout: 10000000 }] ); // earn some more rewards, this time 20 can also claim. @@ -4805,8 +4638,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 10000000 }, - PalletEvent::PaidOut { member: 20, pool_id: 1, payout: 1 } + Event::PaidOut { member: 10, pool_id: 1, payout: 10000000 }, + Event::PaidOut { member: 20, pool_id: 1, payout: 1 } ] ); }); @@ -4822,8 +4655,8 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Created { depositor: 10, pool_id: 1 }, - PalletEvent::Bonded { + Event::Created { depositor: 10, pool_id: 1 }, + Event::Bonded { member: 10, pool_id: 1, bonded: 2500000000000000000, @@ -4849,13 +4682,13 @@ mod reward_counter_precision { assert_eq!( pool_events_since_last_call(), vec![ - PalletEvent::Bonded { + Event::Bonded { member: 20, pool_id: 1, bonded: 100000000000, joined: true }, - PalletEvent::PaidOut { member: 10, pool_id: 1, payout: 9999997 } + Event::PaidOut { member: 10, pool_id: 1, payout: 9999997 } ] ); diff --git a/frame/nomination-pools/test-staking/src/lib.rs b/frame/nomination-pools/test-staking/src/lib.rs index 1ef91a6fddcb0..5a7cd494362ca 100644 --- a/frame/nomination-pools/test-staking/src/lib.rs +++ b/frame/nomination-pools/test-staking/src/lib.rs @@ -22,10 +22,10 @@ mod mock; use frame_support::{assert_noop, assert_ok, bounded_btree_map, traits::Currency}; use mock::*; use pallet_nomination_pools::{ - BondedPools, Error as PoolsError, LastPoolId, PalletEvent as PoolsEvent, PoolMember, - PoolMembers, PoolState, + BondedPools, Error as PoolsError, Event as PoolsEvent, LastPoolId, PoolMember, PoolMembers, + PoolState, }; -use pallet_staking::{CurrentEra, PalletEvent as StakingEvent, Payee, RewardDestination}; +use pallet_staking::{CurrentEra, Event as StakingEvent, Payee, RewardDestination}; use sp_runtime::traits::Zero; #[test] diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 2ba66128085d0..90b9be0568f5a 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -244,7 +244,7 @@ parameter_types! { static ObservedEventsBalances: usize = 0; } -pub(crate) fn pool_events_since_last_call() -> Vec> { +pub(crate) fn pool_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) @@ -255,7 +255,7 @@ pub(crate) fn pool_events_since_last_call() -> Vec Vec> { +pub(crate) fn staking_events_since_last_call() -> Vec> { let events = System::events() .into_iter() .map(|r| r.event) diff --git a/frame/offences/benchmarking/src/lib.rs b/frame/offences/benchmarking/src/lib.rs index c04e0bc86aaf7..f73dd9caac9c6 100644 --- a/frame/offences/benchmarking/src/lib.rs +++ b/frame/offences/benchmarking/src/lib.rs @@ -43,8 +43,8 @@ use pallet_session::{ Config as SessionConfig, SessionManager, }; use pallet_staking::{ - Config as StakingConfig, Exposure, IndividualExposure, Pallet as Staking, - PalletEvent as StakingEvent, RewardDestination, ValidatorPrefs, + Config as StakingConfig, Event as StakingEvent, Exposure, IndividualExposure, + Pallet as Staking, RewardDestination, ValidatorPrefs, }; const SEED: u32 = 0; @@ -311,13 +311,13 @@ benchmarks! { ::RuntimeEvent::from(StakingEvent::::Slashed(id, BalanceOf::::from(slash_amount))) ); let balance_slash = |id| core::iter::once( - ::RuntimeEvent::from(pallet_balances::PalletEvent::::Slashed{who: id, amount: slash_amount.into()}) + ::RuntimeEvent::from(pallet_balances::Event::::Slashed{who: id, amount: slash_amount.into()}) ); let chill = |id| core::iter::once( ::RuntimeEvent::from(StakingEvent::::Chilled(id)) ); let balance_deposit = |id, amount: u32| - ::RuntimeEvent::from(pallet_balances::PalletEvent::::Deposit{who: id, amount: amount.into()}); + ::RuntimeEvent::from(pallet_balances::Event::::Deposit{who: id, amount: amount.into()}); let mut first = true; let slash_events = raw_offenders.into_iter() .flat_map(|offender| { @@ -338,9 +338,9 @@ benchmarks! { let mut reward_events = reporters.clone().into_iter() .flat_map(|reporter| vec![ balance_deposit(reporter.clone(), reward).into(), - frame_system::PalletEvent::::NewAccount { account: reporter.clone() }.into(), + frame_system::Event::::NewAccount { account: reporter.clone() }.into(), ::RuntimeEvent::from( - pallet_balances::PalletEvent::::Endowed{account: reporter, free_balance: reward.into()} + pallet_balances::Event::::Endowed{account: reporter, free_balance: reward.into()} ).into(), ]) .collect::>(); @@ -367,7 +367,7 @@ benchmarks! { std::iter::empty() .chain(slash_events.into_iter().map(Into::into)) .chain(std::iter::once(::RuntimeEvent::from( - pallet_offences::PalletEvent::Offence{ + pallet_offences::Event::Offence{ kind: UnresponsivenessOffence::::ID, timeslot: 0_u32.to_le_bytes().to_vec(), } diff --git a/frame/offences/src/lib.rs b/frame/offences/src/lib.rs index 32af60d6f6fd3..7858b02719c4c 100644 --- a/frame/offences/src/lib.rs +++ b/frame/offences/src/lib.rs @@ -57,7 +57,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// Full identification of the validator. type IdentificationTuple: Parameter; /// A handler called for every offence report. @@ -104,7 +104,7 @@ pub mod pallet { /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// There is an offence reported of the given `kind` happened at the `session_index` and /// (kind-specific) time slot. This event is not deposited for duplicate slashes. /// \[kind, timeslot\]. @@ -145,7 +145,7 @@ where ); // Deposit the event. - Self::deposit_event(PalletEvent::Offence { kind: O::ID, timeslot: time_slot.encode() }); + Self::deposit_event(Event::Offence { kind: O::ID, timeslot: time_slot.encode() }); Ok(()) } diff --git a/frame/offences/src/tests.rs b/frame/offences/src/tests.rs index 7efe5946e2d74..266e05debf050 100644 --- a/frame/offences/src/tests.rs +++ b/frame/offences/src/tests.rs @@ -114,7 +114,7 @@ fn should_deposit_event() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Offences(crate::PalletEvent::Offence { + event: RuntimeEvent::Offences(crate::Event::Offence { kind: KIND, timeslot: time_slot.encode() }), @@ -148,7 +148,7 @@ fn doesnt_deposit_event_for_dups() { System::events(), vec![EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::Offences(crate::PalletEvent::Offence { + event: RuntimeEvent::Offences(crate::Event::Offence { kind: KIND, timeslot: time_slot.encode() }), diff --git a/frame/preimage/src/lib.rs b/frame/preimage/src/lib.rs index 6cbb92d575f89..e4616078b0761 100644 --- a/frame/preimage/src/lib.rs +++ b/frame/preimage/src/lib.rs @@ -76,8 +76,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The Weight information for this pallet. type WeightInfo: weights::WeightInfo; @@ -105,7 +104,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A preimage has been noted. Noted { hash: T::Hash }, /// A preimage has been requested. @@ -234,7 +233,7 @@ impl Pallet { }; PreimageFor::::insert(hash, preimage); - Self::deposit_event(PalletEvent::Noted { hash }); + Self::deposit_event(Event::Noted { hash }); Ok(was_requested) } @@ -258,7 +257,7 @@ impl Pallet { }); StatusFor::::insert(hash, RequestStatus::Requested(count)); if count == 1 { - Self::deposit_event(PalletEvent::Requested { hash: *hash }); + Self::deposit_event(Event::Requested { hash: *hash }); } } @@ -282,7 +281,7 @@ impl Pallet { } StatusFor::::remove(hash); PreimageFor::::remove(hash); - Self::deposit_event(PalletEvent::Cleared { hash: *hash }); + Self::deposit_event(Event::Cleared { hash: *hash }); Ok(()) } @@ -297,7 +296,7 @@ impl Pallet { debug_assert!(count == 1, "preimage request counter at zero?"); PreimageFor::::remove(hash); StatusFor::::remove(hash); - Self::deposit_event(PalletEvent::Cleared { hash: *hash }); + Self::deposit_event(Event::Cleared { hash: *hash }); }, RequestStatus::Unrequested(_) => return Err(Error::::NotRequested.into()), } diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 471fb2e05b9ea..11171eebcf04f 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -91,7 +91,7 @@ benchmarks! { let call: ::Call = frame_system::Call::::remark { remark: vec![] }.into(); }: _(RawOrigin::Signed(caller), real_lookup, Some(T::ProxyType::default()), Box::new(call)) verify { - assert_last_event::(PalletEvent::ProxyExecuted { result: Ok(()) }.into()) + assert_last_event::(Event::ProxyExecuted { result: Ok(()) }.into()) } proxy_announced { @@ -114,7 +114,7 @@ benchmarks! { add_announcements::(a, Some(delegate.clone()), None)?; }: _(RawOrigin::Signed(caller), delegate_lookup, real_lookup, Some(T::ProxyType::default()), Box::new(call)) verify { - assert_last_event::(PalletEvent::ProxyExecuted { result: Ok(()) }.into()) + assert_last_event::(Event::ProxyExecuted { result: Ok(()) }.into()) } remove_announcement { @@ -176,7 +176,7 @@ benchmarks! { let call_hash = T::CallHasher::hash_of(&call); }: _(RawOrigin::Signed(caller.clone()), real_lookup, call_hash) verify { - assert_last_event::(PalletEvent::Announced { real, proxy: caller, call_hash }.into()); + assert_last_event::(Event::Announced { real, proxy: caller, call_hash }.into()); } add_proxy { @@ -229,7 +229,7 @@ benchmarks! { ) verify { let anon_account = Pallet::::anonymous_account(&caller, &T::ProxyType::default(), 0, None); - assert_last_event::(PalletEvent::AnonymousCreated { + assert_last_event::(Event::AnonymousCreated { anonymous: anon_account, who: caller, proxy_type: T::ProxyType::default(), diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 855e7dff01217..673abd7b0708b 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -110,8 +110,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter @@ -332,7 +331,7 @@ pub mod pallet { T::Currency::reserve(&who, deposit)?; Proxies::::insert(&anonymous, (bounded_proxies, deposit)); - Self::deposit_event(PalletEvent::AnonymousCreated { + Self::deposit_event(Event::AnonymousCreated { anonymous, who, proxy_type, @@ -439,7 +438,7 @@ pub mod pallet { }) .map(|d| *deposit = d) })?; - Self::deposit_event(PalletEvent::Announced { real, proxy: who, call_hash }); + Self::deposit_event(Event::Announced { real, proxy: who, call_hash }); Ok(()) } @@ -564,7 +563,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A proxy was executed correctly, with the given. ProxyExecuted { result: DispatchResult }, /// Anonymous account has been created by new proxy with given @@ -703,7 +702,7 @@ impl Pallet { T::Currency::unreserve(delegator, *deposit - new_deposit); } *deposit = new_deposit; - Self::deposit_event(PalletEvent::::ProxyAdded { + Self::deposit_event(Event::::ProxyAdded { delegator: delegator.clone(), delegatee, proxy_type, @@ -745,7 +744,7 @@ impl Pallet { if !proxies.is_empty() { *x = Some((proxies, new_deposit)) } - Self::deposit_event(PalletEvent::::ProxyRemoved { + Self::deposit_event(Event::::ProxyRemoved { delegator: delegator.clone(), delegatee, proxy_type, @@ -841,8 +840,6 @@ impl Pallet { } }); let e = call.dispatch(origin); - Self::deposit_event(PalletEvent::ProxyExecuted { - result: e.map(|_| ()).map_err(|e| e.error), - }); + Self::deposit_event(Event::ProxyExecuted { result: e.map(|_| ()).map_err(|e| e.error) }); } } diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index ce892f53cca30..50b6a97ef3c32 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -164,10 +164,10 @@ impl Config for Test { type AnnouncementDepositFactor = ConstU64<1>; } -use super::{Call as ProxyCall, PalletEvent as ProxyEvent}; +use super::{Call as ProxyCall, Event as ProxyEvent}; use frame_system::Call as SystemCall; -use pallet_balances::{Call as BalancesCall, Error as BalancesError, PalletEvent as BalancesEvent}; -use pallet_utility::{Call as UtilityCall, PalletEvent as UtilityEvent}; +use pallet_balances::{Call as BalancesCall, Error as BalancesError, Event as BalancesEvent}; +use pallet_utility::{Call as UtilityCall, Event as UtilityEvent}; type SystemError = frame_system::Error; diff --git a/frame/ranked-collective/src/benchmarking.rs b/frame/ranked-collective/src/benchmarking.rs index c60b50a6e23d9..a4d074450e836 100644 --- a/frame/ranked-collective/src/benchmarking.rs +++ b/frame/ranked-collective/src/benchmarking.rs @@ -56,7 +56,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert_eq!(MemberCount::::get(0), 1); - assert_last_event::(PalletEvent::MemberAdded { who }.into()); + assert_last_event::(Event::MemberAdded { who }.into()); } remove_member { @@ -75,7 +75,7 @@ benchmarks_instance_pallet! { assert_eq!(MemberCount::::get(r), 2); assert_ne!(last_index[r as usize], IdToIndex::::get(r, &last).unwrap()); } - assert_last_event::(PalletEvent::MemberRemoved { who, rank }.into()); + assert_last_event::(Event::MemberRemoved { who, rank }.into()); } promote_member { @@ -88,7 +88,7 @@ benchmarks_instance_pallet! { }: { call.dispatch_bypass_filter(origin)? } verify { assert_eq!(Members::::get(&who).unwrap().rank, rank + 1); - assert_last_event::(PalletEvent::RankChanged { who, rank: rank + 1 }.into()); + assert_last_event::(Event::RankChanged { who, rank: rank + 1 }.into()); } demote_member { @@ -107,8 +107,8 @@ benchmarks_instance_pallet! { assert_eq!(MemberCount::::get(rank), 2); assert_ne!(last_index, IdToIndex::::get(rank, &last).unwrap()); assert_last_event::(match rank { - 0 => PalletEvent::MemberRemoved { who, rank: 0 }, - r => PalletEvent::RankChanged { who, rank: r - 1 }, + 0 => Event::MemberRemoved { who, rank: 0 }, + r => Event::RankChanged { who, rank: r - 1 }, }.into()); } @@ -133,7 +133,7 @@ benchmarks_instance_pallet! { }: _(SystemOrigin::Signed(caller.clone()), poll, false) verify { let tally = Tally::from_parts(0, 0, 1); - let ev = PalletEvent::Voted { who: caller, poll, vote: VoteRecord::Nay(1), tally }; + let ev = Event::Voted { who: caller, poll, vote: VoteRecord::Nay(1), tally }; assert_last_event::(ev.into()); } diff --git a/frame/ranked-collective/src/lib.rs b/frame/ranked-collective/src/lib.rs index 214c66c62f6f5..7f212b3859776 100644 --- a/frame/ranked-collective/src/lib.rs +++ b/frame/ranked-collective/src/lib.rs @@ -363,7 +363,7 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The outer event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The origin required to add or promote a mmember. The success value indicates the @@ -428,7 +428,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// A member `who` has been added. MemberAdded { who: T::AccountId }, /// The member `who`'s rank has been changed to the given `rank`. @@ -511,12 +511,12 @@ pub mod pallet { match maybe_rank { None => { Members::::remove(&who); - Self::deposit_event(PalletEvent::MemberRemoved { who, rank: 0 }); + Self::deposit_event(Event::MemberRemoved { who, rank: 0 }); }, Some(rank) => { record.rank = rank; Members::::insert(&who, &record); - Self::deposit_event(PalletEvent::RankChanged { who, rank }); + Self::deposit_event(Event::RankChanged { who, rank }); }, } Ok(()) @@ -545,7 +545,7 @@ pub mod pallet { Self::remove_from_rank(&who, r)?; } Members::::remove(&who); - Self::deposit_event(PalletEvent::MemberRemoved { who, rank }); + Self::deposit_event(Event::MemberRemoved { who, rank }); Ok(PostDispatchInfo { actual_weight: Some(T::WeightInfo::remove_member(rank as u32)), pays_fee: Pays::Yes, @@ -605,7 +605,7 @@ pub mod pallet { } }, )?; - Self::deposit_event(PalletEvent::Voted { who, poll, vote, tally }); + Self::deposit_event(Event::Voted { who, poll, vote, tally }); Ok(pays.into()) } @@ -682,7 +682,7 @@ pub mod pallet { IdToIndex::::insert(0, &who, index); IndexToId::::insert(0, index, &who); MemberCount::::insert(0, count); - Self::deposit_event(PalletEvent::MemberAdded { who }); + Self::deposit_event(Event::MemberAdded { who }); Ok(()) } @@ -704,7 +704,7 @@ pub mod pallet { IdToIndex::::insert(rank, &who, index); IndexToId::::insert(rank, index, &who); Members::::insert(&who, MemberRecord { rank }); - Self::deposit_event(PalletEvent::RankChanged { who, rank }); + Self::deposit_event(Event::RankChanged { who, rank }); Ok(()) } diff --git a/frame/recovery/src/benchmarking.rs b/frame/recovery/src/benchmarking.rs index 99143f4b27dc4..9e085a01d1167 100644 --- a/frame/recovery/src/benchmarking.rs +++ b/frame/recovery/src/benchmarking.rs @@ -127,7 +127,7 @@ benchmarks! { rescuer_lookup ) verify { assert_last_event::( - PalletEvent::AccountRecovered { + Event::AccountRecovered { lost_account: lost, rescuer_account: rescuer, }.into() @@ -148,7 +148,7 @@ benchmarks! { n as u16, DEFAULT_DELAY.into() ) verify { - assert_last_event::(PalletEvent::RecoveryCreated { account: caller }.into()); + assert_last_event::(Event::RecoveryCreated { account: caller }.into()); } initiate_recovery { @@ -164,7 +164,7 @@ benchmarks! { lost_account_lookup ) verify { assert_last_event::( - PalletEvent::RecoveryInitiated { + Event::RecoveryInitiated { lost_account: lost_account, rescuer_account: caller, }.into() @@ -217,7 +217,7 @@ benchmarks! { rescuer_account_lookup ) verify { assert_last_event::( - PalletEvent::RecoveryVouched { + Event::RecoveryVouched { lost_account: lost_account, rescuer_account: rescuer_account, sender: caller, @@ -268,7 +268,7 @@ benchmarks! { lost_account_lookup ) verify { assert_last_event::( - PalletEvent::AccountRecovered { + Event::AccountRecovered { lost_account: lost_account, rescuer_account: caller, }.into() @@ -319,7 +319,7 @@ benchmarks! { rescuer_account_lookup ) verify { assert_last_event::( - PalletEvent::RecoveryClosed { + Event::RecoveryClosed { lost_account: caller, rescuer_account: rescuer_account, }.into() @@ -356,7 +356,7 @@ benchmarks! { RawOrigin::Signed(caller.clone()) ) verify { assert_last_event::( - PalletEvent::RecoveryRemoved { + Event::RecoveryRemoved { lost_account: caller }.into() ); diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index 7e8b0bec41b57..5d10caabdeb9b 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -226,8 +226,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -279,7 +278,7 @@ pub mod pallet { /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A recovery process has been set up for an account. RecoveryCreated { account: T::AccountId }, /// A recovery process has been initiated for lost account by rescuer account. @@ -416,7 +415,7 @@ pub mod pallet { let rescuer = T::Lookup::lookup(rescuer)?; // Create the recovery storage item. >::insert(&rescuer, &lost); - Self::deposit_event(PalletEvent::::AccountRecovered { + Self::deposit_event(Event::::AccountRecovered { lost_account: lost, rescuer_account: rescuer, }); @@ -475,7 +474,7 @@ pub mod pallet { // Create the recovery configuration storage item >::insert(&who, recovery_config); - Self::deposit_event(PalletEvent::::RecoveryCreated { account: who }); + Self::deposit_event(Event::::RecoveryCreated { account: who }); Ok(()) } @@ -515,7 +514,7 @@ pub mod pallet { }; // Create the active recovery storage item >::insert(&account, &who, recovery_status); - Self::deposit_event(PalletEvent::::RecoveryInitiated { + Self::deposit_event(Event::::RecoveryInitiated { lost_account: account, rescuer_account: who, }); @@ -560,7 +559,7 @@ pub mod pallet { } // Update storage with the latest details >::insert(&lost, &rescuer, active_recovery); - Self::deposit_event(PalletEvent::::RecoveryVouched { + Self::deposit_event(Event::::RecoveryVouched { lost_account: lost, rescuer_account: rescuer, sender: who, @@ -606,7 +605,7 @@ pub mod pallet { frame_system::Pallet::::inc_consumers(&who).map_err(|_| Error::::BadState)?; // Create the recovery storage item Proxy::::insert(&who, &account); - Self::deposit_event(PalletEvent::::AccountRecovered { + Self::deposit_event(Event::::AccountRecovered { lost_account: account, rescuer_account: who, }); @@ -643,7 +642,7 @@ pub mod pallet { BalanceStatus::Free, ); debug_assert!(res.is_ok()); - Self::deposit_event(PalletEvent::::RecoveryClosed { + Self::deposit_event(Event::::RecoveryClosed { lost_account: who, rescuer_account: rescuer, }); @@ -672,7 +671,7 @@ pub mod pallet { // Unreserve the initial deposit for the recovery configuration. T::Currency::unreserve(&who, recovery_config.deposit); - Self::deposit_event(PalletEvent::::RecoveryRemoved { lost_account: who }); + Self::deposit_event(Event::::RecoveryRemoved { lost_account: who }); Ok(()) } diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index 38bda3f2a8d63..f33a340d98eab 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -124,7 +124,7 @@ pub mod pallet { pub trait Config: frame_system::Config + Sized { // System level stuff. type Call: Parameter + Dispatchable + From>; - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; @@ -220,7 +220,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// A referendum has being submitted. Submitted { /// Index of the referendum. @@ -387,7 +387,7 @@ pub mod pallet { }; ReferendumInfoFor::::insert(index, ReferendumInfo::Ongoing(status)); - Self::deposit_event(PalletEvent::::Submitted { index, track, proposal_hash }); + Self::deposit_event(Event::::Submitted { index, track, proposal_hash }); Ok(()) } @@ -413,11 +413,8 @@ pub mod pallet { let now = frame_system::Pallet::::block_number(); let (info, _, branch) = Self::service_referendum(now, index, status); ReferendumInfoFor::::insert(index, info); - let e = PalletEvent::::DecisionDepositPlaced { - index, - who, - amount: track.decision_deposit, - }; + let e = + Event::::DecisionDepositPlaced { index, who, amount: track.decision_deposit }; Self::deposit_event(e); Ok(branch.weight_of_deposit::().into()) } @@ -443,7 +440,7 @@ pub mod pallet { .ok_or(Error::::NoDeposit)?; Self::refund_deposit(Some(deposit.clone())); ReferendumInfoFor::::insert(index, info); - let e = PalletEvent::::DecisionDepositRefunded { + let e = Event::::DecisionDepositRefunded { index, who: deposit.who, amount: deposit.amount, @@ -466,7 +463,7 @@ pub mod pallet { let _ = T::Scheduler::cancel(last_alarm); } Self::note_one_fewer_deciding(status.track); - Self::deposit_event(PalletEvent::::Cancelled { index, tally: status.tally }); + Self::deposit_event(Event::::Cancelled { index, tally: status.tally }); let info = ReferendumInfo::Cancelled( frame_system::Pallet::::block_number(), status.submission_deposit, @@ -490,7 +487,7 @@ pub mod pallet { let _ = T::Scheduler::cancel(last_alarm); } Self::note_one_fewer_deciding(status.track); - Self::deposit_event(PalletEvent::::Killed { index, tally: status.tally }); + Self::deposit_event(Event::::Killed { index, tally: status.tally }); Self::slash_deposit(Some(status.submission_deposit.clone())); Self::slash_deposit(status.decision_deposit.clone()); let info = ReferendumInfo::Killed(frame_system::Pallet::::block_number()); @@ -744,14 +741,14 @@ impl, I: 'static> Pallet { status.track, ); status.in_queue = false; - Self::deposit_event(PalletEvent::::DecisionStarted { + Self::deposit_event(Event::::DecisionStarted { index, tally: status.tally.clone(), proposal_hash: status.proposal_hash, track: status.track, }); let confirming = if is_passing { - Self::deposit_event(PalletEvent::::ConfirmStarted { index }); + Self::deposit_event(Event::::ConfirmStarted { index }); Some(now.saturating_add(track.confirm_period)) } else { None @@ -931,10 +928,7 @@ impl, I: 'static> Pallet { if status.deciding.is_none() && now >= timeout { // Too long without being decided - end it. Self::ensure_no_alarm(&mut status); - Self::deposit_event(PalletEvent::::TimedOut { - index, - tally: status.tally, - }); + Self::deposit_event(Event::::TimedOut { index, tally: status.tally }); return ( ReferendumInfo::TimedOut( now, @@ -969,7 +963,7 @@ impl, I: 'static> Pallet { status.origin, call_hash, ); - Self::deposit_event(PalletEvent::::Confirmed { + Self::deposit_event(Event::::Confirmed { index, tally: status.tally, }); @@ -988,7 +982,7 @@ impl, I: 'static> Pallet { // Start confirming dirty = true; deciding.confirming = Some(now.saturating_add(track.confirm_period)); - Self::deposit_event(PalletEvent::::ConfirmStarted { index }); + Self::deposit_event(Event::::ConfirmStarted { index }); ServiceBranch::BeginConfirming }, } @@ -997,10 +991,7 @@ impl, I: 'static> Pallet { // Failed! Self::ensure_no_alarm(&mut status); Self::note_one_fewer_deciding(status.track); - Self::deposit_event(PalletEvent::::Rejected { - index, - tally: status.tally, - }); + Self::deposit_event(Event::::Rejected { index, tally: status.tally }); return ( ReferendumInfo::Rejected( now, @@ -1015,7 +1006,7 @@ impl, I: 'static> Pallet { // Stop confirming dirty = true; deciding.confirming = None; - Self::deposit_event(PalletEvent::::ConfirmAborted { index }); + Self::deposit_event(Event::::ConfirmAborted { index }); ServiceBranch::EndConfirming } else { ServiceBranch::ContinueNotConfirming @@ -1076,7 +1067,7 @@ impl, I: 'static> Pallet { fn slash_deposit(deposit: Option>>) { if let Some(Deposit { who, amount }) = deposit { T::Slash::on_unbalanced(T::Currency::slash_reserved(&who, amount).0); - Self::deposit_event(PalletEvent::::DepositSlashed { who, amount }); + Self::deposit_event(Event::::DepositSlashed { who, amount }); } } diff --git a/frame/remark/src/benchmarking.rs b/frame/remark/src/benchmarking.rs index 77f2693cd5a86..c0db8d5d3d59b 100644 --- a/frame/remark/src/benchmarking.rs +++ b/frame/remark/src/benchmarking.rs @@ -40,7 +40,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); }: _(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize]) verify { - assert_last_event::(PalletEvent::Stored { sender: caller, content_hash: sp_io::hashing::blake2_256(&vec![0u8; l as usize]).into() }.into()); + assert_last_event::(Event::Stored { sender: caller, content_hash: sp_io::hashing::blake2_256(&vec![0u8; l as usize]).into() }.into()); } impl_benchmark_test_suite!(Remark, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/frame/remark/src/lib.rs b/frame/remark/src/lib.rs index a6c938dac51ad..b61c79f7f273d 100644 --- a/frame/remark/src/lib.rs +++ b/frame/remark/src/lib.rs @@ -43,8 +43,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; } @@ -71,14 +70,14 @@ pub mod pallet { let extrinsic_index = >::extrinsic_index() .ok_or_else(|| Error::::BadContext)?; sp_io::transaction_index::index(extrinsic_index, remark.len() as u32, content_hash); - Self::deposit_event(PalletEvent::Stored { sender, content_hash: content_hash.into() }); + Self::deposit_event(Event::Stored { sender, content_hash: content_hash.into() }); Ok(().into()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Stored data off chain. Stored { sender: T::AccountId, content_hash: sp_core::H256 }, } diff --git a/frame/remark/src/tests.rs b/frame/remark/src/tests.rs index 13af160894bff..2278e3817b48a 100644 --- a/frame/remark/src/tests.rs +++ b/frame/remark/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for remarks pallet. -use super::{Error, Pallet as Remark, PalletEvent}; +use super::{Error, Event, Pallet as Remark}; use crate::mock::*; use frame_support::{assert_noop, assert_ok}; use frame_system::RawOrigin; @@ -31,7 +31,7 @@ fn generates_event() { assert_ok!(Remark::::store(RawOrigin::Signed(caller).into(), data.clone(),)); let events = System::events(); // this one we create as we expect it - let system_event: ::RuntimeEvent = PalletEvent::Stored { + let system_event: ::RuntimeEvent = Event::Stored { content_hash: sp_io::hashing::blake2_256(&data).into(), sender: caller, } diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 0254f523536f7..b46df64d7608d 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -198,8 +198,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The aggregated origin which the dispatch will take. type Origin: OriginTrait @@ -260,7 +259,7 @@ pub mod pallet { /// Events type. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Scheduled some task. Scheduled { when: T::BlockNumber, index: u32 }, /// Canceled some task. @@ -394,7 +393,7 @@ pub mod pallet { total_weight.saturating_accrue(item_weight); total_weight.saturating_accrue(actual_call_weight); - Self::deposit_event(PalletEvent::Dispatched { + Self::deposit_event(Event::Dispatched { task: (now, index), id: s.maybe_id.clone(), result, @@ -697,7 +696,7 @@ impl Pallet { }); Agenda::::append(when, s); let index = Agenda::::decode_len(when).unwrap_or(1) as u32 - 1; - Self::deposit_event(PalletEvent::Scheduled { when, index }); + Self::deposit_event(Event::Scheduled { when, index }); Ok((when, index)) } @@ -727,7 +726,7 @@ impl Pallet { if let Some(id) = s.maybe_id { Lookup::::remove(id); } - Self::deposit_event(PalletEvent::Canceled { when, index }); + Self::deposit_event(Event::Canceled { when, index }); Ok(()) } else { return Err(Error::::NotFound.into()) @@ -752,8 +751,8 @@ impl Pallet { })?; let new_index = Agenda::::decode_len(new_time).unwrap_or(1) as u32 - 1; - Self::deposit_event(PalletEvent::Canceled { when, index }); - Self::deposit_event(PalletEvent::Scheduled { when: new_time, index: 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)) } @@ -793,7 +792,7 @@ impl Pallet { let index = Agenda::::decode_len(when).unwrap_or(1) as u32 - 1; let address = (when, index); Lookup::::insert(&id, &address); - Self::deposit_event(PalletEvent::Scheduled { when, index }); + Self::deposit_event(Event::Scheduled { when, index }); Ok(address) } @@ -817,7 +816,7 @@ impl Pallet { } Ok(()) })?; - Self::deposit_event(PalletEvent::Canceled { when, index }); + Self::deposit_event(Event::Canceled { when, index }); Ok(()) } else { return Err(Error::::NotFound.into()) @@ -849,8 +848,8 @@ impl Pallet { })?; let new_index = Agenda::::decode_len(new_time).unwrap_or(1) as u32 - 1; - Self::deposit_event(PalletEvent::Canceled { when, index }); - Self::deposit_event(PalletEvent::Scheduled { when: new_time, index: 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)); diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index d6f00a293fd21..b97c8eeb385b7 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -59,13 +59,12 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { Logged(u32, Weight), } @@ -76,7 +75,7 @@ pub mod logger { { #[pallet::weight(*weight)] pub fn log(origin: OriginFor, i: u32, weight: Weight) -> DispatchResult { - Self::deposit_event(PalletEvent::Logged(i, weight)); + Self::deposit_event(Event::Logged(i, weight)); LOG.with(|log| { log.borrow_mut().push((origin.caller().clone(), i)); }); @@ -85,7 +84,7 @@ pub mod logger { #[pallet::weight(*weight)] pub fn log_without_filter(origin: OriginFor, i: u32, weight: Weight) -> DispatchResult { - Self::deposit_event(PalletEvent::Logged(i, weight)); + Self::deposit_event(Event::Logged(i, weight)); LOG.with(|log| { log.borrow_mut().push((origin.caller().clone(), i)); }); diff --git a/frame/scored-pool/src/lib.rs b/frame/scored-pool/src/lib.rs index deff80fe52582..5c121b8d7a4b5 100644 --- a/frame/scored-pool/src/lib.rs +++ b/frame/scored-pool/src/lib.rs @@ -149,7 +149,7 @@ pub mod pallet { + scale_info::TypeInfo; /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; // The deposit which is reserved from candidates if they want to @@ -184,7 +184,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// The given member was removed. See the transaction for who. MemberRemoved, /// An entity has issued a candidacy. See the transaction for who. @@ -313,7 +313,7 @@ pub mod pallet { >::insert(&who, true); - Self::deposit_event(PalletEvent::::CandidateAdded); + Self::deposit_event(Event::::CandidateAdded); Ok(()) } @@ -335,7 +335,7 @@ pub mod pallet { Self::ensure_index(&pool, &who, index)?; Self::remove_member(pool, who, index)?; - Self::deposit_event(PalletEvent::::CandidateWithdrew); + Self::deposit_event(Event::::CandidateWithdrew); Ok(()) } @@ -359,7 +359,7 @@ pub mod pallet { Self::ensure_index(&pool, &who, index)?; Self::remove_member(pool, who, index)?; - Self::deposit_event(PalletEvent::::CandidateKicked); + Self::deposit_event(Event::::CandidateKicked); Ok(()) } @@ -398,7 +398,7 @@ pub mod pallet { pool.insert(location, item); >::put(&pool); - Self::deposit_event(PalletEvent::::CandidateScored); + Self::deposit_event(Event::::CandidateScored); Ok(()) } @@ -473,7 +473,7 @@ impl, I: 'static> Pallet { T::Currency::unreserve(&remove, T::CandidateDeposit::get()); - Self::deposit_event(PalletEvent::::MemberRemoved); + Self::deposit_event(Event::::MemberRemoved); Ok(()) } diff --git a/frame/session/src/lib.rs b/frame/session/src/lib.rs index 31d60ea57d3e9..7d568719477b7 100644 --- a/frame/session/src/lib.rs +++ b/frame/session/src/lib.rs @@ -379,7 +379,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// A stable ID for a validator. type ValidatorId: Member @@ -541,7 +541,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// New session has happened. Note that the argument is the session index, not the /// block number as the type might suggest. NewSession { session_index: SessionIndex }, @@ -708,7 +708,7 @@ impl Pallet { >::put(next_changed); // Record that this happened. - Self::deposit_event(PalletEvent::NewSession { session_index }); + Self::deposit_event(Event::NewSession { session_index }); // Tell everyone about the new session keys. T::SessionHandler::on_new_session::(changed, &session_keys, &queued_amalgamated); diff --git a/frame/society/src/lib.rs b/frame/society/src/lib.rs index 5a63166cf8166..222de9de98f76 100644 --- a/frame/society/src/lib.rs +++ b/frame/society/src/lib.rs @@ -378,7 +378,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The societies's pallet id @@ -477,7 +477,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// 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 @@ -727,7 +727,7 @@ pub mod pallet { T::Currency::reserve(&who, deposit)?; Self::put_bid(bids, &who, value, BidKind::Deposit(deposit)); - Self::deposit_event(PalletEvent::::Bid { candidate_id: who, offer: value }); + Self::deposit_event(Event::::Bid { candidate_id: who, offer: value }); Ok(()) } @@ -769,7 +769,7 @@ pub mod pallet { >::remove(&voucher); }, } - Self::deposit_event(PalletEvent::::Unbid { candidate: who }); + Self::deposit_event(Event::::Unbid { candidate: who }); Ok(()) } else { Err(Error::::BadPosition.into()) @@ -848,7 +848,7 @@ pub mod pallet { >::insert(&voucher, VouchingStatus::Vouching); Self::put_bid(bids, &who, value, BidKind::Vouch(voucher.clone(), tip)); - Self::deposit_event(PalletEvent::::Vouch { + Self::deposit_event(Event::::Vouch { candidate_id: who, offer: value, vouching: voucher, @@ -887,7 +887,7 @@ pub mod pallet { b[pos].kind.check_voucher(&voucher)?; >::remove(&voucher); let who = b.remove(pos).who; - Self::deposit_event(PalletEvent::::Unvouch { candidate: who }); + Self::deposit_event(Event::::Unvouch { candidate: who }); Ok(()) } else { Err(Error::::BadPosition.into()) @@ -930,7 +930,7 @@ pub mod pallet { let vote = if approve { Vote::Approve } else { Vote::Reject }; >::insert(&candidate, &voter, vote); - Self::deposit_event(PalletEvent::::Vote { candidate, voter, vote: approve }); + Self::deposit_event(Event::::Vote { candidate, voter, vote: approve }); Ok(()) } @@ -959,7 +959,7 @@ pub mod pallet { let vote = if approve { Vote::Approve } else { Vote::Reject }; >::insert(&voter, vote); - Self::deposit_event(PalletEvent::::DefenderVote { voter, vote: approve }); + Self::deposit_event(Event::::DefenderVote { voter, vote: approve }); Ok(()) } @@ -1043,7 +1043,7 @@ pub mod pallet { >::put(&founder); >::put(&founder); Rules::::put(T::Hashing::hash(&rules)); - Self::deposit_event(PalletEvent::::Founded { founder }); + Self::deposit_event(Event::::Founded { founder }); Ok(()) } @@ -1073,7 +1073,7 @@ pub mod pallet { Candidates::::kill(); #[allow(deprecated)] SuspendedCandidates::::remove_all(None); - Self::deposit_event(PalletEvent::::Unfounded { founder }); + Self::deposit_event(Event::::Unfounded { founder }); Ok(()) } @@ -1131,17 +1131,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(PalletEvent::::Unvouch { candidate: vouched }); + Self::deposit_event(Event::::Unvouch { candidate: vouched }); } ); } } >::remove(&who); - Self::deposit_event(PalletEvent::::SuspendedMemberJudgement { - who, - judged: forgive, - }); + Self::deposit_event(Event::::SuspendedMemberJudgement { who, judged: forgive }); Ok(()) } @@ -1263,7 +1260,7 @@ pub mod pallet { ensure_root(origin)?; ensure!(max > 1, Error::::MaxMembers); MaxMembers::::put(max); - Self::deposit_event(PalletEvent::::NewMaxMembers { max }); + Self::deposit_event(Event::::NewMaxMembers { max }); Ok(()) } } @@ -1349,7 +1346,7 @@ impl, I: 'static> Pallet { >::remove(&voucher); }, } - Self::deposit_event(PalletEvent::::AutoUnbid { candidate: popped }); + Self::deposit_event(Event::::AutoUnbid { candidate: popped }); } >::put(bids); @@ -1514,7 +1511,7 @@ impl, I: 'static> Pallet { } else { // Suspend Candidate >::insert(&candidate, (value, kind)); - Self::deposit_event(PalletEvent::::CandidateSuspended { candidate }); + Self::deposit_event(Event::::CandidateSuspended { candidate }); None } }) @@ -1584,10 +1581,7 @@ impl, I: 'static> Pallet { >::put(&primary); T::MembershipChanged::change_members_sorted(&accounts, &[], members); - Self::deposit_event(PalletEvent::::Inducted { - primary, - candidates: accounts, - }); + Self::deposit_event(Event::::Inducted { primary, candidates: accounts }); } // Bump the pot by at most PeriodSpend, but less if there's not very much left in our @@ -1652,7 +1646,7 @@ impl, I: 'static> Pallet { if Self::remove_member(who).is_ok() { >::insert(who, true); >::remove(who); - Self::deposit_event(PalletEvent::::MemberSuspended { member: who.clone() }); + Self::deposit_event(Event::::MemberSuspended { member: who.clone() }); } } @@ -1729,7 +1723,7 @@ impl, I: 'static> Pallet { let chosen = pick_item(&mut rng, &members[1..members.len() - 1]) .expect("exited if members empty; qed"); >::put(&chosen); - Self::deposit_event(PalletEvent::::Challenged { member: chosen.clone() }); + Self::deposit_event(Event::::Challenged { member: chosen.clone() }); } else { >::kill(); } @@ -1833,6 +1827,6 @@ impl, I: 'static> OnUnbalanced> for Palle // Must resolve into existing but better to be safe. let _ = T::Currency::resolve_creating(&Self::account_id(), amount); - Self::deposit_event(PalletEvent::::Deposit { value: numeric_amount }); + Self::deposit_event(Event::::Deposit { value: numeric_amount }); } } diff --git a/frame/staking/src/lib.rs b/frame/staking/src/lib.rs index 2c1a9c0f7645d..38466c8cb1d62 100644 --- a/frame/staking/src/lib.rs +++ b/frame/staking/src/lib.rs @@ -934,9 +934,7 @@ where if bonded_eras.first().filter(|(_, start)| offence_session >= *start).is_some() { R::report_offence(reporters, offence) } else { - >::deposit_event(PalletEvent::::OldSlashingReportDiscarded( - offence_session, - )); + >::deposit_event(Event::::OldSlashingReportDiscarded(offence_session)); Ok(()) } } diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index ebdef4d247e4d..19dc60af882d4 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -868,7 +868,7 @@ macro_rules! assert_session_era { }; } -pub(crate) fn staking_events() -> Vec> { +pub(crate) fn staking_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) @@ -880,7 +880,7 @@ parameter_types! { static StakingEventsIndex: usize = 0; } -pub(crate) fn staking_events_since_last_call() -> Vec> { +pub(crate) fn staking_events_since_last_call() -> Vec> { let all: Vec<_> = System::events() .into_iter() .filter_map(|r| if let RuntimeEvent::Staking(inner) = r.event { Some(inner) } else { None }) diff --git a/frame/staking/src/pallet/impls.rs b/frame/staking/src/pallet/impls.rs index bba7584d7a8a7..68aa97db8a324 100644 --- a/frame/staking/src/pallet/impls.rs +++ b/frame/staking/src/pallet/impls.rs @@ -173,14 +173,14 @@ impl Pallet { let validator_exposure_part = Perbill::from_rational(exposure.own, exposure.total); let validator_staking_payout = validator_exposure_part * validator_leftover_payout; - Self::deposit_event(PalletEvent::::PayoutStarted(era, ledger.stash.clone())); + Self::deposit_event(Event::::PayoutStarted(era, ledger.stash.clone())); let mut total_imbalance = PositiveImbalanceOf::::zero(); // We can now make total validator payout: if let Some(imbalance) = Self::make_payout(&ledger.stash, validator_staking_payout + validator_commission_payout) { - Self::deposit_event(PalletEvent::::Rewarded(ledger.stash, imbalance.peek())); + Self::deposit_event(Event::::Rewarded(ledger.stash, imbalance.peek())); total_imbalance.subsume(imbalance); } @@ -200,7 +200,7 @@ impl Pallet { if let Some(imbalance) = Self::make_payout(&nominator.who, nominator_reward) { // Note: this logic does not count payouts for `RewardDestination::None`. nominator_payout_count += 1; - let e = PalletEvent::::Rewarded(nominator.who.clone(), imbalance.peek()); + let e = Event::::Rewarded(nominator.who.clone(), imbalance.peek()); Self::deposit_event(e); total_imbalance.subsume(imbalance); } @@ -224,7 +224,7 @@ impl Pallet { let chilled_as_validator = Self::do_remove_validator(stash); let chilled_as_nominator = Self::do_remove_nominator(stash); if chilled_as_validator || chilled_as_nominator { - Self::deposit_event(PalletEvent::::Chilled(stash.clone())); + Self::deposit_event(Event::::Chilled(stash.clone())); } } @@ -385,11 +385,7 @@ impl Pallet { let issuance = T::Currency::total_issuance(); let (validator_payout, rest) = T::EraPayout::era_payout(staked, issuance, era_duration); - Self::deposit_event(PalletEvent::::EraPaid( - active_era.index, - validator_payout, - rest, - )); + Self::deposit_event(Event::::EraPaid(active_era.index, validator_payout, rest)); // Set ending era reward. >::insert(&active_era.index, validator_payout); @@ -441,12 +437,12 @@ impl Pallet { let election_result = if is_genesis { T::GenesisElectionProvider::elect().map_err(|e| { log!(warn, "genesis election provider failed due to {:?}", e); - Self::deposit_event(PalletEvent::StakingElectionFailed); + Self::deposit_event(Event::StakingElectionFailed); }) } else { T::ElectionProvider::elect().map_err(|e| { log!(warn, "election provider failed due to {:?}", e); - Self::deposit_event(PalletEvent::StakingElectionFailed); + Self::deposit_event(Event::StakingElectionFailed); }) } .ok()?; @@ -474,11 +470,11 @@ impl Pallet { _ => (), } - Self::deposit_event(PalletEvent::StakingElectionFailed); + Self::deposit_event(Event::StakingElectionFailed); return None } - Self::deposit_event(PalletEvent::StakersElected); + Self::deposit_event(Event::StakersElected); Some(Self::trigger_new_era(start_session_index, exposures)) } diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index 73f859776b6a6..49185e288ad9c 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -129,8 +129,7 @@ pub mod pallet { type RewardRemainder: OnUnbalanced>; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for the unbalanced reduction when slashing a staker. type Slash: OnUnbalanced>; @@ -610,7 +609,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(crate) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// The era payout has been set; the first balance is the validator-payout; the second is /// the remainder from the maximum amount of reward. /// \[era_index, validator_payout, remainder\] @@ -803,7 +802,7 @@ pub mod pallet { let stash_balance = T::Currency::free_balance(&stash); let value = value.min(stash_balance); - Self::deposit_event(PalletEvent::::Bonded(stash.clone(), value)); + Self::deposit_event(Event::::Bonded(stash.clone(), value)); let item = StakingLedger { stash, total: value, @@ -860,7 +859,7 @@ pub mod pallet { debug_assert_eq!(T::VoterList::sanity_check(), Ok(())); } - Self::deposit_event(PalletEvent::::Bonded(stash, extra)); + Self::deposit_event(Event::::Bonded(stash, extra)); } Ok(()) } @@ -943,7 +942,7 @@ pub mod pallet { .defensive(); } - Self::deposit_event(PalletEvent::::Unbonded(ledger.stash, value)); + Self::deposit_event(Event::::Unbonded(ledger.stash, value)); } Ok(()) } @@ -999,7 +998,7 @@ pub mod pallet { if ledger.total < old_total { // Already checked that this won't overflow by entry condition. let value = old_total - ledger.total; - Self::deposit_event(PalletEvent::::Withdrawn(stash, value)); + Self::deposit_event(Event::::Withdrawn(stash, value)); } Ok(post_info_weight.into()) @@ -1037,7 +1036,7 @@ pub mod pallet { Self::do_remove_nominator(stash); Self::do_add_validator(stash, prefs.clone()); - Self::deposit_event(PalletEvent::::ValidatorPrefsSet(ledger.stash, prefs)); + Self::deposit_event(Event::::ValidatorPrefsSet(ledger.stash, prefs)); Ok(()) } @@ -1420,7 +1419,7 @@ pub mod pallet { // Last check: the new active amount of ledger must be more than ED. ensure!(ledger.active >= T::Currency::minimum_balance(), Error::::InsufficientBond); - Self::deposit_event(PalletEvent::::Bonded(ledger.stash.clone(), rebonded_value)); + Self::deposit_event(Event::::Bonded(ledger.stash.clone(), rebonded_value)); // NOTE: ledger must be updated prior to calling `Self::weight_of`. Self::update_ledger(&controller, &ledger); @@ -1537,7 +1536,7 @@ pub mod pallet { if let Some(ref mut nom) = maybe_nom { if let Some(pos) = nom.targets.iter().position(|v| v == stash) { nom.targets.swap_remove(pos); - Self::deposit_event(PalletEvent::::Kicked( + Self::deposit_event(Event::::Kicked( nom_stash.clone(), stash.clone(), )); diff --git a/frame/staking/src/slashing.rs b/frame/staking/src/slashing.rs index d8c3213a3b18b..7372c4390f816 100644 --- a/frame/staking/src/slashing.rs +++ b/frame/staking/src/slashing.rs @@ -626,7 +626,7 @@ pub fn do_slash( >::update_ledger(&controller, &ledger); // trigger the event - >::deposit_event(super::PalletEvent::::Slashed(stash.clone(), value)); + >::deposit_event(super::Event::::Slashed(stash.clone(), value)); } } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 841a549804729..e88d686845698 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for the module. -use super::{ConfigOp, MaxUnlockingChunks, PalletEvent, *}; +use super::{ConfigOp, Event, MaxUnlockingChunks, *}; use frame_election_provider_support::{ElectionProvider, SortedListProvider, Support}; use frame_support::{ assert_noop, assert_ok, assert_storage_noop, bounded_vec, @@ -307,7 +307,7 @@ fn rewards_should_work() { ); assert_eq!( *mock::staking_events().last().unwrap(), - PalletEvent::EraPaid(0, total_payout_0, maximum_payout - total_payout_0) + Event::EraPaid(0, total_payout_0, maximum_payout - total_payout_0) ); mock::make_all_reward_payment(0); @@ -345,7 +345,7 @@ fn rewards_should_work() { ); assert_eq!( *mock::staking_events().last().unwrap(), - PalletEvent::EraPaid(1, total_payout_1, maximum_payout - total_payout_1) + Event::EraPaid(1, total_payout_1, maximum_payout - total_payout_1) ); mock::make_all_reward_payment(1); @@ -517,7 +517,7 @@ fn no_candidate_emergency_condition() { // try trigger new era mock::run_to_block(20); - assert_eq!(*staking_events().last().unwrap(), PalletEvent::StakingElectionFailed); + assert_eq!(*staking_events().last().unwrap(), Event::StakingElectionFailed); // No new era is created assert_eq!(current_era, CurrentEra::::get()); @@ -1610,7 +1610,7 @@ fn rebond_emits_right_value_in_event() { }) ); // Event emitted should be correct - assert_eq!(*staking_events().last().unwrap(), PalletEvent::Bonded(11, 100)); + assert_eq!(*staking_events().last().unwrap(), Event::Bonded(11, 100)); // Re-bond way more than available Staking::rebond(Origin::signed(10), 100_000).unwrap(); @@ -1625,7 +1625,7 @@ fn rebond_emits_right_value_in_event() { }) ); // Event emitted should be correct, only 800 - assert_eq!(*staking_events().last().unwrap(), PalletEvent::Bonded(11, 800)); + assert_eq!(*staking_events().last().unwrap(), Event::Bonded(11, 800)); }); } @@ -2786,10 +2786,10 @@ fn deferred_slashes_are_deferred() { assert_eq!( staking_events_since_last_call(), vec![ - PalletEvent::StakersElected, - PalletEvent::EraPaid(3, 11075, 33225), - PalletEvent::Slashed(11, 100), - PalletEvent::Slashed(101, 12) + Event::StakersElected, + Event::EraPaid(3, 11075, 33225), + Event::Slashed(11, 100), + Event::Slashed(101, 12) ] ); }) @@ -2817,10 +2817,10 @@ fn retroactive_deferred_slashes_two_eras_before() { assert_eq!( staking_events_since_last_call(), vec![ - PalletEvent::StakersElected, - PalletEvent::EraPaid(3, 7100, 21300), - PalletEvent::Slashed(11, 100), - PalletEvent::Slashed(101, 12) + Event::StakersElected, + Event::EraPaid(3, 7100, 21300), + Event::Slashed(11, 100), + Event::Slashed(101, 12) ] ); }) @@ -2851,7 +2851,7 @@ fn retroactive_deferred_slashes_one_before() { mock::start_active_era(4); assert_eq!( staking_events_since_last_call(), - vec![PalletEvent::StakersElected, PalletEvent::EraPaid(3, 11075, 33225)] + vec![Event::StakersElected, Event::EraPaid(3, 11075, 33225)] ); assert_eq!(Staking::ledger(10).unwrap().total, 1000); @@ -2860,10 +2860,10 @@ fn retroactive_deferred_slashes_one_before() { assert_eq!( staking_events_since_last_call(), vec![ - PalletEvent::StakersElected, - PalletEvent::EraPaid(4, 11075, 33225), - PalletEvent::Slashed(11, 100), - PalletEvent::Slashed(101, 12) + Event::StakersElected, + Event::EraPaid(4, 11075, 33225), + Event::Slashed(11, 100), + Event::Slashed(101, 12) ] ); @@ -3004,10 +3004,10 @@ fn remove_deferred() { assert_eq!( staking_events_since_last_call(), vec![ - PalletEvent::StakersElected, - PalletEvent::EraPaid(3, 11075, 33225), - PalletEvent::Slashed(11, 50), - PalletEvent::Slashed(101, 7) + Event::StakersElected, + Event::EraPaid(3, 11075, 33225), + Event::Slashed(11, 50), + Event::Slashed(101, 7) ] ); @@ -4435,7 +4435,7 @@ mod election_data_provider { run_to_block(20); assert_eq!(Staking::next_election_prediction(System::block_number()), 45); assert_eq!(staking_events().len(), 1); - assert_eq!(*staking_events().last().unwrap(), PalletEvent::StakersElected); + assert_eq!(*staking_events().last().unwrap(), Event::StakersElected); for b in 21..45 { run_to_block(b); @@ -4446,7 +4446,7 @@ mod election_data_provider { run_to_block(45); assert_eq!(Staking::next_election_prediction(System::block_number()), 70); assert_eq!(staking_events().len(), 3); - assert_eq!(*staking_events().last().unwrap(), PalletEvent::StakersElected); + assert_eq!(*staking_events().last().unwrap(), Event::StakersElected); Staking::force_no_eras(Origin::root()).unwrap(); assert_eq!(Staking::next_election_prediction(System::block_number()), u64::MAX); @@ -4469,7 +4469,7 @@ mod election_data_provider { run_to_block(55); assert_eq!(Staking::next_election_prediction(System::block_number()), 55 + 25); assert_eq!(staking_events().len(), 6); - assert_eq!(*staking_events().last().unwrap(), PalletEvent::StakersElected); + assert_eq!(*staking_events().last().unwrap(), Event::StakersElected); // The new era has been planned, forcing is changed from `ForceNew` to `NotForcing`. assert_eq!(ForceEra::::get(), Forcing::NotForcing); }) @@ -4803,7 +4803,7 @@ fn min_commission_works() { // event emitted should be correct assert_eq!( *staking_events().last().unwrap(), - PalletEvent::ValidatorPrefsSet( + Event::ValidatorPrefsSet( 11, ValidatorPrefs { commission: Perbill::from_percent(5), blocked: false } ) diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 0bf3a04e4a595..ed6b490215ce1 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -425,7 +425,7 @@ pub mod pallet { /// Inner events of this pallet. #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Given number of `(top, child)` keys were migrated respectively, with the given /// `compute`. Migrated { top: u32, child: u32, compute: MigrationCompute }, @@ -452,8 +452,7 @@ pub mod pallet { type SignedFilter: EnsureOrigin; /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency provider type. type Currency: Currency; @@ -620,12 +619,12 @@ pub mod pallet { if real_size_upper < task.dyn_size { // let the imbalance burn. let (_imbalance, _remainder) = T::Currency::slash(&who, deposit); - Self::deposit_event(PalletEvent::::Slashed { who, amount: deposit }); + Self::deposit_event(Event::::Slashed { who, amount: deposit }); debug_assert!(_remainder.is_zero()); return Ok(().into()) } - Self::deposit_event(PalletEvent::::Migrated { + Self::deposit_event(Event::::Migrated { top: task.dyn_top_items, child: task.dyn_child_items, compute: MigrationCompute::Signed, @@ -679,11 +678,11 @@ pub mod pallet { if dyn_size > witness_size { let (_imbalance, _remainder) = T::Currency::slash(&who, deposit); - Self::deposit_event(PalletEvent::::Slashed { who, amount: deposit }); + Self::deposit_event(Event::::Slashed { who, amount: deposit }); debug_assert!(_remainder.is_zero()); Ok(().into()) } else { - Self::deposit_event(PalletEvent::::Migrated { + Self::deposit_event(Event::::Migrated { top: keys.len() as u32, child: 0, compute: MigrationCompute::Signed, @@ -742,13 +741,13 @@ pub mod pallet { if dyn_size != total_size { let (_imbalance, _remainder) = T::Currency::slash(&who, deposit); debug_assert!(_remainder.is_zero()); - Self::deposit_event(PalletEvent::::Slashed { who, amount: deposit }); + Self::deposit_event(Event::::Slashed { who, amount: deposit }); Ok(PostDispatchInfo { actual_weight: Some(T::WeightInfo::migrate_custom_child_fail()), pays_fee: Pays::Yes, }) } else { - Self::deposit_event(PalletEvent::::Migrated { + Self::deposit_event(Event::::Migrated { top: 0, child: child_keys.len() as u32, compute: MigrationCompute::Signed, @@ -818,10 +817,10 @@ pub mod pallet { ); if task.finished() { - Self::deposit_event(PalletEvent::::AutoMigrationFinished); + Self::deposit_event(Event::::AutoMigrationFinished); AutoLimits::::kill(); } else { - Self::deposit_event(PalletEvent::::Migrated { + Self::deposit_event(Event::::Migrated { top: task.dyn_top_items, child: task.dyn_child_items, compute: MigrationCompute::Auto, @@ -851,7 +850,7 @@ pub mod pallet { fn halt(error: Error) { log!(error, "migration halted due to: {:?}", error); AutoLimits::::kill(); - Self::deposit_event(PalletEvent::::Halted { error }); + Self::deposit_event(Event::::Halted { error }); } /// Convert a child root key, aka. "Child-bearing top key" into the proper format. @@ -964,7 +963,7 @@ mod benchmarks { ); frame_system::Pallet::::assert_last_event( - ::RuntimeEvent::from(crate::PalletEvent::Slashed { + ::RuntimeEvent::from(crate::Event::Slashed { who: caller.clone(), amount: T::SignedDepositBase::get() .saturating_add(T::SignedDepositPerItem::get().saturating_mul(1u32.into())), @@ -1300,7 +1299,7 @@ mod test { ),); // The auto migration halted. System::assert_last_event( - crate::PalletEvent::Halted { error: Error::::KeyTooLong }.into(), + crate::Event::Halted { error: Error::::KeyTooLong }.into(), ); // Limits are killed. assert!(AutoLimits::::get().is_none()); @@ -1335,7 +1334,7 @@ mod test { )); // The auto migration halted. System::assert_last_event( - crate::PalletEvent::Halted { error: Error::::KeyTooLong }.into(), + crate::Event::Halted { error: Error::::KeyTooLong }.into(), ); // Limits are killed. assert!(AutoLimits::::get().is_none()); diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index c0c25cba5728f..36b47a2992448 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -115,8 +115,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A sudo-able call. type Call: Parameter + UnfilteredDispatchable + GetDispatchInfo; @@ -151,9 +150,7 @@ pub mod pallet { ensure!(Self::key().map_or(false, |k| sender == k), Error::::RequireSudo); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - Self::deposit_event(PalletEvent::Sudid { - sudo_result: 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()) } @@ -179,9 +176,7 @@ pub mod pallet { ensure!(Self::key().map_or(false, |k| sender == k), Error::::RequireSudo); let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Root.into()); - Self::deposit_event(PalletEvent::Sudid { - sudo_result: 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()) } @@ -206,7 +201,7 @@ pub mod pallet { ensure!(Self::key().map_or(false, |k| sender == k), Error::::RequireSudo); let new = T::Lookup::lookup(new)?; - Self::deposit_event(PalletEvent::KeyChanged { old_sudoer: Key::::get() }); + Self::deposit_event(Event::KeyChanged { old_sudoer: Key::::get() }); Key::::put(&new); // Sudo user does not pay a fee. Ok(Pays::No.into()) @@ -246,7 +241,7 @@ pub mod pallet { let res = call.dispatch_bypass_filter(frame_system::RawOrigin::Signed(who).into()); - Self::deposit_event(PalletEvent::SudoAsDone { + Self::deposit_event(Event::SudoAsDone { sudo_result: res.map(|_| ()).map_err(|e| e.error), }); // Sudo user does not pay a fee. @@ -256,7 +251,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A sudo just took place. \[result\] Sudid { sudo_result: DispatchResult }, /// The \[sudoer\] just switched identity; the old key is supplied if one existed. diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 026533aedf8d3..30ef728d66093 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -39,8 +39,7 @@ pub mod logger { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -58,7 +57,7 @@ pub mod logger { // Ensure that the `origin` is `Root`. ensure_root(origin)?; >::try_append(i).map_err(|_| "could not append")?; - Self::deposit_event(PalletEvent::AppendI32 { value: i, weight }); + Self::deposit_event(Event::AppendI32 { value: i, weight }); Ok(().into()) } @@ -72,14 +71,14 @@ pub mod logger { let sender = ensure_signed(origin)?; >::try_append(i).map_err(|_| "could not append")?; >::try_append(sender.clone()).map_err(|_| "could not append")?; - Self::deposit_event(PalletEvent::AppendI32AndAccount { sender, value: i, weight }); + Self::deposit_event(Event::AppendI32AndAccount { sender, value: i, weight }); Ok(().into()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { AppendI32 { value: i32, weight: Weight }, AppendI32AndAccount { sender: T::AccountId, value: i32, weight: Weight }, } diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index ba6b32b670c3a..8175f2ad810b2 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(PalletEvent::Sudid { sudo_result: 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(PalletEvent::Sudid { sudo_result: 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(PalletEvent::KeyChanged { old_sudoer: Some(1) })); + System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { old_sudoer: Some(1) })); // Double check. assert_ok!(Sudo::set_key(Origin::signed(2), 4)); - System::assert_has_event(TestEvent::Sudo(PalletEvent::KeyChanged { old_sudoer: Some(2) })); + System::assert_has_event(TestEvent::Sudo(Event::KeyChanged { old_sudoer: Some(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(PalletEvent::SudoAsDone { sudo_result: Ok(()) })); + System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone { sudo_result: Ok(()) })); }); } diff --git a/frame/support/procedural/src/construct_runtime/expand/event.rs b/frame/support/procedural/src/construct_runtime/expand/event.rs index 7a706d7ab9587..5ab155fe7bf73 100644 --- a/frame/support/procedural/src/construct_runtime/expand/event.rs +++ b/frame/support/procedural/src/construct_runtime/expand/event.rs @@ -48,10 +48,10 @@ pub fn expand_outer_event( let part_is_generic = !generics.params.is_empty(); let pallet_event = match (instance, part_is_generic) { - (Some(inst), true) => quote!(#path::PalletEvent::<#runtime, #path::#inst>), - (Some(inst), false) => quote!(#path::PalletEvent::<#path::#inst>), - (None, true) => quote!(#path::PalletEvent::<#runtime>), - (None, false) => quote!(#path::PalletEvent), + (Some(inst), true) => quote!(#path::Event::<#runtime, #path::#inst>), + (Some(inst), false) => quote!(#path::Event::<#path::#inst>), + (None, true) => quote!(#path::Event::<#runtime>), + (None, false) => quote!(#path::Event), }; event_variants.extend(expand_event_variant( @@ -100,16 +100,16 @@ fn expand_event_variant( match instance { Some(inst) if part_is_generic => { - quote!(#[codec(index = #index)] #variant_name(#path::PalletEvent<#runtime, #path::#inst>),) + quote!(#[codec(index = #index)] #variant_name(#path::Event<#runtime, #path::#inst>),) }, Some(inst) => { - quote!(#[codec(index = #index)] #variant_name(#path::PalletEvent<#path::#inst>),) + quote!(#[codec(index = #index)] #variant_name(#path::Event<#path::#inst>),) }, None if part_is_generic => { - quote!(#[codec(index = #index)] #variant_name(#path::PalletEvent<#runtime>),) + quote!(#[codec(index = #index)] #variant_name(#path::Event<#runtime>),) }, None => { - quote!(#[codec(index = #index)] #variant_name(#path::PalletEvent),) + quote!(#[codec(index = #index)] #variant_name(#path::Event),) }, } } diff --git a/frame/support/procedural/src/construct_runtime/expand/metadata.rs b/frame/support/procedural/src/construct_runtime/expand/metadata.rs index c0d54b5041e6f..6e2dd5fc002c6 100644 --- a/frame/support/procedural/src/construct_runtime/expand/metadata.rs +++ b/frame/support/procedural/src/construct_runtime/expand/metadata.rs @@ -139,10 +139,10 @@ fn expand_pallet_metadata_events( .params .is_empty(); let pallet_event = match (decl.instance.as_ref(), part_is_generic) { - (Some(inst), true) => quote!(#path::PalletEvent::<#runtime, #path::#inst>), - (Some(inst), false) => quote!(#path::PalletEvent::<#path::#inst>), - (None, true) => quote!(#path::PalletEvent::<#runtime>), - (None, false) => quote!(#path::PalletEvent), + (Some(inst), true) => quote!(#path::Event::<#runtime, #path::#inst>), + (Some(inst), false) => quote!(#path::Event::<#path::#inst>), + (None, true) => quote!(#path::Event::<#runtime>), + (None, false) => quote!(#path::Event), }; quote! { diff --git a/frame/support/procedural/src/construct_runtime/parse.rs b/frame/support/procedural/src/construct_runtime/parse.rs index 4e461850cfef7..711da85c10cfc 100644 --- a/frame/support/procedural/src/construct_runtime/parse.rs +++ b/frame/support/procedural/src/construct_runtime/parse.rs @@ -338,7 +338,7 @@ impl quote::ToTokens for PalletPath { /// Parse [`PalletPart`]'s from a braces enclosed list that is split by commas, e.g. /// -/// `{ Call, PalletEvent }` +/// `{ Call, Event }` fn parse_pallet_parts(input: ParseStream) -> Result> { let pallet_parts: ext::Braces> = input.parse()?; @@ -503,7 +503,7 @@ impl Parse for PalletPartNoGeneric { /// Parse [`PalletPartNoGeneric`]'s from a braces enclosed list that is split by commas, e.g. /// -/// `{ Call, PalletEvent }` +/// `{ Call, Event }` fn parse_pallet_parts_no_generic(input: ParseStream) -> Result> { let pallet_parts: ext::Braces> = input.parse()?; diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 213e7fa611d0a..00204b7a4d906 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -312,7 +312,7 @@ pub fn decl_storage(input: TokenStream) -> TokenStream { /// Test: path::to::test::{Pallet, Call} = 1, /// /// // Pallets with instances -/// Test2_Instance1: test2::::{Pallet, Call, Storage, PalletEvent, Config, Origin}, +/// Test2_Instance1: test2::::{Pallet, Call, Storage, Event, Config, Origin}, /// Test2_DefaultInstance: test2::{Pallet, Call, Storage, Event, Config, Origin} = 4, /// /// // Pallets declared with `pallet` attribute macro: no need to define the parts diff --git a/frame/support/procedural/src/pallet/expand/event.rs b/frame/support/procedural/src/pallet/expand/event.rs index 0b46372cf4232..1263cdc03a988 100644 --- a/frame/support/procedural/src/pallet/expand/event.rs +++ b/frame/support/procedural/src/pallet/expand/event.rs @@ -61,7 +61,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { let event_where_clause = &event.where_clause; // NOTE: actually event where clause must be a subset of config where clause because of - // `type Event: From>`. But we merge either way for potential better error + // `type Event: From>`. But we merge either way for potential better error // message let completed_where_clause = super::merge_where_clauses(&[&event.where_clause, &def.config.where_clause]); @@ -135,10 +135,10 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { quote::quote_spanned!(*fn_span => impl<#type_impl_gen> Pallet<#type_use_gen> #completed_where_clause { - #fn_vis fn deposit_event(event: PalletEvent<#event_use_gen>) { + #fn_vis fn deposit_event(event: Event<#event_use_gen>) { let event = < ::RuntimeEvent as - From> + From> >::from(event); let event = < diff --git a/frame/support/procedural/src/pallet/parse/config.rs b/frame/support/procedural/src/pallet/parse/config.rs index b14809fcdc53f..8d6a5eaa48b58 100644 --- a/frame/support/procedural/src/pallet/parse/config.rs +++ b/frame/support/procedural/src/pallet/parse/config.rs @@ -29,7 +29,7 @@ mod keyword { syn::custom_keyword!(config); syn::custom_keyword!(IsType); syn::custom_keyword!(RuntimeEvent); - syn::custom_keyword!(PalletEvent); + syn::custom_keyword!(Event); syn::custom_keyword!(constant); syn::custom_keyword!(frame_system); syn::custom_keyword!(disable_frame_system_supertrait_check); @@ -43,10 +43,10 @@ pub struct ConfigDef { pub has_instance: bool, /// Const associated type. pub consts_metadata: Vec, - /// Whether the trait has the associated type `PalletEvent`, note that those bounds are + /// Whether the trait has the associated type `Event`, note that those bounds are /// checked: /// * `IsType::RuntimeEvent` - /// * `From` or `From>` or `From>` + /// * `From` or `From>` or `From>` pub has_event_type: bool, /// The where clause on trait definition but modified so `Self` is `T`. pub where_clause: Option, @@ -183,7 +183,7 @@ impl syn::parse::Parse for IsTypeBoundEventParse { } } -/// Parse for `From` or `From>` or `From>` +/// Parse for `From` or `From>` or `From>` pub struct FromEventParse { is_generic: bool, has_instance: bool, @@ -196,7 +196,7 @@ impl syn::parse::Parse for FromEventParse { input.parse::()?; input.parse::()?; - input.parse::()?; + input.parse::()?; if input.peek(syn::Token![<]) { is_generic = true; input.parse::()?; @@ -214,8 +214,8 @@ impl syn::parse::Parse for FromEventParse { } } -/// Check if trait_item is `type PalletEvent`, if so checks its bounds are those expected. -/// (PalletEvent type is reserved type) +/// Check if trait_item is `type Event`, if so checks its bounds are those expected. +/// (Event type is reserved type) fn check_event_type( frame_system: &syn::Ident, trait_item: &syn::TraitItem, @@ -254,14 +254,14 @@ fn check_event_type( b } else { let msg = "Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must \ - bound: `From` or `From>` or `From>`"; + bound: `From` or `From>` or `From>`"; return Err(syn::Error::new(type_.span(), msg)) }; if from_event_bound.is_generic && (from_event_bound.has_instance != trait_has_instance) { - let msg = "Invalid `type PalletEvent`, associated type `PalletEvent` bounds inconsistent \ - `From`. Config and generic PalletEvent must be both with instance or \ + let msg = "Invalid `type Event`, associated type `Event` bounds inconsistent \ + `From`. Config and generic Event must be both with instance or \ without instance"; return Err(syn::Error::new(type_.span(), msg)) } diff --git a/frame/support/procedural/src/pallet/parse/event.rs b/frame/support/procedural/src/pallet/parse/event.rs index 11559353c327b..e046cacac88e8 100644 --- a/frame/support/procedural/src/pallet/parse/event.rs +++ b/frame/support/procedural/src/pallet/parse/event.rs @@ -21,7 +21,7 @@ use syn::spanned::Spanned; /// List of additional token to be used for parsing. mod keyword { - syn::custom_keyword!(PalletEvent); + syn::custom_keyword!(Event); syn::custom_keyword!(pallet); syn::custom_keyword!(generate_deposit); syn::custom_keyword!(deposit_event); @@ -31,11 +31,11 @@ mod keyword { pub struct EventDef { /// The index of event item in pallet module. pub index: usize, - /// The keyword PalletEvent used (contains span). - pub event: keyword::PalletEvent, + /// The keyword Event used (contains span). + pub event: keyword::Event, /// A set of usage of instance, must be check for consistency with trait. pub instances: Vec, - /// The kind of generic the type `PalletEvent` has. + /// The kind of generic the type `Event` has. pub gen_kind: super::GenericKind, /// Whether the function `deposit_event` must be generated. pub deposit_event: Option, @@ -45,7 +45,7 @@ pub struct EventDef { pub attr_span: proc_macro2::Span, } -/// Attribute for a pallet's PalletEvent. +/// Attribute for a pallet's Event. /// /// Syntax is: /// * `#[pallet::generate_deposit($vis fn deposit_event)]` @@ -113,14 +113,14 @@ impl EventDef { let deposit_event = attr_info.deposit_event; if !matches!(item.vis, syn::Visibility::Public(_)) { - let msg = "Invalid pallet::event, `PalletEvent` must be public"; + let msg = "Invalid pallet::event, `Event` must be public"; return Err(syn::Error::new(item.span(), msg)) } let where_clause = item.generics.where_clause.clone(); let mut instances = vec![]; - // NOTE: PalletEvent is not allowed to be only generic on I because it is not supported + // NOTE: Event is not allowed to be only generic on I because it is not supported // by construct_runtime. if let Some(u) = helper::check_type_def_optional_gen(&item.generics, item.ident.span())? { instances.push(u); @@ -134,7 +134,7 @@ impl EventDef { let gen_kind = super::GenericKind::from_gens(has_config, has_instance) .expect("Checked by `helper::check_type_def_optional_gen` above"); - let event = syn::parse2::(item.ident.to_token_stream())?; + let event = syn::parse2::(item.ident.to_token_stream())?; Ok(EventDef { attr_span, index, instances, deposit_event, event, gen_kind, where_clause }) } diff --git a/frame/support/src/event.rs b/frame/support/src/event.rs index 99073edbb10e5..dc45f2bf69d94 100644 --- a/frame/support/src/event.rs +++ b/frame/support/src/event.rs @@ -27,7 +27,7 @@ /// /// ```rust /// frame_support::decl_event!( -/// pub enum PalletEvent { +/// pub enum Event { /// Success, /// Failure(String), /// } @@ -36,7 +36,7 @@ /// # fn main() {} /// ``` /// -/// # Generic PalletEvent Example: +/// # Generic Event Example: /// /// ```rust /// trait Config { @@ -47,7 +47,7 @@ /// mod event1 { /// // Event that specifies the generic parameter explicitly (`Balance`). /// frame_support::decl_event!( -/// pub enum PalletEvent where Balance = ::Balance { +/// pub enum Event where Balance = ::Balance { /// Message(Balance), /// } /// ); @@ -58,7 +58,7 @@ /// // If no name for the generic parameter is specified explicitly, /// // the name will be taken from the type name of the trait. /// frame_support::decl_event!( -/// pub enum PalletEvent where ::Balance { +/// pub enum Event where ::Balance { /// Message(Balance), /// } /// ); @@ -67,7 +67,7 @@ /// mod event3 { /// // And we even support declaring multiple generic parameters! /// frame_support::decl_event!( -/// pub enum PalletEvent where ::Balance, ::Token { +/// pub enum Event where ::Balance, ::Token { /// Message(Balance, Token), /// } /// ); @@ -91,7 +91,7 @@ /// /// // For module with instances, DefaultInstance is optional /// frame_support::decl_event!( -/// pub enum PalletEvent where +/// pub enum Event where /// ::Balance, /// ::Token /// { @@ -104,7 +104,7 @@ macro_rules! decl_event { ( $(#[$attr:meta])* - pub enum PalletEvent<$evt_generic_param:ident $(, $instance:ident $(: $instantiable:ident)? $( = $event_default_instance:path)? )?> where + pub enum Event<$evt_generic_param:ident $(, $instance:ident $(: $instantiable:ident)? $( = $event_default_instance:path)? )?> where $( $tt:tt )* ) => { $crate::__decl_generic_event!( @@ -116,7 +116,7 @@ macro_rules! decl_event { }; ( $(#[$attr:meta])* - pub enum PalletEvent { + pub enum Event { $( $events:tt )* @@ -134,13 +134,13 @@ macro_rules! decl_event { /// Events for this module. /// $(#[$attr])* - pub enum PalletEvent { + pub enum Event { $( $events )* } - impl From for () { - fn from(_: PalletEvent) -> () { () } + impl From for () { + fn from(_: Event) -> () { () } } } } @@ -259,7 +259,7 @@ macro_rules! __decl_generic_event { /// /// [`RawEvent`]: enum.RawEvent.html /// [`Config`]: trait.Config.html - pub type PalletEvent<$event_generic_param $(, $instance $( = $event_default_instance)? )?> = RawEvent<$( $generic_type ),* $(, $instance)? >; + pub type Event<$event_generic_param $(, $instance $( = $event_default_instance)? )?> = RawEvent<$( $generic_type ),* $(, $instance)? >; #[derive( Clone, PartialEq, Eq, diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 48f277749956c..024f3225c3ca3 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -1430,7 +1430,7 @@ pub mod pallet_prelude { /// optionally other supertrait and where clause. /// /// The associated type `RuntimeEvent` is reserved, if defined it must bounds -/// `From` and `IsType<::RuntimeEvent>`, see +/// `From` and `IsType<::RuntimeEvent>`, see /// `#[pallet::event]` for more information. /// /// To put `Get` associated type into metadatas, use the attribute `#[pallet::constant]`, e.g.: @@ -1709,7 +1709,7 @@ pub mod pallet_prelude { /// ```ignore /// #[pallet::event] /// #[pallet::generate_deposit($visibility fn deposit_event)] // Optional -/// pub enum PalletEvent<$some_generic> $optional_where_clause { +/// pub enum Event<$some_generic> $optional_where_clause { /// /// Some doc /// $SomeName($SomeType, $YetanotherType, ...), /// ... @@ -1737,7 +1737,7 @@ pub mod pallet_prelude { /// * `#[derive(codec::Decode)]`, /// * `#[derive(frame_support::RuntimeDebugNoBound)]` /// -/// Macro implements `From>` for (). +/// Macro implements `From>` for (). /// /// Macro implements metadata function on `Event` returning the `EventMetadata`. /// @@ -2038,7 +2038,7 @@ pub mod pallet_prelude { /// #[pallet::constant] // put the constant in metadata /// type MyGetParam: Get; /// type Balance: Parameter + MaxEncodedLen + From; -/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; +/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// } /// /// // Define some additional constant to put into the constant metadata. @@ -2100,7 +2100,7 @@ pub mod pallet_prelude { /// #[pallet::event] /// // Generate a funciton on Pallet to deposit an event. /// #[pallet::generate_deposit(pub(super) fn deposit_event)] -/// pub enum PalletEvent { +/// pub enum Event { /// /// doc comment put in metadata /// // `::AccountId` is not defined in metadata list, the last /// // Thus the metadata is `::AccountId`. @@ -2227,7 +2227,7 @@ pub mod pallet_prelude { /// #[pallet::constant] /// type MyGetParam: Get; /// type Balance: Parameter + MaxEncodedLen + From; -/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; +/// type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// } /// /// #[pallet::extra_constants] @@ -2262,7 +2262,7 @@ pub mod pallet_prelude { /// /// #[pallet::event] /// #[pallet::generate_deposit(pub(super) fn deposit_event)] -/// pub enum PalletEvent, I: 'static = ()> { +/// pub enum Event, I: 'static = ()> { /// /// doc comment put in metadata /// Proposed(::AccountId), /// /// doc diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index aa9962c7af05e..623bf80b7e536 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -62,7 +62,7 @@ mod module1 { pub struct Origin(pub core::marker::PhantomData<(T, I)>); frame_support::decl_event! { - pub enum PalletEvent where + pub enum Event where ::AccountId { A(AccountId), @@ -106,7 +106,7 @@ mod module2 { pub struct Origin; frame_support::decl_event! { - pub enum PalletEvent { + pub enum Event { A, } } @@ -151,7 +151,7 @@ mod nested { pub struct Origin; frame_support::decl_event! { - pub enum PalletEvent { + pub enum Event { A, } } @@ -209,7 +209,7 @@ pub mod module3 { pub struct Origin(pub core::marker::PhantomData); frame_support::decl_event! { - pub enum PalletEvent { + pub enum Event { A, } } @@ -419,37 +419,37 @@ fn origin_codec() { fn event_codec() { use codec::Encode; - let event = system::PalletEvent::::ExtrinsicSuccess; + let event = system::Event::::ExtrinsicSuccess; assert_eq!(RuntimeEvent::from(event).encode()[0], 30); - let event = module1::PalletEvent::::A(test_pub()); + let event = module1::Event::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 31); - let event = module2::PalletEvent::A; + let event = module2::Event::A; assert_eq!(RuntimeEvent::from(event).encode()[0], 32); - let event = module1::PalletEvent::::A(test_pub()); + let event = module1::Event::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 33); - let event = nested::module3::PalletEvent::A; + let event = nested::module3::Event::A; assert_eq!(RuntimeEvent::from(event).encode()[0], 34); - let event = module3::PalletEvent::A; + let event = module3::Event::A; assert_eq!(RuntimeEvent::from(event).encode()[0], 35); - let event = module1::PalletEvent::::A(test_pub()); + let event = module1::Event::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 4); - let event = module1::PalletEvent::::A(test_pub()); + let event = module1::Event::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 1); - let event = module1::PalletEvent::::A(test_pub()); + let event = module1::Event::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 2); - let event = module1::PalletEvent::::A(test_pub()); + let event = module1::Event::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 12); - let event = module1::PalletEvent::::A(test_pub()); + let event = module1::Event::::A(test_pub()); assert_eq!(RuntimeEvent::from(event).encode()[0], 13); } @@ -585,7 +585,7 @@ fn test_metadata() { name: "System", storage: None, calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 30, @@ -594,7 +594,7 @@ fn test_metadata() { name: "Module1_1", storage: Some(PalletStorageMetadata { prefix: "Instance1Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 31, @@ -603,7 +603,7 @@ fn test_metadata() { name: "Module2", storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::().into()), constants: vec![], error: None, index: 32, @@ -612,7 +612,7 @@ fn test_metadata() { name: "Module1_2", storage: Some(PalletStorageMetadata { prefix: "Instance2Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 33, @@ -621,7 +621,7 @@ fn test_metadata() { name: "NestedModule3", storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::().into()), constants: vec![], error: None, index: 34, @@ -630,7 +630,7 @@ fn test_metadata() { name: "Module3", storage: Some(PalletStorageMetadata { prefix: "Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::().into()), + event: Some(meta_type::().into()), constants: vec![], error: None, index: 35, @@ -657,7 +657,7 @@ fn test_metadata() { name: "Module1_5", storage: None, calls: None, - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 4, @@ -666,7 +666,7 @@ fn test_metadata() { name: "Module1_6", storage: Some(PalletStorageMetadata { prefix: "Instance6Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 1, @@ -676,7 +676,7 @@ fn test_metadata() { storage: Some(PalletStorageMetadata { prefix: "Instance7Module", entries: vec![] }), calls: Some(meta_type::>().into()), event: Some(PalletEventMetadata { - ty: meta_type::>(), + ty: meta_type::>(), }), constants: vec![], error: None, @@ -686,7 +686,7 @@ fn test_metadata() { name: "Module1_8", storage: Some(PalletStorageMetadata { prefix: "Instance8Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 12, @@ -695,7 +695,7 @@ fn test_metadata() { name: "Module1_9", storage: Some(PalletStorageMetadata { prefix: "Instance9Module", entries: vec![] }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![], error: None, index: 13, diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr index fc9691d32bba4..920e627d43c31 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.stderr @@ -15,7 +15,7 @@ error: `Pallet` does not have #[pallet::event] defined, perhaps you should remov | = note: this error originates in the macro `pallet::__substrate_event_check::is_event_part_defined` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0412]: cannot find type `PalletEvent` in module `pallet` +error[E0412]: cannot find type `Event` in module `pallet` --> tests/construct_runtime_ui/undefined_event_part.rs:49:1 | 49 | / construct_runtime! { @@ -30,9 +30,9 @@ error[E0412]: cannot find type `PalletEvent` in module `pallet` = note: this error originates in the macro `construct_runtime` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this enum | -1 | use frame_system::PalletEvent; +1 | use frame_system::Event; | -help: if you import `PalletEvent`, refer to it directly +help: if you import `Event`, refer to it directly | 49 - construct_runtime! { 50 - pub enum Runtime where diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 268f7690174ca..dcb18869c911e 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -41,7 +41,7 @@ pub trait Currency {} // Test for: // * No default instance -// * Origin, Inherent, PalletEvent +// * Origin, Inherent, Event mod module1 { use super::*; use sp_std::ops::Add; @@ -50,7 +50,7 @@ mod module1 { where ::BlockNumber: From, { - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; type Origin: From>; type SomeParameter: Get; type GenericType: Default + Clone + Codec + EncodeLike + TypeInfo; @@ -102,7 +102,7 @@ mod module1 { } frame_support::decl_event! { - pub enum PalletEvent where Phantom = std::marker::PhantomData { + pub enum Event where Phantom = std::marker::PhantomData { _Phantom(Phantom), AnotherVariant(u32), } @@ -154,7 +154,7 @@ mod module2 { pub trait Config: system::Config { type Amount: Parameter + Default; - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; type Origin: From>; } @@ -178,7 +178,7 @@ mod module2 { } frame_support::decl_event! { - pub enum PalletEvent where Amount = >::Amount { + pub enum Event where Amount = >::Amount { Variant(Amount), } } diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 505a01f3a98c1..bd2da6b9911fa 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -53,7 +53,7 @@ mod nested { pub struct Origin; frame_support::decl_event! { - pub enum PalletEvent { + pub enum Event { A, } } @@ -111,7 +111,7 @@ pub mod module { pub struct Origin(pub core::marker::PhantomData); frame_support::decl_event! { - pub enum PalletEvent { + pub enum Event { A, } } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 017aa5750d0a8..6c0136473c379 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -125,8 +125,7 @@ pub mod pallet { type Balance: Parameter + Default + TypeInfo; - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::extra_constants] @@ -165,18 +164,18 @@ pub mod pallet { fn on_initialize(_: BlockNumberFor) -> Weight { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType2); // Test for where clause - Self::deposit_event(PalletEvent::Something(10)); + Self::deposit_event(Event::Something(10)); 10 } fn on_finalize(_: BlockNumberFor) { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType2); // Test for where clause - Self::deposit_event(PalletEvent::Something(20)); + Self::deposit_event(Event::Something(20)); } fn on_runtime_upgrade() -> Weight { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType2); // Test for where clause - Self::deposit_event(PalletEvent::Something(30)); + Self::deposit_event(Event::Something(30)); 30 } fn integrity_test() { @@ -200,7 +199,7 @@ pub mod pallet { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType3); // Test for where clause let _ = origin; - Self::deposit_event(PalletEvent::Something(3)); + Self::deposit_event(Event::Something(3)); Ok(().into()) } @@ -210,7 +209,7 @@ pub mod pallet { _origin: OriginFor, #[pallet::compact] foo: u32, ) -> DispatchResultWithPostInfo { - Self::deposit_event(PalletEvent::Something(0)); + Self::deposit_event(Event::Something(0)); if foo == 0 { Err(Error::::InsufficientProposersBalance)?; } @@ -238,7 +237,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum PalletEvent + pub enum Event where T::AccountId: SomeAssociation1 + From, { @@ -453,7 +452,7 @@ pub mod pallet2 { where ::AccountId: From + SomeAssociation1, { - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -467,14 +466,14 @@ pub mod pallet2 { T::AccountId: From + SomeAssociation1, { fn on_initialize(_: BlockNumberFor) -> Weight { - Self::deposit_event(PalletEvent::Something(11)); + Self::deposit_event(Event::Something(11)); 0 } fn on_finalize(_: BlockNumberFor) { - Self::deposit_event(PalletEvent::Something(21)); + Self::deposit_event(Event::Something(21)); } fn on_runtime_upgrade() -> Weight { - Self::deposit_event(PalletEvent::Something(31)); + Self::deposit_event(Event::Something(31)); 0 } } @@ -491,7 +490,7 @@ pub mod pallet2 { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Something Something(u32), } @@ -632,7 +631,7 @@ fn transactional_works() { .iter() .map(|e| &e.event) .collect::>(), - vec![&RuntimeEvent::Example(pallet::PalletEvent::Something(0))], + vec![&RuntimeEvent::Example(pallet::Event::Something(0))], ); }) } @@ -888,7 +887,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(3)), + RuntimeEvent::Example(pallet::Event::Something(3)), ); }) } @@ -995,27 +994,27 @@ fn pallet_hooks_expand() { assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(10)), + RuntimeEvent::Example(pallet::Event::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - RuntimeEvent::Example2(pallet2::PalletEvent::Something(11)), + RuntimeEvent::Example2(pallet2::Event::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(20)), + RuntimeEvent::Example(pallet::Event::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - RuntimeEvent::Example2(pallet2::PalletEvent::Something(21)), + RuntimeEvent::Example2(pallet2::Event::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(30)), + RuntimeEvent::Example(pallet::Event::Something(30)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - RuntimeEvent::Example2(pallet2::PalletEvent::Something(31)), + RuntimeEvent::Example2(pallet2::Event::Something(31)), ); }) } @@ -1035,27 +1034,27 @@ fn all_pallets_type_reversed_order_is_correct() { assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example2(pallet2::PalletEvent::Something(11)), + RuntimeEvent::Example2(pallet2::Event::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(10)), + RuntimeEvent::Example(pallet::Event::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - RuntimeEvent::Example2(pallet2::PalletEvent::Something(21)), + RuntimeEvent::Example2(pallet2::Event::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(20)), + RuntimeEvent::Example(pallet::Event::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - RuntimeEvent::Example2(pallet2::PalletEvent::Something(31)), + RuntimeEvent::Example2(pallet2::Event::Something(31)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(30)), + RuntimeEvent::Example(pallet::Event::Something(30)), ); }) } @@ -1303,7 +1302,7 @@ fn metadata() { ], }), calls: Some(meta_type::>().into()), - event: Some(meta_type::>().into()), + event: Some(meta_type::>().into()), constants: vec![ PalletConstantMetadata { name: "MyGetParam", @@ -1378,7 +1377,7 @@ fn metadata() { ], }), calls: None, - event: Some(PalletEventMetadata { ty: meta_type::() }), + event: Some(PalletEventMetadata { ty: meta_type::() }), constants: vec![], error: None, }, diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index a4940607b7ea0..bcc4689668999 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -43,8 +43,7 @@ mod pallet_old { + Into + Default + SomeAssociation; - type RuntimeEvent: From> - + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } decl_storage! { @@ -61,7 +60,7 @@ mod pallet_old { } decl_event!( - pub enum PalletEvent + pub enum Event where Balance = ::Balance, { @@ -121,8 +120,7 @@ pub mod pallet { + scale_info::StaticTypeInfo; #[pallet::constant] type SomeConst: Get; - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::pallet] @@ -151,7 +149,7 @@ pub mod pallet { ensure_root(origin)?; >::put(&new_value); - Self::deposit_event(PalletEvent::Dummy(new_value)); + Self::deposit_event(Event::Dummy(new_value)); Ok(().into()) } @@ -165,7 +163,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Dummy event, just here so there's a generic type that's used. Dummy(T::Balance), } @@ -354,11 +352,11 @@ mod test { #[test] fn types() { assert_eq!( - pallet_old::PalletEvent::::decode( - &mut &pallet::PalletEvent::::Dummy(10).encode()[..] + pallet_old::Event::::decode( + &mut &pallet::Event::::Dummy(10).encode()[..] ) .unwrap(), - pallet_old::PalletEvent::::Dummy(10), + pallet_old::Event::::Dummy(10), ); assert_eq!( diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 1bd9ee1adae79..89ed9ad8fbe4d 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -30,8 +30,7 @@ mod pallet_old { pub trait Config: frame_system::Config { type SomeConst: Get; type Balance: Parameter + codec::HasCompact + From + Into + Default; - type RuntimeEvent: From> - + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } decl_storage! { @@ -46,7 +45,7 @@ mod pallet_old { } decl_event!( - pub enum PalletEvent + pub enum Event where Balance = >::Balance, { @@ -106,7 +105,7 @@ pub mod pallet { + scale_info::StaticTypeInfo; #[pallet::constant] type SomeConst: Get; - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -136,7 +135,7 @@ pub mod pallet { ensure_root(origin)?; >::put(&new_value); - Self::deposit_event(PalletEvent::Dummy(new_value)); + Self::deposit_event(Event::Dummy(new_value)); Ok(().into()) } @@ -150,7 +149,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// Dummy event, just here so there's a generic type that's used. Dummy(T::Balance), } @@ -353,11 +352,11 @@ mod test { #[test] fn types() { assert_eq!( - pallet_old::PalletEvent::::decode( - &mut &pallet::PalletEvent::::Dummy(10).encode()[..] + pallet_old::Event::::decode( + &mut &pallet::Event::::Dummy(10).encode()[..] ) .unwrap(), - pallet_old::PalletEvent::::Dummy(10), + pallet_old::Event::::Dummy(10), ); assert_eq!( diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 3061375e217cd..3dadc80e6787a 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -42,7 +42,7 @@ pub mod pallet { #[pallet::constant] type MyGetParam: Get; type Balance: Parameter + Default + scale_info::StaticTypeInfo; - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -54,26 +54,26 @@ pub mod pallet { impl, I: 'static> Hooks> for Pallet { fn on_initialize(_: BlockNumberFor) -> Weight { if TypeId::of::() == TypeId::of::<()>() { - Self::deposit_event(PalletEvent::Something(10)); + Self::deposit_event(Event::Something(10)); 10 } else { - Self::deposit_event(PalletEvent::Something(11)); + Self::deposit_event(Event::Something(11)); 11 } } fn on_finalize(_: BlockNumberFor) { if TypeId::of::() == TypeId::of::<()>() { - Self::deposit_event(PalletEvent::Something(20)); + Self::deposit_event(Event::Something(20)); } else { - Self::deposit_event(PalletEvent::Something(21)); + Self::deposit_event(Event::Something(21)); } } fn on_runtime_upgrade() -> Weight { if TypeId::of::() == TypeId::of::<()>() { - Self::deposit_event(PalletEvent::Something(30)); + Self::deposit_event(Event::Something(30)); 30 } else { - Self::deposit_event(PalletEvent::Something(31)); + Self::deposit_event(Event::Something(31)); 31 } } @@ -89,7 +89,7 @@ pub mod pallet { #[pallet::compact] _foo: u32, ) -> DispatchResultWithPostInfo { let _ = origin; - Self::deposit_event(PalletEvent::Something(3)); + Self::deposit_event(Event::Something(3)); Ok(().into()) } @@ -112,7 +112,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// doc comment put in metadata Proposed(::AccountId), /// doc @@ -218,7 +218,7 @@ pub mod pallet2 { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -227,7 +227,7 @@ pub mod pallet2 { pub struct Pallet(PhantomData<(T, I)>); #[pallet::event] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// Something Something(u32), } @@ -389,7 +389,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(3)), + RuntimeEvent::Example(pallet::Event::Something(3)), ); }); @@ -400,7 +400,7 @@ fn pallet_expand_deposit_event() { .unwrap(); assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Instance1Example(pallet::PalletEvent::Something(3)), + RuntimeEvent::Instance1Example(pallet::Event::Something(3)), ); }); } @@ -566,27 +566,27 @@ fn pallet_hooks_expand() { assert_eq!( frame_system::Pallet::::events()[0].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(10)), + RuntimeEvent::Example(pallet::Event::Something(10)), ); assert_eq!( frame_system::Pallet::::events()[1].event, - RuntimeEvent::Instance1Example(pallet::PalletEvent::Something(11)), + RuntimeEvent::Instance1Example(pallet::Event::Something(11)), ); assert_eq!( frame_system::Pallet::::events()[2].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(20)), + RuntimeEvent::Example(pallet::Event::Something(20)), ); assert_eq!( frame_system::Pallet::::events()[3].event, - RuntimeEvent::Instance1Example(pallet::PalletEvent::Something(21)), + RuntimeEvent::Instance1Example(pallet::Event::Something(21)), ); assert_eq!( frame_system::Pallet::::events()[4].event, - RuntimeEvent::Example(pallet::PalletEvent::Something(30)), + RuntimeEvent::Example(pallet::Event::Something(30)), ); assert_eq!( frame_system::Pallet::::events()[5].event, - RuntimeEvent::Instance1Example(pallet::PalletEvent::Something(31)), + RuntimeEvent::Instance1Example(pallet::Event::Something(31)), ); }) } @@ -610,7 +610,7 @@ fn metadata() { storage: None, // The storage metadatas have been excluded. calls: Some(scale_info::meta_type::>().into()), event: Some(PalletEventMetadata { - ty: scale_info::meta_type::>(), + ty: scale_info::meta_type::>(), }), constants: vec![ PalletConstantMetadata { @@ -737,9 +737,7 @@ fn metadata() { ], }), calls: Some(scale_info::meta_type::>().into()), - event: Some(PalletEventMetadata { - ty: scale_info::meta_type::>(), - }), + event: Some(PalletEventMetadata { ty: scale_info::meta_type::>() }), constants: vec![PalletConstantMetadata { name: "MyGetParam", ty: scale_info::meta_type::(), @@ -760,8 +758,7 @@ fn metadata() { } match example_pallet_instance1_metadata.event { Some(ref mut event_meta) => { - event_meta.ty = - scale_info::meta_type::>(); + event_meta.ty = scale_info::meta_type::>(); }, _ => unreachable!(), } diff --git a/frame/support/test/tests/pallet_ui/event_field_not_member.rs b/frame/support/test/tests/pallet_ui/event_field_not_member.rs index 1bb003b2e8e71..2b45a971788fb 100644 --- a/frame/support/test/tests/pallet_ui/event_field_not_member.rs +++ b/frame/support/test/tests/pallet_ui/event_field_not_member.rs @@ -6,7 +6,7 @@ mod pallet { #[pallet::config] pub trait Config: frame_system::Config { type Bar; - type RuntimeEvent: IsType<::RuntimeEvent> + From>; + type RuntimeEvent: IsType<::RuntimeEvent> + From>; } #[pallet::pallet] @@ -19,7 +19,7 @@ mod pallet { impl Pallet {} #[pallet::event] - pub enum PalletEvent { + pub enum Event { B { b: T::Bar }, } } diff --git a/frame/support/test/tests/pallet_ui/event_not_in_trait.rs b/frame/support/test/tests/pallet_ui/event_not_in_trait.rs index 881032756c529..94151ba4c3d9d 100644 --- a/frame/support/test/tests/pallet_ui/event_not_in_trait.rs +++ b/frame/support/test/tests/pallet_ui/event_not_in_trait.rs @@ -18,7 +18,7 @@ mod pallet { impl Pallet {} #[pallet::event] - pub enum PalletEvent { + pub enum Event { B { b: T::Bar }, } } diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs index 1f10d2d4e357a..a02cc9b9de883 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound.rs @@ -19,7 +19,7 @@ mod pallet { impl Pallet {} #[pallet::event] - pub enum PalletEvent { + pub enum Event { B { b: T::Bar }, } } diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs index 8e49adbf38960..99df89d67278c 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.rs @@ -19,7 +19,7 @@ mod pallet { impl Pallet {} #[pallet::event] - pub enum PalletEvent { + pub enum Event { B { b: T::Bar }, } } diff --git a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr index d54fa85196051..ea8b2ff000ceb 100644 --- a/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr +++ b/frame/support/test/tests/pallet_ui/event_type_invalid_bound_2.stderr @@ -1,4 +1,4 @@ -error: Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must bound: `From` or `From>` or `From>` +error: Invalid `type RuntimeEvent`, associated type `RuntimeEvent` is reserved and must bound: `From` or `From>` or `From>` --> $DIR/event_type_invalid_bound_2.rs:9:3 | 9 | type RuntimeEvent: IsType<::RuntimeEvent>; diff --git a/frame/support/test/tests/pallet_ui/event_wrong_item_name.stderr b/frame/support/test/tests/pallet_ui/event_wrong_item_name.stderr index 9636144366657..14e8615c56199 100644 --- a/frame/support/test/tests/pallet_ui/event_wrong_item_name.stderr +++ b/frame/support/test/tests/pallet_ui/event_wrong_item_name.stderr @@ -1,4 +1,4 @@ -error: expected `PalletEvent` +error: expected `Event` --> $DIR/event_wrong_item_name.rs:19:11 | 19 | pub enum Foo {} diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 3184aed5bd54b..6f2f099514883 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -18,7 +18,7 @@ pub trait Trait: frame_system::Config { type Balance: frame_support::dispatch::Parameter; /// The overarching event type. - type RuntimeEvent: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } frame_support::decl_storage! { @@ -28,7 +28,7 @@ frame_support::decl_storage! { } frame_support::decl_event!( - pub enum PalletEvent + pub enum Event where B = ::Balance, { diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index 8e5dbf05548c8..ca9e001ca0a7f 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -30,7 +30,7 @@ pub trait Config: 'static + Eq + Clone { type Hash; type AccountId: Encode + EncodeLike + Decode + scale_info::TypeInfo; type Call; - type RuntimeEvent: From>; + type RuntimeEvent: From>; type PalletInfo: frame_support::traits::PalletInfo; type DbWeight: Get; } @@ -47,7 +47,7 @@ impl Module { } frame_support::decl_event!( - pub enum PalletEvent + pub enum Event where BlockNumber = ::BlockNumber, { diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 3790abcd22fcf..19350e728fc3c 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -34,12 +34,12 @@ mod module { #[pallet::config] pub trait Config: frame_system::Config { - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { Complex(Vec, u32, u16, u128), } } @@ -110,7 +110,7 @@ fn deposit_events(n: usize) { let mut t = new_test_ext(); t.execute_with(|| { for _ in 0..n { - module::Pallet::::deposit_event(module::PalletEvent::Complex( + module::Pallet::::deposit_event(module::Event::Complex( vec![1, 2, 3], 2, 3, diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index 1276c2a11fc33..b32849d59377c 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -295,7 +295,7 @@ pub mod pallet { /// The aggregated event type of the runtime. type RuntimeEvent: Parameter + Member - + From> + + From> + Debug + IsType<::RuntimeEvent>; @@ -498,14 +498,14 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let hash = T::Hashing::hash(&remark[..]); - Self::deposit_event(PalletEvent::Remarked { sender: who, hash }); + Self::deposit_event(Event::Remarked { sender: who, hash }); Ok(().into()) } } /// Event for the System pallet. #[pallet::event] - pub enum PalletEvent { + pub enum Event { /// An extrinsic completed successfully. ExtrinsicSuccess { dispatch_info: DispatchInfo }, /// An extrinsic failed. @@ -993,7 +993,7 @@ impl Pallet { pub fn update_code_in_storage(code: &[u8]) -> DispatchResult { storage::unhashed::put_raw(well_known_keys::CODE, code); Self::deposit_log(generic::DigestItem::RuntimeEnvironmentUpdated); - Self::deposit_event(PalletEvent::CodeUpdated); + Self::deposit_event(Event::CodeUpdated); Ok(()) } @@ -1507,7 +1507,7 @@ impl Pallet { info.weight = extract_actual_weight(r, &info); info.pays_fee = extract_actual_pays_fee(r, &info); Self::deposit_event(match r { - Ok(_) => PalletEvent::ExtrinsicSuccess { dispatch_info: info }, + Ok(_) => Event::ExtrinsicSuccess { dispatch_info: info }, Err(err) => { log::trace!( target: "runtime::system", @@ -1515,7 +1515,7 @@ impl Pallet { Self::block_number(), err, ); - PalletEvent::ExtrinsicFailed { dispatch_error: err.error, dispatch_info: info } + Event::ExtrinsicFailed { dispatch_error: err.error, dispatch_info: info } }, }); @@ -1543,13 +1543,13 @@ impl Pallet { /// An account is being created. pub fn on_created_account(who: T::AccountId, _a: &mut AccountInfo) { T::OnNewAccount::on_new_account(&who); - Self::deposit_event(PalletEvent::NewAccount { account: 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(PalletEvent::KilledAccount { account: who }); + Self::deposit_event(Event::KilledAccount { account: who }); } /// Determine whether or not it is possible to update the code. diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 1885363341c66..fb140b24a8689 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -117,7 +117,7 @@ impl Config for Test { type MaxConsumers = ConstU32<16>; } -pub type SysEvent = frame_system::PalletEvent; +pub type SysEvent = frame_system::Event; /// A simple call, which one doesn't matter. pub const CALL: &::Call = diff --git a/frame/tips/src/lib.rs b/frame/tips/src/lib.rs index 85a6b860ac5e7..9313a26e52e00 100644 --- a/frame/tips/src/lib.rs +++ b/frame/tips/src/lib.rs @@ -127,7 +127,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_treasury::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Maximum acceptable reason length. @@ -185,7 +185,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// A new tip suggestion has been opened. NewTip { tip_hash: T::Hash }, /// A tip suggestion has reached threshold and is closing. @@ -269,7 +269,7 @@ pub mod pallet { finders_fee: true, }; Tips::::insert(&hash, tip); - Self::deposit_event(PalletEvent::NewTip { tip_hash: hash }); + Self::deposit_event(Event::NewTip { tip_hash: hash }); Ok(()) } @@ -304,7 +304,7 @@ pub mod pallet { let err_amount = T::Currency::unreserve(&who, tip.deposit); debug_assert!(err_amount.is_zero()); } - Self::deposit_event(PalletEvent::TipRetracted { tip_hash: hash }); + Self::deposit_event(Event::TipRetracted { tip_hash: hash }); Ok(()) } @@ -345,7 +345,7 @@ pub mod pallet { let hash = T::Hashing::hash_of(&(&reason_hash, &who)); Reasons::::insert(&reason_hash, &reason); - Self::deposit_event(PalletEvent::NewTip { tip_hash: hash }); + Self::deposit_event(Event::NewTip { tip_hash: hash }); let tips = vec![(tipper.clone(), tip_value)]; let tip = OpenTip { reason: reason_hash, @@ -395,7 +395,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(PalletEvent::TipClosing { tip_hash: hash }); + Self::deposit_event(Event::TipClosing { tip_hash: hash }); } Tips::::insert(&hash, tip); Ok(()) @@ -454,7 +454,7 @@ pub mod pallet { T::OnSlash::on_unbalanced(imbalance); } Reasons::::remove(&tip.reason); - Self::deposit_event(PalletEvent::TipSlashed { + Self::deposit_event(Event::TipSlashed { tip_hash: hash, finder: tip.finder, deposit: tip.deposit, @@ -553,7 +553,7 @@ impl, I: 'static> 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(PalletEvent::TipClosed { tip_hash: hash, who: 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 7b3e50a04b9b1..dfa3290d67d8d 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -39,7 +39,7 @@ use frame_support::{ }; use super::*; -use crate::{self as pallet_tips, PalletEvent as TipEvent}; +use crate::{self as pallet_tips, Event as TipEvent}; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; diff --git a/frame/transaction-payment/asset-tx-payment/src/lib.rs b/frame/transaction-payment/asset-tx-payment/src/lib.rs index 827a9635f2692..768d556bcb6a3 100644 --- a/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -114,8 +114,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_transaction_payment::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The fungibles instance used to pay for transactions in assets. type Fungibles: Balanced; /// The actual transaction charging logic that charges the fees. @@ -128,7 +127,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee, /// has been paid by `who` in an asset `asset_id`. AssetTxFeePaid { @@ -291,7 +290,7 @@ where tip.into(), already_withdrawn.into(), )?; - Pallet::::deposit_event(PalletEvent::::AssetTxFeePaid { + Pallet::::deposit_event(Event::::AssetTxFeePaid { who, actual_fee, tip, diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 24625cad40394..83432271b47de 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -250,8 +250,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for withdrawing, refunding and depositing the transaction fee. /// Transaction fees are withdrawn before the transaction is executed. @@ -327,7 +326,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee, /// has been paid by `who`. TransactionFeePaid { who: T::AccountId, actual_fee: BalanceOf, tip: BalanceOf }, @@ -772,11 +771,7 @@ where T::OnChargeTransaction::correct_and_deposit_fee( &who, info, post_info, actual_fee, tip, imbalance, )?; - Pallet::::deposit_event(PalletEvent::::TransactionFeePaid { - who, - actual_fee, - tip, - }); + Pallet::::deposit_event(Event::::TransactionFeePaid { who, actual_fee, tip }); } Ok(()) } @@ -1428,12 +1423,12 @@ mod tests { assert_eq!(Balances::free_balance(2), 0); // Transfer Event System::assert_has_event(RuntimeEvent::Balances( - pallet_balances::PalletEvent::Transfer { from: 2, to: 3, amount: 80 }, + pallet_balances::Event::Transfer { from: 2, to: 3, amount: 80 }, )); // Killed Event - System::assert_has_event(RuntimeEvent::System( - system::PalletEvent::KilledAccount { account: 2 }, - )); + System::assert_has_event(RuntimeEvent::System(system::Event::KilledAccount { + account: 2, + })); }); } @@ -1488,7 +1483,7 @@ mod tests { assert_eq!(Balances::total_balance(&user), 0); // TransactionFeePaid Event System::assert_has_event(RuntimeEvent::TransactionPayment( - pallet_transaction_payment::PalletEvent::TransactionFeePaid { + pallet_transaction_payment::Event::TransactionFeePaid { who: user, actual_fee: 0, tip: 0, diff --git a/frame/transaction-storage/src/benchmarking.rs b/frame/transaction-storage/src/benchmarking.rs index 8b32ed028436c..cab4c92317bb5 100644 --- a/frame/transaction-storage/src/benchmarking.rs +++ b/frame/transaction-storage/src/benchmarking.rs @@ -132,7 +132,7 @@ benchmarks! { }: _(RawOrigin::Signed(caller.clone()), vec![0u8; l as usize]) verify { assert!(!BlockTransactions::::get().is_empty()); - assert_last_event::(PalletEvent::Stored { index: 0 }.into()); + assert_last_event::(Event::Stored { index: 0 }.into()); } renew { @@ -145,7 +145,7 @@ benchmarks! { run_to_block::(1u32.into()); }: _(RawOrigin::Signed(caller.clone()), T::BlockNumber::zero(), 0) verify { - assert_last_event::(PalletEvent::Renewed { index: 0 }.into()); + assert_last_event::(Event::Renewed { index: 0 }.into()); } check_proof_max { @@ -163,7 +163,7 @@ benchmarks! { let proof = TransactionStorageProof::decode(&mut encoded_proof).unwrap(); }: check_proof(RawOrigin::None, proof) verify { - assert_last_event::(PalletEvent::ProofChecked.into()); + assert_last_event::(Event::ProofChecked.into()); } impl_benchmark_test_suite!(TransactionStorage, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index fb7b5694d5419..5fdd3a58deb44 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -92,8 +92,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A dispatchable call. type Call: Parameter + Dispatchable @@ -226,7 +225,7 @@ pub mod pallet { .map_err(|_| Error::::TooManyTransactions)?; Ok(()) })?; - Self::deposit_event(PalletEvent::Stored { index }); + Self::deposit_event(Event::Stored { index }); Ok(()) } @@ -270,7 +269,7 @@ pub mod pallet { }) .map_err(|_| Error::::TooManyTransactions) })?; - Self::deposit_event(PalletEvent::Renewed { index }); + Self::deposit_event(Event::Renewed { index }); Ok(().into()) } @@ -323,14 +322,14 @@ pub mod pallet { Error::::InvalidProof ); ProofChecked::::put(true); - Self::deposit_event(PalletEvent::ProofChecked); + Self::deposit_event(Event::ProofChecked); Ok(().into()) } } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Stored data under specified index. Stored { index: u32 }, /// Renewed data under specified index. diff --git a/frame/treasury/src/benchmarking.rs b/frame/treasury/src/benchmarking.rs index 6e6824b8d95a3..b3787e2063c45 100644 --- a/frame/treasury/src/benchmarking.rs +++ b/frame/treasury/src/benchmarking.rs @@ -80,7 +80,7 @@ benchmarks_instance_pallet! { } verify { if origin.is_ok() { - assert_last_event::(PalletEvent::SpendApproved { proposal_index: 0, amount: value, beneficiary }.into()) + assert_last_event::(Event::SpendApproved { proposal_index: 0, amount: value, beneficiary }.into()) } } diff --git a/frame/treasury/src/lib.rs b/frame/treasury/src/lib.rs index 45258eaaa52c0..158a13ba23ad5 100644 --- a/frame/treasury/src/lib.rs +++ b/frame/treasury/src/lib.rs @@ -155,7 +155,7 @@ pub mod pallet { type RejectOrigin: EnsureOrigin; /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Handler for the unbalanced decrease when slashing for a rejected proposal or bounty. @@ -267,7 +267,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// New proposal. Proposed { proposal_index: ProposalIndex }, /// We have ended a spend period and will now allocate funds. @@ -353,7 +353,7 @@ pub mod pallet { >::put(c + 1); >::insert(c, Proposal { proposer, value, beneficiary, bond }); - Self::deposit_event(PalletEvent::Proposed { proposal_index: c }); + Self::deposit_event(Event::Proposed { proposal_index: c }); Ok(()) } @@ -379,7 +379,7 @@ pub mod pallet { let imbalance = T::Currency::slash_reserved(&proposal.proposer, value).0; T::OnSlash::on_unbalanced(imbalance); - Self::deposit_event(PalletEvent::::Rejected { + Self::deposit_event(Event::::Rejected { proposal_index: proposal_id, slashed: value, }); @@ -439,7 +439,7 @@ pub mod pallet { Proposals::::insert(proposal_index, proposal); ProposalCount::::put(proposal_index + 1); - Self::deposit_event(PalletEvent::SpendApproved { proposal_index, amount, beneficiary }); + Self::deposit_event(Event::SpendApproved { proposal_index, amount, beneficiary }); Ok(()) } @@ -504,7 +504,7 @@ impl, I: 'static> Pallet { let mut total_weight: Weight = Zero::zero(); let mut budget_remaining = Self::pot(); - Self::deposit_event(PalletEvent::Spending { budget_remaining }); + Self::deposit_event(Event::Spending { budget_remaining }); let account_id = Self::account_id(); let mut missed_any = false; @@ -525,7 +525,7 @@ impl, I: 'static> Pallet { // provide the allocation. imbalance.subsume(T::Currency::deposit_creating(&p.beneficiary, p.value)); - Self::deposit_event(PalletEvent::Awarded { + Self::deposit_event(Event::Awarded { proposal_index: index, award: p.value, account: p.beneficiary, @@ -560,7 +560,7 @@ impl, I: 'static> Pallet { let (debit, credit) = T::Currency::pair(burn); imbalance.subsume(debit); T::BurnDestination::on_unbalanced(credit); - Self::deposit_event(PalletEvent::Burnt { burnt_funds: burn }) + Self::deposit_event(Event::Burnt { burnt_funds: burn }) } // Must never be an error, but better to be safe. @@ -575,7 +575,7 @@ impl, I: 'static> Pallet { drop(problem); } - Self::deposit_event(PalletEvent::Rollover { rollover_balance: budget_remaining }); + Self::deposit_event(Event::Rollover { rollover_balance: budget_remaining }); total_weight } @@ -596,6 +596,6 @@ impl, I: 'static> OnUnbalanced> for Palle // Must resolve into existing but better to be safe. let _ = T::Currency::resolve_creating(&Self::account_id(), amount); - Self::deposit_event(PalletEvent::Deposit { value: numeric_amount }); + Self::deposit_event(Event::Deposit { value: numeric_amount }); } } diff --git a/frame/uniques/src/benchmarking.rs b/frame/uniques/src/benchmarking.rs index fdbc532e7dcd5..ab34558f95eb3 100644 --- a/frame/uniques/src/benchmarking.rs +++ b/frame/uniques/src/benchmarking.rs @@ -145,7 +145,7 @@ benchmarks_instance_pallet! { let call = Call::::create { collection, admin }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(PalletEvent::Created { collection: T::Helper::collection(0), creator: caller.clone(), owner: caller }.into()); + assert_last_event::(Event::Created { collection: T::Helper::collection(0), creator: caller.clone(), owner: caller }.into()); } force_create { @@ -153,7 +153,7 @@ benchmarks_instance_pallet! { let caller_lookup = T::Lookup::unlookup(caller.clone()); }: _(SystemOrigin::Root, T::Helper::collection(0), caller_lookup, true) verify { - assert_last_event::(PalletEvent::ForceCreated { collection: T::Helper::collection(0), owner: caller }.into()); + assert_last_event::(Event::ForceCreated { collection: T::Helper::collection(0), owner: caller }.into()); } destroy { @@ -175,7 +175,7 @@ benchmarks_instance_pallet! { let witness = Collection::::get(collection).unwrap().destroy_witness(); }: _(SystemOrigin::Signed(caller), collection, witness) verify { - assert_last_event::(PalletEvent::Destroyed { collection }.into()); + assert_last_event::(Event::Destroyed { collection }.into()); } mint { @@ -183,7 +183,7 @@ benchmarks_instance_pallet! { let item = T::Helper::item(0); }: _(SystemOrigin::Signed(caller.clone()), collection, item, caller_lookup) verify { - assert_last_event::(PalletEvent::Issued { collection, item, owner: caller }.into()); + assert_last_event::(Event::Issued { collection, item, owner: caller }.into()); } burn { @@ -191,7 +191,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(caller_lookup)) verify { - assert_last_event::(PalletEvent::Burned { collection, item, owner: caller }.into()); + assert_last_event::(Event::Burned { collection, item, owner: caller }.into()); } transfer { @@ -202,7 +202,7 @@ benchmarks_instance_pallet! { let target_lookup = T::Lookup::unlookup(target.clone()); }: _(SystemOrigin::Signed(caller.clone()), collection, item, target_lookup) verify { - assert_last_event::(PalletEvent::Transferred { collection, item, from: caller, to: target }.into()); + assert_last_event::(Event::Transferred { collection, item, from: caller, to: target }.into()); } redeposit { @@ -221,7 +221,7 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), collection, items.clone()) verify { - assert_last_event::(PalletEvent::Redeposited { collection, successful_items: items }.into()); + assert_last_event::(Event::Redeposited { collection, successful_items: items }.into()); } freeze { @@ -229,7 +229,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); }: _(SystemOrigin::Signed(caller.clone()), T::Helper::collection(0), T::Helper::item(0)) verify { - assert_last_event::(PalletEvent::Frozen { collection: T::Helper::collection(0), item: T::Helper::item(0) }.into()); + assert_last_event::(Event::Frozen { collection: T::Helper::collection(0), item: T::Helper::item(0) }.into()); } thaw { @@ -242,14 +242,14 @@ benchmarks_instance_pallet! { )?; }: _(SystemOrigin::Signed(caller.clone()), collection, item) verify { - assert_last_event::(PalletEvent::Thawed { collection, item }.into()); + assert_last_event::(Event::Thawed { collection, item }.into()); } freeze_collection { let (collection, caller, caller_lookup) = create_collection::(); }: _(SystemOrigin::Signed(caller.clone()), collection) verify { - assert_last_event::(PalletEvent::CollectionFrozen { collection }.into()); + assert_last_event::(Event::CollectionFrozen { collection }.into()); } thaw_collection { @@ -258,7 +258,7 @@ benchmarks_instance_pallet! { Uniques::::freeze_collection(origin, collection)?; }: _(SystemOrigin::Signed(caller.clone()), collection) verify { - assert_last_event::(PalletEvent::CollectionThawed { collection }.into()); + assert_last_event::(Event::CollectionThawed { collection }.into()); } transfer_ownership { @@ -270,7 +270,7 @@ benchmarks_instance_pallet! { Uniques::::set_accept_ownership(origin, Some(collection))?; }: _(SystemOrigin::Signed(caller), collection, target_lookup) verify { - assert_last_event::(PalletEvent::OwnerChanged { collection, new_owner: target }.into()); + assert_last_event::(Event::OwnerChanged { collection, new_owner: target }.into()); } set_team { @@ -280,7 +280,7 @@ benchmarks_instance_pallet! { let target2 = T::Lookup::unlookup(account("target", 2, SEED)); }: _(SystemOrigin::Signed(caller), collection, target0, target1, target2) verify { - assert_last_event::(PalletEvent::TeamChanged{ + assert_last_event::(Event::TeamChanged{ collection, issuer: account("target", 0, SEED), admin: account("target", 1, SEED), @@ -302,7 +302,7 @@ benchmarks_instance_pallet! { }; }: { call.dispatch_bypass_filter(origin)? } verify { - assert_last_event::(PalletEvent::ItemStatusChanged { collection }.into()); + assert_last_event::(Event::ItemStatusChanged { collection }.into()); } set_attribute { @@ -314,7 +314,7 @@ benchmarks_instance_pallet! { add_item_metadata::(item); }: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone(), value.clone()) verify { - assert_last_event::(PalletEvent::AttributeSet { collection, maybe_item: Some(item), key, value }.into()); + assert_last_event::(Event::AttributeSet { collection, maybe_item: Some(item), key, value }.into()); } clear_attribute { @@ -324,7 +324,7 @@ benchmarks_instance_pallet! { let (key, ..) = add_item_attribute::(item); }: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone()) verify { - assert_last_event::(PalletEvent::AttributeCleared { collection, maybe_item: Some(item), key }.into()); + assert_last_event::(Event::AttributeCleared { collection, maybe_item: Some(item), key }.into()); } set_metadata { @@ -334,7 +334,7 @@ benchmarks_instance_pallet! { let (item, ..) = mint_item::(0); }: _(SystemOrigin::Signed(caller), collection, item, data.clone(), false) verify { - assert_last_event::(PalletEvent::MetadataSet { collection, item, data, is_frozen: false }.into()); + assert_last_event::(Event::MetadataSet { collection, item, data, is_frozen: false }.into()); } clear_metadata { @@ -343,7 +343,7 @@ benchmarks_instance_pallet! { add_item_metadata::(item); }: _(SystemOrigin::Signed(caller), collection, item) verify { - assert_last_event::(PalletEvent::MetadataCleared { collection, item }.into()); + assert_last_event::(Event::MetadataCleared { collection, item }.into()); } set_collection_metadata { @@ -352,7 +352,7 @@ benchmarks_instance_pallet! { let (collection, caller, _) = create_collection::(); }: _(SystemOrigin::Signed(caller), collection, data.clone(), false) verify { - assert_last_event::(PalletEvent::CollectionMetadataSet { collection, data, is_frozen: false }.into()); + assert_last_event::(Event::CollectionMetadataSet { collection, data, is_frozen: false }.into()); } clear_collection_metadata { @@ -360,7 +360,7 @@ benchmarks_instance_pallet! { add_collection_metadata::(); }: _(SystemOrigin::Signed(caller), collection) verify { - assert_last_event::(PalletEvent::CollectionMetadataCleared { collection }.into()); + assert_last_event::(Event::CollectionMetadataCleared { collection }.into()); } approve_transfer { @@ -370,7 +370,7 @@ benchmarks_instance_pallet! { let delegate_lookup = T::Lookup::unlookup(delegate.clone()); }: _(SystemOrigin::Signed(caller.clone()), collection, item, delegate_lookup) verify { - assert_last_event::(PalletEvent::ApprovedTransfer { collection, item, owner: caller, delegate }.into()); + assert_last_event::(Event::ApprovedTransfer { collection, item, owner: caller, delegate }.into()); } cancel_approval { @@ -382,7 +382,7 @@ benchmarks_instance_pallet! { Uniques::::approve_transfer(origin, collection, item, delegate_lookup.clone())?; }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(delegate_lookup)) verify { - assert_last_event::(PalletEvent::ApprovalCancelled { collection, item, owner: caller, delegate }.into()); + assert_last_event::(Event::ApprovalCancelled { collection, item, owner: caller, delegate }.into()); } set_accept_ownership { @@ -391,7 +391,7 @@ benchmarks_instance_pallet! { let collection = T::Helper::collection(0); }: _(SystemOrigin::Signed(caller.clone()), Some(collection)) verify { - assert_last_event::(PalletEvent::OwnershipAcceptanceChanged { + assert_last_event::(Event::OwnershipAcceptanceChanged { who: caller, maybe_collection: Some(collection), }.into()); @@ -401,7 +401,7 @@ benchmarks_instance_pallet! { let (collection, caller, _) = create_collection::(); }: _(SystemOrigin::Signed(caller.clone()), collection, u32::MAX) verify { - assert_last_event::(PalletEvent::CollectionMaxSupplySet { + assert_last_event::(Event::CollectionMaxSupplySet { collection, max_supply: u32::MAX, }.into()); @@ -415,7 +415,7 @@ benchmarks_instance_pallet! { let price = ItemPrice::::from(100u32); }: _(SystemOrigin::Signed(caller.clone()), collection, item, Some(price), Some(delegate_lookup)) verify { - assert_last_event::(PalletEvent::ItemPriceSet { + assert_last_event::(Event::ItemPriceSet { collection, item, price, @@ -434,7 +434,7 @@ benchmarks_instance_pallet! { T::Currency::make_free_balance_be(&buyer, DepositBalanceOf::::max_value()); }: _(SystemOrigin::Signed(buyer.clone()), collection, item, price.clone()) verify { - assert_last_event::(PalletEvent::ItemBought { + assert_last_event::(Event::ItemBought { collection, item, price, diff --git a/frame/uniques/src/functions.rs b/frame/uniques/src/functions.rs index bc0adfe7c0e5e..107214558307f 100644 --- a/frame/uniques/src/functions.rs +++ b/frame/uniques/src/functions.rs @@ -51,7 +51,7 @@ impl, I: 'static> Pallet { Item::::insert(&collection, &item, &details); ItemPriceOf::::remove(&collection, &item); - Self::deposit_event(PalletEvent::Transferred { + Self::deposit_event(Event::Transferred { collection, item, from: origin, @@ -66,7 +66,7 @@ impl, I: 'static> Pallet { admin: T::AccountId, deposit: DepositBalanceOf, free_holding: bool, - event: PalletEvent, + event: Event, ) -> DispatchResult { ensure!(!Collection::::contains_key(collection), Error::::InUse); @@ -125,7 +125,7 @@ impl, I: 'static> Pallet { T::Currency::unreserve(&collection_details.owner, collection_details.total_deposit); CollectionMaxSupply::::remove(&collection); - Self::deposit_event(PalletEvent::Destroyed { collection }); + Self::deposit_event(Event::Destroyed { collection }); Ok(DestroyWitness { items: collection_details.items, @@ -174,7 +174,7 @@ impl, I: 'static> Pallet { }, )?; - Self::deposit_event(PalletEvent::Issued { collection, item, owner }); + Self::deposit_event(Event::Issued { collection, item, owner }); Ok(()) } @@ -204,7 +204,7 @@ impl, I: 'static> Pallet { Account::::remove((&owner, &collection, &item)); ItemPriceOf::::remove(&collection, &item); - Self::deposit_event(PalletEvent::Burned { collection, item, owner }); + Self::deposit_event(Event::Burned { collection, item, owner }); Ok(()) } @@ -220,7 +220,7 @@ impl, I: 'static> Pallet { if let Some(ref price) = price { ItemPriceOf::::insert(&collection, &item, (price, whitelisted_buyer.clone())); - Self::deposit_event(PalletEvent::ItemPriceSet { + Self::deposit_event(Event::ItemPriceSet { collection, item, price: *price, @@ -228,7 +228,7 @@ impl, I: 'static> Pallet { }); } else { ItemPriceOf::::remove(&collection, &item); - Self::deposit_event(PalletEvent::ItemPriceRemoved { collection, item }); + Self::deposit_event(Event::ItemPriceRemoved { collection, item }); } Ok(()) @@ -263,7 +263,7 @@ impl, I: 'static> Pallet { Self::do_transfer(collection, item, buyer.clone(), |_, _| Ok(()))?; - Self::deposit_event(PalletEvent::ItemBought { + Self::deposit_event(Event::ItemBought { collection, item, price: price_info.0, diff --git a/frame/uniques/src/impl_nonfungibles.rs b/frame/uniques/src/impl_nonfungibles.rs index a5e20dd9c2f0c..cead6f562ab58 100644 --- a/frame/uniques/src/impl_nonfungibles.rs +++ b/frame/uniques/src/impl_nonfungibles.rs @@ -98,11 +98,7 @@ impl, I: 'static> Create<::AccountId> for Pallet admin.clone(), T::CollectionDeposit::get(), false, - PalletEvent::Created { - collection: *collection, - creator: who.clone(), - owner: admin.clone(), - }, + Event::Created { collection: *collection, creator: who.clone(), owner: admin.clone() }, ) } } diff --git a/frame/uniques/src/lib.rs b/frame/uniques/src/lib.rs index b5632ec12623d..c087794b59dbd 100644 --- a/frame/uniques/src/lib.rs +++ b/frame/uniques/src/lib.rs @@ -91,7 +91,7 @@ pub mod pallet { /// The module configuration trait. pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Identifier for the collection of item. @@ -271,7 +271,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent, I: 'static = ()> { + pub enum Event, I: 'static = ()> { /// A `collection` was created. Created { collection: T::CollectionId, creator: T::AccountId, owner: T::AccountId }, /// A `collection` was force-created. @@ -464,7 +464,7 @@ pub mod pallet { admin.clone(), T::CollectionDeposit::get(), false, - PalletEvent::Created { collection, creator: owner, owner: admin }, + Event::Created { collection, creator: owner, owner: admin }, ) } @@ -501,7 +501,7 @@ pub mod pallet { owner.clone(), Zero::zero(), free_holding, - PalletEvent::ForceCreated { collection, owner }, + Event::ForceCreated { collection, owner }, ) } @@ -698,7 +698,7 @@ pub mod pallet { } Collection::::insert(&collection, &collection_details); - Self::deposit_event(PalletEvent::::Redeposited { + Self::deposit_event(Event::::Redeposited { collection, successful_items: successful, }); @@ -733,7 +733,7 @@ pub mod pallet { details.is_frozen = true; Item::::insert(&collection, &item, &details); - Self::deposit_event(PalletEvent::::Frozen { collection, item }); + Self::deposit_event(Event::::Frozen { collection, item }); Ok(()) } @@ -764,7 +764,7 @@ pub mod pallet { details.is_frozen = false; Item::::insert(&collection, &item, &details); - Self::deposit_event(PalletEvent::::Thawed { collection, item }); + Self::deposit_event(Event::::Thawed { collection, item }); Ok(()) } @@ -790,7 +790,7 @@ pub mod pallet { details.is_frozen = true; - Self::deposit_event(PalletEvent::::CollectionFrozen { collection }); + Self::deposit_event(Event::::CollectionFrozen { collection }); Ok(()) }) } @@ -817,7 +817,7 @@ pub mod pallet { details.is_frozen = false; - Self::deposit_event(PalletEvent::::CollectionThawed { collection }); + Self::deposit_event(Event::::CollectionThawed { collection }); Ok(()) }) } @@ -864,7 +864,7 @@ pub mod pallet { details.owner = owner.clone(); OwnershipAcceptance::::remove(&owner); - Self::deposit_event(PalletEvent::OwnerChanged { collection, new_owner: owner }); + Self::deposit_event(Event::OwnerChanged { collection, new_owner: owner }); Ok(()) }) } @@ -902,12 +902,7 @@ pub mod pallet { details.admin = admin.clone(); details.freezer = freezer.clone(); - Self::deposit_event(PalletEvent::TeamChanged { - collection, - issuer, - admin, - freezer, - }); + Self::deposit_event(Event::TeamChanged { collection, issuer, admin, freezer }); Ok(()) }) } @@ -950,7 +945,7 @@ pub mod pallet { Item::::insert(&collection, &item, &details); let delegate = details.approved.expect("set as Some above; qed"); - Self::deposit_event(PalletEvent::ApprovedTransfer { + Self::deposit_event(Event::ApprovedTransfer { collection, item, owner: details.owner, @@ -1002,7 +997,7 @@ pub mod pallet { } Item::::insert(&collection, &item, &details); - Self::deposit_event(PalletEvent::ApprovalCancelled { + Self::deposit_event(Event::ApprovalCancelled { collection, item, owner: details.owner, @@ -1055,7 +1050,7 @@ pub mod pallet { CollectionAccount::::remove(&old_owner, &collection); CollectionAccount::::insert(&new_owner, &collection, ()); - Self::deposit_event(PalletEvent::ItemStatusChanged { collection }); + Self::deposit_event(Event::ItemStatusChanged { collection }); Ok(()) }) } @@ -1121,7 +1116,7 @@ pub mod pallet { Attribute::::insert((&collection, maybe_item, &key), (&value, deposit)); Collection::::insert(collection, &collection_details); - Self::deposit_event(PalletEvent::AttributeSet { collection, maybe_item, key, value }); + Self::deposit_event(Event::AttributeSet { collection, maybe_item, key, value }); Ok(()) } @@ -1166,7 +1161,7 @@ pub mod pallet { collection_details.total_deposit.saturating_reduce(deposit); T::Currency::unreserve(&collection_details.owner, deposit); Collection::::insert(collection, &collection_details); - Self::deposit_event(PalletEvent::AttributeCleared { collection, maybe_item, key }); + Self::deposit_event(Event::AttributeCleared { collection, maybe_item, key }); } Ok(()) } @@ -1232,7 +1227,7 @@ pub mod pallet { *metadata = Some(ItemMetadata { deposit, data: data.clone(), is_frozen }); Collection::::insert(&collection, &collection_details); - Self::deposit_event(PalletEvent::MetadataSet { collection, item, data, is_frozen }); + Self::deposit_event(Event::MetadataSet { collection, item, data, is_frozen }); Ok(()) }) } @@ -1278,7 +1273,7 @@ pub mod pallet { collection_details.total_deposit.saturating_reduce(deposit); Collection::::insert(&collection, &collection_details); - Self::deposit_event(PalletEvent::MetadataCleared { collection, item }); + Self::deposit_event(Event::MetadataCleared { collection, item }); Ok(()) }) } @@ -1339,11 +1334,7 @@ pub mod pallet { *metadata = Some(CollectionMetadata { deposit, data: data.clone(), is_frozen }); - Self::deposit_event(PalletEvent::CollectionMetadataSet { - collection, - data, - is_frozen, - }); + Self::deposit_event(Event::CollectionMetadataSet { collection, data, is_frozen }); Ok(()) }) } @@ -1381,7 +1372,7 @@ pub mod pallet { let deposit = metadata.take().ok_or(Error::::UnknownCollection)?.deposit; T::Currency::unreserve(&details.owner, deposit); - Self::deposit_event(PalletEvent::CollectionMetadataCleared { collection }); + Self::deposit_event(Event::CollectionMetadataCleared { collection }); Ok(()) }) } @@ -1417,7 +1408,7 @@ pub mod pallet { } else { OwnershipAcceptance::::remove(&who); } - Self::deposit_event(PalletEvent::OwnershipAcceptanceChanged { who, maybe_collection }); + Self::deposit_event(Event::OwnershipAcceptanceChanged { who, maybe_collection }); Ok(()) } @@ -1456,7 +1447,7 @@ pub mod pallet { ensure!(details.items <= max_supply, Error::::MaxSupplyTooSmall); CollectionMaxSupply::::insert(&collection, max_supply); - Self::deposit_event(PalletEvent::CollectionMaxSupplySet { collection, max_supply }); + Self::deposit_event(Event::CollectionMaxSupplySet { collection, max_supply }); Ok(()) } diff --git a/frame/uniques/src/tests.rs b/frame/uniques/src/tests.rs index 6e7fbc9da1330..63bee10ed35ec 100644 --- a/frame/uniques/src/tests.rs +++ b/frame/uniques/src/tests.rs @@ -17,7 +17,7 @@ //! Tests for Uniques pallet. -use crate::{mock::*, PalletEvent, *}; +use crate::{mock::*, Event, *}; use frame_support::{assert_noop, assert_ok, dispatch::Dispatchable, traits::Currency}; use pallet_balances::Error as BalancesError; use sp_std::prelude::*; @@ -70,7 +70,7 @@ fn attributes(collection: u32) -> Vec<(Option, Vec, Vec)> { s } -fn events() -> Vec> { +fn events() -> Vec> { let result = System::events() .into_iter() .map(|r| r.event) @@ -663,7 +663,7 @@ fn max_supply_should_work() { )); assert_eq!(CollectionMaxSupply::::get(collection_id).unwrap(), max_supply); - assert!(events().contains(&PalletEvent::::CollectionMaxSupplySet { + assert!(events().contains(&Event::::CollectionMaxSupplySet { collection: collection_id, max_supply, })); @@ -732,7 +732,7 @@ fn set_price_should_work() { assert_eq!(item.0, 2); assert_eq!(item.1, Some(3)); - assert!(events().contains(&PalletEvent::::ItemPriceSet { + assert!(events().contains(&Event::::ItemPriceSet { collection: collection_id, item: item_1, price: 1, @@ -741,7 +741,7 @@ fn set_price_should_work() { // validate we can unset the price assert_ok!(Uniques::set_price(Origin::signed(user_id), collection_id, item_2, None, None)); - assert!(events().contains(&PalletEvent::::ItemPriceRemoved { + assert!(events().contains(&Event::::ItemPriceRemoved { collection: collection_id, item: item_2 })); @@ -819,7 +819,7 @@ fn buy_item_should_work() { // can buy when I'm a whitelisted buyer assert_ok!(Uniques::buy_item(Origin::signed(user_3), collection_id, item_2, price_2,)); - assert!(events().contains(&PalletEvent::::ItemBought { + assert!(events().contains(&Event::::ItemBought { collection: collection_id, item: item_2, price: price_2, diff --git a/frame/utility/src/benchmarking.rs b/frame/utility/src/benchmarking.rs index 78a0598e74d6d..fbbd6f2b378c7 100644 --- a/frame/utility/src/benchmarking.rs +++ b/frame/utility/src/benchmarking.rs @@ -41,7 +41,7 @@ benchmarks! { let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), calls) verify { - assert_last_event::(PalletEvent::BatchCompleted.into()) + assert_last_event::(Event::BatchCompleted.into()) } as_derivative { @@ -62,7 +62,7 @@ benchmarks! { let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), calls) verify { - assert_last_event::(PalletEvent::BatchCompleted.into()) + assert_last_event::(Event::BatchCompleted.into()) } dispatch_as { @@ -83,7 +83,7 @@ benchmarks! { let caller = whitelisted_caller(); }: _(RawOrigin::Signed(caller), calls) verify { - assert_last_event::(PalletEvent::BatchCompleted.into()) + assert_last_event::(Event::BatchCompleted.into()) } impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test); diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 96bbf5ac6f54c..057cda8cafb55 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -84,7 +84,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From + IsType<::RuntimeEvent>; + type RuntimeEvent: From + IsType<::RuntimeEvent>; /// The overarching call type. type Call: Parameter @@ -106,7 +106,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// Batch of dispatches did not complete fully. Index of first failing dispatch given, as /// well as the error. BatchInterrupted { index: u32, error: DispatchError }, @@ -220,7 +220,7 @@ pub mod pallet { // Add the weight of this call. weight = weight.saturating_add(extract_actual_weight(&result, &info)); if let Err(e) = result { - Self::deposit_event(PalletEvent::BatchInterrupted { + Self::deposit_event(Event::BatchInterrupted { index: index as u32, error: e.error, }); @@ -229,9 +229,9 @@ pub mod pallet { // Return the actual used weight + base_weight of this call. return Ok(Some(base_weight + weight).into()) } - Self::deposit_event(PalletEvent::ItemCompleted); + Self::deposit_event(Event::ItemCompleted); } - Self::deposit_event(PalletEvent::BatchCompleted); + Self::deposit_event(Event::BatchCompleted); let base_weight = T::WeightInfo::batch(calls_len as u32); Ok(Some(base_weight + weight).into()) } @@ -348,9 +348,9 @@ pub mod pallet { err.post_info = Some(base_weight + weight).into(); err })?; - Self::deposit_event(PalletEvent::ItemCompleted); + Self::deposit_event(Event::ItemCompleted); } - Self::deposit_event(PalletEvent::BatchCompleted); + Self::deposit_event(Event::BatchCompleted); let base_weight = T::WeightInfo::batch_all(calls_len as u32); Ok(Some(base_weight + weight).into()) } @@ -382,7 +382,7 @@ pub mod pallet { let res = call.dispatch_bypass_filter((*as_origin).into()); - Self::deposit_event(PalletEvent::DispatchedAs { + Self::deposit_event(Event::DispatchedAs { result: res.map(|_| ()).map_err(|e| e.error), }); Ok(()) @@ -444,15 +444,15 @@ pub mod pallet { weight = weight.saturating_add(extract_actual_weight(&result, &info)); if let Err(e) = result { has_error = true; - Self::deposit_event(PalletEvent::ItemFailed { error: e.error }); + Self::deposit_event(Event::ItemFailed { error: e.error }); } else { - Self::deposit_event(PalletEvent::ItemCompleted); + Self::deposit_event(Event::ItemCompleted); } } if has_error { - Self::deposit_event(PalletEvent::BatchCompletedWithErrors); + Self::deposit_event(Event::BatchCompletedWithErrors); } else { - Self::deposit_event(PalletEvent::BatchCompleted); + Self::deposit_event(Event::BatchCompleted); } let base_weight = T::WeightInfo::batch(calls_len as u32); Ok(Some(base_weight + weight).into()) diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 2f3df4b58d5f2..fe82af3b20bdc 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -336,7 +336,7 @@ fn batch_with_signed_filters() { vec![Call::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })] ),); System::assert_last_event( - utility::PalletEvent::BatchInterrupted { + utility::Event::BatchInterrupted { index: 0, error: frame_system::Error::::CallFiltered.into(), } @@ -411,8 +411,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") } - .into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); // No weight is refunded assert_eq!(extract_actual_weight(&result, &info), info.weight); @@ -427,8 +426,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") } - .into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); assert_eq!(extract_actual_weight(&result, &info), info.weight - diff * batch_len); @@ -441,8 +439,7 @@ fn batch_handles_weight_refund() { let result = call.dispatch(Origin::signed(1)); assert_ok!(result); System::assert_last_event( - utility::PalletEvent::BatchInterrupted { index: 1, error: DispatchError::Other("") } - .into(), + utility::Event::BatchInterrupted { index: 1, error: DispatchError::Other("") }.into(), ); assert_eq!( extract_actual_weight(&result, &info), @@ -590,7 +587,7 @@ fn batch_all_does_not_nest() { // and balances. assert_ok!(Utility::batch_all(Origin::signed(1), vec![batch_nested])); System::assert_has_event( - utility::PalletEvent::BatchInterrupted { + utility::Event::BatchInterrupted { index: 0, error: frame_system::Error::::CallFiltered.into(), } @@ -624,9 +621,9 @@ fn force_batch_works() { call_transfer(2, 5), ] ),); - System::assert_last_event(utility::PalletEvent::BatchCompletedWithErrors.into()); + System::assert_last_event(utility::Event::BatchCompletedWithErrors.into()); System::assert_has_event( - utility::PalletEvent::ItemFailed { error: DispatchError::Other("") }.into(), + utility::Event::ItemFailed { error: DispatchError::Other("") }.into(), ); assert_eq!(Balances::free_balance(1), 0); assert_eq!(Balances::free_balance(2), 20); @@ -635,9 +632,9 @@ fn force_batch_works() { Origin::signed(2), vec![call_transfer(1, 5), call_transfer(1, 5),] ),); - System::assert_last_event(utility::PalletEvent::BatchCompleted.into()); + System::assert_last_event(utility::Event::BatchCompleted.into()); assert_ok!(Utility::force_batch(Origin::signed(1), vec![call_transfer(2, 50),]),); - System::assert_last_event(utility::PalletEvent::BatchCompletedWithErrors.into()); + System::assert_last_event(utility::Event::BatchCompletedWithErrors.into()); }); } diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 1da057f124a21..1ca8d41f9a41c 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -155,8 +155,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The currency trait. type Currency: LockableCurrency; @@ -258,7 +257,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { /// The amount vested has been updated. This could indicate a change in funds available. /// The balance given is the amount which is left unvested (and thus locked). VestingUpdated { account: T::AccountId, unvested: BalanceOf }, @@ -568,11 +567,11 @@ impl Pallet { fn write_lock(who: &T::AccountId, total_locked_now: BalanceOf) { if total_locked_now.is_zero() { T::Currency::remove_lock(VESTING_ID, who); - Self::deposit_event(PalletEvent::::VestingCompleted { account: who.clone() }); + Self::deposit_event(Event::::VestingCompleted { account: who.clone() }); } else { let reasons = WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE; T::Currency::set_lock(VESTING_ID, who, total_locked_now, reasons); - Self::deposit_event(PalletEvent::::VestingUpdated { + Self::deposit_event(Event::::VestingUpdated { account: who.clone(), unvested: total_locked_now, }); diff --git a/frame/whitelist/src/lib.rs b/frame/whitelist/src/lib.rs index da822d6e06cb0..6bce32f27b6af 100644 --- a/frame/whitelist/src/lib.rs +++ b/frame/whitelist/src/lib.rs @@ -61,8 +61,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching event type. - type RuntimeEvent: From> - + IsType<::RuntimeEvent>; + type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. type Call: IsType<::Call> @@ -93,7 +92,7 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum PalletEvent { + pub enum Event { CallWhitelisted { call_hash: T::Hash }, WhitelistedCallRemoved { call_hash: T::Hash }, WhitelistedCallDispatched { call_hash: T::Hash, result: DispatchResultWithPostInfo }, @@ -130,7 +129,7 @@ pub mod pallet { WhitelistedCall::::insert(call_hash, ()); T::PreimageProvider::request_preimage(&call_hash); - Self::deposit_event(PalletEvent::::CallWhitelisted { call_hash }); + Self::deposit_event(Event::::CallWhitelisted { call_hash }); Ok(()) } @@ -143,7 +142,7 @@ pub mod pallet { T::PreimageProvider::unrequest_preimage(&call_hash); - Self::deposit_event(PalletEvent::::WhitelistedCallRemoved { call_hash }); + Self::deposit_event(Event::::WhitelistedCallRemoved { call_hash }); Ok(()) } @@ -229,7 +228,7 @@ impl Pallet { Err(call_err) => call_err.post_info.actual_weight, }; - Self::deposit_event(PalletEvent::::WhitelistedCallDispatched { call_hash, result }); + Self::deposit_event(Event::::WhitelistedCallDispatched { call_hash, result }); call_actual_weight } diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 2f90cd943b28a..5a370f11c8e5d 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -503,8 +503,8 @@ impl frame_support::traits::OriginTrait for Origin { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct RuntimeEvent; -impl From> for RuntimeEvent { - fn from(_evt: frame_system::PalletEvent) -> Self { +impl From> for RuntimeEvent { + fn from(_evt: frame_system::Event) -> Self { unimplemented!("Not required in tests!") } } From e467bfef8ab9201263b3990465db411a884ee23c Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 10:26:01 +0200 Subject: [PATCH 35/63] rename Call to RuntimeCall --- bin/node-template/runtime/src/lib.rs | 4 ++-- .../src/construct_runtime/expand/call.rs | 24 +++++++++---------- .../src/construct_runtime/expand/unsigned.rs | 2 +- .../procedural/src/pallet/expand/call.rs | 8 +++---- .../procedural/src/pallet/parse/call.rs | 8 +++---- .../src/pallet/parse/extra_constants.rs | 2 +- .../procedural/src/pallet/parse/mod.rs | 8 +++---- frame/support/src/dispatch.rs | 4 ++-- frame/support/test/compile_pass/src/lib.rs | 4 ++-- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 9cb6720a7d022..869c1c0f708bf 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -156,7 +156,7 @@ impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The aggregated dispatch type that is available for extrinsics. - type Call = Call; + type Call = RuntimeCall; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. @@ -208,7 +208,7 @@ impl pallet_aura::Config for Runtime { impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type KeyOwnerProofSystem = (); diff --git a/frame/support/procedural/src/construct_runtime/expand/call.rs b/frame/support/procedural/src/construct_runtime/expand/call.rs index 801b69035121d..49ef3ac6d7e57 100644 --- a/frame/support/procedural/src/construct_runtime/expand/call.rs +++ b/frame/support/procedural/src/construct_runtime/expand/call.rs @@ -42,7 +42,7 @@ pub fn expand_outer_dispatch( variant_defs.extend( quote!(#[codec(index = #index)] #name( #scrate::dispatch::CallableCallFor<#name, #runtime> ),), ); - variant_patterns.push(quote!(Call::#name(call))); + variant_patterns.push(quote!(RuntimeCall::#name(call))); pallet_names.push(name); query_call_part_macros.push(quote! { #path::__substrate_call_check::is_call_part_defined!(#name); @@ -59,11 +59,11 @@ pub fn expand_outer_dispatch( #scrate::scale_info::TypeInfo, #scrate::RuntimeDebug, )] - pub enum Call { + pub enum RuntimeCall { #variant_defs } #[cfg(test)] - impl Call { + impl RuntimeCall { /// Return a list of the module names together with their size in memory. pub const fn sizes() -> &'static [( &'static str, usize )] { use #scrate::dispatch::Callable; @@ -71,7 +71,7 @@ pub fn expand_outer_dispatch( &[#( ( stringify!(#pallet_names), - size_of::< <#pallet_names as Callable<#runtime>>::Call >(), + size_of::< <#pallet_names as Callable<#runtime>>::RuntimeCall >(), ), )*] } @@ -98,14 +98,14 @@ pub fn expand_outer_dispatch( } } } - impl #scrate::dispatch::GetDispatchInfo for Call { + impl #scrate::dispatch::GetDispatchInfo for RuntimeCall { fn get_dispatch_info(&self) -> #scrate::dispatch::DispatchInfo { match self { #( #variant_patterns => call.get_dispatch_info(), )* } } } - impl #scrate::dispatch::GetCallMetadata for Call { + impl #scrate::dispatch::GetCallMetadata for RuntimeCall { fn get_call_metadata(&self) -> #scrate::dispatch::CallMetadata { use #scrate::dispatch::GetCallName; match self { @@ -130,16 +130,16 @@ pub fn expand_outer_dispatch( match module { #( stringify!(#pallet_names) => - <<#pallet_names as Callable<#runtime>>::Call + <<#pallet_names as Callable<#runtime>>::RuntimeCall as GetCallName>::get_call_names(), )* _ => unreachable!(), } } } - impl #scrate::dispatch::Dispatchable for Call { + impl #scrate::dispatch::Dispatchable for RuntimeCall { type Origin = Origin; - type Config = Call; + type Config = RuntimeCall; type Info = #scrate::weights::DispatchInfo; type PostInfo = #scrate::weights::PostDispatchInfo; fn dispatch(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo { @@ -152,7 +152,7 @@ pub fn expand_outer_dispatch( #scrate::traits::UnfilteredDispatchable::dispatch_bypass_filter(self, origin) } } - impl #scrate::traits::UnfilteredDispatchable for Call { + impl #scrate::traits::UnfilteredDispatchable for RuntimeCall { type Origin = Origin; fn dispatch_bypass_filter(self, origin: Origin) -> #scrate::dispatch::DispatchResultWithPostInfo { match self { @@ -165,7 +165,7 @@ pub fn expand_outer_dispatch( } #( - impl #scrate::traits::IsSubType<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for Call { + impl #scrate::traits::IsSubType<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for RuntimeCall { #[allow(unreachable_patterns)] fn is_sub_type(&self) -> Option<&#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> { match self { @@ -176,7 +176,7 @@ pub fn expand_outer_dispatch( } } - impl From<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for Call { + impl From<#scrate::dispatch::CallableCallFor<#pallet_names, #runtime>> for RuntimeCall { fn from(call: #scrate::dispatch::CallableCallFor<#pallet_names, #runtime>) -> Self { #variant_patterns } diff --git a/frame/support/procedural/src/construct_runtime/expand/unsigned.rs b/frame/support/procedural/src/construct_runtime/expand/unsigned.rs index c030676802093..908f02fddf393 100644 --- a/frame/support/procedural/src/construct_runtime/expand/unsigned.rs +++ b/frame/support/procedural/src/construct_runtime/expand/unsigned.rs @@ -44,7 +44,7 @@ pub fn expand_outer_validate_unsigned( #( #query_validate_unsigned_part_macros )* impl #scrate::unsigned::ValidateUnsigned for #runtime { - type Call = Call; + type Call = RuntimeCall; fn pre_dispatch(call: &Self::Call) -> Result<(), #scrate::unsigned::TransactionValidityError> { #[allow(unreachable_patterns)] diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index a9468451ad1d4..7da5163897356 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -38,7 +38,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { let type_impl_gen = &def.type_impl_generics(span); let type_decl_bounded_gen = &def.type_decl_bounded_generics(span); let type_use_gen = &def.type_use_generics(span); - let call_ident = syn::Ident::new("Call", span); + let call_ident = syn::Ident::new("RuntimeCall", span); let pallet_ident = &def.pallet_struct.pallet; let fn_name = methods.iter().map(|method| &method.name).collect::>(); @@ -127,7 +127,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { compile_error!(concat!( "`", stringify!($pallet_name), - "` does not have #[pallet::call] defined, perhaps you should remove `Call` from \ + "` does not have #[pallet::call] defined, perhaps you should remove `RuntimeCall` from \ construct_runtime?", )); } @@ -290,7 +290,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { }, )* Self::__Ignore(_, _) => { - let _ = origin; // Use origin for empty Call enum + let _ = origin; // Use origin for empty RuntimeCall enum unreachable!("__PhantomItem cannot be used."); }, } @@ -300,7 +300,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { impl<#type_impl_gen> #frame_support::dispatch::Callable for #pallet_ident<#type_use_gen> #where_clause { - type Call = #call_ident<#type_use_gen>; + type RuntimeCall = #call_ident<#type_use_gen>; } impl<#type_impl_gen> #pallet_ident<#type_use_gen> #where_clause { diff --git a/frame/support/procedural/src/pallet/parse/call.rs b/frame/support/procedural/src/pallet/parse/call.rs index 336e08c3d39b7..ddff308357e46 100644 --- a/frame/support/procedural/src/pallet/parse/call.rs +++ b/frame/support/procedural/src/pallet/parse/call.rs @@ -23,7 +23,7 @@ use syn::spanned::Spanned; /// List of additional token to be used for parsing. mod keyword { - syn::custom_keyword!(Call); + syn::custom_keyword!(RuntimeCall); syn::custom_keyword!(OriginFor); syn::custom_keyword!(weight); syn::custom_keyword!(call_index); @@ -57,7 +57,7 @@ pub struct CallVariantDef { pub args: Vec<(bool, syn::Ident, Box)>, /// Weight formula. pub weight: syn::Expr, - /// Call index of the dispatchable. + /// RuntimeCall index of the dispatchable. pub call_index: u8, /// Docs, used for metadata. pub docs: Vec, @@ -237,7 +237,7 @@ impl CallDef { Some(i) => i, None => last_index.map_or(Some(0), |idx| idx.checked_add(1)).ok_or_else(|| { - let msg = "Call index doesn't fit into u8, index is 256"; + let msg = "RuntimeCall index doesn't fit into u8, index is 256"; syn::Error::new(method.sig.span(), msg) })?, }; @@ -245,7 +245,7 @@ impl CallDef { if let Some(used_fn) = indices.insert(final_index, method.sig.ident.clone()) { let msg = format!( - "Call indices are conflicting: Both functions {} and {} are at index {}", + "RuntimeCall indices are conflicting: Both functions {} and {} are at index {}", used_fn, method.sig.ident, final_index, ); let mut err = syn::Error::new(used_fn.span(), &msg); diff --git a/frame/support/procedural/src/pallet/parse/extra_constants.rs b/frame/support/procedural/src/pallet/parse/extra_constants.rs index d8622da08461b..5e0ff68c8e9a6 100644 --- a/frame/support/procedural/src/pallet/parse/extra_constants.rs +++ b/frame/support/procedural/src/pallet/parse/extra_constants.rs @@ -22,7 +22,7 @@ use syn::spanned::Spanned; /// List of additional token to be used for parsing. mod keyword { syn::custom_keyword!(DispatchResultWithPostInfo); - syn::custom_keyword!(Call); + syn::custom_keyword!(RuntimeCall); syn::custom_keyword!(OriginFor); syn::custom_keyword!(weight); syn::custom_keyword!(compact); diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index 763daa2c07421..e9bd35b1fff72 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -105,7 +105,7 @@ impl Def { let m = hooks::HooksDef::try_from(span, index, item)?; hooks = Some(m); }, - Some(PalletAttr::Call(span)) if call.is_none() => + Some(PalletAttr::RuntimeCall(span)) if call.is_none() => call = Some(call::CallDef::try_from(span, index, item)?), Some(PalletAttr::Error(span)) if error.is_none() => error = Some(error::ErrorDef::try_from(span, index, item)?), @@ -391,7 +391,7 @@ enum PalletAttr { Config(proc_macro2::Span), Pallet(proc_macro2::Span), Hooks(proc_macro2::Span), - Call(proc_macro2::Span), + RuntimeCall(proc_macro2::Span), Error(proc_macro2::Span), RuntimeEvent(proc_macro2::Span), Origin(proc_macro2::Span), @@ -410,7 +410,7 @@ impl PalletAttr { Self::Config(span) => *span, Self::Pallet(span) => *span, Self::Hooks(span) => *span, - Self::Call(span) => *span, + Self::RuntimeCall(span) => *span, Self::Error(span) => *span, Self::RuntimeEvent(span) => *span, Self::Origin(span) => *span, @@ -441,7 +441,7 @@ impl syn::parse::Parse for PalletAttr { } else if lookahead.peek(keyword::hooks) { Ok(PalletAttr::Hooks(content.parse::()?.span())) } else if lookahead.peek(keyword::call) { - Ok(PalletAttr::Call(content.parse::()?.span())) + Ok(PalletAttr::RuntimeCall(content.parse::()?.span())) } else if lookahead.peek(keyword::error) { Ok(PalletAttr::Error(content.parse::()?.span())) } else if lookahead.peek(keyword::event) { diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index c9c089fd1e8d6..47e14064171dc 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -56,12 +56,12 @@ pub type DispatchErrorWithPostInfo = /// Serializable version of pallet dispatchable. pub trait Callable { - type Call: UnfilteredDispatchable + Codec + Clone + PartialEq + Eq; + type RuntimeCall: UnfilteredDispatchable + Codec + Clone + PartialEq + Eq; } // dirty hack to work around serde_derive issue // https://github.com/rust-lang/rust/issues/51331 -pub type CallableCallFor = >::Call; +pub type CallableCallFor = >::RuntimeCall; /// Origin for the System pallet. #[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)] diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index ff1013348c94f..fe1e774205e94 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -70,7 +70,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = Call; + type Call = RuntimeCall; type DbWeight = (); type OnNewAccount = (); type OnKilledAccount = (); @@ -82,7 +82,7 @@ impl frame_system::Config for Runtime { pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; construct_runtime!( pub enum Runtime where From d5b79755ca0825946b196924ec55d860f3b347ac Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 12:03:52 +0200 Subject: [PATCH 36/63] renamed at wrong places :P --- .../procedural/src/construct_runtime/expand/call.rs | 4 ++-- frame/support/procedural/src/pallet/expand/call.rs | 8 ++++---- frame/support/procedural/src/pallet/parse/call.rs | 8 ++++---- .../procedural/src/pallet/parse/extra_constants.rs | 2 +- frame/support/procedural/src/pallet/parse/mod.rs | 8 ++++---- frame/support/src/dispatch.rs | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/frame/support/procedural/src/construct_runtime/expand/call.rs b/frame/support/procedural/src/construct_runtime/expand/call.rs index 49ef3ac6d7e57..bce550b37cb60 100644 --- a/frame/support/procedural/src/construct_runtime/expand/call.rs +++ b/frame/support/procedural/src/construct_runtime/expand/call.rs @@ -71,7 +71,7 @@ pub fn expand_outer_dispatch( &[#( ( stringify!(#pallet_names), - size_of::< <#pallet_names as Callable<#runtime>>::RuntimeCall >(), + size_of::< <#pallet_names as Callable<#runtime>>::Call >(), ), )*] } @@ -130,7 +130,7 @@ pub fn expand_outer_dispatch( match module { #( stringify!(#pallet_names) => - <<#pallet_names as Callable<#runtime>>::RuntimeCall + <<#pallet_names as Callable<#runtime>>::Call as GetCallName>::get_call_names(), )* _ => unreachable!(), diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index 7da5163897356..a9468451ad1d4 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -38,7 +38,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { let type_impl_gen = &def.type_impl_generics(span); let type_decl_bounded_gen = &def.type_decl_bounded_generics(span); let type_use_gen = &def.type_use_generics(span); - let call_ident = syn::Ident::new("RuntimeCall", span); + let call_ident = syn::Ident::new("Call", span); let pallet_ident = &def.pallet_struct.pallet; let fn_name = methods.iter().map(|method| &method.name).collect::>(); @@ -127,7 +127,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { compile_error!(concat!( "`", stringify!($pallet_name), - "` does not have #[pallet::call] defined, perhaps you should remove `RuntimeCall` from \ + "` does not have #[pallet::call] defined, perhaps you should remove `Call` from \ construct_runtime?", )); } @@ -290,7 +290,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { }, )* Self::__Ignore(_, _) => { - let _ = origin; // Use origin for empty RuntimeCall enum + let _ = origin; // Use origin for empty Call enum unreachable!("__PhantomItem cannot be used."); }, } @@ -300,7 +300,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { impl<#type_impl_gen> #frame_support::dispatch::Callable for #pallet_ident<#type_use_gen> #where_clause { - type RuntimeCall = #call_ident<#type_use_gen>; + type Call = #call_ident<#type_use_gen>; } impl<#type_impl_gen> #pallet_ident<#type_use_gen> #where_clause { diff --git a/frame/support/procedural/src/pallet/parse/call.rs b/frame/support/procedural/src/pallet/parse/call.rs index ddff308357e46..336e08c3d39b7 100644 --- a/frame/support/procedural/src/pallet/parse/call.rs +++ b/frame/support/procedural/src/pallet/parse/call.rs @@ -23,7 +23,7 @@ use syn::spanned::Spanned; /// List of additional token to be used for parsing. mod keyword { - syn::custom_keyword!(RuntimeCall); + syn::custom_keyword!(Call); syn::custom_keyword!(OriginFor); syn::custom_keyword!(weight); syn::custom_keyword!(call_index); @@ -57,7 +57,7 @@ pub struct CallVariantDef { pub args: Vec<(bool, syn::Ident, Box)>, /// Weight formula. pub weight: syn::Expr, - /// RuntimeCall index of the dispatchable. + /// Call index of the dispatchable. pub call_index: u8, /// Docs, used for metadata. pub docs: Vec, @@ -237,7 +237,7 @@ impl CallDef { Some(i) => i, None => last_index.map_or(Some(0), |idx| idx.checked_add(1)).ok_or_else(|| { - let msg = "RuntimeCall index doesn't fit into u8, index is 256"; + let msg = "Call index doesn't fit into u8, index is 256"; syn::Error::new(method.sig.span(), msg) })?, }; @@ -245,7 +245,7 @@ impl CallDef { if let Some(used_fn) = indices.insert(final_index, method.sig.ident.clone()) { let msg = format!( - "RuntimeCall indices are conflicting: Both functions {} and {} are at index {}", + "Call indices are conflicting: Both functions {} and {} are at index {}", used_fn, method.sig.ident, final_index, ); let mut err = syn::Error::new(used_fn.span(), &msg); diff --git a/frame/support/procedural/src/pallet/parse/extra_constants.rs b/frame/support/procedural/src/pallet/parse/extra_constants.rs index 5e0ff68c8e9a6..d8622da08461b 100644 --- a/frame/support/procedural/src/pallet/parse/extra_constants.rs +++ b/frame/support/procedural/src/pallet/parse/extra_constants.rs @@ -22,7 +22,7 @@ use syn::spanned::Spanned; /// List of additional token to be used for parsing. mod keyword { syn::custom_keyword!(DispatchResultWithPostInfo); - syn::custom_keyword!(RuntimeCall); + syn::custom_keyword!(Call); syn::custom_keyword!(OriginFor); syn::custom_keyword!(weight); syn::custom_keyword!(compact); diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index e9bd35b1fff72..763daa2c07421 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -105,7 +105,7 @@ impl Def { let m = hooks::HooksDef::try_from(span, index, item)?; hooks = Some(m); }, - Some(PalletAttr::RuntimeCall(span)) if call.is_none() => + Some(PalletAttr::Call(span)) if call.is_none() => call = Some(call::CallDef::try_from(span, index, item)?), Some(PalletAttr::Error(span)) if error.is_none() => error = Some(error::ErrorDef::try_from(span, index, item)?), @@ -391,7 +391,7 @@ enum PalletAttr { Config(proc_macro2::Span), Pallet(proc_macro2::Span), Hooks(proc_macro2::Span), - RuntimeCall(proc_macro2::Span), + Call(proc_macro2::Span), Error(proc_macro2::Span), RuntimeEvent(proc_macro2::Span), Origin(proc_macro2::Span), @@ -410,7 +410,7 @@ impl PalletAttr { Self::Config(span) => *span, Self::Pallet(span) => *span, Self::Hooks(span) => *span, - Self::RuntimeCall(span) => *span, + Self::Call(span) => *span, Self::Error(span) => *span, Self::RuntimeEvent(span) => *span, Self::Origin(span) => *span, @@ -441,7 +441,7 @@ impl syn::parse::Parse for PalletAttr { } else if lookahead.peek(keyword::hooks) { Ok(PalletAttr::Hooks(content.parse::()?.span())) } else if lookahead.peek(keyword::call) { - Ok(PalletAttr::RuntimeCall(content.parse::()?.span())) + Ok(PalletAttr::Call(content.parse::()?.span())) } else if lookahead.peek(keyword::error) { Ok(PalletAttr::Error(content.parse::()?.span())) } else if lookahead.peek(keyword::event) { diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index 47e14064171dc..c9c089fd1e8d6 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -56,12 +56,12 @@ pub type DispatchErrorWithPostInfo = /// Serializable version of pallet dispatchable. pub trait Callable { - type RuntimeCall: UnfilteredDispatchable + Codec + Clone + PartialEq + Eq; + type Call: UnfilteredDispatchable + Codec + Clone + PartialEq + Eq; } // dirty hack to work around serde_derive issue // https://github.com/rust-lang/rust/issues/51331 -pub type CallableCallFor = >::RuntimeCall; +pub type CallableCallFor = >::Call; /// Origin for the System pallet. #[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)] From 795553f72d0a64939f147d7df40463cf50e3dc17 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 12:49:39 +0200 Subject: [PATCH 37/63] rename Call --- .../pallets/template/src/mock.rs | 2 +- bin/node-template/runtime/src/lib.rs | 12 +-- bin/node/cli/src/service.rs | 4 +- bin/node/executor/benches/bench.rs | 4 +- bin/node/executor/tests/basic.rs | 12 +-- bin/node/executor/tests/fees.rs | 6 +- bin/node/runtime/src/impls.rs | 8 +- bin/node/runtime/src/lib.rs | 90 +++++++++---------- bin/node/testing/src/bench.rs | 6 +- frame/alliance/src/mock.rs | 6 +- frame/assets/src/mock.rs | 2 +- frame/atomic-swap/src/tests.rs | 2 +- frame/aura/src/mock.rs | 2 +- frame/authority-discovery/src/lib.rs | 2 +- frame/authorship/src/lib.rs | 2 +- frame/babe/src/mock.rs | 4 +- frame/bags-list/src/mock.rs | 2 +- frame/balances/src/tests.rs | 2 +- frame/balances/src/tests_composite.rs | 2 +- frame/balances/src/tests_local.rs | 2 +- frame/balances/src/tests_reentrancy.rs | 2 +- frame/beefy-mmr/src/mock.rs | 2 +- frame/beefy/src/mock.rs | 2 +- frame/benchmarking/src/baseline.rs | 2 +- frame/benchmarking/src/tests.rs | 2 +- frame/benchmarking/src/tests_instance.rs | 2 +- frame/bounties/src/tests.rs | 2 +- frame/child-bounties/src/tests.rs | 2 +- frame/collective/src/tests.rs | 10 +-- frame/contracts/src/exec.rs | 4 +- frame/contracts/src/tests.rs | 6 +- frame/conviction-voting/src/tests.rs | 4 +- frame/democracy/src/tests.rs | 10 +-- .../election-provider-multi-phase/src/mock.rs | 4 +- .../election-provider-support/src/onchain.rs | 2 +- frame/elections-phragmen/src/lib.rs | 2 +- frame/examples/basic/src/tests.rs | 2 +- frame/examples/offchain-worker/src/tests.rs | 6 +- frame/examples/parallel/src/tests.rs | 4 +- frame/executive/src/lib.rs | 18 ++-- frame/gilt/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 6 +- frame/identity/src/tests.rs | 2 +- frame/im-online/src/mock.rs | 4 +- frame/indices/src/mock.rs | 2 +- frame/lottery/src/mock.rs | 4 +- frame/lottery/src/tests.rs | 52 +++++------ frame/membership/src/lib.rs | 2 +- frame/merkle-mountain-range/src/mock.rs | 2 +- frame/multisig/src/tests.rs | 8 +- frame/nicks/src/lib.rs | 2 +- frame/node-authorization/src/mock.rs | 2 +- .../nomination-pools/benchmarking/src/mock.rs | 2 +- frame/nomination-pools/src/mock.rs | 2 +- .../nomination-pools/test-staking/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 4 +- frame/offences/src/mock.rs | 2 +- frame/preimage/src/mock.rs | 2 +- frame/proxy/src/tests.rs | 12 +-- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/ranked-collective/src/tests.rs | 2 +- frame/recovery/src/mock.rs | 4 +- frame/recovery/src/tests.rs | 4 +- frame/referenda/src/mock.rs | 12 +-- frame/remark/src/mock.rs | 2 +- frame/scheduler/src/mock.rs | 4 +- frame/scored-pool/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/session/src/mock.rs | 2 +- frame/society/src/mock.rs | 2 +- frame/staking/src/mock.rs | 2 +- frame/staking/src/tests.rs | 10 +-- frame/state-trie-migration/src/lib.rs | 2 +- frame/sudo/src/mock.rs | 4 +- frame/support/test/tests/construct_runtime.rs | 2 +- .../no_std_genesis_config.rs | 2 +- .../pallet_error_too_large.rs | 2 +- .../undefined_call_part.rs | 2 +- .../undefined_event_part.rs | 2 +- .../undefined_genesis_config_part.rs | 2 +- .../undefined_inherent_part.rs | 2 +- .../undefined_origin_part.rs | 2 +- .../undefined_validate_unsigned_part.rs | 2 +- frame/support/test/tests/instance.rs | 2 +- frame/support/test/tests/issue2219.rs | 2 +- frame/support/test/tests/origin.rs | 2 +- frame/support/test/tests/pallet.rs | 2 +- .../test/tests/pallet_compatibility.rs | 2 +- .../tests/pallet_compatibility_instance.rs | 2 +- frame/support/test/tests/pallet_instance.rs | 2 +- .../tests/pallet_with_name_trait_is_valid.rs | 2 +- frame/support/test/tests/storage_layers.rs | 2 +- frame/system/benches/bench.rs | 2 +- frame/system/benchmarking/src/mock.rs | 2 +- frame/system/src/mock.rs | 2 +- frame/system/src/offchain.rs | 2 +- frame/timestamp/src/mock.rs | 2 +- frame/tips/src/tests.rs | 2 +- .../asset-tx-payment/src/tests.rs | 4 +- frame/transaction-payment/src/lib.rs | 8 +- frame/transaction-storage/src/mock.rs | 4 +- frame/treasury/src/tests.rs | 2 +- frame/uniques/src/mock.rs | 2 +- frame/uniques/src/tests.rs | 4 +- frame/utility/src/tests.rs | 16 ++-- frame/vesting/src/mock.rs | 2 +- frame/whitelist/src/mock.rs | 4 +- 107 files changed, 262 insertions(+), 262 deletions(-) diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index f506be56a84d6..e111d59c1f8eb 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -28,7 +28,7 @@ impl system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 869c1c0f708bf..babee9893a154 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -262,7 +262,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; } /// Configure the pallet-template in pallets/template. @@ -310,9 +310,9 @@ pub type SignedExtra = ( ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -468,17 +468,17 @@ impl_runtime_apis! { } } - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi for Runtime { fn query_call_info( - call: Call, + call: RuntimeCall, len: u32, ) -> pallet_transaction_payment::RuntimeDispatchInfo { TransactionPayment::query_call_info(call, len) } fn query_call_fee_details( - call: Call, + call: RuntimeCall, len: u32, ) -> pallet_transaction_payment::FeeDetails { TransactionPayment::query_call_fee_details(call, len) diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index b20a3ac59a96a..698d537e6bb80 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -570,7 +570,7 @@ mod tests { use codec::Encode; use kitchensink_runtime::{ constants::{currency::CENTS, time::SLOT_DURATION}, - Address, BalancesCall, Call, UncheckedExtrinsic, + Address, BalancesCall, RuntimeCall, UncheckedExtrinsic, }; use node_primitives::{Block, DigestItem, Signature}; use sc_client_api::BlockBackend; @@ -763,7 +763,7 @@ mod tests { let signer = charlie.clone(); let function = - Call::Balances(BalancesCall::transfer { dest: to.into(), value: amount }); + RuntimeCall::Balances(BalancesCall::transfer { dest: to.into(), value: amount }); let check_non_zero_sender = frame_system::CheckNonZeroSender::new(); let check_spec_version = frame_system::CheckSpecVersion::new(); diff --git a/bin/node/executor/benches/bench.rs b/bin/node/executor/benches/bench.rs index a1d31a5a966db..4cd0e6d99ced5 100644 --- a/bin/node/executor/benches/bench.rs +++ b/bin/node/executor/benches/bench.rs @@ -19,7 +19,7 @@ use codec::{Decode, Encode}; use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; use frame_support::Hashable; use kitchensink_runtime::{ - constants::currency::*, Block, BuildStorage, Call, CheckedExtrinsic, GenesisConfig, Header, + constants::currency::*, Block, BuildStorage, RuntimeCall, CheckedExtrinsic, GenesisConfig, Header, UncheckedExtrinsic, }; use node_executor::ExecutorDispatch; @@ -168,7 +168,7 @@ fn test_blocks( }]; block1_extrinsics.extend((0..20).map(|i| CheckedExtrinsic { signed: Some((alice(), signed_extra(i, 0))), - function: Call::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer { dest: bob().into(), value: 1 * DOLLARS, }), diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index 235cb8d5ab98f..7606b291d9143 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -28,7 +28,7 @@ use sp_runtime::{ use kitchensink_runtime::{ constants::{currency::*, time::SLOT_DURATION}, - Balances, Call, CheckedExtrinsic, Header, Runtime, RuntimeEvent, System, TransactionPayment, + Balances, RuntimeCall, CheckedExtrinsic, Header, Runtime, RuntimeEvent, System, TransactionPayment, UncheckedExtrinsic, }; use node_primitives::{Balance, Hash}; @@ -67,7 +67,7 @@ fn transfer_fee(extrinsic: &E) -> Balance { fn xt() -> UncheckedExtrinsic { sign(CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), - function: Call::Balances(default_transfer_call()), + function: RuntimeCall::Balances(default_transfer_call()), }) } @@ -88,7 +88,7 @@ fn changes_trie_block() -> (Vec, Hash) { }, CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), - function: Call::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer { dest: bob().into(), value: 69 * DOLLARS, }), @@ -115,7 +115,7 @@ fn blocks() -> ((Vec, Hash), (Vec, Hash)) { }, CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), - function: Call::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer { dest: bob().into(), value: 69 * DOLLARS, }), @@ -135,14 +135,14 @@ fn blocks() -> ((Vec, Hash), (Vec, Hash)) { }, CheckedExtrinsic { signed: Some((bob(), signed_extra(0, 0))), - function: Call::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer { dest: alice().into(), value: 5 * DOLLARS, }), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(1, 0))), - function: Call::Balances(pallet_balances::Call::transfer { + function: RuntimeCall::Balances(pallet_balances::Call::transfer { dest: bob().into(), value: 15 * DOLLARS, }), diff --git a/bin/node/executor/tests/fees.rs b/bin/node/executor/tests/fees.rs index 296d1d8e28798..a2f755d81ad2d 100644 --- a/bin/node/executor/tests/fees.rs +++ b/bin/node/executor/tests/fees.rs @@ -22,7 +22,7 @@ use frame_support::{ }; use kitchensink_runtime::{ constants::{currency::*, time::SLOT_DURATION}, - Balances, Call, CheckedExtrinsic, Multiplier, Runtime, TransactionByteFee, TransactionPayment, + Balances, RuntimeCall, CheckedExtrinsic, Multiplier, Runtime, TransactionByteFee, TransactionPayment, }; use node_primitives::Balance; use node_testing::keyring::*; @@ -163,7 +163,7 @@ fn transaction_fee_is_correct() { let tip = 1_000_000; let xt = sign(CheckedExtrinsic { signed: Some((alice(), signed_extra(0, tip))), - function: Call::Balances(default_transfer_call()), + function: RuntimeCall::Balances(default_transfer_call()), }); let r = executor_call:: _>( @@ -241,7 +241,7 @@ 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 { + function: RuntimeCall::Balances(pallet_balances::Call::transfer { dest: bob().into(), value: 0, }), diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index eaf872d6f3fec..f5dafa9c727b6 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -18,7 +18,7 @@ //! Some configurable implementations as associated type for the substrate runtime. use crate::{ - AccountId, AllianceMotion, Assets, Authorship, Balances, Call, Hash, NegativeImbalance, Runtime, + AccountId, AllianceMotion, Assets, Authorship, Balances, RuntimeCall, Hash, NegativeImbalance, Runtime, }; use frame_support::{ pallet_prelude::*, @@ -77,11 +77,11 @@ impl IdentityVerifier for AllianceIdentityVerifier { } pub struct AllianceProposalProvider; -impl ProposalProvider for AllianceProposalProvider { +impl ProposalProvider for AllianceProposalProvider { fn propose_proposal( who: AccountId, threshold: u32, - proposal: Box, + proposal: Box, length_bound: u32, ) -> Result<(u32, u32), DispatchError> { AllianceMotion::do_propose_proposed(who, threshold, proposal, length_bound) @@ -109,7 +109,7 @@ impl ProposalProvider for AllianceProposalProvider { AllianceMotion::do_close(proposal_hash, proposal_index, proposal_weight_bound, length_bound) } - fn proposal_of(proposal_hash: Hash) -> Option { + fn proposal_of(proposal_hash: Hash) -> Option { AllianceMotion::proposal_of(proposal_hash) } } diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index e7f479fd98180..587dfde4b113c 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -205,7 +205,7 @@ impl frame_system::Config for Runtime { type BlockLength = RuntimeBlockLength; type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = Index; type BlockNumber = BlockNumber; type Hash = Hash; @@ -230,7 +230,7 @@ impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = pallet_utility::weights::SubstrateWeight; } @@ -244,7 +244,7 @@ parameter_types! { impl pallet_multisig::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -286,25 +286,25 @@ impl Default for ProxyType { Self::Any } } -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { match self { ProxyType::Any => true, ProxyType::NonTransfer => !matches!( c, - Call::Balances(..) | - Call::Assets(..) | Call::Uniques(..) | - Call::Vesting(pallet_vesting::Call::vested_transfer { .. }) | - Call::Indices(pallet_indices::Call::transfer { .. }) + RuntimeCall::Balances(..) | + RuntimeCall::Assets(..) | RuntimeCall::Uniques(..) | + RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) | + RuntimeCall::Indices(pallet_indices::Call::transfer { .. }) ), ProxyType::Governance => matches!( c, - Call::Democracy(..) | - Call::Council(..) | Call::Society(..) | - Call::TechnicalCommittee(..) | - Call::Elections(..) | Call::Treasury(..) + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | RuntimeCall::Society(..) | + RuntimeCall::TechnicalCommittee(..) | + RuntimeCall::Elections(..) | RuntimeCall::Treasury(..) ), - ProxyType::Staking => matches!(c, Call::Staking(..)), + ProxyType::Staking => matches!(c, RuntimeCall::Staking(..)), } } fn is_superset(&self, o: &Self) -> bool { @@ -320,7 +320,7 @@ impl InstanceFilter for ProxyType { impl pallet_proxy::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -344,7 +344,7 @@ impl pallet_scheduler::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = Call; + type Call = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<50>; @@ -827,7 +827,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; - type Call = Call; + type Call = RuntimeCall; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -846,7 +846,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; - type Call = Call; + type Call = RuntimeCall; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -889,7 +889,7 @@ parameter_types! { } impl pallet_democracy::Config for Runtime { - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type Currency = Balances; type EnactmentPeriod = EnactmentPeriod; @@ -948,7 +948,7 @@ parameter_types! { type CouncilCollective = pallet_collective::Instance1; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = CouncilMotionDuration; type MaxProposals = CouncilMaxProposals; @@ -1005,7 +1005,7 @@ parameter_types! { type TechnicalCollective = pallet_collective::Instance2; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = TechnicalMotionDuration; type MaxProposals = TechnicalMaxProposals; @@ -1137,7 +1137,7 @@ impl pallet_contracts::Config for Runtime { type Randomness = RandomnessCollectiveFlip; type Currency = Balances; type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; /// The safest default is to allow no calls at all. /// /// Runtimes should whitelist dispatchables that are allowed to be called from contracts @@ -1163,7 +1163,7 @@ impl pallet_contracts::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; } parameter_types! { @@ -1178,14 +1178,14 @@ parameter_types! { impl frame_system::offchain::CreateSignedTransaction for Runtime where - Call: From, + RuntimeCall: From, { fn create_transaction>( - call: Call, + call: RuntimeCall, public: ::Signer, account: AccountId, nonce: Index, - ) -> Option<(Call, ::SignaturePayload)> { + ) -> Option<(RuntimeCall, ::SignaturePayload)> { let tip = 0; // take the biggest period possible. let period = @@ -1225,10 +1225,10 @@ impl frame_system::offchain::SigningTypes for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - Call: From, + RuntimeCall: From, { type Extrinsic = UncheckedExtrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } impl pallet_im_online::Config for Runtime { @@ -1256,7 +1256,7 @@ impl pallet_authority_discovery::Config for Runtime { impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type KeyOwnerProofSystem = Historical; @@ -1312,7 +1312,7 @@ parameter_types! { impl pallet_recovery::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = pallet_recovery::weights::SubstrateWeight; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; @@ -1383,7 +1383,7 @@ parameter_types! { impl pallet_lottery::Config for Runtime { type PalletId = LotteryPalletId; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; type RuntimeEvent = RuntimeEvent; @@ -1479,7 +1479,7 @@ impl pallet_uniques::Config for Runtime { impl pallet_transaction_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; - type Call = Call; + type Call = RuntimeCall; type FeeDestination = (); type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight; type MaxBlockTransactions = @@ -1490,7 +1490,7 @@ impl pallet_transaction_storage::Config for Runtime { impl pallet_whitelist::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type PreimageProvider = Preimage; @@ -1527,7 +1527,7 @@ parameter_types! { type AllianceCollective = pallet_collective::Instance3; impl pallet_collective::Config for Runtime { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = AllianceMotionDuration; type MaxProposals = AllianceMaxProposals; @@ -1545,7 +1545,7 @@ parameter_types! { impl pallet_alliance::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Proposal = Call; + type Proposal = RuntimeCall; type AdminOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionMoreThan, @@ -1671,11 +1671,11 @@ pub type SignedExtra = ( ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; /// The payload being signed in transactions. -pub type SignedPayload = generic::SignedPayload; +pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; +pub type CheckedExtrinsic = generic::CheckedExtrinsic; /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< Runtime, @@ -1970,13 +1970,13 @@ impl_runtime_apis! { } } - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi for Runtime { - fn query_call_info(call: Call, len: u32) -> RuntimeDispatchInfo { + fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo { TransactionPayment::query_call_info(call, len) } - fn query_call_fee_details(call: Call, len: u32) -> FeeDetails { + fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails { TransactionPayment::query_call_fee_details(call, len) } } @@ -2158,7 +2158,7 @@ mod tests { fn validate_transaction_submitter_bounds() { fn is_submit_signed_transaction() where - T: CreateSignedTransaction, + T: CreateSignedTransaction, { } @@ -2178,11 +2178,11 @@ mod tests { #[test] fn call_size() { - let size = core::mem::size_of::(); + let size = core::mem::size_of::(); assert!( size <= 208, - "size of Call {} is more than 208 bytes: some calls have too big arguments, use Box to reduce the - size of Call. + "size of RuntimeCall {} is more than 208 bytes: some calls have too big arguments, use Box to reduce the + size of RuntimeCall. If the limit is too strong, maybe consider increase the limit to 300.", size, ); diff --git a/bin/node/testing/src/bench.rs b/bin/node/testing/src/bench.rs index 534f0a4f09732..ca650a597a2c2 100644 --- a/bin/node/testing/src/bench.rs +++ b/bin/node/testing/src/bench.rs @@ -35,7 +35,7 @@ use crate::{ use codec::{Decode, Encode}; use futures::executor; use kitchensink_runtime::{ - constants::currency::DOLLARS, AccountId, BalancesCall, Call, CheckedExtrinsic, MinimumPeriod, + constants::currency::DOLLARS, AccountId, BalancesCall, RuntimeCall, CheckedExtrinsic, MinimumPeriod, Signature, SystemCall, UncheckedExtrinsic, }; use node_primitives::Block; @@ -308,12 +308,12 @@ impl<'a> Iterator for BlockContentIterator<'a> { )), function: match self.content.block_type { BlockType::RandomTransfersKeepAlive => - Call::Balances(BalancesCall::transfer_keep_alive { + RuntimeCall::Balances(BalancesCall::transfer_keep_alive { dest: sp_runtime::MultiAddress::Id(receiver), value: kitchensink_runtime::ExistentialDeposit::get() + 1, }), BlockType::RandomTransfersReaping => { - Call::Balances(BalancesCall::transfer { + RuntimeCall::Balances(BalancesCall::transfer { dest: sp_runtime::MultiAddress::Id(receiver), // Transfer so that ending balance would be 1 less than existential // deposit so that we kill the sender account. diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 6805686cd115b..aaa1971d233ac 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -45,7 +45,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -91,7 +91,7 @@ parameter_types! { type AllianceCollective = pallet_collective::Instance1; impl pallet_collective::Config for Test { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = MotionDuration; type MaxProposals = MaxProposals; @@ -202,7 +202,7 @@ parameter_types! { } impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Proposal = Call; + type Proposal = RuntimeCall; type AdminOrigin = EnsureSignedBy; type MembershipManager = EnsureSignedBy; type AnnouncementOrigin = EnsureSignedBy; diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index a8c115b577aec..b440826841733 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -50,7 +50,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index 962ee25ebf820..eaac9ebf91613 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -41,7 +41,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index c5de7c5ea0899..4385d04076914 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -60,7 +60,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index 6b1956e7d2fdb..eff269d45280e 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -238,7 +238,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AuthorityId; diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index f82a665671779..e5b1e9dedeb3d 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -471,7 +471,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 8352f65ebe8d2..a03d92e20dce5 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -77,7 +77,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Version = (); type Hashing = sp_runtime::traits::BlakeTwo256; @@ -100,7 +100,7 @@ impl frame_system::offchain::SendTransactionTypes for Test where Call: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = TestXt; } diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index 1c887d77dd3ee..56a8a63ac1c7b 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 0c59bc6d9d499..27723fd8d72ad 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -39,7 +39,7 @@ macro_rules! decl_tests { 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 }); + &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 { diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs index e53dfbd8c91a0..ddac89dbd6f2e 100644 --- a/frame/balances/src/tests_composite.rs +++ b/frame/balances/src/tests_composite.rs @@ -57,7 +57,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index bdfc1fb2a0aeb..41f310f2c4847 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index cef058f7efb4e..485c07ec2897f 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -62,7 +62,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 9b0e1d01abdf9..63c77ba39ba0b 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 348f8649d97a0..2b15042430089 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index 5638eca54c188..e05c016df8cb1 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -179,7 +179,7 @@ pub mod mock { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index 7c643c6476e19..b9b9a1e038890 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -93,7 +93,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 991eab17ba6f3..2ca04e32383d3 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -95,7 +95,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index fe0bc31604526..7100ff8cd4c6c 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -72,7 +72,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 7189f0f41dc40..4d75770b6065b 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -75,7 +75,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 7d7c3eee1e522..fe88a938d124f 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -100,7 +100,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -120,7 +120,7 @@ impl frame_system::Config for Test { } impl Config for Test { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; @@ -130,7 +130,7 @@ impl Config for Test { } impl Config for Test { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; @@ -144,7 +144,7 @@ impl mock_democracy::Config for Test { } impl Config for Test { type Origin = Origin; - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type MotionDuration = ConstU64<3>; type MaxProposals = MaxProposals; @@ -910,7 +910,7 @@ fn motions_reproposing_disapproved_works() { #[test] fn motions_approval_with_enough_votes_and_lower_voting_threshold_works() { new_test_ext().execute_with(|| { - let proposal = Call::Democracy(mock_democracy::Call::external_propose_majority {}); + let proposal = RuntimeCall::Democracy(mock_democracy::Call::external_propose_majority {}); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index eb6c3b11dd756..0b4f7db9ecc36 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -2616,7 +2616,7 @@ mod tests { Call::System(SysCall::remark_with_event { remark: b"Hello".to_vec() }); // transfers are disallowed by the `TestFiler` (see below) - let forbidden_call = Call::Balances(BalanceCall::transfer { dest: CHARLIE, value: 22 }); + let forbidden_call = RuntimeCall::Balances(BalanceCall::transfer { dest: CHARLIE, value: 22 }); // simple cases: direct call assert_err!( @@ -2636,7 +2636,7 @@ mod tests { }); TestFilter::set_filter(|call| match call { - Call::Balances(pallet_balances::Call::transfer { .. }) => false, + RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => false, _ => true, }); diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index f884b83f78e11..2472f6e83bf79 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -276,7 +276,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; @@ -314,7 +314,7 @@ impl pallet_timestamp::Config for Test { } impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -360,7 +360,7 @@ impl Config for Test { type Randomness = Randomness; type Currency = Balances; type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type CallFilter = TestFilter; type CallStack = [Frame; 31]; type WeightPrice = Self; diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 38d1efd4e63d6..f4c31c397c18b 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -51,7 +51,7 @@ frame_support::construct_runtime!( pub struct BaseFilter; impl Contains for BaseFilter { fn contains(call: &Call) -> bool { - !matches!(call, &Call::Balances(pallet_balances::Call::set_balance { .. })) + !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) } } @@ -67,7 +67,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index e6611e6d7f68f..71cbe027d796d 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -72,7 +72,7 @@ frame_support::construct_runtime!( pub struct BaseFilter; impl Contains for BaseFilter { fn contains(call: &Call) -> bool { - !matches!(call, &Call::Balances(pallet_balances::Call::set_balance { .. })) + !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) } } @@ -88,7 +88,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -113,7 +113,7 @@ impl pallet_scheduler::Config for Test { type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = Call; + type Call = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = (); @@ -156,7 +156,7 @@ impl SortedMembers for OneToFive { } impl Config for Test { - type Proposal = Call; + type Proposal = RuntimeCall; type RuntimeEvent = RuntimeEvent; type Currency = pallet_balances::Pallet; type EnactmentPeriod = ConstU64<2>; @@ -217,7 +217,7 @@ fn params_should_work() { } fn set_balance_proposal(value: u64) -> Vec { - Call::Balances(pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0 }) + RuntimeCall::Balances(pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0 }) .encode() } diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index b1bced53cc756..0aba753f43c1d 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -201,7 +201,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; @@ -393,7 +393,7 @@ impl frame_system::offchain::SendTransactionTypes for Runt where Call: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; } diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index eb6d683bdf8cd..066f0315e0899 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -214,7 +214,7 @@ mod tests { type Origin = Origin; type Index = AccountId; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index f96c23df1f4cd..7db1e858655a1 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1188,7 +1188,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 64373646ee9c6..1ddd923eaf358 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -63,7 +63,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 8201b659940f2..cb66de6b88a23 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -94,7 +94,7 @@ impl frame_system::offchain::SendTransactionTypes for Test where Call: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; } @@ -119,7 +119,7 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; type AuthorityId = crypto::TestAuthId; - type Call = Call; + type Call = RuntimeCall; type GracePeriod = ConstU64<5>; type UnsignedInterval = ConstU64<128>; type UnsignedPriority = UnsignedPriority; diff --git a/frame/examples/parallel/src/tests.rs b/frame/examples/parallel/src/tests.rs index 888b5077bb502..472c0d1e9b0b3 100644 --- a/frame/examples/parallel/src/tests.rs +++ b/frame/examples/parallel/src/tests.rs @@ -46,7 +46,7 @@ parameter_types! { impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type PalletInfo = PalletInfo; type Index = u64; type BlockNumber = u64; @@ -71,7 +71,7 @@ impl frame_system::Config for Test { } impl Config for Test { - type Call = Call; + type Call = RuntimeCall; } fn test_pub(n: u8) -> sp_core::sr25519::Public { diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 98a9fc2724658..15ec49b5f02cf 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -737,7 +737,7 @@ mod tests { type DbWeight = (); type Origin = Origin; type Index = u64; - type Call = Call; + type Call = RuntimeCall; type BlockNumber = u64; type Hash = sp_core::H256; type Hashing = BlakeTwo256; @@ -841,7 +841,7 @@ mod tests { } fn call_transfer(dest: u64, value: u64) -> Call { - Call::Balances(BalancesCall::transfer { dest, value }) + RuntimeCall::Balances(BalancesCall::transfer { dest, value }) } #[test] @@ -984,7 +984,7 @@ mod tests { let mut t = new_test_ext(10000); // given: TestXt uses the encoded len as fixed Len: let xt = TestXt::new( - Call::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); let encoded = xt.encode(); @@ -1007,7 +1007,7 @@ mod tests { for nonce in 0..=num_to_exhaust_block { let xt = TestXt::new( - Call::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), sign_extra(1, nonce.into(), 0), ); let res = Executive::apply_extrinsic(xt); @@ -1032,15 +1032,15 @@ mod tests { #[test] fn block_weight_and_size_is_stored_per_tx() { let xt = TestXt::new( - Call::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); let x1 = TestXt::new( - Call::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), sign_extra(1, 1, 0), ); let x2 = TestXt::new( - Call::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), sign_extra(1, 2, 0), ); let len = xt.clone().encode().len() as u32; @@ -1311,7 +1311,7 @@ mod tests { #[test] fn custom_runtime_upgrade_is_called_when_using_execute_block_trait() { let xt = TestXt::new( - Call::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); @@ -1440,7 +1440,7 @@ mod tests { #[should_panic(expected = "Invalid inherent position for extrinsic at index 1")] fn invalid_inherent_position_fail() { let xt1 = TestXt::new( - Call::Balances(BalancesCall::transfer { dest: 33, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); let xt2 = TestXt::new(Call::Custom(custom::Call::inherent_call {}), None); diff --git a/frame/gilt/src/mock.rs b/frame/gilt/src/mock.rs index 52dea595a5bde..3c5517b112053 100644 --- a/frame/gilt/src/mock.rs +++ b/frame/gilt/src/mock.rs @@ -50,7 +50,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 597b6ac145352..c25845337a62f 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -82,7 +82,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; @@ -105,7 +105,7 @@ impl frame_system::offchain::SendTransactionTypes for Test where Call: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = TestXt; } @@ -225,7 +225,7 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type KeyOwnerProofSystem = Historical; diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index 33251ea07302f..ceb8255382b08 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -60,7 +60,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index b6b7295f60d34..b219cc09ac455 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -134,7 +134,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -235,7 +235,7 @@ impl frame_system::offchain::SendTransactionTypes for Runt where Call: From, { - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; } diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 68a704f5b4153..27e1a5a92c05b 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -53,7 +53,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 65650b28da650..95082726766f9 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -59,7 +59,7 @@ impl frame_system::Config for Test { type DbWeight = (); type Origin = Origin; type Index = u64; - type Call = Call; + type Call = RuntimeCall; type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -97,7 +97,7 @@ parameter_types! { impl Config for Test { type PalletId = LotteryPalletId; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type Randomness = TestRandomness; type RuntimeEvent = RuntimeEvent; diff --git a/frame/lottery/src/tests.rs b/frame/lottery/src/tests.rs index d8dd6e4b7fe6c..e649abb099469 100644 --- a/frame/lottery/src/tests.rs +++ b/frame/lottery/src/tests.rs @@ -43,8 +43,8 @@ fn basic_end_to_end_works() { let length = 20; let delay = 5; let calls = vec![ - Call::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - Call::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), ]; // Set calls for the lottery @@ -55,7 +55,7 @@ fn basic_end_to_end_works() { assert!(crate::Lottery::::get().is_some()); assert_eq!(Balances::free_balance(&1), 100); - let call = Box::new(Call::Balances(BalancesCall::transfer { dest: 2, value: 20 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 20 })); assert_ok!(Lottery::buy_ticket(Origin::signed(1), call.clone())); // 20 from the transfer, 10 from buying a ticket assert_eq!(Balances::free_balance(&1), 100 - 20 - 10); @@ -127,16 +127,16 @@ fn set_calls_works() { assert!(!CallIndices::::exists()); let calls = vec![ - Call::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - Call::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), ]; assert_ok!(Lottery::set_calls(Origin::root(), calls)); assert!(CallIndices::::exists()); let too_many_calls = vec![ - Call::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - Call::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), Call::System(SystemCall::remark { remark: vec![] }), ]; @@ -155,8 +155,8 @@ fn set_calls_works() { fn call_to_indices_works() { new_test_ext().execute_with(|| { let calls = vec![ - Call::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - Call::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), ]; let indices = Lottery::calls_to_indices(&calls).unwrap().into_inner(); // Only comparing the length since it is otherwise dependant on the API @@ -164,8 +164,8 @@ fn call_to_indices_works() { assert_eq!(indices.len(), calls.len()); let too_many_calls = vec![ - Call::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - Call::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), Call::System(SystemCall::remark { remark: vec![] }), ]; assert_noop!(Lottery::calls_to_indices(&too_many_calls), Error::::TooManyCalls); @@ -202,7 +202,7 @@ fn buy_ticket_works_as_simple_passthrough() { // as a simple passthrough to the real call. new_test_ext().execute_with(|| { // No lottery set up - let call = Box::new(Call::Balances(BalancesCall::transfer { dest: 2, value: 20 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 20 })); // This is just a basic transfer then assert_ok!(Lottery::buy_ticket(Origin::signed(1), call.clone())); assert_eq!(Balances::free_balance(&1), 100 - 20); @@ -210,8 +210,8 @@ fn buy_ticket_works_as_simple_passthrough() { // Lottery is set up, but too expensive to enter, so `do_buy_ticket` fails. let calls = vec![ - Call::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), - Call::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), ]; assert_ok!(Lottery::set_calls(Origin::root(), calls)); @@ -222,14 +222,14 @@ fn buy_ticket_works_as_simple_passthrough() { assert_eq!(TicketsCount::::get(), 0); // If call would fail, the whole thing still fails the same - let fail_call = Box::new(Call::Balances(BalancesCall::transfer { dest: 2, value: 1000 })); + let fail_call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 1000 })); assert_noop!( Lottery::buy_ticket(Origin::signed(1), fail_call), BalancesError::::InsufficientBalance, ); let bad_origin_call = - Box::new(Call::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 })); + Box::new(RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 })); assert_noop!(Lottery::buy_ticket(Origin::signed(1), bad_origin_call), BadOrigin,); // User can call other txs, but doesn't get a ticket @@ -239,7 +239,7 @@ fn buy_ticket_works_as_simple_passthrough() { assert_eq!(TicketsCount::::get(), 0); let successful_call = - Box::new(Call::Balances(BalancesCall::transfer { dest: 2, value: 1 })); + Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 1 })); assert_ok!(Lottery::buy_ticket(Origin::signed(2), successful_call)); assert_eq!(TicketsCount::::get(), 1); }); @@ -251,12 +251,12 @@ fn buy_ticket_works() { // Set calls for the lottery. let calls = vec![ Call::System(SystemCall::remark { remark: vec![] }), - Call::Balances(BalancesCall::transfer { dest: 0, value: 0 }), + RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), ]; assert_ok!(Lottery::set_calls(Origin::root(), calls)); // Can't buy ticket before start - let call = Box::new(Call::Balances(BalancesCall::transfer { dest: 2, value: 1 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 1 })); assert_ok!(Lottery::buy_ticket(Origin::signed(1), call.clone())); assert_eq!(TicketsCount::::get(), 0); @@ -269,7 +269,7 @@ fn buy_ticket_works() { assert_eq!(TicketsCount::::get(), 1); // Can't buy another of the same ticket (even if call is slightly changed) - let call = Box::new(Call::Balances(BalancesCall::transfer { dest: 3, value: 30 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 3, value: 30 })); assert_ok!(Lottery::buy_ticket(Origin::signed(1), call)); assert_eq!(TicketsCount::::get(), 1); @@ -296,7 +296,7 @@ fn buy_ticket_works() { #[test] fn do_buy_ticket_already_participating() { new_test_ext().execute_with(|| { - let calls = vec![Call::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(Origin::root(), calls.clone())); assert_ok!(Lottery::start_lottery(Origin::root(), 1, 10, 10, false)); @@ -311,7 +311,7 @@ fn do_buy_ticket_already_participating() { #[test] fn buy_ticket_already_participating() { new_test_ext().execute_with(|| { - let calls = vec![Call::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(Origin::root(), calls.clone())); assert_ok!(Lottery::start_lottery(Origin::root(), 1, 10, 10, false)); @@ -331,7 +331,7 @@ fn buy_ticket_already_participating() { #[test] fn buy_ticket_insufficient_balance() { new_test_ext().execute_with(|| { - let calls = vec![Call::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(Origin::root(), calls.clone())); // Price set to 100. assert_ok!(Lottery::start_lottery(Origin::root(), 100, 10, 10, false)); @@ -346,7 +346,7 @@ fn buy_ticket_insufficient_balance() { #[test] fn do_buy_ticket_insufficient_balance() { new_test_ext().execute_with(|| { - let calls = vec![Call::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(Origin::root(), calls.clone())); // Price set to 101. assert_ok!(Lottery::start_lottery(Origin::root(), 101, 10, 10, false)); @@ -363,7 +363,7 @@ fn do_buy_ticket_insufficient_balance() { #[test] fn do_buy_ticket_keep_alive() { new_test_ext().execute_with(|| { - let calls = vec![Call::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(Origin::root(), calls.clone())); // Price set to 100. assert_ok!(Lottery::start_lottery(Origin::root(), 100, 10, 10, false)); @@ -415,7 +415,7 @@ fn choose_ticket_trivial_cases() { #[test] fn choose_account_one_participant() { new_test_ext().execute_with(|| { - let calls = vec![Call::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; + let calls = vec![RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 })]; assert_ok!(Lottery::set_calls(Origin::root(), calls.clone())); assert_ok!(Lottery::start_lottery(Origin::root(), 10, 10, 10, false)); let call = Box::new(calls[0].clone()); diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 56ec705f606dc..9e3e654e69a7d 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -547,7 +547,7 @@ mod tests { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index 70fd748912b5b..05893717d6c74 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -45,7 +45,7 @@ frame_support::construct_runtime!( impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index ccb59a41c2b24..08d980819600f 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -95,7 +95,7 @@ pub struct TestBaseCallFilter; impl Contains for TestBaseCallFilter { fn contains(c: &Call) -> bool { match *c { - Call::Balances(_) => true, + RuntimeCall::Balances(_) => true, // Needed for benchmarking Call::System(frame_system::Call::remark { .. }) => true, _ => false, @@ -104,7 +104,7 @@ impl Contains for TestBaseCallFilter { } impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type DepositBase = ConstU64<1>; type DepositFactor = ConstU64<1>; @@ -131,7 +131,7 @@ fn now() -> Timepoint { } fn call_transfer(dest: u64, value: u64) -> Call { - Call::Balances(BalancesCall::transfer { dest, value }) + RuntimeCall::Balances(BalancesCall::transfer { dest, value }) } #[test] diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 812cacb69c786..599b34599ae4a 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -284,7 +284,7 @@ mod tests { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index fb6bbc8b8a6f6..f2cf0ad9a7cb7 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -56,7 +56,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 9323b03a50d85..8534b1c5327e7 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -35,7 +35,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index f2d9156d60117..fae7fede85799 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -130,7 +130,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 90b9be0568f5a..69bd5dd550abc 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -46,7 +46,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 7158e8d1ff8b0..30205161e93ba 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -51,7 +51,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; @@ -208,7 +208,7 @@ where Call: From, { type Extrinsic = Extrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } impl crate::Config for Test {} diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 7466b7e4adc40..1f819dc7dc1ae 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -96,7 +96,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 8c78d897e1aca..81c7e21b58c9b 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 50b6a97ef3c32..ed617cf67f7e7 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -96,7 +96,7 @@ impl pallet_balances::Config for Test { } impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -129,7 +129,7 @@ impl InstanceFilter for ProxyType { match self { ProxyType::Any => true, ProxyType::JustTransfer => { - matches!(c, Call::Balances(pallet_balances::Call::transfer { .. })) + matches!(c, RuntimeCall::Balances(pallet_balances::Call::transfer { .. })) }, ProxyType::JustUtility => matches!(c, Call::Utility { .. }), } @@ -151,7 +151,7 @@ impl Contains for BaseFilter { } impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ConstU64<1>; @@ -198,7 +198,7 @@ fn expect_events(e: Vec) { } fn call_transfer(dest: u64, value: u64) -> Call { - Call::Balances(BalancesCall::transfer { dest, value }) + RuntimeCall::Balances(BalancesCall::transfer { dest, value }) } #[test] @@ -524,7 +524,7 @@ fn proxying_works() { ); let call = - Box::new(Call::Balances(BalancesCall::transfer_keep_alive { dest: 6, value: 1 })); + Box::new(RuntimeCall::Balances(BalancesCall::transfer_keep_alive { dest: 6, value: 1 })); assert_ok!(Call::Proxy(super::Call::new_call_variant_proxy(1, None, call.clone())) .dispatch(Origin::signed(2))); System::assert_last_event( diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 08cc2ddfd408a..4eb77cacbbd32 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -200,7 +200,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index 6341207637399..e2e38c94a4ada 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -60,7 +60,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index ef777dedb0613..576f89e0375f9 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -56,7 +56,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -104,7 +104,7 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; type WeightInfo = (); - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; diff --git a/frame/recovery/src/tests.rs b/frame/recovery/src/tests.rs index a900a5b6bfa2a..b8be78dff192a 100644 --- a/frame/recovery/src/tests.rs +++ b/frame/recovery/src/tests.rs @@ -45,7 +45,7 @@ fn set_recovered_works() { // Root can set a recovered account though assert_ok!(Recovery::set_recovered(Origin::root(), 5, 1)); // Account 1 should now be able to make a call through account 5 - let call = Box::new(Call::Balances(BalancesCall::transfer { dest: 1, value: 100 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 1, value: 100 })); assert_ok!(Recovery::as_recovered(Origin::signed(1), 5, call)); // Account 1 has successfully drained the funds from account 5 assert_eq!(Balances::free_balance(1), 200); @@ -85,7 +85,7 @@ fn recovery_life_cycle_works() { assert_ok!(Recovery::as_recovered(Origin::signed(1), 5, call)); // Account 1 should now be able to make a call through account 5 to get all of their funds assert_eq!(Balances::free_balance(5), 110); - let call = Box::new(Call::Balances(BalancesCall::transfer { dest: 1, value: 110 })); + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 1, value: 110 })); assert_ok!(Recovery::as_recovered(Origin::signed(1), 5, call)); // All funds have been fully recovered! assert_eq!(Balances::free_balance(1), 200); diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index a94c8b2605855..db14b4ff9b3c0 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -56,7 +56,7 @@ frame_support::construct_runtime!( pub struct BaseFilter; impl Contains for BaseFilter { fn contains(call: &Call) -> bool { - !matches!(call, &Call::Balances(pallet_balances::Call::set_balance { .. })) + !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) } } @@ -72,7 +72,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -103,7 +103,7 @@ impl pallet_scheduler::Config for Test { type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = Call; + type Call = RuntimeCall; type MaximumWeight = ConstU64<2_000_000_000_000>; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<100>; @@ -211,7 +211,7 @@ impl TracksInfo for TestTracksInfo { impl Config for Test { type WeightInfo = (); - type Call = Call; + type Call = RuntimeCall; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -295,12 +295,12 @@ impl VoteTally for Tally { } pub fn set_balance_proposal(value: u64) -> Vec { - Call::Balances(pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0 }) + RuntimeCall::Balances(pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0 }) .encode() } pub fn set_balance_proposal_hash(value: u64) -> H256 { - let c = Call::Balances(pallet_balances::Call::set_balance { + let c = RuntimeCall::Balances(pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0, diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index dee6a293d6583..69c49f394d969 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -46,7 +46,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index b97c8eeb385b7..2d1448f118edc 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -127,7 +127,7 @@ impl system::Config for Test { type BlockLength = (); type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -172,7 +172,7 @@ impl Config for Test { type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = Call; + type Call = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EitherOfDiverse, EnsureSignedBy>; type MaxScheduledPerBlock = ConstU32<10>; diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index 28f63b320420e..b7786ddbef5d0 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 6094a43d00c5b..76578d64c9c36 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -55,7 +55,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 587d646158524..22b9ae6afcf56 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -250,7 +250,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index fea87049fe1d3..7267714ecb416 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -67,7 +67,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 19dc60af882d4..9ed98c167833e 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -135,7 +135,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index e88d686845698..dae2b8eb7d62d 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -3782,7 +3782,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(2); // Collect payouts when there are no nominators - let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 1 }); + let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 1 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3795,7 +3795,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(3); // Collect payouts for an era where the validator did not receive any points. - let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 2 }); + let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 2 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3808,7 +3808,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(4); // Collect payouts when the validator has `half_max_nom_rewarded` nominators. - let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 3 }); + let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 3 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3831,14 +3831,14 @@ fn payout_stakers_handles_weight_refund() { start_active_era(6); // Collect payouts when the validator had `half_max_nom_rewarded` nominators. - let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); + let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); assert_eq!(extract_actual_weight(&result, &info), max_nom_rewarded_weight); // Try and collect payouts for an era that has already been collected. - let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); + let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert!(result.is_err()); diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index ed6b490215ce1..4b8e38f23dc5c 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1084,7 +1084,7 @@ mod mock { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u32; type Hash = H256; diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 30ef728d66093..ee3a732164097 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -125,7 +125,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -154,7 +154,7 @@ impl logger::Config for Test { // Implement the sudo module's `Config` on the Test runtime. impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; } // New types for dispatchable functions. diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 623bf80b7e536..6db70ef5e5ae3 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -250,7 +250,7 @@ impl system::Config for Runtime { type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = Call; + type Call = RuntimeCall; type DbWeight = (); } diff --git a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs index 623a30e23d73f..021e426652931 100644 --- a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs +++ b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs @@ -15,7 +15,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index a14519930066c..5dffecb7abf36 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -49,7 +49,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index bdfea120369b2..1cdb3ec7237f7 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index bea30a73bab7d..b2ea5d18a1fce 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index 4309e749290d5..be531f549d03e 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index 176de187c713c..fa5358d655a78 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index 2f880097ba3ee..c09ece3d297e3 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index 8c0d231122f93..ac6ffae3a500e 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index dcb18869c911e..08d71e792379e 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -282,7 +282,7 @@ impl system::Config for Runtime { type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = Call; + type Call = RuntimeCall; type DbWeight = (); } diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 22045779fd7a1..24c783e68fc02 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -165,7 +165,7 @@ impl system::Config for Runtime { type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = Call; + type Call = RuntimeCall; type DbWeight = (); } diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index bd2da6b9911fa..64ba75b0eda0b 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -151,7 +151,7 @@ impl system::Config for RuntimeOriginTest { type AccountId = u32; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = Call; + type Call = RuntimeCall; type DbWeight = (); } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 6c0136473c379..cc55209f7f7ab 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -552,7 +552,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index bcc4689668999..228277399f751 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -229,7 +229,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 89ed9ad8fbe4d..92d4d20c5b15a 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -213,7 +213,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 3dadc80e6787a..841b4ff003100 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -254,7 +254,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 6f2f099514883..41806d4b9a4e7 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -130,7 +130,7 @@ mod tests { type Index = u64; type BlockNumber = u64; type Hash = sp_core::H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index efa16a2589867..0e7fce4999eef 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -89,7 +89,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index 19350e728fc3c..ddc4a59f91537 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -76,7 +76,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index f53b5e2bec9be..997bd8e9fb1dd 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -46,7 +46,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = Call; + type Call = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index fb140b24a8689..25bd0bfadfd2d 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -95,7 +95,7 @@ impl Config for Test { type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index 86440188a765c..093ed4f21ae5a 100644 --- a/frame/system/src/offchain.rs +++ b/frame/system/src/offchain.rs @@ -631,7 +631,7 @@ mod tests { impl SendTransactionTypes for TestRuntime { type Extrinsic = Extrinsic; - type OverarchingCall = Call; + type OverarchingCall = RuntimeCall; } #[derive(codec::Encode, codec::Decode)] diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index bb6c631b0a04f..2f48f17531fd8 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -59,7 +59,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index dfa3290d67d8d..0e1885cf3ae64 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -70,7 +70,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index 589b195a8a247..1aa6d3b314c42 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -56,7 +56,7 @@ frame_support::construct_runtime!( ); const CALL: &::Call = - &Call::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); thread_local! { static EXTRINSIC_BASE_WEIGHT: RefCell = RefCell::new(0); @@ -90,7 +90,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 83432271b47de..2d7d89833ec88 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -833,7 +833,7 @@ mod tests { ); const CALL: &::Call = - &Call::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); thread_local! { static EXTRINSIC_BASE_WEIGHT: RefCell = RefCell::new(0); @@ -868,7 +868,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -1177,7 +1177,7 @@ mod tests { #[test] fn query_info_and_fee_details_works() { - let call = Call::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); let origin = 111111; let extra = (); let xt = TestXt::new(call.clone(), Some((origin, extra))); @@ -1234,7 +1234,7 @@ mod tests { #[test] fn query_call_info_and_fee_details_works() { - let call = Call::Balances(BalancesCall::transfer { dest: 2, value: 69 }); + let call = RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); let info = call.get_dispatch_info(); let encoded_call = call.encode(); let len = encoded_call.len() as u32; diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index e901aa4e510b7..5ea3a158a2aab 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -88,7 +88,7 @@ impl pallet_balances::Config for Test { impl pallet_transaction_storage::Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type Currency = Balances; type FeeDestination = (); type WeightInfo = (); diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 92fec60ad0d9d..2f34ccc75a1fa 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = Call; + type Call = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index f258c7236d641..e007e5de1f11f 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -50,7 +50,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = Call; + type Call = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/uniques/src/tests.rs b/frame/uniques/src/tests.rs index 63bee10ed35ec..4dabf3f4470b6 100644 --- a/frame/uniques/src/tests.rs +++ b/frame/uniques/src/tests.rs @@ -849,7 +849,7 @@ fn buy_item_should_work() { // freeze collection assert_ok!(Uniques::freeze_collection(Origin::signed(user_1), collection_id)); - let buy_item_call = mock::Call::Uniques(crate::Call::::buy_item { + let buy_item_call = mock::RuntimeCall::Uniques(crate::Call::::buy_item { collection: collection_id, item: item_3, bid_price: price_1, @@ -861,7 +861,7 @@ fn buy_item_should_work() { // freeze item assert_ok!(Uniques::freeze(Origin::signed(user_1), collection_id, item_3)); - let buy_item_call = mock::Call::Uniques(crate::Call::::buy_item { + let buy_item_call = mock::RuntimeCall::Uniques(crate::Call::::buy_item { collection: collection_id, item: item_3, bid_price: price_1, diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index fe82af3b20bdc..c6376e2ed187e 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -110,7 +110,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -152,7 +152,7 @@ impl Contains for TestBaseCallFilter { fn contains(c: &Call) -> bool { match *c { // Transfer works. Use `transfer_keep_alive` for a call that doesn't pass the filter. - Call::Balances(pallet_balances::Call::transfer { .. }) => true, + RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => true, Call::Utility(_) => true, // For benchmarking, this acts as a noop call Call::System(frame_system::Call::remark { .. }) => true, @@ -164,7 +164,7 @@ impl Contains for TestBaseCallFilter { } impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -188,7 +188,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } fn call_transfer(dest: u64, value: u64) -> Call { - Call::Balances(BalancesCall::transfer { dest, value }) + RuntimeCall::Balances(BalancesCall::transfer { dest, value }) } fn call_foobar(err: bool, start_weight: u64, end_weight: Option) -> Call { @@ -281,7 +281,7 @@ fn as_derivative_filters() { Utility::as_derivative( Origin::signed(1), 1, - Box::new(Call::Balances(pallet_balances::Call::transfer_keep_alive { + Box::new(RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })), @@ -303,8 +303,8 @@ fn batch_with_root_works() { assert_ok!(Utility::batch( Origin::root(), vec![ - Call::Balances(BalancesCall::force_transfer { source: 1, dest: 2, value: 5 }), - Call::Balances(BalancesCall::force_transfer { source: 1, dest: 2, value: 5 }), + RuntimeCall::Balances(BalancesCall::force_transfer { source: 1, dest: 2, value: 5 }), + RuntimeCall::Balances(BalancesCall::force_transfer { source: 1, dest: 2, value: 5 }), call, // Check filters are correctly bypassed ] )); @@ -333,7 +333,7 @@ fn batch_with_signed_filters() { new_test_ext().execute_with(|| { assert_ok!(Utility::batch( Origin::signed(1), - vec![Call::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })] + vec![RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })] ),); System::assert_last_event( utility::Event::BatchInterrupted { diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 108d2244a31ab..5482a2f3dd5b8 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -55,7 +55,7 @@ impl frame_system::Config for Test { type BlockLength = (); type BlockNumber = u64; type BlockWeights = (); - type Call = Call; + type Call = RuntimeCall; type DbWeight = (); type RuntimeEvent = RuntimeEvent; type Hash = H256; diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 82d1f95416395..4c56fa399781c 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -62,7 +62,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = Call; + type Call = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -104,7 +104,7 @@ impl pallet_preimage::Config for Test { impl pallet_whitelist::Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = Call; + type Call = RuntimeCall; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type PreimageProvider = Preimage; From 32989ee35c090696683dadd77c9216d2fb59f509 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 13:09:49 +0200 Subject: [PATCH 38/63] rename --- bin/node-template/runtime/src/lib.rs | 3 +- bin/node/cli/benches/block_production.rs | 2 +- bin/node/cli/src/service.rs | 6 +- bin/node/executor/benches/bench.rs | 6 +- bin/node/executor/tests/basic.rs | 38 ++++---- bin/node/executor/tests/fees.rs | 21 +++-- bin/node/runtime/src/impls.rs | 3 +- bin/node/runtime/src/lib.rs | 12 ++- bin/node/testing/src/bench.rs | 7 +- frame/alliance/src/mock.rs | 6 +- frame/collective/src/tests.rs | 10 ++- frame/contracts/src/exec.rs | 9 +- frame/contracts/src/tests.rs | 2 +- frame/contracts/src/wasm/mod.rs | 3 +- frame/democracy/src/tests.rs | 8 +- .../src/unsigned.rs | 4 +- frame/examples/offchain-worker/src/tests.rs | 11 ++- frame/executive/src/lib.rs | 2 +- frame/im-online/src/tests.rs | 6 +- frame/lottery/src/tests.rs | 21 +++-- frame/multisig/src/tests.rs | 4 +- frame/proxy/src/tests.rs | 37 ++++---- frame/recovery/src/tests.rs | 4 +- frame/referenda/src/mock.rs | 8 +- frame/staking/src/tests.rs | 15 ++-- frame/support/test/tests/construct_runtime.rs | 22 ++--- frame/support/test/tests/pallet.rs | 32 +++---- frame/system/src/mock.rs | 2 +- frame/utility/src/tests.rs | 87 ++++++++++++------- frame/whitelist/src/tests.rs | 13 +-- 30 files changed, 236 insertions(+), 168 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index babee9893a154..1270c7c3840a0 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -310,7 +310,8 @@ pub type SignedExtra = ( ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; /// Executive: handles dispatch to the various modules. diff --git a/bin/node/cli/benches/block_production.rs b/bin/node/cli/benches/block_production.rs index c0f3b96e093cb..0a734fa447448 100644 --- a/bin/node/cli/benches/block_production.rs +++ b/bin/node/cli/benches/block_production.rs @@ -122,7 +122,7 @@ fn new_node(tokio_handle: Handle) -> node_cli::service::NewFullBase { fn extrinsic_set_time(now: u64) -> OpaqueExtrinsic { kitchensink_runtime::UncheckedExtrinsic { signature: None, - function: kitchensink_runtime::Call::Timestamp(pallet_timestamp::Call::set { now }), + function: kitchensink_runtime::RuntimeCall::Timestamp(pallet_timestamp::Call::set { now }), } .into() } diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 698d537e6bb80..abbd3c90be2e9 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -762,8 +762,10 @@ mod tests { }; let signer = charlie.clone(); - let function = - RuntimeCall::Balances(BalancesCall::transfer { dest: to.into(), value: amount }); + let function = RuntimeCall::Balances(BalancesCall::transfer { + dest: to.into(), + value: amount, + }); let check_non_zero_sender = frame_system::CheckNonZeroSender::new(); let check_spec_version = frame_system::CheckSpecVersion::new(); diff --git a/bin/node/executor/benches/bench.rs b/bin/node/executor/benches/bench.rs index 4cd0e6d99ced5..94d8124a716cf 100644 --- a/bin/node/executor/benches/bench.rs +++ b/bin/node/executor/benches/bench.rs @@ -19,8 +19,8 @@ use codec::{Decode, Encode}; use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; use frame_support::Hashable; use kitchensink_runtime::{ - constants::currency::*, Block, BuildStorage, RuntimeCall, CheckedExtrinsic, GenesisConfig, Header, - UncheckedExtrinsic, + constants::currency::*, Block, BuildStorage, CheckedExtrinsic, GenesisConfig, Header, + RuntimeCall, UncheckedExtrinsic, }; use node_executor::ExecutorDispatch; use node_primitives::{BlockNumber, Hash}; @@ -164,7 +164,7 @@ fn test_blocks( let mut test_ext = new_test_ext(genesis_config); let mut block1_extrinsics = vec![CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: 0 }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: 0 }), }]; block1_extrinsics.extend((0..20).map(|i| CheckedExtrinsic { signed: Some((alice(), signed_extra(i, 0))), diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index 7606b291d9143..55a3b6f0aeb32 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -28,8 +28,8 @@ use sp_runtime::{ use kitchensink_runtime::{ constants::{currency::*, time::SLOT_DURATION}, - Balances, RuntimeCall, CheckedExtrinsic, Header, Runtime, RuntimeEvent, System, TransactionPayment, - UncheckedExtrinsic, + Balances, CheckedExtrinsic, Header, Runtime, RuntimeCall, RuntimeEvent, System, + TransactionPayment, UncheckedExtrinsic, }; use node_primitives::{Balance, Hash}; use node_testing::keyring::*; @@ -84,7 +84,7 @@ fn changes_trie_block() -> (Vec, Hash) { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time }), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), @@ -111,7 +111,7 @@ fn blocks() -> ((Vec, Hash), (Vec, Hash)) { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time1 }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time1 }), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(0, 0))), @@ -131,7 +131,7 @@ fn blocks() -> ((Vec, Hash), (Vec, Hash)) { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time2 }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time2 }), }, CheckedExtrinsic { signed: Some((bob(), signed_extra(0, 0))), @@ -166,11 +166,11 @@ fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec, Hash) { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }), }, CheckedExtrinsic { signed: Some((alice(), signed_extra(nonce, 0))), - function: Call::System(frame_system::Call::remark { remark: vec![0; size] }), + function: RuntimeCall::System(frame_system::Call::remark { remark: vec![0; size] }), }, ], (time * 1000 / SLOT_DURATION).into(), @@ -732,24 +732,24 @@ fn deploying_wasm_contract_should_work() { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time }), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(0, 0))), - function: Call::Contracts( - pallet_contracts::Call::instantiate_with_code:: { - value: 0, - gas_limit: 500_000_000, - storage_deposit_limit: None, - code: transfer_code, - data: Vec::new(), - salt: Vec::new(), - }, - ), + function: RuntimeCall::Contracts(pallet_contracts::Call::instantiate_with_code::< + Runtime, + > { + value: 0, + gas_limit: 500_000_000, + storage_deposit_limit: None, + code: transfer_code, + data: Vec::new(), + salt: Vec::new(), + }), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(1, 0))), - function: Call::Contracts(pallet_contracts::Call::call:: { + function: RuntimeCall::Contracts(pallet_contracts::Call::call:: { dest: sp_runtime::MultiAddress::Id(addr.clone()), value: 10, gas_limit: 500_000_000, diff --git a/bin/node/executor/tests/fees.rs b/bin/node/executor/tests/fees.rs index a2f755d81ad2d..fbd1da025601b 100644 --- a/bin/node/executor/tests/fees.rs +++ b/bin/node/executor/tests/fees.rs @@ -22,7 +22,8 @@ use frame_support::{ }; use kitchensink_runtime::{ constants::{currency::*, time::SLOT_DURATION}, - Balances, RuntimeCall, CheckedExtrinsic, Multiplier, Runtime, TransactionByteFee, TransactionPayment, + Balances, CheckedExtrinsic, Multiplier, Runtime, RuntimeCall, TransactionByteFee, + TransactionPayment, }; use node_primitives::Balance; use node_testing::keyring::*; @@ -54,12 +55,12 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time1 }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time1 }), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(0, 0))), - function: Call::Sudo(pallet_sudo::Call::sudo { - call: Box::new(Call::System(frame_system::Call::fill_block { + function: RuntimeCall::Sudo(pallet_sudo::Call::sudo { + call: Box::new(RuntimeCall::System(frame_system::Call::fill_block { ratio: Perbill::from_percent(60), })), }), @@ -77,11 +78,11 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time2 }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time2 }), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(1, 0))), - function: Call::System(frame_system::Call::remark { remark: vec![0; 1] }), + function: RuntimeCall::System(frame_system::Call::remark { remark: vec![0; 1] }), }, ], (time2 / SLOT_DURATION).into(), @@ -252,7 +253,7 @@ fn block_weight_capacity_report() { 0, CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }), }, ); @@ -322,11 +323,13 @@ fn block_length_capacity_report() { vec![ CheckedExtrinsic { signed: None, - function: Call::Timestamp(pallet_timestamp::Call::set { now: time * 1000 }), + function: RuntimeCall::Timestamp(pallet_timestamp::Call::set { + now: time * 1000, + }), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(nonce, 0))), - function: Call::System(frame_system::Call::remark { + function: RuntimeCall::System(frame_system::Call::remark { remark: vec![0u8; (block_number * factor) as usize], }), }, diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index f5dafa9c727b6..bd60f63aa1272 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -18,7 +18,8 @@ //! Some configurable implementations as associated type for the substrate runtime. use crate::{ - AccountId, AllianceMotion, Assets, Authorship, Balances, RuntimeCall, Hash, NegativeImbalance, Runtime, + AccountId, AllianceMotion, Assets, Authorship, Balances, Hash, NegativeImbalance, Runtime, + RuntimeCall, }; use frame_support::{ pallet_prelude::*, diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 587dfde4b113c..35836ad929c14 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -293,16 +293,19 @@ impl InstanceFilter for ProxyType { ProxyType::NonTransfer => !matches!( c, RuntimeCall::Balances(..) | - RuntimeCall::Assets(..) | RuntimeCall::Uniques(..) | + RuntimeCall::Assets(..) | + RuntimeCall::Uniques(..) | RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) | RuntimeCall::Indices(pallet_indices::Call::transfer { .. }) ), ProxyType::Governance => matches!( c, RuntimeCall::Democracy(..) | - RuntimeCall::Council(..) | RuntimeCall::Society(..) | + RuntimeCall::Council(..) | + RuntimeCall::Society(..) | RuntimeCall::TechnicalCommittee(..) | - RuntimeCall::Elections(..) | RuntimeCall::Treasury(..) + RuntimeCall::Elections(..) | + RuntimeCall::Treasury(..) ), ProxyType::Staking => matches!(c, RuntimeCall::Staking(..)), } @@ -1671,7 +1674,8 @@ pub type SignedExtra = ( ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; /// The payload being signed in transactions. pub type SignedPayload = generic::SignedPayload; /// Extrinsic type that has already been checked. diff --git a/bin/node/testing/src/bench.rs b/bin/node/testing/src/bench.rs index ca650a597a2c2..7980cc102fb38 100644 --- a/bin/node/testing/src/bench.rs +++ b/bin/node/testing/src/bench.rs @@ -35,8 +35,8 @@ use crate::{ use codec::{Decode, Encode}; use futures::executor; use kitchensink_runtime::{ - constants::currency::DOLLARS, AccountId, BalancesCall, RuntimeCall, CheckedExtrinsic, MinimumPeriod, - Signature, SystemCall, UncheckedExtrinsic, + constants::currency::DOLLARS, AccountId, BalancesCall, CheckedExtrinsic, MinimumPeriod, + RuntimeCall, Signature, SystemCall, UncheckedExtrinsic, }; use node_primitives::Block; use sc_block_builder::BlockBuilderProvider; @@ -321,7 +321,8 @@ impl<'a> Iterator for BlockContentIterator<'a> { (kitchensink_runtime::ExistentialDeposit::get() - 1), }) }, - BlockType::Noop => Call::System(SystemCall::remark { remark: Vec::new() }), + BlockType::Noop => + RuntimeCall::System(SystemCall::remark { remark: Vec::new() }), }, }, self.runtime_version.spec_version, diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index aaa1971d233ac..e8c1b3635d170 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -318,13 +318,13 @@ pub fn test_cid() -> Cid { } pub fn make_proposal(value: u64) -> Call { - Call::System(frame_system::Call::remark { remark: value.encode() }) + RuntimeCall::System(frame_system::Call::remark { remark: value.encode() }) } pub fn make_set_rule_proposal(rule: Cid) -> Call { - Call::Alliance(pallet_alliance::Call::set_rule { rule }) + RuntimeCall::Alliance(pallet_alliance::Call::set_rule { rule }) } pub fn make_kick_member_proposal(who: u64) -> Call { - Call::Alliance(pallet_alliance::Call::kick_member { who }) + RuntimeCall::Alliance(pallet_alliance::Call::kick_member { who }) } diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index fe88a938d124f..2f8a98289596a 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -173,7 +173,9 @@ pub fn new_test_ext() -> sp_io::TestExternalities { } fn make_proposal(value: u64) -> Call { - Call::System(frame_system::Call::remark_with_event { remark: value.to_be_bytes().to_vec() }) + RuntimeCall::System(frame_system::Call::remark_with_event { + remark: value.to_be_bytes().to_vec(), + }) } fn record(event: RuntimeEvent) -> EventRecord { @@ -253,7 +255,7 @@ fn close_works() { #[test] fn proposal_weight_limit_works_on_approve() { new_test_ext().execute_with(|| { - let proposal = Call::Collective(crate::Call::set_members { + let proposal = RuntimeCall::Collective(crate::Call::set_members { new_members: vec![1, 2, 3], prime: None, old_count: MaxMembers::get(), @@ -283,7 +285,7 @@ fn proposal_weight_limit_works_on_approve() { #[test] fn proposal_weight_limit_ignored_on_disapprove() { new_test_ext().execute_with(|| { - let proposal = Call::Collective(crate::Call::set_members { + let proposal = RuntimeCall::Collective(crate::Call::set_members { new_members: vec![1, 2, 3], prime: None, old_count: MaxMembers::get(), @@ -669,7 +671,7 @@ fn limit_active_proposals() { #[test] fn correct_validate_and_get_proposal() { new_test_ext().execute_with(|| { - let proposal = Call::Collective(crate::Call::set_members { + let proposal = RuntimeCall::Collective(crate::Call::set_members { new_members: vec![1, 2, 3], prime: None, old_count: MaxMembers::get(), diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 0b4f7db9ecc36..9f9d8ad2c554b 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -2562,7 +2562,7 @@ mod tests { #[test] fn call_runtime_works() { let code_hash = MockLoader::insert(Call, |ctx, _| { - let call = Call::System(frame_system::Call::remark_with_event { + let call = RuntimeCall::System(frame_system::Call::remark_with_event { remark: b"Hello World".to_vec(), }); ctx.ext.call_runtime(call).unwrap(); @@ -2613,10 +2613,11 @@ mod tests { // remark should still be allowed let allowed_call = - Call::System(SysCall::remark_with_event { remark: b"Hello".to_vec() }); + RuntimeCall::System(SysCall::remark_with_event { remark: b"Hello".to_vec() }); // transfers are disallowed by the `TestFiler` (see below) - let forbidden_call = RuntimeCall::Balances(BalanceCall::transfer { dest: CHARLIE, value: 22 }); + let forbidden_call = + RuntimeCall::Balances(BalanceCall::transfer { dest: CHARLIE, value: 22 }); // simple cases: direct call assert_err!( @@ -2625,7 +2626,7 @@ mod tests { ); // as part of a patch: return is OK (but it interrupted the batch) - assert_ok!(ctx.ext.call_runtime(Call::Utility(UtilCall::batch { + assert_ok!(ctx.ext.call_runtime(RuntimeCall::Utility(UtilCall::batch { calls: vec![allowed_call.clone(), forbidden_call, allowed_call] })),); diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 2472f6e83bf79..26d7c8a2a557c 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -2499,7 +2499,7 @@ fn gas_estimation_call_runtime() { // Call something trivial with a huge gas limit so that we can observe the effects // of pre-charging. This should create a difference between consumed and required. - let call = Call::Contracts(crate::Call::call { + let call = RuntimeCall::Contracts(crate::Call::call { dest: addr_callee, value: 0, gas_limit: GAS_LIMIT / 3, diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 02a360fe86b45..968096821f463 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -2257,7 +2257,8 @@ mod tests { #[test] #[cfg(feature = "unstable-interface")] fn call_runtime_works() { - let call = Call::System(frame_system::Call::remark { remark: b"Hello World".to_vec() }); + let call = + RuntimeCall::System(frame_system::Call::remark { remark: b"Hello World".to_vec() }); let mut ext = MockExt::default(); let result = execute(CODE_CALL_RUNTIME, call.encode(), &mut ext).unwrap(); assert_eq!(*ext.runtime_calls.borrow(), vec![call]); diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 71cbe027d796d..3fe18982ba75e 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -217,8 +217,12 @@ fn params_should_work() { } fn set_balance_proposal(value: u64) -> Vec { - RuntimeCall::Balances(pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0 }) - .encode() + RuntimeCall::Balances(pallet_balances::Call::set_balance { + who: 42, + new_free: value, + new_reserved: 0, + }) + .encode() } #[test] diff --git a/frame/election-provider-multi-phase/src/unsigned.rs b/frame/election-provider-multi-phase/src/unsigned.rs index de25355f0ca5b..a77cce529ed26 100644 --- a/frame/election-provider-multi-phase/src/unsigned.rs +++ b/frame/election-provider-multi-phase/src/unsigned.rs @@ -755,8 +755,8 @@ mod tests { use super::*; use crate::{ mock::{ - roll_to, roll_to_with_ocw, trim_helpers, witness, BlockNumber, Call as OuterCall, - ExtBuilder, Extrinsic, MinerMaxWeight, MultiPhase, Origin, Runtime, System, + roll_to, roll_to_with_ocw, trim_helpers, witness, BlockNumber, ExtBuilder, Extrinsic, + MinerMaxWeight, MultiPhase, Origin, Runtime, RuntimeCall as OuterCall, System, TestNposSolution, TrimHelpers, UnsignedPhase, }, CurrentPhase, InvalidTransaction, Phase, QueuedSolution, TransactionSource, diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index cb66de6b88a23..5f707e8e2289e 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -233,7 +233,7 @@ fn should_submit_signed_transaction_on_chain() { assert!(pool_state.read().transactions.is_empty()); let tx = Extrinsic::decode(&mut &*tx).unwrap(); assert_eq!(tx.signature.unwrap().0, 0); - assert_eq!(tx.call, Call::Example(crate::Call::submit_price { price: 15523 })); + assert_eq!(tx.call, RuntimeCall::Example(crate::Call::submit_price { price: 15523 })); }); } @@ -278,7 +278,7 @@ fn should_submit_unsigned_transaction_on_chain_for_any_account() { let tx = pool_state.write().transactions.pop().unwrap(); let tx = Extrinsic::decode(&mut &*tx).unwrap(); assert_eq!(tx.signature, None); - if let Call::Example(crate::Call::submit_price_unsigned_with_signed_payload { + if let RuntimeCall::Example(crate::Call::submit_price_unsigned_with_signed_payload { price_payload: body, signature, }) = tx.call @@ -337,7 +337,7 @@ fn should_submit_unsigned_transaction_on_chain_for_all_accounts() { let tx = pool_state.write().transactions.pop().unwrap(); let tx = Extrinsic::decode(&mut &*tx).unwrap(); assert_eq!(tx.signature, None); - if let Call::Example(crate::Call::submit_price_unsigned_with_signed_payload { + if let RuntimeCall::Example(crate::Call::submit_price_unsigned_with_signed_payload { price_payload: body, signature, }) = tx.call @@ -379,7 +379,10 @@ fn should_submit_raw_unsigned_transaction_on_chain() { assert_eq!(tx.signature, None); assert_eq!( tx.call, - Call::Example(crate::Call::submit_price_unsigned { block_number: 1, price: 15523 }) + RuntimeCall::Example(crate::Call::submit_price_unsigned { + block_number: 1, + price: 15523 + }) ); }); } diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 15ec49b5f02cf..81da9ff582b96 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -1135,7 +1135,7 @@ mod tests { id, &1, 110, lock, ); let xt = TestXt::new( - Call::System(SystemCall::remark { remark: vec![1u8] }), + RuntimeCall::System(SystemCall::remark { remark: vec![1u8] }), sign_extra(1, 0, 0), ); let weight = xt.get_dispatch_info().weight + diff --git a/frame/im-online/src/tests.rs b/frame/im-online/src/tests.rs index 05e1af169dba9..b44d5c354d111 100644 --- a/frame/im-online/src/tests.rs +++ b/frame/im-online/src/tests.rs @@ -240,7 +240,8 @@ fn should_generate_heartbeats() { // check stuff about the transaction. let ex: Extrinsic = Decode::decode(&mut &*transaction).unwrap(); let heartbeat = match ex.call { - crate::mock::Call::ImOnline(crate::Call::heartbeat { heartbeat, .. }) => heartbeat, + crate::mock::RuntimeCall::ImOnline(crate::Call::heartbeat { heartbeat, .. }) => + heartbeat, e => panic!("Unexpected call: {:?}", e), }; @@ -355,7 +356,8 @@ fn should_not_send_a_report_if_already_online() { // check stuff about the transaction. let ex: Extrinsic = Decode::decode(&mut &*transaction).unwrap(); let heartbeat = match ex.call { - crate::mock::Call::ImOnline(crate::Call::heartbeat { heartbeat, .. }) => heartbeat, + crate::mock::RuntimeCall::ImOnline(crate::Call::heartbeat { heartbeat, .. }) => + heartbeat, e => panic!("Unexpected call: {:?}", e), }; diff --git a/frame/lottery/src/tests.rs b/frame/lottery/src/tests.rs index e649abb099469..12d4e69a818c3 100644 --- a/frame/lottery/src/tests.rs +++ b/frame/lottery/src/tests.rs @@ -137,7 +137,7 @@ fn set_calls_works() { let too_many_calls = vec![ RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), - Call::System(SystemCall::remark { remark: vec![] }), + RuntimeCall::System(SystemCall::remark { remark: vec![] }), ]; assert_noop!( @@ -166,7 +166,7 @@ fn call_to_indices_works() { let too_many_calls = vec![ RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 }), RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), - Call::System(SystemCall::remark { remark: vec![] }), + RuntimeCall::System(SystemCall::remark { remark: vec![] }), ]; assert_noop!(Lottery::calls_to_indices(&too_many_calls), Error::::TooManyCalls); }); @@ -222,19 +222,23 @@ fn buy_ticket_works_as_simple_passthrough() { assert_eq!(TicketsCount::::get(), 0); // If call would fail, the whole thing still fails the same - let fail_call = Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 1000 })); + let fail_call = + Box::new(RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 1000 })); assert_noop!( Lottery::buy_ticket(Origin::signed(1), fail_call), BalancesError::::InsufficientBalance, ); - let bad_origin_call = - Box::new(RuntimeCall::Balances(BalancesCall::force_transfer { source: 0, dest: 0, value: 0 })); + let bad_origin_call = Box::new(RuntimeCall::Balances(BalancesCall::force_transfer { + source: 0, + dest: 0, + value: 0, + })); assert_noop!(Lottery::buy_ticket(Origin::signed(1), bad_origin_call), BadOrigin,); // User can call other txs, but doesn't get a ticket let remark_call = - Box::new(Call::System(SystemCall::remark { remark: b"hello, world!".to_vec() })); + Box::new(RuntimeCall::System(SystemCall::remark { remark: b"hello, world!".to_vec() })); assert_ok!(Lottery::buy_ticket(Origin::signed(2), remark_call)); assert_eq!(TicketsCount::::get(), 0); @@ -250,7 +254,7 @@ fn buy_ticket_works() { new_test_ext().execute_with(|| { // Set calls for the lottery. let calls = vec![ - Call::System(SystemCall::remark { remark: vec![] }), + RuntimeCall::System(SystemCall::remark { remark: vec![] }), RuntimeCall::Balances(BalancesCall::transfer { dest: 0, value: 0 }), ]; assert_ok!(Lottery::set_calls(Origin::root(), calls)); @@ -274,7 +278,8 @@ fn buy_ticket_works() { assert_eq!(TicketsCount::::get(), 1); // Buy ticket for remark - let call = Box::new(Call::System(SystemCall::remark { remark: b"hello, world!".to_vec() })); + let call = + Box::new(RuntimeCall::System(SystemCall::remark { remark: b"hello, world!".to_vec() })); assert_ok!(Lottery::buy_ticket(Origin::signed(1), call.clone())); assert_eq!(TicketsCount::::get(), 2); diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index 08d980819600f..0d4bd9cd0dd5a 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -97,7 +97,7 @@ impl Contains for TestBaseCallFilter { match *c { RuntimeCall::Balances(_) => true, // Needed for benchmarking - Call::System(frame_system::Call::remark { .. }) => true, + RuntimeCall::System(frame_system::Call::remark { .. }) => true, _ => false, } } @@ -766,7 +766,7 @@ fn multisig_1_of_3_works() { #[test] fn multisig_filters() { new_test_ext().execute_with(|| { - let call = Box::new(Call::System(frame_system::Call::set_code { code: vec![] })); + let call = Box::new(RuntimeCall::System(frame_system::Call::set_code { code: vec![] })); assert_noop!( Multisig::as_multi_threshold_1(Origin::signed(1), vec![2], call.clone()), DispatchError::from(frame_system::Error::::CallFiltered), diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index ed617cf67f7e7..36b33f0d3c035 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -131,7 +131,7 @@ impl InstanceFilter for ProxyType { ProxyType::JustTransfer => { matches!(c, RuntimeCall::Balances(pallet_balances::Call::transfer { .. })) }, - ProxyType::JustUtility => matches!(c, Call::Utility { .. }), + ProxyType::JustUtility => matches!(c, RuntimeCall::Utility { .. }), } } fn is_superset(&self, o: &Self) -> bool { @@ -143,8 +143,8 @@ impl Contains for BaseFilter { fn contains(c: &Call) -> bool { match *c { // Remark is used as a no-op call in the benchmarking - Call::System(SystemCall::remark { .. }) => true, - Call::System(_) => false, + RuntimeCall::System(SystemCall::remark { .. }) => true, + RuntimeCall::System(_) => false, _ => true, } } @@ -346,8 +346,10 @@ fn filtering_works() { assert!(Balances::mutate_account(&derivative_id, |a| a.free = 1000).is_ok()); let inner = Box::new(call_transfer(6, 1)); - let call = - Box::new(Call::Utility(UtilityCall::as_derivative { index: 0, call: inner.clone() })); + let call = Box::new(RuntimeCall::Utility(UtilityCall::as_derivative { + index: 0, + call: inner.clone(), + })); assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone())); System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into()); assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone())); @@ -359,7 +361,7 @@ fn filtering_works() { ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(), ); - let call = Box::new(Call::Utility(UtilityCall::batch { calls: vec![*inner] })); + let call = Box::new(RuntimeCall::Utility(UtilityCall::batch { calls: vec![*inner] })); assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone())); expect_events(vec![ UtilityEvent::BatchCompleted.into(), @@ -376,9 +378,12 @@ fn filtering_works() { ProxyEvent::ProxyExecuted { result: Ok(()) }.into(), ]); - let inner = - Box::new(Call::Proxy(ProxyCall::new_call_variant_add_proxy(5, ProxyType::Any, 0))); - let call = Box::new(Call::Utility(UtilityCall::batch { calls: vec![*inner] })); + let inner = Box::new(RuntimeCall::Proxy(ProxyCall::new_call_variant_add_proxy( + 5, + ProxyType::Any, + 0, + ))); + let call = Box::new(RuntimeCall::Utility(UtilityCall::batch { calls: vec![*inner] })); assert_ok!(Proxy::proxy(Origin::signed(2), 1, None, call.clone())); expect_events(vec![ UtilityEvent::BatchCompleted.into(), @@ -395,7 +400,7 @@ fn filtering_works() { ProxyEvent::ProxyExecuted { result: Ok(()) }.into(), ]); - let call = Box::new(Call::Proxy(ProxyCall::remove_proxies {})); + let call = Box::new(RuntimeCall::Proxy(ProxyCall::remove_proxies {})); assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone())); System::assert_last_event( ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(), @@ -517,15 +522,17 @@ fn proxying_works() { System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into()); assert_eq!(Balances::free_balance(6), 1); - let call = Box::new(Call::System(SystemCall::set_code { code: vec![] })); + let call = Box::new(RuntimeCall::System(SystemCall::set_code { code: vec![] })); assert_ok!(Proxy::proxy(Origin::signed(3), 1, None, call.clone())); System::assert_last_event( ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(), ); - let call = - Box::new(RuntimeCall::Balances(BalancesCall::transfer_keep_alive { dest: 6, value: 1 })); - assert_ok!(Call::Proxy(super::Call::new_call_variant_proxy(1, None, call.clone())) + let call = Box::new(RuntimeCall::Balances(BalancesCall::transfer_keep_alive { + dest: 6, + value: 1, + })); + assert_ok!(RuntimeCall::Proxy(super::Call::new_call_variant_proxy(1, None, call.clone())) .dispatch(Origin::signed(2))); System::assert_last_event( ProxyEvent::ProxyExecuted { result: Err(SystemError::CallFiltered.into()) }.into(), @@ -572,7 +579,7 @@ fn anonymous_works() { System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into()); assert_eq!(Balances::free_balance(6), 1); - let call = Box::new(Call::Proxy(ProxyCall::new_call_variant_kill_anonymous( + let call = Box::new(RuntimeCall::Proxy(ProxyCall::new_call_variant_kill_anonymous( 1, ProxyType::Any, 0, diff --git a/frame/recovery/src/tests.rs b/frame/recovery/src/tests.rs index b8be78dff192a..59b1d3b771b8f 100644 --- a/frame/recovery/src/tests.rs +++ b/frame/recovery/src/tests.rs @@ -77,11 +77,11 @@ fn recovery_life_cycle_works() { assert_ok!(Recovery::claim_recovery(Origin::signed(1), 5)); // Account 1 can use account 5 to close the active recovery process, claiming the deposited // funds used to initiate the recovery process into account 5. - let call = Box::new(Call::Recovery(RecoveryCall::close_recovery { rescuer: 1 })); + let call = Box::new(RuntimeCall::Recovery(RecoveryCall::close_recovery { rescuer: 1 })); assert_ok!(Recovery::as_recovered(Origin::signed(1), 5, call)); // Account 1 can then use account 5 to remove the recovery configuration, claiming the // deposited funds used to create the recovery configuration into account 5. - let call = Box::new(Call::Recovery(RecoveryCall::remove_recovery {})); + let call = Box::new(RuntimeCall::Recovery(RecoveryCall::remove_recovery {})); assert_ok!(Recovery::as_recovered(Origin::signed(1), 5, call)); // Account 1 should now be able to make a call through account 5 to get all of their funds assert_eq!(Balances::free_balance(5), 110); diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index db14b4ff9b3c0..1b7f97a2b12e2 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -295,8 +295,12 @@ impl VoteTally for Tally { } pub fn set_balance_proposal(value: u64) -> Vec { - RuntimeCall::Balances(pallet_balances::Call::set_balance { who: 42, new_free: value, new_reserved: 0 }) - .encode() + RuntimeCall::Balances(pallet_balances::Call::set_balance { + who: 42, + new_free: value, + new_reserved: 0, + }) + .encode() } pub fn set_balance_proposal_hash(value: u64) -> H256 { diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index dae2b8eb7d62d..485a9dc3ae66a 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -3782,7 +3782,8 @@ fn payout_stakers_handles_weight_refund() { start_active_era(2); // Collect payouts when there are no nominators - let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 1 }); + let call = + TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 1 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3795,7 +3796,8 @@ fn payout_stakers_handles_weight_refund() { start_active_era(3); // Collect payouts for an era where the validator did not receive any points. - let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 2 }); + let call = + TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 2 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3808,7 +3810,8 @@ fn payout_stakers_handles_weight_refund() { start_active_era(4); // Collect payouts when the validator has `half_max_nom_rewarded` nominators. - let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 3 }); + let call = + TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 3 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3831,14 +3834,16 @@ fn payout_stakers_handles_weight_refund() { start_active_era(6); // Collect payouts when the validator had `half_max_nom_rewarded` nominators. - let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); + let call = + TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); assert_eq!(extract_actual_weight(&result, &info), max_nom_rewarded_weight); // Try and collect payouts for an era that has already been collected. - let call = TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); + let call = + TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert!(result.is_err()); diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index 6db70ef5e5ae3..e0b5cc8e96a5a 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -456,17 +456,17 @@ fn event_codec() { #[test] fn call_codec() { use codec::Encode; - assert_eq!(Call::System(system::Call::noop {}).encode()[0], 30); - assert_eq!(Call::Module1_1(module1::Call::fail {}).encode()[0], 31); - assert_eq!(Call::Module2(module2::Call::fail {}).encode()[0], 32); - assert_eq!(Call::Module1_2(module1::Call::fail {}).encode()[0], 33); - assert_eq!(Call::NestedModule3(nested::module3::Call::fail {}).encode()[0], 34); - assert_eq!(Call::Module3(module3::Call::fail {}).encode()[0], 35); - assert_eq!(Call::Module1_4(module1::Call::fail {}).encode()[0], 3); - assert_eq!(Call::Module1_6(module1::Call::fail {}).encode()[0], 1); - assert_eq!(Call::Module1_7(module1::Call::fail {}).encode()[0], 2); - assert_eq!(Call::Module1_8(module1::Call::fail {}).encode()[0], 12); - assert_eq!(Call::Module1_9(module1::Call::fail {}).encode()[0], 13); + assert_eq!(RuntimeCall::System(system::Call::noop {}).encode()[0], 30); + assert_eq!(RuntimeCall::Module1_1(module1::Call::fail {}).encode()[0], 31); + assert_eq!(RuntimeCall::Module2(module2::Call::fail {}).encode()[0], 32); + assert_eq!(RuntimeCall::Module1_2(module1::Call::fail {}).encode()[0], 33); + assert_eq!(RuntimeCall::NestedModule3(nested::module3::Call::fail {}).encode()[0], 34); + assert_eq!(RuntimeCall::Module3(module3::Call::fail {}).encode()[0], 35); + assert_eq!(RuntimeCall::Module1_4(module1::Call::fail {}).encode()[0], 3); + assert_eq!(RuntimeCall::Module1_6(module1::Call::fail {}).encode()[0], 1); + assert_eq!(RuntimeCall::Module1_7(module1::Call::fail {}).encode()[0], 2); + assert_eq!(RuntimeCall::Module1_8(module1::Call::fail {}).encode()[0], 12); + assert_eq!(RuntimeCall::Module1_9(module1::Call::fail {}).encode()[0], 13); } #[test] diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index cc55209f7f7ab..9d356fd97e230 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -608,7 +608,7 @@ frame_support::construct_runtime!( // Test that the part `Call` is excluded from Example2 and included in Example4. fn _ensure_call_is_correctly_excluded_and_included(call: Call) { match call { - Call::System(_) | Call::Example(_) | Call::Example4(_) => (), + RuntimeCall::System(_) | RuntimeCall::Example(_) | RuntimeCall::Example4(_) => (), } } @@ -692,7 +692,7 @@ fn inherent_expand() { let inherents = InherentData::new().create_extrinsics(); let expected = vec![UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_no_post_info {}), + function: RuntimeCall::Example(pallet::Call::foo_no_post_info {}), signature: None, }]; assert_eq!(expected, inherents); @@ -707,11 +707,11 @@ fn inherent_expand() { ), vec![ UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_no_post_info {}), + function: RuntimeCall::Example(pallet::Call::foo_no_post_info {}), signature: None, }, UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo { foo: 1, bar: 0 }), + function: RuntimeCall::Example(pallet::Call::foo { foo: 1, bar: 0 }), signature: None, }, ], @@ -729,11 +729,11 @@ fn inherent_expand() { ), vec![ UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_no_post_info {}), + function: RuntimeCall::Example(pallet::Call::foo_no_post_info {}), signature: None, }, UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo { foo: 0, bar: 0 }), + function: RuntimeCall::Example(pallet::Call::foo { foo: 0, bar: 0 }), signature: None, }, ], @@ -750,7 +750,7 @@ fn inherent_expand() { Digest::default(), ), vec![UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_storage_layer { foo: 0 }), + function: RuntimeCall::Example(pallet::Call::foo_storage_layer { foo: 0 }), signature: None, }], ); @@ -768,7 +768,7 @@ fn inherent_expand() { Digest::default(), ), vec![UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_no_post_info {}), + function: RuntimeCall::Example(pallet::Call::foo_no_post_info {}), signature: Some((1, (), ())), }], ); @@ -787,11 +787,11 @@ fn inherent_expand() { ), vec![ UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo { foo: 1, bar: 1 }), + function: RuntimeCall::Example(pallet::Call::foo { foo: 1, bar: 1 }), signature: None, }, UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_storage_layer { foo: 0 }), + function: RuntimeCall::Example(pallet::Call::foo_storage_layer { foo: 0 }), signature: None, }, ], @@ -809,15 +809,15 @@ fn inherent_expand() { ), vec![ UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo { foo: 1, bar: 1 }), + function: RuntimeCall::Example(pallet::Call::foo { foo: 1, bar: 1 }), signature: None, }, UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_storage_layer { foo: 0 }), + function: RuntimeCall::Example(pallet::Call::foo_storage_layer { foo: 0 }), signature: None, }, UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_no_post_info {}), + function: RuntimeCall::Example(pallet::Call::foo_no_post_info {}), signature: None, }, ], @@ -835,15 +835,15 @@ fn inherent_expand() { ), vec![ UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo { foo: 1, bar: 1 }), + function: RuntimeCall::Example(pallet::Call::foo { foo: 1, bar: 1 }), signature: None, }, UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo { foo: 1, bar: 0 }), + function: RuntimeCall::Example(pallet::Call::foo { foo: 1, bar: 0 }), signature: Some((1, (), ())), }, UncheckedExtrinsic { - function: Call::Example(pallet::Call::foo_no_post_info {}), + function: RuntimeCall::Example(pallet::Call::foo_no_post_info {}), signature: None, }, ], diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 25bd0bfadfd2d..7b76e3d318367 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -121,7 +121,7 @@ pub type SysEvent = frame_system::Event; /// A simple call, which one doesn't matter. pub const CALL: &::Call = - &Call::System(frame_system::Call::set_heap_pages { pages: 0u64 }); + &RuntimeCall::System(frame_system::Call::set_heap_pages { pages: 0u64 }); /// Create new externalities for `System` module tests. pub fn new_test_ext() -> sp_io::TestExternalities { diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index c6376e2ed187e..b6a358017513f 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -153,11 +153,11 @@ impl Contains for TestBaseCallFilter { match *c { // Transfer works. Use `transfer_keep_alive` for a call that doesn't pass the filter. RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => true, - Call::Utility(_) => true, + RuntimeCall::Utility(_) => true, // For benchmarking, this acts as a noop call - Call::System(frame_system::Call::remark { .. }) => true, + RuntimeCall::System(frame_system::Call::remark { .. }) => true, // For tests - Call::Example(_) => true, + RuntimeCall::Example(_) => true, _ => false, } } @@ -192,7 +192,7 @@ fn call_transfer(dest: u64, value: u64) -> Call { } fn call_foobar(err: bool, start_weight: u64, end_weight: Option) -> Call { - Call::Example(ExampleCall::foobar { err, start_weight, end_weight }) + RuntimeCall::Example(ExampleCall::foobar { err, start_weight, end_weight }) } #[test] @@ -219,8 +219,10 @@ fn as_derivative_handles_weight_refund() { // Full weight when ok let inner_call = call_foobar(false, start_weight, None); - let call = - Call::Utility(UtilityCall::as_derivative { index: 0, call: Box::new(inner_call) }); + let call = RuntimeCall::Utility(UtilityCall::as_derivative { + index: 0, + call: Box::new(inner_call), + }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -228,8 +230,10 @@ fn as_derivative_handles_weight_refund() { // Refund weight when ok let inner_call = call_foobar(false, start_weight, Some(end_weight)); - let call = - Call::Utility(UtilityCall::as_derivative { index: 0, call: Box::new(inner_call) }); + let call = RuntimeCall::Utility(UtilityCall::as_derivative { + index: 0, + call: Box::new(inner_call), + }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -238,8 +242,10 @@ fn as_derivative_handles_weight_refund() { // Full weight when err let inner_call = call_foobar(true, start_weight, None); - let call = - Call::Utility(UtilityCall::as_derivative { index: 0, call: Box::new(inner_call) }); + let call = RuntimeCall::Utility(UtilityCall::as_derivative { + index: 0, + call: Box::new(inner_call), + }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_noop!( @@ -256,8 +262,10 @@ fn as_derivative_handles_weight_refund() { // Refund weight when err let inner_call = call_foobar(true, start_weight, Some(end_weight)); - let call = - Call::Utility(UtilityCall::as_derivative { index: 0, call: Box::new(inner_call) }); + let call = RuntimeCall::Utility(UtilityCall::as_derivative { + index: 0, + call: Box::new(inner_call), + }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_noop!( @@ -295,16 +303,25 @@ fn as_derivative_filters() { fn batch_with_root_works() { new_test_ext().execute_with(|| { let k = b"a".to_vec(); - let call = - Call::System(frame_system::Call::set_storage { items: vec![(k.clone(), k.clone())] }); + let call = RuntimeCall::System(frame_system::Call::set_storage { + items: vec![(k.clone(), k.clone())], + }); assert!(!TestBaseCallFilter::contains(&call)); assert_eq!(Balances::free_balance(1), 10); assert_eq!(Balances::free_balance(2), 10); assert_ok!(Utility::batch( Origin::root(), vec![ - RuntimeCall::Balances(BalancesCall::force_transfer { source: 1, dest: 2, value: 5 }), - RuntimeCall::Balances(BalancesCall::force_transfer { source: 1, dest: 2, value: 5 }), + RuntimeCall::Balances(BalancesCall::force_transfer { + source: 1, + dest: 2, + value: 5 + }), + RuntimeCall::Balances(BalancesCall::force_transfer { + source: 1, + dest: 2, + value: 5 + }), call, // Check filters are correctly bypassed ] )); @@ -333,7 +350,10 @@ fn batch_with_signed_filters() { new_test_ext().execute_with(|| { assert_ok!(Utility::batch( Origin::signed(1), - vec![RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { dest: 2, value: 1 })] + vec![RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { + dest: 2, + value: 1 + })] ),); System::assert_last_event( utility::Event::BatchInterrupted { @@ -363,11 +383,12 @@ fn batch_early_exit_works() { fn batch_weight_calculation_doesnt_overflow() { use sp_runtime::Perbill; new_test_ext().execute_with(|| { - let big_call = Call::System(SystemCall::fill_block { ratio: Perbill::from_percent(50) }); + let big_call = + RuntimeCall::System(SystemCall::fill_block { ratio: Perbill::from_percent(50) }); assert_eq!(big_call.get_dispatch_info().weight, Weight::max_value() / 2); // 3 * 50% saturates to 100% - let batch_call = Call::Utility(crate::Call::batch { + let batch_call = RuntimeCall::Utility(crate::Call::batch { calls: vec![big_call.clone(), big_call.clone(), big_call.clone()], }); @@ -386,7 +407,7 @@ fn batch_handles_weight_refund() { // Full weight when ok let inner_call = call_foobar(false, start_weight, None); let batch_calls = vec![inner_call; batch_len as usize]; - let call = Call::Utility(UtilityCall::batch { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -395,7 +416,7 @@ fn batch_handles_weight_refund() { // Refund weight when ok let inner_call = call_foobar(false, start_weight, Some(end_weight)); let batch_calls = vec![inner_call; batch_len as usize]; - let call = Call::Utility(UtilityCall::batch { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -406,7 +427,7 @@ fn batch_handles_weight_refund() { let good_call = call_foobar(false, start_weight, None); let bad_call = call_foobar(true, start_weight, None); let batch_calls = vec![good_call, bad_call]; - let call = Call::Utility(UtilityCall::batch { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -421,7 +442,7 @@ fn batch_handles_weight_refund() { let bad_call = call_foobar(true, start_weight, Some(end_weight)); let batch_calls = vec![good_call, bad_call]; let batch_len = batch_calls.len() as Weight; - let call = Call::Utility(UtilityCall::batch { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -434,7 +455,7 @@ fn batch_handles_weight_refund() { let good_call = call_foobar(false, start_weight, Some(end_weight)); let bad_call = call_foobar(true, start_weight, Some(end_weight)); let batch_calls = vec![good_call, bad_call.clone(), bad_call]; - let call = Call::Utility(UtilityCall::batch { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -471,7 +492,7 @@ fn batch_all_revert() { assert_eq!(Balances::free_balance(1), 10); assert_eq!(Balances::free_balance(2), 10); - let batch_all_calls = Call::Utility(crate::Call::::batch_all { + let batch_all_calls = RuntimeCall::Utility(crate::Call::::batch_all { calls: vec![call_transfer(2, 5), call_transfer(2, 10), call_transfer(2, 5)], }); assert_noop!( @@ -502,7 +523,7 @@ fn batch_all_handles_weight_refund() { // Full weight when ok let inner_call = call_foobar(false, start_weight, None); let batch_calls = vec![inner_call; batch_len as usize]; - let call = Call::Utility(UtilityCall::batch_all { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch_all { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -511,7 +532,7 @@ fn batch_all_handles_weight_refund() { // Refund weight when ok let inner_call = call_foobar(false, start_weight, Some(end_weight)); let batch_calls = vec![inner_call; batch_len as usize]; - let call = Call::Utility(UtilityCall::batch_all { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch_all { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_ok!(result); @@ -522,7 +543,7 @@ fn batch_all_handles_weight_refund() { let good_call = call_foobar(false, start_weight, None); let bad_call = call_foobar(true, start_weight, None); let batch_calls = vec![good_call, bad_call]; - let call = Call::Utility(UtilityCall::batch_all { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch_all { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_err_ignore_postinfo!(result, "The cake is a lie."); @@ -534,7 +555,7 @@ fn batch_all_handles_weight_refund() { let bad_call = call_foobar(true, start_weight, Some(end_weight)); let batch_calls = vec![good_call, bad_call]; let batch_len = batch_calls.len() as Weight; - let call = Call::Utility(UtilityCall::batch_all { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch_all { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_err_ignore_postinfo!(result, "The cake is a lie."); @@ -544,7 +565,7 @@ fn batch_all_handles_weight_refund() { let good_call = call_foobar(false, start_weight, Some(end_weight)); let bad_call = call_foobar(true, start_weight, Some(end_weight)); let batch_calls = vec![good_call, bad_call.clone(), bad_call]; - let call = Call::Utility(UtilityCall::batch_all { calls: batch_calls }); + let call = RuntimeCall::Utility(UtilityCall::batch_all { calls: batch_calls }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(1)); assert_err_ignore_postinfo!(result, "The cake is a lie."); @@ -559,7 +580,7 @@ fn batch_all_handles_weight_refund() { #[test] fn batch_all_does_not_nest() { new_test_ext().execute_with(|| { - let batch_all = Call::Utility(UtilityCall::batch_all { + let batch_all = RuntimeCall::Utility(UtilityCall::batch_all { calls: vec![call_transfer(2, 1), call_transfer(2, 1), call_transfer(2, 1)], }); @@ -582,7 +603,7 @@ fn batch_all_does_not_nest() { // And for those who want to get a little fancy, we check that the filter persists across // other kinds of dispatch wrapping functions... in this case // `batch_all(batch(batch_all(..)))` - let batch_nested = Call::Utility(UtilityCall::batch { calls: vec![batch_all] }); + let batch_nested = RuntimeCall::Utility(UtilityCall::batch { calls: vec![batch_all] }); // Batch will end with `Ok`, but does not actually execute as we can see from the event // and balances. assert_ok!(Utility::batch_all(Origin::signed(1), vec![batch_nested])); @@ -601,7 +622,7 @@ fn batch_all_does_not_nest() { #[test] fn batch_limit() { new_test_ext().execute_with(|| { - let calls = vec![Call::System(SystemCall::remark { remark: vec![] }); 40_000]; + let calls = vec![RuntimeCall::System(SystemCall::remark { remark: vec![] }); 40_000]; assert_noop!(Utility::batch(Origin::signed(1), calls.clone()), Error::::TooManyCalls); assert_noop!(Utility::batch_all(Origin::signed(1), calls), Error::::TooManyCalls); }); diff --git a/frame/whitelist/src/tests.rs b/frame/whitelist/src/tests.rs index 67bccaeaeebe1..36db0609445b7 100644 --- a/frame/whitelist/src/tests.rs +++ b/frame/whitelist/src/tests.rs @@ -25,7 +25,7 @@ use sp_runtime::{traits::Hash, DispatchError}; #[test] fn test_whitelist_call_and_remove() { new_test_ext().execute_with(|| { - let call = Call::System(frame_system::Call::remark { remark: vec![] }); + let call = RuntimeCall::System(frame_system::Call::remark { remark: vec![] }); let encoded_call = call.encode(); let call_hash = ::Hashing::hash(&encoded_call[..]); @@ -67,7 +67,7 @@ fn test_whitelist_call_and_remove() { #[test] fn test_whitelist_call_and_execute() { new_test_ext().execute_with(|| { - let call = Call::System(frame_system::Call::remark_with_event { remark: vec![1] }); + let call = RuntimeCall::System(frame_system::Call::remark_with_event { remark: vec![1] }); let call_weight = call.get_dispatch_info().weight; let encoded_call = call.encode(); let call_hash = ::Hashing::hash(&encoded_call[..]); @@ -112,7 +112,7 @@ fn test_whitelist_call_and_execute() { #[test] fn test_whitelist_call_and_execute_failing_call() { new_test_ext().execute_with(|| { - let call = Call::Whitelist(crate::Call::dispatch_whitelisted_call { + let call = RuntimeCall::Whitelist(crate::Call::dispatch_whitelisted_call { call_hash: Default::default(), call_weight_witness: 0, }); @@ -131,8 +131,9 @@ fn test_whitelist_call_and_execute_failing_call() { #[test] fn test_whitelist_call_and_execute_without_note_preimage() { new_test_ext().execute_with(|| { - let call = - Box::new(Call::System(frame_system::Call::remark_with_event { remark: vec![1] })); + let call = Box::new(RuntimeCall::System(frame_system::Call::remark_with_event { + remark: vec![1], + })); let call_hash = ::Hashing::hash_of(&call); assert_ok!(Whitelist::whitelist_call(Origin::root(), call_hash)); @@ -155,7 +156,7 @@ fn test_whitelist_call_and_execute_without_note_preimage() { #[test] fn test_whitelist_call_and_execute_decode_consumes_all() { new_test_ext().execute_with(|| { - let call = Call::System(frame_system::Call::remark_with_event { remark: vec![1] }); + let call = RuntimeCall::System(frame_system::Call::remark_with_event { remark: vec![1] }); let call_weight = call.get_dispatch_info().weight; let mut call = call.encode(); // Appending something does not make the encoded call invalid. From 7bb234700078f581b65ef33fbd75603e969fa5ee Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 14:04:10 +0200 Subject: [PATCH 39/63] rename associated type --- docs/Upgrading-2.0-to-3.0.md | 2 +- frame/alliance/src/lib.rs | 2 +- frame/balances/src/tests.rs | 2 +- frame/contracts/src/exec.rs | 4 ++-- frame/contracts/src/lib.rs | 4 ++-- frame/contracts/src/wasm/mod.rs | 2 +- frame/contracts/src/wasm/runtime.rs | 2 +- frame/examples/basic/src/lib.rs | 4 ++-- frame/executive/src/lib.rs | 4 ++-- frame/lottery/src/lib.rs | 16 +++++++------- frame/multisig/src/benchmarking.rs | 4 ++-- frame/multisig/src/lib.rs | 6 ++--- frame/proxy/src/benchmarking.rs | 10 ++++----- frame/proxy/src/lib.rs | 14 ++++++------ frame/recovery/src/benchmarking.rs | 2 +- frame/recovery/src/lib.rs | 2 +- frame/scheduler/src/benchmarking.rs | 4 ++-- frame/scheduler/src/lib.rs | 10 ++++----- frame/staking/src/mock.rs | 2 +- frame/sudo/src/lib.rs | 6 ++--- .../src/construct_runtime/expand/origin.rs | 10 ++++----- .../src/construct_runtime/expand/unsigned.rs | 4 ++-- .../procedural/src/pallet/parse/mod.rs | 8 +++---- frame/support/src/dispatch.rs | 10 ++++----- frame/support/src/lib.rs | 12 +++++----- frame/support/src/traits/dispatch.rs | 6 ++--- frame/support/test/tests/instance.rs | 12 +++++----- frame/support/test/tests/pallet.rs | 8 +++---- frame/support/test/tests/pallet_instance.rs | 6 ++--- .../tests/pallet_with_name_trait_is_valid.rs | 10 ++++----- frame/support/test/tests/system.rs | 2 +- frame/system/src/extensions/check_genesis.rs | 2 +- .../system/src/extensions/check_mortality.rs | 2 +- .../src/extensions/check_non_zero_sender.rs | 4 ++-- frame/system/src/extensions/check_nonce.rs | 4 ++-- .../src/extensions/check_spec_version.rs | 2 +- .../system/src/extensions/check_tx_version.rs | 2 +- frame/system/src/extensions/check_weight.rs | 22 +++++++++---------- frame/system/src/lib.rs | 8 +++---- frame/system/src/mock.rs | 4 ++-- frame/system/src/mocking.rs | 2 +- frame/system/src/offchain.rs | 6 ++--- .../asset-tx-payment/src/tests.rs | 2 +- frame/transaction-payment/src/lib.rs | 2 +- frame/utility/src/benchmarking.rs | 6 ++--- frame/utility/src/lib.rs | 20 ++++++++--------- frame/whitelist/src/benchmarking.rs | 4 ++-- frame/whitelist/src/lib.rs | 8 +++---- test-utils/runtime/src/lib.rs | 8 +++---- 49 files changed, 149 insertions(+), 149 deletions(-) diff --git a/docs/Upgrading-2.0-to-3.0.md b/docs/Upgrading-2.0-to-3.0.md index f750c6dd5865b..22f9c6c7125d2 100644 --- a/docs/Upgrading-2.0-to-3.0.md +++ b/docs/Upgrading-2.0-to-3.0.md @@ -148,7 +148,7 @@ And update the overall definition for weights on frame and a few related types a + type BlockLength = RuntimeBlockLength; + type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = Call; + type RuntimeCall = RuntimeCall; type Index = Index; @@ -171,25 +198,19 @@ impl frame_system::Trait for Runtime { type Header = generic::Header; diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index c263121fefe8b..1c10661cef39e 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -233,7 +233,7 @@ pub mod pallet { + From> + GetDispatchInfo + IsSubType> - + IsType<::Call>; + + IsType<::RuntimeCall>; /// Origin for admin-level operations, like setting the Alliance's rules. type AdminOrigin: EnsureOrigin; diff --git a/frame/balances/src/tests.rs b/frame/balances/src/tests.rs index 27723fd8d72ad..b84ecb28cfa57 100644 --- a/frame/balances/src/tests.rs +++ b/frame/balances/src/tests.rs @@ -38,7 +38,7 @@ 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 = + 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. diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 9f9d8ad2c554b..b0a246b12ddef 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -282,7 +282,7 @@ pub trait Ext: sealing::Sealed { fn append_debug_buffer(&mut self, msg: &str) -> bool; /// Call some dispatchable and return the result. - fn call_runtime(&self, call: ::Call) -> DispatchResultWithPostInfo; + fn call_runtime(&self, call: ::RuntimeCall) -> DispatchResultWithPostInfo; /// Recovers ECDSA compressed public key based on signature and message hash. fn ecdsa_recover(&self, signature: &[u8; 65], message_hash: &[u8; 32]) -> Result<[u8; 33], ()>; @@ -1279,7 +1279,7 @@ where } } - fn call_runtime(&self, call: ::Call) -> DispatchResultWithPostInfo { + fn call_runtime(&self, call: ::RuntimeCall) -> DispatchResultWithPostInfo { let mut origin: T::Origin = RawOrigin::Signed(self.address().clone()).into(); origin.add_filter(T::CallFilter::contains); call.dispatch(origin) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 838445edd5947..9e1548bd5dee7 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -249,7 +249,7 @@ pub mod pallet { type Call: Dispatchable + GetDispatchInfo + codec::Decode - + IsType<::Call>; + + IsType<::RuntimeCall>; /// Filter that is applied to calls dispatched by contracts. /// @@ -270,7 +270,7 @@ pub mod pallet { /// Therefore please make sure to be restrictive about which dispatchables are allowed /// in order to not introduce a new DoS vector like memory allocation patterns that can /// be exploited to drive the runtime into a panic. - type CallFilter: Contains<::Call>; + type CallFilter: Contains<::RuntimeCall>; /// Used to answer contracts' queries regarding the current weight price. This is **not** /// used to calculate the actual fee and is only for informational purposes. diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index 968096821f463..c94c0e744b7f0 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -532,7 +532,7 @@ mod tests { self.debug_buffer.extend(msg.as_bytes()); true } - fn call_runtime(&self, call: ::Call) -> DispatchResultWithPostInfo { + fn call_runtime(&self, call: ::RuntimeCall) -> DispatchResultWithPostInfo { self.runtime_calls.borrow_mut().push(call); Ok(Default::default()) } diff --git a/frame/contracts/src/wasm/runtime.rs b/frame/contracts/src/wasm/runtime.rs index 1d5478a5277cd..0c50d6e1f5a6d 100644 --- a/frame/contracts/src/wasm/runtime.rs +++ b/frame/contracts/src/wasm/runtime.rs @@ -2302,7 +2302,7 @@ pub mod env { ) -> Result { use frame_support::{dispatch::GetDispatchInfo, weights::extract_actual_weight}; ctx.charge_gas(RuntimeCosts::CopyFromContract(call_len))?; - let call: ::Call = + let call: ::RuntimeCall = ctx.read_sandbox_memory_as_unbounded(call_ptr, call_len)?; let dispatch_info = call.get_dispatch_info(); let charged = ctx.charge_gas(RuntimeCosts::CallRuntime(dispatch_info.weight))?; diff --git a/frame/examples/basic/src/lib.rs b/frame/examples/basic/src/lib.rs index cdd0b1cea0cd0..0713a4ef857a5 100644 --- a/frame/examples/basic/src/lib.rs +++ b/frame/examples/basic/src/lib.rs @@ -719,11 +719,11 @@ impl sp_std::fmt::Debug for WatchDummy { impl SignedExtension for WatchDummy where - ::Call: IsSubType>, + ::RuntimeCall: IsSubType>, { const IDENTIFIER: &'static str = "WatchDummy"; type AccountId = T::AccountId; - type Call = ::Call; + type Call = ::RuntimeCall; type AdditionalSigned = (); type Pre = (); diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 81da9ff582b96..119b8e9e6714f 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -66,7 +66,7 @@ //! # }; //! # use sp_runtime::traits::ValidateUnsigned; //! # impl ValidateUnsigned for Runtime { -//! # type Call = (); +//! # type RuntimeCall = (); //! # //! # fn validate_unsigned(_source: TransactionSource, _call: &Self::Call) -> TransactionValidity { //! # UnknownTransaction::NoUnsignedValidator.into() @@ -97,7 +97,7 @@ //! # }; //! # use sp_runtime::traits::ValidateUnsigned; //! # impl ValidateUnsigned for Runtime { -//! # type Call = (); +//! # type RuntimeCall = (); //! # //! # fn validate_unsigned(_source: TransactionSource, _call: &Self::Call) -> TransactionValidity { //! # UnknownTransaction::NoUnsignedValidator.into() diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index c8989665768e4..8f732eb79326c 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -96,17 +96,17 @@ pub struct LotteryConfig { } pub trait ValidateCall { - fn validate_call(call: &::Call) -> bool; + fn validate_call(call: &::RuntimeCall) -> bool; } impl ValidateCall for () { - fn validate_call(_: &::Call) -> bool { + fn validate_call(_: &::RuntimeCall) -> bool { false } } impl ValidateCall for Pallet { - fn validate_call(call: &::Call) -> bool { + fn validate_call(call: &::RuntimeCall) -> bool { let valid_calls = CallIndices::::get(); let call_index = match Self::call_to_index(call) { Ok(call_index) => call_index, @@ -300,7 +300,7 @@ pub mod pallet { T::WeightInfo::buy_ticket() .saturating_add(call.get_dispatch_info().weight) )] - pub fn buy_ticket(origin: OriginFor, call: Box<::Call>) -> DispatchResult { + pub fn buy_ticket(origin: OriginFor, call: Box<::RuntimeCall>) -> DispatchResult { let caller = ensure_signed(origin.clone())?; call.clone().dispatch(origin).map_err(|e| e.error)?; @@ -315,7 +315,7 @@ pub mod pallet { /// /// This extrinsic must be called by the Manager origin. #[pallet::weight(T::WeightInfo::set_calls(calls.len() as u32))] - pub fn set_calls(origin: OriginFor, calls: Vec<::Call>) -> DispatchResult { + pub fn set_calls(origin: OriginFor, calls: Vec<::RuntimeCall>) -> DispatchResult { T::ManagerOrigin::ensure_origin(origin)?; ensure!(calls.len() <= T::MaxCalls::get() as usize, Error::::TooManyCalls); if calls.is_empty() { @@ -404,7 +404,7 @@ impl Pallet { /// Converts a vector of calls into a vector of call indices. fn calls_to_indices( - calls: &[::Call], + calls: &[::RuntimeCall], ) -> Result, DispatchError> { let mut indices = BoundedVec::::with_bounded_capacity(calls.len()); for c in calls.iter() { @@ -415,7 +415,7 @@ impl Pallet { } /// Convert a call to it's call index by encoding the call and taking the first two bytes. - fn call_to_index(call: &::Call) -> Result { + fn call_to_index(call: &::RuntimeCall) -> Result { let encoded_call = call.encode(); if encoded_call.len() < 2 { return Err(Error::::EncodingFailed.into()) @@ -424,7 +424,7 @@ impl Pallet { } /// Logic for buying a ticket. - fn do_buy_ticket(caller: &T::AccountId, call: &::Call) -> DispatchResult { + fn do_buy_ticket(caller: &T::AccountId, call: &::RuntimeCall) -> DispatchResult { // Check the call is valid lottery let config = Lottery::::get().ok_or(Error::::NotConfigured)?; let block_number = frame_system::Pallet::::block_number(); diff --git a/frame/multisig/src/benchmarking.rs b/frame/multisig/src/benchmarking.rs index 8201426f5330f..dc880512bfe30 100644 --- a/frame/multisig/src/benchmarking.rs +++ b/frame/multisig/src/benchmarking.rs @@ -42,7 +42,7 @@ fn setup_multi( } signatories.sort(); // Must first convert to outer call type. - let call: ::Call = + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![0; z as usize] }.into(); let call_data = OpaqueCall::::from_encoded(call.encode()); Ok((signatories, call_data)) @@ -54,7 +54,7 @@ benchmarks! { let z in 0 .. 10_000; let max_signatories = T::MaxSignatories::get().into(); let (mut signatories, _) = setup_multi::(max_signatories, z)?; - let call: ::Call = frame_system::Call::::remark { + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![0; z as usize] }.into(); let call_hash = call.using_encoded(blake2_256); diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index b49ad7720f8b5..9ef571c1cd551 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -99,7 +99,7 @@ pub struct Multisig { approvals: Vec, } -type OpaqueCall = WrapperKeepOpaque<::Call>; +type OpaqueCall = WrapperKeepOpaque<::RuntimeCall>; type CallHash = [u8; 32]; @@ -266,7 +266,7 @@ pub mod pallet { pub fn as_multi_threshold_1( origin: OriginFor, other_signatories: Vec, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let max_sigs = T::MaxSignatories::get() as usize; @@ -695,7 +695,7 @@ impl Pallet { fn get_call( hash: &[u8; 32], maybe_known: Option<&OpaqueCall>, - ) -> Option<(::Call, usize)> { + ) -> Option<(::RuntimeCall, usize)> { maybe_known.map_or_else( || { Calls::::get(hash) diff --git a/frame/proxy/src/benchmarking.rs b/frame/proxy/src/benchmarking.rs index 11171eebcf04f..f7e440d1f7d6f 100644 --- a/frame/proxy/src/benchmarking.rs +++ b/frame/proxy/src/benchmarking.rs @@ -88,7 +88,7 @@ benchmarks! { // ... and "real" is the traditional caller. This is not a typo. let real: T::AccountId = whitelisted_caller(); let real_lookup = T::Lookup::unlookup(real); - let call: ::Call = frame_system::Call::::remark { remark: vec![] }.into(); + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![] }.into(); }: _(RawOrigin::Signed(caller), real_lookup, Some(T::ProxyType::default()), Box::new(call)) verify { assert_last_event::(Event::ProxyExecuted { result: Ok(()) }.into()) @@ -105,7 +105,7 @@ benchmarks! { // ... and "real" is the traditional caller. This is not a typo. let real: T::AccountId = whitelisted_caller(); let real_lookup = T::Lookup::unlookup(real); - let call: ::Call = frame_system::Call::::remark { remark: vec![] }.into(); + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![] }.into(); Proxy::::announce( RawOrigin::Signed(delegate.clone()).into(), real_lookup.clone(), @@ -126,7 +126,7 @@ benchmarks! { // ... and "real" is the traditional caller. This is not a typo. let real: T::AccountId = whitelisted_caller(); let real_lookup = T::Lookup::unlookup(real); - let call: ::Call = frame_system::Call::::remark { remark: vec![] }.into(); + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![] }.into(); Proxy::::announce( RawOrigin::Signed(caller.clone()).into(), real_lookup.clone(), @@ -149,7 +149,7 @@ benchmarks! { // ... and "real" is the traditional caller. This is not a typo. let real: T::AccountId = whitelisted_caller(); let real_lookup = T::Lookup::unlookup(real.clone()); - let call: ::Call = frame_system::Call::::remark { remark: vec![] }.into(); + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![] }.into(); Proxy::::announce( RawOrigin::Signed(caller.clone()).into(), real_lookup, @@ -172,7 +172,7 @@ benchmarks! { let real: T::AccountId = whitelisted_caller(); let real_lookup = T::Lookup::unlookup(real.clone()); add_announcements::(a, Some(caller.clone()), None)?; - let call: ::Call = frame_system::Call::::remark { remark: vec![] }.into(); + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![] }.into(); let call_hash = T::CallHasher::hash_of(&call); }: _(RawOrigin::Signed(caller.clone()), real_lookup, call_hash) verify { diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index 673abd7b0708b..d358b29c9772e 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -118,7 +118,7 @@ pub mod pallet { + GetDispatchInfo + From> + IsSubType> - + IsType<::Call>; + + IsType<::RuntimeCall>; /// The currency mechanism. type Currency: ReservableCurrency; @@ -131,7 +131,7 @@ pub mod pallet { + Member + Ord + PartialOrd - + InstanceFilter<::Call> + + InstanceFilter<::RuntimeCall> + Default + MaxEncodedLen; @@ -208,7 +208,7 @@ pub mod pallet { origin: OriginFor, real: AccountIdLookupOf, force_proxy_type: Option, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResult { let who = ensure_signed(origin)?; let real = T::Lookup::lookup(real)?; @@ -539,7 +539,7 @@ pub mod pallet { delegate: AccountIdLookupOf, real: AccountIdLookupOf, force_proxy_type: Option, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResult { ensure_signed(origin)?; let delegate = T::Lookup::lookup(delegate)?; @@ -817,12 +817,12 @@ impl Pallet { fn do_proxy( def: ProxyDefinition, real: T::AccountId, - call: ::Call, + call: ::RuntimeCall, ) { // This is a freshly authenticated new account, the origin restrictions doesn't apply. let mut origin: T::Origin = frame_system::RawOrigin::Signed(real).into(); - origin.add_filter(move |c: &::Call| { - let c = ::Call::from_ref(c); + origin.add_filter(move |c: &::RuntimeCall| { + let c = ::RuntimeCall::from_ref(c); // We make sure the proxy call does access this pallet to change modify proxies. match c.is_sub_type() { // Proxy call cannot add or remove a proxy with more permissions than it already diff --git a/frame/recovery/src/benchmarking.rs b/frame/recovery/src/benchmarking.rs index 9e085a01d1167..870543d9bd290 100644 --- a/frame/recovery/src/benchmarking.rs +++ b/frame/recovery/src/benchmarking.rs @@ -107,7 +107,7 @@ benchmarks! { let caller: T::AccountId = whitelisted_caller(); let recovered_account: T::AccountId = account("recovered_account", 0, SEED); let recovered_account_lookup = T::Lookup::unlookup(recovered_account.clone()); - let call: ::Call = frame_system::Call::::remark { remark: vec![] }.into(); + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![] }.into(); Proxy::::insert(&caller, &recovered_account); }: _( diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index 5d10caabdeb9b..e3de75a7fcbc0 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -384,7 +384,7 @@ pub mod pallet { pub fn as_recovered( origin: OriginFor, account: AccountIdLookupOf, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResult { let who = ensure_signed(origin)?; let account = T::Lookup::lookup(account)?; diff --git a/frame/scheduler/src/benchmarking.rs b/frame/scheduler/src/benchmarking.rs index a8e36b72814b7..fbd59555b5ebc 100644 --- a/frame/scheduler/src/benchmarking.rs +++ b/frame/scheduler/src/benchmarking.rs @@ -77,9 +77,9 @@ fn fill_schedule( Ok(()) } -fn call_and_hash(i: u32) -> (::Call, T::Hash) { +fn call_and_hash(i: u32) -> (::RuntimeCall, T::Hash) { // Essentially a no-op call. - let call: ::Call = frame_system::Call::remark { remark: i.encode() }.into(); + let call: ::RuntimeCall = frame_system::Call::remark { remark: i.encode() }.into(); let hash = T::Hashing::hash_of(&call); (call, hash) } diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index b46df64d7608d..87bf57f778077 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -82,7 +82,7 @@ pub type PeriodicIndex = u32; /// The location of a scheduled task that can be used to remove it. pub type TaskAddress = (BlockNumber, u32); -pub type CallOrHashOf = MaybeHashed<::Call, ::Hash>; +pub type CallOrHashOf = MaybeHashed<::RuntimeCall, ::Hash>; #[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))] #[derive(Clone, RuntimeDebug, Encode, Decode)] @@ -113,7 +113,7 @@ pub struct ScheduledV3 { use crate::ScheduledV3 as ScheduledV2; pub type ScheduledV2Of = ScheduledV3< - ::Call, + ::RuntimeCall, ::BlockNumber, ::PalletsOrigin, ::AccountId, @@ -543,7 +543,7 @@ impl Pallet { pub fn migrate_v1_to_v3() -> Weight { let mut weight = T::DbWeight::get().reads_writes(1, 1); - Agenda::::translate::::Call, T::BlockNumber>>>, _>( + Agenda::::translate::::RuntimeCall, T::BlockNumber>>>, _>( |_, agenda| { Some( agenda @@ -859,7 +859,7 @@ impl Pallet { } } -impl schedule::v2::Anon::Call, T::PalletsOrigin> +impl schedule::v2::Anon::RuntimeCall, T::PalletsOrigin> for Pallet { type Address = TaskAddress; @@ -891,7 +891,7 @@ impl schedule::v2::Anon::Call, T::Palle } } -impl schedule::v2::Named::Call, T::PalletsOrigin> +impl schedule::v2::Named::RuntimeCall, T::PalletsOrigin> for Pallet { type Address = TaskAddress; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 9ed98c167833e..e758b75917d63 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -305,7 +305,7 @@ impl crate::pallet::pallet::Config for Test { } pub(crate) type StakingCall = crate::Call; -pub(crate) type TestCall = ::Call; +pub(crate) type TestCall = ::RuntimeCall; pub struct ExtBuilder { nominate: bool, diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 36b47a2992448..6cee27f018c7e 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -143,7 +143,7 @@ pub mod pallet { })] pub fn sudo( origin: OriginFor, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { // This is a public call, so we ensure that the origin is some signed account. let sender = ensure_signed(origin)?; @@ -168,7 +168,7 @@ pub mod pallet { #[pallet::weight((*_weight, call.get_dispatch_info().class))] pub fn sudo_unchecked_weight( origin: OriginFor, - call: Box<::Call>, + call: Box<::RuntimeCall>, _weight: Weight, ) -> DispatchResultWithPostInfo { // This is a public call, so we ensure that the origin is some signed account. @@ -231,7 +231,7 @@ pub mod pallet { pub fn sudo_as( origin: OriginFor, who: AccountIdLookupOf, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { // This is a public call, so we ensure that the origin is some signed account. let sender = ensure_signed(origin)?; diff --git a/frame/support/procedural/src/construct_runtime/expand/origin.rs b/frame/support/procedural/src/construct_runtime/expand/origin.rs index 46f08832f0bb4..b4e4f723c1e5e 100644 --- a/frame/support/procedural/src/construct_runtime/expand/origin.rs +++ b/frame/support/procedural/src/construct_runtime/expand/origin.rs @@ -104,7 +104,7 @@ pub fn expand_outer_origin( #[derive(Clone)] pub struct Origin { caller: OriginCaller, - filter: #scrate::sp_std::rc::Rc::Call) -> bool>>, + filter: #scrate::sp_std::rc::Rc::RuntimeCall) -> bool>>, } #[cfg(not(feature = "std"))] @@ -131,11 +131,11 @@ pub fn expand_outer_origin( } impl #scrate::traits::OriginTrait for Origin { - type Call = <#runtime as #system_path::Config>::Call; + type Call = <#runtime as #system_path::Config>::RuntimeCall; type PalletsOrigin = OriginCaller; type AccountId = <#runtime as #system_path::Config>::AccountId; - fn add_filter(&mut self, filter: impl Fn(&Self::Call) -> bool + 'static) { + fn add_filter(&mut self, filter: impl Fn(&Self::RuntimeCall) -> bool + 'static) { let f = self.filter.clone(); self.filter = #scrate::sp_std::rc::Rc::new(Box::new(move |call| { @@ -146,7 +146,7 @@ pub fn expand_outer_origin( fn reset_filter(&mut self) { let filter = < <#runtime as #system_path::Config>::BaseCallFilter - as #scrate::traits::Contains<<#runtime as #system_path::Config>::Call> + as #scrate::traits::Contains<<#runtime as #system_path::Config>::RuntimeCall> >::contains; self.filter = #scrate::sp_std::rc::Rc::new(Box::new(filter)); @@ -156,7 +156,7 @@ pub fn expand_outer_origin( self.caller = other.into().caller; } - fn filter_call(&self, call: &Self::Call) -> bool { + fn filter_call(&self, call: &Self::RuntimeCall) -> bool { match self.caller { // Root bypasses all filters OriginCaller::system(#system_path::Origin::<#runtime>::Root) => true, diff --git a/frame/support/procedural/src/construct_runtime/expand/unsigned.rs b/frame/support/procedural/src/construct_runtime/expand/unsigned.rs index 908f02fddf393..6df9df3b16c4b 100644 --- a/frame/support/procedural/src/construct_runtime/expand/unsigned.rs +++ b/frame/support/procedural/src/construct_runtime/expand/unsigned.rs @@ -46,7 +46,7 @@ pub fn expand_outer_validate_unsigned( impl #scrate::unsigned::ValidateUnsigned for #runtime { type Call = RuntimeCall; - fn pre_dispatch(call: &Self::Call) -> Result<(), #scrate::unsigned::TransactionValidityError> { + fn pre_dispatch(call: &Self::RuntimeCall) -> Result<(), #scrate::unsigned::TransactionValidityError> { #[allow(unreachable_patterns)] match call { #( Call::#pallet_names(inner_call) => #pallet_names::pre_dispatch(inner_call), )* @@ -59,7 +59,7 @@ pub fn expand_outer_validate_unsigned( fn validate_unsigned( #[allow(unused_variables)] source: #scrate::unsigned::TransactionSource, - call: &Self::Call, + call: &Self::RuntimeCall, ) -> #scrate::unsigned::TransactionValidity { #[allow(unreachable_patterns)] match call { diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index 763daa2c07421..e9bd35b1fff72 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -105,7 +105,7 @@ impl Def { let m = hooks::HooksDef::try_from(span, index, item)?; hooks = Some(m); }, - Some(PalletAttr::Call(span)) if call.is_none() => + Some(PalletAttr::RuntimeCall(span)) if call.is_none() => call = Some(call::CallDef::try_from(span, index, item)?), Some(PalletAttr::Error(span)) if error.is_none() => error = Some(error::ErrorDef::try_from(span, index, item)?), @@ -391,7 +391,7 @@ enum PalletAttr { Config(proc_macro2::Span), Pallet(proc_macro2::Span), Hooks(proc_macro2::Span), - Call(proc_macro2::Span), + RuntimeCall(proc_macro2::Span), Error(proc_macro2::Span), RuntimeEvent(proc_macro2::Span), Origin(proc_macro2::Span), @@ -410,7 +410,7 @@ impl PalletAttr { Self::Config(span) => *span, Self::Pallet(span) => *span, Self::Hooks(span) => *span, - Self::Call(span) => *span, + Self::RuntimeCall(span) => *span, Self::Error(span) => *span, Self::RuntimeEvent(span) => *span, Self::Origin(span) => *span, @@ -441,7 +441,7 @@ impl syn::parse::Parse for PalletAttr { } else if lookahead.peek(keyword::hooks) { Ok(PalletAttr::Hooks(content.parse::()?.span())) } else if lookahead.peek(keyword::call) { - Ok(PalletAttr::Call(content.parse::()?.span())) + Ok(PalletAttr::RuntimeCall(content.parse::()?.span())) } else if lookahead.peek(keyword::error) { Ok(PalletAttr::Error(content.parse::()?.span())) } else if lookahead.peek(keyword::event) { diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index c9c089fd1e8d6..c985f224df531 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -2614,7 +2614,7 @@ mod tests { type AccountId; type Call; type BaseCallFilter; - type Origin: crate::traits::OriginTrait; + type Origin: crate::traits::OriginTrait; type BlockNumber: Into; type PalletInfo: crate::traits::PalletInfo; type DbWeight: Get; @@ -2715,11 +2715,11 @@ mod tests { } impl crate::traits::OriginTrait for OuterOrigin { - type Call = ::Call; + type Call = ::RuntimeCall; type PalletsOrigin = OuterOrigin; type AccountId = ::AccountId; - fn add_filter(&mut self, _filter: impl Fn(&Self::Call) -> bool + 'static) { + fn add_filter(&mut self, _filter: impl Fn(&Self::RuntimeCall) -> bool + 'static) { unimplemented!("Not required in tests!") } @@ -2731,7 +2731,7 @@ mod tests { unimplemented!("Not required in tests!") } - fn filter_call(&self, _call: &Self::Call) -> bool { + fn filter_call(&self, _call: &Self::RuntimeCall) -> bool { unimplemented!("Not required in tests!") } @@ -2763,7 +2763,7 @@ mod tests { impl system::Config for TraitImpl { type Origin = OuterOrigin; type AccountId = u32; - type Call = (); + type RuntimeCall = (); type BaseCallFilter = frame_support::traits::Everything; type BlockNumber = u32; type PalletInfo = Self; diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 024f3225c3ca3..5d8ea61abaef2 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2170,7 +2170,7 @@ pub mod pallet_prelude { /// type Call = Call; /// fn validate_unsigned( /// source: TransactionSource, -/// call: &Self::Call +/// call: &Self::RuntimeCall /// ) -> TransactionValidity { /// Err(TransactionValidityError::Invalid(InvalidTransaction::Call)) /// } @@ -2184,11 +2184,11 @@ pub mod pallet_prelude { /// /// const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; /// -/// fn create_inherent(_data: &InherentData) -> Option { +/// fn create_inherent(_data: &InherentData) -> Option { /// unimplemented!(); /// } /// -/// fn is_inherent(_call: &Self::Call) -> bool { +/// fn is_inherent(_call: &Self::RuntimeCall) -> bool { /// unimplemented!(); /// } /// } @@ -2302,7 +2302,7 @@ pub mod pallet_prelude { /// type Call = Call; /// fn validate_unsigned( /// source: TransactionSource, -/// call: &Self::Call +/// call: &Self::RuntimeCall /// ) -> TransactionValidity { /// Err(TransactionValidityError::Invalid(InvalidTransaction::Call)) /// } @@ -2315,11 +2315,11 @@ pub mod pallet_prelude { /// /// const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; /// -/// fn create_inherent(_data: &InherentData) -> Option { +/// fn create_inherent(_data: &InherentData) -> Option { /// unimplemented!(); /// } /// -/// fn is_inherent(_call: &Self::Call) -> bool { +/// fn is_inherent(_call: &Self::RuntimeCall) -> bool { /// unimplemented!(); /// } /// } diff --git a/frame/support/src/traits/dispatch.rs b/frame/support/src/traits/dispatch.rs index afc819aa454e5..493abb8a13fef 100644 --- a/frame/support/src/traits/dispatch.rs +++ b/frame/support/src/traits/dispatch.rs @@ -239,7 +239,7 @@ pub trait UnfilteredDispatchable { /// Methods available on `frame_system::Config::Origin`. pub trait OriginTrait: Sized { /// Runtime call type, as in `frame_system::Config::Call` - type Call; + type RuntimeCall; /// The caller origin, overarching type of all pallets origins. type PalletsOrigin: Parameter @@ -252,7 +252,7 @@ pub trait OriginTrait: Sized { type AccountId; /// Add a filter to the origin. - fn add_filter(&mut self, filter: impl Fn(&Self::Call) -> bool + 'static); + fn add_filter(&mut self, filter: impl Fn(&Self::RuntimeCall) -> bool + 'static); /// Reset origin filters to default one, i.e `frame_system::Config::BaseCallFilter`. fn reset_filter(&mut self); @@ -264,7 +264,7 @@ pub trait OriginTrait: Sized { /// out. /// /// For root origin caller, the filters are bypassed and true is returned. - fn filter_call(&self, call: &Self::Call) -> bool; + fn filter_call(&self, call: &Self::RuntimeCall) -> bool; /// Get the caller. fn caller(&self) -> &Self::PalletsOrigin; diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 08d71e792379e..8197ec8640fca 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -129,18 +129,18 @@ mod module1 { type Error = MakeFatalError<()>; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &InherentData) -> Option { + fn create_inherent(_data: &InherentData) -> Option { unimplemented!(); } fn check_inherent( - _: &Self::Call, + _: &Self::RuntimeCall, _: &InherentData, ) -> std::result::Result<(), Self::Error> { unimplemented!(); } - fn is_inherent(_call: &Self::Call) -> bool { + fn is_inherent(_call: &Self::RuntimeCall) -> bool { unimplemented!(); } } @@ -198,18 +198,18 @@ mod module2 { type Error = MakeFatalError<()>; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &InherentData) -> Option { + fn create_inherent(_data: &InherentData) -> Option { unimplemented!(); } fn check_inherent( - _call: &Self::Call, + _call: &Self::RuntimeCall, _data: &InherentData, ) -> std::result::Result<(), Self::Error> { unimplemented!(); } - fn is_inherent(_call: &Self::Call) -> bool { + fn is_inherent(_call: &Self::RuntimeCall) -> bool { unimplemented!(); } } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 9d356fd97e230..79f134d2712f5 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -376,7 +376,7 @@ pub mod pallet { T::AccountId: From + SomeAssociation1 + From + From, { type Call = Call; - fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { + fn validate_unsigned(_source: TransactionSource, call: &Self::RuntimeCall) -> TransactionValidity { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType5); // Test for where clause if matches!(call, Call::foo_storage_layer { .. }) { @@ -396,17 +396,17 @@ pub mod pallet { const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &InherentData) -> Option { + fn create_inherent(_data: &InherentData) -> Option { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType6); // Test for where clause Some(Call::foo_no_post_info {}) } - fn is_inherent(call: &Self::Call) -> bool { + fn is_inherent(call: &Self::RuntimeCall) -> bool { matches!(call, Call::foo_no_post_info {} | Call::foo { .. }) } - fn check_inherent(call: &Self::Call, _: &InherentData) -> Result<(), Self::Error> { + fn check_inherent(call: &Self::RuntimeCall, _: &InherentData) -> Result<(), Self::Error> { match call { Call::foo_no_post_info {} => Ok(()), Call::foo { foo: 0, bar: 0 } => Err(InherentError::Fatal), diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index 841b4ff003100..b253e613647a1 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -176,7 +176,7 @@ pub mod pallet { type Call = Call; fn validate_unsigned( _source: TransactionSource, - _call: &Self::Call, + _call: &Self::RuntimeCall, ) -> TransactionValidity { Err(TransactionValidityError::Invalid(InvalidTransaction::Call)) } @@ -189,11 +189,11 @@ pub mod pallet { const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &InherentData) -> Option { + fn create_inherent(_data: &InherentData) -> Option { unimplemented!(); } - fn is_inherent(_call: &Self::Call) -> bool { + fn is_inherent(_call: &Self::RuntimeCall) -> bool { unimplemented!(); } } diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 41806d4b9a4e7..d92a257b2c21e 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -64,7 +64,7 @@ impl sp_runtime::traits::ValidateUnsigned for Module { fn validate_unsigned( _source: sp_runtime::transaction_validity::TransactionSource, - _call: &Self::Call, + _call: &Self::RuntimeCall, ) -> sp_runtime::transaction_validity::TransactionValidity { unimplemented!(); } @@ -77,18 +77,18 @@ impl frame_support::inherent::ProvideInherent for Module { type Error = frame_support::inherent::MakeFatalError<()>; const INHERENT_IDENTIFIER: frame_support::inherent::InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &frame_support::inherent::InherentData) -> Option { + fn create_inherent(_data: &frame_support::inherent::InherentData) -> Option { unimplemented!(); } fn check_inherent( - _: &Self::Call, + _: &Self::RuntimeCall, _: &frame_support::inherent::InherentData, ) -> std::result::Result<(), Self::Error> { unimplemented!(); } - fn is_inherent(_call: &Self::Call) -> bool { + fn is_inherent(_call: &Self::RuntimeCall) -> bool { unimplemented!(); } } @@ -108,7 +108,7 @@ mod tests { type TestHeader = sp_runtime::generic::Header; type TestUncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic< ::AccountId, - ::Call, + ::RuntimeCall, (), SignedExtra, >; diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index ca9e001ca0a7f..e9489029f45b5 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -25,7 +25,7 @@ pub trait Config: 'static + Eq + Clone { type Origin: Into, Self::Origin>> + From>; - type BaseCallFilter: frame_support::traits::Contains; + type BaseCallFilter: frame_support::traits::Contains; type BlockNumber: Decode + Encode + EncodeLike + Clone + Default + scale_info::TypeInfo; type Hash; type AccountId: Encode + EncodeLike + Decode + scale_info::TypeInfo; diff --git a/frame/system/src/extensions/check_genesis.rs b/frame/system/src/extensions/check_genesis.rs index a0679b11487f6..f5811f306cfe3 100644 --- a/frame/system/src/extensions/check_genesis.rs +++ b/frame/system/src/extensions/check_genesis.rs @@ -54,7 +54,7 @@ impl CheckGenesis { impl SignedExtension for CheckGenesis { type AccountId = T::AccountId; - type Call = ::Call; + type Call = ::RuntimeCall; type AdditionalSigned = T::Hash; type Pre = (); const IDENTIFIER: &'static str = "CheckGenesis"; diff --git a/frame/system/src/extensions/check_mortality.rs b/frame/system/src/extensions/check_mortality.rs index 5090093fe168f..64c6fee4cd666 100644 --- a/frame/system/src/extensions/check_mortality.rs +++ b/frame/system/src/extensions/check_mortality.rs @@ -56,7 +56,7 @@ impl sp_std::fmt::Debug for CheckMortality { impl SignedExtension for CheckMortality { type AccountId = T::AccountId; - type Call = T::Call; + type Call = T::RuntimeCall; type AdditionalSigned = T::Hash; type Pre = (); const IDENTIFIER: &'static str = "CheckMortality"; diff --git a/frame/system/src/extensions/check_non_zero_sender.rs b/frame/system/src/extensions/check_non_zero_sender.rs index 9a6c4007b3779..093424999aab3 100644 --- a/frame/system/src/extensions/check_non_zero_sender.rs +++ b/frame/system/src/extensions/check_non_zero_sender.rs @@ -53,10 +53,10 @@ impl CheckNonZeroSender { impl SignedExtension for CheckNonZeroSender where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { type AccountId = T::AccountId; - type Call = T::Call; + type Call = T::RuntimeCall; type AdditionalSigned = (); type Pre = (); const IDENTIFIER: &'static str = "CheckNonZeroSender"; diff --git a/frame/system/src/extensions/check_nonce.rs b/frame/system/src/extensions/check_nonce.rs index 476aa2fb7478c..7259b80013ae5 100644 --- a/frame/system/src/extensions/check_nonce.rs +++ b/frame/system/src/extensions/check_nonce.rs @@ -60,10 +60,10 @@ impl sp_std::fmt::Debug for CheckNonce { impl SignedExtension for CheckNonce where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { type AccountId = T::AccountId; - type Call = T::Call; + type Call = T::RuntimeCall; type AdditionalSigned = (); type Pre = (); const IDENTIFIER: &'static str = "CheckNonce"; diff --git a/frame/system/src/extensions/check_spec_version.rs b/frame/system/src/extensions/check_spec_version.rs index 0280d31f657ae..ef5f40402692c 100644 --- a/frame/system/src/extensions/check_spec_version.rs +++ b/frame/system/src/extensions/check_spec_version.rs @@ -54,7 +54,7 @@ impl CheckSpecVersion { impl SignedExtension for CheckSpecVersion { type AccountId = T::AccountId; - type Call = ::Call; + type Call = ::RuntimeCall; type AdditionalSigned = u32; type Pre = (); const IDENTIFIER: &'static str = "CheckSpecVersion"; diff --git a/frame/system/src/extensions/check_tx_version.rs b/frame/system/src/extensions/check_tx_version.rs index b92d8978bde01..be0b8fe2354aa 100644 --- a/frame/system/src/extensions/check_tx_version.rs +++ b/frame/system/src/extensions/check_tx_version.rs @@ -54,7 +54,7 @@ impl CheckTxVersion { impl SignedExtension for CheckTxVersion { type AccountId = T::AccountId; - type Call = ::Call; + type Call = ::RuntimeCall; type AdditionalSigned = u32; type Pre = (); const IDENTIFIER: &'static str = "CheckTxVersion"; diff --git a/frame/system/src/extensions/check_weight.rs b/frame/system/src/extensions/check_weight.rs index b59c36ecb53b5..8a2ccd31f1ffd 100644 --- a/frame/system/src/extensions/check_weight.rs +++ b/frame/system/src/extensions/check_weight.rs @@ -40,12 +40,12 @@ pub struct CheckWeight(sp_std::marker::PhantomData); impl CheckWeight where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { /// Checks if the current extrinsic does not exceed the maximum weight a single extrinsic /// with given `DispatchClass` can have. fn check_extrinsic_weight( - info: &DispatchInfoOf, + info: &DispatchInfoOf, ) -> Result<(), TransactionValidityError> { let max = T::BlockWeights::get().get(info.class).max_extrinsic; match max { @@ -58,18 +58,18 @@ where /// /// Upon successes, it returns the new block weight as a `Result`. fn check_block_weight( - info: &DispatchInfoOf, + info: &DispatchInfoOf, ) -> Result { let maximum_weight = T::BlockWeights::get(); let all_weight = Pallet::::block_weight(); - calculate_consumed_weight::(maximum_weight, all_weight, info) + calculate_consumed_weight::(maximum_weight, all_weight, info) } /// Checks if the current extrinsic can fit into the block with respect to block length limits. /// /// Upon successes, it returns the new block length as a `Result`. fn check_block_length( - info: &DispatchInfoOf, + info: &DispatchInfoOf, len: usize, ) -> Result { let length_limit = T::BlockLength::get(); @@ -92,7 +92,7 @@ where /// /// It checks and notes the new weight and length. pub fn do_pre_dispatch( - info: &DispatchInfoOf, + info: &DispatchInfoOf, len: usize, ) -> Result<(), TransactionValidityError> { let next_len = Self::check_block_length(info, len)?; @@ -107,7 +107,7 @@ where /// Do the validate checks. This can be applied to both signed and unsigned. /// /// It only checks that the block weight and length limit will not exceed. - pub fn do_validate(info: &DispatchInfoOf, len: usize) -> TransactionValidity { + pub fn do_validate(info: &DispatchInfoOf, len: usize) -> TransactionValidity { // ignore the next length. If they return `Ok`, then it is below the limit. let _ = Self::check_block_length(info, len)?; // during validation we skip block limit check. Since the `validate_transaction` @@ -168,10 +168,10 @@ where impl SignedExtension for CheckWeight where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { type AccountId = T::AccountId; - type Call = T::Call; + type Call = T::RuntimeCall; type AdditionalSigned = (); type Pre = (); const IDENTIFIER: &'static str = "CheckWeight"; @@ -678,13 +678,13 @@ mod tests { DispatchInfo { weight: 6, class: DispatchClass::Mandatory, ..Default::default() }; // when - assert_ok!(calculate_consumed_weight::<::Call>( + assert_ok!(calculate_consumed_weight::<::RuntimeCall>( maximum_weight.clone(), all_weight.clone(), &mandatory1 )); assert_err!( - calculate_consumed_weight::<::Call>( + calculate_consumed_weight::<::RuntimeCall>( maximum_weight, all_weight, &mandatory2 diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index b32849d59377c..accd3ff01fef0 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -205,7 +205,7 @@ pub mod pallet { pub trait Config: 'static + Eq + Clone { /// The basic call filter to use in Origin. All origins are built with this filter as base, /// except Root. - type BaseCallFilter: Contains; + type BaseCallFilter: Contains; /// Block & extrinsics weights: base values and limits. #[pallet::constant] @@ -219,10 +219,10 @@ pub mod pallet { type Origin: Into, Self::Origin>> + From> + Clone - + OriginTrait; + + OriginTrait; - /// The aggregated `Call` type. - type Call: Dispatchable + Debug; + /// The aggregated `RuntimeCall` type. + type RuntimeCall: Dispatchable + Debug; /// Account index (aka nonce) type. This stores the number of previous transactions /// associated with a sender account. diff --git a/frame/system/src/mock.rs b/frame/system/src/mock.rs index 7b76e3d318367..ec20d0a17e34f 100644 --- a/frame/system/src/mock.rs +++ b/frame/system/src/mock.rs @@ -95,7 +95,7 @@ impl Config for Test { type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -120,7 +120,7 @@ impl Config for Test { pub type SysEvent = frame_system::Event; /// A simple call, which one doesn't matter. -pub const CALL: &::Call = +pub const CALL: &::RuntimeCall = &RuntimeCall::System(frame_system::Call::set_heap_pages { pages: 0u64 }); /// Create new externalities for `System` module tests. diff --git a/frame/system/src/mocking.rs b/frame/system/src/mocking.rs index ccb63f9bb236c..d8cfcb9baf268 100644 --- a/frame/system/src/mocking.rs +++ b/frame/system/src/mocking.rs @@ -22,7 +22,7 @@ use sp_runtime::generic; /// An unchecked extrinsic type to be used in tests. pub type MockUncheckedExtrinsic = generic::UncheckedExtrinsic< ::AccountId, - ::Call, + ::RuntimeCall, Signature, Extra, >; diff --git a/frame/system/src/offchain.rs b/frame/system/src/offchain.rs index 093ed4f21ae5a..99a4c1541d30f 100644 --- a/frame/system/src/offchain.rs +++ b/frame/system/src/offchain.rs @@ -617,7 +617,7 @@ pub trait SignedPayload: Encode { #[cfg(test)] mod tests { use super::*; - use crate::mock::{Call, Test as TestRuntime, CALL}; + use crate::mock::{RuntimeCall, Test as TestRuntime, CALL}; use codec::Decode; use sp_core::offchain::{testing, TransactionPoolExt}; use sp_runtime::testing::{TestSignature, TestXt, UintAuthorityId}; @@ -627,9 +627,9 @@ mod tests { type Signature = TestSignature; } - type Extrinsic = TestXt; + type Extrinsic = TestXt; - impl SendTransactionTypes for TestRuntime { + impl SendTransactionTypes for TestRuntime { type Extrinsic = Extrinsic; type OverarchingCall = RuntimeCall; } diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index 1aa6d3b314c42..3b29df22f2f6c 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -55,7 +55,7 @@ frame_support::construct_runtime!( } ); -const CALL: &::Call = +const CALL: &::RuntimeCall = &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); thread_local! { diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 2d7d89833ec88..f770eb98ca908 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -832,7 +832,7 @@ mod tests { } ); - const CALL: &::Call = + const CALL: &::RuntimeCall = &RuntimeCall::Balances(BalancesCall::transfer { dest: 2, value: 69 }); thread_local! { diff --git a/frame/utility/src/benchmarking.rs b/frame/utility/src/benchmarking.rs index fbbd6f2b378c7..c29eded25aa5b 100644 --- a/frame/utility/src/benchmarking.rs +++ b/frame/utility/src/benchmarking.rs @@ -33,7 +33,7 @@ benchmarks! { where_clause { where ::PalletsOrigin: Clone } batch { let c in 0 .. 1000; - let mut calls: Vec<::Call> = Vec::new(); + let mut calls: Vec<::RuntimeCall> = Vec::new(); for i in 0 .. c { let call = frame_system::Call::remark { remark: vec![] }.into(); calls.push(call); @@ -54,7 +54,7 @@ benchmarks! { batch_all { let c in 0 .. 1000; - let mut calls: Vec<::Call> = Vec::new(); + let mut calls: Vec<::RuntimeCall> = Vec::new(); for i in 0 .. c { let call = frame_system::Call::remark { remark: vec![] }.into(); calls.push(call); @@ -75,7 +75,7 @@ benchmarks! { force_batch { let c in 0 .. 1000; - let mut calls: Vec<::Call> = Vec::new(); + let mut calls: Vec<::RuntimeCall> = Vec::new(); for i in 0 .. c { let call = frame_system::Call::remark { remark: vec![] }.into(); calls.push(call); diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 057cda8cafb55..d11acb19cb089 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -93,7 +93,7 @@ pub mod pallet { + From> + UnfilteredDispatchable + IsSubType> - + IsType<::Call>; + + IsType<::RuntimeCall>; /// The caller origin, overarching type of all pallets origins. type PalletsOrigin: Parameter + @@ -133,7 +133,7 @@ pub mod pallet { /// The limit on the number of batched calls. fn batched_calls_limit() -> u32 { let allocator_limit = sp_core::MAX_POSSIBLE_ALLOCATION; - let call_size = ((sp_std::mem::size_of::<::Call>() as u32 + CALL_ALIGN - + let call_size = ((sp_std::mem::size_of::<::RuntimeCall>() as u32 + CALL_ALIGN - 1) / CALL_ALIGN) * CALL_ALIGN; // The margin to take into account vec doubling capacity. let margin_factor = 3; @@ -147,7 +147,7 @@ pub mod pallet { fn integrity_test() { // If you hit this error, you need to try to `Box` big dispatchable parameters. assert!( - sp_std::mem::size_of::<::Call>() as u32 <= CALL_ALIGN, + sp_std::mem::size_of::<::RuntimeCall>() as u32 <= CALL_ALIGN, "Call enum size should be smaller than {} bytes.", CALL_ALIGN, ); @@ -201,7 +201,7 @@ pub mod pallet { })] pub fn batch( origin: OriginFor, - calls: Vec<::Call>, + calls: Vec<::RuntimeCall>, ) -> DispatchResultWithPostInfo { let is_root = ensure_root(origin.clone()).is_ok(); let calls_len = calls.len(); @@ -262,7 +262,7 @@ pub mod pallet { pub fn as_derivative( origin: OriginFor, index: u16, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { let mut origin = origin; let who = ensure_signed(origin.clone())?; @@ -317,7 +317,7 @@ pub mod pallet { })] pub fn batch_all( origin: OriginFor, - calls: Vec<::Call>, + calls: Vec<::RuntimeCall>, ) -> DispatchResultWithPostInfo { let is_root = ensure_root(origin.clone()).is_ok(); let calls_len = calls.len(); @@ -333,8 +333,8 @@ pub mod pallet { } else { let mut filtered_origin = origin.clone(); // Don't allow users to nest `batch_all` calls. - filtered_origin.add_filter(move |c: &::Call| { - let c = ::Call::from_ref(c); + filtered_origin.add_filter(move |c: &::RuntimeCall| { + let c = ::RuntimeCall::from_ref(c); !matches!(c.is_sub_type(), Some(Call::batch_all { .. })) }); call.dispatch(filtered_origin) @@ -376,7 +376,7 @@ pub mod pallet { pub fn dispatch_as( origin: OriginFor, as_origin: Box, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResult { ensure_root(origin)?; @@ -422,7 +422,7 @@ pub mod pallet { })] pub fn force_batch( origin: OriginFor, - calls: Vec<::Call>, + calls: Vec<::RuntimeCall>, ) -> DispatchResultWithPostInfo { let is_root = ensure_root(origin.clone()).is_ok(); let calls_len = calls.len(); diff --git a/frame/whitelist/src/benchmarking.rs b/frame/whitelist/src/benchmarking.rs index cafd1668819dd..9e55d38fd8140 100644 --- a/frame/whitelist/src/benchmarking.rs +++ b/frame/whitelist/src/benchmarking.rs @@ -71,7 +71,7 @@ benchmarks! { let remark_len = >::MaxSize::get() - 10; let remark = sp_std::vec![1u8; remark_len as usize]; - let call: ::Call = frame_system::Call::remark { remark }.into(); + let call: ::RuntimeCall = frame_system::Call::remark { remark }.into(); let call_weight = call.get_dispatch_info().weight; let encoded_call = call.encode(); let call_hash = T::Hashing::hash(&encoded_call[..]); @@ -100,7 +100,7 @@ benchmarks! { let origin = T::DispatchWhitelistedOrigin::successful_origin(); let remark = sp_std::vec![1u8; n as usize]; - let call: ::Call = frame_system::Call::remark { remark }.into(); + let call: ::RuntimeCall = frame_system::Call::remark { remark }.into(); let call_hash = T::Hashing::hash_of(&call); Pallet::::whitelist_call(origin.clone(), call_hash) diff --git a/frame/whitelist/src/lib.rs b/frame/whitelist/src/lib.rs index 6bce32f27b6af..60a6fc4266aaa 100644 --- a/frame/whitelist/src/lib.rs +++ b/frame/whitelist/src/lib.rs @@ -64,7 +64,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. - type Call: IsType<::Call> + type Call: IsType<::RuntimeCall> + Dispatchable + GetDispatchInfo + FullCodec @@ -165,7 +165,7 @@ pub mod pallet { let call = T::PreimageProvider::get_preimage(&call_hash) .ok_or(Error::::UnavailablePreImage)?; - let call = ::Call::decode_all_with_depth_limit( + let call = ::RuntimeCall::decode_all_with_depth_limit( sp_api::MAX_EXTRINSIC_DEPTH, &mut &call[..], ) @@ -191,7 +191,7 @@ pub mod pallet { })] pub fn dispatch_whitelisted_call_with_preimage( origin: OriginFor, - call: Box<::Call>, + call: Box<::RuntimeCall>, ) -> DispatchResultWithPostInfo { T::DispatchWhitelistedOrigin::ensure_origin(origin)?; @@ -216,7 +216,7 @@ impl Pallet { /// Clean whitelisting/preimage and dispatch call. /// /// Return the call actual weight of the dispatched call if there is some. - fn clean_and_dispatch(call_hash: T::Hash, call: ::Call) -> Option { + fn clean_and_dispatch(call_hash: T::Hash, call: ::RuntimeCall) -> Option { WhitelistedCall::::remove(call_hash); T::PreimageProvider::unrequest_preimage(&call_hash); diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 5a370f11c8e5d..21319184b4117 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -455,11 +455,11 @@ impl From for Result, Origin> { } impl frame_support::traits::OriginTrait for Origin { - type Call = ::Call; + type RuntimeCall = ::RuntimeCall; type PalletsOrigin = Origin; type AccountId = ::AccountId; - fn add_filter(&mut self, _filter: impl Fn(&Self::Call) -> bool + 'static) { + fn add_filter(&mut self, _filter: impl Fn(&Self::RuntimeCall) -> bool + 'static) { unimplemented!("Not required in tests!") } @@ -471,7 +471,7 @@ impl frame_support::traits::OriginTrait for Origin { unimplemented!("Not required in tests!") } - fn filter_call(&self, _call: &Self::Call) -> bool { + fn filter_call(&self, _call: &Self::RuntimeCall) -> bool { unimplemented!("Not required in tests!") } @@ -585,7 +585,7 @@ impl frame_system::Config for Runtime { type BlockWeights = RuntimeBlockWeights; type BlockLength = RuntimeBlockLength; type Origin = Origin; - type Call = Extrinsic; + type RuntimeCall = Extrinsic; type Index = u64; type BlockNumber = u64; type Hash = H256; From 740e9803431a0b9f61905147f8787562a8d7f677 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 15:24:05 +0200 Subject: [PATCH 40/63] fix --- bin/node-template/node/src/benchmarking.rs | 2 +- .../pallets/template/src/mock.rs | 2 +- bin/node-template/runtime/src/lib.rs | 6 +-- bin/node/cli/src/service.rs | 2 +- bin/node/runtime/src/lib.rs | 28 +++++----- frame/alliance/src/mock.rs | 2 +- frame/assets/src/mock.rs | 2 +- frame/atomic-swap/src/tests.rs | 2 +- frame/aura/src/mock.rs | 2 +- frame/authority-discovery/src/lib.rs | 2 +- frame/authorship/src/lib.rs | 2 +- frame/babe/src/mock.rs | 2 +- frame/bags-list/src/mock.rs | 2 +- frame/balances/src/tests_composite.rs | 2 +- frame/balances/src/tests_local.rs | 2 +- frame/balances/src/tests_reentrancy.rs | 2 +- frame/beefy-mmr/src/mock.rs | 2 +- frame/beefy/src/mock.rs | 2 +- frame/benchmarking/src/baseline.rs | 2 +- frame/benchmarking/src/tests.rs | 2 +- frame/benchmarking/src/tests_instance.rs | 2 +- frame/bounties/src/tests.rs | 2 +- frame/child-bounties/src/tests.rs | 2 +- frame/collective/src/tests.rs | 2 +- frame/contracts/src/lib.rs | 2 +- frame/contracts/src/tests.rs | 6 +-- frame/conviction-voting/src/tests.rs | 2 +- frame/democracy/src/tests.rs | 4 +- .../election-provider-multi-phase/src/mock.rs | 2 +- .../election-provider-support/src/onchain.rs | 2 +- frame/elections-phragmen/src/lib.rs | 2 +- frame/examples/basic/src/tests.rs | 2 +- frame/examples/offchain-worker/src/lib.rs | 2 +- frame/examples/offchain-worker/src/tests.rs | 4 +- frame/examples/parallel/src/lib.rs | 2 +- frame/examples/parallel/src/tests.rs | 4 +- frame/executive/src/lib.rs | 2 +- frame/gilt/src/mock.rs | 2 +- frame/grandpa/src/lib.rs | 2 +- frame/grandpa/src/mock.rs | 4 +- frame/identity/src/tests.rs | 2 +- frame/im-online/src/mock.rs | 2 +- frame/indices/src/mock.rs | 2 +- frame/lottery/src/lib.rs | 2 +- frame/lottery/src/mock.rs | 4 +- frame/membership/src/lib.rs | 2 +- frame/merkle-mountain-range/src/mock.rs | 2 +- frame/multisig/src/lib.rs | 2 +- frame/multisig/src/tests.rs | 4 +- frame/nicks/src/lib.rs | 2 +- frame/node-authorization/src/mock.rs | 2 +- .../nomination-pools/benchmarking/src/mock.rs | 2 +- frame/nomination-pools/src/mock.rs | 2 +- .../nomination-pools/test-staking/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/offences/src/mock.rs | 2 +- frame/preimage/src/mock.rs | 2 +- frame/proxy/src/lib.rs | 2 +- frame/proxy/src/tests.rs | 6 +-- frame/randomness-collective-flip/src/lib.rs | 2 +- frame/ranked-collective/src/tests.rs | 2 +- frame/recovery/src/lib.rs | 2 +- frame/recovery/src/mock.rs | 4 +- frame/referenda/src/lib.rs | 2 +- frame/referenda/src/mock.rs | 6 +-- frame/referenda/src/types.rs | 2 +- frame/remark/src/mock.rs | 2 +- frame/scheduler/src/lib.rs | 2 +- frame/scheduler/src/mock.rs | 4 +- frame/scored-pool/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/session/src/mock.rs | 2 +- frame/society/src/mock.rs | 2 +- frame/staking/src/mock.rs | 2 +- frame/state-trie-migration/src/lib.rs | 2 +- frame/sudo/src/lib.rs | 2 +- frame/sudo/src/mock.rs | 4 +- .../src/construct_runtime/expand/call.rs | 4 +- .../src/construct_runtime/expand/origin.rs | 4 +- .../src/construct_runtime/expand/unsigned.rs | 8 +-- .../procedural/src/pallet/expand/call.rs | 2 +- frame/support/src/dispatch.rs | 6 +-- frame/support/src/traits/dispatch.rs | 6 +-- frame/support/test/compile_pass/src/lib.rs | 2 +- frame/support/test/tests/construct_runtime.rs | 2 +- .../no_std_genesis_config.rs | 2 +- .../pallet_error_too_large.rs | 2 +- .../undefined_call_part.rs | 2 +- .../undefined_event_part.rs | 2 +- .../undefined_genesis_config_part.rs | 2 +- .../undefined_inherent_part.rs | 2 +- .../undefined_origin_part.rs | 2 +- .../undefined_validate_unsigned_part.rs | 2 +- frame/support/test/tests/instance.rs | 2 +- frame/support/test/tests/issue2219.rs | 2 +- frame/support/test/tests/origin.rs | 2 +- frame/support/test/tests/pallet.rs | 2 +- .../test/tests/pallet_compatibility.rs | 2 +- .../tests/pallet_compatibility_instance.rs | 2 +- frame/support/test/tests/pallet_instance.rs | 2 +- .../tests/pallet_with_name_trait_is_valid.rs | 2 +- frame/support/test/tests/storage_layers.rs | 2 +- frame/system/benches/bench.rs | 2 +- frame/system/benchmarking/src/mock.rs | 2 +- frame/system/src/lib.rs | 2 +- frame/timestamp/src/mock.rs | 2 +- frame/tips/src/tests.rs | 2 +- .../asset-tx-payment/src/lib.rs | 10 ++-- .../asset-tx-payment/src/payment.rs | 16 +++--- .../asset-tx-payment/src/tests.rs | 2 +- frame/transaction-payment/src/lib.rs | 52 +++++++++---------- frame/transaction-payment/src/payment.rs | 16 +++--- frame/transaction-storage/src/lib.rs | 2 +- frame/transaction-storage/src/mock.rs | 4 +- frame/treasury/src/tests.rs | 2 +- frame/uniques/src/mock.rs | 2 +- frame/utility/src/lib.rs | 2 +- frame/utility/src/tests.rs | 4 +- frame/vesting/src/mock.rs | 2 +- frame/whitelist/src/lib.rs | 2 +- frame/whitelist/src/mock.rs | 4 +- test-utils/runtime/src/lib.rs | 6 +-- 122 files changed, 209 insertions(+), 209 deletions(-) diff --git a/bin/node-template/node/src/benchmarking.rs b/bin/node-template/node/src/benchmarking.rs index f0e32104cd3ee..90fe06edf04b8 100644 --- a/bin/node-template/node/src/benchmarking.rs +++ b/bin/node-template/node/src/benchmarking.rs @@ -119,7 +119,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder { pub fn create_benchmark_extrinsic( client: &FullClient, sender: sp_core::sr25519::Pair, - call: runtime::Call, + call: runtime::RuntimeCall, nonce: u32, ) -> runtime::UncheckedExtrinsic { let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"); diff --git a/bin/node-template/pallets/template/src/mock.rs b/bin/node-template/pallets/template/src/mock.rs index e111d59c1f8eb..3289ec2da4952 100644 --- a/bin/node-template/pallets/template/src/mock.rs +++ b/bin/node-template/pallets/template/src/mock.rs @@ -28,7 +28,7 @@ impl system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 1270c7c3840a0..55cb2dc0b4dbc 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -156,7 +156,7 @@ impl frame_system::Config for Runtime { /// The identifier used to distinguish between accounts. type AccountId = AccountId; /// The aggregated dispatch type that is available for extrinsics. - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; /// The lookup mechanism to get account ID from whatever is passed in dispatchers. type Lookup = AccountIdLookup; /// The index type for storing how many extrinsics an account has signed. @@ -208,7 +208,7 @@ impl pallet_aura::Config for Runtime { impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type KeyOwnerProofSystem = (); @@ -262,7 +262,7 @@ impl pallet_transaction_payment::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; } /// Configure the pallet-template in pallets/template. diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index abbd3c90be2e9..798ec7e3e2a63 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -69,7 +69,7 @@ pub fn fetch_nonce(client: &FullClient, account: sp_core::sr25519::Pair) -> u32 pub fn create_extrinsic( client: &FullClient, sender: sp_core::sr25519::Pair, - function: impl Into, + function: impl Into, nonce: Option, ) -> kitchensink_runtime::UncheckedExtrinsic { let function = function.into(); diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 35836ad929c14..4b02aef4723bc 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -205,7 +205,7 @@ impl frame_system::Config for Runtime { type BlockLength = RuntimeBlockLength; type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = Index; type BlockNumber = BlockNumber; type Hash = Hash; @@ -230,7 +230,7 @@ impl pallet_randomness_collective_flip::Config for Runtime {} impl pallet_utility::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = pallet_utility::weights::SubstrateWeight; } @@ -244,7 +244,7 @@ parameter_types! { impl pallet_multisig::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type DepositBase = DepositBase; type DepositFactor = DepositFactor; @@ -323,7 +323,7 @@ impl InstanceFilter for ProxyType { impl pallet_proxy::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ProxyDepositBase; @@ -347,7 +347,7 @@ impl pallet_scheduler::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<50>; @@ -830,7 +830,7 @@ impl pallet_referenda::TracksInfo for TracksInfo { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -849,7 +849,7 @@ impl pallet_referenda::Config for Runtime { impl pallet_referenda::Config for Runtime { type WeightInfo = pallet_referenda::weights::SubstrateWeight; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; @@ -1140,7 +1140,7 @@ impl pallet_contracts::Config for Runtime { type Randomness = RandomnessCollectiveFlip; type Currency = Balances; type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; /// The safest default is to allow no calls at all. /// /// Runtimes should whitelist dispatchables that are allowed to be called from contracts @@ -1166,7 +1166,7 @@ impl pallet_contracts::Config for Runtime { impl pallet_sudo::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; } parameter_types! { @@ -1259,7 +1259,7 @@ impl pallet_authority_discovery::Config for Runtime { impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type KeyOwnerProofSystem = Historical; @@ -1315,7 +1315,7 @@ parameter_types! { impl pallet_recovery::Config for Runtime { type RuntimeEvent = RuntimeEvent; type WeightInfo = pallet_recovery::weights::SubstrateWeight; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; @@ -1386,7 +1386,7 @@ parameter_types! { impl pallet_lottery::Config for Runtime { type PalletId = LotteryPalletId; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type Randomness = RandomnessCollectiveFlip; type RuntimeEvent = RuntimeEvent; @@ -1482,7 +1482,7 @@ impl pallet_uniques::Config for Runtime { impl pallet_transaction_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type FeeDestination = (); type WeightInfo = pallet_transaction_storage::weights::SubstrateWeight; type MaxBlockTransactions = @@ -1493,7 +1493,7 @@ impl pallet_transaction_storage::Config for Runtime { impl pallet_whitelist::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type PreimageProvider = Preimage; diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index e8c1b3635d170..fddf172a24db8 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -45,7 +45,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/assets/src/mock.rs b/frame/assets/src/mock.rs index b440826841733..98f134636070e 100644 --- a/frame/assets/src/mock.rs +++ b/frame/assets/src/mock.rs @@ -50,7 +50,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/atomic-swap/src/tests.rs b/frame/atomic-swap/src/tests.rs index eaac9ebf91613..c46e8a59fa8ca 100644 --- a/frame/atomic-swap/src/tests.rs +++ b/frame/atomic-swap/src/tests.rs @@ -41,7 +41,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/aura/src/mock.rs b/frame/aura/src/mock.rs index 4385d04076914..132965e4a746e 100644 --- a/frame/aura/src/mock.rs +++ b/frame/aura/src/mock.rs @@ -60,7 +60,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/authority-discovery/src/lib.rs b/frame/authority-discovery/src/lib.rs index eff269d45280e..31c1fe00a6d0f 100644 --- a/frame/authority-discovery/src/lib.rs +++ b/frame/authority-discovery/src/lib.rs @@ -238,7 +238,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AuthorityId; diff --git a/frame/authorship/src/lib.rs b/frame/authorship/src/lib.rs index e5b1e9dedeb3d..3d45977d33818 100644 --- a/frame/authorship/src/lib.rs +++ b/frame/authorship/src/lib.rs @@ -471,7 +471,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index a03d92e20dce5..68837cd32a5e7 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -77,7 +77,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Version = (); type Hashing = sp_runtime::traits::BlakeTwo256; diff --git a/frame/bags-list/src/mock.rs b/frame/bags-list/src/mock.rs index 56a8a63ac1c7b..fb6d7db919f45 100644 --- a/frame/bags-list/src/mock.rs +++ b/frame/bags-list/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/balances/src/tests_composite.rs b/frame/balances/src/tests_composite.rs index ddac89dbd6f2e..5f7ee48892f15 100644 --- a/frame/balances/src/tests_composite.rs +++ b/frame/balances/src/tests_composite.rs @@ -57,7 +57,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/balances/src/tests_local.rs b/frame/balances/src/tests_local.rs index 41f310f2c4847..d822fc27b721a 100644 --- a/frame/balances/src/tests_local.rs +++ b/frame/balances/src/tests_local.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/balances/src/tests_reentrancy.rs b/frame/balances/src/tests_reentrancy.rs index 485c07ec2897f..5ca4c869c689e 100644 --- a/frame/balances/src/tests_reentrancy.rs +++ b/frame/balances/src/tests_reentrancy.rs @@ -62,7 +62,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/beefy-mmr/src/mock.rs b/frame/beefy-mmr/src/mock.rs index 63c77ba39ba0b..792b775b77998 100644 --- a/frame/beefy-mmr/src/mock.rs +++ b/frame/beefy-mmr/src/mock.rs @@ -71,7 +71,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/beefy/src/mock.rs b/frame/beefy/src/mock.rs index 2b15042430089..7c4cd1af01533 100644 --- a/frame/beefy/src/mock.rs +++ b/frame/beefy/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/benchmarking/src/baseline.rs b/frame/benchmarking/src/baseline.rs index e05c016df8cb1..38aa7b261cb01 100644 --- a/frame/benchmarking/src/baseline.rs +++ b/frame/benchmarking/src/baseline.rs @@ -179,7 +179,7 @@ pub mod mock { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/benchmarking/src/tests.rs b/frame/benchmarking/src/tests.rs index b9b9a1e038890..61e16d15d2e94 100644 --- a/frame/benchmarking/src/tests.rs +++ b/frame/benchmarking/src/tests.rs @@ -93,7 +93,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/benchmarking/src/tests_instance.rs b/frame/benchmarking/src/tests_instance.rs index 2ca04e32383d3..7617696a949cf 100644 --- a/frame/benchmarking/src/tests_instance.rs +++ b/frame/benchmarking/src/tests_instance.rs @@ -95,7 +95,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/bounties/src/tests.rs b/frame/bounties/src/tests.rs index 7100ff8cd4c6c..c94072f1b4bb5 100644 --- a/frame/bounties/src/tests.rs +++ b/frame/bounties/src/tests.rs @@ -72,7 +72,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account diff --git a/frame/child-bounties/src/tests.rs b/frame/child-bounties/src/tests.rs index 4d75770b6065b..cd0b3edb8ead9 100644 --- a/frame/child-bounties/src/tests.rs +++ b/frame/child-bounties/src/tests.rs @@ -75,7 +75,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 2f8a98289596a..6319abb66b9d3 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -100,7 +100,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 9e1548bd5dee7..6656c7a393f04 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -246,7 +246,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. - type Call: Dispatchable + type RuntimeCall: Dispatchable + GetDispatchInfo + codec::Decode + IsType<::RuntimeCall>; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 26d7c8a2a557c..4a1e21bf1bcc0 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -276,7 +276,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = AccountId32; type Lookup = IdentityLookup; @@ -314,7 +314,7 @@ impl pallet_timestamp::Config for Test { } impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -360,7 +360,7 @@ impl Config for Test { type Randomness = Randomness; type Currency = Balances; type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type CallFilter = TestFilter; type CallStack = [Frame; 31]; type WeightPrice = Self; diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index f4c31c397c18b..036a68032304b 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -67,7 +67,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 3fe18982ba75e..72965259dcadb 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -88,7 +88,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -113,7 +113,7 @@ impl pallet_scheduler::Config for Test { type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = (); diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 0aba753f43c1d..2005d9a1dbd81 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -201,7 +201,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/election-provider-support/src/onchain.rs b/frame/election-provider-support/src/onchain.rs index 066f0315e0899..c899e021f974a 100644 --- a/frame/election-provider-support/src/onchain.rs +++ b/frame/election-provider-support/src/onchain.rs @@ -214,7 +214,7 @@ mod tests { type Origin = Origin; type Index = AccountId; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 7db1e858655a1..28750149eab2a 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1188,7 +1188,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/examples/basic/src/tests.rs b/frame/examples/basic/src/tests.rs index 1ddd923eaf358..50f10a892340a 100644 --- a/frame/examples/basic/src/tests.rs +++ b/frame/examples/basic/src/tests.rs @@ -63,7 +63,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index e9e4d3c7ca50e..8f07fe4585b96 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -129,7 +129,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching dispatch call type. - type Call: From>; + type RuntimeCall: From>; // Configuration parameters diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 5f707e8e2289e..5181747d30cde 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -119,7 +119,7 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; type AuthorityId = crypto::TestAuthId; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type GracePeriod = ConstU64<5>; type UnsignedInterval = ConstU64<128>; type UnsignedPriority = UnsignedPriority; diff --git a/frame/examples/parallel/src/lib.rs b/frame/examples/parallel/src/lib.rs index 7b8948c2ebd09..33669c3dafc26 100644 --- a/frame/examples/parallel/src/lib.rs +++ b/frame/examples/parallel/src/lib.rs @@ -43,7 +43,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { /// The overarching dispatch call type. - type Call: From>; + type RuntimeCall: From>; } #[pallet::pallet] diff --git a/frame/examples/parallel/src/tests.rs b/frame/examples/parallel/src/tests.rs index 472c0d1e9b0b3..41e2978a42ebe 100644 --- a/frame/examples/parallel/src/tests.rs +++ b/frame/examples/parallel/src/tests.rs @@ -46,7 +46,7 @@ parameter_types! { impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type PalletInfo = PalletInfo; type Index = u64; type BlockNumber = u64; @@ -71,7 +71,7 @@ impl frame_system::Config for Test { } impl Config for Test { - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; } fn test_pub(n: u8) -> sp_core::sr25519::Public { diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 119b8e9e6714f..b4ded42481396 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -737,7 +737,7 @@ mod tests { type DbWeight = (); type Origin = Origin; type Index = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type BlockNumber = u64; type Hash = sp_core::H256; type Hashing = BlakeTwo256; diff --git a/frame/gilt/src/mock.rs b/frame/gilt/src/mock.rs index 3c5517b112053..a9cca0ff22780 100644 --- a/frame/gilt/src/mock.rs +++ b/frame/gilt/src/mock.rs @@ -50,7 +50,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index f71fbaea0833c..78beb72fedc54 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -92,7 +92,7 @@ pub mod pallet { + IsType<::RuntimeEvent>; /// The function call. - type Call: From>; + type RuntimeCall: From>; /// The proof of key ownership, used for validating equivocation reports /// The proof must include the session index and validator count of the diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index c25845337a62f..ac8851c6c121f 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -82,7 +82,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; @@ -225,7 +225,7 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type KeyOwnerProofSystem = Historical; diff --git a/frame/identity/src/tests.rs b/frame/identity/src/tests.rs index ceb8255382b08..35c1755540f4d 100644 --- a/frame/identity/src/tests.rs +++ b/frame/identity/src/tests.rs @@ -60,7 +60,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index b219cc09ac455..7fac89e481817 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -134,7 +134,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/indices/src/mock.rs b/frame/indices/src/mock.rs index 27e1a5a92c05b..8d6cd44aaef1d 100644 --- a/frame/indices/src/mock.rs +++ b/frame/indices/src/mock.rs @@ -53,7 +53,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 8f732eb79326c..34a97636cb389 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -134,7 +134,7 @@ pub mod pallet { type PalletId: Get; /// A dispatchable call. - type Call: Parameter + type RuntimeCall: Parameter + Dispatchable + GetDispatchInfo + From>; diff --git a/frame/lottery/src/mock.rs b/frame/lottery/src/mock.rs index 95082726766f9..b521b83e7ce2b 100644 --- a/frame/lottery/src/mock.rs +++ b/frame/lottery/src/mock.rs @@ -59,7 +59,7 @@ impl frame_system::Config for Test { type DbWeight = (); type Origin = Origin; type Index = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type BlockNumber = u64; type Hash = H256; type Hashing = BlakeTwo256; @@ -97,7 +97,7 @@ parameter_types! { impl Config for Test { type PalletId = LotteryPalletId; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type Randomness = TestRandomness; type RuntimeEvent = RuntimeEvent; diff --git a/frame/membership/src/lib.rs b/frame/membership/src/lib.rs index 9e3e654e69a7d..bfdb258b4d69b 100644 --- a/frame/membership/src/lib.rs +++ b/frame/membership/src/lib.rs @@ -547,7 +547,7 @@ mod tests { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/merkle-mountain-range/src/mock.rs b/frame/merkle-mountain-range/src/mock.rs index 05893717d6c74..5a9fe7cc90b65 100644 --- a/frame/merkle-mountain-range/src/mock.rs +++ b/frame/merkle-mountain-range/src/mock.rs @@ -45,7 +45,7 @@ frame_support::construct_runtime!( impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/multisig/src/lib.rs b/frame/multisig/src/lib.rs index 9ef571c1cd551..26d5e4e3c3132 100644 --- a/frame/multisig/src/lib.rs +++ b/frame/multisig/src/lib.rs @@ -120,7 +120,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. - type Call: Parameter + type RuntimeCall: Parameter + Dispatchable + GetDispatchInfo + From>; diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index 0d4bd9cd0dd5a..b05803e546932 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -61,7 +61,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -104,7 +104,7 @@ impl Contains for TestBaseCallFilter { } impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type DepositBase = ConstU64<1>; type DepositFactor = ConstU64<1>; diff --git a/frame/nicks/src/lib.rs b/frame/nicks/src/lib.rs index 599b34599ae4a..b4e6cd48e6258 100644 --- a/frame/nicks/src/lib.rs +++ b/frame/nicks/src/lib.rs @@ -284,7 +284,7 @@ mod tests { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/node-authorization/src/mock.rs b/frame/node-authorization/src/mock.rs index f2cf0ad9a7cb7..448f8cef80e28 100644 --- a/frame/node-authorization/src/mock.rs +++ b/frame/node-authorization/src/mock.rs @@ -56,7 +56,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 8534b1c5327e7..aad38ee8475d2 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -35,7 +35,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/nomination-pools/src/mock.rs b/frame/nomination-pools/src/mock.rs index fae7fede85799..80c990d2c5932 100644 --- a/frame/nomination-pools/src/mock.rs +++ b/frame/nomination-pools/src/mock.rs @@ -130,7 +130,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 69bd5dd550abc..d616ee1ffc180 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -46,7 +46,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 30205161e93ba..51b52eef8087f 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -51,7 +51,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/offences/src/mock.rs b/frame/offences/src/mock.rs index 1f819dc7dc1ae..8e2af0bc479ab 100644 --- a/frame/offences/src/mock.rs +++ b/frame/offences/src/mock.rs @@ -96,7 +96,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/preimage/src/mock.rs b/frame/preimage/src/mock.rs index 81c7e21b58c9b..d40dbfad8ec97 100644 --- a/frame/preimage/src/mock.rs +++ b/frame/preimage/src/mock.rs @@ -58,7 +58,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/proxy/src/lib.rs b/frame/proxy/src/lib.rs index d358b29c9772e..9a6cbe54d45da 100644 --- a/frame/proxy/src/lib.rs +++ b/frame/proxy/src/lib.rs @@ -113,7 +113,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. - type Call: Parameter + type RuntimeCall: Parameter + Dispatchable + GetDispatchInfo + From> diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index 36b33f0d3c035..b60b184217ffa 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -96,7 +96,7 @@ impl pallet_balances::Config for Test { } impl pallet_utility::Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = (); } @@ -151,7 +151,7 @@ impl Contains for BaseFilter { } impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ProxyType = ProxyType; type ProxyDepositBase = ConstU64<1>; diff --git a/frame/randomness-collective-flip/src/lib.rs b/frame/randomness-collective-flip/src/lib.rs index 4eb77cacbbd32..6a6dab954f9b5 100644 --- a/frame/randomness-collective-flip/src/lib.rs +++ b/frame/randomness-collective-flip/src/lib.rs @@ -200,7 +200,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/ranked-collective/src/tests.rs b/frame/ranked-collective/src/tests.rs index e2e38c94a4ada..618904c1e5549 100644 --- a/frame/ranked-collective/src/tests.rs +++ b/frame/ranked-collective/src/tests.rs @@ -60,7 +60,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/recovery/src/lib.rs b/frame/recovery/src/lib.rs index e3de75a7fcbc0..dd9e7208320c4 100644 --- a/frame/recovery/src/lib.rs +++ b/frame/recovery/src/lib.rs @@ -232,7 +232,7 @@ pub mod pallet { type WeightInfo: WeightInfo; /// The overarching call type. - type Call: Parameter + type RuntimeCall: Parameter + Dispatchable + GetDispatchInfo + From>; diff --git a/frame/recovery/src/mock.rs b/frame/recovery/src/mock.rs index 576f89e0375f9..f0910d9a0cda5 100644 --- a/frame/recovery/src/mock.rs +++ b/frame/recovery/src/mock.rs @@ -56,7 +56,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -104,7 +104,7 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; type WeightInfo = (); - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type ConfigDepositBase = ConfigDepositBase; type FriendDepositFactor = FriendDepositFactor; diff --git a/frame/referenda/src/lib.rs b/frame/referenda/src/lib.rs index f33a340d98eab..92e5ecf5e539b 100644 --- a/frame/referenda/src/lib.rs +++ b/frame/referenda/src/lib.rs @@ -123,7 +123,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + Sized { // System level stuff. - type Call: Parameter + Dispatchable + From>; + type RuntimeCall: Parameter + Dispatchable + From>; type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// Weight information for extrinsics in this pallet. diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index 1b7f97a2b12e2..87417c0a5055c 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -72,7 +72,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -103,7 +103,7 @@ impl pallet_scheduler::Config for Test { type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type MaximumWeight = ConstU64<2_000_000_000_000>; type ScheduleOrigin = EnsureRoot; type MaxScheduledPerBlock = ConstU32<100>; @@ -211,7 +211,7 @@ impl TracksInfo for TestTracksInfo { impl Config for Test { type WeightInfo = (); - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type Scheduler = Scheduler; type Currency = pallet_balances::Pallet; diff --git a/frame/referenda/src/types.rs b/frame/referenda/src/types.rs index 3eba783246e10..984bd0642d959 100644 --- a/frame/referenda/src/types.rs +++ b/frame/referenda/src/types.rs @@ -30,7 +30,7 @@ pub type BalanceOf = pub type NegativeImbalanceOf = <>::Currency as Currency< ::AccountId, >>::NegativeImbalance; -pub type CallOf = >::Call; +pub type CallOf = >::RuntimeCall; pub type VotesOf = >::Votes; pub type TallyOf = >::Tally; pub type PalletsOriginOf = <::Origin as OriginTrait>::PalletsOrigin; diff --git a/frame/remark/src/mock.rs b/frame/remark/src/mock.rs index 69c49f394d969..6ce7115345e57 100644 --- a/frame/remark/src/mock.rs +++ b/frame/remark/src/mock.rs @@ -46,7 +46,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index 87bf57f778077..dd40d1afd088b 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -209,7 +209,7 @@ pub mod pallet { type PalletsOrigin: From> + Codec + Clone + Eq + TypeInfo; /// The aggregated call type. - type Call: Parameter + type RuntimeCall: Parameter + Dispatchable::Origin, PostInfo = PostDispatchInfo> + GetDispatchInfo + From>; diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 2d1448f118edc..62731cea918c8 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -127,7 +127,7 @@ impl system::Config for Test { type BlockLength = (); type DbWeight = RocksDbWeight; type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -172,7 +172,7 @@ impl Config for Test { type RuntimeEvent = RuntimeEvent; type Origin = Origin; type PalletsOrigin = OriginCaller; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type MaximumWeight = MaximumSchedulerWeight; type ScheduleOrigin = EitherOfDiverse, EnsureSignedBy>; type MaxScheduledPerBlock = ConstU32<10>; diff --git a/frame/scored-pool/src/mock.rs b/frame/scored-pool/src/mock.rs index b7786ddbef5d0..693c84325bae8 100644 --- a/frame/scored-pool/src/mock.rs +++ b/frame/scored-pool/src/mock.rs @@ -66,7 +66,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 76578d64c9c36..01be3605601f4 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -55,7 +55,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/session/src/mock.rs b/frame/session/src/mock.rs index 22b9ae6afcf56..4275dd39ed1f1 100644 --- a/frame/session/src/mock.rs +++ b/frame/session/src/mock.rs @@ -250,7 +250,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/society/src/mock.rs b/frame/society/src/mock.rs index 7267714ecb416..15eb70d449119 100644 --- a/frame/society/src/mock.rs +++ b/frame/society/src/mock.rs @@ -67,7 +67,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u128; type Lookup = IdentityLookup; diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index e758b75917d63..13cfbdfeb62f8 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -135,7 +135,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/state-trie-migration/src/lib.rs b/frame/state-trie-migration/src/lib.rs index 4b8e38f23dc5c..c848f6afad185 100644 --- a/frame/state-trie-migration/src/lib.rs +++ b/frame/state-trie-migration/src/lib.rs @@ -1084,7 +1084,7 @@ mod mock { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u32; type Hash = H256; diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index 6cee27f018c7e..a3ebcbedceb2b 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -118,7 +118,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A sudo-able call. - type Call: Parameter + UnfilteredDispatchable + GetDispatchInfo; + type RuntimeCall: Parameter + UnfilteredDispatchable + GetDispatchInfo; } #[pallet::pallet] diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index ee3a732164097..1abf7e52f38d5 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -125,7 +125,7 @@ impl frame_system::Config for Test { type BlockLength = (); type DbWeight = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -154,7 +154,7 @@ impl logger::Config for Test { // Implement the sudo module's `Config` on the Test runtime. impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; } // New types for dispatchable functions. diff --git a/frame/support/procedural/src/construct_runtime/expand/call.rs b/frame/support/procedural/src/construct_runtime/expand/call.rs index bce550b37cb60..49ef3ac6d7e57 100644 --- a/frame/support/procedural/src/construct_runtime/expand/call.rs +++ b/frame/support/procedural/src/construct_runtime/expand/call.rs @@ -71,7 +71,7 @@ pub fn expand_outer_dispatch( &[#( ( stringify!(#pallet_names), - size_of::< <#pallet_names as Callable<#runtime>>::Call >(), + size_of::< <#pallet_names as Callable<#runtime>>::RuntimeCall >(), ), )*] } @@ -130,7 +130,7 @@ pub fn expand_outer_dispatch( match module { #( stringify!(#pallet_names) => - <<#pallet_names as Callable<#runtime>>::Call + <<#pallet_names as Callable<#runtime>>::RuntimeCall as GetCallName>::get_call_names(), )* _ => unreachable!(), diff --git a/frame/support/procedural/src/construct_runtime/expand/origin.rs b/frame/support/procedural/src/construct_runtime/expand/origin.rs index b4e4f723c1e5e..186104d5c14ca 100644 --- a/frame/support/procedural/src/construct_runtime/expand/origin.rs +++ b/frame/support/procedural/src/construct_runtime/expand/origin.rs @@ -135,7 +135,7 @@ pub fn expand_outer_origin( type PalletsOrigin = OriginCaller; type AccountId = <#runtime as #system_path::Config>::AccountId; - fn add_filter(&mut self, filter: impl Fn(&Self::RuntimeCall) -> bool + 'static) { + fn add_filter(&mut self, filter: impl Fn(&Self::Call) -> bool + 'static) { let f = self.filter.clone(); self.filter = #scrate::sp_std::rc::Rc::new(Box::new(move |call| { @@ -156,7 +156,7 @@ pub fn expand_outer_origin( self.caller = other.into().caller; } - fn filter_call(&self, call: &Self::RuntimeCall) -> bool { + fn filter_call(&self, call: &Self::Call) -> bool { match self.caller { // Root bypasses all filters OriginCaller::system(#system_path::Origin::<#runtime>::Root) => true, diff --git a/frame/support/procedural/src/construct_runtime/expand/unsigned.rs b/frame/support/procedural/src/construct_runtime/expand/unsigned.rs index 6df9df3b16c4b..19c195e77d8a4 100644 --- a/frame/support/procedural/src/construct_runtime/expand/unsigned.rs +++ b/frame/support/procedural/src/construct_runtime/expand/unsigned.rs @@ -46,10 +46,10 @@ pub fn expand_outer_validate_unsigned( impl #scrate::unsigned::ValidateUnsigned for #runtime { type Call = RuntimeCall; - fn pre_dispatch(call: &Self::RuntimeCall) -> Result<(), #scrate::unsigned::TransactionValidityError> { + fn pre_dispatch(call: &Self::Call) -> Result<(), #scrate::unsigned::TransactionValidityError> { #[allow(unreachable_patterns)] match call { - #( Call::#pallet_names(inner_call) => #pallet_names::pre_dispatch(inner_call), )* + #( RuntimeCall::#pallet_names(inner_call) => #pallet_names::pre_dispatch(inner_call), )* // pre-dispatch should not stop inherent extrinsics, validation should prevent // including arbitrary (non-inherent) extrinsics to blocks. _ => Ok(()), @@ -59,11 +59,11 @@ pub fn expand_outer_validate_unsigned( fn validate_unsigned( #[allow(unused_variables)] source: #scrate::unsigned::TransactionSource, - call: &Self::RuntimeCall, + call: &Self::Call, ) -> #scrate::unsigned::TransactionValidity { #[allow(unreachable_patterns)] match call { - #( Call::#pallet_names(inner_call) => #pallet_names::validate_unsigned(source, inner_call), )* + #( RuntimeCall::#pallet_names(inner_call) => #pallet_names::validate_unsigned(source, inner_call), )* _ => #scrate::unsigned::UnknownTransaction::NoUnsignedValidator.into(), } } diff --git a/frame/support/procedural/src/pallet/expand/call.rs b/frame/support/procedural/src/pallet/expand/call.rs index a9468451ad1d4..8b2922b5fa4f2 100644 --- a/frame/support/procedural/src/pallet/expand/call.rs +++ b/frame/support/procedural/src/pallet/expand/call.rs @@ -300,7 +300,7 @@ pub fn expand_call(def: &mut Def) -> proc_macro2::TokenStream { impl<#type_impl_gen> #frame_support::dispatch::Callable for #pallet_ident<#type_use_gen> #where_clause { - type Call = #call_ident<#type_use_gen>; + type RuntimeCall = #call_ident<#type_use_gen>; } impl<#type_impl_gen> #pallet_ident<#type_use_gen> #where_clause { diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index c985f224df531..e6f636633c7bb 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -56,12 +56,12 @@ pub type DispatchErrorWithPostInfo = /// Serializable version of pallet dispatchable. pub trait Callable { - type Call: UnfilteredDispatchable + Codec + Clone + PartialEq + Eq; + type RuntimeCall: UnfilteredDispatchable + Codec + Clone + PartialEq + Eq; } // dirty hack to work around serde_derive issue // https://github.com/rust-lang/rust/issues/51331 -pub type CallableCallFor = >::Call; +pub type CallableCallFor = >::RuntimeCall; /// Origin for the System pallet. #[derive(PartialEq, Eq, Clone, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)] @@ -2340,7 +2340,7 @@ macro_rules! decl_module { impl<$trait_instance: $trait_name $(, $instance: $instantiable)?> $crate::dispatch::Callable<$trait_instance> for $mod_type<$trait_instance $(, $instance)?> where $( $other_where_bounds )* { - type Call = $call_type<$trait_instance $(, $instance)?>; + type RuntimeCall = $call_type<$trait_instance $(, $instance)?>; } $crate::__dispatch_impl_metadata! { diff --git a/frame/support/src/traits/dispatch.rs b/frame/support/src/traits/dispatch.rs index 493abb8a13fef..afc819aa454e5 100644 --- a/frame/support/src/traits/dispatch.rs +++ b/frame/support/src/traits/dispatch.rs @@ -239,7 +239,7 @@ pub trait UnfilteredDispatchable { /// Methods available on `frame_system::Config::Origin`. pub trait OriginTrait: Sized { /// Runtime call type, as in `frame_system::Config::Call` - type RuntimeCall; + type Call; /// The caller origin, overarching type of all pallets origins. type PalletsOrigin: Parameter @@ -252,7 +252,7 @@ pub trait OriginTrait: Sized { type AccountId; /// Add a filter to the origin. - fn add_filter(&mut self, filter: impl Fn(&Self::RuntimeCall) -> bool + 'static); + fn add_filter(&mut self, filter: impl Fn(&Self::Call) -> bool + 'static); /// Reset origin filters to default one, i.e `frame_system::Config::BaseCallFilter`. fn reset_filter(&mut self); @@ -264,7 +264,7 @@ pub trait OriginTrait: Sized { /// out. /// /// For root origin caller, the filters are bypassed and true is returned. - fn filter_call(&self, call: &Self::RuntimeCall) -> bool; + fn filter_call(&self, call: &Self::Call) -> bool; /// Get the caller. fn caller(&self) -> &Self::PalletsOrigin; diff --git a/frame/support/test/compile_pass/src/lib.rs b/frame/support/test/compile_pass/src/lib.rs index fe1e774205e94..6e4d2363b2f7c 100644 --- a/frame/support/test/compile_pass/src/lib.rs +++ b/frame/support/test/compile_pass/src/lib.rs @@ -70,7 +70,7 @@ impl frame_system::Config for Runtime { type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type DbWeight = (); type OnNewAccount = (); type OnKilledAccount = (); diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index e0b5cc8e96a5a..e44c6c522c551 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -250,7 +250,7 @@ impl system::Config for Runtime { type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type DbWeight = (); } diff --git a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs index 021e426652931..a1ccdccc83de2 100644 --- a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs +++ b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs @@ -15,7 +15,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index 5dffecb7abf36..89dc95aea2392 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -49,7 +49,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index 1cdb3ec7237f7..5f014b04058c1 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index b2ea5d18a1fce..0630171289540 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index be531f549d03e..af615922af047 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index fa5358d655a78..0782706845d30 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index c09ece3d297e3..92a3f304a2d53 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index ac6ffae3a500e..aa3f97798d148 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -24,7 +24,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 8197ec8640fca..514f09c88715d 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -282,7 +282,7 @@ impl system::Config for Runtime { type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type DbWeight = (); } diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 24c783e68fc02..487701d69fe38 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -165,7 +165,7 @@ impl system::Config for Runtime { type AccountId = AccountId; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type DbWeight = (); } diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index 64ba75b0eda0b..e70cab21f1478 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -151,7 +151,7 @@ impl system::Config for RuntimeOriginTest { type AccountId = u32; type RuntimeEvent = RuntimeEvent; type PalletInfo = PalletInfo; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type DbWeight = (); } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 79f134d2712f5..54286978cfa71 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -552,7 +552,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index 228277399f751..44a7ee5916be4 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -229,7 +229,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 92d4d20c5b15a..3df8093c4e965 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -213,7 +213,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index b253e613647a1..af55038251899 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -254,7 +254,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index d92a257b2c21e..796df2c145b0e 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -130,7 +130,7 @@ mod tests { type Index = u64; type BlockNumber = u64; type Hash = sp_core::H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; type Lookup = sp_runtime::traits::IdentityLookup; diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index 0e7fce4999eef..6592a091af42d 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -89,7 +89,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u32; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_runtime::testing::H256; type Hashing = sp_runtime::traits::BlakeTwo256; type AccountId = u64; diff --git a/frame/system/benches/bench.rs b/frame/system/benches/bench.rs index ddc4a59f91537..c7099b795581d 100644 --- a/frame/system/benches/bench.rs +++ b/frame/system/benches/bench.rs @@ -76,7 +76,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/system/benchmarking/src/mock.rs b/frame/system/benchmarking/src/mock.rs index 997bd8e9fb1dd..1c0a7efa03735 100644 --- a/frame/system/benchmarking/src/mock.rs +++ b/frame/system/benchmarking/src/mock.rs @@ -46,7 +46,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = AccountIndex; type BlockNumber = BlockNumber; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = sp_core::H256; type Hashing = ::sp_runtime::traits::BlakeTwo256; type AccountId = AccountId; diff --git a/frame/system/src/lib.rs b/frame/system/src/lib.rs index accd3ff01fef0..77256660146a0 100644 --- a/frame/system/src/lib.rs +++ b/frame/system/src/lib.rs @@ -219,7 +219,7 @@ pub mod pallet { type Origin: Into, Self::Origin>> + From> + Clone - + OriginTrait; + + OriginTrait; /// The aggregated `RuntimeCall` type. type RuntimeCall: Dispatchable + Debug; diff --git a/frame/timestamp/src/mock.rs b/frame/timestamp/src/mock.rs index 2f48f17531fd8..3ea50155b7bef 100644 --- a/frame/timestamp/src/mock.rs +++ b/frame/timestamp/src/mock.rs @@ -59,7 +59,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/tips/src/tests.rs b/frame/tips/src/tests.rs index 0e1885cf3ae64..197da42419f3b 100644 --- a/frame/tips/src/tests.rs +++ b/frame/tips/src/tests.rs @@ -70,7 +70,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account diff --git a/frame/transaction-payment/asset-tx-payment/src/lib.rs b/frame/transaction-payment/asset-tx-payment/src/lib.rs index 768d556bcb6a3..c14c7ba11b546 100644 --- a/frame/transaction-payment/asset-tx-payment/src/lib.rs +++ b/frame/transaction-payment/asset-tx-payment/src/lib.rs @@ -154,7 +154,7 @@ pub struct ChargeAssetTxPayment { impl ChargeAssetTxPayment where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, AssetBalanceOf: Send + Sync + FixedPointOperand, BalanceOf: Send + Sync + FixedPointOperand + IsType>, ChargeAssetIdOf: Send + Sync, @@ -170,8 +170,8 @@ where fn withdraw_fee( &self, who: &T::AccountId, - call: &T::Call, - info: &DispatchInfoOf, + call: &T::RuntimeCall, + info: &DispatchInfoOf, len: usize, ) -> Result<(BalanceOf, InitialPayment), TransactionValidityError> { let fee = pallet_transaction_payment::Pallet::::compute_fee(len as u32, info, self.tip); @@ -211,7 +211,7 @@ impl sp_std::fmt::Debug for ChargeAssetTxPayment { impl SignedExtension for ChargeAssetTxPayment where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, AssetBalanceOf: Send + Sync + FixedPointOperand, BalanceOf: Send + Sync + From + FixedPointOperand + IsType>, ChargeAssetIdOf: Send + Sync, @@ -219,7 +219,7 @@ where { const IDENTIFIER: &'static str = "ChargeAssetTxPayment"; type AccountId = T::AccountId; - type Call = T::Call; + type Call = T::RuntimeCall; type AdditionalSigned = (); type Pre = ( // tip diff --git a/frame/transaction-payment/asset-tx-payment/src/payment.rs b/frame/transaction-payment/asset-tx-payment/src/payment.rs index 394696cc18929..80ff4e40dcffa 100644 --- a/frame/transaction-payment/asset-tx-payment/src/payment.rs +++ b/frame/transaction-payment/asset-tx-payment/src/payment.rs @@ -54,8 +54,8 @@ pub trait OnChargeAssetTransaction { /// Note: The `fee` already includes the `tip`. fn withdraw_fee( who: &T::AccountId, - call: &T::Call, - dispatch_info: &DispatchInfoOf, + call: &T::RuntimeCall, + dispatch_info: &DispatchInfoOf, asset_id: Self::AssetId, fee: Self::Balance, tip: Self::Balance, @@ -68,8 +68,8 @@ pub trait OnChargeAssetTransaction { /// Note: The `fee` already includes the `tip`. fn correct_and_deposit_fee( who: &T::AccountId, - dispatch_info: &DispatchInfoOf, - post_info: &PostDispatchInfoOf, + dispatch_info: &DispatchInfoOf, + post_info: &PostDispatchInfoOf, corrected_fee: Self::Balance, tip: Self::Balance, already_withdrawn: Self::LiquidityInfo, @@ -114,8 +114,8 @@ where /// Note: The `fee` already includes the `tip`. fn withdraw_fee( who: &T::AccountId, - _call: &T::Call, - _info: &DispatchInfoOf, + _call: &T::RuntimeCall, + _info: &DispatchInfoOf, asset_id: Self::AssetId, fee: Self::Balance, _tip: Self::Balance, @@ -142,8 +142,8 @@ where /// Note: The `corrected_fee` already includes the `tip`. fn correct_and_deposit_fee( who: &T::AccountId, - _dispatch_info: &DispatchInfoOf, - _post_info: &PostDispatchInfoOf, + _dispatch_info: &DispatchInfoOf, + _post_info: &PostDispatchInfoOf, corrected_fee: Self::Balance, _tip: Self::Balance, paid: Self::LiquidityInfo, diff --git a/frame/transaction-payment/asset-tx-payment/src/tests.rs b/frame/transaction-payment/asset-tx-payment/src/tests.rs index 3b29df22f2f6c..2515b28a6d93e 100644 --- a/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -90,7 +90,7 @@ impl frame_system::Config for Runtime { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = AccountId; diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index f770eb98ca908..2934d6082a1cb 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -404,7 +404,7 @@ where len: u32, ) -> RuntimeDispatchInfo> where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { // NOTE: we can actually make it understand `ChargeTransactionPayment`, but would be some // hassle for sure. We have to make it aware of the index of `ChargeTransactionPayment` in @@ -431,7 +431,7 @@ where len: u32, ) -> FeeDetails> where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { let dispatch_info = ::get_dispatch_info(&unchecked_extrinsic); @@ -446,11 +446,11 @@ where } /// Query information of a dispatch class, weight, and fee of a given encoded `Call`. - pub fn query_call_info(call: T::Call, len: u32) -> RuntimeDispatchInfo> + pub fn query_call_info(call: T::RuntimeCall, len: u32) -> RuntimeDispatchInfo> where - T::Call: Dispatchable + GetDispatchInfo, + T::RuntimeCall: Dispatchable + GetDispatchInfo, { - let dispatch_info = ::get_dispatch_info(&call); + let dispatch_info = ::get_dispatch_info(&call); let DispatchInfo { weight, class, .. } = dispatch_info; RuntimeDispatchInfo { @@ -461,20 +461,20 @@ where } /// Query fee details of a given encoded `Call`. - pub fn query_call_fee_details(call: T::Call, len: u32) -> FeeDetails> + pub fn query_call_fee_details(call: T::RuntimeCall, len: u32) -> FeeDetails> where - T::Call: Dispatchable + GetDispatchInfo, + T::RuntimeCall: Dispatchable + GetDispatchInfo, { - let dispatch_info = ::get_dispatch_info(&call); + let dispatch_info = ::get_dispatch_info(&call); let tip = 0u32.into(); Self::compute_fee_details(len, &dispatch_info, tip) } /// Compute the final fee value for a particular transaction. - pub fn compute_fee(len: u32, info: &DispatchInfoOf, tip: BalanceOf) -> BalanceOf + pub fn compute_fee(len: u32, info: &DispatchInfoOf, tip: BalanceOf) -> BalanceOf where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { Self::compute_fee_details(len, info, tip).final_fee() } @@ -482,11 +482,11 @@ where /// Compute the fee details for a particular transaction. pub fn compute_fee_details( len: u32, - info: &DispatchInfoOf, + info: &DispatchInfoOf, tip: BalanceOf, ) -> FeeDetails> where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { Self::compute_fee_raw(len, info.weight, tip, info.pays_fee, info.class) } @@ -497,12 +497,12 @@ where /// weight is used for the weight fee calculation. pub fn compute_actual_fee( len: u32, - info: &DispatchInfoOf, - post_info: &PostDispatchInfoOf, + info: &DispatchInfoOf, + post_info: &PostDispatchInfoOf, tip: BalanceOf, ) -> BalanceOf where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { Self::compute_actual_fee_details(len, info, post_info, tip).final_fee() } @@ -510,12 +510,12 @@ where /// Compute the actual post dispatch fee details for a particular transaction. pub fn compute_actual_fee_details( len: u32, - info: &DispatchInfoOf, - post_info: &PostDispatchInfoOf, + info: &DispatchInfoOf, + post_info: &PostDispatchInfoOf, tip: BalanceOf, ) -> FeeDetails> where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { Self::compute_fee_raw( len, @@ -596,7 +596,7 @@ pub struct ChargeTransactionPayment(#[codec(compact)] BalanceOf); impl ChargeTransactionPayment where - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, BalanceOf: Send + Sync + FixedPointOperand, { /// utility constructor. Used only in client/factory code. @@ -612,8 +612,8 @@ where fn withdraw_fee( &self, who: &T::AccountId, - call: &T::Call, - info: &DispatchInfoOf, + call: &T::RuntimeCall, + info: &DispatchInfoOf, len: usize, ) -> Result< ( @@ -645,7 +645,7 @@ where /// state of-the-art blockchains, number of per-block transactions is expected to be in a /// range reasonable enough to not saturate the `Balance` type while multiplying by the tip. pub fn get_priority( - info: &DispatchInfoOf, + info: &DispatchInfoOf, len: usize, tip: BalanceOf, final_fee: BalanceOf, @@ -715,11 +715,11 @@ impl sp_std::fmt::Debug for ChargeTransactionPayment { impl SignedExtension for ChargeTransactionPayment where BalanceOf: Send + Sync + From + FixedPointOperand, - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { const IDENTIFIER: &'static str = "ChargeTransactionPayment"; type AccountId = T::AccountId; - type Call = T::Call; + type Call = T::RuntimeCall; type AdditionalSigned = (); type Pre = ( // tip @@ -781,7 +781,7 @@ impl EstimateCallFee where BalanceOf: FixedPointOperand, - T::Call: Dispatchable, + T::RuntimeCall: Dispatchable, { fn estimate_call_fee(call: &AnyCall, post_info: PostDispatchInfo) -> BalanceOf { let len = call.encoded_size() as u32; @@ -868,7 +868,7 @@ mod tests { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; diff --git a/frame/transaction-payment/src/payment.rs b/frame/transaction-payment/src/payment.rs index 3a5fad0d66a52..ebc9c5c5afd62 100644 --- a/frame/transaction-payment/src/payment.rs +++ b/frame/transaction-payment/src/payment.rs @@ -37,8 +37,8 @@ pub trait OnChargeTransaction { /// Note: The `fee` already includes the `tip`. fn withdraw_fee( who: &T::AccountId, - call: &T::Call, - dispatch_info: &DispatchInfoOf, + call: &T::RuntimeCall, + dispatch_info: &DispatchInfoOf, fee: Self::Balance, tip: Self::Balance, ) -> Result; @@ -50,8 +50,8 @@ pub trait OnChargeTransaction { /// Note: The `fee` already includes the `tip`. fn correct_and_deposit_fee( who: &T::AccountId, - dispatch_info: &DispatchInfoOf, - post_info: &PostDispatchInfoOf, + dispatch_info: &DispatchInfoOf, + post_info: &PostDispatchInfoOf, corrected_fee: Self::Balance, tip: Self::Balance, already_withdrawn: Self::LiquidityInfo, @@ -92,8 +92,8 @@ where /// Note: The `fee` already includes the `tip`. fn withdraw_fee( who: &T::AccountId, - _call: &T::Call, - _info: &DispatchInfoOf, + _call: &T::RuntimeCall, + _info: &DispatchInfoOf, fee: Self::Balance, tip: Self::Balance, ) -> Result { @@ -120,8 +120,8 @@ where /// Note: The `corrected_fee` already includes the `tip`. fn correct_and_deposit_fee( who: &T::AccountId, - _dispatch_info: &DispatchInfoOf, - _post_info: &PostDispatchInfoOf, + _dispatch_info: &DispatchInfoOf, + _post_info: &PostDispatchInfoOf, corrected_fee: Self::Balance, tip: Self::Balance, already_withdrawn: Self::LiquidityInfo, diff --git a/frame/transaction-storage/src/lib.rs b/frame/transaction-storage/src/lib.rs index 5fdd3a58deb44..e623079ac863b 100644 --- a/frame/transaction-storage/src/lib.rs +++ b/frame/transaction-storage/src/lib.rs @@ -94,7 +94,7 @@ pub mod pallet { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A dispatchable call. - type Call: Parameter + type RuntimeCall: Parameter + Dispatchable + GetDispatchInfo + From>; diff --git a/frame/transaction-storage/src/mock.rs b/frame/transaction-storage/src/mock.rs index 5ea3a158a2aab..1cb725e63e83b 100644 --- a/frame/transaction-storage/src/mock.rs +++ b/frame/transaction-storage/src/mock.rs @@ -52,7 +52,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; @@ -88,7 +88,7 @@ impl pallet_balances::Config for Test { impl pallet_transaction_storage::Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Currency = Balances; type FeeDestination = (); type WeightInfo = (); diff --git a/frame/treasury/src/tests.rs b/frame/treasury/src/tests.rs index 2f34ccc75a1fa..ce8574a7e6884 100644 --- a/frame/treasury/src/tests.rs +++ b/frame/treasury/src/tests.rs @@ -65,7 +65,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Index = u64; type BlockNumber = u64; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u128; // u64 is not enough to hold bytes used to generate bounty account diff --git a/frame/uniques/src/mock.rs b/frame/uniques/src/mock.rs index e007e5de1f11f..6808c48007a92 100644 --- a/frame/uniques/src/mock.rs +++ b/frame/uniques/src/mock.rs @@ -50,7 +50,7 @@ impl frame_system::Config for Test { type BlockWeights = (); type BlockLength = (); type Origin = Origin; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Index = u64; type BlockNumber = u64; type Hash = H256; diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index d11acb19cb089..8d8fc43c07172 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -87,7 +87,7 @@ pub mod pallet { type RuntimeEvent: From + IsType<::RuntimeEvent>; /// The overarching call type. - type Call: Parameter + type RuntimeCall: Parameter + Dispatchable + GetDispatchInfo + From> diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index b6a358017513f..97380a2dd534e 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -110,7 +110,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -164,7 +164,7 @@ impl Contains for TestBaseCallFilter { } impl Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type PalletsOrigin = OriginCaller; type WeightInfo = (); } diff --git a/frame/vesting/src/mock.rs b/frame/vesting/src/mock.rs index 5482a2f3dd5b8..24e5bf20c592c 100644 --- a/frame/vesting/src/mock.rs +++ b/frame/vesting/src/mock.rs @@ -55,7 +55,7 @@ impl frame_system::Config for Test { type BlockLength = (); type BlockNumber = u64; type BlockWeights = (); - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type DbWeight = (); type RuntimeEvent = RuntimeEvent; type Hash = H256; diff --git a/frame/whitelist/src/lib.rs b/frame/whitelist/src/lib.rs index 60a6fc4266aaa..e5dda5fd510ba 100644 --- a/frame/whitelist/src/lib.rs +++ b/frame/whitelist/src/lib.rs @@ -64,7 +64,7 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// The overarching call type. - type Call: IsType<::RuntimeCall> + type RuntimeCall: IsType<::RuntimeCall> + Dispatchable + GetDispatchInfo + FullCodec diff --git a/frame/whitelist/src/mock.rs b/frame/whitelist/src/mock.rs index 4c56fa399781c..9fa5ddb97cb58 100644 --- a/frame/whitelist/src/mock.rs +++ b/frame/whitelist/src/mock.rs @@ -62,7 +62,7 @@ impl frame_system::Config for Test { type Index = u64; type BlockNumber = u64; type Hash = H256; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type Hashing = BlakeTwo256; type AccountId = u64; type Lookup = IdentityLookup; @@ -104,7 +104,7 @@ impl pallet_preimage::Config for Test { impl pallet_whitelist::Config for Test { type RuntimeEvent = RuntimeEvent; - type Call = RuntimeCall; + type RuntimeCall = RuntimeCall; type WhitelistOrigin = EnsureRoot; type DispatchWhitelistedOrigin = EnsureRoot; type PreimageProvider = Preimage; diff --git a/test-utils/runtime/src/lib.rs b/test-utils/runtime/src/lib.rs index 21319184b4117..2e44d177b21a6 100644 --- a/test-utils/runtime/src/lib.rs +++ b/test-utils/runtime/src/lib.rs @@ -455,11 +455,11 @@ impl From for Result, Origin> { } impl frame_support::traits::OriginTrait for Origin { - type RuntimeCall = ::RuntimeCall; + type Call = ::RuntimeCall; type PalletsOrigin = Origin; type AccountId = ::AccountId; - fn add_filter(&mut self, _filter: impl Fn(&Self::RuntimeCall) -> bool + 'static) { + fn add_filter(&mut self, _filter: impl Fn(&Self::Call) -> bool + 'static) { unimplemented!("Not required in tests!") } @@ -471,7 +471,7 @@ impl frame_support::traits::OriginTrait for Origin { unimplemented!("Not required in tests!") } - fn filter_call(&self, _call: &Self::RuntimeCall) -> bool { + fn filter_call(&self, _call: &Self::Call) -> bool { unimplemented!("Not required in tests!") } From 5eddd0d4cab98c080fc7aef1ab128285c370f166 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 15:39:27 +0200 Subject: [PATCH 41/63] fix & fmt --- frame/contracts/src/wasm/mod.rs | 5 +++- frame/lottery/src/lib.rs | 10 +++++-- frame/scheduler/src/lib.rs | 44 +++++++++++++++------------- frame/sudo/src/lib.rs | 4 ++- frame/support/src/dispatch.rs | 6 ++-- frame/support/test/tests/pallet.rs | 5 +++- frame/transaction-payment/src/lib.rs | 6 +++- frame/utility/src/lib.rs | 15 ++++++---- 8 files changed, 59 insertions(+), 36 deletions(-) diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index c94c0e744b7f0..e3b56f746b444 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -532,7 +532,10 @@ mod tests { self.debug_buffer.extend(msg.as_bytes()); true } - fn call_runtime(&self, call: ::RuntimeCall) -> DispatchResultWithPostInfo { + fn call_runtime( + &self, + call: ::RuntimeCall, + ) -> DispatchResultWithPostInfo { self.runtime_calls.borrow_mut().push(call); Ok(Default::default()) } diff --git a/frame/lottery/src/lib.rs b/frame/lottery/src/lib.rs index 34a97636cb389..505dd1bb98caa 100644 --- a/frame/lottery/src/lib.rs +++ b/frame/lottery/src/lib.rs @@ -300,7 +300,10 @@ pub mod pallet { T::WeightInfo::buy_ticket() .saturating_add(call.get_dispatch_info().weight) )] - pub fn buy_ticket(origin: OriginFor, call: Box<::RuntimeCall>) -> DispatchResult { + pub fn buy_ticket( + origin: OriginFor, + call: Box<::RuntimeCall>, + ) -> DispatchResult { let caller = ensure_signed(origin.clone())?; call.clone().dispatch(origin).map_err(|e| e.error)?; @@ -315,7 +318,10 @@ pub mod pallet { /// /// This extrinsic must be called by the Manager origin. #[pallet::weight(T::WeightInfo::set_calls(calls.len() as u32))] - pub fn set_calls(origin: OriginFor, calls: Vec<::RuntimeCall>) -> DispatchResult { + pub fn set_calls( + origin: OriginFor, + calls: Vec<::RuntimeCall>, + ) -> DispatchResult { T::ManagerOrigin::ensure_origin(origin)?; ensure!(calls.len() <= T::MaxCalls::get() as usize, Error::::TooManyCalls); if calls.is_empty() { diff --git a/frame/scheduler/src/lib.rs b/frame/scheduler/src/lib.rs index dd40d1afd088b..67903746ecdf7 100644 --- a/frame/scheduler/src/lib.rs +++ b/frame/scheduler/src/lib.rs @@ -82,7 +82,8 @@ pub type PeriodicIndex = u32; /// The location of a scheduled task that can be used to remove it. pub type TaskAddress = (BlockNumber, u32); -pub type CallOrHashOf = MaybeHashed<::RuntimeCall, ::Hash>; +pub type CallOrHashOf = + MaybeHashed<::RuntimeCall, ::Hash>; #[cfg_attr(any(feature = "std", test), derive(PartialEq, Eq))] #[derive(Clone, RuntimeDebug, Encode, Decode)] @@ -543,27 +544,28 @@ impl Pallet { pub fn migrate_v1_to_v3() -> Weight { let mut weight = T::DbWeight::get().reads_writes(1, 1); - Agenda::::translate::::RuntimeCall, T::BlockNumber>>>, _>( - |_, agenda| { - Some( - agenda - .into_iter() - .map(|schedule| { - weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); - - schedule.map(|schedule| ScheduledV3 { - maybe_id: schedule.maybe_id, - priority: schedule.priority, - call: schedule.call.into(), - maybe_periodic: schedule.maybe_periodic, - origin: system::RawOrigin::Root.into(), - _phantom: Default::default(), - }) + Agenda::::translate::< + Vec::RuntimeCall, T::BlockNumber>>>, + _, + >(|_, agenda| { + Some( + agenda + .into_iter() + .map(|schedule| { + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); + + schedule.map(|schedule| ScheduledV3 { + maybe_id: schedule.maybe_id, + priority: schedule.priority, + call: schedule.call.into(), + maybe_periodic: schedule.maybe_periodic, + origin: system::RawOrigin::Root.into(), + _phantom: Default::default(), }) - .collect::>(), - ) - }, - ); + }) + .collect::>(), + ) + }); #[allow(deprecated)] frame_support::storage::migration::remove_storage_prefix( diff --git a/frame/sudo/src/lib.rs b/frame/sudo/src/lib.rs index a3ebcbedceb2b..30d0de7d8eec5 100644 --- a/frame/sudo/src/lib.rs +++ b/frame/sudo/src/lib.rs @@ -118,7 +118,9 @@ pub mod pallet { type RuntimeEvent: From> + IsType<::RuntimeEvent>; /// A sudo-able call. - type RuntimeCall: Parameter + UnfilteredDispatchable + GetDispatchInfo; + type RuntimeCall: Parameter + + UnfilteredDispatchable + + GetDispatchInfo; } #[pallet::pallet] diff --git a/frame/support/src/dispatch.rs b/frame/support/src/dispatch.rs index e6f636633c7bb..7991a1d67691f 100644 --- a/frame/support/src/dispatch.rs +++ b/frame/support/src/dispatch.rs @@ -2612,7 +2612,7 @@ mod tests { pub trait Config: 'static { type AccountId; - type Call; + type RuntimeCall; type BaseCallFilter; type Origin: crate::traits::OriginTrait; type BlockNumber: Into; @@ -2719,7 +2719,7 @@ mod tests { type PalletsOrigin = OuterOrigin; type AccountId = ::AccountId; - fn add_filter(&mut self, _filter: impl Fn(&Self::RuntimeCall) -> bool + 'static) { + fn add_filter(&mut self, _filter: impl Fn(&Self::Call) -> bool + 'static) { unimplemented!("Not required in tests!") } @@ -2731,7 +2731,7 @@ mod tests { unimplemented!("Not required in tests!") } - fn filter_call(&self, _call: &Self::RuntimeCall) -> bool { + fn filter_call(&self, _call: &Self::Call) -> bool { unimplemented!("Not required in tests!") } diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 54286978cfa71..2170ea1747390 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -376,7 +376,10 @@ pub mod pallet { T::AccountId: From + SomeAssociation1 + From + From, { type Call = Call; - fn validate_unsigned(_source: TransactionSource, call: &Self::RuntimeCall) -> TransactionValidity { + fn validate_unsigned( + _source: TransactionSource, + call: &Self::RuntimeCall, + ) -> TransactionValidity { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType5); // Test for where clause if matches!(call, Call::foo_storage_layer { .. }) { diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 2934d6082a1cb..397a5fdc3bcc9 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -472,7 +472,11 @@ where } /// Compute the final fee value for a particular transaction. - pub fn compute_fee(len: u32, info: &DispatchInfoOf, tip: BalanceOf) -> BalanceOf + pub fn compute_fee( + len: u32, + info: &DispatchInfoOf, + tip: BalanceOf, + ) -> BalanceOf where T::RuntimeCall: Dispatchable, { diff --git a/frame/utility/src/lib.rs b/frame/utility/src/lib.rs index 8d8fc43c07172..602beb871b21d 100644 --- a/frame/utility/src/lib.rs +++ b/frame/utility/src/lib.rs @@ -133,8 +133,9 @@ pub mod pallet { /// The limit on the number of batched calls. fn batched_calls_limit() -> u32 { let allocator_limit = sp_core::MAX_POSSIBLE_ALLOCATION; - let call_size = ((sp_std::mem::size_of::<::RuntimeCall>() as u32 + CALL_ALIGN - - 1) / CALL_ALIGN) * CALL_ALIGN; + let call_size = ((sp_std::mem::size_of::<::RuntimeCall>() as u32 + + CALL_ALIGN - 1) / CALL_ALIGN) * + CALL_ALIGN; // The margin to take into account vec doubling capacity. let margin_factor = 3; @@ -333,10 +334,12 @@ pub mod pallet { } else { let mut filtered_origin = origin.clone(); // Don't allow users to nest `batch_all` calls. - filtered_origin.add_filter(move |c: &::RuntimeCall| { - let c = ::RuntimeCall::from_ref(c); - !matches!(c.is_sub_type(), Some(Call::batch_all { .. })) - }); + filtered_origin.add_filter( + move |c: &::RuntimeCall| { + let c = ::RuntimeCall::from_ref(c); + !matches!(c.is_sub_type(), Some(Call::batch_all { .. })) + }, + ); call.dispatch(filtered_origin) }; // Add the weight of this call. From e1abbf86f17943b50132263b3845c700fb40ee91 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 15:47:30 +0200 Subject: [PATCH 42/63] commit --- frame/babe/src/mock.rs | 2 +- frame/election-provider-multi-phase/src/mock.rs | 2 +- frame/examples/offchain-worker/src/tests.rs | 2 +- frame/executive/src/lib.rs | 2 +- frame/grandpa/src/mock.rs | 2 +- frame/im-online/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 68837cd32a5e7..016130337bf9f 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -101,7 +101,7 @@ where Call: From, { type OverarchingCall = RuntimeCall; - type Extrinsic = TestXt; + type Extrinsic = TestXt; } impl_opaque_keys! { diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 2005d9a1dbd81..8c2acb9961fe4 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -397,7 +397,7 @@ where type Extrinsic = Extrinsic; } -pub type Extrinsic = sp_runtime::testing::TestXt; +pub type Extrinsic = sp_runtime::testing::TestXt; parameter_types! { pub MaxNominations: u32 = ::LIMIT as u32; diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 5181747d30cde..1ef158b7f2e4a 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -82,7 +82,7 @@ impl frame_system::Config for Test { type MaxConsumers = ConstU32<16>; } -type Extrinsic = TestXt; +type Extrinsic = TestXt; type AccountId = <::Signer as IdentifyAccount>::AccountId; impl frame_system::offchain::SigningTypes for Test { diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index b4ded42481396..58172357f86a7 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -801,7 +801,7 @@ mod tests { frame_system::CheckWeight, pallet_transaction_payment::ChargeTransactionPayment, ); - type TestXt = sp_runtime::testing::TestXt; + type TestXt = sp_runtime::testing::TestXt; type TestBlock = Block; type TestUncheckedExtrinsic = TestXt; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index ac8851c6c121f..94224268a7ce0 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -106,7 +106,7 @@ where Call: From, { type OverarchingCall = RuntimeCall; - type Extrinsic = TestXt; + type Extrinsic = TestXt; } parameter_types! { diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 7fac89e481817..1e7217ea0c4db 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -87,7 +87,7 @@ impl pallet_session::historical::SessionManager for TestSessionManager } /// An extrinsic type used for tests. -pub type Extrinsic = TestXt; +pub type Extrinsic = TestXt; type IdentificationTuple = (u64, u64); type Offence = crate::UnresponsivenessOffence; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 51b52eef8087f..365ea4a81806a 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -146,7 +146,7 @@ parameter_types! { pub const RewardCurve: &'static sp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS; } -pub type Extrinsic = sp_runtime::testing::TestXt; +pub type Extrinsic = sp_runtime::testing::TestXt; pub struct OnChainSeqPhragmen; impl onchain::Config for OnChainSeqPhragmen { From 064b3124a5e4ca85252040b786a75f8f38db39ac Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 17:00:14 +0200 Subject: [PATCH 43/63] frame-support-test --- frame/support/test/tests/construct_runtime.rs | 10 +++++----- .../both_use_and_excluded_parts.rs | 2 +- .../both_use_and_excluded_parts.stderr | 2 +- .../exclude_undefined_part.rs | 2 +- .../exclude_undefined_part.stderr | 2 +- .../no_std_genesis_config.rs | 2 +- .../pallet_error_too_large.rs | 2 +- .../construct_runtime_ui/undefined_call_part.rs | 2 +- .../undefined_event_part.rs | 2 +- .../undefined_genesis_config_part.rs | 2 +- .../undefined_inherent_part.rs | 2 +- .../undefined_origin_part.rs | 2 +- .../undefined_validate_unsigned_part.rs | 2 +- .../construct_runtime_ui/use_undefined_part.rs | 2 +- .../use_undefined_part.stderr | 2 +- frame/support/test/tests/instance.rs | 14 +++++++------- frame/support/test/tests/issue2219.rs | 2 +- frame/support/test/tests/origin.rs | 10 +++++----- frame/support/test/tests/pallet.rs | 17 +++++++---------- .../support/test/tests/pallet_compatibility.rs | 2 +- .../test/tests/pallet_compatibility_instance.rs | 2 +- frame/support/test/tests/pallet_instance.rs | 8 ++++---- .../tests/pallet_with_name_trait_is_valid.rs | 8 ++++---- frame/support/test/tests/storage_layers.rs | 10 +++++----- frame/support/test/tests/system.rs | 2 +- 25 files changed, 55 insertions(+), 58 deletions(-) diff --git a/frame/support/test/tests/construct_runtime.rs b/frame/support/test/tests/construct_runtime.rs index e44c6c522c551..89fff8daa0d25 100644 --- a/frame/support/test/tests/construct_runtime.rs +++ b/frame/support/test/tests/construct_runtime.rs @@ -278,7 +278,7 @@ frame_support::construct_runtime!( pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; #[test] fn check_modules_error_type() { @@ -527,7 +527,7 @@ fn call_name() { #[test] fn call_metadata() { use frame_support::dispatch::{CallMetadata, GetCallMetadata}; - let call = Call::Module3(module3::Call::::aux_4 {}); + let call = RuntimeCall::Module3(module3::Call::::aux_4 {}); let metadata = call.get_call_metadata(); let expected = CallMetadata { function_name: "aux_4".into(), pallet_name: "Module3".into() }; assert_eq!(metadata, expected); @@ -543,7 +543,7 @@ fn get_call_names() { #[test] fn get_module_names() { use frame_support::dispatch::GetCallMetadata; - let module_names = Call::get_module_names(); + let module_names = RuntimeCall::get_module_names(); assert_eq!( [ "System", @@ -565,13 +565,13 @@ fn get_module_names() { #[test] fn call_subtype_conversion() { use frame_support::{dispatch::CallableCallFor, traits::IsSubType}; - let call = Call::Module3(module3::Call::::fail {}); + let call = RuntimeCall::Module3(module3::Call::::fail {}); let subcall: Option<&CallableCallFor> = call.is_sub_type(); let subcall_none: Option<&CallableCallFor> = call.is_sub_type(); assert_eq!(Some(&module3::Call::::fail {}), subcall); assert_eq!(None, subcall_none); - let from = Call::from(subcall.unwrap().clone()); + let from = RuntimeCall::from(subcall.unwrap().clone()); assert_eq!(from, call); } diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs index 98cd1f197f619..7a074db9986a2 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.rs @@ -15,7 +15,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u64; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr index 608d57d6a97fc..ff8cd022b70d9 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr @@ -7,7 +7,7 @@ error: Unexpected tokens, expected one of `=`, `,` error[E0412]: cannot find type `Call` in this scope --> $DIR/both_use_and_excluded_parts.rs:18:64 | -18 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +18 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; | ^^^^ not found in this scope | help: consider importing one of these items diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs index 51be7e30bd3eb..302b5af7ecd26 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.rs @@ -20,7 +20,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u64; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr index 4e31cfb75c074..b63f4e531f6ab 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr @@ -7,7 +7,7 @@ error: Invalid pallet part specified, the pallet `Pallet` doesn't have the `Call error[E0412]: cannot find type `Call` in this scope --> $DIR/exclude_undefined_part.rs:23:64 | -23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; | ^^^^ not found in this scope | help: consider importing one of these items diff --git a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs index a1ccdccc83de2..fd6b51db07672 100644 --- a/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs +++ b/frame/support/test/tests/construct_runtime_ui/no_std_genesis_config.rs @@ -6,7 +6,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u32; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl test_pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs index 89dc95aea2392..f73c611d29686 100644 --- a/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs +++ b/frame/support/test/tests/construct_runtime_ui/pallet_error_too_large.rs @@ -40,7 +40,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u32; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs index 5f014b04058c1..f90af88d23a9b 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_call_part.rs @@ -15,7 +15,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u32; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs index 0630171289540..60d4b166c41fd 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_event_part.rs @@ -15,7 +15,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u32; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs index af615922af047..5f7beed686339 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_genesis_config_part.rs @@ -15,7 +15,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u32; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs index 0782706845d30..fb866c161ccb8 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_inherent_part.rs @@ -15,7 +15,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u32; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs index 92a3f304a2d53..26ca5d6eb4cb0 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_origin_part.rs @@ -15,7 +15,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u32; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs index aa3f97798d148..81c040c660451 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.rs @@ -15,7 +15,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u32; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs index 1664dcc42b755..c74e29bc05469 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.rs @@ -20,7 +20,7 @@ pub type Signature = sr25519::Signature; pub type BlockNumber = u64; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl pallet::Config for Runtime {} diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr index ed41f0ce673a4..9f3373d0b4dfa 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr @@ -7,7 +7,7 @@ error: Invalid pallet part specified, the pallet `Pallet` doesn't have the `Call error[E0412]: cannot find type `Call` in this scope --> $DIR/use_undefined_part.rs:23:64 | -23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; | ^^^^ not found in this scope | help: consider importing one of these items diff --git a/frame/support/test/tests/instance.rs b/frame/support/test/tests/instance.rs index 514f09c88715d..c9eebdaff6bc4 100644 --- a/frame/support/test/tests/instance.rs +++ b/frame/support/test/tests/instance.rs @@ -129,18 +129,18 @@ mod module1 { type Error = MakeFatalError<()>; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &InherentData) -> Option { + fn create_inherent(_data: &InherentData) -> Option { unimplemented!(); } fn check_inherent( - _: &Self::RuntimeCall, + _: &Self::Call, _: &InherentData, ) -> std::result::Result<(), Self::Error> { unimplemented!(); } - fn is_inherent(_call: &Self::RuntimeCall) -> bool { + fn is_inherent(_call: &Self::Call) -> bool { unimplemented!(); } } @@ -198,18 +198,18 @@ mod module2 { type Error = MakeFatalError<()>; const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &InherentData) -> Option { + fn create_inherent(_data: &InherentData) -> Option { unimplemented!(); } fn check_inherent( - _call: &Self::RuntimeCall, + _call: &Self::Call, _data: &InherentData, ) -> std::result::Result<(), Self::Error> { unimplemented!(); } - fn is_inherent(_call: &Self::RuntimeCall) -> bool { + fn is_inherent(_call: &Self::Call) -> bool { unimplemented!(); } } @@ -315,7 +315,7 @@ frame_support::construct_runtime!( pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; fn new_test_ext() -> sp_io::TestExternalities { GenesisConfig { diff --git a/frame/support/test/tests/issue2219.rs b/frame/support/test/tests/issue2219.rs index 487701d69fe38..0b24a6aa89828 100644 --- a/frame/support/test/tests/issue2219.rs +++ b/frame/support/test/tests/issue2219.rs @@ -155,7 +155,7 @@ pub type BlockNumber = u64; pub type Index = u64; pub type Header = generic::Header; pub type Block = generic::Block; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; impl system::Config for Runtime { type BaseCallFilter = frame_support::traits::Everything; diff --git a/frame/support/test/tests/origin.rs b/frame/support/test/tests/origin.rs index e70cab21f1478..53124059e6353 100644 --- a/frame/support/test/tests/origin.rs +++ b/frame/support/test/tests/origin.rs @@ -134,10 +134,10 @@ impl nested::module::Config for RuntimeOriginTest {} impl module::Config for RuntimeOriginTest {} pub struct BaseCallFilter; -impl Contains for BaseCallFilter { - fn contains(c: &Call) -> bool { +impl Contains for BaseCallFilter { + fn contains(c: &RuntimeCall) -> bool { match c { - Call::NestedModule(_) => true, + RuntimeCall::NestedModule(_) => true, _ => false, } } @@ -170,7 +170,7 @@ frame_support::construct_runtime!( pub type Signature = sr25519::Signature; pub type BlockNumber = u64; pub type Header = generic::Header; -pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; pub type Block = generic::Block; #[test] @@ -192,7 +192,7 @@ fn origin_default_filter() { assert_eq!(Origin::from(nested::module::Origin).filter_call(&rejected_call), false); let mut origin = Origin::from(Some(0)); - origin.add_filter(|c| matches!(c, Call::Module(_))); + origin.add_filter(|c| matches!(c, RuntimeCall::Module(_))); assert_eq!(origin.filter_call(&accepted_call), false); assert_eq!(origin.filter_call(&rejected_call), false); diff --git a/frame/support/test/tests/pallet.rs b/frame/support/test/tests/pallet.rs index 2170ea1747390..897fcefd5f541 100644 --- a/frame/support/test/tests/pallet.rs +++ b/frame/support/test/tests/pallet.rs @@ -376,10 +376,7 @@ pub mod pallet { T::AccountId: From + SomeAssociation1 + From + From, { type Call = Call; - fn validate_unsigned( - _source: TransactionSource, - call: &Self::RuntimeCall, - ) -> TransactionValidity { + fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType5); // Test for where clause if matches!(call, Call::foo_storage_layer { .. }) { @@ -399,17 +396,17 @@ pub mod pallet { const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &InherentData) -> Option { + fn create_inherent(_data: &InherentData) -> Option { let _ = T::AccountId::from(SomeType1); // Test for where clause let _ = T::AccountId::from(SomeType6); // Test for where clause Some(Call::foo_no_post_info {}) } - fn is_inherent(call: &Self::RuntimeCall) -> bool { + fn is_inherent(call: &Self::Call) -> bool { matches!(call, Call::foo_no_post_info {} | Call::foo { .. }) } - fn check_inherent(call: &Self::RuntimeCall, _: &InherentData) -> Result<(), Self::Error> { + fn check_inherent(call: &Self::Call, _: &InherentData) -> Result<(), Self::Error> { match call { Call::foo_no_post_info {} => Ok(()), Call::foo { foo: 0, bar: 0 } => Err(InherentError::Fatal), @@ -592,7 +589,7 @@ impl pallet4::Config for Runtime {} pub type Header = sp_runtime::generic::Header; pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( pub enum Runtime where @@ -608,8 +605,8 @@ frame_support::construct_runtime!( } ); -// Test that the part `Call` is excluded from Example2 and included in Example4. -fn _ensure_call_is_correctly_excluded_and_included(call: Call) { +// Test that the part `RuntimeCall` is excluded from Example2 and included in Example4. +fn _ensure_call_is_correctly_excluded_and_included(call: RuntimeCall) { match call { RuntimeCall::System(_) | RuntimeCall::Example(_) | RuntimeCall::Example4(_) => (), } diff --git a/frame/support/test/tests/pallet_compatibility.rs b/frame/support/test/tests/pallet_compatibility.rs index 44a7ee5916be4..3d71d77515977 100644 --- a/frame/support/test/tests/pallet_compatibility.rs +++ b/frame/support/test/tests/pallet_compatibility.rs @@ -263,7 +263,7 @@ impl pallet_old::Config for Runtime { pub type Header = sp_runtime::generic::Header; pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( pub enum Runtime where diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 3df8093c4e965..3e00dc16932fd 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -264,7 +264,7 @@ impl pallet_old::Config for Runtime { pub type Header = sp_runtime::generic::Header; pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( pub enum Runtime where diff --git a/frame/support/test/tests/pallet_instance.rs b/frame/support/test/tests/pallet_instance.rs index af55038251899..7508abd281de8 100644 --- a/frame/support/test/tests/pallet_instance.rs +++ b/frame/support/test/tests/pallet_instance.rs @@ -176,7 +176,7 @@ pub mod pallet { type Call = Call; fn validate_unsigned( _source: TransactionSource, - _call: &Self::RuntimeCall, + _call: &Self::Call, ) -> TransactionValidity { Err(TransactionValidityError::Invalid(InvalidTransaction::Call)) } @@ -189,11 +189,11 @@ pub mod pallet { const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &InherentData) -> Option { + fn create_inherent(_data: &InherentData) -> Option { unimplemented!(); } - fn is_inherent(_call: &Self::RuntimeCall) -> bool { + fn is_inherent(_call: &Self::Call) -> bool { unimplemented!(); } } @@ -294,7 +294,7 @@ impl pallet2::Config for Runtime { pub type Header = sp_runtime::generic::Header; pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( pub enum Runtime where diff --git a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs index 796df2c145b0e..b0338e02a784f 100644 --- a/frame/support/test/tests/pallet_with_name_trait_is_valid.rs +++ b/frame/support/test/tests/pallet_with_name_trait_is_valid.rs @@ -64,7 +64,7 @@ impl sp_runtime::traits::ValidateUnsigned for Module { fn validate_unsigned( _source: sp_runtime::transaction_validity::TransactionSource, - _call: &Self::RuntimeCall, + _call: &Self::Call, ) -> sp_runtime::transaction_validity::TransactionValidity { unimplemented!(); } @@ -77,18 +77,18 @@ impl frame_support::inherent::ProvideInherent for Module { type Error = frame_support::inherent::MakeFatalError<()>; const INHERENT_IDENTIFIER: frame_support::inherent::InherentIdentifier = INHERENT_IDENTIFIER; - fn create_inherent(_data: &frame_support::inherent::InherentData) -> Option { + fn create_inherent(_data: &frame_support::inherent::InherentData) -> Option { unimplemented!(); } fn check_inherent( - _: &Self::RuntimeCall, + _: &Self::Call, _: &frame_support::inherent::InherentData, ) -> std::result::Result<(), Self::Error> { unimplemented!(); } - fn is_inherent(_call: &Self::RuntimeCall) -> bool { + fn is_inherent(_call: &Self::Call) -> bool { unimplemented!(); } } diff --git a/frame/support/test/tests/storage_layers.rs b/frame/support/test/tests/storage_layers.rs index 6592a091af42d..a3e512302fe4f 100644 --- a/frame/support/test/tests/storage_layers.rs +++ b/frame/support/test/tests/storage_layers.rs @@ -79,7 +79,7 @@ pub type BlockNumber = u64; pub type Index = u64; pub type Header = sp_runtime::generic::Header; pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; impl frame_system::Config for Runtime { type BlockWeights = (); @@ -255,11 +255,11 @@ fn storage_layer_commit_then_rollback() { fn storage_layer_in_pallet_call() { TestExternalities::default().execute_with(|| { use sp_runtime::traits::Dispatchable; - let call1 = Call::MyPallet(pallet::Call::set_value { value: 2 }); + let call1 = RuntimeCall::MyPallet(pallet::Call::set_value { value: 2 }); assert_ok!(call1.dispatch(Origin::signed(0))); assert_eq!(Value::::get(), 2); - let call2 = Call::MyPallet(pallet::Call::set_value { value: 1 }); + let call2 = RuntimeCall::MyPallet(pallet::Call::set_value { value: 1 }); assert_noop!(call2.dispatch(Origin::signed(0)), Error::::Revert); }); } @@ -270,11 +270,11 @@ fn storage_layer_in_decl_pallet_call() { use frame_support::StorageValue; use sp_runtime::traits::Dispatchable; - let call1 = Call::DeclPallet(decl_pallet::Call::set_value { value: 2 }); + let call1 = RuntimeCall::DeclPallet(decl_pallet::Call::set_value { value: 2 }); assert_ok!(call1.dispatch(Origin::signed(0))); assert_eq!(decl_pallet::DeclValue::get(), 2); - let call2 = Call::DeclPallet(decl_pallet::Call::set_value { value: 1 }); + let call2 = RuntimeCall::DeclPallet(decl_pallet::Call::set_value { value: 1 }); assert_noop!(call2.dispatch(Origin::signed(0)), "Revert!"); // Calling the function directly also works with storage layers. assert_noop!(decl_pallet::Module::::set_value(Origin::signed(1), 1), "Revert!"); diff --git a/frame/support/test/tests/system.rs b/frame/support/test/tests/system.rs index e9489029f45b5..9736c74dc236d 100644 --- a/frame/support/test/tests/system.rs +++ b/frame/support/test/tests/system.rs @@ -29,7 +29,7 @@ pub trait Config: 'static + Eq + Clone { type BlockNumber: Decode + Encode + EncodeLike + Clone + Default + scale_info::TypeInfo; type Hash; type AccountId: Encode + EncodeLike + Decode + scale_info::TypeInfo; - type Call; + type RuntimeCall; type RuntimeEvent: From>; type PalletInfo: frame_support::traits::PalletInfo; type DbWeight: Get; From 40a139aa04cfffc79adfb9a4514c742a07adeda8 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 18:53:17 +0200 Subject: [PATCH 44/63] passing tests --- frame/alliance/src/mock.rs | 12 +- frame/babe/src/mock.rs | 2 +- frame/collective/src/tests.rs | 4 +- frame/contracts/src/exec.rs | 4 +- frame/contracts/src/tests.rs | 8 +- frame/contracts/src/wasm/mod.rs | 4 +- frame/conviction-voting/src/tests.rs | 4 +- frame/democracy/src/tests.rs | 6 +- .../election-provider-multi-phase/src/mock.rs | 5 +- frame/elections-phragmen/src/lib.rs | 3 +- frame/examples/offchain-worker/src/tests.rs | 8 +- frame/executive/src/lib.rs | 12 +- frame/grandpa/src/mock.rs | 2 +- frame/im-online/src/mock.rs | 2 +- frame/lottery/src/tests.rs | 3 +- frame/multisig/src/tests.rs | 6 +- frame/nomination-pools/src/tests.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 4 +- frame/proxy/src/tests.rs | 10 +- frame/recovery/src/tests.rs | 4 +- frame/referenda/src/mock.rs | 4 +- frame/referenda/src/tests.rs | 2 +- frame/scheduler/src/mock.rs | 6 +- frame/scheduler/src/tests.rs | 167 +++++++++++------- frame/staking/src/tests.rs | 15 +- frame/sudo/src/mock.rs | 4 +- frame/sudo/src/tests.rs | 37 ++-- frame/utility/src/tests.rs | 8 +- 28 files changed, 198 insertions(+), 150 deletions(-) diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index fddf172a24db8..390dedaf518ec 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -157,11 +157,11 @@ impl IdentityVerifier for AllianceIdentityVerifier { } pub struct AllianceProposalProvider; -impl ProposalProvider for AllianceProposalProvider { +impl ProposalProvider for AllianceProposalProvider { fn propose_proposal( who: u64, threshold: u32, - proposal: Box, + proposal: Box, length_bound: u32, ) -> Result<(u32, u32), DispatchError> { AllianceMotion::do_propose_proposed(who, threshold, proposal, length_bound) @@ -189,7 +189,7 @@ impl ProposalProvider for AllianceProposalProvider { AllianceMotion::do_close(proposal_hash, proposal_index, proposal_weight_bound, length_bound) } - fn proposal_of(proposal_hash: H256) -> Option { + fn proposal_of(proposal_hash: H256) -> Option { AllianceMotion::proposal_of(proposal_hash) } } @@ -317,14 +317,14 @@ pub fn test_cid() -> Cid { Cid::new_v0(&*result) } -pub fn make_proposal(value: u64) -> Call { +pub fn make_proposal(value: u64) -> RuntimeCall { RuntimeCall::System(frame_system::Call::remark { remark: value.encode() }) } -pub fn make_set_rule_proposal(rule: Cid) -> Call { +pub fn make_set_rule_proposal(rule: Cid) -> RuntimeCall { RuntimeCall::Alliance(pallet_alliance::Call::set_rule { rule }) } -pub fn make_kick_member_proposal(who: u64) -> Call { +pub fn make_kick_member_proposal(who: u64) -> RuntimeCall { RuntimeCall::Alliance(pallet_alliance::Call::kick_member { who }) } diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 016130337bf9f..6582177ef982a 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -98,7 +98,7 @@ impl frame_system::Config for Test { impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type OverarchingCall = RuntimeCall; type Extrinsic = TestXt; diff --git a/frame/collective/src/tests.rs b/frame/collective/src/tests.rs index 6319abb66b9d3..c10643d87abe0 100644 --- a/frame/collective/src/tests.rs +++ b/frame/collective/src/tests.rs @@ -32,7 +32,7 @@ use sp_runtime::{ }; pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( pub enum Test where @@ -172,7 +172,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { ext } -fn make_proposal(value: u64) -> Call { +fn make_proposal(value: u64) -> RuntimeCall { RuntimeCall::System(frame_system::Call::remark_with_event { remark: value.to_be_bytes().to_vec(), }) diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index b0a246b12ddef..3e78d199aafdd 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1348,8 +1348,8 @@ mod tests { storage::Storage, tests::{ test_utils::{get_balance, place_contract, set_balance}, - Call, ExtBuilder, RuntimeEvent as MetaEvent, Test, TestFilter, ALICE, BOB, CHARLIE, - GAS_LIMIT, + ExtBuilder, RuntimeCall, RuntimeEvent as MetaEvent, Test, TestFilter, ALICE, BOB, + CHARLIE, GAS_LIMIT, }, Error, }; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 4a1e21bf1bcc0..469a44b91f2f2 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -340,17 +340,17 @@ impl Convert> for Test { pub struct TestFilter; thread_local! { - static CALL_FILTER: RefCell bool> = RefCell::new(|_| true); + static CALL_FILTER: RefCell bool> = RefCell::new(|_| true); } impl TestFilter { - pub fn set_filter(filter: fn(&Call) -> bool) { + pub fn set_filter(filter: fn(&RuntimeCall) -> bool) { CALL_FILTER.with(|fltr| *fltr.borrow_mut() = filter); } } -impl Contains for TestFilter { - fn contains(call: &Call) -> bool { +impl Contains for TestFilter { + fn contains(call: &RuntimeCall) -> bool { CALL_FILTER.with(|fltr| fltr.borrow()(call)) } } diff --git a/frame/contracts/src/wasm/mod.rs b/frame/contracts/src/wasm/mod.rs index e3b56f746b444..f7fcfadfd3ef9 100644 --- a/frame/contracts/src/wasm/mod.rs +++ b/frame/contracts/src/wasm/mod.rs @@ -280,7 +280,7 @@ mod tests { }, gas::GasMeter, storage::WriteOutcome, - tests::{Call, Test, ALICE, BOB}, + tests::{RuntimeCall, Test, ALICE, BOB}, BalanceOf, CodeHash, Error, Pallet as Contracts, }; use assert_matches::assert_matches; @@ -339,7 +339,7 @@ mod tests { transfers: Vec, // (topics, data) events: Vec<(Vec, Vec)>, - runtime_calls: RefCell>, + runtime_calls: RefCell>, schedule: Schedule, gas_meter: GasMeter, debug_buffer: Vec, diff --git a/frame/conviction-voting/src/tests.rs b/frame/conviction-voting/src/tests.rs index 036a68032304b..b2b7605311b01 100644 --- a/frame/conviction-voting/src/tests.rs +++ b/frame/conviction-voting/src/tests.rs @@ -49,8 +49,8 @@ frame_support::construct_runtime!( // Test that a fitlered call can be dispatched. pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(call: &Call) -> bool { +impl Contains for BaseFilter { + fn contains(call: &RuntimeCall) -> bool { !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) } } diff --git a/frame/democracy/src/tests.rs b/frame/democracy/src/tests.rs index 72965259dcadb..7c752eb5f3acb 100644 --- a/frame/democracy/src/tests.rs +++ b/frame/democracy/src/tests.rs @@ -70,8 +70,8 @@ frame_support::construct_runtime!( // Test that a fitlered call can be dispatched. pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(call: &Call) -> bool { +impl Contains for BaseFilter { + fn contains(call: &RuntimeCall) -> bool { !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) } } @@ -228,7 +228,7 @@ fn set_balance_proposal(value: u64) -> Vec { #[test] fn set_balance_proposal_is_correctly_filtered_out() { for i in 0..10 { - let call = Call::decode(&mut &set_balance_proposal(i)[..]).unwrap(); + let call = RuntimeCall::decode(&mut &set_balance_proposal(i)[..]).unwrap(); assert!(!::BaseCallFilter::contains(&call)); } } diff --git a/frame/election-provider-multi-phase/src/mock.rs b/frame/election-provider-multi-phase/src/mock.rs index 8c2acb9961fe4..e442573d2cdb9 100644 --- a/frame/election-provider-multi-phase/src/mock.rs +++ b/frame/election-provider-multi-phase/src/mock.rs @@ -50,7 +50,8 @@ use sp_runtime::{ use std::sync::Arc; pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = + sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( pub enum Runtime where @@ -391,7 +392,7 @@ impl crate::Config for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - Call: From, + RuntimeCall: From, { type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 28750149eab2a..db89ad8474970 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1301,7 +1301,8 @@ mod tests { } pub type Block = sp_runtime::generic::Block; - pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; + pub type UncheckedExtrinsic = + sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( pub enum Test where diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 1ef158b7f2e4a..d001ee9914be6 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -92,7 +92,7 @@ impl frame_system::offchain::SigningTypes for Test { impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; @@ -100,14 +100,14 @@ where impl frame_system::offchain::CreateSignedTransaction for Test where - Call: From, + RuntimeCall: From, { fn create_transaction>( - call: Call, + call: RuntimeCall, _public: ::Signer, _account: AccountId, nonce: u64, - ) -> Option<(Call, ::SignaturePayload)> { + ) -> Option<(RuntimeCall, ::SignaturePayload)> { Some((call, (nonce, ()))) } } diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 58172357f86a7..6768065d7ff37 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -840,7 +840,7 @@ mod tests { Some((who, extra(nonce, fee))) } - fn call_transfer(dest: u64, value: u64) -> Call { + fn call_transfer(dest: u64, value: u64) -> RuntimeCall { RuntimeCall::Balances(BalancesCall::transfer { dest, value }) } @@ -1096,8 +1096,8 @@ mod tests { #[test] fn validate_unsigned() { - let valid = TestXt::new(Call::Custom(custom::Call::allowed_unsigned {}), None); - let invalid = TestXt::new(Call::Custom(custom::Call::unallowed_unsigned {}), None); + let valid = TestXt::new(RuntimeCall::Custom(custom::Call::allowed_unsigned {}), None); + let invalid = TestXt::new(RuntimeCall::Custom(custom::Call::unallowed_unsigned {}), None); let mut t = new_test_ext(1); t.execute_with(|| { @@ -1413,7 +1413,7 @@ mod tests { #[test] fn calculating_storage_root_twice_works() { - let call = Call::Custom(custom::Call::calculate_storage_root {}); + let call = RuntimeCall::Custom(custom::Call::calculate_storage_root {}); let xt = TestXt::new(call, sign_extra(1, 0, 0)); let header = new_test_ext(1).execute_with(|| { @@ -1443,7 +1443,7 @@ mod tests { RuntimeCall::Balances(BalancesCall::transfer { dest: 33, value: 0 }), sign_extra(1, 0, 0), ); - let xt2 = TestXt::new(Call::Custom(custom::Call::inherent_call {}), None); + let xt2 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent_call {}), None); let header = new_test_ext(1).execute_with(|| { // Let's build some fake block. @@ -1468,7 +1468,7 @@ mod tests { #[test] fn valid_inherents_position_works() { - let xt1 = TestXt::new(Call::Custom(custom::Call::inherent_call {}), None); + let xt1 = TestXt::new(RuntimeCall::Custom(custom::Call::inherent_call {}), None); let xt2 = TestXt::new(call_transfer(33, 0), sign_extra(1, 0, 0)); let header = new_test_ext(1).execute_with(|| { diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 94224268a7ce0..62b797f18ea5f 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -103,7 +103,7 @@ impl frame_system::Config for Test { impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type OverarchingCall = RuntimeCall; type Extrinsic = TestXt; diff --git a/frame/im-online/src/mock.rs b/frame/im-online/src/mock.rs index 1e7217ea0c4db..562f55720a0a1 100644 --- a/frame/im-online/src/mock.rs +++ b/frame/im-online/src/mock.rs @@ -233,7 +233,7 @@ impl Config for Runtime { impl frame_system::offchain::SendTransactionTypes for Runtime where - Call: From, + RuntimeCall: From, { type OverarchingCall = RuntimeCall; type Extrinsic = Extrinsic; diff --git a/frame/lottery/src/tests.rs b/frame/lottery/src/tests.rs index 12d4e69a818c3..ff3111b52db77 100644 --- a/frame/lottery/src/tests.rs +++ b/frame/lottery/src/tests.rs @@ -20,7 +20,8 @@ use super::*; use frame_support::{assert_noop, assert_ok, assert_storage_noop}; use mock::{ - new_test_ext, run_to_block, Balances, BalancesCall, Call, Lottery, Origin, SystemCall, Test, + new_test_ext, run_to_block, Balances, BalancesCall, Lottery, Origin, RuntimeCall, SystemCall, + Test, }; use pallet_balances::Error as BalancesError; use sp_runtime::traits::BadOrigin; diff --git a/frame/multisig/src/tests.rs b/frame/multisig/src/tests.rs index b05803e546932..eec4122f5d7a1 100644 --- a/frame/multisig/src/tests.rs +++ b/frame/multisig/src/tests.rs @@ -92,8 +92,8 @@ impl pallet_balances::Config for Test { } pub struct TestBaseCallFilter; -impl Contains for TestBaseCallFilter { - fn contains(c: &Call) -> bool { +impl Contains for TestBaseCallFilter { + fn contains(c: &RuntimeCall) -> bool { match *c { RuntimeCall::Balances(_) => true, // Needed for benchmarking @@ -130,7 +130,7 @@ fn now() -> Timepoint { Multisig::timepoint() } -fn call_transfer(dest: u64, value: u64) -> Call { +fn call_transfer(dest: u64, value: u64) -> RuntimeCall { RuntimeCall::Balances(BalancesCall::transfer { dest, value }) } diff --git a/frame/nomination-pools/src/tests.rs b/frame/nomination-pools/src/tests.rs index 5aa8e97266e0d..b748206c5b540 100644 --- a/frame/nomination-pools/src/tests.rs +++ b/frame/nomination-pools/src/tests.rs @@ -3873,7 +3873,7 @@ mod create { Balances::make_free_balance_be(&11, 5 + 20); // Then - let create = Call::Pools(crate::Call::::create { + let create = RuntimeCall::Pools(crate::Call::::create { amount: 20, root: 11, nominator: 11, diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index 365ea4a81806a..55bfe4d88c9c5 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -205,7 +205,7 @@ impl pallet_offences::Config for Test { impl frame_system::offchain::SendTransactionTypes for Test where - Call: From, + RuntimeCall: From, { type Extrinsic = Extrinsic; type OverarchingCall = RuntimeCall; @@ -214,7 +214,7 @@ where impl crate::Config for Test {} pub type Block = sp_runtime::generic::Block; -pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic; frame_support::construct_runtime!( pub enum Test where diff --git a/frame/proxy/src/tests.rs b/frame/proxy/src/tests.rs index b60b184217ffa..7dc09f354a86e 100644 --- a/frame/proxy/src/tests.rs +++ b/frame/proxy/src/tests.rs @@ -124,8 +124,8 @@ impl Default for ProxyType { Self::Any } } -impl InstanceFilter for ProxyType { - fn filter(&self, c: &Call) -> bool { +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { match self { ProxyType::Any => true, ProxyType::JustTransfer => { @@ -139,8 +139,8 @@ impl InstanceFilter for ProxyType { } } pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(c: &Call) -> bool { +impl Contains for BaseFilter { + fn contains(c: &RuntimeCall) -> bool { match *c { // Remark is used as a no-op call in the benchmarking RuntimeCall::System(SystemCall::remark { .. }) => true, @@ -197,7 +197,7 @@ fn expect_events(e: Vec) { assert_eq!(last_events(e.len()), e); } -fn call_transfer(dest: u64, value: u64) -> Call { +fn call_transfer(dest: u64, value: u64) -> RuntimeCall { RuntimeCall::Balances(BalancesCall::transfer { dest, value }) } diff --git a/frame/recovery/src/tests.rs b/frame/recovery/src/tests.rs index 59b1d3b771b8f..a3f19e5a61bc8 100644 --- a/frame/recovery/src/tests.rs +++ b/frame/recovery/src/tests.rs @@ -20,8 +20,8 @@ use super::*; use frame_support::{assert_noop, assert_ok, bounded_vec, traits::Currency}; use mock::{ - new_test_ext, run_to_block, Balances, BalancesCall, Call, MaxFriends, Origin, Recovery, - RecoveryCall, Test, + new_test_ext, run_to_block, Balances, BalancesCall, MaxFriends, Origin, Recovery, RecoveryCall, + RuntimeCall, Test, }; use sp_runtime::traits::BadOrigin; diff --git a/frame/referenda/src/mock.rs b/frame/referenda/src/mock.rs index 87417c0a5055c..e3ca6df6e4192 100644 --- a/frame/referenda/src/mock.rs +++ b/frame/referenda/src/mock.rs @@ -54,8 +54,8 @@ frame_support::construct_runtime!( // Test that a fitlered call can be dispatched. pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(call: &Call) -> bool { +impl Contains for BaseFilter { + fn contains(call: &RuntimeCall) -> bool { !matches!(call, &RuntimeCall::Balances(pallet_balances::Call::set_balance { .. })) } } diff --git a/frame/referenda/src/tests.rs b/frame/referenda/src/tests.rs index d5435daf185bd..69cd62f79159a 100644 --- a/frame/referenda/src/tests.rs +++ b/frame/referenda/src/tests.rs @@ -500,7 +500,7 @@ fn kill_errors_works() { #[test] fn set_balance_proposal_is_correctly_filtered_out() { for i in 0..10 { - let call = crate::mock::Call::decode(&mut &set_balance_proposal(i)[..]).unwrap(); + let call = crate::mock::RuntimeCall::decode(&mut &set_balance_proposal(i)[..]).unwrap(); assert!(!::BaseCallFilter::contains(&call)); } } diff --git a/frame/scheduler/src/mock.rs b/frame/scheduler/src/mock.rs index 62731cea918c8..96131908acabd 100644 --- a/frame/scheduler/src/mock.rs +++ b/frame/scheduler/src/mock.rs @@ -111,9 +111,9 @@ frame_support::construct_runtime!( // Scheduler must dispatch with root and no filter, this tests base filter is indeed not used. pub struct BaseFilter; -impl Contains for BaseFilter { - fn contains(call: &Call) -> bool { - !matches!(call, Call::Logger(LoggerCall::log { .. })) +impl Contains for BaseFilter { + fn contains(call: &RuntimeCall) -> bool { + !matches!(call, RuntimeCall::Logger(LoggerCall::log { .. })) } } diff --git a/frame/scheduler/src/tests.rs b/frame/scheduler/src/tests.rs index d03e13da4747a..36eb7d3f961c6 100644 --- a/frame/scheduler/src/tests.rs +++ b/frame/scheduler/src/tests.rs @@ -18,7 +18,9 @@ //! # Scheduler tests. use super::*; -use crate::mock::{logger, new_test_ext, root, run_to_block, Call, LoggerCall, Scheduler, Test, *}; +use crate::mock::{ + logger, new_test_ext, root, run_to_block, LoggerCall, RuntimeCall, Scheduler, Test, *, +}; use frame_support::{ assert_err, assert_noop, assert_ok, traits::{Contains, GetStorageVersion, OnInitialize, PreimageProvider}, @@ -30,7 +32,7 @@ use substrate_test_utils::assert_eq_uvec; #[test] fn basic_scheduling_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }); assert!(!::BaseCallFilter::contains(&call)); assert_ok!(Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.into())); run_to_block(3); @@ -45,7 +47,7 @@ fn basic_scheduling_works() { #[test] fn scheduling_with_preimages_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }); let hash = ::Hashing::hash_of(&call); let hashed = MaybeHashed::Hash(hash); assert_ok!(Preimage::note_preimage(Origin::signed(0), call.encode())); @@ -65,7 +67,7 @@ fn scheduling_with_preimages_works() { #[test] fn scheduling_with_preimage_postpones_correctly() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }); let hash = ::Hashing::hash_of(&call); let hashed = MaybeHashed::Hash(hash); @@ -98,7 +100,7 @@ fn scheduling_with_preimage_postpones_correctly() { fn schedule_after_works() { new_test_ext().execute_with(|| { run_to_block(2); - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }); assert!(!::BaseCallFilter::contains(&call)); // This will schedule the call 3 blocks after the next block... so block 3 + 3 = 6 assert_ok!(Scheduler::do_schedule(DispatchTime::After(3), None, 127, root(), call.into())); @@ -115,7 +117,7 @@ fn schedule_after_works() { fn schedule_after_zero_works() { new_test_ext().execute_with(|| { run_to_block(2); - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }); assert!(!::BaseCallFilter::contains(&call)); assert_ok!(Scheduler::do_schedule(DispatchTime::After(0), None, 127, root(), call.into())); // Will trigger on the next block. @@ -135,7 +137,7 @@ fn periodic_scheduling_works() { Some((3, 3)), 127, root(), - Call::Logger(logger::Call::log { i: 42, weight: 1000 }).into() + RuntimeCall::Logger(logger::Call::log { i: 42, weight: 1000 }).into() )); run_to_block(3); assert!(logger::log().is_empty()); @@ -157,7 +159,7 @@ fn periodic_scheduling_works() { #[test] fn reschedule_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.into()).unwrap(), @@ -188,7 +190,7 @@ fn reschedule_works() { #[test] fn reschedule_named_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule_named( @@ -230,7 +232,7 @@ fn reschedule_named_works() { #[test] fn reschedule_named_perodic_works() { new_test_ext().execute_with(|| { - let call = Call::Logger(LoggerCall::log { i: 42, weight: 1000 }); + let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule_named( @@ -292,7 +294,7 @@ fn cancel_named_scheduling_works_with_normal_cancel() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), ) .unwrap(); let i = Scheduler::do_schedule( @@ -300,7 +302,7 @@ fn cancel_named_scheduling_works_with_normal_cancel() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }).into(), ) .unwrap(); run_to_block(3); @@ -322,7 +324,7 @@ fn cancel_named_periodic_scheduling_works() { Some((3, 3)), 127, root(), - Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }).into(), ) .unwrap(); // same id results in error. @@ -332,7 +334,7 @@ fn cancel_named_periodic_scheduling_works() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), ) .is_err()); // different id is ok. @@ -342,7 +344,7 @@ fn cancel_named_periodic_scheduling_works() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), ) .unwrap(); run_to_block(3); @@ -364,16 +366,22 @@ fn scheduler_respects_weight_limits() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 42, + weight: MaximumSchedulerWeight::get() / 2 + }) + .into(), )); assert_ok!(Scheduler::do_schedule( DispatchTime::At(4), None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 69, + weight: MaximumSchedulerWeight::get() / 2 + }) + .into(), )); // 69 and 42 do not fit together run_to_block(4); @@ -391,16 +399,22 @@ fn scheduler_respects_hard_deadlines_more() { None, 0, root(), - Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 42, + weight: MaximumSchedulerWeight::get() / 2 + }) + .into(), )); assert_ok!(Scheduler::do_schedule( DispatchTime::At(4), None, 0, root(), - Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 69, + weight: MaximumSchedulerWeight::get() / 2 + }) + .into(), )); // With base weights, 69 and 42 should not fit together, but do because of hard // deadlines @@ -417,16 +431,22 @@ fn scheduler_respects_priority_ordering() { None, 1, root(), - Call::Logger(LoggerCall::log { i: 42, weight: MaximumSchedulerWeight::get() / 2 }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 42, + weight: MaximumSchedulerWeight::get() / 2 + }) + .into(), )); assert_ok!(Scheduler::do_schedule( DispatchTime::At(4), None, 0, root(), - Call::Logger(LoggerCall::log { i: 69, weight: MaximumSchedulerWeight::get() / 2 }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 69, + weight: MaximumSchedulerWeight::get() / 2 + }) + .into(), )); run_to_block(4); assert_eq!(logger::log(), vec![(root(), 69u32), (root(), 42u32)]); @@ -444,22 +464,27 @@ fn scheduler_respects_priority_ordering_with_soft_deadlines() { None, 255, root(), - Call::Logger(LoggerCall::log { i: 42, weight: max_weight / 2 - item_weight }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: max_weight / 2 - item_weight }) + .into(), )); assert_ok!(Scheduler::do_schedule( DispatchTime::At(4), None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: max_weight / 2 - item_weight }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: max_weight / 2 - item_weight }) + .into(), )); assert_ok!(Scheduler::do_schedule( DispatchTime::At(4), None, 126, root(), - Call::Logger(LoggerCall::log { i: 2600, weight: max_weight / 2 - item_weight + 1 }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 2600, + weight: max_weight / 2 - item_weight + 1 + }) + .into(), )); // 2600 does not fit with 69 or 42, but has higher priority, so will go through @@ -484,7 +509,7 @@ fn on_initialize_weight_is_correct() { None, 255, root(), - Call::Logger(LoggerCall::log { i: 3, weight: call_weight + 1 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 3, weight: call_weight + 1 }).into(), )); // Anon Periodic assert_ok!(Scheduler::do_schedule( @@ -492,7 +517,7 @@ fn on_initialize_weight_is_correct() { Some((1000, 3)), 128, root(), - Call::Logger(LoggerCall::log { i: 42, weight: call_weight + 2 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: call_weight + 2 }).into(), )); // Anon assert_ok!(Scheduler::do_schedule( @@ -500,7 +525,7 @@ fn on_initialize_weight_is_correct() { None, 127, root(), - Call::Logger(LoggerCall::log { i: 69, weight: call_weight + 3 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: call_weight + 3 }).into(), )); // Named Periodic assert_ok!(Scheduler::do_schedule_named( @@ -509,7 +534,7 @@ fn on_initialize_weight_is_correct() { Some((1000, 3)), 126, root(), - Call::Logger(LoggerCall::log { i: 2600, weight: call_weight + 4 }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 2600, weight: call_weight + 4 }).into(), )); // Will include the named periodic only @@ -552,8 +577,8 @@ fn on_initialize_weight_is_correct() { #[test] fn root_calls_works() { new_test_ext().execute_with(|| { - let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); - let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); + let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); assert_ok!(Scheduler::schedule_named(Origin::root(), 1u32.encode(), 4, None, 127, call,)); assert_ok!(Scheduler::schedule(Origin::root(), 4, None, 127, call2)); run_to_block(3); @@ -573,9 +598,9 @@ fn fails_to_schedule_task_in_the_past() { new_test_ext().execute_with(|| { run_to_block(3); - let call1 = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); - let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); - let call3 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call1 = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); + let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call3 = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); assert_err!( Scheduler::schedule_named(Origin::root(), 1u32.encode(), 2, None, 127, call1), @@ -597,8 +622,8 @@ fn fails_to_schedule_task_in_the_past() { #[test] fn should_use_orign() { new_test_ext().execute_with(|| { - let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); - let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); + let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); assert_ok!(Scheduler::schedule_named( system::RawOrigin::Signed(1).into(), 1u32.encode(), @@ -623,8 +648,8 @@ fn should_use_orign() { #[test] fn should_check_orign() { new_test_ext().execute_with(|| { - let call = Box::new(Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); - let call2 = Box::new(Call::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); + let call = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }).into()); + let call2 = Box::new(RuntimeCall::Logger(LoggerCall::log { i: 42, weight: 1000 }).into()); assert_noop!( Scheduler::schedule_named( system::RawOrigin::Signed(2).into(), @@ -646,10 +671,12 @@ fn should_check_orign() { #[test] fn should_check_orign_for_cancel() { new_test_ext().execute_with(|| { - let call = - Box::new(Call::Logger(LoggerCall::log_without_filter { i: 69, weight: 1000 }).into()); - let call2 = - Box::new(Call::Logger(LoggerCall::log_without_filter { i: 42, weight: 1000 }).into()); + let call = Box::new( + RuntimeCall::Logger(LoggerCall::log_without_filter { i: 69, weight: 1000 }).into(), + ); + let call2 = Box::new( + RuntimeCall::Logger(LoggerCall::log_without_filter { i: 42, weight: 1000 }).into(), + ); assert_ok!(Scheduler::schedule_named( system::RawOrigin::Signed(1).into(), 1u32.encode(), @@ -693,14 +720,14 @@ fn migration_to_v3_works() { Some(ScheduledV1 { maybe_id: None, priority: i as u8 + 10, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }), + call: RuntimeCall::Logger(LoggerCall::log { i: 96, weight: 100 }), maybe_periodic: None, }), None, Some(ScheduledV1 { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }), + call: RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }), maybe_periodic: Some((456u64, 10)), }), ]; @@ -718,7 +745,8 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: None, priority: 10, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 96, weight: 100 }) + .into(), maybe_periodic: None, origin: root(), _phantom: PhantomData::::default(), @@ -727,7 +755,8 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }) + .into(), maybe_periodic: Some((456u64, 10)), origin: root(), _phantom: PhantomData::::default(), @@ -740,7 +769,8 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: None, priority: 11, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 96, weight: 100 }) + .into(), maybe_periodic: None, origin: root(), _phantom: PhantomData::::default(), @@ -749,7 +779,8 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }) + .into(), maybe_periodic: Some((456u64, 10)), origin: root(), _phantom: PhantomData::::default(), @@ -762,7 +793,8 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: None, priority: 12, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 96, weight: 100 }) + .into(), maybe_periodic: None, origin: root(), _phantom: PhantomData::::default(), @@ -771,7 +803,8 @@ fn migration_to_v3_works() { Some(ScheduledV3Of:: { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }) + .into(), maybe_periodic: Some((456u64, 10)), origin: root(), _phantom: PhantomData::::default(), @@ -794,7 +827,7 @@ fn test_migrate_origin() { Some(Scheduled { maybe_id: None, priority: i as u8 + 10, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), origin: 3u32, maybe_periodic: None, _phantom: Default::default(), @@ -804,7 +837,7 @@ fn test_migrate_origin() { maybe_id: Some(b"test".to_vec()), priority: 123, origin: 2u32, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), maybe_periodic: Some((456u64, 10)), _phantom: Default::default(), }), @@ -833,7 +866,8 @@ fn test_migrate_origin() { Some(ScheduledV2::, u64, OriginCaller, u64> { maybe_id: None, priority: 10, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 96, weight: 100 }) + .into(), maybe_periodic: None, origin: system::RawOrigin::Root.into(), _phantom: PhantomData::::default(), @@ -842,7 +876,8 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }) + .into(), maybe_periodic: Some((456u64, 10)), origin: system::RawOrigin::None.into(), _phantom: PhantomData::::default(), @@ -855,7 +890,8 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: None, priority: 11, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 96, weight: 100 }) + .into(), maybe_periodic: None, origin: system::RawOrigin::Root.into(), _phantom: PhantomData::::default(), @@ -864,7 +900,8 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }) + .into(), maybe_periodic: Some((456u64, 10)), origin: system::RawOrigin::None.into(), _phantom: PhantomData::::default(), @@ -877,7 +914,8 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: None, priority: 12, - call: Call::Logger(LoggerCall::log { i: 96, weight: 100 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 96, weight: 100 }) + .into(), maybe_periodic: None, origin: system::RawOrigin::Root.into(), _phantom: PhantomData::::default(), @@ -886,7 +924,8 @@ fn test_migrate_origin() { Some(ScheduledV2 { maybe_id: Some(b"test".to_vec()), priority: 123, - call: Call::Logger(LoggerCall::log { i: 69, weight: 1000 }).into(), + call: RuntimeCall::Logger(LoggerCall::log { i: 69, weight: 1000 }) + .into(), maybe_periodic: Some((456u64, 10)), origin: system::RawOrigin::None.into(), _phantom: PhantomData::::default(), diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 485a9dc3ae66a..e88d686845698 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -3782,8 +3782,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(2); // Collect payouts when there are no nominators - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 1 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 1 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3796,8 +3795,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(3); // Collect payouts for an era where the validator did not receive any points. - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 2 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 2 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3810,8 +3808,7 @@ fn payout_stakers_handles_weight_refund() { start_active_era(4); // Collect payouts when the validator has `half_max_nom_rewarded` nominators. - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 3 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 3 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); @@ -3834,16 +3831,14 @@ fn payout_stakers_handles_weight_refund() { start_active_era(6); // Collect payouts when the validator had `half_max_nom_rewarded` nominators. - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert_ok!(result); assert_eq!(extract_actual_weight(&result, &info), max_nom_rewarded_weight); // Try and collect payouts for an era that has already been collected. - let call = - TestRuntimeCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); + let call = TestCall::Staking(StakingCall::payout_stakers { validator_stash: 11, era: 5 }); let info = call.get_dispatch_info(); let result = call.dispatch(Origin::signed(20)); assert!(result.is_err()); diff --git a/frame/sudo/src/mock.rs b/frame/sudo/src/mock.rs index 1abf7e52f38d5..b4e48535dfcda 100644 --- a/frame/sudo/src/mock.rs +++ b/frame/sudo/src/mock.rs @@ -113,8 +113,8 @@ parameter_types! { } pub struct BlockEverything; -impl Contains for BlockEverything { - fn contains(_: &Call) -> bool { +impl Contains for BlockEverything { + fn contains(_: &RuntimeCall) -> bool { false } } diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index 8175f2ad810b2..f35ed61da4f1d 100644 --- a/frame/sudo/src/tests.rs +++ b/frame/sudo/src/tests.rs @@ -20,8 +20,8 @@ use super::*; use frame_support::{assert_noop, assert_ok}; use mock::{ - new_test_ext, Call, Logger, LoggerCall, Origin, RuntimeEvent as TestEvent, Sudo, SudoCall, - System, Test, + new_test_ext, Logger, LoggerCall, Origin, RuntimeCall, RuntimeEvent as TestEvent, Sudo, + SudoCall, System, Test, }; #[test] @@ -39,12 +39,14 @@ fn sudo_basics() { // Configure a default test environment and set the root `key` to 1. new_test_ext(1).execute_with(|| { // A privileged function should work when `sudo` is passed the root `key` as `origin`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = + Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); assert_ok!(Sudo::sudo(Origin::signed(1), call)); assert_eq!(Logger::i32_log(), vec![42i32]); // A privileged function should not work when `sudo` is passed a non-root `key` as `origin`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = + Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); assert_noop!(Sudo::sudo(Origin::signed(2), call), Error::::RequireSudo); }); } @@ -56,7 +58,8 @@ fn sudo_emits_events_correctly() { System::set_block_number(1); // 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 })); + let call = + Box::new(RuntimeCall::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 { sudo_result: Ok(()) })); }) @@ -66,12 +69,14 @@ fn sudo_emits_events_correctly() { fn sudo_unchecked_weight_basics() { new_test_ext(1).execute_with(|| { // A privileged function should work when `sudo` is passed the root `key` as origin. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = + Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); assert_ok!(Sudo::sudo_unchecked_weight(Origin::signed(1), call, 1_000)); assert_eq!(Logger::i32_log(), vec![42i32]); // A privileged function should not work when called with a non-root `key`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = + Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); assert_noop!( Sudo::sudo_unchecked_weight(Origin::signed(2), call, 1_000), Error::::RequireSudo, @@ -80,7 +85,8 @@ fn sudo_unchecked_weight_basics() { assert_eq!(Logger::i32_log(), vec![42i32]); // Controls the dispatched weight. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); + let call = + Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1 })); let sudo_unchecked_weight_call = SudoCall::sudo_unchecked_weight { call, weight: 1_000 }; let info = sudo_unchecked_weight_call.get_dispatch_info(); assert_eq!(info.weight, 1_000); @@ -94,7 +100,8 @@ fn sudo_unchecked_weight_emits_events_correctly() { System::set_block_number(1); // 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 })); + let call = + Box::new(RuntimeCall::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 { sudo_result: Ok(()) })); }) @@ -134,17 +141,20 @@ fn set_key_emits_events_correctly() { fn sudo_as_basics() { new_test_ext(1).execute_with(|| { // A privileged function will not work when passed to `sudo_as`. - let call = Box::new(Call::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); + let call = + Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: 1_000 })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); assert!(Logger::i32_log().is_empty()); assert!(Logger::account_log().is_empty()); // A non-privileged function should not work when called with a non-root `key`. - let call = Box::new(Call::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 })); + let call = + Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 })); assert_noop!(Sudo::sudo_as(Origin::signed(3), 2, call), Error::::RequireSudo); // 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 })); + let call = + Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log { i: 42, weight: 1 })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); assert_eq!(Logger::i32_log(), vec![42i32]); // The correct user makes the call within `sudo_as`. @@ -159,7 +169,8 @@ fn sudo_as_emits_events_correctly() { System::set_block_number(1); // 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 })); + let call = + Box::new(RuntimeCall::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 { sudo_result: Ok(()) })); }); diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 97380a2dd534e..e578e905dd6e7 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -148,8 +148,8 @@ parameter_types! { impl example::Config for Test {} pub struct TestBaseCallFilter; -impl Contains for TestBaseCallFilter { - fn contains(c: &Call) -> bool { +impl Contains for TestBaseCallFilter { + fn contains(c: &RuntimeCall) -> bool { match *c { // Transfer works. Use `transfer_keep_alive` for a call that doesn't pass the filter. RuntimeCall::Balances(pallet_balances::Call::transfer { .. }) => true, @@ -187,11 +187,11 @@ pub fn new_test_ext() -> sp_io::TestExternalities { ext } -fn call_transfer(dest: u64, value: u64) -> Call { +fn call_transfer(dest: u64, value: u64) -> RuntimeCall { RuntimeCall::Balances(BalancesCall::transfer { dest, value }) } -fn call_foobar(err: bool, start_weight: u64, end_weight: Option) -> Call { +fn call_foobar(err: bool, start_weight: u64, end_weight: Option) -> RuntimeCall { RuntimeCall::Example(ExampleCall::foobar { err, start_weight, end_weight }) } From 22e41f7e30336d6361d7a639ebb1fe51e5a7c0b9 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 19:17:48 +0200 Subject: [PATCH 45/63] update docs --- frame/contracts/src/lib.rs | 2 +- frame/executive/src/lib.rs | 2 +- frame/support/src/inherent.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 6656c7a393f04..9f46cdc7ca182 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -260,7 +260,7 @@ pub mod pallet { /// # Stability /// /// The runtime **must** make sure that all dispatchables that are callable by - /// contracts remain stable. In addition [`Self::Call`] itself must remain stable. + /// contracts remain stable. In addition [`Self::RuntimeCall`] itself must remain stable. /// This means that no existing variants are allowed to switch their positions. /// /// # Note diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 6768065d7ff37..256af243c7750 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -66,7 +66,7 @@ //! # }; //! # use sp_runtime::traits::ValidateUnsigned; //! # impl ValidateUnsigned for Runtime { -//! # type RuntimeCall = (); +//! # type Call = (); //! # //! # fn validate_unsigned(_source: TransactionSource, _call: &Self::Call) -> TransactionValidity { //! # UnknownTransaction::NoUnsignedValidator.into() diff --git a/frame/support/src/inherent.rs b/frame/support/src/inherent.rs index 0aa6b9d3f75a9..15273cb11e024 100644 --- a/frame/support/src/inherent.rs +++ b/frame/support/src/inherent.rs @@ -60,7 +60,7 @@ pub trait ProvideInherent { /// /// NOTE: If the inherent is required then the runtime asserts that the block contains at least /// one inherent for which: - /// * type is [`Self::Call`], + /// * type is [`Self::RuntimeCall`], /// * [`Self::is_inherent`] returns true. /// /// NOTE: This is currently only checked by block producers, not all full nodes. From 9e913675baf2ac5a70d2ea642ea283cb37da8106 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 19:57:01 +0200 Subject: [PATCH 46/63] rustdoc fix --- frame/executive/src/lib.rs | 2 +- frame/support/src/inherent.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/executive/src/lib.rs b/frame/executive/src/lib.rs index 256af243c7750..3a58d3f913110 100644 --- a/frame/executive/src/lib.rs +++ b/frame/executive/src/lib.rs @@ -97,7 +97,7 @@ //! # }; //! # use sp_runtime::traits::ValidateUnsigned; //! # impl ValidateUnsigned for Runtime { -//! # type RuntimeCall = (); +//! # type Call = (); //! # //! # fn validate_unsigned(_source: TransactionSource, _call: &Self::Call) -> TransactionValidity { //! # UnknownTransaction::NoUnsignedValidator.into() diff --git a/frame/support/src/inherent.rs b/frame/support/src/inherent.rs index 15273cb11e024..0aa6b9d3f75a9 100644 --- a/frame/support/src/inherent.rs +++ b/frame/support/src/inherent.rs @@ -60,7 +60,7 @@ pub trait ProvideInherent { /// /// NOTE: If the inherent is required then the runtime asserts that the block contains at least /// one inherent for which: - /// * type is [`Self::RuntimeCall`], + /// * type is [`Self::Call`], /// * [`Self::is_inherent`] returns true. /// /// NOTE: This is currently only checked by block producers, not all full nodes. From 3103f8344ab6a4e5b8aa29570ed114abe3a4fd58 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 24 Aug 2022 20:14:29 +0200 Subject: [PATCH 47/63] update .stderr --- .../both_use_and_excluded_parts.stderr | 23 ++++++------------- .../exclude_undefined_part.stderr | 23 ++++++------------- .../undefined_validate_unsigned_part.stderr | 4 ++-- .../use_undefined_part.stderr | 23 ++++++------------- 4 files changed, 23 insertions(+), 50 deletions(-) diff --git a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr index ff8cd022b70d9..5f1fccd43c549 100644 --- a/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr +++ b/frame/support/test/tests/construct_runtime_ui/both_use_and_excluded_parts.stderr @@ -1,28 +1,19 @@ error: Unexpected tokens, expected one of `=`, `,` - --> $DIR/both_use_and_excluded_parts.rs:29:43 + --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:29:43 | 29 | Pallet: pallet exclude_parts { Pallet } use_parts { Pallet }, | ^^^^^^^^^ -error[E0412]: cannot find type `Call` in this scope - --> $DIR/both_use_and_excluded_parts.rs:18:64 +error[E0412]: cannot find type `RuntimeCall` in this scope + --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:18:64 | 18 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; - | ^^^^ not found in this scope - | -help: consider importing one of these items - | -1 | use crate::pallet::Call; - | -1 | use frame_support_test::Call; - | -1 | use frame_system::Call; - | -1 | use test_pallet::Call; - | + | - ^^^^^^^^^^^ not found in this scope + | | + | help: you might be missing a type parameter: `` error[E0412]: cannot find type `Runtime` in this scope - --> $DIR/both_use_and_excluded_parts.rs:20:25 + --> tests/construct_runtime_ui/both_use_and_excluded_parts.rs:20:25 | 20 | impl pallet::Config for Runtime {} | ^^^^^^^ not found in this scope diff --git a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr index b63f4e531f6ab..c623ecfbf4cdf 100644 --- a/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/exclude_undefined_part.stderr @@ -1,28 +1,19 @@ error: Invalid pallet part specified, the pallet `Pallet` doesn't have the `Call` part. Available parts are: `Pallet`, `Storage`. - --> $DIR/exclude_undefined_part.rs:34:34 + --> tests/construct_runtime_ui/exclude_undefined_part.rs:34:34 | 34 | Pallet: pallet exclude_parts { Call }, | ^^^^ -error[E0412]: cannot find type `Call` in this scope - --> $DIR/exclude_undefined_part.rs:23:64 +error[E0412]: cannot find type `RuntimeCall` in this scope + --> tests/construct_runtime_ui/exclude_undefined_part.rs:23:64 | 23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; - | ^^^^ not found in this scope - | -help: consider importing one of these items - | -1 | use crate::pallet::Call; - | -1 | use frame_support_test::Call; - | -1 | use frame_system::Call; - | -1 | use test_pallet::Call; - | + | - ^^^^^^^^^^^ not found in this scope + | | + | help: you might be missing a type parameter: `` error[E0412]: cannot find type `Runtime` in this scope - --> $DIR/exclude_undefined_part.rs:25:25 + --> tests/construct_runtime_ui/exclude_undefined_part.rs:25:25 | 25 | impl pallet::Config for Runtime {} | ^^^^^^^ not found in this scope diff --git a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr index 94226075d9a4b..a5e4fe3c1cd5a 100644 --- a/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/undefined_validate_unsigned_part.stderr @@ -15,14 +15,14 @@ error: `Pallet` does not have #[pallet::validate_unsigned] defined, perhaps you | = note: this error originates in the macro `pallet::__substrate_validate_unsigned_check::is_validate_unsigned_part_defined` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0599]: no variant or associated item named `Pallet` found for enum `Call` in the current scope +error[E0599]: no variant or associated item named `Pallet` found for enum `RuntimeCall` in the current scope --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:56:3 | 49 | construct_runtime! { | ------------------ variant or associated item `Pallet` not found here ... 56 | Pallet: pallet::{Pallet, ValidateUnsigned}, - | ^^^^^^ variant or associated item not found in `Call` + | ^^^^^^ variant or associated item not found in `RuntimeCall` error[E0599]: no function or associated item named `pre_dispatch` found for struct `pallet::Pallet` in the current scope --> tests/construct_runtime_ui/undefined_validate_unsigned_part.rs:49:1 diff --git a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr index 9f3373d0b4dfa..e289c75fb008a 100644 --- a/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr +++ b/frame/support/test/tests/construct_runtime_ui/use_undefined_part.stderr @@ -1,28 +1,19 @@ error: Invalid pallet part specified, the pallet `Pallet` doesn't have the `Call` part. Available parts are: `Pallet`, `Storage`. - --> $DIR/use_undefined_part.rs:34:30 + --> tests/construct_runtime_ui/use_undefined_part.rs:34:30 | 34 | Pallet: pallet use_parts { Call }, | ^^^^ -error[E0412]: cannot find type `Call` in this scope - --> $DIR/use_undefined_part.rs:23:64 +error[E0412]: cannot find type `RuntimeCall` in this scope + --> tests/construct_runtime_ui/use_undefined_part.rs:23:64 | 23 | pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; - | ^^^^ not found in this scope - | -help: consider importing one of these items - | -1 | use crate::pallet::Call; - | -1 | use frame_support_test::Call; - | -1 | use frame_system::Call; - | -1 | use test_pallet::Call; - | + | - ^^^^^^^^^^^ not found in this scope + | | + | help: you might be missing a type parameter: `` error[E0412]: cannot find type `Runtime` in this scope - --> $DIR/use_undefined_part.rs:25:25 + --> tests/construct_runtime_ui/use_undefined_part.rs:25:25 | 25 | impl pallet::Config for Runtime {} | ^^^^^^^ not found in this scope From a59c90eaab794d21c95c73e4140a9136393233f0 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 25 Aug 2022 08:52:38 +0200 Subject: [PATCH 48/63] wrong code in docs --- frame/support/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index 5d8ea61abaef2..024f3225c3ca3 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2170,7 +2170,7 @@ pub mod pallet_prelude { /// type Call = Call; /// fn validate_unsigned( /// source: TransactionSource, -/// call: &Self::RuntimeCall +/// call: &Self::Call /// ) -> TransactionValidity { /// Err(TransactionValidityError::Invalid(InvalidTransaction::Call)) /// } @@ -2184,11 +2184,11 @@ pub mod pallet_prelude { /// /// const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; /// -/// fn create_inherent(_data: &InherentData) -> Option { +/// fn create_inherent(_data: &InherentData) -> Option { /// unimplemented!(); /// } /// -/// fn is_inherent(_call: &Self::RuntimeCall) -> bool { +/// fn is_inherent(_call: &Self::Call) -> bool { /// unimplemented!(); /// } /// } @@ -2302,7 +2302,7 @@ pub mod pallet_prelude { /// type Call = Call; /// fn validate_unsigned( /// source: TransactionSource, -/// call: &Self::RuntimeCall +/// call: &Self::Call /// ) -> TransactionValidity { /// Err(TransactionValidityError::Invalid(InvalidTransaction::Call)) /// } @@ -2315,11 +2315,11 @@ pub mod pallet_prelude { /// /// const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER; /// -/// fn create_inherent(_data: &InherentData) -> Option { +/// fn create_inherent(_data: &InherentData) -> Option { /// unimplemented!(); /// } /// -/// fn is_inherent(_call: &Self::RuntimeCall) -> bool { +/// fn is_inherent(_call: &Self::Call) -> bool { /// unimplemented!(); /// } /// } From 747aff1c94dc97693aa03b38d72858d65233003b Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 25 Aug 2022 10:08:44 +0200 Subject: [PATCH 49/63] merge fix --- frame/support/procedural/src/pallet/parse/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/pallet/parse/storage.rs b/frame/support/procedural/src/pallet/parse/storage.rs index 97abdd3ad0977..f0e1353774910 100644 --- a/frame/support/procedural/src/pallet/parse/storage.rs +++ b/frame/support/procedural/src/pallet/parse/storage.rs @@ -775,7 +775,7 @@ impl StorageDef { error.push_value(last); Ok(Some(QueryKind::ResultQuery( - syn::Path { leading_colon: leading_colon.clone(), segments: error }, + syn::Path { leading_colon, segments: error }, err_variant, ))) }, From d575f5b6705a626a3bcd0255bf65239b4e932a82 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sat, 27 Aug 2022 09:12:00 +0200 Subject: [PATCH 50/63] fix in error message --- frame/support/procedural/src/pallet/parse/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index e9bd35b1fff72..54ffca8b12ee0 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -187,13 +187,13 @@ impl Def { match (self.config.has_event_type, self.event.is_some()) { (true, false) => { let msg = "Invalid usage of RuntimeEvent, `Config` contains associated type `RuntimeEvent`, \ - but enum `RuntimeEvent` is not declared (i.e. no use of `#[pallet::event]`). \ + but enum `Event` is not declared (i.e. no use of `#[pallet::event]`). \ Note that type `RuntimeEvent` in trait is reserved to work alongside pallet event."; Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) }, (false, true) => { let msg = "Invalid usage of RuntimeEvent, `Config` contains no associated type \ - `RuntimeEvent`, but enum `RuntimeEvent` is declared (in use of `#[pallet::event]`). \ + `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). \ An RuntimeEvent associated type must be declare on trait `Config`."; Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) }, From 85a31f403a355c8341a828ff0b369f09cfeab041 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sat, 27 Aug 2022 09:26:40 +0200 Subject: [PATCH 51/63] update .stderr --- frame/support/test/tests/pallet_ui/event_not_in_trait.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr b/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr index 709ef4fda2d82..2eda72eb5f72f 100644 --- a/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr +++ b/frame/support/test/tests/pallet_ui/event_not_in_trait.stderr @@ -1,4 +1,4 @@ -error: Invalid usage of RuntimeEvent, `Config` contains no associated type `RuntimeEvent`, but enum `RuntimeEvent` is declared (in use of `#[pallet::event]`). An RuntimeEvent associated type must be declare on trait `Config`. +error: Invalid usage of RuntimeEvent, `Config` contains no associated type `RuntimeEvent`, but enum `Event` is declared (in use of `#[pallet::event]`). An RuntimeEvent associated type must be declare on trait `Config`. --> $DIR/event_not_in_trait.rs:1:1 | 1 | #[frame_support::pallet] From 60f50a098f045918eeb21f7d91ede855031416dd Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 28 Aug 2022 08:38:07 +0200 Subject: [PATCH 52/63] docs & error message --- frame/support/procedural/src/pallet/expand/event.rs | 2 +- frame/support/procedural/src/pallet/parse/config.rs | 4 ++-- frame/support/procedural/src/pallet/parse/mod.rs | 2 +- frame/support/src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frame/support/procedural/src/pallet/expand/event.rs b/frame/support/procedural/src/pallet/expand/event.rs index 1263cdc03a988..abed680eb245e 100644 --- a/frame/support/procedural/src/pallet/expand/event.rs +++ b/frame/support/procedural/src/pallet/expand/event.rs @@ -61,7 +61,7 @@ pub fn expand_event(def: &mut Def) -> proc_macro2::TokenStream { let event_where_clause = &event.where_clause; // NOTE: actually event where clause must be a subset of config where clause because of - // `type Event: From>`. But we merge either way for potential better error + // `type RuntimeEvent: From>`. But we merge either way for potential better error // message let completed_where_clause = super::merge_where_clauses(&[&event.where_clause, &def.config.where_clause]); diff --git a/frame/support/procedural/src/pallet/parse/config.rs b/frame/support/procedural/src/pallet/parse/config.rs index 8d6a5eaa48b58..0f3aa69b170ce 100644 --- a/frame/support/procedural/src/pallet/parse/config.rs +++ b/frame/support/procedural/src/pallet/parse/config.rs @@ -214,7 +214,7 @@ impl syn::parse::Parse for FromEventParse { } } -/// Check if trait_item is `type Event`, if so checks its bounds are those expected. +/// Check if trait_item is `type RuntimeEvent`, if so checks its bounds are those expected. /// (Event type is reserved type) fn check_event_type( frame_system: &syn::Ident, @@ -260,7 +260,7 @@ fn check_event_type( if from_event_bound.is_generic && (from_event_bound.has_instance != trait_has_instance) { - let msg = "Invalid `type Event`, associated type `Event` bounds inconsistent \ + let msg = "Invalid `type RuntimeEvent`, associated type `RuntimeEvent` bounds inconsistent \ `From`. Config and generic Event must be both with instance or \ without instance"; return Err(syn::Error::new(type_.span(), msg)) diff --git a/frame/support/procedural/src/pallet/parse/mod.rs b/frame/support/procedural/src/pallet/parse/mod.rs index 54ffca8b12ee0..f1e520952d872 100644 --- a/frame/support/procedural/src/pallet/parse/mod.rs +++ b/frame/support/procedural/src/pallet/parse/mod.rs @@ -182,7 +182,7 @@ impl Def { } /// Check that usage of trait `Event` is consistent with the definition, i.e. it is declared - /// and trait defines type Event, or not declared and no trait associated type. + /// and trait defines type RuntimeEvent, or not declared and no trait associated type. fn check_event_usage(&self) -> syn::Result<()> { match (self.config.has_event_type, self.event.is_some()) { (true, false) => { diff --git a/frame/support/src/lib.rs b/frame/support/src/lib.rs index a78c06d927a21..bfa993d7f5dc5 100644 --- a/frame/support/src/lib.rs +++ b/frame/support/src/lib.rs @@ -2406,7 +2406,7 @@ pub mod pallet_prelude { /// ``` /// 5. **migrate Config**: move trait into the module with /// * all const in decl_module to `#[pallet::constant]` -/// * add bound `IsType<::RuntimeEvent>` to `type Event` +/// * add bound `IsType<::RuntimeEvent>` to `type RuntimeEvent` /// 7. **migrate decl_module**: write: /// ```ignore /// #[pallet::hooks] From 39927f32be8e00835bfae3bf54eacfb3f9857b83 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 28 Aug 2022 19:05:44 +0200 Subject: [PATCH 53/63] . --- frame/support/procedural/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/procedural/src/lib.rs b/frame/support/procedural/src/lib.rs index 00204b7a4d906..0f72b28748cee 100644 --- a/frame/support/procedural/src/lib.rs +++ b/frame/support/procedural/src/lib.rs @@ -311,7 +311,7 @@ pub fn decl_storage(input: TokenStream) -> TokenStream { /// System: frame_system::{Pallet, Call, Event, Config} = 0, /// Test: path::to::test::{Pallet, Call} = 1, /// -/// // Pallets with instances +/// // Pallets with instances. /// Test2_Instance1: test2::::{Pallet, Call, Storage, Event, Config, Origin}, /// Test2_DefaultInstance: test2::{Pallet, Call, Storage, Event, Config, Origin} = 4, /// From 3a517cc21f42e83a22601e8f14a67ece0a616292 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 29 Aug 2022 18:31:29 +0200 Subject: [PATCH 54/63] merge fix --- frame/alliance/src/tests.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index d5e081c3c0c7c..c952bb424a8b3 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -406,7 +406,7 @@ fn give_retirement_notice_work() { assert_ok!(Alliance::give_retirement_notice(Origin::signed(3))); assert_eq!(Alliance::members(MemberRole::Fellow), Vec::::new()); assert_eq!(Alliance::members(MemberRole::Retiring), vec![3]); - System::assert_last_event(mock::Event::Alliance( + System::assert_last_event(mock::RuntimeEvent::Alliance( crate::Event::MemberRetirementPeriodStarted { member: (3) }, )); @@ -439,7 +439,7 @@ fn retire_works() { System::set_block_number(System::block_number() + RetirementPeriod::get()); assert_ok!(Alliance::retire(Origin::signed(3))); assert_eq!(Alliance::members(MemberRole::Fellow), Vec::::new()); - System::assert_last_event(mock::Event::Alliance(crate::Event::MemberRetired { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MemberRetired { member: (3), unreserved: None, })); @@ -488,7 +488,7 @@ fn kick_member_works() { assert_ok!(Alliance::kick_member(Origin::signed(2), 2)); assert_eq!(Alliance::members(MemberRole::Founder), vec![1]); assert_eq!(>::get(2), None); - System::assert_last_event(mock::Event::Alliance(crate::Event::MemberKicked { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MemberKicked { member: (2), slashed: Some(25), })); From 8ae1258131056c4ce73f9f117c4fc1094c82ba9c Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 31 Aug 2022 16:37:35 +0200 Subject: [PATCH 55/63] merge fix --- frame/support/test/tests/pallet_compatibility_instance.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/support/test/tests/pallet_compatibility_instance.rs b/frame/support/test/tests/pallet_compatibility_instance.rs index 8344850f1dd20..e1c237212b9ba 100644 --- a/frame/support/test/tests/pallet_compatibility_instance.rs +++ b/frame/support/test/tests/pallet_compatibility_instance.rs @@ -33,7 +33,7 @@ mod pallet_old { pub trait Config: frame_system::Config { type SomeConst: Get; type Balance: Parameter + codec::HasCompact + From + Into + Default; - type Event: From> + Into<::RuntimeEvent>; + type RuntimeEvent: From> + Into<::RuntimeEvent>; } decl_storage! { From 77b6181c6011f7e2518e3a0ebda405662ca78442 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Wed, 31 Aug 2022 16:53:45 +0200 Subject: [PATCH 56/63] fmt --- bin/node/executor/tests/basic.rs | 20 +++---- frame/scheduler/src/tests.rs | 89 +++++++++++++++++++++----------- frame/sudo/src/tests.rs | 36 ++++++++----- frame/utility/src/tests.rs | 3 +- 4 files changed, 96 insertions(+), 52 deletions(-) diff --git a/bin/node/executor/tests/basic.rs b/bin/node/executor/tests/basic.rs index 0e37572ea55dd..2fdc17953c892 100644 --- a/bin/node/executor/tests/basic.rs +++ b/bin/node/executor/tests/basic.rs @@ -736,16 +736,16 @@ fn deploying_wasm_contract_should_work() { }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(0, 0))), - function: RuntimeCall::Contracts( - pallet_contracts::Call::instantiate_with_code:: { - value: 0, - gas_limit: Weight::from_ref_time(500_000_000), - storage_deposit_limit: None, - code: transfer_code, - data: Vec::new(), - salt: Vec::new(), - }, - ), + function: RuntimeCall::Contracts(pallet_contracts::Call::instantiate_with_code::< + Runtime, + > { + value: 0, + gas_limit: Weight::from_ref_time(500_000_000), + storage_deposit_limit: None, + code: transfer_code, + data: Vec::new(), + salt: Vec::new(), + }), }, CheckedExtrinsic { signed: Some((charlie(), signed_extra(1, 0))), diff --git a/frame/scheduler/src/tests.rs b/frame/scheduler/src/tests.rs index 0f1aa71793779..ed6617f7bc15d 100644 --- a/frame/scheduler/src/tests.rs +++ b/frame/scheduler/src/tests.rs @@ -32,7 +32,8 @@ use substrate_test_utils::assert_eq_uvec; #[test] fn basic_scheduling_works() { new_test_ext().execute_with(|| { - let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); + let call = + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_ok!(Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.into())); run_to_block(3); @@ -47,7 +48,8 @@ fn basic_scheduling_works() { #[test] fn scheduling_with_preimages_works() { new_test_ext().execute_with(|| { - let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); + let call = + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); let hash = ::Hashing::hash_of(&call); let hashed = MaybeHashed::Hash(hash); assert_ok!(Preimage::note_preimage(Origin::signed(0), call.encode())); @@ -67,7 +69,8 @@ fn scheduling_with_preimages_works() { #[test] fn scheduling_with_preimage_postpones_correctly() { new_test_ext().execute_with(|| { - let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); + let call = + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); let hash = ::Hashing::hash_of(&call); let hashed = MaybeHashed::Hash(hash); @@ -100,7 +103,8 @@ fn scheduling_with_preimage_postpones_correctly() { fn schedule_after_works() { new_test_ext().execute_with(|| { run_to_block(2); - let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); + let call = + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); // This will schedule the call 3 blocks after the next block... so block 3 + 3 = 6 assert_ok!(Scheduler::do_schedule(DispatchTime::After(3), None, 127, root(), call.into())); @@ -117,7 +121,8 @@ fn schedule_after_works() { fn schedule_after_zero_works() { new_test_ext().execute_with(|| { run_to_block(2); - let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); + let call = + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_ok!(Scheduler::do_schedule(DispatchTime::After(0), None, 127, root(), call.into())); // Will trigger on the next block. @@ -137,7 +142,8 @@ fn periodic_scheduling_works() { Some((3, 3)), 127, root(), - RuntimeCall::Logger(logger::Call::log { i: 42, weight: Weight::from_ref_time(1000) }).into() + RuntimeCall::Logger(logger::Call::log { i: 42, weight: Weight::from_ref_time(1000) }) + .into() )); run_to_block(3); assert!(logger::log().is_empty()); @@ -159,7 +165,8 @@ fn periodic_scheduling_works() { #[test] fn reschedule_works() { new_test_ext().execute_with(|| { - let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); + let call = + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule(DispatchTime::At(4), None, 127, root(), call.into()).unwrap(), @@ -190,7 +197,8 @@ fn reschedule_works() { #[test] fn reschedule_named_works() { new_test_ext().execute_with(|| { - let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); + let call = + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule_named( @@ -232,7 +240,8 @@ fn reschedule_named_works() { #[test] fn reschedule_named_perodic_works() { new_test_ext().execute_with(|| { - let call = RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); + let call = + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }); assert!(!::BaseCallFilter::contains(&call)); assert_eq!( Scheduler::do_schedule_named( @@ -294,7 +303,8 @@ fn cancel_named_scheduling_works_with_normal_cancel() { None, 127, root(), - RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }) + .into(), ) .unwrap(); let i = Scheduler::do_schedule( @@ -302,7 +312,8 @@ fn cancel_named_scheduling_works_with_normal_cancel() { None, 127, root(), - RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }) + .into(), ) .unwrap(); run_to_block(3); @@ -324,7 +335,8 @@ fn cancel_named_periodic_scheduling_works() { Some((3, 3)), 127, root(), - RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }) + .into(), ) .unwrap(); // same id results in error. @@ -334,7 +346,8 @@ fn cancel_named_periodic_scheduling_works() { None, 127, root(), - RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }) + .into(), ) .is_err()); // different id is ok. @@ -344,7 +357,8 @@ fn cancel_named_periodic_scheduling_works() { None, 127, root(), - RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }) + .into(), ) .unwrap(); run_to_block(3); @@ -509,7 +523,8 @@ fn on_initialize_weight_is_correct() { None, 255, root(), - RuntimeCall::Logger(LoggerCall::log { i: 3, weight: call_weight + Weight::one() }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 3, weight: call_weight + Weight::one() }) + .into(), )); // Anon Periodic assert_ok!(Scheduler::do_schedule( @@ -517,8 +532,11 @@ fn on_initialize_weight_is_correct() { Some((1000, 3)), 128, root(), - RuntimeCall::Logger(LoggerCall::log { i: 42, weight: call_weight + Weight::from_ref_time(2) }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 42, + weight: call_weight + Weight::from_ref_time(2) + }) + .into(), )); // Anon assert_ok!(Scheduler::do_schedule( @@ -526,8 +544,11 @@ fn on_initialize_weight_is_correct() { None, 127, root(), - RuntimeCall::Logger(LoggerCall::log { i: 69, weight: call_weight + Weight::from_ref_time(3) }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 69, + weight: call_weight + Weight::from_ref_time(3) + }) + .into(), )); // Named Periodic assert_ok!(Scheduler::do_schedule_named( @@ -588,10 +609,12 @@ fn on_initialize_weight_is_correct() { fn root_calls_works() { new_test_ext().execute_with(|| { let call = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }) + .into(), ); let call2 = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }) + .into(), ); assert_ok!(Scheduler::schedule_named(Origin::root(), 1u32.encode(), 4, None, 127, call,)); assert_ok!(Scheduler::schedule(Origin::root(), 4, None, 127, call2)); @@ -613,13 +636,16 @@ fn fails_to_schedule_task_in_the_past() { run_to_block(3); let call1 = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }) + .into(), ); let call2 = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }) + .into(), ); let call3 = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }) + .into(), ); assert_err!( Scheduler::schedule_named(Origin::root(), 1u32.encode(), 2, None, 127, call1), @@ -642,11 +668,14 @@ fn fails_to_schedule_task_in_the_past() { fn should_use_orign() { new_test_ext().execute_with(|| { let call = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }) + .into(), ); let call2 = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), - ); assert_ok!(Scheduler::schedule_named( + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }) + .into(), + ); + assert_ok!(Scheduler::schedule_named( system::RawOrigin::Signed(1).into(), 1u32.encode(), 4, @@ -671,10 +700,12 @@ fn should_use_orign() { fn should_check_orign() { new_test_ext().execute_with(|| { let call = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 69, weight: Weight::from_ref_time(1000) }) + .into(), ); let call2 = Box::new( - RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }).into(), + RuntimeCall::Logger(LoggerCall::log { i: 42, weight: Weight::from_ref_time(1000) }) + .into(), ); assert_noop!( Scheduler::schedule_named( diff --git a/frame/sudo/src/tests.rs b/frame/sudo/src/tests.rs index e63393b6928ad..7571fb7c720a5 100644 --- a/frame/sudo/src/tests.rs +++ b/frame/sudo/src/tests.rs @@ -62,8 +62,10 @@ fn sudo_emits_events_correctly() { System::set_block_number(1); // Should emit event to indicate success when called with the root `key` and `call` is `Ok`. - let call = - Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: Weight::one() })); + let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { + i: 42, + weight: Weight::one(), + })); assert_ok!(Sudo::sudo(Origin::signed(1), call)); System::assert_has_event(TestEvent::Sudo(Event::Sudid { sudo_result: Ok(()) })); }) @@ -97,8 +99,10 @@ fn sudo_unchecked_weight_basics() { assert_eq!(Logger::i32_log(), vec![42i32]); // Controls the dispatched weight. - let call = - Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: Weight::one() })); + let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { + i: 42, + weight: Weight::one(), + })); let sudo_unchecked_weight_call = SudoCall::sudo_unchecked_weight { call, weight: Weight::from_ref_time(1_000) }; let info = sudo_unchecked_weight_call.get_dispatch_info(); @@ -113,8 +117,10 @@ fn sudo_unchecked_weight_emits_events_correctly() { System::set_block_number(1); // Should emit event to indicate success when called with the root `key` and `call` is `Ok`. - let call = - Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { i: 42, weight: Weight::one() })); + let call = Box::new(RuntimeCall::Logger(LoggerCall::privileged_i32_log { + i: 42, + weight: Weight::one(), + })); assert_ok!(Sudo::sudo_unchecked_weight( Origin::signed(1), call, @@ -167,13 +173,17 @@ fn sudo_as_basics() { assert!(Logger::account_log().is_empty()); // A non-privileged function should not work when called with a non-root `key`. - let call = - Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log { i: 42, weight: Weight::one() })); + let call = Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log { + i: 42, + weight: Weight::one(), + })); assert_noop!(Sudo::sudo_as(Origin::signed(3), 2, call), Error::::RequireSudo); // A non-privileged function will work when passed to `sudo_as` with the root `key`. - let call = - Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log { i: 42, weight: Weight::one() })); + let call = Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log { + i: 42, + weight: Weight::one(), + })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); assert_eq!(Logger::i32_log(), vec![42i32]); // The correct user makes the call within `sudo_as`. @@ -188,8 +198,10 @@ fn sudo_as_emits_events_correctly() { System::set_block_number(1); // A non-privileged function will work when passed to `sudo_as` with the root `key`. - let call = - Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log { i: 42, weight: Weight::one() })); + let call = Box::new(RuntimeCall::Logger(LoggerCall::non_privileged_log { + i: 42, + weight: Weight::one(), + })); assert_ok!(Sudo::sudo_as(Origin::signed(1), 2, call)); System::assert_has_event(TestEvent::Sudo(Event::SudoAsDone { sudo_result: Ok(()) })); }); diff --git a/frame/utility/src/tests.rs b/frame/utility/src/tests.rs index 0e9b4eb673deb..3dc1ee042ea42 100644 --- a/frame/utility/src/tests.rs +++ b/frame/utility/src/tests.rs @@ -383,7 +383,8 @@ fn batch_early_exit_works() { fn batch_weight_calculation_doesnt_overflow() { use sp_runtime::Perbill; new_test_ext().execute_with(|| { - let big_call = RuntimeCall::System(SystemCall::fill_block { ratio: Perbill::from_percent(50) }); + let big_call = + RuntimeCall::System(SystemCall::fill_block { ratio: Perbill::from_percent(50) }); assert_eq!(big_call.get_dispatch_info().weight, Weight::MAX / 2); // 3 * 50% saturates to 100% From fe00ba4b33046cd7ac598195b0f700961fd36f07 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 1 Sep 2022 15:33:55 +0200 Subject: [PATCH 57/63] fmt --- bin/node/runtime/src/impls.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index 17a133e699c30..b89d97594ba7c 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -18,8 +18,8 @@ //! Some configurable implementations as associated type for the substrate runtime. use crate::{ - AccountId, AllianceCollective, AllianceMotion, Assets, Authorship, Balances, RuntimeCall, Hash, - NegativeImbalance, Runtime, + AccountId, AllianceCollective, AllianceMotion, Assets, Authorship, Balances, Hash, + NegativeImbalance, Runtime, RuntimeCall, }; use frame_support::{ pallet_prelude::*, From a92411d5e0f7c45392c91d1d9d9d4715e51ffdc7 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 1 Sep 2022 15:35:28 +0200 Subject: [PATCH 58/63] merge fix --- frame/alliance/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index b6d5e71e05f56..ffe4cf86c6c57 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -38,7 +38,7 @@ fn assert_last_event, I: 'static>(generic_event: >:: frame_system::Pallet::::assert_last_event(generic_event.into()); } -fn assert_prev_event, I: 'static>(generic_event: >::Event) { +fn assert_prev_event, I: 'static>(generic_event: >::RuntimeEvent) { let events = frame_system::Pallet::::events(); assert_eq!(events.get(events.len() - 2).expect("events expected").event, generic_event.into()); } From 8c14f8b6cecfdb4a049a296b2e8e952774b17e50 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Thu, 1 Sep 2022 15:40:54 +0200 Subject: [PATCH 59/63] more fixing --- frame/alliance/src/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index 282e8dd3b0e4e..26854ce89cecf 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -158,12 +158,12 @@ fn force_set_members_works() { // assert events proposals.sort(); - assert_prev_event(mock::Event::Alliance(crate::Event::AllianceDisbanded { + assert_prev_event(mock::RuntimeEvent::Alliance(crate::Event::AllianceDisbanded { members: vec![1, 3, 9], proposals, })); - System::assert_last_event(mock::Event::Alliance(crate::Event::MembersInitialized { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MembersInitialized { founders: vec![5, 8], fellows: vec![4], allies: vec![2], From e4e9d374a3eb8f5370240caf529280eb23db66ad Mon Sep 17 00:00:00 2001 From: Szegoo Date: Fri, 2 Sep 2022 13:46:06 +0200 Subject: [PATCH 60/63] fmt --- frame/scheduler/src/tests.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frame/scheduler/src/tests.rs b/frame/scheduler/src/tests.rs index 4acca1b25c9c1..f1168e6e9d26f 100644 --- a/frame/scheduler/src/tests.rs +++ b/frame/scheduler/src/tests.rs @@ -523,8 +523,11 @@ fn on_initialize_weight_is_correct() { None, 255, root(), - RuntimeCall::Logger(LoggerCall::log { i: 3, weight: call_weight + Weight::from_ref_time(1) }) - .into(), + RuntimeCall::Logger(LoggerCall::log { + i: 3, + weight: call_weight + Weight::from_ref_time(1) + }) + .into(), )); // Anon Periodic assert_ok!(Scheduler::do_schedule( From 42e504d9b6e8373ba2f305632e65fc69aa58a305 Mon Sep 17 00:00:00 2001 From: Szegoo Date: Sun, 4 Sep 2022 08:15:50 +0200 Subject: [PATCH 61/63] remove unused --- bin/node-template/runtime/src/lib.rs | 1 - bin/node/runtime/src/lib.rs | 1 - frame/contracts/src/lib.rs | 2 +- frame/contracts/src/tests.rs | 8 ++++---- frame/examples/offchain-worker/src/lib.rs | 3 --- frame/examples/offchain-worker/src/tests.rs | 1 - frame/examples/parallel/src/lib.rs | 5 +---- frame/examples/parallel/src/tests.rs | 4 +--- frame/grandpa/src/lib.rs | 3 --- frame/grandpa/src/mock.rs | 1 - 10 files changed, 7 insertions(+), 22 deletions(-) diff --git a/bin/node-template/runtime/src/lib.rs b/bin/node-template/runtime/src/lib.rs index 4db9a0e233b96..031f5d6fed093 100644 --- a/bin/node-template/runtime/src/lib.rs +++ b/bin/node-template/runtime/src/lib.rs @@ -208,7 +208,6 @@ impl pallet_aura::Config for Runtime { impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; type KeyOwnerProofSystem = (); diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 32b99cc784f8a..c0c0488b7af1b 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1259,7 +1259,6 @@ impl pallet_authority_discovery::Config for Runtime { impl pallet_grandpa::Config for Runtime { type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; type KeyOwnerProofSystem = Historical; diff --git a/frame/contracts/src/lib.rs b/frame/contracts/src/lib.rs index 3e2c90eb47427..9890bd840cc3a 100644 --- a/frame/contracts/src/lib.rs +++ b/frame/contracts/src/lib.rs @@ -1119,7 +1119,7 @@ where fn deposit_event(topics: Vec, event: Event) { >::deposit_event_indexed( &topics, - ::Event::from(event).into(), + ::RuntimeEvent::from(event).into(), ) } } diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 3d1ff60aef756..1464407348708 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -877,7 +877,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Called { + event: RuntimeEvent::Contracts(crate::Event::Called { caller: caller_addr.clone(), contract: callee_addr.clone(), }), @@ -885,7 +885,7 @@ fn deploy_and_call_other_contract() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Called { + event: RuntimeEvent::Contracts(crate::Event::Called { caller: ALICE, contract: caller_addr.clone(), }), @@ -1209,7 +1209,7 @@ fn self_destruct_works() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Called { + event: RuntimeEvent::Contracts(crate::Event::Called { caller: ALICE, contract: addr.clone(), }), @@ -3382,7 +3382,7 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: Event::Contracts(crate::Event::Called { + event: RuntimeEvent::Contracts(crate::Event::Called { caller: ALICE, contract: addr.clone(), }), diff --git a/frame/examples/offchain-worker/src/lib.rs b/frame/examples/offchain-worker/src/lib.rs index 8f07fe4585b96..fdf8b61a01acd 100644 --- a/frame/examples/offchain-worker/src/lib.rs +++ b/frame/examples/offchain-worker/src/lib.rs @@ -128,9 +128,6 @@ pub mod pallet { /// The overarching event type. type RuntimeEvent: From> + IsType<::RuntimeEvent>; - /// The overarching dispatch call type. - type RuntimeCall: From>; - // Configuration parameters /// A grace period after we send transaction. diff --git a/frame/examples/offchain-worker/src/tests.rs b/frame/examples/offchain-worker/src/tests.rs index 8b1ffe933f38d..2c189935ac19d 100644 --- a/frame/examples/offchain-worker/src/tests.rs +++ b/frame/examples/offchain-worker/src/tests.rs @@ -119,7 +119,6 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; type AuthorityId = crypto::TestAuthId; - type RuntimeCall = RuntimeCall; type GracePeriod = ConstU64<5>; type UnsignedInterval = ConstU64<128>; type UnsignedPriority = UnsignedPriority; diff --git a/frame/examples/parallel/src/lib.rs b/frame/examples/parallel/src/lib.rs index 33669c3dafc26..3432a79638664 100644 --- a/frame/examples/parallel/src/lib.rs +++ b/frame/examples/parallel/src/lib.rs @@ -41,10 +41,7 @@ pub mod pallet { use frame_system::pallet_prelude::*; #[pallet::config] - pub trait Config: frame_system::Config { - /// The overarching dispatch call type. - type RuntimeCall: From>; - } + pub trait Config: frame_system::Config {} #[pallet::pallet] #[pallet::generate_store(pub(super) trait Store)] diff --git a/frame/examples/parallel/src/tests.rs b/frame/examples/parallel/src/tests.rs index 41e2978a42ebe..80c8213fdfb1c 100644 --- a/frame/examples/parallel/src/tests.rs +++ b/frame/examples/parallel/src/tests.rs @@ -70,9 +70,7 @@ impl frame_system::Config for Test { type MaxConsumers = frame_support::traits::ConstU32<16>; } -impl Config for Test { - type RuntimeCall = RuntimeCall; -} +impl Config for Test {} fn test_pub(n: u8) -> sp_core::sr25519::Public { sp_core::sr25519::Public::from_raw([n; 32]) diff --git a/frame/grandpa/src/lib.rs b/frame/grandpa/src/lib.rs index 78beb72fedc54..1fcf5c67150b5 100644 --- a/frame/grandpa/src/lib.rs +++ b/frame/grandpa/src/lib.rs @@ -91,9 +91,6 @@ pub mod pallet { + Into<::RuntimeEvent> + IsType<::RuntimeEvent>; - /// The function call. - type RuntimeCall: From>; - /// The proof of key ownership, used for validating equivocation reports /// The proof must include the session index and validator count of the /// session at which the equivocation occurred. diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index d693f3a4b0560..5aae751de9ea6 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -225,7 +225,6 @@ parameter_types! { impl Config for Test { type RuntimeEvent = RuntimeEvent; - type RuntimeCall = RuntimeCall; type KeyOwnerProofSystem = Historical; From 4395316c1fe05266b704b0be0764caa67a0d20da Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 5 Sep 2022 18:48:47 +0200 Subject: [PATCH 62/63] fmt --- bin/node/runtime/src/impls.rs | 3 ++- frame/alliance/src/mock.rs | 1 - frame/contracts/src/exec.rs | 3 ++- frame/contracts/src/tests.rs | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/node/runtime/src/impls.rs b/bin/node/runtime/src/impls.rs index 4dfd63f6424af..3509592ebf04a 100644 --- a/bin/node/runtime/src/impls.rs +++ b/bin/node/runtime/src/impls.rs @@ -18,7 +18,8 @@ //! Some configurable implementations as associated type for the substrate runtime. use crate::{ - AccountId, AllianceMotion, Assets, Authorship, Balances, RuntimeCall, Hash, NegativeImbalance, Runtime, + AccountId, AllianceMotion, Assets, Authorship, Balances, Hash, NegativeImbalance, Runtime, + RuntimeCall, }; use frame_support::{ pallet_prelude::*, diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 186acecb09044..37d66ea77ab97 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -355,4 +355,3 @@ pub fn make_proposal(proposal: RuntimeCall) -> (RuntimeCall, u32, H256) { let hash = BlakeTwo256::hash_of(&proposal); (proposal, len, hash) } - diff --git a/frame/contracts/src/exec.rs b/frame/contracts/src/exec.rs index 91d2111ffcd01..5893d87b813b2 100644 --- a/frame/contracts/src/exec.rs +++ b/frame/contracts/src/exec.rs @@ -1370,7 +1370,8 @@ mod tests { storage::Storage, tests::{ test_utils::{get_balance, hash, place_contract, set_balance}, - RuntimeCall, RuntimeEvent as MetaEvent, ExtBuilder, Test, TestFilter, ALICE, BOB, CHARLIE, GAS_LIMIT, + ExtBuilder, RuntimeCall, RuntimeEvent as MetaEvent, Test, TestFilter, ALICE, BOB, + CHARLIE, GAS_LIMIT, }, Error, }; diff --git a/frame/contracts/src/tests.rs b/frame/contracts/src/tests.rs index 1464407348708..9dddbc6dd2916 100644 --- a/frame/contracts/src/tests.rs +++ b/frame/contracts/src/tests.rs @@ -3360,7 +3360,9 @@ fn call_after_killed_account_needs_funding() { }, EventRecord { phase: Phase::Initialization, - event: RuntimeEvent::System(frame_system::Event::NewAccount { account: addr.clone() }), + event: RuntimeEvent::System(frame_system::Event::NewAccount { + account: addr.clone() + }), topics: vec![], }, EventRecord { From c3de9a61c0d90e726f080581a3395182f863520c Mon Sep 17 00:00:00 2001 From: Szegoo Date: Mon, 5 Sep 2022 21:02:12 +0200 Subject: [PATCH 63/63] fix --- frame/alliance/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index fb9bf4b69cd2c..79fd33965edb5 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -63,7 +63,7 @@ fn init_members_works() { // assert a retiring member from previous Alliance not removed assert!(Alliance::is_member_of(&2, MemberRole::Retiring)); - System::assert_last_event(mock::Event::Alliance(crate::Event::MembersInitialized { + System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MembersInitialized { founders: vec![5, 8], fellows: vec![4], allies: vec![2],