Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/swapsUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
Expand Down
10 changes: 9 additions & 1 deletion src/swapsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down