Skip to content

Commit dbfb1ad

Browse files
paco0xnicholaspai
andauthored
fix(erc7683): EIP712 encoding (#506)
* fix eip712 encoding * reduce duplicate code --------- Co-authored-by: nicholaspai <9457025+nicholaspai@users.noreply.github.com>
1 parent 334269a commit dbfb1ad

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

contracts/erc7683/ERC7683Across.sol

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,23 @@ library ERC7683Permit2Lib {
4949
"uint32 originChainId,",
5050
"uint32 initiateDeadline,",
5151
"uint32 fillDeadline,",
52-
"AcrossOrderData orderData)",
53-
ACROSS_ORDER_DATA_TYPE
52+
"AcrossOrderData orderData)"
5453
);
55-
bytes32 internal constant CROSS_CHAIN_ORDER_TYPE_HASH = keccak256(CROSS_CHAIN_ORDER_TYPE);
54+
55+
bytes internal constant CROSS_CHAIN_ORDER_EIP712_TYPE =
56+
abi.encodePacked(CROSS_CHAIN_ORDER_TYPE, ACROSS_ORDER_DATA_TYPE);
57+
bytes32 internal constant CROSS_CHAIN_ORDER_TYPE_HASH = keccak256(CROSS_CHAIN_ORDER_EIP712_TYPE);
58+
5659
string private constant TOKEN_PERMISSIONS_TYPE = "TokenPermissions(address token,uint256 amount)";
5760
string internal constant PERMIT2_ORDER_TYPE =
58-
string(abi.encodePacked("CrossChainOrder witness)", CROSS_CHAIN_ORDER_TYPE, TOKEN_PERMISSIONS_TYPE));
61+
string(
62+
abi.encodePacked(
63+
"CrossChainOrder witness)",
64+
ACROSS_ORDER_DATA_TYPE,
65+
CROSS_CHAIN_ORDER_TYPE,
66+
TOKEN_PERMISSIONS_TYPE
67+
)
68+
);
5969

6070
// Hashes an order to get an order hash. Needed for permit2.
6171
function hashOrder(CrossChainOrder memory order, bytes32 orderDataHash) internal pure returns (bytes32) {

0 commit comments

Comments
 (0)