Browse Source

runtime: proposals: Remove obsolete dependencies.

Shamil Gadelshin 4 years ago
parent
commit
3355d1dace

+ 0 - 2
Cargo.lock

@@ -3958,13 +3958,11 @@ dependencies = [
  "pallet-membership",
  "pallet-proposals-discussion",
  "pallet-proposals-engine",
- "pallet-recurring-reward",
  "pallet-referendum",
  "pallet-staking",
  "pallet-staking-handler",
  "pallet-staking-reward-curve",
  "pallet-timestamp",
- "pallet-token-mint",
  "pallet-working-group",
  "parity-scale-codec",
  "serde",

+ 0 - 3
runtime-modules/proposals/codex/Cargo.toml

@@ -15,7 +15,6 @@ frame-system = { package = 'frame-system', default-features = false, git = 'http
 staking = { package = 'pallet-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-minting = { package = 'pallet-token-mint', default-features = false, path = '../../token-minting'}
 working-group = { package = 'pallet-working-group', default-features = false, path = '../../working-group'}
 common = { package = 'pallet-common', default-features = false, path = '../../common'}
 proposals-engine = { package = 'pallet-proposals-engine', default-features = false, path = '../engine'}
@@ -28,7 +27,6 @@ sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com
 sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 sp-staking = { package = 'sp-staking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 pallet-staking-reward-curve = { package = 'pallet-staking-reward-curve', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-recurring-rewards = { package = 'pallet-recurring-reward', default-features = false, path = '../../recurring-reward'}
 strum = {version = "0.19", default-features = false}
 staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../../staking-handler'}
 referendum = { package = 'pallet-referendum', default-features = false, path = '../../referendum'}
@@ -47,7 +45,6 @@ std = [
     'staking/std',
     'pallet-timestamp/std',
     'balances/std',
-    'minting/std',
     'working-group/std',
     'common/std',
     'proposals-engine/std',

+ 4 - 17
runtime-modules/proposals/codex/src/lib.rs

@@ -59,7 +59,7 @@ mod types;
 mod tests;
 
 use frame_support::dispatch::DispatchResult;
-use frame_support::traits::{Currency, Get};
+use frame_support::traits::Get;
 use frame_support::{decl_error, decl_module, decl_storage, ensure, print};
 use frame_system::ensure_root;
 use sp_arithmetic::traits::Zero;
@@ -92,8 +92,6 @@ pub trait Trait:
     + proposals_discussion::Trait
     + common::Trait
     + staking::Trait
-    + common::currency::GovernanceCurrency
-    + minting::Trait
 {
     /// Validates member id and origin combination.
     type MembershipOriginValidator: ActorOriginValidator<
@@ -169,16 +167,6 @@ pub type GeneralProposalParameters<T> = GeneralProposalParams<
     <T as frame_system::Trait>::BlockNumber,
 >;
 
-/// Balance alias for GovernanceCurrency from `common` module. TODO: replace with BalanceOf
-pub type BalanceOfGovernanceCurrency<T> =
-    <<T as common::currency::GovernanceCurrency>::Currency as Currency<
-        <T as frame_system::Trait>::AccountId,
-    >>::Balance;
-
-/// Balance alias for token mint balance from `token mint` module. TODO: replace with BalanceOf
-pub type BalanceOfMint<T> =
-    <<T as minting::Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
-
 decl_error! {
     /// Codex module predefined errors
     pub enum Error for Module<T: Trait> {
@@ -399,11 +387,11 @@ impl<T: Trait> Module<T> {
             }
             ProposalDetails::Spending(ref balance, _) => {
                 ensure!(
-                    *balance != BalanceOfMint::<T>::zero(),
+                    *balance != BalanceOf::<T>::zero(),
                     Error::<T>::InvalidSpendingProposalBalance
                 );
                 ensure!(
-                    *balance <= <BalanceOfMint<T>>::from(MAX_SPENDING_PROPOSAL_VALUE),
+                    *balance <= <BalanceOf<T>>::from(MAX_SPENDING_PROPOSAL_VALUE),
                     Error::<T>::InvalidSpendingProposalBalance
                 );
             }
@@ -426,8 +414,7 @@ impl<T: Trait> Module<T> {
             }
             ProposalDetails::SetWorkingGroupBudgetCapacity(ref mint_balance, _) => {
                 ensure!(
-                    *mint_balance
-                        <= <BalanceOfMint<T>>::from(WORKING_GROUP_BUDGET_CAPACITY_MAX_VALUE),
+                    *mint_balance <= <BalanceOf<T>>::from(WORKING_GROUP_BUDGET_CAPACITY_MAX_VALUE),
                     Error::<T>::InvalidWorkingGroupBudgetCapacity
                 );
             }

+ 0 - 15
runtime-modules/proposals/codex/src/tests/mock.rs

@@ -152,11 +152,6 @@ impl Default for crate::Call<Test> {
     }
 }
 
-impl minting::Trait for Test {
-    type Currency = Balances;
-    type MintId = u64;
-}
-
 impl common::origin::ActorOriginValidator<Origin, u64, u64> for () {
     fn ensure_actor_origin(origin: Origin, _: u64) -> Result<u64, &'static str> {
         let account_id = frame_system::ensure_signed(origin)?;
@@ -311,12 +306,6 @@ impl working_group::Trait<StorageWorkingGroupInstance> for Test {
     type WeightInfo = WorkingGroupWeightInfo;
 }
 
-impl recurring_rewards::Trait for Test {
-    type PayoutStatusHandler = ();
-    type RecipientId = u64;
-    type RewardRelationshipId = u64;
-}
-
 pallet_staking_reward_curve::build! {
     const I_NPOS: PiecewiseLinear<'static> = curve!(
         min_inflation: 0_025_000,
@@ -398,10 +387,6 @@ pub(crate) fn default_proposal_parameters() -> ProposalParameters<u64, u64> {
     }
 }
 
-impl common::currency::GovernanceCurrency for Test {
-    type Currency = balances::Module<Self>;
-}
-
 impl crate::Trait for Test {
     type MembershipOriginValidator = ();
     type ProposalEncoder = ();

+ 1 - 1
runtime-modules/proposals/codex/src/tests/mod.rs

@@ -42,7 +42,7 @@ where
     empty_stake_call: EmptyStakeCall,
     successful_call: SuccessfulCall,
     proposal_parameters: ProposalParameters<u64, u64>,
-    proposal_details: ProposalDetails<u64, u64, u64, u64, u64, u64>,
+    proposal_details: ProposalDetails<u64, u64, u64, u64>,
 }
 
 impl<InsufficientRightsCall, EmptyStakeCall, SuccessfulCall>

+ 10 - 26
runtime-modules/proposals/codex/src/types.rs

@@ -17,8 +17,6 @@ pub trait ProposalEncoder<T: crate::Trait> {
 
 /// _ProposalDetails_ alias for type simplification
 pub type ProposalDetailsOf<T> = ProposalDetails<
-    crate::BalanceOfMint<T>,
-    crate::BalanceOfGovernanceCurrency<T>,
     <T as frame_system::Trait>::BlockNumber,
     <T as frame_system::Trait>::AccountId,
     crate::BalanceOf<T>,
@@ -28,14 +26,7 @@ pub type ProposalDetailsOf<T> = ProposalDetails<
 /// Proposal details provide voters the information required for the perceived voting.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Clone, PartialEq, Debug)]
-pub enum ProposalDetails<
-    MintedBalance,
-    CurrencyBalance,
-    BlockNumber,
-    AccountId,
-    StakeBalance,
-    WorkerId,
-> {
+pub enum ProposalDetails<BlockNumber, AccountId, Balance, WorkerId> {
     /// The text of the `text` proposal
     Text(Vec<u8>),
 
@@ -43,45 +34,38 @@ pub enum ProposalDetails<
     RuntimeUpgrade(Vec<u8>),
 
     /// Balance and destination account for the `spending` proposal
-    Spending(MintedBalance, AccountId),
+    Spending(Balance, AccountId),
 
     /// Validator count for the `set validator count` proposal
     SetValidatorCount(u32),
 
     /// Add opening for the working group leader position.
-    AddWorkingGroupLeaderOpening(AddOpeningParameters<BlockNumber, CurrencyBalance>),
+    AddWorkingGroupLeaderOpening(AddOpeningParameters<BlockNumber, Balance>),
 
     /// Fill opening for the working group leader position.
     FillWorkingGroupLeaderOpening(FillOpeningParameters),
 
     /// Set working group budget capacity.
-    SetWorkingGroupBudgetCapacity(MintedBalance, WorkingGroup),
+    SetWorkingGroupBudgetCapacity(Balance, WorkingGroup),
 
     /// Decrease the working group leader stake.
-    DecreaseWorkingGroupLeaderStake(WorkerId, StakeBalance, WorkingGroup),
+    DecreaseWorkingGroupLeaderStake(WorkerId, Balance, WorkingGroup),
 
     /// Slash the working group leader stake.
-    SlashWorkingGroupLeaderStake(WorkerId, Penalty<StakeBalance>, WorkingGroup),
+    SlashWorkingGroupLeaderStake(WorkerId, Penalty<Balance>, WorkingGroup),
 
     /// Set working group leader reward balance.
-    SetWorkingGroupLeaderReward(WorkerId, Option<MintedBalance>, WorkingGroup),
+    SetWorkingGroupLeaderReward(WorkerId, Option<Balance>, WorkingGroup),
 
     /// Fire the working group leader with possible slashing.
-    TerminateWorkingGroupLeaderRole(TerminateRoleParameters<WorkerId, StakeBalance>),
+    TerminateWorkingGroupLeaderRole(TerminateRoleParameters<WorkerId, Balance>),
 
     /// Amend constitution.
     AmendConstitution(Vec<u8>),
 }
 
-impl<MintedBalance, CurrencyBalance, BlockNumber, AccountId, StakeBalance, WorkerId> Default
-    for ProposalDetails<
-        MintedBalance,
-        CurrencyBalance,
-        BlockNumber,
-        AccountId,
-        StakeBalance,
-        WorkerId,
-    >
+impl<BlockNumber, AccountId, Balance, WorkerId> Default
+    for ProposalDetails<BlockNumber, AccountId, Balance, WorkerId>
 {
     fn default() -> Self {
         ProposalDetails::Text(b"invalid proposal details".to_vec())

+ 0 - 2
runtime-modules/proposals/engine/Cargo.toml

@@ -29,8 +29,6 @@ referendum = { package = 'pallet-referendum', default-features = false, path = '
 sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 council = { package = 'pallet-council', default-features = false, path = '../../council'}
-recurringrewards = { package = 'pallet-recurring-reward', default-features = false, path = '../../recurring-reward'}
-minting = { package = 'pallet-token-mint', default-features = false, path = '../../token-minting'}
 membership = { package = 'pallet-membership', default-features = false, path = '../../membership'}
 referendum = { package = 'pallet-referendum', default-features = false, path = '../../referendum'}
 

+ 0 - 15
runtime-modules/proposals/engine/src/tests/mock/mod.rs

@@ -142,10 +142,6 @@ impl balances::Trait for Test {
     type MaxLocks = ();
 }
 
-impl common::currency::GovernanceCurrency for Test {
-    type Currency = balances::Module<Self>;
-}
-
 impl proposals::Trait for Test {}
 
 parameter_types! {
@@ -352,17 +348,6 @@ impl council::Trait for Test {
     fn new_council_elected(_: &[council::CouncilMemberOf<Self>]) {}
 }
 
-impl recurringrewards::Trait for Test {
-    type PayoutStatusHandler = ();
-    type RecipientId = u64;
-    type RewardRelationshipId = u64;
-}
-
-impl minting::Trait for Test {
-    type Currency = Balances;
-    type MintId = u64;
-}
-
 impl LockComparator<<Test as balances::Trait>::Balance> for Test {
     fn are_locks_conflicting(new_lock: &LockIdentifier, existing_locks: &[LockIdentifier]) -> bool {
         existing_locks.iter().any(|l| l == new_lock)

+ 14 - 38
runtime-modules/proposals/engine/src/tests/mod.rs

@@ -16,10 +16,7 @@ use frame_system::{EventRecord, Phase};
 pub(crate) fn increase_total_balance_issuance_using_account_id(account_id: u64, balance: u64) {
     let initial_balance = Balances::total_issuance();
     {
-        let _ = <Test as common::currency::GovernanceCurrency>::Currency::deposit_creating(
-            &account_id,
-            balance,
-        );
+        let _ = Balances::deposit_creating(&account_id, balance);
     }
     assert_eq!(Balances::total_issuance(), initial_balance + balance);
 }
@@ -1042,10 +1039,7 @@ fn create_dummy_proposal_succeeds_with_stake() {
             .with_account_id(account_id)
             .with_stake(account_id);
 
-        let _imbalance = <Test as common::currency::GovernanceCurrency>::Currency::deposit_creating(
-            &account_id,
-            500,
-        );
+        let _imbalance = Balances::deposit_creating(&account_id, 500);
 
         let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
 
@@ -1166,19 +1160,13 @@ fn finalize_expired_proposal_and_check_stake_removing_with_balance_checks_succee
             .with_stake(1);
 
         let account_balance = 500;
-        let _imbalance = <Test as common::currency::GovernanceCurrency>::Currency::deposit_creating(
-            &account_id,
-            account_balance,
-        );
+        let _imbalance = Balances::deposit_creating(&account_id, account_balance);
 
-        assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::usable_balance(&account_id),
-            account_balance
-        );
+        assert_eq!(Balances::usable_balance(&account_id), account_balance);
 
         let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
         assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::usable_balance(&account_id),
+            Balances::usable_balance(&account_id),
             account_balance - stake_amount
         );
 
@@ -1206,7 +1194,7 @@ fn finalize_expired_proposal_and_check_stake_removing_with_balance_checks_succee
 
         let rejection_fee = RejectionFee::get();
         assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::usable_balance(&account_id),
+            Balances::usable_balance(&account_id),
             account_balance - rejection_fee
         );
     });
@@ -1238,19 +1226,13 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() {
             .with_stake(1);
 
         let account_balance = 500;
-        let _imbalance = <Test as common::currency::GovernanceCurrency>::Currency::deposit_creating(
-            &account_id,
-            account_balance,
-        );
+        let _imbalance = Balances::deposit_creating(&account_id, account_balance);
 
-        assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::usable_balance(&account_id),
-            account_balance
-        );
+        assert_eq!(Balances::usable_balance(&account_id), account_balance);
 
         let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
         assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::usable_balance(&account_id),
+            Balances::usable_balance(&account_id),
             account_balance - stake_amount
         );
 
@@ -1282,7 +1264,7 @@ fn proposal_cancellation_with_slashes_with_balance_checks_succeeds() {
 
         let cancellation_fee = CancellationFee::get();
         assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::total_balance(&account_id),
+            Balances::total_balance(&account_id),
             account_balance - cancellation_fee
         );
     });
@@ -1316,20 +1298,14 @@ fn proposal_slashing_succeeds() {
             .with_account_id(account_id.clone())
             .with_stake(account_id);
 
-        assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::total_balance(&account_id),
-            initial_balance
-        );
+        assert_eq!(Balances::total_balance(&account_id), initial_balance);
 
         let proposal_id = dummy_proposal.create_proposal_and_assert(Ok(1)).unwrap();
 
-        assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::total_balance(&account_id),
-            initial_balance
-        );
+        assert_eq!(Balances::total_balance(&account_id), initial_balance);
 
         assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::usable_balance(&account_id),
+            Balances::usable_balance(&account_id),
             initial_balance - stake_amount
         );
 
@@ -1344,7 +1320,7 @@ fn proposal_slashing_succeeds() {
         assert!(!<crate::Proposals<Test>>::contains_key(proposal_id));
 
         assert_eq!(
-            <Test as common::currency::GovernanceCurrency>::Currency::total_balance(&account_id),
+            Balances::total_balance(&account_id),
             initial_balance - stake_amount
         );