Fix for embark run crashing after console connects to it
The providerUrl being provided to the console VM was looking for a WebsocketProvider-specific property which did not exist on the HttpProvider. Type checking was added to provide the necessary type-dependent property.
This commit is contained in:
parent
a43627de5b
commit
31d3125baf
|
@ -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};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue