mirror of https://github.com/embarklabs/embark.git
use request to get contract
This commit is contained in:
parent
c83064adf6
commit
30b1975e34
|
@ -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);
|
||||
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();
|
||||
});
|
||||
} else {
|
||||
realArgs.push(arg);
|
||||
nextEachCb();
|
||||
}
|
||||
|
||||
|
||||
}, () => {
|
||||
callback(realArgs);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue