Skip to content

Commit

Permalink
chore: removes prefix from node's uri (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
404skillz committed Jan 10, 2022
1 parent 64c7aea commit eef6307
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# network specific node uri: `"ETH_NODE_URI_" + networkName.toUpperCase()`
ETH_NODE_URI_MAINNET=https://eth-mainnet.alchemyapi.io/v2/<apiKey>
# network specific node uri: `"NODE_URI_" + networkName.toUpperCase()`
NODE_URI_MAINNET=https://eth-mainnet.alchemyapi.io/v2/<apiKey>
# generic node uri (if no specific found):
ETH_NODE_URI=https://eth-{{networkName}}.infura.io/v3/<apiKey>
NODE_URI=https://eth-{{networkName}}.infura.io/v3/<apiKey>

# network specific mnemonic: `MNEMONIC_${networkName.toUpperCase()}`
MNEMONIC_MAINNET=<mnemonic for mainnet>
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gas-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Run gas tests
run: yarn test:gas
env:
ETH_NODE_URI_MAINNET: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMYKEY }}
NODE_URI_MAINNET: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMYKEY }}

- name: Run eth gas reporter
run: npx codechecks
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ jobs:
- name: Run e2e tests
run: yarn test:e2e
env:
ETH_NODE_URI_MAINNET: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMYKEY }}
NODE_URI_MAINNET: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMYKEY }}
8 changes: 4 additions & 4 deletions utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import 'dotenv/config';

export function getNodeUrl(networkName: string): string {
if (networkName) {
const uri = process.env[`ETH_NODE_URI_${networkName.toUpperCase()}`];
const uri = process.env[`NODE_URI_${networkName.toUpperCase()}`];
if (uri && uri !== '') {
return uri;
}
}

if (networkName === 'localhost') {
// do not use ETH_NODE_URI
// do not use NODE_URI
return 'http://localhost:8545';
}

let uri = process.env.ETH_NODE_URI;
let uri = process.env.NODE_URI;
if (uri) {
uri = uri.replace('{{networkName}}', networkName);
}
if (!uri || uri === '') {
// throw new Error(`environment variable "ETH_NODE_URI" not configured `);
// throw new Error(`environment variable "NODE_URI" not configured `);
return '';
}
if (uri.indexOf('{{') >= 0) {
Expand Down

0 comments on commit eef6307

Please sign in to comment.