-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: permit2 for token flows #63
Conversation
7414f2d
to
7735bff
Compare
4050e2e
to
ff795e8
Compare
TODO:
|
* forge install: permit2 * remove vendored contracts * move IOrders to interfaces/ * move permit2 to folder
test: permit2 flows
@@ -118,8 +128,7 @@ abstract contract OrderOrigin { | |||
/// @param token - The token to transfer. | |||
/// @custom:emits Sweep | |||
/// @custom:reverts OnlyBuilder if called by non-block builder | |||
function sweep(address recipient, address token) public { | |||
if (msg.sender != block.coinbase) revert OnlyBuilder(); | |||
function sweep(address recipient, address token) external { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did we make a decision on specifying a min amount swept here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it isn't strictly necessary because sweep
should be submitted in a bundle with the corresponding initiate
calls; if another Filler gets their bundle submitted first, the second bundle's initiate
calls will be rejected (because of the tx nonce) so the bundle should be rejected for that reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests pass, code is clean, architecture makes sense
uint256 num = outputs.length; | ||
bytes32[] memory hashes = new bytes32[](num); | ||
for (uint256 i = 0; i < num; ++i) { | ||
hashes[i] = keccak256(abi.encode(_OUTPUT_TYPEHASH, outputs[i])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so quick note, if the output ever includes another struct or a dynamic type, we can't use abi.encode here. This may be worth documenting here and near the output structdef
returns (Witness memory _witness) | ||
{ | ||
_witness.witnessHash = | ||
keccak256(abi.encode(_ENTER_WITNESS_TYPEHASH, EnterWitness(rollupChainId, rollupRecipient))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same note. if the struct ever includes dynamic types we can't use abi.encode
implement permit2 signature-based token transfers for all token flows