aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-18 21:37:34 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-18 21:38:10 +0800
commitc71781d9abf7f2654a51dbef95bd18200ea2bde1 (patch)
treebcaf7b858ba1d22d6f8c1afe0ff21aec28467598 /packages/contract-wrappers
parentdad557164ea4ccc012243d43df013078a7c37eb6 (diff)
downloaddexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.gz
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.bz2
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.lz
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.xz
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.tar.zst
dexon-sol-tools-c71781d9abf7f2654a51dbef95bd18200ea2bde1.zip
Merge
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/erc721_token_wrapper.ts20
-rw-r--r--packages/contract-wrappers/test/exchange_wrapper_test.ts4
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 3d24702b3..7c2b41c62 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();