aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-05-15 21:14:36 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-05-23 06:20:34 +0800
commit1ff34bd0f4084d2f9dfd6f07447bb63684ac51ac (patch)
treee7f1870dab995b33c381924707a17acc1feaf3c8 /packages/contracts
parentb86248f13fcb8f326098252beee6ca557e0175e7 (diff)
downloaddexon-sol-tools-1ff34bd0f4084d2f9dfd6f07447bb63684ac51ac.tar
dexon-sol-tools-1ff34bd0f4084d2f9dfd6f07447bb63684ac51ac.tar.gz
dexon-sol-tools-1ff34bd0f4084d2f9dfd6f07447bb63684ac51ac.tar.bz2
dexon-sol-tools-1ff34bd0f4084d2f9dfd6f07447bb63684ac51ac.tar.lz
dexon-sol-tools-1ff34bd0f4084d2f9dfd6f07447bb63684ac51ac.tar.xz
dexon-sol-tools-1ff34bd0f4084d2f9dfd6f07447bb63684ac51ac.tar.zst
dexon-sol-tools-1ff34bd0f4084d2f9dfd6f07447bb63684ac51ac.zip
Remove web3Factory.create and remove dev-tools dependency on sol-cov
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/package.json2
-rw-r--r--packages/contracts/src/utils/web3_wrapper.ts12
-rw-r--r--packages/contracts/test/global_hooks.ts4
-rw-r--r--packages/contracts/test/utils/coverage.ts21
4 files changed, 35 insertions, 4 deletions
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 9c7142cdb..f17c64a6f 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -44,6 +44,8 @@
"devDependencies": {
"@0xproject/abi-gen": "^0.2.13",
"@0xproject/dev-utils": "^0.4.1",
+ "@0xproject/subproviders": "^0.10.1",
+ "@0xproject/sol-cov": "^0.0.10",
"@0xproject/tslint-config": "^0.4.17",
"@types/lodash": "4.14.104",
"@types/node": "^8.0.53",
diff --git a/packages/contracts/src/utils/web3_wrapper.ts b/packages/contracts/src/utils/web3_wrapper.ts
index ed1c488a2..5d3d9f7c9 100644
--- a/packages/contracts/src/utils/web3_wrapper.ts
+++ b/packages/contracts/src/utils/web3_wrapper.ts
@@ -1,12 +1,18 @@
-import { devConstants, web3Factory } from '@0xproject/dev-utils';
+import { devConstants, env, EnvVars, web3Factory } from '@0xproject/dev-utils';
+import { prependSubprovider } from '@0xproject/subproviders';
import { Provider } from '@0xproject/types';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
+import { coverage } from './coverage';
+
export const txDefaults = {
from: devConstants.TESTRPC_FIRST_ADDRESS,
gas: devConstants.GAS_ESTIMATE,
};
const providerConfigs = { shouldUseInProcessGanache: true };
-export const web3 = web3Factory.create(providerConfigs);
-export const provider = web3.currentProvider;
+export const provider = web3Factory.getRpcProvider(providerConfigs);
+const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);
+if (isCoverageEnabled) {
+ prependSubprovider(provider, coverage.getCoverageSubproviderSingleton());
+}
export const web3Wrapper = new Web3Wrapper(provider);
diff --git a/packages/contracts/test/global_hooks.ts b/packages/contracts/test/global_hooks.ts
index 089521d94..509dc6837 100644
--- a/packages/contracts/test/global_hooks.ts
+++ b/packages/contracts/test/global_hooks.ts
@@ -1,4 +1,6 @@
-import { coverage, env, EnvVars } from '@0xproject/dev-utils';
+import { env, EnvVars } from '@0xproject/dev-utils';
+
+import { coverage } from './utils/coverage';
after('generate coverage report', async () => {
if (env.parseBoolean(EnvVars.SolidityCoverage)) {
diff --git a/packages/contracts/test/utils/coverage.ts b/packages/contracts/test/utils/coverage.ts
new file mode 100644
index 000000000..e3c5be428
--- /dev/null
+++ b/packages/contracts/test/utils/coverage.ts
@@ -0,0 +1,21 @@
+import { devConstants } from '@0xproject/dev-utils';
+import { CoverageSubprovider, ZeroExArtifactAdapter } from '@0xproject/sol-cov';
+import * as fs from 'fs';
+import * as _ from 'lodash';
+
+let coverageSubprovider: CoverageSubprovider;
+
+export const coverage = {
+ getCoverageSubproviderSingleton(): CoverageSubprovider {
+ if (_.isUndefined(coverageSubprovider)) {
+ coverageSubprovider = coverage._getCoverageSubprovider();
+ }
+ return coverageSubprovider;
+ },
+ _getCoverageSubprovider(): CoverageSubprovider {
+ const defaultFromAddress = devConstants.TESTRPC_FIRST_ADDRESS;
+ const config = JSON.parse(fs.readFileSync('compiler.json').toString());
+ const zeroExArtifactsAdapter = new ZeroExArtifactAdapter(config.artifactsDir, config.contractsDir);
+ return new CoverageSubprovider(zeroExArtifactsAdapter, defaultFromAddress);
+ },
+};