Documentation
¶
Overview ¶
Package client provides thin HTTP clients for Heimdall's REST gateway and CometBFT JSON-RPC endpoint.
Neither client decodes response bodies. They return raw bytes and leave unmarshalling to the caller so subcommands can choose between typed decode (for rendered output) and direct JSON passthrough (for --json / --field).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CurlTransport ¶
CurlTransport replaces the HTTP call with an equivalent `curl` command dumped to Out. Last printed curl is also captured for tests.
type HTTPError ¶
HTTPError is returned when the Heimdall node responds with a non-2xx status. Body is the raw response body; StatusCode is the HTTP code.
type HTTPTransport ¶
HTTPTransport is the default Transport: it forwards to an *http.Client.
type NetworkError ¶
type NetworkError struct {
Err error
}
NetworkError marks transport-level failures (DNS, TCP reset, TLS handshake, etc.).
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
type RESTClient ¶
RESTClient wraps net/http for Heimdall's REST gateway.
func NewRESTClient ¶
func NewRESTClient(base string, timeout time.Duration, headers map[string]string, insecure bool) *RESTClient
NewRESTClient returns a RESTClient configured from the resolved config.
type RPCClient ¶
type RPCClient struct {
BaseURL string
Headers map[string]string
Transport Transport
// contains filtered or unexported fields
}
RPCClient is a CometBFT JSON-RPC client.
func NewRPCClient ¶
func NewRPCClient(base string, timeout time.Duration, headers map[string]string, insecure bool) *RPCClient
NewRPCClient returns an RPCClient configured from the resolved config.
func (*RPCClient) Call ¶
func (c *RPCClient) Call(ctx context.Context, method string, params map[string]any) (json.RawMessage, error)
Call issues a JSON-RPC call with the given method and params and returns the raw `result` field. Returns *RPCError on a JSON-RPC error, *HTTPError on HTTP 4xx/5xx, or *NetworkError on transport failures.
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data string `json:"data,omitempty"`
}
RPCError represents a JSON-RPC error payload.
type RPCRequest ¶
type RPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID uint64 `json:"id"`
Method string `json:"method"`
Params map[string]any `json:"params,omitempty"`
}
RPCRequest is the JSON-RPC 2.0 envelope used by CometBFT.
type RPCResponse ¶
type RPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID uint64 `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
}
RPCResponse is the JSON-RPC 2.0 response envelope.
type Transport ¶
type Transport interface {
// Do performs the request and returns the response body, status
// code, and error. Implementations must honour req.Context().
Do(req *http.Request) ([]byte, int, error)
}
Transport abstracts how a request is carried out so that --curl can short-circuit execution and emit the equivalent command instead.
type UsageError ¶
type UsageError struct {
Msg string
}
UsageError marks a caller-side mistake (bad flag, bad argument).
func (*UsageError) Error ¶
func (e *UsageError) Error() string