orbs-network / management-service

Reads network management state from Ethereum and reports it to Boyar and virtual chains
MIT License
2 stars 2 forks source link

Support passing required config values via environment variables #115

Closed Luke-Rogerson closed 1 year ago

Luke-Rogerson commented 1 year ago

What's this?

Support passing required config values via environment variables (needed for v3 architecture), in addition to config file.

Testing

Unit tests

Run npx ava --verbose --timeout=10m --serial --fail-fast src/cli-args.test.ts

Running locally

No config file and no environment variables

  1. Run npx tsc --skipLibCheck -p ./tsconfig.prod.json && npm run start

Environment variables and no config file

  1. Add the following env vars:
    export ETHEREUM_ENDPOINT=https://mainnet.infura.io/v3/123
    export NODE_ADDRESS=55555555d4bbbe34b470f12cb0e2cd2387f6710ec5815733005bc887c317e8cf
  2. Run npx tsc --skipLibCheck -p ./tsconfig.prod.json && npm run start

Config file and no environment variables

  1. Ensure previous env vars are not set:
    unset ETHEREUM_ENDPOINT
    unset NODE_ADDRESS
  2. Create config.json in root of project with following:
    {
    "EthereumEndpoint": "https://mainnet.infura.io/v3/123",
    "MaticEndpoint": "https://polygon-mainnet.g.alchemy.com/v2/123",
    "node-address": "55555555d4bbbe34b470f12cb0e2cd2387f6710ec5815733005bc887c317e8cf"
    }
  3. Run npx tsc --skipLibCheck -p ./tsconfig.prod.json && npm run start -- --config ./config.json