bundler_client

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: MIT Imports: 8 Imported by: 0

README

go-bundler-client

Golang client for ERC-4337-spec bundlers. Uses types from Stackup's bundler.

Example
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/mdehoog/go-bundler-client"
)

func main() {
	ctx := context.Background()
	c, err := bundler_client.DialContext(ctx, "http://localhost:4337")
	if err != nil {
		log.Fatalf("Failed to connect to bundler: %v", err)
	}

	chainId, err := c.ChainId(ctx)
	if err != nil {
		log.Fatalf("Failed to retrieve chainId from bundler: %v", err)
	}
	fmt.Printf("ChainId: %d\n", chainId.Uint64())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	EthClient
	DebugClient
}

func Dial

func Dial(rawurl string) (Client, error)

func DialContext

func DialContext(ctx context.Context, rawurl string) (Client, error)

func NewClient

func NewClient(c *rpc.Client) Client

type DebugClient

type DebugClient interface {
	BundlerClearState(ctx context.Context) error
	BundlerDumpMempool(ctx context.Context, entryPoint common.Address) ([]*userop.UserOperation, error)
	BundlerSendBundleNow(ctx context.Context) (*common.Hash, error)
	BundlerSetBundlingMode(ctx context.Context, mode string) error
}

type EthClient

type EthClient interface {
	SendUserOperation(ctx context.Context, op *userop.UserOperation, entryPoint common.Address) (common.Hash, error)
	EstimateUserOperationGas(ctx context.Context, op *userop.UserOperation, entryPoint common.Address) (*gas.GasEstimates, error)
	GetUserOperationReceipt(ctx context.Context, userOpHash common.Hash) (*filter.UserOperationReceipt, error)
	GetUserOperationByHash(ctx context.Context, userOpHash common.Hash) (*filter.HashLookupResult, error)
	SupportedEntryPoints(ctx context.Context) ([]common.Address, error)
	ChainId(ctx context.Context) (*big.Int, error)
}

type RpcClient

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

func (*RpcClient) BundlerClearState

func (c *RpcClient) BundlerClearState(ctx context.Context) error

func (*RpcClient) BundlerDumpMempool

func (c *RpcClient) BundlerDumpMempool(ctx context.Context, entryPoint common.Address) ([]*userop.UserOperation, error)

func (*RpcClient) BundlerSendBundleNow

func (c *RpcClient) BundlerSendBundleNow(ctx context.Context) (*common.Hash, error)

func (*RpcClient) BundlerSetBundlingMode

func (c *RpcClient) BundlerSetBundlingMode(ctx context.Context, mode string) error

func (*RpcClient) ChainId

func (c *RpcClient) ChainId(ctx context.Context) (*big.Int, error)

func (*RpcClient) EstimateUserOperationGas

func (c *RpcClient) EstimateUserOperationGas(ctx context.Context, op *userop.UserOperation, entryPoint common.Address) (*gas.GasEstimates, error)

func (*RpcClient) GetUserOperationByHash

func (c *RpcClient) GetUserOperationByHash(ctx context.Context, userOpHash common.Hash) (*filter.HashLookupResult, error)

func (*RpcClient) GetUserOperationReceipt

func (c *RpcClient) GetUserOperationReceipt(ctx context.Context, userOpHash common.Hash) (*filter.UserOperationReceipt, error)

func (*RpcClient) SendUserOperation

func (c *RpcClient) SendUserOperation(ctx context.Context, op *userop.UserOperation, entryPoint common.Address) (common.Hash, error)

func (*RpcClient) SupportedEntryPoints

func (c *RpcClient) SupportedEntryPoints(ctx context.Context) ([]common.Address, error)

type UserOperation

type UserOperation struct {
	Sender               common.Address `json:"sender"`
	Nonce                *hexutil.Big   `json:"nonce"`
	InitCode             hexutil.Bytes  `json:"initCode"`
	CallData             hexutil.Bytes  `json:"callData"`
	CallGasLimit         *hexutil.Big   `json:"callGasLimit"`
	VerificationGasLimit *hexutil.Big   `json:"verificationGasLimit"`
	PreVerificationGas   *hexutil.Big   `json:"preVerificationGas"`
	MaxFeePerGas         *hexutil.Big   `json:"maxFeePerGas"`
	MaxPriorityFeePerGas *hexutil.Big   `json:"maxPriorityFeePerGas"`
	PaymasterAndData     hexutil.Bytes  `json:"paymasterAndData"`
	Signature            hexutil.Bytes  `json:"signature"`
}

func (*UserOperation) ToUserOperation

func (uo *UserOperation) ToUserOperation() *userop.UserOperation

Jump to

Keyboard shortcuts

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