-
-
Notifications
You must be signed in to change notification settings - Fork 255
feat: improve token detection #7408
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
|
@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. |
| | NetworkControllerGetNetworkClientByIdAction | ||
| | NetworkControllerGetStateAction | ||
| | TokensControllerGetStateAction | ||
| | TokenDetectionControllerAddDetectedTokensViaPollingAction |
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.
Amazing TY
| | KeyringControllerLockEvent | ||
| | KeyringControllerUnlockEvent |
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.
Nice bug fix to prevent calls when wallet is locked!
| | AccountsControllerSelectedEvmAccountChangeEvent | ||
| | TransactionControllerTransactionConfirmedEvent | ||
| | TransactionControllerIncomingTransactionsReceivedEvent; |
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.
Nice bug fix to ensure the wallet balances and tokens update from various events related to TX updates or Account selection changes.
| if (!this.#useTokenDetection()) { | ||
| return; | ||
| } | ||
|
|
||
| // Check if external services are enabled (websocket requires external services) | ||
| if (!this.#useExternalServices()) { | ||
| return; | ||
| } |
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.
Nice WS fix!
Explanation
Extension UI: MetaMask/metamask-extension#38708
Mobile UI: MetaMask/metamask-mobile#23864
Acceptance Criteria
• Replace all Account API v2 calls with Account API v4 for token auto-detection.
• Continue using RPC-based detection for chains not supported by Account API v4.
• If Account API v4 requests fail, fallback to RPC-based token detection.
• If Account API v4 returns any unprocessed networks, fallback to RPC detection for those networks as well.
References
Checklist
Note
Replaces token auto-detection via Accounts API v2 with v4, delegating supported chains to TokenBalancesController, adding RPC fallbacks/new actions, and improving polling, lock handling, and tests.
TokenDetectionController.detectTokens()addsforceRpcand is exposed viaTokenDetectionController:detectTokens.addDetectedTokensViaPollingand enhancesaddDetectedTokensViaWs; respects prefs/external services; metrics tracking.TokenDetectionController:detectTokenswithforceRpc: true.TokenDetectionController:addDetectedTokensViaPolling.isActive), transaction events handling, per-chain polling grouping/updates, token address filtering, and robust state normalization.unprocessedNetworks, maps to hex; maintains timeout/batching; staked balances handling.index.tsexports for new actions; changelog documents breaking changes and new flows.Written by Cursor Bugbot for commit 10463da. This will update automatically on new commits. Configure here.