Commit 7f146c2
authored
Fix: assets controller custom asset metadata case (#8727)
## Explanation
<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:
* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->
## References
<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?
For example:
* Fixes #12345
* Related to #67890
-->
## 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](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md)
- [ ] I've introduced [breaking
changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md)
in this PR and have prepared draft pull requests for clients and
consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Medium risk due to switching the RPC detector’s token-list API
endpoint/caching behavior and adding new required NetworkController
events, which can affect asset detection/refresh across networks for
consumers.
>
> **Overview**
> RPC token detection is reworked to use the same
`token.api.cx.metamask.io/tokens/{chainId}` endpoint and filtering rules
as `TokenListController`, including chain-specific `occurrenceFloor`
handling, Linea aggregator filtering, and forwarding
`iconUrl`/`aggregators` into detection results. A shared optional
TanStack Query `queryClient` is introduced to cache/dedupe per-chain
token-list fetches, and `AssetsController` now passes its existing API
query client to `RpcDataSource` by default.
>
> `AssetsController` now listens for `NetworkController:networkAdded`
and **new** `NetworkController:networkRemoved` events (breaking for
restricted messengers) to force-refresh assets after network config
changes, and refactors RPC custom-asset supplemental subscription
selection into a pure helper. Fixes include making custom-asset
spam-filter bypass case-insensitive in `TokenDataSource`, preventing
`RpcDataSource` from clobbering enriched native metadata with stubs on
refresh/error paths, and only graduating custom assets when upstream
sources report a strictly positive balance.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
4249719. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 8bc0a07 commit 7f146c2
15 files changed
Lines changed: 1146 additions & 181 deletions
File tree
- packages/assets-controller
- src
- data-sources
- evm-rpc-services
- clients
- services
- middlewares
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
10 | 19 | | |
11 | 20 | | |
| 21 | + | |
| 22 | + | |
12 | 23 | | |
13 | 24 | | |
14 | 25 | | |
15 | 26 | | |
16 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
17 | 36 | | |
18 | 37 | | |
19 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1905 | 1905 | | |
1906 | 1906 | | |
1907 | 1907 | | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
1908 | 1925 | | |
1909 | 1926 | | |
1910 | 1927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| 137 | + | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
| |||
319 | 321 | | |
320 | 322 | | |
321 | 323 | | |
322 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
323 | 327 | | |
| 328 | + | |
324 | 329 | | |
325 | 330 | | |
326 | 331 | | |
| |||
822 | 827 | | |
823 | 828 | | |
824 | 829 | | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
825 | 835 | | |
826 | 836 | | |
827 | 837 | | |
| |||
1011 | 1021 | | |
1012 | 1022 | | |
1013 | 1023 | | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
1020 | 1030 | | |
1021 | 1031 | | |
1022 | 1032 | | |
1023 | 1033 | | |
| 1034 | + | |
1024 | 1035 | | |
1025 | 1036 | | |
1026 | 1037 | | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
1027 | 1042 | | |
1028 | 1043 | | |
1029 | 1044 | | |
| |||
2605 | 2620 | | |
2606 | 2621 | | |
2607 | 2622 | | |
2608 | | - | |
2609 | | - | |
2610 | | - | |
2611 | | - | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
2612 | 2630 | | |
2613 | 2631 | | |
2614 | 2632 | | |
| |||
2620 | 2638 | | |
2621 | 2639 | | |
2622 | 2640 | | |
2623 | | - | |
| 2641 | + | |
2624 | 2642 | | |
2625 | | - | |
2626 | | - | |
2627 | | - | |
2628 | | - | |
2629 | | - | |
2630 | | - | |
2631 | | - | |
2632 | | - | |
2633 | | - | |
2634 | | - | |
2635 | | - | |
2636 | | - | |
2637 | | - | |
2638 | | - | |
2639 | | - | |
2640 | | - | |
2641 | | - | |
2642 | | - | |
2643 | | - | |
2644 | | - | |
2645 | | - | |
2646 | | - | |
2647 | | - | |
2648 | | - | |
2649 | | - | |
2650 | | - | |
2651 | | - | |
2652 | | - | |
2653 | | - | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
2654 | 2650 | | |
2655 | | - | |
2656 | | - | |
| 2651 | + | |
2657 | 2652 | | |
2658 | 2653 | | |
2659 | 2654 | | |
2660 | 2655 | | |
2661 | | - | |
2662 | 2656 | | |
2663 | | - | |
| 2657 | + | |
2664 | 2658 | | |
2665 | 2659 | | |
2666 | 2660 | | |
2667 | 2661 | | |
2668 | 2662 | | |
2669 | 2663 | | |
2670 | | - | |
| 2664 | + | |
2671 | 2665 | | |
2672 | 2666 | | |
2673 | 2667 | | |
| |||
3042 | 3036 | | |
3043 | 3037 | | |
3044 | 3038 | | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
3045 | 3055 | | |
3046 | 3056 | | |
3047 | 3057 | | |
| |||
Lines changed: 57 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
106 | 113 | | |
107 | 114 | | |
108 | 115 | | |
| |||
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
131 | 143 | | |
132 | 144 | | |
133 | 145 | | |
| |||
300 | 312 | | |
301 | 313 | | |
302 | 314 | | |
303 | | - | |
304 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
305 | 322 | | |
306 | 323 | | |
307 | 324 | | |
| |||
356 | 373 | | |
357 | 374 | | |
358 | 375 | | |
| 376 | + | |
359 | 377 | | |
360 | | - | |
| 378 | + | |
361 | 379 | | |
362 | 380 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
377 | 385 | | |
378 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
379 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
380 | 402 | | |
381 | 403 | | |
382 | 404 | | |
| |||
1021 | 1043 | | |
1022 | 1044 | | |
1023 | 1045 | | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1033 | 1064 | | |
1034 | 1065 | | |
1035 | 1066 | | |
| |||
0 commit comments