git.delta.rocks / unique-network / refs/commits / 788534ba419e

difftreelog

Fix total pieces tests

Trubnikov Sergey2022-07-06parent: #edc0202.patch.diff
in: master

6 files 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} 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} from './util/helpers';3031const expect = chai.expect;32let alice: IKeyringPair;33let bob: IKeyringPair;3435describe('integration test: ext. ():', () => {36  before(async () => {37    await usingApi(async (api, privateKeyWrapper) => {38      alice = privateKeyWrapper('//Alice');39      bob = privateKeyWrapper('//Bob');40    });41  });4243  it('Create new item in NFT collection', async () => {44    const createMode = 'NFT';45    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});46    await createItemExpectSuccess(alice, newCollectionID, createMode);47  });48  it('Create new item in Fungible collection', async () => {49    const createMode = 'Fungible';50    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});51    await createItemExpectSuccess(alice, newCollectionID, createMode);52  });53  it('Create new item in ReFungible collection', async () => {54    const createMode = 'ReFungible';55    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});56    await createItemExpectSuccess(alice, newCollectionID, createMode);57  });58  it('Create new item in NFT collection with collection admin permissions', async () => {59    const createMode = 'NFT';60    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});61    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);62    await createItemExpectSuccess(bob, newCollectionID, createMode);63  });64  it('Create new item in Fungible collection with collection admin permissions', async () => {65    const createMode = 'Fungible';66    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});67    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);68    await createItemExpectSuccess(bob, newCollectionID, createMode);69  });70  it('Create new item in ReFungible collection with collection admin permissions', async () => {71    const createMode = 'ReFungible';72    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});73    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);74    await createItemExpectSuccess(bob, newCollectionID, createMode);75  });7677  it('Set property Admin', async () => {78    const createMode = 'NFT';79    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 80      propPerm:   [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});81    82    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'k', value: 't2'}]);83  });8485  it('Set property AdminConst', async () => {86    const createMode = 'NFT';87    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 88      propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});89    90    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);91  });9293  it('Set property itemOwnerOrAdmin', async () => {94    const createMode = 'NFT';95    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},96      propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});97    98    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);99  });100101  it('Check total pieces of Fungible token', async () => {102    await usingApi(async api => {103      const createMode = 'Fungible';104      const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});105      const amountPieces = 10n;106      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);107      {108        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);109        expect(totalPieces.isSome).to.be.true;110        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);111      }112113      await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);114      {115        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);116        expect(totalPieces.isSome).to.be.true;117        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);118      }119120      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;121      expect(totalPieces.isSome).to.be.true;122      expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);123    });124  });125126  it('Check total pieces of NFT token', async () => {127    await usingApi(async api => {128      const createMode = 'NFT';129      const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});130      const amountPieces = 1n;131      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);132      {133        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);134        expect(totalPieces.isSome).to.be.true;135        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);136      }137138      await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);139      {140        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);141        expect(totalPieces.isSome).to.be.true;142        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);143      }144145      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;146      expect(totalPieces.isSome).to.be.true;147      expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);148    });149  });150151  it('Check total pieces of ReFungible token', async () => {152    await usingApi(async api => {153      const createMode = 'ReFungible';154      const createCollectionResult = await createCollection(api, alice, {mode: {type: createMode}});155      const collectionId  = createCollectionResult.collectionId;156      const amountPieces = 100n;157      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);158      {159        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);160        expect(totalPieces.isSome).to.be.true;161        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);162      }163164      await transferExpectSuccess(collectionId, tokenId, bob, alice, 60n, createMode);165      {166        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);167        expect(totalPieces.isSome).to.be.true;168        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);169      }170171      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;172      expect(totalPieces.isSome).to.be.true;173      expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);174    });175  });176});177178describe('Negative integration test: ext. createItem():', () => {179  before(async () => {180    await usingApi(async (api, privateKeyWrapper) => {181      alice = privateKeyWrapper('//Alice');182      bob = privateKeyWrapper('//Bob');183    });184  });185186  it('Regular user cannot create new item in NFT collection', async () => {187    const createMode = 'NFT';188    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});189    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;190  });191  it('Regular user cannot create new item in Fungible collection', async () => {192    const createMode = 'Fungible';193    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});194    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;195  });196  it('Regular user cannot create new item in ReFungible collection', async () => {197    const createMode = 'ReFungible';198    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});199    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;200  });201202  it('No editing rights', async () => {203    await usingApi(async () => {204      const createMode = 'NFT';205      const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 206        propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});207      await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);208209      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);210    });211  });212213  it('User doesnt have editing rights', async () => {214    await usingApi(async () => {215      const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});216      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);217    });218  });219220  it('Adding property without access rights', async () => {221    await usingApi(async () => {222      const newCollectionID = await createCollectionWithPropsExpectSuccess();223      await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);224225      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);226    });227  });228229  it('Adding more than 64 prps', async () => {230    await usingApi(async () => {231      const prps = [];232233      for (let i = 0; i < 65; i++) {234        prps.push({key: `key${i}`, value: `value${i}`});235      }236237      const newCollectionID = await createCollectionWithPropsExpectSuccess();238      239      await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);240    });241  });242243  it('Trying to add bigger property than allowed', async () => {244    await usingApi(async () => {245      const newCollectionID = await createCollectionWithPropsExpectSuccess();246      247      await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);248    });249  });250251  it('Check total pieces for invalid Fungible token', async () => {252    await usingApi(async api => {253      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});254      const collectionId  = createCollectionResult.collectionId;255      const invalidTokenId = 1000_000;256      257      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;258      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.isNone).to.be.true;259    });260  });261262  it('Check total pieces for invalid NFT token', async () => {263    await usingApi(async api => {264      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'NFT'}});265      const collectionId  = createCollectionResult.collectionId;266      const invalidTokenId = 1000_000;267      268      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;269      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.isNone).to.be.true;270    });271  });272273  it('Check total pieces for invalid Refungible token', async () => {274    await usingApi(async api => {275      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});276      const collectionId  = createCollectionResult.collectionId;277      const invalidTokenId = 1000_000;278      279      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;280      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.isNone).to.be.true;281    });282  });283});
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 {default as usingApi} 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} from './util/helpers';3031const expect = chai.expect;32let alice: IKeyringPair;33let bob: IKeyringPair;3435describe('integration test: ext. ():', () => {36  before(async () => {37    await usingApi(async (api, privateKeyWrapper) => {38      alice = privateKeyWrapper('//Alice');39      bob = privateKeyWrapper('//Bob');40    });41  });4243  it('Create new item in NFT collection', async () => {44    const createMode = 'NFT';45    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});46    await createItemExpectSuccess(alice, newCollectionID, createMode);47  });48  it('Create new item in Fungible collection', async () => {49    const createMode = 'Fungible';50    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});51    await createItemExpectSuccess(alice, newCollectionID, createMode);52  });53  it('Create new item in ReFungible collection', async () => {54    const createMode = 'ReFungible';55    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});56    await createItemExpectSuccess(alice, newCollectionID, createMode);57  });58  it('Create new item in NFT collection with collection admin permissions', async () => {59    const createMode = 'NFT';60    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});61    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);62    await createItemExpectSuccess(bob, newCollectionID, createMode);63  });64  it('Create new item in Fungible collection with collection admin permissions', async () => {65    const createMode = 'Fungible';66    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});67    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);68    await createItemExpectSuccess(bob, newCollectionID, createMode);69  });70  it('Create new item in ReFungible collection with collection admin permissions', async () => {71    const createMode = 'ReFungible';72    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});73    await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);74    await createItemExpectSuccess(bob, newCollectionID, createMode);75  });7677  it('Set property Admin', async () => {78    const createMode = 'NFT';79    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 80      propPerm:   [{key: 'k', permission: {mutable: true, collectionAdmin: true, tokenOwner: false}}]});81    82    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'k', value: 't2'}]);83  });8485  it('Set property AdminConst', async () => {86    const createMode = 'NFT';87    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 88      propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: true, tokenOwner: false}}]});89    90    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);91  });9293  it('Set property itemOwnerOrAdmin', async () => {94    const createMode = 'NFT';95    const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode},96      propPerm:   [{key: 'key1', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}}]});97    98    await createItemWithPropsExpectSuccess(alice, newCollectionID, createMode, [{key: 'key1', value: 'val1'}]);99  });100101  it('Check total pieces of Fungible token', async () => {102    await usingApi(async api => {103      const createMode = 'Fungible';104      const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});105      const amountPieces = 10n;106      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);107      {108        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);109        expect(totalPieces.isSome).to.be.true;110        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);111      }112113      await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);114      {115        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);116        expect(totalPieces.isSome).to.be.true;117        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);118      }119120      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;121      expect(totalPieces.toBigInt()).to.be.eq(amountPieces);122    });123  });124125  it('Check total pieces of NFT token', async () => {126    await usingApi(async api => {127      const createMode = 'NFT';128      const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});129      const amountPieces = 1n;130      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);131      {132        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);133        expect(totalPieces.isSome).to.be.true;134        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);135      }136137      await transferExpectSuccess(collectionId, tokenId, bob, alice, 1, createMode);138      {139        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);140        expect(totalPieces.isSome).to.be.true;141        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);142      }143144      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;145      expect(totalPieces.toBigInt()).to.be.eq(amountPieces);146    });147  });148149  it('Check total pieces of ReFungible token', async () => {150    await usingApi(async api => {151      const createMode = 'ReFungible';152      const createCollectionResult = await createCollection(api, alice, {mode: {type: createMode}});153      const collectionId  = createCollectionResult.collectionId;154      const amountPieces = 100n;155      const tokenId = await createItemExpectSuccess(alice, collectionId, createMode, bob.address);156      {157        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);158        expect(totalPieces.isSome).to.be.true;159        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);160      }161162      await transferExpectSuccess(collectionId, tokenId, bob, alice, 60n, createMode);163      {164        const totalPieces = await api.rpc.unique.totalPieces(collectionId, tokenId);165        expect(totalPieces.isSome).to.be.true;166        expect(totalPieces.unwrap().toBigInt()).to.be.eq(amountPieces);167      }168169      const totalPieces = (await api.rpc.unique.tokenData(collectionId, tokenId, [])).pieces;170      expect(totalPieces.toBigInt()).to.be.eq(amountPieces);171    });172  });173});174175describe('Negative integration test: ext. createItem():', () => {176  before(async () => {177    await usingApi(async (api, privateKeyWrapper) => {178      alice = privateKeyWrapper('//Alice');179      bob = privateKeyWrapper('//Bob');180    });181  });182183  it('Regular user cannot create new item in NFT collection', async () => {184    const createMode = 'NFT';185    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});186    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;187  });188  it('Regular user cannot create new item in Fungible collection', async () => {189    const createMode = 'Fungible';190    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});191    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;192  });193  it('Regular user cannot create new item in ReFungible collection', async () => {194    const createMode = 'ReFungible';195    const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});196    await expect(createItemExpectSuccess(bob, newCollectionID, createMode)).to.be.rejected;197  });198199  it('No editing rights', async () => {200    await usingApi(async () => {201      const createMode = 'NFT';202      const newCollectionID = await createCollectionWithPropsExpectSuccess({mode: {type: createMode}, 203        propPerm:   [{key: 'key1', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}]});204      await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);205206      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);207    });208  });209210  it('User doesnt have editing rights', async () => {211    await usingApi(async () => {212      const newCollectionID = await createCollectionWithPropsExpectSuccess({propPerm: [{key: 'key1', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}]});213      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'key1', value: 'v'}]);214    });215  });216217  it('Adding property without access rights', async () => {218    await usingApi(async () => {219      const newCollectionID = await createCollectionWithPropsExpectSuccess();220      await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);221222      await createItemWithPropsExpectFailure(bob, newCollectionID, 'NFT', [{key: 'k', value: 'v'}]);223    });224  });225226  it('Adding more than 64 prps', async () => {227    await usingApi(async () => {228      const prps = [];229230      for (let i = 0; i < 65; i++) {231        prps.push({key: `key${i}`, value: `value${i}`});232      }233234      const newCollectionID = await createCollectionWithPropsExpectSuccess();235      236      await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', prps);237    });238  });239240  it('Trying to add bigger property than allowed', async () => {241    await usingApi(async () => {242      const newCollectionID = await createCollectionWithPropsExpectSuccess();243      244      await createItemWithPropsExpectFailure(alice, newCollectionID, 'NFT', [{key: 'k', value: 'vvvvvv'.repeat(5000)}, {key: 'k2', value: 'vvv'.repeat(5000)}]);245    });246  });247248  it('Check total pieces for invalid Fungible token', async () => {249    await usingApi(async api => {250      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'Fungible', decimalPoints: 0}});251      const collectionId  = createCollectionResult.collectionId;252      const invalidTokenId = 1000_000;253      254      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;255      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);256    });257  });258259  it('Check total pieces for invalid NFT token', async () => {260    await usingApi(async api => {261      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'NFT'}});262      const collectionId  = createCollectionResult.collectionId;263      const invalidTokenId = 1000_000;264      265      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;266      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);267    });268  });269270  it('Check total pieces for invalid Refungible token', async () => {271    await usingApi(async api => {272      const createCollectionResult = await createCollection(api, alice, {mode: {type: 'ReFungible'}});273      const collectionId  = createCollectionResult.collectionId;274      const invalidTokenId = 1000_000;275      276      expect((await api.rpc.unique.totalPieces(collectionId, invalidTokenId)).isNone).to.be.true;277      expect((await api.rpc.unique.tokenData(collectionId, invalidTokenId, [])).pieces.toBigInt()).to.be.eq(0n);278    });279  });280});
modifiedtests/src/interfaces/augment-api-events.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-events.ts
+++ b/tests/src/interfaces/augment-api-events.ts
@@ -13,45 +13,45 @@
       /**
        * A balance was set by root.
        **/
-      BalanceSet: AugmentedEvent<ApiType, [AccountId32, u128, u128]>;
+      BalanceSet: AugmentedEvent<ApiType, [who: AccountId32, free: u128, reserved: u128], { who: AccountId32, free: u128, reserved: u128 }>;
       /**
        * Some amount was deposited (e.g. for transaction fees).
        **/
-      Deposit: AugmentedEvent<ApiType, [AccountId32, u128]>;
+      Deposit: AugmentedEvent<ApiType, [who: AccountId32, amount: u128], { who: AccountId32, amount: u128 }>;
       /**
        * An account was removed whose balance was non-zero but below ExistentialDeposit,
        * resulting in an outright loss.
        **/
-      DustLost: AugmentedEvent<ApiType, [AccountId32, u128]>;
+      DustLost: AugmentedEvent<ApiType, [account: AccountId32, amount: u128], { account: AccountId32, amount: u128 }>;
       /**
        * An account was created with some free balance.
        **/
-      Endowed: AugmentedEvent<ApiType, [AccountId32, u128]>;
+      Endowed: AugmentedEvent<ApiType, [account: AccountId32, freeBalance: u128], { account: AccountId32, freeBalance: u128 }>;
       /**
        * Some balance was reserved (moved from free to reserved).
        **/
-      Reserved: AugmentedEvent<ApiType, [AccountId32, u128]>;
+      Reserved: AugmentedEvent<ApiType, [who: AccountId32, amount: u128], { who: AccountId32, amount: u128 }>;
       /**
        * Some balance was moved from the reserve of the first account to the second account.
        * Final argument indicates the destination balance type.
        **/
-      ReserveRepatriated: AugmentedEvent<ApiType, [AccountId32, AccountId32, u128, FrameSupportTokensMiscBalanceStatus]>;
+      ReserveRepatriated: AugmentedEvent<ApiType, [from: AccountId32, to: AccountId32, amount: u128, destinationStatus: FrameSupportTokensMiscBalanceStatus], { from: AccountId32, to: AccountId32, amount: u128, destinationStatus: FrameSupportTokensMiscBalanceStatus }>;
       /**
        * Some amount was removed from the account (e.g. for misbehavior).
        **/
-      Slashed: AugmentedEvent<ApiType, [AccountId32, u128]>;
+      Slashed: AugmentedEvent<ApiType, [who: AccountId32, amount: u128], { who: AccountId32, amount: u128 }>;
       /**
        * Transfer succeeded.
        **/
-      Transfer: AugmentedEvent<ApiType, [AccountId32, AccountId32, u128]>;
+      Transfer: AugmentedEvent<ApiType, [from: AccountId32, to: AccountId32, amount: u128], { from: AccountId32, to: AccountId32, amount: u128 }>;
       /**
        * Some balance was unreserved (moved from reserved to free).
        **/
-      Unreserved: AugmentedEvent<ApiType, [AccountId32, u128]>;
+      Unreserved: AugmentedEvent<ApiType, [who: AccountId32, amount: u128], { who: AccountId32, amount: u128 }>;
       /**
        * Some amount was withdrawn from the account (e.g. for transaction fees).
        **/
-      Withdraw: AugmentedEvent<ApiType, [AccountId32, u128]>;
+      Withdraw: AugmentedEvent<ApiType, [who: AccountId32, amount: u128], { who: AccountId32, amount: u128 }>;
       /**
        * Generic event
        **/
@@ -167,27 +167,27 @@
       /**
        * Downward message executed with the given outcome.
        **/
-      ExecutedDownward: AugmentedEvent<ApiType, [U8aFixed, XcmV2TraitsOutcome]>;
+      ExecutedDownward: AugmentedEvent<ApiType, [messageId: U8aFixed, outcome: XcmV2TraitsOutcome], { messageId: U8aFixed, outcome: XcmV2TraitsOutcome }>;
       /**
        * Downward message is invalid XCM.
        **/
-      InvalidFormat: AugmentedEvent<ApiType, [U8aFixed]>;
+      InvalidFormat: AugmentedEvent<ApiType, [messageId: U8aFixed], { messageId: U8aFixed }>;
       /**
        * Downward message is overweight and was placed in the overweight queue.
        **/
-      OverweightEnqueued: AugmentedEvent<ApiType, [U8aFixed, u64, u64]>;
+      OverweightEnqueued: AugmentedEvent<ApiType, [messageId: U8aFixed, overweightIndex: u64, requiredWeight: u64], { messageId: U8aFixed, overweightIndex: u64, requiredWeight: u64 }>;
       /**
        * Downward message from the overweight queue was executed.
        **/
-      OverweightServiced: AugmentedEvent<ApiType, [u64, u64]>;
+      OverweightServiced: AugmentedEvent<ApiType, [overweightIndex: u64, weightUsed: u64], { overweightIndex: u64, weightUsed: u64 }>;
       /**
        * Downward message is unsupported version of XCM.
        **/
-      UnsupportedVersion: AugmentedEvent<ApiType, [U8aFixed]>;
+      UnsupportedVersion: AugmentedEvent<ApiType, [messageId: U8aFixed], { messageId: U8aFixed }>;
       /**
        * The weight limit for handling downward messages was reached.
        **/
-      WeightExhausted: AugmentedEvent<ApiType, [U8aFixed, u64, u64]>;
+      WeightExhausted: AugmentedEvent<ApiType, [messageId: U8aFixed, remainingWeight: u64, requiredWeight: u64], { messageId: U8aFixed, remainingWeight: u64, requiredWeight: u64 }>;
       /**
        * Generic event
        **/
@@ -241,19 +241,19 @@
       /**
        * Downward messages were processed using the given weight.
        **/
-      DownwardMessagesProcessed: AugmentedEvent<ApiType, [u64, H256]>;
+      DownwardMessagesProcessed: AugmentedEvent<ApiType, [weightUsed: u64, dmqHead: H256], { weightUsed: u64, dmqHead: H256 }>;
       /**
        * Some downward messages have been received and will be processed.
        **/
-      DownwardMessagesReceived: AugmentedEvent<ApiType, [u32]>;
+      DownwardMessagesReceived: AugmentedEvent<ApiType, [count: u32], { count: u32 }>;
       /**
        * An upgrade has been authorized.
        **/
-      UpgradeAuthorized: AugmentedEvent<ApiType, [H256]>;
+      UpgradeAuthorized: AugmentedEvent<ApiType, [codeHash: H256], { codeHash: H256 }>;
       /**
        * The validation function was applied as of the contained relay chain block number.
        **/
-      ValidationFunctionApplied: AugmentedEvent<ApiType, [u32]>;
+      ValidationFunctionApplied: AugmentedEvent<ApiType, [relayChainBlockNum: u32], { relayChainBlockNum: u32 }>;
       /**
        * The relay-chain aborted the upgrade process.
        **/
@@ -390,29 +390,29 @@
       [key: string]: AugmentedEvent<ApiType>;
     };
     rmrkCore: {
-      CollectionCreated: AugmentedEvent<ApiType, [AccountId32, u32]>;
-      CollectionDestroyed: AugmentedEvent<ApiType, [AccountId32, u32]>;
-      CollectionLocked: AugmentedEvent<ApiType, [AccountId32, u32]>;
-      IssuerChanged: AugmentedEvent<ApiType, [AccountId32, AccountId32, u32]>;
-      NFTAccepted: AugmentedEvent<ApiType, [AccountId32, RmrkTraitsNftAccountIdOrCollectionNftTuple, u32, u32]>;
-      NFTBurned: AugmentedEvent<ApiType, [AccountId32, u32]>;
-      NftMinted: AugmentedEvent<ApiType, [AccountId32, u32, u32]>;
-      NFTRejected: AugmentedEvent<ApiType, [AccountId32, u32, u32]>;
-      NFTSent: AugmentedEvent<ApiType, [AccountId32, RmrkTraitsNftAccountIdOrCollectionNftTuple, u32, u32, bool]>;
-      PrioritySet: AugmentedEvent<ApiType, [u32, u32]>;
-      PropertySet: AugmentedEvent<ApiType, [u32, Option<u32>, Bytes, Bytes]>;
-      ResourceAccepted: AugmentedEvent<ApiType, [u32, u32]>;
-      ResourceAdded: AugmentedEvent<ApiType, [u32, u32]>;
-      ResourceRemoval: AugmentedEvent<ApiType, [u32, u32]>;
-      ResourceRemovalAccepted: AugmentedEvent<ApiType, [u32, u32]>;
+      CollectionCreated: AugmentedEvent<ApiType, [issuer: AccountId32, collectionId: u32], { issuer: AccountId32, collectionId: u32 }>;
+      CollectionDestroyed: AugmentedEvent<ApiType, [issuer: AccountId32, collectionId: u32], { issuer: AccountId32, collectionId: u32 }>;
+      CollectionLocked: AugmentedEvent<ApiType, [issuer: AccountId32, collectionId: u32], { issuer: AccountId32, collectionId: u32 }>;
+      IssuerChanged: AugmentedEvent<ApiType, [oldIssuer: AccountId32, newIssuer: AccountId32, collectionId: u32], { oldIssuer: AccountId32, newIssuer: AccountId32, collectionId: u32 }>;
+      NFTAccepted: AugmentedEvent<ApiType, [sender: AccountId32, recipient: RmrkTraitsNftAccountIdOrCollectionNftTuple, collectionId: u32, nftId: u32], { sender: AccountId32, recipient: RmrkTraitsNftAccountIdOrCollectionNftTuple, collectionId: u32, nftId: u32 }>;
+      NFTBurned: AugmentedEvent<ApiType, [owner: AccountId32, nftId: u32], { owner: AccountId32, nftId: u32 }>;
+      NftMinted: AugmentedEvent<ApiType, [owner: AccountId32, collectionId: u32, nftId: u32], { owner: AccountId32, collectionId: u32, nftId: u32 }>;
+      NFTRejected: AugmentedEvent<ApiType, [sender: AccountId32, collectionId: u32, nftId: u32], { sender: AccountId32, collectionId: u32, nftId: u32 }>;
+      NFTSent: AugmentedEvent<ApiType, [sender: AccountId32, recipient: RmrkTraitsNftAccountIdOrCollectionNftTuple, collectionId: u32, nftId: u32, approvalRequired: bool], { sender: AccountId32, recipient: RmrkTraitsNftAccountIdOrCollectionNftTuple, collectionId: u32, nftId: u32, approvalRequired: bool }>;
+      PrioritySet: AugmentedEvent<ApiType, [collectionId: u32, nftId: u32], { collectionId: u32, nftId: u32 }>;
+      PropertySet: AugmentedEvent<ApiType, [collectionId: u32, maybeNftId: Option<u32>, key: Bytes, value: Bytes], { collectionId: u32, maybeNftId: Option<u32>, key: Bytes, value: Bytes }>;
+      ResourceAccepted: AugmentedEvent<ApiType, [nftId: u32, resourceId: u32], { nftId: u32, resourceId: u32 }>;
+      ResourceAdded: AugmentedEvent<ApiType, [nftId: u32, resourceId: u32], { nftId: u32, resourceId: u32 }>;
+      ResourceRemoval: AugmentedEvent<ApiType, [nftId: u32, resourceId: u32], { nftId: u32, resourceId: u32 }>;
+      ResourceRemovalAccepted: AugmentedEvent<ApiType, [nftId: u32, resourceId: u32], { nftId: u32, resourceId: u32 }>;
       /**
        * Generic event
        **/
       [key: string]: AugmentedEvent<ApiType>;
     };
     rmrkEquip: {
-      BaseCreated: AugmentedEvent<ApiType, [AccountId32, u32]>;
-      EquippablesUpdated: AugmentedEvent<ApiType, [u32, u32]>;
+      BaseCreated: AugmentedEvent<ApiType, [issuer: AccountId32, baseId: u32], { issuer: AccountId32, baseId: u32 }>;
+      EquippablesUpdated: AugmentedEvent<ApiType, [baseId: u32, slotId: u32], { baseId: u32, slotId: u32 }>;
       /**
        * Generic event
        **/
@@ -422,19 +422,19 @@
       /**
        * The call for the provided hash was not found so the task has been aborted.
        **/
-      CallLookupFailed: AugmentedEvent<ApiType, [ITuple<[u32, u32]>, Option<U8aFixed>, FrameSupportScheduleLookupError]>;
+      CallLookupFailed: AugmentedEvent<ApiType, [task: ITuple<[u32, u32]>, id: Option<U8aFixed>, error: FrameSupportScheduleLookupError], { task: ITuple<[u32, u32]>, id: Option<U8aFixed>, error: FrameSupportScheduleLookupError }>;
       /**
        * Canceled some task.
        **/
-      Canceled: AugmentedEvent<ApiType, [u32, u32]>;
+      Canceled: AugmentedEvent<ApiType, [when: u32, index: u32], { when: u32, index: u32 }>;
       /**
        * Dispatched some task.
        **/
-      Dispatched: AugmentedEvent<ApiType, [ITuple<[u32, u32]>, Option<U8aFixed>, Result<Null, SpRuntimeDispatchError>]>;
+      Dispatched: AugmentedEvent<ApiType, [task: ITuple<[u32, u32]>, id: Option<U8aFixed>, result: Result<Null, SpRuntimeDispatchError>], { task: ITuple<[u32, u32]>, id: Option<U8aFixed>, result: Result<Null, SpRuntimeDispatchError> }>;
       /**
        * Scheduled some task.
        **/
-      Scheduled: AugmentedEvent<ApiType, [u32, u32]>;
+      Scheduled: AugmentedEvent<ApiType, [when: u32, index: u32], { when: u32, index: u32 }>;
       /**
        * Generic event
        **/
@@ -454,15 +454,15 @@
       /**
        * The \[sudoer\] just switched identity; the old key is supplied if one existed.
        **/
-      KeyChanged: AugmentedEvent<ApiType, [Option<AccountId32>]>;
+      KeyChanged: AugmentedEvent<ApiType, [oldSudoer: Option<AccountId32>], { oldSudoer: Option<AccountId32> }>;
       /**
        * A sudo just took place. \[result\]
        **/
-      Sudid: AugmentedEvent<ApiType, [Result<Null, SpRuntimeDispatchError>]>;
+      Sudid: AugmentedEvent<ApiType, [sudoResult: Result<Null, SpRuntimeDispatchError>], { sudoResult: Result<Null, SpRuntimeDispatchError> }>;
       /**
        * A sudo just took place. \[result\]
        **/
-      SudoAsDone: AugmentedEvent<ApiType, [Result<Null, SpRuntimeDispatchError>]>;
+      SudoAsDone: AugmentedEvent<ApiType, [sudoResult: Result<Null, SpRuntimeDispatchError>], { sudoResult: Result<Null, SpRuntimeDispatchError> }>;
       /**
        * Generic event
        **/
@@ -476,23 +476,23 @@
       /**
        * An extrinsic failed.
        **/
-      ExtrinsicFailed: AugmentedEvent<ApiType, [SpRuntimeDispatchError, FrameSupportWeightsDispatchInfo]>;
+      ExtrinsicFailed: AugmentedEvent<ApiType, [dispatchError: SpRuntimeDispatchError, dispatchInfo: FrameSupportWeightsDispatchInfo], { dispatchError: SpRuntimeDispatchError, dispatchInfo: FrameSupportWeightsDispatchInfo }>;
       /**
        * An extrinsic completed successfully.
        **/
-      ExtrinsicSuccess: AugmentedEvent<ApiType, [FrameSupportWeightsDispatchInfo]>;
+      ExtrinsicSuccess: AugmentedEvent<ApiType, [dispatchInfo: FrameSupportWeightsDispatchInfo], { dispatchInfo: FrameSupportWeightsDispatchInfo }>;
       /**
        * An account was reaped.
        **/
-      KilledAccount: AugmentedEvent<ApiType, [AccountId32]>;
+      KilledAccount: AugmentedEvent<ApiType, [account: AccountId32], { account: AccountId32 }>;
       /**
        * A new account was created.
        **/
-      NewAccount: AugmentedEvent<ApiType, [AccountId32]>;
+      NewAccount: AugmentedEvent<ApiType, [account: AccountId32], { account: AccountId32 }>;
       /**
        * On on-chain remark happened.
        **/
-      Remarked: AugmentedEvent<ApiType, [AccountId32, H256]>;
+      Remarked: AugmentedEvent<ApiType, [sender: AccountId32, hash_: H256], { sender: AccountId32, hash_: H256 }>;
       /**
        * Generic event
        **/
@@ -502,31 +502,31 @@
       /**
        * Some funds have been allocated.
        **/
-      Awarded: AugmentedEvent<ApiType, [u32, u128, AccountId32]>;
+      Awarded: AugmentedEvent<ApiType, [proposalIndex: u32, award: u128, account: AccountId32], { proposalIndex: u32, award: u128, account: AccountId32 }>;
       /**
        * Some of our funds have been burnt.
        **/
-      Burnt: AugmentedEvent<ApiType, [u128]>;
+      Burnt: AugmentedEvent<ApiType, [burntFunds: u128], { burntFunds: u128 }>;
       /**
        * Some funds have been deposited.
        **/
-      Deposit: AugmentedEvent<ApiType, [u128]>;
+      Deposit: AugmentedEvent<ApiType, [value: u128], { value: u128 }>;
       /**
        * New proposal.
        **/
-      Proposed: AugmentedEvent<ApiType, [u32]>;
+      Proposed: AugmentedEvent<ApiType, [proposalIndex: u32], { proposalIndex: u32 }>;
       /**
        * A proposal was rejected; funds were slashed.
        **/
-      Rejected: AugmentedEvent<ApiType, [u32, u128]>;
+      Rejected: AugmentedEvent<ApiType, [proposalIndex: u32, slashed: u128], { proposalIndex: u32, slashed: u128 }>;
       /**
        * Spending has finished; this is the amount that rolls over until next spend.
        **/
-      Rollover: AugmentedEvent<ApiType, [u128]>;
+      Rollover: AugmentedEvent<ApiType, [rolloverBalance: u128], { rolloverBalance: u128 }>;
       /**
        * We have ended a spend period and will now allocate funds.
        **/
-      Spending: AugmentedEvent<ApiType, [u128]>;
+      Spending: AugmentedEvent<ApiType, [budgetRemaining: u128], { budgetRemaining: u128 }>;
       /**
        * Generic event
        **/
@@ -629,15 +629,15 @@
       /**
        * Claimed vesting.
        **/
-      Claimed: AugmentedEvent<ApiType, [AccountId32, u128]>;
+      Claimed: AugmentedEvent<ApiType, [who: AccountId32, amount: u128], { who: AccountId32, amount: u128 }>;
       /**
        * Added new vesting schedule.
        **/
-      VestingScheduleAdded: AugmentedEvent<ApiType, [AccountId32, AccountId32, OrmlVestingVestingSchedule]>;
+      VestingScheduleAdded: AugmentedEvent<ApiType, [from: AccountId32, to: AccountId32, vestingSchedule: OrmlVestingVestingSchedule], { from: AccountId32, to: AccountId32, vestingSchedule: OrmlVestingVestingSchedule }>;
       /**
        * Updated vesting schedules.
        **/
-      VestingSchedulesUpdated: AugmentedEvent<ApiType, [AccountId32]>;
+      VestingSchedulesUpdated: AugmentedEvent<ApiType, [who: AccountId32], { who: AccountId32 }>;
       /**
        * Generic event
        **/
modifiedtests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth
--- a/tests/src/interfaces/augment-api-rpc.ts
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -717,6 +717,10 @@
        **/
       topmostTokenOwner: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<PalletEvmAccountBasicCrossAccountIdRepr>>>;
       /**
+       * Get total pieces of token
+       **/
+      totalPieces: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, tokenId: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Option<u128>>>;
+      /**
        * Get amount of unique collection tokens
        **/
       totalSupply: AugmentedRpc<(collection: u32 | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u32>>;
modifiedtests/src/interfaces/default/types.tsdiffbeforeafterboth
--- a/tests/src/interfaces/default/types.ts
+++ b/tests/src/interfaces/default/types.ts
@@ -2561,6 +2561,7 @@
 export interface UpDataStructsTokenData extends Struct {
   readonly properties: Vec<UpDataStructsProperty>;
   readonly owner: Option<PalletEvmAccountBasicCrossAccountIdRepr>;
+  readonly pieces: u128;
 }
 
 /** @name XcmDoubleEncoded */
modifiedtests/src/interfaces/lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/lookup.ts
+++ b/tests/src/interfaces/lookup.ts
@@ -2859,7 +2859,8 @@
    **/
   UpDataStructsTokenData: {
     properties: 'Vec<UpDataStructsProperty>',
-    owner: 'Option<PalletEvmAccountBasicCrossAccountIdRepr>'
+    owner: 'Option<PalletEvmAccountBasicCrossAccountIdRepr>',
+    pieces: 'u128'
   },
   /**
    * Lookup376: up_data_structs::RpcCollection<sp_core::crypto::AccountId32>
modifiedtests/src/interfaces/types-lookup.tsdiffbeforeafterboth
--- a/tests/src/interfaces/types-lookup.ts
+++ b/tests/src/interfaces/types-lookup.ts
@@ -2977,6 +2977,7 @@
   export interface UpDataStructsTokenData extends Struct {
     readonly properties: Vec<UpDataStructsProperty>;
     readonly owner: Option<PalletEvmAccountBasicCrossAccountIdRepr>;
+    readonly pieces: u128;
   }
 
   /** @name UpDataStructsRpcCollection (376) */