aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/deploy/src/utils/network.ts
blob: 74123e6a5c5b734e18be26cb014eb6abd972c76d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import promisify = require('es6-promisify');
import * as Web3 from 'web3';

import {Web3Wrapper} from './web3_wrapper';

export const network = {
    async getNetworkIdIfExistsAsync(port: number): Promise<number> {
        const url = `http://localhost:${port}`;
        const web3Provider = new Web3.providers.HttpProvider(url);
        const defaults = {};
        const web3Wrapper = new Web3Wrapper(web3Provider, defaults);
        const networkIdIfExists = await web3Wrapper.getNetworkIdIfExistsAsync();
        return networkIdIfExists;
    },
};