Skip to content

Commit 8a7da22

Browse files
committed
Release v0.7.0
1 parent 016af2a commit 8a7da22

35 files changed

Lines changed: 2675 additions & 838 deletions

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
# FIREBLOCKS_ASSET_ID= # optional — override auto-detected asset ID
2525
# FIREBLOCKS_MAX_POLL_ATTEMPTS= # optional — max poll attempts for tx confirmation (default: 60)
2626

27-
# --- Option D: Raw Private Key (local dev only, NOT recommended) ---
27+
# --- Option D: Bankr (agent wallet API) ---
28+
# BANKR_API_KEY= # https://bankr.bot
29+
30+
# --- Option E: Raw Private Key (local dev only, NOT recommended) ---
2831
# PRIVATE_KEY= # hex-encoded — no spending limits or guardrails
2932
# RPC_URL= # RPC endpoint for the target chain

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pnpm run type-check # TypeScript type checking
3030
| `src/lib/onchain/predicate-clients.ts` | Typed clients for predicate contracts |
3131
| `src/lib/manifest/` | Manifest schema, validation, types |
3232
| `src/lib/handler/` | `createToolHandler` — Web Request/Response handler factory |
33-
| `src/lib/middleware/` | Gating middleware (NFT gate, predicate gate, x402, x402 facilitators, well-known endpoint) |
33+
| `src/lib/middleware/` | Gating middleware (predicate gate, x402, x402 facilitators, well-known endpoint) |
3434
| `src/lib/wallet/` | Re-exports from `@opensea/wallet-adapters` (adapters, types, and viem bridge) |
3535
| `src/lib/adapters/` | Framework adapters (Vercel, Cloudflare, Express) |
3636
| `src/lib/utils.ts` | Shared utilities used across `lib/` |
@@ -55,7 +55,7 @@ When reviewing changes to this package, verify:
5555

5656
5. **CLI error messages**: Error messages shown to SDK consumers should not reference internal file paths (e.g., "Update chains.ts"). Link to the README or provide actionable instructions instead.
5757

58-
6. **Multi-step CLI flows**: Commands that require multiple onchain transactions (e.g., `register --nft-gate` does `registerTool` then `setCollections`) must handle partial failure gracefully — print recovery instructions if the second TX fails.
58+
6. **Multi-step CLI flows**: Commands that require multiple onchain transactions must handle partial failure gracefully — print recovery instructions if a subsequent TX fails.
5959

6060
7. **`--dry-run` accuracy**: Dry-run output must reflect the full onchain footprint. If the command sends multiple transactions, the dry-run should mention all of them.
6161

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
11
# @opensea/tool-sdk
22

3+
## 0.7.0
4+
5+
### Minor Changes
6+
7+
- 2391e1e: Add `--predicate-config` flag to `register` command (F4d)
8+
9+
When `--access-predicate <addr>` is supplied, the CLI now:
10+
11+
- Calls `name()` on the predicate to identify its type
12+
- Displays the predicate name in the registration summary
13+
- Accepts `--predicate-config <json>` to bundle predicate setup with registration
14+
- ERC721OwnerPredicate: `--predicate-config '{"collections":["0x..."]}'`
15+
- ERC1155OwnerPredicate: `--predicate-config '{"collection":"0x...","tokenIds":["1","2"]}'`
16+
- Prints a warning if `--access-predicate` is used without `--predicate-config`, explaining that the tool will accept any caller until configured
17+
- Validates `--access-predicate` addresses
18+
19+
- 1be6808: Add `set-collections`, `get-collections`, and `set-collection-tokens` CLI commands (F4c)
20+
21+
- `set-collections <toolId> <addr...>` — set the ERC-721 collection gate list for an already-registered tool
22+
- `get-collections <toolId>` — read the current ERC-721 collection gate list
23+
- `set-collection-tokens <toolId> <addr> <tokenId...>` — set the ERC-1155 collection + token ID gate
24+
- All commands auto-detect registry version and select the matching predicate deployment
25+
- Supports `--dry-run`, `--wallet-provider`, `--rpc-url`, and `--network` options
26+
27+
- 69b30ff: Fix `--nft-gate` broken end-to-end on Base mainnet (F4a)
28+
29+
The SDK hardcoded the v0.2 `ERC721OwnerPredicate` address, which is rejected by the live v0.1 registry on Base. The `register` command now queries the registry's `version()` and selects the matching predicate deployment automatically.
30+
31+
- Re-added `--nft-gate <collection>` to `register` with registry-version-aware predicate selection
32+
- Added `ERC721_OWNER_PREDICATE_V1` deployment constant
33+
- Added `getPredicateForRegistryVersion()` resolver
34+
- Added `registryVersion` option to `PredicateClientConfig`
35+
- Updated `tool-registry/README.md` and `SKILLS.md` with v0.1 predicate addresses
36+
37+
- 2c1e552: Add `--auth siwe` flag to the `pay` CLI command. When set, uses `paidAuthenticatedFetch` (SIWE + x402 payment) instead of payment-only flow. Also auto-enables SIWE auth when `--manifest` points to a manifest with an `access` block.
38+
- 53a49cf: Remove deprecated `nftGate` middleware and `--nft-gate` CLI flag behavior
39+
40+
- Removed `nftGate` middleware (`src/lib/middleware/nft-gate.ts`) and its `NFTGateConfig` type
41+
- Removed `nft` field from `ToolContext.gates` and `BypassGates`
42+
- Re-added `--nft-gate` option to `register` with registry-version-aware predicate selection
43+
- Use `predicateGate` with `--access-predicate` instead for all access gating middleware
44+
45+
**BREAKING:** `nftGate`, `NFTGateConfig`, and `ToolContext.gates.nft` are no longer exported. Migrate to `predicateGate({ toolId })`.
46+
47+
- 91d95ba: Add `SubscriptionPredicateClient` and `CompositePredicateClient` typed clients matching `tool-registry` example predicates. Add missing `CollectionsSet` event to `ERC721OwnerPredicateABI`. Fix stale v0.1 predicate addresses in SKILLS.md examples.
48+
49+
### Patch Changes
50+
51+
- b02f9b0: Treat 4xx probe responses (e.g. 400 from Zod validation) as "endpoint reachable" instead of printing a misleading WARN. Only 5xx responses are flagged as failures.
52+
- cab7a72: Treat 402 with valid `accepts` array as auth-OK in `smoke` command
53+
54+
- When a paywalled tool returns 402 with payment requirements after SIWE auth, `smoke` now exits 0 and prints: "Auth OK — paywall fired (expected for paywalled tools)."
55+
- The `--expect` flag no longer defaults to 200; when omitted, 402-with-accepts is auto-success. When explicitly set, the exact status code is asserted as before.
56+
357
## 0.6.0
458

559
### Minor Changes

README.md

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,14 @@ Register a tool onchain via the ToolRegistry contract.
7979
PRIVATE_KEY=0x... RPC_URL=https://... npx @opensea/tool-sdk register \
8080
--metadata <url> \
8181
--network base \
82-
--nft-gate 0x... # optional: NFT collection for predicate
82+
--access-predicate 0x... # optional: access predicate address
8383
```
8484

8585
| Flag | Description |
8686
|------|-------------|
8787
| `--metadata <url>` | Metadata URI (required) |
8888
| `--network <network>` | `base` or `mainnet` (default: `base`) |
89-
| `--nft-gate <address>` | NFT collection for SimpleNFT721PredicateFactory |
90-
| `--access-predicate <address>` | Manual access predicate address |
89+
| `--access-predicate <address>` | Access predicate address |
9190
| `--dry-run` | Print summary without transacting |
9291
| `-y, --yes` | Skip confirmation prompt |
9392

@@ -161,14 +160,14 @@ npx @opensea/tool-sdk pay https://my-tool.vercel.app/api/tool \
161160
Make an authenticated call to a predicate-gated tool endpoint via SIWE.
162161

163162
```bash
164-
TOOL_SDK_PRIVATE_KEY=0x... npx @opensea/tool-sdk auth https://my-tool.vercel.app/api/tool \
163+
PRIVATE_KEY=0x... RPC_URL=https://mainnet.base.org npx @opensea/tool-sdk auth https://my-tool.vercel.app/api/tool \
165164
--body '{"query":"hello"}'
166165
```
167166

168167
| Flag | Description |
169168
|------|-------------|
170169
| `--body <json>` | JSON body (inline string or `@path/to/file.json`) |
171-
| `--key <hex>` | Wallet private key (defaults to `TOOL_SDK_PRIVATE_KEY` env var) — use env var in production to avoid exposing keys in shell history |
170+
| `--wallet-provider <provider>` | Wallet provider to use for signing |
172171

173172
### `dry-run-gate`
174173

@@ -201,6 +200,39 @@ npx @opensea/tool-sdk dry-run-predicate-gate \
201200
| `--tool-id <id>` | Onchain tool ID to configure in the gate |
202201
| `--input <json>` | JSON input body (inline or `@path`) |
203202

203+
## Wallet Configuration
204+
205+
All commands that sign transactions (`register`, `update-metadata`, `pay`, `auth`, `smoke`) need a wallet. You can configure one in two ways:
206+
207+
1. **Environment variables** — set the env vars for your provider and the CLI auto-detects it (priority: Privy > Fireblocks > Turnkey > Bankr > PrivateKey).
208+
2. **`--wallet-provider` flag** — explicitly select a provider by name.
209+
210+
| Provider | `--wallet-provider` value | Required env vars |
211+
|----------|--------------------------|-------------------|
212+
| Privy | `privy` | `PRIVY_APP_ID`, `PRIVY_APP_SECRET`, `PRIVY_WALLET_ID` |
213+
| Fireblocks | `fireblocks` | `FIREBLOCKS_API_KEY`, `FIREBLOCKS_API_SECRET`, `FIREBLOCKS_VAULT_ID` |
214+
| Turnkey | `turnkey` | `TURNKEY_API_PUBLIC_KEY`, `TURNKEY_API_PRIVATE_KEY`, `TURNKEY_ORGANIZATION_ID`, `TURNKEY_WALLET_ADDRESS`, `TURNKEY_RPC_URL` |
215+
| Bankr | `bankr` | `BANKR_API_KEY` |
216+
| Private Key | `private-key` | `PRIVATE_KEY`, `RPC_URL` |
217+
218+
See [`.env.example`](.env.example) for a full annotated template.
219+
220+
### Examples
221+
222+
```bash
223+
# Auto-detect from env vars (simplest)
224+
PRIVATE_KEY=0x... RPC_URL=https://mainnet.base.org npx @opensea/tool-sdk register \
225+
--metadata <url> --network base
226+
227+
# Explicit provider selection
228+
BANKR_API_KEY=... npx @opensea/tool-sdk register \
229+
--metadata <url> --network base --wallet-provider bankr
230+
231+
# Privy server wallet
232+
PRIVY_APP_ID=... PRIVY_APP_SECRET=... PRIVY_WALLET_ID=... npx @opensea/tool-sdk auth \
233+
https://my-tool.vercel.app/api/tool --body '{"query":"hello"}'
234+
```
235+
204236
## Library API
205237

206238
### `defineManifest(manifest)`
@@ -256,7 +288,7 @@ const handler = createToolHandler({
256288
manifest,
257289
inputSchema: z.object({ query: z.string() }),
258290
outputSchema: z.object({ result: z.string() }),
259-
gates: [], // optional: nftGate, x402Gate
291+
gates: [], // optional: predicateGate, x402Gate
260292
handler: async (input, ctx) => {
261293
return { result: `Hello: ${input.query}` }
262294
},
@@ -414,46 +446,6 @@ if (ok && granted) {
414446
`ok === false` means the predicate misbehaved upstream and the result is
415447
indeterminate; treat it as a transient failure, not a denial.
416448

417-
### NFT Gate (deprecated)
418-
419-
> **Deprecated.** Prefer `predicateGate` for any tool registered against the
420-
> canonical `ToolRegistry`. `nftGate` re-implements ERC-721 ownership
421-
> off-chain against a single hardcoded collection address, which means the
422-
> off-chain policy can drift from the onchain `accessPredicate` and
423-
> multi-collection / non-ERC-721 access models require parallel
424-
> implementations. Use `nftGate` only for local development and unregistered
425-
> tools where you do not yet have a `toolId`.
426-
427-
Requires callers to hold an ERC-721 NFT. Uses SIWE (Sign-In with Ethereum) for address verification.
428-
429-
```typescript
430-
import { nftGate } from "@opensea/tool-sdk"
431-
432-
const gate = nftGate({
433-
collection: "0x1234...5678", // ERC-721 on Base
434-
rpcUrl: "https://mainnet.base.org", // optional
435-
})
436-
437-
const handler = createToolHandler({
438-
manifest,
439-
inputSchema,
440-
outputSchema,
441-
gates: [gate],
442-
handler: async (input, ctx) => {
443-
// ctx.callerAddress is set on success
444-
// ctx.gates.nft.granted === true
445-
return { result: "access granted" }
446-
},
447-
})
448-
```
449-
450-
Authorization header format: `SIWE <base64url(siwe-message)>.<hex-signature>`
451-
452-
> **Note:** The NFT gate is stateless and does not track nonces. Callers should
453-
> include a short-lived `expirationTime` in their SIWE messages to limit replay
454-
> window. Tool operators requiring stronger replay protection should implement
455-
> server-side nonce tracking.
456-
457449
### x402 Gate (hosted facilitator)
458450

459451
The SDK ships two hosted-facilitator gates with the same shape:

0 commit comments

Comments
 (0)