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 ¶
- func ParseVertex(data json.RawMessage) (*dag.Vertex, error)
- type Adapter
- func (a *Adapter) Call(ctx context.Context, method string, params any, out any) error
- func (a *Adapter) Client() *http.Client
- func (a *Adapter) Endpoint() string
- func (a *Adapter) GetRecentVertices(ctx context.Context, limit int) ([]json.RawMessage, error)
- func (a *Adapter) GetVertexByID(ctx context.Context, id string) (json.RawMessage, error)
- func (a *Adapter) MethodPrefix() string
- func (a *Adapter) ParseVertex(data json.RawMessage) (*dag.Vertex, error)
- type Error
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 ¶
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 ¶
Call is the generic JSON-RPC 2.0 request helper. Chain-specific adapters invoke this for their custom methods.
func (*Adapter) Client ¶
Client exposes the underlying http.Client so chain-specific adapters can reuse it for custom RPCs without opening a second pool.
func (*Adapter) GetRecentVertices ¶
GetRecentVertices fetches the N most recent vertices.
func (*Adapter) GetVertexByID ¶
GetVertexByID fetches a specific vertex by ID.
func (*Adapter) MethodPrefix ¶
MethodPrefix returns the JSON-RPC method prefix (e.g. "aivm").
func (*Adapter) ParseVertex ¶
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.