mirror of
https://github.com/hanzoai/bootnode.git
synced 2026-09-30 20:46:32 +00:00
Adds a Go subsystem alongside the existing Python FastAPI service so
bootnode can fold into `superbase` per HIP-0106. The Python service in
`api/bootnode/` stays untouched.
What landed:
- `schema/bootnode.zap` — public typed surface (chains, RPC, tokens,
NFTs, transfers, smart wallets, ERC-4337, gas, webhooks, fleets,
nodes, usage). No `.capnp` anywhere — ZAP only, per brand policy.
- `zap/gen/` — hand-rolled Go bindings that match what `zapc generate`
emits, so `go build` works without zapc installed locally.
- `api/mount.go` — the HIP-0106 contract:
func Mount(r chi.Router, deps Deps) error
mounts every FastAPI-parity route group through `api/handlers/`.
- `api/deps.go` — cross-subsystem ZAP client interfaces (IAM, KMS,
Base, O11y, Commerce). No business logic, no hard imports — keeps
the Bootnode module independent of sibling subsystems until they
ship their typed clients.
- `api/handlers/` — 149 chi routes mounted (Python has 150). Each
handler body is a 501 stub with a `TODO(bootnode-port)` pointing at
the Python file + symbol to port.
- `api/middleware/` — IAM-backed auth, OTEL-friendly telemetry,
per-org rate limit (stub).
- `api/store/` — per-tenant SQLite access via `deps.Base.Open(orgID,
"bootnode")` per HIP-0302.
- `api/web3/` — chain registry + RPC pool surface (production version
prefers luxfi/* over upstream go-ethereum).
- `cmd/bootnode/main.go` — standalone shim; same `api.Mount` superbase
calls in production.
- `docs/PYTHON_TO_GO_PORT.md` — endpoint-by-endpoint port map.
Build: `go build ./...` and `go vet ./...` clean. Standalone shim
smokes 200 on /health, /ready, /v1/chains; 401 on auth-required
endpoints with no JWT; 501 on every TODO route.
Out of scope (not in this commit):
- Handler bodies (Phase 2 — porting in RPC → tokens → NFTs → ...
priority order).
- superbase wiring (lands when the superbase repo opens its main).
- Python service removal (stays until handlers reach prod parity).
84 lines
3.2 KiB
Go
84 lines
3.2 KiB
Go
package handlers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
// MountWallets registers /v1/wallets/* — ERC-4337 smart account API.
|
|
func MountWallets(r chi.Router, _ Deps) {
|
|
r.Route("/wallets", func(r chi.Router) {
|
|
r.Post("/create", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/wallets/__init__.py:create —
|
|
// keccak256 CREATE2 address (NOT sha256). See LLM.md "Phase 3" notes.
|
|
stub(w, "wallets/create")
|
|
})
|
|
r.Get("/", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/wallets/__init__.py:list
|
|
stub(w, "wallets list")
|
|
})
|
|
r.Get("/{address}", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/wallets/__init__.py:get
|
|
stub(w, "wallets/{address}")
|
|
})
|
|
r.Post("/{address}/estimate", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/wallets/__init__.py:estimate
|
|
stub(w, "wallets/{address}/estimate")
|
|
})
|
|
r.Get("/{address}/nonce", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/wallets/__init__.py:nonce
|
|
stub(w, "wallets/{address}/nonce")
|
|
})
|
|
_ = chi.URLParam
|
|
})
|
|
}
|
|
|
|
// MountBundler registers /v1/bundler/{chain} — ERC-4337 RPC entrypoint.
|
|
func MountBundler(r chi.Router, _ Deps) {
|
|
r.Route("/bundler", func(r chi.Router) {
|
|
r.Post("/{chain}", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/bundler/__init__.py:rpc —
|
|
// implements eth_sendUserOperation / eth_estimateUserOperationGas / etc.
|
|
stub(w, "bundler/{chain}")
|
|
})
|
|
r.Post("/{chain}/{network}", func(w http.ResponseWriter, _ *http.Request) {
|
|
stub(w, "bundler/{chain}/{network}")
|
|
})
|
|
})
|
|
}
|
|
|
|
// MountGas registers /v1/gas/* — gas prices + paymaster policies.
|
|
func MountGas(r chi.Router, _ Deps) {
|
|
r.Route("/gas", func(r chi.Router) {
|
|
r.Get("/{chain}/prices", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/gas/__init__.py:prices
|
|
stub(w, "gas/{chain}/prices")
|
|
})
|
|
r.Post("/sponsor", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/gas/__init__.py:sponsor
|
|
stub(w, "gas/sponsor")
|
|
})
|
|
r.Post("/estimate", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/gas/__init__.py:estimate
|
|
stub(w, "gas/estimate")
|
|
})
|
|
r.Get("/policies", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/gas/__init__.py:list_policies
|
|
stub(w, "gas/policies GET")
|
|
})
|
|
r.Post("/policies", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/gas/__init__.py:create_policy
|
|
stub(w, "gas/policies POST")
|
|
})
|
|
r.Get("/policies/{id}", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/gas/__init__.py:get_policy
|
|
stub(w, "gas/policies/{id}")
|
|
})
|
|
r.Delete("/policies/{id}", func(w http.ResponseWriter, _ *http.Request) {
|
|
// TODO(bootnode-port): port from bootnode/api/gas/__init__.py:delete_policy
|
|
stub(w, "gas/policies/{id} DELETE")
|
|
})
|
|
})
|
|
}
|