git.delta.rocks / unique-network / refs/commits / 71f425f89b51

difftreelog

fix(tests) repair createMultipleItem + ..Ex, remove features made obsolete by properties

Fahrrader2022-05-30parent: #2dd1788.patch.diff
in: master

9 files changed

modifiedtests/src/contracts.test.tsdiffbeforeafterboth
--- a/tests/src/contracts.test.ts
+++ b/tests/src/contracts.test.ts
@@ -139,9 +139,9 @@
       await addToAllowListExpectSuccess(alice, collectionId, bob.address);
 
       const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [
-        {Nft: {const_data: '0x010203'}},
-        {Nft: {const_data: '0x010204'}},
-        {Nft: {const_data: '0x010205'}},
+        {NFT: {/*const_data: '0x010203'*/}},
+        {NFT: {/*const_data: '0x010204'*/}},
+        {NFT: {/*const_data: '0x010205'*/}},
       ]);
       const events = await submitTransactionAsync(alice, transferTx);
       const result = getGenericResult(events);
@@ -153,15 +153,15 @@
       expect(tokensAfter).to.be.deep.equal([
         {
           Owner: bob.address,
-          ConstData: '0x010203',
+          //ConstData: '0x010203',
         },
         {
           Owner: bob.address,
-          ConstData: '0x010204',
+          //ConstData: '0x010204',
         },
         {
           Owner: bob.address,
-          ConstData: '0x010205',
+          //ConstData: '0x010205',
         },
       ]);
     });
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -63,17 +63,17 @@
       const bob = privateKey('//Bob');
       const tx = api.tx.unique.createCollectionEx({
         mode: {Fungible: 8},
-        access: 'AllowList',
+        //access: 'AllowList',
         name: [1],
         description: [2],
         tokenPrefix: '0x000000',
-        offchainSchema: '0x111111',
-        schemaVersion: 'Unique',
+        //offchainSchema: '0x111111',
+        //schemaVersion: 'Unique',
         pendingSponsor: bob.address,
         limits: {
           accountTokenOwnershipLimit: 3,
         },
-        constOnChainSchema: '0x333333',
+        //constOnChainSchema: '0x333333',
       });
       const events = await submitTransactionAsync(alice, tx);
       const result = getCreateCollectionResult(events);
@@ -81,15 +81,15 @@
       const collection = (await getDetailedCollectionInfo(api, result.collectionId))!;
       expect(collection.owner.toString()).to.equal(alice.address);
       expect(collection.mode.asFungible.toNumber()).to.equal(8);
-      expect(collection.access.isAllowList).to.be.true;
+      //expect(collection.access.isAllowList).to.be.true;
       expect(collection.name.map(v => v.toNumber())).to.deep.equal([1]);
       expect(collection.description.map(v => v.toNumber())).to.deep.equal([2]);
       expect(collection.tokenPrefix.toString()).to.equal('0x000000');
-      expect(collection.offchainSchema.toString()).to.equal('0x111111');
-      expect(collection.schemaVersion.isUnique).to.be.true;
+      //expect(collection.offchainSchema.toString()).to.equal('0x111111');
+      //expect(collection.schemaVersion.isUnique).to.be.true;
       expect(collection.sponsorship.asUnconfirmed.toString()).to.equal(bob.address);
       expect(collection.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.equal(3);
-      expect(collection.constOnChainSchema.toString()).to.equal('0x333333');
+      //expect(collection.constOnChainSchema.toString()).to.equal('0x333333');
     });
   });
 });
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -30,29 +30,34 @@
   getBalance,
   getTokenOwner,
   getLastTokenId,
-  getConstMetadata,
   getCreatedCollectionCount,
   createCollectionWithPropsExpectSuccess,
-  getCreateItemsResult,
   createMultipleItemsWithPropsExpectSuccess,
-  createMultipleItemsWithPropsExpectFailure,
+  getTokenProperties,
 } from './util/helpers';
 
 chai.use(chaiAsPromised);
 const expect = chai.expect;
 
 describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {
-  it('Create  0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {
+  it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionExpectSuccess();
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
+
       const alice = privateKey('//Alice');
-      const args = [{Nft: {const_data: '0x31'}},
-        {Nft: {const_data: '0x32'}},
-        {Nft: {const_data: '0x33'}}];
-      const createMultipleItemsTx = api.tx.unique
-        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+      await submitTransactionAsync(
+        alice, 
+        api.tx.unique.setPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}])
+      );
+      
+      const args = [
+        {NFT: {properties: [{key: 'data', value: '1'}]}},
+        {NFT: {properties: [{key: 'data', value: '2'}]}},
+        {NFT: {properties: [{key: 'data', value: '3'}]}}
+      ];
+      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
       await submitTransactionAsync(alice, createMultipleItemsTx);
       const itemsListIndexAfter = await getLastTokenId(api, collectionId);
       expect(itemsListIndexAfter).to.be.equal(3);
@@ -61,13 +66,13 @@
       expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));
       expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));
 
-      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
-      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
-      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
+      expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('1');
+      expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('2');
+      expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('3');
     });
   });
 
-  it('Create  0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {
+  it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
@@ -87,16 +92,16 @@
     });
   });
 
-  it('Create  0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {
+  it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       const alice = privateKey('//Alice');
       const args = [
-        {ReFungible: {const_data: [0x31], pieces: 1}},
-        {ReFungible: {const_data: [0x32], pieces: 1}},
-        {ReFungible: {const_data: [0x33], pieces: 1}},
+        {ReFungible: {pieces: 1}},
+        {ReFungible: {pieces: 2}},
+        {ReFungible: {pieces: 3}},
       ];
       const createMultipleItemsTx = api.tx.unique
         .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
@@ -105,12 +110,8 @@
       expect(itemsListIndexAfter).to.be.equal(3);
 
       expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);
-      expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(1n);
-      expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(1n);
-
-      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
-      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
-      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
+      expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(2n);
+      expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(3n);
     });
   });
 
@@ -123,8 +124,8 @@
         tokenLimit: 2,
       });
       const args = [
-        {NFT: {const_data: 'A'}},
-        {NFT: {const_data: 'B'}},
+        {NFT: {}},
+        {NFT: {}},
       ];
       const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
       const events = await submitTransactionAsync(alice, createMultipleItemsTx);
@@ -133,16 +134,17 @@
     });
   });
 
-  it('Create  0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {
+  it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       const alice = privateKey('//Alice');
-      const bob = privateKey('//Bob');
-      const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},
-        {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},
-        {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];
+      const args = [
+        {NFT: {properties: [{key: 'k', value: 'v1'}]}},
+        {NFT: {properties: [{key: 'k', value: 'v2'}]}},
+        {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+      ];
 
       await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
       const itemsListIndexAfter = await getLastTokenId(api, collectionId);
@@ -152,13 +154,13 @@
       expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));
       expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));
 
-      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
-      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
-      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
+      expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');
+      expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');
+      expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');
     });
   });
 
-  it('Create  0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {
+  it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
@@ -166,9 +168,11 @@
       const alice = privateKey('//Alice');
       const bob = privateKey('//Bob');
       await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
-      const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},
-        {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},
-        {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];
+      const args = [
+        {NFT: {properties: [{key: 'k', value: 'v1'}]}},
+        {NFT: {properties: [{key: 'k', value: 'v2'}]}},
+        {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+      ];
 
       await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
       const itemsListIndexAfter = await getLastTokenId(api, collectionId);
@@ -178,22 +182,25 @@
       expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));
       expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));
 
-      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
-      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
-      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
+      expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');
+      expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');
+      expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');
     });
   });
 
-  it('Create  0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {
+  it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
+      const collectionId = await createCollectionWithPropsExpectSuccess(
+        {propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]}
+      );
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       const alice = privateKey('//Alice');
-      const bob = privateKey('//Bob');
-      const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v1'}]}},
-        {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'v2'}]}},
-        {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'v3'}]}}];
+      const args = [
+        {NFT: {properties: [{key: 'k', value: 'v1'}]}},
+        {NFT: {properties: [{key: 'k', value: 'v2'}]}},
+        {NFT: {properties: [{key: 'k', value: 'v3'}]}}
+      ];
 
       await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);
       const itemsListIndexAfter = await getLastTokenId(api, collectionId);
@@ -203,15 +210,14 @@
       expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));
       expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));
 
-      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
-      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
-      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
+      expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');
+      expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');
+      expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');
     });
   });
 });
 
 describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {
-
   let alice: IKeyringPair;
   let bob: IKeyringPair;
 
@@ -222,15 +228,19 @@
     });
   });
 
-  it('Create  0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {
+  it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionExpectSuccess();
+      const collectionId = await createCollectionWithPropsExpectSuccess(
+        {propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]}
+      );
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
-      const args = [{Nft: {const_data: '0x31'}},
-        {Nft: {const_data: '0x32'}},
-        {Nft: {const_data: '0x33'}}];
+      const args = [
+        {NFT: {properties: [{key: 'data', value: 'v1'}]}},
+        {NFT: {properties: [{key: 'data', value: 'v2'}]}},
+        {NFT: {properties: [{key: 'data', value: 'v3'}]}}
+      ];
       const createMultipleItemsTx = api.tx.unique
         .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
       await submitTransactionAsync(bob, createMultipleItemsTx);
@@ -241,13 +251,13 @@
       expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));
       expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));
 
-      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
-      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
-      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
+      expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('v1');
+      expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('v2');
+      expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('v3');
     });
   });
 
-  it('Create  0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {
+  it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
@@ -267,16 +277,16 @@
     });
   });
 
-  it('Create  0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {
+  it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
       const args = [
-        {ReFungible: {const_data: [0x31], pieces: 1}},
-        {ReFungible: {const_data: [0x32], pieces: 1}},
-        {ReFungible: {const_data: [0x33], pieces: 1}},
+        {ReFungible: {pieces: 1}},
+        {ReFungible: {pieces: 2}},
+        {ReFungible: {pieces: 3}},
       ];
       const createMultipleItemsTx = api.tx.unique
         .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
@@ -285,18 +295,13 @@
       expect(itemsListIndexAfter).to.be.equal(3);
 
       expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);
-      expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(1n);
-      expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(1n);
-
-      expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
-      expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
-      expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
+      expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(2n);
+      expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(3n);
     });
   });
 });
 
 describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {
-
   let alice: IKeyringPair;
   let bob: IKeyringPair;
 
@@ -312,12 +317,11 @@
       const collectionId = await createCollectionExpectSuccess();
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
-      const args = [{Nft: {const_data: '0x31'}},
-        {Nft: {const_data: '0x32'}},
-        {Nft: {const_data: '0x33'}}];
-      const createMultipleItemsTx = api.tx.unique
-        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
-      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
+      const args = [{NFT: {}},
+        {NFT: {}},
+        {NFT: {}}];
+      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+      await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
     });
   });
 
@@ -331,9 +335,8 @@
         {Fungible: {value: 2}},
         {Fungible: {value: 3}},
       ];
-      const createMultipleItemsTx = api.tx.unique
-        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
-      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
+      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+      await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
     });
   });
 
@@ -343,37 +346,38 @@
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       const args = [
-        {ReFungible: {const_data: [0x31], pieces: 1}},
-        {ReFungible: {const_data: [0x32], pieces: 1}},
-        {ReFungible: {const_data: [0x33], pieces: 1}},
+        {ReFungible: {pieces: 1}},
+        {ReFungible: {pieces: 1}},
+        {ReFungible: {pieces: 1}},
       ];
-      const createMultipleItemsTx = api.tx.unique
-        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
-      await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
+      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+      await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);
     });
   });
 
   it('Create token in not existing collection', async () => {
     await usingApi(async (api: ApiPromise) => {
       const collectionId = await getCreatedCollectionCount(api) + 1;
-      const createMultipleItemsTx = api.tx.unique
-        .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);
-      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
+      const createMultipleItemsTx = api.tx.unique.createMultipleItems(
+        collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']
+      );
+      await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionNotFound/);
     });
   });
 
   it('Create NFT and Re-fungible tokens that has reached the maximum data limit', async () => {
     await usingApi(async (api: ApiPromise) => {
       // NFT
-      const collectionId = await createCollectionExpectSuccess();
+      const collectionId = await createCollectionWithPropsExpectSuccess({
+        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+      });
       const alice = privateKey('//Alice');
       const args = [
-        {NFT: {const_data: 'A'.repeat(2049)}},
-        {NFT: {const_data: 'B'.repeat(2049)}},
-        {NFT: {const_data: 'C'.repeat(2049)}},
+        {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},
+        {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},
+        {NFT: {properties: [{key: 'key', value: 'C'.repeat(32769)}]}},
       ];
-      const createMultipleItemsTx = api.tx.unique
-        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
       await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
 
       // ReFungible
@@ -395,68 +399,61 @@
       const collectionId = await createCollectionExpectSuccess();
       const createMultipleItemsTx = api.tx.unique
         .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);
-      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
-      // garbage collection :-D
+      await expect(
+        executeTransaction(api, alice, createMultipleItemsTx)
+      ).to.be.rejectedWith(
+        /nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/
+      );
+      // garbage collection :-D // lol
       await destroyCollectionExpectSuccess(collectionId);
     });
   });
 
   it('Create tokens with different data limits <> maximum data limit', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionExpectSuccess();
+      const collectionId = await createCollectionWithPropsExpectSuccess({
+        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+      });
       const args = [
-        {NFT: {const_data: 'A'}},
-        {NFT: {const_data: 'B'.repeat(2049)}},
+        {NFT: {properties: [{key: 'key', value: 'A'}]}},
+        {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},
       ];
-      const createMultipleItemsTx = await api.tx.unique
-        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
       await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
     });
   });
 
   it('Fails when minting tokens exceeds collectionLimits amount', async () => {
     await usingApi(async (api) => {
-
       const collectionId = await createCollectionExpectSuccess();
       await setCollectionLimitsExpectSuccess(alice, collectionId, {
         tokenLimit: 1,
       });
       const args = [
-        {NFT: {const_data: 'A'}},
-        {NFT: {const_data: 'B'}},
+        {NFT: {}},
+        {NFT: {}},
       ];
       const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
-      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
-    });
-  });
-
-  it('No editing rights', async () => {
-    await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
-        propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: true}}]});
-      const itemsListIndexBefore = await getLastTokenId(api, collectionId);
-      expect(itemsListIndexBefore).to.be.equal(0);
-      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
-      const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},
-        {Nft: {const_data: '0x32'}},
-        {Nft: {const_data: '0x33'}}];
-
-      await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);
+      await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);
     });
   });
 
   it('User doesnt have editing rights', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
-        propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});
+      const collectionId = await createCollectionWithPropsExpectSuccess({
+        propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]
+      });
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
-      const args = [{Nft: {const_data: '0x31', properties: [{key: 'key1', value: 'v2'}]}},
-        {Nft: {const_data: '0x32'}},
-        {Nft: {const_data: '0x33'}}];
+      const args = [
+        {NFT: {properties: [{key: 'key1', value: 'v2'}]}},
+        {NFT: {}},
+        {NFT: {}}
+      ];
 
-      await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);
+      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
+      await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);
     });
   });
 
@@ -466,18 +463,27 @@
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
       expect(itemsListIndexBefore).to.be.equal(0);
-      const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'v'}]}},
-        {Nft: {const_data: '0x32'}},
-        {Nft: {const_data: '0x33'}}];
+      const args = [{NFT: {properties: [{key: 'k', value: 'v'}]}},
+        {NFT: {}},
+        {NFT: {}}];
 
-      await createMultipleItemsWithPropsExpectFailure(bob, collectionId, args);
+      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
+      await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);
     });
   });
 
   it('Adding more than 64 prps', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],
-        propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});
+      const propPerms = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];
+      for (let i = 0; i < 65; i++) {
+        propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});
+      }
+
+      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+
+      const tx1 = api.tx.unique.setPropertyPermissions(collectionId, propPerms);
+      await expect(executeTransaction(api, alice, tx1)).to.be.rejectedWith(/common\.PropertyLimitReached/);
+
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
       await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
@@ -488,24 +494,31 @@
         prps.push({key: `key${i}`, value: `value${i}`});
       }
 
-      const args = [{Nft: {const_data: '0x31', properties: prps}},
-        {Nft: {const_data: '0x32', properties: prps}},
-        {Nft: {const_data: '0x33', properties: prps}}];
+      const args = [
+        {NFT: {properties: prps}},
+        {NFT: {properties: prps}},
+        {NFT: {properties: prps}}
+      ];
 
-      createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);
+      // there are no permissions, but will fail anyway because of too much weight for a block
+      const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);;
+      await expect(submitTransactionExpectFailAsync(alice, tx2)).to.be.rejected;
     });
   });
 
   it('Trying to add bigger property than allowed', async () => {
     await usingApi(async (api: ApiPromise) => {
-      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm:   [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});
+      const collectionId = await createCollectionWithPropsExpectSuccess({
+        propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]
+      });
       const itemsListIndexBefore = await getLastTokenId(api, collectionId);
       expect(itemsListIndexBefore).to.be.equal(0);
-      const args = [{Nft: {const_data: '0x31', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},
-        {Nft: {const_data: '0x32', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},
-        {Nft: {const_data: '0x33', properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];
+      const args = [{NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},
+        {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},
+        {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];
 
-      createMultipleItemsWithPropsExpectFailure(alice, collectionId, args);
+      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+      await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);
     });
   });
 });
modifiedtests/src/createMultipleItemsEx.test.tsdiffbeforeafterboth
before · tests/src/createMultipleItemsEx.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';2122describe('createMultipleItemsEx', () => {23  it('can initialize multiple NFT with different owners', async () => {24    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});25    const alice = privateKey('//Alice');26    const bob = privateKey('//Bob');27    const charlie = privateKey('//Charlie');28    await usingApi(async (api) => {29      const data = [30        {31          owner: {substrate: alice.address},32          constData: '0x0000',33        }, {34          owner: {substrate: bob.address},35          constData: '0x2222',36        }, {37          owner: {substrate: charlie.address},38          constData: '0x4444',39        },40      ];4142      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {43        NFT: data,44      }));45      const tokens = await api.query.nonfungible.tokenData.entries(collection);46      const json = tokens.map(([, token]) => token.toJSON());47      expect(json).to.be.deep.equal(data);48    });49  });5051  it('createMultipleItemsEx with property Admin', async () => {52    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});53    const alice = privateKey('//Alice');54    const bob = privateKey('//Bob');55    const charlie = privateKey('//Charlie');56    await usingApi(async (api) => {57      const data = [58        {59          owner: {substrate: alice.address},60          constData: '0x1111',61          properties: [{key: 'k', value: 'v1'}],62        }, {63          owner: {substrate: bob.address},64          constData: '0x2222',65          properties: [{key: 'k', value: 'v2'}],66        }, {67          owner: {substrate: charlie.address},68          constData: '0x4444',69          properties: [{key: 'k', value: 'v3'}],70        },71      ];7273      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {74        NFT: data,75      }));76      for (let i = 1; i < 4; i++) {77        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;78      }79    });80  });8182  it('createMultipleItemsEx with property AdminConst', async () => {83    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});84    const alice = privateKey('//Alice');85    const bob = privateKey('//Bob');86    const charlie = privateKey('//Charlie');87    await usingApi(async (api) => {88      const data = [89        {90          owner: {substrate: alice.address},91          constData: '0x0000',92          properties: [{key: 'k', value: 'v1'}],93        }, {94          owner: {substrate: bob.address},95          constData: '0x2222',96          properties: [{key: 'k', value: 'v2'}],97        }, {98          owner: {substrate: charlie.address},99          constData: '0x4444',100          properties: [{key: 'k', value: 'v3'}],101        },102      ];103104      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {105        NFT: data,106      }));107      for (let i = 1; i < 4; i++) {108        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;109      }110    });111  });112113  it('createMultipleItemsEx with property itemOwnerOrAdmin', async () => {114    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: true}}]});115    const alice = privateKey('//Alice');116    const bob = privateKey('//Bob');117    const charlie = privateKey('//Charlie');118    await usingApi(async (api) => {119      const data = [120        {121          owner: {substrate: alice.address},122          constData: '0x0000',123          properties: [{key: 'k', value: 'v1'}],124        }, {125          owner: {substrate: bob.address},126          constData: '0x2222',127          properties: [{key: 'k', value: 'v2'}],128        }, {129          owner: {substrate: charlie.address},130          constData: '0x4444',131          properties: [{key: 'k', value: 'v3'}],132        },133      ];134135      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {136        NFT: data,137      }));138      for (let i = 1; i < 4; i++) {139        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;140      }141    });142  });143144  it('No editing rights', async () => {145    const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],146      propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});147    const alice = privateKey('//Alice');148    const bob = privateKey('//Bob');149    const charlie = privateKey('//Charlie');150    await addCollectionAdminExpectSuccess(alice, collection, bob.address);151    await usingApi(async (api) => {152      const data = [153        {154          owner: {substrate: alice.address},155          properties: [{key: 'key1', value: 'v2'}],156        }, {157          owner: {substrate: alice.address},158          properties: [{key: 'key1', value: 'v2'}],159        }, {160          owner: {substrate: alice.address},161          properties: [{key: 'key1', value: 'v2'}],162        },163      ];164165      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});166      // await executeTransaction(api, alice, tx);167168      await submitTransactionExpectFailAsync(alice, tx);169    });170  });171172  it('User doesnt have editing rights', async () => {173    const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],174      propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});175    const alice = privateKey('//Alice');176    const bob = privateKey('//Bob');177    const charlie = privateKey('//Charlie');178    await addCollectionAdminExpectSuccess(alice, collection, bob.address);179    await usingApi(async (api) => {180      const data = [181        {182          owner: {substrate: alice.address},183          properties: [{key: 'key1', value: 'v2'}],184        }, {185          owner: {substrate: alice.address},186          properties: [{key: 'key1', value: 'v2'}],187        }, {188          owner: {substrate: alice.address},189          properties: [{key: 'key1', value: 'v2'}],190        },191      ];192193      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});194      // await executeTransaction(api, alice, tx);195196      await submitTransactionExpectFailAsync(alice, tx);197    });198  });199200  it('Adding property without access rights', async () => {201    const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});202    const alice = privateKey('//Alice');203    const bob = privateKey('//Bob');204    const charlie = privateKey('//Charlie');205    await addCollectionAdminExpectSuccess(alice, collection, bob.address);206    await usingApi(async (api) => {207      const data = [208        {209          owner: {substrate: alice.address},210          properties: [{key: 'key1', value: 'v2'}],211        }, {212          owner: {substrate: bob.address},213          properties: [{key: 'key1', value: 'v2'}],214        }, {215          owner: {substrate: charlie.address},216          properties: [{key: 'key1', value: 'v2'}],217        },218      ];219220      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});221222      await submitTransactionExpectFailAsync(alice, tx);223    });224  });225226  it('Adding more than 64 prps', async () => {227    const prps = [{key: 'key', value: 'v'}];228    const propPerm = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];229230    for (let i = 0; i < 65; i++) {231      prps.push({key: `key${i}`, value: `value${i}`});232      propPerm.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});233    }234235    const collection = await createCollectionWithPropsExpectSuccess({propPerm: propPerm});236    const alice = privateKey('//Alice');237    const bob = privateKey('//Bob');238    const charlie = privateKey('//Charlie');239    await addCollectionAdminExpectSuccess(alice, collection, bob.address);240    await usingApi(async (api) => {241      const data = [242        {243          owner: {substrate: alice.address},244          properties: prps,245        }, {246          owner: {substrate: alice.address},247          properties: prps,248        }, {249          owner: {substrate: alice.address},250          properties: prps,251        },252      ];253254      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});255256      await submitTransactionExpectFailAsync(alice, tx);257    });258  });259260  it('Trying to add bigger property than allowed', async () => {261    const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});262    const alice = privateKey('//Alice');263    const bob = privateKey('//Bob');264    const charlie = privateKey('//Charlie');265    await addCollectionAdminExpectSuccess(alice, collection, bob.address);266    await usingApi(async (api) => {267      const data = [268        {269          owner: {substrate: alice.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],270        }, {271          owner: {substrate: bob.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],272        }, {273          owner: {substrate: charlie.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],274        },275      ];276277      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});278279      await submitTransactionExpectFailAsync(alice, tx);280    });281  });282283  it('can initialize multiple NFT with different owners', async () => {284    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});285    const alice = privateKey('//Alice');286    const bob = privateKey('//Bob');287    const charlie = privateKey('//Charlie');288    await usingApi(async (api) => {289      const data = [290        {291          owner: {substrate: alice.address},292          constData: '0x0000',293        }, {294          owner: {substrate: bob.address},295          constData: '0x2222',296        }, {297          owner: {substrate: charlie.address},298          constData: '0x4444',299        },300      ];301302      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {303        NFT: data,304      }));305      const tokens = await api.query.nonfungible.tokenData.entries(collection);306      const json = tokens.map(([, token]) => token.toJSON());307      expect(json).to.be.deep.equal(data);308    });309  });310311  it('can initialize multiple NFT with different owners', async () => {312    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});313    const alice = privateKey('//Alice');314    const bob = privateKey('//Bob');315    const charlie = privateKey('//Charlie');316    await usingApi(async (api) => {317      const data = [318        {319          owner: {substrate: alice.address},320          constData: '0x0000',321        }, {322          owner: {substrate: bob.address},323          constData: '0x2222',324        }, {325          owner: {substrate: charlie.address},326          constData: '0x4444',327        },328      ];329330      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {331        NFT: data,332      }));333      const tokens = await api.query.nonfungible.tokenData.entries(collection);334      const json = tokens.map(([, token]) => token.toJSON());335      expect(json).to.be.deep.equal(data);336    });337  });338339  it('fails when trying to set multiple owners when creating multiple refungibles', async () => {340    const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});341    const alice = privateKey('//Alice');342    const bob = privateKey('//Bob');343344    await usingApi(async (api) => {345      // Polkadot requires map, and yet requires keys to be JSON encoded346      const users = new Map();347      users.set(JSON.stringify({substrate: alice.address}), 1);348      users.set(JSON.stringify({substrate: bob.address}), 1);349350      // TODO: better error message?351      await expect(executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {352        RefungibleMultipleItems: [353          {users},354          {users},355        ],356      }))).to.be.rejectedWith(/^refungible\.NotRefungibleDataUsedToMintFungibleCollectionToken$/);357    });358  });359});360'';
after · tests/src/createMultipleItemsEx.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import {expect} from 'chai';18import privateKey from './substrate/privateKey';19import usingApi, {executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';20import {createCollectionExpectSuccess, createCollectionWithPropsExpectSuccess, addCollectionAdminExpectSuccess, getCreateItemsResult} from './util/helpers';2122describe('createMultipleItemsEx', () => {23  it('can initialize multiple NFT with different owners', async () => {24    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});25    const alice = privateKey('//Alice');26    const bob = privateKey('//Bob');27    const charlie = privateKey('//Charlie');28    await usingApi(async (api) => {29      const data = [30        {31          owner: {substrate: alice.address},32          // constData: '0x0000',33        }, {34          owner: {substrate: bob.address},35          // constData: '0x2222',36        }, {37          owner: {substrate: charlie.address},38          // constData: '0x4444',39        },40      ];4142      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {43        NFT: data,44      }));45      const tokens = await api.query.nonfungible.tokenData.entries(collection);46      const json = tokens.map(([, token]) => token.toJSON());47      expect(json).to.be.deep.equal(data);48    });49  });5051  it('createMultipleItemsEx with property Admin', async () => {52    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});53    const alice = privateKey('//Alice');54    const bob = privateKey('//Bob');55    const charlie = privateKey('//Charlie');56    await usingApi(async (api) => {57      const data = [58        {59          owner: {substrate: alice.address},60          // constData: '0x1111',61          properties: [{key: 'k', value: 'v1'}],62        }, {63          owner: {substrate: bob.address},64          // constData: '0x2222',65          properties: [{key: 'k', value: 'v2'}],66        }, {67          owner: {substrate: charlie.address},68          // constData: '0x4444',69          properties: [{key: 'k', value: 'v3'}],70        },71      ];7273      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {74        NFT: data,75      }));76      for (let i = 1; i < 4; i++) {77        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;78      }79    });80  });8182  it('createMultipleItemsEx with property AdminConst', async () => {83    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});84    const alice = privateKey('//Alice');85    const bob = privateKey('//Bob');86    const charlie = privateKey('//Charlie');87    await usingApi(async (api) => {88      const data = [89        {90          owner: {substrate: alice.address},91          // constData: '0x0000',92          properties: [{key: 'k', value: 'v1'}],93        }, {94          owner: {substrate: bob.address},95          // constData: '0x2222',96          properties: [{key: 'k', value: 'v2'}],97        }, {98          owner: {substrate: charlie.address},99          // constData: '0x4444',100          properties: [{key: 'k', value: 'v3'}],101        },102      ];103104      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {105        NFT: data,106      }));107      for (let i = 1; i < 4; i++) {108        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;109      }110    });111  });112113  it('createMultipleItemsEx with property itemOwnerOrAdmin', async () => {114    const collection = await createCollectionWithPropsExpectSuccess({mode: {type: 'NFT'}, propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: true}}]});115    const alice = privateKey('//Alice');116    const bob = privateKey('//Bob');117    const charlie = privateKey('//Charlie');118    await usingApi(async (api) => {119      const data = [120        {121          owner: {substrate: alice.address},122          // constData: '0x0000',123          properties: [{key: 'k', value: 'v1'}],124        }, {125          owner: {substrate: bob.address},126          // constData: '0x2222',127          properties: [{key: 'k', value: 'v2'}],128        }, {129          owner: {substrate: charlie.address},130          // constData: '0x4444',131          properties: [{key: 'k', value: 'v3'}],132        },133      ];134135      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {136        NFT: data,137      }));138      for (let i = 1; i < 4; i++) {139        expect(await api.rpc.unique.tokenProperties(collection, i)).not.to.be.empty;140      }141    });142  });143144  it('No editing rights', async () => {145    const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],146      propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});147    const alice = privateKey('//Alice');148    const bob = privateKey('//Bob');149    const charlie = privateKey('//Charlie');150    await addCollectionAdminExpectSuccess(alice, collection, bob.address);151    await usingApi(async (api) => {152      const data = [153        {154          owner: {substrate: alice.address},155          properties: [{key: 'key1', value: 'v2'}],156        }, {157          owner: {substrate: bob.address},158          properties: [{key: 'key1', value: 'v2'}],159        }, {160          owner: {substrate: charlie.address},161          properties: [{key: 'key1', value: 'v2'}],162        },163      ];164165      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});166      // await executeTransaction(api, alice, tx);167168      //await submitTransactionExpectFailAsync(alice, tx);169      await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);170    });171  });172173  it('User doesnt have editing rights', async () => {174    const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}],175      propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});176    const alice = privateKey('//Alice');177    const bob = privateKey('//Bob');178    const charlie = privateKey('//Charlie');179    await addCollectionAdminExpectSuccess(alice, collection, bob.address);180    await usingApi(async (api) => {181      const data = [182        {183          owner: {substrate: alice.address},184          properties: [{key: 'key1', value: 'v2'}],185        }, {186          owner: {substrate: alice.address},187          properties: [{key: 'key1', value: 'v2'}],188        }, {189          owner: {substrate: alice.address},190          properties: [{key: 'key1', value: 'v2'}],191        },192      ];193194      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});195      // await executeTransaction(api, alice, tx);196197      //await submitTransactionExpectFailAsync(alice, tx);198      await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);199    });200  });201202  it('Adding property without access rights', async () => {203    const collection = await createCollectionWithPropsExpectSuccess({properties: [{key: 'key1', value: 'v'}]});204    const alice = privateKey('//Alice');205    const bob = privateKey('//Bob');206    const charlie = privateKey('//Charlie');207    await addCollectionAdminExpectSuccess(alice, collection, bob.address);208    await usingApi(async (api) => {209      const data = [210        {211          owner: {substrate: alice.address},212          properties: [{key: 'key1', value: 'v2'}],213        }, {214          owner: {substrate: bob.address},215          properties: [{key: 'key1', value: 'v2'}],216        }, {217          owner: {substrate: charlie.address},218          properties: [{key: 'key1', value: 'v2'}],219        },220      ];221222      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});223224      await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);225      //await submitTransactionExpectFailAsync(alice, tx);226    });227  });228229  it('Adding more than 64 properties', async () => {230    const propPerms = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];231232    for (let i = 0; i < 65; i++) {233      propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});234    }235236    const alice = privateKey('//Alice');237    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});238    await usingApi(async (api) => {239      await expect(240        executeTransaction(api, alice, api.tx.unique.setPropertyPermissions(collection, propPerms))241      ).to.be.rejectedWith(/common\.PropertyLimitReached/);242    });243  });244245  it('Trying to add bigger property than allowed', async () => {246    const collection = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});247    const alice = privateKey('//Alice');248    const bob = privateKey('//Bob');249    const charlie = privateKey('//Charlie');250    await addCollectionAdminExpectSuccess(alice, collection, bob.address);251    await usingApi(async (api) => {252      const data = [253        {254          owner: {substrate: alice.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],255        }, {256          owner: {substrate: bob.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],257        }, {258          owner: {substrate: charlie.address}, properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}],259        },260      ];261262      const tx = api.tx.unique.createMultipleItemsEx(collection, {NFT: data});263264      //await submitTransactionExpectFailAsync(alice, tx);265      await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);266    });267  });268269  it('can initialize multiple NFT with different owners', async () => {270    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});271    const alice = privateKey('//Alice');272    const bob = privateKey('//Bob');273    const charlie = privateKey('//Charlie');274    await usingApi(async (api) => {275      const data = [276        {277          owner: {substrate: alice.address},278          // constData: '0x0000',279        }, {280          owner: {substrate: bob.address},281          // constData: '0x2222',282        }, {283          owner: {substrate: charlie.address},284          // constData: '0x4444',285        },286      ];287288      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {289        NFT: data,290      }));291      const tokens = await api.query.nonfungible.tokenData.entries(collection);292      const json = tokens.map(([, token]) => token.toJSON());293      expect(json).to.be.deep.equal(data);294    });295  });296297  it('can initialize multiple NFT with different owners', async () => {298    const collection = await createCollectionExpectSuccess({mode: {type: 'NFT'}});299    const alice = privateKey('//Alice');300    const bob = privateKey('//Bob');301    const charlie = privateKey('//Charlie');302    await usingApi(async (api) => {303      const data = [304        {305          owner: {substrate: alice.address},306          // constData: '0x0000',307        }, {308          owner: {substrate: bob.address},309          // constData: '0x2222',310        }, {311          owner: {substrate: charlie.address},312          // constData: '0x4444',313        },314      ];315316      await executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {317        NFT: data,318      }));319      const tokens = await api.query.nonfungible.tokenData.entries(collection);320      const json = tokens.map(([, token]) => token.toJSON());321      expect(json).to.be.deep.equal(data);322    });323  });324325  it('fails when trying to set multiple owners when creating multiple refungibles', async () => {326    const collection = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});327    const alice = privateKey('//Alice');328    const bob = privateKey('//Bob');329330    await usingApi(async (api) => {331      // Polkadot requires map, and yet requires keys to be JSON encoded332      const users = new Map();333      users.set(JSON.stringify({substrate: alice.address}), 1);334      users.set(JSON.stringify({substrate: bob.address}), 1);335336      // TODO: better error message?337      await expect(executeTransaction(api, alice, api.tx.unique.createMultipleItemsEx(collection, {338        RefungibleMultipleItems: [339          {users},340          {users},341        ],342      }))).to.be.rejectedWith(/^refungible\.NotRefungibleDataUsedToMintFungibleCollectionToken$/);343    });344  });345});346'';
modifiedtests/src/nesting/properties.test.tsdiffbeforeafterboth
--- a/tests/src/nesting/properties.test.ts
+++ b/tests/src/nesting/properties.test.ts
@@ -792,7 +792,7 @@
         ]), 
       )).to.be.rejectedWith(/common\.NoSpaceForProperty/);
 
-      expect((await api.rpc.unique.tokenProperties(collection, token, ['a_holy_book', 'young years'])).toJSON()).to.be.empty;
+      expect((await api.rpc.unique.tokenProperties(collection, token, ['a_holy_book', 'young_years'])).toJSON()).to.be.empty;
       const propertiesMap = (await api.query.nonfungible.tokenProperties(collection, token)).toJSON();
       expect(propertiesMap.consumedSpace).to.be.equal(originalSpace);
     });
deletedtests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth
--- a/tests/src/setConstOnChainSchema.test.ts
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-import {Keyring} from '@polkadot/api';
-import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import {
-  createCollectionExpectSuccess,
-  destroyCollectionExpectSuccess,
-  addCollectionAdminExpectSuccess,
-  queryCollectionExpectSuccess,
-  getCreatedCollectionCount,
-} from './util/helpers';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
-
-let alice: IKeyringPair;
-let bob: IKeyringPair;
-let schema: any;
-let largeSchema: any;
-
-before(async () => {
-  await usingApi(async () => {
-    const keyring = new Keyring({type: 'sr25519'});
-    alice = keyring.addFromUri('//Alice');
-    bob = keyring.addFromUri('//Bob');
-    schema = '0x31';
-    largeSchema = new Array(1024 * 1024 + 10).fill(0xff);
-  });
-});
-describe('Integration Test ext. setConstOnChainSchema()', () => {
-
-  it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      const collection = await queryCollectionExpectSuccess(api, collectionId);
-      expect(collection.owner.toString()).to.be.eq(alice.address);
-      const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);
-      await submitTransactionAsync(alice, setSchema);
-    });
-  });
-
-  it('Collection admin can set the scheme', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      const collection = await queryCollectionExpectSuccess(api, collectionId);
-      expect(collection.owner.toString()).to.be.eq(alice.address);
-      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
-      const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);
-      await submitTransactionAsync(bob, setSchema);
-    });
-  });
-
-  it('Checking collection data using the ConstOnChainSchema parameter', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);
-      await submitTransactionAsync(alice, setSchema);
-      const collection = await queryCollectionExpectSuccess(api, collectionId);
-      expect(collection.constOnChainSchema.toString()).to.be.eq(schema);
-    });
-  });
-});
-
-describe('Negative Integration Test ext. setConstOnChainSchema()', () => {
-
-  it('Set a non-existent collection', async () => {
-    await usingApi(async (api) => {
-      // tslint:disable-next-line: radix
-      const collectionId = await getCreatedCollectionCount(api) + 1;
-      const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);
-      await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
-    });
-  });
-
-  it('Set a previously deleted collection', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      await destroyCollectionExpectSuccess(collectionId);
-      const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);
-      await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
-    });
-  });
-
-  it('Set invalid data in schema (size too large:> 1MB)', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, largeSchema);
-      await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
-    });
-  });
-
-  it('Execute method not on behalf of the collection owner', async () => {
-    await usingApi(async (api) => {
-      const collectionId = await createCollectionExpectSuccess();
-      const collection = await queryCollectionExpectSuccess(api, collectionId);
-      expect(collection.owner.toString()).to.be.eq(alice.address);
-      const setSchema = api.tx.unique.setConstOnChainSchema(collectionId, schema);
-      await expect(submitTransactionExpectFailAsync(bob, setSchema)).to.be.rejected;
-    });
-  });
-
-});
deletedtests/src/setOffchainSchema.test.tsdiffbeforeafterboth
--- a/tests/src/setOffchainSchema.test.ts
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import privateKey from './substrate/privateKey';
-import usingApi from './substrate/substrate-api';
-import {
-  createCollectionExpectSuccess,
-  destroyCollectionExpectSuccess,
-  findNotExistingCollection,
-  queryCollectionExpectSuccess,
-  setOffchainSchemaExpectFailure,
-  setOffchainSchemaExpectSuccess,
-  addCollectionAdminExpectSuccess,
-} from './util/helpers';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
-
-const DATA = [1, 2, 3, 4];
-
-describe('Integration Test setOffchainSchema', () => {
-  let alice: IKeyringPair;
-  let bob: IKeyringPair;
-
-  before(async () => {
-    await usingApi(async () => {
-      alice = privateKey('//Alice');
-      bob = privateKey('//Bob');
-    });
-  });
-
-  it('execute setOffchainSchema, verify data was set', async () => {
-    await usingApi(async api => {
-      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
-      await setOffchainSchemaExpectSuccess(alice, collectionId, DATA);
-      const collection = await queryCollectionExpectSuccess(api, collectionId);
-
-      expect('0x' + Buffer.from(collection.offchainSchema).toString('hex')).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
-    });
-  });
-
-  it('execute setOffchainSchema (collection admin), verify data was set', async () => {
-    await usingApi(async api => {
-      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
-      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
-      await setOffchainSchemaExpectSuccess(bob, collectionId, DATA);
-      const collection = await queryCollectionExpectSuccess(api, collectionId);
-
-      expect('0x' + Buffer.from(collection.offchainSchema).toString('hex')).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
-    });
-  });
-});
-
-describe('Negative Integration Test setOffchainSchema', () => {
-  let alice: IKeyringPair;
-  let bob: IKeyringPair;
-
-  let validCollectionId: number;
-
-  before(async () => {
-    await usingApi(async () => {
-      alice = privateKey('//Alice');
-      bob = privateKey('//Bob');
-
-      validCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
-    });
-  });
-
-  it('fails on not existing collection id', async () => {
-    const nonExistingCollectionId = await usingApi(findNotExistingCollection);
-
-    await setOffchainSchemaExpectFailure(alice, nonExistingCollectionId, DATA);
-  });
-
-  it('fails on destroyed collection id', async () => {
-    const destroyedCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
-    await destroyCollectionExpectSuccess(destroyedCollectionId);
-
-    await setOffchainSchemaExpectFailure(alice, destroyedCollectionId, DATA);
-  });
-
-  it('fails on too long data', async () => {
-    const tooLongData = new Array(8 * 1024 + 10).fill(0xff);
-
-    await setOffchainSchemaExpectFailure(alice, validCollectionId, tooLongData);
-  });
-
-  it('fails on execution by non-owner', async () => {
-    await setOffchainSchemaExpectFailure(bob, validCollectionId, DATA);
-  });
-});
deletedtests/src/setSchemaVersion.test.tsdiffbeforeafterboth
--- a/tests/src/setSchemaVersion.test.ts
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
-// This file is part of Unique Network.
-
-// Unique Network is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Unique Network is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-
-// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
-import {ApiPromise, Keyring} from '@polkadot/api';
-import {IKeyringPair} from '@polkadot/types/types';
-import chai from 'chai';
-import chaiAsPromised from 'chai-as-promised';
-import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import {
-  createCollectionExpectSuccess,
-  destroyCollectionExpectSuccess,
-  getCreatedCollectionCount,
-  getCreateItemResult,
-  getDetailedCollectionInfo,
-  addCollectionAdminExpectSuccess,
-} from './util/helpers';
-
-chai.use(chaiAsPromised);
-const expect = chai.expect;
-
-let alice: IKeyringPair;
-let bob: IKeyringPair;
-let charlie: IKeyringPair;
-
-/*
-1. We create collection.
-2. Save just created collection id.
-3. Use this id for setSchemaVersion.
-*/
-describe('setSchemaVersion positive', () => {
-  let tx;
-  before(async () => {
-    await usingApi(async () => {
-      const keyring = new Keyring({type: 'sr25519'});
-      alice = keyring.addFromUri('//Alice');
-    });
-  });
-  it('execute setSchemaVersion with image url and unique ', async () => {
-    await usingApi(async (api: ApiPromise) => {
-      const collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
-      tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'Unique');
-      const events = await submitTransactionAsync(alice, tx);
-      const result = getCreateItemResult(events);
-      const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);
-      // tslint:disable-next-line:no-unused-expression
-      expect(result.success).to.be.true;
-      // tslint:disable-next-line:no-unused-expression
-      expect(collectionInfo).to.be.exist;
-      // tslint:disable-next-line:no-unused-expression
-      expect(collectionInfo ? collectionInfo.schemaVersion.toString() : '').to.be.equal('Unique');
-    });
-  });
-});
-
-describe('Collection admin setSchemaVersion positive', () => {
-  let tx;
-  let collectionIdForTesting: any;
-
-  before(async () => {
-    await usingApi(async () => {
-      const keyring = new Keyring({type: 'sr25519'});
-      alice = keyring.addFromUri('//Alice');
-      bob = keyring.addFromUri('//Bob');
-      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
-      await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob.address);
-    });
-  });
-  it('execute setSchemaVersion with image url and unique ', async () => {
-    await usingApi(async (api: ApiPromise) => {
-      tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'Unique');
-      const events = await submitTransactionAsync(bob, tx);
-      const result = getCreateItemResult(events);
-      const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);
-      // tslint:disable-next-line:no-unused-expression
-      expect(result.success).to.be.true;
-      // tslint:disable-next-line:no-unused-expression
-      expect(collectionInfo).to.be.exist;
-      // tslint:disable-next-line:no-unused-expression
-      expect(collectionInfo ? collectionInfo.schemaVersion.toString() : '').to.be.equal('Unique');
-    });
-  });
-
-  it('validate schema version with just entered data', async () => {
-    await usingApi(async (api: ApiPromise) => {
-      tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'ImageURL');
-      const events = await submitTransactionAsync(bob, tx);
-      const result = getCreateItemResult(events);
-      const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);
-      // tslint:disable-next-line:no-unused-expression
-      expect(result.success).to.be.true;
-      // tslint:disable-next-line:no-unused-expression
-      expect(collectionInfo).to.be.exist;
-      // tslint:disable-next-line:no-unused-expression
-      expect(collectionInfo ? collectionInfo.schemaVersion.toString() : '').to.be.equal('ImageURL');
-    });
-  });
-});
-
-describe('setSchemaVersion negative', () => {
-  let tx;
-  let collectionIdForTesting: any;
-  before(async () => {
-    await usingApi(async () => {
-      const keyring = new Keyring({type: 'sr25519'});
-      alice = keyring.addFromUri('//Alice');
-      charlie = keyring.addFromUri('//Charlie');
-      collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
-    });
-  });
-  it('execute setSchemaVersion for not exists collection', async () => {
-    await usingApi(async (api: ApiPromise) => {
-      const collectionCount = await getCreatedCollectionCount(api);
-      const nonExistedCollectionId = collectionCount + 1;
-      tx = api.tx.unique.setSchemaVersion(nonExistedCollectionId, 'ImageURL');
-      await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
-    });
-  });
-  it('execute setSchemaVersion for deleted collection', async () => {
-    await usingApi(async (api: ApiPromise) => {
-      await destroyCollectionExpectSuccess(collectionIdForTesting);
-      tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'ImageURL');
-      await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
-    });
-  });
-  it('Regular user can`t execute setSchemaVersion with image url and unique ', async () => {
-    await usingApi(async (api: ApiPromise) => {
-      tx = api.tx.unique.setSchemaVersion(collectionIdForTesting, 'Unique');
-      await expect(submitTransactionAsync(charlie, tx)).to.be.rejected;
-    });
-  });
-});
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -27,7 +27,7 @@
 import privateKey from '../substrate/privateKey';
 import {default as usingApi, executeTransaction, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';
 import {hexToStr, strToUTF16, utf16ToStr} from './util';
-import {UpDataStructsRpcCollection, UpDataStructsCreateItemData} from '@polkadot/types/lookup';
+import {UpDataStructsRpcCollection, UpDataStructsCreateItemData, UpDataStructsProperty} from '@polkadot/types/lookup';
 
 chai.use(chaiAsPromised);
 const expect = chai.expect;
@@ -141,7 +141,6 @@
 
 export interface IReFungibleTokenDataType {
   owner: IReFungibleOwner[];
-  constData: number[];
 }
 
 export function uniqueEventMessage(events: EventRecord[]): IGetMessage {
@@ -784,7 +783,7 @@
   });
 }
 
-export async function setOffchainSchemaExpectSuccess(sender: IKeyringPair, collectionId: number, data: number[]) {
+/*export async function setOffchainSchemaExpectSuccess(sender: IKeyringPair, collectionId: number, data: number[]) {
   await usingApi(async (api) => {
     const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));
     const events = await submitTransactionAsync(sender, tx);
@@ -799,7 +798,7 @@
     const tx = api.tx.unique.setOffchainSchema(collectionId, '0x' + Buffer.from(data).toString('hex'));
     await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
   });
-}
+}*/
 
 export interface CreateFungibleData {
   readonly Value: bigint;
@@ -1111,12 +1110,20 @@
 ): Promise<string[]> {
   return (await api.rpc.unique.adminlist(collectionId)).toHuman() as any;
 }
-export async function getConstMetadata(
+/*export async function getConstMetadata(
   api: ApiPromise,
   collectionId: number,
   tokenId: number,
 ): Promise<number[]> {
   return [...(await api.rpc.unique.constMetadata(collectionId, tokenId))];
+}*/
+export async function getTokenProperties(
+  api: ApiPromise,
+  collectionId: number,
+  tokenId: number,
+  propertyKeys: string[],
+): Promise<UpDataStructsProperty[]> {
+  return (await api.rpc.unique.tokenProperties(collectionId, tokenId, propertyKeys)).toHuman() as any;
 }
 
 export async function createFungibleItemExpectSuccess(
@@ -1150,18 +1157,6 @@
   });
 }
 
-export async function createMultipleItemsWithPropsExpectFailure(sender: IKeyringPair, collectionId: number, itemsData: any, owner: CrossAccountId | string = sender.address) {
-  await usingApi(async (api) => {
-    const to = normalizeAccountId(owner);
-    const tx = api.tx.unique.createMultipleItems(collectionId, to, itemsData);
-
-    const events = await expect(await submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
-    const result = getCreateItemsResult(events);
-
-    expect(result).to.be.equal(false);
-  });
-}
-
 export async function createMultipleItemsExWithPropsExpectSuccess(sender: IKeyringPair, collectionId: number, itemsData: any) {
   await usingApi(async (api) => {
     const tx = api.tx.unique.createMultipleItemsEx(collectionId, itemsData);
@@ -1187,10 +1182,10 @@
       const createData = {fungible: {value: 10}};
       tx = api.tx.unique.createItem(collectionId, to, createData as any);
     } else if (createMode === 'ReFungible') {
-      const createData = {refungible: {const_data: [], pieces: 100}};
+      const createData = {refungible: {pieces: 100}};
       tx = api.tx.unique.createItem(collectionId, to, createData as any);
     } else {
-      const data = api.createType('UpDataStructsCreateItemData', {NFT: {constData: 'test', properties: props}});
+      const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});
       tx = api.tx.unique.createItem(collectionId, to, data as UpDataStructsCreateItemData);
     }
 
@@ -1225,7 +1220,7 @@
 
     let tx;
     if (createMode === 'NFT') {
-      const data = api.createType('UpDataStructsCreateItemData', {NFT: {constData: 'test', properties: props}});
+      const data = api.createType('UpDataStructsCreateItemData', {NFT: {properties: props}});
       tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), data);
     } else {
       tx = api.tx.unique.createItem(collectionId, normalizeAccountId(owner), createMode);
@@ -1251,10 +1246,10 @@
       const createData = {fungible: {value: 10}};
       tx = api.tx.unique.createItem(collectionId, to, createData as any);
     } else if (createMode === 'ReFungible') {
-      const createData = {refungible: {const_data: [], pieces: 100}};
+      const createData = {refungible: {pieces: 100}};
       tx = api.tx.unique.createItem(collectionId, to, createData as any);
     } else {
-      const createData = {nft: {const_data: []}};
+      const createData = {nft: {}};
       tx = api.tx.unique.createItem(collectionId, to, createData as any);
     }