Fix register var and runcode

This commit is contained in:
Anthony Laibe 2018-08-29 11:03:06 +01:00
parent cc312a91b6
commit 98c785a4bb
2 changed files with 10 additions and 9 deletions

View File

@ -56,23 +56,24 @@ class CodeRunner {
} }
registerEmbarkJs() { registerEmbarkJs() {
this.registerVar('IpfsApi', IpfsApi, false);
this.registerVar('Web3', Web3, false);
this.registerVar('EmbarkJS', EmbarkJS, false);
if (this.ipc.connected) { if (this.ipc.connected) {
return; return;
} }
this.registerVar('IpfsApi', IpfsApi);
this.registerVar('Web3', Web3);
this.registerVar('EmbarkJS', EmbarkJS);
this.events.on('code-generator-ready', () => { this.events.on('code-generator-ready', () => {
this.events.request('code-generator:embarkjs:provider-code', (code) => { this.events.request('code-generator:embarkjs:provider-code', (code) => {
this.evalCode(code); const func = () => {};
this.evalCode(this.getInitProviderCode()); this.evalCode(code, func, true);
this.evalCode(this.getInitProviderCode(), func, true);
}); });
}); });
} }
registerVar(varName, code) { registerVar(varName, code, toRecord = true) {
if (this.ipc.isServer() && varName !== 'web3') { if (this.ipc.isServer() && toRecord) {
this.commands.push({varName, code}); this.commands.push({varName, code});
this.ipc.broadcast("runcode:newCommand", {varName, code}); this.ipc.broadcast("runcode:newCommand", {varName, code});
} }

View File

@ -254,7 +254,7 @@ class BlockchainConnector {
registerWeb3Object() { registerWeb3Object() {
// doesn't feel quite right, should be a cmd or plugin method // doesn't feel quite right, should be a cmd or plugin method
// can just be a command without a callback // 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() { subscribeToPendingTransactions() {