aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-16 20:27:53 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-16 20:27:53 +0800
commit4111095da355a940d712800cd45f651f949b89c8 (patch)
treeb0cc21b448b43f22627bb2bd929b914f75cb73f2
parent6c21ddcedba28f00429b8e57af60459b59ac92df (diff)
downloaddexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.tar
dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.tar.gz
dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.tar.bz2
dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.tar.lz
dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.tar.xz
dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.tar.zst
dexon-sol-tools-4111095da355a940d712800cd45f651f949b89c8.zip
Don't throw on transferFrom is the sender is an owner
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts20
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(