Skip to content

Commit

Permalink
Governance proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed Nov 22, 2024
1 parent d72239b commit 6d0dfa6
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 48 deletions.
25 changes: 12 additions & 13 deletions runtime/astar/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,24 @@ pub fn default_config(para_id: u32) -> serde_json::Value {
let dave = GenesisAccount::<sr25519::Public>::from_seed("Dave");
let eve = GenesisAccount::<sr25519::Public>::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::<Vec<_>>();

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::<Vec<_>>();

let config = RuntimeGenesisConfig {
system: Default::default(),
sudo: SudoConfig {
Expand Down
11 changes: 11 additions & 0 deletions runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1111,6 +1113,15 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
)
)
}
ProxyType::Governance => {
matches!(
c,
RuntimeCall::Democracy(..)
| RuntimeCall::Council(..)
| RuntimeCall::TechnicalCommittee(..)
| RuntimeCall::CommunityCouncil(..)
)
}
}
}

Expand Down
35 changes: 16 additions & 19 deletions runtime/local/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,27 @@ pub fn default_config() -> serde_json::Value {
let dave = GenesisAccount::<sr25519::Public>::from_seed("Dave");
let eve = GenesisAccount::<sr25519::Public>::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::<Vec<_>>();

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::<Vec<_>>();

let config = RuntimeGenesisConfig {
system: Default::default(),
sudo: SudoConfig {
Expand Down
11 changes: 11 additions & 0 deletions runtime/local/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -850,6 +852,15 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
)
)
}
ProxyType::Governance => {
matches!(
c,
RuntimeCall::Democracy(..)
| RuntimeCall::Council(..)
| RuntimeCall::TechnicalCommittee(..)
| RuntimeCall::CommunityCouncil(..)
)
}
}
}

Expand Down
25 changes: 12 additions & 13 deletions runtime/shibuya/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,24 @@ pub fn default_config(para_id: u32) -> serde_json::Value {
let dave = GenesisAccount::<sr25519::Public>::from_seed("Dave");
let eve = GenesisAccount::<sr25519::Public>::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::<Vec<_>>();

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::<Vec<_>>();

let config = RuntimeGenesisConfig {
system: Default::default(),
sudo: SudoConfig {
Expand Down
13 changes: 10 additions & 3 deletions runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -1099,8 +1099,15 @@ impl InstanceFilter<RuntimeCall> 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(..)
)
}
}
}

Expand Down

0 comments on commit 6d0dfa6

Please sign in to comment.