-
-
Notifications
You must be signed in to change notification settings - Fork 249
fix: token selector issues #6358
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
Conversation
existingAssets[accountGroupId] = {}; | ||
for (const [network, chainAssets] of Object.entries(accountAssets)) { | ||
existingAssets[accountGroupId][network] = [...chainAssets]; | ||
} |
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 was tricky to spot. By reusing the array from the memoized object and later pushing to it, the new test was failing unless it was checked on isolation. This could have caused problems in the clients as well.
)) { | ||
const accountGroupId = accountsMap[accountAddress]; | ||
const account = accountsMap[accountAddress.toLowerCase()]; | ||
if (!account) { |
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 not be possible, but better not to take any chances that can crash the app.
const tokenAddress = token.address as Hex; | ||
const accountGroupId = accountsMap[accountAddress]; | ||
const account = accountsMap[accountAddress]; | ||
if (!account) { |
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 not be possible, but better not to take any chances that can crash the app.
type MultichainAccountType = Exclude< | ||
InternalAccount['type'], | ||
`eip155:${string}` | ||
>; |
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.
Going to use this type from the account instead of the generic evm
and multichain
. This will allow us to determine the type of bitcoin account the asset belongs to.
This future issue was raised recently on slack.
@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.
|
@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.
|
chainAccounts, | ||
)) { | ||
const accountGroupId = accountsMap[accountAddress]; | ||
const account = accountsMap[accountAddress.toLowerCase()]; |
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.
toLowerCase()
here because accountsByChainId
in mobile uses checksumed addresses, unlike every other controller state.
This is only temporary though, because as soon as native addresses are returned in token balances, all this code can go.
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> The format for EVM addresses for AccountTrackerController in mobile differs from extension and from the other controller states. This was causing it to miss native account balances. It also uses the correct internal account type in the assets, so that BTC account types can be identified. Finally, it fixes an issue with the `mergeAssets` function mutating internal parts of cached objects. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [X] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
Explanation
The format for EVM addresses for AccountTrackerController in mobile differs from extension and from the other controller states. This was causing it to miss native account balances.
It also uses the correct internal account type in the assets, so that BTC account types can be identified.
Finally, it fixes an issue with the
mergeAssets
function mutating internal parts of cached objects.References
Checklist