feat(Stellar): asset enrichment through snap data source#9422
Draft
khanti42 wants to merge 5 commits into
Draft
Conversation
Comment on lines
+306
to
+322
| if (assetsBalance) { | ||
| const response: DataResponse = { assetsBalance, updateMode: 'merge' }; | ||
| for (const subscription of this.activeSubscriptions.values()) { | ||
| subscription.onAssetsUpdate(response)?.catch(console.error); | ||
| } | ||
| if (!assetsBalance) { | ||
| return; | ||
| } | ||
|
|
||
| const response: DataResponse = { assetsBalance, updateMode: 'merge' }; | ||
| for (const subscription of this.activeSubscriptions.values()) { | ||
| subscription.onAssetsUpdate(response)?.catch(console.error); |
Contributor
There was a problem hiding this comment.
this should not change
| * Handle snap balance updates from the keyring. | ||
| * Transforms the payload and publishes to AssetsController. | ||
| * | ||
| * Push updates carry amounts only. Per-asset snap enrichment (e.g. Stellar |
Contributor
There was a problem hiding this comment.
no need to add comment
| } | ||
| } | ||
|
|
||
| if ( |
Contributor
There was a problem hiding this comment.
we should just add step 3 with Feature flag
| } | ||
| } | ||
| results.assetsBalance ??= {}; | ||
| const accountBalances = results.assetsBalance[accountId] ?? {}; |
Contributor
There was a problem hiding this comment.
on step 3:
if stellar feature flag:
- fetch enrichment
- update the state (results.assetsBalance)
| * When false, SnapDataSource skips `getAccountAssetInfo` enrichment. | ||
| * Evaluated at call time. Defaults to () => false. | ||
| */ | ||
| assetEnrichmentEnabled?: () => boolean; |
Contributor
There was a problem hiding this comment.
i think they prefer stellar focus, but up to them
and there are 2 way to get feature flag
- use messenger call directly from data source, so u dont need pass in , as we are temp solution, which i think is better (please check packages/network-controller/src/NetworkController.ts)
- pass in from client, like what u did
| }) | ||
| ) { | ||
| // TODO(STELLAR): Remove this Snap-side accountAssetInfo enrichment path once the Accounts API returns account-asset enrichment directly. | ||
| await enrichAccountAssetInfo({ |
Contributor
There was a problem hiding this comment.
um..i feel just do:
- call snap
- modify data
that will be clear enough
putting into a function, may create complexity, but it also clean
i leave it to Asset team
| const next: Record<string, AssetBalance> = { ...previousBalances }; | ||
| for (const [assetId, balance] of Object.entries(accountBalances)) { | ||
| next[assetId] = { | ||
| ...(previousBalances[assetId] ?? { amount: '0' }), |
Contributor
There was a problem hiding this comment.
still have amt 0?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
References
Checklist