Skip to content

Commit

Permalink
Update workers README and version (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Luc <[email protected]>
  • Loading branch information
o-az and lucemans authored Jan 24, 2024
1 parent 1052b0b commit 6695441
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
48 changes: 43 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,63 @@ services:
- 6379:6379
```
### 🦀 Cloudflare Worker
### 🦀 Cloudflare Workers
Running the cloudflare worker is as easy as running the following command:
Additionally, there is a hosted instance available at [worker.enstate.rs](https://worker.enstate.rs).
```sh
cd worker
```

#### Run the worker locally

```sh
cp .dev.vars.example .dev.vars
```

Edit your `.dev.vars` file at this time to include environment variables for `UNIVERSAL_RESOLVER`, `RPC_URL` (optional) and `OPENSEA_API_KEY` (optional).

To run the worker locally you can now run:

```
pnpm dev
```

#### Deploying to Cloudflare Workers

Create a [**KV namespace**](https://developers.cloudflare.com/kv/get-started/#3-create-a-kv-namespace) via `wrangler` or the Cloudflare dashboard.

```sh
cd worker && pnpx wrangler deploy
pnpm wrangler kv:namespace create <YOUR_NAMESPACE>
```

Copy the `id` of your newly created KV namespace to your [`wrangler.toml`](./worker/wrangler.toml). The `binding` value should remain as `enstate-1` regardless of what you named yours when you created it.

Deploy the worker:

```sh
pnpm wrangler deploy
```

Upload your secrets:

```sh
echo "https://rpc.ankr.com/eth/XXXXXX" | pnpm wrangler secret put RPC_URL
echo "XXXXX" | pnpm wrangler secret put OPENSEA_API_KEY
```

Additionally, there is a hosted instance available at [worker.enstate.rs](https://worker.enstate.rs).

## Contributing

### Standalone Server

```sh
cargo run -p enstate
cd server && cargo run -p enstate
```

### Cloudflare Worker

```sh
cd worker && pnpm dev
```

For more information on running the worker locally, please see [running Cloudflare Workers locally](#run-the-worker-locally).
2 changes: 1 addition & 1 deletion worker/.dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
OPENSEA_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
UNIVERSAL_RESOLVER=0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62s

2 changes: 1 addition & 1 deletion worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"dev": "wrangler dev"
},
"devDependencies": {
"wrangler": "^3.19.0"
"wrangler": "^3.23.0"
}
}
3 changes: 2 additions & 1 deletion worker/wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#: schema https://github.com/cloudflare/workers-sdk/files/12887590/wrangler.schema.json
name = "enstate-worker"
main = "build/worker/shim.mjs"
compatibility_date = "2023-03-22"
Expand All @@ -14,4 +15,4 @@ kv_namespaces = [
command = "cargo install -q worker-build && worker-build --release"

[vars]
OPENSEA_API_KEY="xxxx"
UNIVERSAL_RESOLVER="0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62"

0 comments on commit 6695441

Please sign in to comment.