diff options
author | Jacob Evans <dekz@dekz.net> | 2018-06-20 08:24:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-20 08:24:12 +0800 |
commit | be17308e507019e7c04a8a32e9aecf667de7aa2c (patch) | |
tree | 6154b7b6a8205488bf633986e1517188759ced11 /packages/contracts | |
parent | e216eb1e7b49f1ad4bc2c8a07007b4ef94373c5d (diff) | |
parent | 25fa29e6e14e3e2d5551b868ee4c433ae9708e60 (diff) | |
download | dexon-sol-tools-be17308e507019e7c04a8a32e9aecf667de7aa2c.tar dexon-sol-tools-be17308e507019e7c04a8a32e9aecf667de7aa2c.tar.gz dexon-sol-tools-be17308e507019e7c04a8a32e9aecf667de7aa2c.tar.bz2 dexon-sol-tools-be17308e507019e7c04a8a32e9aecf667de7aa2c.tar.lz dexon-sol-tools-be17308e507019e7c04a8a32e9aecf667de7aa2c.tar.xz dexon-sol-tools-be17308e507019e7c04a8a32e9aecf667de7aa2c.tar.zst dexon-sol-tools-be17308e507019e7c04a8a32e9aecf667de7aa2c.zip |
Merge pull request #717 from 0xProject/feature/contracts/erc721proxy-always-safeTransferFrom
ERC721Proxy Always call safeTransferFrom
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol | 8 | ||||
-rw-r--r-- | packages/contracts/test/asset_proxy/proxies.ts | 8 |
2 files changed, 7 insertions, 9 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol index d09aba599..9dc9e6525 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC721Transfer.sol @@ -53,13 +53,7 @@ contract MixinERC721Transfer is bytes memory receiverData ) = decodeERC721AssetData(assetData); - // Transfer token. Saves gas by calling safeTransferFrom only - // when there is receiverData present. Either succeeds or throws. - if (receiverData.length > 0) { - ERC721Token(token).safeTransferFrom(from, to, tokenId, receiverData); - } else { - ERC721Token(token).transferFrom(from, to, tokenId); - } + ERC721Token(token).safeTransferFrom(from, to, tokenId, receiverData); } /// @dev Decodes ERC721 Asset data. diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts index 9760d3b9c..2c27f7382 100644 --- a/packages/contracts/test/asset_proxy/proxies.ts +++ b/packages/contracts/test/asset_proxy/proxies.ts @@ -276,7 +276,7 @@ describe('Asset Transfer Proxies', () => { expect(newOwnerMakerAsset).to.be.bignumber.equal(takerAddress); }); - it('should not call onERC721Received when transferring to a smart contract without receiver data', async () => { + it('should call onERC721Received when transferring to a smart contract without receiver data', async () => { // Construct ERC721 asset data const encodedAssetData = assetProxyUtils.encodeERC721AssetData(erc721Token.address, erc721MakerTokenId); const encodedAssetDataWithoutProxyId = encodedAssetData.slice(0, -2); @@ -297,7 +297,11 @@ describe('Asset Transfer Proxies', () => { const logDecoder = new LogDecoder(web3Wrapper, erc721Receiver.address); const tx = await logDecoder.getTxWithDecodedLogsAsync(txHash); // Verify that no log was emitted by erc721 receiver - expect(tx.logs.length).to.be.equal(0); + expect(tx.logs.length).to.be.equal(1); + const tokenReceivedLog = tx.logs[0] as LogWithDecodedArgs<TokenReceivedContractEventArgs>; + expect(tokenReceivedLog.args.from).to.be.equal(makerAddress); + expect(tokenReceivedLog.args.tokenId).to.be.bignumber.equal(erc721MakerTokenId); + expect(tokenReceivedLog.args.data).to.be.equal(constants.NULL_BYTES); // Verify transfer was successful const newOwnerMakerAsset = await erc721Token.ownerOf.callAsync(erc721MakerTokenId); expect(newOwnerMakerAsset).to.be.bignumber.equal(erc721Receiver.address); |