Repository navigation
chore(stellar): read asset metadata from controller and gated by FF and local config - #493
Conversation
| (decimalPlaces && decimalPlaces > STELLAR_DECIMAL_PLACES) || | ||
| // > Max value | ||
| toSmallestUnit(amount).gt(new BigNumber(MAX_INT64).toString()) | ||
| toSmallestUnit(amount).gt(MAX_INT64) |
There was a problem hiding this comment.
this is not related to this PR, but just a small refactor
| * @returns Whether AssetsController reads are active. | ||
| */ | ||
| async isMigrationEnabled(): Promise<boolean> { | ||
| if (!AppConfig.enableAssetMigration) { |
There was a problem hiding this comment.
make sure we dont read controller when we are not ready
There was a problem hiding this comment.
why a specific configuration for it? why not rely on the feqature flag only?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
this is try to resolve the inconsistency trustline limit, but we are not yet using this yet
There was a problem hiding this comment.
🟡 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
|
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
question: is the goal of this sub-point to specify that by default the current changes make it off?
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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 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
|




Explanation
This PR does
References
Checklist