Skip to content

chore(stellar): read asset metadata from controller and gated by FF and local config - #493

Merged
stanleyyconsensys merged 6 commits into
mainfrom
dev/stellar/asset-metadata-messenger
Oct 21, 2026
Merged

stanleyyconsensys merged 6 commits into
mainfrom
dev/stellar/asset-metadata-messenger

Conversation

@stanleyyconsensys

@stanleyyconsensys stanleyyconsensys commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

This PR does

  • Adds gated AssetsController metadata reads to the Stellar Snap, retaining snap-state fallback.

References

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@stanleyyconsensys
stanleyyconsensys requested a balanced review from Copilot October 21, 2026 10:40
(decimalPlaces && decimalPlaces > STELLAR_DECIMAL_PLACES) ||
// > Max value
toSmallestUnit(amount).gt(new BigNumber(MAX_INT64).toString())
toSmallestUnit(amount).gt(MAX_INT64)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is not related to this PR, but just a small refactor

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.

very worthwhile!

* @returns Whether AssetsController reads are active.
*/
async isMigrationEnabled(): Promise<boolean> {
if (!AppConfig.enableAssetMigration) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

make sure we dont read controller when we are not ready

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 a specific configuration for it? why not rely on the feqature flag only?

@stanleyyconsensys stanleyyconsensys Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just to gate when the PR merge, but a release ship, and someone turn on the FF when we dont wanna to read from controller

if (isCoreClassicAsset(asset)) {
const { sponsor, limit } = asset.balance.metadata;
const { sponsor } = asset.balance.metadata;
const limit = normalizeCoreTrustlineLimit(asset.balance.metadata.limit);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is try to resolve the inconsistency trustline limit, but we are not yet using this yet

Copilot AI 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.

🟡 Changes recommended

Trustline normalization interprets whole-token display limits as stroops, understating them by a factor of 10,000,000.

1 open issue
What changed in this PR

Adds gated AssetsController metadata reads to the Stellar Snap, retaining snap-state fallback.

Changes:

  • Wire controller access behind local configuration and a remote feature flag.
  • Add metadata mapping, SEP-41 fetching, and trustline-limit normalization.
  • Update tests, permissions, dependencies, and release notes.
File Description
yarn.lock Record new dependencies.
packages/​stellar-wallet-snap/​src/​services/​assets/​AssetsService.ts Gate migration reads locally.
packages/​stellar-wallet-snap/​src/​services/​assets/​AssetsService.test.ts Test migration gating.
packages/​stellar-wallet-snap/​src/​services/​assets/​api.ts Normalize trustline limits.
packages/​stellar-wallet-snap/​src/​services/​assets/​api.test.ts Test limit normalization.
packages/​stellar-wallet-snap/​src/​services/​asset-metadata/​utils.ts Accept supplied metadata icons.
packages/​stellar-wallet-snap/​src/​services/​asset-metadata/​AssetMetadataService.ts Read controller metadata with fallback.
packages/​stellar-wallet-snap/​src/​services/​asset-metadata/​AssetMetadataService.test.ts Cover metadata reads and fallback.
packages/​stellar-wallet-snap/​src/​services/​asset-metadata/​__mocks__/​assets.fixtures.ts Supply the new service dependency.
packages/​stellar-wallet-snap/​src/​context.ts Wire controller providers and services.
packages/​stellar-wallet-snap/​src/​config.ts Default migration to disabled.
packages/​stellar-wallet-snap/​src/​config.test.ts Verify migration default.
packages/​stellar-wallet-snap/​src/​api/​integer.ts Simplify maximum-amount comparison.
packages/​stellar-wallet-snap/​src/​api/​core-messenger.ts Define controller messenger types.
packages/​stellar-wallet-snap/​snap.manifest.json Request messenger permissions.
packages/​stellar-wallet-snap/​package.json Add controller-related dependencies.
packages/​stellar-wallet-snap/​CHANGELOG.md Document gated metadata reads.

Review effort: Balanced

Comment thread packages/stellar-wallet-snap/src/services/assets/api.ts
@stanleyyconsensys
stanleyyconsensys marked this pull request as ready for review October 21, 2026 10:48
@stanleyyconsensys
stanleyyconsensys requested review from a team as code owners October 21, 2026 10:48
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI 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.

🔵 Needs a closer look

The new messenger permissions and controller integration require host-level validation before approval.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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.

praise: just like Tron's, very nice 👏

### Added

- Read asset metadata from AssetsController when feature flag `enableAssetMigration` and local flag `enableAssetMigration` is on ([#493](https://github.com/MetaMask/internal-snaps/pull/493))
- `enableAssetMigration` set to off.

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.

question: is the goal of this sub-point to specify that by default the current changes make it off?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yea, we only switch to on, when full set of code ready to use controller
becoz in stellar we keep shipping new feature, i dont wanna this block / change any behavior when the migration is not ready

@khanti42 khanti42 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 just some nit comment

Also I see Stellar endowments getAssetMetadata but not AssetsController:getAssets. While Tron uses getAssets (forceUpdate / bypassServerCache) for post-tx freshness. If Stellar later needs live Core refresh after submit, we will need another endowment + adapter method.

Comment thread packages/stellar-wallet-snap/src/services/assets/api.ts
@stanleyyconsensys

Copy link
Copy Markdown
Contributor Author

LGTM just some nit comment

Also I see Stellar endowments getAssetMetadata but not AssetsController:getAssets. While Tron uses getAssets (forceUpdate / bypassServerCache) for post-tx freshness. If Stellar later needs live Core refresh after submit, we will need another endowment + adapter method.

not the same in Stellar
getAssets => get account asset
getAssetMetadata => get asset that even not own by this account (such as change trust)

we dont use forceUpdate / bypassServerCache, becoz horizon already return all data, we already using onChain data when build a txn

reading from controller for stellar is just for

  • get asset metadata
  • get asset balance for onAmountInput (thats all)

@stanleyyconsensys
stanleyyconsensys added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 5dd2c2a Oct 21, 2026
61 checks passed
@stanleyyconsensys
stanleyyconsensys deleted the dev/stellar/asset-metadata-messenger branch October 21, 2026 12:48

This branch was successfully deployed

1 active deployment
default-branch — 6d48c212 Deployed Oct 21, 2026 by stanleyyconsensys via Determine whether this PR is a release PR #1877
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.

4 participants