use request to get contract

This commit is contained in:
Iuri Matias 2018-05-21 13:11:13 -04:00 committed by Jonathan Rainville
parent 7cebbec7b6
commit c83064adf6
1 changed files with 9 additions and 4 deletions

View File

@ -20,6 +20,7 @@ class Deploy {
// TODO: determining the arguments could also be in a module since it's not
// part of ta 'normal' contract deployment
determineArguments(suppliedArgs, contract, callback) {
const self = this;
let realArgs = [], contractName, referedContract;
let args = suppliedArgs;
@ -41,10 +42,13 @@ class Deploy {
if (arg[0] === "$") {
contractName = arg.substr(1);
referedContract = this.contractsManager.getContract(contractName);
realArgs.push(referedContract.deployedAddress);
self.events.request('contracts:contract', contractName, (referedContract) => {
realArgs.push(referedContract.deployedAddress);
nextEachCb();
});
} else if (Array.isArray(arg)) {
let subRealArgs = [];
// todo: convert to async each
for (let sub_arg of arg) {
if (sub_arg[0] === "$") {
contractName = sub_arg.substr(1);
@ -54,14 +58,15 @@ class Deploy {
subRealArgs.push(sub_arg);
}
}
// todo: put this in the final callback
realArgs.push(subRealArgs);
nextEachCb();
} else {
realArgs.push(arg);
nextEachCb();
}
nextEachCb();
}, () => {
callback(realArgs);
});