difftreelog
fix PR
in: master
2 files changed
pallets/nonfungible/src/lib.rsdiffbeforeafterboth1088 token: TokenId,1088 token: TokenId,1089 ) -> Result<Option<T::CrossAccountId>, DispatchError> {1089 ) -> Result<Option<T::CrossAccountId>, DispatchError> {1090 ensure! {1090 ensure! {1091 <TokenData<T>>::iter_keys().find(1091 <TokenData<T>>::get((collection.id, token)).is_some()1092 |(c, t)| return *c == collection.id && *t == token).is_some()1093 ,<CommonError<T>>::TokenNotFound1092 ,<CommonError<T>>::TokenNotFound1094 };1093 };1095 Ok(<Allowance<T>>::get((collection.id, token)))1094 Ok(<Allowance<T>>::get((collection.id, token)))tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -219,7 +219,7 @@
}
});
- itEth('Can perform approve()', async ({helper}) => {
+ itEth.only('Can perform approve()', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);
const spender = helper.eth.createAccount();
@@ -230,6 +230,14 @@
const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
{
+ const badTokenId = 1234567;
+ await expect(contract.methods.getApproved(badTokenId).call()).to.be.rejectedWith('revert TokenNotFound');
+ }
+ {
+ const approved = await contract.methods.getApproved(tokenId).call();
+ expect(approved).to.be.equal('0x0000000000000000000000000000000000000000');
+ }
+ {
const result = await contract.methods.approve(spender, tokenId).send({from: owner});
const event = result.events.Approval;
@@ -237,30 +245,12 @@
expect(event.returnValues.owner).to.be.equal(owner);
expect(event.returnValues.approved).to.be.equal(spender);
expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);
- }
- });
-
- itEth('Can perform setApproval()', async ({helper}) => {
- const owner = await helper.eth.createAccountWithBalance(donor);
- const operator = helper.eth.createAccount();
-
- const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
- const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
-
- const result = await contract.methods.mint(owner).send({from: owner});
- const tokenId = result.events.Transfer.returnValues.tokenId;
-
- {
- const approved = await contract.methods.getApproved(tokenId).call();
- expect(approved).to.be.equal('0x0000000000000000000000000000000000000000');
}
- await contract.methods.approve(operator, tokenId).send({from: owner});
{
const approved = await contract.methods.getApproved(tokenId).call();
- expect(approved).to.be.equal(operator);
+ expect(approved).to.be.equal(spender);
}
});
-
itEth('Can perform setApprovalForAll()', async ({helper}) => {
const owner = await helper.eth.createAccountWithBalance(donor);