node

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: MIT Imports: 11 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustNewClient

func MustNewClient(config *Config, logger framework.Logger) *client

MustNewClient instantiates a new client, with fatal exit on error

func NewClient

func NewClient(cfg *Config, logger framework.Logger) (*client, error)

NewClient instantiates a new client

Types

type BlockReceiptResponse

type BlockReceiptResponse struct {
	Jsonrpc string            `json:"jsonrpc"`
	Id      int               `json:"id"`
	Result  []json.RawMessage `json:"result"`
	Error   interface{}       `json:"error"`
}

BlockReceiptResponse is a raw block receipts result from a node client

type BlockResponse

type BlockResponse struct {
	Jsonrpc string          `json:"jsonrpc"`
	Id      int             `json:"id"`
	Result  json.RawMessage `json:"result"`
	Error   interface{}     `json:"error"`
}

BlockResponse is a raw node client result for a block

type Client

type Client interface {
	GetLatestBlockNumber(ctx context.Context) (uint64, error)
	GetBlockByNumber(ctx context.Context, blockNumber uint64) (*BlockResponse, error)
	GetTracesForBlock(ctx context.Context, blockNumber uint64) (*TraceResponse, error)
	GetBlockReceipt(ctx context.Context, blockNumber uint64) (*BlockReceiptResponse, error)
	GetTransactionReceipt(ctx context.Context, txHash string) (*TxReceiptResponse, error)
	CodeAt(ctx context.Context, address string) (*CodeAtResponse, error)
	GetEthClient() *ethclient.Client
}

type CodeAtResponse added in v0.0.4

type CodeAtResponse struct {
	Jsonrpc string          `json:"jsonrpc"`
	Id      int             `json:"id"`
	Result  json.RawMessage `json:"result"`
	Error   interface{}     `json:"error"`
}

CodeAtResponse is a contract code result from a node client

type Config

type Config struct {
	Blockchain constants.Blockchain `env:"BLOCKCHAIN,required"`
	NodeHost   string               `env:"NODE_HOST,required"`
	RPCTimeout time.Duration        `env:"RPC_TIMEOUT" envDefault:"300s"`
	RPCRetries int                  `env:"RPC_RETRIES" envDefault:"2"`
}

Config holds configurable properties for node client

func MustParseConfig

func MustParseConfig(logger util.Logger) *Config

MustParseConfig parses config from env vars, with fatal exit on error

func ParseConfig

func ParseConfig() (*Config, error)

ParseConfig parses config from env vars

type TraceResponse

type TraceResponse struct {
	Jsonrpc string        `json:"jsonrpc"`
	Id      int           `json:"id"`
	Result  []TraceResult `json:"result"`
	Error   interface{}   `json:"error"`
}

TraceResponse is a raw node client result for getting traces

type TraceResult

type TraceResult struct {
	Result json.RawMessage `json:"result"`
	Error  interface{}     `json:"error"`
}

TraceResult is a single trace object

type TxReceiptResponse

type TxReceiptResponse struct {
	Jsonrpc string          `json:"jsonrpc"`
	Id      int             `json:"id"`
	Result  json.RawMessage `json:"result"`
	Error   interface{}     `json:"error"`
}

TxReceiptResponse is a raw tx receipts result from a node client

Jump to

Keyboard shortcuts

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