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

difftreelog

source

tests/src/createMultipleItems.test.ts26.1 KiBsourcehistory
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 {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import chai from 'chai';20import chaiAsPromised from 'chai-as-promised';21import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync, executeTransaction} from './substrate/substrate-api';22import {23  createCollectionExpectSuccess,24  destroyCollectionExpectSuccess,25  getGenericResult,26  normalizeAccountId,27  setCollectionLimitsExpectSuccess,28  addCollectionAdminExpectSuccess,29  getBalance,30  getTokenOwner,31  getLastTokenId,32  getCreatedCollectionCount,33  createCollectionWithPropsExpectSuccess,34  createMultipleItemsWithPropsExpectSuccess,35  getTokenProperties,36  requirePallets,37  Pallets,38  checkPalletsPresence,39} from './util/helpers';4041chai.use(chaiAsPromised);42const expect = chai.expect;4344describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {45  it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {46    await usingApi(async (api, privateKeyWrapper) => {47      const collectionId = await createCollectionExpectSuccess();48      const itemsListIndexBefore = await getLastTokenId(api, collectionId);49      expect(itemsListIndexBefore).to.be.equal(0);5051      const alice = privateKeyWrapper('//Alice');52      await submitTransactionAsync(53        alice, 54        api.tx.unique.setTokenPropertyPermissions(collectionId, [{key: 'data', permission: {tokenOwner: true}}]),55      );56      57      const args = [58        {NFT: {properties: [{key: 'data', value: '1'}]}},59        {NFT: {properties: [{key: 'data', value: '2'}]}},60        {NFT: {properties: [{key: 'data', value: '3'}]}},61      ];62      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);63      await submitTransactionAsync(alice, createMultipleItemsTx);64      const itemsListIndexAfter = await getLastTokenId(api, collectionId);65      expect(itemsListIndexAfter).to.be.equal(3);6667      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));68      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));69      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));7071      expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('1');72      expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('2');73      expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('3');74    });75  });7677  it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {78    await usingApi(async (api, privateKeyWrapper) => {79      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});80      const itemsListIndexBefore = await getLastTokenId(api, collectionId);81      expect(itemsListIndexBefore).to.be.equal(0);82      const alice = privateKeyWrapper('//Alice');83      const args = [84        {Fungible: {value: 1}},85        {Fungible: {value: 2}},86        {Fungible: {value: 3}},87      ];88      const createMultipleItemsTx = api.tx.unique89        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);90      await submitTransactionAsync(alice, createMultipleItemsTx);91      const token1Data = await getBalance(api, collectionId, alice.address, 0);9293      expect(token1Data).to.be.equal(6n); // 1 + 2 + 394    });95  });9697  it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async function() {98    await requirePallets(this, [Pallets.ReFungible]);99100    await usingApi(async (api, privateKeyWrapper) => {101      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});102      const itemsListIndexBefore = await getLastTokenId(api, collectionId);103      expect(itemsListIndexBefore).to.be.equal(0);104      const alice = privateKeyWrapper('//Alice');105      const args = [106        {ReFungible: {pieces: 1}},107        {ReFungible: {pieces: 2}},108        {ReFungible: {pieces: 3}},109      ];110      const createMultipleItemsTx = api.tx.unique111        .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);112      await submitTransactionAsync(alice, createMultipleItemsTx);113      const itemsListIndexAfter = await getLastTokenId(api, collectionId);114      expect(itemsListIndexAfter).to.be.equal(3);115116      expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);117      expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(2n);118      expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(3n);119    });120  });121122  it('Can mint amount of items equals to collection limits', async () => {123    await usingApi(async (api, privateKeyWrapper) => {124      const alice = privateKeyWrapper('//Alice');125126      const collectionId = await createCollectionExpectSuccess();127      await setCollectionLimitsExpectSuccess(alice, collectionId, {128        tokenLimit: 2,129      });130      const args = [131        {NFT: {}},132        {NFT: {}},133      ];134      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);135      const events = await submitTransactionAsync(alice, createMultipleItemsTx);136      const result = getGenericResult(events);137      expect(result.success).to.be.true;138    });139  });140141  it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {142    await usingApi(async (api, privateKeyWrapper) => {143      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});144      const itemsListIndexBefore = await getLastTokenId(api, collectionId);145      expect(itemsListIndexBefore).to.be.equal(0);146      const alice = privateKeyWrapper('//Alice');147      const args = [148        {NFT: {properties: [{key: 'k', value: 'v1'}]}},149        {NFT: {properties: [{key: 'k', value: 'v2'}]}},150        {NFT: {properties: [{key: 'k', value: 'v3'}]}},151      ];152153      await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);154      const itemsListIndexAfter = await getLastTokenId(api, collectionId);155      expect(itemsListIndexAfter).to.be.equal(3);156157      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));158      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));159      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));160161      expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');162      expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');163      expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');164    });165  });166167  it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {168    await usingApi(async (api, privateKeyWrapper) => {169      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});170      const itemsListIndexBefore = await getLastTokenId(api, collectionId);171      expect(itemsListIndexBefore).to.be.equal(0);172      const alice = privateKeyWrapper('//Alice');173      const bob = privateKeyWrapper('//Bob');174      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);175      const args = [176        {NFT: {properties: [{key: 'k', value: 'v1'}]}},177        {NFT: {properties: [{key: 'k', value: 'v2'}]}},178        {NFT: {properties: [{key: 'k', value: 'v3'}]}},179      ];180181      await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);182      const itemsListIndexAfter = await getLastTokenId(api, collectionId);183      expect(itemsListIndexAfter).to.be.equal(3);184185      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));186      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));187      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));188189      expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');190      expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');191      expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');192    });193  });194195  it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {196    await usingApi(async (api, privateKeyWrapper) => {197      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});198      const itemsListIndexBefore = await getLastTokenId(api, collectionId);199      expect(itemsListIndexBefore).to.be.equal(0);200      const alice = privateKeyWrapper('//Alice');201      const args = [202        {NFT: {properties: [{key: 'k', value: 'v1'}]}},203        {NFT: {properties: [{key: 'k', value: 'v2'}]}},204        {NFT: {properties: [{key: 'k', value: 'v3'}]}},205      ];206207      await createMultipleItemsWithPropsExpectSuccess(alice, collectionId, args);208      const itemsListIndexAfter = await getLastTokenId(api, collectionId);209      expect(itemsListIndexAfter).to.be.equal(3);210211      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));212      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));213      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));214215      expect((await getTokenProperties(api, collectionId, 1, ['k']))[0].value).to.be.equal('v1');216      expect((await getTokenProperties(api, collectionId, 2, ['k']))[0].value).to.be.equal('v2');217      expect((await getTokenProperties(api, collectionId, 3, ['k']))[0].value).to.be.equal('v3');218    });219  });220});221222describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {223  let alice: IKeyringPair;224  let bob: IKeyringPair;225226  before(async () => {227    await usingApi(async (api, privateKeyWrapper) => {228      alice = privateKeyWrapper('//Alice');229      bob = privateKeyWrapper('//Bob');230    });231  });232233  it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {234    await usingApi(async (api: ApiPromise) => {235      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});236      const itemsListIndexBefore = await getLastTokenId(api, collectionId);237      expect(itemsListIndexBefore).to.be.equal(0);238      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);239      const args = [240        {NFT: {properties: [{key: 'data', value: 'v1'}]}},241        {NFT: {properties: [{key: 'data', value: 'v2'}]}},242        {NFT: {properties: [{key: 'data', value: 'v3'}]}},243      ];244      const createMultipleItemsTx = api.tx.unique245        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);246      await submitTransactionAsync(bob, createMultipleItemsTx);247      const itemsListIndexAfter = await getLastTokenId(api, collectionId);248      expect(itemsListIndexAfter).to.be.equal(3);249250      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(bob.address));251      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));252      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));253254      expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('v1');255      expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('v2');256      expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('v3');257    });258  });259260  it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {261    await usingApi(async (api: ApiPromise) => {262      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});263      const itemsListIndexBefore = await getLastTokenId(api, collectionId);264      expect(itemsListIndexBefore).to.be.equal(0);265      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);266      const args = [267        {Fungible: {value: 1}},268        {Fungible: {value: 2}},269        {Fungible: {value: 3}},270      ];271      const createMultipleItemsTx = api.tx.unique272        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);273      await submitTransactionAsync(bob, createMultipleItemsTx);274      const token1Data = await getBalance(api, collectionId, bob.address, 0);275276      expect(token1Data).to.be.equal(6n); // 1 + 2 + 3277    });278  });279280  it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async function() {281    await requirePallets(this, [Pallets.ReFungible]);282283    await usingApi(async (api: ApiPromise) => {284      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});285      const itemsListIndexBefore = await getLastTokenId(api, collectionId);286      expect(itemsListIndexBefore).to.be.equal(0);287      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);288      const args = [289        {ReFungible: {pieces: 1}},290        {ReFungible: {pieces: 2}},291        {ReFungible: {pieces: 3}},292      ];293      const createMultipleItemsTx = api.tx.unique294        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);295      await submitTransactionAsync(bob, createMultipleItemsTx);296      const itemsListIndexAfter = await getLastTokenId(api, collectionId);297      expect(itemsListIndexAfter).to.be.equal(3);298299      expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);300      expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(2n);301      expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(3n);302    });303  });304});305306describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {307  let alice: IKeyringPair;308  let bob: IKeyringPair;309310  before(async () => {311    await usingApi(async (api, privateKeyWrapper) => {312      alice = privateKeyWrapper('//Alice');313      bob = privateKeyWrapper('//Bob');314    });315  });316317  it('Regular user cannot create items in active NFT collection', async () => {318    await usingApi(async (api: ApiPromise) => {319      const collectionId = await createCollectionExpectSuccess();320      const itemsListIndexBefore = await getLastTokenId(api, collectionId);321      expect(itemsListIndexBefore).to.be.equal(0);322      const args = [{NFT: {}},323        {NFT: {}},324        {NFT: {}}];325      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);326      await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);327    });328  });329330  it('Regular user cannot create items in active Fungible collection', async () => {331    await usingApi(async (api: ApiPromise) => {332      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});333      const itemsListIndexBefore = await getLastTokenId(api, collectionId);334      expect(itemsListIndexBefore).to.be.equal(0);335      const args = [336        {Fungible: {value: 1}},337        {Fungible: {value: 2}},338        {Fungible: {value: 3}},339      ];340      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);341      await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);342    });343  });344345  it('Regular user cannot create items in active ReFungible collection', async function() {346    await requirePallets(this, [Pallets.ReFungible]);347348    await usingApi(async (api: ApiPromise) => {349      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});350      const itemsListIndexBefore = await getLastTokenId(api, collectionId);351      expect(itemsListIndexBefore).to.be.equal(0);352      const args = [353        {ReFungible: {pieces: 1}},354        {ReFungible: {pieces: 1}},355        {ReFungible: {pieces: 1}},356      ];357      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);358      await expect(executeTransaction(api, bob, createMultipleItemsTx)).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);359    });360  });361362  it('Create token in not existing collection', async () => {363    await usingApi(async (api: ApiPromise) => {364      const collectionId = await getCreatedCollectionCount(api) + 1;365      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);366      await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionNotFound/);367    });368  });369370  it('Create NFTs that has reached the maximum data limit', async function() {371    await usingApi(async (api, privateKeyWrapper) => {372      const collectionId = await createCollectionWithPropsExpectSuccess({373        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],374      });375      const alice = privateKeyWrapper('//Alice');376      const args = [377        {NFT: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},378        {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},379        {NFT: {properties: [{key: 'key', value: 'C'.repeat(32769)}]}},380      ];381      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);382      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;383    });384  });385386  it('Create Refungible tokens that has reached the maximum data limit', async function() {387    await requirePallets(this, [Pallets.ReFungible]);388389    await usingApi(async api => {390      const collectionIdReFungible =391        await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});392      {393        const argsReFungible = [394          {ReFungible: [10, [['key', 'A'.repeat(32769)]]]},395          {ReFungible: [10, [['key', 'B'.repeat(32769)]]]},396          {ReFungible: [10, [['key', 'C'.repeat(32769)]]]},397        ];398        const createMultipleItemsTxFungible = api.tx.unique399          .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);400        await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;401      }402      {403        const argsReFungible = [404          {ReFungible: {properties: [{key: 'key', value: 'A'.repeat(32769)}]}},405          {ReFungible: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},406          {ReFungible: {properties: [{key: 'key', value: 'C'.repeat(32769)}]}},407        ];408        const createMultipleItemsTxFungible = api.tx.unique409          .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);410        await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;411      }412    });413  });414415  it('Create tokens with different types', async () => {416    await usingApi(async (api: ApiPromise) => {417      const collectionId = await createCollectionExpectSuccess();418419      const types = ['NFT', 'Fungible'];420421      if (await checkPalletsPresence([Pallets.ReFungible])) {422        types.push('ReFungible');423      }424425      const createMultipleItemsTx = api.tx.unique426        .createMultipleItems(collectionId, normalizeAccountId(alice.address), types);427      await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/nonfungible\.NotNonfungibleDataUsedToMintFungibleCollectionToken/);428      // garbage collection :-D // lol429      await destroyCollectionExpectSuccess(collectionId);430    });431  });432433  it('Create tokens with different data limits <> maximum data limit', async () => {434    await usingApi(async (api: ApiPromise) => {435      const collectionId = await createCollectionWithPropsExpectSuccess({436        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],437      });438      const args = [439        {NFT: {properties: [{key: 'key', value: 'A'}]}},440        {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},441      ];442      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);443      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;444    });445  });446447  it('Fails when minting tokens exceeds collectionLimits amount', async () => {448    await usingApi(async (api) => {449      const collectionId = await createCollectionExpectSuccess();450      await setCollectionLimitsExpectSuccess(alice, collectionId, {451        tokenLimit: 1,452      });453      const args = [454        {NFT: {}},455        {NFT: {}},456      ];457      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);458      await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);459    });460  });461462  it('User doesnt have editing rights', async () => {463    await usingApi(async (api: ApiPromise) => {464      const collectionId = await createCollectionWithPropsExpectSuccess({465        propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],466      });467      const itemsListIndexBefore = await getLastTokenId(api, collectionId);468      expect(itemsListIndexBefore).to.be.equal(0);469      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);470      const args = [471        {NFT: {properties: [{key: 'key1', value: 'v2'}]}},472        {NFT: {}},473        {NFT: {}},474      ];475476      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);477      await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);478    });479  });480481  it('Adding property without access rights', async () => {482    await usingApi(async (api: ApiPromise) => {483      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'k', value: 'v1'}]});484      const itemsListIndexBefore = await getLastTokenId(api, collectionId);485      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);486      expect(itemsListIndexBefore).to.be.equal(0);487      const args = [{NFT: {properties: [{key: 'k', value: 'v'}]}},488        {NFT: {}},489        {NFT: {}}];490491      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);492      await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);493    });494  });495496  it('Adding more than 64 prps', async () => {497    await usingApi(async (api: ApiPromise) => {498      const propPerms = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];499      for (let i = 0; i < 65; i++) {500        propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});501      }502503      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});504505      const tx1 = api.tx.unique.setTokenPropertyPermissions(collectionId, propPerms);506      await expect(executeTransaction(api, alice, tx1)).to.be.rejectedWith(/common\.PropertyLimitReached/);507508      const itemsListIndexBefore = await getLastTokenId(api, collectionId);509      expect(itemsListIndexBefore).to.be.equal(0);510      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);511512      const prps = [];513514      for (let i = 0; i < 65; i++) {515        prps.push({key: `key${i}`, value: `value${i}`});516      }517518      const args = [519        {NFT: {properties: prps}},520        {NFT: {properties: prps}},521        {NFT: {properties: prps}},522      ];523524      // there are no permissions, but will fail anyway because of too much weight for a block525      const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);526      await expect(submitTransactionExpectFailAsync(alice, tx2)).to.be.rejected;527    });528  });529530  it('Trying to add bigger property than allowed', async () => {531    await usingApi(async (api: ApiPromise) => {532      const collectionId = await createCollectionWithPropsExpectSuccess({533        propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],534      });535      const itemsListIndexBefore = await getLastTokenId(api, collectionId);536      expect(itemsListIndexBefore).to.be.equal(0);537      const args = [{NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},538        {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},539        {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];540541      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);542      await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);543    });544  });545});