aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/utils/web3_wrapper.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-06-07 09:07:22 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-06-07 09:07:22 +0800
commit2af6d3f6bc03932f53d199971694c3c0d9441ba8 (patch)
treeb17f3343a635aa72a917b89f278f63924e25da3e /packages/contracts/src/utils/web3_wrapper.ts
parentcbe5438a31a54a92a198b2cc5ad8a5d5feb033b4 (diff)
parent67c4ad128c405692e471274148c9a2ef7cd8b6ca (diff)
downloaddexon-0x-contracts-2af6d3f6bc03932f53d199971694c3c0d9441ba8.tar.gz
dexon-0x-contracts-2af6d3f6bc03932f53d199971694c3c0d9441ba8.tar.zst
dexon-0x-contracts-2af6d3f6bc03932f53d199971694c3c0d9441ba8.zip
Merge branch 'v2-prototype' of https://github.com/0xProject/0x-monorepo into feature/website/onboarding-flow-allowances
Diffstat (limited to 'packages/contracts/src/utils/web3_wrapper.ts')
-rw-r--r--packages/contracts/src/utils/web3_wrapper.ts40
1 files changed, 37 insertions, 3 deletions
diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts
index 1049ab967..df9bf88c8 100644
--- a/packages/contracts/src/utils/web3_wrapper.ts
+++ b/packages/contracts/src/utils/web3_wrapper.ts
@@ -1,19 +1,53 @@
import { devConstants, env, EnvVars, web3Factory } from '@0xproject/dev-utils';
import { prependSubprovider } from '@0xproject/subproviders';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
-import { Provider } from 'ethereum-types';
import { coverage } from './coverage';
-export const txDefaults = {
+enum ProviderType {
+ Ganache = 'ganache',
+ Geth = 'geth',
+}
+
+let testProvider: ProviderType;
+switch (process.env.TEST_PROVIDER) {
+ case undefined:
+ testProvider = ProviderType.Ganache;
+ break;
+ case 'ganache':
+ testProvider = ProviderType.Ganache;
+ break;
+ case 'geth':
+ testProvider = ProviderType.Geth;
+ break;
+ default:
+ throw new Error(`Unknown TEST_PROVIDER: ${process.env.TEST_PROVIDER}`);
+}
+
+const ganacheTxDefaults = {
from: devConstants.TESTRPC_FIRST_ADDRESS,
gas: devConstants.GAS_LIMIT,
};
-const providerConfigs = { shouldUseInProcessGanache: true };
+const gethTxDefaults = {
+ from: devConstants.TESTRPC_FIRST_ADDRESS,
+};
+export const txDefaults = testProvider === ProviderType.Ganache ? ganacheTxDefaults : gethTxDefaults;
+
+const gethConfigs = {
+ shouldUseInProcessGanache: false,
+ rpcUrl: 'http://localhost:8501',
+ shouldUseFakeGasEstimate: false,
+};
+const ganacheConfigs = {
+ shouldUseInProcessGanache: true,
+};
+const providerConfigs = testProvider === ProviderType.Ganache ? ganacheConfigs : gethConfigs;
+
export const provider = web3Factory.getRpcProvider(providerConfigs);
const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);
if (isCoverageEnabled) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
prependSubprovider(provider, coverageSubprovider);
}
+
export const web3Wrapper = new Web3Wrapper(provider);