Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use EIP712s hashTypedData functions #1306

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 14 additions & 19 deletions source/swap-erc20/contracts/SwapERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -710,27 +710,22 @@ contract SwapERC20 is ISwapERC20, Ownable, EIP712 {
address senderToken,
uint256 senderAmount
) private view returns (bytes32) {
return
return _hashTypedData(
keccak256(
abi.encodePacked(
"\x19\x01", // EIP191: Indicates EIP712
DOMAIN_SEPARATOR,
keccak256(
abi.encode(
ORDER_TYPEHASH,
nonce,
expiry,
signerWallet,
signerToken,
signerAmount,
protocolFee,
senderWallet,
senderToken,
senderAmount
)
)
abi.encode(
ORDER_TYPEHASH,
nonce,
expiry,
signerWallet,
signerToken,
signerAmount,
protocolFee,
senderWallet,
senderToken,
senderAmount
)
);
)
);
}

/**
Expand Down
29 changes: 12 additions & 17 deletions source/swap/contracts/Swap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -465,25 +465,20 @@ contract Swap is ISwap, Ownable2Step, EIP712 {
* @return bytes32 A keccak256 abi.encodePacked value
*/
function _getOrderHash(Order calldata order) private view returns (bytes32) {
return
return _hashTypedDataV4(
keccak256(
abi.encodePacked(
"\x19\x01", // EIP191: Indicates EIP712
DOMAIN_SEPARATOR,
keccak256(
abi.encode(
ORDER_TYPEHASH,
order.nonce,
order.expiry,
protocolFee,
keccak256(abi.encode(PARTY_TYPEHASH, order.signer)),
keccak256(abi.encode(PARTY_TYPEHASH, order.sender)),
order.affiliateWallet,
order.affiliateAmount
)
)
abi.encode(
ORDER_TYPEHASH,
order.nonce,
order.expiry,
protocolFee,
keccak256(abi.encode(PARTY_TYPEHASH, order.signer)),
keccak256(abi.encode(PARTY_TYPEHASH, order.sender)),
order.affiliateWallet,
order.affiliateAmount
)
);
)
);
}

/**
Expand Down
Loading