git.delta.rocks / unique-network / refs/commits / 15ea50e38a6d

difftreelog

feat add financial council

Daniel Shiposha2024-03-26parent: #470ffd5.patch.diff
in: master

8 files changed

modifiedpallets/foreign-assets/src/lib.rsdiffbeforeafterboth
--- a/pallets/foreign-assets/src/lib.rs
+++ b/pallets/foreign-assets/src/lib.rs
@@ -68,7 +68,7 @@
 		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>;
@@ -154,7 +154,7 @@
 			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()
addedruntime/common/config/governance/financial_council.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/common/config/governance/financial_council.rs
@@ -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>;
modifiedruntime/common/config/governance/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/governance/mod.rs
+++ b/runtime/common/config/governance/mod.rs
@@ -49,6 +49,9 @@
 pub mod technical_committee;
 pub use technical_committee::*;
 
+pub mod financial_council;
+pub use financial_council::*;
+
 pub mod fellowship;
 pub use fellowship::*;
 
modifiedruntime/common/config/pallets/foreign_asset.rsdiffbeforeafterboth
before · runtime/common/config/pallets/foreign_asset.rs
1use frame_support::{parameter_types, PalletId};2#[cfg(not(feature = "governance"))]3use frame_system::EnsureRoot;4use pallet_evm::account::CrossAccountId;5use sp_core::H160;6use staging_xcm::prelude::*;7use staging_xcm_builder::AccountKey20Aliases;89#[cfg(feature = "governance")]10use crate::runtime_common::config::governance;11use crate::{12	runtime_common::config::{13		ethereum::CrossAccountId as ConfigCrossAccountId,14		xcm::{LocationToAccountId, SelfLocation},15	},16	RelayNetwork, Runtime, RuntimeEvent,17};1819parameter_types! {20	pub ForeignAssetPalletId: PalletId = PalletId(*b"frgnasts");21}2223pub struct LocationToCrossAccountId;24impl staging_xcm_executor::traits::ConvertLocation<ConfigCrossAccountId>25	for LocationToCrossAccountId26{27	fn convert_location(location: &Location) -> Option<ConfigCrossAccountId> {28		LocationToAccountId::convert_location(location)29			.map(ConfigCrossAccountId::from_sub)30			.or_else(|| {31				let eth_address =32					AccountKey20Aliases::<RelayNetwork, H160>::convert_location(location)?;3334				Some(ConfigCrossAccountId::from_eth(eth_address))35			})36	}37}3839impl pallet_foreign_assets::Config for Runtime {40	type RuntimeEvent = RuntimeEvent;4142	#[cfg(feature = "governance")]43	type ForceRegisterOrigin = governance::RootOrTechnicalCommitteeMember;4445	#[cfg(not(feature = "governance"))]46	type ForceRegisterOrigin = EnsureRoot<Self::AccountId>;4748	type PalletId = ForeignAssetPalletId;49	type SelfLocation = SelfLocation;50	type LocationToAccountId = LocationToCrossAccountId;51	type WeightInfo = pallet_foreign_assets::weights::SubstrateWeight<Self>;52}
after · runtime/common/config/pallets/foreign_asset.rs
1use frame_support::{parameter_types, PalletId};2#[cfg(not(feature = "governance"))]3use frame_system::EnsureRoot;4use pallet_evm::account::CrossAccountId;5use sp_core::H160;6use staging_xcm::prelude::*;7use staging_xcm_builder::AccountKey20Aliases;89#[cfg(feature = "governance")]10use crate::runtime_common::config::governance;11use crate::{12	runtime_common::config::{13		ethereum::CrossAccountId as ConfigCrossAccountId,14		xcm::{LocationToAccountId, SelfLocation},15	},16	RelayNetwork, Runtime, RuntimeEvent,17};1819parameter_types! {20	pub ForeignAssetPalletId: PalletId = PalletId(*b"frgnasts");21}2223pub struct LocationToCrossAccountId;24impl staging_xcm_executor::traits::ConvertLocation<ConfigCrossAccountId>25	for LocationToCrossAccountId26{27	fn convert_location(location: &Location) -> Option<ConfigCrossAccountId> {28		LocationToAccountId::convert_location(location)29			.map(ConfigCrossAccountId::from_sub)30			.or_else(|| {31				let eth_address =32					AccountKey20Aliases::<RelayNetwork, H160>::convert_location(location)?;3334				Some(ConfigCrossAccountId::from_eth(eth_address))35			})36	}37}3839impl pallet_foreign_assets::Config for Runtime {40	type RuntimeEvent = RuntimeEvent;4142	#[cfg(feature = "governance")]43	type ManagerOrigin = governance::RootOrFinancialCouncilMember;4445	#[cfg(not(feature = "governance"))]46	type ManagerOrigin = EnsureRoot<Self::AccountId>;4748	type PalletId = ForeignAssetPalletId;49	type SelfLocation = SelfLocation;50	type LocationToAccountId = LocationToCrossAccountId;51	type WeightInfo = pallet_foreign_assets::weights::SubstrateWeight<Self>;52}
modifiedruntime/common/construct_runtime.rsdiffbeforeafterboth
--- a/runtime/common/construct_runtime.rs
+++ b/runtime/common/construct_runtime.rs
@@ -81,6 +81,12 @@
 				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,
 
 				// XCM helpers.
modifiedruntime/opal/src/governance_timings.rsdiffbeforeafterboth
--- a/runtime/opal/src/governance_timings.rs
+++ b/runtime/opal/src/governance_timings.rs
@@ -52,3 +52,11 @@
 		pub TechnicalMotionDuration: BlockNumber = 15 * MINUTES;
 	}
 }
+
+pub mod financial_council {
+	use super::*;
+
+	parameter_types! {
+		pub FinancialCouncilMotionDuration: BlockNumber = 15 * MINUTES;
+	}
+}
modifiedruntime/quartz/src/governance_timings.rsdiffbeforeafterboth
--- a/runtime/quartz/src/governance_timings.rs
+++ b/runtime/quartz/src/governance_timings.rs
@@ -52,3 +52,11 @@
 		pub TechnicalMotionDuration: BlockNumber = 3 * DAYS;
 	}
 }
+
+pub mod financial_council {
+	use super::*;
+
+	parameter_types! {
+		pub FinancialCouncilMotionDuration: BlockNumber = 3 * DAYS;
+	}
+}
modifiedruntime/unique/src/governance_timings.rsdiffbeforeafterboth
--- a/runtime/unique/src/governance_timings.rs
+++ b/runtime/unique/src/governance_timings.rs
@@ -52,3 +52,11 @@
 		pub TechnicalMotionDuration: BlockNumber = 3 * DAYS;
 	}
 }
+
+pub mod financial_council {
+	use super::*;
+
+	parameter_types! {
+		pub FinancialCouncilMotionDuration: BlockNumber = 3 * DAYS;
+	}
+}