From 6d0dfa6d0546a05c00956991e830f34df875a32b Mon Sep 17 00:00:00 2001 From: Dino Pacandi Date: Fri, 22 Nov 2024 15:34:43 +0100 Subject: [PATCH] Governance proxy --- runtime/astar/src/genesis_config.rs | 25 +++++++++---------- runtime/astar/src/lib.rs | 11 +++++++++ runtime/local/src/genesis_config.rs | 35 ++++++++++++--------------- runtime/local/src/lib.rs | 11 +++++++++ runtime/shibuya/src/genesis_config.rs | 25 +++++++++---------- runtime/shibuya/src/lib.rs | 13 +++++++--- 6 files changed, 72 insertions(+), 48 deletions(-) diff --git a/runtime/astar/src/genesis_config.rs b/runtime/astar/src/genesis_config.rs index de2080edb..35d323b14 100644 --- a/runtime/astar/src/genesis_config.rs +++ b/runtime/astar/src/genesis_config.rs @@ -40,25 +40,24 @@ pub fn default_config(para_id: u32) -> serde_json::Value { let dave = GenesisAccount::::from_seed("Dave"); let eve = GenesisAccount::::from_seed("Eve"); - let balances: Vec<(AccountId, Balance)> = vec![ - (alice.account_id(), 1_000_000_000 * ASTR), - (bob.account_id(), 1_000_000_000 * ASTR), - ( - TreasuryPalletId::get().into_account_truncating(), - 1_000_000_000 * ASTR, - ), - ( - CommunityTreasuryPalletId::get().into_account_truncating(), - 1_000_000_000 * ASTR, - ), - ]; - let authorities = vec![&alice, &bob]; let accounts = vec![&alice, &bob, &charlie, &dave, &eve] .iter() .map(|x| x.account_id()) .collect::>(); + let balances = accounts + .iter() + .chain( + vec![ + TreasuryPalletId::get().into_account_truncating(), + CommunityTreasuryPalletId::get().into_account_truncating(), + ] + .iter(), + ) + .map(|x| (x.clone(), 1_000_000_000 * ASTR)) + .collect::>(); + let config = RuntimeGenesisConfig { system: Default::default(), sudo: SudoConfig { diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 2470d17d1..67e66d76f 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -1040,6 +1040,8 @@ pub enum ProxyType { DappStaking, /// Only claim_staker call from pallet DappStaking allowed for proxy account StakerRewardClaim, + /// All governance related calls allowed for proxy account + Governance, } impl Default for ProxyType { @@ -1111,6 +1113,15 @@ impl InstanceFilter for ProxyType { ) ) } + ProxyType::Governance => { + matches!( + c, + RuntimeCall::Democracy(..) + | RuntimeCall::Council(..) + | RuntimeCall::TechnicalCommittee(..) + | RuntimeCall::CommunityCouncil(..) + ) + } } } diff --git a/runtime/local/src/genesis_config.rs b/runtime/local/src/genesis_config.rs index c6dc2c2e6..faaa588b2 100644 --- a/runtime/local/src/genesis_config.rs +++ b/runtime/local/src/genesis_config.rs @@ -44,30 +44,27 @@ pub fn default_config() -> serde_json::Value { let dave = GenesisAccount::::from_seed("Dave"); let eve = GenesisAccount::::from_seed("Eve"); - let balances: Vec<(AccountId, Balance)> = vec![ - (alice.account_id(), 1_000_000_000 * AST), - (bob.account_id(), 1_000_000_000 * AST), - ( - TreasuryPalletId::get().into_account_truncating(), - 1_000_000_000 * AST, - ), - ( - CommunityTreasuryPalletId::get().into_account_truncating(), - 1_000_000_000 * AST, - ), - ( - // Private key: 0x01ab6e801c06e59ca97a14fc0a1978b27fa366fc87450e0b65459dd3515b7391 - // H160 public address: 0xaaafB3972B05630fCceE866eC69CdADd9baC2771 - AccountId::from_ss58check("5FQedkNQcF2fJPwkB6Z1ZcMgGti4vcJQNs6x85YPv3VhjBBT").unwrap(), - 1_000_000_000 * AST, - ), - ]; - let accounts = vec![&alice, &bob, &charlie, &dave, &eve] .iter() .map(|x| x.account_id()) .collect::>(); + let balances = accounts + .iter() + .chain( + vec![ + TreasuryPalletId::get().into_account_truncating(), + CommunityTreasuryPalletId::get().into_account_truncating(), + // Private key: 0x01ab6e801c06e59ca97a14fc0a1978b27fa366fc87450e0b65459dd3515b7391 + // H160 public address: 0xaaafB3972B05630fCceE866eC69CdADd9baC2771 + AccountId::from_ss58check("5FQedkNQcF2fJPwkB6Z1ZcMgGti4vcJQNs6x85YPv3VhjBBT") + .unwrap(), + ] + .iter(), + ) + .map(|x| (x.clone(), 1_000_000_000 * AST)) + .collect::>(); + let config = RuntimeGenesisConfig { system: Default::default(), sudo: SudoConfig { diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index 650698f91..b290d574a 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -788,6 +788,8 @@ pub enum ProxyType { DappStaking, /// Only claim_staker call from pallet DappStaking allowed for proxy account StakerRewardClaim, + /// All governance related calls allowed for proxy account + Governance, } impl Default for ProxyType { @@ -850,6 +852,15 @@ impl InstanceFilter for ProxyType { ) ) } + ProxyType::Governance => { + matches!( + c, + RuntimeCall::Democracy(..) + | RuntimeCall::Council(..) + | RuntimeCall::TechnicalCommittee(..) + | RuntimeCall::CommunityCouncil(..) + ) + } } } diff --git a/runtime/shibuya/src/genesis_config.rs b/runtime/shibuya/src/genesis_config.rs index 1b6ce2db9..3d6dfde1c 100644 --- a/runtime/shibuya/src/genesis_config.rs +++ b/runtime/shibuya/src/genesis_config.rs @@ -40,25 +40,24 @@ pub fn default_config(para_id: u32) -> serde_json::Value { let dave = GenesisAccount::::from_seed("Dave"); let eve = GenesisAccount::::from_seed("Eve"); - let balances: Vec<(AccountId, Balance)> = vec![ - (alice.account_id(), 1_000_000_000 * SBY), - (bob.account_id(), 1_000_000_000 * SBY), - ( - TreasuryPalletId::get().into_account_truncating(), - 1_000_000_000 * SBY, - ), - ( - CommunityTreasuryPalletId::get().into_account_truncating(), - 1_000_000_000 * SBY, - ), - ]; - let authorities = vec![&alice, &bob]; let accounts = vec![&alice, &bob, &charlie, &dave, &eve] .iter() .map(|x| x.account_id()) .collect::>(); + let balances = accounts + .iter() + .chain( + vec![ + TreasuryPalletId::get().into_account_truncating(), + CommunityTreasuryPalletId::get().into_account_truncating(), + ] + .iter(), + ) + .map(|x| (x.clone(), 1_000_000_000 * SBY)) + .collect::>(); + let config = RuntimeGenesisConfig { system: Default::default(), sudo: SudoConfig { diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index 39829378a..ea539a6c4 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -1010,7 +1010,7 @@ pub enum ProxyType { Balances, /// All Runtime calls from Pallet Assets allowed for proxy account Assets, - /// Not used at the moment, but kept for backwards compatibility. + /// All governance related calls allowed for proxy account Governance, /// Only provide_judgement call from pallet identity allowed for proxy account IdentityJudgement, @@ -1099,8 +1099,15 @@ impl InstanceFilter for ProxyType { ) ) } - // Not used at the moment, but kept for backwards compatibility. - ProxyType::Governance => false, + ProxyType::Governance => { + matches!( + c, + RuntimeCall::Democracy(..) + | RuntimeCall::Council(..) + | RuntimeCall::TechnicalCommittee(..) + | RuntimeCall::CommunityCouncil(..) + ) + } } }