ethrpc

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StandardABISerializer

func StandardABISerializer() *abi.Serializer

The serializer we should use in all places that go from ABI validated data, back down to JSON that might be: 1) Passed to end-users over a JSON/RPC API 2) Passed to domain plugins over a gRPC API

Types

type BlockHeaderJSONRPC

type BlockHeaderJSONRPC struct {
	Number           ethtypes.HexUint64          `json:"number"`
	Hash             ethtypes.HexBytes0xPrefix   `json:"hash"`
	MixHash          ethtypes.HexBytes0xPrefix   `json:"mixHash"`
	ParentHash       ethtypes.HexBytes0xPrefix   `json:"parentHash"`
	Nonce            ethtypes.HexBytes0xPrefix   `json:"nonce"`
	SHA3Uncles       ethtypes.HexBytes0xPrefix   `json:"sha3Uncles"`
	LogsBloom        ethtypes.HexBytes0xPrefix   `json:"logsBloom"`
	TransactionsRoot ethtypes.HexBytes0xPrefix   `json:"transactionsRoot"`
	StateRoot        ethtypes.HexBytes0xPrefix   `json:"stateRoot"`
	ReceiptsRoot     ethtypes.HexBytes0xPrefix   `json:"receiptsRoot"`
	Miner            *ethtypes.Address0xHex      `json:"miner"`
	Difficulty       *ethtypes.HexInteger        `json:"difficulty"`
	TotalDifficulty  *ethtypes.HexInteger        `json:"totalDifficulty"`
	ExtraData        ethtypes.HexBytes0xPrefix   `json:"extraData"`
	BaseFeePerGas    *ethtypes.HexInteger        `json:"baseFeePerGas"`
	Size             *ethtypes.HexInteger        `json:"size"`
	GasLimit         *ethtypes.HexInteger        `json:"gasLimit"`
	GasUsed          *ethtypes.HexInteger        `json:"gasUsed"`
	Timestamp        *ethtypes.HexInteger        `json:"timestamp"`
	Uncles           []ethtypes.HexBytes0xPrefix `json:"uncles"`
}

func (*BlockHeaderJSONRPC) ToBlockInfo

func (b *BlockHeaderJSONRPC) ToBlockInfo(includeLogsBloom bool) *BlockInfoJSONRPC

type BlockInfoJSONRPC

type BlockInfoJSONRPC struct {
	Number       ethtypes.HexUint64          `json:"number"`
	Hash         ethtypes.HexBytes0xPrefix   `json:"hash"`
	ParentHash   ethtypes.HexBytes0xPrefix   `json:"parentHash"`
	Timestamp    *ethtypes.HexInteger        `json:"timestamp"`
	LogsBloom    ethtypes.HexBytes0xPrefix   `json:"logsBloom"`
	Transactions []ethtypes.HexBytes0xPrefix `json:"transactions"`
}

BlockInfoJSONRPC are the info fields we parse from the JSON/RPC response, and cache

func (*BlockInfoJSONRPC) Equal

func (bi *BlockInfoJSONRPC) Equal(bi2 *BlockInfoJSONRPC) bool

func (*BlockInfoJSONRPC) IsParentOf

func (bi *BlockInfoJSONRPC) IsParentOf(other *BlockInfoJSONRPC) bool

func (*BlockInfoJSONRPC) MarshalFormat

func (bi *BlockInfoJSONRPC) MarshalFormat(jss *JSONSerializerSet, opts ...MarshalOption) (_ json.RawMessage, err error)

func (*BlockInfoJSONRPC) ToFFCAPIMinimalBlockInfo

func (bi *BlockInfoJSONRPC) ToFFCAPIMinimalBlockInfo() *ffcapi.MinimalBlockInfo

type EVMBlockWithTransactionsJSONRPC

type EVMBlockWithTransactionsJSONRPC struct {
	BlockHeaderJSONRPC
	Transactions []*TxInfoJSONRPC `json:"transactions"`
}

EVMBlockWithTransactionsJSONRPC is the full JSON/RPC structure you get with "true" on eth_getBlockByNumber / eth_getBlockByHash

func (*EVMBlockWithTransactionsJSONRPC) MarshalFormat

func (b *EVMBlockWithTransactionsJSONRPC) MarshalFormat(jss *JSONSerializerSet, opts ...MarshalOption) (jb json.RawMessage, err error)

func (*EVMBlockWithTransactionsJSONRPC) ToBlockInfo

func (b *EVMBlockWithTransactionsJSONRPC) ToBlockInfo(includeLogsBloom bool) *BlockInfoJSONRPC

type EVMBlockWithTxHashesJSONRPC

type EVMBlockWithTxHashesJSONRPC struct {
	BlockHeaderJSONRPC
	Transactions []ethtypes.HexBytes0xPrefix `json:"transactions"`
}

EVMBlockWithTxHashesJSONRPC is the full JSON/RPC structure you get with "false" on eth_getBlockByNumber / eth_getBlockByHash

func (*EVMBlockWithTxHashesJSONRPC) MarshalFormat

func (b *EVMBlockWithTxHashesJSONRPC) MarshalFormat(jss *JSONSerializerSet, opts ...MarshalOption) (_ json.RawMessage, err error)

func (*EVMBlockWithTxHashesJSONRPC) ToBlockInfo

func (b *EVMBlockWithTxHashesJSONRPC) ToBlockInfo(includeLogsBloom bool) *BlockInfoJSONRPC

type JSONFormatOptions

type JSONFormatOptions string
const DefaultJSONFormatOptions JSONFormatOptions = ""

func (JSONFormatOptions) GetABISerializer

func (jfo JSONFormatOptions) GetABISerializer(ctx context.Context) (serializer *abi.Serializer, err error)

func (JSONFormatOptions) GetABISerializerIgnoreErrors

func (jfo JSONFormatOptions) GetABISerializerIgnoreErrors(ctx context.Context) *abi.Serializer

func (JSONFormatOptions) GetSerializerSet

func (jfo JSONFormatOptions) GetSerializerSet(ctx context.Context, skipErrors bool) (ss *JSONSerializerSet, err error)

type JSONSerializerSet

type JSONSerializerSet struct {
	Mode    abi.FormattingMode
	Integer abi.IntSerializer
	Float   abi.FloatSerializer
	Bytes   abi.ByteSerializer
	Address abi.AddressSerializer
	Pretty  bool
}

func StandardSerializerSet

func StandardSerializerSet() *JSONSerializerSet

func (*JSONSerializerSet) ABISerializer

func (ss *JSONSerializerSet) ABISerializer() *abi.Serializer

func (*JSONSerializerSet) MarshalFormattedMap

func (ss *JSONSerializerSet) MarshalFormattedMap(value map[string]any, opts ...MarshalOption) (data json.RawMessage, err error)

MarshalFormattedMap takes a map that contains certain pre-selected types (see below switch) and does JSON marshalling adhering to the request of the users.

type LogFilterJSONRPC

type LogFilterJSONRPC struct {
	FromBlock *ethtypes.HexInteger          `json:"fromBlock,omitempty"`
	ToBlock   *ethtypes.HexInteger          `json:"toBlock,omitempty"`
	Address   []*ethtypes.Address0xHex      `json:"address,omitempty"`
	Topics    [][]ethtypes.HexBytes0xPrefix `json:"topics,omitempty"`
}

See https://ethereum.org/hr/developers/docs/apis/json-rpc/#eth_newfilter The address, as well as the entries in the topic array, can be DATA|Array. We just use array in all cases.

type LogJSONRPC

type LogJSONRPC struct {
	Removed          bool                        `json:"removed"`
	LogIndex         ethtypes.HexUint64          `json:"logIndex"`
	TransactionIndex ethtypes.HexUint64          `json:"transactionIndex"`
	BlockNumber      ethtypes.HexUint64          `json:"blockNumber"`
	TransactionHash  ethtypes.HexBytes0xPrefix   `json:"transactionHash"`
	BlockHash        ethtypes.HexBytes0xPrefix   `json:"blockHash"`
	Address          *ethtypes.Address0xHex      `json:"address"`
	Data             ethtypes.HexBytes0xPrefix   `json:"data"`
	Topics           []ethtypes.HexBytes0xPrefix `json:"topics"`
}

func (*LogJSONRPC) MarshalFormat

func (l *LogJSONRPC) MarshalFormat(jss *JSONSerializerSet, opts ...MarshalOption) (_ json.RawMessage, err error)

type MarshalOption

type MarshalOption struct {
	RedactFields   []string // helpful when you want to trim large fields
	OmitNullFields []string // a simplified approach to "omitempty" on JSON struct formatting tags
}

Marshalling options specific to the structure that is being marshalled, rather than JSONFormatOptions which are specific to the way to represent data in JSON

type TxInfoJSONRPC

type TxInfoJSONRPC struct {
	BlockHash        ethtypes.HexBytes0xPrefix `json:"blockHash"`   // null if pending
	BlockNumber      ethtypes.HexUint64        `json:"blockNumber"` // null if pending
	ChainID          *ethtypes.HexInteger      `json:"chainId"`
	From             *ethtypes.Address0xHex    `json:"from"`
	Gas              *ethtypes.HexInteger      `json:"gas"`
	GasPrice         *ethtypes.HexInteger      `json:"gasPrice"`
	Hash             ethtypes.HexBytes0xPrefix `json:"hash"`
	Input            ethtypes.HexBytes0xPrefix `json:"input"`
	Nonce            *ethtypes.HexInteger      `json:"nonce"`
	To               *ethtypes.Address0xHex    `json:"to"`
	TransactionIndex *ethtypes.HexInteger      `json:"transactionIndex"` // null if pending
	Type             *ethtypes.HexInteger      `json:"type"`
	Value            *ethtypes.HexInteger      `json:"value"`
	V                *ethtypes.HexInteger      `json:"v"`
	R                *ethtypes.HexInteger      `json:"r"`
	S                *ethtypes.HexInteger      `json:"s"`
}

TxInfoJSONRPC is the transaction info obtained over JSON/RPC from the ethereum client, with input data

func (*TxInfoJSONRPC) MarshalFormat

func (txi *TxInfoJSONRPC) MarshalFormat(jss *JSONSerializerSet, opts ...MarshalOption) (_ json.RawMessage, err error)

type TxReceiptJSONRPC

type TxReceiptJSONRPC struct {
	TransactionHash   ethtypes.HexBytes0xPrefix `json:"transactionHash"`
	TransactionIndex  ethtypes.HexUint64        `json:"transactionIndex"`
	BlockHash         ethtypes.HexBytes0xPrefix `json:"blockHash"`
	BlockNumber       ethtypes.HexUint64        `json:"blockNumber"`
	From              *ethtypes.Address0xHex    `json:"from"`
	To                *ethtypes.Address0xHex    `json:"to"`
	CumulativeGasUsed *ethtypes.HexInteger      `json:"cumulativeGasUsed"`
	EffectiveGasPrice *ethtypes.HexInteger      `json:"effectiveGasPrice"`
	GasUsed           *ethtypes.HexInteger      `json:"gasUsed"`
	ContractAddress   *ethtypes.Address0xHex    `json:"contractAddress"`
	Logs              []*LogJSONRPC             `json:"logs"`
	LogsBloom         ethtypes.HexBytes0xPrefix `json:"logsBloom"`
	Type              *ethtypes.HexInteger      `json:"type"`
	Status            *ethtypes.HexInteger      `json:"status"`
	RevertReason      ethtypes.HexBytes0xPrefix `json:"revertReason"`
}

TxReceiptJSONRPC is the receipt obtained over JSON/RPC from the ethereum client, with gas used, logs and contract address

func (*TxReceiptJSONRPC) MarshalFormat

func (txr *TxReceiptJSONRPC) MarshalFormat(jss *JSONSerializerSet, opts ...MarshalOption) (jb json.RawMessage, err error)

Jump to

Keyboard shortcuts

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