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 committed by Iuri Matias
parent 7eda40742d
commit c782f9b0a8
1 changed files with 5 additions and 3 deletions

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();
});
@ -211,6 +212,7 @@ class ContractDeployer {
});
},
function createDeployObject(next) {
let contractCode = contract.code;
let contractObject = self.blockchain.ContractObject({abi: contract.abiDefinition});
try {
@ -242,7 +244,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) {