From f864bb60987426e33766df5d341d83f0b381b61b Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 27 Oct 2015 11:51:30 -0500 Subject: [PATCH] compiling correctly and moved wall of code is_a_token I think is no longer necessary methinks...because now you can just draw up your coin as is. At the very least the function needs to be rewritten. In addition I moved the wall of code that you had a TODO to move on...and I put it in its own separate function configureContractsParameters. Let me know what we should do with is_a_token. --- lib/config/contracts.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/config/contracts.js b/lib/config/contracts.js index ac109af6..5045f8d6 100644 --- a/lib/config/contracts.js +++ b/lib/config/contracts.js @@ -41,8 +41,12 @@ ContractsConfig.prototype.config = function(env) { }; ContractsConfig.prototype.is_a_token = function(target, compiled_contracts) { - for (var className in compiled_contracts) { + for (var className in compiled_contracts) { //This needs some serious changing + if (this.contractStubs[className] && this.contractStubs[className].indexOf(target) >= 0) { + console.log("hit the condition") + console.log(this.contractStubs[className]); + console.log(this.contractStubs[className].indexOf(target)); return true; } } @@ -75,29 +79,30 @@ ContractsConfig.prototype.compileContracts = function(env) { } } - var all_compiled_contracts = {}; - // compile files - compiled_contracts = this.compiler.compile(this.contractFiles); - + + compiled_contracts = this.compiler.compile(this.contractFiles); //compile and push to contract DB + for (var className in compiled_contracts) { - var contract = compiled_contracts[className]; if (this.is_a_token(className, compiled_contracts)) { continue; } - all_compiled_contracts[className] = contract; this.all_contracts.push(className); this.contractDB[className] = { args: [], types: ['file'], gasPrice: this.blockchainConfig.gasPrice, gasLimit: this.blockchainConfig.gasLimit, - compiled: contract + compiled: compiled_contracts[className] } } - // TODO: move this + this.configureContractsParameters(contractsConfig); + this.sortContracts(); +}; + +ContractsConfig.prototype.configureContractsParameters = function(contractsConfig) { for(className in contractsConfig) { var contractConfig = contractsConfig[className]; @@ -123,7 +128,7 @@ ContractsConfig.prototype.compileContracts = function(env) { if (contractConfig.instanceOf !== undefined) { contract.types.push('instance'); contract.instanceOf = contractConfig.instanceOf; - contract.compiled = all_compiled_contracts[contractConfig.instanceOf]; + contract.compiled = compiled_contracts[contractConfig.instanceOf]; } if (contractConfig.address !== undefined) { contract.types.push('static'); @@ -139,8 +144,7 @@ ContractsConfig.prototype.compileContracts = function(env) { } } - this.sortContracts(); -}; +} ContractsConfig.prototype.sortContracts = function() { var converted_dependencies = [], i; @@ -162,4 +166,3 @@ ContractsConfig.prototype.sortContracts = function() { }; module.exports = ContractsConfig; -