Skip to content

Commit cf3cfe5

Browse files
committed
generate an abi file compatible with mist and metamask
1 parent 2fbb41b commit cf3cfe5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/deploy.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,16 +193,20 @@ Deploy.prototype.execute_cmds = function(cmds) {
193193
console.log("executing: " + cmd);
194194
eval(cmd);
195195
}
196-
}
196+
};
197197

198198
Deploy.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

207211
Deploy.prototype.generate_abi_file = function() {
208212
var result = "";

0 commit comments

Comments
 (0)