ethapi

package
v3.0.0-alpha5.0...-c974331 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package ethapi implements the general Ethereum API functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RPCMarshalBlock

func RPCMarshalBlock(b *types.Block, inclTx bool, fullTx bool, additional map[string]interface{}) (map[string]interface{}, error)

nolint

func RPCMarshalBlockDeprecated

func RPCMarshalBlockDeprecated(block *types.Block, inclTx bool, fullTx bool) (map[string]interface{}, error)

RPCMarshalBlock converts the given block to the RPC output which depends on fullTx. If inclTx is true transactions are returned. When fullTx is true the returned block contains full transaction details, otherwise it will only contain transaction hashes.

func RPCMarshalBlockEx

func RPCMarshalBlockEx(b *types.Block, inclTx bool, fullTx bool, borTx types.Transaction, borTxHash libcommon.Hash, additional map[string]interface{}) (map[string]interface{}, error)

nolint

func RPCMarshalBlockExDeprecated

func RPCMarshalBlockExDeprecated(block *types.Block, inclTx bool, fullTx bool, borTx types.Transaction, borTxHash libcommon.Hash) (map[string]interface{}, error)

func RPCMarshalHeader

func RPCMarshalHeader(head *types.Header) map[string]interface{}

RPCMarshalHeader converts the given header to the RPC output .

Types

type Account

type Account struct {
	Nonce     *hexutil.Uint64                    `json:"nonce"`
	Code      *hexutility.Bytes                  `json:"code"`
	Balance   **hexutil.Big                      `json:"balance"`
	State     *map[libcommon.Hash]libcommon.Hash `json:"state"`
	StateDiff *map[libcommon.Hash]libcommon.Hash `json:"stateDiff"`
}

account indicates the overriding fields of account during the execution of a message call. Note, state and stateDiff can't be specified at the same time. If state is set, message execution will only use the data in the given state. Otherwise if statDiff is set, all diff will be applied first and then execute the call message.

type AccountResult

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

Result structs for GetProof

type CallArgs

type CallArgs struct {
	From                 *libcommon.Address `json:"from"`
	To                   *libcommon.Address `json:"to"`
	Gas                  *hexutil.Uint64    `json:"gas"`
	GasPrice             *hexutil.Big       `json:"gasPrice"`
	MaxPriorityFeePerGas *hexutil.Big       `json:"maxPriorityFeePerGas"`
	MaxFeePerGas         *hexutil.Big       `json:"maxFeePerGas"`
	MaxFeePerBlobGas     *hexutil.Big       `json:"maxFeePerBlobGas"`
	Value                *hexutil.Big       `json:"value"`
	Nonce                *hexutil.Uint64    `json:"nonce"`
	Data                 *hexutility.Bytes  `json:"data"`
	Input                *hexutility.Bytes  `json:"input"`
	AccessList           *types2.AccessList `json:"accessList"`
	ChainID              *hexutil.Big       `json:"chainId,omitempty"`
}

CallArgs represents the arguments for a call.

func (*CallArgs) ToMessage

func (args *CallArgs) ToMessage(globalGasCap uint64, baseFee *uint256.Int) (types.Message, error)

ToMessage converts CallArgs to the Message type used by the core evm

type ExecutionResult

type ExecutionResult struct {
	Gas         uint64         `json:"gas"`
	Failed      bool           `json:"failed"`
	ReturnValue string         `json:"returnValue"`
	StructLogs  []StructLogRes `json:"structLogs"`
}

ExecutionResult groups all structured logs emitted by the EVM while replaying a transaction in debug mode as well as transaction execution status, the amount of gas used and the return value

type RPCTransaction

type RPCTransaction struct {
	BlockHash        *libcommon.Hash    `json:"blockHash"`
	BlockNumber      *hexutil.Big       `json:"blockNumber"`
	From             libcommon.Address  `json:"from"`
	Gas              hexutil.Uint64     `json:"gas"`
	GasPrice         *hexutil.Big       `json:"gasPrice,omitempty"`
	Tip              *hexutil.Big       `json:"maxPriorityFeePerGas,omitempty"`
	FeeCap           *hexutil.Big       `json:"maxFeePerGas,omitempty"`
	MaxFeePerBlobGas *hexutil.Big       `json:"maxFeePerBlobGas,omitempty"`
	Hash             libcommon.Hash     `json:"hash"`
	Input            hexutility.Bytes   `json:"input"`
	Nonce            hexutil.Uint64     `json:"nonce"`
	To               *libcommon.Address `json:"to"`
	TransactionIndex *hexutil.Uint64    `json:"transactionIndex"`
	Value            *hexutil.Big       `json:"value"`
	Type             hexutil.Uint64     `json:"type"`
	Accesses         *types2.AccessList `json:"accessList,omitempty"`
	ChainID          *hexutil.Big       `json:"chainId,omitempty"`
	V                *hexutil.Big       `json:"v"`
	YParity          *hexutil.Big       `json:"yParity,omitempty"`
	R                *hexutil.Big       `json:"r"`
	S                *hexutil.Big       `json:"s"`

	BlobVersionedHashes []libcommon.Hash `json:"blobVersionedHashes,omitempty"`
}

RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction

type Receiver

type Receiver struct {
	// contains filtered or unexported fields
}

func (*Receiver) Receive

func (r *Receiver) Receive(
	itemType trie.StreamItem,
	accountKey []byte,
	storageKey []byte,
	accountValue *accounts.Account,
	storageValue []byte,
	hash []byte,
	hasTree bool,
	cutoff int,
) error

func (*Receiver) Root

func (r *Receiver) Root() libcommon.Hash

type RevertError

type RevertError struct {
	// contains filtered or unexported fields
}

RevertError is an API error that encompassas an EVM revertal with JSON error code and a binary data blob.

func NewRevertError

func NewRevertError(result *evmtypes.ExecutionResult) *RevertError

func (*RevertError) ErrorCode

func (e *RevertError) ErrorCode() int

ErrorCode returns the JSON error code for a revertal. See: https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal

func (*RevertError) ErrorData

func (e *RevertError) ErrorData() interface{}

ErrorData returns the hex encoded revert reason.

type StateOverrides

type StateOverrides map[libcommon.Address]Account

func (*StateOverrides) Override

func (overrides *StateOverrides) Override(state *state.IntraBlockState) error

type StorageResult

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

type StructLogRes

type StructLogRes struct {
	Pc      uint64             `json:"pc"`
	Op      string             `json:"op"`
	Gas     uint64             `json:"gas"`
	GasCost uint64             `json:"gasCost"`
	Depth   int                `json:"depth"`
	Error   error              `json:"error,omitempty"`
	Stack   *[]string          `json:"stack,omitempty"`
	Memory  *[]string          `json:"memory,omitempty"`
	Storage *map[string]string `json:"storage,omitempty"`
}

StructLogRes stores a structured log emitted by the EVM while replaying a transaction in debug mode

func FormatLogs

func FormatLogs(logs []logger.StructLog) []StructLogRes

FormatLogs formats EVM returned structured logs for json output

Jump to

Keyboard shortcuts

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