diff --git a/src/constants.ts b/src/constants.ts index f3154c57..ea8dfbc7 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -40,10 +40,15 @@ 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'; +export const BRIDGE_DEV_BASE_URL = 'https://bridge.dev-api.cx.metamask.io'; //* Contract addresses 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, }, }); 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: