diff options
author | fragosti <francesco.agosti93@gmail.com> | 2018-06-07 07:36:11 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2018-06-07 07:36:11 +0800 |
commit | e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a (patch) | |
tree | 84929c7ae4e95896dacfb69517aaaba97ec8ad85 /packages/contracts/src/utils/web3_wrapper.ts | |
parent | a97d77064aacda3de74b04894f110b05298c5ca8 (diff) | |
parent | 785b9811f30869f01242ce9ff81c282bf7f5352f (diff) | |
download | dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.gz dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.zst dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.zip |
Merge branch 'v2-prototype' of https://github.com/0xProject/0x-monorepo into feature/improve-linting
Diffstat (limited to 'packages/contracts/src/utils/web3_wrapper.ts')
-rw-r--r-- | packages/contracts/src/utils/web3_wrapper.ts | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts index 95fb55753..df9bf88c8 100644 --- a/packages/contracts/src/utils/web3_wrapper.ts +++ b/packages/contracts/src/utils/web3_wrapper.ts @@ -4,15 +4,50 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper'; 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); |