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

fix(erc7683): EIP712 encoding #506

Merged
merged 4 commits into from
Jul 2, 2024
Merged
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
18 changes: 14 additions & 4 deletions contracts/erc7683/ERC7683Across.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,23 @@ library ERC7683Permit2Lib {
"uint32 originChainId,",
"uint32 initiateDeadline,",
"uint32 fillDeadline,",
"AcrossOrderData orderData)",
ACROSS_ORDER_DATA_TYPE
"AcrossOrderData orderData)"
);
bytes32 internal constant CROSS_CHAIN_ORDER_TYPE_HASH = keccak256(CROSS_CHAIN_ORDER_TYPE);

bytes internal constant CROSS_CHAIN_ORDER_EIP712_TYPE =
abi.encodePacked(CROSS_CHAIN_ORDER_TYPE, ACROSS_ORDER_DATA_TYPE);
bytes32 internal constant CROSS_CHAIN_ORDER_TYPE_HASH = keccak256(CROSS_CHAIN_ORDER_EIP712_TYPE);

string private constant TOKEN_PERMISSIONS_TYPE = "TokenPermissions(address token,uint256 amount)";
string internal constant PERMIT2_ORDER_TYPE =
string(abi.encodePacked("CrossChainOrder witness)", CROSS_CHAIN_ORDER_TYPE, TOKEN_PERMISSIONS_TYPE));
string(
abi.encodePacked(
"CrossChainOrder witness)",
ACROSS_ORDER_DATA_TYPE,
CROSS_CHAIN_ORDER_TYPE,
TOKEN_PERMISSIONS_TYPE
)
);

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