mirror of https://github.com/embarklabs/embark.git
conflict in en.json
This commit is contained in:
parent
3e9376138b
commit
5f3361d030
|
@ -1,23 +1,25 @@
|
|||
let __mainContext;
|
||||
// still needs to be run on a separate file due to the global context
|
||||
var RunCode = require('./runCode.js');
|
||||
|
||||
class CodeRunner {
|
||||
constructor(options) {
|
||||
this.plugins = options.plugins;
|
||||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
}
|
||||
|
||||
registerVar(varName, code) {
|
||||
__mainContext[varName] = code;
|
||||
}
|
||||
// necessary to init the context
|
||||
RunCode.initContext();
|
||||
|
||||
doEval(code) {
|
||||
try {
|
||||
// TODO: add trace log here
|
||||
return eval(code);
|
||||
} catch(e) {
|
||||
throw new Error(e + "\n" + code);
|
||||
this.events.on("runcode:register", (varName, code) => {
|
||||
RunCode.registerVar(varName, code);
|
||||
});
|
||||
|
||||
this.events.setCommandHandler('runcode:eval', (code, cb) => {
|
||||
let result = RunCode.doEval(code);
|
||||
if (cb) {
|
||||
cb(null, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,16 @@
|
|||
/*eslint no-unused-vars: off*/
|
||||
let Web3 = require('web3');
|
||||
let web3;
|
||||
let ipfs;
|
||||
let __mainContext;
|
||||
let __mainContext = this;
|
||||
|
||||
function initContext() {
|
||||
doEval("__mainContext = this");
|
||||
}
|
||||
|
||||
// ======================
|
||||
// the eval is used for evaluating some of the contact calls for different purposes
|
||||
// this should be at least moved to a different process and scope
|
||||
// for now it is defined here
|
||||
// ======================
|
||||
function doEval(code, opts) {
|
||||
if (opts && opts.web3) {
|
||||
web3 = opts.web3;
|
||||
}
|
||||
if (opts && opts.ipfs) {
|
||||
ipfs = opts.ipfs;
|
||||
}
|
||||
|
||||
function doEval(code) {
|
||||
try {
|
||||
// TODO: add trace log here
|
||||
return eval(code);
|
||||
|
@ -25,6 +19,12 @@ function doEval(code, opts) {
|
|||
}
|
||||
}
|
||||
|
||||
function registerVar(varName, code) {
|
||||
__mainContext[varName] = code;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
doEval: doEval
|
||||
doEval: doEval,
|
||||
registerVar: registerVar,
|
||||
initContext: initContext
|
||||
};
|
||||
|
|
|
@ -15,6 +15,7 @@ class Blockchain {
|
|||
}
|
||||
this.registerServiceCheck();
|
||||
this.registerRequests();
|
||||
this.registerWeb3Object();
|
||||
}
|
||||
|
||||
initWeb3() {
|
||||
|
@ -156,6 +157,11 @@ class Blockchain {
|
|||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Blockchain;
|
||||
|
|
|
@ -2,8 +2,6 @@ let async = require('async');
|
|||
//require("../utils/debug_util.js")(__filename, async);
|
||||
let utils = require('../utils/utils.js');
|
||||
|
||||
let RunCode = require('../coderunner/runCode.js');
|
||||
|
||||
class Deploy {
|
||||
constructor(options) {
|
||||
this.blockchain = options.blockchain;
|
||||
|
@ -129,7 +127,7 @@ class Deploy {
|
|||
// TODO: can be moved into a afterDeploy event
|
||||
// just need to figure out the gasLimit coupling issue
|
||||
self.events.request('code-generator:contract:vanilla', contract, self.gasLimit, (contractCode) => {
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
self.events.request('runcode:eval', contractCode);
|
||||
return callback();
|
||||
});
|
||||
}
|
||||
|
@ -152,8 +150,7 @@ class Deploy {
|
|||
// TODO: can be moved into a afterDeploy event
|
||||
// just need to figure out the gasLimit coupling issue
|
||||
self.events.request('code-generator:contract:vanilla', contract, self.gasLimit, (contractCode) => {
|
||||
RunCode.doEval(contractCode, self.web3);
|
||||
RunCode.doEval(contractCode, {web3: self.web3});
|
||||
self.events.request('runcode:eval', contractCode);
|
||||
|
||||
let onDeployPlugins = self.plugins.getPluginsProperty('onDeployActions', 'onDeployActions');
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ class Engine {
|
|||
|
||||
let services = {
|
||||
"pipeline": this.pipelineService,
|
||||
"codeRunner": this.codeRunnerService,
|
||||
"codeGenerator": this.codeGeneratorService,
|
||||
"deployment": this.deploymentService,
|
||||
"fileWatcher": this.fileWatchService,
|
||||
|
@ -160,15 +161,17 @@ class Engine {
|
|||
});
|
||||
}
|
||||
|
||||
codeRunnerService(_options) {
|
||||
this.codeRunner = new CodeRunner({
|
||||
plugins: this.plugins,
|
||||
events: this.events,
|
||||
logger: this.logger
|
||||
});
|
||||
}
|
||||
|
||||
codeGeneratorService(_options) {
|
||||
let self = this;
|
||||
|
||||
this.codeRunner = new CodeRunner({
|
||||
plugins: self.plugins,
|
||||
events: self.events,
|
||||
logger: self.logger
|
||||
});
|
||||
|
||||
this.codeGenerator = new CodeGenerator({
|
||||
blockchainConfig: self.config.blockchainConfig,
|
||||
contractsConfig: self.config.contractsConfig,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
let utils = require('../utils/utils.js');
|
||||
let RunCode = require('../coderunner/runCode.js');
|
||||
|
||||
class Console {
|
||||
constructor(options) {
|
||||
|
@ -10,7 +9,7 @@ class Console {
|
|||
}
|
||||
|
||||
runCode(code) {
|
||||
RunCode.doEval(code);
|
||||
this.events.request('runcode:eval', code);
|
||||
}
|
||||
|
||||
processEmbarkCmd (cmd) {
|
||||
|
@ -48,8 +47,9 @@ class Console {
|
|||
}
|
||||
|
||||
try {
|
||||
let result = RunCode.doEval(cmd);
|
||||
return callback(result);
|
||||
this.events.request('runcode:eval', cmd, (err, result) => {
|
||||
callback(result);
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
if (e.message.indexOf('not defined') > 0) {
|
||||
|
|
|
@ -114,5 +114,7 @@
|
|||
"Couldn't connect to an Ethereum node are you sure it's on?": "Couldn't connect to an Ethereum node are you sure it's on?",
|
||||
"make sure you have an Ethereum node or simulator running. e.g '%s'": "make sure you have an Ethereum node or simulator running. e.g '%s'",
|
||||
"Embark is building, please wait...": "Embark is building, please wait...",
|
||||
"finished building DApp and deploying to": "finished building DApp and deploying to"
|
||||
"finished building DApp and deploying to": "finished building DApp and deploying to",
|
||||
"Type": "Type",
|
||||
"to see the list of available commands": "to see the list of available commands"
|
||||
}
|
|
@ -128,6 +128,7 @@ class Embark {
|
|||
|
||||
engine.startMonitor();
|
||||
engine.startService("libraryManager");
|
||||
engine.startService("codeRunner");
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("deployment");
|
||||
|
@ -202,6 +203,7 @@ class Embark {
|
|||
}
|
||||
|
||||
engine.startService("libraryManager");
|
||||
engine.startService("codeRunner");
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("deployment", {onlyCompile: options.onlyCompile});
|
||||
|
@ -317,6 +319,7 @@ class Embark {
|
|||
function startServices(callback) {
|
||||
|
||||
engine.startService("libraryManager");
|
||||
engine.startService("codeRunner");
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("deployment");
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
let RunCode = require('../../coderunner/runCode.js');
|
||||
const stringReplaceAsync = require('string-replace-async');
|
||||
const async = require('async');
|
||||
|
||||
|
@ -64,9 +63,7 @@ class SpecialConfigs {
|
|||
for(let cmd of onDeployCode) {
|
||||
self.logger.info("==== executing: " + cmd);
|
||||
try {
|
||||
// TODO: request and re-add web3 object if necessary
|
||||
//RunCode.doEval(cmd, self.blockchain.web3);
|
||||
RunCode.doEval(cmd);
|
||||
self.events.request('runcode:eval', cmd);
|
||||
} catch(e) {
|
||||
if (e.message.indexOf("invalid opcode") >= 0) {
|
||||
self.logger.error('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation');
|
||||
|
@ -103,9 +100,7 @@ class SpecialConfigs {
|
|||
for(let cmd of onDeployCode) {
|
||||
self.logger.info("==== executing: " + cmd);
|
||||
try {
|
||||
// TODO: request and re-add web3 object if necessary
|
||||
//RunCode.doEval(cmd, self.blockchain.web3);
|
||||
RunCode.doEval(cmd);
|
||||
self.events.request('runcode:eval', cmd);
|
||||
} catch(e) {
|
||||
if (e.message.indexOf("invalid opcode") >= 0) {
|
||||
self.logger.error('the transaction was rejected; this usually happens due to a throw or a require, it can also happen due to an invalid operation');
|
||||
|
|
|
@ -2,7 +2,6 @@ var async = require('async');
|
|||
//require("../utils/debug_util.js")(__filename, async);
|
||||
var Web3 = require('web3');
|
||||
var Engine = require('../core/engine.js');
|
||||
var RunCode = require('../coderunner/runCode.js');
|
||||
var TestLogger = require('./test_logger.js');
|
||||
|
||||
var getSimulator = function() {
|
||||
|
@ -68,6 +67,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
|
|||
function startServices(callback) {
|
||||
//{abiType: 'contracts', embarkJS: false}
|
||||
self.engine.startService("libraryManager");
|
||||
self.engine.startService("codeRunner");
|
||||
self.engine.startService("web3", {
|
||||
web3: self.web3
|
||||
});
|
||||
|
@ -106,7 +106,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
|
|||
throw new Error(err);
|
||||
}
|
||||
self.web3.eth.defaultAccount = accounts[0];
|
||||
RunCode.doEval(result, {web3: self.web3});
|
||||
self.engine.events.request('runcode:eval', result);
|
||||
//cb();
|
||||
cb(accounts);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue