Skip to content

feat(stellar): asset migration - #331

Draft
stanleyyconsensys wants to merge 8 commits into
mainfrom
dev/stellar/asset-migration
Draft

stanleyyconsensys wants to merge 8 commits into
mainfrom
dev/stellar/asset-migration

Conversation

@stanleyyconsensys

Copy link
Copy Markdown
Contributor

Explanation

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 review from a team as code owners September 21, 2026 06:38
@stanleyyconsensys
stanleyyconsensys marked this pull request as draft September 21, 2026 06:38

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.

Copilot review overview

🟡 Changes recommended

There are confirmed blocking issues that force migration behavior on unconditionally and bypass the intended migration guard when backfilling the catalog, plus a formatting issue likely to fail lint/format checks.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity · 2 Low severity

Open (4)
What changed in this PR

Adds initial “Core assets migration” plumbing for the Stellar snap so that (when a remote flag enables it) holdings and catalog metadata can be read from Core’s AssetsController instead of snap state, while still allowing fallback to existing snap persistence where needed.

Changes:

  • Introduces AssetsService + CoreAssetsAdapter and wires Core messenger/endowments to fetch account assets and asset metadata.
  • Updates on-chain account resolution/sync to optionally bind balances from Core assets and (optionally) overlay account ledger meta from Soroban RPC.
  • Extends network layer with getAccountLedgerMeta and adds additional validation helpers for Stellar int64-like values.
File Description
yarn.lock Adds Core migration-related dependencies for the Stellar snap workspace.
packages/​stellar-wallet-snap/​src/​services/​on-chain-account/​utils.ts Makes minimum-balance calc use a named constant; adds helper to invert minimum reserve into subentry count.
packages/​stellar-wallet-snap/​src/​services/​on-chain-account/​utils.test.ts Adds tests for subentryCountFromMinimumReserveStroops.
packages/​stellar-wallet-snap/​src/​services/​on-chain-account/​OnChainAccountService.ts Adds Core-backed account resolution and skips snap-state sync when migration is enabled.
packages/​stellar-wallet-snap/​src/​services/​on-chain-account/​OnChainAccountService.test.ts Adds tests for Core-backed account resolution and migration-enabled sync skip.
packages/​stellar-wallet-snap/​src/​services/​on-chain-account/​__mocks__/​onChainAccount.fixtures.ts Wires AssetsService into on-chain account service test fixture.
packages/​stellar-wallet-snap/​src/​services/​network/​NetworkService.ts Adds getAccountLedgerMeta via Soroban RPC getAccountEntry.
packages/​stellar-wallet-snap/​src/​services/​network/​NetworkService.test.ts Adds unit tests for getAccountLedgerMeta success/error paths.
packages/​stellar-wallet-snap/​src/​services/​network/​api.ts Adds AccountLedgerMeta type for RPC-derived account fields.
packages/​stellar-wallet-snap/​src/​services/​assets/​utils.ts Adds migration-flag helper (currently with a blocking issue noted in comments).
packages/​stellar-wallet-snap/​src/​services/​assets/​index.ts Exposes new assets facade, adapter, parsing helpers, and migration util.
packages/​stellar-wallet-snap/​src/​services/​assets/​AssetsService.ts Adds Core AssetsController facade with parsing/validation of Core payloads.
packages/​stellar-wallet-snap/​src/​services/​assets/​AssetsService.test.ts Adds tests for catalog metadata parsing and account-asset validation behavior.
packages/​stellar-wallet-snap/​src/​services/​assets/​api.ts Defines superstruct validation for Core “Stellar-shaped” asset rows/metadata.
packages/​stellar-wallet-snap/​src/​services/​assets/​api.test.ts Adds tests for the Core asset validation/parsing helpers.
packages/​stellar-wallet-snap/​src/​services/​assets/​adapters/​CoreAssetsAdapter.ts Implements adapter over AssetsProvider calls (account assets + metadata).
packages/​stellar-wallet-snap/​src/​services/​assets/​__mocks__/​assetsService.fixtures.ts Adds AssetsService test fixture with mocked adapter + feature flag values.
packages/​stellar-wallet-snap/​src/​services/​asset-metadata/​utils.ts Allows overriding icon URL (e.g., from Core metadata image).
packages/​stellar-wallet-snap/​src/​services/​asset-metadata/​AssetMetadataService.ts Adds Core metadata lookup path + migration-enabled sync skip (with one bypass issue noted in comments).
packages/​stellar-wallet-snap/​src/​services/​asset-metadata/​AssetMetadataService.test.ts Adds tests for migration-enabled sync skip and Core-first metadata resolution.
packages/​stellar-wallet-snap/​src/​services/​asset-metadata/​__mocks__/​assets.fixtures.ts Wires AssetsService into asset-metadata service mock fixture.
packages/​stellar-wallet-snap/​src/​handlers/​keyring/​keyring.ts Updates call to resolveOnChainAccountByKeyringAccountId with account address.
packages/​stellar-wallet-snap/​src/​handlers/​clientRequest/​onAmountInput.test.ts Updates expectations for the new resolveOnChainAccountByKeyringAccountId signature.
packages/​stellar-wallet-snap/​src/​handlers/​accountResolver.ts Updates call to resolveOnChainAccountByKeyringAccountId with account address.
packages/​stellar-wallet-snap/​src/​handlers/​accountResolver.test.ts Updates expectations for the new resolveOnChainAccountByKeyringAccountId signature.
packages/​stellar-wallet-snap/​src/​context.ts Wires Core messenger providers + adapter/service and injects into dependent services.
packages/​stellar-wallet-snap/​src/​constants.ts Adds ACCOUNT_MINIMUM_BASE_RESERVE_UNIT constant for minimum-balance math.
packages/​stellar-wallet-snap/​src/​api/​integer.ts Fixes max-int comparison usage and adds ValidStellarInt64Struct.
packages/​stellar-wallet-snap/​src/​api/​integer.test.ts Adds tests for ValidStellarInt64Struct.
packages/​stellar-wallet-snap/​src/​api/​core-messenger.ts Defines types/actions namespace for Core messenger endowment (formatting issue noted in comments).
packages/​stellar-wallet-snap/​snap.manifest.json Adds endowment:messenger actions for feature flag + assets controller reads.
packages/​stellar-wallet-snap/​package.json Adds devDependencies needed for Core messenger + assets controller integration.
packages/​snap-networks-utils/​src/​providers/​assets/​AssetsProvider.ts Adds AssetsController getAssetMetadata action support.
packages/​snap-networks-utils/​src/​providers/​assets/​AssetsProvider.test.ts Adds test for AssetsProvider.getAssetMetadata.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +20 to +23
return true;
const flagValue = await remoteFeatureFlagsProvider.getFeatureFlag(
SNAPS_ASSETS_MIGRATION_FLAG_KEYS.stellar,
);
Comment on lines +143 to +144
const tokensMetadata = await this.#getAssetsByChainId(scope);
await this.#assetMetadataRepository.saveMany(tokensMetadata);
Comment on lines +1 to +5
import type {
AssetsControllerGetAccountAssetByIDAction,
AssetsControllerGetAccountAssetsByIDsAction,
AssetsControllerGetAccountAssetsByScopeAction,
AssetsControllerGetAssetMetadataAction,

if (assets.length === 0) {
// If the account has no assets from core,
// Possiblly not indexed, or not activated

This branch was successfully deployed

1 active (outdated) deployment
default-branch — 2a59e1d7 Deployed Sep 21, 2026 by stanleyyconsensys via Determine whether this PR is a release PR #1099
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.

2 participants