fix issue where contract was being deployed everytime when gas config was set; catch errors on individual onDeploy cmds
This commit is contained in:
parent
36d7890cfc
commit
ab5d3722b9
|
@ -44,10 +44,9 @@ class Deploy {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
realArgs = self.determineArguments(params || contract.args);
|
||||||
|
|
||||||
if (contract.address !== undefined) {
|
if (contract.address !== undefined) {
|
||||||
|
|
||||||
realArgs = self.determineArguments(params || contract.args);
|
|
||||||
|
|
||||||
contract.deployedAddress = contract.address;
|
contract.deployedAddress = contract.address;
|
||||||
self.deployTracker.trackContract(contract.className, contract.realRuntimeBytecode, realArgs, contract.address);
|
self.deployTracker.trackContract(contract.className, contract.realRuntimeBytecode, realArgs, contract.address);
|
||||||
self.deployTracker.save();
|
self.deployTracker.save();
|
||||||
|
@ -55,7 +54,7 @@ class Deploy {
|
||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
let trackedContract = self.deployTracker.getContract(contract.className, contract.realRuntimeBytecode, contract.args);
|
let trackedContract = self.deployTracker.getContract(contract.className, contract.realRuntimeBytecode, realArgs);
|
||||||
|
|
||||||
if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") {
|
if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") {
|
||||||
self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan);
|
self.logger.info(contract.className.bold.cyan + " already deployed at ".green + trackedContract.address.bold.cyan);
|
||||||
|
@ -88,8 +87,8 @@ class Deploy {
|
||||||
if (contract.onDeploy !== undefined) {
|
if (contract.onDeploy !== undefined) {
|
||||||
self.logger.info('executing onDeploy commands');
|
self.logger.info('executing onDeploy commands');
|
||||||
|
|
||||||
let cmds = "";
|
let contractCode = codeGenerator.generateContractCode(contract);
|
||||||
cmds += codeGenerator.generateContractCode(contract);
|
RunCode.doEval(contractCode, self.web3);
|
||||||
|
|
||||||
let withErrors = false;
|
let withErrors = false;
|
||||||
let regex = /\$\w+/g;
|
let regex = /\$\w+/g;
|
||||||
|
@ -128,9 +127,18 @@ class Deploy {
|
||||||
return callback(new Error("error running onDeploy"));
|
return callback(new Error("error running onDeploy"));
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds += onDeployCode.join(';\n');
|
// TODO: convert to for to avoid repeated callback
|
||||||
|
for(let cmd of onDeployCode) {
|
||||||
RunCode.doEval(cmds, self.web3);
|
self.logger.info("executing: " + cmd);
|
||||||
|
try {
|
||||||
|
RunCode.doEval(cmd, 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');
|
||||||
|
}
|
||||||
|
return callback(new Error(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
|
|
|
@ -59,4 +59,3 @@ class DeployTracker {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = DeployTracker;
|
module.exports = DeployTracker;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue