From e3fde1ad225f2c72c8d06a8c6ab47104e9b46b89 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 12 Apr 2018 17:54:08 -0400 Subject: [PATCH] support mapping contract file in contracts config --- lib/core/config.js | 12 ++++++++++++ test_apps/test_app/config/contracts.json | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/lib/core/config.js b/lib/core/config.js index c6aafe59..89a66c36 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -47,6 +47,7 @@ Config.prototype.loadConfigFiles = function(options) { this.loadPipelineConfigFile(); this.loadContractsConfigFile(); + this.loadExternalContractsFiles(); this.loadWebServerConfigFile(); this.loadChainTrackerFile(); this.loadPluginContractFiles(); @@ -60,6 +61,7 @@ Config.prototype.reloadConfig = function() { this.loadContractsConfigFile(); this.loadPipelineConfigFile(); this.loadContractsConfigFile(); + this.loadExternalContractsFiles(); this.loadChainTrackerFile(); }; @@ -140,6 +142,16 @@ Config.prototype.loadContractsConfigFile = function() { this.contractsConfig = this._mergeConfig(configFilePath, configObject, this.env); }; +Config.prototype.loadExternalContractsFiles = function() { + let contracts = this.contractsConfig.contracts; + for (let contractName in contracts) { + let contract = contracts[contractName]; + if (contract.file) { + this.contractsFiles.push(new File({filename: contract.file, type: "dapp_file", basedir: '', path: contract.file})); + } + } +}; + Config.prototype.loadStorageConfigFile = function() { var versions = utils.recursiveMerge({"ipfs-api": "17.2.4"}, this.embarkConfig.versions || {}); diff --git a/test_apps/test_app/config/contracts.json b/test_apps/test_app/config/contracts.json index d504a8ff..8ab61e18 100644 --- a/test_apps/test_app/config/contracts.json +++ b/test_apps/test_app/config/contracts.json @@ -62,6 +62,12 @@ ["$MyToken2", "$SimpleStorage"], 100 ] + }, + "SimpleStorageTest": { + "file": "./some_folder/test_contract.sol", + "args": [ + 1000 + ] } }, "afterDeploy": [