difftreelog
fix PR
in: master
2 files changed
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -1088,8 +1088,7 @@
token: TokenId,
) -> Result<Option<T::CrossAccountId>, DispatchError> {
ensure! {
- <TokenData<T>>::iter_keys().find(
- |(c, t)| return *c == collection.id && *t == token).is_some()
+ <TokenData<T>>::get((collection.id, token)).is_some()
,<CommonError<T>>::TokenNotFound
};
Ok(<Allowance<T>>::get((collection.id, token)))
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth219 }219 }220 });220 });221221222 itEth('Can perform approve()', async ({helper}) => {222 itEth.only('Can perform approve()', async ({helper}) => {223 const owner = await helper.eth.createAccountWithBalance(donor);223 const owner = await helper.eth.createAccountWithBalance(donor);224 const spender = helper.eth.createAccount();224 const spender = helper.eth.createAccount();225225229 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);229 const collectionAddress = helper.ethAddress.fromCollectionId(collection.collectionId);230 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);230 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);231231232 {233 const badTokenId = 1234567;234 await expect(contract.methods.getApproved(badTokenId).call()).to.be.rejectedWith('revert TokenNotFound');235 }236 {237 const approved = await contract.methods.getApproved(tokenId).call();238 expect(approved).to.be.equal('0x0000000000000000000000000000000000000000');239 }232 {240 {233 const result = await contract.methods.approve(spender, tokenId).send({from: owner});241 const result = await contract.methods.approve(spender, tokenId).send({from: owner});234242238 expect(event.returnValues.approved).to.be.equal(spender);246 expect(event.returnValues.approved).to.be.equal(spender);239 expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);247 expect(event.returnValues.tokenId).to.be.equal(`${tokenId}`);240 }248 }249 {250 const approved = await contract.methods.getApproved(tokenId).call();251 expect(approved).to.be.equal(spender);252 }241 });253 });242243 itEth('Can perform setApproval()', async ({helper}) => {244 const owner = await helper.eth.createAccountWithBalance(donor);245 const operator = helper.eth.createAccount();246247 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');248 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);249250 const result = await contract.methods.mint(owner).send({from: owner});251 const tokenId = result.events.Transfer.returnValues.tokenId;252253 {254 const approved = await contract.methods.getApproved(tokenId).call();255 expect(approved).to.be.equal('0x0000000000000000000000000000000000000000');256 }257 await contract.methods.approve(operator, tokenId).send({from: owner});258 {259 const approved = await contract.methods.getApproved(tokenId).call();260 expect(approved).to.be.equal(operator);261 }262 });263264254265 itEth('Can perform setApprovalForAll()', async ({helper}) => {255 itEth('Can perform setApprovalForAll()', async ({helper}) => {