Skip to content

Commit

Permalink
rename public key env
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Feb 18, 2024
1 parent 2995116 commit 70a5ef3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ USERNAME=default
DATABASE=default
PASSWORD=

# Webhook Ed25519 signature (Optional)
PUBLIC_KEYS=... # ed25519 public key provided by https://github.com/pinax-network/substreams-sink-webhook
# Webhook Ed25519 public key (comma separated for multiple) (optional)
# https://github.com/pinax-network/substreams-sink-webhook
PUBLIC_KEY=

# Sink HTTP server (Optional)
# Sink HTTP server (optional)
PORT=3000
HOSTNAME=0.0.0.0
VERBOSE=true
1 change: 0 additions & 1 deletion .env.test

This file was deleted.

11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Every request can also be executed via the [online UI](http://localhost:3000).
1. Associate Webhook Ed25519 public keys from [substreams-sink-webhook](https://github.com/pinax-network/substreams-sink-webhook).

```bash
$ echo "PUBLIC_KEYS=<PK1>,<PK2>,..." >> .env
$ echo "PUBLIC_KEY=<PK1>,<PK2>,..." >> .env
```

1. Initialize the database (_set database credentials in [environment](#environment)_)
Expand Down Expand Up @@ -78,10 +78,11 @@ USERNAME=default
DATABASE=default
PASSWORD=
# Webhook Ed25519 signature (Optional)
PUBLIC_KEYS=... # ed25519 public key provided by https://github.com/pinax-network/substreams-sink-webhook
# Webhook Ed25519 public key (comma separated for multiple) (optional)
# https://github.com/pinax-network/substreams-sink-webhook
PUBLIC_KEY=
# Sink HTTP server (Optional)
# Sink HTTP server (optional)
PORT=3000
HOSTNAME=0.0.0.0
VERBOSE=true
Expand All @@ -103,7 +104,7 @@ Options:
-v, --verbose <boolean> Enable verbose logging (choices: "true", "false", default: "true", env: VERBOSE)
-p, --port <number> Sink HTTP server port (default: "3000", env: PORT)
--hostname <string> Sink HTTP server hostname (default: "0.0.0.0", env: HOSTNAME)
--public-keys <string> Webhook Ed25519 public keys (comma separated) (env: PUBLIC_KEYS)
--public-key <string> Webhook Ed25519 public key (comma separated for multiple) (env: PUBLIC_KEY)
--host <string> Clickhouse DB hostname (default: "http://localhost:8123", env: HOST)
--username <string> Clickhouse DB username (default: "default", env: USERNAME)
--password <string> Clickhouse DB password (default: "", env: PASSWORD)
Expand Down
5 changes: 2 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export const opts = program
.addOption(new Option("-v, --verbose <boolean>", "Enable verbose logging").choices(["true", "false"]).env("VERBOSE").default(DEFAULT_VERBOSE))
.addOption(new Option("-p, --port <number>", "Sink HTTP server port").env("PORT").default(DEFAULT_PORT))
.addOption(new Option("--hostname <string>", "Sink HTTP server hostname").env("HOSTNAME").default(DEFAULT_HOSTNAME))
.addOption(new Option("--public-key <string>", "Webhook Ed25519 public keys (comma separated)").env("PUBLIC_KEY").hideHelp())
.addOption(new Option("--public-keys <string>", "Webhook Ed25519 public keys (comma separated)").env("PUBLIC_KEYS"))
.addOption(new Option("--public-key <string>", "Webhook Ed25519 public keys (comma separated for multiple)").env("PUBLIC_KEY"))
.addOption(new Option("--host <string>", "Clickhouse DB hostname").env("HOST").default(DEFAULT_HOST))
.addOption(new Option("--username <string>", "Clickhouse DB username").env("USERNAME").default(DEFAULT_USERNAME))
.addOption(new Option("--password <string>", "Clickhouse DB password").env("PASSWORD").default(DEFAULT_PASSWORD))
Expand All @@ -36,7 +35,7 @@ export const config = ConfigSchema.parse(opts);

// validate public key
export const publicKeys: string[] = [];
for ( const publicKey of [...config.publicKeys ?? [], ...config.publicKey ?? []] ) {
for ( const publicKey of config.publicKey ?? [] ) {
if ( publicKey.length !== 64 ) throw new Error("Invalid Ed25519 public key length");
publicKeys.push(publicKey);
}
1 change: 0 additions & 1 deletion src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const splitString = (separator: string ) => z.optional(z.string().transfo

export const ConfigSchema = z.object({
publicKey: splitString(","),
publicKeys: splitString(","),
port: positiveNumber,
verbose: boolean,
host: z.string(),
Expand Down

0 comments on commit 70a5ef3

Please sign in to comment.