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).
47 lines
2.2 KiB
Go
47 lines
2.2 KiB
Go
// Package web3 wraps chain configuration + multi-chain RPC plumbing.
|
|
//
|
|
// The HTTP layer asks this package for canonical chain data; the RPC
|
|
// proxy fans out through a pool defined in client.go. luxfi/* packages
|
|
// are preferred for any chain library imports (see ~/.claude/CLAUDE.md).
|
|
package web3
|
|
|
|
// ChainInfo is the canonical per-chain record exposed at /v1/chains.
|
|
// Mirrors bootnode/core/chains/registry.py.
|
|
type ChainInfo struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
ChainID int64 `json:"chainId"`
|
|
IsEVM bool `json:"isEvm"`
|
|
Currency string `json:"currency"`
|
|
Explorer string `json:"explorer"`
|
|
}
|
|
|
|
// allChains is the initial static set; production reads from
|
|
// deps.Base ("registry" table) so customers can add custom chains.
|
|
//
|
|
// TODO(bootnode-port): hydrate from bootnode/core/chains/registry.py
|
|
// (CHAIN_REGISTRY) at startup; allow per-org overrides.
|
|
var allChains = []ChainInfo{
|
|
{ID: "ethereum", Name: "Ethereum", ChainID: 1, IsEVM: true, Currency: "ETH", Explorer: "https://etherscan.io"},
|
|
{ID: "polygon", Name: "Polygon", ChainID: 137, IsEVM: true, Currency: "MATIC", Explorer: "https://polygonscan.com"},
|
|
{ID: "arbitrum", Name: "Arbitrum One", ChainID: 42161, IsEVM: true, Currency: "ETH", Explorer: "https://arbiscan.io"},
|
|
{ID: "optimism", Name: "Optimism", ChainID: 10, IsEVM: true, Currency: "ETH", Explorer: "https://optimistic.etherscan.io"},
|
|
{ID: "base", Name: "Base", ChainID: 8453, IsEVM: true, Currency: "ETH", Explorer: "https://basescan.org"},
|
|
{ID: "bsc", Name: "BNB Chain", ChainID: 56, IsEVM: true, Currency: "BNB", Explorer: "https://bscscan.com"},
|
|
{ID: "avalanche", Name: "Avalanche C-Chain", ChainID: 43114, IsEVM: true, Currency: "AVAX", Explorer: "https://snowtrace.io"},
|
|
{ID: "lux", Name: "Lux Network", ChainID: 96369, IsEVM: true, Currency: "LUX", Explorer: "https://explore.lux.network"},
|
|
}
|
|
|
|
// AllChains returns every chain Bootnode currently knows about.
|
|
func AllChains() []ChainInfo { return append([]ChainInfo(nil), allChains...) }
|
|
|
|
// ChainByName looks up one chain by its kebab-cased ID.
|
|
func ChainByName(id string) (ChainInfo, bool) {
|
|
for _, c := range allChains {
|
|
if c.ID == id {
|
|
return c, true
|
|
}
|
|
}
|
|
return ChainInfo{}, false
|
|
}
|