-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: nicholaspai <[email protected]>
- Loading branch information
1 parent
4e73544
commit 37c7dc9
Showing
8 changed files
with
147 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import "./OriginSettler.sol"; | ||
import "./DestinationSettler.sol"; | ||
import "./IPermit2.sol"; | ||
import {GaslessCrossChainOrder} from "./ERC7683.sol"; | ||
|
||
bytes constant CALL_BY_USER_TYPE = abi.encodePacked( | ||
"CallByUser(", "address user,", "Asset asset,", "uint64 chainId,", "bytes32 delegateCodeHash,", "Call[] calls)" | ||
); | ||
|
||
bytes constant CALL_TYPE = abi.encodePacked("Call(", "address target,", "bytes callData,", "uint256 value)"); | ||
|
||
bytes constant ASSET_TYPE = abi.encodePacked("Asset(", "address token,", "uint256 amount)"); | ||
|
||
bytes32 constant CALL_BY_USER_TYPE_HASH = keccak256(CALL_BY_USER_TYPE); | ||
|
||
library ERC7683Permit2Lib { | ||
bytes internal constant GASLESS_CROSS_CHAIN_ORDER_TYPE = abi.encodePacked( | ||
"GaslessCrossChainOrder(", | ||
"address originSettler,", | ||
"address user,", | ||
"uint256 nonce,", | ||
"uint256 originChainId,", | ||
"uint32 openDeadline,", | ||
"uint32 fillDeadline,", | ||
"bytes32 orderDataType,", | ||
"CallByUser orderData)" | ||
); | ||
|
||
bytes internal constant GASLESS_CROSS_CHAIN_ORDER_EIP712_TYPE = | ||
abi.encodePacked(GASLESS_CROSS_CHAIN_ORDER_TYPE, CALL_BY_USER_TYPE, CALL_TYPE, ASSET_TYPE); | ||
bytes32 internal constant GASLESS_CROSS_CHAIN_ORDER_TYPE_HASH = keccak256(GASLESS_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( | ||
"GaslessCrossChainOrder witness)", CALL_BY_USER_TYPE, GASLESS_CROSS_CHAIN_ORDER_TYPE, TOKEN_PERMISSIONS_TYPE | ||
) | ||
); | ||
|
||
// Hashes an order to get an order hash. Needed for permit2. | ||
function hashOrder(GaslessCrossChainOrder memory order, bytes32 orderDataHash) internal pure returns (bytes32) { | ||
return keccak256( | ||
abi.encode( | ||
GASLESS_CROSS_CHAIN_ORDER_TYPE_HASH, | ||
order.originSettler, | ||
order.user, | ||
order.nonce, | ||
order.originChainId, | ||
order.openDeadline, | ||
order.fillDeadline, | ||
order.orderDataType, | ||
orderDataHash | ||
) | ||
); | ||
} | ||
|
||
function hashUserCallData(CallByUser memory userCallData) internal pure returns (bytes32) { | ||
return keccak256( | ||
abi.encode( | ||
CALL_BY_USER_TYPE_HASH, | ||
userCallData.user, | ||
userCallData.asset, | ||
userCallData.chainId, | ||
userCallData.delegateCodeHash, | ||
userCallData.calls | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
pragma solidity ^0.8.0; | ||
|
||
interface IPermit2 { | ||
struct TokenPermissions { | ||
address token; | ||
uint256 amount; | ||
} | ||
|
||
struct PermitTransferFrom { | ||
TokenPermissions permitted; | ||
uint256 nonce; | ||
uint256 deadline; | ||
} | ||
|
||
struct SignatureTransferDetails { | ||
address to; | ||
uint256 requestedAmount; | ||
} | ||
|
||
function permitWitnessTransferFrom( | ||
PermitTransferFrom memory permit, | ||
SignatureTransferDetails calldata transferDetails, | ||
address owner, | ||
bytes32 witness, | ||
string calldata witnessTypeString, | ||
bytes calldata signature | ||
) external; | ||
|
||
function transferFrom(address from, address to, uint160 amount, address token) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.