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(tokens): add more fields to metadata #265

Merged
merged 6 commits into from
Oct 2, 2023
Merged

Conversation

satish-ravi
Copy link
Contributor

@satish-ravi satish-ravi commented Sep 29, 2023

Fixes ACT-923, adds fields needed for the new token details screen.

  • showZeroBalance - true for tokens to be displayed when balance is 0
  • isStableCoin - true for core stable tokens
  • isCashInEligible - true for tokens that can be cashed-in
  • isCashOutEligible - true for tokens that can be cashed-out
  • infoUrl - link to coingecko
  • networkIconUrl - computed, set for all non native tokens with the native token's image url

@cajubelt
Copy link
Contributor

for network name could we just use a static mapping from network id to network name in app code?

@cajubelt
Copy link
Contributor

hidePriceDelta is a little weird, should it be isStableCoin instead?

@MuckT
Copy link
Contributor

MuckT commented Sep 29, 2023

@cajubelt I don't think we should do a static mapping for networkName as it doesn't account for chain forks e.g BTC > BTH.

@cajubelt
Copy link
Contributor

@MuckT so if a chain forked what would you do? Seems like you would need app code changes no matter what to support both forks right?

@MuckT
Copy link
Contributor

MuckT commented Sep 29, 2023

@cajubelt I am not sure we would need app code changes to support both forks with dynamic configs. Also if we did have a static mapping wouldn't it display the incorrect networkName on older app versions?

@cajubelt
Copy link
Contributor

cajubelt commented Sep 29, 2023

@MuckT to my knowledge, in past forks, one branch (I'm going to call this "the trunk", as opposed to "the fork") has kept the same name. Like Ethereum vs Ethereum Classic. Seems like it would take full-stack code changes to turn on support for the fork. Is it such a bad thing to just default to the trunk and add support for the fork in a later version if it grows popular enough to warrant that? I'm not sure we even have a choice

edit: I think I mis-read your message thinking you agreed that we would need frontend code changes to support a new network. I love the ambition of getting the wallet in a state where we don't need code changes to support new networks, but I'm not sure it's realistic in the near term. For instance, currently we have an enum "NetworkId" that covers all the network id's supported by the current app version. At the very least, that would need to get removed-- but it's already used in over a hundred places

@satish-ravi
Copy link
Contributor Author

For the forking use-case, as @cajubelt mentions, at a minimum we'd need to add a new network id for the forked network. So we can always add the new name along with that change. There could be some benefits of having the name remotely configurable, but this actually doesn't seem the right place to do it. The name is a 1:1 mapping to the network id so we don't need to duplicate it for all tokens. I think we can start off with just a static map in the wallet for now, as the change in names for existing network ids (at least what we have currently now) has never happened. We can always make it configurable through a dynamic config mapping network ids to names or even just an entry in the translation file in future releases

@MuckT
Copy link
Contributor

MuckT commented Sep 29, 2023

@cajubelt @satish-ravi I was hopefully we could support new networks without an app release, but as you mention with networkIds We'd need an app release to update those mappings. With that in mind a static mapping sounds like it will work well.

Copy link
Contributor

@MuckT MuckT left a comment

Choose a reason for hiding this comment

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

I really like that you added schema validation and new tests the computed field networkIconUrl 👨‍🍳

Copy link
Member

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

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

Great!

src/types.ts Outdated
@@ -41,12 +41,18 @@ export interface TokenInfoJSON {
pegTo?: string
isSupercharged?: boolean
bridge?: string
isStableCoin?: boolean
isZeroState?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need this? And would there be a more descriptive name?

Suggested change
isZeroState?: boolean
showZeroBalance?: boolean

Copy link
Contributor Author

@satish-ravi satish-ravi Oct 2, 2023

Choose a reason for hiding this comment

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

This is for showing the token even if the balance is zero in the new Assets screen. And I've updated the name, I like it better too 😄

README.md Outdated
Comment on lines 28 to 31
| `isStableCoin` | Whether the token is a stable coin and the price is not expected to change |
| `isZeroState` | Whether the token is displayed even if the balance is zero |
| `isCashInEligible` | Whether the token is eligible for cash-ins |
| `isCashOutEligible` | Whether the token is eligible for cash-outs |
Copy link
Member

@jeanregisser jeanregisser Oct 2, 2023

Choose a reason for hiding this comment

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

Do we expect outside contributors to fill these?
The documented fields in the README were only for the required fields to keep external contributions as simple as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, these are internal only. I've removed these and included some of these in types.ts where the name isn't completely obvious.

@satish-ravi satish-ravi merged commit 73fb10e into main Oct 2, 2023
@satish-ravi satish-ravi deleted the satish/act-923 branch October 2, 2023 18: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.

5 participants