2017-12-14 00:49:05 +00:00
|
|
|
/*eslint no-unused-vars: off*/
|
2018-05-23 15:16:56 +00:00
|
|
|
let __mainContext = this;
|
|
|
|
|
|
|
|
function initContext() {
|
|
|
|
doEval("__mainContext = this");
|
|
|
|
}
|
2017-02-18 21:53:49 +00:00
|
|
|
|
|
|
|
// ======================
|
|
|
|
// 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
|
|
|
|
// ======================
|
2018-05-23 15:16:56 +00:00
|
|
|
function doEval(code) {
|
2018-08-15 09:40:51 +00:00
|
|
|
// TODO: add trace log here
|
|
|
|
return eval(code);
|
2017-02-18 21:53:49 +00:00
|
|
|
}
|
|
|
|
|
2018-05-23 15:16:56 +00:00
|
|
|
function registerVar(varName, code) {
|
|
|
|
__mainContext[varName] = code;
|
|
|
|
}
|
|
|
|
|
2018-08-08 12:42:45 +00:00
|
|
|
function getWeb3Config() {
|
|
|
|
return {defaultAccount:__mainContext.web3.eth.defaultAccount, provider: __mainContext.web3.currentProvider};
|
|
|
|
}
|
|
|
|
|
2017-02-18 21:53:49 +00:00
|
|
|
module.exports = {
|
2018-08-08 12:42:45 +00:00
|
|
|
doEval,
|
|
|
|
registerVar,
|
|
|
|
initContext,
|
|
|
|
getWeb3Config
|
2017-02-18 21:53:49 +00:00
|
|
|
};
|