mirror of https://github.com/embarklabs/embark.git
warn if mismatch on network id
This commit is contained in:
parent
5f77d5e5f0
commit
ca32d7aac0
|
@ -38,7 +38,13 @@
|
||||||
"blockchainExit": "blockchainExit",
|
"blockchainExit": "blockchainExit",
|
||||||
"init": "init",
|
"init": "init",
|
||||||
"initiated": "initiated",
|
"initiated": "initiated",
|
||||||
"servicePortOnProxy": 10
|
"servicePortOnProxy": 10,
|
||||||
|
"networkIds": {
|
||||||
|
"mainnet": 1,
|
||||||
|
"testnet": 3,
|
||||||
|
"ropsten": 3,
|
||||||
|
"rinkeby": 4
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"storage": {
|
"storage": {
|
||||||
"init": "init",
|
"init": "init",
|
||||||
|
|
|
@ -2,6 +2,7 @@ const Web3 = require('web3');
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const Provider = require('./provider.js');
|
const Provider = require('./provider.js');
|
||||||
const utils = require('../../utils/utils');
|
const utils = require('../../utils/utils');
|
||||||
|
const constants = require('../../constants');
|
||||||
|
|
||||||
const WEB3_READY = 'web3Ready';
|
const WEB3_READY = 'web3Ready';
|
||||||
|
|
||||||
|
@ -18,7 +19,6 @@ class BlockchainConnector {
|
||||||
this.isDev = options.isDev;
|
this.isDev = options.isDev;
|
||||||
this.web3Endpoint = '';
|
this.web3Endpoint = '';
|
||||||
this.isWeb3Ready = false;
|
this.isWeb3Ready = false;
|
||||||
this.web3StartedInProcess = false;
|
|
||||||
|
|
||||||
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
self.events.setCommandHandler("blockchain:web3:isReady", (cb) => {
|
||||||
cb(self.isWeb3Ready);
|
cb(self.isWeb3Ready);
|
||||||
|
@ -74,6 +74,18 @@ class BlockchainConnector {
|
||||||
|
|
||||||
self.events.request("processes:launch", "blockchain", () => {
|
self.events.request("processes:launch", "blockchain", () => {
|
||||||
self.provider.startWeb3Provider(() => {
|
self.provider.startWeb3Provider(() => {
|
||||||
|
this.web3.eth.net.getId()
|
||||||
|
.then(id => {
|
||||||
|
let networkId = self.blockchainConfig.networkId;
|
||||||
|
if (!networkId && constants.blockchain.networkIds[self.blockchainConfig.networkType]) {
|
||||||
|
networkId = constants.blockchain.networkIds[self.blockchainConfig.networkType];
|
||||||
|
}
|
||||||
|
if (id !== networkId) {
|
||||||
|
self.logger.warn(__('Connected to a blockchain node on network {{realId}} while your config specifies {{configId}}', {realId: id, configId: networkId}));
|
||||||
|
self.logger.warn(__('Make sure you started the right blockchain node'));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
self.provider.fundAccounts(() => {
|
self.provider.fundAccounts(() => {
|
||||||
self.isWeb3Ready = true;
|
self.isWeb3Ready = true;
|
||||||
self.events.emit(WEB3_READY);
|
self.events.emit(WEB3_READY);
|
||||||
|
|
Loading…
Reference in New Issue