aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/deploy/src/utils/network.ts
blob: fc8709e0f964ddeac09a753b3f652fa58d8d6baa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import {promisify} from '@0xproject/utils';
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 web3 = new Web3(web3Provider);
        const networkId = _.parseInt(await promisify<string>(web3.version.getNetwork)());
        return networkId;
    },
};