requests

package
v0.0.0-...-1f8a15b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlockNumbers = struct {
	// Latest is the parameter for the latest block
	Latest BlockNumber
	// Earliest is the parameter for the earliest block
	Earliest BlockNumber
	// Pending is the parameter for the pending block
	Pending BlockNumber
}{
	Latest:   "latest",
	Earliest: "earliest",
	Pending:  "pending",
}
View Source
var (
	// ErrBadRequest for http bad requests
	ErrBadRequest = errors.New("bad request")
)
View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var Methods = struct {
	// ETHGetTransactionCount represents the eth_getTransactionCount method
	ETHGetTransactionCount RPCMethod
	// ETHGetBalance represents the eth_getBalance method
	ETHGetBalance RPCMethod
	// ETHSendRawTransaction represents the eth_sendRawTransaction method
	ETHSendRawTransaction RPCMethod
	// ETHGetBlockByNumber represents the eth_getBlockByNumber method
	ETHGetBlockByNumber RPCMethod
	// ETHGetBlock represents the eth_getBlock method
	ETHGetBlock RPCMethod
	// ETHGetLogs represents the eth_getLogs method
	ETHGetLogs RPCMethod
	// ETHBlockNumber represents the eth_blockNumber method
	ETHBlockNumber RPCMethod
	// AdminNodeInfo represents the admin_nodeInfo method
	AdminNodeInfo RPCMethod
	// TxpoolContent represents the txpool_content method
	TxpoolContent RPCMethod
	// OTSGetBlockDetails represents the ots_getBlockDetails method
	OTSGetBlockDetails RPCMethod
	// ETHNewHeads represents the eth_newHeads sub method
	ETHNewHeads              SubMethod
	ETHLogs                  SubMethod
	TraceCall                RPCMethod
	TraceTransaction         RPCMethod
	DebugAccountAt           RPCMethod
	ETHGetCode               RPCMethod
	ETHEstimateGas           RPCMethod
	ETHGasPrice              RPCMethod
	ETHGetTransactionByHash  RPCMethod
	ETHGetTransactionReceipt RPCMethod
	BorGetRootHash           RPCMethod
	ETHCall                  RPCMethod
}{
	ETHGetTransactionCount:   "eth_getTransactionCount",
	ETHGetBalance:            "eth_getBalance",
	ETHSendRawTransaction:    "eth_sendRawTransaction",
	ETHGetBlockByNumber:      "eth_getBlockByNumber",
	ETHGetBlock:              "eth_getBlock",
	ETHGetLogs:               "eth_getLogs",
	ETHBlockNumber:           "eth_blockNumber",
	AdminNodeInfo:            "admin_nodeInfo",
	TxpoolContent:            "txpool_content",
	OTSGetBlockDetails:       "ots_getBlockDetails",
	ETHNewHeads:              "eth_newHeads",
	ETHLogs:                  "eth_logs",
	TraceCall:                "trace_call",
	TraceTransaction:         "trace_transaction",
	DebugAccountAt:           "debug_accountAt",
	ETHGetCode:               "eth_getCode",
	ETHEstimateGas:           "eth_estimateGas",
	ETHGasPrice:              "eth_gasPrice",
	ETHGetTransactionByHash:  "eth_getTransactionByHash",
	ETHGetTransactionReceipt: "eth_getTransactionReceipt",
	BorGetRootHash:           "bor_getRootHash",
	ETHCall:                  "eth_call",
}
View Source
var TraceOpts = struct {
	VmTrace   TraceOpt
	Trace     TraceOpt
	StateDiff TraceOpt
}{
	VmTrace:   "vmTrace",
	Trace:     "trace",
	StateDiff: "stateDiff",
}

Functions

func Compare

func Compare(expected types.Log, actual types.Log) ([]error, bool)

func NewLog

func NewLog(hash libcommon.Hash, blockNum uint64, address libcommon.Address, topics []libcommon.Hash, data hexutility.Bytes, txIndex uint, blockHash libcommon.Hash, index hexutil.Uint, removed bool) types.Log

Types

type AccountResult

type AccountResult struct {
	Address      libcommon.Address `json:"address"`
	AccountProof []string          `json:"accountProof"`
	Balance      *hexutil.Big      `json:"balance"`
	CodeHash     libcommon.Hash    `json:"codeHash"`
	Code         hexutility.Bytes  `json:"code"`
	Nonce        hexutil.Uint64    `json:"nonce"`
	StorageHash  libcommon.Hash    `json:"storageHash"`
	StorageProof []StorageResult   `json:"storageProof"`
}

AccountResult is the result struct for GetProof

type Block

type Block struct {
	BlockWithTxHashes
	Transactions []*jsonrpc.RPCTransaction `json:"transactions"`
}

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(input []byte) error

type BlockNumber

type BlockNumber string

func AsBlockNumber

func AsBlockNumber(n *big.Int) BlockNumber

func (BlockNumber) Uint64

func (bn BlockNumber) Uint64() uint64

type BlockWithTxHashes

type BlockWithTxHashes struct {
	*types.Header
	Hash              libcommon.Hash `json:"hash"`
	TransactionHashes []libcommon.Hash
}

func (*BlockWithTxHashes) UnmarshalJSON

func (b *BlockWithTxHashes) UnmarshalJSON(input []byte) error

type CallResult

type CallResult struct {
	GasUsed hexutil.Big       `json:"gasUsed"`
	Output  hexutility.Bytes  `json:"output"`
	Address libcommon.Address `json:"address"`
	Code    hexutility.Bytes  `json:"code"`
}

type CallTrace

type CallTrace struct {
	Type         string          `json:"type"`
	Action       TraceCallAction `json:"action"`
	Result       *CallResult     `json:"result"`
	Subtraces    int             `json:"subtraces"`
	TraceAddress []int           `json:"traceAddress"`
	Error        string          `json:"error"`
}

type CommonResponse

type CommonResponse struct {
	Version   string    `json:"jsonrpc"`
	RequestId int       `json:"id"`
	Error     *EthError `json:"error"`
}

type DebugAccountAt

type DebugAccountAt struct {
	CommonResponse
	Result AccountResult `json:"result"`
}

type ETHEstimateGas

type ETHEstimateGas struct {
	CommonResponse
	Number hexutil.Uint64 `json:"result"`
}

type EthError

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

func (EthError) Error

func (e EthError) Error() string

type EthGetTransactionCount

type EthGetTransactionCount struct {
	CommonResponse
	Result hexutil2.Uint64 `json:"result"`
}

type EthTxPool

type EthTxPool struct {
	CommonResponse
	Result interface{} `json:"result"`
}

type NopRequestGenerator

type NopRequestGenerator struct {
}

func (NopRequestGenerator) AdminNodeInfo

func (n NopRequestGenerator) AdminNodeInfo() (p2p.NodeInfo, error)

func (NopRequestGenerator) BlockNumber

func (n NopRequestGenerator) BlockNumber() (uint64, error)

func (NopRequestGenerator) Call

func (n NopRequestGenerator) Call(args ethapi.CallArgs, blockRef rpc.BlockReference, overrides *ethapi.StateOverrides) ([]byte, error)

func (NopRequestGenerator) DebugAccountAt

func (n NopRequestGenerator) DebugAccountAt(blockHash libcommon.Hash, txIndex uint64, account libcommon.Address) (*AccountResult, error)

func (NopRequestGenerator) EstimateGas

func (n NopRequestGenerator) EstimateGas(args ethereum.CallMsg, blockNum BlockNumber) (uint64, error)

func (NopRequestGenerator) FilterLogs

func (n NopRequestGenerator) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)

func (NopRequestGenerator) GasPrice

func (n NopRequestGenerator) GasPrice() (*big.Int, error)

func (NopRequestGenerator) GetBalance

func (n NopRequestGenerator) GetBalance(address libcommon.Address, blockRef rpc.BlockReference) (*big.Int, error)

func (NopRequestGenerator) GetBlockByNumber

func (n NopRequestGenerator) GetBlockByNumber(ctx context.Context, blockNum rpc.BlockNumber, withTxs bool) (*Block, error)

func (NopRequestGenerator) GetCode

func (n NopRequestGenerator) GetCode(address libcommon.Address, blockRef rpc.BlockReference) (hexutility.Bytes, error)

func (NopRequestGenerator) GetRootHash

func (n NopRequestGenerator) GetRootHash(ctx context.Context, startBlock uint64, endBlock uint64) (libcommon.Hash, error)

func (NopRequestGenerator) GetTransactionByHash

func (n NopRequestGenerator) GetTransactionByHash(hash libcommon.Hash) (*jsonrpc.RPCTransaction, error)

func (NopRequestGenerator) GetTransactionCount

func (n NopRequestGenerator) GetTransactionCount(address libcommon.Address, blockRef rpc.BlockReference) (*big.Int, error)

func (NopRequestGenerator) GetTransactionReceipt

func (n NopRequestGenerator) GetTransactionReceipt(ctx context.Context, hash libcommon.Hash) (*types.Receipt, error)

func (NopRequestGenerator) PingErigonRpc

func (n NopRequestGenerator) PingErigonRpc() PingResult

func (NopRequestGenerator) SendTransaction

func (n NopRequestGenerator) SendTransaction(signedTx types.Transaction) (libcommon.Hash, error)

func (NopRequestGenerator) Subscribe

func (n NopRequestGenerator) Subscribe(ctx context.Context, method SubMethod, subChan interface{}, args ...interface{}) (ethereum.Subscription, error)

func (NopRequestGenerator) SubscribeFilterLogs

func (n NopRequestGenerator) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)

func (NopRequestGenerator) TraceCall

func (n NopRequestGenerator) TraceCall(blockRef rpc.BlockReference, args ethapi.CallArgs, traceOpts ...TraceOpt) (*TraceCallResult, error)

func (NopRequestGenerator) TraceTransaction

func (n NopRequestGenerator) TraceTransaction(hash libcommon.Hash) ([]TransactionTrace, error)

func (NopRequestGenerator) TxpoolContent

func (n NopRequestGenerator) TxpoolContent() (int, int, int, error)

type PingResult

type PingResult callResult

type RPCMethod

type RPCMethod string

RPCMethod is the type for rpc methods used

type RequestGenerator

type RequestGenerator interface {
	PingErigonRpc() PingResult
	GetBalance(address libcommon.Address, blockRef rpc.BlockReference) (*big.Int, error)
	AdminNodeInfo() (p2p.NodeInfo, error)
	GetBlockByNumber(ctx context.Context, blockNum rpc.BlockNumber, withTxs bool) (*Block, error)
	GetTransactionByHash(hash libcommon.Hash) (*jsonrpc.RPCTransaction, error)
	GetTransactionReceipt(ctx context.Context, hash libcommon.Hash) (*types.Receipt, error)
	TraceTransaction(hash libcommon.Hash) ([]TransactionTrace, error)
	GetTransactionCount(address libcommon.Address, blockRef rpc.BlockReference) (*big.Int, error)
	BlockNumber() (uint64, error)
	SendTransaction(signedTx types.Transaction) (libcommon.Hash, error)
	FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
	SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
	Subscribe(ctx context.Context, method SubMethod, subChan interface{}, args ...interface{}) (ethereum.Subscription, error)
	TxpoolContent() (int, int, int, error)
	Call(args ethapi.CallArgs, blockRef rpc.BlockReference, overrides *ethapi.StateOverrides) ([]byte, error)
	TraceCall(blockRef rpc.BlockReference, args ethapi.CallArgs, traceOpts ...TraceOpt) (*TraceCallResult, error)
	DebugAccountAt(blockHash libcommon.Hash, txIndex uint64, account libcommon.Address) (*AccountResult, error)
	GetCode(address libcommon.Address, blockRef rpc.BlockReference) (hexutility.Bytes, error)
	EstimateGas(args ethereum.CallMsg, blockNum BlockNumber) (uint64, error)
	GasPrice() (*big.Int, error)

	GetRootHash(ctx context.Context, startBlock uint64, endBlock uint64) (libcommon.Hash, error)
}

func NewRequestGenerator

func NewRequestGenerator(target string, logger log.Logger) RequestGenerator

type StorageResult

type StorageResult struct {
	Key   string       `json:"key"`
	Value *hexutil.Big `json:"value"`
	Proof []string     `json:"proof"`
}

type SubMethod

type SubMethod string

SubMethod is the type for sub methods used in subscriptions

type TraceCall

type TraceCall struct {
	CommonResponse
	Result TraceCallResult `json:"result"`
}

type TraceCallAction

type TraceCallAction struct {
	From          libcommon.Address `json:"from"`
	To            libcommon.Address `json:"to"`
	Address       libcommon.Address `json:"address"`
	RefundAddress libcommon.Address `json:"refundAddress"`
	Gas           hexutil.Big       `json:"gas"`
	Value         hexutil.Big       `json:"value"`
	Balance       hexutil.Big       `json:"balance"`
	Init          hexutility.Bytes  `json:"init"`
	Input         hexutility.Bytes  `json:"input"`
	CallType      string            `json:"callType"`
}

TraceCallAction is superset of all possible action types

type TraceCallResult

type TraceCallResult struct {
	Output    hexutility.Bytes                         `json:"output"`
	Trace     []CallTrace                              `json:"trace"`
	StateDiff map[libcommon.Address]TraceCallStateDiff `json:"stateDiff"`
}

type TraceCallStateDiff

type TraceCallStateDiff struct {
	Balance interface{}                                             `json:"balance"`
	Nonce   interface{}                                             `json:"nonce"`
	Code    interface{}                                             `json:"code"`
	Storage map[libcommon.Hash]map[string]TraceCallStateDiffStorage `json:"storage"`
}

type TraceCallStateDiffStorage

type TraceCallStateDiffStorage struct {
	From libcommon.Hash `json:"from"`
	To   libcommon.Hash `json:"to"`
}

type TraceOpt

type TraceOpt string

type TransactionTrace

type TransactionTrace struct {
	Type                string          `json:"type"`
	Action              TraceCallAction `json:"action"`
	Result              *CallResult     `json:"result"`
	Error               string          `json:"error"`
	BlockHash           libcommon.Hash  `json:"blockHash"`
	BlockNumber         uint64          `json:"blockNumber"`
	TransactionHash     libcommon.Hash  `json:"transactionHash"`
	TransactionPosition uint64          `json:"transactionPosition"`
	Subtraces           int             `json:"subtraces"`
	TraceAddress        []int           `json:"traceAddress"`
}

Jump to

Keyboard shortcuts

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