Inline network module
This commit is contained in:
parent
36125c3539
commit
e0d79bd332
@ -1,10 +1,11 @@
|
|||||||
|
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
||||||
import {BigNumber} from 'bignumber.js';
|
import {BigNumber} from 'bignumber.js';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
import * as Web3 from 'web3';
|
||||||
import * as yargs from 'yargs';
|
import * as yargs from 'yargs';
|
||||||
|
|
||||||
import {commands} from './src/commands';
|
import {commands} from './src/commands';
|
||||||
import {network} from './src/utils/network';
|
|
||||||
import {
|
import {
|
||||||
CliOptions,
|
CliOptions,
|
||||||
CompilerOptions,
|
CompilerOptions,
|
||||||
@ -37,10 +38,13 @@ async function onCompileCommand(args: CliOptions): Promise<void> {
|
|||||||
* @param argv Instance of process.argv provided by yargs.
|
* @param argv Instance of process.argv provided by yargs.
|
||||||
*/
|
*/
|
||||||
async function onMigrateCommand(argv: CliOptions): Promise<void> {
|
async function onMigrateCommand(argv: CliOptions): Promise<void> {
|
||||||
const networkIdIfExists = await network.getNetworkIdIfExistsAsync(argv.jsonrpcPort);
|
const url = `http://localhost:${argv.jsonrpcPort}`;
|
||||||
|
const web3Provider = new Web3.providers.HttpProvider(url);
|
||||||
|
const web3Wrapper = new Web3Wrapper(web3Provider);
|
||||||
|
const networkId = await web3Wrapper.getNetworkIdAsync();
|
||||||
const compilerOpts: CompilerOptions = {
|
const compilerOpts: CompilerOptions = {
|
||||||
contractsDir: argv.contractsDir,
|
contractsDir: argv.contractsDir,
|
||||||
networkId: networkIdIfExists,
|
networkId,
|
||||||
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
};
|
};
|
||||||
@ -53,7 +57,7 @@ async function onMigrateCommand(argv: CliOptions): Promise<void> {
|
|||||||
const deployerOpts = {
|
const deployerOpts = {
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
jsonrpcPort: argv.jsonrpcPort,
|
jsonrpcPort: argv.jsonrpcPort,
|
||||||
networkId: networkIdIfExists,
|
networkId,
|
||||||
defaults,
|
defaults,
|
||||||
};
|
};
|
||||||
await commands.migrateAsync(deployerOpts);
|
await commands.migrateAsync(deployerOpts);
|
||||||
@ -63,10 +67,13 @@ async function onMigrateCommand(argv: CliOptions): Promise<void> {
|
|||||||
* @param argv Instance of process.argv provided by yargs.
|
* @param argv Instance of process.argv provided by yargs.
|
||||||
*/
|
*/
|
||||||
async function onDeployCommand(argv: CliOptions): Promise<void> {
|
async function onDeployCommand(argv: CliOptions): Promise<void> {
|
||||||
const networkIdIfExists = await network.getNetworkIdIfExistsAsync(argv.jsonrpcPort);
|
const url = `http://localhost:${argv.jsonrpcPort}`;
|
||||||
|
const web3Provider = new Web3.providers.HttpProvider(url);
|
||||||
|
const web3Wrapper = new Web3Wrapper(web3Provider);
|
||||||
|
const networkId = await web3Wrapper.getNetworkIdAsync();
|
||||||
const compilerOpts: CompilerOptions = {
|
const compilerOpts: CompilerOptions = {
|
||||||
contractsDir: argv.contractsDir,
|
contractsDir: argv.contractsDir,
|
||||||
networkId: networkIdIfExists,
|
networkId,
|
||||||
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
};
|
};
|
||||||
@ -79,7 +86,7 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
|
|||||||
const deployerOpts: DeployerOptions = {
|
const deployerOpts: DeployerOptions = {
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
jsonrpcPort: argv.jsonrpcPort,
|
jsonrpcPort: argv.jsonrpcPort,
|
||||||
networkId: networkIdIfExists,
|
networkId,
|
||||||
defaults,
|
defaults,
|
||||||
};
|
};
|
||||||
const deployerArgsString = argv.args;
|
const deployerArgsString = argv.args;
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
import {promisify} from '@0xproject/utils';
|
|
||||||
import {Web3Wrapper} from '@0xproject/web3-wrapper';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
import * as Web3 from 'web3';
|
|
||||||
|
|
||||||
export const network = {
|
|
||||||
async getNetworkIdIfExistsAsync(port: number): Promise<number> {
|
|
||||||
const url = `http://localhost:${port}`;
|
|
||||||
const web3Provider = new Web3.providers.HttpProvider(url);
|
|
||||||
const web3Wrapper = new Web3Wrapper(web3Provider);
|
|
||||||
const networkId = web3Wrapper.getNetworkIdAsync();
|
|
||||||
return networkId;
|
|
||||||
},
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user