Skip to content
Open
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
2 changes: 1 addition & 1 deletion snapshots/ERC7683Allocator_openFor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"openFor_simpleOrder_userHimself": "171750"
"openFor_simpleOrder_userHimself": "171785"
}
5 changes: 5 additions & 0 deletions src/allocators/lib/ERC7683AllocatorLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ library ERC7683AllocatorLib {
error InvalidRecipientCallbackLength();
error InvalidOrderDataType(bytes32 orderDataType, bytes32 expectedOrderDataType);
error InvalidOriginSettler(address originSettler, address expectedOriginSettler);
error InvalidOriginChainId(uint256 originChainId, uint256 expectedChainId);
error InvalidOrderData(bytes orderData);

/// @notice Checks and decodes the order data for a gasless cross-chain order.
Expand Down Expand Up @@ -78,6 +79,10 @@ library ERC7683AllocatorLib {
if (order.originSettler != address(this)) {
revert InvalidOriginSettler(order.originSettler, address(this));
}
// Check that the order is intended for the current chain
if (order.originChainId != block.chainid) {
revert InvalidOriginChainId(order.originChainId, block.chainid);
}

// Decode the orderData
(orderData, deposit) = decodeOrderData(order.orderData);
Expand Down
10 changes: 10 additions & 0 deletions test/ERC7683Allocator.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ contract ERC7683Allocator_open is MockAllocator {
}

contract ERC7683Allocator_openFor is MockAllocator {
function test_revert_InvalidOriginChainId(uint256 wrongChainId) public {
vm.assume(wrongChainId != block.chainid);
IOriginSettler.GaslessCrossChainOrder memory gasless = _getGaslessCrossChainOrder();
gasless.originChainId = wrongChainId;
vm.prank(user);
vm.expectRevert(
abi.encodeWithSelector(ERC7683AL.InvalidOriginChainId.selector, wrongChainId, block.chainid)
);
erc7683Allocator.openFor(gasless, '', '');
}
function test_revert_InvalidOrderDataType() public {
// Order data type is invalid
bytes32 falseOrderDataType = keccak256('false');
Expand Down