rpcadapter

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package rpcadapter provides the shared JSON-RPC plumbing used by every chain-specific DAG adapter (ai, bridge, key, mpc, oracle, quantum, threshold, zk, ...). One implementation of the generic Vertex shape, one implementation of the request/response dance — each chain adapter embeds Adapter and adds only its chain-specific extras.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseVertex

func ParseVertex(data json.RawMessage) (*dag.Vertex, error)

ParseVertex parses a generic DAG vertex. Exposed as a free function so chain adapters can reuse it from their own ParseVertex overrides.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter is the shared JSON-RPC adapter. Every DAG chain's adapter package embeds this type and provides its method prefix (e.g. "aivm", "bvm", "xvm", "mvm"). The two generic RPCs — getRecentVertices and getVertex — dispatch via the prefix.

func New

func New(rpcEndpoint, methodPrefix string) *Adapter

New constructs an Adapter for the given RPC endpoint and JSON-RPC method prefix (without the dot). For example, methodPrefix="aivm" dispatches to "aivm.getRecentVertices" and "aivm.getVertex".

func (*Adapter) Call

func (a *Adapter) Call(ctx context.Context, method string, params any, out any) error

Call is the generic JSON-RPC 2.0 request helper. Chain-specific adapters invoke this for their custom methods.

func (*Adapter) Client

func (a *Adapter) Client() *http.Client

Client exposes the underlying http.Client so chain-specific adapters can reuse it for custom RPCs without opening a second pool.

func (*Adapter) Endpoint

func (a *Adapter) Endpoint() string

Endpoint returns the configured RPC endpoint (for logging / tests).

func (*Adapter) GetRecentVertices

func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)

GetRecentVertices fetches the N most recent vertices.

func (*Adapter) GetVertexByID

func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)

GetVertexByID fetches a specific vertex by ID.

func (*Adapter) MethodPrefix

func (a *Adapter) MethodPrefix() string

MethodPrefix returns the JSON-RPC method prefix (e.g. "aivm").

func (*Adapter) ParseVertex

func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)

ParseVertex parses a generic DAG vertex from the RPC response. Chain- specific adapters that need extra metadata should override this by wrapping the result and copying fields.

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error is the JSON-RPC 2.0 error object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL