git.delta.rocks / unique-network / refs/commits / d68299c35c5b

difftreelog

fix PR

Trubnikov Sergey2023-03-09parent: #0595f0d.patch.diff
in: master

2 files changed

modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
1088 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>>::TokenNotFound
1094 };1093 };
1095 Ok(<Allowance<T>>::get((collection.id, token)))1094 Ok(<Allowance<T>>::get((collection.id, token)))
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
219 }219 }
220 });220 });
221221
222 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();
225225
229 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);
231231
232 {
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});
234242
238 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 });
242
243 itEth('Can perform setApproval()', async ({helper}) => {
244 const owner = await helper.eth.createAccountWithBalance(donor);
245 const operator = helper.eth.createAccount();
246
247 const {collectionAddress} = await helper.eth.createNFTCollection(owner, 'A', 'B', 'C');
248 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
249
250 const result = await contract.methods.mint(owner).send({from: owner});
251 const tokenId = result.events.Transfer.returnValues.tokenId;
252
253 {
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 });
263
264254
265 itEth('Can perform setApprovalForAll()', async ({helper}) => {255 itEth('Can perform setApprovalForAll()', async ({helper}) => {