-
Notifications
You must be signed in to change notification settings - Fork 1k
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
update TokenInfo extensions type to support objects nested 2 levels deep #140
Conversation
@@ -1,4 +1,4 @@ | |||
type ExtensionValue = string | number | boolean | null; | |||
type ExtensionValue = string | number | boolean | null | undefined; |
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.
what prompted this bit?
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.
The case where a mapping doesn't exist for a token/chain, so there is no value for a key that other entries may have. For example the '42161' object here:
...
"extensions": {
"bridgeInfo": {
"137": {
"tokenAddress": "0x9c2C5fd7b07E95EE044DDeba0E97a665F142394f"
},
"42161": {
"tokenAddress": "0x6314C31A7a1652cE482cffe247E9CB7c3f4BB9aF"
}
}
},
{
...
"extensions": {
"bridgeInfo": {
"137": {
"tokenAddress": "0xD6DF932A45C0f255f85145f286eA0b292B21C90B"
}
}
},
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.
undefined wouldn't be relevant in this case because the key isn't defined, unless I'm missing something?
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.
That's what I initially thought too, but this is the error im getting when not including undefined (using a list with the extensions from the above comment):
Property '"42161"' is incompatible with index signature. Type 'undefined' is not assignable to type 'ExtensionValue | { [key: string]: ExtensionValue; }'
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.
Discussed offline and assumption is that this may be a typescript bug where the typechecker is assuming a uniform type where the same properties need to appear in repeated objects. Decision is to keep undefined in the ExtensionValue type as a workaround for this.
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.
Okay I understand you better with the ways and how u explained to me. I am Moses Okeoghene Ojero from Nigeria
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.
Ok
Thank you |
Hello what is this all about
On Tue, 14 Jun 2022 at 14:12, magid20 ***@***.***> wrote:
Thank you
—
Reply to this email directly, view it on GitHub
<#140 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AS6MVAKR7OJSQJR46AKCFWDVPCALZANCNFSM5YSSZTPQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Ojeroroy16
|
How do I update the token info what do I have to do
…Sent from my iPhone
On 16 Jun 2022, at 18:27, Jordan Frankfurt ***@***.***> wrote:
@JFrankfurt approved this pull request.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
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.
good job ;)
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.
👍
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.
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.
Please confirm
@@ -1,4 +1,4 @@ | |||
type ExtensionValue = string | number | boolean | null; | |||
type ExtensionValue = string | number | boolean | null | undefined; |
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.
Okay I understand you better with the ways and how u explained to me. I am Moses Okeoghene Ojero from Nigeria
There is an inconsistency between the tokenlist schema and the TokenInfo interface. The schema supports objects nested 2 levels deep (as it should), however the interface does not. This PR updates the TokenInfo extensions type/interface to also support 2-level nested objects.
This change was tested by importing a token list JSON file with the nested objects (cross-chain list) and verifying that there are no errors when setting it as a TokenList type.