git.delta.rocks / unique-network / refs/commits / b40985b366bf

difftreelog

Implement inflation pallet, unit, and integration tests

Greg Zaitsev2021-04-07parent: #26015a9.patch.diff
in: master

11 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,5 +1,7 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
+version = 3
+
 [[package]]
 name = "Inflector"
 version = "0.11.4"
@@ -3606,6 +3608,7 @@
  "pallet-contracts-primitives",
  "pallet-contracts-rpc-runtime-api",
  "pallet-grandpa",
+ "pallet-inflation",
  "pallet-nft",
  "pallet-randomness-collective-flip",
  "pallet-sudo",
@@ -3920,6 +3923,24 @@
 ]
 
 [[package]]
+name = "pallet-inflation"
+version = "3.0.0"
+dependencies = [
+ "frame-benchmarking",
+ "frame-support",
+ "frame-system",
+ "pallet-balances",
+ "pallet-randomness-collective-flip",
+ "pallet-timestamp",
+ "parity-scale-codec",
+ "serde",
+ "sp-core",
+ "sp-io",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
 name = "pallet-nft"
 version = "3.0.0"
 dependencies = [
addedpallets/inflation/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/pallets/inflation/Cargo.toml
@@ -0,0 +1,48 @@
+[package]
+authors = ['Substrate DevHub <https://github.com/substrate-developer-hub>']
+description = 'Unqiue pallet inflation'
+edition = '2018'
+homepage = 'https://substrate.io'
+license = 'Unlicense'
+name = 'pallet-inflation'
+repository = 'https://github.com/usetech-llc/nft_private/'
+version = '3.0.0'
+
+[package.metadata.docs.rs]
+targets = ['x86_64-unknown-linux-gnu']
+
+# alias "parity-scale-code" to "codec"
+[dependencies.codec]
+default-features = false
+features = ['derive']
+package = 'parity-scale-codec'
+version = '2.0.0'
+
+[dependencies]
+serde = { version = "1.0.119" }
+frame-support = { default-features = false, version = '3.0.0' }
+frame-system = { default-features = false, version = '3.0.0' }
+pallet-balances = { default-features = false, version = '3.0.0' }
+pallet-timestamp = { default-features = false, version = '3.0.0' }
+pallet-randomness-collective-flip = { default-features = false, version = '3.0.0' }
+sp-std = { default-features = false, version = '3.0.0' }
+frame-benchmarking = { default-features = false, version = "3.0.0", optional = true }
+sp-core = { default-features = false, version = '3.0.0' }
+sp-io = { default-features = false, version = '3.0.0' }
+sp-runtime = { default-features = false, version = '3.0.0' }
+
+[features]
+default = ['std']
+std = [
+    'codec/std',
+    'serde/std',
+    'frame-support/std',
+    'frame-system/std',
+    'pallet-balances/std',
+    'pallet-timestamp/std',
+    'pallet-randomness-collective-flip/std',
+    'sp-std/std',
+    'sp-runtime/std',
+    'frame-benchmarking/std',
+]
+runtime-benchmarks = ["frame-benchmarking"]
addedpallets/inflation/src/benchmarking.rsdiffbeforeafterboth
--- /dev/null
+++ b/pallets/inflation/src/benchmarking.rs
@@ -0,0 +1,19 @@
+#![cfg(feature = "runtime-benchmarks")]
+
+use super::*;
+use crate::Module as Inflation;
+
+use sp_std::prelude::*;
+use frame_system::RawOrigin;
+use frame_benchmarking::{benchmarks}; 
+use frame_support::traits::OnInitialize;
+
+benchmarks! {
+
+	on_initialize {
+        let block1: T::BlockNumber = T::BlockNumber::from(1u32);
+        let block2: T::BlockNumber = T::BlockNumber::from(2u32);
+        Inflation::<T>::on_initialize(block1); // Create Treasury account
+	}: { Inflation::<T>::on_initialize(block2); } // Benchmark deposit_into_existing path
+
+}
addedpallets/inflation/src/lib.rsdiffbeforeafterboth
--- /dev/null
+++ b/pallets/inflation/src/lib.rs
@@ -0,0 +1,130 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+#![recursion_limit = "1024"]
+
+#![cfg_attr(not(feature = "std"), no_std)]
+
+#[cfg(feature = "std")]
+pub use std::*;
+
+#[cfg(feature = "std")]
+pub use serde::*;
+
+#[cfg(feature = "runtime-benchmarks")]
+mod benchmarking;
+
+#[cfg(test)]
+mod tests;
+
+pub use frame_support::{
+    construct_runtime, decl_module, decl_storage,
+    ensure,
+    traits::{
+        Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,
+        Randomness, IsSubType, WithdrawReasons,
+    },
+    weights::{
+        constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
+        DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,
+        WeightToFeePolynomial, DispatchClass,
+    },
+    StorageValue,
+    transactional,
+};
+
+// #[cfg(feature = "runtime-benchmarks")]
+pub use frame_support::dispatch::DispatchResult;
+
+use sp_runtime::{
+	Perbill,
+    traits::{Zero}
+};
+use sp_std::convert::TryInto;
+
+use frame_system::{self as system};
+
+/// The balance type of this module.
+pub type BalanceOf<T> =
+	<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
+
+pub const YEAR: u32 = 5_259_600;
+pub const TOTAL_YEARS_UNTIL_FLAT: u32 = 9;
+pub const START_INFLATION_PERCENT: u32 = 10;
+pub const END_INFLATION_PERCENT: u32 = 4;
+
+pub trait Config: system::Config {
+    type Currency: Currency<Self::AccountId>;
+    type TreasuryAccountId: Get<Self::AccountId>;
+    type InflationBlockInterval: Get<Self::BlockNumber>;
+}
+
+decl_storage! {
+    trait Store for Module<T: Config> as Inflation {
+        /// starting year total issuance
+        pub StartingYearTotalIssuance get(fn starting_year_total_issuance): BalanceOf<T>;
+
+        /// Current block inflation
+        pub BlockInflation get(fn block_inflation): BalanceOf<T>;
+    }
+}
+
+decl_module! {
+    pub struct Module<T: Config> for enum Call 
+    where 
+        origin: T::Origin,
+    {
+        const InflationBlockInterval: T::BlockNumber = T::InflationBlockInterval::get();
+
+        fn on_initialize(now: T::BlockNumber) -> Weight 
+        {
+			let mut consumed_weight = 0;
+			let mut add_weight = |reads, writes, weight| {
+				consumed_weight += T::DbWeight::get().reads_writes(reads, writes);
+				consumed_weight += weight;
+			};
+
+            let block_interval: u32 = T::InflationBlockInterval::get().try_into().unwrap_or(0);
+
+            // Recalculate inflation on the first block of the year (or if it is not initialized yet)
+            if (now % T::BlockNumber::from(YEAR)).is_zero() || <BlockInflation<T>>::get().is_zero() {
+                let current_year: u32 = (now / T::BlockNumber::from(YEAR)).try_into().unwrap_or(0);
+
+                let one_percent = Perbill::from_percent(1);
+
+                if current_year <= TOTAL_YEARS_UNTIL_FLAT {
+                    let amount: BalanceOf<T> = Perbill::from_rational_approximation(
+                        block_interval * (START_INFLATION_PERCENT * TOTAL_YEARS_UNTIL_FLAT - current_year * (START_INFLATION_PERCENT - END_INFLATION_PERCENT)), 
+                        YEAR * TOTAL_YEARS_UNTIL_FLAT
+                    ) * ( one_percent * T::Currency::total_issuance() );
+                    <BlockInflation<T>>::put(amount);
+                }
+                else {
+                    let amount: BalanceOf<T> = Perbill::from_rational_approximation(
+                        block_interval * END_INFLATION_PERCENT, 
+                        YEAR
+                    ) * (one_percent * T::Currency::total_issuance());
+                    <BlockInflation<T>>::put(amount);
+                }
+                <StartingYearTotalIssuance<T>>::set(T::Currency::total_issuance());
+
+                // First time deposit
+                T::Currency::deposit_creating(&T::TreasuryAccountId::get(), <BlockInflation<T>>::get());
+
+                add_weight(7, 6, 28_300_000);
+            }
+
+            // Apply inflation every InflationBlockInterval blocks and in the 1st block to initialize Treasury account
+            else if (now % T::BlockNumber::from(block_interval)).is_zero() {
+                T::Currency::deposit_into_existing(&T::TreasuryAccountId::get(), <BlockInflation<T>>::get()).ok();
+
+                add_weight(3, 2, 12_900_000);
+            }
+
+            consumed_weight
+        }
+
+    }
+}
addedpallets/inflation/src/tests.rsdiffbeforeafterboth
--- /dev/null
+++ b/pallets/inflation/src/tests.rs
@@ -0,0 +1,192 @@
+#[cfg(test)]
+mod tests {
+	use crate as pallet_inflation;
+
+    use frame_system;
+	use frame_support::{traits::{Currency}, parameter_types};
+    use frame_support::{traits::OnInitialize};
+	use sp_core::H256;
+	use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
+
+	type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
+	type Block = frame_system::mocking::MockBlock<Test>;
+
+    const YEAR: u64 = 5_259_600;
+
+    parameter_types! {
+        pub const ExistentialDeposit: u64 = 1;
+        pub const MaxLocks: u32 = 50;
+    }
+    
+    impl pallet_balances::Config for Test {
+        type AccountStore = System;
+        type Balance = u64;
+        type DustRemoval = ();
+        type Event = ();
+        type ExistentialDeposit = ExistentialDeposit;
+        type WeightInfo = ();
+        type MaxLocks = MaxLocks;
+    }
+    
+	frame_support::construct_runtime!(
+		pub enum Test where
+			Block = Block,
+			NodeBlock = Block,
+			UncheckedExtrinsic = UncheckedExtrinsic,
+		{
+            Balances: pallet_balances::{Module, Call, Storage},
+			System: frame_system::{Module, Call, Config, Storage, Event<T>},
+			Inflation: pallet_inflation::{Module, Call, Storage},
+		}
+	);
+
+	parameter_types! {
+		pub const BlockHashCount: u64 = 250;
+		pub BlockWeights: frame_system::limits::BlockWeights =
+			frame_system::limits::BlockWeights::simple_max(1024);
+        pub const SS58Prefix: u8 = 42;
+    }
+
+    impl frame_system::Config for Test {
+        type BaseCallFilter = ();
+        type BlockWeights = ();
+        type BlockLength = ();
+        type DbWeight = ();
+        type Origin = Origin;
+        type Call = 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 Version = ();
+        type PalletInfo = PalletInfo;
+        type AccountData = pallet_balances::AccountData<u64>;
+        type OnNewAccount = ();
+        type OnKilledAccount = ();
+        type SystemWeightInfo = ();
+        type SS58Prefix = SS58Prefix;
+    }
+
+    parameter_types! {
+        pub TreasuryAccountId: u64 = 1234;
+        pub const InflationBlockInterval: u32 = 100; // every time per how many blocks inflation is applied
+    }
+        
+    impl pallet_inflation::Config for Test {
+        type Currency = Balances;
+        type TreasuryAccountId = TreasuryAccountId;
+        type InflationBlockInterval = InflationBlockInterval;
+    }
+
+    // Build genesis storage according to the mock runtime.
+    pub fn new_test_ext() -> sp_io::TestExternalities {
+        frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
+    }
+
+    #[test]
+	fn inflation_works() {
+		new_test_ext().execute_with(|| {
+            // Total issuance = 1_000_000_000
+            let initial_issuance: u64 = 1_000_000_000;
+            let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+            assert_eq!(Balances::free_balance(1234), initial_issuance);
+
+            // BlockInflation should be set after 1st block and 
+            // first inflation deposit should be equal to BlockInflation
+            Inflation::on_initialize(1);
+            assert!(Inflation::block_inflation() > 0);
+            assert_eq!(Balances::free_balance(1234) - initial_issuance, Inflation::block_inflation());
+		});
+	}
+
+    #[test]
+	fn inflation_second_deposit() {
+		new_test_ext().execute_with(|| {
+            // Total issuance = 1_000_000_000
+            let initial_issuance: u64 = 1_000_000_000;
+            let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+            assert_eq!(Balances::free_balance(1234), initial_issuance);
+			Inflation::on_initialize(1);
+
+            // Next inflation deposit happens when block is multiple of InflationBlockInterval
+            let mut block: u32 = 2;
+            let balance_before: u64 = Balances::free_balance(1234);
+            while block % InflationBlockInterval::get() != 0 {
+                Inflation::on_initialize(block as u64);
+                block += 1;
+            }
+            let balance_just_before: u64 = Balances::free_balance(1234);
+            assert_eq!(balance_before, balance_just_before);
+
+            // The block with inflation
+            Inflation::on_initialize(block as u64);
+            let balance_after: u64 = Balances::free_balance(1234);
+            assert_eq!(balance_after - balance_just_before, Inflation::block_inflation());
+		});
+	}
+
+    #[test]
+	fn inflation_in_1_year() {
+		new_test_ext().execute_with(|| {
+            // Total issuance = 1_000_000_000
+            let initial_issuance: u64 = 1_000_000_000;
+            let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+            assert_eq!(Balances::free_balance(1234), initial_issuance);
+			Inflation::on_initialize(1);
+            let block_inflation_year_0 = Inflation::block_inflation();
+
+            Inflation::on_initialize(YEAR);
+            let block_inflation_year_1 = Inflation::block_inflation();
+
+            // Assert that year 1 inflation is less than year 0
+            assert!(block_inflation_year_0 > block_inflation_year_1);
+		});
+	}
+
+    #[test]
+	fn inflation_in_1_to_9_years() {
+		new_test_ext().execute_with(|| {
+            // Total issuance = 1_000_000_000
+            let initial_issuance: u64 = 1_000_000_000;
+            let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+            assert_eq!(Balances::free_balance(1234), initial_issuance);
+            Inflation::on_initialize(1);
+
+            for year in 1..=9 {
+                let block_inflation_year_before = Inflation::block_inflation();
+                Inflation::on_initialize(YEAR * year);
+                let block_inflation_year_after = Inflation::block_inflation();
+
+                // Assert that next year inflation is less than previous year inflation
+                assert!(block_inflation_year_before > block_inflation_year_after);
+            }
+
+		});
+	}
+
+    #[test]
+	fn inflation_after_year_10_is_flat() {
+		new_test_ext().execute_with(|| {
+            // Total issuance = 1_000_000_000
+            let initial_issuance: u64 = 1_000_000_000;
+            let _ = <Balances as Currency<_>>::deposit_creating(&1234, initial_issuance);
+            assert_eq!(Balances::free_balance(1234), initial_issuance);
+            Inflation::on_initialize(YEAR * 9);
+
+            for year in 10..=20 {
+                let block_inflation_year_before = Inflation::block_inflation();
+                Inflation::on_initialize(YEAR * year);
+                let block_inflation_year_after = Inflation::block_inflation();
+
+                // Assert that next year inflation is equal to previous year inflation
+                assert_eq!(block_inflation_year_before, block_inflation_year_after);
+            }
+		});
+	}
+
+}
modifiedpallets/nft/src/benchmarking.rsdiffbeforeafterboth
before · pallets/nft/src/benchmarking.rs
1#[cfg(feature = "runtime-benchmarks")]2// mod benchmarking {3    use super::*;4    use sp_std::prelude::*;5    use frame_system::RawOrigin;6    // use frame_support::{ensure, traits::OnFinalize};7    use frame_benchmarking::{benchmarks, account, whitelisted_caller};  // , TrackedStorageKey, 8    use crate::Module as Nft;910    const SEED: u32 = 1;1112    fn default_nft_data() -> CreateItemData {13        CreateItemData::NFT(CreateNftData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1] })14    }15    16    fn default_fungible_data () -> CreateItemData {17        CreateItemData::Fungible(CreateFungibleData { })18    }19    20    fn default_re_fungible_data () -> CreateItemData {21        CreateItemData::ReFungible(CreateReFungibleData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1] })22    }232425    benchmarks! {2627        _ {}2829        create_collection {30            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();31            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();32            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();33            let mode: CollectionMode = CollectionMode::NFT;34            let caller: T::AccountId = account("caller", 0, SEED);35        }: create_collection(RawOrigin::Signed(caller.clone()), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode)36        verify {37			assert_eq!(Nft::<T>::collection(2).owner, caller);38        }3940        destroy_collection {41            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();42            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();43            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();44            let mode: CollectionMode = CollectionMode::NFT;45            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());46            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;47        }: destroy_collection(RawOrigin::Signed(caller.clone()), 2)4849        add_to_white_list {50            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();51            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();52            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();53            let mode: CollectionMode = CollectionMode::NFT;54            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());55            let whitelist_account: T::AccountId = account("admin", 0, SEED);56            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;57        }: add_to_white_list(RawOrigin::Signed(caller.clone()), 2, whitelist_account)5859        remove_from_white_list {60            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();61            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();62            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();63            let mode: CollectionMode = CollectionMode::NFT;64            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());65            let whitelist_account: T::AccountId = account("admin", 0, SEED);66            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;67            Nft::<T>::add_to_white_list(RawOrigin::Signed(caller.clone()).into(), 2, whitelist_account.clone())?;68        }: remove_from_white_list(RawOrigin::Signed(caller.clone()), 2, whitelist_account)6970        set_public_access_mode {71            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();72            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();73            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();74            let mode: CollectionMode = CollectionMode::NFT;75            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());76            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;77        }: set_public_access_mode(RawOrigin::Signed(caller.clone()), 2, AccessMode::WhiteList)7879        set_mint_permission {80            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();81            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();82            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();83            let mode: CollectionMode = CollectionMode::NFT;84            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());85            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;86        }: set_mint_permission(RawOrigin::Signed(caller.clone()), 2, true)8788        change_collection_owner {89            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();90            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();91            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();92            let mode: CollectionMode = CollectionMode::NFT;93            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());94            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;95            let new_owner: T::AccountId = account("admin", 0, SEED);96        }: change_collection_owner(RawOrigin::Signed(caller.clone()), 2, new_owner)9798        add_collection_admin {99            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();100            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();101            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();102            let mode: CollectionMode = CollectionMode::NFT;103            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());104            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;105            let new_admin: T::AccountId = account("admin", 0, SEED);106        }: add_collection_admin(RawOrigin::Signed(caller.clone()), 2, new_admin)107108        remove_collection_admin {109            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();110            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();111            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();112            let mode: CollectionMode = CollectionMode::NFT;113            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());114            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;115            let new_admin: T::AccountId = account("admin", 0, SEED);116            Nft::<T>::add_collection_admin(RawOrigin::Signed(caller.clone()).into(), 2, new_admin.clone())?;117        }: remove_collection_admin(RawOrigin::Signed(caller.clone()), 2, new_admin)118119        set_collection_sponsor {120            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();121            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();122            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();123            let mode: CollectionMode = CollectionMode::NFT;124            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());125            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;126        }: set_collection_sponsor(RawOrigin::Signed(caller.clone()), 2, caller.clone())127128        confirm_sponsorship {129            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();130            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();131            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();132            let mode: CollectionMode = CollectionMode::NFT;133            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());134            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;135            Nft::<T>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone())?;136        }: confirm_sponsorship(RawOrigin::Signed(caller.clone()), 2)137138        remove_collection_sponsor {139            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();140            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();141            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();142            let mode: CollectionMode = CollectionMode::NFT;143            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());144            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;145            Nft::<T>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone())?;146            Nft::<T>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), 2)?;147        }: remove_collection_sponsor(RawOrigin::Signed(caller.clone()), 2)148149        // nft item150        create_item_nft {151            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();152            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();153            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();154            let mode: CollectionMode = CollectionMode::NFT;155            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());156            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;157            let data = default_nft_data();158            159        }: create_item(RawOrigin::Signed(caller.clone()), 2, caller.clone(), data)160161        #[extra]162        create_item_nft_large {163            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();164            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();165            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();166            let mode: CollectionMode = CollectionMode::NFT;167            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());168            let mut nft_data = CreateNftData {169                const_data: vec![],170                variable_data: vec![]171            };172            for i in 0..1998 {173                nft_data.const_data.push(10);174                nft_data.variable_data.push(10);175            }176            let data = CreateItemData::NFT(nft_data);177            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;178179        }: create_item(RawOrigin::Signed(caller.clone()), 2, caller.clone(), data)180181        // fungible item182        create_item_fungible {183            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();184            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();185            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();186            let mode: CollectionMode = CollectionMode::Fungible(3);187            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());188            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;189            let data = default_fungible_data();190191        }: create_item(RawOrigin::Signed(caller.clone()), 2, caller.clone(), data)192193        // refungible item194        create_item_refungible {195            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();196            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();197            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();198            let mode: CollectionMode = CollectionMode::ReFungible(3);199            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());200            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;201            let data = default_re_fungible_data();202203        }: create_item(RawOrigin::Signed(caller.clone()), 2, caller.clone(), data)204205        burn_item {206            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();207            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();208            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();209            let mode: CollectionMode = CollectionMode::NFT;210            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());211            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;212            let data = default_nft_data();213            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;214215        }: burn_item(RawOrigin::Signed(caller.clone()), 2, 1)216217        transfer_nft {218            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();219            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();220            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();221            let mode: CollectionMode = CollectionMode::NFT;222            let recipient: T::AccountId = account("recipient", 0, SEED);223            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());224            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;225            let data = default_nft_data();226            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;227228        }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)229        230        transfer_fungible {231            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();232            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();233            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();234            let mode: CollectionMode = CollectionMode::Fungible(3);235            let recipient: T::AccountId = account("recipient", 0, SEED);236            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());237            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;238            let data = default_fungible_data();239            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;240241        }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)242243        transfer_refungible {244            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();245            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();246            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();247            let mode: CollectionMode = CollectionMode::ReFungible(3);248            let recipient: T::AccountId = account("recipient", 0, SEED);249            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());250            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;251            let data = default_re_fungible_data();252            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;253254        }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)255256        approve {257            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();258            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();259            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();260            let mode: CollectionMode = CollectionMode::ReFungible(3);261            let recipient: T::AccountId = account("recipient", 0, SEED);262            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());263            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;264            let data = default_re_fungible_data();265            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;266267        }: approve(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1)268269        // Nft270        transfer_from_nft {271            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();272            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();273            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();274            let mode: CollectionMode = CollectionMode::NFT;275            let recipient: T::AccountId = account("recipient", 0, SEED);276            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());277            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;278            let data = default_nft_data();279            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;280            Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;281282        }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)283284        // Fungible285        transfer_from_fungible {286            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();287            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();288            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();289            let mode: CollectionMode = CollectionMode::Fungible(3);290            let recipient: T::AccountId = account("recipient", 0, SEED);291            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());292            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;293            let data = default_fungible_data();294            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;295            Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;296297        }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)298299        // ReFungible300        transfer_from_refungible {301            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();302            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();303            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();304            let mode: CollectionMode = CollectionMode::ReFungible(3);305            let recipient: T::AccountId = account("recipient", 0, SEED);306            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());307            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;308            let data = default_re_fungible_data();309            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;310            Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;311312        }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)313314        enable_contract_sponsoring {315            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());316317        }: enable_contract_sponsoring(RawOrigin::Signed(caller.clone()), caller.clone(), true)318319        set_offchain_schema {320            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();321            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();322            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();323            let mode: CollectionMode = CollectionMode::ReFungible(3);324            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());325            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;326327        }: set_offchain_schema(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec())328329        set_const_on_chain_schema {330            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();331            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();332            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();333            let mode: CollectionMode = CollectionMode::ReFungible(3);334            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());335            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;336        }: set_const_on_chain_schema(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec())337        338        set_variable_on_chain_schema {339            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();340            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();341            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();342            let mode: CollectionMode = CollectionMode::ReFungible(3);343            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());344            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;345        }: set_variable_on_chain_schema(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec())346347        set_variable_meta_data {348            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();349            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();350            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();351            let mode: CollectionMode = CollectionMode::NFT;352            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());353            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;354            let data = default_nft_data();355            Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;356357        }: set_variable_meta_data(RawOrigin::Signed(caller.clone()), 2, 1, [1, 2, 3].to_vec())358359        set_schema_version {360            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();361            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();362            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();363            let mode: CollectionMode = CollectionMode::NFT;364            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());365            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;366        }: set_schema_version(RawOrigin::Signed(caller.clone()), 2, SchemaVersion::Unique)367368        set_chain_limits {369            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());370            let limits = ChainLimits { 371                collection_numbers_limit: 0,372                account_token_ownership_limit: 0,373                collections_admins_limit: 0,374                custom_data_limit: 0,375                nft_sponsor_transfer_timeout: 0,376                fungible_sponsor_transfer_timeout: 0,377                refungible_sponsor_transfer_timeout: 0378            };379        }: set_chain_limits(RawOrigin::Signed(caller.clone()), limits)380381        set_contract_sponsoring_rate_limit {382            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();383            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();384            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();385            let mode: CollectionMode = CollectionMode::NFT;386            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());387            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;388            let block_number: T::BlockNumber = 0.into();   389        }: set_contract_sponsoring_rate_limit(RawOrigin::Signed(caller.clone()), caller.clone(), block_number)390391        set_collection_limits{392            let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();393            let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();394            let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();395            let mode: CollectionMode = CollectionMode::NFT;396            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());397            Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;398     399            let cl = CollectionLimits {400                account_token_ownership_limit: 0,401                sponsored_data_size: 0,402                token_limit: 0,403                sponsor_transfer_timeout: 0404            };405406        }: set_collection_limits(RawOrigin::Signed(caller.clone()), 2, cl)407408        add_to_contract_white_list{409            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());410        }: add_to_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), caller.clone())411412        remove_from_contract_white_list{413            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());414            Nft::<T>::add_to_contract_white_list(RawOrigin::Signed(caller.clone()).into(), caller.clone(), caller.clone())?;415        }: remove_from_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), caller.clone())416417        toggle_contract_white_list{418            let caller: T::AccountId = T::AccountId::from(whitelisted_caller());419        }: toggle_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), true)420}
after · pallets/nft/src/benchmarking.rs
1#![cfg(feature = "runtime-benchmarks")]23use super::*;4use crate::Module as Nft;56use sp_std::prelude::*;7use frame_system::RawOrigin;8use frame_benchmarking::{benchmarks, account, whitelisted_caller};  // , TrackedStorageKey, 910const SEED: u32 = 1;11/*12fn default_nft_data() -> CreateItemData {13    CreateItemData::NFT(CreateNftData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1] })14}1516fn default_fungible_data () -> CreateItemData {17    CreateItemData::Fungible(CreateFungibleData { })18}1920fn default_re_fungible_data () -> CreateItemData {21    CreateItemData::ReFungible(CreateReFungibleData { const_data: vec![1, 2, 3], variable_data: vec![3, 2, 1] })22}23*/2425benchmarks! {2627    create_collection {28        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();29        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();30        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();31        let mode: CollectionMode = CollectionMode::NFT;32        let caller: T::AccountId = account("caller", 0, SEED);33    }: _(RawOrigin::Signed(caller.clone()), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode)34/*35    verify {36        assert_eq!(Nft::<T>::collection_id(2).owner, caller);37    }38    destroy_collection {39        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();40        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();41        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();42        let mode: CollectionMode = CollectionMode::NFT;43        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());44        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;45    }: _(RawOrigin::Signed(caller.clone()), 2)4647    add_to_white_list {48        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();49        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();50        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();51        let mode: CollectionMode = CollectionMode::NFT;52        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());53        let whitelist_account: T::AccountId = account("admin", 0, SEED);54        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;55    }: add_to_white_list(RawOrigin::Signed(caller.clone()), 2, whitelist_account)5657    remove_from_white_list {58        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();59        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();60        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();61        let mode: CollectionMode = CollectionMode::NFT;62        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());63        let whitelist_account: T::AccountId = account("admin", 0, SEED);64        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;65        Nft::<T>::add_to_white_list(RawOrigin::Signed(caller.clone()).into(), 2, whitelist_account.clone())?;66    }: remove_from_white_list(RawOrigin::Signed(caller.clone()), 2, whitelist_account)6768    set_public_access_mode {69        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();70        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();71        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();72        let mode: CollectionMode = CollectionMode::NFT;73        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());74        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;75    }: set_public_access_mode(RawOrigin::Signed(caller.clone()), 2, AccessMode::WhiteList)7677    set_mint_permission {78        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();79        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();80        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();81        let mode: CollectionMode = CollectionMode::NFT;82        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());83        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;84    }: set_mint_permission(RawOrigin::Signed(caller.clone()), 2, true)8586    change_collection_owner {87        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();88        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();89        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();90        let mode: CollectionMode = CollectionMode::NFT;91        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());92        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;93        let new_owner: T::AccountId = account("admin", 0, SEED);94    }: change_collection_owner(RawOrigin::Signed(caller.clone()), 2, new_owner)9596    add_collection_admin {97        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();98        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();99        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();100        let mode: CollectionMode = CollectionMode::NFT;101        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());102        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;103        let new_admin: T::AccountId = account("admin", 0, SEED);104    }: add_collection_admin(RawOrigin::Signed(caller.clone()), 2, new_admin)105106    remove_collection_admin {107        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();108        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();109        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();110        let mode: CollectionMode = CollectionMode::NFT;111        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());112        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;113        let new_admin: T::AccountId = account("admin", 0, SEED);114        Nft::<T>::add_collection_admin(RawOrigin::Signed(caller.clone()).into(), 2, new_admin.clone())?;115    }: remove_collection_admin(RawOrigin::Signed(caller.clone()), 2, new_admin)116117    set_collection_sponsor {118        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();119        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();120        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();121        let mode: CollectionMode = CollectionMode::NFT;122        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());123        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;124    }: set_collection_sponsor(RawOrigin::Signed(caller.clone()), 2, caller.clone())125126    confirm_sponsorship {127        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();128        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();129        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();130        let mode: CollectionMode = CollectionMode::NFT;131        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());132        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;133        Nft::<T>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone())?;134    }: confirm_sponsorship(RawOrigin::Signed(caller.clone()), 2)135136    remove_collection_sponsor {137        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();138        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();139        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();140        let mode: CollectionMode = CollectionMode::NFT;141        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());142        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;143        Nft::<T>::set_collection_sponsor(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone())?;144        Nft::<T>::confirm_sponsorship(RawOrigin::Signed(caller.clone()).into(), 2)?;145    }: remove_collection_sponsor(RawOrigin::Signed(caller.clone()), 2)146147    // nft item148    create_item_nft {149        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();150        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();151        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();152        let mode: CollectionMode = CollectionMode::NFT;153        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());154        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;155        let data = default_nft_data();156        157    }: create_item(RawOrigin::Signed(caller.clone()), 2, caller.clone(), data)158159    #[extra]160    create_item_nft_large {161        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();162        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();163        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();164        let mode: CollectionMode = CollectionMode::NFT;165        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());166        let mut nft_data = CreateNftData {167            const_data: vec![],168            variable_data: vec![]169        };170        for i in 0..1998 {171            nft_data.const_data.push(10);172            nft_data.variable_data.push(10);173        }174        let data = CreateItemData::NFT(nft_data);175        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;176177    }: create_item(RawOrigin::Signed(caller.clone()), 2, caller.clone(), data)178179    // fungible item180    create_item_fungible {181        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();182        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();183        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();184        let mode: CollectionMode = CollectionMode::Fungible(3);185        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());186        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;187        let data = default_fungible_data();188189    }: create_item(RawOrigin::Signed(caller.clone()), 2, caller.clone(), data)190191    // refungible item192    create_item_refungible {193        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();194        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();195        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();196        let mode: CollectionMode = CollectionMode::ReFungible(3);197        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());198        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;199        let data = default_re_fungible_data();200201    }: create_item(RawOrigin::Signed(caller.clone()), 2, caller.clone(), data)202203    burn_item {204        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();205        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();206        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();207        let mode: CollectionMode = CollectionMode::NFT;208        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());209        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;210        let data = default_nft_data();211        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;212213    }: burn_item(RawOrigin::Signed(caller.clone()), 2, 1)214215    transfer_nft {216        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();217        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();218        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();219        let mode: CollectionMode = CollectionMode::NFT;220        let recipient: T::AccountId = account("recipient", 0, SEED);221        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());222        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;223        let data = default_nft_data();224        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;225226    }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)227    228    transfer_fungible {229        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();230        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();231        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();232        let mode: CollectionMode = CollectionMode::Fungible(3);233        let recipient: T::AccountId = account("recipient", 0, SEED);234        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());235        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;236        let data = default_fungible_data();237        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;238239    }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)240241    transfer_refungible {242        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();243        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();244        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();245        let mode: CollectionMode = CollectionMode::ReFungible(3);246        let recipient: T::AccountId = account("recipient", 0, SEED);247        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());248        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;249        let data = default_re_fungible_data();250        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;251252    }: transfer(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1, 1)253254    approve {255        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();256        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();257        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();258        let mode: CollectionMode = CollectionMode::ReFungible(3);259        let recipient: T::AccountId = account("recipient", 0, SEED);260        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());261        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;262        let data = default_re_fungible_data();263        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;264265    }: approve(RawOrigin::Signed(caller.clone()), recipient.clone(), 2, 1)266267    // Nft268    transfer_from_nft {269        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();270        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();271        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();272        let mode: CollectionMode = CollectionMode::NFT;273        let recipient: T::AccountId = account("recipient", 0, SEED);274        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());275        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;276        let data = default_nft_data();277        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;278        Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;279280    }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)281282    // Fungible283    transfer_from_fungible {284        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();285        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();286        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();287        let mode: CollectionMode = CollectionMode::Fungible(3);288        let recipient: T::AccountId = account("recipient", 0, SEED);289        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());290        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;291        let data = default_fungible_data();292        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;293        Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;294295    }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)296297    // ReFungible298    transfer_from_refungible {299        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();300        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();301        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();302        let mode: CollectionMode = CollectionMode::ReFungible(3);303        let recipient: T::AccountId = account("recipient", 0, SEED);304        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());305        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;306        let data = default_re_fungible_data();307        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;308        Nft::<T>::approve(RawOrigin::Signed(caller.clone()).into(), recipient.clone(), 2, 1)?;309310    }: transfer_from(RawOrigin::Signed(caller.clone()), caller.clone(), recipient.clone(), 2, 1, 1)311312    enable_contract_sponsoring {313        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());314315    }: enable_contract_sponsoring(RawOrigin::Signed(caller.clone()), caller.clone(), true)316317    set_offchain_schema {318        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();319        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();320        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();321        let mode: CollectionMode = CollectionMode::ReFungible(3);322        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());323        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;324325    }: set_offchain_schema(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec())326327    set_const_on_chain_schema {328        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();329        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();330        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();331        let mode: CollectionMode = CollectionMode::ReFungible(3);332        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());333        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;334    }: set_const_on_chain_schema(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec())335    336    set_variable_on_chain_schema {337        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();338        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();339        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();340        let mode: CollectionMode = CollectionMode::ReFungible(3);341        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());342        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;343    }: set_variable_on_chain_schema(RawOrigin::Signed(caller.clone()), 2, [1,2,3].to_vec())344345    set_variable_meta_data {346        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();347        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();348        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();349        let mode: CollectionMode = CollectionMode::NFT;350        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());351        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;352        let data = default_nft_data();353        Nft::<T>::create_item(RawOrigin::Signed(caller.clone()).into(), 2, caller.clone(), data)?;354355    }: set_variable_meta_data(RawOrigin::Signed(caller.clone()), 2, 1, [1, 2, 3].to_vec())356357    set_schema_version {358        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();359        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();360        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();361        let mode: CollectionMode = CollectionMode::NFT;362        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());363        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;364    }: set_schema_version(RawOrigin::Signed(caller.clone()), 2, SchemaVersion::Unique)365366    set_chain_limits {367        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());368        let limits = ChainLimits { 369            collection_numbers_limit: 0,370            account_token_ownership_limit: 0,371            collections_admins_limit: 0,372            custom_data_limit: 0,373            nft_sponsor_transfer_timeout: 0,374            fungible_sponsor_transfer_timeout: 0,375            refungible_sponsor_transfer_timeout: 0376        };377    }: set_chain_limits(RawOrigin::Signed(caller.clone()), limits)378379    set_contract_sponsoring_rate_limit {380        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();381        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();382        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();383        let mode: CollectionMode = CollectionMode::NFT;384        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());385        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;386        let block_number: T::BlockNumber = 0.into();   387    }: set_contract_sponsoring_rate_limit(RawOrigin::Signed(caller.clone()), caller.clone(), block_number)388389    set_collection_limits{390        let col_name1: Vec<u16> = "Test1".encode_utf16().collect::<Vec<u16>>();391        let col_desc1: Vec<u16> = "TestDescription1".encode_utf16().collect::<Vec<u16>>();392        let token_prefix1: Vec<u8> = b"token_prefix1".to_vec();393        let mode: CollectionMode = CollectionMode::NFT;394        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());395        Nft::<T>::create_collection(RawOrigin::Signed(caller.clone()).into(), col_name1.clone(), col_desc1.clone(), token_prefix1.clone(), mode.clone())?;396    397        let cl = CollectionLimits {398            account_token_ownership_limit: 0,399            sponsored_data_size: 0,400            token_limit: 0,401            sponsor_transfer_timeout: 0402        };403404    }: set_collection_limits(RawOrigin::Signed(caller.clone()), 2, cl)405406    add_to_contract_white_list{407        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());408    }: add_to_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), caller.clone())409410    remove_from_contract_white_list{411        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());412        Nft::<T>::add_to_contract_white_list(RawOrigin::Signed(caller.clone()).into(), caller.clone(), caller.clone())?;413    }: remove_from_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), caller.clone())414415    toggle_contract_white_list{416        let caller: T::AccountId = T::AccountId::from(whitelisted_caller());417    }: toggle_contract_white_list(RawOrigin::Signed(caller.clone()), caller.clone(), true)418*/419}
modifiedruntime/Cargo.tomldiffbeforeafterboth
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -26,6 +26,7 @@
 
 # local dependencies
 pallet-nft = { path = '../pallets/nft', default-features = false, version = '3.0.0' }
+pallet-inflation = { path = '../pallets/inflation', default-features = false, version = '3.0.0' }
 
 # Substrate dependencies
 frame-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
@@ -72,6 +73,7 @@
     'pallet-balances/runtime-benchmarks',
     'pallet-timestamp/runtime-benchmarks',
     'pallet-nft/runtime-benchmarks',
+    'pallet-inflation/runtime-benchmarks',
     'sp-runtime/runtime-benchmarks',
 ]
 std = [
@@ -95,6 +97,7 @@
     'pallet-treasury/std',
     'pallet-vesting/std',
 
+    'pallet-inflation/std',
     'pallet-nft/std',
     'sp-api/std',
     'sp-block-builder/std',
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -525,7 +525,7 @@
 	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
 }
 
-/// Used for the module nft in `./nft.rs`
+/// Used for the pallet nft in `./nft.rs`
 impl pallet_nft::Config for Runtime {
     type Event = Event;
     type WeightInfo = nft_weights::WeightInfo;
@@ -534,6 +534,21 @@
 	type TreasuryAccountId = TreasuryAccountId;
 }
 
+/// Reimport pallet inflation
+extern crate pallet_inflation;
+pub use pallet_inflation::*;
+
+parameter_types! {
+	pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied
+}
+
+/// Used for the pallet inflation
+impl pallet_inflation::Config for Runtime {
+	type Currency = Balances;
+	type TreasuryAccountId = TreasuryAccountId;
+	type InflationBlockInterval = InflationBlockInterval;
+}
+
 construct_runtime!(
     pub enum Runtime where
         Block = Block,
@@ -549,6 +564,7 @@
         Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
         TransactionPayment: pallet_transaction_payment::{Module, Storage},
         Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
+        Inflation: pallet_inflation::{Module, Call, Storage},
         Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},
         Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},
         Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},
@@ -759,6 +775,7 @@
 			let params = (&config, &whitelist);
 
 			add_benchmark!(params, batches, pallet_nft, Nft);
+			add_benchmark!(params, batches, pallet_inflation, Inflation);
 
 			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
 			Ok(batches)
modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -50,7 +50,8 @@
     "testSetContractSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setContractSponsoringRateLimit.test.ts",
     "testSetOffchainSchema": "mocha --timeout 9999999 -r ts-node/register ./**/setOffchainSchema.test.ts",
     "testOverflow": "mocha --timeout 9999999 -r ts-node/register ./**/overflow.test.ts",
-    "testSetVariableMetadataSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetadataSponsoringRateLimit.test.ts"
+    "testSetVariableMetadataSponsoringRateLimit": "mocha --timeout 9999999 -r ts-node/register ./**/setVariableMetadataSponsoringRateLimit.test.ts",
+    "testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts"
   },
   "author": "",
   "license": "SEE LICENSE IN ../LICENSE",
modifiedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth
--- a/tests/src/creditFeesToTreasury.test.ts
+++ b/tests/src/creditFeesToTreasury.test.ts
@@ -18,6 +18,7 @@
 } from './util/helpers';
 
 import { default as waitNewBlocks } from './substrate/wait-new-blocks';
+import { ApiPromise } from '@polkadot/api';
 
 chai.use(chaiAsPromised);
 const expect = chai.expect;
@@ -30,6 +31,25 @@
 let alice: IKeyringPair;
 let bob: IKeyringPair;
 
+// Skip the inflation block pauses if the block is close to inflation block 
+// until the inflation happens
+function skipInflationBlock(api: ApiPromise): Promise<void> {
+  const promise = new Promise<void>(async (resolve, reject) => {
+    const blockInterval = parseInt((await api.consts.inflation.inflationBlockInterval).toString());
+    const unsubscribe = await api.rpc.chain.subscribeNewHeads(head => {
+      const currentBlock = parseInt(head.number.toString());
+      if (currentBlock % blockInterval < blockInterval - 10) {
+        unsubscribe();
+        resolve();
+      } else {
+        console.log(`Skipping inflation block, current block: ${currentBlock}`);
+      }
+    });
+  });
+
+  return promise;
+}
+
 describe('integration test: Fees must be credited to Treasury:', () => {
   before(async () => {
     await usingApi(async (api) => {
@@ -40,6 +60,7 @@
 
   it('Total issuance does not change', async () => {
     await usingApi(async (api) => {
+      await skipInflationBlock(api);
       await waitNewBlocks(api, 1);
 
       const totalBefore = new BigNumber((await api.query.balances.totalIssuance()).toString());
@@ -59,6 +80,7 @@
 
   it('Sender balance decreased by fee+sent amount, Treasury balance increased by fee', async () => {
     await usingApi(async (api) => {
+      await skipInflationBlock(api);
       await waitNewBlocks(api, 1);
 
       const alicePrivateKey = privateKey('//Alice');
@@ -81,6 +103,7 @@
 
   it('Treasury balance increased by failed tx fee', async () => {
     await usingApi(async (api) => {
+      await skipInflationBlock(api);
       await waitNewBlocks(api, 1);
 
       const bobPrivateKey = privateKey('//Bob');
@@ -101,6 +124,7 @@
 
   it('NFT Transactions also send fees to Treasury', async () => {
     await usingApi(async (api) => {
+      await skipInflationBlock(api);
       await waitNewBlocks(api, 1);
 
       const treasuryBalanceBefore = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
@@ -119,6 +143,7 @@
 
   it('Fees are sane', async () => {
     await usingApi(async (api) => {
+      await skipInflationBlock(api);
       await waitNewBlocks(api, 1);
 
       const aliceBalanceBefore = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
@@ -135,6 +160,7 @@
 
   it('NFT Transfer fee is close to 0.1 Unique', async () => {
     await usingApi(async (api) => {
+      await skipInflationBlock(api);
       await waitNewBlocks(api, 1);
 
       const collectionId = await createCollectionExpectSuccess();
@@ -147,7 +173,7 @@
 
       // console.log(fee.toString());
       const expectedTransferFee = 0.1;
-      const tolerance = 0.00001;
+      const tolerance = 0.001;
       expect(fee.dividedBy(1e15).minus(expectedTransferFee).abs().toNumber()).to.be.lessThan(tolerance);
     });
   });
addedtests/src/inflation.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/inflation.test.ts
@@ -0,0 +1,49 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "./substrate/substrate-api";
+import { alicesPublicKey, bobsPublicKey } from "./accounts";
+import privateKey from "./substrate/privateKey";
+import { BigNumber } from 'bignumber.js';
+import { IKeyringPair } from '@polkadot/types/types';
+import { 
+  getGenericResult,
+} from './util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+
+describe('integration test: Inflation', () => {
+  before(async () => {
+    await usingApi(async (api) => {
+      alice = privateKey('//Alice');
+      bob = privateKey('//Bob');
+    });
+  });
+
+  it('First year inflation is 10%', async () => {
+    await usingApi(async (api) => {
+
+      const blockInterval = parseInt((await api.consts.inflation.inflationBlockInterval).toString());
+      const totalIssuanceStart = new BigNumber((await api.query.inflation.startingYearTotalIssuance()).toString());
+      const blockInflation = new BigNumber((await api.query.inflation.blockInflation()).toString());
+
+      const YEAR = 5259600; // Blocks in one year
+      const totalExpectedInflation = totalIssuanceStart.multipliedBy(0.1);
+      const totalActualInflation = blockInflation.multipliedBy(YEAR / blockInterval);
+
+      const tolerance = 0.00001; // Relative difference per year between theoretical and actual inflation
+      expect(totalExpectedInflation.dividedBy(totalActualInflation).minus(1).abs().toNumber()).to.be.lessThan(tolerance);
+    });
+  });
+
+
+});
+