Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update workers README and version #64

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading