--- a/tests/src/approve.test.ts +++ b/tests/src/approve.test.ts @@ -49,7 +49,7 @@ const tokenId = await helper.ft.getLastTokenId(collectionId); await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}); const amount = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amount).to.be.equal(BigInt(1)); + expect(amount).to.be.equal(1n); }); itSub.ifWithPallets('[refungible] Execute the extrinsic and check approvedList', [Pallets.ReFungible], async ({helper}) => { @@ -57,7 +57,7 @@ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n}); await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}); const amount = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amount).to.be.equal(BigInt(1)); + expect(amount).to.be.equal(1n); }); itSub('[nft] Remove approval by using 0 amount', async ({helper}) => { @@ -76,11 +76,11 @@ const tokenId = await helper.ft.getLastTokenId(collectionId); await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}); const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amountBefore).to.be.equal(BigInt(1)); + expect(amountBefore).to.be.equal(1n); await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n); const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amountAfter).to.be.equal(BigInt(0)); + expect(amountAfter).to.be.equal(0n); }); itSub.ifWithPallets('[refungible] Remove approval by using 0 amount', [Pallets.ReFungible], async ({helper}) => { @@ -88,18 +88,18 @@ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n}); await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}); const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amountBefore).to.be.equal(BigInt(1)); + expect(amountBefore).to.be.equal(1n); await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n); const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amountAfter).to.be.equal(BigInt(0)); + expect(amountAfter).to.be.equal(0n); }); itSub('can`t be called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => { const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)}); const result = (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: charlie.address}); - await expect(result).to.be.rejected; + await expect(result).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); }); @@ -128,7 +128,7 @@ const tokenId = await helper.ft.getLastTokenId(collectionId); await (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address}); const amount = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: charlie.address}, testCase.account(bob)); - expect(amount).to.be.equal(BigInt(1)); + expect(amount).to.be.equal(1n); }); itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => { @@ -136,7 +136,7 @@ const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob), pieces: 100n}); await (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address}, 100n); const amount = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: charlie.address}, testCase.account(bob)); - expect(amount).to.be.equal(BigInt(100n)); + expect(amount).to.be.equal(100n); }); }); @@ -169,7 +169,7 @@ const before = await helper.ft.getBalance(collectionId, {Substrate: alice.address}); await helper.ft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 1n); const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address}); - expect(after - before).to.be.equal(BigInt(1)); + expect(after - before).to.be.equal(1n); }); itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => { @@ -179,7 +179,7 @@ const before = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address}); await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 1n); const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address}); - expect(after - before).to.be.equal(BigInt(1)); + expect(after - before).to.be.equal(1n); }); }); @@ -203,7 +203,7 @@ const owner = await helper.nft.getTokenOwner(collectionId, tokenId); expect(owner.Substrate).to.be.equal(alice.address); const transferTokenFromTx = () => helper.nft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}); - await expect(transferTokenFromTx()).to.be.rejected; + await expect(transferTokenFromTx()).to.be.rejectedWith('common.ApprovedValueTooLow'); }); itSub('Fungible up to an approved amount', async ({helper}) => { @@ -214,10 +214,10 @@ const before = await helper.ft.getBalance(collectionId, {Substrate: alice.address}); await helper.ft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 1n); const after = await helper.ft.getBalance(collectionId, {Substrate: alice.address}); - expect(after - before).to.be.equal(BigInt(1)); + expect(after - before).to.be.equal(1n); const transferTokenFromTx = () => helper.ft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 1n); - await expect(transferTokenFromTx()).to.be.rejected; + await expect(transferTokenFromTx()).to.be.rejectedWith('common.ApprovedValueTooLow'); }); itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => { @@ -227,9 +227,9 @@ const before = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address}); await helper.rft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 100n); const after = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address}); - expect(after - before).to.be.equal(BigInt(100)); + expect(after - before).to.be.equal(100n); const transferTokenFromTx = () => helper.rft.transferTokenFrom(charlie, collectionId, tokenId, testCase.account(bob), {Substrate: alice.address}, 100n); - await expect(transferTokenFromTx()).to.be.rejected; + await expect(transferTokenFromTx()).to.be.rejectedWith('common.ApprovedValueTooLow'); }); }); @@ -255,12 +255,12 @@ const charlieBefore = await helper.ft.getBalance(collectionId, {Substrate: charlie.address}); await helper.ft.transferTokenFrom(bob, collectionId, tokenId, testCase.account(alice), {Substrate: charlie.address}, 2n); const charlieAfter = await helper.ft.getBalance(collectionId, {Substrate: charlie.address}); - expect(charlieAfter - charlieBefore).to.be.equal(BigInt(2)); + expect(charlieAfter - charlieBefore).to.be.equal(2n); const daveBefore = await helper.ft.getBalance(collectionId, {Substrate: dave.address}); await helper.ft.transferTokenFrom(bob, collectionId, tokenId, testCase.account(alice), {Substrate: dave.address}, 8n); const daveAfter = await helper.ft.getBalance(collectionId, {Substrate: dave.address}); - expect(daveAfter - daveBefore).to.be.equal(BigInt(8)); + expect(daveAfter - daveBefore).to.be.equal(8n); }); }); @@ -277,45 +277,51 @@ }); itSub('NFT', async ({helper}) => { + const owner = testCase.account(alice); const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); - const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)}); + const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: owner}); + await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}); expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true; + await (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n); expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false; - const transferTokenFromTx = () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address}); - await expect(transferTokenFromTx()).to.be.rejected; + + const transferTokenFromTx = helper.nft.transferTokenFrom(bob, collectionId, tokenId, owner, {Substrate: bob.address}); + await expect(transferTokenFromTx).to.be.rejectedWith('common.ApprovedValueTooLow'); }); itSub('Fungible', async ({helper}) => { + const owner = testCase.account(alice); const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}, 0); - await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice)); + await helper.ft.mintTokens(alice, collectionId, 10n, owner); const tokenId = await helper.ft.getLastTokenId(collectionId); await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}); - const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amountBefore).to.be.equal(BigInt(1)); + const amountBefore = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, owner); + expect(amountBefore).to.be.equal(1n); await (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n); - const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amountAfter).to.be.equal(BigInt(0)); + const amountAfter = await helper.ft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, owner); + expect(amountAfter).to.be.equal(0n); - const transferTokenFromTx = () => helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 1n); - await expect(transferTokenFromTx()).to.be.rejected; + const transferTokenFromTx = helper.ft.transferTokenFrom(bob, collectionId, tokenId, owner, {Substrate: charlie.address}, 1n); + await expect(transferTokenFromTx).to.be.rejectedWith('common.ApprovedValueTooLow'); }); itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => { + const owner = testCase.account(alice); const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); - const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n}); + const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner, pieces: 100n}); await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}); - const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amountBefore).to.be.equal(BigInt(1)); + const amountBefore = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, owner); + expect(amountBefore).to.be.equal(1n); await (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 0n); - const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, testCase.account(alice)); - expect(amountAfter).to.be.equal(BigInt(0)); + const amountAfter = await helper.rft.getTokenApprovedPieces(collectionId, tokenId, {Substrate: bob.address}, owner); + expect(amountAfter).to.be.equal(0n); - const transferTokenFromTx = () => helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: charlie.address}, 100n); - await expect(transferTokenFromTx()).to.be.rejected; + const transferTokenFromTx = helper.rft.transferTokenFrom(bob, collectionId, tokenId, owner, {Substrate: charlie.address}, 1n); + await expect(transferTokenFromTx).to.be.rejectedWith('common.ApprovedValueTooLow'); }); }); @@ -335,7 +341,7 @@ const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)}); const result = (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address}, 2n); - await expect(result).to.be.rejected; + await expect(result).to.be.rejectedWith('nonfungible.NonfungibleItemsHaveNoAmount'); expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false; }); @@ -344,14 +350,14 @@ await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice)); const tokenId = await helper.ft.getLastTokenId(collectionId); const result = (helper.ft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 11n); - await expect(result).to.be.rejected; + await expect(result).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); itSub.ifWithPallets('ReFungible', [Pallets.ReFungible], async ({helper}) => { const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n}); const result = (helper.rft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: bob.address}, 101n); - await expect(result).to.be.rejected; + await expect(result).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); }); @@ -367,12 +373,12 @@ }); }); - itSub('can be called by collection admin on non-owned item', async ({helper}) => { + itSub('cannot be called by collection admin on non-owned item', async ({helper}) => { const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)}); await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address}); - const result = (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address}); - await expect(result).to.be.rejected; + const approveTx = (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: charlie.address}); + await expect(approveTx).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); }); @@ -380,6 +386,7 @@ let alice: IKeyringPair; let bob: IKeyringPair; let charlie: IKeyringPair; + const NONEXISTENT_COLLECTION = (2 ** 32) - 1; before(async () => { await usingPlaygrounds(async (helper, privateKey) => { @@ -389,75 +396,73 @@ }); itSub('[nft] Approve for a collection that does not exist', async ({helper}) => { - const collectionId = 1 << 32 - 1; - await expect((helper.nft as any)[testCase.method](bob, collectionId, 1, {Substrate: charlie.address})).to.be.rejected; + const approveTx = (helper.nft as any)[testCase.method](bob, NONEXISTENT_COLLECTION, 1, {Substrate: charlie.address}); + await expect(approveTx).to.be.rejectedWith('common.CollectionNotFound'); }); itSub('[fungible] Approve for a collection that does not exist', async ({helper}) => { - const collectionId = 1 << 32 - 1; - const approveTx = () => (helper.ft as any)[testCase.method](bob, collectionId, 1, {Substrate: charlie.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.ft as any)[testCase.method](bob, NONEXISTENT_COLLECTION, 1, {Substrate: charlie.address}); + await expect(approveTx).to.be.rejectedWith('common.CollectionNotFound'); }); itSub.ifWithPallets('[refungible] Approve for a collection that does not exist', [Pallets.ReFungible], async ({helper}) => { - const collectionId = 1 << 32 - 1; - const approveTx = () => (helper.rft as any)[testCase.method](bob, collectionId, 1, {Substrate: charlie.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.rft as any)[testCase.method](bob, NONEXISTENT_COLLECTION, 1, {Substrate: charlie.address}); + await expect(approveTx).to.be.rejectedWith('common.CollectionNotFound'); }); itSub('[nft] Approve for a collection that was destroyed', async ({helper}) => { const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); await helper.nft.burn(alice, collectionId); - const approveTx = () => (helper.nft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.nft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address}); + await expect(approveTx).to.be.rejectedWith('common.CollectionNotFound'); }); itSub('[fungible] Approve for a collection that was destroyed', async ({helper}) => { const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); await helper.ft.burn(alice, collectionId); - const approveTx = () => (helper.ft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.ft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address}); + await expect(approveTx).to.be.rejectedWith('common.CollectionNotFound'); }); itSub.ifWithPallets('[refungible] Approve for a collection that was destroyed', [Pallets.ReFungible], async ({helper}) => { const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); await helper.rft.burn(alice, collectionId); - const approveTx = () => (helper.rft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.rft as any)[testCase.method](alice, collectionId, 1, {Substrate: bob.address}); + await expect(approveTx).to.be.rejectedWith('common.CollectionNotFound'); }); itSub('[nft] Approve transfer of a token that does not exist', async ({helper}) => { const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); - const approveTx = () => (helper.nft as any)[testCase.method](alice, collectionId, 2, {Substrate: bob.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.nft as any)[testCase.method](alice, collectionId, 2, {Substrate: bob.address}); + await expect(approveTx).to.be.rejectedWith('common.TokenNotFound'); }); itSub.ifWithPallets('[refungible] Approve transfer of a token that does not exist', [Pallets.ReFungible], async ({helper}) => { const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); - const approveTx = () => (helper.rft as any)[testCase.method](alice, collectionId, 2, {Substrate: bob.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.rft as any)[testCase.method](alice, collectionId, 2, {Substrate: bob.address}); + await expect(approveTx).to.be.rejectedWith('common.CantApproveMoreThanOwned'); // TODO: why the error is not common.TokenNotFound }); itSub('[nft] Approve using the address that does not own the approved token', async ({helper}) => { const {collectionId} = await helper.nft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice)}); - const approveTx = () => (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.nft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}); + await expect(approveTx).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); itSub('[fungible] Approve using the address that does not own the approved token', async ({helper}) => { const {collectionId} = await helper.ft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); await helper.ft.mintTokens(alice, collectionId, 10n, testCase.account(alice)); const tokenId = await helper.ft.getLastTokenId(collectionId); - const approveTx = () => (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}); + await expect(approveTx).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); itSub.ifWithPallets('[refungible] Approve using the address that does not own the approved token', [Pallets.ReFungible], async ({helper}) => { const {collectionId} = await helper.rft.mintCollection(alice, {name: 'col', description: 'descr', tokenPrefix: 'COL'}); const {tokenId} = await helper.rft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(alice), pieces: 100n}); - const approveTx = () => (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}); + await expect(approveTx).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); itSub.ifWithPallets('should fail if approved more ReFungibles than owned', [Pallets.ReFungible], async ({helper}) => { @@ -466,8 +471,8 @@ await helper.rft.transferToken(alice, collectionId, tokenId, testCase.account(bob), 100n); await (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 100n); - const approveTx = () => (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 101n); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.rft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 101n); + await expect(approveTx).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); itSub('should fail if approved more Fungibles than owned', async ({helper}) => { @@ -477,8 +482,8 @@ await helper.ft.transferToken(alice, collectionId, tokenId, testCase.account(bob), 10n); await (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 10n); - const approveTx = () => (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 11n); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.ft as any)[testCase.method](bob, collectionId, tokenId, {Substrate: alice.address}, 11n); + await expect(approveTx).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); itSub('fails when called by collection owner on non-owned item when OwnerCanTransfer == false', async ({helper}) => { @@ -486,8 +491,8 @@ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: testCase.account(bob)}); await helper.collection.setLimits(alice, collectionId, {ownerCanTransfer: false}); - const approveTx = () => (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: charlie.address}); - await expect(approveTx()).to.be.rejected; + const approveTx = (helper.nft as any)[testCase.method](alice, collectionId, tokenId, {Substrate: charlie.address}); + await expect(approveTx).to.be.rejectedWith('common.CantApproveMoreThanOwned'); }); }); }); @@ -571,14 +576,14 @@ const daveBalanceBefore = await helper.ft.getBalance(collectionId, {Substrate: dave.address}); await helper.ft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: charlie.address}, {Substrate: dave.address}, 1n); const daveBalanceAfter = await helper.ft.getBalance(collectionId, {Substrate: dave.address}); - expect(daveBalanceAfter - daveBalanceBefore).to.be.equal(BigInt(1)); + expect(daveBalanceAfter - daveBalanceBefore).to.be.equal(1n); await helper.collection.addAdmin(alice ,collectionId, {Substrate: bob.address}); const aliceBalanceBefore = await helper.ft.getBalance(collectionId, {Substrate: alice.address}); await helper.ft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: dave.address}, {Substrate: alice.address}, 1n); const aliceBalanceAfter = await helper.ft.getBalance(collectionId, {Substrate: alice.address}); - expect(aliceBalanceAfter - aliceBalanceBefore).to.be.equal(BigInt(1)); + expect(aliceBalanceAfter - aliceBalanceBefore).to.be.equal(1n); }); itSub.ifWithPallets('ReFungible up to an approved amount', [Pallets.ReFungible], async ({helper}) => { @@ -589,14 +594,14 @@ const daveBefore = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: dave.address}); await helper.rft.transferTokenFrom(alice, collectionId, tokenId, {Substrate: charlie.address}, {Substrate: dave.address}, 1n); const daveAfter = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: dave.address}); - expect(daveAfter - daveBefore).to.be.equal(BigInt(1)); + expect(daveAfter - daveBefore).to.be.equal(1n); await helper.collection.addAdmin(alice, collectionId, {Substrate: bob.address}); const aliceBefore = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address}); await helper.rft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: dave.address}, {Substrate: alice.address}, 1n); const aliceAfter = await helper.rft.getTokenBalance(collectionId, tokenId, {Substrate: alice.address}); - expect(aliceAfter - aliceBefore).to.be.equal(BigInt(1)); + expect(aliceAfter - aliceBefore).to.be.equal(1n); }); }); @@ -620,7 +625,7 @@ await collection.approveTokens(alice, {Substrate: charlie.address}, 1n); // const allowances1 = await getAllowance(collectionId, 0, Alice.address, Bob.address); // const allowances2 = await getAllowance(collectionId, 0, Alice.address, Charlie.address); - // expect(allowances1 + allowances2).to.be.eq(BigInt(2)); + // expect(allowances1 + allowances2).to.be.eq(2n); }); itSub.skip('Owned 10, approval 1: 1, approval 2: 1, resulting approved value: 2. ReFungible', async ({helper}) => { @@ -630,7 +635,7 @@ await token.approve(alice, {Substrate: charlie.address}, 1n); // const allowances1 = await getAllowance(collectionId, itemId, Alice.address, Bob.address); // const allowances2 = await getAllowance(collectionId, itemId, Alice.address, Charlie.address); - // expect(allowances1 + allowances2).to.be.eq(BigInt(2)); + // expect(allowances1 + allowances2).to.be.eq(2n); }); // Canceled by changing approve logic