diff --git a/shared/constants/transaction.ts b/shared/constants/transaction.ts index 38311de3be76..ac4bb77b070a 100644 --- a/shared/constants/transaction.ts +++ b/shared/constants/transaction.ts @@ -199,3 +199,10 @@ export enum TokenStandard { /** Not a token, but rather the base asset of the selected chain. */ none = 'NONE', } + +/** + * The hostname used for Ethereum Mainnet transaction simulations, and for + * retrieving metadata for transaction simulation supported networks. + */ +export const TX_SENTINEL_URL = + 'https://tx-sentinel-ethereum-mainnet.api.cx.metamask.io'; diff --git a/test/e2e/mock-e2e.js b/test/e2e/mock-e2e.js index d6d19d972d3b..e938b5604a82 100644 --- a/test/e2e/mock-e2e.js +++ b/test/e2e/mock-e2e.js @@ -16,6 +16,7 @@ const { SWAPS_API_V2_BASE_URL, TOKEN_API_BASE_URL, } = require('../../shared/constants/swaps'); +const { TX_SENTINEL_URL } = require('../../shared/constants/transaction'); const { SECURITY_ALERTS_PROD_API_BASE_URL } = require('./tests/ppom/constants'); const { DEFAULT_FEATURE_FLAGS_RESPONSE: BRIDGE_DEFAULT_FEATURE_FLAGS_RESPONSE, @@ -314,6 +315,21 @@ async function setupMocking( }; }); + // This endpoint returns metadata for "transaction simulation" supported networks. + await server.forGet(`${TX_SENTINEL_URL}/networks`).thenJson(200, { + 1: { + name: 'Mainnet', + group: 'ethereum', + chainID: 1, + nativeCurrency: { name: 'ETH', symbol: 'ETH', decimals: 18 }, + network: 'ethereum-mainnet', + explorer: 'https://etherscan.io', + confirmations: true, + smartTransactions: true, + hidden: false, + }, + }); + await server .forGet(`${SWAPS_API_V2_BASE_URL}/featureFlags`) .thenCallback(() => { diff --git a/test/e2e/tests/simulation-details/simulation-details.spec.ts b/test/e2e/tests/simulation-details/simulation-details.spec.ts index 20475a945dde..c69a2f798b3d 100644 --- a/test/e2e/tests/simulation-details/simulation-details.spec.ts +++ b/test/e2e/tests/simulation-details/simulation-details.spec.ts @@ -1,6 +1,7 @@ import { hexToNumber } from '@metamask/utils'; import { Mockttp, MockttpServer } from 'mockttp'; import { CHAIN_IDS } from '../../../../shared/constants/network'; +import { TX_SENTINEL_URL } from '../../../../shared/constants/transaction'; import FixtureBuilder from '../../fixture-builder'; import { createDappTransaction, @@ -43,15 +44,6 @@ import { } from './mock-request-send-eth'; import { MockRequestResponse } from './types'; -const TX_SENTINEL_URL = - 'https://tx-sentinel-ethereum-mainnet.api.cx.metamask.io/'; - -const mockNetworkRequest = async (mockServer: Mockttp) => { - await mockServer.forGet(`${TX_SENTINEL_URL}/networks`).thenJson(200, { - '1': { name: 'Mainnet', confirmations: true }, - }); -}; - async function withFixturesForSimulationDetails( { title, @@ -64,17 +56,13 @@ async function withFixturesForSimulationDetails( }, test: (args: Pick) => Promise, ) { - const testSpecificMock = async (mockServer: MockttpServer) => { - await mockNetworkRequest(mockServer); - await mockRequests(mockServer); - }; await withFixtures( { fixtures: new FixtureBuilder({ inputChainId }) .withPermissionControllerConnectedToTestDapp() .build(), title, - testSpecificMock, + testSpecificMock: mockRequests, dapp: true, localNodeOptions: { hardfork: 'london',