git.delta.rocks / unique-network / refs/commits / 8c823a622616

difftreelog

Add reaffirm approved address test

Max Andreev2022-12-01parent: #79fd5e9.patch.diff
in: master

1 file changed

modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
339 expect(await helper.nft.getTokenOwner(collection.collectionId, token2.tokenId)).to.deep.eq({Ethereum: receiverEth.toLowerCase()});339 expect(await helper.nft.getTokenOwner(collection.collectionId, token2.tokenId)).to.deep.eq({Ethereum: receiverEth.toLowerCase()});
340 });340 });
341
342 itEth('Can reaffirm approved address', async ({helper}) => {
343 const owner = await helper.eth.createAccountWithBalance(donor, 100n);
344 const [receiver1, receiver2] = await helper.arrange.createAccounts([100n, 100n], donor);
345 const receiver1Cross = helper.ethCrossAccount.fromKeyringPair(receiver1);
346 const receiver2Cross = helper.ethCrossAccount.fromKeyringPair(receiver2);
347 const collection = await helper.nft.mintCollection(minter, {name: 'A', description: 'B', tokenPrefix: 'C'});
348 const token1 = await collection.mintToken(minter, {Ethereum: owner});
349 const token2 = await collection.mintToken(minter, {Ethereum: owner});
350 const collectionEvm = helper.ethNativeContract.collection(helper.ethAddress.fromCollectionId(collection.collectionId), 'nft');
351
352 // Can approve and reaffirm approved address:
353 await collectionEvm.methods.approveCross(receiver1Cross, token1.tokenId).send({from: owner});
354 await collectionEvm.methods.approveCross(receiver2Cross, token1.tokenId).send({from: owner});
355
356 // receiver1 cannot transferFrom:
357 await expect(helper.nft.transferTokenFrom(receiver1, collection.collectionId, token1.tokenId, {Ethereum: owner}, {Substrate: receiver1.address})).to.be.rejected;
358 // receiver2 can transferFrom:
359 await helper.nft.transferTokenFrom(receiver2, collection.collectionId, token1.tokenId, {Ethereum: owner}, {Substrate: receiver2.address});
360
361 // can set approved address to zero address:
362 await collectionEvm.methods.approveCross(receiver1Cross, token2.tokenId).send({from: owner});
363
364 // FIXME how to remove approval?:
365 await collectionEvm.methods.approveCross({eth: '0x0000000000000000000000000000000000000000', sub: '0'}, token2.tokenId).call({from: owner});
366 await collectionEvm.methods.approve('0x0000000000000000000000000000000000000000', token2.tokenId).call({from: owner});
367
368 // receiver1 cannot transfer token anymore:
369 await expect(helper.nft.transferTokenFrom(receiver1, collection.collectionId, token2.tokenId, {Ethereum: owner}, {Substrate: receiver1.address})).to.be.rejected;
370 });
341371
342 itEth('Can perform transferFrom()', async ({helper}) => {372 itEth('Can perform transferFrom()', async ({helper}) => {
343 const owner = await helper.eth.createAccountWithBalance(donor);373 const owner = await helper.eth.createAccountWithBalance(donor);