Skip to content

Commit

Permalink
Improve env var handling for nameguard-js (#382)
Browse files Browse the repository at this point in the history
* Improve env var handling for nameguard-js
  • Loading branch information
lightwalker-eth authored Aug 28, 2024
1 parent 6529bfb commit 2912357
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-pumas-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@namehash/nameguard-js": patch
---

Refine nameguard-js unit tests
4 changes: 4 additions & 0 deletions .github/workflows/typescript-packages-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
paths:
- "packages/**"

env:
PROVIDER_URI_MAINNET: ${{ secrets.PROVIDER_URI_MAINNET }}
PROVIDER_URI_SEPOLIA: ${{ secrets.PROVIDER_URI_SEPOLIA }}

jobs:
test:
strategy:
Expand Down
12 changes: 12 additions & 0 deletions packages/nameguard-js/src/nameguard-js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ import { createClient } from "./nameguard-js";
const PROVIDER_URI_MAINNET = process.env.PROVIDER_URI_MAINNET;
const PROVIDER_URI_SEPOLIA = process.env.PROVIDER_URI_SEPOLIA;

if (!PROVIDER_URI_MAINNET) {
throw new Error(
"The PROVIDER_URI_MAINNET environment variable is not defined.",
);
}

if (!PROVIDER_URI_SEPOLIA) {
throw new Error(
"The PROVIDER_URI_SEPOLIA environment variable is not defined.",
);
}

/**
* This is a fake endpoint that will not work.
* If a client created with this endpoint tries to make an API request, it will throw an error.
Expand Down

0 comments on commit 2912357

Please sign in to comment.