Skip to content

feat(stellar): fetch live data in keyring listAccountAssets and getAccountBalances + read balance data from AssetsController + stop account sync while Asset migration is off - #331

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

stanleyyconsensys wants to merge 52 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 thread packages/stellar-wallet-snap/src/services/assets/utils.ts Outdated
Comment thread packages/stellar-wallet-snap/src/services/asset-metadata/AssetMetadataService.ts Outdated
Comment thread packages/stellar-wallet-snap/src/api/core-messenger.ts Outdated
@socket-security

socket-security Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

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

Unresolved critical and moderate issues affect migrated account correctness, source selection, state safety, and secret handling.

4 open issues
4 resolved since last review

Review effort: Lite

Comment thread packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts
Comment thread packages/stellar-wallet-snap/CHANGELOG.md
Comment thread packages/stellar-wallet-snap/src/services/asset-metadata/AssetMetadataService.ts Outdated

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

Unresolved critical fixture security and network-safety issues, plus trustline and balance correctness issues, remain.

3 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve trustline sponsors in classic balances

packages/​stellar-wallet-snap/​src/​services/​on-chain-account/​OnChainAccountService.ts:481

The AssetsController classic balance metadata includes the trustline sponsor, but this mapping drops it before creating the serializable balance. As a result, migrated sponsored trustlines are returned by keyring APIs without their sponsor address, unlike Horizon-backed accounts. Preserve the non-empty sponsor when building the serialized entry.

4 resolved since last review

Review effort: Lite

Comment thread packages/stellar-wallet-snap/scripts/horizon-event-fixture.mjs Outdated
Comment thread packages/stellar-wallet-snap/scripts/horizon-event-fixture.mjs Outdated
Comment thread packages/stellar-wallet-snap/src/handlers/keyring/keyring.ts Outdated
@stanleyyconsensys stanleyyconsensys changed the title feat(stellar): asset migration feat(stellar): return live data in keyring listAccountAssets and getAccountBalances but gate by local config enableAssetMigration Oct 22, 2026
@stanleyyconsensys stanleyyconsensys changed the title feat(stellar): return live data in keyring listAccountAssets and getAccountBalances but gate by local config enableAssetMigration feat(stellar): fetch live data in keyring listAccountAssets and getAccountBalances + read balance data from AssetsController + stop account sync while Asset migration is off Oct 22, 2026
@stanleyyconsensys
stanleyyconsensys marked this pull request as ready for review October 22, 2026 07:55
khanti42
khanti42 previously approved these changes Oct 22, 2026

// If the account is not activated or not yet synced, return the native asset with zero balance
// TDOO: remove this gate after asset migration is fully enabled.
if (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.

this is to maintain the same experience of stellar, incase, there are some hot fix need to ship, we wont ship some major behavior change to client

especially this will increase the network call when we unblock it

@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.

🟡 Changes recommended

The classic trustline sponsor metadata issue and documented typos remain unresolved.

2 open issues
3 resolved since last review

Review effort: Lite

limit,
address,
authorized,
sponsored,
let onChainAccount: OnChainAccount | null = null;

// If the account is not activated or not yet synced, return the native asset with zero balance
// TDOO: remove this gate after asset migration is fully enabled.

This branch was successfully deployed

1 active (outdated) deployment
default-branch — 0988a17d Deployed Oct 22, 2026 by stanleyyconsensys via Determine whether this PR is a release PR #1903
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