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

difftreelog

createItem migrated

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

1 file changed

modifiedtests/src/createItem.test.tsdiffbeforeafterboth
before · tests/src/createItem.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 {default as usingApi, executeTransaction} from './substrate/substrate-api';18import chai from 'chai';19import {IKeyringPair} from '@polkadot/types/types';20import {21  createCollectionExpectSuccess,22  createItemExpectSuccess,23  addCollectionAdminExpectSuccess,24  createCollectionWithPropsExpectSuccess,25  createItemWithPropsExpectSuccess,26  createItemWithPropsExpectFailure,27  createCollection,28  transferExpectSuccess,29  itApi,30  normalizeAccountId,31  getCreateItemResult,32  requirePallets,33  Pallets,34} from './util/helpers';3536const expect = chai.expect;37let alice: IKeyringPair;38let bob: IKeyringPair;3940describe('integration test: ext. ():', () => {41  before(async () => {42    await usingApi(async (api, privateKeyWrapper) => {43      alice = privateKeyWrapper('//Alice');44      bob = privateKeyWrapper('//Bob');45    });46  });4748  it('Create new item in NFT collection', async () => {49    const createMode = 'NFT';50    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});51    await createItemExpectSuccess(alice, newCollectionID, createMode);52  });53  it('Create new item in Fungible collection', async () => {54    const createMode = 'Fungible';55    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});56    await createItemExpectSuccess(alice, newCollectionID, createMode);57  });58  itApi('Check events on create new item in Fungible collection', async ({api}) => {59    const createMode = 'Fungible';60    61    const newCollectionID = (await createCollection(api, alice, {mode: {type: createMode, decimalPoints: 0}})).collectionId;62    63    const to = normalizeAccountId(alice);64    {65      const createData = {fungible: {value: 100}};66      const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);67      const events = await executeTransaction(api, alice, tx);68      const result = getCreateItemResult(events);69      expect(result.amount).to.be.equal(100);70      expect(result.collectionId).to.be.equal(newCollectionID);71      expect(result.recipient).to.be.deep.equal(to);72    }73    {74      const createData = {fungible: {value: 50}};75      const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);76      const events = await executeTransaction(api, alice, tx);77      const result = getCreateItemResult(events);78      expect(result.amount).to.be.equal(50);79      expect(result.collectionId).to.be.equal(newCollectionID);80      expect(result.recipient).to.be.deep.equal(to);81    }8283  });84  it('Create new item in ReFungible collection', async function() {85    await requirePallets(this, [Pallets.ReFungible]);8687    const createMode = 'ReFungible';88    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});89    await createItemExpectSuccess(alice, newCollectionID, createMode);90  });91  it('Create new item in NFT collection with collection admin permissions', async () => {92    const createMode = 'NFT';93    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});94    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);95    await createItemExpectSuccess(bob, newCollectionID, createMode);96  });97  it('Create new item in Fungible collection with collection admin permissions', async () => {98    const createMode = 'Fungible';99    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});100    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);101    await createItemExpectSuccess(bob, newCollectionID, createMode);102  });103  it('Create new item in ReFungible collection with collection admin permissions', async function() {104    await requirePallets(this, [Pallets.ReFungible]);105106    const createMode = 'ReFungible';107    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});108    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);109    await createItemExpectSuccess(bob, newCollectionID, createMode);110  });111112  it('Set property Admin', async () => {113    const createMode = 'NFT';114    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 115      propPerm:   [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});116    117    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'k', value: 't2'}]);118  });119120  it('Set property AdminConst', async () => {121    const createMode = 'NFT';122    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 123      propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});124    125    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);126  });127128  it('Set property itemOwnerOrAdmin', async () => {129    const createMode = 'NFT';130    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},131      propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});132    133    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);134  });135136  it('Check total pieces of Fungible token', async () => {137    await usingApi(async api => {138      const createMode = 'Fungible';139      const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});140      const amountPieces = 10n;141      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);142      {143        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);144        expect(totalPieces.isSome).to.be.true;145        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);146      }147148      await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);149      {150        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);151        expect(totalPieces.isSome).to.be.true;152        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);153      }154155      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;156      expect(totalPieces.toBigInt()).to.be.eq(amountPieces);157    });158  });159160  it('Check total pieces of NFT token', async () => {161    await usingApi(async api => {162      const createMode = 'NFT';163      const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});164      const amountPieces = 1n;165      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);166      {167        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);168        expect(totalPieces.isSome).to.be.true;169        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);170      }171172      await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);173      {174        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);175        expect(totalPieces.isSome).to.be.true;176        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);177      }178179      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;180      expect(totalPieces.toBigInt()).to.be.eq(amountPieces);181    });182  });183184  it('Check total pieces of ReFungible token', async function() {185    await requirePallets(this, [Pallets.ReFungible]);186187    await usingApi(async api => {188      const createMode = 'ReFungible';189      const createCollectionResult = await createCollection(api, alice, {mode: {type: createMode}});190      const collectionId  = createCollectionResult.collectionId;191      const amountPieces = 100n;192      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);193      {194        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);195        expect(totalPieces.isSome).to.be.true;196        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);197      }198199      await transferExpectSuccess(collectionId, tokenId, bob, alice, 60n, createMode);200      {201        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);202        expect(totalPieces.isSome).to.be.true;203        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);204      }205206      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;207      expect(totalPieces.toBigInt()).to.be.eq(amountPieces);208    });209  });210});211212describe('Negative integration test: ext. createItem():', () => {213  before(async () => {214    await usingApi(async (api, privateKeyWrapper) => {215      alice = privateKeyWrapper('//Alice');216      bob = privateKeyWrapper('//Bob');217    });218  });219220  it('Regular user cannot create new item in NFT collection', async () => {221    const createMode = 'NFT';222    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});223    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;224  });225  it('Regular user cannot create new item in Fungible collection', async () => {226    const createMode = 'Fungible';227    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});228    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;229  });230  it('Regular user cannot create new item in ReFungible collection', async function() {231    await requirePallets(this, [Pallets.ReFungible]);232233    const createMode = 'ReFungible';234    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});235    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;236  });237238  it('No editing rights', async () => {239    await usingApi(async () => {240      const createMode = 'NFT';241      const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 242        propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});243      await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);244245      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);246    });247  });248249  it('User doesnt have editing rights', async () => {250    await usingApi(async () => {251      const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});252      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);253    });254  });255256  it('Adding property without access rights', async () => {257    await usingApi(async () => {258      const newCollectionID = await createCollectionWithPropsExpectSuccess();259      await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);260261      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);262    });263  });264265  it('Adding more than 64 prps', async () => {266    await usingApi(async () => {267      const prps = [];268269      for (let i = 0; i < 65; i++) {270        prps.push({key: `key${i}`, value: `value${i}`});271      }272273      const newCollectionID = await createCollectionWithPropsExpectSuccess();274      275      await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);276    });277  });278279  it('Trying to add bigger property than allowed', async () => {280    await usingApi(async () => {281      const newCollectionID = await createCollectionWithPropsExpectSuccess();282      283      await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);284    });285  });286287  it('Check total pieces for invalid Fungible token', async () => {288    await usingApi(async api => {289      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});290      const collectionId  = createCollectionResult.collectionId;291      const invalidTokenId = 1000_000;292      293      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;294      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);295    });296  });297298  it('Check total pieces for invalid NFT token', async () => {299    await usingApi(async api => {300      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'NFT'}});301      const collectionId  = createCollectionResult.collectionId;302      const invalidTokenId = 1000_000;303      304      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;305      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);306    });307  });308309  it('Check total pieces for invalid Refungible token', async function() {310    await requirePallets(this, [Pallets.ReFungible]);311312    await usingApi(async api => {313      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});314      const collectionId  = createCollectionResult.collectionId;315      const invalidTokenId = 1000_000;316      317      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;318      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);319    });320  });321});
after · tests/src/createItem.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 chai from 'chai';18import chaiAsPromised from 'chai-as-promised';19import {IKeyringPair} from '@polkadot/types/types';20import {21  createCollection,22  itApi,23  normalizeAccountId,24  getCreateItemResult,25} from './util/helpers';26import {usingPlaygrounds} from './util/playgrounds';27import {IProperty} from './util/playgrounds/types';28import {executeTransaction} from './substrate/substrate-api';2930chai.use(chaiAsPromised);31const expect = chai.expect;3233let donor: IKeyringPair;3435before(async () => {36  await usingPlaygrounds(async (_, privateKey) => {37    donor = privateKey('//Alice');38  });39});4041let alice: IKeyringPair;42let bob: IKeyringPair;4344describe('integration test: ext. ():', () => {45  before(async () => {46    await usingPlaygrounds(async (helper) => {47      [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);48    });49  });5051  it('Create new item in NFT collection', async () => {52    await usingPlaygrounds(async (helper) => {53      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});54      await collection.mintToken(alice, {Substrate: alice.address});55    });56  });57  it('Create new item in Fungible collection', async () => {58    await usingPlaygrounds(async (helper) => {59      const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);60      await collection.mint(alice, {Substrate: alice.address}, 10n);61    });62  });63  itApi.skip('Check events on create new item in Fungible collection', async ({api}) => {64    const createMode = 'Fungible';6566    const newCollectionID = (await createCollection(api, alice, {mode: {type: createMode, decimalPoints: 0}})).collectionId;6768    const to = normalizeAccountId(alice);69    {70      const createData = {fungible: {value: 100}};71      const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);72      const events = await executeTransaction(api, alice, tx);73      const result = getCreateItemResult(events);74      expect(result.amount).to.be.equal(100);75      expect(result.collectionId).to.be.equal(newCollectionID);76      expect(result.recipient).to.be.deep.equal(to);77    }78    {79      const createData = {fungible: {value: 50}};80      const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);81      const events = await executeTransaction(api, alice, tx);82      const result = getCreateItemResult(events);83      expect(result.amount).to.be.equal(50);84      expect(result.collectionId).to.be.equal(newCollectionID);85      expect(result.recipient).to.be.deep.equal(to);86    }8788  });89  it('Create new item in ReFungible collection', async function() {90    await usingPlaygrounds(async (helper) => {91      const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});92      await collection.mintToken(alice, {Substrate: alice.address}, 100n);93    });94  });95  it('Create new item in NFT collection with collection admin permissions', async () => {96    await usingPlaygrounds(async (helper) => {97      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});98      await collection.addAdmin(alice, {Substrate: bob.address});99      await collection.mintToken(bob, {Substrate: alice.address});100    });101  });102  it('Create new item in Fungible collection with collection admin permissions', async () => {103    await usingPlaygrounds(async (helper) => {104      const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);105      await collection.addAdmin(alice, {Substrate: bob.address});106      await collection.mint(bob, {Substrate: alice.address}, 10n);107    });108  });109  it('Create new item in ReFungible collection with collection admin permissions', async function() {110    await usingPlaygrounds(async (helper) => {111      const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});112      await collection.addAdmin(alice, {Substrate: bob.address});113      await collection.mintToken(bob, {Substrate: alice.address}, 100n);114    });115  });116117  it('Set property Admin', async () => {118    await usingPlaygrounds(async (helper) => {119      const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',120        properties: [{key: 'k', value: 'v'}],121        tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: true, collectionAdmin: true}}],122      });123      await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);124    });125  });126127  it('Set property AdminConst', async () => {128    await usingPlaygrounds(async (helper) => {129      const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',130        properties: [{key: 'k', value: 'v'}],131        tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: false, collectionAdmin: true}}],132      });133      await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);134    });135  });136137  it('Set property itemOwnerOrAdmin', async () => {138    await usingPlaygrounds(async (helper) => {139      const collection = await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL',140        properties: [{key: 'k', value: 'v'}],141        tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: true, mutable: true, collectionAdmin: true}}],142      });143      await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);144    });145  });146147  it('Check total pieces of Fungible token', async () => {148    await usingPlaygrounds(async (helper) => {149      const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);150      const amount = 10n;151      await collection.mint(alice, {Substrate: bob.address}, amount);152      {153        const totalPieces = await collection.getTotalPieces();154        expect(totalPieces).to.be.equal(amount);155      }156      await collection.transfer(bob, {Substrate: alice.address}, 1n);157      {158        const totalPieces = await collection.getTotalPieces();159        expect(totalPieces).to.be.equal(amount);160      }161    });162  });163164  it('Check total pieces of NFT token', async () => {165    await usingPlaygrounds(async (helper) => {166      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});167      const amount = 1n;168      const token = await collection.mintToken(alice, {Substrate: bob.address});169      {170        const totalPieces = await helper.api?.rpc.unique.totalPieces(collection.collectionId, token.tokenId);171        expect(totalPieces?.unwrap().toBigInt()).to.be.equal(amount);172      }173      await token.transfer(bob, {Substrate: alice.address});174      {175        const totalPieces = await helper.api?.rpc.unique.totalPieces(collection.collectionId, token.tokenId);176        expect(totalPieces?.unwrap().toBigInt()).to.be.equal(amount);177      }178    });179  });180181  it('Check total pieces of ReFungible token', async function() {182    await usingPlaygrounds(async (helper) => {183      const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});184      const amount = 100n;185      const token = await collection.mintToken(alice, {Substrate: bob.address}, amount);186      {187        const totalPieces = await token.getTotalPieces();188        expect(totalPieces).to.be.equal(amount);189      }190      await token.transfer(bob, {Substrate: alice.address}, 60n);191      {192        const totalPieces = await token.getTotalPieces();193        expect(totalPieces).to.be.equal(amount);194      }195    });196  });197});198199describe('Negative integration test: ext. createItem():', () => {200  before(async () => {201    await usingPlaygrounds(async (helper) => {202      [alice, bob] = await helper.arrange.createAccounts([100n, 100n], donor);203    });204  });205206  it('Regular user cannot create new item in NFT collection', async () => {207    await usingPlaygrounds(async (helper) => {208      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});209      const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});210      await expect(mintTx()).to.be.rejected;211    });212  });213  it('Regular user cannot create new item in Fungible collection', async () => {214    await usingPlaygrounds(async (helper) => {215      const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);216      const mintTx = async () => collection.mint(bob, {Substrate: bob.address}, 10n);217      await expect(mintTx()).to.be.rejected;218    });219  });220  it('Regular user cannot create new item in ReFungible collection', async () => {221    await usingPlaygrounds(async (helper) => {222      const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});223      const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});224      await expect(mintTx()).to.be.rejected;225    });226  });227228  it('No editing rights', async () => {229    await usingPlaygrounds(async (helper) => {230      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',231        tokenPropertyPermissions: [{key: 'k', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}],232      });233      const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);234      await expect(mintTx()).to.be.rejected;235    });236  });237238  it('User doesnt have editing rights', async () => {239    await usingPlaygrounds(async (helper) => {240      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',241        tokenPropertyPermissions: [{key: 'k', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],242      });243      const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);244      await expect(mintTx()).to.be.rejected;245    });246  });247248  it('Adding property without access rights', async () => {249    await usingPlaygrounds(async (helper) => {250      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});251      const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);252      await expect(mintTx()).to.be.rejected;253    });254  });255256  it('Adding more than 64 prps', async () => {257    const props: IProperty[] = [];258259    for (let i = 0; i < 65; i++) {260      props.push({key: `key${i}`, value: `value${i}`});261    }262263    await usingPlaygrounds(async (helper) => {264      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});265      const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, props);266      await expect(mintTx()).to.be.rejected;267    });268  });269270  it('Trying to add bigger property than allowed', async () => {271    await usingPlaygrounds(async (helper) => {272      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',273        tokenPropertyPermissions: [274          {key: 'k1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},275          {key: 'k2', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},276        ],277      });278      const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [279        {key: 'k1', value: 'vvvvvv'.repeat(5000)},280        {key: 'k2', value: 'vvv'.repeat(5000)},281      ]);282      await expect(mintTx()).to.be.rejected;283    });284  });285286  it('Check total pieces for invalid Fungible token', async () => {287    await usingPlaygrounds(async (helper) => {288      const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);289      const invalidTokenId = 1_000_000;290      expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;291      expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);292    });293  });294295  it('Check total pieces for invalid NFT token', async () => {296    await usingPlaygrounds(async (helper) => {297      const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});298      const invalidTokenId = 1_000_000;299      expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;300      expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);301    });302  });303304  it('Check total pieces for invalid Refungible token', async function() {305    await usingPlaygrounds(async (helper) => {306      const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});307      const invalidTokenId = 1_000_000;308      expect((await helper.api?.rpc.unique.totalPieces(collection.collectionId, invalidTokenId))?.isNone).to.be.true;309      expect((await helper.api?.rpc.unique.tokenData(collection.collectionId, invalidTokenId))?.pieces.toBigInt()).to.be.equal(0n);310    });311  });312});