Skip to content

Conversation

@juanmigdr
Copy link
Member

@juanmigdr juanmigdr commented Oct 31, 2025

Explanation

The feature to hide tokens is now available for NON-EVM assets but there is no way to bring the assets back. This task involves implementing a token import feature for non-EVM assets. This is crucial for improving user experience by allowing users to import. The implementation should be prioritized to align with upcoming Solana campaigns.

References

https://consensyssoftware.atlassian.net/browse/ASSETS-1425

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

Note

Adds MultichainAssetsController:addAsset to manually add non‑EVM assets (with metadata refresh, dedupe, unignore, and event emission) and updates MultichainBalancesController to set zero balance for newly added assets missing snap balances.

  • Multichain Assets:
    • New Action: Add addAsset to MultichainAssetsController (registers action handler, updates accountsAssets, refreshes metadata, removes from allIgnoredAssets, dedupes, and publishes MultichainAssetsController:accountAssetListUpdated).
    • Types: Extend MultichainAssetsControllerActions with MultichainAssetsControllerAddAssetAction.
    • Tests: Add coverage for adding assets, deduping, unignoring, empty-account adds, and event emission (src/MultichainAssetsController/MultichainAssetsController.test.ts).
  • Multichain Balances:
    • Balance Update Logic: On MultichainAssetsController:accountAssetListUpdated, populate balances for new assets and set balance to { amount: '0', unit: '' } when snap returns no balance (uses accounts map to track added assets).
    • Tests: Add tests for zero-balance behavior and existing/empty state updates (src/MultichainBalancesController/MultichainBalancesController.test.ts).
  • Changelog: Document addAsset addition in packages/assets-controllers/CHANGELOG.md.

Written by Cursor Bugbot for commit e4a6194. This will update automatically on new commits. Configure here.

@juanmigdr juanmigdr marked this pull request as ready for review October 31, 2025 11:20
@juanmigdr juanmigdr requested review from a team as code owners October 31, 2025 11:20
* @returns The updated asset list for the account.
*/
async addAsset(
assetId: CaipAssetType,
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be an array of assetIds since we want to support selecting and adding multiple assets. I also think the function name should be addAssets.

Copy link
Member Author

Choose a reason for hiding this comment

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

In the current implementation in mobile assets are added in a loop 1 by 1. I can change the implementation. Should I also rename the function to addAssets? Or should we have separate functions and if so in which case do we need addAsset (singular)

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call.
If we can add multiple at the controller level, this should reduce state updates and computations. (Update all at once instead of one at a time).

In favour of renaming this if not yet used on clients.

// Triggered when an asset is added to the accountAssets list manually
for (const assetId of assetsWithoutBalance) {
state.balances[accountId][assetId] = { amount: '0', unit: '' };
}
Copy link

Choose a reason for hiding this comment

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

Bug: Bug

The balance update logic has two main issues: it prevents existing asset balances from refreshing with new snap data, potentially leading to stale values or incorrect zeroing of assets. Also, new accounts don't initialize zero balances for assets not returned by the snap, causing inconsistencies.

Fix in Cursor Fix in Web

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