Browse Source

Move default values for contract config env vars to constants file

develop
Apostolos Fanakis 4 years ago
parent
commit
0e091fa319
  1. 16
      packages/concordia-contracts/constants/config/defaults.js
  2. 3
      packages/concordia-contracts/package.json
  3. 13
      packages/concordia-contracts/truffle-config.js

16
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,
},
};

3
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",

13
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 <http://truffleframework.com/docs/advanced/configuration>
@ -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: '*',
},
},

Loading…
Cancel
Save