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() {
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});
}

View File

@ -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() {