Forráskód Böngészése

Merge remote-tracking branch 'shamil/olympia-expose-lock-ids' into olympia-member-migration-memo-lock-export

Mokhtar Naamani 3 éve
szülő
commit
fb4ffa9565

+ 2 - 2
Cargo.lock

@@ -2383,7 +2383,7 @@ dependencies = [
  "pallet-timestamp",
  "pallet-transaction-payment",
  "pallet-transaction-payment-rpc-runtime-api",
- "pallet-utility 1.0.0",
+ "pallet-utility 1.1.0",
  "pallet-utility 2.0.1",
  "pallet-working-group",
  "parity-scale-codec",
@@ -4309,7 +4309,7 @@ dependencies = [
 
 [[package]]
 name = "pallet-utility"
-version = "1.0.0"
+version = "1.1.0"
 dependencies = [
  "frame-benchmarking",
  "frame-support",

+ 8 - 0
runtime-modules/common/src/lib.rs

@@ -12,10 +12,12 @@ use codec::{Codec, Decode, Encode};
 #[cfg(feature = "std")]
 use serde::{Deserialize, Serialize};
 
+use frame_support::traits::LockIdentifier;
 use frame_support::Parameter;
 pub use membership::{ActorId, MemberId, MembershipTypes, StakingAccountValidator};
 use sp_arithmetic::traits::BaseArithmetic;
 use sp_runtime::traits::{MaybeSerialize, Member};
+use sp_std::collections::btree_set::BTreeSet;
 use sp_std::vec::Vec;
 
 /// HTTP Url string
@@ -92,3 +94,9 @@ pub fn current_block_time<T: frame_system::Trait + pallet_timestamp::Trait>(
         time: <pallet_timestamp::Module<T>>::now(),
     }
 }
+
+/// Provides allowed locks combination for the accounts.
+pub trait AllowedLockCombinationProvider {
+    /// Return allowed locks combination set.
+    fn get_allowed_lock_combinations() -> BTreeSet<(LockIdentifier, LockIdentifier)>;
+}

+ 1 - 1
runtime-modules/utility/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = 'pallet-utility'
-version = '1.0.0'
+version = '1.1.0'
 authors = ['Joystream contributors']
 edition = '2018'
 

+ 10 - 3
runtime-modules/utility/src/lib.rs

@@ -24,16 +24,16 @@ pub(crate) mod tests;
 
 mod benchmarking;
 
-use common::{working_group::WorkingGroup, BalanceKind};
+use common::{working_group::WorkingGroup, AllowedLockCombinationProvider, BalanceKind};
 use council::Module as Council;
-use frame_support::traits::Currency;
-use frame_support::traits::Get;
+use frame_support::traits::{Currency, Get, LockIdentifier};
 use frame_support::weights::{DispatchClass, Weight};
 use frame_support::{decl_error, decl_event, decl_module, ensure, print};
 use frame_system::{ensure_root, ensure_signed};
 use sp_arithmetic::traits::Zero;
 use sp_runtime::traits::Saturating;
 use sp_runtime::SaturatedConversion;
+use sp_std::collections::btree_set::BTreeSet;
 use sp_std::vec::Vec;
 
 type BalanceOf<T> = <T as balances::Trait>::Balance;
@@ -50,6 +50,9 @@ pub trait Trait: frame_system::Trait + balances::Trait + council::Trait {
 
     /// Weight information for extrinsics in this pallet.
     type WeightInfo: WeightInfo;
+
+    /// Exposes allowed lock combinations from the runtime level.
+    type AllowedLockCombinationProvider: AllowedLockCombinationProvider;
 }
 
 /// Utility WeightInfo.
@@ -116,6 +119,10 @@ decl_module! {
         /// Predefined errors
         type Error = Error<T>;
 
+        /// Exposes allowed lock combinations from the runtime level.
+        const AllowedLockCombinations: BTreeSet<(LockIdentifier, LockIdentifier)> =
+            T::AllowedLockCombinationProvider::get_allowed_lock_combinations();
+
         /// Signal proposal extrinsic. Should be used as callable object to pass to the `engine` module.
         ///
         /// <weight>

+ 9 - 0
runtime-modules/utility/src/tests/mocks.rs

@@ -206,6 +206,15 @@ impl Trait for Test {
     fn set_working_group_budget(working_group: WorkingGroup, budget: BalanceOf<Test>) {
         call_wg!(working_group<Test>, set_budget, budget)
     }
+
+    type AllowedLockCombinationProvider = AllowedLockCombinationProvider;
+}
+
+pub struct AllowedLockCombinationProvider;
+impl common::AllowedLockCombinationProvider for AllowedLockCombinationProvider {
+    fn get_allowed_lock_combinations() -> BTreeSet<(LockIdentifier, LockIdentifier)> {
+        Default::default()
+    }
 }
 
 impl WeightInfo for () {

+ 11 - 0
runtime/src/lib.rs

@@ -58,6 +58,7 @@ use sp_runtime::curve::PiecewiseLinear;
 use sp_runtime::traits::{BlakeTwo256, Block as BlockT, IdentityLookup, OpaqueKeys, Saturating};
 use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, ModuleId, Perbill};
 use sp_std::boxed::Box;
+use sp_std::collections::btree_set::BTreeSet;
 use sp_std::vec::Vec;
 #[cfg(feature = "std")]
 use sp_version::NativeVersion;
@@ -71,6 +72,7 @@ pub use runtime_api::*;
 use integration::proposals::{CouncilManager, ExtrinsicProposalEncoder};
 
 use common::working_group::{WorkingGroup, WorkingGroupAuthenticator, WorkingGroupBudgetHandler};
+use common::AllowedLockCombinationProvider;
 use council::ReferendumConnection;
 use referendum::{CastVote, OptionResult};
 use staking_handler::{LockComparator, StakingManager};
@@ -983,9 +985,18 @@ impl proposals_discussion::Trait for Runtime {
     type PostLifeTime = ForumPostLifeTime;
 }
 
+pub struct LockCombinationProvider;
+impl AllowedLockCombinationProvider for LockCombinationProvider {
+    fn get_allowed_lock_combinations() -> BTreeSet<(LockIdentifier, LockIdentifier)> {
+        ALLOWED_LOCK_COMBINATIONS.clone()
+    }
+}
+
 impl joystream_utility::Trait for Runtime {
     type Event = Event;
 
+    type AllowedLockCombinationProvider = LockCombinationProvider;
+
     type WeightInfo = weights::joystream_utility::WeightInfo;
 
     fn get_working_group_budget(working_group: WorkingGroup) -> Balance {