Files
TimandGitHub 39247a11fa feat(web): migrate chain config fetching to /v2/chains endpoint (#7275)
* feat(web): migrate chain config fetching to `/v2/chains` endpoint

Switch the chains list endpoint from `/v1/chains` to `/v2/chains` across
all callers in the web app and shared store package. The v2 endpoint
requires a serviceKey to scope chain features per service (e.g.
WALLET_WEB, MOBILE). The key is configurable via
NEXT_PUBLIC_CONFIG_SERVICE_KEY with a default of 'WALLET_WEB'.

Updated callers: useChains, useInitStaticChains, ofac API, swap order listener, build-time fetch-chains script, and service worker
gateway-utils. Also migrates the single-chain getChainConfig utility
to chainsGetChainV2.

* test: replace crypto UUID with faker UUID in dynamicBaseQuery tests

Updated the test cases in cgwClient.test.ts to use faker for generating UUIDs instead of crypto.randomUUID, ensuring consistent and controlled test data generation.

* refactor: update chain configuration hooks and API calls to use v2 endpoint

Replaced all instances of `getChainsConfig` with `getChainsConfigV2` in the web app and store, ensuring consistent usage of the new endpoint. This includes updates in hooks, API slices, and tests to align with the new service key requirements for fetching chain configurations.

* tests: restore v1/chains MSW handler for mobile test compatibility

The v1/chains handler was removed when migrating to v2, but mobile still queries getChainsConfig which hits /v1/chains. Without a handler, requests fell through to the real staging API, causing snapshot drift in mobile tests. Also extracts the shared mock data into a chainsConfig constant to keep v1
and v2 handlers in sync.

* test: replace hardcoded service key with constant in chains retry tests

Updated the chains retry functionality tests to use a constant for the service key instead of a hardcoded string.

* fix: add validation for serviceKey in getChainsConfigV2 query

Implemented a check to ensure that the serviceKey is provided when calling the getChainsConfigV2 query. If the serviceKey is missing, a custom error is returned, improving error handling and preventing potential issues during API calls.

* fix: add validation for results array in getChainsConfigs

Enhanced error handling in the getChainsConfigs function by adding a check to ensure the results array is present in the API response. If the results array is missing, a custom error is returned, improving robustness against invalid responses.

* fix: remove JSON.stringify from service key in getChainsConfigV2 query

Updated the getChainsConfigV2 query to directly use the CONFIG_SERVICE_KEY constant instead of stringifying it, simplifying the code and ensuring the correct value is passed.
2026-03-02 13:52:49 +01:00
..