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).
102 lines
5.1 KiB
Go
102 lines
5.1 KiB
Go
package handlers
|
|
|
|
import (
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
// MountTeam registers /v1/team/* — org-scoped membership admin.
|
|
func MountTeam(r chi.Router, _ Deps) {
|
|
r.Route("/team", func(r chi.Router) {
|
|
r.Get("/", stubHandler("team GET", "list_members"))
|
|
r.Post("/", stubHandler("team POST", "invite_member"))
|
|
r.Patch("/{member_id}", stubHandler("team/{id} PATCH", "update_member"))
|
|
r.Delete("/{member_id}", stubHandler("team/{id} DELETE", "remove_member"))
|
|
})
|
|
}
|
|
|
|
// MountNetworks registers /v1/networks/* — managed network lifecycle.
|
|
func MountNetworks(r chi.Router, _ Deps) {
|
|
r.Route("/networks", func(r chi.Router) {
|
|
r.Post("/", stubHandler("networks POST", "create_network"))
|
|
r.Get("/", stubHandler("networks GET", "list_networks"))
|
|
r.Get("/{network_id}", stubHandler("networks/{id}", "get_network"))
|
|
r.Post("/{network_id}/scale", stubHandler("networks/{id}/scale", "scale_network"))
|
|
r.Delete("/{network_id}", stubHandler("networks/{id} DELETE", "delete_network"))
|
|
})
|
|
}
|
|
|
|
// MountObservability registers /v1/o11y/*. The actual telemetry pipe
|
|
// belongs to the O11y subsystem — these endpoints are the
|
|
// query/control plane Bootnode exposes for its own dashboards.
|
|
func MountObservability(r chi.Router, _ Deps) {
|
|
r.Route("/o11y", func(r chi.Router) {
|
|
r.Get("/health", stubHandler("o11y/health", "platform_health"))
|
|
r.Get("/metrics", stubHandler("o11y/metrics", "list_metrics"))
|
|
r.Get("/metrics/{service}", stubHandler("o11y/metrics/{service}", "service_metrics"))
|
|
r.Get("/alerts", stubHandler("o11y/alerts GET", "list_alerts"))
|
|
r.Post("/alerts", stubHandler("o11y/alerts POST", "create_alert"))
|
|
r.Get("/service-map", stubHandler("o11y/service-map", "service_map"))
|
|
r.Get("/logs", stubHandler("o11y/logs", "query_logs"))
|
|
r.Get("/events", stubHandler("o11y/events", "query_events"))
|
|
})
|
|
}
|
|
|
|
// MountChat registers /v1/chat/* — AI inference passthrough. Routes
|
|
// forward to deps.LLMGateway in production; stubbed in skeleton.
|
|
func MountChat(r chi.Router, _ Deps) {
|
|
r.Route("/chat", func(r chi.Router) {
|
|
r.Post("/completions", stubHandler("chat/completions", "completions"))
|
|
r.Get("/models", stubHandler("chat/models", "list_models"))
|
|
})
|
|
}
|
|
|
|
// MountBilling registers /v1/billing/* — usage, quota, invoices,
|
|
// checkout. Payment processing belongs to Commerce; Bootnode just
|
|
// reports usage and reads back per-org tiers.
|
|
func MountBilling(r chi.Router, _ Deps) {
|
|
r.Route("/billing", func(r chi.Router) {
|
|
r.Get("/usage", stubHandler("billing/usage", "get_usage"))
|
|
r.Get("/usage/summary", stubHandler("billing/usage/summary", "usage_summary"))
|
|
r.Get("/subscription", stubHandler("billing/subscription", "get_subscription"))
|
|
r.Post("/subscription/upgrade", stubHandler("billing/subscription/upgrade", "upgrade"))
|
|
r.Post("/subscription/downgrade", stubHandler("billing/subscription/downgrade", "downgrade"))
|
|
r.Get("/invoices", stubHandler("billing/invoices", "list_invoices"))
|
|
r.Get("/tiers", stubHandler("billing/tiers", "list_tiers"))
|
|
r.Get("/tiers/{tier_name}", stubHandler("billing/tiers/{name}", "get_tier"))
|
|
r.Get("/limits", stubHandler("billing/limits", "get_limits"))
|
|
r.Post("/checkout", stubHandler("billing/checkout", "checkout"))
|
|
r.Post("/checkout/capture/{order_id}", stubHandler("billing/checkout/capture", "capture"))
|
|
r.Post("/webhooks/commerce", stubHandler("billing/webhooks/commerce", "commerce_webhook"))
|
|
r.Post("/sync", stubHandler("billing/sync POST", "sync_usage"))
|
|
r.Get("/sync/status", stubHandler("billing/sync/status", "sync_status"))
|
|
r.Get("/account", stubHandler("billing/account GET", "get_account"))
|
|
r.Get("/account/subscriptions", stubHandler("billing/account/subscriptions", "account_subscriptions"))
|
|
r.Get("/account/invoices", stubHandler("billing/account/invoices", "account_invoices"))
|
|
r.Get("/account/payment-methods", stubHandler("billing/account/payment-methods", "account_methods"))
|
|
r.Post("/account/sync", stubHandler("billing/account/sync", "account_sync"))
|
|
r.Post("/cloud/authorize", stubHandler("billing/cloud/authorize", "cloud_authorize"))
|
|
r.Get("/cloud/quota", stubHandler("billing/cloud/quota", "cloud_quota"))
|
|
r.Post("/cloud/usage", stubHandler("billing/cloud/usage", "cloud_record_usage"))
|
|
r.Get("/cloud/tiers", stubHandler("billing/cloud/tiers", "cloud_tiers"))
|
|
})
|
|
}
|
|
|
|
// MountZAP registers /v1/zap/* — discovery endpoints for the native
|
|
// ZAP protocol. The wire-level RPC server lives in superbase; these
|
|
// HTTP endpoints describe the schema + tools list to clients.
|
|
//
|
|
// We keep the path names but do NOT serve a .capnp file — public
|
|
// surface is .zap only (brand policy).
|
|
func MountZAP(r chi.Router, _ Deps) {
|
|
r.Route("/zap", func(r chi.Router) {
|
|
r.Get("/connect", stubHandler("zap/connect", "connect_info"))
|
|
r.Get("/info", stubHandler("zap/info", "server_info"))
|
|
r.Get("/tools", stubHandler("zap/tools", "list_tools"))
|
|
r.Get("/resources", stubHandler("zap/resources", "list_resources"))
|
|
r.Get("/health", stubHandler("zap/health", "zap_health"))
|
|
r.Get("/schema", stubHandler("zap/schema", "serve_schema"))
|
|
// schema.capnp endpoint is deliberately NOT mounted — ZAP-only public surface.
|
|
})
|
|
_ = chi.URLParam
|
|
}
|