userop

package
v0.6.47 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: GPL-3.0 Imports: 13 Imported by: 2

Documentation

Overview

Package userop provides the base transaction object used throughout the stackup-bundler.

Index

Constants

This section is empty.

Variables

View Source
var (

	// UserOpPrimitives is the primitive ABI types for each UserOperation field.
	UserOpPrimitives = []abi.ArgumentMarshaling{
		{Name: "sender", InternalType: "Sender", Type: "address"},
		{Name: "nonce", InternalType: "Nonce", Type: "uint256"},
		{Name: "initCode", InternalType: "InitCode", Type: "bytes"},
		{Name: "callData", InternalType: "CallData", Type: "bytes"},
		{Name: "callGasLimit", InternalType: "CallGasLimit", Type: "uint256"},
		{Name: "verificationGasLimit", InternalType: "VerificationGasLimit", Type: "uint256"},
		{Name: "preVerificationGas", InternalType: "PreVerificationGas", Type: "uint256"},
		{Name: "maxFeePerGas", InternalType: "MaxFeePerGas", Type: "uint256"},
		{Name: "maxPriorityFeePerGas", InternalType: "MaxPriorityFeePerGas", Type: "uint256"},
		{Name: "paymasterAndData", InternalType: "PaymasterAndData", Type: "bytes"},
		{Name: "signature", InternalType: "Signature", Type: "bytes"},
	}

	// UserOpType is the ABI type of a UserOperation.
	UserOpType, _ = abi.NewType("tuple", "op", UserOpPrimitives)

	// UserOpArr is the ABI type for an array of UserOperations.
	UserOpArr, _ = abi.NewType("tuple[]", "ops", UserOpPrimitives)
)
View Source
var (
	ErrBadUserOperationData = errors.New("cannot decode UserOperation")
)

Functions

This section is empty.

Types

type UserOperation

type UserOperation struct {
	Sender               common.Address `json:"sender"               mapstructure:"sender"               validate:"required"`
	Nonce                *big.Int       `json:"nonce"                mapstructure:"nonce"                validate:"required"`
	InitCode             []byte         `json:"initCode"             mapstructure:"initCode"             validate:"required"`
	CallData             []byte         `json:"callData"             mapstructure:"callData"             validate:"required"`
	CallGasLimit         *big.Int       `json:"callGasLimit"         mapstructure:"callGasLimit"         validate:"required"`
	VerificationGasLimit *big.Int       `json:"verificationGasLimit" mapstructure:"verificationGasLimit" validate:"required"`
	PreVerificationGas   *big.Int       `json:"preVerificationGas"   mapstructure:"preVerificationGas"   validate:"required"`
	MaxFeePerGas         *big.Int       `json:"maxFeePerGas"         mapstructure:"maxFeePerGas"         validate:"required"`
	MaxPriorityFeePerGas *big.Int       `json:"maxPriorityFeePerGas" mapstructure:"maxPriorityFeePerGas" validate:"required"`
	PaymasterAndData     []byte         `json:"paymasterAndData"     mapstructure:"paymasterAndData"     validate:"required"`
	Signature            []byte         `json:"signature"            mapstructure:"signature"            validate:"required"`
}

UserOperation represents an EIP-4337 style transaction for a smart contract account.

func New

func New(data map[string]any) (*UserOperation, error)

New decodes a map into a UserOperation object and validates all the fields are correctly typed.

func (*UserOperation) GetDynamicGasPrice added in v0.6.5

func (op *UserOperation) GetDynamicGasPrice(basefee *big.Int) *big.Int

GetDynamicGasPrice returns the effective gas price paid by the UserOperation given a basefee. If basefee is nil, it will assume a value of 0.

func (*UserOperation) GetFactory added in v0.1.1

func (op *UserOperation) GetFactory() common.Address

GetFactory returns the address portion of InitCode if applicable. Otherwise it returns the zero address.

func (*UserOperation) GetFactoryData added in v0.6.33

func (op *UserOperation) GetFactoryData() []byte

GetFactoryData returns the data portion of InitCode if applicable. Otherwise it returns an empty byte array.

func (*UserOperation) GetMaxGasAvailable added in v0.6.9

func (op *UserOperation) GetMaxGasAvailable() *big.Int

GetMaxGasAvailable returns the max amount of gas that can be consumed by this UserOperation.

func (*UserOperation) GetMaxPrefund

func (op *UserOperation) GetMaxPrefund() *big.Int

GetMaxPrefund returns the max amount of wei required to pay for gas fees by either the sender or paymaster.

func (*UserOperation) GetPaymaster

func (op *UserOperation) GetPaymaster() common.Address

GetPaymaster returns the address portion of PaymasterAndData if applicable. Otherwise it returns the zero address.

func (*UserOperation) GetUserOpHash

func (op *UserOperation) GetUserOpHash(entryPoint common.Address, chainID *big.Int) common.Hash

GetUserOpHash returns the hash of the userOp + entryPoint address + chainID.

func (*UserOperation) MarshalJSON

func (op *UserOperation) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON encoding of the UserOperation.

func (*UserOperation) Pack

func (op *UserOperation) Pack() []byte

Pack returns a standard message of the userOp. This cannot be used to generate a userOpHash.

func (*UserOperation) PackForSignature

func (op *UserOperation) PackForSignature() []byte

PackForSignature returns a minimal message of the userOp. This can be used to generate a userOpHash.

func (*UserOperation) ToMap added in v0.6.0

func (op *UserOperation) ToMap() (map[string]any, error)

ToMap returns the current UserOp struct as a map type.

Jump to

Keyboard shortcuts

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