docs(assets-controller): add architecture diagrams under docs-temp - #10134
docs(assets-controller): add architecture diagrams under docs-temp#10134Prithpal-Sooriya wants to merge 11 commits into
Conversation
Adds a docs-temp folder with an Archify-generated, self-contained interactive diagram of the assets-controller component map: entry points through the messenger, the middleware pipeline, the four priority balance data sources, the enrichment stage, and external egress. Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Shows the awaited fast lane (parallel balance, graduation, RPC fallback, detection, parallel enrich) alongside the fire-and-forget background lane that retries chains which errored or fall outside Accounts API coverage. Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Shows how handleAssetsUpdate rebuilds the middleware stack for every incoming update: which stages a source contributes, why graduation has to run before RPC fallback, and which two stages basic functionality gates. Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
The interactive viewers are convenient in a browser but cannot be embedded in an issue or a README. Each diagram now also ships as a flat raster and as self-contained vector output, exported from the delivered viewer so the image matches the validated artifact. Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
…ed viewers The visual-check screenshots and receipts were browser evidence, not documentation, so they are dropped in favour of a short index. The delivered HTML viewers are generated artifacts whose bytes are checksummed by archify, so oxfmt must not reformat them. Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
The batch of 50 only applies to chains with no Multicall3 deployment. When an aggregate3 batch throws, the retry issues one eth_call per asset across the whole failed batch with no size limit. Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
|
@cursor can you also use the skill to generate how and when tokens are filtered (where in the middleware flow, and also unlock event, etc) |
|
Added three diagrams for token filtering, pushed to #10134. Reading the code turned up two genuinely different kinds of filtering, so I split them rather than forcing one diagram to carry both.
The two failure modes are opposite and the diagram calls that out: both pipeline filters fail open, so a Token API error keeps every candidate, while the unlock sweep deletes nothing if a call fails.
All three pass |
Adds two diagrams answering how and when a token is filtered out: - 07-token-filtering (workflow): the three moments a token can be cut — the websocket occurrence filter that runs before detection, the enrichment stage filter shared by both middleware stacks, and the keyring-unlock sweep over already-saved state. - 08-spam-verdict (dataflow): how one candidate becomes a keep or drop verdict — the exemption list, the EVM occurrence floor, the non-EVM Blockaid scan, and what a drop actually removes. Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Spam filtering decides what reaches state; a separate set of gates decides what a read returns out of it. 09-visibility-gate covers that second axis: balance and metadata completeness, the user's hidden preference, and chain scope, plus the fact that none of them delete anything. Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>


Explanation
Exploratory: adds a
docs-temp/folder inside the newpackages/assets-controllerpackage containing architecture diagrams that explain the controller's middleware, pipelines, fallback behaviour and token filtering. Diagrams were authored as JSON specs and rendered with the Archify skill.Documentation-only.
package.jsonpublishesdist/only, so nothing here is built, published, or imported.Diagrams
01-component-map02-fetch-pipelinegetAssetsawaits, and what it defers to a background lane03-fallback-cascade04-tracking-lifecycle05-evm-rpc-dataflowaggregate3call and then decoded balances06-event-stackhandleAssetsUpdatecomposes a different middleware stack per source07-token-filtering08-spam-verdict09-visibility-gateThe diagrams pair up. 02 and 06 are the two halves of the middleware architecture: 02 is the fetch stack a caller drives, 06 is the event stack an incoming update drives. 07, 08 and 09 cover filtering: 07 is when a token is judged as spam and 08 is how that verdict is reached, both on the write path; 09 is the separate read path that decides what a caller gets back.
Each diagram ships in four forms — the
.jsonsource, a self-contained interactive.htmlviewer (guided views, light/dark, hover focus), a flat.png, and a self-contained.svg. The PNG and SVG are exported from the delivered viewer, so the image always matches the validated artifact.Component map
Event stack composition
Where a spam token gets filtered out
Spam verdict
Read path visibility gate
What the filtering diagrams say
07-token-filteringputs the three write-path filtering moments side by side as three lanes, because each answers "when" differently:TokenDataSource.occurrenceFilterMiddleware, added to the event stack only forAccountActivityDataSourceand only with basic functionality on. It judges brand-new EVM ERC-20s beforeDetectionMiddleware, so a below-floor airdrop is never detected, enriched, priced or persisted.TokenDataSource.assetsMiddleware, inside the parallel Token ∥ Price stage. This is the one filter both the fetch stack and the event stack share.cleanSpamAssets, run from theKeyringController:unlockhandler before#updateActive(), gated on unlocked + basic functionality +assetsUnifyState.useUnlockCleanup. It is the only pass that edits state that was already saved.The failure modes differ on purpose and the diagram calls this out: both pipeline filters fail open (a Token API error keeps every candidate), while the unlock sweep deletes nothing when a call fails.
08-spam-verdictfollows a single candidate through the decision: the exemption list (native assets, custom assets, balance-only heals, staking contracts and mUSD), then the split into the EVM occurrence floor from/v1/suggestedOccurrenceFloors(default 3) versus the non-EVM Blockaid scan viaPhishingController:bulkScanTokens, then what a drop actually removes — including the stub metadata, which has to go so the token cannot look known and be exempted as a heal on the next pass.09-visibility-gatecovers the other axis, because "filtered" also means "in state but not returned".#getAssetFromStatere-evaluates four gates on every read — balance present, metadata present,assetPreferences.hiddenunset, and chain in scope (enabled network, and not a native token on a chain that has none) — and the aggregate balance selectors apply the same hidden and enabled-network rules. None of these delete anything, so a hidden row keeps refreshing in the background.Verification
All nine pass
archify deliverat theshowcasequality profile (9/9 artifact checks, 0 composition errors). All except04-tracking-lifecyclealso passarchify visual-checkcontainment at 1440×900, 1600×1000, 1920×1080 and 2048×1320 in both themes. The lifecycle renderer pins its three band rows to fixed y coordinates, which gives it a vertical budget that cannot fit a 1440px-wide desktop viewport without the page scrolling; Archify's own bundled lifecycle example overflows the same way. The diagram itself renders correctly — only the page scrolls.Repo checks run:
oxfmt --check(repo-wide),eslint,constraints,readme-content:check,codeowners:check, and the package'schangelog:validate.Note on
.oxfmtrc.jsonThe delivered
.htmlviewers are generated artifacts whose bytes are checksummed byarchify, so oneignorePatternsentry (packages/*/docs-temp/*.html) keepsyarn lint:miscfrom reformatting them.References
n/a — exploratory documentation.
Checklist
README.md) as appropriateTo show artifacts inline, enable in settings.