Skip to content

Commit f882b34

Browse files
committed
use deployment config from contracts.json instead of blockchain.json
1 parent 408090a commit f882b34

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

lib/core/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ Config.prototype.loadBlockchainConfigFile = function() {
7575

7676
Config.prototype.loadContractsConfigFile = function() {
7777

78-
var configObject = {};
78+
var configObject = {
79+
"deployment": {
80+
"host": "localhost",
81+
"port": 8545,
82+
"type": "rpc"
83+
}
84+
};
7985

8086
var configPlugins = this.plugins.getPluginsFor('contractsConfig');
8187
if (configPlugins.length > 0) {

lib/core/engine.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,12 @@ class Engine {
220220
this.web3 = options.web3;
221221
if (this.web3 === undefined) {
222222
this.web3 = new Web3();
223-
let web3Endpoint = 'http://' + this.config.blockchainConfig.rpcHost + ':' + this.config.blockchainConfig.rpcPort;
224-
this.web3.setProvider(new this.web3.providers.HttpProvider(web3Endpoint));
223+
if (this.config.contractsConfig.deployment.type === "rpc") {
224+
let web3Endpoint = 'http://' + this.config.contractsConfig.deployment.host + ':' + this.config.contractsConfig.deployment.port;
225+
this.web3.setProvider(new this.web3.providers.HttpProvider(web3Endpoint));
226+
} else {
227+
throw new Error("contracts config error: unknown deployment type " + this.config.contractsConfig.deployment.type);
228+
}
225229
}
226230

227231
self.servicesMonitor.addCheck('Ethereum', function (cb) {

test_app/config/contracts.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
},
77
"deployment": {
88
"host": "localhost",
9-
"port": 8545
9+
"port": 8545,
10+
"type": "rpc"
1011
},
1112
"dappConnection": [
1213
"$WEB3",

0 commit comments

Comments
 (0)