diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-07 01:56:01 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-07 03:41:15 +0800 |
commit | 5d2f9d7a33c4494b06098f13fca487613fe83c73 (patch) | |
tree | ab2f4278d4acd39f6ea51ab21cecb5a3c793666b /packages/contracts/src/utils | |
parent | 3baf14b793be44910d71c093f911429203ac4ee5 (diff) | |
download | dexon-0x-contracts-5d2f9d7a33c4494b06098f13fca487613fe83c73.tar.gz dexon-0x-contracts-5d2f9d7a33c4494b06098f13fca487613fe83c73.tar.zst dexon-0x-contracts-5d2f9d7a33c4494b06098f13fca487613fe83c73.zip |
Use an enum for ProviderType in contracts/src/utils/web3_wrapper
Diffstat (limited to 'packages/contracts/src/utils')
-rw-r--r-- | packages/contracts/src/utils/web3_wrapper.ts | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts index 6df8ac073..63ce2c8cc 100644 --- a/packages/contracts/src/utils/web3_wrapper.ts +++ b/packages/contracts/src/utils/web3_wrapper.ts @@ -5,7 +5,25 @@ import { Provider } from 'ethereum-types'; import { coverage } from './coverage'; -const testProvider = process.env.TEST_PROVIDER || 'ganache'; +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, @@ -14,7 +32,7 @@ const ganacheTxDefaults = { const gethTxDefaults = { from: devConstants.TESTRPC_FIRST_ADDRESS, }; -export const txDefaults = testProvider === 'ganache' ? ganacheTxDefaults : gethTxDefaults; +export const txDefaults = testProvider === ProviderType.Ganache ? ganacheTxDefaults : gethTxDefaults; const gethConfigs = { shouldUseInProcessGanache: false, @@ -24,8 +42,7 @@ const gethConfigs = { const ganacheConfigs = { shouldUseInProcessGanache: true, }; - -const providerConfigs = testProvider === 'ganache' ? ganacheConfigs : gethConfigs; +const providerConfigs = testProvider === ProviderType.Ganache ? ganacheConfigs : gethConfigs; export const provider = web3Factory.getRpcProvider(providerConfigs); const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage); |