EmbarkJS available

This commit is contained in:
Anthony Laibe 2018-08-28 11:47:40 +01:00
parent d772b4fdaf
commit 307b7dc8e7
7 changed files with 25 additions and 14 deletions

View File

@ -279,6 +279,7 @@ class EmbarkController {
engine.startService("storage");
engine.startService("codeGenerator");
engine.startService("webServer");
engine.startService("namingSystem");
return callback();
}
@ -315,6 +316,7 @@ class EmbarkController {
if(engine.ipc.connected && engine.ipc.isClient()) {
return callback();
}
engine.config.reloadConfig();
engine.events.request('deploy:contracts', function (err) {
callback(err);
});

View File

@ -63,10 +63,7 @@ Config.prototype.loadConfigFiles = function(options) {
this.loadStorageConfigFile();
this.loadCommunicationConfigFile();
this.loadNameSystemConfigFile();
this.loadContractsConfigFile();
this.loadPipelineConfigFile();
this.loadContractsConfigFile();
this.loadExternalContractsFiles();
this.loadWebServerConfigFile();
@ -82,7 +79,6 @@ Config.prototype.reloadConfig = function() {
this.loadStorageConfigFile();
this.loadCommunicationConfigFile();
this.loadNameSystemConfigFile();
this.loadContractsConfigFile();
this.loadPipelineConfigFile();
this.loadContractsConfigFile();
this.loadExternalContractsFiles();

View File

@ -1,5 +1,9 @@
const RunCode = require('./runCode.js');
const EmbarkJS = require('embarkjs');
const IpfsApi = require('ipfs-api');
const Web3 = require('web3');
const namehash = require('eth-ens-namehash');
class CodeRunner {
constructor(options) {
this.plugins = options.plugins;
@ -26,6 +30,9 @@ class CodeRunner {
}
});
} else {
this.runCode.registerVar('IpfsApi', IpfsApi);
this.runCode.registerVar('Web3', Web3);
this.runCode.registerVar('namehash', namehash);
this.runCode.registerVar('EmbarkJS', EmbarkJS);
this.events.on('code-generator-ready', () => {
this.events.request('code-generator:embarkjs:initialization-code', (code) => {

View File

@ -9,7 +9,7 @@ class RunCode {
try {
return vm.runInNewContext(code, this.context);
} catch(e) {
console.log(e)
console.log(e.message)
}
}
@ -19,6 +19,8 @@ class RunCode {
// /*global web3*/
if (varName === 'web3') {
global.web3 = code;
} else if (varName === 'namehash') {
global.namehash = code;
}
this.context[varName] = code;
}

View File

@ -350,13 +350,19 @@ class CodeGenerator {
code += plugin.embarkjs_code.join('\n');
}
const codeTypes = {'communication': this.communicationConfig,
'names': this.namesystemConfig,
'storage': this.storageConfig};
let initCodes = this.plugins.getPluginsFor('initCode');
for (let plugin of initCodes) {
let initCodes = plugin.embarkjs_init_code['communication'] || [];
for (let initCode of initCodes) {
let [block, shouldInit] = initCode;
if (shouldInit.call(plugin, this.communicationConfig)) {
code += block;
for (let codeTypeName of Object.keys(codeTypes)) {
let initCodes = plugin.embarkjs_init_code[codeTypeName] || [];
for (let initCode of initCodes) {
let [block, shouldInit] = initCode;
if (shouldInit.call(plugin, codeTypes[codeTypeName])) {
code += block;
}
}
}
}

View File

@ -307,7 +307,6 @@ class ENS {
}
addSetProvider(config) {
let code = "\nEmbarkJS.Names.setProvider('ens'," + JSON.stringify(config) + ");";
let shouldInit = (namesConfig) => {

View File

@ -1,5 +1,4 @@
/*global web3*/
const namehash = require('eth-ens-namehash');
/*global web3, namehash*/
function registerSubDomain(ens, registrar, resolver, defaultAccount, subdomain, rootDomain, reverseNode, address, logger, secureSend, callback) {
const subnode = namehash.hash(subdomain);