From 2004c0d7398a5e77d08e3b4d8030c0f22cb09cc8 Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Fri, 1 Jun 2018 13:19:36 -0700 Subject: Add ability to quickly switch between Geth and Ganache by changing a const --- packages/dev-utils/src/web3_factory.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'packages/dev-utils/src/web3_factory.ts') diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index d8379825a..25201228d 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -19,16 +19,22 @@ export interface Web3Config { hasAddresses?: boolean; // default: true shouldUseInProcessGanache?: boolean; // default: false rpcUrl?: string; // default: localhost:8545 + shouldUseFakeGasEstimate?: boolean; // default: true } export const web3Factory = { getRpcProvider(config: Web3Config = {}): ProviderEngine { const provider = new ProviderEngine(); const hasAddresses = _.isUndefined(config.hasAddresses) || config.hasAddresses; + config.shouldUseFakeGasEstimate = + _.isUndefined(config.shouldUseFakeGasEstimate) || config.shouldUseFakeGasEstimate; if (!hasAddresses) { provider.addProvider(new EmptyWalletSubprovider()); } - // provider.addProvider(new FakeGasEstimateSubprovider(constants.GAS_LIMIT)); + + if (config.shouldUseFakeGasEstimate) { + provider.addProvider(new FakeGasEstimateSubprovider(constants.GAS_LIMIT)); + } const logger = { log: (arg: any) => { fs.appendFileSync('ganache.log', `${arg}\n`); -- cgit v1.2.3