Overview
TheHashing mixin provides EIP712 typed structured data hashing functionality for orders. It inherits from OpenZeppelin’s EIP712 contract and implements order hashing according to the EIP712 standard, which mirrors the hashing done in client libraries used to prepare and sign orders.
Source: src/exchange/mixins/Hashing.sol
State Variables
domainSeparator
_domainSeparatorV4() function from the parent EIP712 contract.
Constructor
Hashing contract by setting the domain separator and calling the parent EIP712 constructor.
Parameters
name(string): The name of the signing domainversion(string): The current major version of the signing domain
Functions
hashOrder
Order object according to the EIP712 procedure for hashing and signing typed structured data.
Parameters
order(Order): The order object to hash, containing fields such as:salt: Random value for uniquenessmaker: Address of the order makersigner: Address of the signertaker: Address of the taker (or zero address for any taker)tokenId: The token ID being tradedmakerAmount: Amount provided by makertakerAmount: Amount provided by takerexpiration: Order expiration timestampnonce: Maker’s nonce for order cancellationfeeRateBps: Fee rate in basis pointsside: Order side (buy/sell)signatureType: Type of signature used
Returns
bytes32: The typed data hash of the order object
Implementation Details
The order hash is computed by:- Encoding all order fields with the
ORDER_TYPEHASH - Hashing the encoded data with
keccak256 - Passing the hash through
_hashTypedDataV4()to combine it with the domain separator