|
1 | 1 | // SPDX-License-Identifier: UNLICENSED
|
2 | 2 | pragma solidity ^0.8.24;
|
3 | 3 |
|
| 4 | +import {IOrders} from "./IOrders.sol"; |
| 5 | +import {UsesPermit2} from "../UsesPermit2.sol"; |
4 | 6 | import {ISignatureTransfer} from "permit2/src/interfaces/ISignatureTransfer.sol";
|
5 |
| -import {IOrders} from "../interfaces/IOrders.sol"; |
6 |
| - |
7 |
| -abstract contract UsesPermit2 { |
8 |
| - /// @param permit - the permit2 single token transfer details. includes a `deadline` and an unordered `nonce`. |
9 |
| - /// @param signer - the signer of the permit2 info; the owner of the tokens. |
10 |
| - /// @param signature - the signature over the permit + witness. |
11 |
| - struct Permit2 { |
12 |
| - ISignatureTransfer.PermitTransferFrom permit; |
13 |
| - address owner; |
14 |
| - bytes signature; |
15 |
| - } |
16 |
| - |
17 |
| - /// @param permit - the permit2 batch token transfer details. includes a `deadline` and an unordered `nonce`. |
18 |
| - /// @param signer - the signer of the permit2 info; the owner of the tokens. |
19 |
| - /// @param signature - the signature over the permit + witness. |
20 |
| - struct Permit2Batch { |
21 |
| - ISignatureTransfer.PermitBatchTransferFrom permit; |
22 |
| - address owner; |
23 |
| - bytes signature; |
24 |
| - } |
25 |
| - |
26 |
| - /// @notice Struct to hold the pre-hashed witness field and the witness type string. |
27 |
| - struct Witness { |
28 |
| - bytes32 witnessHash; |
29 |
| - string witnessTypeString; |
30 |
| - } |
31 |
| - |
32 |
| - /// @notice The Permit2 contract address. |
33 |
| - address immutable permit2Contract; |
34 |
| - |
35 |
| - constructor(address _permit2) { |
36 |
| - permit2Contract = _permit2; |
37 |
| - } |
38 |
| -} |
39 | 7 |
|
40 | 8 | abstract contract OrdersPermit2 is UsesPermit2 {
|
41 | 9 | string constant _OUTPUT_WITNESS_TYPESTRING =
|
@@ -128,72 +96,3 @@ abstract contract OrdersPermit2 is UsesPermit2 {
|
128 | 96 | }
|
129 | 97 | }
|
130 | 98 | }
|
131 |
| - |
132 |
| -abstract contract PassagePermit2 is UsesPermit2 { |
133 |
| - string constant _ENTER_WITNESS_TYPESTRING = |
134 |
| - "EnterWitness witness)EnterWitness(uint256 rollupChainId,address rollupRecipient)TokenPermissions(address token,uint256 amount)"; |
135 |
| - |
136 |
| - bytes32 constant _ENTER_WITNESS_TYPEHASH = keccak256("EnterWitness(uint256 rollupChainId,address rollupRecipient)"); |
137 |
| - |
138 |
| - string constant _EXIT_WITNESS_TYPESTRING = |
139 |
| - "ExitWitness witness)ExitWitness(address hostRecipient)TokenPermissions(address token,uint256 amount)"; |
140 |
| - |
141 |
| - bytes32 constant _EXIT_WITNESS_TYPEHASH = keccak256("ExitWitness(address hostRecipient)"); |
142 |
| - |
143 |
| - /// @notice Struct to hash Enter witness data into a 32-byte witness field, in an EIP-712 compliant way. |
144 |
| - struct EnterWitness { |
145 |
| - uint256 rollupChainId; |
146 |
| - address rollupRecipient; |
147 |
| - } |
148 |
| - |
149 |
| - /// @notice Struct to hash Exit witness data into a 32-byte witness field, in an EIP-712 compliant way. |
150 |
| - struct ExitWitness { |
151 |
| - address hostRecipient; |
152 |
| - } |
153 |
| - |
154 |
| - /// @notice Encode & hash the rollupChainId and rollupRecipient for use as a permit2 witness. |
155 |
| - /// @return _witness - the hashed witness and its typestring. |
156 |
| - function enterWitness(uint256 rollupChainId, address rollupRecipient) |
157 |
| - public |
158 |
| - pure |
159 |
| - returns (Witness memory _witness) |
160 |
| - { |
161 |
| - _witness.witnessHash = |
162 |
| - keccak256(abi.encode(_ENTER_WITNESS_TYPEHASH, EnterWitness(rollupChainId, rollupRecipient))); |
163 |
| - _witness.witnessTypeString = _ENTER_WITNESS_TYPESTRING; |
164 |
| - } |
165 |
| - |
166 |
| - /// @notice Hash the hostRecipient for use as a permit2 witness. |
167 |
| - /// @return _witness - the hashed witness and its typestring. |
168 |
| - function exitWitness(address hostRecipient) public pure returns (Witness memory _witness) { |
169 |
| - _witness.witnessHash = keccak256(abi.encode(_EXIT_WITNESS_TYPEHASH, ExitWitness(hostRecipient))); |
170 |
| - _witness.witnessTypeString = _EXIT_WITNESS_TYPESTRING; |
171 |
| - } |
172 |
| - |
173 |
| - /// @notice Transfer tokens using permit2. |
174 |
| - /// @param _witness - the hashed witness and its typestring. |
175 |
| - /// @param permit2 - the Permit2 information. |
176 |
| - function _permitWitnessTransferFrom(Witness memory _witness, Permit2 calldata permit2) internal { |
177 |
| - ISignatureTransfer(permit2Contract).permitWitnessTransferFrom( |
178 |
| - permit2.permit, |
179 |
| - _selfTransferDetails(permit2.permit.permitted.amount), |
180 |
| - permit2.owner, |
181 |
| - _witness.witnessHash, |
182 |
| - _witness.witnessTypeString, |
183 |
| - permit2.signature |
184 |
| - ); |
185 |
| - } |
186 |
| - |
187 |
| - /// @notice Construct TransferDetails transferring a balance to this contract, for passing to permit2. |
188 |
| - /// @dev always transfers the full amount to address(this). |
189 |
| - /// @param amount - the amount to transfer to this contract. |
190 |
| - /// @return transferDetails - the SignatureTransferDetails generated. |
191 |
| - function _selfTransferDetails(uint256 amount) |
192 |
| - internal |
193 |
| - view |
194 |
| - returns (ISignatureTransfer.SignatureTransferDetails memory transferDetails) |
195 |
| - { |
196 |
| - transferDetails.to = address(this); |
197 |
| - transferDetails.requestedAmount = amount; |
198 |
| - } |
199 |
| -} |
0 commit comments