From 2c4a2768a281b314345bba4a32a3adb1576bd618 Mon Sep 17 00:00:00 2001 From: rkv Date: Fri, 09 Sep 2022 09:11:35 +0000 Subject: [PATCH] add amount to approveToken in unique playgrounds --- --- a/tests/src/approve.test.ts +++ b/tests/src/approve.test.ts @@ -15,33 +15,21 @@ // along with Unique Network. If not, see . import {IKeyringPair} from '@polkadot/types/types'; -import {ApiPromise} from '@polkadot/api'; import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import {default as usingApi} from './substrate/substrate-api'; import { approveExpectFail, approveExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, - destroyCollectionExpectSuccess, - setCollectionLimitsExpectSuccess, - transferExpectSuccess, - addCollectionAdminExpectSuccess, - adminApproveFromExpectFail, - getCreatedCollectionCount, - transferFromExpectSuccess, - transferFromExpectFail, - requirePallets, - Pallets, } from './util/helpers'; -import { usingPlaygrounds } from './util/playgrounds'; +import {usingPlaygrounds} from './util/playgrounds'; let donor: IKeyringPair; before(async () => { - await usingPlaygrounds(async (_, privateKeyWrapper) => { - donor = privateKeyWrapper('//Alice'); + await usingPlaygrounds(async (_, privateKey) => { + donor = privateKey('//Alice'); }); }); @@ -95,7 +83,7 @@ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address}); await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}); expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true; - await helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0).signAndSend(alice); + await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, undefined, 0n); expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false; }); }); @@ -333,7 +321,7 @@ const {tokenId} = await helper.nft.mintToken(alice, {collectionId: collectionId, owner: alice.address}); await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}); expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.true; - await helper.api?.tx.unique.approve({Substrate: bob.address}, collectionId, tokenId, 0).signAndSend(alice); + await helper.nft.approveToken(alice, collectionId, tokenId, {Substrate: bob.address}, undefined, 0n); expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: bob.address})).to.be.false; const transferTokenFromTx = async () => helper.nft.transferTokenFrom(bob, collectionId, tokenId, {Substrate: bob.address}, {Substrate: bob.address}); await expect(transferTokenFromTx()).to.be.rejected; @@ -391,7 +379,8 @@ await usingPlaygrounds(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: bob.address}); - await helper.api?.tx.unique.approve({Substrate: charlie.address}, collectionId, tokenId, 2).signAndSend(bob); + const approveTx = async () => helper.nft.approveToken(bob, collectionId, tokenId, {Substrate: charlie.address}, undefined, 2n); + await expect(approveTx()).to.be.rejected; expect(await helper.nft.isTokenApproved(collectionId, tokenId, {Substrate: charlie.address})).to.be.false; }); }); --- a/tests/src/util/playgrounds/unique.ts +++ b/tests/src/util/playgrounds/unique.ts @@ -1419,8 +1419,8 @@ * @example approveToken(aliceKeyring, 10, 5, {Substrate: "5DyN4Y92vZCjv38fg..."}) * @returns ```true``` if extrinsic success, otherwise ```false``` */ - async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, label?: string) { - return super.approveToken(signer, collectionId, tokenId, toAddressObj, label, 1n); + async approveToken(signer: IKeyringPair, collectionId: number, tokenId: number, toAddressObj: ICrossAccountId, label?: string, amount=1n) { + return super.approveToken(signer, collectionId, tokenId, toAddressObj, label, amount); } } -- gitstuff