diff options
author | Remco Bloemen <remco@wicked.ventures> | 2018-06-26 03:30:38 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-06-27 03:23:19 +0800 |
commit | 3b46e82625fbb16ad4068851df5a2d96ff448f35 (patch) | |
tree | a18181f36cc7cc639d39a469f2ca08811cde58a6 /packages/contracts | |
parent | dbaf1fcd43637f2acc08af5a30cc3c1890dacb24 (diff) | |
download | dexon-sol-tools-3b46e82625fbb16ad4068851df5a2d96ff448f35.tar dexon-sol-tools-3b46e82625fbb16ad4068851df5a2d96ff448f35.tar.gz dexon-sol-tools-3b46e82625fbb16ad4068851df5a2d96ff448f35.tar.bz2 dexon-sol-tools-3b46e82625fbb16ad4068851df5a2d96ff448f35.tar.lz dexon-sol-tools-3b46e82625fbb16ad4068851df5a2d96ff448f35.tar.xz dexon-sol-tools-3b46e82625fbb16ad4068851df5a2d96ff448f35.tar.zst dexon-sol-tools-3b46e82625fbb16ad4068851df5a2d96ff448f35.zip |
ERC20 inline return
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol index 8081e7dd3..fce8da7c7 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol @@ -88,7 +88,6 @@ contract MixinERC20Transfer is // | | 36 | | 2. to | // | | 68 | | 3. amount | - bool success; assembly { /////// Token contract address /////// // The token address is found as follows: @@ -116,7 +115,7 @@ contract MixinERC20Transfer is calldatacopy(add(cdStart, 4), 36, 96) /////// Call `token.transferFrom` using the calldata /////// - success := call( + let success := call( gas, // forward all gas token, // call address of token contract 0, // don't send any ETH @@ -141,11 +140,17 @@ contract MixinERC20Transfer is gt(mload(cdStart), 0) ) )) + if success { + return(0, 0) + } + + // Revert with `Error("TRANSFER_FAILED")` + mstore(0, 0x08c379a000000000000000000000000000000000000000000000000000000000) + mstore(32, 0x0000002000000000000000000000000000000000000000000000000000000000) + mstore(64, 0x0000000f5452414e534645525f4641494c454400000000000000000000000000) + mstore(96, 0) + revert(0, 100) } - require( - success, - "TRANSFER_FAILED" - ); } |