File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -193,16 +193,20 @@ Deploy.prototype.execute_cmds = function(cmds) {
193193 console . log ( "executing: " + cmd ) ;
194194 eval ( cmd ) ;
195195 }
196- }
196+ } ;
197197
198198Deploy . prototype . generate_provider_file = function ( ) {
199199 var result = "" ;
200- result += "var web3 = new Web3();" ;
201- result += "web3.setProvider(new web3.providers.HttpProvider('http://" + this . blockchainConfig . rpcHost + ":" + this . blockchainConfig . rpcPort + "'));" ;
200+
201+ result += "if (typeof web3 !== 'undefined' && typeof Web3 !== 'undefined') {" ;
202+ result += 'web3 = new Web3(web3.currentProvider);' ;
203+ result += "} else if (typeof Web3 !== 'undefined') {" ;
204+ result += 'web3 = new Web3(new Web3.providers.HttpProvider("http://' + this . blockchainConfig . rpcHost + ':' + this . blockchainConfig . rpcPort + '"));' ;
205+ result += '}' ;
202206 result += "web3.eth.defaultAccount = web3.eth.accounts[0];" ;
203207
204208 return result ;
205- }
209+ } ;
206210
207211Deploy . prototype . generate_abi_file = function ( ) {
208212 var result = "" ;
You can’t perform that action at this time.
0 commit comments