From f882b3486b4495505d21d5485bf73c414895e828 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 5 Jul 2017 20:24:28 -0400 Subject: [PATCH] use deployment config from contracts.json instead of blockchain.json --- lib/core/config.js | 8 +++++++- lib/core/engine.js | 8 ++++++-- test_app/config/contracts.json | 3 ++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/core/config.js b/lib/core/config.js index 6665e7b4..bd1865a1 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -75,7 +75,13 @@ Config.prototype.loadBlockchainConfigFile = function() { Config.prototype.loadContractsConfigFile = function() { - var configObject = {}; + var configObject = { + "deployment": { + "host": "localhost", + "port": 8545, + "type": "rpc" + } + }; var configPlugins = this.plugins.getPluginsFor('contractsConfig'); if (configPlugins.length > 0) { diff --git a/lib/core/engine.js b/lib/core/engine.js index 31d48e2d..a2f8be20 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -220,8 +220,12 @@ class Engine { this.web3 = options.web3; if (this.web3 === undefined) { this.web3 = new Web3(); - let web3Endpoint = 'http://' + this.config.blockchainConfig.rpcHost + ':' + this.config.blockchainConfig.rpcPort; - this.web3.setProvider(new this.web3.providers.HttpProvider(web3Endpoint)); + if (this.config.contractsConfig.deployment.type === "rpc") { + let web3Endpoint = 'http://' + this.config.contractsConfig.deployment.host + ':' + this.config.contractsConfig.deployment.port; + this.web3.setProvider(new this.web3.providers.HttpProvider(web3Endpoint)); + } else { + throw new Error("contracts config error: unknown deployment type " + this.config.contractsConfig.deployment.type); + } } self.servicesMonitor.addCheck('Ethereum', function (cb) { diff --git a/test_app/config/contracts.json b/test_app/config/contracts.json index 265d20f4..1d42028d 100644 --- a/test_app/config/contracts.json +++ b/test_app/config/contracts.json @@ -6,7 +6,8 @@ }, "deployment": { "host": "localhost", - "port": 8545 + "port": 8545, + "type": "rpc" }, "dappConnection": [ "$WEB3",