client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: GPL-3.0 Imports: 9 Imported by: 2

Documentation

Overview

Package client provides the mediator for processing incoming UserOperations to the bundler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client controls the end to end process of adding incoming UserOperations to the mempool. It also implements the required RPC methods as specified in EIP-4337.

func New

func New(mempool *mempool.Mempool, chainID *big.Int, supportedEntryPoints []common.Address) *Client

New initializes a new ERC-4337 client which can be extended with modules for validating UserOperations that are allowed to be added to the mempool.

func (*Client) ChainID

func (i *Client) ChainID() (string, error)

ChainID implements the method call for eth_chainId. It returns the current chainID used by the client. This method is used to validate that the client's chainID is in sync with the caller.

func (*Client) SendUserOperation

func (i *Client) SendUserOperation(op map[string]any, ep string) (string, error)

SendUserOperation implements the method call for eth_sendUserOperation. It returns true if userOp was accepted otherwise returns an error.

func (*Client) SupportedEntryPoints

func (i *Client) SupportedEntryPoints() ([]string, error)

SupportedEntryPoints implements the method call for eth_supportedEntryPoints. It returns the array of EntryPoint addresses that is supported by the client. The first address in the array is the preferred EntryPoint.

func (*Client) UseLogger

func (i *Client) UseLogger(logger logr.Logger)

UseLogger defines the logger object used by the Client instance based on the go-logr/logr interface.

func (*Client) UseModules

func (i *Client) UseModules(handlers ...modules.UserOpHandlerFunc)

UseModules defines the UserOpHandlers to process a userOp after it has gone through the standard checks.

type RpcAdapter

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

RpcAdapter is an adapter for routing JSON-RPC method calls to the correct client functions.

func NewRpcAdapter

func NewRpcAdapter(client *Client) *RpcAdapter

NewRpcAdapter initializes a new RpcAdapter which can be used with a JSON-RPC server.

func (*RpcAdapter) Eth_chainId

func (r *RpcAdapter) Eth_chainId() (string, error)

Eth_chainId routes eth_chainId method calls to *Client.ChainID.

func (*RpcAdapter) Eth_sendUserOperation

func (r *RpcAdapter) Eth_sendUserOperation(op map[string]any, ep string) (string, error)

Eth_sendUserOperation routes eth_sendUserOperation method calls to *Client.SendUserOperation.

func (*RpcAdapter) Eth_supportedEntryPoints

func (r *RpcAdapter) Eth_supportedEntryPoints() ([]string, error)

Eth_supportedEntryPoints routes eth_supportedEntryPoints method calls to *Client.SupportedEntryPoints.

Jump to

Keyboard shortcuts

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