diff --git a/app/scripts/controllers/swaps.js b/app/scripts/controllers/swaps.js index a464729c1..6cb06cca9 100644 --- a/app/scripts/controllers/swaps.js +++ b/app/scripts/controllers/swaps.js @@ -18,6 +18,7 @@ import { fetchTradesInfo as defaultFetchTradesInfo, fetchSwapsFeatureLiveness as defaultFetchSwapsFeatureLiveness, } from '../../../ui/app/pages/swaps/swaps.util' +import { MAINNET_CHAIN_ID } from './network/enums' const METASWAP_ADDRESS = '0x881d40237659c251811cec9c364ef91dc08d300c' @@ -91,7 +92,8 @@ export default class SwapsController { this.indexOfNewestCallInFlight = 0 - this.ethersProvider = new ethers.providers.Web3Provider(provider) + // The chain ID is hard-coded as Mainnet because swaps is only used on Mainnet + this.ethersProvider = new ethers.providers.Web3Provider(provider, parseInt(MAINNET_CHAIN_ID, 16)) this._setupSwapsLivenessFetching() } diff --git a/test/stub/provider.js b/test/stub/provider.js index 6cbcb2700..4ff63297a 100644 --- a/test/stub/provider.js +++ b/test/stub/provider.js @@ -31,6 +31,9 @@ export function createTestProviderTools (opts = {}) { // handle block tracker methods engine.push(providerAsMiddleware(GanacheCore.provider({ mnemonic: getTestSeed(), + network_id: opts.networkId, + _chainId: opts.chainId, + _chainIdRpc: opts.chainId, }))) // wrap in standard provider interface const provider = providerFromEngine(engine) diff --git a/test/unit/app/controllers/swaps-test.js b/test/unit/app/controllers/swaps-test.js index ff54a3fd2..e473bd185 100644 --- a/test/unit/app/controllers/swaps-test.js +++ b/test/unit/app/controllers/swaps-test.js @@ -119,7 +119,7 @@ describe('SwapsController', function () { // by default, all accounts are external accounts (not contracts) eth_getCode: '0x', } - provider = createTestProviderTools({ scaffold: providerResultStub }) + provider = createTestProviderTools({ scaffold: providerResultStub, networkId: 1, chainId: 1 }) .provider })