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(permit): load pre generated permit info #3316

Merged
merged 12 commits into from
Nov 3, 2023

Conversation

alfetopito
Copy link
Collaborator

@alfetopito alfetopito commented Nov 1, 2023

Summary

Part of cowprotocol/token-lists#293

Depends on cowprotocol/token-lists#299

Use the pre-generated permit info data.

  1. When checking whether the token is permittable, check first on the pre-generated data
  • Only when that's not available, check the token is permittable locally
  1. In the token selector, use a combination of pre-generated data and locally fetched permit info
  • With that info, show the flag in the dropdown selector
image image

To Test

  1. Open the token selector
  • There should be tokens with the gas free flag
  1. Pick a permittable token you don't have allowance for
  2. Check the network tab and filter for PermitInfo
  • There should be a request for PermitInfo.<chain id>.json for the current network you are on
  • Switching to different tokens, to another tab, switching to a different window should NOT trigger a new request of this file
  1. Place order
  • Should pop up to sign permit
  • Order appData should contain permit pre hook
  1. Load another token that's permittable and is not in the list, such as 0x30d20208d987713f46dfd34ef128bb16c404d10f (SD) on mainnet
  2. Pick it as a sell token
  • Permit info for it should be loaded and stored on permittableTokens:v1 localStorage
  1. Open the token selector and search for the token that was just added
  • Should have the gas free flag.
  1. Swap it
  • Should work like the one from the list

@alfetopito alfetopito self-assigned this Nov 1, 2023
Copy link

vercel bot commented Nov 1, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cosmos ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 3, 2023 2:55pm
swap-dev ✅ Ready (Inspect) Visit Preview Nov 3, 2023 2:55pm
widget-configurator ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 3, 2023 2:55pm


// TODO: obviously not final
export const PRE_GENERATED_PERMIT_URL =
'https://raw.githubusercontent.com/cowprotocol/token-lists/bd247cad5146da28ff2fb4704e4ae444642a5535/src/public/PermitInfo'
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Waiting on cowprotocol/token-lists#299 to be merged

Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

Beautiful ❤️, nice to see how all fits together: new token modal, script, permit check, library etc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants