From 0e091fa31946abdd6103a7efd6a0aba03b8dc516 Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sat, 21 Nov 2020 17:56:37 +0200 Subject: [PATCH] Move default values for contract config env vars to constants file --- .../constants/config/defaults.js | 16 ++++++++++++++++ packages/concordia-contracts/package.json | 3 ++- packages/concordia-contracts/truffle-config.js | 13 +++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 packages/concordia-contracts/constants/config/defaults.js diff --git a/packages/concordia-contracts/constants/config/defaults.js b/packages/concordia-contracts/constants/config/defaults.js new file mode 100644 index 0000000..e2cfa34 --- /dev/null +++ b/packages/concordia-contracts/constants/config/defaults.js @@ -0,0 +1,16 @@ +const DEVELOP_CHAIN_HOST_DEFAULT = '127.0.0.1'; +const DEVELOP_CHAIN_PORT_DEFAULT = '8545'; + +const TEST_CHAIN_HOST_DEFAULT = '127.0.0.1'; +const TEST_CHAIN_PORT_DEFAULT = '8546'; + +module.exports = { + develop: { + chainHost: DEVELOP_CHAIN_HOST_DEFAULT, + chainPort: DEVELOP_CHAIN_PORT_DEFAULT, + }, + test: { + chainHost: TEST_CHAIN_HOST_DEFAULT, + chainPort: TEST_CHAIN_PORT_DEFAULT, + }, +}; diff --git a/packages/concordia-contracts/package.json b/packages/concordia-contracts/package.json index aba8e5d..c495d6f 100644 --- a/packages/concordia-contracts/package.json +++ b/packages/concordia-contracts/package.json @@ -10,7 +10,8 @@ "_eslint": "yarn eslint . --format table", "_solhint": "yarn solhint --formatter table contracts/*.sol test/*.sol", "test": "yarn truffle test", - "migrate": "yarn truffle migrate --network develop --reset" + "migrate": "yarn truffle migrate --network develop", + "migrate-reset": "yarn truffle migrate --network develop --reset" }, "dependencies": { "@openzeppelin/contracts": "~3.2.0", diff --git a/packages/concordia-contracts/truffle-config.js b/packages/concordia-contracts/truffle-config.js index 3ef72a1..669e9b9 100644 --- a/packages/concordia-contracts/truffle-config.js +++ b/packages/concordia-contracts/truffle-config.js @@ -1,7 +1,8 @@ const path = require('path'); +const defaults = require('./constants/config/defaults'); -const { GANACHE_HOST } = process.env; -const { GANACHE_PORT } = process.env; +const { CHAIN_HOST } = process.env; +const { CHAIN_PORT } = process.env; module.exports = { // See @@ -14,13 +15,13 @@ module.exports = { contracts_build_directory: path.join(__dirname, 'build/'), networks: { develop: { - host: GANACHE_HOST || '127.0.0.1', - port: GANACHE_PORT || '8545', + host: CHAIN_HOST || defaults.develop.chainHost, + port: CHAIN_PORT || defaults.develop.chainPort, network_id: '*', }, test: { - host: GANACHE_HOST || '127.0.0.1', - port: GANACHE_PORT || '8546', + host: CHAIN_HOST || defaults.test.chainHost, + port: CHAIN_PORT || defaults.test.chainPort, network_id: '*', }, },