aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-12-08 23:01:40 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-12-14 22:47:02 +0800
commitcb596c1413938ce23901135f8235bb813cc6e784 (patch)
tree2810c3801e369691c482911af7218f7f4db43907 /packages
parent6120a43fff7b1b1aa1813533f3a990bb72df74a0 (diff)
downloaddexon-0x-contracts-cb596c1413938ce23901135f8235bb813cc6e784.tar.gz
dexon-0x-contracts-cb596c1413938ce23901135f8235bb813cc6e784.tar.zst
dexon-0x-contracts-cb596c1413938ce23901135f8235bb813cc6e784.zip
Move more shared utils into utils package and reuse them
Diffstat (limited to 'packages')
-rw-r--r--packages/0x.js/src/0x.ts3
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts2
-rw-r--r--packages/0x.js/src/order_watcher/event_watcher.ts2
-rw-r--r--packages/0x.js/src/order_watcher/expiration_watcher.ts2
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts2
-rw-r--r--packages/0x.js/test/0x.js_test.ts4
-rw-r--r--packages/0x.js/test/ether_token_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/exchange_transfer_simulator_test.ts4
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/expiration_watcher_test.ts5
-rw-r--r--packages/0x.js/test/order_state_watcher_test.ts4
-rw-r--r--packages/0x.js/test/order_validation_test.ts4
-rw-r--r--packages/0x.js/test/subscription_test.ts4
-rw-r--r--packages/0x.js/test/token_registry_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/token_wrapper_test.ts4
-rw-r--r--packages/0x.js/test/utils/blockchain_lifecycle.ts26
-rw-r--r--packages/0x.js/test/utils/constants.ts3
-rw-r--r--packages/0x.js/test/utils/rpc.ts58
-rw-r--r--packages/0x.js/test/utils/web3_factory.ts3
-rw-r--r--packages/contracts/package.json1
-rw-r--r--packages/contracts/test/ts/multi_sig_with_time_lock.ts6
-rw-r--r--packages/contracts/util/balances.ts2
-rw-r--r--packages/contracts/util/bignumber_config.ts11
-rw-r--r--packages/contracts/util/rpc.ts43
-rw-r--r--packages/types/src/index.ts4
-rw-r--r--packages/utils/src/bignumber_config.ts (renamed from packages/0x.js/src/bignumber_config.ts)0
-rw-r--r--packages/utils/src/class_utils.ts (renamed from packages/0x.js/src/utils/class_utils.ts)0
-rw-r--r--packages/utils/src/index.ts3
-rw-r--r--packages/utils/src/interval_utils.ts (renamed from packages/0x.js/src/utils/interval_utils.ts)0
29 files changed, 41 insertions, 171 deletions
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts
index 935e4ac1a..e93b5e615 100644
--- a/packages/0x.js/src/0x.ts
+++ b/packages/0x.js/src/0x.ts
@@ -1,11 +1,11 @@
import {schemas, SchemaValidator} from '@0xproject/json-schemas';
+import {intervalUtils, bigNumberConfigs} from '@0xproject/utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import BigNumber from 'bignumber.js';
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
import {artifacts} from './artifacts';
-import {bigNumberConfigs} from './bignumber_config';
import {EtherTokenWrapper} from './contract_wrappers/ether_token_wrapper';
import {ExchangeWrapper} from './contract_wrappers/exchange_wrapper';
import {TokenRegistryWrapper} from './contract_wrappers/token_registry_wrapper';
@@ -26,7 +26,6 @@ import {
import {AbiDecoder} from './utils/abi_decoder';
import {assert} from './utils/assert';
import {constants} from './utils/constants';
-import {intervalUtils} from './utils/interval_utils';
import {OrderStateUtils} from './utils/order_state_utils';
import {signatureUtils} from './utils/signature_utils';
import {utils} from './utils/utils';
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
index 5caf06db2..a796dc1ec 100644
--- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
@@ -1,3 +1,4 @@
+import {intervalUtils} from '@0xproject/utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import {Block, BlockAndLogStreamer} from 'ethereumjs-blockstream';
import * as _ from 'lodash';
@@ -19,7 +20,6 @@ import {
import {AbiDecoder} from '../utils/abi_decoder';
import {constants} from '../utils/constants';
import {filterUtils} from '../utils/filter_utils';
-import {intervalUtils} from '../utils/interval_utils';
const CONTRACT_NAME_TO_NOT_FOUND_ERROR: {[contractName: string]: ZeroExError} = {
ZRX: ZeroExError.ZRXContractDoesNotExist,
diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts
index d5b30d567..c11079208 100644
--- a/packages/0x.js/src/order_watcher/event_watcher.ts
+++ b/packages/0x.js/src/order_watcher/event_watcher.ts
@@ -1,3 +1,4 @@
+import {intervalUtils} from '@0xproject/utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -10,7 +11,6 @@ import {
} from '../types';
import {AbiDecoder} from '../utils/abi_decoder';
import {assert} from '../utils/assert';
-import {intervalUtils} from '../utils/interval_utils';
import {utils} from '../utils/utils';
const DEFAULT_EVENT_POLLING_INTERVAL_MS = 200;
diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts
index 9a1bb1ca4..5faac43cf 100644
--- a/packages/0x.js/src/order_watcher/expiration_watcher.ts
+++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts
@@ -1,10 +1,10 @@
+import {intervalUtils} from '@0xproject/utils';
import {BigNumber} from 'bignumber.js';
import {RBTree} from 'bintrees';
import * as _ from 'lodash';
import {ZeroEx} from '../0x';
import {SignedOrder, ZeroExError} from '../types';
-import {intervalUtils} from '../utils/interval_utils';
import {utils} from '../utils/utils';
const DEFAULT_EXPIRATION_MARGIN_MS = 0;
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts
index 08f52d6e1..9ae1579c6 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -1,4 +1,5 @@
import {schemas} from '@0xproject/json-schemas';
+import {intervalUtils} from '@0xproject/utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
@@ -29,7 +30,6 @@ import {
} from '../types';
import {AbiDecoder} from '../utils/abi_decoder';
import {assert} from '../utils/assert';
-import {intervalUtils} from '../utils/interval_utils';
import {OrderStateUtils} from '../utils/order_state_utils';
import {utils} from '../utils/utils';
diff --git a/packages/0x.js/test/0x.js_test.ts b/packages/0x.js/test/0x.js_test.ts
index 6b7a70699..52f9566dc 100644
--- a/packages/0x.js/test/0x.js_test.ts
+++ b/packages/0x.js/test/0x.js_test.ts
@@ -1,3 +1,4 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -6,13 +7,12 @@ import * as Sinon from 'sinon';
import {ApprovalContractEventArgs, LogWithDecodedArgs, Order, TokenEvents, ZeroEx, ZeroExError} from '../src';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {TokenUtils} from './utils/token_utils';
import {web3Factory} from './utils/web3_factory';
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
chaiSetup.configure();
const expect = chai.expect;
diff --git a/packages/0x.js/test/ether_token_wrapper_test.ts b/packages/0x.js/test/ether_token_wrapper_test.ts
index d3e4439ee..e0d738f84 100644
--- a/packages/0x.js/test/ether_token_wrapper_test.ts
+++ b/packages/0x.js/test/ether_token_wrapper_test.ts
@@ -1,3 +1,4 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import 'mocha';
@@ -5,14 +6,13 @@ import * as Web3 from 'web3';
import {ZeroEx, ZeroExError} from '../src';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
// Since the address depositing/withdrawing ETH/WETH also needs to pay gas costs for the transaction,
// a small amount of ETH will be used to pay this gas cost. We therefore check that the difference between
diff --git a/packages/0x.js/test/exchange_transfer_simulator_test.ts b/packages/0x.js/test/exchange_transfer_simulator_test.ts
index a1d9bdade..dbd1e99bd 100644
--- a/packages/0x.js/test/exchange_transfer_simulator_test.ts
+++ b/packages/0x.js/test/exchange_transfer_simulator_test.ts
@@ -1,3 +1,4 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
@@ -5,14 +6,13 @@ import {ExchangeContractErrs, Token, ZeroEx} from '../src';
import {BlockParamLiteral, TradeSide, TransferType} from '../src/types';
import {ExchangeTransferSimulator} from '../src/utils/exchange_transfer_simulator';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('ExchangeTransferSimulator', () => {
const web3 = web3Factory.create();
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts
index 14559c706..b7628e6d2 100644
--- a/packages/0x.js/test/exchange_wrapper_test.ts
+++ b/packages/0x.js/test/exchange_wrapper_test.ts
@@ -1,3 +1,4 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import 'mocha';
@@ -19,7 +20,6 @@ import {
} from '../src';
import {BlockParamLiteral, DoneCallback} from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {FillScenarios} from './utils/fill_scenarios';
@@ -28,7 +28,7 @@ import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
const NON_EXISTENT_ORDER_HASH = '0x79370342234e7acd6bbeac335bd3bb1d368383294b64b8160a00f4060e4d3777';
diff --git a/packages/0x.js/test/expiration_watcher_test.ts b/packages/0x.js/test/expiration_watcher_test.ts
index d4581259d..e72653b67 100644
--- a/packages/0x.js/test/expiration_watcher_test.ts
+++ b/packages/0x.js/test/expiration_watcher_test.ts
@@ -1,3 +1,4 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
@@ -12,8 +13,8 @@ import {DoneCallback, Token} from '../src/types';
import {constants} from '../src/utils/constants';
import {utils} from '../src/utils/utils';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
+import {constants as testConstants} from './utils/constants';
import {FillScenarios} from './utils/fill_scenarios';
import {reportCallbackErrors} from './utils/report_callback_errors';
import {TokenUtils} from './utils/token_utils';
@@ -21,7 +22,7 @@ import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(testConstants.RPC_URL);
describe('ExpirationWatcher', () => {
let web3: Web3;
diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts
index b5968dc24..4086c00fd 100644
--- a/packages/0x.js/test/order_state_watcher_test.ts
+++ b/packages/0x.js/test/order_state_watcher_test.ts
@@ -1,3 +1,4 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
@@ -21,7 +22,6 @@ import {
import {OrderStateWatcher} from '../src/order_watcher/order_state_watcher';
import {DoneCallback} from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {FillScenarios} from './utils/fill_scenarios';
@@ -33,7 +33,7 @@ const TIMEOUT_MS = 150;
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('OrderStateWatcher', () => {
let web3: Web3;
diff --git a/packages/0x.js/test/order_validation_test.ts b/packages/0x.js/test/order_validation_test.ts
index d585c1f3c..9c36ce0d6 100644
--- a/packages/0x.js/test/order_validation_test.ts
+++ b/packages/0x.js/test/order_validation_test.ts
@@ -1,3 +1,4 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import * as Sinon from 'sinon';
@@ -8,7 +9,6 @@ import {BlockParamLiteral, TradeSide, TransferType} from '../src/types';
import {ExchangeTransferSimulator} from '../src/utils/exchange_transfer_simulator';
import {OrderValidationUtils} from '../src/utils/order_validation_utils';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {FillScenarios} from './utils/fill_scenarios';
@@ -17,7 +17,7 @@ import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('OrderValidation', () => {
let web3: Web3;
diff --git a/packages/0x.js/test/subscription_test.ts b/packages/0x.js/test/subscription_test.ts
index 3aeeaa109..d280d720a 100644
--- a/packages/0x.js/test/subscription_test.ts
+++ b/packages/0x.js/test/subscription_test.ts
@@ -1,3 +1,4 @@
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
import * as _ from 'lodash';
@@ -15,7 +16,6 @@ import {
} from '../src';
import {BlockParamLiteral, DoneCallback} from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {reportCallbackErrors} from './utils/report_callback_errors';
@@ -24,7 +24,7 @@ import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('SubscriptionTest', () => {
let web3: Web3;
diff --git a/packages/0x.js/test/token_registry_wrapper_test.ts b/packages/0x.js/test/token_registry_wrapper_test.ts
index f1f307f3a..aaf4fa448 100644
--- a/packages/0x.js/test/token_registry_wrapper_test.ts
+++ b/packages/0x.js/test/token_registry_wrapper_test.ts
@@ -1,18 +1,18 @@
import {schemas, SchemaValidator} from '@0xproject/json-schemas';
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import * as chai from 'chai';
import * as _ from 'lodash';
import 'mocha';
import {Token, ZeroEx} from '../src';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
const TOKEN_REGISTRY_SIZE_AFTER_MIGRATION = 7;
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts
index ae6016869..2500168f9 100644
--- a/packages/0x.js/test/token_wrapper_test.ts
+++ b/packages/0x.js/test/token_wrapper_test.ts
@@ -1,4 +1,5 @@
import {promisify} from '@0xproject/utils';
+import {BlockchainLifecycle} from '@0xproject/dev-utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import BigNumber from 'bignumber.js';
import * as chai from 'chai';
@@ -21,7 +22,6 @@ import {
} from '../src';
import {BlockParamLiteral, DoneCallback} from '../src/types';
-import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {chaiSetup} from './utils/chai_setup';
import {constants} from './utils/constants';
import {TokenUtils} from './utils/token_utils';
@@ -29,7 +29,7 @@ import {web3Factory} from './utils/web3_factory';
chaiSetup.configure();
const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle();
+const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL);
describe('TokenWrapper', () => {
let web3: Web3;
diff --git a/packages/0x.js/test/utils/blockchain_lifecycle.ts b/packages/0x.js/test/utils/blockchain_lifecycle.ts
deleted file mode 100644
index 9a44ccd6f..000000000
--- a/packages/0x.js/test/utils/blockchain_lifecycle.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import {RPC} from './rpc';
-
-export class BlockchainLifecycle {
- private rpc: RPC;
- private snapshotIdsStack: number[];
- constructor() {
- this.rpc = new RPC();
- this.snapshotIdsStack = [];
- }
- // TODO: In order to run these tests on an actual node, we should check if we are running against
- // TestRPC, if so, use snapshots, otherwise re-deploy contracts before every test
- public async startAsync(): Promise<void> {
- const snapshotId = await this.rpc.takeSnapshotAsync();
- this.snapshotIdsStack.push(snapshotId);
- }
- public async revertAsync(): Promise<void> {
- const snapshotId = this.snapshotIdsStack.pop() as number;
- const didRevert = await this.rpc.revertSnapshotAsync(snapshotId);
- if (!didRevert) {
- throw new Error(`Snapshot with id #${snapshotId} failed to revert`);
- }
- }
- public async mineABlock(): Promise<void> {
- await this.rpc.mineBlockAsync();
- }
-}
diff --git a/packages/0x.js/test/utils/constants.ts b/packages/0x.js/test/utils/constants.ts
index 75fdf49c9..d486da581 100644
--- a/packages/0x.js/test/utils/constants.ts
+++ b/packages/0x.js/test/utils/constants.ts
@@ -1,7 +1,6 @@
export const constants = {
NULL_ADDRESS: '0x0000000000000000000000000000000000000000',
- RPC_HOST: 'localhost',
- RPC_PORT: 8545,
+ RPC_URL: 'http://localhost:8545',
ROPSTEN_NETWORK_ID: 3,
KOVAN_NETWORK_ID: 42,
TESTRPC_NETWORK_ID: 50,
diff --git a/packages/0x.js/test/utils/rpc.ts b/packages/0x.js/test/utils/rpc.ts
deleted file mode 100644
index 309a96d5e..000000000
--- a/packages/0x.js/test/utils/rpc.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-import * as ethUtil from 'ethereumjs-util';
-import * as request from 'request-promise-native';
-
-import {constants} from './constants';
-
-export class RPC {
- private host: string;
- private port: number;
- private id: number;
- constructor() {
- this.host = constants.RPC_HOST;
- this.port = constants.RPC_PORT;
- this.id = 0;
- }
- public async takeSnapshotAsync(): Promise<number> {
- const method = 'evm_snapshot';
- const params: any[] = [];
- const payload = this.toPayload(method, params);
- const snapshotIdHex = await this.sendAsync(payload);
- const snapshotId = ethUtil.bufferToInt(ethUtil.toBuffer(snapshotIdHex));
- return snapshotId;
- }
- public async revertSnapshotAsync(snapshotId: number): Promise<boolean> {
- const method = 'evm_revert';
- const params = [snapshotId];
- const payload = this.toPayload(method, params);
- const didRevert = await this.sendAsync(payload);
- return didRevert;
- }
- public async mineBlockAsync(): Promise<void> {
- const method = 'evm_mine';
- const params: any[] = [];
- const payload = this.toPayload(method, params);
- await this.sendAsync(payload);
- }
- private toPayload(method: string, params: any[] = []): string {
- const payload = JSON.stringify({
- id: this.id,
- method,
- params,
- });
- this.id += 1;
- return payload;
- }
- private async sendAsync(payload: string): Promise<any> {
- const opts = {
- method: 'POST',
- uri: `http://${this.host}:${this.port}`,
- body: payload,
- headers: {
- 'content-type': 'application/json',
- },
- };
- const bodyString = await request(opts);
- const body = JSON.parse(bodyString);
- return body.result;
- }
-}
diff --git a/packages/0x.js/test/utils/web3_factory.ts b/packages/0x.js/test/utils/web3_factory.ts
index da4828943..6f72cec58 100644
--- a/packages/0x.js/test/utils/web3_factory.ts
+++ b/packages/0x.js/test/utils/web3_factory.ts
@@ -21,13 +21,12 @@ export const web3Factory = {
},
getRpcProvider(hasAddresses: boolean = true): Web3.Provider {
const provider = new ProviderEngine();
- const rpcUrl = `http://${constants.RPC_HOST}:${constants.RPC_PORT}`;
if (!hasAddresses) {
provider.addProvider(new EmptyWalletSubprovider());
}
provider.addProvider(new FakeGasEstimateSubprovider(constants.GAS_ESTIMATE));
provider.addProvider(new RpcSubprovider({
- rpcUrl,
+ rpcUrl: constants.RPC_URL,
}));
provider.start();
return provider;
diff --git a/packages/contracts/package.json b/packages/contracts/package.json
index 93f28f990..c8ccd0a3a 100644
--- a/packages/contracts/package.json
+++ b/packages/contracts/package.json
@@ -29,6 +29,7 @@
},
"homepage": "https://github.com/0xProject/0x.js/packages/contracts/README.md",
"devDependencies": {
+ "@0xproject/dev-utils": "^0.0.1",
"@0xproject/tslint-config": "^0.2.1",
"@0xproject/types": "^0.1.0",
"@types/bluebird": "^3.5.3",
diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock.ts b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
index 84eb21b4a..d92c5967f 100644
--- a/packages/contracts/test/ts/multi_sig_with_time_lock.ts
+++ b/packages/contracts/test/ts/multi_sig_with_time_lock.ts
@@ -1,13 +1,14 @@
+import {RPC} from '@0xproject/dev-utils';
import {promisify} from '@0xproject/utils';
import {BigNumber} from 'bignumber.js';
import * as chai from 'chai';
import Web3 = require('web3');
import * as multiSigWalletJSON from '../../build/contracts/MultiSigWalletWithTimeLock.json';
+import * as truffleConf from '../../truffle.js';
import {Artifacts} from '../../util/artifacts';
import {constants} from '../../util/constants';
import {MultiSigWrapper} from '../../util/multi_sig_wrapper';
-import {RPC} from '../../util/rpc';
import {ContractInstance} from '../../util/types';
import {chaiSetup} from './utils/chai_setup';
@@ -38,7 +39,8 @@ contract('MultiSigWalletWithTimeLock', (accounts: string[]) => {
const secondsTimeLocked = await multiSig.secondsTimeLocked.call();
initialSecondsTimeLocked = secondsTimeLocked.toNumber();
- rpc = new RPC();
+ const rpcUrl = `http://${truffleConf.networks.development.host}:${truffleConf.networks.development.port}`;
+ rpc = new RPC(rpcUrl);
});
describe('changeTimeLock', () => {
diff --git a/packages/contracts/util/balances.ts b/packages/contracts/util/balances.ts
index fce15db6d..7f5e843a5 100644
--- a/packages/contracts/util/balances.ts
+++ b/packages/contracts/util/balances.ts
@@ -1,7 +1,7 @@
+import {bigNumberConfigs} from '@0xproject/utils';
import {BigNumber} from 'bignumber.js';
import * as _ from 'lodash';
-import {bigNumberConfigs} from './bignumber_config';
import {BalancesByOwner, ContractInstance} from './types';
bigNumberConfigs.configure();
diff --git a/packages/contracts/util/bignumber_config.ts b/packages/contracts/util/bignumber_config.ts
deleted file mode 100644
index 38f59d341..000000000
--- a/packages/contracts/util/bignumber_config.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import {BigNumber} from 'bignumber.js';
-
-export const bigNumberConfigs = {
- configure() {
- // By default BigNumber's `toString` method converts to exponential notation if the value has
- // more then 20 digits. We want to avoid this behavior, so we set EXPONENTIAL_AT to a high number
- BigNumber.config({
- EXPONENTIAL_AT: 1000,
- });
- },
-};
diff --git a/packages/contracts/util/rpc.ts b/packages/contracts/util/rpc.ts
deleted file mode 100644
index 023602bd6..000000000
--- a/packages/contracts/util/rpc.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import 'isomorphic-fetch';
-
-import * as truffleConf from '../truffle.js';
-
-export class RPC {
- private host: string;
- private port: number;
- private id: number;
- constructor() {
- this.host = truffleConf.networks.development.host;
- this.port = truffleConf.networks.development.port;
- this.id = 0;
- }
- public async increaseTimeAsync(time: number) {
- const method = 'evm_increaseTime';
- const params = [time];
- const payload = this.toPayload(method, params);
- return this.sendAsync(payload);
- }
- public async mineBlockAsync() {
- const method = 'evm_mine';
- const payload = this.toPayload(method);
- return this.sendAsync(payload);
- }
- private toPayload(method: string, params: any[] = []) {
- const payload = JSON.stringify({
- id: this.id,
- method,
- params,
- });
- this.id++;
- return payload;
- }
- private async sendAsync(payload: string): Promise<any> {
- const opts = {
- method: 'POST',
- body: payload,
- };
- const response = await fetch(`http://${this.host}:${this.port}`, opts);
- const responsePayload = await response.json();
- return responsePayload;
- }
-}
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 8d69af63d..3db1aebe1 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -8,6 +8,10 @@ export interface TxData {
nonce?: number;
}
+export interface TxDataPayable extends TxData {
+ value?: BigNumber;
+}
+
export interface TransactionReceipt {
blockHash: string;
blockNumber: number;
diff --git a/packages/0x.js/src/bignumber_config.ts b/packages/utils/src/bignumber_config.ts
index 2d5214e6f..2d5214e6f 100644
--- a/packages/0x.js/src/bignumber_config.ts
+++ b/packages/utils/src/bignumber_config.ts
diff --git a/packages/0x.js/src/utils/class_utils.ts b/packages/utils/src/class_utils.ts
index 04e60ee57..04e60ee57 100644
--- a/packages/0x.js/src/utils/class_utils.ts
+++ b/packages/utils/src/class_utils.ts
diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts
index edfd192b2..403bc7236 100644
--- a/packages/utils/src/index.ts
+++ b/packages/utils/src/index.ts
@@ -1,2 +1,5 @@
export {promisify} from './promisify';
export {addressUtils} from './address_utils';
+export {classUtils} from './class_utils';
+export {intervalUtils} from './interval_utils';
+export {bigNumberConfigs} from './bignumber_config';
diff --git a/packages/0x.js/src/utils/interval_utils.ts b/packages/utils/src/interval_utils.ts
index 62b79f2f5..62b79f2f5 100644
--- a/packages/0x.js/src/utils/interval_utils.ts
+++ b/packages/utils/src/interval_utils.ts