Skip to content

Commit 92490af

Browse files
committed
Sync from opensea-devtools
1 parent f95cd6c commit 92490af

106 files changed

Lines changed: 11093 additions & 20 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Tool SDK — Environment Variables
2+
# Copy to .env and fill in the values you need.
3+
4+
# =============================================================================
5+
# Wallet signing — pick ONE provider for onchain operations (register, update)
6+
# =============================================================================
7+
8+
# --- Option A: Privy (default, recommended) ---
9+
# PRIVY_APP_ID= # https://dashboard.privy.io
10+
# PRIVY_APP_SECRET=
11+
# PRIVY_WALLET_ID=
12+
13+
# --- Option B: Turnkey (HSM-backed) ---
14+
# TURNKEY_API_PUBLIC_KEY= # https://app.turnkey.com
15+
# TURNKEY_API_PRIVATE_KEY= # hex-encoded P-256 private key
16+
# TURNKEY_ORGANIZATION_ID=
17+
# TURNKEY_WALLET_ADDRESS=
18+
# TURNKEY_RPC_URL= # required — RPC endpoint for gas estimation and tx broadcast
19+
20+
# --- Option C: Fireblocks (enterprise MPC) ---
21+
# FIREBLOCKS_API_KEY= # https://www.fireblocks.com
22+
# FIREBLOCKS_API_SECRET= # RSA PEM key from Fireblocks console
23+
# FIREBLOCKS_VAULT_ID=
24+
# FIREBLOCKS_ASSET_ID= # optional — override auto-detected asset ID
25+
# FIREBLOCKS_MAX_POLL_ATTEMPTS= # optional — max poll attempts for tx confirmation (default: 60)
26+
27+
# --- Option D: Raw Private Key (local dev only, NOT recommended) ---
28+
# PRIVATE_KEY= # hex-encoded — no spending limits or guardrails
29+
# RPC_URL= # RPC endpoint for the target chain

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build-and-test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
- uses: actions/setup-node@v6
15+
with:
16+
node-version-file: .nvmrc
17+
- run: npm install
18+
- run: npm run build
19+
- run: npm run lint
20+
- run: npm run type-check
21+
- run: npm test
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish npm package
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
build-before-publish:
7+
description: Run build and test before publishing
8+
type: boolean
9+
default: true
10+
stub-package-dir:
11+
description: Path to stub package directory (e.g. packages/opensea-js-stub)
12+
type: string
13+
default: ""
14+
node-version-file:
15+
description: Path to node version file
16+
type: string
17+
default: .nvmrc
18+
secrets:
19+
OPENSEA_API_KEY:
20+
required: false
21+
ALCHEMY_API_KEY:
22+
required: false
23+
24+
jobs:
25+
publish-npm:
26+
runs-on: ubuntu-latest
27+
permissions:
28+
id-token: write
29+
contents: read
30+
steps:
31+
- uses: actions/checkout@v6
32+
- uses: actions/setup-node@v6
33+
with:
34+
node-version-file: ${{ inputs.node-version-file }}
35+
registry-url: https://registry.npmjs.org/
36+
37+
# Use npm install (not npm ci) because the package-lock.json may be
38+
# out of sync after the sync-package workflow resolves workspace: protocols
39+
# and updates dependencies. npm ci requires exact lockfile match.
40+
#
41+
# --legacy-peer-deps mirrors pnpm's permissive peer-dep behavior used in the
42+
# monorepo. Without it, packages like api-types fail on openapi-typescript@^7
43+
# which declares a strict `typescript@^5.x` peer while we ship typescript@^6.
44+
- run: npm install --legacy-peer-deps
45+
46+
- if: ${{ inputs.build-before-publish }}
47+
run: npm run build
48+
49+
- if: ${{ inputs.build-before-publish }}
50+
run: npm test
51+
env:
52+
OPENSEA_API_KEY: ${{ secrets.OPENSEA_API_KEY }}
53+
ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }}
54+
55+
- run: npm publish --provenance --access public
56+
57+
- if: ${{ inputs.stub-package-dir != '' }}
58+
run: npm publish --provenance --access public
59+
working-directory: ${{ inputs.stub-package-dir }}
60+
continue-on-error: true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24.14.1

AGENTS.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# tool-sdk — Agent Conventions
2+
3+
TypeScript SDK and CLI for building ERC-XXXX compliant AI agent tools.
4+
5+
## Quick Reference
6+
7+
```bash
8+
cd packages/tool-sdk
9+
pnpm install
10+
pnpm run build # Build with tsup
11+
pnpm run test # Run tests with Vitest
12+
pnpm run lint # Lint with Biome
13+
pnpm run format # Format with Biome
14+
pnpm run type-check # TypeScript type checking
15+
```
16+
17+
## Architecture
18+
19+
| Path | Role |
20+
|------|------|
21+
| `src/index.ts` | Library entry point — public `tool-sdk` exports |
22+
| `src/cli.ts` | CLI entry point (Commander program wiring) |
23+
| `src/types.ts` | Shared public types |
24+
| `src/cli/commands/` | CLI commands: `register`, `validate`, `verify`, `hash`, `init` |
25+
| `src/lib/onchain/abis.ts` | TypeScript ABI definitions mirroring Solidity interfaces |
26+
| `src/lib/onchain/chains.ts` | Deployed contract addresses per chain |
27+
| `src/lib/onchain/registry.ts` | `ToolRegistryClient` — onchain interaction wrapper |
28+
| `src/lib/onchain/hash.ts` | JCS keccak256 manifest hashing |
29+
| `src/lib/manifest/` | Manifest schema, validation, types |
30+
| `src/lib/handler/` | `createToolHandler` — Web Request/Response handler factory |
31+
| `src/lib/middleware/` | Gating middleware (NFT gate, x402, well-known endpoint) |
32+
| `src/lib/wallet/` | Re-exports from `@opensea/wallet-adapters` (adapters, types, and viem bridge) |
33+
| `src/lib/adapters/` | Framework adapters (Vercel, Cloudflare, Express) |
34+
| `src/lib/utils.ts` | Shared utilities used across `lib/` |
35+
| `src/templates/` | Scaffolding templates for `init` command |
36+
| `src/__tests__/` | Vitest test suite |
37+
38+
## Review Checklist
39+
40+
When reviewing changes to this package, verify:
41+
42+
1. **ABI completeness**: `abis.ts` must include every function and event from the corresponding Solidity interfaces in `../tool-registry/src/interfaces/`. If the Solidity interface adds a function, `abis.ts` must add it too. Missing ABI entries mean SDK consumers cannot call those functions.
43+
44+
2. **Address sync**: Addresses in `chains.ts` must match `../tool-registry/README.md`. After a new deploy, both files must be updated together.
45+
46+
3. **Dead code after refactors**: When removing features (e.g., dropping a predicate factory), verify that all related imports, constants, and references are also removed. Check for unused imports at the top of refactored files.
47+
48+
4. **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.
49+
50+
5. **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.
51+
52+
6. **`--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.
53+
54+
## Conventions
55+
56+
- ESM-only (`"type": "module"`). Use `.js` extensions in import paths.
57+
- Biome for linting and formatting: double quotes, 2-space indent, trailing commas.
58+
- `as const` on all ABI definitions for type narrowing with viem.
59+
- CLI commands use Commander.js. Wallet is configured via `--wallet-provider` flag or env vars (see `.env.example`).
60+
- `ToolRegistryClient` wraps viem `PublicClient` and `WalletClient` — all onchain reads/writes go through it.

LICENSE

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
1-
MIT License
1+
Copyright 2026 Ozone Networks, Inc.
22

3-
Copyright (c) 2026 OpenSea
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
116

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)