diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-16 20:27:53 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-16 20:27:53 +0800 |
commit | 4111095da355a940d712800cd45f651f949b89c8 (patch) | |
tree | b0cc21b448b43f22627bb2bd929b914f75cb73f2 /packages | |
parent | 6c21ddcedba28f00429b8e57af60459b59ac92df (diff) | |
download | dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.tar.gz dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.tar.zst dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.zip |
Don't throw on transferFrom is the sender is an owner
Diffstat (limited to 'packages')
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts index b7e5519c4..6f6b4f716 100644 --- a/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts @@ -342,15 +342,17 @@ export class ERC721TokenWrapper extends ContractWrapper { const normalizedSenderAddress = senderAddress.toLowerCase(); const tokenContract = await this._getTokenContractAsync(normalizedTokenAddress); const ownerAddress = await this.getOwnerOfAsync(tokenAddress, tokenId); - const isApprovedForAll = await this.isApprovedForAllAsync( - normalizedTokenAddress, - ownerAddress, - normalizedSenderAddress, - ); - if (!isApprovedForAll) { - const approvedAddress = await this.getApprovedIfExistsAsync(normalizedTokenAddress, tokenId); - if (approvedAddress !== senderAddress) { - throw new Error(ContractWrappersError.ERC721NoApproval); + if (normalizedSenderAddress !== ownerAddress) { + const isApprovedForAll = await this.isApprovedForAllAsync( + normalizedTokenAddress, + ownerAddress, + normalizedSenderAddress, + ); + if (!isApprovedForAll) { + const approvedAddress = await this.getApprovedIfExistsAsync(normalizedTokenAddress, tokenId); + if (approvedAddress !== senderAddress) { + throw new Error(ContractWrappersError.ERC721NoApproval); + } } } const txHash = await tokenContract.transferFrom.sendTransactionAsync( |