diff --git a/lib/core/modules/coderunner/codeRunner.js b/lib/core/modules/coderunner/codeRunner.js index 0a3d0aaf1..66f995780 100644 --- a/lib/core/modules/coderunner/codeRunner.js +++ b/lib/core/modules/coderunner/codeRunner.js @@ -56,23 +56,24 @@ class CodeRunner { } registerEmbarkJs() { + this.registerVar('IpfsApi', IpfsApi, false); + this.registerVar('Web3', Web3, false); + this.registerVar('EmbarkJS', EmbarkJS, false); + if (this.ipc.connected) { return; } - - this.registerVar('IpfsApi', IpfsApi); - this.registerVar('Web3', Web3); - this.registerVar('EmbarkJS', EmbarkJS); this.events.on('code-generator-ready', () => { this.events.request('code-generator:embarkjs:provider-code', (code) => { - this.evalCode(code); - this.evalCode(this.getInitProviderCode()); + const func = () => {}; + this.evalCode(code, func, true); + this.evalCode(this.getInitProviderCode(), func, true); }); }); } - registerVar(varName, code) { - if (this.ipc.isServer() && varName !== 'web3') { + registerVar(varName, code, toRecord = true) { + if (this.ipc.isServer() && toRecord) { this.commands.push({varName, code}); this.ipc.broadcast("runcode:newCommand", {varName, code}); } diff --git a/lib/modules/blockchain_connector/index.js b/lib/modules/blockchain_connector/index.js index 6d812ef5e..ce179cce5 100644 --- a/lib/modules/blockchain_connector/index.js +++ b/lib/modules/blockchain_connector/index.js @@ -254,7 +254,7 @@ class BlockchainConnector { registerWeb3Object() { // doesn't feel quite right, should be a cmd or plugin method // can just be a command without a callback - this.events.emit("runcode:register", "web3", this.web3); + this.events.emit("runcode:register", "web3", this.web3, false); } subscribeToPendingTransactions() {