git.delta.rocks / unique-network / refs/commits / 4d07c60d3d95

difftreelog

add rpc methods + tests

PraetorP2022-08-17parent: #e804565.patch.diff
in: master

17 files changed

modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -262,6 +262,14 @@
 	#[method(name = "unique_totalStakingLocked")]
 	fn total_staking_locked(&self, staker: CrossAccountId, at: Option<BlockHash>)
 		-> Result<String>;
+
+	/// Return the total amount locked by staking tokens.
+	#[method(name = "unique_pendingUnstake")]
+	fn pending_unstake(
+		&self,
+		staker: Option<CrossAccountId>,
+		at: Option<BlockHash>,
+	) -> Result<String>;
 }
 
 mod rmrk_unique_rpc {
@@ -548,6 +556,7 @@
 		.map(|(b, a)| (b, a.to_string()))
 		.collect::<Vec<_>>(), unique_api);
 	pass_method!(total_staking_locked(staker: CrossAccountId) -> String => |v| v.to_string(), unique_api);
+	pass_method!(pending_unstake(staker: Option<CrossAccountId>) -> String => |v| v.to_string(), unique_api);
 }
 
 #[allow(deprecated)]
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -63,7 +63,7 @@
 use fc_rpc_core::types::FilterPool;
 use fc_mapping_sync::{MappingSyncWorker, SyncStrategy};
 
-use unique_runtime_common::types::{
+use up_common::types::opaque::{
 	AuraId, RuntimeInstance, AccountId, Balance, Index, Hash, Block, BlockNumber,
 };
 
modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -31,12 +31,12 @@
 
 #[cfg(feature = "runtime-benchmarks")]
 mod benchmarking;
-pub mod types;
-
 #[cfg(test)]
 mod tests;
+pub mod types;
+pub mod weights;
 
-use sp_std::vec::Vec;
+use sp_std::{vec::Vec, iter::Sum};
 use codec::EncodeLike;
 use pallet_balances::BalanceLock;
 pub use types::ExtendedLockableCurrency;
@@ -48,6 +48,9 @@
 	},
 	ensure,
 };
+
+use weights::WeightInfo;
+
 pub use pallet::*;
 use pallet_evm::account::CrossAccountId;
 use sp_runtime::{
@@ -79,6 +82,9 @@
 
 		type TreasuryAccountId: Get<Self::AccountId>;
 
+		/// Weight information for extrinsics in this pallet.
+		type WeightInfo: WeightInfo;
+
 		// The block number provider
 		type BlockNumberProvider: BlockNumberProvider<BlockNumber = Self::BlockNumber>;
 
@@ -136,6 +142,7 @@
 		fn on_initialize(current_block: T::BlockNumber) -> Weight
 		where
 			<T as frame_system::Config>::BlockNumber: From<u32>,
+			// <<T as pallet::Config>::Currency as Currency<T::AccountId>>::Balance: Sum,
 		{
 			PendingUnstake::<T>::iter()
 				.filter_map(|((staker, block), amount)| {
@@ -172,7 +179,7 @@
 
 	#[pallet::call]
 	impl<T: Config> Pallet<T> {
-		#[pallet::weight(0)]
+		#[pallet::weight(T::WeightInfo::set_admin_address())]
 		pub fn set_admin_address(origin: OriginFor<T>, admin: T::AccountId) -> DispatchResult {
 			ensure_root(origin)?;
 			<Admin<T>>::set(Some(admin));
@@ -180,7 +187,7 @@
 			Ok(())
 		}
 
-		#[pallet::weight(0)]
+		#[pallet::weight(T::WeightInfo::start_app_promotion())]
 		pub fn start_app_promotion(
 			origin: OriginFor<T>,
 			promotion_start_relay_block: T::BlockNumber,
@@ -201,7 +208,7 @@
 			Ok(())
 		}
 
-		#[pallet::weight(0)]
+		#[pallet::weight(T::WeightInfo::stake())]
 		pub fn stake(staker: OriginFor<T>, amount: BalanceOf<T>) -> DispatchResult {
 			let staker_id = ensure_signed(staker)?;
 
@@ -210,10 +217,16 @@
 
 			ensure!(balance >= amount, ArithmeticError::Underflow);
 
-			Self::set_lock_unchecked(&staker_id, amount);
+			<<T as Config>::Currency as Currency<T::AccountId>>::ensure_can_withdraw(
+				&staker_id,
+				amount,
+				WithdrawReasons::all(),
+				balance - amount,
+			)?;
+
+			Self::add_lock_balance(&staker_id, amount)?;
 
-			let block_number =
-				<T::BlockNumberProvider as BlockNumberProvider>::current_block_number();
+			let block_number = frame_system::Pallet::<T>::block_number();
 
 			<Staked<T>>::insert(
 				(&staker_id, block_number),
@@ -231,7 +244,7 @@
 			Ok(())
 		}
 
-		#[pallet::weight(0)]
+		#[pallet::weight(T::WeightInfo::unstake())]
 		pub fn unstake(staker: OriginFor<T>, amount: BalanceOf<T>) -> DispatchResult {
 			let staker_id = ensure_signed(staker)?;
 
@@ -249,7 +262,7 @@
 					.ok_or(ArithmeticError::Underflow)?,
 			);
 
-			let block = <T::BlockNumberProvider>::current_block_number() + WEEK.into();
+			let block = frame_system::Pallet::<T>::block_number() + WEEK.into();
 			<PendingUnstake<T>>::insert(
 				(&staker_id, block),
 				<PendingUnstake<T>>::get((&staker_id, block))
@@ -400,8 +413,8 @@
 
 	fn add_lock_balance(staker: &T::AccountId, amount: BalanceOf<T>) -> DispatchResult {
 		Self::get_locked_balance(staker)
-			.map(|l| l.amount)
-			.and_then(|b| b.checked_add(&amount))
+			.map_or(<BalanceOf<T>>::default(), |l| l.amount)
+			.checked_add(&amount)
 			.map(|new_lock| Self::set_lock_unchecked(staker, new_lock))
 			.ok_or(ArithmeticError::Overflow.into())
 	}
@@ -437,10 +450,11 @@
 	pub fn total_staked_by_id_per_block(
 		staker: impl EncodeLike<T::AccountId>,
 	) -> Option<Vec<(T::BlockNumber, BalanceOf<T>)>> {
-		let staked = Staked::<T>::iter_prefix((staker,))
+		let mut staked = Staked::<T>::iter_prefix((staker,))
 			.into_iter()
 			.map(|(block, amount)| (block, amount))
 			.collect::<Vec<_>>();
+		staked.sort_by_key(|(block, _)| *block);
 		if !staked.is_empty() {
 			Some(staked)
 		} else {
@@ -495,3 +509,14 @@
 		day_rate * base
 	}
 }
+
+impl<T: Config> Pallet<T>
+where
+	<<T as pallet::Config>::Currency as Currency<T::AccountId>>::Balance: Sum,
+{
+	pub fn cross_id_pending_unstake(staker: Option<T::CrossAccountId>) -> BalanceOf<T> {
+		staker.map_or(PendingUnstake::<T>::iter_values().sum(), |s| {
+			PendingUnstake::<T>::iter_prefix_values((s.as_sub(),)).sum()
+		})
+	}
+}
modifiedprimitives/rpc/src/lib.rsdiffbeforeafterboth
--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -129,5 +129,6 @@
 		fn total_staked(staker: Option<CrossAccountId>) -> Result<u128>;
 		fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>>;
 		fn total_staking_locked(staker: CrossAccountId) -> Result<u128>;
+		fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128>;
 	}
 }
addedruntime/common/config/pallets/app_promotion.rsdiffbeforeafterboth
--- /dev/null
+++ b/runtime/common/config/pallets/app_promotion.rs
@@ -0,0 +1,27 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+use crate::{
+	runtime_common::config::pallets::{TreasuryAccountId, RelayChainBlockNumberProvider},
+	Runtime, Balances,
+};
+
+impl pallet_app_promotion::Config for Runtime {
+	type Currency = Balances;
+	type WeightInfo = pallet_app_promotion::weights::SubstrateWeight<Self>;
+	type TreasuryAccountId = TreasuryAccountId;
+	type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
+}
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -40,6 +40,9 @@
 #[cfg(feature = "scheduler")]
 pub mod scheduler;
 
+#[cfg(feature = "app-promotion")]
+pub mod app_promotion;
+
 parameter_types! {
 	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account_truncating();
 	pub const CollectionCreationPrice: Balance = 2 * UNIQUE;
modifiedruntime/common/construct_runtime/mod.rsdiffbeforeafterboth
--- a/runtime/common/construct_runtime/mod.rs
+++ b/runtime/common/construct_runtime/mod.rs
@@ -77,6 +77,9 @@
                 #[runtimes(opal)]
                 RmrkEquip: pallet_proxy_rmrk_equip::{Pallet, Call, Storage, Event<T>} = 72,
 
+                #[runtimes(opal)]
+                Promotion: pallet_app_promotion::{Pallet, Call, Storage} = 73,
+
                 // Frontier
                 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,
                 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -190,7 +190,6 @@
 
                 fn total_staked(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {
                     Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_total_staked(staker).unwrap_or_default())
-                    // Ok(0)
                 }
 
                 fn total_staked_per_block(staker: CrossAccountId) -> Result<Vec<(BlockNumber, u128)>, DispatchError> {
@@ -198,9 +197,12 @@
                 }
 
                 fn total_staking_locked(staker: CrossAccountId) -> Result<u128, DispatchError> {
-                    // Ok(0)
                     Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_locked_balance(staker))
                 }
+
+                fn pending_unstake(staker: Option<CrossAccountId>) -> Result<u128, DispatchError> {
+                    Ok(<pallet_app_promotion::Pallet<Runtime>>::cross_id_pending_unstake(staker))
+                }
             }
 
             impl rmrk_rpc::RmrkApi<
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -124,11 +124,12 @@
     "orml-vesting/std",
 ]
 limit-testing = ['pallet-unique/limit-testing', 'up-data-structs/limit-testing']
-opal-runtime = ['refungible', 'scheduler', 'rmrk']
+opal-runtime = ['refungible', 'scheduler', 'rmrk', 'app-promotion']
 
 refungible = []
 scheduler = []
 rmrk = []
+app-promotion = []
 
 ################################################################################
 # Substrate Dependencies
modifiedtests/src/app-promotion.test.tsdiffbeforeafterboth
--- a/tests/src/app-promotion.test.ts
+++ b/tests/src/app-promotion.test.ts
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {default as usingApi, submitTransactionAsync} from './substrate/substrate-api';
-import {IKeyringPair} from '@polkadot/types/types';
+import {IKeyringPair, ITuple} from '@polkadot/types/types';
 import {
   
   createMultipleItemsExpectSuccess,
@@ -33,26 +33,38 @@
   U128_MAX,
   burnFromExpectSuccess,
   UNIQUE,
+  getModuleNames,
+  Pallets,
+  getBlockNumber,
 } from './util/helpers';
 
-import chai from 'chai';
+import chai, {use} from 'chai';
 import chaiAsPromised from 'chai-as-promised';
-import getBalance from './substrate/get-balance';
-import { unique } from './interfaces/definitions';
+import getBalance, {getBalanceSingle} from './substrate/get-balance';
+import {unique} from './interfaces/definitions';
+import {usingPlaygrounds} from './util/playgrounds';
+import {default as waitNewBlocks} from './substrate/wait-new-blocks';
+
+import BN from 'bn.js';
+import {mnemonicGenerate} from '@polkadot/util-crypto';
+import {UniqueHelper} from './util/playgrounds/unique';
 chai.use(chaiAsPromised);
 const expect = chai.expect;
 
 let alice: IKeyringPair;
 let bob: IKeyringPair;
 let palletAdmin: IKeyringPair;
+let nominal: bigint; 
 
 describe('integration test: AppPromotion', () => {
-  before(async () => {
-    await usingApi(async (api, privateKeyWrapper) => {
+  before(async function() {
+    await usingPlaygrounds(async (helper, privateKeyWrapper) => {
+      if (!getModuleNames(helper.api!).includes(Pallets.AppPromotion)) this.skip();
       alice = privateKeyWrapper('//Alice');
       bob = privateKeyWrapper('//Bob');
       palletAdmin = privateKeyWrapper('//palletAdmin');
-      const tx = api.tx.sudo.sudo(api.tx.promotion.setAdminAddress(palletAdmin.addressRaw));
+      const tx = helper.api!.tx.sudo.sudo(helper.api!.tx.promotion.setAdminAddress(palletAdmin.addressRaw));
+      nominal = helper.balance.getOneTokenNominal();
       await submitTransactionAsync(alice, tx);
     });
   });
@@ -69,22 +81,110 @@
     // assert:  query appPromotion.staked(Alice) equal [100, 200]
     // assert:  query appPromotion.totalStaked() increased by 200
     
-    await usingApi(async (api, privateKeyWrapper) => {
-      await submitTransactionAsync(alice, api.tx.balances.transfer(bob.addressRaw, 10n * UNIQUE));
-      const [alicesBalanceBefore, bobsBalanceBefore] = await getBalance(api, [alice.address, bob.address]);
+    await usingPlaygrounds(async (helper, privateKeyWrapper) => {
+      const totalStakedBefore = (await helper.api!.rpc.unique.totalStaked()).toBigInt();
+      const staker = await createUser();
+   
+      const firstStakedBlock = await helper.chain.getLatestBlockNumber();
+      
+      await expect(submitTransactionAsync(staker, helper.api!.tx.promotion.stake(1n * nominal))).to.be.eventually.fulfilled;
+      expect((await helper.api!.rpc.unique.totalStakingLocked(normalizeAccountId(staker))).toBigInt()).to.be.equal(nominal);
+      expect(9n * nominal - await helper.balance.getSubstrate(staker.address) <= nominal / 2n).to.be.true;
+      expect((await helper.api!.rpc.unique.totalStaked(normalizeAccountId(staker))).toBigInt()).to.be.equal(nominal);
+      expect((await helper.api!.rpc.unique.totalStaked()).toBigInt()).to.be.equal(totalStakedBefore + nominal);
       
-      console.log(`alice: ${alicesBalanceBefore} \n bob: ${bobsBalanceBefore}`);
+      await waitNewBlocks(helper.api!, 1);
+      const secondStakedBlock = await helper.chain.getLatestBlockNumber();
       
-      await submitTransactionAsync(alice, api.tx.promotion.stake(1n * UNIQUE));
-      await submitTransactionAsync(bob, api.tx.promotion.stake(1n * UNIQUE));
-      const alice_total_staked = (await (api.rpc.unique.totalStaked(normalizeAccountId(alice)))).toBigInt();
-      const bob_total_staked = (await api.rpc.unique.totalStaked(normalizeAccountId(bob))).toBigInt();
-       
-      console.log(`alice staked: ${alice_total_staked} \n bob staked: ${bob_total_staked}, total staked: ${(await api.rpc.unique.totalStaked()).toBigInt()}`);
+      await expect(submitTransactionAsync(staker, helper.api!.tx.promotion.stake(2n * nominal))).to.be.eventually.fulfilled;
+      expect((await helper.api!.rpc.unique.totalStakingLocked(normalizeAccountId(staker))).toBigInt()).to.be.equal(3n * nominal);
+      
+      const stakedPerBlock = (await helper.api!.rpc.unique.totalStakedPerBlock(normalizeAccountId(staker))).map(([block, amount]) => [block.toBigInt(), amount.toBigInt()]);
+      expect(stakedPerBlock.map((x) => x[1])).to.be.deep.equal([nominal, 2n * nominal]);
+    });
+  });
+  
+  it('will throws if stake amount is more than total free balance', async () => {
+    // arrange: Alice balance = 1000
+    // assert:  Alice calls appPromotion.stake(1000) throws /// because Alice needs some fee
+
+    // act:     Alice calls appPromotion.stake(700)
+    // assert:  Alice calls appPromotion.stake(400) throws /// because Alice has ~300 free QTZ and 700 locked
+
+    await usingPlaygrounds(async helper => { 
       
+      const staker = await createUser();
       
+      await expect(submitTransactionAsync(staker, helper.api!.tx.promotion.stake(10n * nominal))).to.be.eventually.rejected;
+      await expect(submitTransactionAsync(staker, helper.api!.tx.promotion.stake(7n * nominal))).to.be.eventually.fulfilled;
+      await expect(submitTransactionAsync(staker, helper.api!.tx.promotion.stake(4n * nominal))).to.be.eventually.rejected;
       
     });
   });
+  
+  it.skip('for different accounts in one block is possible', async () => {
+    // arrange: Alice, Bob, Charlie, Dave balance = 1000
+    // arrange: Alice, Bob, Charlie, Dave calls appPromotion.stake(100) in the same time
+
+    // assert:  query appPromotion.staked(Alice/Bob/Charlie/Dave) equal [100]
+    await usingPlaygrounds(async helper => {
+      const crowd = await creteAccounts([10n, 10n, 10n, 10n], alice, helper);
+      // const promises = crowd.map(async user => submitTransactionAsync(user, helper.api!.tx.promotion.stake(nominal)));
+      // await expect(Promise.all(promises)).to.be.eventually.fulfilled;
+    });
+  });
+
+});
+
+describe.skip('unstake balance extrinsic', () => {
+  before(async function() {
+    await usingPlaygrounds(async (helper, privateKeyWrapper) => {
+      if (!getModuleNames(helper.api!).includes(Pallets.AppPromotion)) this.skip();
+      alice = privateKeyWrapper('//Alice');
+      bob = privateKeyWrapper('//Bob');
+      palletAdmin = privateKeyWrapper('//palletAdmin');
+      const tx = helper.api!.tx.sudo.sudo(helper.api!.tx.promotion.setAdminAddress(palletAdmin.addressRaw));
+      nominal = helper.balance.getOneTokenNominal();
+      await submitTransactionAsync(alice, tx);
+    });
+  });
+  it('will change balance state to "reserved", add it to "pendingUnstake" map, and subtract it from totalStaked', async () => {
+    // arrange: Alice balance = 1000
+    // arrange: Alice calls appPromotion.stake(Alice, 500)
+
+    // act:     Alice calls appPromotion.unstake(300)
+    // assert:  Alice reserved balance to equal 300
+    // assert:  query appPromotion.staked(Alice) equal [200] /// 500 - 300
+    // assert:  query appPromotion.pendingUnstake(Alice) to equal [300]
+    // assert:  query appPromotion.totalStaked() decreased by 300
+  });
+});
+
+
+
+async function createUser(amount?: bigint) {
+  return await usingPlaygrounds(async (helper, privateKeyWrapper) => {
+    const user: IKeyringPair = privateKeyWrapper(`//Alice+${(new Date()).getTime()}`);
+    await helper.balance.transferToSubstrate(alice, user.address, amount ? amount : 10n * helper.balance.getOneTokenNominal());
+    return user;
+  });
+}
+
+const creteAccounts = async (balances: bigint[], donor: IKeyringPair, helper: UniqueHelper) => {
+  let nonce = await helper.chain.getNonce(donor.address);
+  const tokenNominal = helper.balance.getOneTokenNominal();
+  const transactions = [];
+  const accounts = [];
+  for (const balance of balances) {
+    const recepient = helper.util.fromSeed(mnemonicGenerate());
+    accounts.push(recepient);
+    if (balance !== 0n){
+      const tx = helper.constructApiCall('api.tx.balances.transfer', [{Id: recepient.address}, balance * tokenNominal]);
+      transactions.push(helper.signTransaction(donor, tx, 'account generation', {nonce}));
+      nonce++;
+    }
+  }
 
-});
\ No newline at end of file
+  await Promise.all(transactions);
+  return accounts;
+};
\ No newline at end of file
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -703,6 +703,10 @@
        **/
       nextSponsored: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, account: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<u64>>>;
       /**
+       * Returns the total amount of unstaked tokens
+       **/
+      pendingUnstake: AugmentedRpc<(staker?: PalletEvmAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
+      /**
        * Get property permissions, optionally limited to the provided keys
        **/
       propertyPermissions: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, propertyKeys?: Vec<Text> | (Text | string)[], at?: Hash | string | Uint8Array) => Observable<Vec<UpDataStructsPropertyKeyPermission>>>;
modifiedtests/src/interfaces/lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -5,1266 +5,8 @@
 
 export default {
   /**
-   * Lookup3: frame_system::AccountInfo<Index, pallet_balances::AccountData<Balance>>
-   **/
-  FrameSystemAccountInfo: {
-    nonce: 'u32',
-    consumers: 'u32',
-    providers: 'u32',
-    sufficients: 'u32',
-    data: 'PalletBalancesAccountData'
-  },
-  /**
-   * Lookup5: pallet_balances::AccountData<Balance>
-   **/
-  PalletBalancesAccountData: {
-    free: 'u128',
-    reserved: 'u128',
-    miscFrozen: 'u128',
-    feeFrozen: 'u128'
-  },
-  /**
-   * Lookup7: frame_support::weights::PerDispatchClass<T>
-   **/
-  FrameSupportWeightsPerDispatchClassU64: {
-    normal: 'u64',
-    operational: 'u64',
-    mandatory: 'u64'
-  },
-  /**
-   * Lookup11: sp_runtime::generic::digest::Digest
-   **/
-  SpRuntimeDigest: {
-    logs: 'Vec<SpRuntimeDigestDigestItem>'
-  },
-  /**
-   * Lookup13: sp_runtime::generic::digest::DigestItem
-   **/
-  SpRuntimeDigestDigestItem: {
-    _enum: {
-      Other: 'Bytes',
-      __Unused1: 'Null',
-      __Unused2: 'Null',
-      __Unused3: 'Null',
-      Consensus: '([u8;4],Bytes)',
-      Seal: '([u8;4],Bytes)',
-      PreRuntime: '([u8;4],Bytes)',
-      __Unused7: 'Null',
-      RuntimeEnvironmentUpdated: 'Null'
-    }
-  },
-  /**
-   * Lookup16: frame_system::EventRecord<opal_runtime::Event, primitive_types::H256>
-   **/
-  FrameSystemEventRecord: {
-    phase: 'FrameSystemPhase',
-    event: 'Event',
-    topics: 'Vec<H256>'
-  },
-  /**
-   * Lookup18: frame_system::pallet::Event<T>
-   **/
-  FrameSystemEvent: {
-    _enum: {
-      ExtrinsicSuccess: {
-        dispatchInfo: 'FrameSupportWeightsDispatchInfo',
-      },
-      ExtrinsicFailed: {
-        dispatchError: 'SpRuntimeDispatchError',
-        dispatchInfo: 'FrameSupportWeightsDispatchInfo',
-      },
-      CodeUpdated: 'Null',
-      NewAccount: {
-        account: 'AccountId32',
-      },
-      KilledAccount: {
-        account: 'AccountId32',
-      },
-      Remarked: {
-        _alias: {
-          hash_: 'hash',
-        },
-        sender: 'AccountId32',
-        hash_: 'H256'
-      }
-    }
-  },
-  /**
-   * Lookup19: frame_support::weights::DispatchInfo
-   **/
-  FrameSupportWeightsDispatchInfo: {
-    weight: 'u64',
-    class: 'FrameSupportWeightsDispatchClass',
-    paysFee: 'FrameSupportWeightsPays'
-  },
-  /**
-   * Lookup20: frame_support::weights::DispatchClass
-   **/
-  FrameSupportWeightsDispatchClass: {
-    _enum: ['Normal', 'Operational', 'Mandatory']
-  },
-  /**
-   * Lookup21: frame_support::weights::Pays
-   **/
-  FrameSupportWeightsPays: {
-    _enum: ['Yes', 'No']
-  },
-  /**
-   * Lookup22: sp_runtime::DispatchError
-   **/
-  SpRuntimeDispatchError: {
-    _enum: {
-      Other: 'Null',
-      CannotLookup: 'Null',
-      BadOrigin: 'Null',
-      Module: 'SpRuntimeModuleError',
-      ConsumerRemaining: 'Null',
-      NoProviders: 'Null',
-      TooManyConsumers: 'Null',
-      Token: 'SpRuntimeTokenError',
-      Arithmetic: 'SpRuntimeArithmeticError',
-      Transactional: 'SpRuntimeTransactionalError'
-    }
-  },
-  /**
-   * Lookup23: sp_runtime::ModuleError
-   **/
-  SpRuntimeModuleError: {
-    index: 'u8',
-    error: '[u8;4]'
-  },
-  /**
-   * Lookup24: sp_runtime::TokenError
-   **/
-  SpRuntimeTokenError: {
-    _enum: ['NoFunds', 'WouldDie', 'BelowMinimum', 'CannotCreate', 'UnknownAsset', 'Frozen', 'Unsupported']
-  },
-  /**
-   * Lookup25: sp_runtime::ArithmeticError
-   **/
-  SpRuntimeArithmeticError: {
-    _enum: ['Underflow', 'Overflow', 'DivisionByZero']
-  },
-  /**
-   * Lookup26: sp_runtime::TransactionalError
-   **/
-  SpRuntimeTransactionalError: {
-    _enum: ['LimitReached', 'NoLayer']
-  },
-  /**
-   * Lookup27: cumulus_pallet_parachain_system::pallet::Event<T>
-   **/
-  CumulusPalletParachainSystemEvent: {
-    _enum: {
-      ValidationFunctionStored: 'Null',
-      ValidationFunctionApplied: {
-        relayChainBlockNum: 'u32',
-      },
-      ValidationFunctionDiscarded: 'Null',
-      UpgradeAuthorized: {
-        codeHash: 'H256',
-      },
-      DownwardMessagesReceived: {
-        count: 'u32',
-      },
-      DownwardMessagesProcessed: {
-        weightUsed: 'u64',
-        dmqHead: 'H256'
-      }
-    }
-  },
-  /**
-   * Lookup28: pallet_balances::pallet::Event<T, I>
-   **/
-  PalletBalancesEvent: {
-    _enum: {
-      Endowed: {
-        account: 'AccountId32',
-        freeBalance: 'u128',
-      },
-      DustLost: {
-        account: 'AccountId32',
-        amount: 'u128',
-      },
-      Transfer: {
-        from: 'AccountId32',
-        to: 'AccountId32',
-        amount: 'u128',
-      },
-      BalanceSet: {
-        who: 'AccountId32',
-        free: 'u128',
-        reserved: 'u128',
-      },
-      Reserved: {
-        who: 'AccountId32',
-        amount: 'u128',
-      },
-      Unreserved: {
-        who: 'AccountId32',
-        amount: 'u128',
-      },
-      ReserveRepatriated: {
-        from: 'AccountId32',
-        to: 'AccountId32',
-        amount: 'u128',
-        destinationStatus: 'FrameSupportTokensMiscBalanceStatus',
-      },
-      Deposit: {
-        who: 'AccountId32',
-        amount: 'u128',
-      },
-      Withdraw: {
-        who: 'AccountId32',
-        amount: 'u128',
-      },
-      Slashed: {
-        who: 'AccountId32',
-        amount: 'u128'
-      }
-    }
-  },
-  /**
-   * Lookup29: frame_support::traits::tokens::misc::BalanceStatus
-   **/
-  FrameSupportTokensMiscBalanceStatus: {
-    _enum: ['Free', 'Reserved']
-  },
-  /**
-   * Lookup30: pallet_transaction_payment::pallet::Event<T>
-   **/
-  PalletTransactionPaymentEvent: {
-    _enum: {
-      TransactionFeePaid: {
-        who: 'AccountId32',
-        actualFee: 'u128',
-        tip: 'u128'
-      }
-    }
-  },
-  /**
-   * Lookup31: pallet_treasury::pallet::Event<T, I>
-   **/
-  PalletTreasuryEvent: {
-    _enum: {
-      Proposed: {
-        proposalIndex: 'u32',
-      },
-      Spending: {
-        budgetRemaining: 'u128',
-      },
-      Awarded: {
-        proposalIndex: 'u32',
-        award: 'u128',
-        account: 'AccountId32',
-      },
-      Rejected: {
-        proposalIndex: 'u32',
-        slashed: 'u128',
-      },
-      Burnt: {
-        burntFunds: 'u128',
-      },
-      Rollover: {
-        rolloverBalance: 'u128',
-      },
-      Deposit: {
-        value: 'u128',
-      },
-      SpendApproved: {
-        proposalIndex: 'u32',
-        amount: 'u128',
-        beneficiary: 'AccountId32'
-      }
-    }
-  },
-  /**
-   * Lookup32: pallet_sudo::pallet::Event<T>
-   **/
-  PalletSudoEvent: {
-    _enum: {
-      Sudid: {
-        sudoResult: 'Result<Null, SpRuntimeDispatchError>',
-      },
-      KeyChanged: {
-        oldSudoer: 'Option<AccountId32>',
-      },
-      SudoAsDone: {
-        sudoResult: 'Result<Null, SpRuntimeDispatchError>'
-      }
-    }
-  },
-  /**
-   * Lookup36: orml_vesting::module::Event<T>
-   **/
-  OrmlVestingModuleEvent: {
-    _enum: {
-      VestingScheduleAdded: {
-        from: 'AccountId32',
-        to: 'AccountId32',
-        vestingSchedule: 'OrmlVestingVestingSchedule',
-      },
-      Claimed: {
-        who: 'AccountId32',
-        amount: 'u128',
-      },
-      VestingSchedulesUpdated: {
-        who: 'AccountId32'
-      }
-    }
-  },
-  /**
-   * Lookup37: orml_vesting::VestingSchedule<BlockNumber, Balance>
-   **/
-  OrmlVestingVestingSchedule: {
-    start: 'u32',
-    period: 'u32',
-    periodCount: 'u32',
-    perPeriod: 'Compact<u128>'
-  },
-  /**
-   * Lookup39: cumulus_pallet_xcmp_queue::pallet::Event<T>
-   **/
-  CumulusPalletXcmpQueueEvent: {
-    _enum: {
-      Success: {
-        messageHash: 'Option<H256>',
-        weight: 'u64',
-      },
-      Fail: {
-        messageHash: 'Option<H256>',
-        error: 'XcmV2TraitsError',
-        weight: 'u64',
-      },
-      BadVersion: {
-        messageHash: 'Option<H256>',
-      },
-      BadFormat: {
-        messageHash: 'Option<H256>',
-      },
-      UpwardMessageSent: {
-        messageHash: 'Option<H256>',
-      },
-      XcmpMessageSent: {
-        messageHash: 'Option<H256>',
-      },
-      OverweightEnqueued: {
-        sender: 'u32',
-        sentAt: 'u32',
-        index: 'u64',
-        required: 'u64',
-      },
-      OverweightServiced: {
-        index: 'u64',
-        used: 'u64'
-      }
-    }
-  },
-  /**
-   * Lookup41: xcm::v2::traits::Error
-   **/
-  XcmV2TraitsError: {
-    _enum: {
-      Overflow: 'Null',
-      Unimplemented: 'Null',
-      UntrustedReserveLocation: 'Null',
-      UntrustedTeleportLocation: 'Null',
-      MultiLocationFull: 'Null',
-      MultiLocationNotInvertible: 'Null',
-      BadOrigin: 'Null',
-      InvalidLocation: 'Null',
-      AssetNotFound: 'Null',
-      FailedToTransactAsset: 'Null',
-      NotWithdrawable: 'Null',
-      LocationCannotHold: 'Null',
-      ExceedsMaxMessageSize: 'Null',
-      DestinationUnsupported: 'Null',
-      Transport: 'Null',
-      Unroutable: 'Null',
-      UnknownClaim: 'Null',
-      FailedToDecode: 'Null',
-      MaxWeightInvalid: 'Null',
-      NotHoldingFees: 'Null',
-      TooExpensive: 'Null',
-      Trap: 'u64',
-      UnhandledXcmVersion: 'Null',
-      WeightLimitReached: 'u64',
-      Barrier: 'Null',
-      WeightNotComputable: 'Null'
-    }
-  },
-  /**
-   * Lookup43: pallet_xcm::pallet::Event<T>
-   **/
-  PalletXcmEvent: {
-    _enum: {
-      Attempted: 'XcmV2TraitsOutcome',
-      Sent: '(XcmV1MultiLocation,XcmV1MultiLocation,XcmV2Xcm)',
-      UnexpectedResponse: '(XcmV1MultiLocation,u64)',
-      ResponseReady: '(u64,XcmV2Response)',
-      Notified: '(u64,u8,u8)',
-      NotifyOverweight: '(u64,u8,u8,u64,u64)',
-      NotifyDispatchError: '(u64,u8,u8)',
-      NotifyDecodeFailed: '(u64,u8,u8)',
-      InvalidResponder: '(XcmV1MultiLocation,u64,Option<XcmV1MultiLocation>)',
-      InvalidResponderVersion: '(XcmV1MultiLocation,u64)',
-      ResponseTaken: 'u64',
-      AssetsTrapped: '(H256,XcmV1MultiLocation,XcmVersionedMultiAssets)',
-      VersionChangeNotified: '(XcmV1MultiLocation,u32)',
-      SupportedVersionChanged: '(XcmV1MultiLocation,u32)',
-      NotifyTargetSendFail: '(XcmV1MultiLocation,u64,XcmV2TraitsError)',
-      NotifyTargetMigrationFail: '(XcmVersionedMultiLocation,u64)'
-    }
-  },
-  /**
-   * Lookup44: xcm::v2::traits::Outcome
-   **/
-  XcmV2TraitsOutcome: {
-    _enum: {
-      Complete: 'u64',
-      Incomplete: '(u64,XcmV2TraitsError)',
-      Error: 'XcmV2TraitsError'
-    }
-  },
-  /**
-   * Lookup45: xcm::v1::multilocation::MultiLocation
-   **/
-  XcmV1MultiLocation: {
-    parents: 'u8',
-    interior: 'XcmV1MultilocationJunctions'
-  },
-  /**
-   * Lookup46: xcm::v1::multilocation::Junctions
-   **/
-  XcmV1MultilocationJunctions: {
-    _enum: {
-      Here: 'Null',
-      X1: 'XcmV1Junction',
-      X2: '(XcmV1Junction,XcmV1Junction)',
-      X3: '(XcmV1Junction,XcmV1Junction,XcmV1Junction)',
-      X4: '(XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction)',
-      X5: '(XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction)',
-      X6: '(XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction)',
-      X7: '(XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction)',
-      X8: '(XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction,XcmV1Junction)'
-    }
-  },
-  /**
-   * Lookup47: xcm::v1::junction::Junction
-   **/
-  XcmV1Junction: {
-    _enum: {
-      Parachain: 'Compact<u32>',
-      AccountId32: {
-        network: 'XcmV0JunctionNetworkId',
-        id: '[u8;32]',
-      },
-      AccountIndex64: {
-        network: 'XcmV0JunctionNetworkId',
-        index: 'Compact<u64>',
-      },
-      AccountKey20: {
-        network: 'XcmV0JunctionNetworkId',
-        key: '[u8;20]',
-      },
-      PalletInstance: 'u8',
-      GeneralIndex: 'Compact<u128>',
-      GeneralKey: 'Bytes',
-      OnlyChild: 'Null',
-      Plurality: {
-        id: 'XcmV0JunctionBodyId',
-        part: 'XcmV0JunctionBodyPart'
-      }
-    }
-  },
-  /**
-   * Lookup49: xcm::v0::junction::NetworkId
-   **/
-  XcmV0JunctionNetworkId: {
-    _enum: {
-      Any: 'Null',
-      Named: 'Bytes',
-      Polkadot: 'Null',
-      Kusama: 'Null'
-    }
-  },
-  /**
-   * Lookup53: xcm::v0::junction::BodyId
-   **/
-  XcmV0JunctionBodyId: {
-    _enum: {
-      Unit: 'Null',
-      Named: 'Bytes',
-      Index: 'Compact<u32>',
-      Executive: 'Null',
-      Technical: 'Null',
-      Legislative: 'Null',
-      Judicial: 'Null'
-    }
-  },
-  /**
-   * Lookup54: xcm::v0::junction::BodyPart
-   **/
-  XcmV0JunctionBodyPart: {
-    _enum: {
-      Voice: 'Null',
-      Members: {
-        count: 'Compact<u32>',
-      },
-      Fraction: {
-        nom: 'Compact<u32>',
-        denom: 'Compact<u32>',
-      },
-      AtLeastProportion: {
-        nom: 'Compact<u32>',
-        denom: 'Compact<u32>',
-      },
-      MoreThanProportion: {
-        nom: 'Compact<u32>',
-        denom: 'Compact<u32>'
-      }
-    }
-  },
-  /**
-   * Lookup55: xcm::v2::Xcm<Call>
-   **/
-  XcmV2Xcm: 'Vec<XcmV2Instruction>',
-  /**
-   * Lookup57: xcm::v2::Instruction<Call>
-   **/
-  XcmV2Instruction: {
-    _enum: {
-      WithdrawAsset: 'XcmV1MultiassetMultiAssets',
-      ReserveAssetDeposited: 'XcmV1MultiassetMultiAssets',
-      ReceiveTeleportedAsset: 'XcmV1MultiassetMultiAssets',
-      QueryResponse: {
-        queryId: 'Compact<u64>',
-        response: 'XcmV2Response',
-        maxWeight: 'Compact<u64>',
-      },
-      TransferAsset: {
-        assets: 'XcmV1MultiassetMultiAssets',
-        beneficiary: 'XcmV1MultiLocation',
-      },
-      TransferReserveAsset: {
-        assets: 'XcmV1MultiassetMultiAssets',
-        dest: 'XcmV1MultiLocation',
-        xcm: 'XcmV2Xcm',
-      },
-      Transact: {
-        originType: 'XcmV0OriginKind',
-        requireWeightAtMost: 'Compact<u64>',
-        call: 'XcmDoubleEncoded',
-      },
-      HrmpNewChannelOpenRequest: {
-        sender: 'Compact<u32>',
-        maxMessageSize: 'Compact<u32>',
-        maxCapacity: 'Compact<u32>',
-      },
-      HrmpChannelAccepted: {
-        recipient: 'Compact<u32>',
-      },
-      HrmpChannelClosing: {
-        initiator: 'Compact<u32>',
-        sender: 'Compact<u32>',
-        recipient: 'Compact<u32>',
-      },
-      ClearOrigin: 'Null',
-      DescendOrigin: 'XcmV1MultilocationJunctions',
-      ReportError: {
-        queryId: 'Compact<u64>',
-        dest: 'XcmV1MultiLocation',
-        maxResponseWeight: 'Compact<u64>',
-      },
-      DepositAsset: {
-        assets: 'XcmV1MultiassetMultiAssetFilter',
-        maxAssets: 'Compact<u32>',
-        beneficiary: 'XcmV1MultiLocation',
-      },
-      DepositReserveAsset: {
-        assets: 'XcmV1MultiassetMultiAssetFilter',
-        maxAssets: 'Compact<u32>',
-        dest: 'XcmV1MultiLocation',
-        xcm: 'XcmV2Xcm',
-      },
-      ExchangeAsset: {
-        give: 'XcmV1MultiassetMultiAssetFilter',
-        receive: 'XcmV1MultiassetMultiAssets',
-      },
-      InitiateReserveWithdraw: {
-        assets: 'XcmV1MultiassetMultiAssetFilter',
-        reserve: 'XcmV1MultiLocation',
-        xcm: 'XcmV2Xcm',
-      },
-      InitiateTeleport: {
-        assets: 'XcmV1MultiassetMultiAssetFilter',
-        dest: 'XcmV1MultiLocation',
-        xcm: 'XcmV2Xcm',
-      },
-      QueryHolding: {
-        queryId: 'Compact<u64>',
-        dest: 'XcmV1MultiLocation',
-        assets: 'XcmV1MultiassetMultiAssetFilter',
-        maxResponseWeight: 'Compact<u64>',
-      },
-      BuyExecution: {
-        fees: 'XcmV1MultiAsset',
-        weightLimit: 'XcmV2WeightLimit',
-      },
-      RefundSurplus: 'Null',
-      SetErrorHandler: 'XcmV2Xcm',
-      SetAppendix: 'XcmV2Xcm',
-      ClearError: 'Null',
-      ClaimAsset: {
-        assets: 'XcmV1MultiassetMultiAssets',
-        ticket: 'XcmV1MultiLocation',
-      },
-      Trap: 'Compact<u64>',
-      SubscribeVersion: {
-        queryId: 'Compact<u64>',
-        maxResponseWeight: 'Compact<u64>',
-      },
-      UnsubscribeVersion: 'Null'
-    }
-  },
-  /**
-   * Lookup58: xcm::v1::multiasset::MultiAssets
-   **/
-  XcmV1MultiassetMultiAssets: 'Vec<XcmV1MultiAsset>',
-  /**
-   * Lookup60: xcm::v1::multiasset::MultiAsset
-   **/
-  XcmV1MultiAsset: {
-    id: 'XcmV1MultiassetAssetId',
-    fun: 'XcmV1MultiassetFungibility'
-  },
-  /**
-   * Lookup61: xcm::v1::multiasset::AssetId
-   **/
-  XcmV1MultiassetAssetId: {
-    _enum: {
-      Concrete: 'XcmV1MultiLocation',
-      Abstract: 'Bytes'
-    }
-  },
-  /**
-   * Lookup62: xcm::v1::multiasset::Fungibility
-   **/
-  XcmV1MultiassetFungibility: {
-    _enum: {
-      Fungible: 'Compact<u128>',
-      NonFungible: 'XcmV1MultiassetAssetInstance'
-    }
-  },
-  /**
-   * Lookup63: xcm::v1::multiasset::AssetInstance
-   **/
-  XcmV1MultiassetAssetInstance: {
-    _enum: {
-      Undefined: 'Null',
-      Index: 'Compact<u128>',
-      Array4: '[u8;4]',
-      Array8: '[u8;8]',
-      Array16: '[u8;16]',
-      Array32: '[u8;32]',
-      Blob: 'Bytes'
-    }
-  },
-  /**
-   * Lookup66: xcm::v2::Response
-   **/
-  XcmV2Response: {
-    _enum: {
-      Null: 'Null',
-      Assets: 'XcmV1MultiassetMultiAssets',
-      ExecutionResult: 'Option<(u32,XcmV2TraitsError)>',
-      Version: 'u32'
-    }
-  },
-  /**
-   * Lookup69: xcm::v0::OriginKind
-   **/
-  XcmV0OriginKind: {
-    _enum: ['Native', 'SovereignAccount', 'Superuser', 'Xcm']
-  },
-  /**
-   * Lookup70: xcm::double_encoded::DoubleEncoded<T>
-   **/
-  XcmDoubleEncoded: {
-    encoded: 'Bytes'
-  },
-  /**
-   * Lookup71: xcm::v1::multiasset::MultiAssetFilter
-   **/
-  XcmV1MultiassetMultiAssetFilter: {
-    _enum: {
-      Definite: 'XcmV1MultiassetMultiAssets',
-      Wild: 'XcmV1MultiassetWildMultiAsset'
-    }
-  },
-  /**
-   * Lookup72: xcm::v1::multiasset::WildMultiAsset
-   **/
-  XcmV1MultiassetWildMultiAsset: {
-    _enum: {
-      All: 'Null',
-      AllOf: {
-        id: 'XcmV1MultiassetAssetId',
-        fun: 'XcmV1MultiassetWildFungibility'
-      }
-    }
-  },
-  /**
-   * Lookup73: xcm::v1::multiasset::WildFungibility
-   **/
-  XcmV1MultiassetWildFungibility: {
-    _enum: ['Fungible', 'NonFungible']
-  },
-  /**
-   * Lookup74: xcm::v2::WeightLimit
-   **/
-  XcmV2WeightLimit: {
-    _enum: {
-      Unlimited: 'Null',
-      Limited: 'Compact<u64>'
-    }
-  },
-  /**
-   * Lookup76: xcm::VersionedMultiAssets
-   **/
-  XcmVersionedMultiAssets: {
-    _enum: {
-      V0: 'Vec<XcmV0MultiAsset>',
-      V1: 'XcmV1MultiassetMultiAssets'
-    }
-  },
-  /**
-   * Lookup78: xcm::v0::multi_asset::MultiAsset
-   **/
-  XcmV0MultiAsset: {
-    _enum: {
-      None: 'Null',
-      All: 'Null',
-      AllFungible: 'Null',
-      AllNonFungible: 'Null',
-      AllAbstractFungible: {
-        id: 'Bytes',
-      },
-      AllAbstractNonFungible: {
-        class: 'Bytes',
-      },
-      AllConcreteFungible: {
-        id: 'XcmV0MultiLocation',
-      },
-      AllConcreteNonFungible: {
-        class: 'XcmV0MultiLocation',
-      },
-      AbstractFungible: {
-        id: 'Bytes',
-        amount: 'Compact<u128>',
-      },
-      AbstractNonFungible: {
-        class: 'Bytes',
-        instance: 'XcmV1MultiassetAssetInstance',
-      },
-      ConcreteFungible: {
-        id: 'XcmV0MultiLocation',
-        amount: 'Compact<u128>',
-      },
-      ConcreteNonFungible: {
-        class: 'XcmV0MultiLocation',
-        instance: 'XcmV1MultiassetAssetInstance'
-      }
-    }
-  },
-  /**
-   * Lookup79: xcm::v0::multi_location::MultiLocation
-   **/
-  XcmV0MultiLocation: {
-    _enum: {
-      Null: 'Null',
-      X1: 'XcmV0Junction',
-      X2: '(XcmV0Junction,XcmV0Junction)',
-      X3: '(XcmV0Junction,XcmV0Junction,XcmV0Junction)',
-      X4: '(XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction)',
-      X5: '(XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction)',
-      X6: '(XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction)',
-      X7: '(XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction)',
-      X8: '(XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction,XcmV0Junction)'
-    }
-  },
-  /**
-   * Lookup80: xcm::v0::junction::Junction
-   **/
-  XcmV0Junction: {
-    _enum: {
-      Parent: 'Null',
-      Parachain: 'Compact<u32>',
-      AccountId32: {
-        network: 'XcmV0JunctionNetworkId',
-        id: '[u8;32]',
-      },
-      AccountIndex64: {
-        network: 'XcmV0JunctionNetworkId',
-        index: 'Compact<u64>',
-      },
-      AccountKey20: {
-        network: 'XcmV0JunctionNetworkId',
-        key: '[u8;20]',
-      },
-      PalletInstance: 'u8',
-      GeneralIndex: 'Compact<u128>',
-      GeneralKey: 'Bytes',
-      OnlyChild: 'Null',
-      Plurality: {
-        id: 'XcmV0JunctionBodyId',
-        part: 'XcmV0JunctionBodyPart'
-      }
-    }
-  },
-  /**
-   * Lookup81: xcm::VersionedMultiLocation
-   **/
-  XcmVersionedMultiLocation: {
-    _enum: {
-      V0: 'XcmV0MultiLocation',
-      V1: 'XcmV1MultiLocation'
-    }
-  },
-  /**
-   * Lookup82: cumulus_pallet_xcm::pallet::Event<T>
-   **/
-  CumulusPalletXcmEvent: {
-    _enum: {
-      InvalidFormat: '[u8;8]',
-      UnsupportedVersion: '[u8;8]',
-      ExecutedDownward: '([u8;8],XcmV2TraitsOutcome)'
-    }
-  },
-  /**
-   * Lookup83: cumulus_pallet_dmp_queue::pallet::Event<T>
-   **/
-  CumulusPalletDmpQueueEvent: {
-    _enum: {
-      InvalidFormat: {
-        messageId: '[u8;32]',
-      },
-      UnsupportedVersion: {
-        messageId: '[u8;32]',
-      },
-      ExecutedDownward: {
-        messageId: '[u8;32]',
-        outcome: 'XcmV2TraitsOutcome',
-      },
-      WeightExhausted: {
-        messageId: '[u8;32]',
-        remainingWeight: 'u64',
-        requiredWeight: 'u64',
-      },
-      OverweightEnqueued: {
-        messageId: '[u8;32]',
-        overweightIndex: 'u64',
-        requiredWeight: 'u64',
-      },
-      OverweightServiced: {
-        overweightIndex: 'u64',
-        weightUsed: 'u64'
-      }
-    }
-  },
-  /**
-   * Lookup84: pallet_unique::RawEvent<sp_core::crypto::AccountId32, pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
-   **/
-  PalletUniqueRawEvent: {
-    _enum: {
-      CollectionSponsorRemoved: 'u32',
-      CollectionAdminAdded: '(u32,PalletEvmAccountBasicCrossAccountIdRepr)',
-      CollectionOwnedChanged: '(u32,AccountId32)',
-      CollectionSponsorSet: '(u32,AccountId32)',
-      SponsorshipConfirmed: '(u32,AccountId32)',
-      CollectionAdminRemoved: '(u32,PalletEvmAccountBasicCrossAccountIdRepr)',
-      AllowListAddressRemoved: '(u32,PalletEvmAccountBasicCrossAccountIdRepr)',
-      AllowListAddressAdded: '(u32,PalletEvmAccountBasicCrossAccountIdRepr)',
-      CollectionLimitSet: 'u32',
-      CollectionPermissionSet: 'u32'
-    }
-  },
-  /**
-   * Lookup85: pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>
-   **/
-  PalletEvmAccountBasicCrossAccountIdRepr: {
-    _enum: {
-      Substrate: 'AccountId32',
-      Ethereum: 'H160'
-    }
-  },
-  /**
-   * Lookup88: pallet_unique_scheduler::pallet::Event<T>
-   **/
-  PalletUniqueSchedulerEvent: {
-    _enum: {
-      Scheduled: {
-        when: 'u32',
-        index: 'u32',
-      },
-      Canceled: {
-        when: 'u32',
-        index: 'u32',
-      },
-      Dispatched: {
-        task: '(u32,u32)',
-        id: 'Option<[u8;16]>',
-        result: 'Result<Null, SpRuntimeDispatchError>',
-      },
-      CallLookupFailed: {
-        task: '(u32,u32)',
-        id: 'Option<[u8;16]>',
-        error: 'FrameSupportScheduleLookupError'
-      }
-    }
-  },
-  /**
-   * Lookup91: frame_support::traits::schedule::LookupError
-   **/
-  FrameSupportScheduleLookupError: {
-    _enum: ['Unknown', 'BadFormat']
-  },
-  /**
-   * Lookup92: pallet_common::pallet::Event<T>
-   **/
-  PalletCommonEvent: {
-    _enum: {
-      CollectionCreated: '(u32,u8,AccountId32)',
-      CollectionDestroyed: 'u32',
-      ItemCreated: '(u32,u32,PalletEvmAccountBasicCrossAccountIdRepr,u128)',
-      ItemDestroyed: '(u32,u32,PalletEvmAccountBasicCrossAccountIdRepr,u128)',
-      Transfer: '(u32,u32,PalletEvmAccountBasicCrossAccountIdRepr,PalletEvmAccountBasicCrossAccountIdRepr,u128)',
-      Approved: '(u32,u32,PalletEvmAccountBasicCrossAccountIdRepr,PalletEvmAccountBasicCrossAccountIdRepr,u128)',
-      CollectionPropertySet: '(u32,Bytes)',
-      CollectionPropertyDeleted: '(u32,Bytes)',
-      TokenPropertySet: '(u32,u32,Bytes)',
-      TokenPropertyDeleted: '(u32,u32,Bytes)',
-      PropertyPermissionSet: '(u32,Bytes)'
-    }
-  },
-  /**
-   * Lookup95: pallet_structure::pallet::Event<T>
-   **/
-  PalletStructureEvent: {
-    _enum: {
-      Executed: 'Result<Null, SpRuntimeDispatchError>'
-    }
-  },
-  /**
-   * Lookup96: pallet_rmrk_core::pallet::Event<T>
-   **/
-  PalletRmrkCoreEvent: {
-    _enum: {
-      CollectionCreated: {
-        issuer: 'AccountId32',
-        collectionId: 'u32',
-      },
-      CollectionDestroyed: {
-        issuer: 'AccountId32',
-        collectionId: 'u32',
-      },
-      IssuerChanged: {
-        oldIssuer: 'AccountId32',
-        newIssuer: 'AccountId32',
-        collectionId: 'u32',
-      },
-      CollectionLocked: {
-        issuer: 'AccountId32',
-        collectionId: 'u32',
-      },
-      NftMinted: {
-        owner: 'AccountId32',
-        collectionId: 'u32',
-        nftId: 'u32',
-      },
-      NFTBurned: {
-        owner: 'AccountId32',
-        nftId: 'u32',
-      },
-      NFTSent: {
-        sender: 'AccountId32',
-        recipient: 'RmrkTraitsNftAccountIdOrCollectionNftTuple',
-        collectionId: 'u32',
-        nftId: 'u32',
-        approvalRequired: 'bool',
-      },
-      NFTAccepted: {
-        sender: 'AccountId32',
-        recipient: 'RmrkTraitsNftAccountIdOrCollectionNftTuple',
-        collectionId: 'u32',
-        nftId: 'u32',
-      },
-      NFTRejected: {
-        sender: 'AccountId32',
-        collectionId: 'u32',
-        nftId: 'u32',
-      },
-      PropertySet: {
-        collectionId: 'u32',
-        maybeNftId: 'Option<u32>',
-        key: 'Bytes',
-        value: 'Bytes',
-      },
-      ResourceAdded: {
-        nftId: 'u32',
-        resourceId: 'u32',
-      },
-      ResourceRemoval: {
-        nftId: 'u32',
-        resourceId: 'u32',
-      },
-      ResourceAccepted: {
-        nftId: 'u32',
-        resourceId: 'u32',
-      },
-      ResourceRemovalAccepted: {
-        nftId: 'u32',
-        resourceId: 'u32',
-      },
-      PrioritySet: {
-        collectionId: 'u32',
-        nftId: 'u32'
-      }
-    }
-  },
-  /**
-   * Lookup97: rmrk_traits::nft::AccountIdOrCollectionNftTuple<sp_core::crypto::AccountId32>
-   **/
-  RmrkTraitsNftAccountIdOrCollectionNftTuple: {
-    _enum: {
-      AccountId: 'AccountId32',
-      CollectionAndNftTuple: '(u32,u32)'
-    }
-  },
-  /**
-   * Lookup102: pallet_rmrk_equip::pallet::Event<T>
-   **/
-  PalletRmrkEquipEvent: {
-    _enum: {
-      BaseCreated: {
-        issuer: 'AccountId32',
-        baseId: 'u32',
-      },
-      EquippablesUpdated: {
-        baseId: 'u32',
-        slotId: 'u32'
-      }
-    }
-  },
-  /**
-   * Lookup103: pallet_evm::pallet::Event<T>
-   **/
-  PalletEvmEvent: {
-    _enum: {
-      Log: 'EthereumLog',
-      Created: 'H160',
-      CreatedFailed: 'H160',
-      Executed: 'H160',
-      ExecutedFailed: 'H160',
-      BalanceDeposit: '(AccountId32,H160,U256)',
-      BalanceWithdraw: '(AccountId32,H160,U256)'
-    }
-  },
-  /**
-   * Lookup104: ethereum::log::Log
-   **/
-  EthereumLog: {
-    address: 'H160',
-    topics: 'Vec<H256>',
-    data: 'Bytes'
-  },
-  /**
-   * Lookup108: pallet_ethereum::pallet::Event
-   **/
-  PalletEthereumEvent: {
-    _enum: {
-      Executed: '(H160,H160,H256,EvmCoreErrorExitReason)'
-    }
-  },
-  /**
-   * Lookup109: evm_core::error::ExitReason
-   **/
-  EvmCoreErrorExitReason: {
-    _enum: {
-      Succeed: 'EvmCoreErrorExitSucceed',
-      Error: 'EvmCoreErrorExitError',
-      Revert: 'EvmCoreErrorExitRevert',
-      Fatal: 'EvmCoreErrorExitFatal'
-    }
-  },
-  /**
-   * Lookup110: evm_core::error::ExitSucceed
-   **/
-  EvmCoreErrorExitSucceed: {
-    _enum: ['Stopped', 'Returned', 'Suicided']
-  },
-  /**
-   * Lookup111: evm_core::error::ExitError
-   **/
-  EvmCoreErrorExitError: {
-    _enum: {
-      StackUnderflow: 'Null',
-      StackOverflow: 'Null',
-      InvalidJump: 'Null',
-      InvalidRange: 'Null',
-      DesignatedInvalid: 'Null',
-      CallTooDeep: 'Null',
-      CreateCollision: 'Null',
-      CreateContractLimit: 'Null',
-      OutOfOffset: 'Null',
-      OutOfGas: 'Null',
-      OutOfFund: 'Null',
-      PCUnderflow: 'Null',
-      CreateEmpty: 'Null',
-      Other: 'Text',
-      InvalidCode: 'Null'
-    }
-  },
-  /**
-   * Lookup114: evm_core::error::ExitRevert
-   **/
-  EvmCoreErrorExitRevert: {
-    _enum: ['Reverted']
-  },
-  /**
-   * Lookup115: evm_core::error::ExitFatal
-   **/
-  EvmCoreErrorExitFatal: {
-    _enum: {
-      NotSupported: 'Null',
-      UnhandledInterrupt: 'Null',
-      CallErrorAsFatal: 'EvmCoreErrorExitError',
-      Other: 'Text'
-    }
-  },
-  /**
-   * Lookup116: frame_system::Phase
-   **/
-  FrameSystemPhase: {
-    _enum: {
-      ApplyExtrinsic: 'u32',
-      Finalization: 'Null',
-      Initialization: 'Null'
-    }
-  },
-  /**
-   * Lookup118: frame_system::LastRuntimeUpgradeInfo
-   **/
-  FrameSystemLastRuntimeUpgradeInfo: {
-    specVersion: 'Compact<u32>',
-    specName: 'Text'
-  },
-  /**
-   * Lookup119: frame_system::pallet::Call<T>
-   **/
-  FrameSystemCall: {
-    _enum: {
-      fill_block: {
-        ratio: 'Perbill',
-      },
-      remark: {
-        remark: 'Bytes',
-      },
-      set_heap_pages: {
-        pages: 'u64',
-      },
-      set_code: {
-        code: 'Bytes',
-      },
-      set_code_without_checks: {
-        code: 'Bytes',
-      },
-      set_storage: {
-        items: 'Vec<(Bytes,Bytes)>',
-      },
-      kill_storage: {
-        _alias: {
-          keys_: 'keys',
-        },
-        keys_: 'Vec<Bytes>',
-      },
-      kill_prefix: {
-        prefix: 'Bytes',
-        subkeys: 'u32',
-      },
-      remark_with_event: {
-        remark: 'Bytes'
-      }
-    }
-  },
-  /**
-   * Lookup124: frame_system::limits::BlockWeights
-   **/
-  FrameSystemLimitsBlockWeights: {
-    baseBlock: 'u64',
-    maxBlock: 'u64',
-    perClass: 'FrameSupportWeightsPerDispatchClassWeightsPerClass'
-  },
-  /**
-   * Lookup125: frame_support::weights::PerDispatchClass<frame_system::limits::WeightsPerClass>
-   **/
-  FrameSupportWeightsPerDispatchClassWeightsPerClass: {
-    normal: 'FrameSystemLimitsWeightsPerClass',
-    operational: 'FrameSystemLimitsWeightsPerClass',
-    mandatory: 'FrameSystemLimitsWeightsPerClass'
-  },
-  /**
-   * Lookup126: frame_system::limits::WeightsPerClass
-   **/
-  FrameSystemLimitsWeightsPerClass: {
-    baseExtrinsic: 'u64',
-    maxExtrinsic: 'Option<u64>',
-    maxTotal: 'Option<u64>',
-    reserved: 'Option<u64>'
-  },
-  /**
-   * Lookup128: frame_system::limits::BlockLength
+   * Lookup2: polkadot_primitives::v2::PersistedValidationData<primitive_types::H256, N>
    **/
-  FrameSystemLimitsBlockLength: {
-    max: 'FrameSupportWeightsPerDispatchClassU32'
-  },
-  /**
-   * Lookup129: frame_support::weights::PerDispatchClass<T>
-   **/
-  FrameSupportWeightsPerDispatchClassU32: {
-    normal: 'u32',
-    operational: 'u32',
-    mandatory: 'u32'
-  },
-  /**
-   * Lookup130: frame_support::weights::RuntimeDbWeight
-   **/
-  FrameSupportWeightsRuntimeDbWeight: {
-    read: 'u64',
-    write: 'u64'
-  },
-  /**
-   * Lookup131: sp_version::RuntimeVersion
-   **/
-  SpVersionRuntimeVersion: {
-    specName: 'Text',
-    implName: 'Text',
-    authoringVersion: 'u32',
-    specVersion: 'u32',
-    implVersion: 'u32',
-    apis: 'Vec<([u8;8],u32)>',
-    transactionVersion: 'u32',
-    stateVersion: 'u8'
-  },
-  /**
-   * Lookup136: frame_system::pallet::Error<T>
-   **/
-  FrameSystemError: {
-    _enum: ['InvalidSpecName', 'SpecVersionNeedsToIncrease', 'FailedToExtractRuntimeVersion', 'NonDefaultComposite', 'NonZeroRefCount', 'CallFiltered']
-  },
-  /**
-   * Lookup137: polkadot_primitives::v2::PersistedValidationData<primitive_types::H256, N>
-   **/
   PolkadotPrimitivesV2PersistedValidationData: {
     parentHead: 'Bytes',
     relayParentNumber: 'u32',
@@ -1272,19 +14,19 @@
     maxPovSize: 'u32'
   },
   /**
-   * Lookup140: polkadot_primitives::v2::UpgradeRestriction
+   * Lookup9: polkadot_primitives::v2::UpgradeRestriction
    **/
   PolkadotPrimitivesV2UpgradeRestriction: {
     _enum: ['Present']
   },
   /**
-   * Lookup141: sp_trie::storage_proof::StorageProof
+   * Lookup10: sp_trie::storage_proof::StorageProof
    **/
   SpTrieStorageProof: {
     trieNodes: 'BTreeSet<Bytes>'
   },
   /**
-   * Lookup143: cumulus_pallet_parachain_system::relay_state_snapshot::MessagingStateSnapshot
+   * Lookup13: cumulus_pallet_parachain_system::relay_state_snapshot::MessagingStateSnapshot
    **/
   CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot: {
     dmqMqcHead: 'H256',
@@ -1293,7 +35,7 @@
     egressChannels: 'Vec<(u32,PolkadotPrimitivesV2AbridgedHrmpChannel)>'
   },
   /**
-   * Lookup146: polkadot_primitives::v2::AbridgedHrmpChannel
+   * Lookup18: polkadot_primitives::v2::AbridgedHrmpChannel
    **/
   PolkadotPrimitivesV2AbridgedHrmpChannel: {
     maxCapacity: 'u32',
@@ -1304,7 +46,7 @@
     mqcHead: 'Option<H256>'
   },
   /**
-   * Lookup147: polkadot_primitives::v2::AbridgedHostConfiguration
+   * Lookup20: polkadot_primitives::v2::AbridgedHostConfiguration
    **/
   PolkadotPrimitivesV2AbridgedHostConfiguration: {
     maxCodeSize: 'u32',
@@ -1318,14 +60,14 @@
     validationUpgradeDelay: 'u32'
   },
   /**
-   * Lookup153: polkadot_core_primitives::OutboundHrmpMessage<polkadot_parachain::primitives::Id>
+   * Lookup26: polkadot_core_primitives::OutboundHrmpMessage<polkadot_parachain::primitives::Id>
    **/
   PolkadotCorePrimitivesOutboundHrmpMessage: {
     recipient: 'u32',
     data: 'Bytes'
   },
   /**
-   * Lookup154: cumulus_pallet_parachain_system::pallet::Call<T>
+   * Lookup28: cumulus_pallet_parachain_system::pallet::Call<T>
    **/
   CumulusPalletParachainSystemCall: {
     _enum: {
@@ -1344,7 +86,7 @@
     }
   },
   /**
-   * Lookup155: cumulus_primitives_parachain_inherent::ParachainInherentData
+   * Lookup29: cumulus_primitives_parachain_inherent::ParachainInherentData
    **/
   CumulusPrimitivesParachainInherentParachainInherentData: {
     validationData: 'PolkadotPrimitivesV2PersistedValidationData',
@@ -1353,27 +95,58 @@
     horizontalMessages: 'BTreeMap<u32, Vec<PolkadotCorePrimitivesInboundHrmpMessage>>'
   },
   /**
-   * Lookup157: polkadot_core_primitives::InboundDownwardMessage<BlockNumber>
+   * Lookup31: polkadot_core_primitives::InboundDownwardMessage<BlockNumber>
    **/
   PolkadotCorePrimitivesInboundDownwardMessage: {
     sentAt: 'u32',
     msg: 'Bytes'
   },
   /**
-   * Lookup160: polkadot_core_primitives::InboundHrmpMessage<BlockNumber>
+   * Lookup34: polkadot_core_primitives::InboundHrmpMessage<BlockNumber>
    **/
   PolkadotCorePrimitivesInboundHrmpMessage: {
     sentAt: 'u32',
     data: 'Bytes'
   },
   /**
-   * Lookup163: cumulus_pallet_parachain_system::pallet::Error<T>
+   * Lookup37: cumulus_pallet_parachain_system::pallet::Event<T>
+   **/
+  CumulusPalletParachainSystemEvent: {
+    _enum: {
+      ValidationFunctionStored: 'Null',
+      ValidationFunctionApplied: {
+        relayChainBlockNum: 'u32',
+      },
+      ValidationFunctionDiscarded: 'Null',
+      UpgradeAuthorized: {
+        codeHash: 'H256',
+      },
+      DownwardMessagesReceived: {
+        count: 'u32',
+      },
+      DownwardMessagesProcessed: {
+        weightUsed: 'u64',
+        dmqHead: 'H256'
+      }
+    }
+  },
+  /**
+   * Lookup38: cumulus_pallet_parachain_system::pallet::Error<T>
    **/
   CumulusPalletParachainSystemError: {
     _enum: ['OverlappingUpgrades', 'ProhibitedByPolkadot', 'TooBig', 'ValidationDataNotAvailable', 'HostConfigurationNotAvailable', 'NotScheduled', 'NothingAuthorized', 'Unauthorized']
   },
   /**
-   * Lookup165: pallet_balances::BalanceLock<Balance>
+   * Lookup41: pallet_balances::AccountData<Balance>
+   **/
+  PalletBalancesAccountData: {
+    free: 'u128',
+    reserved: 'u128',
+    miscFrozen: 'u128',
+    feeFrozen: 'u128'
+  },
+  /**
+   * Lookup43: pallet_balances::BalanceLock<Balance>
    **/
   PalletBalancesBalanceLock: {
     id: '[u8;8]',
@@ -1381,13 +154,13 @@
     reasons: 'PalletBalancesReasons'
   },
   /**
-   * Lookup166: pallet_balances::Reasons
+   * Lookup45: pallet_balances::Reasons
    **/
   PalletBalancesReasons: {
     _enum: ['Fee', 'Misc', 'All']
   },
   /**
-   * Lookup169: pallet_balances::ReserveData<ReserveIdentifier, Balance>
+   * Lookup48: pallet_balances::ReserveData<ReserveIdentifier, Balance>
    **/
   PalletBalancesReserveData: {
     id: '[u8;16]',
@@ -2706,13 +1479,13 @@
     _enum: ['Unknown', 'OverLimit']
   },
   /**
-   * Lookup347: pallet_unique::Error<T>
+   * Lookup346: pallet_unique::Error<T>
    **/
   PalletUniqueError: {
     _enum: ['CollectionDecimalPointLimitExceeded', 'ConfirmUnsetSponsorFail', 'EmptyArgument', 'RepartitionCalledOnNonRefungibleCollection']
   },
   /**
-   * Lookup350: pallet_unique_scheduler::ScheduledV3<frame_support::traits::schedule::MaybeHashed<opal_runtime::Call, primitive_types::H256>, BlockNumber, opal_runtime::OriginCaller, sp_core::crypto::AccountId32>
+   * Lookup349: pallet_unique_scheduler::ScheduledV3<frame_support::traits::schedule::MaybeHashed<opal_runtime::Call, primitive_types::H256>, BlockNumber, opal_runtime::OriginCaller, sp_core::crypto::AccountId32>
    **/
   PalletUniqueSchedulerScheduledV3: {
     maybeId: 'Option<[u8;16]>',
@@ -2722,7 +1495,7 @@
     origin: 'OpalRuntimeOriginCaller'
   },
   /**
-   * Lookup351: opal_runtime::OriginCaller
+   * Lookup350: opal_runtime::OriginCaller
    **/
   OpalRuntimeOriginCaller: {
     _enum: {
@@ -2831,7 +1604,7 @@
     }
   },
   /**
-   * Lookup352: frame_support::dispatch::RawOrigin<sp_core::crypto::AccountId32>
+   * Lookup351: frame_support::dispatch::RawOrigin<sp_core::crypto::AccountId32>
    **/
   FrameSupportDispatchRawOrigin: {
     _enum: {
@@ -2841,7 +1614,7 @@
     }
   },
   /**
-   * Lookup353: pallet_xcm::pallet::Origin
+   * Lookup352: pallet_xcm::pallet::Origin
    **/
   PalletXcmOrigin: {
     _enum: {
@@ -2850,7 +1623,7 @@
     }
   },
   /**
-   * Lookup354: cumulus_pallet_xcm::pallet::Origin
+   * Lookup353: cumulus_pallet_xcm::pallet::Origin
    **/
   CumulusPalletXcmOrigin: {
     _enum: {
@@ -2859,7 +1632,7 @@
     }
   },
   /**
-   * Lookup355: pallet_ethereum::RawOrigin
+   * Lookup354: pallet_ethereum::RawOrigin
    **/
   PalletEthereumRawOrigin: {
     _enum: {
@@ -2867,17 +1640,17 @@
     }
   },
   /**
-   * Lookup356: sp_core::Void
+   * Lookup355: sp_core::Void
    **/
   SpCoreVoid: 'Null',
   /**
-   * Lookup357: pallet_unique_scheduler::pallet::Error<T>
+   * Lookup356: pallet_unique_scheduler::pallet::Error<T>
    **/
   PalletUniqueSchedulerError: {
     _enum: ['FailedToSchedule', 'NotFound', 'TargetBlockNumberInPast', 'RescheduleNoChange']
   },
   /**
-   * Lookup358: up_data_structs::Collection<sp_core::crypto::AccountId32>
+   * Lookup357: up_data_structs::Collection<sp_core::crypto::AccountId32>
    **/
   UpDataStructsCollection: {
     owner: 'AccountId32',
@@ -2891,7 +1664,7 @@
     externalCollection: 'bool'
   },
   /**
-   * Lookup359: up_data_structs::SponsorshipState<sp_core::crypto::AccountId32>
+   * Lookup358: up_data_structs::SponsorshipState<sp_core::crypto::AccountId32>
    **/
   UpDataStructsSponsorshipState: {
     _enum: {
@@ -2901,7 +1674,7 @@
     }
   },
   /**
-   * Lookup360: up_data_structs::Properties
+   * Lookup359: up_data_structs::Properties
    **/
   UpDataStructsProperties: {
     map: 'UpDataStructsPropertiesMapBoundedVec',
@@ -2909,7 +1682,7 @@
     spaceLimit: 'u32'
   },
   /**
-   * Lookup361: up_data_structs::PropertiesMap<sp_runtime::bounded::bounded_vec::BoundedVec<T, S>>
+   * Lookup360: up_data_structs::PropertiesMap<frame_support::storage::bounded_vec::BoundedVec<T, S>>
    **/
   UpDataStructsPropertiesMapBoundedVec: 'BTreeMap<Bytes, Bytes>',
   /**
@@ -2917,7 +1690,7 @@
    **/
   UpDataStructsPropertiesMapPropertyPermission: 'BTreeMap<Bytes, UpDataStructsPropertyPermission>',
   /**
-   * Lookup373: up_data_structs::CollectionStats
+   * Lookup372: up_data_structs::CollectionStats
    **/
   UpDataStructsCollectionStats: {
     created: 'u32',
@@ -2925,18 +1698,18 @@
     alive: 'u32'
   },
   /**
-   * Lookup374: up_data_structs::TokenChild
+   * Lookup373: up_data_structs::TokenChild
    **/
   UpDataStructsTokenChild: {
     token: 'u32',
     collection: 'u32'
   },
   /**
-   * Lookup375: PhantomType::up_data_structs<T>
+   * Lookup374: PhantomType::up_data_structs<T>
    **/
   PhantomTypeUpDataStructs: '[(UpDataStructsTokenData,UpDataStructsRpcCollection,RmrkTraitsCollectionCollectionInfo,RmrkTraitsNftNftInfo,RmrkTraitsResourceResourceInfo,RmrkTraitsPropertyPropertyInfo,RmrkTraitsBaseBaseInfo,RmrkTraitsPartPartType,RmrkTraitsTheme,RmrkTraitsNftNftChild);0]',
   /**
-   * Lookup377: up_data_structs::TokenData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+   * Lookup376: up_data_structs::TokenData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
    **/
   UpDataStructsTokenData: {
     properties: 'Vec<UpDataStructsProperty>',
@@ -2944,7 +1717,7 @@
     pieces: 'u128'
   },
   /**
-   * Lookup379: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
+   * Lookup378: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
    **/
   UpDataStructsRpcCollection: {
     owner: 'AccountId32',
@@ -2960,7 +1733,7 @@
     readOnly: 'bool'
   },
   /**
-   * Lookup380: rmrk_traits::collection::CollectionInfo<sp_runtime::bounded::bounded_vec::BoundedVec<T, S>, sp_runtime::bounded::bounded_vec::BoundedVec<T, S>, sp_core::crypto::AccountId32>
+   * Lookup379: rmrk_traits::collection::CollectionInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>, sp_core::crypto::AccountId32>
    **/
   RmrkTraitsCollectionCollectionInfo: {
     issuer: 'AccountId32',
@@ -2970,7 +1743,7 @@
     nftsCount: 'u32'
   },
   /**
-   * Lookup381: rmrk_traits::nft::NftInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill, sp_runtime::bounded::bounded_vec::BoundedVec<T, S>>
+   * Lookup380: rmrk_traits::nft::NftInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill, frame_support::storage::bounded_vec::BoundedVec<T, S>>
    **/
   RmrkTraitsNftNftInfo: {
     owner: 'RmrkTraitsNftAccountIdOrCollectionNftTuple',
@@ -2980,14 +1753,14 @@
     pending: 'bool'
   },
   /**
-   * Lookup383: rmrk_traits::nft::RoyaltyInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill>
+   * Lookup382: rmrk_traits::nft::RoyaltyInfo<sp_core::crypto::AccountId32, sp_arithmetic::per_things::Permill>
    **/
   RmrkTraitsNftRoyaltyInfo: {
     recipient: 'AccountId32',
     amount: 'Permill'
   },
   /**
-   * Lookup384: rmrk_traits::resource::ResourceInfo<sp_runtime::bounded::bounded_vec::BoundedVec<T, S>, sp_runtime::bounded::bounded_vec::BoundedVec<T, S>>
+   * Lookup383: rmrk_traits::resource::ResourceInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
    **/
   RmrkTraitsResourceResourceInfo: {
     id: 'u32',
@@ -2996,14 +1769,14 @@
     pendingRemoval: 'bool'
   },
   /**
-   * Lookup385: rmrk_traits::property::PropertyInfo<sp_runtime::bounded::bounded_vec::BoundedVec<T, S>, sp_runtime::bounded::bounded_vec::BoundedVec<T, S>>
+   * Lookup384: rmrk_traits::property::PropertyInfo<frame_support::storage::bounded_vec::BoundedVec<T, S>, frame_support::storage::bounded_vec::BoundedVec<T, S>>
    **/
   RmrkTraitsPropertyPropertyInfo: {
     key: 'Bytes',
     value: 'Bytes'
   },
   /**
-   * Lookup386: rmrk_traits::base::BaseInfo<sp_core::crypto::AccountId32, sp_runtime::bounded::bounded_vec::BoundedVec<T, S>>
+   * Lookup385: rmrk_traits::base::BaseInfo<sp_core::crypto::AccountId32, frame_support::storage::bounded_vec::BoundedVec<T, S>>
    **/
   RmrkTraitsBaseBaseInfo: {
     issuer: 'AccountId32',
@@ -3011,80 +1784,80 @@
     symbol: 'Bytes'
   },
   /**
-   * Lookup387: rmrk_traits::nft::NftChild
+   * Lookup386: rmrk_traits::nft::NftChild
    **/
   RmrkTraitsNftNftChild: {
     collectionId: 'u32',
     nftId: 'u32'
   },
   /**
-   * Lookup389: pallet_common::pallet::Error<T>
+   * Lookup388: pallet_common::pallet::Error<T>
    **/
   PalletCommonError: {
     _enum: ['CollectionNotFound', 'MustBeTokenOwner', 'NoPermission', 'CantDestroyNotEmptyCollection', 'PublicMintingNotAllowed', 'AddressNotInAllowlist', 'CollectionNameLimitExceeded', 'CollectionDescriptionLimitExceeded', 'CollectionTokenPrefixLimitExceeded', 'TotalCollectionsLimitExceeded', 'CollectionAdminCountExceeded', 'CollectionLimitBoundsExceeded', 'OwnerPermissionsCantBeReverted', 'TransferNotAllowed', 'AccountTokenLimitExceeded', 'CollectionTokenLimitExceeded', 'MetadataFlagFrozen', 'TokenNotFound', 'TokenValueTooLow', 'ApprovedValueTooLow', 'CantApproveMoreThanOwned', 'AddressIsZero', 'UnsupportedOperation', 'NotSufficientFounds', 'UserIsNotAllowedToNest', 'SourceCollectionIsNotAllowedToNest', 'CollectionFieldSizeExceeded', 'NoSpaceForProperty', 'PropertyLimitReached', 'PropertyKeyIsTooLong', 'InvalidCharacterInPropertyKey', 'EmptyPropertyKey', 'CollectionIsExternal', 'CollectionIsInternal']
   },
   /**
-   * Lookup391: pallet_fungible::pallet::Error<T>
+   * Lookup390: pallet_fungible::pallet::Error<T>
    **/
   PalletFungibleError: {
     _enum: ['NotFungibleDataUsedToMintFungibleCollectionToken', 'FungibleItemsHaveNoId', 'FungibleItemsDontHaveData', 'FungibleDisallowsNesting', 'SettingPropertiesNotAllowed']
   },
   /**
-   * Lookup392: pallet_refungible::ItemData
+   * Lookup391: pallet_refungible::ItemData
    **/
   PalletRefungibleItemData: {
     constData: 'Bytes'
   },
   /**
-   * Lookup397: pallet_refungible::pallet::Error<T>
+   * Lookup394: pallet_refungible::pallet::Error<T>
    **/
   PalletRefungibleError: {
     _enum: ['NotRefungibleDataUsedToMintFungibleCollectionToken', 'WrongRefungiblePieces', 'RepartitionWhileNotOwningAllPieces', 'RefungibleDisallowsNesting', 'SettingPropertiesNotAllowed']
   },
   /**
-   * Lookup398: pallet_nonfungible::ItemData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
+   * Lookup395: pallet_nonfungible::ItemData<pallet_evm::account::BasicCrossAccountIdRepr<sp_core::crypto::AccountId32>>
    **/
   PalletNonfungibleItemData: {
     owner: 'PalletEvmAccountBasicCrossAccountIdRepr'
   },
   /**
-   * Lookup400: up_data_structs::PropertyScope
+   * Lookup397: up_data_structs::PropertyScope
    **/
   UpDataStructsPropertyScope: {
     _enum: ['None', 'Rmrk', 'Eth']
   },
   /**
-   * Lookup402: pallet_nonfungible::pallet::Error<T>
+   * Lookup399: pallet_nonfungible::pallet::Error<T>
    **/
   PalletNonfungibleError: {
     _enum: ['NotNonfungibleDataUsedToMintFungibleCollectionToken', 'NonfungibleItemsHaveNoAmount', 'CantBurnNftWithChildren']
   },
   /**
-   * Lookup403: pallet_structure::pallet::Error<T>
+   * Lookup400: pallet_structure::pallet::Error<T>
    **/
   PalletStructureError: {
     _enum: ['OuroborosDetected', 'DepthLimit', 'BreadthLimit', 'TokenNotFound']
   },
   /**
-   * Lookup404: pallet_rmrk_core::pallet::Error<T>
+   * Lookup401: pallet_rmrk_core::pallet::Error<T>
    **/
   PalletRmrkCoreError: {
     _enum: ['CorruptedCollectionType', 'RmrkPropertyKeyIsTooLong', 'RmrkPropertyValueIsTooLong', 'RmrkPropertyIsNotFound', 'UnableToDecodeRmrkData', 'CollectionNotEmpty', 'NoAvailableCollectionId', 'NoAvailableNftId', 'CollectionUnknown', 'NoPermission', 'NonTransferable', 'CollectionFullOrLocked', 'ResourceDoesntExist', 'CannotSendToDescendentOrSelf', 'CannotAcceptNonOwnedNft', 'CannotRejectNonOwnedNft', 'CannotRejectNonPendingNft', 'ResourceNotPending', 'NoAvailableResourceId']
   },
   /**
-   * Lookup406: pallet_rmrk_equip::pallet::Error<T>
+   * Lookup403: pallet_rmrk_equip::pallet::Error<T>
    **/
   PalletRmrkEquipError: {
     _enum: ['PermissionError', 'NoAvailableBaseId', 'NoAvailablePartId', 'BaseDoesntExist', 'NeedsDefaultThemeFirst', 'PartDoesntExist', 'NoEquippableOnFixedPart']
   },
   /**
-   * Lookup409: pallet_evm::pallet::Error<T>
+   * Lookup406: pallet_evm::pallet::Error<T>
    **/
   PalletEvmError: {
     _enum: ['BalanceLow', 'FeeOverflow', 'PaymentOverflow', 'WithdrawFailed', 'GasPriceTooLow', 'InvalidNonce']
   },
   /**
-   * Lookup412: fp_rpc::TransactionStatus
+   * Lookup409: fp_rpc::TransactionStatus
    **/
   FpRpcTransactionStatus: {
     transactionHash: 'H256',
@@ -3096,11 +1869,11 @@
     logsBloom: 'EthbloomBloom'
   },
   /**
-   * Lookup414: ethbloom::Bloom
+   * Lookup411: ethbloom::Bloom
    **/
   EthbloomBloom: '[u8;256]',
   /**
-   * Lookup416: ethereum::receipt::ReceiptV3
+   * Lookup413: ethereum::receipt::ReceiptV3
    **/
   EthereumReceiptReceiptV3: {
     _enum: {
@@ -3110,7 +1883,7 @@
     }
   },
   /**
-   * Lookup417: ethereum::receipt::EIP658ReceiptData
+   * Lookup414: ethereum::receipt::EIP658ReceiptData
    **/
   EthereumReceiptEip658ReceiptData: {
     statusCode: 'u8',
@@ -3119,7 +1892,7 @@
     logs: 'Vec<EthereumLog>'
   },
   /**
-   * Lookup418: ethereum::block::Block<ethereum::transaction::TransactionV2>
+   * Lookup415: ethereum::block::Block<ethereum::transaction::TransactionV2>
    **/
   EthereumBlock: {
     header: 'EthereumHeader',
@@ -3127,7 +1900,7 @@
     ommers: 'Vec<EthereumHeader>'
   },
   /**
-   * Lookup419: ethereum::header::Header
+   * Lookup416: ethereum::header::Header
    **/
   EthereumHeader: {
     parentHash: 'H256',
@@ -3147,41 +1920,41 @@
     nonce: 'EthereumTypesHashH64'
   },
   /**
-   * Lookup420: ethereum_types::hash::H64
+   * Lookup417: ethereum_types::hash::H64
    **/
   EthereumTypesHashH64: '[u8;8]',
   /**
-   * Lookup425: pallet_ethereum::pallet::Error<T>
+   * Lookup422: pallet_ethereum::pallet::Error<T>
    **/
   PalletEthereumError: {
     _enum: ['InvalidSignature', 'PreLogExists']
   },
   /**
-   * Lookup426: pallet_evm_coder_substrate::pallet::Error<T>
+   * Lookup423: pallet_evm_coder_substrate::pallet::Error<T>
    **/
   PalletEvmCoderSubstrateError: {
     _enum: ['OutOfGas', 'OutOfFund']
   },
   /**
-   * Lookup427: pallet_evm_contract_helpers::SponsoringModeT
+   * Lookup424: pallet_evm_contract_helpers::SponsoringModeT
    **/
   PalletEvmContractHelpersSponsoringModeT: {
     _enum: ['Disabled', 'Allowlisted', 'Generous']
   },
   /**
-   * Lookup429: pallet_evm_contract_helpers::pallet::Error<T>
+   * Lookup426: pallet_evm_contract_helpers::pallet::Error<T>
    **/
   PalletEvmContractHelpersError: {
     _enum: ['NoPermission']
   },
   /**
-   * Lookup430: pallet_evm_migration::pallet::Error<T>
+   * Lookup427: pallet_evm_migration::pallet::Error<T>
    **/
   PalletEvmMigrationError: {
     _enum: ['AccountNotEmpty', 'AccountIsNotMigrating']
   },
   /**
-   * Lookup432: sp_runtime::MultiSignature
+   * Lookup429: sp_runtime::MultiSignature
    **/
   SpRuntimeMultiSignature: {
     _enum: {
@@ -3191,43 +1964,43 @@
     }
   },
   /**
-   * Lookup433: sp_core::ed25519::Signature
+   * Lookup430: sp_core::ed25519::Signature
    **/
   SpCoreEd25519Signature: '[u8;64]',
   /**
-   * Lookup435: sp_core::sr25519::Signature
+   * Lookup434: sp_core::sr25519::Signature
    **/
   SpCoreSr25519Signature: '[u8;64]',
   /**
-   * Lookup436: sp_core::ecdsa::Signature
+   * Lookup435: sp_core::ecdsa::Signature
    **/
   SpCoreEcdsaSignature: '[u8;65]',
   /**
-   * Lookup439: frame_system::extensions::check_spec_version::CheckSpecVersion<T>
+   * Lookup438: frame_system::extensions::check_spec_version::CheckSpecVersion<T>
    **/
   FrameSystemExtensionsCheckSpecVersion: 'Null',
   /**
-   * Lookup440: frame_system::extensions::check_genesis::CheckGenesis<T>
+   * Lookup439: frame_system::extensions::check_genesis::CheckGenesis<T>
    **/
   FrameSystemExtensionsCheckGenesis: 'Null',
   /**
-   * Lookup443: frame_system::extensions::check_nonce::CheckNonce<T>
+   * Lookup442: frame_system::extensions::check_nonce::CheckNonce<T>
    **/
   FrameSystemExtensionsCheckNonce: 'Compact<u32>',
   /**
-   * Lookup444: frame_system::extensions::check_weight::CheckWeight<T>
+   * Lookup443: frame_system::extensions::check_weight::CheckWeight<T>
    **/
   FrameSystemExtensionsCheckWeight: 'Null',
   /**
-   * Lookup445: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
+   * Lookup444: pallet_template_transaction_payment::ChargeTransactionPayment<opal_runtime::Runtime>
    **/
   PalletTemplateTransactionPaymentChargeTransactionPayment: 'Compact<u128>',
   /**
-   * Lookup446: opal_runtime::Runtime
+   * Lookup445: opal_runtime::Runtime
    **/
   OpalRuntimeRuntime: 'Null',
   /**
-   * Lookup447: pallet_ethereum::FakeTransactionFinalizer<opal_runtime::Runtime>
+   * Lookup444: pallet_ethereum::FakeTransactionFinalizer<opal_runtime::Runtime>
    **/
   PalletEthereumFakeTransactionFinalizer: 'Null'
 };
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -1393,28 +1393,7 @@
     readonly type: 'StartInflation';
   }
 
-  /** @name PalletAppPromotionCall (148) */
-  export interface PalletAppPromotionCall extends Enum {
-    readonly isSetAdminAddress: boolean;
-    readonly asSetAdminAddress: {
-      readonly admin: AccountId32;
-    } & Struct;
-    readonly isStartAppPromotion: boolean;
-    readonly asStartAppPromotion: {
-      readonly promotionStartRelayBlock: u32;
-    } & Struct;
-    readonly isStake: boolean;
-    readonly asStake: {
-      readonly amount: u128;
-    } & Struct;
-    readonly isUnstake: boolean;
-    readonly asUnstake: {
-      readonly amount: u128;
-    } & Struct;
-    readonly type: 'SetAdminAddress' | 'StartAppPromotion' | 'Stake' | 'Unstake';
-  }
-
-  /** @name PalletUniqueCall (149) */
+  /** @name PalletUniqueCall (148) */
   export interface PalletUniqueCall extends Enum {
     readonly isCreateCollection: boolean;
     readonly asCreateCollection: {
@@ -1629,164 +1608,28 @@
       readonly nftId: u32;
       readonly resourceId: u32;
     } & Struct;
-    readonly isResourceRemovalAccepted: boolean;
-    readonly asResourceRemovalAccepted: {
-      readonly nftId: u32;
-      readonly resourceId: u32;
-    } & Struct;
-    readonly isPrioritySet: boolean;
-    readonly asPrioritySet: {
+    readonly isCreateMultipleItemsEx: boolean;
+    readonly asCreateMultipleItemsEx: {
       readonly collectionId: u32;
-      readonly nftId: u32;
-    } & Struct;
-    readonly type: 'CollectionCreated' | 'CollectionDestroyed' | 'IssuerChanged' | 'CollectionLocked' | 'NftMinted' | 'NftBurned' | 'NftSent' | 'NftAccepted' | 'NftRejected' | 'PropertySet' | 'ResourceAdded' | 'ResourceRemoval' | 'ResourceAccepted' | 'ResourceRemovalAccepted' | 'PrioritySet';
-  }
-
-<<<<<<< HEAD
-  /** @name RmrkTraitsNftAccountIdOrCollectionNftTuple (97) */
-  interface RmrkTraitsNftAccountIdOrCollectionNftTuple extends Enum {
-    readonly isAccountId: boolean;
-    readonly asAccountId: AccountId32;
-    readonly isCollectionAndNftTuple: boolean;
-    readonly asCollectionAndNftTuple: ITuple<[u32, u32]>;
-    readonly type: 'AccountId' | 'CollectionAndNftTuple';
-  }
-
-  /** @name PalletRmrkEquipEvent (102) */
-  interface PalletRmrkEquipEvent extends Enum {
-    readonly isBaseCreated: boolean;
-    readonly asBaseCreated: {
-      readonly issuer: AccountId32;
-      readonly baseId: u32;
+      readonly data: UpDataStructsCreateItemExData;
     } & Struct;
-    readonly isEquippablesUpdated: boolean;
-    readonly asEquippablesUpdated: {
-      readonly baseId: u32;
-      readonly slotId: u32;
-    } & Struct;
-    readonly type: 'BaseCreated' | 'EquippablesUpdated';
-  }
-
-  /** @name PalletEvmEvent (103) */
-  interface PalletEvmEvent extends Enum {
-    readonly isLog: boolean;
-    readonly asLog: EthereumLog;
-    readonly isCreated: boolean;
-    readonly asCreated: H160;
-    readonly isCreatedFailed: boolean;
-    readonly asCreatedFailed: H160;
-    readonly isExecuted: boolean;
-    readonly asExecuted: H160;
-    readonly isExecutedFailed: boolean;
-    readonly asExecutedFailed: H160;
-    readonly isBalanceDeposit: boolean;
-    readonly asBalanceDeposit: ITuple<[AccountId32, H160, U256]>;
-    readonly isBalanceWithdraw: boolean;
-    readonly asBalanceWithdraw: ITuple<[AccountId32, H160, U256]>;
-    readonly type: 'Log' | 'Created' | 'CreatedFailed' | 'Executed' | 'ExecutedFailed' | 'BalanceDeposit' | 'BalanceWithdraw';
-  }
-
-  /** @name EthereumLog (104) */
-  interface EthereumLog extends Struct {
-    readonly address: H160;
-    readonly topics: Vec<H256>;
-    readonly data: Bytes;
-  }
-
-  /** @name PalletEthereumEvent (108) */
-  interface PalletEthereumEvent extends Enum {
-    readonly isExecuted: boolean;
-    readonly asExecuted: ITuple<[H160, H160, H256, EvmCoreErrorExitReason]>;
-    readonly type: 'Executed';
-  }
-
-  /** @name EvmCoreErrorExitReason (109) */
-  interface EvmCoreErrorExitReason extends Enum {
-    readonly isSucceed: boolean;
-    readonly asSucceed: EvmCoreErrorExitSucceed;
-    readonly isError: boolean;
-    readonly asError: EvmCoreErrorExitError;
-    readonly isRevert: boolean;
-    readonly asRevert: EvmCoreErrorExitRevert;
-    readonly isFatal: boolean;
-    readonly asFatal: EvmCoreErrorExitFatal;
-    readonly type: 'Succeed' | 'Error' | 'Revert' | 'Fatal';
-  }
-
-  /** @name EvmCoreErrorExitSucceed (110) */
-  interface EvmCoreErrorExitSucceed extends Enum {
-    readonly isStopped: boolean;
-    readonly isReturned: boolean;
-    readonly isSuicided: boolean;
-    readonly type: 'Stopped' | 'Returned' | 'Suicided';
-  }
-
-  /** @name EvmCoreErrorExitError (111) */
-  interface EvmCoreErrorExitError extends Enum {
-    readonly isStackUnderflow: boolean;
-    readonly isStackOverflow: boolean;
-    readonly isInvalidJump: boolean;
-    readonly isInvalidRange: boolean;
-    readonly isDesignatedInvalid: boolean;
-    readonly isCallTooDeep: boolean;
-    readonly isCreateCollision: boolean;
-    readonly isCreateContractLimit: boolean;
-    readonly isOutOfOffset: boolean;
-    readonly isOutOfGas: boolean;
-    readonly isOutOfFund: boolean;
-    readonly isPcUnderflow: boolean;
-    readonly isCreateEmpty: boolean;
-    readonly isOther: boolean;
-    readonly asOther: Text;
-    readonly isInvalidCode: boolean;
-    readonly type: 'StackUnderflow' | 'StackOverflow' | 'InvalidJump' | 'InvalidRange' | 'DesignatedInvalid' | 'CallTooDeep' | 'CreateCollision' | 'CreateContractLimit' | 'OutOfOffset' | 'OutOfGas' | 'OutOfFund' | 'PcUnderflow' | 'CreateEmpty' | 'Other' | 'InvalidCode';
-  }
-
-  /** @name EvmCoreErrorExitRevert (114) */
-  interface EvmCoreErrorExitRevert extends Enum {
-    readonly isReverted: boolean;
-    readonly type: 'Reverted';
-  }
-
-  /** @name EvmCoreErrorExitFatal (115) */
-  interface EvmCoreErrorExitFatal extends Enum {
-    readonly isNotSupported: boolean;
-    readonly isUnhandledInterrupt: boolean;
-    readonly isCallErrorAsFatal: boolean;
-    readonly asCallErrorAsFatal: EvmCoreErrorExitError;
-    readonly isOther: boolean;
-    readonly asOther: Text;
-    readonly type: 'NotSupported' | 'UnhandledInterrupt' | 'CallErrorAsFatal' | 'Other';
-  }
-
-  /** @name FrameSystemPhase (116) */
-  interface FrameSystemPhase extends Enum {
-    readonly isApplyExtrinsic: boolean;
-    readonly asApplyExtrinsic: u32;
-    readonly isFinalization: boolean;
-    readonly isInitialization: boolean;
-    readonly type: 'ApplyExtrinsic' | 'Finalization' | 'Initialization';
-  }
-
-  /** @name FrameSystemLastRuntimeUpgradeInfo (118) */
-  interface FrameSystemLastRuntimeUpgradeInfo extends Struct {
-    readonly specVersion: Compact<u32>;
-    readonly specName: Text;
-  }
-
-  /** @name FrameSystemCall (119) */
-  interface FrameSystemCall extends Enum {
-    readonly isFillBlock: boolean;
-    readonly asFillBlock: {
-      readonly ratio: Perbill;
+    readonly isSetTransfersEnabledFlag: boolean;
+    readonly asSetTransfersEnabledFlag: {
+      readonly collectionId: u32;
+      readonly value: bool;
     } & Struct;
-    readonly isRemark: boolean;
-    readonly asRemark: {
-      readonly remark: Bytes;
+    readonly isBurnItem: boolean;
+    readonly asBurnItem: {
+      readonly collectionId: u32;
+      readonly itemId: u32;
+      readonly value: u128;
     } & Struct;
-    readonly isSetHeapPages: boolean;
-    readonly asSetHeapPages: {
-      readonly pages: u64;
+    readonly isBurnFrom: boolean;
+    readonly asBurnFrom: {
+      readonly collectionId: u32;
+      readonly from: PalletEvmAccountBasicCrossAccountIdRepr;
+      readonly itemId: u32;
+      readonly value: u128;
     } & Struct;
     readonly isSetCode: boolean;
     readonly asSetCode: {
@@ -1813,21 +1656,7 @@
     readonly asRemarkWithEvent: {
       readonly remark: Bytes;
     } & Struct;
-    readonly type: 'FillBlock' | 'Remark' | 'SetHeapPages' | 'SetCode' | 'SetCodeWithoutChecks' | 'SetStorage' | 'KillStorage' | 'KillPrefix' | 'RemarkWithEvent';
-  }
-
-  /** @name FrameSystemLimitsBlockWeights (124) */
-  interface FrameSystemLimitsBlockWeights extends Struct {
-    readonly baseBlock: u64;
-    readonly maxBlock: u64;
-    readonly perClass: FrameSupportWeightsPerDispatchClassWeightsPerClass;
-  }
-
-  /** @name FrameSupportWeightsPerDispatchClassWeightsPerClass (125) */
-  interface FrameSupportWeightsPerDispatchClassWeightsPerClass extends Struct {
-    readonly normal: FrameSystemLimitsWeightsPerClass;
-    readonly operational: FrameSystemLimitsWeightsPerClass;
-    readonly mandatory: FrameSystemLimitsWeightsPerClass;
+    readonly type: 'CreateCollection' | 'CreateCollectionEx' | 'DestroyCollection' | 'AddToAllowList' | 'RemoveFromAllowList' | 'ChangeCollectionOwner' | 'AddCollectionAdmin' | 'RemoveCollectionAdmin' | 'SetCollectionSponsor' | 'ConfirmSponsorship' | 'RemoveCollectionSponsor' | 'CreateItem' | 'CreateMultipleItems' | 'SetCollectionProperties' | 'DeleteCollectionProperties' | 'SetTokenProperties' | 'DeleteTokenProperties' | 'SetTokenPropertyPermissions' | 'CreateMultipleItemsEx' | 'SetTransfersEnabledFlag' | 'BurnItem' | 'BurnFrom' | 'Transfer' | 'Approve' | 'TransferFrom' | 'SetCollectionLimits' | 'SetCollectionPermissions' | 'Repartition';
   }
 
   /** @name UpDataStructsCollectionMode (155) */
@@ -1839,7 +1668,7 @@
     readonly type: 'Nft' | 'Fungible' | 'ReFungible';
   }
 
-  /** @name UpDataStructsCreateCollectionData (156) */
+  /** @name UpDataStructsCreateCollectionData (155) */
   export interface UpDataStructsCreateCollectionData extends Struct {
     readonly mode: UpDataStructsCollectionMode;
     readonly access: Option<UpDataStructsAccessMode>;
@@ -1853,14 +1682,14 @@
     readonly properties: Vec<UpDataStructsProperty>;
   }
 
-  /** @name UpDataStructsAccessMode (158) */
+  /** @name UpDataStructsAccessMode (157) */
   export interface UpDataStructsAccessMode extends Enum {
     readonly isNormal: boolean;
     readonly isAllowList: boolean;
     readonly type: 'Normal' | 'AllowList';
   }
 
-  /** @name UpDataStructsCollectionLimits (161) */
+  /** @name UpDataStructsCollectionLimits (160) */
   export interface UpDataStructsCollectionLimits extends Struct {
     readonly accountTokenOwnershipLimit: Option<u32>;
     readonly sponsoredDataSize: Option<u32>;
@@ -1873,7 +1702,7 @@
     readonly transfersEnabled: Option<bool>;
   }
 
-  /** @name UpDataStructsSponsoringRateLimit (163) */
+  /** @name UpDataStructsSponsoringRateLimit (162) */
   export interface UpDataStructsSponsoringRateLimit extends Enum {
     readonly isSponsoringDisabled: boolean;
     readonly isBlocks: boolean;
@@ -1881,43 +1710,43 @@
     readonly type: 'SponsoringDisabled' | 'Blocks';
   }
 
-  /** @name UpDataStructsCollectionPermissions (166) */
+  /** @name UpDataStructsCollectionPermissions (165) */
   export interface UpDataStructsCollectionPermissions extends Struct {
     readonly access: Option<UpDataStructsAccessMode>;
     readonly mintMode: Option<bool>;
     readonly nesting: Option<UpDataStructsNestingPermissions>;
   }
 
-  /** @name UpDataStructsNestingPermissions (168) */
+  /** @name UpDataStructsNestingPermissions (167) */
   export interface UpDataStructsNestingPermissions extends Struct {
     readonly tokenOwner: bool;
     readonly collectionAdmin: bool;
     readonly restricted: Option<UpDataStructsOwnerRestrictedSet>;
   }
 
-  /** @name UpDataStructsOwnerRestrictedSet (170) */
+  /** @name UpDataStructsOwnerRestrictedSet (169) */
   export interface UpDataStructsOwnerRestrictedSet extends BTreeSet<u32> {}
 
-  /** @name UpDataStructsPropertyKeyPermission (176) */
+  /** @name UpDataStructsPropertyKeyPermission (175) */
   export interface UpDataStructsPropertyKeyPermission extends Struct {
     readonly key: Bytes;
     readonly permission: UpDataStructsPropertyPermission;
   }
 
-  /** @name UpDataStructsPropertyPermission (178) */
+  /** @name UpDataStructsPropertyPermission (177) */
   export interface UpDataStructsPropertyPermission extends Struct {
     readonly mutable: bool;
     readonly collectionAdmin: bool;
     readonly tokenOwner: bool;
   }
 
-  /** @name UpDataStructsProperty (181) */
+  /** @name UpDataStructsProperty (180) */
   export interface UpDataStructsProperty extends Struct {
     readonly key: Bytes;
     readonly value: Bytes;
   }
 
-  /** @name PalletEvmAccountBasicCrossAccountIdRepr (184) */
+  /** @name PalletEvmAccountBasicCrossAccountIdRepr (183) */
   export interface PalletEvmAccountBasicCrossAccountIdRepr extends Enum {
     readonly isSubstrate: boolean;
     readonly asSubstrate: AccountId32;
@@ -1926,7 +1755,7 @@
     readonly type: 'Substrate' | 'Ethereum';
   }
 
-  /** @name UpDataStructsCreateItemData (186) */
+  /** @name UpDataStructsCreateItemData (185) */
   export interface UpDataStructsCreateItemData extends Enum {
     readonly isNft: boolean;
     readonly asNft: UpDataStructsCreateNftData;
@@ -1937,17 +1766,17 @@
     readonly type: 'Nft' | 'Fungible' | 'ReFungible';
   }
 
-  /** @name UpDataStructsCreateNftData (187) */
+  /** @name UpDataStructsCreateNftData (186) */
   export interface UpDataStructsCreateNftData extends Struct {
     readonly properties: Vec<UpDataStructsProperty>;
   }
 
-  /** @name UpDataStructsCreateFungibleData (188) */
+  /** @name UpDataStructsCreateFungibleData (187) */
   export interface UpDataStructsCreateFungibleData extends Struct {
     readonly value: u128;
   }
 
-  /** @name UpDataStructsCreateReFungibleData (189) */
+  /** @name UpDataStructsCreateReFungibleData (188) */
   export interface UpDataStructsCreateReFungibleData extends Struct {
     readonly pieces: u128;
     readonly properties: Vec<UpDataStructsProperty>;
@@ -2028,7 +1857,7 @@
     readonly properties: Vec<UpDataStructsProperty>;
   }
 
-  /** @name PalletUniqueSchedulerCall (205) */
+  /** @name PalletUniqueSchedulerCall (204) */
   export interface PalletUniqueSchedulerCall extends Enum {
     readonly isScheduleNamed: boolean;
     readonly asScheduleNamed: {
@@ -2053,7 +1882,7 @@
     readonly type: 'ScheduleNamed' | 'CancelNamed' | 'ScheduleNamedAfter';
   }
 
-  /** @name FrameSupportScheduleMaybeHashed (207) */
+  /** @name FrameSupportScheduleMaybeHashed (206) */
   export interface FrameSupportScheduleMaybeHashed extends Enum {
     readonly isValue: boolean;
     readonly asValue: Call;
@@ -2062,13 +1891,13 @@
     readonly type: 'Value' | 'Hash';
   }
 
-  /** @name PalletTemplateTransactionPaymentCall (208) */
+  /** @name PalletTemplateTransactionPaymentCall (207) */
   export type PalletTemplateTransactionPaymentCall = Null;
 
-  /** @name PalletStructureCall (209) */
+  /** @name PalletStructureCall (208) */
   export type PalletStructureCall = Null;
 
-  /** @name PalletRmrkCoreCall (210) */
+  /** @name PalletRmrkCoreCall (209) */
   export interface PalletRmrkCoreCall extends Enum {
     readonly isCreateCollection: boolean;
     readonly asCreateCollection: {
@@ -2174,7 +2003,7 @@
     readonly type: 'CreateCollection' | 'DestroyCollection' | 'ChangeCollectionIssuer' | 'LockCollection' | 'MintNft' | 'BurnNft' | 'Send' | 'AcceptNft' | 'RejectNft' | 'AcceptResource' | 'AcceptResourceRemoval' | 'SetProperty' | 'SetPriority' | 'AddBasicResource' | 'AddComposableResource' | 'AddSlotResource' | 'RemoveResource';
   }
 
-  /** @name RmrkTraitsResourceResourceTypes (216) */
+  /** @name RmrkTraitsResourceResourceTypes (215) */
   export interface RmrkTraitsResourceResourceTypes extends Enum {
     readonly isBasic: boolean;
     readonly asBasic: RmrkTraitsResourceBasicResource;
@@ -2185,7 +2014,7 @@
     readonly type: 'Basic' | 'Composable' | 'Slot';
   }
 
-  /** @name RmrkTraitsResourceBasicResource (218) */
+  /** @name RmrkTraitsResourceBasicResource (217) */
   export interface RmrkTraitsResourceBasicResource extends Struct {
     readonly src: Option<Bytes>;
     readonly metadata: Option<Bytes>;
@@ -2193,7 +2022,7 @@
     readonly thumb: Option<Bytes>;
   }
 
-  /** @name RmrkTraitsResourceComposableResource (220) */
+  /** @name RmrkTraitsResourceComposableResource (219) */
   export interface RmrkTraitsResourceComposableResource extends Struct {
     readonly parts: Vec<u32>;
     readonly base: u32;
@@ -2203,7 +2032,7 @@
     readonly thumb: Option<Bytes>;
   }
 
-  /** @name RmrkTraitsResourceSlotResource (221) */
+  /** @name RmrkTraitsResourceSlotResource (220) */
   export interface RmrkTraitsResourceSlotResource extends Struct {
     readonly base: u32;
     readonly src: Option<Bytes>;
@@ -2213,7 +2042,7 @@
     readonly thumb: Option<Bytes>;
   }
 
-  /** @name RmrkTraitsNftAccountIdOrCollectionNftTuple (223) */
+  /** @name RmrkTraitsNftAccountIdOrCollectionNftTuple (222) */
   export interface RmrkTraitsNftAccountIdOrCollectionNftTuple extends Enum {
     readonly isAccountId: boolean;
     readonly asAccountId: AccountId32;
@@ -2222,7 +2051,7 @@
     readonly type: 'AccountId' | 'CollectionAndNftTuple';
   }
 
-  /** @name PalletRmrkEquipCall (227) */
+  /** @name PalletRmrkEquipCall (226) */
   export interface PalletRmrkEquipCall extends Enum {
     readonly isCreateBase: boolean;
     readonly asCreateBase: {
@@ -2244,7 +2073,7 @@
     readonly type: 'CreateBase' | 'ThemeAdd' | 'Equippable';
   }
 
-  /** @name RmrkTraitsPartPartType (230) */
+  /** @name RmrkTraitsPartPartType (229) */
   export interface RmrkTraitsPartPartType extends Enum {
     readonly isFixedPart: boolean;
     readonly asFixedPart: RmrkTraitsPartFixedPart;
@@ -2253,14 +2082,14 @@
     readonly type: 'FixedPart' | 'SlotPart';
   }
 
-  /** @name RmrkTraitsPartFixedPart (232) */
+  /** @name RmrkTraitsPartFixedPart (231) */
   export interface RmrkTraitsPartFixedPart extends Struct {
     readonly id: u32;
     readonly z: u32;
     readonly src: Bytes;
   }
 
-  /** @name RmrkTraitsPartSlotPart (233) */
+  /** @name RmrkTraitsPartSlotPart (232) */
   export interface RmrkTraitsPartSlotPart extends Struct {
     readonly id: u32;
     readonly equippable: RmrkTraitsPartEquippableList;
@@ -2268,25 +2097,46 @@
     readonly z: u32;
   }
 
-  /** @name RmrkTraitsPartEquippableList (234) */
+  /** @name RmrkTraitsPartEquippableList (233) */
   export interface RmrkTraitsPartEquippableList extends Enum {
     readonly isAll: boolean;
     readonly type: 'Fee' | 'Misc' | 'All';
   }
 
-  /** @name RmrkTraitsTheme (236) */
+  /** @name RmrkTraitsTheme (235) */
   export interface RmrkTraitsTheme extends Struct {
     readonly name: Bytes;
     readonly properties: Vec<RmrkTraitsThemeThemeProperty>;
     readonly inherit: bool;
   }
 
-  /** @name RmrkTraitsThemeThemeProperty (238) */
+  /** @name RmrkTraitsThemeThemeProperty (237) */
   export interface RmrkTraitsThemeThemeProperty extends Struct {
     readonly key: Bytes;
     readonly value: Bytes;
   }
 
+  /** @name PalletAppPromotionCall (239) */
+  export interface PalletAppPromotionCall extends Enum {
+    readonly isSetAdminAddress: boolean;
+    readonly asSetAdminAddress: {
+      readonly admin: AccountId32;
+    } & Struct;
+    readonly isStartAppPromotion: boolean;
+    readonly asStartAppPromotion: {
+      readonly promotionStartRelayBlock: u32;
+    } & Struct;
+    readonly isStake: boolean;
+    readonly asStake: {
+      readonly amount: u128;
+    } & Struct;
+    readonly isUnstake: boolean;
+    readonly asUnstake: {
+      readonly amount: u128;
+    } & Struct;
+    readonly type: 'SetAdminAddress' | 'StartAppPromotion' | 'Stake' | 'Unstake';
+  }
+
   /** @name PalletEvmCall (240) */
   export interface PalletEvmCall extends Enum {
     readonly isWithdraw: boolean;
@@ -3213,7 +3063,7 @@
     readonly type: 'Unknown' | 'OverLimit';
   }
 
-  /** @name PalletUniqueError (346) */
+  /** @name PalletUniqueError (345) */
   export interface PalletUniqueError extends Enum {
     readonly isCollectionDecimalPointLimitExceeded: boolean;
     readonly isConfirmUnsetSponsorFail: boolean;
@@ -3222,7 +3072,7 @@
     readonly type: 'CollectionDecimalPointLimitExceeded' | 'ConfirmUnsetSponsorFail' | 'EmptyArgument' | 'RepartitionCalledOnNonRefungibleCollection';
   }
 
-  /** @name PalletUniqueSchedulerScheduledV3 (349) */
+  /** @name PalletUniqueSchedulerScheduledV3 (348) */
   export interface PalletUniqueSchedulerScheduledV3 extends Struct {
     readonly maybeId: Option<U8aFixed>;
     readonly priority: u8;
@@ -3231,7 +3081,7 @@
     readonly origin: OpalRuntimeOriginCaller;
   }
 
-  /** @name OpalRuntimeOriginCaller (350) */
+  /** @name OpalRuntimeOriginCaller (349) */
   export interface OpalRuntimeOriginCaller extends Enum {
     readonly isVoid: boolean;
     readonly isSystem: boolean;
@@ -3246,7 +3096,7 @@
     readonly type: 'System' | 'Void' | 'PolkadotXcm' | 'CumulusXcm' | 'Ethereum';
   }
 
-  /** @name FrameSupportDispatchRawOrigin (351) */
+  /** @name FrameSupportDispatchRawOrigin (350) */
   export interface FrameSupportDispatchRawOrigin extends Enum {
     readonly isRoot: boolean;
     readonly isSigned: boolean;
@@ -3255,7 +3105,7 @@
     readonly type: 'Root' | 'Signed' | 'None';
   }
 
-  /** @name PalletXcmOrigin (352) */
+  /** @name PalletXcmOrigin (351) */
   export interface PalletXcmOrigin extends Enum {
     readonly isXcm: boolean;
     readonly asXcm: XcmV1MultiLocation;
@@ -3264,7 +3114,7 @@
     readonly type: 'Xcm' | 'Response';
   }
 
-  /** @name CumulusPalletXcmOrigin (353) */
+  /** @name CumulusPalletXcmOrigin (352) */
   export interface CumulusPalletXcmOrigin extends Enum {
     readonly isRelay: boolean;
     readonly isSiblingParachain: boolean;
@@ -3272,17 +3122,17 @@
     readonly type: 'Relay' | 'SiblingParachain';
   }
 
-  /** @name PalletEthereumRawOrigin (354) */
+  /** @name PalletEthereumRawOrigin (353) */
   export interface PalletEthereumRawOrigin extends Enum {
     readonly isEthereumTransaction: boolean;
     readonly asEthereumTransaction: H160;
     readonly type: 'EthereumTransaction';
   }
 
-  /** @name SpCoreVoid (355) */
+  /** @name SpCoreVoid (354) */
   export type SpCoreVoid = Null;
 
-  /** @name PalletUniqueSchedulerError (356) */
+  /** @name PalletUniqueSchedulerError (355) */
   export interface PalletUniqueSchedulerError extends Enum {
     readonly isFailedToSchedule: boolean;
     readonly isNotFound: boolean;
@@ -3291,7 +3141,7 @@
     readonly type: 'FailedToSchedule' | 'NotFound' | 'TargetBlockNumberInPast' | 'RescheduleNoChange';
   }
 
-  /** @name UpDataStructsCollection (357) */
+  /** @name UpDataStructsCollection (356) */
   export interface UpDataStructsCollection extends Struct {
     readonly owner: AccountId32;
     readonly mode: UpDataStructsCollectionMode;
@@ -3304,7 +3154,7 @@
     readonly externalCollection: bool;
   }
 
-  /** @name UpDataStructsSponsorshipState (358) */
+  /** @name UpDataStructsSponsorshipState (357) */
   export interface UpDataStructsSponsorshipState extends Enum {
     readonly isDisabled: boolean;
     readonly isUnconfirmed: boolean;
@@ -3314,43 +3164,43 @@
     readonly type: 'Disabled' | 'Unconfirmed' | 'Confirmed';
   }
 
-  /** @name UpDataStructsProperties (359) */
+  /** @name UpDataStructsProperties (358) */
   export interface UpDataStructsProperties extends Struct {
     readonly map: UpDataStructsPropertiesMapBoundedVec;
     readonly consumedSpace: u32;
     readonly spaceLimit: u32;
   }
 
-  /** @name UpDataStructsPropertiesMapBoundedVec (360) */
+  /** @name UpDataStructsPropertiesMapBoundedVec (359) */
   export interface UpDataStructsPropertiesMapBoundedVec extends BTreeMap<Bytes, Bytes> {}
 
-  /** @name UpDataStructsPropertiesMapPropertyPermission (365) */
+  /** @name UpDataStructsPropertiesMapPropertyPermission (364) */
   export interface UpDataStructsPropertiesMapPropertyPermission extends BTreeMap<Bytes, UpDataStructsPropertyPermission> {}
 
-  /** @name UpDataStructsCollectionStats (372) */
+  /** @name UpDataStructsCollectionStats (371) */
   export interface UpDataStructsCollectionStats extends Struct {
     readonly created: u32;
     readonly destroyed: u32;
     readonly alive: u32;
   }
 
-  /** @name UpDataStructsTokenChild (373) */
+  /** @name UpDataStructsTokenChild (372) */
   export interface UpDataStructsTokenChild extends Struct {
     readonly token: u32;
     readonly collection: u32;
   }
 
-  /** @name PhantomTypeUpDataStructs (374) */
+  /** @name PhantomTypeUpDataStructs (373) */
   export interface PhantomTypeUpDataStructs extends Vec<ITuple<[UpDataStructsTokenData, UpDataStructsRpcCollection, RmrkTraitsCollectionCollectionInfo, RmrkTraitsNftNftInfo, RmrkTraitsResourceResourceInfo, RmrkTraitsPropertyPropertyInfo, RmrkTraitsBaseBaseInfo, RmrkTraitsPartPartType, RmrkTraitsTheme, RmrkTraitsNftNftChild]>> {}
 
-  /** @name UpDataStructsTokenData (376) */
+  /** @name UpDataStructsTokenData (375) */
   export interface UpDataStructsTokenData extends Struct {
     readonly properties: Vec<UpDataStructsProperty>;
     readonly owner: Option<PalletEvmAccountBasicCrossAccountIdRepr>;
     readonly pieces: u128;
   }
 
-  /** @name UpDataStructsRpcCollection (378) */
+  /** @name UpDataStructsRpcCollection (377) */
   export interface UpDataStructsRpcCollection extends Struct {
     readonly owner: AccountId32;
     readonly mode: UpDataStructsCollectionMode;
@@ -3365,7 +3215,7 @@
     readonly readOnly: bool;
   }
 
-  /** @name RmrkTraitsCollectionCollectionInfo (379) */
+  /** @name RmrkTraitsCollectionCollectionInfo (378) */
   export interface RmrkTraitsCollectionCollectionInfo extends Struct {
     readonly issuer: AccountId32;
     readonly metadata: Bytes;
@@ -3374,7 +3224,7 @@
     readonly nftsCount: u32;
   }
 
-  /** @name RmrkTraitsNftNftInfo (380) */
+  /** @name RmrkTraitsNftNftInfo (379) */
   export interface RmrkTraitsNftNftInfo extends Struct {
     readonly owner: RmrkTraitsNftAccountIdOrCollectionNftTuple;
     readonly royalty: Option<RmrkTraitsNftRoyaltyInfo>;
@@ -3383,13 +3233,13 @@
     readonly pending: bool;
   }
 
-  /** @name RmrkTraitsNftRoyaltyInfo (382) */
+  /** @name RmrkTraitsNftRoyaltyInfo (381) */
   export interface RmrkTraitsNftRoyaltyInfo extends Struct {
     readonly recipient: AccountId32;
     readonly amount: Permill;
   }
 
-  /** @name RmrkTraitsResourceResourceInfo (383) */
+  /** @name RmrkTraitsResourceResourceInfo (382) */
   export interface RmrkTraitsResourceResourceInfo extends Struct {
     readonly id: u32;
     readonly resource: RmrkTraitsResourceResourceTypes;
@@ -3397,26 +3247,26 @@
     readonly pendingRemoval: bool;
   }
 
-  /** @name RmrkTraitsPropertyPropertyInfo (384) */
+  /** @name RmrkTraitsPropertyPropertyInfo (383) */
   export interface RmrkTraitsPropertyPropertyInfo extends Struct {
     readonly key: Bytes;
     readonly value: Bytes;
   }
 
-  /** @name RmrkTraitsBaseBaseInfo (385) */
+  /** @name RmrkTraitsBaseBaseInfo (384) */
   export interface RmrkTraitsBaseBaseInfo extends Struct {
     readonly issuer: AccountId32;
     readonly baseType: Bytes;
     readonly symbol: Bytes;
   }
 
-  /** @name RmrkTraitsNftNftChild (386) */
+  /** @name RmrkTraitsNftNftChild (385) */
   export interface RmrkTraitsNftNftChild extends Struct {
     readonly collectionId: u32;
     readonly nftId: u32;
   }
 
-  /** @name PalletCommonError (388) */
+  /** @name PalletCommonError (387) */
   export interface PalletCommonError extends Enum {
     readonly isCollectionNotFound: boolean;
     readonly isMustBeTokenOwner: boolean;
@@ -3455,7 +3305,7 @@
     readonly type: 'CollectionNotFound' | 'MustBeTokenOwner' | 'NoPermission' | 'CantDestroyNotEmptyCollection' | 'PublicMintingNotAllowed' | 'AddressNotInAllowlist' | 'CollectionNameLimitExceeded' | 'CollectionDescriptionLimitExceeded' | 'CollectionTokenPrefixLimitExceeded' | 'TotalCollectionsLimitExceeded' | 'CollectionAdminCountExceeded' | 'CollectionLimitBoundsExceeded' | 'OwnerPermissionsCantBeReverted' | 'TransferNotAllowed' | 'AccountTokenLimitExceeded' | 'CollectionTokenLimitExceeded' | 'MetadataFlagFrozen' | 'TokenNotFound' | 'TokenValueTooLow' | 'ApprovedValueTooLow' | 'CantApproveMoreThanOwned' | 'AddressIsZero' | 'UnsupportedOperation' | 'NotSufficientFounds' | 'UserIsNotAllowedToNest' | 'SourceCollectionIsNotAllowedToNest' | 'CollectionFieldSizeExceeded' | 'NoSpaceForProperty' | 'PropertyLimitReached' | 'PropertyKeyIsTooLong' | 'InvalidCharacterInPropertyKey' | 'EmptyPropertyKey' | 'CollectionIsExternal' | 'CollectionIsInternal';
   }
 
-  /** @name PalletFungibleError (390) */
+  /** @name PalletFungibleError (389) */
   export interface PalletFungibleError extends Enum {
     readonly isNotFungibleDataUsedToMintFungibleCollectionToken: boolean;
     readonly isFungibleItemsHaveNoId: boolean;
@@ -3465,13 +3315,13 @@
     readonly type: 'NotFungibleDataUsedToMintFungibleCollectionToken' | 'FungibleItemsHaveNoId' | 'FungibleItemsDontHaveData' | 'FungibleDisallowsNesting' | 'SettingPropertiesNotAllowed';
   }
 
-  /** @name PalletRefungibleItemData (391) */
+  /** @name PalletRefungibleItemData (390) */
   export interface PalletRefungibleItemData extends Struct {
     readonly constData: Bytes;
   }
 
-  /** @name PalletRefungibleError (397) */
-  interface PalletRefungibleError extends Enum {
+  /** @name PalletRefungibleError (394) */
+  export interface PalletRefungibleError extends Enum {
     readonly isNotRefungibleDataUsedToMintFungibleCollectionToken: boolean;
     readonly isWrongRefungiblePieces: boolean;
     readonly isRepartitionWhileNotOwningAllPieces: boolean;
@@ -3480,29 +3330,29 @@
     readonly type: 'NotRefungibleDataUsedToMintFungibleCollectionToken' | 'WrongRefungiblePieces' | 'RepartitionWhileNotOwningAllPieces' | 'RefungibleDisallowsNesting' | 'SettingPropertiesNotAllowed';
   }
 
-  /** @name PalletNonfungibleItemData (398) */
-  interface PalletNonfungibleItemData extends Struct {
+  /** @name PalletNonfungibleItemData (395) */
+  export interface PalletNonfungibleItemData extends Struct {
     readonly owner: PalletEvmAccountBasicCrossAccountIdRepr;
   }
 
-  /** @name UpDataStructsPropertyScope (400) */
-  interface UpDataStructsPropertyScope extends Enum {
+  /** @name UpDataStructsPropertyScope (397) */
+  export interface UpDataStructsPropertyScope extends Enum {
     readonly isNone: boolean;
     readonly isRmrk: boolean;
     readonly isEth: boolean;
     readonly type: 'None' | 'Rmrk' | 'Eth';
   }
 
-  /** @name PalletNonfungibleError (402) */
-  interface PalletNonfungibleError extends Enum {
+  /** @name PalletNonfungibleError (399) */
+  export interface PalletNonfungibleError extends Enum {
     readonly isNotNonfungibleDataUsedToMintFungibleCollectionToken: boolean;
     readonly isNonfungibleItemsHaveNoAmount: boolean;
     readonly isCantBurnNftWithChildren: boolean;
     readonly type: 'NotNonfungibleDataUsedToMintFungibleCollectionToken' | 'NonfungibleItemsHaveNoAmount' | 'CantBurnNftWithChildren';
   }
 
-  /** @name PalletStructureError (403) */
-  interface PalletStructureError extends Enum {
+  /** @name PalletStructureError (400) */
+  export interface PalletStructureError extends Enum {
     readonly isOuroborosDetected: boolean;
     readonly isDepthLimit: boolean;
     readonly isBreadthLimit: boolean;
@@ -3510,8 +3360,8 @@
     readonly type: 'OuroborosDetected' | 'DepthLimit' | 'BreadthLimit' | 'TokenNotFound';
   }
 
-  /** @name PalletRmrkCoreError (404) */
-  interface PalletRmrkCoreError extends Enum {
+  /** @name PalletRmrkCoreError (401) */
+  export interface PalletRmrkCoreError extends Enum {
     readonly isCorruptedCollectionType: boolean;
     readonly isRmrkPropertyKeyIsTooLong: boolean;
     readonly isRmrkPropertyValueIsTooLong: boolean;
@@ -3534,8 +3384,8 @@
     readonly type: 'CorruptedCollectionType' | 'RmrkPropertyKeyIsTooLong' | 'RmrkPropertyValueIsTooLong' | 'RmrkPropertyIsNotFound' | 'UnableToDecodeRmrkData' | 'CollectionNotEmpty' | 'NoAvailableCollectionId' | 'NoAvailableNftId' | 'CollectionUnknown' | 'NoPermission' | 'NonTransferable' | 'CollectionFullOrLocked' | 'ResourceDoesntExist' | 'CannotSendToDescendentOrSelf' | 'CannotAcceptNonOwnedNft' | 'CannotRejectNonOwnedNft' | 'CannotRejectNonPendingNft' | 'ResourceNotPending' | 'NoAvailableResourceId';
   }
 
-  /** @name PalletRmrkEquipError (406) */
-  interface PalletRmrkEquipError extends Enum {
+  /** @name PalletRmrkEquipError (403) */
+  export interface PalletRmrkEquipError extends Enum {
     readonly isPermissionError: boolean;
     readonly isNoAvailableBaseId: boolean;
     readonly isNoAvailablePartId: boolean;
@@ -3546,8 +3396,8 @@
     readonly type: 'PermissionError' | 'NoAvailableBaseId' | 'NoAvailablePartId' | 'BaseDoesntExist' | 'NeedsDefaultThemeFirst' | 'PartDoesntExist' | 'NoEquippableOnFixedPart';
   }
 
-  /** @name PalletEvmError (409) */
-  interface PalletEvmError extends Enum {
+  /** @name PalletEvmError (406) */
+  export interface PalletEvmError extends Enum {
     readonly isBalanceLow: boolean;
     readonly isFeeOverflow: boolean;
     readonly isPaymentOverflow: boolean;
@@ -3557,8 +3407,8 @@
     readonly type: 'BalanceLow' | 'FeeOverflow' | 'PaymentOverflow' | 'WithdrawFailed' | 'GasPriceTooLow' | 'InvalidNonce';
   }
 
-  /** @name FpRpcTransactionStatus (412) */
-  interface FpRpcTransactionStatus extends Struct {
+  /** @name FpRpcTransactionStatus (409) */
+  export interface FpRpcTransactionStatus extends Struct {
     readonly transactionHash: H256;
     readonly transactionIndex: u32;
     readonly from: H160;
@@ -3568,11 +3418,11 @@
     readonly logsBloom: EthbloomBloom;
   }
 
-  /** @name EthbloomBloom (414) */
-  interface EthbloomBloom extends U8aFixed {}
+  /** @name EthbloomBloom (411) */
+  export interface EthbloomBloom extends U8aFixed {}
 
-  /** @name EthereumReceiptReceiptV3 (416) */
-  interface EthereumReceiptReceiptV3 extends Enum {
+  /** @name EthereumReceiptReceiptV3 (413) */
+  export interface EthereumReceiptReceiptV3 extends Enum {
     readonly isLegacy: boolean;
     readonly asLegacy: EthereumReceiptEip658ReceiptData;
     readonly isEip2930: boolean;
@@ -3582,23 +3432,23 @@
     readonly type: 'Legacy' | 'Eip2930' | 'Eip1559';
   }
 
-  /** @name EthereumReceiptEip658ReceiptData (417) */
-  interface EthereumReceiptEip658ReceiptData extends Struct {
+  /** @name EthereumReceiptEip658ReceiptData (414) */
+  export interface EthereumReceiptEip658ReceiptData extends Struct {
     readonly statusCode: u8;
     readonly usedGas: U256;
     readonly logsBloom: EthbloomBloom;
     readonly logs: Vec<EthereumLog>;
   }
 
-  /** @name EthereumBlock (418) */
-  interface EthereumBlock extends Struct {
+  /** @name EthereumBlock (415) */
+  export interface EthereumBlock extends Struct {
     readonly header: EthereumHeader;
     readonly transactions: Vec<EthereumTransactionTransactionV2>;
     readonly ommers: Vec<EthereumHeader>;
   }
 
-  /** @name EthereumHeader (419) */
-  interface EthereumHeader extends Struct {
+  /** @name EthereumHeader (416) */
+  export interface EthereumHeader extends Struct {
     readonly parentHash: H256;
     readonly ommersHash: H256;
     readonly beneficiary: H160;
@@ -3616,46 +3466,46 @@
     readonly nonce: EthereumTypesHashH64;
   }
 
-  /** @name EthereumTypesHashH64 (420) */
-  interface EthereumTypesHashH64 extends U8aFixed {}
+  /** @name EthereumTypesHashH64 (417) */
+  export interface EthereumTypesHashH64 extends U8aFixed {}
 
-  /** @name PalletEthereumError (425) */
-  interface PalletEthereumError extends Enum {
+  /** @name PalletEthereumError (422) */
+  export interface PalletEthereumError extends Enum {
     readonly isInvalidSignature: boolean;
     readonly isPreLogExists: boolean;
     readonly type: 'InvalidSignature' | 'PreLogExists';
   }
 
-  /** @name PalletEvmCoderSubstrateError (426) */
-  interface PalletEvmCoderSubstrateError extends Enum {
+  /** @name PalletEvmCoderSubstrateError (423) */
+  export interface PalletEvmCoderSubstrateError extends Enum {
     readonly isOutOfGas: boolean;
     readonly isOutOfFund: boolean;
     readonly type: 'OutOfGas' | 'OutOfFund';
   }
 
-  /** @name PalletEvmContractHelpersSponsoringModeT (427) */
-  interface PalletEvmContractHelpersSponsoringModeT extends Enum {
+  /** @name PalletEvmContractHelpersSponsoringModeT (424) */
+  export interface PalletEvmContractHelpersSponsoringModeT extends Enum {
     readonly isDisabled: boolean;
     readonly isAllowlisted: boolean;
     readonly isGenerous: boolean;
     readonly type: 'Disabled' | 'Allowlisted' | 'Generous';
   }
 
-  /** @name PalletEvmContractHelpersError (429) */
-  interface PalletEvmContractHelpersError extends Enum {
+  /** @name PalletEvmContractHelpersError (426) */
+  export interface PalletEvmContractHelpersError extends Enum {
     readonly isNoPermission: boolean;
     readonly type: 'NoPermission';
   }
 
-  /** @name PalletEvmMigrationError (430) */
-  interface PalletEvmMigrationError extends Enum {
+  /** @name PalletEvmMigrationError (427) */
+  export interface PalletEvmMigrationError extends Enum {
     readonly isAccountNotEmpty: boolean;
     readonly isAccountIsNotMigrating: boolean;
     readonly type: 'AccountNotEmpty' | 'AccountIsNotMigrating';
   }
 
-  /** @name SpRuntimeMultiSignature (432) */
-  interface SpRuntimeMultiSignature extends Enum {
+  /** @name SpRuntimeMultiSignature (429) */
+  export interface SpRuntimeMultiSignature extends Enum {
     readonly isEd25519: boolean;
     readonly asEd25519: SpCoreEd25519Signature;
     readonly isSr25519: boolean;
@@ -3665,34 +3515,34 @@
     readonly type: 'Ed25519' | 'Sr25519' | 'Ecdsa';
   }
 
-  /** @name SpCoreEd25519Signature (433) */
-  interface SpCoreEd25519Signature extends U8aFixed {}
+  /** @name SpCoreEd25519Signature (430) */
+  export interface SpCoreEd25519Signature extends U8aFixed {}
 
-  /** @name SpCoreSr25519Signature (435) */
-  interface SpCoreSr25519Signature extends U8aFixed {}
+  /** @name SpCoreSr25519Signature (434) */
+  export interface SpCoreSr25519Signature extends U8aFixed {}
 
-  /** @name SpCoreEcdsaSignature (436) */
-  interface SpCoreEcdsaSignature extends U8aFixed {}
+  /** @name SpCoreEcdsaSignature (435) */
+  export interface SpCoreEcdsaSignature extends U8aFixed {}
 
-  /** @name FrameSystemExtensionsCheckSpecVersion (439) */
-  type FrameSystemExtensionsCheckSpecVersion = Null;
+  /** @name FrameSystemExtensionsCheckSpecVersion (438) */
+  export type FrameSystemExtensionsCheckSpecVersion = Null;
 
-  /** @name FrameSystemExtensionsCheckGenesis (440) */
-  type FrameSystemExtensionsCheckGenesis = Null;
+  /** @name FrameSystemExtensionsCheckGenesis (439) */
+  export type FrameSystemExtensionsCheckGenesis = Null;
 
-  /** @name FrameSystemExtensionsCheckNonce (443) */
-  interface FrameSystemExtensionsCheckNonce extends Compact<u32> {}
+  /** @name FrameSystemExtensionsCheckNonce (442) */
+  export interface FrameSystemExtensionsCheckNonce extends Compact<u32> {}
 
-  /** @name FrameSystemExtensionsCheckWeight (444) */
-  type FrameSystemExtensionsCheckWeight = Null;
+  /** @name FrameSystemExtensionsCheckWeight (443) */
+  export type FrameSystemExtensionsCheckWeight = Null;
 
-  /** @name PalletTemplateTransactionPaymentChargeTransactionPayment (445) */
-  interface PalletTemplateTransactionPaymentChargeTransactionPayment extends Compact<u128> {}
+  /** @name PalletTemplateTransactionPaymentChargeTransactionPayment (444) */
+  export interface PalletTemplateTransactionPaymentChargeTransactionPayment extends Compact<u128> {}
 
-  /** @name OpalRuntimeRuntime (446) */
-  type OpalRuntimeRuntime = Null;
+  /** @name OpalRuntimeRuntime (445) */
+  export type OpalRuntimeRuntime = Null;
 
-  /** @name PalletEthereumFakeTransactionFinalizer (447) */
-  type PalletEthereumFakeTransactionFinalizer = Null;
+  /** @name PalletEthereumFakeTransactionFinalizer (444) */
+  export type PalletEthereumFakeTransactionFinalizer = Null;
 
 } // declare module
modifiedtests/src/interfaces/unique/definitions.tsdiffbeforeafterboth
--- a/tests/src/interfaces/unique/definitions.ts
+++ b/tests/src/interfaces/unique/definitions.ts
@@ -190,5 +190,10 @@
       [crossAccountParam('staker')],
       'u128',
     ),
+    pendingUnstake: fun(
+      'Returns the total amount of unstaked tokens',
+      [{name: 'staker', type: CROSS_ACCOUNT_ID_TYPE, isOptional: true}],
+      'u128',
+    ),
   },
 };
modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -68,9 +68,10 @@
       const refungible = 'refungible';
       const scheduler = 'scheduler';
       const rmrkPallets = ['rmrkcore', 'rmrkequip'];
+      const appPromotion = 'promotion';
 
       if (chain.eq('OPAL by UNIQUE')) {
-        requiredPallets.push(refungible, scheduler, ...rmrkPallets);
+        requiredPallets.push(refungible, scheduler, appPromotion, ...rmrkPallets);
       } else if (chain.eq('QUARTZ by UNIQUE')) {
         // Insert Quartz additional pallets here
       } else if (chain.eq('UNIQUE')) {
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
before · tests/src/util/helpers.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import '../interfaces/augment-api-rpc';18import '../interfaces/augment-api-query';19import {ApiPromise} from '@polkadot/api';20import type {AccountId, EventRecord, Event} from '@polkadot/types/interfaces';21import type {GenericEventData} from '@polkadot/types';22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';23import {evmToAddress} from '@polkadot/util-crypto';24import BN from 'bn.js';25import chai from 'chai';26import chaiAsPromised from 'chai-as-promised';27import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';28import {hexToStr, strToUTF16, utf16ToStr} from './util';29import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';30import {UpDataStructsTokenChild} from '../interfaces';31import {Context} from 'mocha';3233chai.use(chaiAsPromised);34const expect = chai.expect;3536export type CrossAccountId = {37  Substrate: string,38} | {39  Ethereum: string,40};414243export enum Pallets {44  Inflation = 'inflation',45  RmrkCore = 'rmrkcore',46  RmrkEquip = 'rmrkequip',47  ReFungible = 'refungible',48  Fungible = 'fungible',49  NFT = 'nonfungible',50  Scheduler = 'scheduler',51}5253export async function isUnique(): Promise<boolean> {54  return usingApi(async api => {55    const chain = await api.rpc.system.chain();5657    return chain.eq('UNIQUE');58  });59}6061export async function isQuartz(): Promise<boolean> {62  return usingApi(async api => {63    const chain = await api.rpc.system.chain();64    65    return chain.eq('QUARTZ');66  });67}6869let modulesNames: any;70export function getModuleNames(api: ApiPromise): string[] {71  if (typeof modulesNames === 'undefined') 72    modulesNames = api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());73  return modulesNames;74}7576export async function missingRequiredPallets(requiredPallets: string[]): Promise<string[]> {77  return await usingApi(async api => {78    const pallets = getModuleNames(api);7980    return requiredPallets.filter(p => !pallets.includes(p));81  });82}8384export async function checkPalletsPresence(requiredPallets: string[]): Promise<boolean> {85  return (await missingRequiredPallets(requiredPallets)).length == 0;86}8788export async function requirePallets(mocha: Context, requiredPallets: string[]) {89  const missingPallets = await missingRequiredPallets(requiredPallets);9091  if (missingPallets.length > 0) {92    const skippingTestMsg = `\tSkipping test "${mocha.test?.title}".`;93    const missingPalletsMsg = `\tThe following pallets are missing:\n\t- ${missingPallets.join('\n\t- ')}`;94    const skipMsg = `${skippingTestMsg}\n${missingPalletsMsg}`;9596    console.error('\x1b[38:5:208m%s\x1b[0m', skipMsg);9798    mocha.skip();99  }100}101102export function bigIntToSub(api: ApiPromise, number: bigint) {103  return api.registry.createType('AccountId', '0x' + number.toString(16).padStart(64, '0')).toJSON();104}105106export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {107  if (typeof input === 'string') {108    if (input.length >= 47) {109      return {Substrate: input};110    } else if (input.length === 42 && input.startsWith('0x')) {111      return {Ethereum: input.toLowerCase()};112    } else if (input.length === 40 && !input.startsWith('0x')) {113      return {Ethereum: '0x' + input.toLowerCase()};114    } else {115      throw new Error(`Unknown address format: "${input}"`);116    }117  }118  if ('address' in input) {119    return {Substrate: input.address};120  }121  if ('Ethereum' in input) {122    return {123      Ethereum: input.Ethereum.toLowerCase(),124    };125  } else if ('ethereum' in input) {126    return {127      Ethereum: (input as any).ethereum.toLowerCase(),128    };129  } else if ('Substrate' in input) {130    return input;131  } else if ('substrate' in input) {132    return {133      Substrate: (input as any).substrate,134    };135  }136137  // AccountId138  return {Substrate: input.toString()};139}140export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {141  input = normalizeAccountId(input);142  if ('Substrate' in input) {143    return input.Substrate;144  } else {145    return evmToAddress(input.Ethereum);146  }147}148149export const U128_MAX = (1n << 128n) - 1n;150151const MICROUNIQUE = 1_000_000_000_000n;152const MILLIUNIQUE = 1_000n * MICROUNIQUE;153const CENTIUNIQUE = 10n * MILLIUNIQUE;154export const UNIQUE = 100n * CENTIUNIQUE;155156interface GenericResult<T> {157  success: boolean;158  data: T | null;159}160161interface CreateCollectionResult {162  success: boolean;163  collectionId: number;164}165166interface CreateItemResult {167  success: boolean;168  collectionId: number;169  itemId: number;170  recipient?: CrossAccountId;171  amount?: number;172}173174interface DestroyItemResult {175  success: boolean;176  collectionId: number;177  itemId: number;178  owner: CrossAccountId;179  amount: number;180}181182interface TransferResult {183  collectionId: number;184  itemId: number;185  sender?: CrossAccountId;186  recipient?: CrossAccountId;187  value: bigint;188}189190interface IReFungibleOwner {191  fraction: BN;192  owner: number[];193}194195interface IGetMessage {196  checkMsgUnqMethod: string;197  checkMsgTrsMethod: string;198  checkMsgSysMethod: string;199}200201export interface IFungibleTokenDataType {202  value: number;203}204205export interface IChainLimits {206  collectionNumbersLimit: number;207  accountTokenOwnershipLimit: number;208  collectionsAdminsLimit: number;209  customDataLimit: number;210  nftSponsorTransferTimeout: number;211  fungibleSponsorTransferTimeout: number;212  refungibleSponsorTransferTimeout: number;213  //offchainSchemaLimit: number;214  //constOnChainSchemaLimit: number;215}216217export interface IReFungibleTokenDataType {218  owner: IReFungibleOwner[];219}220221export function uniqueEventMessage(events: EventRecord[]): IGetMessage {222  let checkMsgUnqMethod = '';223  let checkMsgTrsMethod = '';224  let checkMsgSysMethod = '';225  events.forEach(({event: {method, section}}) => {226    if (section === 'common') {227      checkMsgUnqMethod = method;228    } else if (section === 'treasury') {229      checkMsgTrsMethod = method;230    } else if (section === 'system') {231      checkMsgSysMethod = method;232    } else { return null; }233  });234  const result: IGetMessage = {235    checkMsgUnqMethod,236    checkMsgTrsMethod,237    checkMsgSysMethod,238  };239  return result;240}241242export function getEvent<T extends Event>(events: EventRecord[], check: (event: IEvent<AnyTuple>) => event is T): T | undefined {243  const event = events.find(r => check(r.event));244  if (!event) return;245  return event.event as T;246}247248export function getGenericResult<T>(events: EventRecord[]): GenericResult<T>;249export function getGenericResult<T>(250  events: EventRecord[],251  expectSection: string,252  expectMethod: string,253  extractAction: (data: GenericEventData) => T254): GenericResult<T>;255256export function getGenericResult<T>(257  events: EventRecord[],258  expectSection?: string,259  expectMethod?: string,260  extractAction?: (data: GenericEventData) => T,261): GenericResult<T> {262  let success = false;263  let successData = null;264265  events.forEach(({event: {data, method, section}}) => {266    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);267    if (method === 'ExtrinsicSuccess') {268      success = true;269    } else if ((expectSection == section) && (expectMethod == method)) {270      successData = extractAction!(data as any);271    }272  });273274  const result: GenericResult<T> = {275    success,276    data: successData,277  };278  return result;279}280281export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {282  const genericResult = getGenericResult(events, 'common', 'CollectionCreated', (data) => parseInt(data[0].toString(), 10));283  const result: CreateCollectionResult = {284    success: genericResult.success,285    collectionId: genericResult.data ?? 0,286  };287  return result;288}289290export function getCreateItemsResult(events: EventRecord[]): CreateItemResult[] {291  const results: CreateItemResult[] = [];292  293  const genericResult = getGenericResult<CreateItemResult[]>(events, 'common', 'ItemCreated', (data) => {294    const collectionId = parseInt(data[0].toString(), 10);295    const itemId = parseInt(data[1].toString(), 10);296    const recipient = normalizeAccountId(data[2].toJSON() as any);297    const amount = parseInt(data[3].toString(), 10);298299    const itemRes: CreateItemResult = {300      success: true,301      collectionId,302      itemId,303      recipient,304      amount,305    };306307    results.push(itemRes);308    return results;309  });310311  if (!genericResult.success) return [];312  return results;313}314315export function getCreateItemResult(events: EventRecord[]): CreateItemResult {316  const genericResult = getGenericResult(events, 'common', 'ItemCreated', (data) => data.map(function(value) { return value.toJSON(); }));317  318  if (genericResult.data == null) 319    return {320      success: genericResult.success,321      collectionId: 0,322      itemId: 0,323      amount: 0,324    };325  else 326    return {327      success: genericResult.success,328      collectionId: genericResult.data[0] as number,329      itemId: genericResult.data[1] as number,330      recipient: normalizeAccountId(genericResult.data![2] as any),331      amount: genericResult.data[3] as number,332    };333}334335export function getDestroyItemsResult(events: EventRecord[]): DestroyItemResult[] {336  const results: DestroyItemResult[] = [];337  338  const genericResult = getGenericResult<DestroyItemResult[]>(events, 'common', 'ItemDestroyed', (data) => {339    const collectionId = parseInt(data[0].toString(), 10);340    const itemId = parseInt(data[1].toString(), 10);341    const owner = normalizeAccountId(data[2].toJSON() as any);342    const amount = parseInt(data[3].toString(), 10);343344    const itemRes: DestroyItemResult = {345      success: true,346      collectionId,347      itemId,348      owner,349      amount,350    };351352    results.push(itemRes);353    return results;354  });355356  if (!genericResult.success) return [];357  return results;358}359360export function getTransferResult(api: ApiPromise, events: EventRecord[]): TransferResult {361  for (const {event} of events) {362    if (api.events.common.Transfer.is(event)) {363      const [collection, token, sender, recipient, value] = event.data;364      return {365        collectionId: collection.toNumber(),366        itemId: token.toNumber(),367        sender: normalizeAccountId(sender.toJSON() as any),368        recipient: normalizeAccountId(recipient.toJSON() as any),369        value: value.toBigInt(),370      };371    }372  }373  throw new Error('no transfer event');374}375376interface Nft {377  type: 'NFT';378}379380interface Fungible {381  type: 'Fungible';382  decimalPoints: number;383}384385interface ReFungible {386  type: 'ReFungible';387}388389export type CollectionMode = Nft | Fungible | ReFungible;390391export type Property = {392  key: any,393  value: any,394};395396type Permission = {397  mutable: boolean;398  collectionAdmin: boolean;399  tokenOwner: boolean;400}401402type PropertyPermission = {403  key: any;404  permission: Permission;405}406407export type CreateCollectionParams = {408  mode: CollectionMode,409  name: string,410  description: string,411  tokenPrefix: string,412  properties?: Array<Property>,413  propPerm?: Array<PropertyPermission>414};415416const defaultCreateCollectionParams: CreateCollectionParams = {417  description: 'description',418  mode: {type: 'NFT'},419  name: 'name',420  tokenPrefix: 'prefix',421};422423export async function424createCollection(425  api: ApiPromise,426  sender: IKeyringPair,427  params: Partial<CreateCollectionParams> = {},428): Promise<CreateCollectionResult> {429  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};430431  let modeprm = {};432  if (mode.type === 'NFT') {433    modeprm = {nft: null};434  } else if (mode.type === 'Fungible') {435    modeprm = {fungible: mode.decimalPoints};436  } else if (mode.type === 'ReFungible') {437    modeprm = {refungible: null};438  }439440  const tx = api.tx.unique.createCollectionEx({441    name: strToUTF16(name),442    description: strToUTF16(description),443    tokenPrefix: strToUTF16(tokenPrefix),444    mode: modeprm as any,445  });446  const events = await executeTransaction(api, sender, tx);447  return getCreateCollectionResult(events);448}449450export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {451  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};452453  let collectionId = 0;454  await usingApi(async (api, privateKeyWrapper) => {455    // Get number of collections before the transaction456    const collectionCountBefore = await getCreatedCollectionCount(api);457458    // Run the CreateCollection transaction459    const alicePrivateKey = privateKeyWrapper('//Alice');460461    const result = await createCollection(api, alicePrivateKey, params);462463    // Get number of collections after the transaction464    const collectionCountAfter = await getCreatedCollectionCount(api);465466    // Get the collection467    const collection = await queryCollectionExpectSuccess(api, result.collectionId);468469    // What to expect470    // tslint:disable-next-line:no-unused-expression471    expect(result.success).to.be.true;472    expect(result.collectionId).to.be.equal(collectionCountAfter);473    // tslint:disable-next-line:no-unused-expression474    expect(collection).to.be.not.null;475    expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');476    expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicePrivateKey));477    expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);478    expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);479    expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);480481    collectionId = result.collectionId;482  });483484  return collectionId;485}486487export async function createCollectionWithPropsExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {488  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};489490  let collectionId = 0;491  await usingApi(async (api, privateKeyWrapper) => {492    // Get number of collections before the transaction493    const collectionCountBefore = await getCreatedCollectionCount(api);494495    // Run the CreateCollection transaction496    const alicePrivateKey = privateKeyWrapper('//Alice');497498    let modeprm = {};499    if (mode.type === 'NFT') {500      modeprm = {nft: null};501    } else if (mode.type === 'Fungible') {502      modeprm = {fungible: mode.decimalPoints};503    } else if (mode.type === 'ReFungible') {504      modeprm = {refungible: null};505    }506507    const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any, properties: params.properties, tokenPropertyPermissions: params.propPerm});508    const events = await submitTransactionAsync(alicePrivateKey, tx);509    const result = getCreateCollectionResult(events);510511    // Get number of collections after the transaction512    const collectionCountAfter = await getCreatedCollectionCount(api);513514    // Get the collection515    const collection = await queryCollectionExpectSuccess(api, result.collectionId);516517    // What to expect518    // tslint:disable-next-line:no-unused-expression519    expect(result.success).to.be.true;520    expect(result.collectionId).to.be.equal(collectionCountAfter);521    // tslint:disable-next-line:no-unused-expression522    expect(collection).to.be.not.null;523    expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');524    expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicePrivateKey));525    expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);526    expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);527    expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);528529530    collectionId = result.collectionId;531  });532533  return collectionId;534}535536export async function createCollectionWithPropsExpectFailure(params: Partial<CreateCollectionParams> = {}) {537  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};538539  await usingApi(async (api, privateKeyWrapper) => {540    // Get number of collections before the transaction541    const collectionCountBefore = await getCreatedCollectionCount(api);542543    // Run the CreateCollection transaction544    const alicePrivateKey = privateKeyWrapper('//Alice');545546    let modeprm = {};547    if (mode.type === 'NFT') {548      modeprm = {nft: null};549    } else if (mode.type === 'Fungible') {550      modeprm = {fungible: mode.decimalPoints};551    } else if (mode.type === 'ReFungible') {552      modeprm = {refungible: null};553    }554555    const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any, properties: params.properties, tokenPropertyPermissions: params.propPerm});556    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;557558559    // Get number of collections after the transaction560    const collectionCountAfter = await getCreatedCollectionCount(api);561562    expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');563  });564}565566export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {567  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};568569  let modeprm = {};570  if (mode.type === 'NFT') {571    modeprm = {nft: null};572  } else if (mode.type === 'Fungible') {573    modeprm = {fungible: mode.decimalPoints};574  } else if (mode.type === 'ReFungible') {575    modeprm = {refungible: null};576  }577578  await usingApi(async (api, privateKeyWrapper) => {579    // Get number of collections before the transaction580    const collectionCountBefore = await getCreatedCollectionCount(api);581582    // Run the CreateCollection transaction583    const alicePrivateKey = privateKeyWrapper('//Alice');584    const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});585    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;586587    // Get number of collections after the transaction588    const collectionCountAfter = await getCreatedCollectionCount(api);589590    // What to expect591    expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');592  });593}594595export async function findUnusedAddress(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, seedAddition = ''): Promise<IKeyringPair> {596  let bal = 0n;597  let unused;598  do {599    const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000)) + seedAddition;600    unused = privateKeyWrapper(`//${randomSeed}`);601    bal = (await api.query.system.account(unused.address)).data.free.toBigInt();602  } while (bal !== 0n);603  return unused;604}605606export async function getAllowance(api: ApiPromise, collectionId: number, owner: CrossAccountId | string | IKeyringPair, approved: CrossAccountId | string | IKeyringPair, tokenId: number) {607  return (await api.rpc.unique.allowance(collectionId, normalizeAccountId(owner), normalizeAccountId(approved), tokenId)).toBigInt();608}609610export function findUnusedAddresses(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, amount: number): Promise<IKeyringPair[]> {611  return Promise.all(new Array(amount).fill(null).map(() => findUnusedAddress(api, privateKeyWrapper, '_' + Date.now())));612}613614export async function findNotExistingCollection(api: ApiPromise): Promise<number> {615  const totalNumber = await getCreatedCollectionCount(api);616  const newCollection: number = totalNumber + 1;617  return newCollection;618}619620function getDestroyResult(events: EventRecord[]): boolean {621  let success = false;622  events.forEach(({event: {method}}) => {623    if (method == 'ExtrinsicSuccess') {624      success = true;625    }626  });627  return success;628}629630export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {631  await usingApi(async (api, privateKeyWrapper) => {632    // Run the DestroyCollection transaction633    const alicePrivateKey = privateKeyWrapper(senderSeed);634    const tx = api.tx.unique.destroyCollection(collectionId);635    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;636  });637}638639export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {640  await usingApi(async (api, privateKeyWrapper) => {641    // Run the DestroyCollection transaction642    const alicePrivateKey = privateKeyWrapper(senderSeed);643    const tx = api.tx.unique.destroyCollection(collectionId);644    const events = await submitTransactionAsync(alicePrivateKey, tx);645    const result = getDestroyResult(events);646    expect(result).to.be.true;647648    // What to expect649    expect(await getDetailedCollectionInfo(api, collectionId)).to.be.null;650  });651}652653export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {654  await usingApi(async (api) => {655    const tx = api.tx.unique.setCollectionLimits(collectionId, limits);656    const events = await submitTransactionAsync(sender, tx);657    const result = getGenericResult(events);658659    expect(result.success).to.be.true;660  });661}662663export const setCollectionPermissionsExpectSuccess = async (sender: IKeyringPair, collectionId: number, permissions: any) => {664  await usingApi(async(api) => {665    const tx = api.tx.unique.setCollectionPermissions(collectionId, permissions);666    const events = await submitTransactionAsync(sender, tx);667    const result = getGenericResult(events);668669    expect(result.success).to.be.true;670  });671};672673export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {674  await usingApi(async (api) => {675    const tx = api.tx.unique.setCollectionLimits(collectionId, limits);676    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;677    const result = getGenericResult(events);678679    expect(result.success).to.be.false;680  });681}682683export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string, sender = '//Alice') {684  await usingApi(async (api, privateKeyWrapper) => {685686    // Run the transaction687    const senderPrivateKey = privateKeyWrapper(sender);688    const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);689    const events = await submitTransactionAsync(senderPrivateKey, tx);690    const result = getGenericResult(events);691692    // Get the collection693    const collection = await queryCollectionExpectSuccess(api, collectionId);694695    // What to expect696    expect(result.success).to.be.true;697    expect(collection.sponsorship.toJSON()).to.deep.equal({698      unconfirmed: sponsor,699    });700  });701}702703export async function removeCollectionSponsorExpectSuccess(collectionId: number, sender = '//Alice') {704  await usingApi(async (api, privateKeyWrapper) => {705706    // Run the transaction707    const alicePrivateKey = privateKeyWrapper(sender);708    const tx = api.tx.unique.removeCollectionSponsor(collectionId);709    const events = await submitTransactionAsync(alicePrivateKey, tx);710    const result = getGenericResult(events);711712    // Get the collection713    const collection = await queryCollectionExpectSuccess(api, collectionId);714715    // What to expect716    expect(result.success).to.be.true;717    expect(collection.sponsorship.toJSON()).to.be.deep.equal({disabled: null});718  });719}720721export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {722  await usingApi(async (api, privateKeyWrapper) => {723724    // Run the transaction725    const alicePrivateKey = privateKeyWrapper(senderSeed);726    const tx = api.tx.unique.removeCollectionSponsor(collectionId);727    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;728  });729}730731export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed = '//Alice') {732  await usingApi(async (api, privateKeyWrapper) => {733734    // Run the transaction735    const alicePrivateKey = privateKeyWrapper(senderSeed);736    const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);737    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;738  });739}740741export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed = '//Alice') {742  await usingApi(async (api, privateKeyWrapper) => {743744    // Run the transaction745    const sender = privateKeyWrapper(senderSeed);746    await confirmSponsorshipByKeyExpectSuccess(collectionId, sender);747  });748}749750export async function confirmSponsorshipByKeyExpectSuccess(collectionId: number, sender: IKeyringPair) {751  await usingApi(async (api, privateKeyWrapper) => {752753    // Run the transaction754    const tx = api.tx.unique.confirmSponsorship(collectionId);755    const events = await submitTransactionAsync(sender, tx);756    const result = getGenericResult(events);757758    // Get the collection759    const collection = await queryCollectionExpectSuccess(api, collectionId);760761    // What to expect762    expect(result.success).to.be.true;763    expect(collection.sponsorship.toJSON()).to.be.deep.equal({764      confirmed: sender.address,765    });766  });767}768769770export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed = '//Alice') {771  await usingApi(async (api, privateKeyWrapper) => {772773    // Run the transaction774    const sender = privateKeyWrapper(senderSeed);775    const tx = api.tx.unique.confirmSponsorship(collectionId);776    await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;777  });778}779780export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {781  await usingApi(async (api) => {782    const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);783    const events = await submitTransactionAsync(sender, tx);784    const result = getGenericResult(events);785786    expect(result.success).to.be.true;787  });788}789790export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {791  await usingApi(async (api) => {792    const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);793    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;794    const result = getGenericResult(events);795796    expect(result.success).to.be.false;797  });798}799800export async function setTransferFlagExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {801802  await usingApi(async (api) => {803804    const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, enabled);805    const events = await submitTransactionAsync(sender, tx);806    const result = getGenericResult(events);807808    expect(result.success).to.be.true;809  });810}811812export async function setTransferFlagExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {813814  await usingApi(async (api) => {815816    const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, enabled);817    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;818    const result = getGenericResult(events);819820    expect(result.success).to.be.false;821  });822}823824export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {825  await usingApi(async (api) => {826    const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);827    const events = await submitTransactionAsync(sender, tx);828    const result = getGenericResult(events);829830    expect(result.success).to.be.true;831  });832}833834export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {835  await usingApi(async (api) => {836    const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);837    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;838    const result = getGenericResult(events);839840    expect(result.success).to.be.false;841  });842}843844export async function getNextSponsored(845  api: ApiPromise,846  collectionId: number,847  account: string | CrossAccountId,848  tokenId: number,849): Promise<number> {850  return Number((await api.rpc.unique.nextSponsored(collectionId, account, tokenId)).unwrapOr(-1));851}852853export async function toggleContractAllowlistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {854  await usingApi(async (api) => {855    const tx = api.tx.unique.toggleContractAllowList(contractAddress, value);856    const events = await submitTransactionAsync(sender, tx);857    const result = getGenericResult(events);858859    expect(result.success).to.be.true;860  });861}862863export async function isAllowlistedInContract(contractAddress: AccountId | string, user: string) {864  let allowlisted = false;865  await usingApi(async (api) => {866    allowlisted = (await api.query.unique.contractAllowList(contractAddress, user)).toJSON() as boolean;867  });868  return allowlisted;869}870871export async function addToContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {872  await usingApi(async (api) => {873    const tx = api.tx.unique.addToContractAllowList(contractAddress.toString(), user.toString());874    const events = await submitTransactionAsync(sender, tx);875    const result = getGenericResult(events);876877    expect(result.success).to.be.true;878  });879}880881export async function removeFromContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {882  await usingApi(async (api) => {883    const tx = api.tx.unique.removeFromContractAllowList(contractAddress.toString(), user.toString());884    const events = await submitTransactionAsync(sender, tx);885    const result = getGenericResult(events);886887    expect(result.success).to.be.true;888  });889}890891export async function removeFromContractAllowListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {892  await usingApi(async (api) => {893    const tx = api.tx.unique.removeFromContractAllowList(contractAddress.toString(), user.toString());894    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;895    const result = getGenericResult(events);896897    expect(result.success).to.be.false;898  });899}900901export interface CreateFungibleData {902  readonly Value: bigint;903}904905export interface CreateReFungibleData { }906export interface CreateNftData { }907908export type CreateItemData = {909  NFT: CreateNftData;910} | {911  Fungible: CreateFungibleData;912} | {913  ReFungible: CreateReFungibleData;914};915916export async function burnItem(api: ApiPromise, sender: IKeyringPair, collectionId: number, tokenId: number, value: number | bigint) : Promise<boolean> {917  const tx = api.tx.unique.burnItem(collectionId, tokenId, value);918  const events = await submitTransactionAsync(sender, tx);919  return getGenericResult(events).success;920}921922export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, value: number | bigint = 1) {923  await usingApi(async (api) => {924    const balanceBefore = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);925    // if burning token by admin - use adminButnItemExpectSuccess926    expect(balanceBefore >= BigInt(value)).to.be.true;927928    expect(await burnItem(api, sender, collectionId, tokenId, value)).to.be.true;929930    const balanceAfter = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);931    expect(balanceAfter + BigInt(value)).to.be.equal(balanceBefore);932  });933}934935export async function burnItemExpectFailure(sender: IKeyringPair, collectionId: number, tokenId: number, value: number | bigint = 1) {936  await usingApi(async (api) => {937    const tx = api.tx.unique.burnItem(collectionId, tokenId, value);938939    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;940    const result = getCreateCollectionResult(events);941    // tslint:disable-next-line:no-unused-expression942    expect(result.success).to.be.false;943  });944}945946export async function burnFromExpectSuccess(sender: IKeyringPair, from: IKeyringPair | CrossAccountId, collectionId: number, tokenId: number, value: number | bigint = 1) {947  await usingApi(async (api) => {948    const tx = api.tx.unique.burnFrom(collectionId, normalizeAccountId(from), tokenId, value);949    const events = await submitTransactionAsync(sender, tx);950    return getGenericResult(events).success;951  });952}953954export async function955approve(956  api: ApiPromise,957  collectionId: number,958  tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string | IKeyringPair, amount: number | bigint,959) {960  const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);961  const events = await submitTransactionAsync(owner, approveUniqueTx);962  return getGenericResult(events).success;963}964965export async function966approveExpectSuccess(967  collectionId: number,968  tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string, amount: number | bigint = 1,969) {970  await usingApi(async (api: ApiPromise) => {971    const result = await approve(api, collectionId, tokenId, owner, approved, amount);972    expect(result).to.be.true;973974    expect(await getAllowance(api, collectionId, owner, approved, tokenId)).to.be.equal(BigInt(amount));975  });976}977978export async function adminApproveFromExpectSuccess(979  collectionId: number,980  tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,981) {982  await usingApi(async (api: ApiPromise) => {983    const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);984    const events = await submitTransactionAsync(admin, approveUniqueTx);985    const result = getGenericResult(events);986    expect(result.success).to.be.true;987988    expect(await getAllowance(api, collectionId, owner, approved, tokenId)).to.be.equal(BigInt(amount));989  });990}991992export async function993transferFrom(994  api: ApiPromise,995  collectionId: number,996  tokenId: number,997  accountApproved: IKeyringPair,998  accountFrom: IKeyringPair | CrossAccountId,999  accountTo: IKeyringPair | CrossAccountId,1000  value: number | bigint,1001) {1002  const from = normalizeAccountId(accountFrom);1003  const to = normalizeAccountId(accountTo);1004  const transferFromTx = api.tx.unique.transferFrom(from, to, collectionId, tokenId, value);1005  const events = await submitTransactionAsync(accountApproved, transferFromTx);1006  return getGenericResult(events).success;1007}10081009export async function1010transferFromExpectSuccess(1011  collectionId: number,1012  tokenId: number,1013  accountApproved: IKeyringPair,1014  accountFrom: IKeyringPair | CrossAccountId,1015  accountTo: IKeyringPair | CrossAccountId,1016  value: number | bigint = 1,1017  type = 'NFT',1018) {1019  await usingApi(async (api: ApiPromise) => {1020    const from = normalizeAccountId(accountFrom);1021    const to = normalizeAccountId(accountTo);1022    let balanceBefore = 0n;1023    if (type === 'Fungible' || type === 'ReFungible') {1024      balanceBefore = await getBalance(api, collectionId, to, tokenId);1025    }1026    expect(await transferFrom(api, collectionId, tokenId, accountApproved, accountFrom, accountTo, value)).to.be.true;1027    if (type === 'NFT') {1028      expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);1029    }1030    if (type === 'Fungible') {1031      const balanceAfter = await getBalance(api, collectionId, to, tokenId);1032      if (JSON.stringify(to) !== JSON.stringify(from)) {1033        expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));1034      } else {1035        expect(balanceAfter).to.be.equal(balanceBefore);1036      }1037    }1038    if (type === 'ReFungible') {1039      expect(await getBalance(api, collectionId, to, tokenId)).to.be.equal(balanceBefore + BigInt(value));1040    }1041  });1042}10431044export async function1045transferFromExpectFail(1046  collectionId: number,1047  tokenId: number,1048  accountApproved: IKeyringPair,1049  accountFrom: IKeyringPair,1050  accountTo: IKeyringPair,1051  value: number | bigint = 1,1052) {1053  await usingApi(async (api: ApiPromise) => {1054    const transferFromTx = api.tx.unique.transferFrom(normalizeAccountId(accountFrom.address), normalizeAccountId(accountTo.address), collectionId, tokenId, value);1055    const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;1056    const result = getCreateCollectionResult(events);1057    // tslint:disable-next-line:no-unused-expression1058    expect(result.success).to.be.false;1059  });1060}10611062/* eslint no-async-promise-executor: "off" */1063export async function getBlockNumber(api: ApiPromise): Promise<number> {1064  return new Promise<number>(async (resolve) => {1065    const unsubscribe = await api.rpc.chain.subscribeNewHeads((head) => {1066      unsubscribe();1067      resolve(head.number.toNumber());1068    });1069  });1070}10711072export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | CrossAccountId) {1073  await usingApi(async (api) => {1074    const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(address));1075    const events = await submitTransactionAsync(sender, changeAdminTx);1076    const result = getCreateCollectionResult(events);1077    expect(result.success).to.be.true;1078  });1079}10801081export async function adminApproveFromExpectFail(1082  collectionId: number,1083  tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,1084) {1085  await usingApi(async (api: ApiPromise) => {1086    const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);1087    const events = await expect(submitTransactionAsync(admin, approveUniqueTx)).to.be.rejected;1088    const result = getGenericResult(events);1089    expect(result.success).to.be.false;1090  });1091}10921093export async function1094getFreeBalance(account: IKeyringPair): Promise<bigint> {1095  let balance = 0n;1096  await usingApi(async (api) => {1097    balance = BigInt((await api.query.system.account(account.address)).data.free.toString());1098  });10991100  return balance;1101}11021103export async function transferBalanceTo(api: ApiPromise, source: IKeyringPair, target: string, amount = 1000n * UNIQUE) {1104  const tx = api.tx.balances.transfer(target, amount);1105  const events = await submitTransactionAsync(source, tx);1106  const result = getGenericResult(events);1107  expect(result.success).to.be.true;1108}11091110export async function1111scheduleExpectSuccess(1112  operationTx: any,1113  sender: IKeyringPair,1114  blockSchedule: number,1115  scheduledId: string,1116  period = 1,1117  repetitions = 1,1118) {1119  await usingApi(async (api: ApiPromise) => {1120    const blockNumber: number | undefined = await getBlockNumber(api);1121    const expectedBlockNumber = blockNumber + blockSchedule;11221123    expect(blockNumber).to.be.greaterThan(0);1124    const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule1125      scheduledId,1126      expectedBlockNumber, 1127      repetitions > 1 ? [period, repetitions] : null, 1128      0, 1129      {Value: operationTx as any},1130    );11311132    const events = await submitTransactionAsync(sender, scheduleTx);1133    expect(getGenericResult(events).success).to.be.true;1134  });1135}11361137export async function1138scheduleExpectFailure(1139  operationTx: any,1140  sender: IKeyringPair,1141  blockSchedule: number,1142  scheduledId: string,1143  period = 1,1144  repetitions = 1,1145) {1146  await usingApi(async (api: ApiPromise) => {1147    const blockNumber: number | undefined = await getBlockNumber(api);1148    const expectedBlockNumber = blockNumber + blockSchedule;11491150    expect(blockNumber).to.be.greaterThan(0);1151    const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule1152      scheduledId,1153      expectedBlockNumber, 1154      repetitions <= 1 ? null : [period, repetitions], 1155      0, 1156      {Value: operationTx as any},1157    );11581159    //const events = 1160    await expect(submitTransactionExpectFailAsync(sender, scheduleTx)).to.be.rejected;1161    //expect(getGenericResult(events).success).to.be.false;1162  });1163}11641165export async function1166scheduleTransferAndWaitExpectSuccess(1167  collectionId: number,1168  tokenId: number,1169  sender: IKeyringPair,1170  recipient: IKeyringPair,1171  value: number | bigint = 1,1172  blockSchedule: number,1173  scheduledId: string,1174) {1175  await usingApi(async (api: ApiPromise) => {1176    await scheduleTransferExpectSuccess(collectionId, tokenId, sender, recipient, value, blockSchedule, scheduledId);11771178    const recipientBalanceBefore = (await api.query.system.account(recipient.address)).data.free.toBigInt();11791180    // sleep for n + 1 blocks1181    await waitNewBlocks(blockSchedule + 1);11821183    const recipientBalanceAfter = (await api.query.system.account(recipient.address)).data.free.toBigInt();11841185    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(recipient.address));1186    expect(recipientBalanceAfter).to.be.equal(recipientBalanceBefore);1187  });1188}11891190export async function1191scheduleTransferExpectSuccess(1192  collectionId: number,1193  tokenId: number,1194  sender: IKeyringPair,1195  recipient: IKeyringPair,1196  value: number | bigint = 1,1197  blockSchedule: number,1198  scheduledId: string,1199) {1200  await usingApi(async (api: ApiPromise) => {1201    const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);12021203    await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId);12041205    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(sender.address));1206  });1207}12081209export async function1210scheduleTransferFundsPeriodicExpectSuccess(1211  amount: bigint,1212  sender: IKeyringPair,1213  recipient: IKeyringPair,1214  blockSchedule: number,1215  scheduledId: string,1216  period: number,1217  repetitions: number,1218) {1219  await usingApi(async (api: ApiPromise) => {1220    const transferTx = api.tx.balances.transfer(recipient.address, amount);12211222    const balanceBefore = await getFreeBalance(recipient);1223    1224    await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId, period, repetitions);12251226    expect(await getFreeBalance(recipient)).to.be.equal(balanceBefore);1227  });1228}12291230export async function1231transfer(1232  api: ApiPromise,1233  collectionId: number,1234  tokenId: number,1235  sender: IKeyringPair,1236  recipient: IKeyringPair | CrossAccountId,1237  value: number | bigint,1238) : Promise<boolean> {1239  const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient), collectionId, tokenId, value);1240  const events = await executeTransaction(api, sender, transferTx);1241  return getGenericResult(events).success;1242}12431244export async function1245transferExpectSuccess(1246  collectionId: number,1247  tokenId: number,1248  sender: IKeyringPair,1249  recipient: IKeyringPair | CrossAccountId,1250  value: number | bigint = 1,1251  type = 'NFT',1252) {1253  await usingApi(async (api: ApiPromise) => {1254    const from = normalizeAccountId(sender);1255    const to = normalizeAccountId(recipient);12561257    let balanceBefore = 0n;1258    if (type === 'Fungible' || type === 'ReFungible') {1259      balanceBefore = await getBalance(api, collectionId, to, tokenId);1260    }12611262    const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient), collectionId, tokenId, value);1263    const events = await executeTransaction(api, sender, transferTx);1264    const result = getTransferResult(api, events);12651266    expect(result.collectionId).to.be.equal(collectionId);1267    expect(result.itemId).to.be.equal(tokenId);1268    expect(result.sender).to.be.deep.equal(normalizeAccountId(sender.address));1269    expect(result.recipient).to.be.deep.equal(to);1270    expect(result.value).to.be.equal(BigInt(value));12711272    if (type === 'NFT') {1273      expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);1274    }1275    if (type === 'Fungible' || type === 'ReFungible') {1276      const balanceAfter = await getBalance(api, collectionId, to, tokenId);1277      if (JSON.stringify(to) !== JSON.stringify(from)) {1278        expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));1279      } else {1280        expect(balanceAfter).to.be.equal(balanceBefore);1281      }1282    }1283  });1284}12851286export async function1287transferExpectFailure(1288  collectionId: number,1289  tokenId: number,1290  sender: IKeyringPair,1291  recipient: IKeyringPair | CrossAccountId,1292  value: number | bigint = 1,1293) {1294  await usingApi(async (api: ApiPromise) => {1295    const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient), collectionId, tokenId, value);1296    const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;1297    const result = getGenericResult(events);1298    // if (events && Array.isArray(events)) {1299    //   const result = getCreateCollectionResult(events);1300    // tslint:disable-next-line:no-unused-expression1301    expect(result.success).to.be.false;1302    //}1303  });1304}13051306export async function1307approveExpectFail(1308  collectionId: number,1309  tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1,1310) {1311  await usingApi(async (api: ApiPromise) => {1312    const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved.address), collectionId, tokenId, amount);1313    const events = await expect(submitTransactionExpectFailAsync(owner, approveUniqueTx)).to.be.rejected;1314    const result = getCreateCollectionResult(events);1315    // tslint:disable-next-line:no-unused-expression1316    expect(result.success).to.be.false;1317  });1318}13191320export async function getBalance(1321  api: ApiPromise,1322  collectionId: number,1323  owner: string | CrossAccountId | IKeyringPair,1324  token: number,1325): Promise<bigint> {1326  return (await api.rpc.unique.balance(collectionId, normalizeAccountId(owner), token)).toBigInt();1327}1328export async function getTokenOwner(1329  api: ApiPromise,1330  collectionId: number,1331  token: number,1332): Promise<CrossAccountId> {1333  const owner = (await api.rpc.unique.tokenOwner(collectionId, token)).toJSON() as any;1334  if (owner == null) throw new Error('owner == null');1335  return normalizeAccountId(owner);1336}1337export async function getTopmostTokenOwner(1338  api: ApiPromise,1339  collectionId: number,1340  token: number,1341): Promise<CrossAccountId> {1342  const owner = (await api.rpc.unique.topmostTokenOwner(collectionId, token)).toJSON() as any;1343  if (owner == null) throw new Error('owner == null');1344  return normalizeAccountId(owner);1345}1346export async function getTokenChildren(1347  api: ApiPromise,1348  collectionId: number,1349  tokenId: number,1350): Promise<UpDataStructsTokenChild[]> {1351  return (await api.rpc.unique.tokenChildren(collectionId, tokenId)).toJSON() as any;1352}1353export async function isTokenExists(1354  api: ApiPromise,1355  collectionId: number,1356  token: number,1357): Promise<boolean> {1358  return (await api.rpc.unique.tokenExists(collectionId, token)).toJSON();1359}1360export async function getLastTokenId(1361  api: ApiPromise,1362  collectionId: number,1363): Promise<number> {1364  return (await api.rpc.unique.lastTokenId(collectionId)).toJSON();1365}1366export async function getAdminList(1367  api: ApiPromise,1368  collectionId: number,1369): Promise<string[]> {1370  return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any;1371}1372export async function getTokenProperties(1373  api: ApiPromise,1374  collectionId: number,1375  tokenId: number,1376  propertyKeys: string[],1377): Promise<UpDataStructsProperty[]> {1378  return (await api.rpc.unique.tokenProperties(collectionId, tokenId, propertyKeys)).toHuman() as any;1379}13801381export async function createFungibleItemExpectSuccess(1382  sender: IKeyringPair,1383  collectionId: number,1384  data: CreateFungibleData,1385  owner: CrossAccountId | string = sender.address,1386) {1387  return await usingApi(async (api) => {1388    const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), {Fungible: data});13891390    const events = await submitTransactionAsync(sender, tx);1391    const result = getCreateItemResult(events);13921393    expect(result.success).to.be.true;1394    return result.itemId;1395  });1396}13971398export async function createMultipleItemsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {1399  await usingApi(async (api) => {1400    const to = normalizeAccountId(owner);1401    const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);14021403    const events = await submitTransactionAsync(sender, tx);1404    expect(getGenericResult(events).success).to.be.true;1405  });1406}14071408export async function createMultipleItemsWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {1409  await usingApi(async (api) => {1410    const to = normalizeAccountId(owner);1411    const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);14121413    const events = await submitTransactionAsync(sender, tx);1414    const result = getCreateItemsResult(events);14151416    for (const res of result) {1417      expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1418    }1419  });1420}14211422export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {1423  await usingApi(async (api) => {1424    const tx = api.tx.unique.createMultipleItemsEx(collectionId, itemsData);14251426    const events = await submitTransactionAsync(sender, tx);1427    const result = getCreateItemsResult(events);14281429    for (const res of result) {1430      expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1431    }1432  });1433}14341435export async function createItemWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, props:  Array<Property>, owner: CrossAccountId | string = sender.address) {1436  let newItemId = 0;1437  await usingApi(async (api) => {1438    const to = normalizeAccountId(owner);1439    const itemCountBefore = await getLastTokenId(api, collectionId);1440    const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);14411442    let tx;1443    if (createMode === 'Fungible') {1444      const createData = {fungible: {value: 10}};1445      tx = api.tx.unique.createItem(collectionId, to, createData as any);1446    } else if (createMode === 'ReFungible') {1447      const createData = {refungible: {pieces: 100}};1448      tx = api.tx.unique.createItem(collectionId, to, createData as any);1449    } else {1450      const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});1451      tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);1452    }14531454    const events = await submitTransactionAsync(sender, tx);1455    const result = getCreateItemResult(events);14561457    const itemCountAfter = await getLastTokenId(api, collectionId);1458    const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);14591460    if (createMode === 'NFT') {1461      expect(await api.rpc.unique.tokenProperties(collectionId, result.itemId)).not.to.be.empty;1462    }14631464    // What to expect1465    // tslint:disable-next-line:no-unused-expression1466    expect(result.success).to.be.true;1467    if (createMode === 'Fungible') {1468      expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);1469    } else {1470      expect(itemCountAfter).to.be.equal(itemCountBefore + 1);1471    }1472    expect(collectionId).to.be.equal(result.collectionId);1473    expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());1474    expect(to).to.be.deep.equal(result.recipient);1475    newItemId = result.itemId;1476  });1477  return newItemId;1478}14791480export async function createItemWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1481  await usingApi(async (api) => {14821483    let tx;1484    if (createMode === 'NFT') {1485      const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}}) as UpDataStructsCreateItemData;1486      tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);1487    } else {1488      tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);1489    }149014911492    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1493    if(events.message && events.message.toString().indexOf('1002: Verification Error') > -1) return;1494    const result = getCreateItemResult(events);14951496    expect(result.success).to.be.false;1497  });1498}14991500export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1501  let newItemId = 0;1502  await usingApi(async (api) => {1503    const to = normalizeAccountId(owner);1504    const itemCountBefore = await getLastTokenId(api, collectionId);1505    const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);15061507    let tx;1508    if (createMode === 'Fungible') {1509      const createData = {fungible: {value: 10}};1510      tx = api.tx.unique.createItem(collectionId, to, createData as any);1511    } else if (createMode === 'ReFungible') {1512      const createData = {refungible: {pieces: 100}};1513      tx = api.tx.unique.createItem(collectionId, to, createData as any);1514    } else {1515      const createData = {nft: {}};1516      tx = api.tx.unique.createItem(collectionId, to, createData as any);1517    }15181519    const events = await executeTransaction(api, sender, tx);1520    const result = getCreateItemResult(events);15211522    const itemCountAfter = await getLastTokenId(api, collectionId);1523    const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);15241525    // What to expect1526    // tslint:disable-next-line:no-unused-expression1527    expect(result.success).to.be.true;1528    if (createMode === 'Fungible') {1529      expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);1530    } else {1531      expect(itemCountAfter).to.be.equal(itemCountBefore + 1);1532    }1533    expect(collectionId).to.be.equal(result.collectionId);1534    expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());1535    expect(to).to.be.deep.equal(result.recipient);1536    newItemId = result.itemId;1537  });1538  return newItemId;1539}15401541export async function createRefungibleToken(api: ApiPromise, sender: IKeyringPair, collectionId: number, amount: bigint, owner: CrossAccountId | IKeyringPair | string = sender.address) : Promise<CreateItemResult> {1542  const createData = {refungible: {pieces: amount}};1543  const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createData as any);15441545  const events = await submitTransactionAsync(sender, tx);1546  return  getCreateItemResult(events);1547}15481549export async function createItemExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1550  await usingApi(async (api) => {1551    const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);15521553    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1554    const result = getCreateItemResult(events);15551556    expect(result.success).to.be.false;1557  });1558}15591560export async function setPublicAccessModeExpectSuccess(1561  sender: IKeyringPair, collectionId: number,1562  accessMode: 'Normal' | 'AllowList',1563) {1564  await usingApi(async (api) => {15651566    // Run the transaction1567    const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1568    const events = await submitTransactionAsync(sender, tx);1569    const result = getGenericResult(events);15701571    // Get the collection1572    const collection = await queryCollectionExpectSuccess(api, collectionId);15731574    // What to expect1575    // tslint:disable-next-line:no-unused-expression1576    expect(result.success).to.be.true;1577    expect(collection.permissions.access.toHuman()).to.be.equal(accessMode);1578  });1579}15801581export async function setPublicAccessModeExpectFail(1582  sender: IKeyringPair, collectionId: number,1583  accessMode: 'Normal' | 'AllowList',1584) {1585  await usingApi(async (api) => {15861587    // Run the transaction1588    const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1589    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1590    const result = getGenericResult(events);15911592    // What to expect1593    // tslint:disable-next-line:no-unused-expression1594    expect(result.success).to.be.false;1595  });1596}15971598export async function enableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1599  await setPublicAccessModeExpectSuccess(sender, collectionId, 'AllowList');1600}16011602export async function enableAllowListExpectFail(sender: IKeyringPair, collectionId: number) {1603  await setPublicAccessModeExpectFail(sender, collectionId, 'AllowList');1604}16051606export async function disableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1607  await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1608}16091610export async function setMintPermissionExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {1611  await usingApi(async (api) => {16121613    // Run the transaction1614    const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1615    const events = await submitTransactionAsync(sender, tx);1616    const result = getGenericResult(events);1617    expect(result.success).to.be.true;16181619    // Get the collection1620    const collection = await queryCollectionExpectSuccess(api, collectionId);16211622    expect(collection.permissions.mintMode.toHuman()).to.be.equal(enabled);1623  });1624}16251626export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {1627  await setMintPermissionExpectSuccess(sender, collectionId, true);1628}16291630export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {1631  await usingApi(async (api) => {1632    // Run the transaction1633    const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1634    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1635    const result = getCreateCollectionResult(events);1636    // tslint:disable-next-line:no-unused-expression1637    expect(result.success).to.be.false;1638  });1639}16401641export async function setChainLimitsExpectFailure(sender: IKeyringPair, limits: IChainLimits) {1642  await usingApi(async (api) => {1643    // Run the transaction1644    const tx = api.tx.unique.setChainLimits(limits);1645    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1646    const result = getCreateCollectionResult(events);1647    // tslint:disable-next-line:no-unused-expression1648    expect(result.success).to.be.false;1649  });1650}16511652export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId) {1653  return (await api.rpc.unique.allowed(collectionId, normalizeAccountId(address))).toJSON();1654}16551656export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1657  await usingApi(async (api) => {1658    expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.false;16591660    // Run the transaction1661    const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1662    const events = await submitTransactionAsync(sender, tx);1663    const result = getGenericResult(events);1664    expect(result.success).to.be.true;16651666    expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1667  });1668}16691670export async function addToAllowListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1671  await usingApi(async (api) => {16721673    expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;16741675    // Run the transaction1676    const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1677    const events = await submitTransactionAsync(sender, tx);1678    const result = getGenericResult(events);1679    expect(result.success).to.be.true;16801681    expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1682  });1683}16841685export async function addToAllowListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1686  await usingApi(async (api) => {16871688    // Run the transaction1689    const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1690    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1691    const result = getGenericResult(events);16921693    // What to expect1694    // tslint:disable-next-line:no-unused-expression1695    expect(result.success).to.be.false;1696  });1697}16981699export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1700  await usingApi(async (api) => {1701    // Run the transaction1702    const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1703    const events = await submitTransactionAsync(sender, tx);1704    const result = getGenericResult(events);17051706    // What to expect1707    // tslint:disable-next-line:no-unused-expression1708    expect(result.success).to.be.true;1709  });1710}17111712export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1713  await usingApi(async (api) => {1714    // Run the transaction1715    const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1716    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1717    const result = getGenericResult(events);17181719    // What to expect1720    // tslint:disable-next-line:no-unused-expression1721    expect(result.success).to.be.false;1722  });1723}17241725export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)1726  : Promise<UpDataStructsRpcCollection | null> => {1727  return (await api.rpc.unique.collectionById(collectionId)).unwrapOr(null);1728};17291730export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {1731  // set global object - collectionsCount1732  return (await api.rpc.unique.collectionStats()).created.toNumber();1733};17341735export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<UpDataStructsRpcCollection> {1736  return (await api.rpc.unique.collectionById(collectionId)).unwrap();1737}17381739export async function waitNewBlocks(blocksCount = 1): Promise<void> {1740  await usingApi(async (api) => {1741    const promise = new Promise<void>(async (resolve) => {1742      const unsubscribe = await api.rpc.chain.subscribeNewHeads(() => {1743        if (blocksCount > 0) {1744          blocksCount--;1745        } else {1746          unsubscribe();1747          resolve();1748        }1749      });1750    });1751    return promise;1752  });1753}17541755export async function repartitionRFT(1756  api: ApiPromise,1757  collectionId: number,1758  sender: IKeyringPair,1759  tokenId: number,1760  amount: bigint,1761): Promise<boolean> {1762  const tx = api.tx.unique.repartition(collectionId, tokenId, amount);1763  const events = await submitTransactionAsync(sender, tx);1764  const result = getGenericResult(events);17651766  return result.success;1767}17681769export async function itApi(name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {1770  let i: any = it;1771  if (opts.only) i = i.only;1772  else if (opts.skip) i = i.skip;1773  i(name, async () => {1774    await usingApi(async (api, privateKeyWrapper) => {1775      await cb({api, privateKeyWrapper});1776    });1777  });1778}17791780itApi.only = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {only: true});1781itApi.skip = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {skip: true});
after · tests/src/util/helpers.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import '../interfaces/augment-api-rpc';18import '../interfaces/augment-api-query';19import {ApiPromise} from '@polkadot/api';20import type {AccountId, EventRecord, Event} from '@polkadot/types/interfaces';21import type {GenericEventData} from '@polkadot/types';22import {AnyTuple, IEvent, IKeyringPair} from '@polkadot/types/types';23import {evmToAddress} from '@polkadot/util-crypto';24import BN from 'bn.js';25import chai from 'chai';26import chaiAsPromised from 'chai-as-promised';27import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';28import {hexToStr, strToUTF16, utf16ToStr} from './util';29import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';30import {UpDataStructsTokenChild} from '../interfaces';31import {Context} from 'mocha';3233chai.use(chaiAsPromised);34const expect = chai.expect;3536export type CrossAccountId = {37  Substrate: string,38} | {39  Ethereum: string,40};414243export enum Pallets {44  Inflation = 'inflation',45  RmrkCore = 'rmrkcore',46  RmrkEquip = 'rmrkequip',47  ReFungible = 'refungible',48  Fungible = 'fungible',49  NFT = 'nonfungible',50  Scheduler = 'scheduler',51  AppPromotion = 'promotion',52}5354export async function isUnique(): Promise<boolean> {55  return usingApi(async api => {56    const chain = await api.rpc.system.chain();5758    return chain.eq('UNIQUE');59  });60}6162export async function isQuartz(): Promise<boolean> {63  return usingApi(async api => {64    const chain = await api.rpc.system.chain();65    66    return chain.eq('QUARTZ');67  });68}6970let modulesNames: any;71export function getModuleNames(api: ApiPromise): string[] {72  if (typeof modulesNames === 'undefined') 73    modulesNames = api.runtimeMetadata.asLatest.pallets.map(m => m.name.toString().toLowerCase());74  return modulesNames;75}7677export async function missingRequiredPallets(requiredPallets: string[]): Promise<string[]> {78  return await usingApi(async api => {79    const pallets = getModuleNames(api);8081    return requiredPallets.filter(p => !pallets.includes(p));82  });83}8485export async function checkPalletsPresence(requiredPallets: string[]): Promise<boolean> {86  return (await missingRequiredPallets(requiredPallets)).length == 0;87}8889export async function requirePallets(mocha: Context, requiredPallets: string[]) {90  const missingPallets = await missingRequiredPallets(requiredPallets);9192  if (missingPallets.length > 0) {93    const skippingTestMsg = `\tSkipping test "${mocha.test?.title}".`;94    const missingPalletsMsg = `\tThe following pallets are missing:\n\t- ${missingPallets.join('\n\t- ')}`;95    const skipMsg = `${skippingTestMsg}\n${missingPalletsMsg}`;9697    console.error('\x1b[38:5:208m%s\x1b[0m', skipMsg);9899    mocha.skip();100  }101}102103export function bigIntToSub(api: ApiPromise, number: bigint) {104  return api.registry.createType('AccountId', '0x' + number.toString(16).padStart(64, '0')).toJSON();105}106107export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {108  if (typeof input === 'string') {109    if (input.length >= 47) {110      return {Substrate: input};111    } else if (input.length === 42 && input.startsWith('0x')) {112      return {Ethereum: input.toLowerCase()};113    } else if (input.length === 40 && !input.startsWith('0x')) {114      return {Ethereum: '0x' + input.toLowerCase()};115    } else {116      throw new Error(`Unknown address format: "${input}"`);117    }118  }119  if ('address' in input) {120    return {Substrate: input.address};121  }122  if ('Ethereum' in input) {123    return {124      Ethereum: input.Ethereum.toLowerCase(),125    };126  } else if ('ethereum' in input) {127    return {128      Ethereum: (input as any).ethereum.toLowerCase(),129    };130  } else if ('Substrate' in input) {131    return input;132  } else if ('substrate' in input) {133    return {134      Substrate: (input as any).substrate,135    };136  }137138  // AccountId139  return {Substrate: input.toString()};140}141export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {142  input = normalizeAccountId(input);143  if ('Substrate' in input) {144    return input.Substrate;145  } else {146    return evmToAddress(input.Ethereum);147  }148}149150export const U128_MAX = (1n << 128n) - 1n;151152const MICROUNIQUE = 1_000_000_000_000n;153const MILLIUNIQUE = 1_000n * MICROUNIQUE;154const CENTIUNIQUE = 10n * MILLIUNIQUE;155export const UNIQUE = 100n * CENTIUNIQUE;156157interface GenericResult<T> {158  success: boolean;159  data: T | null;160}161162interface CreateCollectionResult {163  success: boolean;164  collectionId: number;165}166167interface CreateItemResult {168  success: boolean;169  collectionId: number;170  itemId: number;171  recipient?: CrossAccountId;172  amount?: number;173}174175interface DestroyItemResult {176  success: boolean;177  collectionId: number;178  itemId: number;179  owner: CrossAccountId;180  amount: number;181}182183interface TransferResult {184  collectionId: number;185  itemId: number;186  sender?: CrossAccountId;187  recipient?: CrossAccountId;188  value: bigint;189}190191interface IReFungibleOwner {192  fraction: BN;193  owner: number[];194}195196interface IGetMessage {197  checkMsgUnqMethod: string;198  checkMsgTrsMethod: string;199  checkMsgSysMethod: string;200}201202export interface IFungibleTokenDataType {203  value: number;204}205206export interface IChainLimits {207  collectionNumbersLimit: number;208  accountTokenOwnershipLimit: number;209  collectionsAdminsLimit: number;210  customDataLimit: number;211  nftSponsorTransferTimeout: number;212  fungibleSponsorTransferTimeout: number;213  refungibleSponsorTransferTimeout: number;214  //offchainSchemaLimit: number;215  //constOnChainSchemaLimit: number;216}217218export interface IReFungibleTokenDataType {219  owner: IReFungibleOwner[];220}221222export function uniqueEventMessage(events: EventRecord[]): IGetMessage {223  let checkMsgUnqMethod = '';224  let checkMsgTrsMethod = '';225  let checkMsgSysMethod = '';226  events.forEach(({event: {method, section}}) => {227    if (section === 'common') {228      checkMsgUnqMethod = method;229    } else if (section === 'treasury') {230      checkMsgTrsMethod = method;231    } else if (section === 'system') {232      checkMsgSysMethod = method;233    } else { return null; }234  });235  const result: IGetMessage = {236    checkMsgUnqMethod,237    checkMsgTrsMethod,238    checkMsgSysMethod,239  };240  return result;241}242243export function getEvent<T extends Event>(events: EventRecord[], check: (event: IEvent<AnyTuple>) => event is T): T | undefined {244  const event = events.find(r => check(r.event));245  if (!event) return;246  return event.event as T;247}248249export function getGenericResult<T>(events: EventRecord[]): GenericResult<T>;250export function getGenericResult<T>(251  events: EventRecord[],252  expectSection: string,253  expectMethod: string,254  extractAction: (data: GenericEventData) => T255): GenericResult<T>;256257export function getGenericResult<T>(258  events: EventRecord[],259  expectSection?: string,260  expectMethod?: string,261  extractAction?: (data: GenericEventData) => T,262): GenericResult<T> {263  let success = false;264  let successData = null;265266  events.forEach(({event: {data, method, section}}) => {267    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);268    if (method === 'ExtrinsicSuccess') {269      success = true;270    } else if ((expectSection == section) && (expectMethod == method)) {271      successData = extractAction!(data as any);272    }273  });274275  const result: GenericResult<T> = {276    success,277    data: successData,278  };279  return result;280}281282export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {283  const genericResult = getGenericResult(events, 'common', 'CollectionCreated', (data) => parseInt(data[0].toString(), 10));284  const result: CreateCollectionResult = {285    success: genericResult.success,286    collectionId: genericResult.data ?? 0,287  };288  return result;289}290291export function getCreateItemsResult(events: EventRecord[]): CreateItemResult[] {292  const results: CreateItemResult[] = [];293  294  const genericResult = getGenericResult<CreateItemResult[]>(events, 'common', 'ItemCreated', (data) => {295    const collectionId = parseInt(data[0].toString(), 10);296    const itemId = parseInt(data[1].toString(), 10);297    const recipient = normalizeAccountId(data[2].toJSON() as any);298    const amount = parseInt(data[3].toString(), 10);299300    const itemRes: CreateItemResult = {301      success: true,302      collectionId,303      itemId,304      recipient,305      amount,306    };307308    results.push(itemRes);309    return results;310  });311312  if (!genericResult.success) return [];313  return results;314}315316export function getCreateItemResult(events: EventRecord[]): CreateItemResult {317  const genericResult = getGenericResult(events, 'common', 'ItemCreated', (data) => data.map(function(value) { return value.toJSON(); }));318  319  if (genericResult.data == null) 320    return {321      success: genericResult.success,322      collectionId: 0,323      itemId: 0,324      amount: 0,325    };326  else 327    return {328      success: genericResult.success,329      collectionId: genericResult.data[0] as number,330      itemId: genericResult.data[1] as number,331      recipient: normalizeAccountId(genericResult.data![2] as any),332      amount: genericResult.data[3] as number,333    };334}335336export function getDestroyItemsResult(events: EventRecord[]): DestroyItemResult[] {337  const results: DestroyItemResult[] = [];338  339  const genericResult = getGenericResult<DestroyItemResult[]>(events, 'common', 'ItemDestroyed', (data) => {340    const collectionId = parseInt(data[0].toString(), 10);341    const itemId = parseInt(data[1].toString(), 10);342    const owner = normalizeAccountId(data[2].toJSON() as any);343    const amount = parseInt(data[3].toString(), 10);344345    const itemRes: DestroyItemResult = {346      success: true,347      collectionId,348      itemId,349      owner,350      amount,351    };352353    results.push(itemRes);354    return results;355  });356357  if (!genericResult.success) return [];358  return results;359}360361export function getTransferResult(api: ApiPromise, events: EventRecord[]): TransferResult {362  for (const {event} of events) {363    if (api.events.common.Transfer.is(event)) {364      const [collection, token, sender, recipient, value] = event.data;365      return {366        collectionId: collection.toNumber(),367        itemId: token.toNumber(),368        sender: normalizeAccountId(sender.toJSON() as any),369        recipient: normalizeAccountId(recipient.toJSON() as any),370        value: value.toBigInt(),371      };372    }373  }374  throw new Error('no transfer event');375}376377interface Nft {378  type: 'NFT';379}380381interface Fungible {382  type: 'Fungible';383  decimalPoints: number;384}385386interface ReFungible {387  type: 'ReFungible';388}389390export type CollectionMode = Nft | Fungible | ReFungible;391392export type Property = {393  key: any,394  value: any,395};396397type Permission = {398  mutable: boolean;399  collectionAdmin: boolean;400  tokenOwner: boolean;401}402403type PropertyPermission = {404  key: any;405  permission: Permission;406}407408export type CreateCollectionParams = {409  mode: CollectionMode,410  name: string,411  description: string,412  tokenPrefix: string,413  properties?: Array<Property>,414  propPerm?: Array<PropertyPermission>415};416417const defaultCreateCollectionParams: CreateCollectionParams = {418  description: 'description',419  mode: {type: 'NFT'},420  name: 'name',421  tokenPrefix: 'prefix',422};423424export async function425createCollection(426  api: ApiPromise,427  sender: IKeyringPair,428  params: Partial<CreateCollectionParams> = {},429): Promise<CreateCollectionResult> {430  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};431432  let modeprm = {};433  if (mode.type === 'NFT') {434    modeprm = {nft: null};435  } else if (mode.type === 'Fungible') {436    modeprm = {fungible: mode.decimalPoints};437  } else if (mode.type === 'ReFungible') {438    modeprm = {refungible: null};439  }440441  const tx = api.tx.unique.createCollectionEx({442    name: strToUTF16(name),443    description: strToUTF16(description),444    tokenPrefix: strToUTF16(tokenPrefix),445    mode: modeprm as any,446  });447  const events = await executeTransaction(api, sender, tx);448  return getCreateCollectionResult(events);449}450451export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {452  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};453454  let collectionId = 0;455  await usingApi(async (api, privateKeyWrapper) => {456    // Get number of collections before the transaction457    const collectionCountBefore = await getCreatedCollectionCount(api);458459    // Run the CreateCollection transaction460    const alicePrivateKey = privateKeyWrapper('//Alice');461462    const result = await createCollection(api, alicePrivateKey, params);463464    // Get number of collections after the transaction465    const collectionCountAfter = await getCreatedCollectionCount(api);466467    // Get the collection468    const collection = await queryCollectionExpectSuccess(api, result.collectionId);469470    // What to expect471    // tslint:disable-next-line:no-unused-expression472    expect(result.success).to.be.true;473    expect(result.collectionId).to.be.equal(collectionCountAfter);474    // tslint:disable-next-line:no-unused-expression475    expect(collection).to.be.not.null;476    expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');477    expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicePrivateKey));478    expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);479    expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);480    expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);481482    collectionId = result.collectionId;483  });484485  return collectionId;486}487488export async function createCollectionWithPropsExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {489  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};490491  let collectionId = 0;492  await usingApi(async (api, privateKeyWrapper) => {493    // Get number of collections before the transaction494    const collectionCountBefore = await getCreatedCollectionCount(api);495496    // Run the CreateCollection transaction497    const alicePrivateKey = privateKeyWrapper('//Alice');498499    let modeprm = {};500    if (mode.type === 'NFT') {501      modeprm = {nft: null};502    } else if (mode.type === 'Fungible') {503      modeprm = {fungible: mode.decimalPoints};504    } else if (mode.type === 'ReFungible') {505      modeprm = {refungible: null};506    }507508    const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any, properties: params.properties, tokenPropertyPermissions: params.propPerm});509    const events = await submitTransactionAsync(alicePrivateKey, tx);510    const result = getCreateCollectionResult(events);511512    // Get number of collections after the transaction513    const collectionCountAfter = await getCreatedCollectionCount(api);514515    // Get the collection516    const collection = await queryCollectionExpectSuccess(api, result.collectionId);517518    // What to expect519    // tslint:disable-next-line:no-unused-expression520    expect(result.success).to.be.true;521    expect(result.collectionId).to.be.equal(collectionCountAfter);522    // tslint:disable-next-line:no-unused-expression523    expect(collection).to.be.not.null;524    expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');525    expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicePrivateKey));526    expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);527    expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);528    expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);529530531    collectionId = result.collectionId;532  });533534  return collectionId;535}536537export async function createCollectionWithPropsExpectFailure(params: Partial<CreateCollectionParams> = {}) {538  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};539540  await usingApi(async (api, privateKeyWrapper) => {541    // Get number of collections before the transaction542    const collectionCountBefore = await getCreatedCollectionCount(api);543544    // Run the CreateCollection transaction545    const alicePrivateKey = privateKeyWrapper('//Alice');546547    let modeprm = {};548    if (mode.type === 'NFT') {549      modeprm = {nft: null};550    } else if (mode.type === 'Fungible') {551      modeprm = {fungible: mode.decimalPoints};552    } else if (mode.type === 'ReFungible') {553      modeprm = {refungible: null};554    }555556    const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any, properties: params.properties, tokenPropertyPermissions: params.propPerm});557    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;558559560    // Get number of collections after the transaction561    const collectionCountAfter = await getCreatedCollectionCount(api);562563    expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');564  });565}566567export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {568  const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};569570  let modeprm = {};571  if (mode.type === 'NFT') {572    modeprm = {nft: null};573  } else if (mode.type === 'Fungible') {574    modeprm = {fungible: mode.decimalPoints};575  } else if (mode.type === 'ReFungible') {576    modeprm = {refungible: null};577  }578579  await usingApi(async (api, privateKeyWrapper) => {580    // Get number of collections before the transaction581    const collectionCountBefore = await getCreatedCollectionCount(api);582583    // Run the CreateCollection transaction584    const alicePrivateKey = privateKeyWrapper('//Alice');585    const tx = api.tx.unique.createCollectionEx({name: strToUTF16(name), description: strToUTF16(description), tokenPrefix: strToUTF16(tokenPrefix), mode: modeprm as any});586    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;587588    // Get number of collections after the transaction589    const collectionCountAfter = await getCreatedCollectionCount(api);590591    // What to expect592    expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');593  });594}595596export async function findUnusedAddress(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, seedAddition = ''): Promise<IKeyringPair> {597  let bal = 0n;598  let unused;599  do {600    const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000)) + seedAddition;601    unused = privateKeyWrapper(`//${randomSeed}`);602    bal = (await api.query.system.account(unused.address)).data.free.toBigInt();603  } while (bal !== 0n);604  return unused;605}606607export async function getAllowance(api: ApiPromise, collectionId: number, owner: CrossAccountId | string | IKeyringPair, approved: CrossAccountId | string | IKeyringPair, tokenId: number) {608  return (await api.rpc.unique.allowance(collectionId, normalizeAccountId(owner), normalizeAccountId(approved), tokenId)).toBigInt();609}610611export function findUnusedAddresses(api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair, amount: number): Promise<IKeyringPair[]> {612  return Promise.all(new Array(amount).fill(null).map(() => findUnusedAddress(api, privateKeyWrapper, '_' + Date.now())));613}614615export async function findNotExistingCollection(api: ApiPromise): Promise<number> {616  const totalNumber = await getCreatedCollectionCount(api);617  const newCollection: number = totalNumber + 1;618  return newCollection;619}620621function getDestroyResult(events: EventRecord[]): boolean {622  let success = false;623  events.forEach(({event: {method}}) => {624    if (method == 'ExtrinsicSuccess') {625      success = true;626    }627  });628  return success;629}630631export async function destroyCollectionExpectFailure(collectionId: number, senderSeed = '//Alice') {632  await usingApi(async (api, privateKeyWrapper) => {633    // Run the DestroyCollection transaction634    const alicePrivateKey = privateKeyWrapper(senderSeed);635    const tx = api.tx.unique.destroyCollection(collectionId);636    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;637  });638}639640export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed = '//Alice') {641  await usingApi(async (api, privateKeyWrapper) => {642    // Run the DestroyCollection transaction643    const alicePrivateKey = privateKeyWrapper(senderSeed);644    const tx = api.tx.unique.destroyCollection(collectionId);645    const events = await submitTransactionAsync(alicePrivateKey, tx);646    const result = getDestroyResult(events);647    expect(result).to.be.true;648649    // What to expect650    expect(await getDetailedCollectionInfo(api, collectionId)).to.be.null;651  });652}653654export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {655  await usingApi(async (api) => {656    const tx = api.tx.unique.setCollectionLimits(collectionId, limits);657    const events = await submitTransactionAsync(sender, tx);658    const result = getGenericResult(events);659660    expect(result.success).to.be.true;661  });662}663664export const setCollectionPermissionsExpectSuccess = async (sender: IKeyringPair, collectionId: number, permissions: any) => {665  await usingApi(async(api) => {666    const tx = api.tx.unique.setCollectionPermissions(collectionId, permissions);667    const events = await submitTransactionAsync(sender, tx);668    const result = getGenericResult(events);669670    expect(result.success).to.be.true;671  });672};673674export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {675  await usingApi(async (api) => {676    const tx = api.tx.unique.setCollectionLimits(collectionId, limits);677    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;678    const result = getGenericResult(events);679680    expect(result.success).to.be.false;681  });682}683684export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string, sender = '//Alice') {685  await usingApi(async (api, privateKeyWrapper) => {686687    // Run the transaction688    const senderPrivateKey = privateKeyWrapper(sender);689    const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);690    const events = await submitTransactionAsync(senderPrivateKey, tx);691    const result = getGenericResult(events);692693    // Get the collection694    const collection = await queryCollectionExpectSuccess(api, collectionId);695696    // What to expect697    expect(result.success).to.be.true;698    expect(collection.sponsorship.toJSON()).to.deep.equal({699      unconfirmed: sponsor,700    });701  });702}703704export async function removeCollectionSponsorExpectSuccess(collectionId: number, sender = '//Alice') {705  await usingApi(async (api, privateKeyWrapper) => {706707    // Run the transaction708    const alicePrivateKey = privateKeyWrapper(sender);709    const tx = api.tx.unique.removeCollectionSponsor(collectionId);710    const events = await submitTransactionAsync(alicePrivateKey, tx);711    const result = getGenericResult(events);712713    // Get the collection714    const collection = await queryCollectionExpectSuccess(api, collectionId);715716    // What to expect717    expect(result.success).to.be.true;718    expect(collection.sponsorship.toJSON()).to.be.deep.equal({disabled: null});719  });720}721722export async function removeCollectionSponsorExpectFailure(collectionId: number, senderSeed = '//Alice') {723  await usingApi(async (api, privateKeyWrapper) => {724725    // Run the transaction726    const alicePrivateKey = privateKeyWrapper(senderSeed);727    const tx = api.tx.unique.removeCollectionSponsor(collectionId);728    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;729  });730}731732export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed = '//Alice') {733  await usingApi(async (api, privateKeyWrapper) => {734735    // Run the transaction736    const alicePrivateKey = privateKeyWrapper(senderSeed);737    const tx = api.tx.unique.setCollectionSponsor(collectionId, sponsor);738    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;739  });740}741742export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed = '//Alice') {743  await usingApi(async (api, privateKeyWrapper) => {744745    // Run the transaction746    const sender = privateKeyWrapper(senderSeed);747    await confirmSponsorshipByKeyExpectSuccess(collectionId, sender);748  });749}750751export async function confirmSponsorshipByKeyExpectSuccess(collectionId: number, sender: IKeyringPair) {752  await usingApi(async (api, privateKeyWrapper) => {753754    // Run the transaction755    const tx = api.tx.unique.confirmSponsorship(collectionId);756    const events = await submitTransactionAsync(sender, tx);757    const result = getGenericResult(events);758759    // Get the collection760    const collection = await queryCollectionExpectSuccess(api, collectionId);761762    // What to expect763    expect(result.success).to.be.true;764    expect(collection.sponsorship.toJSON()).to.be.deep.equal({765      confirmed: sender.address,766    });767  });768}769770771export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed = '//Alice') {772  await usingApi(async (api, privateKeyWrapper) => {773774    // Run the transaction775    const sender = privateKeyWrapper(senderSeed);776    const tx = api.tx.unique.confirmSponsorship(collectionId);777    await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;778  });779}780781export async function enableContractSponsoringExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {782  await usingApi(async (api) => {783    const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);784    const events = await submitTransactionAsync(sender, tx);785    const result = getGenericResult(events);786787    expect(result.success).to.be.true;788  });789}790791export async function enableContractSponsoringExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, enable: boolean) {792  await usingApi(async (api) => {793    const tx = api.tx.unique.enableContractSponsoring(contractAddress, enable);794    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;795    const result = getGenericResult(events);796797    expect(result.success).to.be.false;798  });799}800801export async function setTransferFlagExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {802803  await usingApi(async (api) => {804805    const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, enabled);806    const events = await submitTransactionAsync(sender, tx);807    const result = getGenericResult(events);808809    expect(result.success).to.be.true;810  });811}812813export async function setTransferFlagExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {814815  await usingApi(async (api) => {816817    const tx = api.tx.unique.setTransfersEnabledFlag(collectionId, enabled);818    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;819    const result = getGenericResult(events);820821    expect(result.success).to.be.false;822  });823}824825export async function setContractSponsoringRateLimitExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {826  await usingApi(async (api) => {827    const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);828    const events = await submitTransactionAsync(sender, tx);829    const result = getGenericResult(events);830831    expect(result.success).to.be.true;832  });833}834835export async function setContractSponsoringRateLimitExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, rateLimit: number) {836  await usingApi(async (api) => {837    const tx = api.tx.unique.setContractSponsoringRateLimit(contractAddress, rateLimit);838    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;839    const result = getGenericResult(events);840841    expect(result.success).to.be.false;842  });843}844845export async function getNextSponsored(846  api: ApiPromise,847  collectionId: number,848  account: string | CrossAccountId,849  tokenId: number,850): Promise<number> {851  return Number((await api.rpc.unique.nextSponsored(collectionId, account, tokenId)).unwrapOr(-1));852}853854export async function toggleContractAllowlistExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, value = true) {855  await usingApi(async (api) => {856    const tx = api.tx.unique.toggleContractAllowList(contractAddress, value);857    const events = await submitTransactionAsync(sender, tx);858    const result = getGenericResult(events);859860    expect(result.success).to.be.true;861  });862}863864export async function isAllowlistedInContract(contractAddress: AccountId | string, user: string) {865  let allowlisted = false;866  await usingApi(async (api) => {867    allowlisted = (await api.query.unique.contractAllowList(contractAddress, user)).toJSON() as boolean;868  });869  return allowlisted;870}871872export async function addToContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {873  await usingApi(async (api) => {874    const tx = api.tx.unique.addToContractAllowList(contractAddress.toString(), user.toString());875    const events = await submitTransactionAsync(sender, tx);876    const result = getGenericResult(events);877878    expect(result.success).to.be.true;879  });880}881882export async function removeFromContractAllowListExpectSuccess(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {883  await usingApi(async (api) => {884    const tx = api.tx.unique.removeFromContractAllowList(contractAddress.toString(), user.toString());885    const events = await submitTransactionAsync(sender, tx);886    const result = getGenericResult(events);887888    expect(result.success).to.be.true;889  });890}891892export async function removeFromContractAllowListExpectFailure(sender: IKeyringPair, contractAddress: AccountId | string, user: AccountId | string) {893  await usingApi(async (api) => {894    const tx = api.tx.unique.removeFromContractAllowList(contractAddress.toString(), user.toString());895    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;896    const result = getGenericResult(events);897898    expect(result.success).to.be.false;899  });900}901902export interface CreateFungibleData {903  readonly Value: bigint;904}905906export interface CreateReFungibleData { }907export interface CreateNftData { }908909export type CreateItemData = {910  NFT: CreateNftData;911} | {912  Fungible: CreateFungibleData;913} | {914  ReFungible: CreateReFungibleData;915};916917export async function burnItem(api: ApiPromise, sender: IKeyringPair, collectionId: number, tokenId: number, value: number | bigint) : Promise<boolean> {918  const tx = api.tx.unique.burnItem(collectionId, tokenId, value);919  const events = await submitTransactionAsync(sender, tx);920  return getGenericResult(events).success;921}922923export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, value: number | bigint = 1) {924  await usingApi(async (api) => {925    const balanceBefore = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);926    // if burning token by admin - use adminButnItemExpectSuccess927    expect(balanceBefore >= BigInt(value)).to.be.true;928929    expect(await burnItem(api, sender, collectionId, tokenId, value)).to.be.true;930931    const balanceAfter = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);932    expect(balanceAfter + BigInt(value)).to.be.equal(balanceBefore);933  });934}935936export async function burnItemExpectFailure(sender: IKeyringPair, collectionId: number, tokenId: number, value: number | bigint = 1) {937  await usingApi(async (api) => {938    const tx = api.tx.unique.burnItem(collectionId, tokenId, value);939940    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;941    const result = getCreateCollectionResult(events);942    // tslint:disable-next-line:no-unused-expression943    expect(result.success).to.be.false;944  });945}946947export async function burnFromExpectSuccess(sender: IKeyringPair, from: IKeyringPair | CrossAccountId, collectionId: number, tokenId: number, value: number | bigint = 1) {948  await usingApi(async (api) => {949    const tx = api.tx.unique.burnFrom(collectionId, normalizeAccountId(from), tokenId, value);950    const events = await submitTransactionAsync(sender, tx);951    return getGenericResult(events).success;952  });953}954955export async function956approve(957  api: ApiPromise,958  collectionId: number,959  tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string | IKeyringPair, amount: number | bigint,960) {961  const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);962  const events = await submitTransactionAsync(owner, approveUniqueTx);963  return getGenericResult(events).success;964}965966export async function967approveExpectSuccess(968  collectionId: number,969  tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string, amount: number | bigint = 1,970) {971  await usingApi(async (api: ApiPromise) => {972    const result = await approve(api, collectionId, tokenId, owner, approved, amount);973    expect(result).to.be.true;974975    expect(await getAllowance(api, collectionId, owner, approved, tokenId)).to.be.equal(BigInt(amount));976  });977}978979export async function adminApproveFromExpectSuccess(980  collectionId: number,981  tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,982) {983  await usingApi(async (api: ApiPromise) => {984    const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);985    const events = await submitTransactionAsync(admin, approveUniqueTx);986    const result = getGenericResult(events);987    expect(result.success).to.be.true;988989    expect(await getAllowance(api, collectionId, owner, approved, tokenId)).to.be.equal(BigInt(amount));990  });991}992993export async function994transferFrom(995  api: ApiPromise,996  collectionId: number,997  tokenId: number,998  accountApproved: IKeyringPair,999  accountFrom: IKeyringPair | CrossAccountId,1000  accountTo: IKeyringPair | CrossAccountId,1001  value: number | bigint,1002) {1003  const from = normalizeAccountId(accountFrom);1004  const to = normalizeAccountId(accountTo);1005  const transferFromTx = api.tx.unique.transferFrom(from, to, collectionId, tokenId, value);1006  const events = await submitTransactionAsync(accountApproved, transferFromTx);1007  return getGenericResult(events).success;1008}10091010export async function1011transferFromExpectSuccess(1012  collectionId: number,1013  tokenId: number,1014  accountApproved: IKeyringPair,1015  accountFrom: IKeyringPair | CrossAccountId,1016  accountTo: IKeyringPair | CrossAccountId,1017  value: number | bigint = 1,1018  type = 'NFT',1019) {1020  await usingApi(async (api: ApiPromise) => {1021    const from = normalizeAccountId(accountFrom);1022    const to = normalizeAccountId(accountTo);1023    let balanceBefore = 0n;1024    if (type === 'Fungible' || type === 'ReFungible') {1025      balanceBefore = await getBalance(api, collectionId, to, tokenId);1026    }1027    expect(await transferFrom(api, collectionId, tokenId, accountApproved, accountFrom, accountTo, value)).to.be.true;1028    if (type === 'NFT') {1029      expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);1030    }1031    if (type === 'Fungible') {1032      const balanceAfter = await getBalance(api, collectionId, to, tokenId);1033      if (JSON.stringify(to) !== JSON.stringify(from)) {1034        expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));1035      } else {1036        expect(balanceAfter).to.be.equal(balanceBefore);1037      }1038    }1039    if (type === 'ReFungible') {1040      expect(await getBalance(api, collectionId, to, tokenId)).to.be.equal(balanceBefore + BigInt(value));1041    }1042  });1043}10441045export async function1046transferFromExpectFail(1047  collectionId: number,1048  tokenId: number,1049  accountApproved: IKeyringPair,1050  accountFrom: IKeyringPair,1051  accountTo: IKeyringPair,1052  value: number | bigint = 1,1053) {1054  await usingApi(async (api: ApiPromise) => {1055    const transferFromTx = api.tx.unique.transferFrom(normalizeAccountId(accountFrom.address), normalizeAccountId(accountTo.address), collectionId, tokenId, value);1056    const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;1057    const result = getCreateCollectionResult(events);1058    // tslint:disable-next-line:no-unused-expression1059    expect(result.success).to.be.false;1060  });1061}10621063/* eslint no-async-promise-executor: "off" */1064export async function getBlockNumber(api: ApiPromise): Promise<number> {1065  return new Promise<number>(async (resolve) => {1066    const unsubscribe = await api.rpc.chain.subscribeNewHeads((head) => {1067      unsubscribe();1068      resolve(head.number.toNumber());1069    });1070  });1071}10721073export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | CrossAccountId) {1074  await usingApi(async (api) => {1075    const changeAdminTx = api.tx.unique.addCollectionAdmin(collectionId, normalizeAccountId(address));1076    const events = await submitTransactionAsync(sender, changeAdminTx);1077    const result = getCreateCollectionResult(events);1078    expect(result.success).to.be.true;1079  });1080}10811082export async function adminApproveFromExpectFail(1083  collectionId: number,1084  tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,1085) {1086  await usingApi(async (api: ApiPromise) => {1087    const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved), collectionId, tokenId, amount);1088    const events = await expect(submitTransactionAsync(admin, approveUniqueTx)).to.be.rejected;1089    const result = getGenericResult(events);1090    expect(result.success).to.be.false;1091  });1092}10931094export async function1095getFreeBalance(account: IKeyringPair): Promise<bigint> {1096  let balance = 0n;1097  await usingApi(async (api) => {1098    balance = BigInt((await api.query.system.account(account.address)).data.free.toString());1099  });11001101  return balance;1102}11031104export async function transferBalanceTo(api: ApiPromise, source: IKeyringPair, target: string, amount = 1000n * UNIQUE) {1105  const tx = api.tx.balances.transfer(target, amount);1106  const events = await submitTransactionAsync(source, tx);1107  const result = getGenericResult(events);1108  expect(result.success).to.be.true;1109}11101111export async function1112scheduleExpectSuccess(1113  operationTx: any,1114  sender: IKeyringPair,1115  blockSchedule: number,1116  scheduledId: string,1117  period = 1,1118  repetitions = 1,1119) {1120  await usingApi(async (api: ApiPromise) => {1121    const blockNumber: number | undefined = await getBlockNumber(api);1122    const expectedBlockNumber = blockNumber + blockSchedule;11231124    expect(blockNumber).to.be.greaterThan(0);1125    const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule1126      scheduledId,1127      expectedBlockNumber, 1128      repetitions > 1 ? [period, repetitions] : null, 1129      0, 1130      {Value: operationTx as any},1131    );11321133    const events = await submitTransactionAsync(sender, scheduleTx);1134    expect(getGenericResult(events).success).to.be.true;1135  });1136}11371138export async function1139scheduleExpectFailure(1140  operationTx: any,1141  sender: IKeyringPair,1142  blockSchedule: number,1143  scheduledId: string,1144  period = 1,1145  repetitions = 1,1146) {1147  await usingApi(async (api: ApiPromise) => {1148    const blockNumber: number | undefined = await getBlockNumber(api);1149    const expectedBlockNumber = blockNumber + blockSchedule;11501151    expect(blockNumber).to.be.greaterThan(0);1152    const scheduleTx = api.tx.scheduler.scheduleNamed( // schedule1153      scheduledId,1154      expectedBlockNumber, 1155      repetitions <= 1 ? null : [period, repetitions], 1156      0, 1157      {Value: operationTx as any},1158    );11591160    //const events = 1161    await expect(submitTransactionExpectFailAsync(sender, scheduleTx)).to.be.rejected;1162    //expect(getGenericResult(events).success).to.be.false;1163  });1164}11651166export async function1167scheduleTransferAndWaitExpectSuccess(1168  collectionId: number,1169  tokenId: number,1170  sender: IKeyringPair,1171  recipient: IKeyringPair,1172  value: number | bigint = 1,1173  blockSchedule: number,1174  scheduledId: string,1175) {1176  await usingApi(async (api: ApiPromise) => {1177    await scheduleTransferExpectSuccess(collectionId, tokenId, sender, recipient, value, blockSchedule, scheduledId);11781179    const recipientBalanceBefore = (await api.query.system.account(recipient.address)).data.free.toBigInt();11801181    // sleep for n + 1 blocks1182    await waitNewBlocks(blockSchedule + 1);11831184    const recipientBalanceAfter = (await api.query.system.account(recipient.address)).data.free.toBigInt();11851186    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(recipient.address));1187    expect(recipientBalanceAfter).to.be.equal(recipientBalanceBefore);1188  });1189}11901191export async function1192scheduleTransferExpectSuccess(1193  collectionId: number,1194  tokenId: number,1195  sender: IKeyringPair,1196  recipient: IKeyringPair,1197  value: number | bigint = 1,1198  blockSchedule: number,1199  scheduledId: string,1200) {1201  await usingApi(async (api: ApiPromise) => {1202    const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);12031204    await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId);12051206    expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(sender.address));1207  });1208}12091210export async function1211scheduleTransferFundsPeriodicExpectSuccess(1212  amount: bigint,1213  sender: IKeyringPair,1214  recipient: IKeyringPair,1215  blockSchedule: number,1216  scheduledId: string,1217  period: number,1218  repetitions: number,1219) {1220  await usingApi(async (api: ApiPromise) => {1221    const transferTx = api.tx.balances.transfer(recipient.address, amount);12221223    const balanceBefore = await getFreeBalance(recipient);1224    1225    await scheduleExpectSuccess(transferTx, sender, blockSchedule, scheduledId, period, repetitions);12261227    expect(await getFreeBalance(recipient)).to.be.equal(balanceBefore);1228  });1229}12301231export async function1232transfer(1233  api: ApiPromise,1234  collectionId: number,1235  tokenId: number,1236  sender: IKeyringPair,1237  recipient: IKeyringPair | CrossAccountId,1238  value: number | bigint,1239) : Promise<boolean> {1240  const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient), collectionId, tokenId, value);1241  const events = await executeTransaction(api, sender, transferTx);1242  return getGenericResult(events).success;1243}12441245export async function1246transferExpectSuccess(1247  collectionId: number,1248  tokenId: number,1249  sender: IKeyringPair,1250  recipient: IKeyringPair | CrossAccountId,1251  value: number | bigint = 1,1252  type = 'NFT',1253) {1254  await usingApi(async (api: ApiPromise) => {1255    const from = normalizeAccountId(sender);1256    const to = normalizeAccountId(recipient);12571258    let balanceBefore = 0n;1259    if (type === 'Fungible' || type === 'ReFungible') {1260      balanceBefore = await getBalance(api, collectionId, to, tokenId);1261    }12621263    const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient), collectionId, tokenId, value);1264    const events = await executeTransaction(api, sender, transferTx);1265    const result = getTransferResult(api, events);12661267    expect(result.collectionId).to.be.equal(collectionId);1268    expect(result.itemId).to.be.equal(tokenId);1269    expect(result.sender).to.be.deep.equal(normalizeAccountId(sender.address));1270    expect(result.recipient).to.be.deep.equal(to);1271    expect(result.value).to.be.equal(BigInt(value));12721273    if (type === 'NFT') {1274      expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);1275    }1276    if (type === 'Fungible' || type === 'ReFungible') {1277      const balanceAfter = await getBalance(api, collectionId, to, tokenId);1278      if (JSON.stringify(to) !== JSON.stringify(from)) {1279        expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));1280      } else {1281        expect(balanceAfter).to.be.equal(balanceBefore);1282      }1283    }1284  });1285}12861287export async function1288transferExpectFailure(1289  collectionId: number,1290  tokenId: number,1291  sender: IKeyringPair,1292  recipient: IKeyringPair | CrossAccountId,1293  value: number | bigint = 1,1294) {1295  await usingApi(async (api: ApiPromise) => {1296    const transferTx = api.tx.unique.transfer(normalizeAccountId(recipient), collectionId, tokenId, value);1297    const events = await expect(submitTransactionExpectFailAsync(sender, transferTx)).to.be.rejected;1298    const result = getGenericResult(events);1299    // if (events && Array.isArray(events)) {1300    //   const result = getCreateCollectionResult(events);1301    // tslint:disable-next-line:no-unused-expression1302    expect(result.success).to.be.false;1303    //}1304  });1305}13061307export async function1308approveExpectFail(1309  collectionId: number,1310  tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number | bigint = 1,1311) {1312  await usingApi(async (api: ApiPromise) => {1313    const approveUniqueTx = api.tx.unique.approve(normalizeAccountId(approved.address), collectionId, tokenId, amount);1314    const events = await expect(submitTransactionExpectFailAsync(owner, approveUniqueTx)).to.be.rejected;1315    const result = getCreateCollectionResult(events);1316    // tslint:disable-next-line:no-unused-expression1317    expect(result.success).to.be.false;1318  });1319}13201321export async function getBalance(1322  api: ApiPromise,1323  collectionId: number,1324  owner: string | CrossAccountId | IKeyringPair,1325  token: number,1326): Promise<bigint> {1327  return (await api.rpc.unique.balance(collectionId, normalizeAccountId(owner), token)).toBigInt();1328}1329export async function getTokenOwner(1330  api: ApiPromise,1331  collectionId: number,1332  token: number,1333): Promise<CrossAccountId> {1334  const owner = (await api.rpc.unique.tokenOwner(collectionId, token)).toJSON() as any;1335  if (owner == null) throw new Error('owner == null');1336  return normalizeAccountId(owner);1337}1338export async function getTopmostTokenOwner(1339  api: ApiPromise,1340  collectionId: number,1341  token: number,1342): Promise<CrossAccountId> {1343  const owner = (await api.rpc.unique.topmostTokenOwner(collectionId, token)).toJSON() as any;1344  if (owner == null) throw new Error('owner == null');1345  return normalizeAccountId(owner);1346}1347export async function getTokenChildren(1348  api: ApiPromise,1349  collectionId: number,1350  tokenId: number,1351): Promise<UpDataStructsTokenChild[]> {1352  return (await api.rpc.unique.tokenChildren(collectionId, tokenId)).toJSON() as any;1353}1354export async function isTokenExists(1355  api: ApiPromise,1356  collectionId: number,1357  token: number,1358): Promise<boolean> {1359  return (await api.rpc.unique.tokenExists(collectionId, token)).toJSON();1360}1361export async function getLastTokenId(1362  api: ApiPromise,1363  collectionId: number,1364): Promise<number> {1365  return (await api.rpc.unique.lastTokenId(collectionId)).toJSON();1366}1367export async function getAdminList(1368  api: ApiPromise,1369  collectionId: number,1370): Promise<string[]> {1371  return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any;1372}1373export async function getTokenProperties(1374  api: ApiPromise,1375  collectionId: number,1376  tokenId: number,1377  propertyKeys: string[],1378): Promise<UpDataStructsProperty[]> {1379  return (await api.rpc.unique.tokenProperties(collectionId, tokenId, propertyKeys)).toHuman() as any;1380}13811382export async function createFungibleItemExpectSuccess(1383  sender: IKeyringPair,1384  collectionId: number,1385  data: CreateFungibleData,1386  owner: CrossAccountId | string = sender.address,1387) {1388  return await usingApi(async (api) => {1389    const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), {Fungible: data});13901391    const events = await submitTransactionAsync(sender, tx);1392    const result = getCreateItemResult(events);13931394    expect(result.success).to.be.true;1395    return result.itemId;1396  });1397}13981399export async function createMultipleItemsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {1400  await usingApi(async (api) => {1401    const to = normalizeAccountId(owner);1402    const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);14031404    const events = await submitTransactionAsync(sender, tx);1405    expect(getGenericResult(events).success).to.be.true;1406  });1407}14081409export async function createMultipleItemsWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {1410  await usingApi(async (api) => {1411    const to = normalizeAccountId(owner);1412    const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);14131414    const events = await submitTransactionAsync(sender, tx);1415    const result = getCreateItemsResult(events);14161417    for (const res of result) {1418      expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1419    }1420  });1421}14221423export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {1424  await usingApi(async (api) => {1425    const tx = api.tx.unique.createMultipleItemsEx(collectionId, itemsData);14261427    const events = await submitTransactionAsync(sender, tx);1428    const result = getCreateItemsResult(events);14291430    for (const res of result) {1431      expect(await api.rpc.unique.tokenProperties(collectionId, res.itemId)).not.to.be.empty;1432    }1433  });1434}14351436export async function createItemWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, props:  Array<Property>, owner: CrossAccountId | string = sender.address) {1437  let newItemId = 0;1438  await usingApi(async (api) => {1439    const to = normalizeAccountId(owner);1440    const itemCountBefore = await getLastTokenId(api, collectionId);1441    const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);14421443    let tx;1444    if (createMode === 'Fungible') {1445      const createData = {fungible: {value: 10}};1446      tx = api.tx.unique.createItem(collectionId, to, createData as any);1447    } else if (createMode === 'ReFungible') {1448      const createData = {refungible: {pieces: 100}};1449      tx = api.tx.unique.createItem(collectionId, to, createData as any);1450    } else {1451      const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});1452      tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);1453    }14541455    const events = await submitTransactionAsync(sender, tx);1456    const result = getCreateItemResult(events);14571458    const itemCountAfter = await getLastTokenId(api, collectionId);1459    const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);14601461    if (createMode === 'NFT') {1462      expect(await api.rpc.unique.tokenProperties(collectionId, result.itemId)).not.to.be.empty;1463    }14641465    // What to expect1466    // tslint:disable-next-line:no-unused-expression1467    expect(result.success).to.be.true;1468    if (createMode === 'Fungible') {1469      expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);1470    } else {1471      expect(itemCountAfter).to.be.equal(itemCountBefore + 1);1472    }1473    expect(collectionId).to.be.equal(result.collectionId);1474    expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());1475    expect(to).to.be.deep.equal(result.recipient);1476    newItemId = result.itemId;1477  });1478  return newItemId;1479}14801481export async function createItemWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, props: Array<Property>, owner: CrossAccountId | string = sender.address) {1482  await usingApi(async (api) => {14831484    let tx;1485    if (createMode === 'NFT') {1486      const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}}) as UpDataStructsCreateItemData;1487      tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);1488    } else {1489      tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);1490    }149114921493    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1494    if(events.message && events.message.toString().indexOf('1002: Verification Error') > -1) return;1495    const result = getCreateItemResult(events);14961497    expect(result.success).to.be.false;1498  });1499}15001501export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1502  let newItemId = 0;1503  await usingApi(async (api) => {1504    const to = normalizeAccountId(owner);1505    const itemCountBefore = await getLastTokenId(api, collectionId);1506    const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);15071508    let tx;1509    if (createMode === 'Fungible') {1510      const createData = {fungible: {value: 10}};1511      tx = api.tx.unique.createItem(collectionId, to, createData as any);1512    } else if (createMode === 'ReFungible') {1513      const createData = {refungible: {pieces: 100}};1514      tx = api.tx.unique.createItem(collectionId, to, createData as any);1515    } else {1516      const createData = {nft: {}};1517      tx = api.tx.unique.createItem(collectionId, to, createData as any);1518    }15191520    const events = await executeTransaction(api, sender, tx);1521    const result = getCreateItemResult(events);15221523    const itemCountAfter = await getLastTokenId(api, collectionId);1524    const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);15251526    // What to expect1527    // tslint:disable-next-line:no-unused-expression1528    expect(result.success).to.be.true;1529    if (createMode === 'Fungible') {1530      expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);1531    } else {1532      expect(itemCountAfter).to.be.equal(itemCountBefore + 1);1533    }1534    expect(collectionId).to.be.equal(result.collectionId);1535    expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());1536    expect(to).to.be.deep.equal(result.recipient);1537    newItemId = result.itemId;1538  });1539  return newItemId;1540}15411542export async function createRefungibleToken(api: ApiPromise, sender: IKeyringPair, collectionId: number, amount: bigint, owner: CrossAccountId | IKeyringPair | string = sender.address) : Promise<CreateItemResult> {1543  const createData = {refungible: {pieces: amount}};1544  const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createData as any);15451546  const events = await submitTransactionAsync(sender, tx);1547  return  getCreateItemResult(events);1548}15491550export async function createItemExpectFailure(sender: IKeyringPair, collectionId: number, createMode: string, owner: CrossAccountId | string = sender.address) {1551  await usingApi(async (api) => {1552    const tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);15531554    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1555    const result = getCreateItemResult(events);15561557    expect(result.success).to.be.false;1558  });1559}15601561export async function setPublicAccessModeExpectSuccess(1562  sender: IKeyringPair, collectionId: number,1563  accessMode: 'Normal' | 'AllowList',1564) {1565  await usingApi(async (api) => {15661567    // Run the transaction1568    const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1569    const events = await submitTransactionAsync(sender, tx);1570    const result = getGenericResult(events);15711572    // Get the collection1573    const collection = await queryCollectionExpectSuccess(api, collectionId);15741575    // What to expect1576    // tslint:disable-next-line:no-unused-expression1577    expect(result.success).to.be.true;1578    expect(collection.permissions.access.toHuman()).to.be.equal(accessMode);1579  });1580}15811582export async function setPublicAccessModeExpectFail(1583  sender: IKeyringPair, collectionId: number,1584  accessMode: 'Normal' | 'AllowList',1585) {1586  await usingApi(async (api) => {15871588    // Run the transaction1589    const tx = api.tx.unique.setCollectionPermissions(collectionId, {access: accessMode});1590    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1591    const result = getGenericResult(events);15921593    // What to expect1594    // tslint:disable-next-line:no-unused-expression1595    expect(result.success).to.be.false;1596  });1597}15981599export async function enableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1600  await setPublicAccessModeExpectSuccess(sender, collectionId, 'AllowList');1601}16021603export async function enableAllowListExpectFail(sender: IKeyringPair, collectionId: number) {1604  await setPublicAccessModeExpectFail(sender, collectionId, 'AllowList');1605}16061607export async function disableAllowListExpectSuccess(sender: IKeyringPair, collectionId: number) {1608  await setPublicAccessModeExpectSuccess(sender, collectionId, 'Normal');1609}16101611export async function setMintPermissionExpectSuccess(sender: IKeyringPair, collectionId: number, enabled: boolean) {1612  await usingApi(async (api) => {16131614    // Run the transaction1615    const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1616    const events = await submitTransactionAsync(sender, tx);1617    const result = getGenericResult(events);1618    expect(result.success).to.be.true;16191620    // Get the collection1621    const collection = await queryCollectionExpectSuccess(api, collectionId);16221623    expect(collection.permissions.mintMode.toHuman()).to.be.equal(enabled);1624  });1625}16261627export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {1628  await setMintPermissionExpectSuccess(sender, collectionId, true);1629}16301631export async function setMintPermissionExpectFailure(sender: IKeyringPair, collectionId: number, enabled: boolean) {1632  await usingApi(async (api) => {1633    // Run the transaction1634    const tx = api.tx.unique.setCollectionPermissions(collectionId, {mintMode: enabled});1635    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1636    const result = getCreateCollectionResult(events);1637    // tslint:disable-next-line:no-unused-expression1638    expect(result.success).to.be.false;1639  });1640}16411642export async function setChainLimitsExpectFailure(sender: IKeyringPair, limits: IChainLimits) {1643  await usingApi(async (api) => {1644    // Run the transaction1645    const tx = api.tx.unique.setChainLimits(limits);1646    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1647    const result = getCreateCollectionResult(events);1648    // tslint:disable-next-line:no-unused-expression1649    expect(result.success).to.be.false;1650  });1651}16521653export async function isAllowlisted(api: ApiPromise, collectionId: number, address: string | CrossAccountId) {1654  return (await api.rpc.unique.allowed(collectionId, normalizeAccountId(address))).toJSON();1655}16561657export async function addToAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {1658  await usingApi(async (api) => {1659    expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.false;16601661    // Run the transaction1662    const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1663    const events = await submitTransactionAsync(sender, tx);1664    const result = getGenericResult(events);1665    expect(result.success).to.be.true;16661667    expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1668  });1669}16701671export async function addToAllowListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1672  await usingApi(async (api) => {16731674    expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;16751676    // Run the transaction1677    const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1678    const events = await submitTransactionAsync(sender, tx);1679    const result = getGenericResult(events);1680    expect(result.success).to.be.true;16811682    expect(await isAllowlisted(api, collectionId, normalizeAccountId(address))).to.be.true;1683  });1684}16851686export async function addToAllowListExpectFail(sender: IKeyringPair, collectionId: number, address: string | AccountId) {1687  await usingApi(async (api) => {16881689    // Run the transaction1690    const tx = api.tx.unique.addToAllowList(collectionId, normalizeAccountId(address));1691    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1692    const result = getGenericResult(events);16931694    // What to expect1695    // tslint:disable-next-line:no-unused-expression1696    expect(result.success).to.be.false;1697  });1698}16991700export async function removeFromAllowListExpectSuccess(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1701  await usingApi(async (api) => {1702    // Run the transaction1703    const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1704    const events = await submitTransactionAsync(sender, tx);1705    const result = getGenericResult(events);17061707    // What to expect1708    // tslint:disable-next-line:no-unused-expression1709    expect(result.success).to.be.true;1710  });1711}17121713export async function removeFromAllowListExpectFailure(sender: IKeyringPair, collectionId: number, address: CrossAccountId) {1714  await usingApi(async (api) => {1715    // Run the transaction1716    const tx = api.tx.unique.removeFromAllowList(collectionId, normalizeAccountId(address));1717    const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;1718    const result = getGenericResult(events);17191720    // What to expect1721    // tslint:disable-next-line:no-unused-expression1722    expect(result.success).to.be.false;1723  });1724}17251726export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)1727  : Promise<UpDataStructsRpcCollection | null> => {1728  return (await api.rpc.unique.collectionById(collectionId)).unwrapOr(null);1729};17301731export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {1732  // set global object - collectionsCount1733  return (await api.rpc.unique.collectionStats()).created.toNumber();1734};17351736export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<UpDataStructsRpcCollection> {1737  return (await api.rpc.unique.collectionById(collectionId)).unwrap();1738}17391740export async function waitNewBlocks(blocksCount = 1): Promise<void> {1741  await usingApi(async (api) => {1742    const promise = new Promise<void>(async (resolve) => {1743      const unsubscribe = await api.rpc.chain.subscribeNewHeads(() => {1744        if (blocksCount > 0) {1745          blocksCount--;1746        } else {1747          unsubscribe();1748          resolve();1749        }1750      });1751    });1752    return promise;1753  });1754}17551756export async function repartitionRFT(1757  api: ApiPromise,1758  collectionId: number,1759  sender: IKeyringPair,1760  tokenId: number,1761  amount: bigint,1762): Promise<boolean> {1763  const tx = api.tx.unique.repartition(collectionId, tokenId, amount);1764  const events = await submitTransactionAsync(sender, tx);1765  const result = getGenericResult(events);17661767  return result.success;1768}17691770export async function itApi(name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any, opts: { only?: boolean, skip?: boolean } = {}) {1771  let i: any = it;1772  if (opts.only) i = i.only;1773  else if (opts.skip) i = i.skip;1774  i(name, async () => {1775    await usingApi(async (api, privateKeyWrapper) => {1776      await cb({api, privateKeyWrapper});1777    });1778  });1779}17801781itApi.only = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {only: true});1782itApi.skip = (name: string, cb: (apis: { api: ApiPromise, privateKeyWrapper: (account: string) => IKeyringPair }) => any) => itApi(name, cb, {skip: true});
modifiedtests/src/util/playgrounds/index.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/index.ts
+++ b/tests/src/util/playgrounds/index.ts
@@ -4,7 +4,10 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import config from '../../config';
 import '../../interfaces/augment-api-events';
-import {DevUniqueHelper} from './unique.dev';
+import * as defs from '../../interfaces/definitions';
+import {ApiPromise, WsProvider} from '@polkadot/api';
+import { UniqueHelper } from './unique';
+
 
 class SilentLogger {
   log(msg: any, level: any): void { }
@@ -15,13 +18,53 @@
   };
 }
 
-export const usingPlaygrounds = async (code: (helper: DevUniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<void>) => {
+
+class DevUniqueHelper extends UniqueHelper {
+  async connect(wsEndpoint: string, listeners?: any): Promise<void> {
+    const wsProvider = new WsProvider(wsEndpoint);
+    this.api = new ApiPromise({
+      provider: wsProvider, 
+      signedExtensions: {
+        ContractHelpers: {
+          extrinsic: {},
+          payload: {},
+        },
+        FakeTransactionFinalizer: {
+          extrinsic: {},
+          payload: {},
+        },
+      },
+      rpc: {
+        unique: defs.unique.rpc,
+        rmrk: defs.rmrk.rpc,
+        eth: {
+          feeHistory: {
+            description: 'Dummy',
+            params: [],
+            type: 'u8',
+          },
+          maxPriorityFeePerGas: {
+            description: 'Dummy',
+            params: [],
+            type: 'u8',
+          },
+        },
+      },
+    });
+    await this.api.isReadyOrError;
+    this.network = await UniqueHelper.detectNetwork(this.api);
+  }
+}
+
+
+export const usingPlaygrounds = async <T = void> (code: (helper: UniqueHelper, privateKey: (seed: string) => IKeyringPair) => Promise<T>) => {
   // TODO: Remove, this is temporary: Filter unneeded API output
   // (Jaco promised it will be removed in the next version)
   const consoleErr = console.error;
   const consoleLog = console.log;
   const consoleWarn = console.warn;
-
+  let result: T = null as unknown as T;
+  
   const outFn = (printer: any) => (...args: any[]) => {
     for (const arg of args) {
       if (typeof arg !== 'string')
@@ -41,7 +84,7 @@
     await helper.connect(config.substrateUrl);
     const ss58Format = helper.chain.getChainProperties().ss58Format;
     const privateKey = (seed: string) => helper.util.fromSeed(seed, ss58Format);
-    await code(helper, privateKey);
+    result = await code(helper, privateKey);
   }
   finally {
     await helper.disconnect();
@@ -49,4 +92,5 @@
     console.log = consoleLog;
     console.warn = consoleWarn;
   }
+  return result as T;
 };
\ No newline at end of file