diff options
author | Remco Bloemen <remco@wicked.ventures> | 2018-02-27 08:27:28 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:16 +0800 |
commit | 6f3c6f7599b68be0fa9b952b0aabf879575b00e8 (patch) | |
tree | e8e6ba5c927174655b2f2b435be52c7420c69e3b /packages/contracts | |
parent | 246eca91aa9a816215483cb1a28b6a3d0c73206e (diff) | |
download | dexon-sol-tools-6f3c6f7599b68be0fa9b952b0aabf879575b00e8.tar dexon-sol-tools-6f3c6f7599b68be0fa9b952b0aabf879575b00e8.tar.gz dexon-sol-tools-6f3c6f7599b68be0fa9b952b0aabf879575b00e8.tar.bz2 dexon-sol-tools-6f3c6f7599b68be0fa9b952b0aabf879575b00e8.tar.lz dexon-sol-tools-6f3c6f7599b68be0fa9b952b0aabf879575b00e8.tar.xz dexon-sol-tools-6f3c6f7599b68be0fa9b952b0aabf879575b00e8.tar.zst dexon-sol-tools-6f3c6f7599b68be0fa9b952b0aabf879575b00e8.zip |
Implement EIP712 and ABIv2 in LibOrder
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol index 7f01fc1b7..b548479cd 100644 --- a/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/LibOrder.sol @@ -17,11 +17,12 @@ */ pragma solidity ^0.4.19; +pragma experimental ABIEncoderV2; contract LibOrder { bytes32 constant orderSchemaHash = keccak256( - "address exchangeContractAddress", + "address exchange", "address makerAddress", "address takerAddress", "address makerTokenAddress", @@ -36,6 +37,7 @@ contract LibOrder { ); struct Order { + address exchange; address maker; address taker; address makerToken; @@ -46,30 +48,20 @@ contract LibOrder { uint256 makerFee; uint256 takerFee; uint256 expirationTimestampInSec; - bytes32 orderHash; + uint256 salt; } - - /// @dev Calculates Keccak-256 hash of order with specified parameters. - /// @param orderAddresses Array of order's maker, taker, makerToken, takerToken, and feeRecipient. - /// @param orderValues Array of order's makerTokenAmount, takerTokenAmount, makerFee, takerFee, expirationTimestampInSec, and salt. - /// @return Keccak-256 hash of order. - function getOrderHash(address[5] orderAddresses, uint256[6] orderValues) + + /// @dev Calculates Keccak-256 hash of the order. + /// @param order The order structure. + /// @return Keccak-256 EIP712 hash of the order. + function getOrderHash(Order memory order) public view returns (bytes32 orderHash) { + // TODO: EIP712 is not finalized yet orderHash = keccak256( - address(this), - orderAddresses[0], // maker - orderAddresses[1], // taker - orderAddresses[2], // makerToken - orderAddresses[3], // takerToken - orderAddresses[4], // feeRecipient - orderValues[0], // makerTokenAmount - orderValues[1], // takerTokenAmount - orderValues[2], // makerFee - orderValues[3], // takerFee - orderValues[4], // expirationTimestampInSec - orderValues[5] // salt + orderSchemaHash, + keccak256(order) ); return orderHash; } |