Enabling contract:deploy:beforeDeploy plugins to access deploymentAccount value by adding it into the contract object.

This commit is contained in:
hodlbank 2018-08-03 19:52:34 +00:00
parent 69bd34392b
commit 513154e427

View File

@ -143,7 +143,6 @@ class ContractDeployer {
let self = this;
let accounts = [];
let contractParams = (contract.realArgs || contract.args).slice();
let contractCode = contract.code;
let deploymentAccount = self.blockchain.defaultAccount();
let deployObject;
@ -171,10 +170,12 @@ class ContractDeployer {
}
deploymentAccount = deploymentAccount || accounts[0];
contract.deploymentAccount = deploymentAccount;
next();
});
},
function doLinking(next) {
let contractCode = contract.code;
self.events.request('contracts:list', (_err, contracts) => {
for (let contractObj of contracts) {
let filename = contractObj.filename;
@ -196,7 +197,7 @@ class ContractDeployer {
}
contractCode = contractCode.replace(new RegExp(toReplace, "g"), deployedAddress);
}
// saving code changes back to contract object
// saving code changes back to the contract object
contract.code = contractCode;
next();
});
@ -205,6 +206,7 @@ class ContractDeployer {
self.plugins.emitAndRunActionsForEvent('deploy:contract:beforeDeploy', {contract: contract}, next);
},
function createDeployObject(next) {
let contractCode = contract.code;
let contractObject = self.blockchain.ContractObject({abi: contract.abiDefinition});
try {
@ -236,7 +238,7 @@ class ContractDeployer {
self.logger.info(__("deploying") + " " + contract.className.bold.cyan + " " + __("with").green + " " + contract.gas + " " + __("gas at the price of").green + " " + contract.gasPrice + " " + __("Wei, estimated cost:").green + " " + estimatedCost + " Wei".green);
self.blockchain.deployContractFromObject(deployObject, {
from: deploymentAccount,
from: contract.deploymentAccount,
gas: contract.gas,
gasPrice: contract.gasPrice
}, function(error, receipt) {