git.delta.rocks / unique-network / refs/commits / 340447083f1b

difftreelog

wip migrating createMultipleItems

rkv2022-09-12parent: #d856e87.patch.diff
in: master

1 file changed

modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
before · tests/src/createMultipleItems.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 {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});
after · tests/src/createMultipleItems.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 {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';40import {usingPlaygrounds} from './util/playgrounds';4142chai.use(chaiAsPromised);43const expect = chai.expect;4445let donor: IKeyringPair;4647before(async () => {48  await usingPlaygrounds(async (_, privateKey) => {49    donor = privateKey('//Alice');50  });51});5253let alice: IKeyringPair;54let bob: IKeyringPair;5556describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {57  before(async () => {58    await usingPlaygrounds(async (helper) => {59      [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);60    });61  });6263  it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {64    await usingPlaygrounds(async (helper) => {65      const collection = await helper.nft.mintCollection(alice, {66        name: 'name',67        description: 'descr',68        tokenPrefix: 'COL',69        tokenPropertyPermissions: [70          {key: 'data', permission: {tokenOwner: true, mutable: false, collectionAdmin: false}},71        ],72      });73      const args = [74        {properties: [{key: 'data', value: '1'}]},75        {properties: [{key: 'data', value: '2'}]},76        {properties: [{key: 'data', value: '3'}]},77      ];78      const tokens = await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);79      for (const [i, token] of tokens.entries()) {80        const tokenData = await token.getData();81        expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});82        expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);83      }84    });85  });8687  it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {88    await usingPlaygrounds(async (helper) => {89      const collection = await helper.ft.mintCollection(alice, {90        name: 'name',91        description: 'descr',92        tokenPrefix: 'COL',93      });94      const args = [95        {value: 1n},96        {value: 2n},97        {value: 3n},98      ];99      await helper.ft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);100      expect(await collection.getBalance({Substrate: alice.address})).to.be.equal(6n);101    });102  });103104  it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async function() {105    await usingPlaygrounds(async (helper) => {106      const collection = await helper.rft.mintCollection(alice, {107        name: 'name',108        description: 'descr',109        tokenPrefix: 'COL',110      });111      const args = [112        {pieces: 1n},113        {pieces: 2n},114        {pieces: 3n},115      ];116      const tokens = await helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);117118      for (const [i, token] of tokens.entries()) {119        expect(await token.getBalance({Substrate: alice.address})).to.be.equal(BigInt(i + 1));120      }121    });122  });123124  it('Can mint amount of items equals to collection limits', async () => {125    await usingPlaygrounds(async (helper) => {126      const collection = await helper.nft.mintCollection(alice, {127        name: 'name',128        description: 'descr',129        tokenPrefix: 'COL',130        limits: {131          tokenLimit: 2,132        },133      });134      const args = [{}, {}];135      await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);136    });137  });138139  it('Create 0x31, 0x32, 0x33 items in active NFT with property Admin', async () => {140    await usingPlaygrounds(async (helper) => {141      const collection = await helper.nft.mintCollection(alice, {142        name: 'name',143        description: 'descr',144        tokenPrefix: 'COL',145        tokenPropertyPermissions: [146          {key: 'data', permission: {tokenOwner: false, mutable: true, collectionAdmin: true}},147        ],148      });149      const args = [150        {properties: [{key: 'data', value: '1'}]},151        {properties: [{key: 'data', value: '2'}]},152        {properties: [{key: 'data', value: '3'}]},153      ];154      const tokens = await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);155      for (const [i, token] of tokens.entries()) {156        const tokenData = await token.getData();157        expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});158        expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);159      }160    });161  });162163  it('Create 0x31, 0x32, 0x33 items in active NFT with property AdminConst', async () => {164    await usingPlaygrounds(async (helper) => {165      const collection = await helper.nft.mintCollection(alice, {166        name: 'name',167        description: 'descr',168        tokenPrefix: 'COL',169        tokenPropertyPermissions: [170          {key: 'data', permission: {tokenOwner: false, mutable: false, collectionAdmin: true}},171        ],172      });173      const args = [174        {properties: [{key: 'data', value: '1'}]},175        {properties: [{key: 'data', value: '2'}]},176        {properties: [{key: 'data', value: '3'}]},177      ];178      const tokens = await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);179      for (const [i, token] of tokens.entries()) {180        const tokenData = await token.getData();181        expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});182        expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);183      }184    });185  });186187  it('Create 0x31, 0x32, 0x33 items in active NFT with property itemOwnerOrAdmin', async () => {188    await usingPlaygrounds(async (helper) => {189      const collection = await helper.nft.mintCollection(alice, {190        name: 'name',191        description: 'descr',192        tokenPrefix: 'COL',193        tokenPropertyPermissions: [194          {key: 'data', permission: {tokenOwner: true, mutable: true, collectionAdmin: true}},195        ],196      });197      const args = [198        {properties: [{key: 'data', value: '1'}]},199        {properties: [{key: 'data', value: '2'}]},200        {properties: [{key: 'data', value: '3'}]},201      ];202      const tokens = await helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);203      for (const [i, token] of tokens.entries()) {204        const tokenData = await token.getData();205        expect(tokenData?.normalizedOwner).to.be.deep.equal({Substrate: alice.address});206        expect(tokenData?.properties[0].value).to.be.equal(args[i].properties[0].value);207      }208    });209  });210});211212describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {213  let alice: IKeyringPair;214  let bob: IKeyringPair;215216  before(async () => {217    await usingApi(async (api, privateKeyWrapper) => {218      alice = privateKeyWrapper('//Alice');219      bob = privateKeyWrapper('//Bob');220    });221  });222223  it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {224    await usingApi(async (api: ApiPromise) => {225      const collectionId = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'data', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});226      const itemsListIndexBefore = await getLastTokenId(api, collectionId);227      expect(itemsListIndexBefore).to.be.equal(0);228      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);229      const args = [230        {NFT: {properties: [{key: 'data', value: 'v1'}]}},231        {NFT: {properties: [{key: 'data', value: 'v2'}]}},232        {NFT: {properties: [{key: 'data', value: 'v3'}]}},233      ];234      const createMultipleItemsTx = api.tx.unique235        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);236      await submitTransactionAsync(bob, createMultipleItemsTx);237      const itemsListIndexAfter = await getLastTokenId(api, collectionId);238      expect(itemsListIndexAfter).to.be.equal(3);239240      expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(bob.address));241      expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));242      expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));243244      expect((await getTokenProperties(api, collectionId, 1, ['data']))[0].value).to.be.equal('v1');245      expect((await getTokenProperties(api, collectionId, 2, ['data']))[0].value).to.be.equal('v2');246      expect((await getTokenProperties(api, collectionId, 3, ['data']))[0].value).to.be.equal('v3');247    });248  });249250  it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {251    await usingApi(async (api: ApiPromise) => {252      const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});253      const itemsListIndexBefore = await getLastTokenId(api, collectionId);254      expect(itemsListIndexBefore).to.be.equal(0);255      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);256      const args = [257        {Fungible: {value: 1}},258        {Fungible: {value: 2}},259        {Fungible: {value: 3}},260      ];261      const createMultipleItemsTx = api.tx.unique262        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);263      await submitTransactionAsync(bob, createMultipleItemsTx);264      const token1Data = await getBalance(api, collectionId, bob.address, 0);265266      expect(token1Data).to.be.equal(6n); // 1 + 2 + 3267    });268  });269270  it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async function() {271    await requirePallets(this, [Pallets.ReFungible]);272273    await usingApi(async (api: ApiPromise) => {274      const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});275      const itemsListIndexBefore = await getLastTokenId(api, collectionId);276      expect(itemsListIndexBefore).to.be.equal(0);277      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);278      const args = [279        {ReFungible: {pieces: 1}},280        {ReFungible: {pieces: 2}},281        {ReFungible: {pieces: 3}},282      ];283      const createMultipleItemsTx = api.tx.unique284        .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);285      await submitTransactionAsync(bob, createMultipleItemsTx);286      const itemsListIndexAfter = await getLastTokenId(api, collectionId);287      expect(itemsListIndexAfter).to.be.equal(3);288289      expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);290      expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(2n);291      expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(3n);292    });293  });294});295296describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {297  let alice: IKeyringPair;298  let bob: IKeyringPair;299300  before(async () => {301    await usingPlaygrounds(async (helper) => {302      [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);303    });304  });305306  it('Regular user cannot create items in active NFT collection', async () => {307    await usingPlaygrounds(async (helper) => {308      const collection = await helper.nft.mintCollection(alice, {309        name: 'name',310        description: 'descr',311        tokenPrefix: 'COL',312      });313      const args = [314        {},315        {},316      ];317      const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);318      await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);319    });320  });321322  it('Regular user cannot create items in active Fungible collection', async () => {323    await usingPlaygrounds(async (helper) => {324      const collection = await helper.ft.mintCollection(alice, {325        name: 'name',326        description: 'descr',327        tokenPrefix: 'COL',328      });329      const args = [330        {value: 1n},331        {value: 2n},332        {value: 3n},333      ];334      const mintTx = async () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);335      await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);336    });337  });338339  it('Regular user cannot create items in active ReFungible collection', async function() {340    await usingPlaygrounds(async (helper) => {341      const collection = await helper.rft.mintCollection(alice, {342        name: 'name',343        description: 'descr',344        tokenPrefix: 'COL',345      });346      const args = [347        {pieces: 1n},348        {pieces: 1n},349        {pieces: 1n},350      ];351      const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);352      await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);353    });354  });355356  it('Create token in not existing collection', async () => {357    await usingPlaygrounds(async (helper) => {358      const collectionId = 1_000_000;359      const args = [360        {},361        {},362      ];363      const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);364      await expect(mintTx()).to.be.rejectedWith(/common\.CollectionNotFound/);365    });366  });367368  it('Create NFTs that has reached the maximum data limit', async function() {369    await usingPlaygrounds(async (helper) => {370      const collection = await helper.nft.mintCollection(alice, {371        name: 'name',372        description: 'descr',373        tokenPrefix: 'COL',374        tokenPropertyPermissions: [375          {key: 'data', permission: {tokenOwner: true, mutable: true, collectionAdmin: true}},376        ],377      });378      const args = [379        {properties: [{key: 'data', value: 'A'.repeat(32769)}]},380        {properties: [{key: 'data', value: 'B'.repeat(32769)}]},381        {properties: [{key: 'data', value: 'C'.repeat(32769)}]},382      ];383      const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);384      await expect(mintTx()).to.be.rejected;385    });386  });387388  it('Create Refungible tokens that has reached the maximum data limit', async function() {389    await usingPlaygrounds(async (helper) => {390      const collection = await helper.rft.mintCollection(alice, {391        name: 'name',392        description: 'descr',393        tokenPrefix: 'COL',394        tokenPropertyPermissions: [395          {key: 'data', permission: {tokenOwner: true, mutable: true, collectionAdmin: true}},396        ],397      });398      const args = [399        {pieces: 10n, properties: [{key: 'data', value: 'A'.repeat(32769)}]},400        {pieces: 10n, properties: [{key: 'data', value: 'B'.repeat(32769)}]},401        {pieces: 10n, properties: [{key: 'data', value: 'C'.repeat(32769)}]},402      ];403      const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);404      await expect(mintTx()).to.be.rejected;405    });406  });407408  it('Create tokens with different types', async () => {409    await usingPlaygrounds(async (helper) => {410      const {collectionId} = await helper.nft.mintCollection(alice, {411        name: 'name',412        description: 'descr',413        tokenPrefix: 'COL',414      });415416      //FIXME:417      const types = ['NFT', 'Fungible', 'ReFungible'];418      const mintTx = helper.api?.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), types);419      await expect(helper.signTransaction(alice, mintTx)).to.be.rejected;420    });421  });422423  it('Create tokens with different data limits <> maximum data limit', async () => {424    await usingApi(async (api: ApiPromise) => {425      const collectionId = await createCollectionWithPropsExpectSuccess({426        propPerm: [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],427      });428      const args = [429        {NFT: {properties: [{key: 'key', value: 'A'}]}},430        {NFT: {properties: [{key: 'key', value: 'B'.repeat(32769)}]}},431      ];432      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);433      await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;434    });435  });436437  it('Fails when minting tokens exceeds collectionLimits amount', async () => {438    await usingApi(async (api) => {439      const collectionId = await createCollectionExpectSuccess();440      await setCollectionLimitsExpectSuccess(alice, collectionId, {441        tokenLimit: 1,442      });443      const args = [444        {NFT: {}},445        {NFT: {}},446      ];447      const createMultipleItemsTx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);448      await expect(executeTransaction(api, alice, createMultipleItemsTx)).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);449    });450  });451452  it('User doesnt have editing rights', async () => {453    await usingApi(async (api: ApiPromise) => {454      const collectionId = await createCollectionWithPropsExpectSuccess({455        propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],456      });457      const itemsListIndexBefore = await getLastTokenId(api, collectionId);458      expect(itemsListIndexBefore).to.be.equal(0);459      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);460      const args = [461        {NFT: {properties: [{key: 'key1', value: 'v2'}]}},462        {NFT: {}},463        {NFT: {}},464      ];465466      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);467      await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);468    });469  });470471  it('Adding property without access rights', async () => {472    await usingApi(async (api: ApiPromise) => {473      const collectionId = await createCollectionWithPropsExpectSuccess({properties: [{key: 'k', value: 'v1'}]});474      const itemsListIndexBefore = await getLastTokenId(api, collectionId);475      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);476      expect(itemsListIndexBefore).to.be.equal(0);477      const args = [{NFT: {properties: [{key: 'k', value: 'v'}]}},478        {NFT: {}},479        {NFT: {}}];480481      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(bob.address), args);482      await expect(executeTransaction(api, bob, tx)).to.be.rejectedWith(/common\.NoPermission/);483    });484  });485486  it('Adding more than 64 prps', async () => {487    await usingApi(async (api: ApiPromise) => {488      const propPerms = [{key: 'key', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}];489      for (let i = 0; i < 65; i++) {490        propPerms.push({key: `key${i}`, permission: {mutable: true, collectionAdmin: true, tokenOwner: true}});491      }492493      const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});494495      const tx1 = api.tx.unique.setTokenPropertyPermissions(collectionId, propPerms);496      await expect(executeTransaction(api, alice, tx1)).to.be.rejectedWith(/common\.PropertyLimitReached/);497498      const itemsListIndexBefore = await getLastTokenId(api, collectionId);499      expect(itemsListIndexBefore).to.be.equal(0);500      await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);501502      const prps = [];503504      for (let i = 0; i < 65; i++) {505        prps.push({key: `key${i}`, value: `value${i}`});506      }507508      const args = [509        {NFT: {properties: prps}},510        {NFT: {properties: prps}},511        {NFT: {properties: prps}},512      ];513514      // there are no permissions, but will fail anyway because of too much weight for a block515      const tx2 = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);516      await expect(submitTransactionExpectFailAsync(alice, tx2)).to.be.rejected;517    });518  });519520  it('Trying to add bigger property than allowed', async () => {521    await usingApi(async (api: ApiPromise) => {522      const collectionId = await createCollectionWithPropsExpectSuccess({523        propPerm: [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}],524      });525      const itemsListIndexBefore = await getLastTokenId(api, collectionId);526      expect(itemsListIndexBefore).to.be.equal(0);527      const args = [{NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},528        {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}},529        {NFT: {properties: [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]}}];530531      const tx = api.tx.unique.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);532      await expect(executeTransaction(api, alice, tx)).to.be.rejectedWith(/common\.NoPermission/);533    });534  });535});