git.delta.rocks / unique-network / refs/commits / 7b6dca1f6320

difftreelog

fix PR

Trubnikov Sergey2023-03-10parent: #8df8e96.patch.diff
in: master

3 files changed

modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
520 /// @param tokenId The NFT to find the approved address for520 /// @param tokenId The NFT to find the approved address for
521 /// @return The approved address for this NFT, or the zero address if there is none521 /// @return The approved address for this NFT, or the zero address if there is none
522 fn get_approved(&self, token_id: U256) -> Result<Address> {522 fn get_approved(&self, token_id: U256) -> Result<Address> {
523 let token = token_id.try_into()?;523 let token_id = token_id.try_into()?;
524 let operator = <Pallet<T>>::get_allowance(self, token).map_err(dispatch_to_evm::<T>)?;524 let operator = <Pallet<T>>::get_allowance(self, token_id).map_err(dispatch_to_evm::<T>)?;
525 Ok(if let Some(operator) = operator {525 Ok(if let Some(operator) = operator {
526 *operator.as_eth()526 *operator.as_eth()
527 } else {527 } else {
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
10851085
1086 pub fn get_allowance(1086 pub fn get_allowance(
1087 collection: &NonfungibleHandle<T>,1087 collection: &NonfungibleHandle<T>,
1088 token: TokenId,1088 token_id: TokenId,
1089 ) -> Result<Option<T::CrossAccountId>, DispatchError> {1089 ) -> Result<Option<T::CrossAccountId>, DispatchError> {
1090 ensure!(1090 ensure!(
1091 <TokenData<T>>::get((collection.id, token)).is_some(),1091 <TokenData<T>>::get((collection.id, token_id)).is_some(),
1092 <CommonError<T>>::TokenNotFound1092 <CommonError<T>>::TokenNotFound
1093 );1093 );
1094 Ok(<Allowance<T>>::get((collection.id, token)))1094 Ok(<Allowance<T>>::get((collection.id, token_id)))
1095 }1095 }
10961096
1097 /// Set allowance for the spender to `transfer` or `burn` sender's token.1097 /// Set allowance for the spender to `transfer` or `burn` sender's token.
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
230 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);230 const contract = await helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
231231
232 {232 {
233 const badTokenId = 1234567;233 const badTokenId = await contract.methods.nextTokenId().call() + 1;
234 await expect(contract.methods.getApproved(badTokenId).call()).to.be.rejectedWith('revert TokenNotFound');234 await expect(contract.methods.getApproved(badTokenId).call()).to.be.rejectedWith('revert TokenNotFound');
235 }235 }
236 {236 {