Skip to content

Commit

Permalink
feat: add financial council
Browse files Browse the repository at this point in the history
  • Loading branch information
mrshiposha committed Mar 26, 2024
1 parent c748379 commit ae0b7e2
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pallets/foreign-assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub mod module {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// Origin for force registering of a foreign asset.
type ForceRegisterOrigin: EnsureOrigin<Self::RuntimeOrigin>;
type ManagerOrigin: EnsureOrigin<Self::RuntimeOrigin>;

/// The ID of the foreign assets pallet.
type PalletId: Get<PalletId>;
Expand Down Expand Up @@ -156,7 +156,7 @@ pub mod module {
token_prefix: CollectionTokenPrefix,
mode: ForeignCollectionMode,
) -> DispatchResult {
T::ForceRegisterOrigin::ensure_origin(origin.clone())?;
T::ManagerOrigin::ensure_origin(origin.clone())?;

let asset_id: AssetId = versioned_asset_id
.as_ref()
Expand Down
56 changes: 56 additions & 0 deletions runtime/common/config/governance/financial_council.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
use super::*;

parameter_types! {
pub FinancialCouncilMaxProposals: u32 = 100;
pub FinancialCouncilMaxMembers: u32 = 100;
}

#[cfg(not(feature = "gov-test-timings"))]
use crate::governance_timings::financial_council as financial_council_timings;

#[cfg(feature = "gov-test-timings")]
pub mod financial_council_timings {
use super::*;

parameter_types! {
pub FinancialCouncilMotionDuration: BlockNumber = 35;
}
}

pub type FinancialCollective = pallet_collective::Instance3;
impl pallet_collective::Config<FinancialCollective> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = financial_council_timings::FinancialCouncilMotionDuration;
type MaxProposals = FinancialCouncilMaxProposals;
type MaxMembers = FinancialCouncilMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = pallet_collective::weights::SubstrateWeight<Runtime>;
type SetMembersOrigin = EnsureRoot<AccountId>;
type MaxProposalWeight = MaxCollectivesProposalWeight;
}

pub type FinancialCollectiveMembership = pallet_membership::Instance3;
impl pallet_membership::Config<FinancialCollectiveMembership> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = RootOrMoreThanHalfCouncil;
type RemoveOrigin = RootOrMoreThanHalfCouncil;
type SwapOrigin = RootOrMoreThanHalfCouncil;
type ResetOrigin = EnsureRoot<AccountId>;
type PrimeOrigin = RootOrMoreThanHalfCouncil;
type MembershipInitialized = TechnicalCommittee;
type MembershipChanged = TechnicalCommittee;
type MaxMembers = FinancialCouncilMaxMembers;
type WeightInfo = pallet_membership::weights::SubstrateWeight<Runtime>;
}

pub type FinancialCouncilMember = pallet_collective::EnsureMember<AccountId, FinancialCollective>;

pub type RootOrFinancialCouncilMember =
EitherOfDiverse<EnsureRoot<AccountId>, FinancialCouncilMember>;

pub type AllFinancialCouncil =
pallet_collective::EnsureProportionAtLeast<AccountId, FinancialCollective, 1, 1>;

pub type RootOrAllFinancialCouncil = EitherOfDiverse<EnsureRoot<AccountId>, AllFinancialCouncil>;
3 changes: 3 additions & 0 deletions runtime/common/config/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pub use democracy::*;
pub mod technical_committee;
pub use technical_committee::*;

pub mod financial_council;
pub use financial_council::*;

pub mod fellowship;
pub use fellowship::*;

Expand Down
4 changes: 2 additions & 2 deletions runtime/common/config/pallets/foreign_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ impl pallet_foreign_assets::Config for Runtime {
type RuntimeEvent = RuntimeEvent;

#[cfg(feature = "governance")]
type ForceRegisterOrigin = governance::RootOrTechnicalCommitteeMember;
type ManagerOrigin = governance::RootOrFinancialCouncilMember;

#[cfg(not(feature = "governance"))]
type ForceRegisterOrigin = EnsureRoot<Self::AccountId>;
type ManagerOrigin = EnsureRoot<Self::AccountId>;

type PalletId = ForeignAssetPalletId;
type SelfLocation = SelfLocation;
Expand Down
6 changes: 6 additions & 0 deletions runtime/common/construct_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ macro_rules! construct_runtime {
#[cfg(feature = "governance")]
Scheduler: pallet_scheduler = 49,

#[cfg(feature = "governance")]
FinancialCouncil: pallet_collective::<Instance3> = 97,

#[cfg(feature = "governance")]
FinancialCouncilMembership: pallet_membership::<Instance3> = 98,

#[cfg(feature = "governance")]
Origins: pallet_gov_origins = 99,

Expand Down
8 changes: 8 additions & 0 deletions runtime/opal/src/governance_timings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ pub mod technical_committee {
pub TechnicalMotionDuration: BlockNumber = 15 * MINUTES;
}
}

pub mod financial_council {
use super::*;

parameter_types! {
pub FinancialCouncilMotionDuration: BlockNumber = 15 * MINUTES;
}
}
8 changes: 8 additions & 0 deletions runtime/quartz/src/governance_timings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ pub mod technical_committee {
pub TechnicalMotionDuration: BlockNumber = 3 * DAYS;
}
}

pub mod financial_council {
use super::*;

parameter_types! {
pub FinancialCouncilMotionDuration: BlockNumber = 3 * DAYS;
}
}
8 changes: 8 additions & 0 deletions runtime/unique/src/governance_timings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,11 @@ pub mod technical_committee {
pub TechnicalMotionDuration: BlockNumber = 3 * DAYS;
}
}

pub mod financial_council {
use super::*;

parameter_types! {
pub FinancialCouncilMotionDuration: BlockNumber = 3 * DAYS;
}
}

0 comments on commit ae0b7e2

Please sign in to comment.