From c1471b876cb8f9961c2c728d962196fb24ad1357 Mon Sep 17 00:00:00 2001 From: IF <139582705+infiniteflower@users.noreply.github.com> Date: Thu, 7 Aug 2025 17:25:38 -0400 Subject: [PATCH 1/3] chore: migrate topAssets to bridge API instead of swaps API --- src/constants.ts | 6 +++++- src/swapsUtil.ts | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index f3154c57..7c11eccb 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -40,11 +40,15 @@ export const CHAIN_ID_TO_NAME_MAP: { [key: string]: string } = { }; //* APIs base urls - +// LEGACY export const API_BASE_URL = 'https://swap.api.cx.metamask.io'; export const DEV_BASE_URL = 'https://swap.dev-api.cx.metamask.io'; export const GAS_API_BASE_URL = 'https://gas.api.cx.metamask.io'; +// BRIDGE +export const BRIDGE_API_BASE_URL = 'https://bridge.api.cx.metamask.io'; +export const BRIDGE_DEV_BASE_URL = 'https://bridge.dev-api.cx.metamask.io'; + //* Contract addresses export const ETH_SWAPS_CONTRACT_ADDRESS = diff --git a/src/swapsUtil.ts b/src/swapsUtil.ts index b4a43322..6317e269 100644 --- a/src/swapsUtil.ts +++ b/src/swapsUtil.ts @@ -23,6 +23,8 @@ import { BN } from 'bn.js'; import { ALLOWED_CONTRACT_ADDRESSES, API_BASE_URL, + BRIDGE_API_BASE_URL, + BRIDGE_DEV_BASE_URL, CHAIN_ID_TO_NAME_MAP, DEV_BASE_URL, ETH_CHAIN_ID, @@ -214,6 +216,12 @@ export const getBaseApiURL = function (type: APIType, chainId: Hex): string { chainId === SWAPS_TESTNET_CHAIN_ID ? [ETH_CHAIN_ID, DEV_BASE_URL] : [chainId, API_BASE_URL]; + + const bridgeApiBaseUrl = + chainId === SWAPS_TESTNET_CHAIN_ID + ? BRIDGE_DEV_BASE_URL + : BRIDGE_API_BASE_URL; + const apiDecimalChainId: number = convertHexToDecimal(apiChainId); switch (type) { case APIType.TRADES: @@ -223,7 +231,7 @@ export const getBaseApiURL = function (type: APIType, chainId: Hex): string { case APIType.TOKEN: return `${apiBaseUrl}/networks/${apiDecimalChainId}/token`; case APIType.TOP_ASSETS: - return `${apiBaseUrl}/networks/${apiDecimalChainId}/topAssets`; + return `${bridgeApiBaseUrl}/networks/${apiDecimalChainId}/topAssets`; case APIType.FEATURE_FLAG: return `${apiBaseUrl}/featureFlags`; case APIType.AGGREGATOR_METADATA: From d224fe42d7b7aa29edd1d0722e01461ef25d2647 Mon Sep 17 00:00:00 2001 From: IF <139582705+infiniteflower@users.noreply.github.com> Date: Thu, 7 Aug 2025 17:26:01 -0400 Subject: [PATCH 2/3] chore: clean up --- src/constants.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index 7c11eccb..ea8dfbc7 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -40,10 +40,11 @@ export const CHAIN_ID_TO_NAME_MAP: { [key: string]: string } = { }; //* APIs base urls +export const GAS_API_BASE_URL = 'https://gas.api.cx.metamask.io'; + // LEGACY export const API_BASE_URL = 'https://swap.api.cx.metamask.io'; export const DEV_BASE_URL = 'https://swap.dev-api.cx.metamask.io'; -export const GAS_API_BASE_URL = 'https://gas.api.cx.metamask.io'; // BRIDGE export const BRIDGE_API_BASE_URL = 'https://bridge.api.cx.metamask.io'; From 36d73da2a7469a544ead92414f38b65b85500622 Mon Sep 17 00:00:00 2001 From: IF <139582705+infiniteflower@users.noreply.github.com> Date: Thu, 7 Aug 2025 17:38:50 -0400 Subject: [PATCH 3/3] fix: tests --- src/swapsUtil.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/swapsUtil.test.ts b/src/swapsUtil.test.ts index df1f1849..8ce63390 100644 --- a/src/swapsUtil.test.ts +++ b/src/swapsUtil.test.ts @@ -521,7 +521,7 @@ describe('SwapsUtil', () => { describe('fetchTopAssets', () => { it('should work', async () => { mockFetch({ - 'https://swap.api.cx.metamask.io/networks/1/topAssets': { + 'https://bridge.api.cx.metamask.io/networks/1/topAssets': { body: API_TRADES, }, });