diff --git a/lib/deploy.js b/lib/deploy.js index 4b43bcd6..cfbba629 100644 --- a/lib/deploy.js +++ b/lib/deploy.js @@ -15,6 +15,21 @@ var Deploy = function(options) { }); }; +Deploy.prototype.determineArguments = function(suppliedArgs) { + var realArgs = [], l, arg, contractName, referedContract; + + for (l = 0; l < suppliedArgs.length; l++) { + arg = suppliedArgs[l]; + if (arg[0] === "$") { + contractName = arg.substr(1); + referedContract = this.contractsManager.getContract(contractName); + realArgs.push(referedContract.deployedAddress); + } else { + realArgs.push(arg); + } + } +}; + Deploy.prototype.checkAndDeployContract = function(contract, params, callback) { var self = this; var suppliedArgs; @@ -32,20 +47,7 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) { if (contract.address !== undefined) { - // determine arguments - suppliedArgs = (params || contract.args); - realArgs = []; - - for (l = 0; l < suppliedArgs.length; l++) { - arg = suppliedArgs[l]; - if (arg[0] === "$") { - contractName = arg.substr(1); - referedContract = this.contractsManager.getContract(contractName); - realArgs.push(referedContract.deployedAddress); - } else { - realArgs.push(arg); - } - } + realArgs = self.determineArguments(params || contract.args); contract.deployedAddress = contract.address; self.deployTracker.trackContract(contract.className, contract.code, realArgs, contract.address); @@ -63,20 +65,7 @@ Deploy.prototype.checkAndDeployContract = function(contract, params, callback) { return callback(); } else { - // determine arguments - suppliedArgs = (params || contract.args); - realArgs = []; - - for (l = 0; l < suppliedArgs.length; l++) { - arg = suppliedArgs[l]; - if (arg[0] === "$") { - contractName = arg.substr(1); - referedContract = this.contractsManager.getContract(contractName); - realArgs.push(referedContract.deployedAddress); - } else { - realArgs.push(arg); - } - } + realArgs = self.determineArguments(params || contract.args); this.deployContract(contract, realArgs, function(err, address) { if (err) {