add support for static addresses in contracts config

This commit is contained in:
Iuri Matias 2016-09-27 21:13:54 -04:00
parent 2b6e5e834a
commit 4b4b15f405
4 changed files with 46 additions and 0 deletions

19
demo/chains.json Normal file
View File

@ -0,0 +1,19 @@
{
"0xb6cfeab83614da04c03db0fb8a6787a45d0be8d576fcc6f8f457a5a816d22ab3": {
"name": "development",
"contracts": {
"2ac097aa929aece4724cc229cc7bd26c7dfa153f3274b5623936cb4a4dc12fa1": {
"address": "0x123",
"name": "token"
},
"e0d35d6564373021d9749a7a8815cf58cc5ca7b7edaf4740c1913898561531c3": {
"address": "0x9e3b27a53318d4dc0b6716afc5ad146480b86b64",
"name": "SimpleStorage2"
},
"f3765f8b702ccb44eb19f1adecbf5a216175713fbd41d9fae100d8e3dfc5e74f": {
"address": "0x6ecb595483da2c264ea5e039743340ebce8af0da",
"name": "SimpleStorage"
}
}
}
}

View File

@ -3,6 +3,7 @@
"gas": "auto",
"contracts": {
"token": {
"address": "0x123",
"args": [
100
]

View File

@ -52,6 +52,7 @@ ContractsManager.prototype.build = function() {
contract.type = 'file';
contract.className = className;
contract.address = contractConfig.address;
this.contracts[className] = contract;
}

View File

@ -15,6 +15,31 @@ var Deploy = function(options) {
Deploy.prototype.checkAndDeployContract = function(contract, params, callback) {
var self = this;
if (contract.address !== undefined) {
// determine arguments
var suppliedArgs = (params || contract.args);
var realArgs = [];
for (var l = 0; l < suppliedArgs.length; l++) {
var arg = suppliedArgs[l];
if (arg[0] === "$") {
var contractName = arg.substr(1);
var referedContract = this.contractsManager.getContract(contractName);
realArgs.push(referedContract.deployedAddress);
} else {
realArgs.push(arg);
}
}
contract.deployedAddress = contract.address;
self.deployTracker.trackContract(contract.className, contract.code, realArgs, contract.address);
self.deployTracker.save();
self.logger.contractsState(self.contractsManager.contractsState());
return callback();
}
var trackedContract = self.deployTracker.getContract(contract.className, contract.code, contract.args);
if (trackedContract && this.web3.eth.getCode(trackedContract.address) !== "0x") {