Setting web3 provider when web3 context is toggled

pull/1/head
Dave Hoover 9 years ago
parent ed460f09c6
commit 9a273198af
  1. 1
      .gitignore
  2. 20
      src/app.js

1
.gitignore vendored

@ -1,2 +1,3 @@
.vscode
build
node_modules

@ -243,22 +243,28 @@ var run = function() {
$vmToggle.on('change', executionContextChange );
$web3Toggle.on('change', executionContextChange );
$web3endpoint.on('change', function() {
var endpoint = $web3endpoint.val();
if (endpoint == 'ipc')
web3.setProvider(new web3.providers.IpcProvider());
else
web3.setProvider(new web3.providers.HttpProvider(endpoint));
compile();
setProviderFromEndpoint();
if (executionContext == 'web3') compile();
});
function executionContextChange (ev) {
if (ev.target.value == 'web3' && !confirm("Are you sure you want to connect to a local ethereum node?") ) {
$vmToggle.get(0).checked = true;
executionContext = 'vm';
} else executionContext = ev.target.value;
} else {
executionContext = ev.target.value;
setProviderFromEndpoint();
}
compile();
}
function setProviderFromEndpoint() {
var endpoint = $web3endpoint.val();
if (endpoint == 'ipc')
web3.setProvider(new web3.providers.IpcProvider());
else
web3.setProvider(new web3.providers.HttpProvider(endpoint));
}
// ------------------ gist publish --------------

Loading…
Cancel
Save