Commit 24518b2
authored
chore: remove hardcoded NFT chain allowlist from NftDetectionController (#8180)
## Explanation
### Summary
As part of the NFT provider migration plan, this PR removes the
hardcoded `supportedNftDetectionNetworks` allowlist from
`NftDetectionController` and delegates chain support validation to the
server instead.
> **Deployment dependency:** This PR depends on backend changes deployed
to production in
[`va-mmcx-nft-api#221`](consensys-vertical-apps/va-mmcx-nft-api#221).
**Do not merge this PR until those backend changes are live in
production.** The server must return an empty array (instead of an
error) for unsupported chains before the client-side chain gating can be
safely removed.
### Changes
- **Remove `supportedNftDetectionNetworks`**: Drops the static
`Set<Hex>` that previously allowed only 8 specific chains (Mainnet, BSC,
Polygon, Avalanche, Linea, Base, Sei, Monad) through NFT detection.
Detection now passes all provided chain IDs directly to the API.
- **Remove chain filtering in `detectNfts`**: The pre-API filter that
dropped unsupported chains before calling `#getOwnerNfts` has been
removed. `chainIds` is now passed through unmodified, allowing the
server to decide what to return.
- **Add non-EVM guard in `#getOwnerNfts`**: Chains that convert to
decimal `'0'` (non-EVM/invalid chains) are filtered out before making
the API call, and if all chains are non-EVM, the method returns `{
tokens: [], continuation: null }` early — avoiding a pointless API
round-trip.
- **Fix `continuation` type**: Updated `ReservoirResponse.continuation`
from `string | undefined` to `string | null` to match the updated server
response shape.
### Motivation
Keeping a hardcoded chain allowlist in the Core package tightly coupled
backend and frontend release cycles — adding support for a new chain
required coordinated changes in both places simultaneously. The backend
change in
[`va-mmcx-nft-api#221`](consensys-vertical-apps/va-mmcx-nft-api#221)
updates the NFT API to return `[]` instead of an error for unsupported
chains. With that in place, the Core package no longer needs to know
which chains are supported, enabling each side to evolve independently
going forward.
### Testing
- All existing `NftDetectionController` tests should continue to pass.
- Verify that NFT detection on previously unsupported chains gracefully
returns no results rather than throwing.
- Verify that non-EVM chains short-circuit before hitting the API.
### Merge checklist
- [ ]
[`va-mmcx-nft-api#221`](consensys-vertical-apps/va-mmcx-nft-api#221)
is merged and deployed to production
- [ ] NFT detection verified end-to-end against production API on at
least one previously unsupported chain
<!--
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
https://consensyssoftware.atlassian.net/browse/ASSETS-2899
<!--
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**
> Changes NFT auto-detection behavior by delegating chain support to the
backend and altering pagination typing; incorrect backend behavior or
unexpected chain IDs could impact NFT detection results.
>
> **Overview**
> **NFT detection no longer hardcodes a supported-chain allowlist.**
`NftDetectionController.detectNfts` now passes all provided `chainIds`
through to the NFT API instead of filtering to a fixed set of EVM
chains, relying on the server to return empty results for unsupported
networks.
>
> **Non-EVM guardrails and response typing were updated.**
`#getOwnerNfts` filters out chain IDs that convert to decimal `0` and
returns an empty `{ tokens: [], continuation: null }` without making an
API call when only non-EVM chains are provided, and
`ReservoirResponse.continuation` is widened to `string | null` to match
the API shape.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
33e9745. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 5470e31 commit 24518b2
File tree
2 files changed
+20
-26
lines changed- packages/assets-controllers
- src
2 files changed
+20
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
Lines changed: 17 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | 66 | | |
81 | 67 | | |
82 | 68 | | |
| |||
188 | 174 | | |
189 | 175 | | |
190 | 176 | | |
191 | | - | |
| 177 | + | |
192 | 178 | | |
193 | 179 | | |
194 | 180 | | |
| |||
540 | 526 | | |
541 | 527 | | |
542 | 528 | | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
543 | 542 | | |
544 | | - | |
| 543 | + | |
545 | 544 | | |
546 | 545 | | |
547 | 546 | | |
| |||
575 | 574 | | |
576 | 575 | | |
577 | 576 | | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | 577 | | |
583 | | - | |
| 578 | + | |
584 | 579 | | |
585 | 580 | | |
586 | 581 | | |
| |||
611 | 606 | | |
612 | 607 | | |
613 | 608 | | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
| 609 | + | |
619 | 610 | | |
620 | 611 | | |
621 | 612 | | |
| |||
0 commit comments