mirror of https://github.com/embarklabs/embark.git
Fix register var and runcode
This commit is contained in:
parent
cc312a91b6
commit
98c785a4bb
|
@ -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});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
Loading…
Reference in New Issue