Documentation
¶
Overview ¶
Package client speaks JSON-RPC 2.0 to an Ethereum execution-layer node over WebSocket. It implements the small surface juno needs to follow the L1 head and serve starknet_getMessageStatus.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) BlockNumber(ctx context.Context) (uint64, error)
- func (c *Client) Call(ctx context.Context, method string, params ...any) (json.RawMessage, error)
- func (c *Client) ChainID(ctx context.Context) (*big.Int, error)
- func (c *Client) Close()
- func (c *Client) FilterLogs(ctx context.Context, q FilterQuery) ([]eth.Log, error)
- func (c *Client) HeaderByNumber(ctx context.Context, tag string) (eth.Header, error)
- func (c *Client) SubscribeLogs(ctx context.Context, q FilterQuery, sink chan<- *eth.Log) (Subscription, error)
- func (c *Client) TransactionReceipt(ctx context.Context, txHash eth.Hash) (eth.Receipt, error)
- type FilterQuery
- type Option
- type Subscription
Constants ¶
const BlockFinalized = "finalized"
Variables ¶
var ErrClosed = errors.New("client closed")
ErrClosed is terminal: the client was explicitly closed and will not redial.
var ErrSubscriptionQueueOverflow = errors.New("subscription queue overflow (slow subscriber)")
ErrSubscriptionQueueOverflow fails a subscription whose sink is not drained fast enough, matching go-ethereum's behaviour.
var ErrTransportClosed = errors.New("transport closed")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) FilterLogs ¶
func (*Client) HeaderByNumber ¶
HeaderByNumber maps a null result — the server's signal for "the named block does not exist yet" — to eth.ErrNotFound.
func (*Client) SubscribeLogs ¶
func (c *Client) SubscribeLogs( ctx context.Context, q FilterQuery, sink chan<- *eth.Log, ) (Subscription, error)
SubscribeLogs uses ctx only for the subscribe call itself; the sub lives until Unsubscribe or a transport failure.
type FilterQuery ¶
type FilterQuery struct {
FromBlock *uint64
ToBlock *uint64
Addresses []eth.Address
// Topics is position-major: Topics[i] is the allowed-set at topic
// position i (OR'd together); empty means "any value at that position".
Topics [][]eth.Hash
}
FilterQuery selects logs by inclusive block range, contract address, and topics. A nil FromBlock/ToBlock is omitted from the wire: geth treats an explicit toBlock as a bounded historical filter, which would break live eth_subscribe subscriptions.
func (FilterQuery) MarshalJSON ¶
func (q FilterQuery) MarshalJSON() ([]byte, error)
type Option ¶
type Option func(*options)
func WithDialTimeout ¶
func WithLogger ¶
func WithLogger(l log.StructuredLogger) Option
func WithPingConfig ¶
WithPingConfig falls back to the defaults (30s/10s) for non-positive values.
type Subscription ¶
type Subscription interface {
Err() <-chan error
Unsubscribe()
}
Subscription mirrors go-ethereum's event.Subscription, as a drop-in for callers migrating off that package.