use request to get contract

This commit is contained in:
Iuri Matias 2018-05-21 13:30:45 -04:00 committed by Jonathan Rainville
parent c83064adf6
commit 30b1975e34
1 changed files with 15 additions and 15 deletions

View File

@ -21,10 +21,8 @@ class Deploy {
// part of ta 'normal' contract deployment
determineArguments(suppliedArgs, contract, callback) {
const self = this;
let realArgs = [], contractName, referedContract;
let args = suppliedArgs;
if (!Array.isArray(args)) {
args = [];
let abi = contract.abiDefinition.find((abi) => abi.type === 'constructor');
@ -38,35 +36,37 @@ class Deploy {
}
}
let realArgs = [];
async.eachLimit(args, 1, (arg, nextEachCb) => {
if (arg[0] === "$") {
contractName = arg.substr(1);
let contractName = arg.substr(1);
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) {
async.eachLimit(arg, 1, (sub_arg, nextSubEachCb) => {
if (sub_arg[0] === "$") {
contractName = sub_arg.substr(1);
referedContract = this.contractsManager.getContract(contractName);
subRealArgs.push(referedContract.deployedAddress);
let contractName = sub_arg.substr(1);
self.events.request('contracts:contract', contractName, (referedContract) => {
subRealArgs.push(referedContract.deployedAddress);
nextSubEachCb();
});
} else {
subRealArgs.push(sub_arg);
nextSubEachCb();
}
}
// todo: put this in the final callback
realArgs.push(subRealArgs);
nextEachCb();
}, () => {
realArgs.push(subRealArgs);
nextEachCb();
});
} else {
realArgs.push(arg);
nextEachCb();
}
}, () => {
callback(realArgs);
});