Last active
November 7, 2019 23:44
-
-
Save feuGeneA/dbf0ac03e1ad00f7980ae5ac1333dc61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/contracts/dev-utils/contracts/src/DevUtils.sol b/contracts/dev-utils/contracts/src/DevUtils.sol | |
index 44166d22b..dba070d65 100644 | |
--- a/contracts/dev-utils/contracts/src/DevUtils.sol | |
+++ b/contracts/dev-utils/contracts/src/DevUtils.sol | |
@@ -19,6 +19,10 @@ | |
pragma solidity ^0.5.5; | |
pragma experimental ABIEncoderV2; | |
+import "@0x/contracts-exchange-libs/contracts/src/LibEIP712ExchangeDomain.sol"; | |
+import "@0x/contracts-exchange-libs/contracts/src/LibOrder.sol"; | |
+import "@0x/contracts-utils/contracts/src/LibEIP712.sol"; | |
+import "@0x/contracts-utils/contracts/src/LibBytes.sol"; | |
import "./OrderValidationUtils.sol"; | |
import "./OrderTransferSimulationUtils.sol"; | |
import "./LibTransactionDecoder.sol"; | |
@@ -29,6 +33,7 @@ import "./EthBalanceChecker.sol"; | |
contract DevUtils is | |
OrderValidationUtils, | |
LibTransactionDecoder, | |
+ LibEIP712ExchangeDomain, | |
EthBalanceChecker, | |
OrderTransferSimulationUtils | |
{ | |
@@ -36,5 +41,32 @@ contract DevUtils is | |
public | |
OrderValidationUtils(_exchange) | |
OrderTransferSimulationUtils(_exchange) | |
+ LibEIP712ExchangeDomain(uint256(0), address(0)) // null args because because we only use constants | |
{} | |
+ | |
+ function getOrderHash(LibOrder.Order calldata order, uint256 chainId, address exchange) | |
+ external | |
+ pure | |
+ returns (bytes32 orderHash) | |
+ { | |
+ return LibOrder.getTypedDataHash( | |
+ LibOrder.Order({ | |
+ makerAddress: order.makerAddress, | |
+ takerAddress: order.takerAddress, | |
+ feeRecipientAddress: order.feeRecipientAddress, | |
+ senderAddress: order.senderAddress, | |
+ makerAssetAmount: order.makerAssetAmount, | |
+ takerAssetAmount: order.takerAssetAmount, | |
+ makerFee: order.makerFee, | |
+ takerFee: order.takerFee, | |
+ expirationTimeSeconds: order.expirationTimeSeconds, | |
+ salt: order.salt, | |
+ makerAssetData: order.makerAssetData, | |
+ takerAssetData: order.takerAssetData, | |
+ makerFeeAssetData: order.makerFeeAssetData, | |
+ takerFeeAssetData: order.takerFeeAssetData | |
+ }), | |
+ LibEIP712.hashEIP712Domain(_EIP712_EXCHANGE_DOMAIN_NAME, _EIP712_EXCHANGE_DOMAIN_VERSION, chainId, exchange) | |
+ ); | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment