difftreelog
Remove asyncs without awaits
in: master
23 files changed
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth56 const collection = await helper.collection.getData(collectionId);56 const collection = await helper.collection.getData(collectionId);57 expect(collection?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(alice.address));57 expect(collection?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(alice.address));585859 const changeAdminTxBob = async () => helper.collection.addAdmin(bob, collectionId, {Substrate: bob.address});59 const changeAdminTxBob = () => helper.collection.addAdmin(bob, collectionId, {Substrate: bob.address});60 const changeAdminTxCharlie = async () => helper.collection.addAdmin(bob, collectionId, {Substrate: charlie.address});60 const changeAdminTxCharlie = () => helper.collection.addAdmin(bob, collectionId, {Substrate: charlie.address});61 await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);61 await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);62 await expect(changeAdminTxBob()).to.be.rejectedWith(/common\.NoPermission/);62 await expect(changeAdminTxBob()).to.be.rejectedWith(/common\.NoPermission/);636375 const adminListAfterAddAdmin = await collection.getAdmins();75 const adminListAfterAddAdmin = await collection.getAdmins();76 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: bob.address});76 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: bob.address});777778 const changeAdminTxCharlie = async () => collection.addAdmin(bob, {Substrate: charlie.address});78 const changeAdminTxCharlie = () => collection.addAdmin(bob, {Substrate: charlie.address});79 await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);79 await expect(changeAdminTxCharlie()).to.be.rejectedWith(/common\.NoPermission/);808081 const adminListAfterAddNewAdmin = await collection.getAdmins();81 const adminListAfterAddNewAdmin = await collection.getAdmins();87 const [alice, bob] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);87 const [alice, bob] = await helper.arrange.createAccounts([10n, 10n, 10n], donor);88 const collectionId = (1 << 32) - 1;88 const collectionId = (1 << 32) - 1;898990 const addAdminTx = async () => helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});90 const addAdminTx = () => helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});91 await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);91 await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);929293 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)93 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)99 const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});99 const collection = await helper.nft.mintCollection(alice, {name: 'Collection Name', description: 'Collection Description', tokenPrefix: 'COL'});100100101 await collection.burn(alice);101 await collection.burn(alice);102 const addAdminTx = async () => collection.addAdmin(alice, {Substrate: bob.address});102 const addAdminTx = () => collection.addAdmin(alice, {Substrate: bob.address});103 await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);103 await expect(addAdminTx()).to.be.rejectedWith(/common\.CollectionNotFound/);104104105 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)105 // Verifying that nothing bad happened (network is live, new collections can be created, etc.)119 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: accounts[i].address});119 expect(adminListAfterAddAdmin).to.be.deep.contains({Substrate: accounts[i].address});120 }120 }121121122 const addExtraAdminTx = async () => collection.addAdmin(alice, {Substrate: accounts[chainAdminLimit].address});122 const addExtraAdminTx = () => collection.addAdmin(alice, {Substrate: accounts[chainAdminLimit].address});123 await expect(addExtraAdminTx()).to.be.rejectedWith(/common\.CollectionAdminCountExceeded/);123 await expect(addExtraAdminTx()).to.be.rejectedWith(/common\.CollectionAdminCountExceeded/);124 });124 });125});125});tests/src/adminTransferAndBurn.test.tsdiffbeforeafterboth36 expect(limits.ownerCanTransfer).to.be.true;36 expect(limits.ownerCanTransfer).to.be.true;373738 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});38 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});39 const transferResult = async () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});39 const transferResult = () => helper.nft.transferToken(alice, collectionId, tokenId, {Substrate: charlie.address});40 await expect(transferResult()).to.be.rejected;40 await expect(transferResult()).to.be.rejected;414142 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});42 await helper.nft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address});52 expect(limits.ownerCanTransfer).to.be.true;52 expect(limits.ownerCanTransfer).to.be.true;535354 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});54 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});55 const burnTxFailed = async () => helper.nft.burnToken(alice, collectionId, tokenId);55 const burnTxFailed = () => helper.nft.burnToken(alice, collectionId, tokenId);565657 await expect(burnTxFailed()).to.be.rejected;57 await expect(burnTxFailed()).to.be.rejected;5858tests/src/allowLists.test.tsdiffbeforeafterboth30 });30 });31 });31 });323233 describe('Positive', async () => {33 describe('Positive', () => {34 itSub('Owner can add address to allow list', async ({helper}) => {34 itSub('Owner can add address to allow list', async ({helper}) => {35 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});35 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});36 // allow list does not need to be enabled to add someone in advance36 // allow list does not need to be enabled to add someone in advance58 });58 });59 });59 });606061 describe('Negative', async () => {61 describe('Negative', () => {62 itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {62 itSub('Nobody can add address to allow list of non-existing collection', async ({helper}) => {63 const collectionId = (1<<32) - 1;63 const collectionId = (1<<32) - 1;64 await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))64 await expect(helper.nft.addToAllowList(bob, collectionId, {Substrate: charlie.address}))92 });92 });93 });93 });949495 describe('Positive', async () => {95 describe('Positive', () => {96 itSub('Owner can remove address from allow list', async ({helper}) => {96 itSub('Owner can remove address from allow list', async ({helper}) => {97 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});97 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});98 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});98 await helper.nft.addToAllowList(alice, collectionId, {Substrate: bob.address});128 });128 });129 });129 });130130131 describe('Negative', async () => {131 describe('Negative', () => {132 itSub('Non-privileged user cannot remove address from allow list', async ({helper}) => {132 itSub('Non-privileged user cannot remove address from allow list', async ({helper}) => {133 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});133 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});134 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});134 await helper.nft.addToAllowList(alice, collectionId, {Substrate: charlie.address});168 });168 });169 });169 });170170171 describe('Positive', async () => {171 describe('Positive', () => {172 itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer.', async ({helper}) => {172 itSub('If Public Access mode is set to AllowList, tokens can be transferred to a allowlisted address with transfer.', async ({helper}) => {173 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});173 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});174 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});174 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});219 });219 });220 });220 });221221222 describe('Negative', async () => {222 describe('Negative', () => {223 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}) => {223 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}) => {224 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});224 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});225 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});225 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});303 {access: 'AllowList', mintMode: true},303 {access: 'AllowList', mintMode: true},304 ];304 ];305305306 const testPermissionSuite = async (permissions: ICollectionPermissions) => {306 const testPermissionSuite = (permissions: ICollectionPermissions) => {307 const allowlistedMintingShouldFail = !permissions.mintMode!;307 const allowlistedMintingShouldFail = !permissions.mintMode!;308308309 const appropriateRejectionMessage = permissions.mintMode! ? /common\.AddressNotInAllowlist/ : /common\.PublicMintingNotAllowed/;309 const appropriateRejectionMessage = permissions.mintMode! ? /common\.AddressNotInAllowlist/ : /common\.PublicMintingNotAllowed/;323 );323 );324324325325326 describe(`Public Access Mode = ${permissions.access}, Mint Mode = ${permissions.mintMode}`, async () => {326 describe(`Public Access Mode = ${permissions.access}, Mint Mode = ${permissions.mintMode}`, () => {327 describe('Positive', async () => {327 describe('Positive', () => {328 itSub('With the condtions above, tokens can be created by owner', async ({helper}) => {328 itSub('With the condtions above, tokens can be created by owner', async ({helper}) => {329 const collection = await helper.nft.mintCollection(alice, {});329 const collection = await helper.nft.mintCollection(alice, {});330 await collection.setPermissions(alice, permissions);330 await collection.setPermissions(alice, permissions);341 if (!allowlistedMintingShouldFail) allowlistedMintingTest();341 if (!allowlistedMintingShouldFail) allowlistedMintingTest();342 });342 });343343344 describe('Negative', async () => {344 describe('Negative', () => {345 itSub('With the condtions above, tokens can\'t be created by non-priviliged non-allow-listed address', async ({helper}) => {345 itSub('With the condtions above, tokens can\'t be created by non-priviliged non-allow-listed address', async ({helper}) => {346 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});346 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});347 await collection.setPermissions(alice, permissions);347 await collection.setPermissions(alice, permissions);tests/src/approve.test.tsdiffbeforeafterboth92 itSub('can`t be called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {92 itSub('can`t be called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => {93 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});93 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});94 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});94 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});95 const approveTokenTx = async () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});95 const approveTokenTx = () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});96 await expect(approveTokenTx()).to.be.rejected;96 await expect(approveTokenTx()).to.be.rejected;97 });97 });98});98});196 await helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});196 await helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});197 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);197 const owner = await helper.nft.getTokenOwner(collectionId, tokenId);198 expect(owner.Substrate).to.be.equal(alice.address);198 expect(owner.Substrate).to.be.equal(alice.address);199 const transferTokenFromTx = async () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});199 const transferTokenFromTx = () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});200 await expect(transferTokenFromTx()).to.be.rejected;200 await expect(transferTokenFromTx()).to.be.rejected;201 });201 });202202210 const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address});210 const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address});211 expect(after - before).to.be.equal(BigInt(1));211 expect(after - before).to.be.equal(BigInt(1));212212213 const transferTokenFromTx = async () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);213 const transferTokenFromTx = () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 1n);214 await expect(transferTokenFromTx()).to.be.rejected;214 await expect(transferTokenFromTx()).to.be.rejected;215 });215 });216216222 await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);222 await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);223 const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});223 const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address});224 expect(after - before).to.be.equal(BigInt(100));224 expect(after - before).to.be.equal(BigInt(100));225 const transferTokenFromTx = async () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);225 const transferTokenFromTx = () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address}, 100n);226 await expect(transferTokenFromTx()).to.be.rejected;226 await expect(transferTokenFromTx()).to.be.rejected;227 });227 });228});228});277 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;277 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true;278 await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));278 await helper.signTransaction(alice, helper.constructApiCall('api.tx.unique.approve', [{Substrate: bob.address}, collectionId, tokenId, 0]));279 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;279 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false;280 const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});280 const transferTokenFromTx = () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address});281 await expect(transferTokenFromTx()).to.be.rejected;281 await expect(transferTokenFromTx()).to.be.rejected;282 });282 });283283293 const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});293 const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});294 expect(amountAfter).to.be.equal(BigInt(0));294 expect(amountAfter).to.be.equal(BigInt(0));295295296 const transferTokenFromTx = async () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);296 const transferTokenFromTx = () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n);297 await expect(transferTokenFromTx()).to.be.rejected;297 await expect(transferTokenFromTx()).to.be.rejected;298 });298 });299299308 const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});308 const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, {Substrate: alice.address});309 expect(amountAfter).to.be.equal(BigInt(0));309 expect(amountAfter).to.be.equal(BigInt(0));310310311 const transferTokenFromTx = async () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);311 const transferTokenFromTx = () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n);312 await expect(transferTokenFromTx()).to.be.rejected;312 await expect(transferTokenFromTx()).to.be.rejected;313 });313 });314});314});328 itSub('1 for NFT', async ({helper}) => {328 itSub('1 for NFT', async ({helper}) => {329 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});329 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});330 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});330 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});331 const approveTx = async () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));331 const approveTx = () => helper.signTransaction(bob, helper.constructApiCall('api.tx.unique.approve', [{Substrate: charlie.address}, collectionId, tokenId, 2]));332 await expect(approveTx()).to.be.rejected;332 await expect(approveTx()).to.be.rejected;333 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;333 expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false;334 });334 });337 const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);337 const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);338 await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);338 await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);339 const tokenId = await helper.ft.getLastTokenId(collectionId);339 const tokenId = await helper.ft.getLastTokenId(collectionId);340 const approveTx = async () => helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 11n);340 const approveTx = () => helper.ft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 11n);341 await expect(approveTx()).to.be.rejected;341 await expect(approveTx()).to.be.rejected;342 });342 });343343344 itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {344 itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => {345 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});345 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});346 const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});346 const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});347 const approveTx = async () => helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 101n);347 const approveTx = () => helper.rft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, 101n);348 await expect(approveTx()).to.be.rejected;348 await expect(approveTx()).to.be.rejected;349 });349 });350});350});483 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});483 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});484 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});484 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});485 await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});485 await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address});486 const approveTx = async () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});486 const approveTx = () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address});487 await expect(approveTx()).to.be.rejected;487 await expect(approveTx()).to.be.rejected;488 });488 });489});489});502502503 itSub('[nft] Approve for a collection that does not exist', async ({helper}) => {503 itSub('[nft] Approve for a collection that does not exist', async ({helper}) => {504 const collectionId = 1 << 32 - 1;504 const collectionId = 1 << 32 - 1;505 const approveTx = async () => helper.nft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});505 const approveTx = () => helper.nft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});506 await expect(approveTx()).to.be.rejected;506 await expect(approveTx()).to.be.rejected;507 });507 });508508509 itSub('[fungible] Approve for a collection that does not exist', async ({helper}) => {509 itSub('[fungible] Approve for a collection that does not exist', async ({helper}) => {510 const collectionId = 1 << 32 - 1;510 const collectionId = 1 << 32 - 1;511 const approveTx = async () => helper.ft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});511 const approveTx = () => helper.ft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});512 await expect(approveTx()).to.be.rejected;512 await expect(approveTx()).to.be.rejected;513 });513 });514514515 itSub.ifWithPallets('[refungible] Approve for a collection that does not exist', [Pallets.ReFungible], async ({helper}) => {515 itSub.ifWithPallets('[refungible] Approve for a collection that does not exist', [Pallets.ReFungible], async ({helper}) => {516 const collectionId = 1 << 32 - 1;516 const collectionId = 1 << 32 - 1;517 const approveTx = async () => helper.rft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});517 const approveTx = () => helper.rft.approveToken(bob, collectionId, 1, {Substrate: charlie.address});518 await expect(approveTx()).to.be.rejected;518 await expect(approveTx()).to.be.rejected;519 });519 });520520521 itSub('[nft] Approve for a collection that was destroyed', async ({helper}) => {521 itSub('[nft] Approve for a collection that was destroyed', async ({helper}) => {522 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});522 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});523 await helper.nft.burn(alice, collectionId);523 await helper.nft.burn(alice, collectionId);524 const approveTx = async () => helper.nft.approveToken(alice, collectionId, 1, {Substrate: bob.address});524 const approveTx = () => helper.nft.approveToken(alice, collectionId, 1, {Substrate: bob.address});525 await expect(approveTx()).to.be.rejected;525 await expect(approveTx()).to.be.rejected;526 });526 });527527528 itSub('[fungible] Approve for a collection that was destroyed', async ({helper}) => {528 itSub('[fungible] Approve for a collection that was destroyed', async ({helper}) => {529 const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});529 const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});530 await helper.ft.burn(alice, collectionId);530 await helper.ft.burn(alice, collectionId);531 const approveTx = async () => helper.ft.approveToken(alice, collectionId, 1, {Substrate: bob.address});531 const approveTx = () => helper.ft.approveToken(alice, collectionId, 1, {Substrate: bob.address});532 await expect(approveTx()).to.be.rejected;532 await expect(approveTx()).to.be.rejected;533 });533 });534534535 itSub.ifWithPallets('[refungible] Approve for a collection that was destroyed', [Pallets.ReFungible], async ({helper}) => {535 itSub.ifWithPallets('[refungible] Approve for a collection that was destroyed', [Pallets.ReFungible], async ({helper}) => {536 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});536 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});537 await helper.rft.burn(alice, collectionId);537 await helper.rft.burn(alice, collectionId);538 const approveTx = async () => helper.rft.approveToken(alice, collectionId, 1, {Substrate: bob.address});538 const approveTx = () => helper.rft.approveToken(alice, collectionId, 1, {Substrate: bob.address});539 await expect(approveTx()).to.be.rejected;539 await expect(approveTx()).to.be.rejected;540 });540 });541 541 542 itSub('[nft] Approve transfer of a token that does not exist', async ({helper}) => {542 itSub('[nft] Approve transfer of a token that does not exist', async ({helper}) => {543 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});543 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});544 const approveTx = async () => helper.nft.approveToken(alice, collectionId, 2, {Substrate: bob.address});544 const approveTx = () => helper.nft.approveToken(alice, collectionId, 2, {Substrate: bob.address});545 await expect(approveTx()).to.be.rejected;545 await expect(approveTx()).to.be.rejected;546 });546 });547547548 itSub.ifWithPallets('[refungible] Approve transfer of a token that does not exist', [Pallets.ReFungible], async ({helper}) => {548 itSub.ifWithPallets('[refungible] Approve transfer of a token that does not exist', [Pallets.ReFungible], async ({helper}) => {549 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});549 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});550 const approveTx = async () => helper.rft.approveToken(alice, collectionId, 2, {Substrate: bob.address});550 const approveTx = () => helper.rft.approveToken(alice, collectionId, 2, {Substrate: bob.address});551 await expect(approveTx()).to.be.rejected;551 await expect(approveTx()).to.be.rejected;552 });552 });553553554 itSub('[nft] Approve using the address that does not own the approved token', async ({helper}) => {554 itSub('[nft] Approve using the address that does not own the approved token', async ({helper}) => {555 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});555 const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});556 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});556 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address});557 const approveTx = async () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});557 const approveTx = () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});558 await expect(approveTx()).to.be.rejected;558 await expect(approveTx()).to.be.rejected;559 });559 });560560561 itSub('[fungible] Approve using the address that does not own the approved token', async ({helper}) => {561 itSub('[fungible] Approve using the address that does not own the approved token', async ({helper}) => {562 const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});562 const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});563 await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);563 await helper.ft.mintTokens(alice, collectionId, 10n, alice.address);564 const tokenId = await helper.ft.getLastTokenId(collectionId);564 const tokenId = await helper.ft.getLastTokenId(collectionId);565 const approveTx = async () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});565 const approveTx = () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});566 await expect(approveTx()).to.be.rejected;566 await expect(approveTx()).to.be.rejected;567 });567 });568568569 itSub.ifWithPallets('[refungible] Approve using the address that does not own the approved token', [Pallets.ReFungible], async ({helper}) => {569 itSub.ifWithPallets('[refungible] Approve using the address that does not own the approved token', [Pallets.ReFungible], async ({helper}) => {570 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});570 const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});571 const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});571 const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: alice.address, pieces: 100n});572 const approveTx = async () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});572 const approveTx = () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address});573 await expect(approveTx()).to.be.rejected;573 await expect(approveTx()).to.be.rejected;574 });574 });575575579 await helper.rft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 100n);579 await helper.rft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 100n);580 await helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 100n);580 await helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 100n);581581582 const approveTx = async () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 101n);582 const approveTx = () => helper.rft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 101n);583 await expect(approveTx()).to.be.rejected;583 await expect(approveTx()).to.be.rejected;584 });584 });585585590590591 await helper.ft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 10n);591 await helper.ft.transferToken(alice, collectionId, tokenId, {Substrate: bob.address}, 10n);592 await helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 10n);592 await helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 10n);593 const approveTx = async () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 11n);593 const approveTx = () => helper.ft.approveToken(bob, collectionId, tokenId, {Substrate: alice.address}, 11n);594 await expect(approveTx()).to.be.rejected;594 await expect(approveTx()).to.be.rejected;595 });595 });596596599 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});599 const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: bob.address});600 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: false});600 await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: false});601601602 const approveTx = async () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});602 const approveTx = () => helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: charlie.address});603 await expect(approveTx()).to.be.rejected;603 await expect(approveTx()).to.be.rejected;604 });604 });605});605});tests/src/change-collection-owner.test.tsdiffbeforeafterboth565657 await collection.changeOwner(alice, bob.address);57 await collection.changeOwner(alice, bob.address);585859 const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);59 const changeOwnerTx = () => collection.changeOwner(alice, alice.address);60 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);60 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);616162 const afterChanging = await helper.collection.getData(collection.collectionId);62 const afterChanging = await helper.collection.getData(collection.collectionId);115115116 itSub('Not owner can\'t change owner.', async ({helper}) => {116 itSub('Not owner can\'t change owner.', async ({helper}) => {117 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});117 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});118 const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);118 const changeOwnerTx = () => collection.changeOwner(bob, bob.address);119 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);119 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);120 });120 });121121122 itSub('Collection admin can\'t change owner.', async ({helper}) => {122 itSub('Collection admin can\'t change owner.', async ({helper}) => {123 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});123 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});124 await collection.addAdmin(alice, {Substrate: bob.address});124 await collection.addAdmin(alice, {Substrate: bob.address});125 const changeOwnerTx = async () => collection.changeOwner(bob, bob.address);125 const changeOwnerTx = () => collection.changeOwner(bob, bob.address);126 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);126 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);127 });127 });128128129 itSub('Can\'t change owner of a non-existing collection.', async ({helper}) => {129 itSub('Can\'t change owner of a non-existing collection.', async ({helper}) => {130 const collectionId = (1 << 32) - 1;130 const collectionId = (1 << 32) - 1;131 const changeOwnerTx = async () => helper.collection.changeOwner(bob, collectionId, bob.address);131 const changeOwnerTx = () => helper.collection.changeOwner(bob, collectionId, bob.address);132 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.CollectionNotFound/);132 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.CollectionNotFound/);133 });133 });134134135 itSub('Former collectionOwner not allowed to sponsorship management operations in the collection', async ({helper}) => {135 itSub('Former collectionOwner not allowed to sponsorship management operations in the collection', async ({helper}) => {136 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});136 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});137 await collection.changeOwner(alice, bob.address);137 await collection.changeOwner(alice, bob.address);138138139 const changeOwnerTx = async () => collection.changeOwner(alice, alice.address);139 const changeOwnerTx = () => collection.changeOwner(alice, alice.address);140 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);140 await expect(changeOwnerTx()).to.be.rejectedWith(/common\.NoPermission/);141141142 const afterChanging = await helper.collection.getData(collection.collectionId);142 const afterChanging = await helper.collection.getData(collection.collectionId);143 expect(afterChanging?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(bob.address));143 expect(afterChanging?.normalizedOwner).to.be.equal(helper.address.normalizeSubstrate(bob.address));144144145 const setSponsorTx = async () => collection.setSponsor(alice, charlie.address);145 const setSponsorTx = () => collection.setSponsor(alice, charlie.address);146 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);146 const confirmSponsorshipTx = () => collection.confirmSponsorship(alice);147 const removeSponsorTx = async () => collection.removeSponsor(alice);147 const removeSponsorTx = () => collection.removeSponsor(alice);148 await expect(setSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);148 await expect(setSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);149 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);149 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);150 await expect(removeSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);150 await expect(removeSponsorTx()).to.be.rejectedWith(/common\.NoPermission/);157 ownerCanTransfer: true,157 ownerCanTransfer: true,158 };158 };159159160 const setLimitsTx = async () => collection.setLimits(alice, limits);160 const setLimitsTx = () => collection.setLimits(alice, limits);161 await expect(setLimitsTx()).to.be.rejectedWith(/common\.NoPermission/);161 await expect(setLimitsTx()).to.be.rejectedWith(/common\.NoPermission/);162162163 const setPermissionTx = async () => collection.setPermissions(alice, {access: 'AllowList', mintMode: true});163 const setPermissionTx = () => collection.setPermissions(alice, {access: 'AllowList', mintMode: true});164 await expect(setPermissionTx()).to.be.rejectedWith(/common\.NoPermission/);164 await expect(setPermissionTx()).to.be.rejectedWith(/common\.NoPermission/);165165166 const burnTx = async () => collection.burn(alice);166 const burnTx = () => collection.burn(alice);167 await expect(burnTx()).to.be.rejectedWith(/common\.NoPermission/);167 await expect(burnTx()).to.be.rejectedWith(/common\.NoPermission/);168 });168 });169});169});tests/src/confirmSponsorship.test.tsdiffbeforeafterboth119 await token.transfer(alice, {Substrate: zeroBalance.address});119 await token.transfer(alice, {Substrate: zeroBalance.address});120 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);120 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);121121122 const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});122 const transferTx = () => token.transfer(zeroBalance, {Substrate: alice.address});123 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');123 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');124 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);124 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);125125137 await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);137 await collection.transfer(zeroBalance, {Substrate: zeroBalance.address}, 1n);138 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);138 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);139139140 const transferTx = async () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});140 const transferTx = () => collection.transfer(zeroBalance, {Substrate: zeroBalance.address});141 await expect(transferTx()).to.be.rejected;141 await expect(transferTx()).to.be.rejected;142 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);142 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);143143155 await token.transfer(zeroBalance, {Substrate: alice.address});155 await token.transfer(zeroBalance, {Substrate: alice.address});156156157 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);157 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);158 const transferTx = async () => token.transfer(zeroBalance, {Substrate: alice.address});158 const transferTx = () => token.transfer(zeroBalance, {Substrate: alice.address});159 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');159 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');160 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);160 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);161161175 await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});175 await collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});176176177 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);177 const bobBalanceBefore = await helper.balance.getSubstrate(bob.address);178 const mintTx = async () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});178 const mintTx = () => collection.mintToken(zeroBalance, {Substrate: zeroBalance.address});179 await expect(mintTx()).to.be.rejectedWith('Inability to pay some fees');179 await expect(mintTx()).to.be.rejectedWith('Inability to pay some fees');180 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);180 const bobBalanceAfter = await helper.balance.getSubstrate(bob.address);181181199199200 itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {200 itSub('(!negative test!) Confirm sponsorship for a collection that never existed', async ({helper}) => {201 const collectionId = (1 << 32) - 1;201 const collectionId = (1 << 32) - 1;202 const confirmSponsorshipTx = async () => helper.collection.confirmSponsorship(bob, collectionId);202 const confirmSponsorshipTx = () => helper.collection.confirmSponsorship(bob, collectionId);203 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);203 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);204 });204 });205205206 itSub('(!negative test!) Confirm sponsorship using a non-sponsor address', async ({helper}) => {206 itSub('(!negative test!) Confirm sponsorship using a non-sponsor address', async ({helper}) => {207 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});207 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});208 await collection.setSponsor(alice, bob.address);208 await collection.setSponsor(alice, bob.address);209 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);209 const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);210 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);210 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);211 });211 });212212213 itSub('(!negative test!) Confirm sponsorship using owner address', async ({helper}) => {213 itSub('(!negative test!) Confirm sponsorship using owner address', async ({helper}) => {214 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});214 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});215 await collection.setSponsor(alice, bob.address);215 await collection.setSponsor(alice, bob.address);216 const confirmSponsorshipTx = async () => collection.confirmSponsorship(alice);216 const confirmSponsorshipTx = () => collection.confirmSponsorship(alice);217 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);217 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);218 });218 });219219220 itSub('(!negative test!) Confirm sponsorship by collection admin', async ({helper}) => {220 itSub('(!negative test!) Confirm sponsorship by collection admin', async ({helper}) => {221 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});221 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});222 await collection.setSponsor(alice, bob.address);222 await collection.setSponsor(alice, bob.address);223 await collection.addAdmin(alice, {Substrate: charlie.address});223 await collection.addAdmin(alice, {Substrate: charlie.address});224 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);224 const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);225 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);225 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);226 });226 });227227228 itSub('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async ({helper}) => {228 itSub('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async ({helper}) => {229 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});229 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});230 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);230 const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);231 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);231 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/unique\.ConfirmUnsetSponsorFail/);232 });232 });233233234 itSub('(!negative test!) Confirm sponsorship in a collection that was destroyed', async ({helper}) => {234 itSub('(!negative test!) Confirm sponsorship in a collection that was destroyed', async ({helper}) => {235 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});235 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});236 await collection.burn(alice);236 await collection.burn(alice);237 const confirmSponsorshipTx = async () => collection.confirmSponsorship(charlie);237 const confirmSponsorshipTx = () => collection.confirmSponsorship(charlie);238 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);238 await expect(confirmSponsorshipTx()).to.be.rejectedWith(/common\.CollectionNotFound/);239 });239 });240240244 await collection.confirmSponsorship(bob);244 await collection.confirmSponsorship(bob);245 const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});245 const token = await collection.mintToken(alice, {Substrate: ownerZeroBalance.address});246 const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);246 const sponsorBalanceBefore = await helper.balance.getSubstrate(bob.address);247 const transferTx = async () => token.transfer(senderZeroBalance, {Substrate: alice.address});247 const transferTx = () => token.transfer(senderZeroBalance, {Substrate: alice.address});248 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');248 await expect(transferTx()).to.be.rejectedWith('Inability to pay some fees');249 const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);249 const sponsorBalanceAfter = await helper.balance.getSubstrate(bob.address);250 expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);250 expect(sponsorBalanceAfter).to.equal(sponsorBalanceBefore);tests/src/createCollection.test.tsdiffbeforeafterboth116 });116 });117117118 itSub('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async ({helper}) => {118 itSub('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async ({helper}) => {119 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});119 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'A'.repeat(65), description: 'descr', tokenPrefix: 'COL'});120 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');120 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');121 });121 });122 itSub('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async ({helper}) => {122 itSub('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async ({helper}) => {123 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});123 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'A'.repeat(257), tokenPrefix: 'COL'});124 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');124 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');125 });125 });126 itSub('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async ({helper}) => {126 itSub('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async ({helper}) => {127 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});127 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'A'.repeat(17)});128 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');128 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');129 });129 });130 130 131 itSub('(!negative test!) fails when bad limits are set', async ({helper}) => {131 itSub('(!negative test!) fails when bad limits are set', async ({helper}) => {132 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});132 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', limits: {tokenLimit: 0}});133 await expect(mintCollectionTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);133 await expect(mintCollectionTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);134 });134 });135135139 for (let i = 0; i < 65; i++) {139 for (let i = 0; i < 65; i++) {140 props.push({key: `key${i}`, value: `value${i}`});140 props.push({key: `key${i}`, value: `value${i}`});141 }141 }142 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});142 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});143 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');143 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');144 });144 });145145150 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});150 props.push({key: `key${i}`.repeat(80), value: `value${i}`.repeat(80)});151 }151 }152152153 const mintCollectionTx = async () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});153 const mintCollectionTx = () => helper.nft.mintCollection(alice, {name: 'name', description: 'descr', tokenPrefix: 'COL', properties: props});154 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');154 await expect(mintCollectionTx()).to.be.rejectedWith('Verification Error');155 });155 });156});156});tests/src/createItem.test.tsdiffbeforeafterboth186186187 itSub('Regular user cannot create new item in NFT collection', async ({helper}) => {187 itSub('Regular user cannot create new item in NFT collection', async ({helper}) => {188 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});188 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});189 const mintTx = async () => collection.mintToken(bob, {Substrate: bob.address});189 const mintTx = () => collection.mintToken(bob, {Substrate: bob.address});190 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);190 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);191 });191 });192 itSub('Regular user cannot create new item in Fungible collection', async ({helper}) => {192 itSub('Regular user cannot create new item in Fungible collection', async ({helper}) => {193 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);193 const collection = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0);194 const mintTx = async () => collection.mint(bob, 10n, {Substrate: bob.address});194 const mintTx = () => collection.mint(bob, 10n, {Substrate: bob.address});195 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);195 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);196 });196 });197 itSub.ifWithPallets('Regular user cannot create new item in ReFungible collection', [Pallets.ReFungible], async ({helper}) => {197 itSub.ifWithPallets('Regular user cannot create new item in ReFungible collection', [Pallets.ReFungible], async ({helper}) => {198 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});198 const collection = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});199 const mintTx = async () => collection.mintToken(bob, 100n, {Substrate: bob.address});199 const mintTx = () => collection.mintToken(bob, 100n, {Substrate: bob.address});200 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);200 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);201 });201 });202202203 itSub('No editing rights', async ({helper}) => {203 itSub('No editing rights', async ({helper}) => {204 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',204 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',205 tokenPropertyPermissions: [{key: 'k', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}],205 tokenPropertyPermissions: [{key: 'k', permission: {mutable: false, collectionAdmin: false, tokenOwner: false}}],206 });206 });207 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);207 const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);208 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);208 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);209 });209 });210210211 itSub('User doesnt have editing rights', async ({helper}) => {211 itSub('User doesnt have editing rights', async ({helper}) => {212 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',212 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL',213 tokenPropertyPermissions: [{key: 'k', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],213 tokenPropertyPermissions: [{key: 'k', permission: {mutable: true, collectionAdmin: false, tokenOwner: false}}],214 });214 });215 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);215 const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);216 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);216 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);217 });217 });218218219 itSub('Adding property without access rights', async ({helper}) => {219 itSub('Adding property without access rights', async ({helper}) => {220 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});220 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});221 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);221 const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [{key: 'k', value: 'v'}]);222 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);222 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);223 });223 });224224231231232232233 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});233 const collection = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'});234 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, props);234 const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, props);235 await expect(mintTx()).to.be.rejectedWith('Verification Error');235 await expect(mintTx()).to.be.rejectedWith('Verification Error');236 });236 });237237242 {key: 'k2', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},242 {key: 'k2', permission: {mutable: true, collectionAdmin: true, tokenOwner: true}},243 ],243 ],244 });244 });245 const mintTx = async () => collection.mintToken(alice, {Substrate: bob.address}, [245 const mintTx = () => collection.mintToken(alice, {Substrate: bob.address}, [246 {key: 'k1', value: 'vvvvvv'.repeat(5000)},246 {key: 'k1', value: 'vvvvvv'.repeat(5000)},247 {key: 'k2', value: 'vvv'.repeat(5000)},247 {key: 'k2', value: 'vvv'.repeat(5000)},248 ]);248 ]);tests/src/createMultipleItems.test.tsdiffbeforeafterboth183 {},183 {},184 {},184 {},185 ];185 ];186 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);186 const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);187 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);187 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);188 });188 });189189198 {value: 2n},198 {value: 2n},199 {value: 3n},199 {value: 3n},200 ];200 ];201 const mintTx = async () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, args, {Substrate: alice.address});201 const mintTx = () => helper.ft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, args, {Substrate: alice.address});202 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);202 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);203 });203 });204204213 {pieces: 1n},213 {pieces: 1n},214 {pieces: 1n},214 {pieces: 1n},215 ];215 ];216 const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);216 const mintTx = () => helper.rft.mintMultipleTokensWithOneOwner(bob, collection.collectionId, {Substrate: alice.address}, args);217 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);217 await expect(mintTx()).to.be.rejectedWith(/common\.PublicMintingNotAllowed/);218 });218 });219219223 {},223 {},224 {},224 {},225 ];225 ];226 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);226 const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(bob, collectionId, {Substrate: alice.address}, args);227 await expect(mintTx()).to.be.rejectedWith(/common\.CollectionNotFound/);227 await expect(mintTx()).to.be.rejectedWith(/common\.CollectionNotFound/);228 });228 });229229241 {properties: [{key: 'data', value: 'B'.repeat(32769)}]},241 {properties: [{key: 'data', value: 'B'.repeat(32769)}]},242 {properties: [{key: 'data', value: 'C'.repeat(32769)}]},242 {properties: [{key: 'data', value: 'C'.repeat(32769)}]},243 ];243 ];244 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);244 const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);245 await expect(mintTx()).to.be.rejectedWith('Verification Error');245 await expect(mintTx()).to.be.rejectedWith('Verification Error');246 });246 });247247259 {pieces: 10n, properties: [{key: 'data', value: 'B'.repeat(32769)}]},259 {pieces: 10n, properties: [{key: 'data', value: 'B'.repeat(32769)}]},260 {pieces: 10n, properties: [{key: 'data', value: 'C'.repeat(32769)}]},260 {pieces: 10n, properties: [{key: 'data', value: 'C'.repeat(32769)}]},261 ];261 ];262 const mintTx = async () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);262 const mintTx = () => helper.rft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);263 await expect(mintTx()).to.be.rejectedWith('Verification Error');263 await expect(mintTx()).to.be.rejectedWith('Verification Error');264 });264 });265265291 {properties: [{key: 'data', value: 'A'}]},291 {properties: [{key: 'data', value: 'A'}]},292 {properties: [{key: 'data', value: 'B'.repeat(32769)}]},292 {properties: [{key: 'data', value: 'B'.repeat(32769)}]},293 ];293 ];294 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);294 const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);295 await expect(mintTx()).to.be.rejectedWith('Verification Error');295 await expect(mintTx()).to.be.rejectedWith('Verification Error');296 });296 });297297311 {},311 {},312 {},312 {},313 ];313 ];314 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);314 const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);315 await expect(mintTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);315 await expect(mintTx()).to.be.rejectedWith(/common\.CollectionTokenLimitExceeded/);316 });316 });317317327 const args = [327 const args = [328 {properties: [{key: 'data', value: 'A'}]},328 {properties: [{key: 'data', value: 'A'}]},329 ];329 ];330 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);330 const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);331 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);331 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);332 });332 });333333346 const args = [346 const args = [347 {properties: [{key: 'data', value: 'A'}]},347 {properties: [{key: 'data', value: 'A'}]},348 ];348 ];349 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);349 const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);350 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);350 await expect(mintTx()).to.be.rejectedWith(/common\.NoPermission/);351 });351 });352352368 {properties: prps},368 {properties: prps},369 ];369 ];370370371 const mintTx = async () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);371 const mintTx = () => helper.nft.mintMultipleTokensWithOneOwner(alice, collection.collectionId, {Substrate: alice.address}, args);372 await expect(mintTx()).to.be.rejectedWith('Verification Error');372 await expect(mintTx()).to.be.rejectedWith('Verification Error');373 });373 });374});374});tests/src/eth/base.test.tsdiffbeforeafterboth69 });69 });70});70});717172describe('ERC165 tests', async () => {72describe('ERC165 tests', () => {73 // https://eips.ethereum.org/EIPS/eip-16573 // https://eips.ethereum.org/EIPS/eip-165747475 let erc721MetadataCompatibleNftCollectionId: number;75 let erc721MetadataCompatibleNftCollectionId: number;tests/src/eth/nesting/nest.test.tsdiffbeforeafterboth81 });81 });82 });82 });838384 describe('Negative Test: EVM Nesting', async() => {84 describe('Negative Test: EVM Nesting', () => {85 itEth('NFT: disallows to nest token if nesting is disabled', async ({helper}) => {85 itEth('NFT: disallows to nest token if nesting is disabled', async ({helper}) => {86 const owner = await helper.eth.createAccountWithBalance(donor);86 const owner = await helper.eth.createAccountWithBalance(donor);8787tests/src/eth/util/index.tsdiffbeforeafterboth58 }58 }59};59};60 60 61export async function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {61export function itEth(name: string, cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {62 (opts.only ? it.only : 62 (opts.only ? it.only : 63 opts.skip ? it.skip : it)(name, async function() {63 opts.skip ? it.skip : it)(name, async function() {64 await usingEthPlaygrounds(async (helper, privateKey) => {64 await usingEthPlaygrounds(async (helper, privateKey) => {71 });71 });72}72}737374export async function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {74export function itEthIfWithPallet(name: string, required: string[], cb: (apis: { helper: EthUniqueHelper, privateKey: (seed: string | {filename: string}) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {75 return itEth(name, cb, {requiredPallets: required, ...opts});75 return itEth(name, cb, {requiredPallets: required, ...opts});76}76}7777tests/src/eth/util/playgrounds/unique.dev.tsdiffbeforeafterboth367 return this.web3;367 return this.web3;368 }368 }369369370 async connectWeb3(wsEndpoint: string) {370 connectWeb3(wsEndpoint: string) {371 if(this.web3 !== null) return;371 if(this.web3 !== null) return;372 this.web3Provider = new Web3.providers.WebsocketProvider(wsEndpoint);372 this.web3Provider = new Web3.providers.WebsocketProvider(wsEndpoint);373 this.web3 = new Web3(this.web3Provider);373 this.web3 = new Web3(this.web3Provider);tests/src/pallet-presence.test.tsdiffbeforeafterboth83 });83 });84 });84 });858586 itSub('Required pallets are present', async ({helper}) => {86 itSub('Required pallets are present', ({helper}) => {87 expect(helper.fetchAllPalletNames()).to.contain.members([...requiredPallets]);87 expect(helper.fetchAllPalletNames()).to.contain.members([...requiredPallets]);88 });88 });898990 itSub('Governance and consensus pallets are present', async ({helper}) => {90 itSub('Governance and consensus pallets are present', ({helper}) => {91 expect(helper.fetchAllPalletNames()).to.contain.members([...consensusPallets]);91 expect(helper.fetchAllPalletNames()).to.contain.members([...consensusPallets]);92 });92 });939394 itSub('No extra pallets are included', async ({helper}) => {94 itSub('No extra pallets are included', ({helper}) => {95 expect(helper.fetchAllPalletNames().sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());95 expect(helper.fetchAllPalletNames().sort()).to.be.deep.equal([...requiredPallets, ...consensusPallets].sort());96 });96 });97});97});tests/src/refungible.test.tsdiffbeforeafterboth191920const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;20const MAX_REFUNGIBLE_PIECES = 1_000_000_000_000_000_000_000n;212122describe('integration test: Refungible functionality:', async () => {22describe('integration test: Refungible functionality:', () => {23 let donor: IKeyringPair;23 let donor: IKeyringPair;24 let alice: IKeyringPair;24 let alice: IKeyringPair;25 let bob: IKeyringPair;25 let bob: IKeyringPair;tests/src/rmrk/addResource.seqtest.tsdiffbeforeafterboth112 const resourcesInfo = [];112 const resourcesInfo = [];113 const resourceNum = 4;113 const resourceNum = 4;114114115 const checkResource = async (resource: ResourceInfo, resType: string, expectedId: number, expected: {115 const checkResource = (resource: ResourceInfo, resType: string, expectedId: number, expected: {116 src: string,116 src: string,117 metadata: string,117 metadata: string,118 license: string,118 license: string,tests/src/rmrk/equipNft.seqtest.tsdiffbeforeafterboth303031const slotId = 1;31const slotId = 1;323233async function createTestCollection(api: ApiPromise): Promise<number> {33function createTestCollection(api: ApiPromise): Promise<number> {34 return createCollection(34 return createCollection(35 api,35 api,36 alice,36 alice,60 return nftChildId;60 return nftChildId;61}61}626263async function createTestBase(api: ApiPromise): Promise<number> {63function createTestBase(api: ApiPromise): Promise<number> {64 return createBase(api, alice, 'test-base', 'DTBase', [64 return createBase(api, alice, 'test-base', 'DTBase', [65 {65 {66 SlotPart: {66 SlotPart: {tests/src/rmrk/rmrkIsolation.seqtest.tsdiffbeforeafterboth58 return rmrkNftId;58 return rmrkNftId;59}59}606061describe('RMRK External Integration Test', async () => {61describe('RMRK External Integration Test', () => {62 before(async function() {62 before(async function() {63 await usingPlaygrounds(async (_helper, privateKey) => {63 await usingPlaygrounds(async (_helper, privateKey) => {64 alice = await privateKey('//Alice');64 alice = await privateKey('//Alice');78 });78 });79});79});808081describe('Negative Integration Test: External Collections, Internal Ops', async () => {81describe('Negative Integration Test: External Collections, Internal Ops', () => {82 let uniqueCollectionId: number;82 let uniqueCollectionId: number;83 let rmrkCollectionId: number;83 let rmrkCollectionId: number;84 let rmrkNftId: number;84 let rmrkNftId: number;196 });196 });197});197});198198199describe('Negative Integration Test: Internal Collections, External Ops', async () => {199describe('Negative Integration Test: Internal Collections, External Ops', () => {200 let collectionId: number;200 let collectionId: number;201 let nftId: number;201 let nftId: number;202202tests/src/rmrk/util/fetch.tsdiffbeforeafterboth20 return (await api.rpc.rmrk.lastCollectionIdx()).toNumber();20 return (await api.rpc.rmrk.lastCollectionIdx()).toNumber();21}21}222223export async function getCollection(api: ApiPromise, id: number): Promise<Option<Collection>> {23export function getCollection(api: ApiPromise, id: number): Promise<Option<Collection>> {24 return api.rpc.rmrk.collectionById(id);24 return api.rpc.rmrk.collectionById(id);25}25}262636 .map((value) => value.toNumber());36 .map((value) => value.toNumber());37}37}383839export async function getNft(api: ApiPromise, collectionId: number, nftId: number): Promise<Option<Nft>> {39export function getNft(api: ApiPromise, collectionId: number, nftId: number): Promise<Option<Nft>> {40 return api.rpc.rmrk.nftById(collectionId, nftId);40 return api.rpc.rmrk.nftById(collectionId, nftId);41}41}424256 return (await api.rpc.rmrk.nftChildren(collectionId, nftId)).toArray();56 return (await api.rpc.rmrk.nftChildren(collectionId, nftId)).toArray();57}57}585859export async function getBase(api: ApiPromise, baseId: number): Promise<Option<Base>> {59export function getBase(api: ApiPromise, baseId: number): Promise<Option<Base>> {60 return api.rpc.rmrk.base(baseId);60 return api.rpc.rmrk.base(baseId);61}61}6262112 .map((name) => name.toUtf8());112 .map((name) => name.toUtf8());113}113}114114115export async function getTheme(115export function getTheme(116 api: ApiPromise,116 api: ApiPromise,117 baseId: number,117 baseId: number,118 themeName: string,118 themeName: string,tests/src/tx-version-presence.test.tsdiffbeforeafterboth26 });26 });27 });27 });282829 itSub('Signed extension CheckTxVersion is present', async () => {29 itSub('Signed extension CheckTxVersion is present', () => {30 expect(metadata.asLatest.extrinsic.signedExtensions.map(se => se.identifier.toString())).to.include('CheckTxVersion');30 expect(metadata.asLatest.extrinsic.signedExtensions.map(se => se.identifier.toString())).to.include('CheckTxVersion');31 });31 });32});32});tests/src/util/globalSetup.tsdiffbeforeafterboth90 });90 });91};91};929293const fundFilenamesWithRetries = async (retriesLeft: number): Promise<boolean> => {93const fundFilenamesWithRetries = (retriesLeft: number): Promise<boolean> => {94 if (retriesLeft <= 0) return Promise.resolve(false);94 if (retriesLeft <= 0) return Promise.resolve(false);95 return fundFilenames()95 return fundFilenames()96 .then(() => Promise.resolve(true))96 .then(() => Promise.resolve(true))tests/src/util/index.tsdiffbeforeafterboth59 return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);59 return usingPlaygroundsGeneral<DevUniqueHelper>(DevUniqueHelper, url, code);60};60};616162export const usingWestmintPlaygrounds = async (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {62export const usingWestmintPlaygrounds = (url: string, code: (helper: DevWestmintHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {63 return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);63 return usingPlaygroundsGeneral<DevWestmintHelper>(DevWestmintHelper, url, code);64};64};656566export const usingRelayPlaygrounds = async (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {66export const usingRelayPlaygrounds = (url: string, code: (helper: DevRelayHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {67 return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);67 return usingPlaygroundsGeneral<DevRelayHelper>(DevRelayHelper, url, code);68};68};696970export const usingAcalaPlaygrounds = async (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {70export const usingAcalaPlaygrounds = (url: string, code: (helper: DevAcalaHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {71 return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);71 return usingPlaygroundsGeneral<DevAcalaHelper>(DevAcalaHelper, url, code);72};72};737374export const usingKaruraPlaygrounds = async (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {74export const usingKaruraPlaygrounds = (url: string, code: (helper: DevKaruraHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {75 return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);75 return usingPlaygroundsGeneral<DevKaruraHelper>(DevAcalaHelper, url, code);76};76};777778export const usingMoonbeamPlaygrounds = async (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {78export const usingMoonbeamPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {79 return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);79 return usingPlaygroundsGeneral<DevMoonbeamHelper>(DevMoonbeamHelper, url, code);80};80};818182export const usingMoonriverPlaygrounds = async (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {82export const usingMoonriverPlaygrounds = (url: string, code: (helper: DevMoonbeamHelper, privateKey: (seed: string) => Promise<IKeyringPair>) => Promise<void>) => {83 return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);83 return usingPlaygroundsGeneral<DevMoonriverHelper>(DevMoonriverHelper, url, code);84};84};8585107 }107 }108}108}109109110export async function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {110export function itSub(name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {111 (opts.only ? it.only : 111 (opts.only ? it.only : 112 opts.skip ? it.skip : it)(name, async function () {112 opts.skip ? it.skip : it)(name, async function () {113 await usingPlaygrounds(async (helper, privateKey) => {113 await usingPlaygrounds(async (helper, privateKey) => {119 });119 });120 });120 });121}121}122export async function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {122export function itSubIfWithPallet(name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any, opts: { only?: boolean, skip?: boolean, requiredPallets?: string[] } = {}) {123 return itSub(name, cb, {requiredPallets: required, ...opts});123 return itSub(name, cb, {requiredPallets: required, ...opts});124}124}125itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});125itSub.only = (name: string, cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSub(name, cb, {only: true});129itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});129itSubIfWithPallet.skip = (name: string, required: string[], cb: (apis: { helper: DevUniqueHelper, privateKey: (seed: string) => Promise<IKeyringPair> }) => any) => itSubIfWithPallet(name, required, cb, {skip: true});130itSub.ifWithPallets = itSubIfWithPallet;130itSub.ifWithPallets = itSubIfWithPallet;131131132export async function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {132export function describeXCM(title: string, fn: (this: Mocha.Suite) => void, opts: {skip?: boolean} = {}) {133 (process.env.RUN_XCM_TESTS && !opts.skip133 (process.env.RUN_XCM_TESTS && !opts.skip134 ? describe134 ? describe135 : describe.skip)(title, fn);135 : describe.skip)(title, fn);tests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth267 }267 }268 const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber])]);268 const block2 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber])]);269 const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber - 1])]);269 const block1 = await this.helper.callRpc('api.rpc.chain.getBlock', [await this.helper.callRpc('api.rpc.chain.getBlockHash', [blockNumber - 1])]);270 const findCreationDate = async (block: any) => {270 const findCreationDate = (block: any) => {271 const humanBlock = block.toHuman();271 const humanBlock = block.toHuman();272 let date;272 let date;273 humanBlock.block.extrinsics.forEach((ext: any) => {273 humanBlock.block.extrinsics.forEach((ext: any) => {349 * @param blocksCount number of blocks to wait349 * @param blocksCount number of blocks to wait350 * @returns 350 * @returns 351 */351 */352 async newBlocks(blocksCount = 1): Promise<void> {352 newBlocks(blocksCount = 1): Promise<void> {353 // eslint-disable-next-line no-async-promise-executor353 // eslint-disable-next-line no-async-promise-executor354 const promise = new Promise<void>(async (resolve) => {354 const promise = new Promise<void>(async (resolve) => {355 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {355 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(() => {364 return promise;364 return promise;365 }365 }366366367 async forParachainBlockNumber(blockNumber: bigint) {367 forParachainBlockNumber(blockNumber: bigint) {368 // eslint-disable-next-line no-async-promise-executor368 // eslint-disable-next-line no-async-promise-executor369 return new Promise<void>(async (resolve) => {369 return new Promise<void>(async (resolve) => {370 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async (data: any) => {370 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads((data: any) => {371 if (data.number.toNumber() >= blockNumber) {371 if (data.number.toNumber() >= blockNumber) {372 unsubscribe();372 unsubscribe();373 resolve();373 resolve();376 });376 });377 }377 }378 378 379 async forRelayBlockNumber(blockNumber: bigint) {379 forRelayBlockNumber(blockNumber: bigint) {380 // eslint-disable-next-line no-async-promise-executor380 // eslint-disable-next-line no-async-promise-executor381 return new Promise<void>(async (resolve) => {381 return new Promise<void>(async (resolve) => {382 const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData(async (data: any) => {382 const unsubscribe = await this.helper.getApi().query.parachainSystem.validationData((data: any) => {383 if (data.value.relayParentNumber.toNumber() >= blockNumber) {383 if (data.value.relayParentNumber.toNumber() >= blockNumber) {384 // @ts-ignore384 // @ts-ignore385 unsubscribe();385 unsubscribe();389 });389 });390 }390 }391391392 async event(maxBlocksToWait: number, eventSection: string, eventMethod: string) {392 event(maxBlocksToWait: number, eventSection: string, eventMethod: string) {393 // eslint-disable-next-line no-async-promise-executor393 // eslint-disable-next-line no-async-promise-executor394 const promise = new Promise<EventRecord | null>(async (resolve) => {394 const promise = new Promise<EventRecord | null>(async (resolve) => {395 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async header => {395 const unsubscribe = await this.helper.getApi().rpc.chain.subscribeNewHeads(async header => {