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