ethereumRPCProvider

package
v0.0.0-...-5495d05 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ProviderInternalErr = &RPCProviderError{Code: -32603, Message: "Internal error"}
View Source
var ProviderInvalidParams = &RPCProviderError{Code: -32602, Message: "Invalid params"}
View Source
var ProviderInvalidReq = &RPCProviderError{Code: -32600, Message: "Invalid request"}
View Source
var ProviderMethodNotFound = &RPCProviderError{Code: -32601, Message: "Method not found"}
View Source
var ProviderMethodNotSupport = &RPCProviderError{Code: -32004, Message: "Method not supported"}
View Source
var ProviderParseErr = &RPCProviderError{Code: -32700, Message: "Parse error"}

Functions

This section is empty.

Types

type ETHRPCPresetMethods

type ETHRPCPresetMethods struct{}

func (*ETHRPCPresetMethods) Accounts

func (e *ETHRPCPresetMethods) Accounts() ([]types.Address, *RPCProviderError)

func (*ETHRPCPresetMethods) BlockTransactionCountByHash

func (e *ETHRPCPresetMethods) BlockTransactionCountByHash(types.Hash) (types.Uint64, *RPCProviderError)

func (*ETHRPCPresetMethods) BlockTransactionCountByNumber

func (e *ETHRPCPresetMethods) BlockTransactionCountByNumber(EthBlockNumString) (types.Uint64, *RPCProviderError)

func (*ETHRPCPresetMethods) Code

func (*ETHRPCPresetMethods) Coinbase

func (*ETHRPCPresetMethods) EstimateGas

func (*ETHRPCPresetMethods) GasPrice

func (e *ETHRPCPresetMethods) GasPrice() (*types.BigInt, *RPCProviderError)

func (*ETHRPCPresetMethods) HashRate

func (e *ETHRPCPresetMethods) HashRate() (*types.BigInt, *RPCProviderError)

func (*ETHRPCPresetMethods) Mining

func (e *ETHRPCPresetMethods) Mining() (bool, *RPCProviderError)

func (*ETHRPCPresetMethods) NetVersion

func (e *ETHRPCPresetMethods) NetVersion() (string, *RPCProviderError)

func (*ETHRPCPresetMethods) ProtocolVersion

func (e *ETHRPCPresetMethods) ProtocolVersion() (string, *RPCProviderError)

func (*ETHRPCPresetMethods) SendTransaction

func (*ETHRPCPresetMethods) StorageAt

func (*ETHRPCPresetMethods) Syncing

func (e *ETHRPCPresetMethods) Syncing() (bool, any, *RPCProviderError)

func (*ETHRPCPresetMethods) TransactionByBlockHashAndIndex

func (e *ETHRPCPresetMethods) TransactionByBlockHashAndIndex(types.Hash, uint64) (*EthFullTransaction, *RPCProviderError)

func (*ETHRPCPresetMethods) TransactionByBlockNumberAndIndex

func (e *ETHRPCPresetMethods) TransactionByBlockNumberAndIndex(EthBlockNumString, uint64) (*EthFullTransaction, *RPCProviderError)

func (*ETHRPCPresetMethods) TransactionCount

func (*ETHRPCPresetMethods) UncleByBlockHashAndIndex

func (e *ETHRPCPresetMethods) UncleByBlockHashAndIndex(types.Hash, uint64) (*EthBlock, *RPCProviderError)

func (*ETHRPCPresetMethods) UncleByBlockNumberAndIndex

func (e *ETHRPCPresetMethods) UncleByBlockNumberAndIndex(EthBlockNumString, uint64) (*EthBlock, *RPCProviderError)

func (*ETHRPCPresetMethods) UncleCountByBlockHash

func (e *ETHRPCPresetMethods) UncleCountByBlockHash(types.Hash) (types.Uint64, *RPCProviderError)

func (*ETHRPCPresetMethods) UncleCountByBlockNumber

func (e *ETHRPCPresetMethods) UncleCountByBlockNumber(EthBlockNumString) (types.Uint64, *RPCProviderError)

func (*ETHRPCPresetMethods) Web3ClientVersion

func (e *ETHRPCPresetMethods) Web3ClientVersion() (string, *RPCProviderError)

type EthBasicTransaction

type EthBasicTransaction struct {
	Type                 types.Uint64   `json:"type"`
	Nonce                types.BigInt   `json:"nonce"`
	From                 types.Address  `json:"from"`
	To                   *types.Address `json:"to"`
	AccessList           []any          `json:"accessList"`
	Input                types.Data     `json:"input"`
	Data                 types.Data     `json:"data"`
	Gas                  types.Uint64   `json:"gas"`
	GasPrice             *types.BigInt  `json:"gasPrice"`
	MaxPriorityFeePerGas *types.BigInt  `json:"maxPriorityFeePerGas"`
	MaxFeePerGas         *types.BigInt  `json:"maxFeePerGas"`
	Value                *types.BigInt  `json:"value"`
}

type EthBlock

type EthBlock struct {
	Number                types.Uint64   `json:"number"`
	Hash                  types.Hash     `json:"hash"`
	ParentHash            types.Hash     `json:"parentHash"`
	Nonce                 types.Data     `json:"nonce"`
	Sha3Uncles            *types.Hash    `json:"sha3Uncles"`
	LogsBloom             *types.Data    `json:"logsBloom"`
	TransactionsRoot      types.Hash     `json:"transactionsRoot"`
	StateRoot             types.Hash     `json:"stateRoot"`
	ReceiptsRoot          types.Hash     `json:"receiptsRoot"`
	Miner                 *types.Address `json:"miner"`
	Difficulty            *types.BigInt  `json:"difficulty"`
	TotalDifficulty       *types.BigInt  `json:"totalDifficulty"`
	ExtraData             types.Data     `json:"extraData"`
	MixHash               types.Data     `json:"mixHash"`
	Size                  types.Uint64   `json:"size"`
	GasLimit              types.Uint64   `json:"gasLimit"`
	GasUsed               types.Uint64   `json:"gasUsed"`
	BaseFeePerGas         *types.BigInt  `json:"baseFeePerGas"`
	Withdrawals           []any          `json:"withdrawals"`
	WithdrawalsRoot       *types.Hash    `json:"withdrawalsRoot"`
	BlobGasUsed           types.Uint64   `json:"blobGasUsed"`
	ExcessBlobGas         types.Uint64   `json:"excessBlobGas"`
	ParentBeaconBlockRoot *types.Hash    `json:"parentBeaconBlockRoot"`
	Timestamp             types.Uint64   `json:"timestamp"`
	Transactions          []any          `json:"transactions"`
	Uncles                []types.Hash   `json:"uncles"`
}

type EthBlockNumString

type EthBlockNumString string

func (*EthBlockNumString) FromAny

func (e *EthBlockNumString) FromAny(v any) bool

func (EthBlockNumString) Uint64

func (e EthBlockNumString) Uint64(defBlk uint64) uint64

func (EthBlockNumString) ValidBlock

func (e EthBlockNumString) ValidBlock() bool

type EthFullTransaction

type EthFullTransaction struct {
	BlockHash   types.Hash    `json:"blockHash"`
	BlockNumber types.Uint64  `json:"blockNumber"`
	ChainId     *types.BigInt `json:"chainId"`

	EthBasicTransaction
	Hash             types.Hash   `json:"hash"`
	TransactionIndex types.Uint64 `json:"transactionIndex"`
	YParity          types.Uint64 `json:"yParity"`
	V                types.Uint64 `json:"v"`
	R                types.Data   `json:"r"`
	S                types.Data   `json:"s"`
}

type EthGetLogsParam

type EthGetLogsParam struct {
	FromBlock *EthBlockNumString `json:"fromBlock"`
	ToBlock   *EthBlockNumString `json:"toBlock"`
	Address   any                `json:"address"`
	Topics    []types.Hash       `json:"topics"`
	BlockHash *types.Hash        `json:"blockhash"`
}

type EthLog

type EthLog struct {
	Removed          bool          `json:"removed"`
	LogIndex         types.Uint64  `json:"logIndex"`
	TransactionIndex types.Uint64  `json:"transactionIndex"`
	TransactionHash  types.Hash    `json:"transactionHash"`
	BlockHash        types.Hash    `json:"blockHash"`
	BlockNumber      types.Uint64  `json:"blockNumber"`
	Address          types.Address `json:"address"`
	Data             types.Data    `json:"data"`
	Topics           []types.Data  `json:"topics"`
}

type EthTransactionReceipt

type EthTransactionReceipt struct {
	Root              *types.Hash    `json:"root,omitempty"`
	BlockHash         types.Hash     `json:"blockHash"`
	BlockNumber       types.Uint64   `json:"blockNumber"`
	ChainId           *types.BigInt  `json:"chainId"`
	Type              types.Uint64   `json:"type"`
	TxHash            types.Hash     `json:"transactionHash"`
	TxIndex           types.Uint64   `json:"transactionIndex"`
	From              types.Address  `json:"from"`
	To                *types.Address `json:"to"`
	ContractAddress   *types.Address `json:"contractAddress"`
	Logs              []EthLog       `json:"logs"`
	LogsBloom         types.Data     `json:"logsBloom"`
	GasUsed           types.Uint64   `json:"gasUsed"`
	CumulativeGasUsed types.Uint64   `json:"cumulativeGasUsed"`
	EffectiveGasPrice *types.BigInt  `json:"effectiveGasPrice"`
	BlobGasPrice      *types.BigInt  `json:"blobGasPrice"`
	Status            types.Uint64   `json:"status"`
}

type IEthereumRPCProvider

type IEthereumRPCProvider interface {
	SupportCheck(string) bool
	Web3ClientVersion() (string, *RPCProviderError)
	NetVersion() (string, *RPCProviderError)
	ProtocolVersion() (string, *RPCProviderError)
	Syncing() (bool, any, *RPCProviderError)
	Coinbase() (types.Address, *RPCProviderError)
	ChainId() (*types.BigInt, *RPCProviderError)
	Mining() (bool, *RPCProviderError)
	HashRate() (*types.BigInt, *RPCProviderError)
	GasPrice() (*types.BigInt, *RPCProviderError)
	Accounts() ([]types.Address, *RPCProviderError)
	BlockNumber() (types.Uint64, *RPCProviderError)
	Balance(addr types.Address, blk EthBlockNumString) (*types.BigInt, *RPCProviderError)
	StorageAt(addr types.Address, key types.Key, blk EthBlockNumString) (types.Data, *RPCProviderError)
	TransactionCount(addr types.Address, blk EthBlockNumString) (types.Uint64, *RPCProviderError)
	BlockTransactionCountByHash(hash types.Hash) (types.Uint64, *RPCProviderError)
	BlockTransactionCountByNumber(blk EthBlockNumString) (types.Uint64, *RPCProviderError)
	UncleCountByBlockHash(blkHash types.Hash) (types.Uint64, *RPCProviderError)
	UncleCountByBlockNumber(blk EthBlockNumString) (types.Uint64, *RPCProviderError)
	Code(addr types.Address, blk EthBlockNumString) (types.Data, *RPCProviderError)
	SendTransaction(tx EthBasicTransaction) (types.Hash, *RPCProviderError)
	SendRawTransaction(data types.Data) (types.Hash, *RPCProviderError)
	Call(tx EthBasicTransaction, blk EthBlockNumString) (types.Data, *RPCProviderError)
	EstimateGas(tx EthBasicTransaction, blk EthBlockNumString) (types.Uint64, *RPCProviderError)
	BlockByHash(blkHash types.Hash, fullTx bool) (*EthBlock, *RPCProviderError)
	BlockByNumber(blk EthBlockNumString, fullTx bool) (*EthBlock, *RPCProviderError)
	TransactionByHash(txHash types.Hash) (*EthFullTransaction, *RPCProviderError)
	TransactionByBlockHashAndIndex(hash types.Hash, idx uint64) (*EthFullTransaction, *RPCProviderError)
	TransactionByBlockNumberAndIndex(blk EthBlockNumString, idx uint64) (*EthFullTransaction, *RPCProviderError)
	TransactionReceipt(txHash types.Hash) (*EthTransactionReceipt, *RPCProviderError)
	UncleByBlockHashAndIndex(blkHash types.Hash, idx uint64) (*EthBlock, *RPCProviderError)
	UncleByBlockNumberAndIndex(blk EthBlockNumString, idx uint64) (*EthBlock, *RPCProviderError)
	Logs(EthGetLogsParam) ([]EthLog, *RPCProviderError)
}

IEthereumRPCProvider known unsupported rpc method: web3_sha3, net_listening, net_peerCount, eth_protocolVersion, eth_sign, eth_signTransaction, eth_newFilter, eth_newBlockFilter, eth_newPendingTransactionFilter, eth_uninstallFilter, eth_getFilterChanges, eth_getFilterLogs

type RPCProviderError

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

func (*RPCProviderError) Error

func (e *RPCProviderError) Error() error

Jump to

Keyboard shortcuts

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