-
Notifications
You must be signed in to change notification settings - Fork 97
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): fetch token name from chain #3374
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
type OldPermitInfo = PermitInfo | false | ||
|
||
const UNSUPPORTED: PermitInfo = { type: 'unsupported' } | ||
|
||
/** | ||
* Handles data migration from former way of storing unsupported tokens to the new one | ||
*/ | ||
function migrateData(data: Record<string, OldPermitInfo>): Record<string, PermitInfo> { | ||
const migrated: Record<string, PermitInfo> = {} | ||
|
||
for (const [k, v] of Object.entries(data)) { | ||
if (v === false) { | ||
migrated[k] = UNSUPPORTED | ||
} else { | ||
migrated[k] = v | ||
} | ||
} | ||
|
||
return migrated | ||
} |
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.
This should only be needed until this hits prod and the token-lists preGenerated version is not updated.
export const permittableTokensAtom = atomWithStorage<PermittableTokens>('permittableTokens:v1', { | ||
export const permittableTokensAtom = atomWithStorage<PermittableTokens>('permittableTokens:v2', { |
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.
Bumping the version to not use the old formats anymore
[ | ||
{ | ||
"constant": true, | ||
"inputs": [], | ||
"name": "name", | ||
"outputs": [ | ||
{ | ||
"name": "", | ||
"type": "string" | ||
} | ||
], | ||
"payable": false, | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
] |
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's a duplication, I know, but I want to have just the minimal ABI possible.
Also, if I would use the one from the abis lib, it would create an inner dependency and I don't want that for this lib
export type PermitType = 'dai-like' | 'eip-2612' | 'unsupported' | ||
|
||
export type SupportedPermitInfo = { | ||
export type PermitInfo = { | ||
type: PermitType | ||
version: string | undefined // Some tokens have it different than `1`, and won't work without it | ||
// TODO: make it not optional once token-lists is migrated | ||
name?: string | ||
version?: string | undefined // Some tokens have it different than `1`, and won't work without it | ||
} | ||
type UnsupportedPermitInfo = false | ||
export type PermitInfo = SupportedPermitInfo | UnsupportedPermitInfo |
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.
Biggest change:
- Remove
false
version in favor ofunsupported
type - Add
name
7fee0c2
to
eb1011f
Compare
No top level dependency changes detected. Learn more about Socket for GitHub ↗︎ |
eb1011f
to
d8ee7d3
Compare
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.
Both, the picture is after importing |
Hmm, not able to reproduce it. I imported it via the address, and with this method I can see 2 ways if importing it. Can you share the contents of your It might be that your local check has failed and it cached the failure. |
d8ee7d3
to
0390891
Compare
bbcf125
to
77471bf
Compare
Summary
Fetching token name from the contracts rather than relying on what comes from the token lists
Also, this PR changes the schema in 2 important ways:
name
is now storedfalse
values for unsupported. Instead, it'll have the typeunsupported
A new version of the @cowprotocol/permit-utils should be published from these changes, so it can be used on token-lists repo.
To Test
0x0001a500a6b18995b03f44bb040a5ffc28e45cb0
on mainnet