Documentation ¶
Index ¶
- Constants
- func ToBatchNumArg(number *big.Int) string
- type ArgAddress
- type ArgBig
- type ArgBytes
- type ArgHash
- type ArgUint64
- type Batch
- type BatchNumber
- type Block
- type BlockNumber
- type Error
- type ErrorObject
- type Index
- type Log
- type LogFilterRequest
- type PoolInterface
- type RPCError
- type Receipt
- type Request
- type Response
- type StateInterface
- type SubscriptionResponse
- type SubscriptionResponseParams
- type Transaction
- type TransactionOrHash
- type TxArgs
Constants ¶
const ( // PendingBlockNumber represents the pending block number PendingBlockNumber = BlockNumber(-3) // LatestBlockNumber represents the latest block number LatestBlockNumber = BlockNumber(-2) // EarliestBlockNumber represents the earliest block number EarliestBlockNumber = BlockNumber(-1) // LatestBatchNumber represents the latest batch number LatestBatchNumber = BatchNumber(-2) // EarliestBatchNumber represents the earliest batch number EarliestBatchNumber = BatchNumber(-1) // Earliest contains the string to represent the earliest block known. Earliest = "earliest" // Latest contains the string to represent the latest block known. Latest = "latest" // Pending contains the string to represent pending blocks. Pending = "pending" )
const ( // DefaultErrorCode rpc default error code DefaultErrorCode = -32000 // RevertedErrorCode error code for reverted txs RevertedErrorCode = 3 // InvalidRequestErrorCode error code for invalid requests InvalidRequestErrorCode = -32600 // NotFoundErrorCode error code for not found objects NotFoundErrorCode = -32601 // InvalidParamsErrorCode error code for invalid parameters InvalidParamsErrorCode = -32602 // ParserErrorCode error code for parsing errors ParserErrorCode = -32700 )
Variables ¶
This section is empty.
Functions ¶
func ToBatchNumArg ¶
ToBatchNumArg converts a big.Int into a batch number rpc parameter
Types ¶
type ArgAddress ¶
ArgAddress represents a common.Address that accepts strings shorter than 32 bytes, like 0x00
func (*ArgAddress) Address ¶
func (arg *ArgAddress) Address() common.Address
Address returns an instance of common.Address
func (*ArgAddress) UnmarshalText ¶
func (b *ArgAddress) UnmarshalText(input []byte) error
UnmarshalText unmarshals from text
type ArgBig ¶
ArgBig helps to marshal big number values provided in the RPC requests
func (ArgBig) MarshalText ¶
MarshalText marshals an array of bytes into an instance of ArgBig
func (*ArgBig) UnmarshalText ¶
UnmarshalText unmarshals an instance of ArgBig into an array of bytes
type ArgBytes ¶
type ArgBytes []byte
ArgBytes helps to marshal byte array values provided in the RPC requests
func ArgBytesPtr ¶
ArgBytesPtr helps to marshal byte array values provided in the RPC requests
func (ArgBytes) MarshalText ¶
MarshalText marshals into text
func (*ArgBytes) UnmarshalText ¶
UnmarshalText unmarshals from text
type ArgHash ¶
ArgHash represents a common.Hash that accepts strings shorter than 64 bytes, like 0x00
func (*ArgHash) UnmarshalText ¶
UnmarshalText unmarshals from text
type ArgUint64 ¶
type ArgUint64 uint64
ArgUint64 helps to marshal uint64 values provided in the RPC requests
func ArgUint64Ptr ¶
ArgUint64Ptr returns the pointer of the provided ArgUint64
func (ArgUint64) MarshalText ¶
MarshalText marshals into text
func (*ArgUint64) UnmarshalText ¶
UnmarshalText unmarshals from text
type Batch ¶
type Batch struct { Number ArgUint64 `json:"number"` Coinbase common.Address `json:"coinbase"` StateRoot common.Hash `json:"stateRoot"` GlobalExitRoot common.Hash `json:"globalExitRoot"` LocalExitRoot common.Hash `json:"localExitRoot"` AccInputHash common.Hash `json:"accInputHash"` Timestamp ArgUint64 `json:"timestamp"` SendSequencesTxHash *common.Hash `json:"sendSequencesTxHash"` VerifyBatchTxHash *common.Hash `json:"verifyBatchTxHash"` Transactions []TransactionOrHash `json:"transactions"` }
Batch structure
type BatchNumber ¶
type BatchNumber int64
BatchNumber is the number of a ethereum block
func (*BatchNumber) GetNumericBatchNumber ¶
func (b *BatchNumber) GetNumericBatchNumber(ctx context.Context, s StateInterface, dbTx pgx.Tx) (uint64, Error)
GetNumericBatchNumber returns a numeric batch number based on the BatchNumber instance
func (*BatchNumber) UnmarshalJSON ¶
func (b *BatchNumber) UnmarshalJSON(buffer []byte) error
UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called
type Block ¶
type Block struct { ParentHash common.Hash `json:"parentHash"` Sha3Uncles common.Hash `json:"sha3Uncles"` Miner common.Address `json:"miner"` StateRoot common.Hash `json:"stateRoot"` TxRoot common.Hash `json:"transactionsRoot"` ReceiptsRoot common.Hash `json:"receiptsRoot"` LogsBloom types.Bloom `json:"logsBloom"` Difficulty ArgUint64 `json:"difficulty"` TotalDifficulty ArgUint64 `json:"totalDifficulty"` Size ArgUint64 `json:"size"` Number ArgUint64 `json:"number"` GasLimit ArgUint64 `json:"gasLimit"` GasUsed ArgUint64 `json:"gasUsed"` Timestamp ArgUint64 `json:"timestamp"` ExtraData ArgBytes `json:"extraData"` MixHash common.Hash `json:"mixHash"` Nonce ArgBytes `json:"nonce"` Hash common.Hash `json:"hash"` Transactions []TransactionOrHash `json:"transactions"` Uncles []common.Hash `json:"uncles"` }
Block structure
type BlockNumber ¶
type BlockNumber int64
BlockNumber is the number of a ethereum block
func StringToBlockNumber ¶
func StringToBlockNumber(str string) (BlockNumber, error)
StringToBlockNumber converts a string like "latest" or "0x1" to a BlockNumber instance
func (*BlockNumber) GetNumericBlockNumber ¶
func (b *BlockNumber) GetNumericBlockNumber(ctx context.Context, s StateInterface, dbTx pgx.Tx) (uint64, Error)
GetNumericBlockNumber returns a numeric block number based on the BlockNumber instance
func (*BlockNumber) StringOrHex ¶
func (b *BlockNumber) StringOrHex() string
StringOrHex returns the block number as a string or hex n == -3 = pending n == -2 = latest n == -1 = earliest n >= 0 = hex(n)
func (*BlockNumber) UnmarshalJSON ¶
func (b *BlockNumber) UnmarshalJSON(buffer []byte) error
UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called
type ErrorObject ¶
type ErrorObject struct { Code int `json:"code"` Message string `json:"message"` Data *ArgBytes `json:"data,omitempty"` }
ErrorObject is a jsonrpc error
type Index ¶
type Index int64
Index of a item
func (*Index) UnmarshalJSON ¶
UnmarshalJSON automatically decodes the user input for the block number, when a JSON RPC method is called
type Log ¶
type Log struct { Address common.Address `json:"address"` Topics []common.Hash `json:"topics"` Data ArgBytes `json:"data"` BlockNumber ArgUint64 `json:"blockNumber"` TxHash common.Hash `json:"transactionHash"` TxIndex ArgUint64 `json:"transactionIndex"` BlockHash common.Hash `json:"blockHash"` LogIndex ArgUint64 `json:"logIndex"` Removed bool `json:"removed"` }
Log structure
type LogFilterRequest ¶
type LogFilterRequest struct { BlockHash *common.Hash `json:"blockHash,omitempty"` FromBlock *string `json:"fromBlock,omitempty"` ToBlock *string `json:"toBlock,omitempty"` Address interface{} `json:"address,omitempty"` Topics []interface{} `json:"topics,omitempty"` }
LogFilterRequest represents a log filter request.
type PoolInterface ¶
type PoolInterface interface { AddTx(ctx context.Context, tx types.Transaction, ip string) error GetGasPrice(ctx context.Context) (uint64, error) GetNonce(ctx context.Context, address common.Address) (uint64, error) GetPendingTxHashesSince(ctx context.Context, since time.Time) ([]common.Hash, error) GetPendingTxs(ctx context.Context, isClaims bool, limit uint64) ([]pool.Transaction, error) CountPendingTransactions(ctx context.Context) (uint64, error) GetTxByHash(ctx context.Context, hash common.Hash) (*pool.Transaction, error) }
PoolInterface contains the methods required to interact with the tx pool.
type RPCError ¶
type RPCError struct {
// contains filtered or unexported fields
}
RPCError represents an error returned by a JSON RPC endpoint.
func NewRPCError ¶
NewRPCError creates a new error instance to be returned by the RPC endpoints
func NewRPCErrorWithData ¶
NewRPCErrorWithData creates a new error instance with data to be returned by the RPC endpoints
type Receipt ¶
type Receipt struct { Root common.Hash `json:"root"` CumulativeGasUsed ArgUint64 `json:"cumulativeGasUsed"` LogsBloom types.Bloom `json:"logsBloom"` Logs []*types.Log `json:"logs"` Status ArgUint64 `json:"status"` TxHash common.Hash `json:"transactionHash"` TxIndex ArgUint64 `json:"transactionIndex"` BlockHash common.Hash `json:"blockHash"` BlockNumber ArgUint64 `json:"blockNumber"` GasUsed ArgUint64 `json:"gasUsed"` FromAddr common.Address `json:"from"` ToAddr *common.Address `json:"to"` ContractAddress *common.Address `json:"contractAddress"` Type ArgUint64 `json:"type"` }
Receipt structure
func NewReceipt ¶
NewReceipt creates a new Receipt instance
type Request ¶
type Request struct { JSONRPC string `json:"jsonrpc"` ID interface{} `json:"id"` Method string `json:"method"` Params json.RawMessage `json:"params,omitempty"` }
Request is a jsonrpc request
type Response ¶
type Response struct { JSONRPC string ID interface{} Result json.RawMessage Error *ErrorObject }
Response is a jsonrpc success response
func NewResponse ¶
NewResponse returns Success/Error response object
func (Response) MarshalJSON ¶
MarshalJSON customizes the JSON representation of the response.
type StateInterface ¶
type StateInterface interface { PrepareWebSocket() BeginStateTransaction(ctx context.Context) (pgx.Tx, error) DebugTransaction(ctx context.Context, transactionHash common.Hash, traceConfig state.TraceConfig, dbTx pgx.Tx) (*runtime.ExecutionResult, error) EstimateGas(transaction *types.Transaction, senderAddress common.Address, l2BlockNumber *uint64, dbTx pgx.Tx) (uint64, error) GetBalance(ctx context.Context, address common.Address, blockNumber uint64, dbTx pgx.Tx) (*big.Int, error) GetCode(ctx context.Context, address common.Address, blockNumber uint64, dbTx pgx.Tx) ([]byte, error) GetL2BlockByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (*types.Block, error) GetL2BlockByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*types.Block, error) BatchNumberByL2BlockNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error) GetL2BlockHashesSince(ctx context.Context, since time.Time, dbTx pgx.Tx) ([]common.Hash, error) GetL2BlockHeaderByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (*types.Header, error) GetL2BlockTransactionCountByHash(ctx context.Context, hash common.Hash, dbTx pgx.Tx) (uint64, error) GetL2BlockTransactionCountByNumber(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (uint64, error) GetLastConsolidatedL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) GetLastL2Block(ctx context.Context, dbTx pgx.Tx) (*types.Block, error) GetLastL2BlockNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) GetLogs(ctx context.Context, fromBlock uint64, toBlock uint64, addresses []common.Address, topics [][]common.Hash, blockHash *common.Hash, since *time.Time, dbTx pgx.Tx) ([]*types.Log, error) GetNonce(ctx context.Context, address common.Address, blockNumber uint64, dbTx pgx.Tx) (uint64, error) GetStorageAt(ctx context.Context, address common.Address, position *big.Int, blockNumber uint64, dbTx pgx.Tx) (*big.Int, error) GetSyncingInfo(ctx context.Context, dbTx pgx.Tx) (state.SyncingInfo, error) GetTransactionByHash(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Transaction, error) GetTransactionByL2BlockHashAndIndex(ctx context.Context, blockHash common.Hash, index uint64, dbTx pgx.Tx) (*types.Transaction, error) GetTransactionByL2BlockNumberAndIndex(ctx context.Context, blockNumber uint64, index uint64, dbTx pgx.Tx) (*types.Transaction, error) GetTransactionReceipt(ctx context.Context, transactionHash common.Hash, dbTx pgx.Tx) (*types.Receipt, error) IsL2BlockConsolidated(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error) IsL2BlockVirtualized(ctx context.Context, blockNumber uint64, dbTx pgx.Tx) (bool, error) ProcessUnsignedTransaction(ctx context.Context, tx *types.Transaction, senderAddress common.Address, l2BlockNumber uint64, noZKEVMCounters bool, dbTx pgx.Tx) *runtime.ExecutionResult RegisterNewL2BlockEventHandler(h state.NewL2BlockEventHandler) GetLastVirtualBatchNum(ctx context.Context, dbTx pgx.Tx) (uint64, error) GetLastVerifiedBatch(ctx context.Context, dbTx pgx.Tx) (*state.VerifiedBatch, error) GetLastBatchNumber(ctx context.Context, dbTx pgx.Tx) (uint64, error) GetBatchByNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.Batch, error) GetTransactionsByBatchNumber(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (txs []types.Transaction, err error) GetVirtualBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VirtualBatch, error) GetVerifiedBatch(ctx context.Context, batchNumber uint64, dbTx pgx.Tx) (*state.VerifiedBatch, error) }
StateInterface gathers the methods required to interact with the state.
type SubscriptionResponse ¶
type SubscriptionResponse struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params SubscriptionResponseParams `json:"params"` }
SubscriptionResponse used to push response for filters that have an active web socket connection
func (SubscriptionResponse) Bytes ¶
func (s SubscriptionResponse) Bytes() ([]byte, error)
Bytes return the serialized response
type SubscriptionResponseParams ¶
type SubscriptionResponseParams struct { Subscription string `json:"subscription"` Result json.RawMessage `json:"result"` }
SubscriptionResponseParams parameters for subscription responses
type Transaction ¶
type Transaction struct { Nonce ArgUint64 `json:"nonce"` GasPrice ArgBig `json:"gasPrice"` Gas ArgUint64 `json:"gas"` To *common.Address `json:"to"` Value ArgBig `json:"value"` Input ArgBytes `json:"input"` V ArgBig `json:"v"` R ArgBig `json:"r"` S ArgBig `json:"s"` Hash common.Hash `json:"hash"` From common.Address `json:"from"` BlockHash *common.Hash `json:"blockHash"` BlockNumber *ArgUint64 `json:"blockNumber"` TxIndex *ArgUint64 `json:"transactionIndex"` ChainID ArgBig `json:"chainId"` Type ArgUint64 `json:"type"` }
Transaction structure
func NewTransaction ¶
func NewTransaction( t types.Transaction, blockNumber *big.Int, blockHash *common.Hash, txIndex *uint64, ) *Transaction
NewTransaction creates a transaction instance
func (Transaction) CoreTx ¶
func (t Transaction) CoreTx() *types.Transaction
CoreTx returns a geth core type Transaction
type TransactionOrHash ¶
type TransactionOrHash struct { Hash *common.Hash Tx *Transaction }
TransactionOrHash for union type of transaction and types.Hash
func (TransactionOrHash) MarshalJSON ¶
func (b TransactionOrHash) MarshalJSON() ([]byte, error)
MarshalJSON marshals into json
func (*TransactionOrHash) UnmarshalJSON ¶
func (b *TransactionOrHash) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from json
type TxArgs ¶
type TxArgs struct { From common.Address To *common.Address Gas *ArgUint64 GasPrice *ArgUint64 Value *ArgBytes Data *ArgBytes }
TxArgs is the transaction argument for the rpc endpoints
func (*TxArgs) ToTransaction ¶
func (args *TxArgs) ToTransaction(ctx context.Context, st StateInterface, blockNumber, maxCumulativeGasUsed uint64, defaultSenderAddress common.Address, dbTx pgx.Tx) (common.Address, *types.Transaction, error)
ToTransaction transforms txnArgs into a Transaction