Merge pull request #848 from embark-framework/bug_fix/embark-console-kills-embark

Fix for embark run crashing after console connects to it
This commit is contained in:
Iuri Matias 2018-09-17 13:39:05 -04:00 committed by GitHub
commit fc98b1ccef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,7 +29,16 @@ class RunCode {
}
getWeb3Config() {
return {defaultAccount: this.context.web3.eth.defaultAccount, providerUrl: this.context.web3.currentProvider.connection._url};
const Web3 = require('web3');
const provider = this.context.web3.currentProvider;
let providerUrl;
if(provider instanceof Web3.providers.HttpProvider){
providerUrl = provider.host;
}
else if(provider instanceof Web3.provider.WebsocketProvider){
providerUrl = provider.connection._url;
}
return {defaultAccount: this.context.web3.eth.defaultAccount, providerUrl: providerUrl};
}
}