diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-07-18 16:38:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-18 16:38:07 +0800 |
commit | ab6bf6edc70d6bfd27cdb7becce838dda8720e39 (patch) | |
tree | a26b8d3c4cfaf7e8d2bb5f65d53b8a056b08985c /packages/contract-wrappers | |
parent | acff177c547dee049b97e4b051fe22e1efaf992c (diff) | |
parent | f20b496dca2dceb4f53ae20660798f8b8148a265 (diff) | |
download | dexon-sol-tools-ab6bf6edc70d6bfd27cdb7becce838dda8720e39.tar dexon-sol-tools-ab6bf6edc70d6bfd27cdb7becce838dda8720e39.tar.gz dexon-sol-tools-ab6bf6edc70d6bfd27cdb7becce838dda8720e39.tar.bz2 dexon-sol-tools-ab6bf6edc70d6bfd27cdb7becce838dda8720e39.tar.lz dexon-sol-tools-ab6bf6edc70d6bfd27cdb7becce838dda8720e39.tar.xz dexon-sol-tools-ab6bf6edc70d6bfd27cdb7becce838dda8720e39.tar.zst dexon-sol-tools-ab6bf6edc70d6bfd27cdb7becce838dda8720e39.zip |
Merge pull request #879 from 0xProject/feature/order-watcher-erc721-tests
Add ERC721 tests for order watcher v2
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts | 20 | ||||
-rw-r--r-- | packages/contract-wrappers/test/exchange_wrapper_test.ts | 4 |
2 files changed, 13 insertions, 11 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..1133a4085 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 !== normalizedSenderAddress) { + throw new Error(ContractWrappersError.ERC721NoApproval); + } } } const txHash = await tokenContract.transferFrom.sendTransactionAsync( diff --git a/packages/contract-wrappers/test/exchange_wrapper_test.ts b/packages/contract-wrappers/test/exchange_wrapper_test.ts index 33da19aee..44f8a5680 100644 --- a/packages/contract-wrappers/test/exchange_wrapper_test.ts +++ b/packages/contract-wrappers/test/exchange_wrapper_test.ts @@ -53,7 +53,6 @@ describe('ExchangeWrapper', () => { await blockchainLifecycle.startAsync(); contractWrappers = new ContractWrappers(provider, config); exchangeContractAddress = contractWrappers.exchange.getContractAddress(); - const erc20ProxyAddress = contractWrappers.erc20Proxy.getContractAddress(); userAddresses = await web3Wrapper.getAvailableAddressesAsync(); zrxTokenAddress = tokenUtils.getProtocolTokenAddress(); fillScenarios = new FillScenarios( @@ -61,7 +60,8 @@ describe('ExchangeWrapper', () => { userAddresses, zrxTokenAddress, exchangeContractAddress, - erc20ProxyAddress, + contractWrappers.erc20Proxy.getContractAddress(), + contractWrappers.erc721Proxy.getContractAddress(), ); [coinbase, makerAddress, takerAddress, feeRecipient, anotherMakerAddress] = userAddresses; [makerTokenAddress, takerTokenAddress] = tokenUtils.getDummyERC20TokenAddresses(); |