Refactor networkId out of web3Wrapper

This commit is contained in:
Leonid Logvinov
2017-12-08 12:51:46 +03:00
parent 5401c69163
commit b362e2c28e
12 changed files with 39 additions and 31 deletions

View File

@@ -31,7 +31,7 @@ export class Deployer {
const jsonrpcUrl = `http://localhost:${this.jsonrpcPort}`;
const web3Provider = new Web3.providers.HttpProvider(jsonrpcUrl);
this.defaults = opts.defaults;
this.web3Wrapper = new Web3Wrapper(web3Provider, this.networkId, this.defaults);
this.web3Wrapper = new Web3Wrapper(web3Provider, this.defaults);
}
/**
* Loads contract artifact and deploys contract with given arguments.

View File

@@ -1,4 +1,5 @@
import {promisify} from '@0xproject/utils';
import {Web3Wrapper} from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import * as Web3 from 'web3';
@@ -6,8 +7,8 @@ export const network = {
async getNetworkIdIfExistsAsync(port: number): Promise<number> {
const url = `http://localhost:${port}`;
const web3Provider = new Web3.providers.HttpProvider(url);
const web3 = new Web3(web3Provider);
const networkId = _.parseInt(await promisify<string>(web3.version.getNetwork)());
const web3Wrapper = new Web3Wrapper(web3Provider);
const networkId = web3Wrapper.getNetworkIdAsync();
return networkId;
},
};