Skip to content

Commit 0ebf987

Browse files
committed
Community treasury
1 parent 94e8123 commit 0ebf987

File tree

2 files changed

+58
-12
lines changed

2 files changed

+58
-12
lines changed

bin/collator/src/local/chain_spec.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
2121
use local_runtime::{
2222
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig,
23-
CommunityCouncilMembershipConfig, CouncilMembershipConfig, DappStakingConfig, EVMConfig,
24-
GrandpaConfig, GrandpaId, InflationConfig, InflationParameters, Precompiles,
25-
RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig, TechnicalCommitteeMembershipConfig,
26-
TierThreshold, VestingConfig, AST,
23+
CommunityCouncilMembershipConfig, CommunityTreasuryPalletId, CouncilMembershipConfig,
24+
DappStakingConfig, EVMConfig, GrandpaConfig, GrandpaId, InflationConfig, InflationParameters,
25+
Precompiles, RuntimeGenesisConfig, Signature, SudoConfig, SystemConfig,
26+
TechnicalCommitteeMembershipConfig, TierThreshold, TreasuryPalletId, VestingConfig, AST,
2727
};
2828
use sc_service::ChainType;
2929
use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
3030
use sp_runtime::{
31-
traits::{IdentifyAccount, Verify},
31+
traits::{AccountIdConversion, IdentifyAccount, Verify},
3232
Permill,
3333
};
3434

@@ -77,6 +77,8 @@ pub fn development_config() -> ChainSpec {
7777
get_account_id_from_seed::<sr25519::Public>("Charlie"),
7878
get_account_id_from_seed::<sr25519::Public>("Eve"),
7979
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
80+
TreasuryPalletId::get().into_account_truncating(),
81+
CommunityTreasuryPalletId::get().into_account_truncating(),
8082
// Arrakis.TEST account in MetaMask
8183
// Import known test account with private key
8284
// 0x01ab6e801c06e59ca97a14fc0a1978b27fa366fc87450e0b65459dd3515b7391
@@ -218,6 +220,7 @@ fn testnet_genesis(
218220
community_council: Default::default(),
219221
democracy: Default::default(),
220222
treasury: Default::default(),
223+
community_treasury: Default::default(),
221224
}
222225
}
223226

runtime/local/src/lib.rs

+50-7
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@ use astar_primitives::{
7272
},
7373
evm::{EvmRevertCodeHandler, HashedDefaultMappings},
7474
governance::{
75-
CommunityCouncilCollectiveInst, CommunityCouncilMembershipInst, EnsureRootOrAllMainCouncil,
76-
EnsureRootOrAllTechnicalCommittee, EnsureRootOrTwoThirdsCommunityCouncil,
77-
EnsureRootOrTwoThirdsMainCouncil, EnsureRootOrTwoThirdsTechnicalCommittee,
78-
MainCouncilCollectiveInst, MainCouncilMembershipInst, MainTreasuryInst,
79-
TechnicalCommitteeCollectiveInst, TechnicalCommitteeMembershipInst,
75+
CommunityCouncilCollectiveInst, CommunityCouncilMembershipInst, CommunityTreasuryInst,
76+
EnsureRootOrAllMainCouncil, EnsureRootOrAllTechnicalCommittee,
77+
EnsureRootOrTwoThirdsCommunityCouncil, EnsureRootOrTwoThirdsMainCouncil,
78+
EnsureRootOrTwoThirdsTechnicalCommittee, MainCouncilCollectiveInst,
79+
MainCouncilMembershipInst, MainTreasuryInst, TechnicalCommitteeCollectiveInst,
80+
TechnicalCommitteeMembershipInst,
8081
},
8182
Address, AssetId, Balance, BlockNumber, Hash, Header, Nonce,
8283
};
@@ -1022,7 +1023,7 @@ impl pallet_democracy::Config for Runtime {
10221023

10231024
parameter_types! {
10241025
pub const ProposalBond: Permill = Permill::from_percent(5);
1025-
pub TreasuryAccount: AccountId = Treasury::account_id();
1026+
pub MainTreasuryAccount: AccountId = Treasury::account_id();
10261027
}
10271028

10281029
impl pallet_treasury::Config<MainTreasuryInst> for Runtime {
@@ -1050,7 +1051,48 @@ impl pallet_treasury::Config<MainTreasuryInst> for Runtime {
10501051
type AssetKind = (); // Only native asset is supported
10511052
type Beneficiary = AccountId;
10521053
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
1053-
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
1054+
type Paymaster = PayFromAccount<Balances, MainTreasuryAccount>;
1055+
type BalanceConverter = UnityAssetBalanceConversion;
1056+
1057+
// New approach to using treasury, useful for OpenGov but not necessarily for us.
1058+
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
1059+
// Only used by 'spend' approach which is disabled
1060+
type PayoutPeriod = ConstU32<0>;
1061+
#[cfg(feature = "runtime-benchmarks")]
1062+
type BenchmarkHelper = ();
1063+
type WeightInfo = pallet_treasury::weights::SubstrateWeight<Runtime>;
1064+
}
1065+
1066+
parameter_types! {
1067+
pub const CommunityTreasuryPalletId: PalletId = PalletId(*b"py/comtr");
1068+
}
1069+
1070+
impl pallet_treasury::Config<CommunityTreasuryInst> for Runtime {
1071+
type PalletId = CommunityTreasuryPalletId;
1072+
type Currency = Balances;
1073+
type RuntimeEvent = RuntimeEvent;
1074+
1075+
// Two origins which can either approve or reject the spending proposal
1076+
type ApproveOrigin = EnsureRootOrTwoThirdsCommunityCouncil;
1077+
type RejectOrigin = EnsureRootOrTwoThirdsCommunityCouncil;
1078+
1079+
type OnSlash = CommunityTreasury;
1080+
type ProposalBond = ProposalBond;
1081+
type ProposalBondMinimum = ConstU128<{ 10 * AST }>;
1082+
// TODO: do we even want this or should we make it unlimited?
1083+
type ProposalBondMaximum = ConstU128<{ 100 * AST }>;
1084+
type SpendPeriod = ConstU32<{ 1 * MINUTES }>;
1085+
1086+
// We don't do periodic burns of the community treasury
1087+
type Burn = ();
1088+
type BurnDestination = ();
1089+
type SpendFunds = ();
1090+
1091+
type MaxApprovals = ConstU32<64>;
1092+
type AssetKind = (); // Only native asset is supported
1093+
type Beneficiary = AccountId;
1094+
type BeneficiaryLookup = IdentityLookup<Self::Beneficiary>;
1095+
type Paymaster = PayFromAccount<Balances, MainTreasuryAccount>;
10541096
type BalanceConverter = UnityAssetBalanceConversion;
10551097

10561098
// New approach to using treasury, useful for OpenGov but not necessarily for us.
@@ -1088,6 +1130,7 @@ construct_runtime!(
10881130
CommunityCouncil: pallet_collective::<Instance4>,
10891131
Democracy: pallet_democracy,
10901132
Treasury: pallet_treasury::<Instance1>,
1133+
CommunityTreasury: pallet_treasury::<Instance2>,
10911134

10921135
EVM: pallet_evm,
10931136
Ethereum: pallet_ethereum,

0 commit comments

Comments
 (0)