Documentation
¶
Overview ¶
Package client provides the mediator for processing incoming UserOperations to the bundler.
Index ¶
- type Client
- func (i *Client) ChainID() (string, error)
- func (i *Client) EstimateUserOperationGas(op map[string]any, ep string) (*gas.GasEstimates, error)
- func (i *Client) GetUserOperationByHash(hash string) (*filter.HashLookupResult, error)
- func (i *Client) GetUserOperationReceipt(hash string) (*filter.UserOperationReceipt, error)
- func (i *Client) SendUserOperation(op map[string]any, ep string) (string, error)
- func (i *Client) SetGetGasEstimateFunc(fn GetGasEstimateFunc)
- func (i *Client) SetGetUserOpByHashFunc(fn GetUserOpByHashFunc)
- func (i *Client) SetGetUserOpReceiptFunc(fn GetUserOpReceiptFunc)
- func (i *Client) SupportedEntryPoints() ([]string, error)
- func (i *Client) UseLogger(logger logr.Logger)
- func (i *Client) UseModules(handlers ...modules.UserOpHandlerFunc)
- type Debug
- type GetGasEstimateFunc
- type GetUserOpByHashFunc
- type GetUserOpReceiptFunc
- type RpcAdapter
- func (r *RpcAdapter) Debug_bundler_clearState() (string, error)
- func (r *RpcAdapter) Debug_bundler_dumpMempool(ep string) ([]map[string]any, error)
- func (r *RpcAdapter) Debug_bundler_sendBundleNow() (string, error)
- func (r *RpcAdapter) Debug_bundler_setBundlingMode(mode string) (string, error)
- func (r *RpcAdapter) Eth_chainId() (string, error)
- func (r *RpcAdapter) Eth_estimateUserOperationGas(op map[string]any, ep string) (*gas.GasEstimates, error)
- func (r *RpcAdapter) Eth_getUserOperationByHash(userOpHash string) (*filter.HashLookupResult, error)
- func (r *RpcAdapter) Eth_getUserOperationReceipt(userOpHash string) (*filter.UserOperationReceipt, error)
- func (r *RpcAdapter) Eth_sendUserOperation(op map[string]any, ep string) (string, error)
- func (r *RpcAdapter) Eth_supportedEntryPoints() ([]string, error)
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, ov *gas.Overhead, 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 ¶
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) EstimateUserOperationGas ¶ added in v0.2.0
EstimateUserOperationGas returns estimates for PreVerificationGas, VerificationGas, and CallGasLimit given a UserOperation and EntryPoint address. The signature field and current gas values will not be validated although there should be dummy values in place for the most reliable results (e.g. a signature with the correct length).
func (*Client) GetUserOperationByHash ¶ added in v0.3.0
func (i *Client) GetUserOperationByHash(hash string) (*filter.HashLookupResult, error)
GetUserOperationByHash returns a UserOperation based on a given userOpHash returned by *Client.SendUserOperation.
func (*Client) GetUserOperationReceipt ¶ added in v0.2.0
func (i *Client) GetUserOperationReceipt( hash string, ) (*filter.UserOperationReceipt, error)
GetUserOperationReceipt fetches a UserOperation receipt based on a userOpHash returned by *Client.SendUserOperation.
func (*Client) SendUserOperation ¶
SendUserOperation implements the method call for eth_sendUserOperation. It returns true if userOp was accepted otherwise returns an error.
func (*Client) SetGetGasEstimateFunc ¶ added in v0.6.0
func (i *Client) SetGetGasEstimateFunc(fn GetGasEstimateFunc)
SetGetGasEstimateFunc defines a general function for fetching an estimate for verificationGasLimit and callGasLimit given a userOp and EntryPoint address. This function is called in *Client.EstimateUserOperationGas.
func (*Client) SetGetUserOpByHashFunc ¶ added in v0.3.0
func (i *Client) SetGetUserOpByHashFunc(fn GetUserOpByHashFunc)
SetGetUserOpByHashFunc defines a general function for fetching a userOp given a userOpHash, EntryPoint address, and chain ID. This function is called in *Client.GetUserOperationByHash.
func (*Client) SetGetUserOpReceiptFunc ¶ added in v0.2.0
func (i *Client) SetGetUserOpReceiptFunc(fn GetUserOpReceiptFunc)
SetGetUserOpReceiptFunc defines a general function for fetching a UserOpReceipt given a userOpHash and EntryPoint address. This function is called in *Client.GetUserOperationReceipt.
func (*Client) SupportedEntryPoints ¶
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 ¶
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 Debug ¶ added in v0.2.0
type Debug struct {
// contains filtered or unexported fields
}
Debug exposes methods used for testing the bundler. These should not be made available in production.
func (*Debug) ClearState ¶ added in v0.2.0
ClearState clears the bundler mempool and reputation data of paymasters/accounts/factories/aggregators.
func (*Debug) DumpMempool ¶ added in v0.2.0
DumpMempool dumps the current UserOperations mempool in order of arrival.
func (*Debug) SendBundleNow ¶ added in v0.2.0
SendBundleNow forces the bundler to build and execute a bundle from the mempool as handleOps() transaction.
type GetGasEstimateFunc ¶ added in v0.6.0
type GetGasEstimateFunc = func(ep common.Address, op *userop.UserOperation) (verificationGas uint64, callGas uint64, err error)
GetGasEstimateFunc is a general interface for fetching an estimate for verificationGasLimit and callGasLimit given a userOp and EntryPoint address.
func GetGasEstimateWithEthClient ¶ added in v0.6.0
func GetGasEstimateWithEthClient( rpc *rpc.Client, ov *gas.Overhead, chain *big.Int, tracer string, ) GetGasEstimateFunc
GetGasEstimateWithEthClient returns an implementation of GetGasEstimateFunc that relies on an eth client to fetch an estimate for verificationGasLimit and callGasLimit.
type GetUserOpByHashFunc ¶ added in v0.3.0
type GetUserOpByHashFunc func(hash string, ep common.Address, chain *big.Int) (*filter.HashLookupResult, error)
GetUserOpByHashFunc is a general interface for fetching a UserOperation given a userOpHash, EntryPoint address, and chain ID.
func GetUserOpByHashWithEthClient ¶ added in v0.3.0
func GetUserOpByHashWithEthClient(eth *ethclient.Client) GetUserOpByHashFunc
GetUserOpByHashWithEthClient returns an implementation of GetUserOpByHashFunc that relies on an eth client to fetch a UserOperation.
type GetUserOpReceiptFunc ¶ added in v0.2.0
type GetUserOpReceiptFunc = func(hash string, ep common.Address) (*filter.UserOperationReceipt, error)
GetUserOpReceiptFunc is a general interface for fetching a UserOperationReceipt given a userOpHash and EntryPoint address.
func GetUserOpReceiptWithEthClient ¶ added in v0.2.0
func GetUserOpReceiptWithEthClient(eth *ethclient.Client) GetUserOpReceiptFunc
GetUserOpReceiptWithEthClient returns an implementation of GetUserOpReceiptFunc that relies on an eth client to fetch a UserOperationReceipt.
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, debug *Debug) *RpcAdapter
NewRpcAdapter initializes a new RpcAdapter which can be used with a JSON-RPC server.
func (*RpcAdapter) Debug_bundler_clearState ¶ added in v0.2.0
func (r *RpcAdapter) Debug_bundler_clearState() (string, error)
Debug_bundler_clearState routes method calls to *Debug.ClearState.
func (*RpcAdapter) Debug_bundler_dumpMempool ¶ added in v0.2.0
func (r *RpcAdapter) Debug_bundler_dumpMempool(ep string) ([]map[string]any, error)
Debug_bundler_dumpMempool routes method calls to *Debug.DumpMempool.
func (*RpcAdapter) Debug_bundler_sendBundleNow ¶ added in v0.2.0
func (r *RpcAdapter) Debug_bundler_sendBundleNow() (string, error)
Debug_bundler_sendBundleNow routes method calls to *Debug.SendBundleNow.
func (*RpcAdapter) Debug_bundler_setBundlingMode ¶ added in v0.2.0
func (r *RpcAdapter) Debug_bundler_setBundlingMode(mode string) (string, error)
Debug_bundler_setBundlingMode routes method calls to *Debug.SetBundlingMode.
func (*RpcAdapter) Eth_chainId ¶
func (r *RpcAdapter) Eth_chainId() (string, error)
Eth_chainId routes method calls to *Client.ChainID.
func (*RpcAdapter) Eth_estimateUserOperationGas ¶ added in v0.2.0
func (r *RpcAdapter) Eth_estimateUserOperationGas(op map[string]any, ep string) (*gas.GasEstimates, error)
Eth_estimateUserOperationGas routes method calls to *Client.EstimateUserOperationGas.
func (*RpcAdapter) Eth_getUserOperationByHash ¶ added in v0.3.0
func (r *RpcAdapter) Eth_getUserOperationByHash( userOpHash string, ) (*filter.HashLookupResult, error)
Eth_getUserOperationByHash routes method calls to *Client.GetUserOperationByHash.
func (*RpcAdapter) Eth_getUserOperationReceipt ¶ added in v0.2.0
func (r *RpcAdapter) Eth_getUserOperationReceipt( userOpHash string, ) (*filter.UserOperationReceipt, error)
Eth_getUserOperationReceipt routes method calls to *Client.GetUserOperationReceipt.
func (*RpcAdapter) Eth_sendUserOperation ¶
Eth_sendUserOperation routes method calls to *Client.SendUserOperation.
func (*RpcAdapter) Eth_supportedEntryPoints ¶
func (r *RpcAdapter) Eth_supportedEntryPoints() ([]string, error)
Eth_supportedEntryPoints routes method calls to *Client.SupportedEntryPoints.