From 5b60c3effa19ad5004f23e37e3be1d6544fe3416 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Mon, 26 Jun 2017 15:25:22 -0400 Subject: [PATCH] fix issue with orbit config --- js/build/embark.bundle.js | 6 +++++- js/embark.js | 8 ++++++-- lib/contracts/abi.js | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/js/build/embark.bundle.js b/js/build/embark.bundle.js index 403c6785b..0480a4b69 100644 --- a/js/build/embark.bundle.js +++ b/js/build/embark.bundle.js @@ -386,7 +386,11 @@ var EmbarkJS = ipfs = HaadIpfsApi(options.server, options.port); } this.currentMessages.orbit = new Orbit(ipfs); - this.currentMessages.orbit.connect(web3.eth.accounts[0]); + if (typeof(web3) === "undefined") { + this.currentMessages.orbit.connect(Math.random().toString(36).substring(2)); + } else { + this.currentMessages.orbit.connect(web3.eth.accounts[0]); + } } else { throw Error('Unknown message provider'); } diff --git a/js/embark.js b/js/embark.js index 3acaab723..6b378cd30 100644 --- a/js/embark.js +++ b/js/embark.js @@ -336,10 +336,14 @@ EmbarkJS.Messages.setProvider = function(provider, options) { if (options === undefined) { ipfs = HaadIpfsApi('localhost', '5001'); } else { - ipfs = HaadIpfsApi(options.server, options.port); + ipfs = HaadIpfsApi(options.host, options.port); } this.currentMessages.orbit = new Orbit(ipfs); - this.currentMessages.orbit.connect(web3.eth.accounts[0]); + if (typeof(web3) === "undefined") { + this.currentMessages.orbit.connect(Math.random().toString(36).substring(2)); + } else { + this.currentMessages.orbit.connect(web3.eth.accounts[0]); + } } else { throw Error('Unknown message provider'); } diff --git a/lib/contracts/abi.js b/lib/contracts/abi.js index 55f184c21..3f5eb36e6 100644 --- a/lib/contracts/abi.js +++ b/lib/contracts/abi.js @@ -120,7 +120,11 @@ class ABIGenerator { if (self.communicationConfig.provider === 'whisper' && self.communicationConfig.enabled === true) { result += "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "');"; } else if (self.communicationConfig.provider === 'orbit' && self.communicationConfig.enabled === true) { - result += "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "', {server: '" + self.communicationConfig.host + "', port: '" + self.communicationConfig.port + "'});"; + if (self.communicationConfig.host === undefined && self.communicationConfig.port === undefined) { + result += "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "');"; + } else { + result += "\nEmbarkJS.Messages.setProvider('" + self.communicationConfig.provider + "', {server: '" + self.communicationConfig.host + "', port: '" + self.communicationConfig.port + "'});"; + } } return result;