Skip to content

fix: prevent TokenBalancesController updating account balance to 0 while multicall contract failed - #5975

Merged
stanleyyconsensys merged 3 commits into
mainfrom
fix/token-balance-update-multicall-contract
Jun 13, 2025
Merged

fix: prevent TokenBalancesController updating account balance to 0 while multicall contract failed#5975
stanleyyconsensys merged 3 commits into
mainfrom
fix/token-balance-update-multicall-contract

Conversation

@stanleyyconsensys

@stanleyyconsensysstanleyyconsensys commented Jun 13, 2025

Copy link
Copy Markdown
Contributor

Explanation

This PR fix:
TokenBalancesController updating account balance to 0 while multicall contract failed

in AssetsControllers/TokenBalancesController -> updateBalancesByChainId
it use multicall contract to continually poll the balance and update the balance for the account,
however even if the contract request failed, it will continue to update

the root cause is because the multicall return an array of MulticallResult object even it failed, but the value of the balance may become undefined

hence, the updateBalancesByChainId will continue using this value to process the logic, and result update the balance to 0

Attached the extension screen that impacted by above logic

image

References

Changelog

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@stanleyyconsensys
stanleyyconsensys requested a review from a team as a code ownerJune 13, 2025 05:14
@stanleyyconsensysstanleyyconsensys changed the title fix: token bal should not update while rpc failfix: prevent TokenBalancesController updating account balance to 0 while multicall contract failedJun 13, 2025
@stanleyyconsensys
stanleyyconsensys requested a review from a team as a code ownerJune 13, 2025 05:28
@stanleyyconsensysstanleyyconsensys self-assigned this Jun 13, 2025
@github-project-automationgithub-project-automationBot moved this to Needs dev review in PR review queueJun 13, 2025

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

as the default state is empty, if the balance not update, the state should remain the same

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why the contract call is failing on SEI ?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Infura block height not sync issue, but anyway, it can be any reason from any RPC

@salimtbsalimtb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@github-project-automationgithub-project-automationBot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queueJun 13, 2025
@salimtb

Copy link
Copy Markdown
Contributor

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
"@metamask-previews/account-tree-controller": "0.1.1-preview-4193b35",
"@metamask-previews/accounts-controller": "30.0.0-preview-4193b35",
"@metamask-previews/address-book-controller": "6.1.0-preview-4193b35",
"@metamask-previews/announcement-controller": "7.0.3-preview-4193b35",
"@metamask-previews/app-metadata-controller": "1.0.0-preview-4193b35",
"@metamask-previews/approval-controller": "7.1.3-preview-4193b35",
"@metamask-previews/assets-controllers": "68.1.0-preview-4193b35",
"@metamask-previews/base-controller": "8.0.1-preview-4193b35",
"@metamask-previews/bridge-controller": "32.1.2-preview-4193b35",
"@metamask-previews/bridge-status-controller": "29.1.1-preview-4193b35",
"@metamask-previews/build-utils": "3.0.3-preview-4193b35",
"@metamask-previews/chain-agnostic-permission": "0.7.0-preview-4193b35",
"@metamask-previews/composable-controller": "11.0.0-preview-4193b35",
"@metamask-previews/controller-utils": "11.10.0-preview-4193b35",
"@metamask-previews/delegation-controller": "0.4.0-preview-4193b35",
"@metamask-previews/earn-controller": "1.1.0-preview-4193b35",
"@metamask-previews/eip1193-permission-middleware": "0.1.0-preview-4193b35",
"@metamask-previews/ens-controller": "16.0.0-preview-4193b35",
"@metamask-previews/error-reporting-service": "1.0.0-preview-4193b35",
"@metamask-previews/eth-json-rpc-provider": "4.1.8-preview-4193b35",
"@metamask-previews/foundryup": "1.0.0-preview-4193b35",
"@metamask-previews/gas-fee-controller": "23.0.0-preview-4193b35",
"@metamask-previews/json-rpc-engine": "10.0.3-preview-4193b35",
"@metamask-previews/json-rpc-middleware-stream": "8.0.7-preview-4193b35",
"@metamask-previews/keyring-controller": "22.0.2-preview-4193b35",
"@metamask-previews/logging-controller": "6.0.4-preview-4193b35",
"@metamask-previews/message-manager": "12.0.1-preview-4193b35",
"@metamask-previews/multichain-api-middleware": "0.4.0-preview-4193b35",
"@metamask-previews/multichain-network-controller": "0.8.0-preview-4193b35",
"@metamask-previews/multichain-transactions-controller": "2.0.0-preview-4193b35",
"@metamask-previews/name-controller": "8.0.3-preview-4193b35",
"@metamask-previews/network-controller": "23.6.0-preview-4193b35",
"@metamask-previews/notification-services-controller": "10.0.0-preview-4193b35",
"@metamask-previews/permission-controller": "11.0.6-preview-4193b35",
"@metamask-previews/permission-log-controller": "3.0.3-preview-4193b35",
"@metamask-previews/phishing-controller": "12.6.0-preview-4193b35",
"@metamask-previews/polling-controller": "13.0.0-preview-4193b35",
"@metamask-previews/preferences-controller": "18.1.0-preview-4193b35",
"@metamask-previews/profile-sync-controller": "17.1.0-preview-4193b35",
"@metamask-previews/queued-request-controller": "10.0.0-preview-4193b35",
"@metamask-previews/rate-limit-controller": "6.0.3-preview-4193b35",
"@metamask-previews/remote-feature-flag-controller": "1.6.0-preview-4193b35",
"@metamask-previews/sample-controllers": "0.1.0-preview-4193b35",
"@metamask-previews/seedless-onboarding-controller": "1.0.0-preview-4193b35",
"@metamask-previews/selected-network-controller": "22.1.0-preview-4193b35",
"@metamask-previews/signature-controller": "30.0.0-preview-4193b35",
"@metamask-previews/token-search-discovery-controller": "3.3.0-preview-4193b35",
"@metamask-previews/transaction-controller": "57.3.0-preview-4193b35",
"@metamask-previews/user-operation-controller": "36.0.0-preview-4193b35"
}

@stanleyyconsensys
stanleyyconsensysforce-pushed the fix/token-balance-update-multicall-contract branch from 4193b35 to da70a75CompareJune 13, 2025 09:25
@stanleyyconsensys
stanleyyconsensys enabled auto-merge (squash) June 13, 2025 09:29
@stanleyyconsensys
stanleyyconsensys merged commit f6622df into mainJun 13, 2025
@stanleyyconsensys
stanleyyconsensys deleted the fix/token-balance-update-multicall-contract branch June 13, 2025 09:30
@github-project-automationgithub-project-automationBot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queueJun 13, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants

@stanleyyconsensys@salimtb