diff options
author | Fabio Berger <me@fabioberger.com> | 2018-07-05 06:38:15 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-07-05 06:38:15 +0800 |
commit | a0b9c7777b2171456a19aa6ddcf2a023b663a816 (patch) | |
tree | b9cf9fe6d0030bf0e2591d3facccf38ff2d622c6 /packages/dev-utils | |
parent | 5204e4c08da7d32012047ee6ca4d898b0c45a47d (diff) | |
parent | 5176d929fa6d3c6ce414448ea2441bd450f04e3c (diff) | |
download | dexon-sol-tools-a0b9c7777b2171456a19aa6ddcf2a023b663a816.tar dexon-sol-tools-a0b9c7777b2171456a19aa6ddcf2a023b663a816.tar.gz dexon-sol-tools-a0b9c7777b2171456a19aa6ddcf2a023b663a816.tar.bz2 dexon-sol-tools-a0b9c7777b2171456a19aa6ddcf2a023b663a816.tar.lz dexon-sol-tools-a0b9c7777b2171456a19aa6ddcf2a023b663a816.tar.xz dexon-sol-tools-a0b9c7777b2171456a19aa6ddcf2a023b663a816.tar.zst dexon-sol-tools-a0b9c7777b2171456a19aa6ddcf2a023b663a816.zip |
merge v2-prototype
Diffstat (limited to 'packages/dev-utils')
-rw-r--r-- | packages/dev-utils/package.json | 5 | ||||
-rw-r--r-- | packages/dev-utils/src/blockchain_lifecycle.ts | 26 | ||||
-rw-r--r-- | packages/dev-utils/src/web3_factory.ts | 5 |
3 files changed, 11 insertions, 25 deletions
diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index e62075054..15f8d6ab0 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -48,12 +48,11 @@ "@0xproject/subproviders": "^0.10.4", "@0xproject/types": "^0.8.1", "@0xproject/utils": "^0.7.1", - "ethereum-types": "^0.0.1", + "ethereum-types": "^0.0.2", "@0xproject/typescript-typings": "^0.4.1", "@0xproject/web3-wrapper": "^0.7.1", "lodash": "^4.17.4", - "web3": "^0.20.0", - "web3-provider-engine": "^14.0.4" + "web3-provider-engine": "14.0.6" }, "publishConfig": { "access": "public" diff --git a/packages/dev-utils/src/blockchain_lifecycle.ts b/packages/dev-utils/src/blockchain_lifecycle.ts index 587332f1a..9bd65ee5d 100644 --- a/packages/dev-utils/src/blockchain_lifecycle.ts +++ b/packages/dev-utils/src/blockchain_lifecycle.ts @@ -1,11 +1,6 @@ import { logUtils } from '@0xproject/utils'; -import { uniqueVersionIds, Web3Wrapper } from '@0xproject/web3-wrapper'; -import { includes } from 'lodash'; - -enum NodeType { - Geth = 'GETH', - Ganache = 'GANACHE', -} +import { NodeType, Web3Wrapper } from '@0xproject/web3-wrapper'; +import * as _ from 'lodash'; // HACK(albrow): 🐉 We have to do this so that debug.setHead works correctly. // (Geth does not seem to like debug.setHead(0), so by sending some transactions @@ -18,6 +13,7 @@ export class BlockchainLifecycle { private _web3Wrapper: Web3Wrapper; private _snapshotIdsStack: number[]; private _addresses: string[] = []; + private _nodeType: NodeType | undefined; constructor(web3Wrapper: Web3Wrapper) { this._web3Wrapper = web3Wrapper; this._snapshotIdsStack = []; @@ -61,16 +57,6 @@ export class BlockchainLifecycle { throw new Error(`Unknown node type: ${nodeType}`); } } - private async _getNodeTypeAsync(): Promise<NodeType> { - const version = await this._web3Wrapper.getNodeVersionAsync(); - if (includes(version, uniqueVersionIds.geth)) { - return NodeType.Geth; - } else if (includes(version, uniqueVersionIds.ganache)) { - return NodeType.Ganache; - } else { - throw new Error(`Unknown client version: ${version}`); - } - } private async _mineMinimumBlocksAsync(): Promise<void> { logUtils.warn('WARNING: minimum block number for tests not met. Mining additional blocks...'); if (this._addresses.length === 0) { @@ -92,4 +78,10 @@ export class BlockchainLifecycle { } logUtils.warn('Done mining the minimum number of blocks.'); } + private async _getNodeTypeAsync(): Promise<NodeType> { + if (_.isUndefined(this._nodeType)) { + this._nodeType = await this._web3Wrapper.getNodeTypeAsync(); + } + return this._nodeType; + } } diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index 47eef4cbd..362a6c3c6 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -1,8 +1,3 @@ -// HACK: web3 injects XMLHttpRequest into the global scope and ProviderEngine checks XMLHttpRequest -// to know whether it is running in a browser or node environment. We need it to be undefined since -// we are not running in a browser env. -// Filed issue: https://github.com/ethereum/web3.js/issues/844 -(global as any).XMLHttpRequest = undefined; import ProviderEngine = require('web3-provider-engine'); import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); |