diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-15 04:58:28 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-06-15 04:58:54 +0800 |
commit | 7ab921669bf52c1cb2d43350b2cccc8efe91bdbd (patch) | |
tree | 3ed0e1047f6b9bb04ce7084cb0b98bdb5cb5b78a /packages/contracts/src/utils/web3_wrapper.ts | |
parent | 4efd28c092e74b438d0397069c0c55cc90c537f2 (diff) | |
download | dexon-0x-contracts-7ab921669bf52c1cb2d43350b2cccc8efe91bdbd.tar dexon-0x-contracts-7ab921669bf52c1cb2d43350b2cccc8efe91bdbd.tar.gz dexon-0x-contracts-7ab921669bf52c1cb2d43350b2cccc8efe91bdbd.tar.bz2 dexon-0x-contracts-7ab921669bf52c1cb2d43350b2cccc8efe91bdbd.tar.lz dexon-0x-contracts-7ab921669bf52c1cb2d43350b2cccc8efe91bdbd.tar.xz dexon-0x-contracts-7ab921669bf52c1cb2d43350b2cccc8efe91bdbd.tar.zst dexon-0x-contracts-7ab921669bf52c1cb2d43350b2cccc8efe91bdbd.zip |
Introduce subprovider for printing revert stack traces
Diffstat (limited to 'packages/contracts/src/utils/web3_wrapper.ts')
-rw-r--r-- | packages/contracts/src/utils/web3_wrapper.ts | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts index c475d96a9..b8e8ed8ce 100644 --- a/packages/contracts/src/utils/web3_wrapper.ts +++ b/packages/contracts/src/utils/web3_wrapper.ts @@ -5,6 +5,7 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { coverage } from './coverage'; import { profiler } from './profiler'; +import { revertTrace } from './revert_trace'; enum ProviderType { Ganache = 'ganache', @@ -48,28 +49,34 @@ const providerConfigs = testProvider === ProviderType.Ganache ? ganacheConfigs : export const provider = web3Factory.getRpcProvider(providerConfigs); const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage); const isProfilerEnabled = env.parseBoolean(EnvVars.SolidityProfiler); -if (isCoverageEnabled && isProfilerEnabled) { - throw new Error( - `Unfortunately for now you can't enable both coverage and profiler at the same time. They both use coverage.json file and there is no way to configure that.`, - ); -} -if (isCoverageEnabled) { - const coverageSubprovider = coverage.getCoverageSubproviderSingleton(); - prependSubprovider(provider, coverageSubprovider); -} -if (isProfilerEnabled) { - if (testProvider === ProviderType.Ganache) { - logUtils.warn( - "Gas costs in Ganache traces are incorrect and we don't recommend using it for profiling. Please switch to Geth", - ); - process.exit(1); - } - const profilerSubprovider = profiler.getProfilerSubproviderSingleton(); - logUtils.log( - "By default profilerSubprovider is stopped so that you don't get noise from setup code. Don't forget to start it before the code you want to profile and stop it afterwards", - ); - profilerSubprovider.stop(); - prependSubprovider(provider, profilerSubprovider); +const isRevertTraceEnabled = env.parseBoolean(EnvVars.SolidityRevertTrace); +// TODO(albrow): Include revertTrace checks in the warnings below. +// if (isCoverageEnabled && isProfilerEnabled) { +// throw new Error( +// `Unfortunately for now you can't enable both coverage and profiler at the same time. They both use coverage.json file and there is no way to configure that.`, +// ); +// } +// if (isCoverageEnabled) { +// const coverageSubprovider = coverage.getCoverageSubproviderSingleton(); +// prependSubprovider(provider, coverageSubprovider); +// } +// if (isProfilerEnabled) { +// if (testProvider === ProviderType.Ganache) { +// logUtils.warn( +// "Gas costs in Ganache traces are incorrect and we don't recommend using it for profiling. Please switch to Geth", +// ); +// process.exit(1); +// } +// const profilerSubprovider = profiler.getProfilerSubproviderSingleton(); +// logUtils.log( +// "By default profilerSubprovider is stopped so that you don't get noise from setup code. Don't forget to start it before the code you want to profile and stop it afterwards", +// ); +// profilerSubprovider.stop(); +// prependSubprovider(provider, profilerSubprovider); +// } +if (isRevertTraceEnabled) { + const revertTraceSubprovider = revertTrace.getRevertTraceSubproviderSingleton(); + prependSubprovider(provider, revertTraceSubprovider); } export const web3Wrapper = new Web3Wrapper(provider); |