git.delta.rocks / unique-network / refs/commits / 3069e4dc18ce

difftreelog

add helpers & fix replace mistakes

rkv2022-09-20parent: #bc53a7e.patch.diff
in: master

6 files changed

modifiedtests/src/allowLists.test.tsdiffbeforeafterboth
before · tests/src/allowLists.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 itSub and/or modify5// itSub 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 itSub 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 {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, itSub} from './util/playgrounds';1920describe('Integration Test ext. Allow list tests', () => {21  let alice: IKeyringPair;22  let bob: IKeyringPair;23  let charlie: IKeyringPair;2425  before(async () => {26    await usingPlaygrounds(async (helper, privateKey) => {27      const donor = privateKey('//Alice');28      [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);29    });30  });3132  itSub('Owner can add address to allow list', async ({helper}) => {33    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});34    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});35    const allowList = await helper.nft.getAllowList(collectionId);36    expect(allowList).to.be.deep.contains({Substrate: bob.address});37  });3839  itSub('Admin can add address to allow list', async ({helper}) => {40    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});41    await helper.nft.addAdmin(alice, collectionId, {Substrate: bob.address});4243    await helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address});44    const allowList = await helper.nft.getAllowList(collectionId);45    expect(allowList).to.be.deep.contains({Substrate: charlie.address});46  });4748  itSub('Non-privileged user cannot add address to allow list', async ({helper}) => {49    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});50    const addToAllowListTx = async () => helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address});51    await expect(addToAllowListTx()).to.be.rejectedWith(/common\.NoPermission/);52  });5354  itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {55    const collectionId = (1<<32) - 1;56    const addToAllowListTx = async () => helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address});57    await expect(addToAllowListTx()).to.be.rejectedWith(/common\.CollectionNotFound/);58  });5960  itSub('Nobody can add address to allow list of destroyed collection', async ({helper}) => {61    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});62    await helper.collection.burn(alice, collectionId);63    const addToAllowListTx = async () => helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});64    await expect(addToAllowListTx()).to.be.rejectedWith(/common\.CollectionNotFound/);65  });6667  itSub('If address is already added to allow list, nothing happens', async ({helper}) => {68    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});69    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});70    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});71    const allowList = await helper.nft.getAllowList(collectionId);72    expect(allowList).to.be.deep.contains({Substrate: bob.address});73  });7475  itSub('Owner can remove address from allow list', async ({helper}) => {76    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});77    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});7879    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});8081    const allowList = await helper.nft.getAllowList(collectionId);8283    expect(allowList).to.be.not.deep.contains({Substrate: bob.address});84  });8586  itSub('Admin can remove address from allow list', async ({helper}) => {87    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});88    await helper.nft.addAdmin(alice, collectionId, {Substrate: charlie.address});89    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});90    await helper.collection.removeFromAllowList(charlie, collectionId, {Substrate: bob.address});9192    const allowList = await helper.nft.getAllowList(collectionId);9394    expect(allowList).to.be.not.deep.contains({Substrate: bob.address});95  });9697  itSub('Non-privileged user cannot remove address from allow list', async ({helper}) => {98    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});99    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});100    const removeTx = async () => helper.collection.removeFromAllowList(bob, collectionId, {Substrate: charlie.address});101    await expect(removeTx()).to.be.rejectedWith(/common\.NoPermission/);102    const allowList = await helper.nft.getAllowList(collectionId);103104    expect(allowList).to.be.deep.contains({Substrate: charlie.address});105  });106107  itSub('Nobody can remove address from allow list of non-existing collection', async ({helper}) => {108    const collectionId = (1<<32) - 1;109    const removeTx = async () => helper.collection.removeFromAllowList(bob, collectionId, {Substrate: charlie.address});110    await expect(removeTx()).to.be.rejectedWith(/common\.CollectionNotFound/);111  });112113  itSub('Nobody can remove address from allow list of deleted collection', async ({helper}) => {114    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});115    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});116    await helper.collection.burn(alice, collectionId);117    const removeTx = async () => helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});118119    await expect(removeTx()).to.be.rejectedWith(/common\.CollectionNotFound/);120  });121122  itSub('If address is already removed from allow list, nothing happens', async ({helper}) => {123    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});124    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});125    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});126    const allowListBefore = await helper.nft.getAllowList(collectionId);127    expect(allowListBefore).to.be.not.deep.contains({Substrate: bob.address});128129    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});130131    const allowListAfter = await helper.nft.getAllowList(collectionId);132    expect(allowListAfter).to.be.not.deep.contains({Substrate: bob.address});133  });134135  itSub('If Public Access mode is set to AllowList, tokens can’t be transferred from a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {136    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});137    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});138    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});139    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});140141    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});142    await expect(transferResult()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);143  });144145  itSub('If Public Access mode is set to AllowList, tokens can’t be transferred from a non-allowlisted address with transfer or transferFrom. Test2', async ({helper}) => {146    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});147    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});148    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});149    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});150    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});151    await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});152    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: alice.address});153154    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});155    await expect(transferResult()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);156  });157158  itSub('If Public Access mode is set to AllowList, tokens can’t be transferred to a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {159    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});160    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});161    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});162    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});163164    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});165    await expect(transferResult()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);166  });167168  itSub('If Public Access mode is set to AllowList, tokens can’t be transferred to a non-allowlisted address with transfer or transferFrom. Test2', async ({helper}) => {169    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});170    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});171    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});172    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});173    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});174175    await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});176    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: alice.address});177178    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});179    await expect(transferResult()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);180  });181182  itSub('If Public Access mode is set to AllowList, tokens can’t be destroyed by a non-allowlisted address (even if itSub owned them before enabling AllowList mode)', async ({helper}) => {183    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});184    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});185    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});186    const burnTx = async () => helper.nft.burnToken(bob, collectionId, tokenId);187    await expect(burnTx()).to.be.rejectedWith(/common\.NoPermission/);188  });189190  itSub('If Public Access mode is set to AllowList, token transfers can’t be Approved by a non-allowlisted address (see Approve method)', async ({helper}) => {191    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});192    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});193    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});194    const approveTx = async () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});195    await expect(approveTx()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);196  });197198  itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer.', async ({helper}) => {199    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});200    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});201    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});202    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});203    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});204    await helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});205    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);206    expect(owner.Substrate).to.be.equal(charlie.address);207  });208209  itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transferFrom.', async ({helper}) => {210    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});211    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});212    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});213    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});214    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});215    await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});216217    await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address});218    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);219    expect(owner.Substrate).to.be.equal(charlie.address);220  });221222  itSub('If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transfer', async ({helper}) => {223    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});224    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});225    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});226    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});227    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});228229    await helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});230    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);231    expect(owner.Substrate).to.be.equal(charlie.address);232  });233234  itSub('If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transferFrom', async ({helper}) => {235    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});236    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});237    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});238    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});239    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});240    await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});241242    await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address});243    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);244    expect(owner.Substrate).to.be.equal(charlie.address);245  });246247  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by owner', async ({helper}) => {248    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});249    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: false});250    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});251    const token = await helper.nft.getToken(collectionId, tokenId);252    expect(token).to.be.not.null;253  });254255  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by admin', async ({helper}) => {256    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});257    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: false});258    await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});259    const {tokenId} = await helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});260    const token = await helper.nft.getToken(collectionId, tokenId);261    expect(token).to.be.not.null;262  });263264  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and allow-listed address', async ({helper}) => {265    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});266    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: false});267    await helper.collection.addToAllowList(alice, collectionId, {Substrate: bob.address});268    const mintTokenTx = async () => helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});269    await expect(mintTokenTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);270  });271272  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-allow listed address', async ({helper}) => {273    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});274    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: false});275    const mintTokenTx = async () => helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});276    await expect(mintTokenTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);277  });278279  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by owner', async ({helper}) => {280    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});281    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true});282    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});283    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);284    expect(owner.Substrate).to.be.equal(alice.address);285  });286287  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by admin', async ({helper}) => {288    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});289    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true});290    await helper.nft.addAdmin(alice, collectionId, {Substrate: bob.address});291    const {tokenId} = await helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});292    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);293    expect(owner.Substrate).to.be.equal(bob.address);294  });295296  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-allow listed address', async ({helper}) => {297    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});298    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true});299    const mintTokenTx = async () => helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});300    await expect(mintTokenTx()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);301  });302303  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by non-privileged and allow listed address', async ({helper}) => {304    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});305    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true});306    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});307    const {tokenId} = await helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});308    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);309    expect(owner.Substrate).to.be.equal(bob.address);310  });311});
after · tests/src/allowLists.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 {IKeyringPair} from '@polkadot/types/types';18import {usingPlaygrounds, expect, itSub} from './util/playgrounds';1920describe('Integration Test ext. Allow list tests', () => {21  let alice: IKeyringPair;22  let bob: IKeyringPair;23  let charlie: IKeyringPair;2425  before(async () => {26    await usingPlaygrounds(async (helper, privateKey) => {27      const donor = privateKey('//Alice');28      [alice, bob, charlie] = await helper.arrange.createAccounts([100n, 100n, 100n], donor);29    });30  });3132  itSub('Owner can add address to allow list', async ({helper}) => {33    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});34    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});35    const allowList = await helper.nft.getAllowList(collectionId);36    expect(allowList).to.be.deep.contains({Substrate: bob.address});37  });3839  itSub('Admin can add address to allow list', async ({helper}) => {40    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});41    await helper.nft.addAdmin(alice, collectionId, {Substrate: bob.address});4243    await helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address});44    const allowList = await helper.nft.getAllowList(collectionId);45    expect(allowList).to.be.deep.contains({Substrate: charlie.address});46  });4748  itSub('Non-privileged user cannot add address to allow list', async ({helper}) => {49    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});50    const addToAllowListTx = async () => helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address});51    await expect(addToAllowListTx()).to.be.rejectedWith(/common\.NoPermission/);52  });5354  itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {55    const collectionId = (1<<32) - 1;56    const addToAllowListTx = async () => helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address});57    await expect(addToAllowListTx()).to.be.rejectedWith(/common\.CollectionNotFound/);58  });5960  itSub('Nobody can add address to allow list of destroyed collection', async ({helper}) => {61    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});62    await helper.collection.burn(alice, collectionId);63    const addToAllowListTx = async () => helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});64    await expect(addToAllowListTx()).to.be.rejectedWith(/common\.CollectionNotFound/);65  });6667  itSub('If address is already added to allow list, nothing happens', async ({helper}) => {68    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});69    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});70    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});71    const allowList = await helper.nft.getAllowList(collectionId);72    expect(allowList).to.be.deep.contains({Substrate: bob.address});73  });7475  itSub('Owner can remove address from allow list', async ({helper}) => {76    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});77    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});7879    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});8081    const allowList = await helper.nft.getAllowList(collectionId);8283    expect(allowList).to.be.not.deep.contains({Substrate: bob.address});84  });8586  itSub('Admin can remove address from allow list', async ({helper}) => {87    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});88    await helper.nft.addAdmin(alice, collectionId, {Substrate: charlie.address});89    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});90    await helper.collection.removeFromAllowList(charlie, collectionId, {Substrate: bob.address});9192    const allowList = await helper.nft.getAllowList(collectionId);9394    expect(allowList).to.be.not.deep.contains({Substrate: bob.address});95  });9697  itSub('Non-privileged user cannot remove address from allow list', async ({helper}) => {98    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});99    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});100    const removeTx = async () => helper.collection.removeFromAllowList(bob, collectionId, {Substrate: charlie.address});101    await expect(removeTx()).to.be.rejectedWith(/common\.NoPermission/);102    const allowList = await helper.nft.getAllowList(collectionId);103104    expect(allowList).to.be.deep.contains({Substrate: charlie.address});105  });106107  itSub('Nobody can remove address from allow list of non-existing collection', async ({helper}) => {108    const collectionId = (1<<32) - 1;109    const removeTx = async () => helper.collection.removeFromAllowList(bob, collectionId, {Substrate: charlie.address});110    await expect(removeTx()).to.be.rejectedWith(/common\.CollectionNotFound/);111  });112113  itSub('Nobody can remove address from allow list of deleted collection', async ({helper}) => {114    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});115    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});116    await helper.collection.burn(alice, collectionId);117    const removeTx = async () => helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});118119    await expect(removeTx()).to.be.rejectedWith(/common\.CollectionNotFound/);120  });121122  itSub('If address is already removed from allow list, nothing happens', async ({helper}) => {123    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});124    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});125    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});126    const allowListBefore = await helper.nft.getAllowList(collectionId);127    expect(allowListBefore).to.be.not.deep.contains({Substrate: bob.address});128129    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: bob.address});130131    const allowListAfter = await helper.nft.getAllowList(collectionId);132    expect(allowListAfter).to.be.not.deep.contains({Substrate: bob.address});133  });134135  itSub('If Public Access mode is set to AllowList, tokens can’t be transferred from a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {136    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});137    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});138    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});139    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});140141    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});142    await expect(transferResult()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);143  });144145  itSub('If Public Access mode is set to AllowList, tokens can’t be transferred from a non-allowlisted address with transfer or transferFrom. Test2', async ({helper}) => {146    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});147    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});148    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});149    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});150    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});151    await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});152    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: alice.address});153154    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});155    await expect(transferResult()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);156  });157158  itSub('If Public Access mode is set to AllowList, tokens can’t be transferred to a non-allowlisted address with transfer or transferFrom. Test1', async ({helper}) => {159    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});160    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});161    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});162    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});163164    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});165    await expect(transferResult()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);166  });167168  itSub('If Public Access mode is set to AllowList, tokens can’t be transferred to a non-allowlisted address with transfer or transferFrom. Test2', async ({helper}) => {169    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});170    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});171    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});172    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});173    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});174175    await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});176    await helper.collection.removeFromAllowList(alice, collectionId, {Substrate: alice.address});177178    const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});179    await expect(transferResult()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);180  });181182  itSub('If Public Access mode is set to AllowList, tokens can’t be destroyed by a non-allowlisted address (even if itSub owned them before enabling AllowList mode)', async ({helper}) => {183    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});184    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});185    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});186    const burnTx = async () => helper.nft.burnToken(bob, collectionId, tokenId);187    await expect(burnTx()).to.be.rejectedWith(/common\.NoPermission/);188  });189190  itSub('If Public Access mode is set to AllowList, token transfers can’t be Approved by a non-allowlisted address (see Approve method)', async ({helper}) => {191    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});192    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});193    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});194    const approveTx = async () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address});195    await expect(approveTx()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);196  });197198  itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer.', async ({helper}) => {199    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});200    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});201    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});202    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});203    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});204    await helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});205    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);206    expect(owner.Substrate).to.be.equal(charlie.address);207  });208209  itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transferFrom.', async ({helper}) => {210    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});211    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});212    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});213    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});214    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});215    await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});216217    await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address});218    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);219    expect(owner.Substrate).to.be.equal(charlie.address);220  });221222  itSub('If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transfer', async ({helper}) => {223    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});224    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});225    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});226    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});227    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});228229    await helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});230    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);231    expect(owner.Substrate).to.be.equal(charlie.address);232  });233234  itSub('If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transferFrom', async ({helper}) => {235    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});236    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});237    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList'});238    await helper.nft.addToAllowList(alice, collectionId, {Substrate: alice.address});239    await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});240    await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});241242    await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: alice.address}, {Substrate: charlie.address});243    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);244    expect(owner.Substrate).to.be.equal(charlie.address);245  });246247  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by owner', async ({helper}) => {248    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});249    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: false});250    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});251    const token = await helper.nft.getToken(collectionId, tokenId);252    expect(token).to.be.not.null;253  });254255  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by admin', async ({helper}) => {256    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});257    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: false});258    await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});259    const {tokenId} = await helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});260    const token = await helper.nft.getToken(collectionId, tokenId);261    expect(token).to.be.not.null;262  });263264  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and allow-listed address', async ({helper}) => {265    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});266    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: false});267    await helper.collection.addToAllowList(alice, collectionId, {Substrate: bob.address});268    const mintTokenTx = async () => helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});269    await expect(mintTokenTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);270  });271272  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-allow listed address', async ({helper}) => {273    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});274    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: false});275    const mintTokenTx = async () => helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});276    await expect(mintTokenTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);277  });278279  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by owner', async ({helper}) => {280    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});281    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true});282    const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});283    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);284    expect(owner.Substrate).to.be.equal(alice.address);285  });286287  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by admin', async ({helper}) => {288    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});289    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true});290    await helper.nft.addAdmin(alice, collectionId, {Substrate: bob.address});291    const {tokenId} = await helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});292    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);293    expect(owner.Substrate).to.be.equal(bob.address);294  });295296  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-allow listed address', async ({helper}) => {297    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});298    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true});299    const mintTokenTx = async () => helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});300    await expect(mintTokenTx()).to.be.rejectedWith(/common\.AddressNotInAllowlist/);301  });302303  itSub('If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by non-privileged and allow listed address', async ({helper}) => {304    const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});305    await helper.nft.setPermissions(alice, collectionId, {access: 'AllowList', mintMode: true});306    await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});307    const {tokenId} = await helper.nft.mintToken(bob, {collectionId: collectionId, owner: bob.address});308    const owner = await helper.nft.getTokenOwner(collectionId, tokenId);309    expect(owner.Substrate).to.be.equal(bob.address);310  });311});
modifiedtests/src/change-collection-owner.test.tsdiffbeforeafterboth
--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -1,12 +1,12 @@
 // Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
 // This file is part of Unique Network.
 
-// Unique Network is free software: you can redistribute itSub and/or modify
-// itSub under the terms of the GNU General Public License as published by
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
 // the Free Software Foundation, either version 3 of the License, or
 // (at your option) any later version.
 
-// Unique Network is distributed in the hope that itSub will be useful,
+// Unique Network is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -1,12 +1,12 @@
 // Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
 // This file is part of Unique Network.
 
-// Unique Network is free software: you can redistribute itSub and/or modify
-// itSub under the terms of the GNU General Public License as published by
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
 // the Free Software Foundation, either version 3 of the License, or
 // (at your option) any later version.
 
-// Unique Network is distributed in the hope that itSub will be useful,
+// Unique Network is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
@@ -17,6 +17,18 @@
 import {IKeyringPair} from '@polkadot/types/types';
 import {usingPlaygrounds, expect, itSub, Pallets} from './util/playgrounds';
 
+async function setSponsorHelper(collection: any, signer: IKeyringPair, sponsorAddress: string) {
+  await collection.setSponsor(signer, sponsorAddress);
+  const raw = (await collection.getData())?.raw;
+  expect(raw.sponsorship.Unconfirmed).to.be.equal(sponsorAddress);
+}
+
+async function confirmSponsorHelper(collection: any, signer: IKeyringPair) {
+  await collection.confirmSponsorship(signer);
+  const raw = (await collection.getData())?.raw;
+  expect(raw.sponsorship.Confirmed).to.be.equal(signer.address);
+}
+
 describe('integration test: ext. confirmSponsorship():', () => {
   let alice: IKeyringPair;
   let bob: IKeyringPair;
@@ -32,21 +44,21 @@
 
   itSub('Confirm collection sponsorship', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    await collection.setSponsor(alice, bob.address);
-    await collection.confirmSponsorship(bob);
+    await setSponsorHelper(collection, alice, bob.address);
+    await confirmSponsorHelper(collection, bob);
   });
 
   itSub('Add sponsor to a collection after the same sponsor was already added and confirmed', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    await collection.setSponsor(alice, bob.address);
-    await collection.confirmSponsorship(bob);
-    await collection.setSponsor(alice, bob.address);
+    await setSponsorHelper(collection, alice, bob.address);
+    await confirmSponsorHelper(collection, bob);
+    await setSponsorHelper(collection, alice, bob.address);
   });
   itSub('Add new sponsor to a collection after another sponsor was already added and confirmed', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    await collection.setSponsor(alice, bob.address);
-    await collection.confirmSponsorship(bob);
-    await collection.setSponsor(alice, charlie.address);
+    await setSponsorHelper(collection, alice, bob.address);
+    await confirmSponsorHelper(collection, bob);
+    await setSponsorHelper(collection, alice, charlie.address);
   });
 
   itSub('NFT: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -1,12 +1,12 @@
 // Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
 // This file is part of Unique Network.
 
-// Unique Network is free software: you can redistribute itSub and/or modify
-// itSub under the terms of the GNU General Public License as published by
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
 // the Free Software Foundation, either version 3 of the License, or
 // (at your option) any later version.
 
-// Unique Network is distributed in the hope that itSub will be useful,
+// Unique Network is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
@@ -16,7 +16,33 @@
 
 import {usingPlaygrounds, expect, itSub, Pallets} from './util/playgrounds';
 import {IKeyringPair} from '@polkadot/types/types';
-import {IProperty} from './util/playgrounds/types';
+import {ICollectionCreationOptions, IProperty} from './util/playgrounds/types';
+import {DevUniqueHelper} from './util/playgrounds/unique.dev';
+
+async function mintCollectionHelper(helper: DevUniqueHelper, signer: IKeyringPair, options: ICollectionCreationOptions, type?: 'nft' | 'fungible' | 'refungible') {
+  let collection;
+  if (type === 'nft') {
+    collection = await helper.nft.mintCollection(signer, options);
+  } else if (type === 'fungible') {
+    collection = await helper.ft.mintCollection(signer, options, 0);
+  } else {
+    collection = await helper.rft.mintCollection(signer, options);
+  }
+  const data = await collection.getData();
+  expect(data?.normalizedOwner).to.be.equal(signer.address);
+  expect(data?.name).to.be.equal(options.name);
+  expect(data?.description).to.be.equal(options.description);
+  expect(data?.raw.tokenPrefix).to.be.equal(options.tokenPrefix);
+  if (options.properties) {
+    expect(data?.raw.properties).to.be.deep.equal(options.properties);
+  }
+
+  if (options.tokenPropertyPermissions) {
+    expect(data?.raw.tokenPropertyPermissions).to.be.deep.equal(options.tokenPropertyPermissions);
+  }
+
+  return collection;
+}
 
 describe('integration test: ext. createCollection():', () => {
   let alice: IKeyringPair;
@@ -29,41 +55,41 @@
   });
   itSub('Create new NFT collection', async ({helper}) => {
 
-    await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
+    await mintCollectionHelper(helper, alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 'nft');
   });
   itSub('Create new NFT collection whith collection_name of maximum length (64 bytes)', async ({helper}) => {
 
-    await helper.nft.mintCollection(alice, {name: 'A'.repeat(64), description: 'descr', tokenPrefix: 'COL'});
+    await mintCollectionHelper(helper, alice, {name: 'A'.repeat(64), description: 'descr', tokenPrefix: 'COL'}, 'nft');
   });
   itSub('Create new NFT collection whith collection_description of maximum length (256 bytes)', async ({helper}) => {
 
-    await helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(256), tokenPrefix: 'COL'});
+    await mintCollectionHelper(helper, alice, {name: 'name', description: 'A'.repeat(256), tokenPrefix: 'COL'}, 'nft');
   });
   itSub('Create new NFT collection whith token_prefix of maximum length (16 bytes)', async ({helper}) => {
 
-    await helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(16)});
+    await mintCollectionHelper(helper, alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(16)}, 'nft');
   });
   itSub('Create new Fungible collection', async ({helper}) => {
 
-    await helper.ft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 0);
+    await mintCollectionHelper(helper, alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 'fungible');
   });
   itSub.ifWithPallets('Create new ReFungible collection', [Pallets.ReFungible], async ({helper}) => {
 
-    await helper.rft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'});
+    await mintCollectionHelper(helper, alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 'refungible');
   });
 
   itSub('create new collection with properties', async ({helper}) => {
 
-    await helper.nft.mintCollection(alice, {
+    await mintCollectionHelper(helper, alice, {
       name: 'name', description: 'descr', tokenPrefix: 'COL',
       properties: [{key: 'key1', value: 'val1'}],
       tokenPropertyPermissions: [{key: 'key1', permission: {tokenOwner: true, mutable: false, collectionAdmin: true}}],
-    });
+    }, 'nft');
   });
 
   itSub('Create new collection with extra fields', async ({helper}) => {
 
-    const collection = await helper.ft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 8);
+    const collection = await mintCollectionHelper(helper, alice, {name: 'name', description: 'descr', tokenPrefix: 'COL'}, 'fungible');
     await collection.setPermissions(alice, {access: 'AllowList'});
     await collection.setLimits(alice, {accountTokenOwnershipLimit: 3});
     const data = await collection.getData();
@@ -74,7 +100,7 @@
     expect(data?.name).to.be.equal('name');
     expect(data?.description).to.be.equal('descr');
     expect(raw.permissions.access).to.be.equal('AllowList');
-    expect(raw.mode).to.be.deep.equal({Fungible: '8'});
+    expect(raw.mode).to.be.deep.equal({Fungible: '0'});
     expect(limits.accountTokenOwnershipLimit).to.be.equal(3);
   });
 
modifiedtests/src/createItem.test.tsdiffbeforeafterboth
--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -1,12 +1,12 @@
 // Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
 // This file is part of Unique Network.
 
-// Unique Network is free software: you can redistribute itSub and/or modify
-// itSub under the terms of the GNU General Public License as published by
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
 // the Free Software Foundation, either version 3 of the License, or
 // (at your option) any later version.
 
-// Unique Network is distributed in the hope that itSub will be useful,
+// Unique Network is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.
@@ -21,13 +21,39 @@
   itApi,
   normalizeAccountId,
   getCreateItemResult,
+  CrossAccountId,
 } from './util/helpers';
 
 import {usingPlaygrounds, expect, itSub, Pallets} from './util/playgrounds';
 import {IProperty} from './util/playgrounds/types';
 import {executeTransaction} from './substrate/substrate-api';
+import {DevUniqueHelper} from './util/playgrounds/unique.dev';
 
+async function mintTokenHelper(helper: DevUniqueHelper, collection: any, signer: IKeyringPair, owner: CrossAccountId, type: 'nft' | 'fungible' | 'refungible'='nft', properties?: IProperty[]) {
+  let token;
+  const itemCountBefore = await helper.collection.getLastTokenId(collection.collectionId);
+  const itemBalanceBefore = (await helper.api!.rpc.unique.balance(collection.collectionId, owner, 0)).toBigInt();
+  if (type === 'nft') {
+    token = await collection.mintToken(signer, owner, properties);
+  } else if (type === 'fungible') {
+    await collection.mint(signer, 10n, owner);
+  } else {
+    token = await collection.mintToken(signer, 100n, owner, properties);
+  }
 
+  const itemCountAfter = await helper.collection.getLastTokenId(collection.collectionId);
+  const itemBalanceAfter = (await helper.api!.rpc.unique.balance(collection.collectionId, owner, 0)).toBigInt();
+
+  if (type === 'fungible') {
+    expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);
+  } else {
+    expect(itemCountAfter).to.be.equal(itemCountBefore + 1);
+  }
+
+  return token;
+}
+
+
 describe('integration test: ext. ():', () => {
   let alice: IKeyringPair;
   let bob: IKeyringPair;
@@ -41,55 +67,55 @@
 
   itSub('Create new item in NFT collection', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    await collection.mintToken(alice, {Substrate: alice.address});
+    await mintTokenHelper(helper, collection, alice, {Substrate: alice.address});
   });
   itSub('Create new item in Fungible collection', async ({helper}) => {
     const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
-    await collection.mint(alice, 10n, {Substrate: alice.address});
+    await mintTokenHelper(helper, collection, alice, {Substrate: alice.address}, 'fungible');
   });
-  itApi.skip('Check events on create new item in Fungible collection', async ({api}) => {
-    const createMode = 'Fungible';
+  itSub('Check events on create new item in Fungible collection', async ({helper}) => {
+    const {collectionId} = await helper.ft.mintCollection(alice, {name: 'test', description: 'test', tokenPrefix: 'test'}, 0);
+    const api = helper.api!;
 
-    const newCollectionID = (await createCollection(api, alice, {mode: {type: createMode, decimalPoints: 0}})).collectionId;
 
     const to = normalizeAccountId(alice);
     {
       const createData = {fungible: {value: 100}};
-      const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);
+      const tx = api.tx.unique.createItem(collectionId, to, createData as any);
       const events = await executeTransaction(api, alice, tx);
       const result = getCreateItemResult(events);
       expect(result.amount).to.be.equal(100);
-      expect(result.collectionId).to.be.equal(newCollectionID);
+      expect(result.collectionId).to.be.equal(collectionId);
       expect(result.recipient).to.be.deep.equal(to);
     }
     {
       const createData = {fungible: {value: 50}};
-      const tx = api.tx.unique.createItem(newCollectionID, to, createData as any);
+      const tx = api.tx.unique.createItem(collectionId, to, createData as any);
       const events = await executeTransaction(api, alice, tx);
       const result = getCreateItemResult(events);
       expect(result.amount).to.be.equal(50);
-      expect(result.collectionId).to.be.equal(newCollectionID);
+      expect(result.collectionId).to.be.equal(collectionId);
       expect(result.recipient).to.be.deep.equal(to);
     }
   });
   itSub.ifWithPallets('Create new item in ReFungible collection', [Pallets.ReFungible], async ({helper}) =>  {
     const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
-    await collection.mintToken(alice, 100n, {Substrate: alice.address});
+    await mintTokenHelper(helper, collection, alice, {Substrate: alice.address}, 'refungible');
   });
   itSub('Create new item in NFT collection with collection admin permissions', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.addAdmin(alice, {Substrate: bob.address});
-    await collection.mintToken(bob, {Substrate: alice.address});
+    await mintTokenHelper(helper, collection, bob, {Substrate: alice.address});
   });
   itSub('Create new item in Fungible collection with collection admin permissions', async ({helper}) => {
     const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
     await collection.addAdmin(alice, {Substrate: bob.address});
-    await collection.mint(bob, 10n, {Substrate: alice.address});
+    await mintTokenHelper(helper, collection, bob, {Substrate: alice.address}, 'fungible');
   });
   itSub.ifWithPallets('Create new item in ReFungible collection with collection admin permissions', [Pallets.ReFungible], async ({helper}) =>  {
     const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     await collection.addAdmin(alice, {Substrate: bob.address});
-    await collection.mintToken(bob, 100n, {Substrate: alice.address});
+    await mintTokenHelper(helper, collection, bob, {Substrate: alice.address}, 'refungible');
   });
 
   itSub('Set property Admin', async ({helper}) => {
@@ -97,7 +123,7 @@
       properties: [{key: 'k', value: 'v'}],
       tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: true, collectionAdmin: true}}],
     });
-    await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+    await mintTokenHelper(helper, collection, alice, {Substrate: bob.address}, 'nft', [{key: 'k', value: 'v'}]);
   });
 
   itSub('Set property AdminConst', async ({helper}) => {
@@ -105,7 +131,7 @@
       properties: [{key: 'k', value: 'v'}],
       tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: false, mutable: false, collectionAdmin: true}}],
     });
-    await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+    await mintTokenHelper(helper, collection, alice, {Substrate: bob.address}, 'nft', [{key: 'k', value: 'v'}]);
   });
 
   itSub('Set property itemOwnerOrAdmin', async ({helper}) => {
@@ -113,13 +139,13 @@
       properties: [{key: 'k', value: 'v'}],
       tokenPropertyPermissions: [{key: 'k', permission: {tokenOwner: true, mutable: true, collectionAdmin: true}}],
     });
-    await collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);
+    await mintTokenHelper(helper, collection, alice, {Substrate: bob.address}, 'nft', [{key: 'k', value: 'v'}]);
   });
 
   itSub('Check total pieces of Fungible token', async ({helper}) => {
     const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);
     const amount = 10n;
-    await collection.mint(alice, amount, {Substrate: bob.address});
+    await mintTokenHelper(helper, collection, alice, {Substrate: bob.address}, 'fungible');
     {
       const totalPieces = await collection.getTotalPieces();
       expect(totalPieces).to.be.equal(amount);
@@ -134,7 +160,7 @@
   itSub('Check total pieces of NFT token', async ({helper}) => {
     const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const amount = 1n;
-    const token = await collection.mintToken(alice, {Substrate: bob.address});
+    const token = await mintTokenHelper(helper, collection, alice, {Substrate: bob.address});
     {
       const totalPieces = await helper.api?.rpc.unique.totalPieces(collection.collectionId, token.tokenId);
       expect(totalPieces?.unwrap().toBigInt()).to.be.equal(amount);
@@ -149,7 +175,7 @@
   itSub.ifWithPallets('Check total pieces of ReFungible token', [Pallets.ReFungible], async ({helper}) => {
     const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});
     const amount = 100n;
-    const token = await collection.mintToken(alice, amount, {Substrate: bob.address});
+    const token = await mintTokenHelper(helper, collection, alice, {Substrate: bob.address}, 'refungible');
     {
       const totalPieces = await token.getTotalPieces();
       expect(totalPieces).to.be.equal(amount);
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -1,12 +1,12 @@
 // Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
 // This file is part of Unique Network.
 
-// Unique Network is free software: you can redistribute itSub and/or modify
-// itSub under the terms of the GNU General Public License as published by
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
 // the Free Software Foundation, either version 3 of the License, or
 // (at your option) any later version.
 
-// Unique Network is distributed in the hope that itSub will be useful,
+// Unique Network is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 // GNU General Public License for more details.