mirror of https://github.com/embarklabs/embark.git
tolerate when whisper is not available; support latest geth
This commit is contained in:
parent
b42031de6b
commit
8348f0a224
|
@ -57,7 +57,7 @@ var EmbarkJS =
|
|||
|
||||
this.abi = options.abi;
|
||||
this.address = options.address;
|
||||
this.code = options.code;
|
||||
this.code = '0x' + options.code;
|
||||
this.web3 = options.web3 || web3;
|
||||
|
||||
var ContractClass = this.web3.eth.contract(this.abi);
|
||||
|
@ -278,6 +278,7 @@ var EmbarkJS =
|
|||
};
|
||||
|
||||
EmbarkJS.Messages.setProvider = function(provider, options) {
|
||||
var self = this;
|
||||
var ipfs;
|
||||
if (provider === 'whisper') {
|
||||
this.currentMessages = EmbarkJS.Messages.Whisper;
|
||||
|
@ -288,7 +289,13 @@ var EmbarkJS =
|
|||
web3 = new Web3(new Web3.providers.HttpProvider("http://" + options.server + ':' + options.port));
|
||||
}
|
||||
}
|
||||
this.currentMessages.identity = web3.shh.newIdentity();
|
||||
web3.version.getWhisper(function(err, res) {
|
||||
if (err) {
|
||||
console.log("whisper not available");
|
||||
} else {
|
||||
self.currentMessages.identity = web3.shh.newIdentity();
|
||||
}
|
||||
});
|
||||
} else if (provider === 'orbit') {
|
||||
this.currentMessages = EmbarkJS.Messages.Orbit;
|
||||
if (options === undefined) {
|
||||
|
|
11
js/embark.js
11
js/embark.js
|
@ -10,7 +10,7 @@ EmbarkJS.Contract = function(options) {
|
|||
|
||||
this.abi = options.abi;
|
||||
this.address = options.address;
|
||||
this.code = options.code;
|
||||
this.code = '0x' + options.code;
|
||||
this.web3 = options.web3 || web3;
|
||||
|
||||
var ContractClass = this.web3.eth.contract(this.abi);
|
||||
|
@ -231,6 +231,7 @@ EmbarkJS.Messages = {
|
|||
};
|
||||
|
||||
EmbarkJS.Messages.setProvider = function(provider, options) {
|
||||
var self = this;
|
||||
var ipfs;
|
||||
if (provider === 'whisper') {
|
||||
this.currentMessages = EmbarkJS.Messages.Whisper;
|
||||
|
@ -241,7 +242,13 @@ EmbarkJS.Messages.setProvider = function(provider, options) {
|
|||
web3 = new Web3(new Web3.providers.HttpProvider("http://" + options.server + ':' + options.port));
|
||||
}
|
||||
}
|
||||
this.currentMessages.identity = web3.shh.newIdentity();
|
||||
web3.version.getWhisper(function(err, res) {
|
||||
if (err) {
|
||||
console.log("whisper not available");
|
||||
} else {
|
||||
self.currentMessages.identity = web3.shh.newIdentity();
|
||||
}
|
||||
});
|
||||
} else if (provider === 'orbit') {
|
||||
this.currentMessages = EmbarkJS.Messages.Orbit;
|
||||
if (options === undefined) {
|
||||
|
|
Loading…
Reference in New Issue