git.delta.rocks / unique-network / refs/commits / 9ecb329aa0c0

difftreelog

Merge remote-tracking branch 'origin/develop' into feature/NFTPAR-241

kpozdnikin2021-01-18parents: #f4eeb2e #07025d8.patch.diff
in: master
# Conflicts:
#	tests/package.json

16 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -1153,7 +1153,7 @@
             }
 
             // Reduce approval by transferred amount or remove if remaining approval drops to 0
-            if approval - value > 0 {
+            if approval.checked_sub(value).unwrap_or(0) > 0 {
                 <Allowances<T>>::insert(collection_id, (item_id, &from, &recipient), approval - value);
             }
             else {
modifiedpallets/nft/src/tests.rsdiffbeforeafterboth
--- a/pallets/nft/src/tests.rs
+++ b/pallets/nft/src/tests.rs
@@ -1,7 +1,7 @@
 // Tests to be written here
 use super::*;
 use crate::mock::*;
-use crate::{AccessMode, ApprovePermissions, CollectionMode,
+use crate::{AccessMode, CollectionMode,
     Ownership, ChainLimits, CreateItemData, CreateNftData, CreateFungibleData, CreateReFungibleData,
     CollectionId, TokenId, MAX_DECIMAL_POINTS};
 use frame_support::{assert_noop, assert_ok};
@@ -28,7 +28,7 @@
 }
 
 fn default_fungible_data () -> CreateFungibleData {
-    CreateFungibleData { }
+    CreateFungibleData { value: 5 }
 }
 
 fn default_re_fungible_data () -> CreateReFungibleData {
@@ -238,35 +238,35 @@
         let data = default_fungible_data();
         create_test_item(collection_id, &data.into());
 
-        assert_eq!(TemplateModule::fungible_item_id(collection_id, 1).owner, 1);
+        assert_eq!(TemplateModule::fungible_item_id(collection_id, 1).value, 5);
     });
 }
 
-#[test]
-fn create_multiple_fungible_items() {
-    new_test_ext().execute_with(|| {
-        default_limits();
+//#[test]
+// fn create_multiple_fungible_items() {
+//     new_test_ext().execute_with(|| {
+//         default_limits();
 
-        create_test_collection(&CollectionMode::Fungible(3), 1);
+//         create_test_collection(&CollectionMode::Fungible(3), 1);
 
-        let origin1 = Origin::signed(1);
+//         let origin1 = Origin::signed(1);
 
-        let items_data = vec![default_fungible_data(), default_fungible_data(), default_fungible_data()];
+//         let items_data = vec![default_fungible_data(), default_fungible_data(), default_fungible_data()];
 
-        assert_ok!(TemplateModule::create_multiple_items(
-            origin1.clone(),
-            1,
-            1,
-            items_data.clone().into_iter().map(|d| { d.into() }).collect()
-        ));
+//         assert_ok!(TemplateModule::create_multiple_items(
+//             origin1.clone(),
+//             1,
+//             1,
+//             items_data.clone().into_iter().map(|d| { d.into() }).collect()
+//         ));
         
-        for (index, _) in items_data.iter().enumerate() {
-            assert_eq!(TemplateModule::fungible_item_id(1, (index + 1) as TokenId).owner, 1);
-        }
-        assert_eq!(TemplateModule::balance_count(1, 1), 3000);
-        assert_eq!(TemplateModule::address_tokens(1, 1), [1, 2, 3]);
-    });
-}
+//         for (index, _) in items_data.iter().enumerate() {
+//             assert_eq!(TemplateModule::fungible_item_id(1, (index + 1) as TokenId).value, 5);
+//         }
+//         assert_eq!(TemplateModule::balance_count(1, 1), 3000);
+//         assert_eq!(TemplateModule::address_tokens(1, 1), [1, 2, 3]);
+//     });
+// }
 
 #[test]
 fn transfer_fungible_item() {
@@ -281,36 +281,26 @@
         let data = default_fungible_data();
         create_test_item(collection_id, &data.into());
 
-        assert_eq!(TemplateModule::fungible_item_id(1, 1).owner, 1);
-        assert_eq!(TemplateModule::balance_count(1, 1), 1000);
-        assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
+        assert_eq!(TemplateModule::fungible_item_id(1, 1).value, 5);
+        assert_eq!(TemplateModule::balance_count(1, 1), 5);
 
         // change owner scenario
-        assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 1000));
-        assert_eq!(TemplateModule::fungible_item_id(1, 1).owner, 2);
-        assert_eq!(TemplateModule::fungible_item_id(1, 1).value, 1000);
+        assert_ok!(TemplateModule::transfer(origin1.clone(), 2, 1, 1, 5));
+        assert_eq!(TemplateModule::fungible_item_id(1, 1).value, 0);
         assert_eq!(TemplateModule::balance_count(1, 1), 0);
-        assert_eq!(TemplateModule::balance_count(1, 2), 1000);
-        // assert_eq!(TemplateModule::address_tokens(1, 1), []);
-        assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
+        assert_eq!(TemplateModule::balance_count(1, 2), 5);
 
         // split item scenario
-        assert_ok!(TemplateModule::transfer(origin2.clone(), 3, 1, 1, 500));
-        assert_eq!(TemplateModule::fungible_item_id(1, 1).owner, 2);
-        assert_eq!(TemplateModule::fungible_item_id(1, 2).owner, 3);
-        assert_eq!(TemplateModule::balance_count(1, 2), 500);
-        assert_eq!(TemplateModule::balance_count(1, 3), 500);
-        assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
-        assert_eq!(TemplateModule::address_tokens(1, 3), [2]);
+        assert_ok!(TemplateModule::transfer(origin2.clone(), 3, 1, 1, 3));
+        assert_eq!(TemplateModule::balance_count(1, 2), 2);
+        assert_eq!(TemplateModule::balance_count(1, 3), 3);
 
         // split item and new owner has account scenario
-        assert_ok!(TemplateModule::transfer(origin2.clone(), 3, 1, 1, 200));
-        assert_eq!(TemplateModule::fungible_item_id(1, 1).value, 300);
-        assert_eq!(TemplateModule::fungible_item_id(1, 2).value, 700);
-        assert_eq!(TemplateModule::balance_count(1, 2), 300);
-        assert_eq!(TemplateModule::balance_count(1, 3), 700);
-        assert_eq!(TemplateModule::address_tokens(1, 2), [1]);
-        assert_eq!(TemplateModule::address_tokens(1, 3), [2]);
+        assert_ok!(TemplateModule::transfer(origin2.clone(), 3, 1, 1, 1));
+        assert_eq!(TemplateModule::fungible_item_id(1, 2).value, 1);
+        assert_eq!(TemplateModule::fungible_item_id(1, 3).value, 4);
+        assert_eq!(TemplateModule::balance_count(1, 2), 1);
+        assert_eq!(TemplateModule::balance_count(1, 3), 4);
     });
 }
 
@@ -451,14 +441,11 @@
             1), Error::<Test>::NoPermission);
 
         // do approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 5));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);
         assert_eq!(
-            TemplateModule::approved(1, (1, 1))[0],
-            ApprovePermissions {
-                approved: 2,
-                amount: 100000000
-            }
+            TemplateModule::approved(1, (1, 1, 2)),
+            5
         );
 
         assert_ok!(TemplateModule::transfer_from(
@@ -469,7 +456,7 @@
             1,
             1
         ));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 0);
+        assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 4);
     });
 }
 
@@ -505,17 +492,10 @@
         assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
 
         // do approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
-        assert_ok!(TemplateModule::approve(origin1.clone(), 3, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 2);
-        assert_eq!(
-            TemplateModule::approved(1, (1, 1))[0],
-            ApprovePermissions {
-                approved: 2,
-                amount: 100000000
-            }
-        );
+        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 5));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 3, 1, 1, 5));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 5);
 
         assert_ok!(TemplateModule::transfer_from(
             origin2.clone(),
@@ -525,7 +505,7 @@
             1,
             1
         ));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 0);
+        assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 4);
     });
 }
 
@@ -560,17 +540,10 @@
         assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
 
         // do approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
-        assert_ok!(TemplateModule::approve(origin1.clone(), 3, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 2);
-        assert_eq!(
-            TemplateModule::approved(1, (1, 1))[0],
-            ApprovePermissions {
-                approved: 2,
-                amount: 100000000
-            }
-        );
+        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 5));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 3, 1, 1, 1000));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 1000);
 
         assert_ok!(TemplateModule::transfer_from(
             origin2.clone(),
@@ -585,13 +558,9 @@
         assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
         assert_eq!(TemplateModule::address_tokens(1, 3), [1]);
 
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
         assert_eq!(
-            TemplateModule::approved(1, (1, 1))[0],
-            ApprovePermissions {
-                approved: 3,
-                amount: 100000000
-            }
+            TemplateModule::approved(1, (1, 1, 3)),
+            900
         );
     });
 }
@@ -609,8 +578,7 @@
         let origin1 = Origin::signed(1);
         let origin2 = Origin::signed(2);
 
-        assert_eq!(TemplateModule::balance_count(1, 1), 1000);
-        assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
+        assert_eq!(TemplateModule::balance_count(1, 1), 5);
 
         assert_ok!(TemplateModule::set_mint_permission(
             origin1.clone(),
@@ -627,16 +595,13 @@
         assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 3));
 
         // do approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
-        assert_ok!(TemplateModule::approve(origin1.clone(), 3, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 2);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 5));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 3, 1, 1, 5));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 5);
         assert_eq!(
-            TemplateModule::approved(1, (1, 1))[0],
-            ApprovePermissions {
-                approved: 2,
-                amount: 100000000
-            }
+            TemplateModule::approved(1, (1, 1, 2)),
+            5
         );
 
         assert_ok!(TemplateModule::transfer_from(
@@ -645,37 +610,23 @@
             3,
             1,
             1,
-            100
+            4
         ));
-        assert_eq!(TemplateModule::balance_count(1, 1), 900);
-        assert_eq!(TemplateModule::balance_count(1, 3), 100);
-        assert_eq!(TemplateModule::address_tokens(1, 1), [1]);
-        assert_eq!(TemplateModule::address_tokens(1, 3), [2]);
+        assert_eq!(TemplateModule::balance_count(1, 1), 1);
+        assert_eq!(TemplateModule::balance_count(1, 3), 4);
 
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
-        assert_eq!(
-            TemplateModule::approved(1, (1, 1))[0],
-            ApprovePermissions {
-                approved: 3,
-                amount: 100000000
-            }
-        );
+        assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 5);
+        assert_eq!(TemplateModule::approved(1, (1, 1, 3)), 1);
 
-        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1));
-        assert_ok!(TemplateModule::transfer_from(
+        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 5));
+        assert_noop!(TemplateModule::transfer_from(
             origin2.clone(),
             1,
             3,
             1,
             1,
-            900
-        ));
-        assert_eq!(TemplateModule::balance_count(1, 1), 0);
-        assert_eq!(TemplateModule::balance_count(1, 3), 1000);
-        // assert_eq!(TemplateModule::address_tokens(1, 1), []);
-        assert_eq!(TemplateModule::address_tokens(1, 3), [2]);
-
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 0);
+            4
+        ), Error::<Test>::TokenValueNotEnough);
     });
 }
 
@@ -725,9 +676,9 @@
         assert_eq!(TemplateModule::balance_count(1, 1), 1);
 
         // burn item
-        assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1));
+        assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 5));
         assert_noop!(
-            TemplateModule::burn_item(origin1.clone(), 1, 1),
+            TemplateModule::burn_item(origin1.clone(), 1, 1, 5),
             Error::<Test>::TokenNotFound
         );
 
@@ -749,12 +700,12 @@
         create_test_item(collection_id, &data.into());
 
         // check balance (collection with id = 1, user id = 1)
-        assert_eq!(TemplateModule::balance_count(1, 1), 1000);
+        assert_eq!(TemplateModule::balance_count(1, 1), 5);
 
         // burn item
-        assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1));
+        assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 5));
         assert_noop!(
-            TemplateModule::burn_item(origin1.clone(), 1, 1),
+            TemplateModule::burn_item(origin1.clone(), 1, 1, 5),
             Error::<Test>::TokenNotFound
         );
 
@@ -791,9 +742,9 @@
         assert_eq!(TemplateModule::balance_count(1, 1), 1000);
 
         // burn item
-        assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1));
+        assert_ok!(TemplateModule::burn_item(origin1.clone(), 1, 1, 1000));
         assert_noop!(
-            TemplateModule::burn_item(origin1.clone(), 1, 1),
+            TemplateModule::burn_item(origin1.clone(), 1, 1, 1000),
             Error::<Test>::TokenNotFound
         );
 
@@ -875,10 +826,10 @@
 
         // check balance (collection with id = 1, user id = 1)
         assert_eq!(TemplateModule::balance_count(nft_collection_id, 1), 1);
-        assert_eq!(TemplateModule::balance_count(fungible_collection_id, 1), 1000);
+        assert_eq!(TemplateModule::balance_count(fungible_collection_id, 1), 5);
         assert_eq!(TemplateModule::balance_count(re_fungible_collection_id, 1), 1000);
         assert_eq!(TemplateModule::nft_item_id(nft_collection_id, 1).owner, 1);
-        assert_eq!(TemplateModule::fungible_item_id(fungible_collection_id, 1).owner, 1);
+        assert_eq!(TemplateModule::fungible_item_id(fungible_collection_id, 1).value, 5);
         assert_eq!(TemplateModule::refungible_item_id(re_fungible_collection_id, 1).owner[0].owner, 1);
     });
 }
@@ -896,8 +847,8 @@
         let origin1 = Origin::signed(1);
         
         // approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1))[0].approved, 2);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1);
     });
 }
 
@@ -914,8 +865,8 @@
         create_test_item(collection_id, &data.into());
 
         // approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1))[0].approved, 2);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 2, 1, 1, 1));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 2)), 1);
 
         assert_ok!(TemplateModule::set_mint_permission(
             origin1.clone(),
@@ -1199,8 +1150,8 @@
         assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), 1, 2));
 
         // do approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1, 1));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);
 
         assert_ok!(TemplateModule::remove_from_white_list(
             origin1.clone(),
@@ -1263,8 +1214,8 @@
         assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
 
         // do approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1, 1));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 1);
 
         assert_ok!(TemplateModule::remove_from_white_list(
             origin1.clone(),
@@ -1298,7 +1249,7 @@
             AccessMode::WhiteList
         ));
         assert_noop!(
-            TemplateModule::burn_item(origin1.clone(), 1, 1),
+            TemplateModule::burn_item(origin1.clone(), 1, 1, 5),
             Error::<Test>::AddresNotInWhiteList
         );
     });
@@ -1321,7 +1272,7 @@
 
         // do approve
         assert_noop!(
-            TemplateModule::approve(origin1.clone(), 1, 1, 1),
+            TemplateModule::approve(origin1.clone(), 1, 1, 1, 5),
             Error::<Test>::AddresNotInWhiteList
         );
     });
@@ -1374,8 +1325,8 @@
         assert_ok!(TemplateModule::add_to_white_list(origin1.clone(), collection_id, 2));
 
         // do approve
-        assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1));
-        assert_eq!(TemplateModule::approved(1, (1, 1)).len(), 1);
+        assert_ok!(TemplateModule::approve(origin1.clone(), 1, 1, 1, 5));
+        assert_eq!(TemplateModule::approved(1, (1, 1, 1)), 5);
 
         assert_ok!(TemplateModule::transfer_from(
             origin1.clone(),
modifiedtests/package.jsondiffbeforeafterboth
--- a/tests/package.json
+++ b/tests/package.json
@@ -20,9 +20,13 @@
     "load": "mocha --timeout 9999999 -r ts-node/register ./**/*.load.ts",
     "testSetSchemaVersion": "mocha --timeout 9999999 -r ts-node/register ./**/setSchemaVersion.test.ts",
     "testSetCollectionLimits": "mocha --timeout 9999999 -r ts-node/register ./**/setCollectionLimits.test.ts",
+    "testRemoveCollectionAdmin": "mocha --timeout 9999999 -r ts-node/register ./**/removeCollectionAdmin.test.ts",
     "testConnection": "mocha --timeout 9999999 -r ts-node/register ./**/connection.test.ts",
     "testCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts",
-    "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts"
+    "testCreateMultipleItems": "mocha --timeout 9999999 -r ts-node/register ./**/createMultipleItems.test.ts",
+    "testApprove": "mocha --timeout 9999999 -r ts-node/register ./**/approve.test.ts",
+    "testTransferFrom": "mocha --timeout 9999999 -r ts-node/register ./**/transferFrom.test.ts",
+    "testCreateCollection": "mocha --timeout 9999999 -r ts-node/register ./**/createCollection.test.ts"
   },
   "author": "",
   "license": "Apache 2.0",
addedtests/src/approve.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/approve.test.ts
@@ -0,0 +1,140 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+import { ApiPromise } from '@polkadot/api';
+import BN from 'bn.js';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from './substrate/privateKey';
+import { default as usingApi } from './substrate/substrate-api';
+import {
+  approveExpectFail,
+  approveExpectSuccess,
+  createCollectionExpectSuccess,
+  createItemExpectSuccess,
+  destroyCollectionExpectSuccess,
+} from './util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {
+  it('Execute the extrinsic and check approvedList', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const nftCollectionId = await createCollectionExpectSuccess();
+      // nft
+      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
+      // reFungible
+      const reFungibleCollectionId =
+        await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+    });
+  });
+
+  it('Remove approval by using 0 amount', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const nftCollectionId = await createCollectionExpectSuccess();
+      // nft
+      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);
+      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 0);
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
+      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 0);
+      // reFungible
+      const reFungibleCollectionId =
+        await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 1);
+      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 0);
+    });
+  });
+});
+
+describe('Negative Integration Test approve(spender, collection_id, item_id, amount):', () => {
+  it('Approve for a collection that does not exist', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      // nft
+      const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
+      await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);
+      // fungible
+      const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
+      await approveExpectFail(fungibleCollectionCount + 1, 1, Alice, Bob);
+      // reFungible
+      const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
+      await approveExpectFail(reFungibleCollectionCount + 1, 1, Alice, Bob);
+    });
+  });
+
+  it('Approve for a collection that was destroyed', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      // nft
+      const nftCollectionId = await createCollectionExpectSuccess();
+      await destroyCollectionExpectSuccess(nftCollectionId);
+      await approveExpectFail(nftCollectionId, 1, Alice, Bob);
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      await destroyCollectionExpectSuccess(fungibleCollectionId);
+      await approveExpectFail(fungibleCollectionId, 1, Alice, Bob);
+      // reFungible
+      const reFungibleCollectionId =
+        await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      await destroyCollectionExpectSuccess(reFungibleCollectionId);
+      await approveExpectFail(reFungibleCollectionId, 1, Alice, Bob);
+    });
+  });
+
+  it('Approve transfer of a token that does not exist', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      // nft
+      const nftCollectionId = await createCollectionExpectSuccess();
+      await approveExpectFail(nftCollectionId, 2, Alice, Bob);
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      await approveExpectFail(fungibleCollectionId, 2, Alice, Bob);
+      // reFungible
+      const reFungibleCollectionId =
+        await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      await approveExpectFail(reFungibleCollectionId, 2, Alice, Bob);
+    });
+  });
+
+  it('Approve using the address that does not own the approved token', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const nftCollectionId = await createCollectionExpectSuccess();
+      // nft
+      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+      await approveExpectFail(nftCollectionId, newNftTokenId, Bob, Alice);
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+      await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice);
+      // reFungible
+      const reFungibleCollectionId =
+        await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+      await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice);
+    });
+  });
+});
addedtests/src/burnItem.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/burnItem.test.ts
@@ -0,0 +1,237 @@
+import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import { Keyring } from "@polkadot/api";
+import { IKeyringPair } from "@polkadot/types/types";
+import { 
+  createCollectionExpectSuccess, 
+  createItemExpectSuccess,
+  getGenericResult,
+  destroyCollectionExpectSuccess
+} from './util/helpers';
+import { nullPublicKey } from "./accounts";
+
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+
+describe('integration test: ext. burnItem():', () => {
+  before(async () => {
+    await usingApi(async (api) => {
+      const keyring = new Keyring({ type: 'sr25519' });
+      alice = keyring.addFromUri(`//Alice`);
+      bob = keyring.addFromUri(`//Bob`);
+    });
+  });
+
+  it('Burn item in NFT collection', async () => {
+    const createMode = 'NFT';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
+    const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
+
+    await usingApi(async (api) => {
+      const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
+      const events = await submitTransactionAsync(alice, tx);
+      const result = getGenericResult(events);
+  
+      // Get the item 
+      const item: any = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON();
+ 
+      // What to expect
+      expect(result.success).to.be.true;
+      expect(item).to.be.not.null;
+      expect(item.Owner).to.be.equal(nullPublicKey);
+    });
+  
+  });
+  it('Burn item in Fungible collection', async () => {
+    const createMode = 'Fungible';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
+    await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens
+    const tokenId = 0; // ignored
+
+    await usingApi(async (api) => {
+      // Destroy 1 of 10
+      const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
+      const events = await submitTransactionAsync(alice, tx);
+      const result = getGenericResult(events);
+  
+      // Get alice balance 
+      const balance: any = (await api.query.nft.fungibleItemList(collectionId, alice.address)).toJSON();
+ 
+      // What to expect
+      expect(result.success).to.be.true;
+      expect(balance).to.be.not.null;
+      expect(balance.Value).to.be.equal(9);
+    });
+
+  });
+  it('Burn item in ReFungible collection', async () => {
+    const createMode = 'ReFungible';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 2 }});
+    const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
+
+    await usingApi(async (api) => {
+      const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
+      const events = await submitTransactionAsync(alice, tx);
+      const result = getGenericResult(events);
+  
+      // Get alice balance 
+      const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
+      
+      // What to expect
+      expect(result.success).to.be.true;
+      expect(balance).to.be.not.null;
+      expect(balance.Owner.length).to.be.equal(0);
+    });
+
+  });
+
+  it('Burn owned portion of item in ReFungible collection', async () => {
+    const createMode = 'ReFungible';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 2 }});
+    const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
+
+    await usingApi(async (api) => {
+      // Transfer 1/100 of the token to Bob
+      const transfertx = api.tx.nft.transfer(bob.address, collectionId, tokenId, 1);
+      const events1 = await submitTransactionAsync(alice, transfertx);
+      const result1 = getGenericResult(events1);
+
+      // Get balances
+      const balanceBefore: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
+
+      // Bob burns his portion
+      const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
+      const events2 = await submitTransactionAsync(bob, tx);
+      const result2 = getGenericResult(events2);
+  
+      // Get balances 
+      const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
+      // console.log(balance);
+      
+      // What to expect before burning
+      expect(result1.success).to.be.true;
+      expect(balanceBefore).to.be.not.null;
+      expect(balanceBefore.Owner.length).to.be.equal(2);
+      expect(balanceBefore.Owner[0].Owner).to.be.equal(alice.address);
+      expect(balanceBefore.Owner[0].Fraction).to.be.equal(99);
+      expect(balanceBefore.Owner[1].Owner).to.be.equal(bob.address);
+      expect(balanceBefore.Owner[1].Fraction).to.be.equal(1);
+
+      // What to expect after burning
+      expect(result2.success).to.be.true;
+      expect(balance).to.be.not.null;
+      expect(balance.Owner.length).to.be.equal(1);
+      expect(balance.Owner[0].Fraction).to.be.equal(99);
+      expect(balance.Owner[0].Owner).to.be.equal(alice.address);
+    });
+
+  });
+
+});
+
+describe('Negative integration test: ext. burnItem():', () => {
+  before(async () => {
+    await usingApi(async (api) => {
+      const keyring = new Keyring({ type: 'sr25519' });
+      alice = keyring.addFromUri(`//Alice`);
+      bob = keyring.addFromUri(`//Bob`);
+    });
+  });
+
+  it('Burn a token in a destroyed collection', async () => {
+    const createMode = 'NFT';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+    const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
+    await destroyCollectionExpectSuccess(collectionId);
+
+    await usingApi(async (api) => {
+      const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
+      const badTransaction = async function () { 
+        await submitTransactionExpectFailAsync(alice, tx);
+      };
+      await expect(badTransaction()).to.be.rejected;
+    });
+
+  });
+
+  it('Burn a token that was never created', async () => {
+    const createMode = 'NFT';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+    const tokenId = 10;
+
+    await usingApi(async (api) => {
+      const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
+      const badTransaction = async function () { 
+        await submitTransactionExpectFailAsync(alice, tx);
+      };
+      await expect(badTransaction()).to.be.rejected;
+    });
+
+  });
+
+  it('Burn a token using the address that does not own it', async () => {
+    const createMode = 'NFT';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+    const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
+
+    await usingApi(async (api) => {
+      const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
+      const badTransaction = async function () { 
+        await submitTransactionExpectFailAsync(bob, tx);
+      };
+      await expect(badTransaction()).to.be.rejected;
+    });
+
+  });
+
+  it('Transfer a burned a token', async () => {
+    const createMode = 'NFT';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+    const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
+
+    await usingApi(async (api) => {
+
+      const burntx = api.tx.nft.burnItem(collectionId, tokenId, 0);
+      const events1 = await submitTransactionAsync(alice, burntx);
+      const result1 = getGenericResult(events1);
+      expect(result1.success).to.be.true;
+  
+      const tx = api.tx.nft.transfer(bob.address, collectionId, tokenId, 0);
+      const badTransaction = async function () { 
+        await submitTransactionExpectFailAsync(alice, tx);
+      };
+      await expect(badTransaction()).to.be.rejected;
+    });
+
+  });
+
+  it('Burn more than owned in Fungible collection', async () => {
+    const createMode = 'Fungible';
+    const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
+    // Helper creates 10 fungible tokens
+    await createItemExpectSuccess(alice, collectionId, createMode);
+    const tokenId = 0; // ignored
+
+    await usingApi(async (api) => {
+      // Destroy 11 of 10
+      const tx = api.tx.nft.burnItem(collectionId, tokenId, 11);
+      const badTransaction = async function () { 
+        await submitTransactionExpectFailAsync(alice, tx);
+      };
+      await expect(badTransaction()).to.be.rejected;
+      
+      // Get alice balance 
+      const balance: any = (await api.query.nft.fungibleItemList(collectionId, alice.address)).toJSON();
+ 
+      // What to expect
+      expect(balance).to.be.not.null;
+      expect(balance.Value).to.be.equal(10);
+    });
+
+  });
+
+});
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -89,7 +89,7 @@
   });
 
   it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {
-    const collectionId = await createCollectionExpectSuccess({mode: 'Fungible'});
+    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0 }});
     await setCollectionSponsorExpectSuccess(collectionId, bob.address);
     await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
 
@@ -115,7 +115,7 @@
   });
 
   it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {
-    const collectionId = await createCollectionExpectSuccess({mode: 'ReFungible'});
+    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0 }});
     await setCollectionSponsorExpectSuccess(collectionId, bob.address);
     await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
 
@@ -210,7 +210,7 @@
   });
 
   it('Fungible: Sponsoring is rate limited', async () => {
-    const collectionId = await createCollectionExpectSuccess({mode: 'Fungible'});
+    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0 }});
     await setCollectionSponsorExpectSuccess(collectionId, bob.address);
     await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
 
@@ -247,7 +247,7 @@
   });
 
   it('ReFungible: Sponsoring is rate limited', async () => {
-    const collectionId = await createCollectionExpectSuccess({mode: 'ReFungible'});
+    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0 }});
     await setCollectionSponsorExpectSuccess(collectionId, bob.address);
     await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
 
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -5,15 +5,15 @@
 
 import chai from 'chai';
 import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi } from "./substrate/substrate-api";
-import { createCollectionExpectSuccess, createCollectionExpectFailure, CollectionMode } from "./util/helpers";
+import { default as usingApi } from './substrate/substrate-api';
+import { createCollectionExpectFailure, createCollectionExpectSuccess } from './util/helpers';
 
 chai.use(chaiAsPromised);
 const expect = chai.expect;
 
 describe('integration test: ext. createCollection():', () => {
   it('Create new NFT collection', async () => {
-    await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: 'NFT'});
+    await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
   });
   it('Create new NFT collection whith collection_name of maximum length (64 bytes)', async () => {
     await createCollectionExpectSuccess({name: 'A'.repeat(64)});
@@ -25,34 +25,35 @@
     await createCollectionExpectSuccess({tokenPrefix: 'A'.repeat(16)});
   });
   it('Create new Fungible collection', async () => {
-    await createCollectionExpectSuccess({mode: 'Fungible'});
+    await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
   });
   it('Create new ReFungible collection', async () => {
-    await createCollectionExpectSuccess({mode: 'ReFungible'});
+    await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
   });
 });
 
 describe('(!negative test!) integration test: ext. createCollection():', () => {
   it('(!negative test!) create new NFT collection whith incorrect data (mode)', async () => {
     await usingApi(async (api) => {
-      const AcollectionCount = parseInt((await api.query.nft.collectionCount()).toString());
+      const AcollectionCount = parseInt((await api.query.nft.collectionCount()).toString(), 10);
 
-      const badTransaction = async function () { 
-        await createCollectionExpectSuccess({mode: 'BadMode' as CollectionMode});
+      const badTransaction = async () => {
+        await createCollectionExpectSuccess({mode: {type: 'Invalid'}});
       };
+      // tslint:disable-next-line:no-unused-expression
       expect(badTransaction()).to.be.rejected;
 
-      const BcollectionCount = parseInt((await api.query.nft.collectionCount()).toString());
+      const BcollectionCount = parseInt((await api.query.nft.collectionCount()).toString(), 10);
       expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Incorrect collection created.');
     });
   });
   it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {
-    await createCollectionExpectFailure({name: 'A'.repeat(65)});
+    await createCollectionExpectFailure({ name: 'A'.repeat(65), mode: {type: 'NFT'}});
   });
   it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {
-    await createCollectionExpectFailure({description: 'A'.repeat(257)});
+    await createCollectionExpectFailure({ description: 'A'.repeat(257), mode: { type: 'NFT' }});
   });
   it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {
-    await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17)});
+    await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});
   });
 });
modifiedtests/src/createItem.test.tsdiffbeforeafterboth
--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -18,17 +18,17 @@
 
   it('Create new item in NFT collection', async () => {
     const createMode = 'NFT';
-    const newCollectionID = await createCollectionExpectSuccess({mode: createMode});
+    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
     await createItemExpectSuccess(alice, newCollectionID, createMode);
   });
   it('Create new item in Fungible collection', async () => {
     const createMode = 'Fungible';
-    const newCollectionID = await createCollectionExpectSuccess({mode: createMode});
+    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
     await createItemExpectSuccess(alice, newCollectionID, createMode);
   });
   it('Create new item in ReFungible collection', async () => {
     const createMode = 'ReFungible';
-    const newCollectionID = await createCollectionExpectSuccess({mode: createMode});
+    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
     await createItemExpectSuccess(alice, newCollectionID, createMode);
   });
 });
modifiedtests/src/destroyCollection.test.tsdiffbeforeafterboth
--- a/tests/src/destroyCollection.test.ts
+++ b/tests/src/destroyCollection.test.ts
@@ -14,11 +14,11 @@
     await destroyCollectionExpectSuccess(collectionId);
   });
   it('Fungible collection can be destroyed', async () => {
-    const collectionId = await createCollectionExpectSuccess({ mode: 'Fungible' });
+    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
     await destroyCollectionExpectSuccess(collectionId);
   });
   it('ReFungible collection can be destroyed', async () => {
-    const collectionId = await createCollectionExpectSuccess({ mode: 'ReFungible' });
+    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
     await destroyCollectionExpectSuccess(collectionId);
   });
 });
addedtests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -0,0 +1,82 @@
+import { ApiPromise } from '@polkadot/api';
+import BN from 'bn.js';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from './substrate/privateKey';
+import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import {createCollectionExpectSuccess, destroyCollectionExpectSuccess} from './util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+describe('Integration Test removeCollectionAdmin(collection_id, account_id):', () => {
+  it('Remove collection admin.', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const collectionId = await createCollectionExpectSuccess();
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const collection: any = (await api.query.nft.collection(collectionId));
+      expect(collection.Owner.toString()).to.be.eq(Alice.address);
+      // first - add collection admin Bob
+      const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, addAdminTx);
+
+      const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
+      expect(adminListAfterAddAdmin).to.be.contains(Bob.address);
+
+      // then remove bob from admins of collection
+      const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, Bob.address);
+      await submitTransactionAsync(Alice, removeAdminTx);
+
+      const adminListAfterRemoveAdmin: any = (await api.query.nft.adminList(collectionId));
+      expect(adminListAfterRemoveAdmin).not.to.be.contains(Bob.address);
+    });
+  });
+});
+
+describe('Negative Integration Test removeCollectionAdmin(collection_id, account_id):', () => {
+  it('Can\'t remove collection admin from not existing collection', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      // tslint:disable-next-line: no-bitwise
+      const collectionId = (1 << 32) - 1;
+      const alice = privateKey('//Alice');
+      const bob = privateKey('//Bob');
+
+      const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, bob.address);
+      await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
+
+      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
+      await createCollectionExpectSuccess();
+    });
+  });
+
+  it('Can\'t remove collection admin from deleted collection', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      // tslint:disable-next-line: no-bitwise
+      const collectionId = await createCollectionExpectSuccess();
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+
+      await destroyCollectionExpectSuccess(collectionId);
+
+      const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, Bob.address);
+      await expect(submitTransactionExpectFailAsync(Alice, changeOwnerTx)).to.be.rejected;
+
+      // Verifying that nothing bad happened (network is live, new collections can be created, etc.)
+      await createCollectionExpectSuccess();
+    });
+  });
+
+  it('Remove admin from collection that has no admins', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const collectionId = await createCollectionExpectSuccess();
+
+      const adminListBeforeAddAdmin: any = (await api.query.nft.adminList(collectionId));
+      expect(adminListBeforeAddAdmin).to.have.lengthOf(0);
+
+      const tx = api.tx.nft.removeCollectionAdmin(collectionId, Alice.address);
+      await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
+    });
+  });
+});
modifiedtests/src/setCollectionLimits.test.tsdiffbeforeafterboth
--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -32,7 +32,7 @@
   });
   it('choose or create collection for testing', async () => {
     await usingApi(async () => {
-      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: 'NFT'});
+      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
     });
   });
 });
modifiedtests/src/setCollectionSponsor.test.tsdiffbeforeafterboth
--- a/tests/src/setCollectionSponsor.test.ts
+++ b/tests/src/setCollectionSponsor.test.ts
@@ -30,11 +30,11 @@
     await setCollectionSponsorExpectSuccess(collectionId, bob.address);
   });
   it('Set Fungible collection sponsor', async () => {
-    const collectionId = await createCollectionExpectSuccess({ mode: 'Fungible' });
+    const collectionId = await createCollectionExpectSuccess({ mode: {type: 'Fungible', decimalPoints: 0} });
     await setCollectionSponsorExpectSuccess(collectionId, bob.address);
   });
   it('Set ReFungible collection sponsor', async () => {
-    const collectionId = await createCollectionExpectSuccess({ mode: 'ReFungible' });
+    const collectionId = await createCollectionExpectSuccess({ mode: {type: 'ReFungible', decimalPoints: 0} });
     await setCollectionSponsorExpectSuccess(collectionId, bob.address);
   });
 
modifiedtests/src/setSchemaVersion.test.tsdiffbeforeafterboth
--- a/tests/src/setSchemaVersion.test.ts
+++ b/tests/src/setSchemaVersion.test.ts
@@ -35,7 +35,7 @@
   });
   it('choose or create collection for testing', async () => {
     await usingApi(async () => {
-      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: 'NFT'});
+      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
     });
   });
 });
@@ -93,12 +93,6 @@
       const nonExistedCollectionId = collectionCount + 1;
       tx = api.tx.nft.setSchemaVersion(nonExistedCollectionId, 'ImageURL');
       await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
-      /*try {
-        await submitTransactionAsync(alice, tx);
-      } catch (e) {
-        // tslint:disable-next-line:no-unused-expression
-        expect(e).to.be.exist;
-      }*/
     });
   });
 
@@ -119,13 +113,6 @@
       await destroyCollectionExpectSuccess(collectionIdForTesting);
       tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');
       await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
-      /*try {
-        tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');
-        await submitTransactionAsync(alice, tx);
-      } catch (e) {
-        // tslint:disable-next-line:no-unused-expression
-        expect(e).to.be.exist;
-      }*/
     });
   });
 });
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
--- a/tests/src/substrate/substrate-api.ts
+++ b/tests/src/substrate/substrate-api.ts
@@ -90,7 +90,6 @@
         res(rec);
         console.error = consoleError;
         console.log = consoleLog;
-        
       });
     };
     const reject = (errror: any) => {
@@ -104,6 +103,8 @@
       await transaction.signAndSend(sender, ({ events = [], status }) => {
         const transactionStatus = getTransactionStatus(events, status);
 
+        console.log('transactionStatus', transactionStatus, 'events', events);
+
         if (transactionStatus == TransactionStatus.Success) {
           resolve(events);
         } else if (transactionStatus == TransactionStatus.Fail) {
@@ -114,4 +115,4 @@
       reject(e);
     }
   });
-}
\ No newline at end of file
+}
addedtests/src/transferFrom.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/transferFrom.test.ts
@@ -0,0 +1,188 @@
+//
+// This file is subject to the terms and conditions defined in
+// file 'LICENSE', which is part of this source code package.
+//
+import { ApiPromise } from '@polkadot/api';
+import chai from 'chai';
+import chaiAsPromised from 'chai-as-promised';
+import privateKey from './substrate/privateKey';
+import { default as usingApi } from './substrate/substrate-api';
+import {
+  approveExpectFail,
+  approveExpectSuccess,
+  createCollectionExpectSuccess,
+  createItemExpectSuccess,
+  destroyCollectionExpectSuccess,
+  transferFromExpectFail,
+  transferFromExpectSuccess,
+} from './util/helpers';
+
+chai.use(chaiAsPromised);
+const expect = chai.expect;
+
+describe('Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {
+  it('Execute the extrinsic and check nftItemList - owner of token', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const Charlie = privateKey('//CHARLIE');
+      // nft
+      const nftCollectionId = await createCollectionExpectSuccess();
+      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
+
+      await transferFromExpectSuccess(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1, 'NFT');
+
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
+      await transferFromExpectSuccess(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1, 'Fungible');
+      // reFungible
+      const reFungibleCollectionId = await
+        createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+      await transferFromExpectSuccess(reFungibleCollectionId,
+        newReFungibleTokenId, Bob, Alice, Charlie, 1, 'ReFungible');
+    });
+  });
+});
+
+describe('Negative Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {
+  it('transferFrom for a collection that does not exist', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const Charlie = privateKey('//CHARLIE');
+      // nft
+      const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
+      await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);
+
+      await transferFromExpectFail(nftCollectionCount + 1, 1, Bob, Alice, Charlie, 1);
+
+      // fungible
+      const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
+      await approveExpectFail(fungibleCollectionCount + 1, 1, Alice, Bob);
+
+      await transferFromExpectFail(fungibleCollectionCount + 1, 1, Bob, Alice, Charlie, 1);
+      // reFungible
+      const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
+      await approveExpectFail(reFungibleCollectionCount + 1, 1, Alice, Bob);
+
+      await transferFromExpectFail(reFungibleCollectionCount + 1, 1, Bob, Alice, Charlie, 1);
+    });
+  });
+
+  /* it('transferFrom for a collection that was destroyed', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      this test copies approve negative test
+    });
+  }); */
+
+  /* it('transferFrom a token that does not exist', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      this test copies approve negative test
+    });
+  }); */
+
+  /* it('transferFrom a token that was deleted', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      this test copies approve negative test
+    });
+  }); */
+
+  it('transferFrom for not approved address', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const Charlie = privateKey('//CHARLIE');
+      // nft
+      const nftCollectionId = await createCollectionExpectSuccess();
+      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+
+      await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
+
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+      await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
+      // reFungible
+      const reFungibleCollectionId = await
+        createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+      await transferFromExpectFail(reFungibleCollectionId,
+        newReFungibleTokenId, Bob, Alice, Charlie, 1);
+    });
+  });
+
+  it('transferFrom incorrect token count', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const Charlie = privateKey('//CHARLIE');
+      // nft
+      const nftCollectionId = await createCollectionExpectSuccess();
+      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+      await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
+
+      await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 2);
+
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+      await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
+      await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 2);
+      // reFungible
+      const reFungibleCollectionId = await
+        createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+      await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+      await transferFromExpectFail(reFungibleCollectionId,
+        newReFungibleTokenId, Bob, Alice, Charlie, 2);
+    });
+  });
+
+  it('execute transferFrom from account that is not owner of collection', async () => {
+    await usingApi(async (api: ApiPromise) => {
+      const Alice = privateKey('//Alice');
+      const Bob = privateKey('//Bob');
+      const Charlie = privateKey('//CHARLIE');
+      const Dave = privateKey('//DAVE');
+      // nft
+      const nftCollectionId = await createCollectionExpectSuccess();
+      const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+      try {
+        await approveExpectFail(nftCollectionId, newNftTokenId, Dave, Bob);
+        await transferFromExpectFail(nftCollectionId, newNftTokenId, Dave, Alice, Charlie, 1);
+      } catch (e) {
+        // tslint:disable-next-line:no-unused-expression
+        expect(e).to.be.exist;
+      }
+
+      // await transferFromExpectFail(nftCollectionId, newNftTokenId, Dave, Alice, Charlie, 1);
+
+      // fungible
+      const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+      const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+      try {
+        await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Dave, Bob);
+        await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Dave, Alice, Charlie, 1);
+      } catch (e) {
+        // tslint:disable-next-line:no-unused-expression
+        expect(e).to.be.exist;
+      }
+      // reFungible
+      const reFungibleCollectionId = await
+        createCollectionExpectSuccess({mode: {type: 'ReFungible', decimalPoints: 0}});
+      const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+      try {
+        await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Dave, Bob);
+        await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Dave, Alice, Charlie, 1);
+      } catch (e) {
+        // tslint:disable-next-line:no-unused-expression
+        expect(e).to.be.exist;
+      }
+    });
+  });
+});
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
before · tests/src/util/helpers.ts
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import type { AccountId, EventRecord } from '@polkadot/types/interfaces';9import { ApiPromise, Keyring } from "@polkadot/api";10import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from "../substrate/substrate-api";11import privateKey from '../substrate/privateKey';12import { alicesPublicKey, nullPublicKey } from "../accounts";13import { strToUTF16, utf16ToStr, hexToStr } from './util';14import { IKeyringPair } from '@polkadot/types/types';15import { BigNumber } from 'bignumber.js';16import { Struct, Enum } from '@polkadot/types/codec';17import { u128 } from '@polkadot/types/primitive';18import { ICollectionInterface } from '../types';19import BN from "bn.js";2021chai.use(chaiAsPromised);22const expect = chai.expect;2324type GenericResult = {25  success: boolean,26};2728type CreateCollectionResult = {29  success: boolean,30  collectionId: number31};3233type CreateItemResult = {34  success: boolean,35  collectionId: number,36  itemId: number37};3839export function getGenericResult(events: EventRecord[]): GenericResult {40  let result: GenericResult = {41    success: false42  }43  events.forEach(({ phase, event: { data, method, section } }) => {44    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);45    if (method == 'ExtrinsicSuccess') {46      result.success = true;47    }48  });49  return result;50}5152export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {53  let success = false;54  let collectionId: number = 0;55  events.forEach(({ phase, event: { data, method, section } }) => {56    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);57    if (method == 'ExtrinsicSuccess') {58      success = true;59    } else if ((section == 'nft') && (method == 'Created')) {60      collectionId = parseInt(data[0].toString());61    }62  });63  let result: CreateCollectionResult = {64    success,65    collectionId66  }67  return result;68}6970export function getCreateItemResult(events: EventRecord[]): CreateItemResult {71  let success = false;72  let collectionId: number = 0;73  let itemId: number = 0;74  events.forEach(({ phase, event: { data, method, section } }) => {75    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);76    if (method == 'ExtrinsicSuccess') {77      success = true;78    } else if ((section == 'nft') && (method == 'ItemCreated')) {79      collectionId = parseInt(data[0].toString());80      itemId = parseInt(data[1].toString());81    }82  });83  let result: CreateItemResult = {84    success,85    collectionId,86    itemId87  }88  return result;89}9091export type CollectionMode = 'NFT' | 'Fungible' | 'ReFungible';92export type CreateCollectionParams = {93  mode: CollectionMode,94  name: string,95  description: string,96  tokenPrefix: string97};9899const defaultCreateCollectionParams: CreateCollectionParams = {100  name: 'name',101  description: 'description',102  mode: 'NFT',103  tokenPrefix: 'prefix'104}105106export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {107  const {name, description, mode, tokenPrefix } = {...defaultCreateCollectionParams, ...params};108109  let collectionId: number = 0;110  await usingApi(async (api) => {111    // Get number of collections before the transaction112    const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());113114    // Run the CreateCollection transaction115    const alicePrivateKey = privateKey('//Alice');116    const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), mode);117    const events = await submitTransactionAsync(alicePrivateKey, tx);118    const result = getCreateCollectionResult(events);119120    // Get number of collections after the transaction121    const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());122123    // Get the collection 124    const collection: any = (await api.query.nft.collection(result.collectionId)).toJSON();125126    // What to expect127    expect(result.success).to.be.true;128    expect(result.collectionId).to.be.equal(BcollectionCount);129    expect(collection).to.be.not.null;130    expect(BcollectionCount).to.be.equal(AcollectionCount+1, 'Error: NFT collection NOT created.');131    expect(collection.Owner).to.be.equal(alicesPublicKey);132    expect(utf16ToStr(collection.Name)).to.be.equal(name);133    expect(utf16ToStr(collection.Description)).to.be.equal(description);134    expect(hexToStr(collection.TokenPrefix)).to.be.equal(tokenPrefix);135136    collectionId = result.collectionId;137  });138139  return collectionId;140}141  142export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {143  const {name, description, mode, tokenPrefix } = {...defaultCreateCollectionParams, ...params};144145  await usingApi(async (api) => {146    // Get number of collections before the transaction147    const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());148149    // Run the CreateCollection transaction150    const alicePrivateKey = privateKey('//Alice');151    const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), mode);152    const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;153    const result = getCreateCollectionResult(events);154155    // Get number of collections after the transaction156    const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());157158    // What to expect159    expect(result.success).to.be.false;160    expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Collection with incorrect data created.');161  });162}163  164export async function findUnusedAddress(api: ApiPromise): Promise<IKeyringPair> {165  let bal = new BigNumber(0);166  let unused;167  do {168    const randomSeed = 'seed' +  Math.floor(Math.random() * Math.floor(10000));169    const keyring = new Keyring({ type: 'sr25519' });170    unused = keyring.addFromUri(`//${randomSeed}`);171    bal = new BigNumber((await api.query.system.account(unused.address)).data.free.toString());172  } while (bal.toFixed() != '0');173  return unused; 174}175176function getDestroyResult(events: EventRecord[]): boolean {177  let success: boolean = false;178  events.forEach(({ phase, event: { data, method, section } }) => {179    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);180    if (method == 'ExtrinsicSuccess') {181      success = true;182    }183  });184  return success;185}186187export async function destroyCollectionExpectFailure(collectionId: number, senderSeed: string = '//Alice') {188  await usingApi(async (api) => {189    // Run the DestroyCollection transaction190    const alicePrivateKey = privateKey(senderSeed);191    const tx = api.tx.nft.destroyCollection(collectionId);192    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;193  });194}195196export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {197  await usingApi(async (api) => {198    // Run the DestroyCollection transaction199    const alicePrivateKey = privateKey(senderSeed);200    const tx = api.tx.nft.destroyCollection(collectionId);201    const events = await submitTransactionAsync(alicePrivateKey, tx);202    const result = getDestroyResult(events);203204    // Get the collection 205    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();206207    // What to expect208    expect(result).to.be.true;209    expect(collection).to.be.not.null;210    expect(collection.Owner).to.be.equal(nullPublicKey);211  });212}213214export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {215  await usingApi(async (api) => {216217    // Run the transaction218    const alicePrivateKey = privateKey('//Alice');219    const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);220    const events = await submitTransactionAsync(alicePrivateKey, tx);221    const result = getGenericResult(events);222223    // Get the collection 224    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();225226    // What to expect227    expect(result.success).to.be.true;228    expect(collection.Sponsor.toString()).to.be.equal(sponsor.toString());229    expect(collection.SponsorConfirmed).to.be.false;230  });231}232233export async function removeCollectionSponsorExpectSuccess(collectionId: number) {234  await usingApi(async (api) => {235236    // Run the transaction237    const alicePrivateKey = privateKey('//Alice');238    const tx = api.tx.nft.removeCollectionSponsor(collectionId);239    const events = await submitTransactionAsync(alicePrivateKey, tx);240    const result = getGenericResult(events);241242    // Get the collection 243    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();244245    // What to expect246    expect(result.success).to.be.true;247    expect(collection.Sponsor).to.be.equal(nullPublicKey);248    expect(collection.SponsorConfirmed).to.be.false;249  });250}251252export async function removeCollectionSponsorExpectFailure(collectionId: number) {253  await usingApi(async (api) => {254255    // Run the transaction256    const alicePrivateKey = privateKey('//Alice');257    const tx = api.tx.nft.removeCollectionSponsor(collectionId);258    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;259  });260}261262export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed: string = '//Alice') {263  await usingApi(async (api) => {264265    // Run the transaction266    const alicePrivateKey = privateKey(senderSeed);267    const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);268    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;269  });270}271272export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {273  await usingApi(async (api) => {274275    // Run the transaction276    const sender = privateKey(senderSeed);277    const tx = api.tx.nft.confirmSponsorship(collectionId);278    const events = await submitTransactionAsync(sender, tx);279    const result = getGenericResult(events);280281    // Get the collection 282    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();283284    // What to expect285    expect(result.success).to.be.true;286    expect(collection.Sponsor).to.be.equal(sender.address);287    expect(collection.SponsorConfirmed).to.be.true;288  });289}290291export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed: string = '//Alice') {292  await usingApi(async (api) => {293294    // Run the transaction295    const sender = privateKey(senderSeed);296    const tx = api.tx.nft.confirmSponsorship(collectionId);297    await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;298  });299}300301export interface CreateFungibleData extends Struct {302  readonly value: u128;303};304305export interface CreateReFungibleData extends Struct {};306export interface CreateNftData extends Struct {};307308export interface CreateItemData extends Enum {309  NFT: CreateNftData,310  Fungible: CreateFungibleData,311  ReFungible: CreateReFungibleData312};313314export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: string = '') {315  let newItemId: number = 0;316  await usingApi(async (api) => {317    const AItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString());318    const Aitem: any = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON();    319    const AItemBalance = new BigNumber(Aitem.Value);320321    if (owner === '') owner = sender.address;322323    let tx;324    if (createMode == 'Fungible') {325      let createData = {fungible: {value: 10}};326      tx = api.tx.nft.createItem(collectionId, owner, createData);327    }328    else {329      tx = api.tx.nft.createItem(collectionId, owner, createMode);330    }331    const events = await submitTransactionAsync(sender, tx);332    const result = getCreateItemResult(events);333334    const BItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString());335    const Bitem: any = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON();    336    const BItemBalance = new BigNumber(Bitem.Value);337338    // What to expect339    expect(result.success).to.be.true;340    if (createMode == 'Fungible') {341      expect(BItemBalance.minus(AItemBalance).toNumber()).to.be.equal(10);342    }343    else {344      expect(BItemCount).to.be.equal(AItemCount+1);345    }346    expect(collectionId).to.be.equal(result.collectionId);347    expect(BItemCount).to.be.equal(result.itemId);348    newItemId = result.itemId;349  });350  return newItemId;351}352353export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {354  await usingApi(async (api) => {355356    // Run the transaction357    const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');358    const events = await submitTransactionAsync(sender, tx);359    const result = getGenericResult(events);360361    // Get the collection 362    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();363364    // What to expect365    expect(result.success).to.be.true;366    expect(collection.Access).to.be.equal('WhiteList');367  });368}369370export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {371  await usingApi(async (api) => {372373    // Run the transaction374    const tx = api.tx.nft.setMintPermission(collectionId, true);375    const events = await submitTransactionAsync(sender, tx);376    const result = getGenericResult(events);377378    // Get the collection 379    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();380381    // What to expect382    expect(result.success).to.be.true;383    expect(collection.MintMode).to.be.equal(true);384  });385}386387export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {388  await usingApi(async (api) => {389390    // Run the transaction391    const tx = api.tx.nft.addToWhiteList(collectionId, address);392    const events = await submitTransactionAsync(sender, tx);393    const result = getGenericResult(events);394395    // Get the collection 396    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();397398    // What to expect399    expect(result.success).to.be.true;400    expect(collection.MintMode).to.be.equal(true);401  });402}403404export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)405  : Promise<ICollectionInterface | null> => {406  return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;407};408409export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {410  // set global object - collectionsCount411  return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();412};
after · tests/src/util/helpers.ts
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { ApiPromise, Keyring } from '@polkadot/api';7import { Enum, Struct } from '@polkadot/types/codec';8import type { AccountId, EventRecord } from '@polkadot/types/interfaces';9import { u128 } from '@polkadot/types/primitive';10import { IKeyringPair } from '@polkadot/types/types';11import { BigNumber } from 'bignumber.js';12import BN from 'bn.js';13import chai from 'chai';14import chaiAsPromised from 'chai-as-promised';15import { alicesPublicKey, nullPublicKey } from '../accounts';16import privateKey from '../substrate/privateKey';17import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';18import { ICollectionInterface } from '../types';19import { hexToStr, strToUTF16, utf16ToStr } from './util';2021chai.use(chaiAsPromised);22const expect = chai.expect;2324type GenericResult = {25  success: boolean,26};2728interface CreateCollectionResult {29  success: boolean;30  collectionId: number;31}3233interface CreateItemResult {34  success: boolean;35  collectionId: number;36  itemId: number;37}3839interface IReFungibleOwner {40  Fraction: BN;41  Owner: number[];42}4344interface ITokenDataType {45  Owner: number[];46  ConstData: number[];47  VariableData: number[];48}4950interface IFungibleTokenDataType {51  Value: BN;52}5354interface IReFungibleTokenDataType {55  Owner: IReFungibleOwner[];56  ConstData: number[];57  VariableData: number[];58}5960export function getGenericResult(events: EventRecord[]): GenericResult {61  const result: GenericResult = {62    success: false,63  };64  events.forEach(({ phase, event: { data, method, section } }) => {65    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);66    if (method === 'ExtrinsicSuccess') {67      result.success = true;68    }69  });70  return result;71}7273export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {74  let success = false;75  let collectionId: number = 0;76  events.forEach(({ phase, event: { data, method, section } }) => {77    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);78    if (method == 'ExtrinsicSuccess') {79      success = true;80    } else if ((section == 'nft') && (method == 'Created')) {81      collectionId = parseInt(data[0].toString());82    }83  });84  const result: CreateCollectionResult = {85    success,86    collectionId,87  };88  return result;89}9091export function getCreateItemResult(events: EventRecord[]): CreateItemResult {92  let success = false;93  let collectionId: number = 0;94  let itemId: number = 0;95  events.forEach(({ phase, event: { data, method, section } }) => {96    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);97    if (method == 'ExtrinsicSuccess') {98      success = true;99    } else if ((section == 'nft') && (method == 'ItemCreated')) {100      collectionId = parseInt(data[0].toString());101      itemId = parseInt(data[1].toString());102    }103  });104  const result: CreateItemResult = {105    success,106    collectionId,107    itemId,108  };109  return result;110}111112interface Invalid {113  type: 'Invalid';114}115116interface Nft {117  type: 'NFT';118}119120interface Fungible {121  type: 'Fungible';122  decimalPoints: number;123}124125interface ReFungible {126  type: 'ReFungible';127  decimalPoints: number;128}129130interface Nft {131  type: 'NFT'132}133134interface Fungible {135  type: 'Fungible',136  decimalPoints: number137}138139interface ReFungible {140  type: 'ReFungible',141  decimalPoints: number142}143144type CollectionMode = Nft | Fungible | ReFungible | Invalid;145146export type CreateCollectionParams = {147  mode: CollectionMode,148  name: string,149  description: string,150  tokenPrefix: string,151};152153const defaultCreateCollectionParams: CreateCollectionParams = {154  description: 'description',155  mode: { type: 'NFT' },156  name: 'name',157  tokenPrefix: 'prefix',158}159160export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {161  const {name, description, mode, tokenPrefix } = {...defaultCreateCollectionParams, ...params};162163  let collectionId: number = 0;164  await usingApi(async (api) => {165    // Get number of collections before the transaction166    const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);167168    // Run the CreateCollection transaction169    const alicePrivateKey = privateKey('//Alice');170171    let modeprm = {};172    if (mode.type === 'NFT') {173      modeprm = {nft: null};174    } else if (mode.type === 'Fungible') {175      modeprm = {fungible: mode.decimalPoints};176    } else if (mode.type === 'ReFungible') {177      modeprm = {refungible: mode.decimalPoints};178    } else if (mode.type === 'Invalid') {179      modeprm = {invalid: null};180    }181182    const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);183    const events = await submitTransactionAsync(alicePrivateKey, tx);184    const result = getCreateCollectionResult(events);185186    // Get number of collections after the transaction187    const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);188189    // Get the collection190    const collection: any = (await api.query.nft.collection(result.collectionId)).toJSON();191192    // What to expect193    // tslint:disable-next-line:no-unused-expression194    expect(result.success).to.be.true;195    expect(result.collectionId).to.be.equal(BcollectionCount);196    // tslint:disable-next-line:no-unused-expression197    expect(collection).to.be.not.null;198    expect(BcollectionCount).to.be.equal(AcollectionCount + 1, 'Error: NFT collection NOT created.');199    expect(collection.Owner).to.be.equal(alicesPublicKey);200    expect(utf16ToStr(collection.Name)).to.be.equal(name);201    expect(utf16ToStr(collection.Description)).to.be.equal(description);202    expect(hexToStr(collection.TokenPrefix)).to.be.equal(tokenPrefix);203204    collectionId = result.collectionId;205  });206207  return collectionId;208}209210export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {211  const {name, description, mode, tokenPrefix } = {...defaultCreateCollectionParams, ...params};212213  let modeprm = {};214  if (mode.type === 'NFT') {215    modeprm = {nft: null};216  } else if (mode.type === 'Fungible') {217    modeprm = {fungible: mode.decimalPoints};218  } else if (mode.type === 'ReFungible') {219    modeprm = {refungible: mode.decimalPoints};220  } else if (mode.type === 'Invalid') {221    modeprm = {invalid: null};222  }223224  await usingApi(async (api) => {225    // Get number of collections before the transaction226    const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());227228    // Run the CreateCollection transaction229    const alicePrivateKey = privateKey('//Alice');230    const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);231    const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;232    const result = getCreateCollectionResult(events);233234    // Get number of collections after the transaction235    const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());236237    // What to expect238    // tslint:disable-next-line:no-unused-expression239    expect(result.success).to.be.false;240    expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Collection with incorrect data created.');241  });242}243244export async function findUnusedAddress(api: ApiPromise): Promise<IKeyringPair> {245  let bal = new BigNumber(0);246  let unused;247  do {248    const randomSeed = 'seed' +  Math.floor(Math.random() * Math.floor(10000));249    const keyring = new Keyring({ type: 'sr25519' });250    unused = keyring.addFromUri(`//${randomSeed}`);251    bal = new BigNumber((await api.query.system.account(unused.address)).data.free.toString());252  } while (bal.toFixed() != '0');253  return unused;254}255256function getDestroyResult(events: EventRecord[]): boolean {257  let success: boolean = false;258  events.forEach(({ phase, event: { data, method, section } }) => {259    // console.log(`    ${phase}: ${section}.${method}:: ${data}`);260    if (method == 'ExtrinsicSuccess') {261      success = true;262    }263  });264  return success;265}266267export async function destroyCollectionExpectFailure(collectionId: number, senderSeed: string = '//Alice') {268  await usingApi(async (api) => {269    // Run the DestroyCollection transaction270    const alicePrivateKey = privateKey(senderSeed);271    const tx = api.tx.nft.destroyCollection(collectionId);272    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;273  });274}275276export async function destroyCollectionExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {277  await usingApi(async (api) => {278    // Run the DestroyCollection transaction279    const alicePrivateKey = privateKey(senderSeed);280    const tx = api.tx.nft.destroyCollection(collectionId);281    const events = await submitTransactionAsync(alicePrivateKey, tx);282    const result = getDestroyResult(events);283284    // Get the collection285    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();286287    // What to expect288    expect(result).to.be.true;289    expect(collection).to.be.not.null;290    expect(collection.Owner).to.be.equal(nullPublicKey);291  });292}293294export async function setCollectionSponsorExpectSuccess(collectionId: number, sponsor: string) {295  await usingApi(async (api) => {296297    // Run the transaction298    const alicePrivateKey = privateKey('//Alice');299    const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);300    const events = await submitTransactionAsync(alicePrivateKey, tx);301    const result = getGenericResult(events);302303    // Get the collection304    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();305306    // What to expect307    expect(result.success).to.be.true;308    expect(collection.Sponsor.toString()).to.be.equal(sponsor.toString());309    expect(collection.SponsorConfirmed).to.be.false;310  });311}312313export async function removeCollectionSponsorExpectSuccess(collectionId: number) {314  await usingApi(async (api) => {315316    // Run the transaction317    const alicePrivateKey = privateKey('//Alice');318    const tx = api.tx.nft.removeCollectionSponsor(collectionId);319    const events = await submitTransactionAsync(alicePrivateKey, tx);320    const result = getGenericResult(events);321322    // Get the collection323    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();324325    // What to expect326    expect(result.success).to.be.true;327    expect(collection.Sponsor).to.be.equal(nullPublicKey);328    expect(collection.SponsorConfirmed).to.be.false;329  });330}331332export async function removeCollectionSponsorExpectFailure(collectionId: number) {333  await usingApi(async (api) => {334335    // Run the transaction336    const alicePrivateKey = privateKey('//Alice');337    const tx = api.tx.nft.removeCollectionSponsor(collectionId);338    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;339  });340}341342export async function setCollectionSponsorExpectFailure(collectionId: number, sponsor: string, senderSeed: string = '//Alice') {343  await usingApi(async (api) => {344345    // Run the transaction346    const alicePrivateKey = privateKey(senderSeed);347    const tx = api.tx.nft.setCollectionSponsor(collectionId, sponsor);348    await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;349  });350}351352export async function confirmSponsorshipExpectSuccess(collectionId: number, senderSeed: string = '//Alice') {353  await usingApi(async (api) => {354355    // Run the transaction356    const sender = privateKey(senderSeed);357    const tx = api.tx.nft.confirmSponsorship(collectionId);358    const events = await submitTransactionAsync(sender, tx);359    const result = getGenericResult(events);360361    // Get the collection362    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();363364    // What to expect365    expect(result.success).to.be.true;366    expect(collection.Sponsor).to.be.equal(sender.address);367    expect(collection.SponsorConfirmed).to.be.true;368  });369}370371export async function confirmSponsorshipExpectFailure(collectionId: number, senderSeed: string = '//Alice') {372  await usingApi(async (api) => {373374    // Run the transaction375    const sender = privateKey(senderSeed);376    const tx = api.tx.nft.confirmSponsorship(collectionId);377    await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;378  });379}380381export interface CreateFungibleData extends Struct {382  readonly value: u128;383}384385export interface CreateReFungibleData extends Struct {}386export interface CreateNftData extends Struct {}387388export interface CreateItemData extends Enum {389  NFT: CreateNftData;390  Fungible: CreateFungibleData;391  ReFungible: CreateReFungibleData;392}393394export async function395approveExpectSuccess(collectionId: number,396                     tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number = 1) {397  await usingApi(async (api: ApiPromise) => {398    const allowanceBefore =399      await api.query.nft.allowances(collectionId, [tokenId, owner.address, approved.address]) as unknown as BN;400    const approveNftTx = await api.tx.nft.approve(approved.address, collectionId, tokenId, amount);401    const events = await submitTransactionAsync(owner, approveNftTx);402    const result = getCreateItemResult(events);403    // tslint:disable-next-line:no-unused-expression404    expect(result.success).to.be.true;405    const allowanceAfter =406      await api.query.nft.allowances(collectionId, [tokenId, owner.address, approved.address]) as unknown as BN;407    expect(allowanceAfter.toNumber() - allowanceBefore.toNumber()).to.be.equal(amount);408  });409}410411export async function412transferFromExpectSuccess(collectionId: number,413                          tokenId: number,414                          accountApproved: IKeyringPair,415                          accountFrom: IKeyringPair,416                          accountTo: IKeyringPair,417                          value: number = 1,418                          type: string = 'NFT') {419  await usingApi(async (api: ApiPromise) => {420    let balanceBefore = new BN(0);421    if (type === 'Fungible') {422      balanceBefore = await api.query.nft.balance(collectionId, accountTo.address) as unknown as BN;423    }424    const transferFromTx = await api.tx.nft.transferFrom(425      accountFrom.address, accountTo.address, collectionId, tokenId, value);426    const events = await submitTransactionAsync(accountFrom, transferFromTx);427    const result = getCreateItemResult(events);428    // tslint:disable-next-line:no-unused-expression429    expect(result.success).to.be.true;430    if (type === 'NFT') {431      const nftItemData = await api.query.nft.nftItemList(collectionId, tokenId) as unknown as ITokenDataType;432      expect(nftItemData.Owner.toString()).to.be.equal(accountTo.address);433    }434    if (type === 'Fungible') {435      const balanceAfter = await api.query.nft.balance(collectionId, accountTo.address) as unknown as BN;436      expect(balanceAfter.sub(balanceBefore).toNumber()).to.be.equal(value);437    }438    if (type === 'ReFungible') {439      const nftItemData =440        await api.query.nft.reFungibleItemList(collectionId, tokenId) as unknown as IReFungibleTokenDataType;441      expect(nftItemData.Owner[0].Owner.toString()).to.be.equal(accountTo.address);442      expect(nftItemData.Owner[0].Fraction.toNumber()).to.be.equal(value);443    }444  });445}446447export async function448transferFromExpectFail(collectionId: number,449                       tokenId: number,450                       accountApproved: IKeyringPair,451                       accountFrom: IKeyringPair,452                       accountTo: IKeyringPair,453                       value: number = 1) {454  await usingApi(async (api: ApiPromise) => {455    const transferFromTx = await api.tx.nft.transferFrom(456      accountFrom.address, accountTo.address, collectionId, tokenId, value);457    const events = await expect(submitTransactionExpectFailAsync(accountApproved, transferFromTx)).to.be.rejected;458    const result = getCreateCollectionResult(events);459    // tslint:disable-next-line:no-unused-expression460    expect(result.success).to.be.false;461  });462}463464export async function465approveExpectFail(collectionId: number,466                  tokenId: number, owner: IKeyringPair, approved: IKeyringPair, amount: number = 1) {467  await usingApi(async (api: ApiPromise) => {468    const approveNftTx = await api.tx.nft.approve(approved.address, collectionId, tokenId, amount);469    const events = await expect(submitTransactionExpectFailAsync(owner, approveNftTx)).to.be.rejected;470    const result = getCreateCollectionResult(events);471    // tslint:disable-next-line:no-unused-expression472    expect(result.success).to.be.false;473  });474}475476export async function createItemExpectSuccess(sender: IKeyringPair, collectionId: number, createMode: string, owner: string = '') {477  let newItemId: number = 0;478  await usingApi(async (api) => {479    const AItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString(), 10);480    const Aitem: any = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON();481    const AItemBalance = new BigNumber(Aitem.Value);482483    if (owner === '') {484      owner = sender.address;485    }486487    let tx;488    if (createMode === 'Fungible') {489      const createData = {fungible: {value: 10}};490      tx = api.tx.nft.createItem(collectionId, owner, createData);491    } else {492      tx = api.tx.nft.createItem(collectionId, owner, createMode);493    }494    const events = await submitTransactionAsync(sender, tx);495    const result = getCreateItemResult(events);496497    const BItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString(), 10);498    const Bitem: any = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON();499    const BItemBalance = new BigNumber(Bitem.Value);500501    // What to expect502    // tslint:disable-next-line:no-unused-expression503    expect(result.success).to.be.true;504    if (createMode === 'Fungible') {505      expect(BItemBalance.minus(AItemBalance).toNumber()).to.be.equal(10);506    } else {507      expect(BItemCount).to.be.equal(AItemCount + 1);508    }509    expect(collectionId).to.be.equal(result.collectionId);510    expect(BItemCount).to.be.equal(result.itemId);511    newItemId = result.itemId;512  });513  return newItemId;514}515516export async function enableWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number) {517  await usingApi(async (api) => {518519    // Run the transaction520    const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');521    const events = await submitTransactionAsync(sender, tx);522    const result = getGenericResult(events);523524    // Get the collection525    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();526527    // What to expect528    expect(result.success).to.be.true;529    expect(collection.Access).to.be.equal('WhiteList');530  });531}532533export async function enablePublicMintingExpectSuccess(sender: IKeyringPair, collectionId: number) {534  await usingApi(async (api) => {535536    // Run the transaction537    const tx = api.tx.nft.setMintPermission(collectionId, true);538    const events = await submitTransactionAsync(sender, tx);539    const result = getGenericResult(events);540541    // Get the collection542    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();543544    // What to expect545    expect(result.success).to.be.true;546    expect(collection.MintMode).to.be.equal(true);547  });548}549550export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string) {551  await usingApi(async (api) => {552553    // Run the transaction554    const tx = api.tx.nft.addToWhiteList(collectionId, address);555    const events = await submitTransactionAsync(sender, tx);556    const result = getGenericResult(events);557558    // Get the collection559    const collection: any = (await api.query.nft.collection(collectionId)).toJSON();560561    // What to expect562    expect(result.success).to.be.true;563    expect(collection.MintMode).to.be.equal(true);564  });565}566567export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)568  : Promise<ICollectionInterface | null> => {569  return await api.query.nft.collection(collectionId) as unknown as ICollectionInterface;570};571572export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {573  // set global object - collectionsCount574  return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();575};