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

feat: actually make permit2 allowance/sign distinct steps #8509

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

gomesalexandre
Copy link
Contributor

Description

Follows up on #8508 by akschually making the steps separate.

While 8508 made sure we use nice copies for permit2 contract allowance / permit2 sign, this actually splits the two into separate steps.

Note, this is for new swapper flow only.

Issue (if applicable)

Risk

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Low

Testing

Engineering

Test with new swapper flow flag on - effectively the same as #8508, except for the first case, where there should be two explicit steps.

0x trade - No Permit2 allowance granted for asset

  • Infinite permit2 allowance grant step should be triggered, with sane looking copies that clearly explain what this is about
  • Permit2 message signing step should be triggered, with sane looking copies as well that clearly explain the diff. between this and the previous step

0x trade - Infinite Permit2 allowance already granted for asset

  • Ensure you have Infinite permit2 allowance already for that asset. You can check it on revoke.cash and confirm Permit2 has unlimited allowance for the asset you're selling. If you don't have it already granted, you can do so by starting the 0x swap flow, grant unlimited allowance, and hard refresh the app
  • 0x swapper should not trigger another Permit2 infinite allowance since already granted
  • 0x swapper should however trigger a Permit2 message signing, with copies looking sane

Non-0x-trade

  • Allowance stages/behaviour should look the same as before.

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

None yet! This only touches the new trade flow under flag.

Screenshots (if applicable)

  • 0x trade - No Permit2 allowance granted for asset

https://jam.dev/c/22ecd401-665f-40ab-910e-c66e71019df9

  • 0x trade - Permit2 allowance granted for asset

https://jam.dev/c/ae7cf74e-90a7-4e97-b929-8e06c8116307

  • Good ol' allowances

https://jam.dev/c/f1cf7bdf-4f3a-4760-9a3d-d813d175b401

@gomesalexandre gomesalexandre requested a review from a team as a code owner January 8, 2025 19:18
@gomesalexandre gomesalexandre linked an issue Jan 8, 2025 that may be closed by this pull request
Comment on lines 109 to 113
return [HopExecutionState.AwaitingAllowanceApproval].includes(state)
}

const isInPermit2SignState = (state: HopExecutionState): boolean => {
return [HopExecutionState.AwaitingPermit2Eip712Sign].includes(state)
Copy link
Member

@woodenfurniture woodenfurniture Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick]

Suggested change
return [HopExecutionState.AwaitingAllowanceApproval].includes(state)
}
const isInPermit2SignState = (state: HopExecutionState): boolean => {
return [HopExecutionState.AwaitingPermit2Eip712Sign].includes(state)
return state === HopExecutionState.AwaitingAllowanceApproval
}
const isInPermit2SignState = (state: HopExecutionState): boolean => {
return state = HopExecutionState.AwaitingPermit2Eip712Sign

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@woodenfurniture woodenfurniture left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works good, get it in

@woodenfurniture woodenfurniture merged commit 18f5c02 into feat_permit2_improve Jan 8, 2025
@woodenfurniture woodenfurniture deleted the feat_permit2_improve_2 branch January 8, 2025 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add distinct step for permit2 contract approval
2 participants