rpc

package
v0.44.0-model Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: GPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtERC4337Controller

func ExtERC4337Controller(hashesMap *xsync.MapOf[string, srv.OpHashes],
	rpcAdapter *client.RpcAdapter, rpcClient *rpc.Client,
	ethRPCClient *ethclient.Client, values *conf.Values,
	logger logr.Logger) gin.HandlerFunc

ExtERC4337Controller extends the default JSON-RPC controller to handle non-ERC4337 Ethereum RPC methods.

func GetClientIPFromXFF

func GetClientIPFromXFF(c *gin.Context) string

GetClientIPFromXFF returns the client ID using x-forwarded-for headers before relying on c.ClientIP(). This assumes use of a trusted proxy.

func NewRPCServer

func NewRPCServer(values *conf.Values, logger logr.Logger, relayer *srv.Relayer,
	rpcAdapter *client.RpcAdapter, ethClient *ethclient.Client,
	rpcClient *rpc.Client, chainID *big.Int) (*gin.Engine, func())

func ParseAndSetBlockNumber

func ParseAndSetBlockNumber(span SpanSetAttr, params []interface{}) (*big.Int, error)

ParseAndSetBlockNumber parses the block number from the provided parameters and sets it as an attribute on the given span.

Parameters:

  • span: A SpanSetAttr interface for setting attributes.
  • params: A slice of interface{} containing the RPC method parameters. The block number is expected to be the second parameter (index 1) if present.

Returns:

  • *big.Int: The parsed block number as a big.Int. Returns nil for "latest", "pending", or "earliest".
  • error: An error if the block number parsing fails or if the parameter is invalid.

The function handles the following cases:

  • No block number provided: Sets the attribute to "latest".
  • Special strings "latest", "pending", "earliest": Sets the attribute accordingly.
  • Numeric strings (decimal or hex): Parses and sets the numeric value.

If successful, it sets the "block_number" attribute on the provided span with the parsed or default value.

func ParseBlockNumber

func ParseBlockNumber(blockParam string) (*big.Int, error)

ParseBlockNumber converts a string representation of a block number to a *big.Int.

Parameters:

  • blockParam: A string representing the block number. It Can be a numeric string (decimal or hexadecimal with "0x" prefix), or one of the special values "latest", "pending", or "earliest".

Returns:

  • *big.Int: The parsed block number as a big.Int. Returns nil for "latest", "pending", or "earliest".
  • error: An error if the parsing fails or if the input is invalid.

The function handles the following cases:

  • "latest", "pending", "earliest": Returns (nil, nil).
  • Hexadecimal (with "0x" prefix): Parses as hexadecimal.
  • Decimal: Attempts to parse as decimal first, then as hexadecimal if decimal parsing fails.

Note: The function returns an error for negative numbers or invalid string formats.

func WithLogr

func WithLogr(logger logr.Logger) gin.HandlerFunc

WithLogr uses a logger with the go-logr/logr interface to log a gin HTTP request.

Types

type HashesResponse

type HashesResponse struct {
	Success bool `json:"success"`
	// SDK or original unsolved user operation hash
	OriginalHash string `json:"original_hash"`
	// If different, it is the hash corresponding to the solved user operation
	SolvedHash string `json:"solved_hash"`
	// Transaction hash
	Trx string `json:"trx"`
}

type SpanSetAttr

type SpanSetAttr interface {
	SetAttributes(...attribute.KeyValue)
}

Jump to

Keyboard shortcuts

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