mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-11 14:34:40 +00:00
refactor determining method arguments
This commit is contained in:
parent
df7ff3916f
commit
88bdd662de
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user