From fa409e83db6b76422d525f7d2e9c947dc3c51262 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Mon, 18 Sep 2023 21:24:35 +0100 Subject: [PATCH] docs(faucet): add readme (#1534) --- .changeset/twelve-monkeys-juggle.md | 5 +++++ packages/faucet/README.md | 30 ++++++++++++++++++++++++++++ packages/faucet/bin/faucet-server.ts | 4 +--- 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 .changeset/twelve-monkeys-juggle.md create mode 100644 packages/faucet/README.md diff --git a/.changeset/twelve-monkeys-juggle.md b/.changeset/twelve-monkeys-juggle.md new file mode 100644 index 0000000000..203bfe6c37 --- /dev/null +++ b/.changeset/twelve-monkeys-juggle.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/faucet": patch +--- + +Added README diff --git a/packages/faucet/README.md b/packages/faucet/README.md new file mode 100644 index 0000000000..a5a5f52850 --- /dev/null +++ b/packages/faucet/README.md @@ -0,0 +1,30 @@ +# faucet + +A minimal Typescript faucet to drip native tokens on Ethereum chains + +## Usage + +Install and run with: + +```sh +npm install @latticexyz/faucet@next +npm faucet-server +``` + +or execute the package bin directly: + +```sh +npx @latticexyz/faucet@next +``` + +## Configuration + +The faucet can configured with the following environment variables: + +| Variable | Description | Default | +| -------------------- | ----------------------------------------------------- | --------- | +| `HOST` | Host that the indexer server listens on | `0.0.0.0` | +| `PORT` | Port that the indexer server listens on | `3001` | +| `RPC_HTTP_URL` | HTTP URL for Ethereum RPC | | +| `FAUCET_PRIVATE_KEY` | Private key of wallet to distribute faucet funds from | | +| `DRIP_AMOUNT_ETHER` | Drip amount in ether | diff --git a/packages/faucet/bin/faucet-server.ts b/packages/faucet/bin/faucet-server.ts index f6a6327a3d..f3edcabe0a 100644 --- a/packages/faucet/bin/faucet-server.ts +++ b/packages/faucet/bin/faucet-server.ts @@ -3,12 +3,10 @@ import "dotenv/config"; import { z } from "zod"; import fastify from "fastify"; import { fastifyTRPCPlugin } from "@trpc/server/adapters/fastify"; -import { ClientConfig, http, parseEther, isHex, createClient } from "viem"; +import { http, parseEther, isHex, createClient } from "viem"; import { privateKeyToAccount } from "viem/accounts"; import { AppRouter, createAppRouter } from "../src/createAppRouter"; -import { getChainId } from "viem/actions"; -// TODO: refine zod type to be either CHAIN_ID or RPC_HTTP_URL/RPC_WS_URL const env = z .object({ HOST: z.string().default("0.0.0.0"),