Documentation ¶
Index ¶
- func ExtERC4337Controller(hashesMap *xsync.MapOf[string, srv.OpHashes], rpcAdapter *client.RpcAdapter, ...) gin.HandlerFunc
- func GetClientIPFromXFF(c *gin.Context) string
- func NewRPCServer(values *conf.Values, logger logr.Logger, relayer *srv.Relayer, ...) (*gin.Engine, func())
- func ParseAndSetBlockNumber(span SpanSetAttr, params []interface{}) (*big.Int, error)
- func ParseBlockNumber(blockParam string) (*big.Int, error)
- func WithLogr(logger logr.Logger) gin.HandlerFunc
- type HashesResponse
- type SpanSetAttr
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 ¶
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 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 ¶
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.
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"` }