mirror of https://github.com/embarklabs/embark.git
Merge pull request #676 from hodlbank/deployment-address-for-beforedeploy-plugin
Enabling contract:deploy:beforeDeploy plugins to access deploymentAccount
This commit is contained in:
commit
bed119a800
|
@ -143,7 +143,6 @@ class ContractDeployer {
|
||||||
let self = this;
|
let self = this;
|
||||||
let accounts = [];
|
let accounts = [];
|
||||||
let contractParams = (contract.realArgs || contract.args).slice();
|
let contractParams = (contract.realArgs || contract.args).slice();
|
||||||
let contractCode = contract.code;
|
|
||||||
let deploymentAccount = self.blockchain.defaultAccount();
|
let deploymentAccount = self.blockchain.defaultAccount();
|
||||||
let deployObject;
|
let deployObject;
|
||||||
|
|
||||||
|
@ -171,10 +170,12 @@ class ContractDeployer {
|
||||||
}
|
}
|
||||||
|
|
||||||
deploymentAccount = deploymentAccount || accounts[0];
|
deploymentAccount = deploymentAccount || accounts[0];
|
||||||
|
contract.deploymentAccount = deploymentAccount;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
function doLinking(next) {
|
function doLinking(next) {
|
||||||
|
let contractCode = contract.code;
|
||||||
self.events.request('contracts:list', (_err, contracts) => {
|
self.events.request('contracts:list', (_err, contracts) => {
|
||||||
for (let contractObj of contracts) {
|
for (let contractObj of contracts) {
|
||||||
let filename = contractObj.filename;
|
let filename = contractObj.filename;
|
||||||
|
@ -196,7 +197,7 @@ class ContractDeployer {
|
||||||
}
|
}
|
||||||
contractCode = contractCode.replace(new RegExp(toReplace, "g"), deployedAddress);
|
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;
|
contract.code = contractCode;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
@ -205,6 +206,7 @@ class ContractDeployer {
|
||||||
self.plugins.emitAndRunActionsForEvent('deploy:contract:beforeDeploy', {contract: contract}, next);
|
self.plugins.emitAndRunActionsForEvent('deploy:contract:beforeDeploy', {contract: contract}, next);
|
||||||
},
|
},
|
||||||
function createDeployObject(next) {
|
function createDeployObject(next) {
|
||||||
|
let contractCode = contract.code;
|
||||||
let contractObject = self.blockchain.ContractObject({abi: contract.abiDefinition});
|
let contractObject = self.blockchain.ContractObject({abi: contract.abiDefinition});
|
||||||
|
|
||||||
try {
|
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.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, {
|
self.blockchain.deployContractFromObject(deployObject, {
|
||||||
from: deploymentAccount,
|
from: contract.deploymentAccount,
|
||||||
gas: contract.gas,
|
gas: contract.gas,
|
||||||
gasPrice: contract.gasPrice
|
gasPrice: contract.gasPrice
|
||||||
}, function(error, receipt) {
|
}, function(error, receipt) {
|
||||||
|
|
Loading…
Reference in New Issue