mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-01-11 14:34:40 +00:00
simplify method dealing with instanceOf
This commit is contained in:
parent
5c283b5232
commit
99c528c230
@ -80,48 +80,51 @@ ContractsManager.prototype.build = function(done) {
|
|||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
function setDeployIntention(callback) {
|
||||||
|
var className, contract;
|
||||||
|
for(className in self.contracts) {
|
||||||
|
contract = self.contracts[className];
|
||||||
|
contract.deploy = (contract.deploy === undefined) || contract.deploy;
|
||||||
|
}
|
||||||
|
},
|
||||||
function dealWithSpecialConfigs(callback) {
|
function dealWithSpecialConfigs(callback) {
|
||||||
var className, contract, parentContractName, parentContract;
|
var className, contract, parentContractName, parentContract;
|
||||||
|
|
||||||
for(className in self.contracts) {
|
for(className in self.contracts) {
|
||||||
contract = self.contracts[className];
|
contract = self.contracts[className];
|
||||||
|
|
||||||
// if deploy intention is not specified default is true
|
if (contract.instanceOf === undefined) { continue; }
|
||||||
if (contract.deploy === undefined) {
|
|
||||||
contract.deploy = true;
|
parentContractName = contract.instanceOf;
|
||||||
|
parentContract = self.contracts[parentContractName];
|
||||||
|
|
||||||
|
if (parentContract === className) {
|
||||||
|
self.logger.error(className + ": instanceOf is set to itself");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contract.instanceOf !== undefined) {
|
if (parentContract === undefined) {
|
||||||
parentContractName = contract.instanceOf;
|
self.logger.error(className + ": couldn't find instanceOf contract " + parentContractName);
|
||||||
parentContract = self.contracts[parentContractName];
|
continue;
|
||||||
|
|
||||||
if (parentContract === className) {
|
|
||||||
self.logger.error(className + ": instanceOf is set to itself");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parentContract === undefined) {
|
|
||||||
slef.logger.error(className + ": couldn't find instanceOf contract " + parentContractName);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parentContract.args && parentContract.args.length > 0 && contract.args === []) {
|
|
||||||
contract.args = parentContract.args;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contract.code !== undefined) {
|
|
||||||
self.logger.error(className + " has code associated to it but it's configured as an instanceOf " + parentContractName);
|
|
||||||
}
|
|
||||||
|
|
||||||
contract.code = parentContract.code;
|
|
||||||
contract.runtimeBytecode = parentContract.runtimeBytecode;
|
|
||||||
contract.gasEstimates = parentContract.gasEstimates;
|
|
||||||
contract.functionHashes = parentContract.functionHashes;
|
|
||||||
contract.abiDefinition = parentContract.abiDefinition;
|
|
||||||
|
|
||||||
contract.gas = contract.gas || parentContract.gas;
|
|
||||||
contract.gasPrice = contract.gasPrice || parentContract.gasPrice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parentContract.args && parentContract.args.length > 0 && contract.args === []) {
|
||||||
|
contract.args = parentContract.args;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contract.code !== undefined) {
|
||||||
|
self.logger.error(className + " has code associated to it but it's configured as an instanceOf " + parentContractName);
|
||||||
|
}
|
||||||
|
|
||||||
|
contract.code = parentContract.code;
|
||||||
|
contract.runtimeBytecode = parentContract.runtimeBytecode;
|
||||||
|
contract.gasEstimates = parentContract.gasEstimates;
|
||||||
|
contract.functionHashes = parentContract.functionHashes;
|
||||||
|
contract.abiDefinition = parentContract.abiDefinition;
|
||||||
|
|
||||||
|
contract.gas = contract.gas || parentContract.gas;
|
||||||
|
contract.gasPrice = contract.gasPrice || parentContract.gasPrice;
|
||||||
|
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user