diff --git a/pallets/asset-index/src/lib.rs b/pallets/asset-index/src/lib.rs index 591162ab86..a8a67b0906 100644 --- a/pallets/asset-index/src/lib.rs +++ b/pallets/asset-index/src/lib.rs @@ -342,7 +342,7 @@ pub mod pallet { /// into the sovereign account of either: /// - the given `recipient` if provided /// - the caller's account if `recipient` is `None` - #[pallet::weight(T::WeightInfo::remove_asset())] // TODO: Set weights + #[pallet::weight(T::WeightInfo::remove_asset())] pub fn remove_asset( origin: OriginFor, asset_id: T::AssetId, @@ -479,7 +479,7 @@ pub mod pallet { /// /// The distribution of the underlying assets will be equivalent to the /// ratio of the liquid assets in the index. - #[pallet::weight(T::WeightInfo::withdraw())] // TODO: Set weights + #[pallet::weight(T::WeightInfo::withdraw())] #[transactional] pub fn withdraw(origin: OriginFor, amount: T::Balance) -> DispatchResultWithPostInfo { let caller = ensure_signed(origin)?; @@ -564,7 +564,7 @@ pub mod pallet { /// as soon as the aforementioned conditions are met, regardless of /// whether the other `AssetWithdrawal`s in the same `PendingWithdrawal` set /// can also be closed successfully. - #[pallet::weight(T::WeightInfo::complete_withdraw())] // TODO: Set weights + #[pallet::weight(T::WeightInfo::complete_withdraw())] pub fn complete_withdraw(origin: OriginFor) -> DispatchResultWithPostInfo { let caller = ensure_signed(origin)?; diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 9587455dd2..5937bee8db 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -5,4 +5,5 @@ #![cfg_attr(not(feature = "std"), no_std)] pub mod constants; pub mod traits; +pub mod types; pub mod weights; diff --git a/runtime/common/src/types.rs b/runtime/common/src/types.rs new file mode 100644 index 0000000000..d78f8a16cb --- /dev/null +++ b/runtime/common/src/types.rs @@ -0,0 +1,9 @@ +// Copyright 2021 ChainSafe Systems +// SPDX-License-Identifier: LGPL-3.0-only + +/// Origin that approved by committee +pub type GovernanceOrigin = frame_system::EnsureOneOf< + AccountId, + frame_system::EnsureRoot, + pallet_committee::EnsureApprovedByCommittee, +>; diff --git a/runtime/dev/src/lib.rs b/runtime/dev/src/lib.rs index 58a1341694..ae3a4aa9ea 100644 --- a/runtime/dev/src/lib.rs +++ b/runtime/dev/src/lib.rs @@ -56,7 +56,7 @@ use xcm_executor::XcmExecutor; use frame_support::traits::Everything; use pallet_committee::EnsureMember; -pub use pint_runtime_common::{constants::*, weights}; +pub use pint_runtime_common::{constants::*, types::GovernanceOrigin, weights}; use primitives::traits::MultiAssetRegistry; pub use primitives::*; use xcm_calls::{ @@ -384,7 +384,7 @@ impl pallet_session::Config for Runtime { impl pallet_collator_selection::Config for Runtime { type Event = Event; type Currency = Balances; - type UpdateOrigin = EnsureApprovedByCommittee; + type UpdateOrigin = GovernanceOrigin; type PotId = PotId; type MaxCandidates = MaxCandidates; type MinCandidates = MinCandidates; @@ -407,8 +407,7 @@ impl pallet_local_treasury::Config for Runtime { } impl pallet_saft_registry::Config for Runtime { - // Using signed as the admin origin for now - type AdminOrigin = frame_system::EnsureSigned; + type AdminOrigin = GovernanceOrigin; type AssetRecorder = AssetIndex; type Balance = Balance; type AssetId = AssetId; @@ -416,12 +415,6 @@ impl pallet_saft_registry::Config for Runtime { type WeightInfo = weights::pallet_saft_registry::WeightInfo; } -type EnsureApprovedByCommittee = frame_system::EnsureOneOf< - AccountId, - frame_system::EnsureRoot, - pallet_committee::EnsureApprovedByCommittee, ->; - impl pallet_committee::Config for Runtime { type Origin = Origin; type Action = Call; @@ -431,13 +424,12 @@ impl pallet_committee::Config for Runtime { type MinCouncilVotes = MinCouncilVotes; type ProposalSubmissionOrigin = EnsureSigned; type ProposalExecutionOrigin = EnsureMember; - type ApprovedByCommitteeOrigin = EnsureApprovedByCommittee; + type ApprovedByCommitteeOrigin = GovernanceOrigin; type Event = Event; type WeightInfo = weights::pallet_committee::WeightInfo; } impl pallet_price_feed::Config for Runtime { - // Using root as the admin origin for now type AdminOrigin = frame_system::EnsureRoot; type SelfAssetId = PINTAssetId; type AssetId = AssetId; diff --git a/runtime/kusama/src/lib.rs b/runtime/kusama/src/lib.rs index 5b4cd3eb4d..e7d6ed9cf1 100644 --- a/runtime/kusama/src/lib.rs +++ b/runtime/kusama/src/lib.rs @@ -56,7 +56,7 @@ use xcm_executor::XcmExecutor; use frame_support::traits::Everything; use pallet_committee::EnsureMember; -pub use pint_runtime_common::{constants::*, weights}; +pub use pint_runtime_common::{constants::*, types::GovernanceOrigin, weights}; use primitives::traits::MultiAssetRegistry; pub use primitives::*; use xcm_calls::{ @@ -382,7 +382,7 @@ impl pallet_session::Config for Runtime { impl pallet_collator_selection::Config for Runtime { type Event = Event; type Currency = Balances; - type UpdateOrigin = EnsureApprovedByCommittee; + type UpdateOrigin = GovernanceOrigin; type PotId = PotId; type MaxCandidates = MaxCandidates; type MinCandidates = MinCandidates; @@ -405,8 +405,7 @@ impl pallet_local_treasury::Config for Runtime { } impl pallet_saft_registry::Config for Runtime { - // Using signed as the admin origin for now - type AdminOrigin = frame_system::EnsureSigned; + type AdminOrigin = GovernanceOrigin; type AssetRecorder = AssetIndex; type Balance = Balance; type AssetId = AssetId; @@ -414,12 +413,6 @@ impl pallet_saft_registry::Config for Runtime { type WeightInfo = weights::pallet_saft_registry::WeightInfo; } -type EnsureApprovedByCommittee = frame_system::EnsureOneOf< - AccountId, - frame_system::EnsureRoot, - pallet_committee::EnsureApprovedByCommittee, ->; - impl pallet_committee::Config for Runtime { type Origin = Origin; type Action = Call; @@ -429,7 +422,7 @@ impl pallet_committee::Config for Runtime { type MinCouncilVotes = MinCouncilVotes; type ProposalSubmissionOrigin = EnsureSigned; type ProposalExecutionOrigin = EnsureMember; - type ApprovedByCommitteeOrigin = EnsureApprovedByCommittee; + type ApprovedByCommitteeOrigin = GovernanceOrigin; type Event = Event; type WeightInfo = weights::pallet_committee::WeightInfo; } diff --git a/runtime/polkadot/src/lib.rs b/runtime/polkadot/src/lib.rs index 4a90d3c8b0..44c860ae7e 100644 --- a/runtime/polkadot/src/lib.rs +++ b/runtime/polkadot/src/lib.rs @@ -56,7 +56,7 @@ use xcm_executor::XcmExecutor; use frame_support::traits::Everything; use pallet_committee::EnsureMember; -pub use pint_runtime_common::{constants::*, weights}; +pub use pint_runtime_common::{constants::*, types::GovernanceOrigin, weights}; use primitives::traits::MultiAssetRegistry; pub use primitives::*; use xcm_calls::{ @@ -384,7 +384,7 @@ impl pallet_session::Config for Runtime { impl pallet_collator_selection::Config for Runtime { type Event = Event; type Currency = Balances; - type UpdateOrigin = EnsureApprovedByCommittee; + type UpdateOrigin = GovernanceOrigin; type PotId = PotId; type MaxCandidates = MaxCandidates; type MinCandidates = MinCandidates; @@ -407,8 +407,7 @@ impl pallet_local_treasury::Config for Runtime { } impl pallet_saft_registry::Config for Runtime { - // Using signed as the admin origin for now - type AdminOrigin = frame_system::EnsureSigned; + type AdminOrigin = GovernanceOrigin; type AssetRecorder = AssetIndex; type Balance = Balance; type AssetId = AssetId; @@ -416,12 +415,6 @@ impl pallet_saft_registry::Config for Runtime { type WeightInfo = weights::pallet_saft_registry::WeightInfo; } -type EnsureApprovedByCommittee = frame_system::EnsureOneOf< - AccountId, - frame_system::EnsureRoot, - pallet_committee::EnsureApprovedByCommittee, ->; - impl pallet_committee::Config for Runtime { type Origin = Origin; type Action = Call; @@ -431,7 +424,7 @@ impl pallet_committee::Config for Runtime { type MinCouncilVotes = MinCouncilVotes; type ProposalSubmissionOrigin = EnsureSigned; type ProposalExecutionOrigin = EnsureMember; - type ApprovedByCommitteeOrigin = EnsureApprovedByCommittee; + type ApprovedByCommitteeOrigin = GovernanceOrigin; type Event = Event; type WeightInfo = weights::pallet_committee::WeightInfo; } @@ -461,8 +454,7 @@ impl pallet_chainlink_feed::Config for Runtime { } impl pallet_asset_index::Config for Runtime { - // Using signed as the admin origin for testing now - type AdminOrigin = frame_system::EnsureSigned; + type AdminOrigin = GovernanceOrigin; type IndexToken = Balances; type Balance = Balance; type LockupPeriod = LockupPeriod;