aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/util
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/util
parent6120a43fff7b1b1aa1813533f3a990bb72df74a0 (diff)
downloaddexon-sol-tools-cb596c1413938ce23901135f8235bb813cc6e784.tar
dexon-sol-tools-cb596c1413938ce23901135f8235bb813cc6e784.tar.gz
dexon-sol-tools-cb596c1413938ce23901135f8235bb813cc6e784.tar.bz2
dexon-sol-tools-cb596c1413938ce23901135f8235bb813cc6e784.tar.lz
dexon-sol-tools-cb596c1413938ce23901135f8235bb813cc6e784.tar.xz
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/util')
-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
3 files changed, 1 insertions, 55 deletions
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;
- }
-}