aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-10 02:08:28 +0800
committerGitHub <noreply@github.com>2018-07-10 02:08:28 +0800
commit4b60a3cbab3a97125499cb89d9c253deebfb7d2d (patch)
tree3cd745f49d55406e95453bf3efac6383fba5f038 /packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol
parent9f08916cf18ad3e2686811933116122eea0890b9 (diff)
parent17956efe351e3ec0b1e9cdeee8292ebb0b4e563c (diff)
downloaddexon-0x-contracts-4b60a3cbab3a97125499cb89d9c253deebfb7d2d.tar
dexon-0x-contracts-4b60a3cbab3a97125499cb89d9c253deebfb7d2d.tar.gz
dexon-0x-contracts-4b60a3cbab3a97125499cb89d9c253deebfb7d2d.tar.bz2
dexon-0x-contracts-4b60a3cbab3a97125499cb89d9c253deebfb7d2d.tar.lz
dexon-0x-contracts-4b60a3cbab3a97125499cb89d9c253deebfb7d2d.tar.xz
dexon-0x-contracts-4b60a3cbab3a97125499cb89d9c253deebfb7d2d.tar.zst
dexon-0x-contracts-4b60a3cbab3a97125499cb89d9c253deebfb7d2d.zip
Merge branch 'v2-prototype' into abi-gen-ignore-unchanged
Diffstat (limited to 'packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol')
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol83
1 files changed, 43 insertions, 40 deletions
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol
index 3b18ac733..88d2da7d7 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinTransactions.sol
@@ -15,7 +15,7 @@
limitations under the License.
*/
-pragma solidity ^0.4.24;
+pragma solidity 0.4.24;
import "./libs/LibExchangeErrors.sol";
import "./mixins/MSignatureValidator.sol";
@@ -37,7 +37,7 @@ contract MixinTransactions is
address public currentContextAddress;
// Hash for the EIP712 ZeroEx Transaction Schema
- bytes32 constant EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH = keccak256(abi.encodePacked(
+ bytes32 constant internal EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH = keccak256(abi.encodePacked(
"ZeroExTransaction(",
"uint256 salt,",
"address signerAddress,",
@@ -45,41 +45,6 @@ contract MixinTransactions is
")"
));
- /// @dev Calculates EIP712 hash of the Transaction.
- /// @param salt Arbitrary number to ensure uniqueness of transaction hash.
- /// @param signerAddress Address of transaction signer.
- /// @param data AbiV2 encoded calldata.
- /// @return EIP712 hash of the Transaction.
- function hashZeroExTransaction(
- uint256 salt,
- address signerAddress,
- bytes memory data
- )
- internal
- pure
- returns (bytes32 result)
- {
- bytes32 schemaHash = EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH;
- bytes32 dataHash = keccak256(data);
- // Assembly for more efficiently computing:
- // keccak256(abi.encode(
- // EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH,
- // salt,
- // signerAddress,
- // keccak256(data)
- // ));
- assembly {
- let memPtr := mload(64)
- mstore(memPtr, schemaHash)
- mstore(add(memPtr, 32), salt)
- mstore(add(memPtr, 64), and(signerAddress, 0xffffffffffffffffffffffffffffffffffffffff))
- mstore(add(memPtr, 96), dataHash)
- result := keccak256(memPtr, 128)
- }
-
- return result;
- }
-
/// @dev Executes an exchange method call in the context of signer.
/// @param salt Arbitrary number to ensure uniqueness of transaction hash.
/// @param signerAddress Address of transaction signer.
@@ -134,9 +99,47 @@ contract MixinTransactions is
"FAILED_EXECUTION"
);
- // Reset current transaction signer
- // TODO: Check if gas is paid when currentContextAddress is already 0.
- currentContextAddress = address(0);
+ // Reset current transaction signer if it was previously updated
+ if (signerAddress != msg.sender) {
+ currentContextAddress = address(0);
+ }
+ }
+
+ /// @dev Calculates EIP712 hash of the Transaction.
+ /// @param salt Arbitrary number to ensure uniqueness of transaction hash.
+ /// @param signerAddress Address of transaction signer.
+ /// @param data AbiV2 encoded calldata.
+ /// @return EIP712 hash of the Transaction.
+ function hashZeroExTransaction(
+ uint256 salt,
+ address signerAddress,
+ bytes memory data
+ )
+ internal
+ pure
+ returns (bytes32 result)
+ {
+ bytes32 schemaHash = EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH;
+ bytes32 dataHash = keccak256(data);
+
+ // Assembly for more efficiently computing:
+ // keccak256(abi.encode(
+ // EIP712_ZEROEX_TRANSACTION_SCHEMA_HASH,
+ // salt,
+ // signerAddress,
+ // keccak256(data)
+ // ));
+
+ assembly {
+ let memPtr := mload(64)
+ mstore(memPtr, schemaHash)
+ mstore(add(memPtr, 32), salt)
+ mstore(add(memPtr, 64), and(signerAddress, 0xffffffffffffffffffffffffffffffffffffffff))
+ mstore(add(memPtr, 96), dataHash)
+ result := keccak256(memPtr, 128)
+ }
+
+ return result;
}
/// @dev The current function will be called in the context of this address (either 0x transaction signer or `msg.sender`).