Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Use pallet names to name enum variants #8990

Merged
27 commits merged into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
95f2e51
Remove unused event_metadata variable
KiChjang Jun 2, 2021
89d2636
Eliminate mod_name and use pallet names to name enum variants
KiChjang Jun 2, 2021
716f4c1
Rename field name `pallet` to `path`
KiChjang Jun 2, 2021
a0e92ac
Use only the pallet name to generate variant names
KiChjang Jun 2, 2021
f3889c0
Use new naming scheme for Event enum in sudo pallet tests
KiChjang Jun 3, 2021
d8d2de8
Use new naming scheme for Event enum in offences pallet tests
KiChjang Jun 3, 2021
541e98d
Use new naming scheme for Event enum in contracts pallet tests
KiChjang Jun 3, 2021
24ed7f6
Use new naming scheme for Event enum in collective pallet tests
KiChjang Jun 3, 2021
668ca5d
Use new naming scheme for Event enum in bounties pallet tests
KiChjang Jun 3, 2021
e783c27
Use new naming scheme for Event enum in balances pallet tests
KiChjang Jun 3, 2021
28163ef
Use new naming scheme for Event enum in assets pallet tests
KiChjang Jun 3, 2021
42f2edb
Use new naming scheme for Event enum in frame support tests
KiChjang Jun 3, 2021
e7c30bb
Use new naming scheme for Event enum in tips pallet tests
KiChjang Jun 3, 2021
0dc40cf
Use new naming scheme for Event enum in transaction payment pallet tests
KiChjang Jun 3, 2021
5392bd8
Use new naming scheme for GenesisConfig fields in example pallet tests
KiChjang Jun 4, 2021
2df6019
Use new naming scheme for GenesisConfig fields in elections pallet tests
KiChjang Jun 4, 2021
cb7ec66
Use new naming scheme for Event enum in election provider multi-phase…
KiChjang Jun 4, 2021
47f113e
Use new naming scheme for Event enum in elections phragmen pallet tests
KiChjang Jun 4, 2021
2fc3d21
Use new naming scheme for GenesisConfig fields in chain spec
KiChjang Jun 4, 2021
9ab7561
Use new naming scheme for Event enum in staking pallet mock
KiChjang Jun 4, 2021
cd21371
Use new naming scheme for GenesisConfig fields in node-template chain…
KiChjang Jun 4, 2021
ff307ff
Use new naming scheme for GenesisConfig fields in node-testing chain …
KiChjang Jun 4, 2021
adc3269
Use new naming scheme for Event enum in node executor tests
KiChjang Jun 4, 2021
e42bc9d
Merge remote-tracking branch 'origin/master' into kckyeung/pallet-nam…
KiChjang Jun 4, 2021
98269a5
Use new naming scheme for GenesisConfig fields in transaction storage…
KiChjang Jun 4, 2021
f976731
Merge branch 'master' into kckyeung/pallet-name-variants
KiChjang Jun 8, 2021
fd92af0
Refactor match conditions
KiChjang Jun 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bin/node-template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,22 @@ fn testnet_genesis(
_enable_println: bool,
) -> GenesisConfig {
GenesisConfig {
frame_system: SystemConfig {
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
changes_trie_config: Default::default(),
},
pallet_balances: BalancesConfig {
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
balances: endowed_accounts.iter().cloned().map(|k|(k, 1 << 60)).collect(),
},
pallet_aura: AuraConfig {
aura: AuraConfig {
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
},
pallet_grandpa: GrandpaConfig {
grandpa: GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
},
pallet_sudo: SudoConfig {
sudo: SudoConfig {
// Assign network admin rights.
key: root_key,
},
Expand Down
40 changes: 20 additions & 20 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,19 @@ pub fn testnet_genesis(
const STASH: Balance = ENDOWMENT / 1000;

GenesisConfig {
frame_system: SystemConfig {
system: SystemConfig {
code: wasm_binary_unwrap().to_vec(),
changes_trie_config: Default::default(),
},
pallet_balances: BalancesConfig {
balances: BalancesConfig {
balances: endowed_accounts.iter().cloned()
.map(|x| (x, ENDOWMENT))
.collect()
},
pallet_indices: IndicesConfig {
indices: IndicesConfig {
indices: vec![],
},
pallet_session: SessionConfig {
session: SessionConfig {
keys: initial_authorities.iter().map(|x| {
(x.0.clone(), x.0.clone(), session_keys(
x.2.clone(),
Expand All @@ -283,59 +283,59 @@ pub fn testnet_genesis(
))
}).collect::<Vec<_>>(),
},
pallet_staking: StakingConfig {
staking: StakingConfig {
validator_count: initial_authorities.len() as u32,
minimum_validator_count: initial_authorities.len() as u32,
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
slash_reward_fraction: Perbill::from_percent(10),
stakers,
.. Default::default()
},
pallet_democracy: DemocracyConfig::default(),
pallet_elections_phragmen: ElectionsConfig {
democracy: DemocracyConfig::default(),
elections: ElectionsConfig {
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.map(|member| (member, STASH))
.collect(),
},
pallet_collective_Instance1: CouncilConfig::default(),
pallet_collective_Instance2: TechnicalCommitteeConfig {
council: CouncilConfig::default(),
technical_committee: TechnicalCommitteeConfig {
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.collect(),
phantom: Default::default(),
},
pallet_sudo: SudoConfig {
sudo: SudoConfig {
key: root_key,
},
pallet_babe: BabeConfig {
babe: BabeConfig {
authorities: vec![],
epoch_config: Some(node_runtime::BABE_GENESIS_EPOCH_CONFIG),
},
pallet_im_online: ImOnlineConfig {
im_online: ImOnlineConfig {
keys: vec![],
},
pallet_authority_discovery: AuthorityDiscoveryConfig {
authority_discovery: AuthorityDiscoveryConfig {
keys: vec![],
},
pallet_grandpa: GrandpaConfig {
grandpa: GrandpaConfig {
authorities: vec![],
},
pallet_membership_Instance1: Default::default(),
pallet_treasury: Default::default(),
pallet_society: SocietyConfig {
technical_membership: Default::default(),
treasury: Default::default(),
society: SocietyConfig {
members: endowed_accounts.iter()
.take((num_endowed_accounts + 1) / 2)
.cloned()
.collect(),
pot: 0,
max_members: 999,
},
pallet_vesting: Default::default(),
pallet_gilt: Default::default(),
pallet_transaction_storage: Default::default(),
vesting: Default::default(),
gilt: Default::default(),
transaction_storage: Default::default(),
}
}

Expand Down
22 changes: 11 additions & 11 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,14 @@ fn full_native_block_import_works() {
let events = vec![
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: Event::frame_system(frame_system::Event::ExtrinsicSuccess(
event: Event::System(frame_system::Event::ExtrinsicSuccess(
DispatchInfo { weight: timestamp_weight, class: DispatchClass::Mandatory, ..Default::default() }
)),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::pallet_balances(pallet_balances::Event::Transfer(
event: Event::Balances(pallet_balances::Event::Transfer(
alice().into(),
bob().into(),
69 * DOLLARS,
Expand All @@ -363,12 +363,12 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(fees * 8 / 10)),
event: Event::Treasury(pallet_treasury::RawEvent::Deposit(fees * 8 / 10)),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::frame_system(frame_system::Event::ExtrinsicSuccess(
event: Event::System(frame_system::Event::ExtrinsicSuccess(
DispatchInfo { weight: transfer_weight, ..Default::default() }
)),
topics: vec![],
Expand Down Expand Up @@ -399,14 +399,14 @@ fn full_native_block_import_works() {
let events = vec![
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: Event::frame_system(frame_system::Event::ExtrinsicSuccess(
event: Event::System(frame_system::Event::ExtrinsicSuccess(
DispatchInfo { weight: timestamp_weight, class: DispatchClass::Mandatory, ..Default::default() }
)),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::pallet_balances(
event: Event::Balances(
pallet_balances::Event::Transfer(
bob().into(),
alice().into(),
Expand All @@ -417,19 +417,19 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(fees * 8 / 10)),
event: Event::Treasury(pallet_treasury::RawEvent::Deposit(fees * 8 / 10)),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::frame_system(frame_system::Event::ExtrinsicSuccess(
event: Event::System(frame_system::Event::ExtrinsicSuccess(
DispatchInfo { weight: transfer_weight, ..Default::default() }
)),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: Event::pallet_balances(
event: Event::Balances(
pallet_balances::Event::Transfer(
alice().into(),
bob().into(),
Expand All @@ -440,12 +440,12 @@ fn full_native_block_import_works() {
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: Event::pallet_treasury(pallet_treasury::RawEvent::Deposit(fees * 8 / 10)),
event: Event::Treasury(pallet_treasury::RawEvent::Deposit(fees * 8 / 10)),
topics: vec![],
},
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: Event::frame_system(frame_system::Event::ExtrinsicSuccess(
event: Event::System(frame_system::Event::ExtrinsicSuccess(
DispatchInfo { weight: transfer_weight, ..Default::default() }
)),
topics: vec![],
Expand Down
40 changes: 20 additions & 20 deletions bin/node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ pub fn config_endowed(
);

GenesisConfig {
frame_system: SystemConfig {
system: SystemConfig {
changes_trie_config: if support_changes_trie { Some(ChangesTrieConfiguration {
digest_interval: 2,
digest_levels: 2,
}) } else { None },
code: code.map(|x| x.to_vec()).unwrap_or_else(|| wasm_binary_unwrap().to_vec()),
},
pallet_indices: IndicesConfig {
indices: IndicesConfig {
indices: vec![],
},
pallet_balances: BalancesConfig {
balances: BalancesConfig {
balances: endowed,
},
pallet_session: SessionConfig {
session: SessionConfig {
keys: vec![
(dave(), alice(), to_session_keys(
&Ed25519Keyring::Alice,
Expand All @@ -85,7 +85,7 @@ pub fn config_endowed(
)),
]
},
pallet_staking: StakingConfig {
staking: StakingConfig {
stakers: vec![
(dave(), alice(), 111 * DOLLARS, StakerStatus::Validator),
(eve(), bob(), 100 * DOLLARS, StakerStatus::Validator),
Expand All @@ -97,29 +97,29 @@ pub fn config_endowed(
invulnerables: vec![alice(), bob(), charlie()],
.. Default::default()
},
pallet_babe: BabeConfig {
babe: BabeConfig {
authorities: vec![],
epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG),
},
pallet_grandpa: GrandpaConfig {
grandpa: GrandpaConfig {
authorities: vec![],
},
pallet_im_online: Default::default(),
pallet_authority_discovery: Default::default(),
pallet_democracy: Default::default(),
pallet_collective_Instance1: Default::default(),
pallet_collective_Instance2: Default::default(),
pallet_membership_Instance1: Default::default(),
pallet_elections_phragmen: Default::default(),
pallet_sudo: Default::default(),
pallet_treasury: Default::default(),
pallet_society: SocietyConfig {
im_online: Default::default(),
authority_discovery: Default::default(),
democracy: Default::default(),
council: Default::default(),
technical_committee: Default::default(),
technical_membership: Default::default(),
elections: Default::default(),
sudo: Default::default(),
treasury: Default::default(),
society: SocietyConfig {
members: vec![alice(), bob()],
pot: 0,
max_members: 999,
},
pallet_vesting: Default::default(),
pallet_gilt: Default::default(),
pallet_transaction_storage: Default::default(),
vesting: Default::default(),
gilt: Default::default(),
transaction_storage: Default::default(),
}
}
2 changes: 1 addition & 1 deletion frame/assets/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ fn transferring_less_than_one_unit_is_fine() {
assert_ok!(Assets::mint(Origin::signed(1), 0, 1, 100));
assert_eq!(Assets::balance(0, 1), 100);
assert_ok!(Assets::transfer(Origin::signed(1), 0, 2, 0));
System::assert_last_event(mock::Event::pallet_assets(crate::Event::Transferred(0, 1, 2, 0)));
System::assert_last_event(mock::Event::Assets(crate::Event::Transferred(0, 1, 2, 0)));
});
}

Expand Down
26 changes: 13 additions & 13 deletions frame/balances/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,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::pallet_balances(crate::Event::ReserveRepatriated(1, 2, 41, Status::Free))
Event::Balances(crate::Event::ReserveRepatriated(1, 2, 41, Status::Free))
);
assert_eq!(Balances::reserved_balance(1), 69);
assert_eq!(Balances::free_balance(1), 0);
Expand Down Expand Up @@ -683,18 +683,18 @@ macro_rules! decl_tests {
System::set_block_number(2);
assert_ok!(Balances::reserve(&1, 10));

System::assert_last_event(Event::pallet_balances(crate::Event::Reserved(1, 10)));
System::assert_last_event(Event::Balances(crate::Event::Reserved(1, 10)));

System::set_block_number(3);
assert!(Balances::unreserve(&1, 5).is_zero());

System::assert_last_event(Event::pallet_balances(crate::Event::Unreserved(1, 5)));
System::assert_last_event(Event::Balances(crate::Event::Unreserved(1, 5)));

System::set_block_number(4);
assert_eq!(Balances::unreserve(&1, 6), 1);

// should only unreserve 5
System::assert_last_event(Event::pallet_balances(crate::Event::Unreserved(1, 5)));
System::assert_last_event(Event::Balances(crate::Event::Unreserved(1, 5)));
});
}

Expand All @@ -709,9 +709,9 @@ macro_rules! decl_tests {
assert_eq!(
events(),
[
Event::frame_system(system::Event::NewAccount(1)),
Event::pallet_balances(crate::Event::Endowed(1, 100)),
Event::pallet_balances(crate::Event::BalanceSet(1, 100, 0)),
Event::System(system::Event::NewAccount(1)),
Event::Balances(crate::Event::Endowed(1, 100)),
Event::Balances(crate::Event::BalanceSet(1, 100, 0)),
]
);

Expand All @@ -721,8 +721,8 @@ macro_rules! decl_tests {
assert_eq!(
events(),
[
Event::frame_system(system::Event::KilledAccount(1)),
Event::pallet_balances(crate::Event::DustLost(1, 99)),
Event::System(system::Event::KilledAccount(1)),
Event::Balances(crate::Event::DustLost(1, 99)),
]
);
});
Expand All @@ -739,9 +739,9 @@ macro_rules! decl_tests {
assert_eq!(
events(),
[
Event::frame_system(system::Event::NewAccount(1)),
Event::pallet_balances(crate::Event::Endowed(1, 100)),
Event::pallet_balances(crate::Event::BalanceSet(1, 100, 0)),
Event::System(system::Event::NewAccount(1)),
Event::Balances(crate::Event::Endowed(1, 100)),
Event::Balances(crate::Event::BalanceSet(1, 100, 0)),
]
);

Expand All @@ -751,7 +751,7 @@ macro_rules! decl_tests {
assert_eq!(
events(),
[
Event::frame_system(system::Event::KilledAccount(1))
Event::System(system::Event::KilledAccount(1))
]
);
});
Expand Down
Loading