Sfoglia il codice sorgente

runtime: Drop the obsolete ‘token-minting’ pallet.

Shamil Gadelshin 4 anni fa
parent
commit
856a24e7cf

+ 0 - 14
Cargo.lock

@@ -4206,20 +4206,6 @@ dependencies = [
  "sp-timestamp",
 ]
 
-[[package]]
-name = "pallet-token-mint"
-version = "3.1.0"
-dependencies = [
- "frame-support",
- "frame-system",
- "pallet-balances",
- "parity-scale-codec",
- "sp-arithmetic",
- "sp-core",
- "sp-io",
- "sp-runtime",
-]
-
 [[package]]
 name = "pallet-transaction-payment"
 version = "2.0.0"

+ 0 - 1
Cargo.toml

@@ -12,7 +12,6 @@ members = [
 	"runtime-modules/referendum",
 	"runtime-modules/service-discovery",
 	"runtime-modules/storage",
-	"runtime-modules/token-minting",
 	"runtime-modules/working-group",
 	"runtime-modules/content-directory",
 	"runtime-modules/constitution",

+ 0 - 27
runtime-modules/token-minting/Cargo.toml

@@ -1,27 +0,0 @@
-[package]
-name = 'pallet-token-mint'
-version = '3.1.0'
-authors = ['Joystream contributors']
-edition = '2018'
-
-[dependencies]
-codec = { package = 'parity-scale-codec', version = '1.3.4', default-features = false, features = ['derive'] }
-sp-arithmetic = { package = 'sp-arithmetic', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-frame-support = { package = 'frame-support', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-frame-system = { package = 'frame-system', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-
-[dev-dependencies]
-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'}
-balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
-
-[features]
-default = ['std']
-std = [
-	'codec/std',
-	'sp-arithmetic/std',
-	'sp-runtime/std',
-	'frame-support/std',
-	'frame-system/std',
-]

+ 0 - 291
runtime-modules/token-minting/src/lib.rs

@@ -1,291 +0,0 @@
-// Clippy linter warning
-#![allow(clippy::type_complexity)]
-// disable it because of possible frontend API break
-// TODO: remove post-Constaninople
-
-// Ensure we're `no_std` when compiling for Wasm.
-#![cfg_attr(not(feature = "std"), no_std)]
-
-use codec::{Codec, Decode, Encode};
-use frame_support::storage::IterableStorageMap;
-use frame_support::traits::Currency;
-use frame_support::{decl_module, decl_storage, ensure, Parameter};
-use sp_arithmetic::traits::{BaseArithmetic, One, Zero};
-use sp_runtime::traits::{MaybeSerialize, Member};
-
-mod mint;
-mod mock;
-mod tests;
-
-pub use mint::*;
-
-pub trait Trait: frame_system::Trait {
-    /// The currency to mint.
-    type Currency: Currency<Self::AccountId>;
-
-    /// The type used as a mint identifier.
-    type MintId: Parameter
-        + Member
-        + BaseArithmetic
-        + Codec
-        + Default
-        + Copy
-        + MaybeSerialize
-        + PartialEq;
-}
-
-pub type BalanceOf<T> =
-    <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
-
-#[derive(PartialEq, Eq, Debug)]
-pub enum GeneralError {
-    MintNotFound,
-    NextAdjustmentInPast,
-}
-
-/// Errors that can arise from attempt to mint and transfer tokens from a mint to
-/// an account.
-#[derive(PartialEq, Eq, Debug)]
-pub enum TransferError {
-    MintNotFound,
-    NotEnoughCapacity,
-}
-
-/// Errors that can arise from attempt to transfer capacity between mints.
-#[derive(PartialEq, Eq, Debug)]
-pub enum CapacityTransferError {
-    SourceMintNotFound,
-    DestinationMintNotFound,
-    NotEnoughCapacity,
-}
-
-impl From<MintingError> for CapacityTransferError {
-    fn from(err: MintingError) -> CapacityTransferError {
-        match err {
-            MintingError::NotEnoughCapacity => CapacityTransferError::NotEnoughCapacity,
-        }
-    }
-}
-
-impl From<MintingError> for TransferError {
-    fn from(err: MintingError) -> TransferError {
-        match err {
-            MintingError::NotEnoughCapacity => TransferError::NotEnoughCapacity,
-        }
-    }
-}
-
-impl From<GeneralError> for &'static str {
-    fn from(err: GeneralError) -> &'static str {
-        match err {
-            GeneralError::MintNotFound => "MintNotFound",
-            GeneralError::NextAdjustmentInPast => "NextAdjustmentInPast",
-        }
-    }
-}
-
-impl From<TransferError> for &'static str {
-    fn from(err: TransferError) -> &'static str {
-        match err {
-            TransferError::MintNotFound => "MintNotFound",
-            TransferError::NotEnoughCapacity => "NotEnoughCapacity",
-        }
-    }
-}
-
-#[derive(Encode, Decode, Copy, Clone, Debug, Eq, PartialEq)]
-pub enum Adjustment<Balance: Zero, BlockNumber> {
-    // First adjustment will be after AdjustOnInterval.block_interval
-    Interval(AdjustOnInterval<Balance, BlockNumber>),
-    // First Adjustment will be at absolute blocknumber
-    IntervalAfterFirstAdjustmentAbsolute(AdjustOnInterval<Balance, BlockNumber>, BlockNumber),
-    // First Adjustment will be after a specified number of blocks
-    IntervalAfterFirstAdjustmentRelative(AdjustOnInterval<Balance, BlockNumber>, BlockNumber),
-}
-
-decl_storage! {
-    trait Store for Module<T: Trait> as TokenMint {
-        /// Mints
-        pub Mints get(fn mints) : map hasher(blake2_128_concat) T::MintId => Mint<BalanceOf<T>, T::BlockNumber>;
-
-        /// The number of mints created.
-        pub MintsCreated get(fn mints_created): T::MintId;
-    }
-}
-// pub Account: map hasher(blake2_128_concat) T::AccountId => AccountData<T::Balance>;
-decl_module! {
-    pub struct Module<T: Trait> for enum Call where origin: T::Origin {
-        fn on_finalize(now: T::BlockNumber) {
-            Self::update_mints(now);
-        }
-    }
-}
-
-impl<T: Trait> Module<T> {
-    fn update_mints(now: T::BlockNumber) {
-        // Are we reading value from storage twice?
-        for (mint_id, ref mut mint) in <Mints<T>>::iter() {
-            if mint.maybe_do_capacity_adjustment(now) {
-                <Mints<T>>::insert(&mint_id, mint);
-            }
-        }
-    }
-
-    /// Adds a new mint with given settings to mints, and returns new MintId.
-    pub fn add_mint(
-        initial_capacity: BalanceOf<T>,
-        adjustment: Option<Adjustment<BalanceOf<T>, T::BlockNumber>>,
-    ) -> Result<T::MintId, GeneralError> {
-        let now = <frame_system::Module<T>>::block_number();
-
-        // Ensure the next adjustment if set, is in the future
-        if let Some(adjustment) = adjustment {
-            if let Adjustment::IntervalAfterFirstAdjustmentAbsolute(_, first_adjustment_in) =
-                adjustment
-            {
-                ensure!(
-                    first_adjustment_in > now,
-                    GeneralError::NextAdjustmentInPast
-                );
-            }
-        }
-
-        // Determine next adjutment
-        let next_adjustment = adjustment.map(|adjustment| match adjustment {
-            Adjustment::Interval(adjust_on_interval) => NextAdjustment {
-                at_block: now + adjust_on_interval.block_interval,
-                adjustment: adjust_on_interval,
-            },
-            Adjustment::IntervalAfterFirstAdjustmentAbsolute(
-                adjust_on_interval,
-                first_adjustment_at,
-            ) => NextAdjustment {
-                adjustment: adjust_on_interval,
-                at_block: first_adjustment_at,
-            },
-            Adjustment::IntervalAfterFirstAdjustmentRelative(
-                adjust_on_interval,
-                first_adjustment_after,
-            ) => NextAdjustment {
-                adjustment: adjust_on_interval,
-                at_block: now + first_adjustment_after,
-            },
-        });
-
-        // get next mint_id and increment total number of mints created
-        let mint_id = Self::mints_created();
-        <MintsCreated<T>>::put(mint_id + One::one());
-
-        <Mints<T>>::insert(mint_id, Mint::new(initial_capacity, next_adjustment, now));
-
-        Ok(mint_id)
-    }
-
-    /// Removes a mint. Passing a non existent mint has no side effects.
-    pub fn remove_mint(mint_id: T::MintId) {
-        <Mints<T>>::remove(&mint_id);
-    }
-
-    /// Tries to transfer exact requested amount from mint to a recipient account id.
-    /// Returns error if amount exceeds mint capacity or the specified mint doesn't exist.
-    /// Transfering amount of zero has no side effects. Return nothing on success.
-    pub fn transfer_tokens(
-        mint_id: T::MintId,
-        requested_amount: BalanceOf<T>,
-        recipient: &T::AccountId,
-    ) -> Result<(), TransferError> {
-        if requested_amount == Zero::zero() {
-            return Ok(());
-        }
-
-        ensure!(
-            <Mints<T>>::contains_key(&mint_id),
-            TransferError::MintNotFound
-        );
-
-        let mut mint = Self::mints(&mint_id);
-
-        // Try minting
-        mint.mint_tokens(requested_amount)?;
-
-        <Mints<T>>::insert(&mint_id, mint);
-
-        // Deposit into recipient account
-        T::Currency::deposit_creating(recipient, requested_amount);
-
-        Ok(())
-    }
-
-    /// Provided mint exists, sets its capacity to specied value, return error otherwise.
-    pub fn set_mint_capacity(
-        mint_id: T::MintId,
-        capacity: BalanceOf<T>,
-    ) -> Result<(), GeneralError> {
-        ensure!(
-            <Mints<T>>::contains_key(&mint_id),
-            GeneralError::MintNotFound
-        );
-
-        <Mints<T>>::mutate(&mint_id, |mint| {
-            mint.set_capacity(capacity);
-        });
-
-        Ok(())
-    }
-
-    /// Provided source and destination mints exist, will attempt to transfer capacity from the source mint
-    /// to the destination mint. Will return errors on non-existence of
-    /// mints or capacity_to_transfer exceeds the source mint's capacity.
-    pub fn transfer_capacity(
-        source: T::MintId,
-        destination: T::MintId,
-        capacity_to_transfer: BalanceOf<T>,
-    ) -> Result<(), CapacityTransferError> {
-        ensure!(
-            <Mints<T>>::contains_key(&source),
-            CapacityTransferError::SourceMintNotFound
-        );
-        ensure!(
-            <Mints<T>>::contains_key(&destination),
-            CapacityTransferError::DestinationMintNotFound
-        );
-
-        <Mints<T>>::mutate(&source, |source_mint| {
-            <Mints<T>>::mutate(&destination, |destination_mint| {
-                source_mint.transfer_capacity_to(destination_mint, capacity_to_transfer)
-            })
-        })?;
-
-        Ok(())
-    }
-
-    /// Returns a mint's capacity if it exists, error otherwise.
-    pub fn get_mint_capacity(mint_id: T::MintId) -> Result<BalanceOf<T>, GeneralError> {
-        ensure!(
-            <Mints<T>>::contains_key(&mint_id),
-            GeneralError::MintNotFound
-        );
-        let mint = Self::mints(&mint_id);
-
-        Ok(mint.capacity())
-    }
-
-    /// Returns a mint's adjustment policy if it exists, error otherwise.
-    pub fn get_mint_next_adjustment(
-        mint_id: T::MintId,
-    ) -> Result<Option<NextAdjustment<BalanceOf<T>, T::BlockNumber>>, GeneralError> {
-        ensure!(
-            <Mints<T>>::contains_key(&mint_id),
-            GeneralError::MintNotFound
-        );
-
-        let mint = Self::mints(&mint_id);
-
-        Ok(mint.next_adjustment())
-    }
-
-    /// Returns true if a mint exists.
-    pub fn mint_exists(mint_id: T::MintId) -> bool {
-        <Mints<T>>::contains_key(&mint_id)
-    }
-}

+ 0 - 153
runtime-modules/token-minting/src/mint.rs

@@ -1,153 +0,0 @@
-use codec::{Decode, Encode};
-use frame_support::ensure;
-use sp_arithmetic::traits::{BaseArithmetic, Zero};
-
-#[derive(Encode, Decode, Copy, Clone, Debug, Eq, PartialEq)]
-pub enum AdjustCapacityBy<Balance: Zero> {
-    /// Set capacity of mint to specific value
-    Setting(Balance),
-    /// Add to the capacity of the mint
-    Adding(Balance),
-    /// Reduce capacity of the mint
-    Reducing(Balance),
-}
-
-#[derive(Encode, Decode, Copy, Clone, Debug, Eq, PartialEq)]
-pub struct AdjustOnInterval<Balance: Zero, BlockNumber> {
-    pub block_interval: BlockNumber,
-    pub adjustment_type: AdjustCapacityBy<Balance>,
-}
-
-#[derive(Encode, Decode, Copy, Clone, Debug, Eq, PartialEq)]
-pub struct NextAdjustment<Balance: Zero, BlockNumber> {
-    pub adjustment: AdjustOnInterval<Balance, BlockNumber>,
-    pub at_block: BlockNumber,
-}
-
-#[derive(Encode, Decode, Default, Copy, Clone)]
-// Note we don't use TokenMint<T: Trait> it breaks the Default derivation macro with error T doesn't impl Default
-// Which requires manually implementing Default trait.
-// We want Default trait on TokenMint so we can use it as value in StorageMap without needing to wrap it in an Option
-pub struct Mint<Balance, BlockNumber>
-where
-    Balance: Copy + BaseArithmetic + Zero,
-    BlockNumber: Copy + BaseArithmetic,
-{
-    capacity: Balance,
-
-    // Whether there is an upcoming block where an adjustment to the mint will be made
-    // When this is not set, the mint is effectively paused.
-    next_adjustment: Option<NextAdjustment<Balance, BlockNumber>>,
-
-    created_at: BlockNumber,
-
-    total_minted: Balance,
-}
-
-#[derive(PartialEq, Eq, Debug)]
-pub enum MintingError {
-    NotEnoughCapacity,
-}
-
-impl<Balance, BlockNumber> Mint<Balance, BlockNumber>
-where
-    Balance: Copy + BaseArithmetic + Zero,
-    BlockNumber: Copy + BaseArithmetic,
-{
-    pub fn new(
-        initial_capacity: Balance,
-        next_adjustment: Option<NextAdjustment<Balance, BlockNumber>>,
-        now: BlockNumber,
-    ) -> Self {
-        Mint {
-            capacity: initial_capacity,
-            created_at: now,
-            total_minted: Zero::zero(),
-            next_adjustment,
-        }
-    }
-
-    pub fn mint_tokens(&mut self, requested_amount: Balance) -> Result<(), MintingError> {
-        ensure!(
-            self.capacity >= requested_amount,
-            MintingError::NotEnoughCapacity
-        );
-        self.capacity -= requested_amount;
-        self.total_minted += requested_amount;
-        Ok(())
-    }
-
-    pub fn set_capacity(&mut self, new_capacity: Balance) {
-        self.capacity = new_capacity;
-    }
-
-    pub fn capacity(&self) -> Balance {
-        self.capacity
-    }
-
-    pub fn can_mint(&self, amount: Balance) -> bool {
-        self.capacity >= amount
-    }
-
-    pub fn created_at(&self) -> BlockNumber {
-        self.created_at
-    }
-
-    pub fn total_minted(&self) -> Balance {
-        self.total_minted
-    }
-
-    pub fn transfer_capacity_to(
-        &mut self,
-        destination: &mut Self,
-        capacity_to_transfer: Balance,
-    ) -> Result<(), MintingError> {
-        ensure!(
-            self.capacity >= capacity_to_transfer,
-            MintingError::NotEnoughCapacity
-        );
-        self.capacity -= capacity_to_transfer;
-        destination.capacity += capacity_to_transfer;
-        Ok(())
-    }
-
-    pub fn next_adjustment(&self) -> Option<NextAdjustment<Balance, BlockNumber>> {
-        self.next_adjustment
-    }
-
-    pub fn maybe_do_capacity_adjustment(&mut self, now: BlockNumber) -> bool {
-        self.next_adjustment.map_or(false, |next_adjustment| {
-            if now != next_adjustment.at_block {
-                false
-            } else {
-                // update mint capacity
-                self.capacity = Self::adjusted_capacity(
-                    self.capacity,
-                    next_adjustment.adjustment.adjustment_type,
-                );
-
-                // set next adjustment
-                self.next_adjustment = Some(NextAdjustment {
-                    adjustment: next_adjustment.adjustment,
-                    at_block: now + next_adjustment.adjustment.block_interval,
-                });
-
-                true
-            }
-        })
-    }
-
-    fn adjusted_capacity(capacity: Balance, adjustment_type: AdjustCapacityBy<Balance>) -> Balance {
-        match adjustment_type {
-            AdjustCapacityBy::Adding(amount) => capacity + amount,
-            AdjustCapacityBy::Setting(amount) => amount,
-            AdjustCapacityBy::Reducing(amount) => {
-                if amount > capacity {
-                    Zero::zero()
-                } else {
-                    capacity - amount
-                }
-            }
-        }
-    }
-}

+ 0 - 89
runtime-modules/token-minting/src/mock.rs

@@ -1,89 +0,0 @@
-#![cfg(test)]
-
-use crate::{Module, Trait};
-use balances;
-use frame_support::{impl_outer_origin, parameter_types};
-use sp_core::H256;
-use sp_runtime::{
-    testing::Header,
-    traits::{BlakeTwo256, IdentityLookup},
-    Perbill,
-};
-
-impl_outer_origin! {
-    pub enum Origin for Test {}
-}
-
-// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
-#[derive(Clone, PartialEq, Eq, Debug)]
-pub struct Test;
-parameter_types! {
-    pub const BlockHashCount: u64 = 250;
-    pub const MaximumBlockWeight: u32 = 1024;
-    pub const MaximumBlockLength: u32 = 2 * 1024;
-    pub const AvailableBlockRatio: Perbill = Perbill::one();
-}
-
-impl frame_system::Trait for Test {
-    type BaseCallFilter = ();
-    type Origin = Origin;
-    type Call = ();
-    type Index = u64;
-    type BlockNumber = u64;
-    type Hash = H256;
-    type Hashing = BlakeTwo256;
-    type AccountId = u64;
-    type Lookup = IdentityLookup<Self::AccountId>;
-    type Header = Header;
-    type Event = ();
-    type BlockHashCount = BlockHashCount;
-    type MaximumBlockWeight = MaximumBlockWeight;
-    type DbWeight = ();
-    type BlockExecutionWeight = ();
-    type ExtrinsicBaseWeight = ();
-    type MaximumExtrinsicWeight = ();
-    type MaximumBlockLength = MaximumBlockLength;
-    type AvailableBlockRatio = AvailableBlockRatio;
-    type Version = ();
-    type PalletInfo = ();
-    type AccountData = balances::AccountData<u64>;
-    type OnNewAccount = ();
-    type OnKilledAccount = ();
-    type SystemWeightInfo = ();
-}
-
-parameter_types! {
-    pub const ExistentialDeposit: u32 = 0;
-    pub const TransferFee: u32 = 0;
-    pub const CreationFee: u32 = 0;
-    pub const TransactionBaseFee: u32 = 1;
-    pub const TransactionByteFee: u32 = 0;
-    pub const MaxLocks: u32 = 50;
-}
-
-impl balances::Trait for Test {
-    type Balance = u64;
-    type DustRemoval = ();
-    type Event = ();
-    type ExistentialDeposit = ExistentialDeposit;
-    type AccountStore = System;
-    type WeightInfo = ();
-    type MaxLocks = MaxLocks;
-}
-
-impl Trait for Test {
-    type Currency = Balances;
-    type MintId = u64;
-}
-
-pub fn build_test_externalities() -> sp_io::TestExternalities {
-    let t = frame_system::GenesisConfig::default()
-        .build_storage::<Test>()
-        .unwrap();
-
-    t.into()
-}
-
-pub type System = frame_system::Module<Test>;
-pub type Balances = balances::Module<Test>;
-pub type Minting = Module<Test>;

+ 0 - 202
runtime-modules/token-minting/src/tests.rs

@@ -1,202 +0,0 @@
-#![cfg(test)]
-
-use super::*;
-use crate::mock::*;
-
-#[test]
-fn adding_and_removing_mints() {
-    build_test_externalities().execute_with(|| {
-        System::set_block_number(1);
-        let capacity: u64 = 5000;
-        let adjustment_amount: u64 = 500;
-
-        let adjustment = AdjustOnInterval {
-            adjustment_type: AdjustCapacityBy::Adding(adjustment_amount),
-            block_interval: 100,
-        };
-
-        let mint_id = Minting::add_mint(capacity, Some(Adjustment::Interval(adjustment)))
-            .ok()
-            .unwrap();
-        assert!(Minting::mint_exists(mint_id));
-
-        assert_eq!(Minting::get_mint_capacity(mint_id).ok().unwrap(), capacity);
-
-        assert_eq!(
-            Minting::get_mint_next_adjustment(mint_id),
-            Ok(Some(NextAdjustment {
-                adjustment,
-                at_block: 1 + 100,
-            }))
-        );
-
-        Minting::remove_mint(mint_id);
-        assert!(!Minting::mint_exists(mint_id));
-    });
-}
-
-#[test]
-fn minting() {
-    build_test_externalities().execute_with(|| {
-        let capacity: u64 = 5000;
-
-        let mint_id = Minting::add_mint(capacity, None).ok().unwrap();
-
-        assert!(Minting::transfer_tokens(mint_id, 1000, &1).is_ok());
-
-        assert_eq!(Balances::free_balance(&1), 1000);
-
-        assert_eq!(Minting::get_mint_capacity(mint_id).ok().unwrap(), 4000);
-    });
-}
-
-#[test]
-fn minting_exact() {
-    build_test_externalities().execute_with(|| {
-        let capacity: u64 = 1000;
-
-        let mint_id = Minting::add_mint(capacity, None).ok().unwrap();
-
-        assert_eq!(
-            Minting::transfer_tokens(mint_id, 2000, &1),
-            Err(TransferError::NotEnoughCapacity)
-        );
-    });
-}
-
-#[test]
-fn adjustment_adding() {
-    build_test_externalities().execute_with(|| {
-        System::set_block_number(0);
-        let capacity: u64 = 5000;
-        let adjustment_amount: u64 = 500;
-
-        let adjustment = AdjustOnInterval {
-            adjustment_type: AdjustCapacityBy::Adding(adjustment_amount),
-            block_interval: 100,
-        };
-
-        let mint_id = Minting::add_mint(capacity, Some(Adjustment::Interval(adjustment)))
-            .ok()
-            .unwrap();
-
-        Minting::update_mints(100);
-        assert_eq!(
-            Minting::get_mint_capacity(mint_id).ok().unwrap(),
-            capacity + (adjustment_amount * 1)
-        );
-
-        // no adjustments should happen
-        Minting::update_mints(100);
-        Minting::update_mints(140);
-        Minting::update_mints(199);
-
-        Minting::update_mints(200);
-        assert_eq!(
-            Minting::get_mint_capacity(mint_id).ok().unwrap(),
-            capacity + (adjustment_amount * 2)
-        );
-    });
-}
-
-#[test]
-fn adjustment_reducing() {
-    build_test_externalities().execute_with(|| {
-        System::set_block_number(0);
-        let capacity: u64 = 5000;
-        let adjustment_amount: u64 = 500;
-
-        let adjustment = AdjustOnInterval {
-            adjustment_type: AdjustCapacityBy::Reducing(adjustment_amount),
-            block_interval: 100,
-        };
-
-        let mint_id = Minting::add_mint(capacity, Some(Adjustment::Interval(adjustment)))
-            .ok()
-            .unwrap();
-
-        Minting::update_mints(100);
-        assert_eq!(
-            Minting::get_mint_capacity(mint_id).ok().unwrap(),
-            capacity - adjustment_amount
-        );
-
-        assert_eq!(
-            Minting::get_mint_capacity(mint_id).ok().unwrap(),
-            capacity - (adjustment_amount * 1)
-        );
-
-        // no adjustments should happen
-        Minting::update_mints(100);
-        Minting::update_mints(140);
-        Minting::update_mints(199);
-
-        Minting::update_mints(200);
-        assert_eq!(
-            Minting::get_mint_capacity(mint_id).ok().unwrap(),
-            capacity - (adjustment_amount * 2)
-        );
-    });
-}
-
-#[test]
-fn adjustment_setting() {
-    build_test_externalities().execute_with(|| {
-        System::set_block_number(0);
-        let capacity: u64 = 2000;
-        let setting_amount: u64 = 5000;
-
-        let adjustment = AdjustOnInterval {
-            adjustment_type: AdjustCapacityBy::Setting(setting_amount),
-            block_interval: 100,
-        };
-
-        let mint_id = Minting::add_mint(capacity, Some(Adjustment::Interval(adjustment)))
-            .ok()
-            .unwrap();
-
-        Minting::update_mints(100);
-        assert_eq!(
-            Minting::get_mint_capacity(mint_id).ok().unwrap(),
-            setting_amount
-        );
-    });
-}
-
-#[test]
-fn adjustment_first_interval() {
-    build_test_externalities().execute_with(|| {
-        System::set_block_number(0);
-        let capacity: u64 = 2000;
-        let amount: u64 = 500;
-
-        let adjustment = AdjustOnInterval {
-            adjustment_type: AdjustCapacityBy::Adding(amount),
-            block_interval: 100,
-        };
-
-        let mint_id = Minting::add_mint(
-            capacity,
-            Some(Adjustment::IntervalAfterFirstAdjustmentAbsolute(
-                adjustment, 1000,
-            )),
-        )
-        .ok()
-        .unwrap();
-
-        Minting::update_mints(100);
-        assert_eq!(Minting::get_mint_capacity(mint_id).ok().unwrap(), capacity);
-
-        Minting::update_mints(1000);
-        assert_eq!(
-            Minting::get_mint_capacity(mint_id).ok().unwrap(),
-            capacity + amount
-        );
-
-        Minting::update_mints(1100);
-        assert_eq!(
-            Minting::get_mint_capacity(mint_id).ok().unwrap(),
-            capacity + 2 * amount
-        );
-    });
-}

+ 4 - 7
runtime/src/tests/proposals_integration/working_group_proposals.rs

@@ -785,14 +785,13 @@ fn create_set_working_group_mint_capacity_proposal_execution_succeeds() {
 }
 
 fn run_create_set_working_group_mint_capacity_proposal_execution_succeeds<
-    T: working_group::Trait<I> + frame_system::Trait + minting::Trait,
+    T: working_group::Trait<I> + frame_system::Trait,
     I: frame_support::traits::Instance,
 >(
     working_group: WorkingGroup,
 ) where
     <T as frame_system::Trait>::AccountId: From<[u8; 32]>,
     <T as common::Trait>::MemberId: From<u64>,
-    <T as minting::Trait>::MintId: From<u64>,
     working_group::BalanceOf<T>: From<u128>,
 {
     initial_test_ext().execute_with(|| {
@@ -843,7 +842,7 @@ fn create_set_group_leader_reward_proposal_execution_succeeds() {
 }
 
 fn run_create_set_group_leader_reward_proposal_execution_succeeds<
-    T: working_group::Trait<I> + frame_system::Trait + minting::Trait,
+    T: working_group::Trait<I> + frame_system::Trait,
     I: frame_support::traits::Instance,
 >(
     working_group: WorkingGroup,
@@ -851,7 +850,6 @@ fn run_create_set_group_leader_reward_proposal_execution_succeeds<
     <T as frame_system::Trait>::AccountId: From<[u8; 32]>,
     <T as common::Trait>::MemberId: From<u64>,
     <T as common::Trait>::ActorId: Into<u64>,
-    <T as minting::Trait>::MintId: From<u64>,
     working_group::BalanceOf<T>: From<u128>,
 {
     initial_test_ext().execute_with(|| {
@@ -951,7 +949,7 @@ fn create_terminate_group_leader_role_proposal_execution_succeeds() {
 }
 
 fn run_create_terminate_group_leader_role_proposal_execution_succeeds<
-    T: working_group::Trait<I> + frame_system::Trait + minting::Trait,
+    T: working_group::Trait<I> + frame_system::Trait,
     I: frame_support::traits::Instance,
     SM: staking_handler::StakingHandler<
         <T as frame_system::Trait>::AccountId,
@@ -965,7 +963,6 @@ fn run_create_terminate_group_leader_role_proposal_execution_succeeds<
     <T as common::Trait>::MemberId: From<u64>,
     common::MemberId<T>: From<u64>,
     <T as common::Trait>::ActorId: Into<u64>,
-    <T as minting::Trait>::MintId: From<u64>,
     <T as pallet_balances::Trait>::Balance: From<u128>,
 {
     initial_test_ext().execute_with(|| {
@@ -1085,7 +1082,7 @@ fn create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds(
 }
 
 fn run_create_terminate_group_leader_role_proposal_with_slashing_execution_succeeds<
-    T: working_group::Trait<I> + frame_system::Trait + minting::Trait,
+    T: working_group::Trait<I> + frame_system::Trait,
     I: frame_support::traits::Instance,
     SM: staking_handler::StakingHandler<
         <T as frame_system::Trait>::AccountId,