From 2e5ff53d7271509accc226e83d76d1785350b1d2 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 13 Jul 2018 12:42:01 +0200 Subject: -fetch'; --- packages/dev-utils/src/web3_factory.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'packages/dev-utils') diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index 362a6c3c6..67112d410 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -1,7 +1,11 @@ import ProviderEngine = require('web3-provider-engine'); -import RpcSubprovider = require('web3-provider-engine/subproviders/rpc'); -import { EmptyWalletSubprovider, FakeGasEstimateSubprovider, GanacheSubprovider } from '@0xproject/subproviders'; +import { + EmptyWalletSubprovider, + FakeGasEstimateSubprovider, + GanacheSubprovider, + RPCSubprovider, +} from '@0xproject/subproviders'; import * as fs from 'fs'; import * as _ from 'lodash'; @@ -49,11 +53,7 @@ export const web3Factory = { }), ); } else { - provider.addProvider( - new RpcSubprovider({ - rpcUrl: config.rpcUrl || constants.RPC_URL, - }), - ); + provider.addProvider(new RPCSubprovider(config.rpcUrl || constants.RPC_URL)); } provider.start(); return provider; -- cgit v1.2.3 From 512502ca0873a290accb53777ca9d93f8d28e84b Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 13 Jul 2018 14:26:02 +0200 Subject: Export Web3ProviderEngine from subproviders package --- packages/dev-utils/package.json | 3 +-- packages/dev-utils/src/web3_factory.ts | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'packages/dev-utils') diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index 1808e23e4..f0ef24684 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -51,8 +51,7 @@ "ethereum-types": "^0.0.2", "@0xproject/typescript-typings": "^0.4.2", "@0xproject/web3-wrapper": "^0.7.2", - "lodash": "^4.17.4", - "web3-provider-engine": "14.0.6" + "lodash": "^4.17.4" }, "publishConfig": { "access": "public" diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index 67112d410..8e713fa68 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -1,10 +1,9 @@ -import ProviderEngine = require('web3-provider-engine'); - import { EmptyWalletSubprovider, FakeGasEstimateSubprovider, GanacheSubprovider, RPCSubprovider, + Web3ProviderEngine, } from '@0xproject/subproviders'; import * as fs from 'fs'; import * as _ from 'lodash'; @@ -20,8 +19,8 @@ export interface Web3Config { } export const web3Factory = { - getRpcProvider(config: Web3Config = {}): ProviderEngine { - const provider = new ProviderEngine(); + getRpcProvider(config: Web3Config = {}): Web3ProviderEngine { + const provider = new Web3ProviderEngine(); const hasAddresses = _.isUndefined(config.hasAddresses) || config.hasAddresses; config.shouldUseFakeGasEstimate = _.isUndefined(config.shouldUseFakeGasEstimate) || config.shouldUseFakeGasEstimate; -- cgit v1.2.3 From edcdc9b1b903158cc61529853d7e9028ecbc266a Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 17 Jul 2018 12:58:42 +0200 Subject: Upgrade tslint to the newest version --- packages/dev-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/dev-utils') diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index f0ef24684..82e8c73b9 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -41,7 +41,7 @@ "npm-run-all": "^4.1.2", "nyc": "^11.0.1", "shx": "^0.2.2", - "tslint": "5.8.0", + "tslint": "5.11.0", "typescript": "2.7.1" }, "dependencies": { -- cgit v1.2.3 From bf8ac3b9e6ee59f267f7850418febfe84dedceb8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 17 Jul 2018 12:59:02 +0200 Subject: Fix tslint issues --- packages/dev-utils/src/blockchain_lifecycle.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'packages/dev-utils') diff --git a/packages/dev-utils/src/blockchain_lifecycle.ts b/packages/dev-utils/src/blockchain_lifecycle.ts index 9bd65ee5d..73e2a58c9 100644 --- a/packages/dev-utils/src/blockchain_lifecycle.ts +++ b/packages/dev-utils/src/blockchain_lifecycle.ts @@ -10,8 +10,8 @@ import * as _ from 'lodash'; const MINIMUM_BLOCKS = 3; export class BlockchainLifecycle { - private _web3Wrapper: Web3Wrapper; - private _snapshotIdsStack: number[]; + private readonly _web3Wrapper: Web3Wrapper; + private readonly _snapshotIdsStack: number[]; private _addresses: string[] = []; private _nodeType: NodeType | undefined; constructor(web3Wrapper: Web3Wrapper) { -- cgit v1.2.3 From 2bfacbb8bab837656368e54ac4bb544f2d4b423b Mon Sep 17 00:00:00 2001 From: Alex Browne Date: Tue, 17 Jul 2018 11:26:47 -0700 Subject: Mine a dummy block in blockchain_lifecycle to re-apply any time offset --- packages/dev-utils/src/blockchain_lifecycle.ts | 39 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'packages/dev-utils') diff --git a/packages/dev-utils/src/blockchain_lifecycle.ts b/packages/dev-utils/src/blockchain_lifecycle.ts index 9bd65ee5d..a0424f01f 100644 --- a/packages/dev-utils/src/blockchain_lifecycle.ts +++ b/packages/dev-utils/src/blockchain_lifecycle.ts @@ -34,6 +34,12 @@ export class BlockchainLifecycle { blockNumber = await this._web3Wrapper.getBlockNumberAsync(); } this._snapshotIdsStack.push(blockNumber); + // HACK(albrow) It's possible that we applied a time offset but + // the transaction we mined to put that time offset into the + // blockchain was reverted. As a workaround, we mine a new dummy + // block so that the latest block timestamp accounts for any + // possible time offsets. + await this._mineDummyBlockAsync(); break; default: throw new Error(`Unknown node type: ${nodeType}`); @@ -59,22 +65,9 @@ export class BlockchainLifecycle { } private async _mineMinimumBlocksAsync(): Promise { logUtils.warn('WARNING: minimum block number for tests not met. Mining additional blocks...'); - if (this._addresses.length === 0) { - this._addresses = await this._web3Wrapper.getAvailableAddressesAsync(); - if (this._addresses.length === 0) { - throw new Error('No accounts found'); - } - } while ((await this._web3Wrapper.getBlockNumberAsync()) < MINIMUM_BLOCKS) { logUtils.warn('Mining block...'); - await this._web3Wrapper.awaitTransactionMinedAsync( - await this._web3Wrapper.sendTransactionAsync({ - from: this._addresses[0], - to: this._addresses[0], - value: '0', - }), - 0, - ); + await this._mineDummyBlockAsync(); } logUtils.warn('Done mining the minimum number of blocks.'); } @@ -84,4 +77,22 @@ export class BlockchainLifecycle { } return this._nodeType; } + // Sends a transaction that has no real effect on the state and waits for it + // to be mined. + private async _mineDummyBlockAsync(): Promise { + if (this._addresses.length === 0) { + this._addresses = await this._web3Wrapper.getAvailableAddressesAsync(); + if (this._addresses.length === 0) { + throw new Error('No accounts found'); + } + } + await this._web3Wrapper.awaitTransactionMinedAsync( + await this._web3Wrapper.sendTransactionAsync({ + from: this._addresses[0], + to: this._addresses[0], + value: '0', + }), + 0, + ); + } } -- cgit v1.2.3 From 8a2a4052f33df4461065df77c81f95bed58b9532 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 18 Jul 2018 15:30:38 +0200 Subject: Update changelogs --- packages/dev-utils/CHANGELOG.json | 9 +++++++++ packages/dev-utils/CHANGELOG.md | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'packages/dev-utils') diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json index 56ecd023e..d092ddf55 100644 --- a/packages/dev-utils/CHANGELOG.json +++ b/packages/dev-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "timestamp": 1531919263, + "version": "0.4.6", + "changes": [ + { + "note": "Dependencies updated" + } + ] + }, { "timestamp": 1531149657, "version": "0.4.5", diff --git a/packages/dev-utils/CHANGELOG.md b/packages/dev-utils/CHANGELOG.md index 55e12b2dd..de9287478 100644 --- a/packages/dev-utils/CHANGELOG.md +++ b/packages/dev-utils/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v0.4.6 - _July 18, 2018_ + + * Dependencies updated + ## v0.4.5 - _July 9, 2018_ * Dependencies updated -- cgit v1.2.3 From f99232095b3effea261b5b24bc01db4f96c416f6 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Wed, 18 Jul 2018 15:48:09 +0200 Subject: Update package versions --- packages/dev-utils/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'packages/dev-utils') diff --git a/packages/dev-utils/package.json b/packages/dev-utils/package.json index 82e8c73b9..3267f98d9 100644 --- a/packages/dev-utils/package.json +++ b/packages/dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/dev-utils", - "version": "0.4.5", + "version": "0.4.6", "engines": { "node": ">=6.12" }, @@ -45,12 +45,12 @@ "typescript": "2.7.1" }, "dependencies": { - "@0xproject/subproviders": "^0.10.5", + "@0xproject/subproviders": "^0.10.6", "@0xproject/types": "^0.8.2", - "@0xproject/utils": "^0.7.2", + "@0xproject/utils": "^0.7.3", "ethereum-types": "^0.0.2", - "@0xproject/typescript-typings": "^0.4.2", - "@0xproject/web3-wrapper": "^0.7.2", + "@0xproject/typescript-typings": "^0.4.3", + "@0xproject/web3-wrapper": "^0.7.3", "lodash": "^4.17.4" }, "publishConfig": { -- cgit v1.2.3