mirror of https://github.com/embarklabs/embark.git
Enabling contract:deploy:beforeDeploy plugins to access deploymentAccount value by adding it into the contract object.
This commit is contained in:
parent
7eda40742d
commit
c782f9b0a8
|
@ -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();
|
||||||
});
|
});
|
||||||
|
@ -211,6 +212,7 @@ class ContractDeployer {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
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 {
|
||||||
|
@ -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.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