aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
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/contracts
parent6120a43fff7b1b1aa1813533f3a990bb72df74a0 (diff)
downloaddexon-sol-tools-cb596c1413938ce23901135f8235bb813cc6e784.tar.gz
dexon-sol-tools-cb596c1413938ce23901135f8235bb813cc6e784.tar.zst
dexon-sol-tools-cb596c1413938ce23901135f8235bb813cc6e784.zip
Move more shared utils into utils package and reuse them
Diffstat (limited to 'packages/contracts')
-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
5 files changed, 6 insertions, 57 deletions
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;
- }
-}