-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
fix: price fetching for native tokens with non zero addresses #4952
Merged
+139
−6
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bergeron
changed the title
zero address
fix: price fetching for native tokens with non zero addresses
Nov 20, 2024
7 tasks
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
7 tasks
github-merge-queue bot
pushed a commit
to MetaMask/metamask-extension
that referenced
this pull request
Nov 21, 2024
## **Description** This consolidates the changes from a series of 3 Multichain Asset List PRs that built on each other: 1. Product code (feature branch): #28386 2. Unit tests: #28451 3. e2e tests: #28524 We created separate branches for rapid iteration and isolated testing. The code is now cleaner and stable enough for review and merge into develop, gated by the `PORTFOLIO_VIEW` feature flag. We will introduce another PR to remove this feature flag when we are ready to ship it. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28593?quickstart=1) ## **Related issues** Fixes: https://github.com/orgs/MetaMask/projects/85/views/35?pane=issue&itemId=82217837 ## **Manual testing steps** `PORTFOLIO_VIEW=1 yarn webpack --watch` 1. View tokens across all networks in one unified list. 2. Filter tokens by selected network 3. Crosschain navigation: - Token detail pages update to display data from the appropriate network. - Send/Swap actions automatically adjust the selected network for user convenience. - Ensure that network switch is functional, and sends/swaps happen on correct chain. Known caveats: 1. POL native token market data not populating. Will be addressed here: #28584 and MetaMask/core#4952 2. Native token swapping on different network than selected network swaps incorrect token: #28587 3. Multichain token detection experimental draft: #28380 ## **Screenshots/Recordings** https://github.com/user-attachments/assets/79e7fd2d-9908-4c7a-8134-089cbe6593cc https://github.com/user-attachments/assets/dfb4a54f-a8ae-48a4-a9e7-50327f56054a ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: Jonathan Bursztyn <[email protected]> Co-authored-by: chloeYue <[email protected]> Co-authored-by: seaona <[email protected]> Co-authored-by: Monte Lai <[email protected]> Co-authored-by: Charly Chevalier <[email protected]> Co-authored-by: Pedro Figueiredo <[email protected]> Co-authored-by: MetaMask Bot <[email protected]> Co-authored-by: NidhiKJha <[email protected]> Co-authored-by: sahar-fehri <[email protected]>
@metamaskbot publish-preview |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
Prithpal-Sooriya
approved these changes
Nov 22, 2024
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.
🤫
gambinish
approved these changes
Nov 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
When querying the price API, the native token is usually represented by the zero address. But this is not the case on some chains like polygon, whose native token has a contract
0x0000000000000000000000000000000000001010
.Note: Extension/mobile would also need to use the exported
getNativeTokenAddress
, so they know where to lookup the native prices in state.Draft extension PR: MetaMask/metamask-extension#28584
References
Changelog
@metamask/assets-controllers
chainIdToNativeTokenAddress
to record chains with unique (non-zero) addressesgetNativeTokenAddress()
exported function to return the correct native token address for native assets (either zero addresses, or the unique addresses recorded inchainIdToNativeTokenAddress
)TokenRatesController
market data mapping to usegetNativeTokenAddress
instead of the zero address for native tokens.Checklist