From 48a5fccbf95c665b0b96f6ca8e1f9c5746b3e99c Mon Sep 17 00:00:00 2001 From: d11e9 Date: Mon, 26 Oct 2015 12:01:40 +0000 Subject: [PATCH] custom web3 endpoint --- assets/js/universal-dapp.js | 2 +- index.html | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/assets/js/universal-dapp.js b/assets/js/universal-dapp.js index e8fdcab6f4..9917399a46 100644 --- a/assets/js/universal-dapp.js +++ b/assets/js/universal-dapp.js @@ -22,7 +22,7 @@ function UniversalDApp (contracts, options) { } else { var host = options.host || "localhost"; var port = options.port || "8545"; - var rpc_url = 'http://' + host + ':' + port; + var rpc_url = options.web3endpoint || ('http://' + host + ':' + port); web3.setProvider( new web3.providers.HttpProvider( rpc_url ) ); } diff --git a/index.html b/index.html index 37b09eab94..bf1215e7ff 100644 --- a/index.html +++ b/index.html @@ -97,13 +97,18 @@
-
@@ -222,12 +227,14 @@ var $vmToggle = $('#vm'); var $web3Toggle = $('#web3'); + var $web3endpoint = $('#web3Endpoint'); var executionContext = 'vm'; $vmToggle.get(0).checked = true; $vmToggle.on('change', executionContextChange ); $web3Toggle.on('change', executionContextChange ); + $web3endpoint.on('change', compile ); function executionContextChange (ev) { if (ev.target.value == 'web3' && !confirm("Are you sure you want to connect to a local ethereum node?") ) { @@ -752,6 +759,7 @@ removable: false, getAddress: function(){ return $('#txorigin').val(); }, removable_instances: true, + web3endpoint: $('#web3Endpoint').val(), renderOutputModifier: function(contractName, $contractOutput) { var contract = data.contracts[contractName]; return $contractOutput