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
--- a/tests/src/allowLists.test.ts
+++ b/tests/src/allowLists.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/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
before · tests/src/confirmSponsorship.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, Pallets} from './util/playgrounds';1920describe('integration test: ext. confirmSponsorship():', () => {21  let alice: IKeyringPair;22  let bob: IKeyringPair;23  let charlie: IKeyringPair;24  let zeroBalance: IKeyringPair;2526  before(async () => {27    await usingPlaygrounds(async (helper, privateKey) => {28      const donor = privateKey('//Alice');29      [alice, bob, charlie, zeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n], donor);30    });31  });3233  itSub('Confirm collection sponsorship', async ({helper}) => {34    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});35    await collection.setSponsor(alice, bob.address);36    await collection.confirmSponsorship(bob);37  });3839  itSub('Add sponsor to a collection after the same sponsor was already added and confirmed', async ({helper}) => {40    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});41    await collection.setSponsor(alice, bob.address);42    await collection.confirmSponsorship(bob);43    await collection.setSponsor(alice, bob.address);44  });45  itSub('Add new sponsor to a collection after another sponsor was already added and confirmed', async ({helper}) => {46    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});47    await collection.setSponsor(alice, bob.address);48    await collection.confirmSponsorship(bob);49    await collection.setSponsor(alice, charlie.address);50  });5152  itSub('NFT: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {53    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});54    await collection.setSponsor(alice, bob.address);55    await collection.confirmSponsorship(bob);56    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);57    const token = await collection.mintToken(alice, {Substrate: zeroBalance.address});58    await token.transfer(zeroBalance, {Substrate: alice.address});59    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);60    expect(bobBalanceAfter < bobBalanceBefore).to.be.true;61  });6263  itSub('Fungible: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {64    const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);65    await collection.setSponsor(alice, bob.address);66    await collection.confirmSponsorship(bob);67    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);68    await collection.mint(alice, 100n, {Substrate: zeroBalance.address});69    await collection.transfer(zeroBalance, {Substrate: alice.address}, 1n);70    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);71    expect(bobBalanceAfter < bobBalanceBefore).to.be.true;72  });7374  itSub.ifWithPallets('ReFungible: Transfer fees are paid by the sponsor after confirmation', [Pallets.ReFungible], async ({helper}) => {75    const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});76    await collection.setSponsor(alice, bob.address);77    await collection.confirmSponsorship(bob);78    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);79    const token = await collection.mintToken(alice, 100n, {Substrate: zeroBalance.address});80    await token.transfer(zeroBalance, {Substrate: alice.address}, 1n);81    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);82    expect(bobBalanceAfter < bobBalanceBefore).to.be.true;83  });8485  itSub('CreateItem fees are paid by the sponsor after confirmation', async ({helper}) => {86    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});87    await collection.setSponsor(alice, bob.address);88    await collection.confirmSponsorship(bob);89    await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});90    await collection.addToAllowList(alice, {Substrate: zeroBalance.address});9192    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);93    await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});94    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);9596    expect(bobBalanceAfter < bobBalanceBefore).to.be.true;97  });9899  itSub('NFT: Sponsoring of transfers is rate limited', async ({helper}) => {100    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});101    await collection.setSponsor(alice, bob.address);102    await collection.confirmSponsorship(bob);103104    const token = await collection.mintToken(alice, {Substrate: alice.address});105    await token.transfer(alice, {Substrate: zeroBalance.address});106    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);107108    const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});109    await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');110    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);111112    expect(bobBalanceAfter === bobBalanceBefore).to.be.true;113  });114115  itSub('Fungible: Sponsoring is rate limited', async ({helper}) => {116    const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});117    await collection.setSponsor(alice, bob.address);118    await collection.confirmSponsorship(bob);119120    await collection.mint(alice, 100n, {Substrate: zeroBalance.address});121    await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);122    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);123124    const transferTx = async () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});125    await expect(transferTx()).to.be.rejected;126    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);127128    expect(bobBalanceAfter === bobBalanceBefore).to.be.true;129  });130131  itSub.ifWithPallets('ReFungible: Sponsoring is rate limited', [Pallets.ReFungible], async ({helper}) => {132    const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});133    await collection.setSponsor(alice, bob.address);134    await collection.confirmSponsorship(bob);135136    const token = await collection.mintToken(alice, 100n, {Substrate: zeroBalance.address});137    await token.transfer(zeroBalance, {Substrate: alice.address});138139    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);140    const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});141    await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');142    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);143144    expect(bobBalanceAfter === bobBalanceBefore).to.be.true;145  });146147  itSub('NFT: Sponsoring of createItem is rate limited', async ({helper}) => {148    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});149    await collection.setSponsor(alice, bob.address);150    await collection.confirmSponsorship(bob);151    await collection.setPermissions(alice, {mintMode: true, access: 'AllowList'});152    await collection.addToAllowList(alice, {Substrate: zeroBalance.address});153154    await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});155156    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);157    const mintTx = async () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});158    await expect(mintTx()).to.be.rejectedWith('Inability to pay some fees');159    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);160161    expect(bobBalanceAfter === bobBalanceBefore).to.be.true;162  });163});164165describe('(!negative test!) integration test: ext. confirmSponsorship():', () => {166  let alice: IKeyringPair;167  let bob: IKeyringPair;168  let charlie: IKeyringPair;169  let ownerZeroBalance: IKeyringPair;170  let senderZeroBalance: IKeyringPair;171172  before(async () => {173    await usingPlaygrounds(async (helper, privateKey) => {174      const donor = privateKey('//Alice');175      [alice, bob, charlie, ownerZeroBalance, senderZeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n, 0n], donor);176    });177  });178179  itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {180    const collectionId = 1_000_000;181    const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);182    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);183  });184185  itSub('(!negative test!) Confirm sponsorship using a non-sponsor address', async ({helper}) => {186    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});187    await collection.setSponsor(alice, bob.address);188    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);189    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);190  });191192  itSub('(!negative test!) Confirm sponsorship using owner address', async ({helper}) => {193    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});194    await collection.setSponsor(alice, bob.address);195    const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);196    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);197  });198199  itSub('(!negative test!) Confirm sponsorship by collection admin', async ({helper}) => {200    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});201    await collection.setSponsor(alice, bob.address);202    await collection.addAdmin(alice, {Substrate: charlie.address});203    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);204    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);205  });206207  itSub('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async ({helper}) => {208    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});209    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);210    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);211  });212213  itSub('(!negative test!) Confirm sponsorship in a collection that was destroyed', async ({helper}) => {214    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});215    await collection.burn(alice);216    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);217    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);218  });219220  itSub('(!negative test!) Transfer fees are not paid by the sponsor if the transfer failed', async ({helper}) => {221    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});222    await collection.setSponsor(alice, bob.address);223    await collection.confirmSponsorship(bob);224    const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});225    const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);226    const transferTx = async () =>  token.transfer(senderZeroBalance, {Substrate: alice.address});227    await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');228    const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);229    expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);230  });231});
after · tests/src/confirmSponsorship.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, Pallets} from './util/playgrounds';1920async function setSponsorHelper(collection: any, signer: IKeyringPair, sponsorAddress: string) {21  await collection.setSponsor(signer, sponsorAddress);22  const raw = (await collection.getData())?.raw;23  expect(raw.sponsorship.Unconfirmed).to.be.equal(sponsorAddress);24}2526async function confirmSponsorHelper(collection: any, signer: IKeyringPair) {27  await collection.confirmSponsorship(signer);28  const raw = (await collection.getData())?.raw;29  expect(raw.sponsorship.Confirmed).to.be.equal(signer.address);30}3132describe('integration test: ext. confirmSponsorship():', () => {33  let alice: IKeyringPair;34  let bob: IKeyringPair;35  let charlie: IKeyringPair;36  let zeroBalance: IKeyringPair;3738  before(async () => {39    await usingPlaygrounds(async (helper, privateKey) => {40      const donor = privateKey('//Alice');41      [alice, bob, charlie, zeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n], donor);42    });43  });4445  itSub('Confirm collection sponsorship', async ({helper}) => {46    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});47    await setSponsorHelper(collection, alice, bob.address);48    await confirmSponsorHelper(collection, bob);49  });5051  itSub('Add sponsor to a collection after the same sponsor was already added and confirmed', async ({helper}) => {52    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});53    await setSponsorHelper(collection, alice, bob.address);54    await confirmSponsorHelper(collection, bob);55    await setSponsorHelper(collection, alice, bob.address);56  });57  itSub('Add new sponsor to a collection after another sponsor was already added and confirmed', async ({helper}) => {58    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});59    await setSponsorHelper(collection, alice, bob.address);60    await confirmSponsorHelper(collection, bob);61    await setSponsorHelper(collection, alice, charlie.address);62  });6364  itSub('NFT: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {65    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});66    await collection.setSponsor(alice, bob.address);67    await collection.confirmSponsorship(bob);68    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);69    const token = await collection.mintToken(alice, {Substrate: zeroBalance.address});70    await token.transfer(zeroBalance, {Substrate: alice.address});71    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);72    expect(bobBalanceAfter < bobBalanceBefore).to.be.true;73  });7475  itSub('Fungible: Transfer fees are paid by the sponsor after confirmation', async ({helper}) => {76    const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);77    await collection.setSponsor(alice, bob.address);78    await collection.confirmSponsorship(bob);79    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);80    await collection.mint(alice, 100n, {Substrate: zeroBalance.address});81    await collection.transfer(zeroBalance, {Substrate: alice.address}, 1n);82    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);83    expect(bobBalanceAfter < bobBalanceBefore).to.be.true;84  });8586  itSub.ifWithPallets('ReFungible: Transfer fees are paid by the sponsor after confirmation', [Pallets.ReFungible], async ({helper}) => {87    const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});88    await collection.setSponsor(alice, bob.address);89    await collection.confirmSponsorship(bob);90    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);91    const token = await collection.mintToken(alice, 100n, {Substrate: zeroBalance.address});92    await token.transfer(zeroBalance, {Substrate: alice.address}, 1n);93    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);94    expect(bobBalanceAfter < bobBalanceBefore).to.be.true;95  });9697  itSub('CreateItem fees are paid by the sponsor after confirmation', async ({helper}) => {98    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});99    await collection.setSponsor(alice, bob.address);100    await collection.confirmSponsorship(bob);101    await collection.setPermissions(alice, {access: 'AllowList', mintMode: true});102    await collection.addToAllowList(alice, {Substrate: zeroBalance.address});103104    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);105    await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});106    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);107108    expect(bobBalanceAfter < bobBalanceBefore).to.be.true;109  });110111  itSub('NFT: Sponsoring of transfers is rate limited', async ({helper}) => {112    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});113    await collection.setSponsor(alice, bob.address);114    await collection.confirmSponsorship(bob);115116    const token = await collection.mintToken(alice, {Substrate: alice.address});117    await token.transfer(alice, {Substrate: zeroBalance.address});118    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);119120    const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});121    await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');122    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);123124    expect(bobBalanceAfter === bobBalanceBefore).to.be.true;125  });126127  itSub('Fungible: Sponsoring is rate limited', async ({helper}) => {128    const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});129    await collection.setSponsor(alice, bob.address);130    await collection.confirmSponsorship(bob);131132    await collection.mint(alice, 100n, {Substrate: zeroBalance.address});133    await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);134    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);135136    const transferTx = async () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});137    await expect(transferTx()).to.be.rejected;138    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);139140    expect(bobBalanceAfter === bobBalanceBefore).to.be.true;141  });142143  itSub.ifWithPallets('ReFungible: Sponsoring is rate limited', [Pallets.ReFungible], async ({helper}) => {144    const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});145    await collection.setSponsor(alice, bob.address);146    await collection.confirmSponsorship(bob);147148    const token = await collection.mintToken(alice, 100n, {Substrate: zeroBalance.address});149    await token.transfer(zeroBalance, {Substrate: alice.address});150151    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);152    const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});153    await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');154    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);155156    expect(bobBalanceAfter === bobBalanceBefore).to.be.true;157  });158159  itSub('NFT: Sponsoring of createItem is rate limited', async ({helper}) => {160    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});161    await collection.setSponsor(alice, bob.address);162    await collection.confirmSponsorship(bob);163    await collection.setPermissions(alice, {mintMode: true, access: 'AllowList'});164    await collection.addToAllowList(alice, {Substrate: zeroBalance.address});165166    await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});167168    const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);169    const mintTx = async () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});170    await expect(mintTx()).to.be.rejectedWith('Inability to pay some fees');171    const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);172173    expect(bobBalanceAfter === bobBalanceBefore).to.be.true;174  });175});176177describe('(!negative test!) integration test: ext. confirmSponsorship():', () => {178  let alice: IKeyringPair;179  let bob: IKeyringPair;180  let charlie: IKeyringPair;181  let ownerZeroBalance: IKeyringPair;182  let senderZeroBalance: IKeyringPair;183184  before(async () => {185    await usingPlaygrounds(async (helper, privateKey) => {186      const donor = privateKey('//Alice');187      [alice, bob, charlie, ownerZeroBalance, senderZeroBalance] = await helper.arrange.createAccounts([100n, 100n, 100n, 0n, 0n], donor);188    });189  });190191  itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {192    const collectionId = 1_000_000;193    const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);194    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);195  });196197  itSub('(!negative test!) Confirm sponsorship using a non-sponsor address', async ({helper}) => {198    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});199    await collection.setSponsor(alice, bob.address);200    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);201    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);202  });203204  itSub('(!negative test!) Confirm sponsorship using owner address', async ({helper}) => {205    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});206    await collection.setSponsor(alice, bob.address);207    const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);208    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);209  });210211  itSub('(!negative test!) Confirm sponsorship by collection admin', async ({helper}) => {212    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});213    await collection.setSponsor(alice, bob.address);214    await collection.addAdmin(alice, {Substrate: charlie.address});215    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);216    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);217  });218219  itSub('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async ({helper}) => {220    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});221    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);222    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);223  });224225  itSub('(!negative test!) Confirm sponsorship in a collection that was destroyed', async ({helper}) => {226    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});227    await collection.burn(alice);228    const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);229    await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);230  });231232  itSub('(!negative test!) Transfer fees are not paid by the sponsor if the transfer failed', async ({helper}) => {233    const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});234    await collection.setSponsor(alice, bob.address);235    await collection.confirmSponsorship(bob);236    const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});237    const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);238    const transferTx = async () =>  token.transfer(senderZeroBalance, {Substrate: alice.address});239    await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');240    const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);241    expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);242  });243});
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.