accept hash of objects as second param for runcode

This commit is contained in:
Iuri Matias 2018-05-18 15:55:34 -04:00
parent db6b90e77f
commit e2c2373249
4 changed files with 13 additions and 9 deletions

View File

@ -131,7 +131,7 @@ class Deploy {
// always run contractCode so other functionality like 'afterDeploy' can also work
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
let contractCode = codeGenerator.generateContractCode(contract, self.gasLimit);
RunCode.doEval(contractCode, self.web3);
RunCode.doEval(contractCode, {web3: self.web3});
return callback();
}
@ -151,13 +151,13 @@ class Deploy {
// always run contractCode so other functionality like 'afterDeploy' can also work
let codeGenerator = new CodeGenerator({contractsManager: self.contractsManager});
let contractCode = codeGenerator.generateContractCode(contract, self.gasLimit);
RunCode.doEval(contractCode, self.web3);
RunCode.doEval(contractCode, {web3: self.web3});
if (contract.onDeploy !== undefined) {
self.logger.info(__('executing onDeploy commands'));
let contractCode = codeGenerator.generateContractCode(contract, self.gasLimit);
RunCode.doEval(contractCode, self.web3);
RunCode.doEval(contractCode, {web3: self.web3});
let withErrors = false;
let regex = /\$\w+/g;
@ -200,7 +200,7 @@ class Deploy {
for(let cmd of onDeployCode) {
self.logger.info(__("executing: ") + cmd);
try {
RunCode.doEval(cmd, self.web3);
RunCode.doEval(cmd, {web3: self.web3});
} 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'));

View File

@ -137,7 +137,7 @@ class DeployManager {
for(let cmd of onDeployCode) {
self.logger.info(__("executing") + ": " + cmd);
try {
RunCode.doEval(cmd, web3);
RunCode.doEval(cmd, {web3: web3});
} 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'));

View File

@ -1,6 +1,7 @@
/*eslint no-unused-vars: off*/
let Web3 = require('web3');
let web3;
let ipfs;
let __mainContext;
// ======================
@ -8,9 +9,12 @@ let __mainContext;
// this should be at least moved to a different process and scope
// for now it is defined here
// ======================
function doEval(code, _web3) {
if (_web3) {
web3 = _web3;
function doEval(code, opts) {
if (opts && opts.web3) {
web3 = opts.web3;
}
if (opts && opts.ipfs) {
ipfs = opts.ipfs;
}
try {

View File

@ -107,7 +107,7 @@ Test.prototype.deployAll = function(contractsConfig, cb) {
throw new Error(err);
}
self.web3.eth.defaultAccount = accounts[0];
RunCode.doEval(result, self.web3);
RunCode.doEval(result, {web3: self.web3});
//cb();
cb(accounts);
});