userop

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const PAYMASTER_DATA_OFFSET = 52
View Source
const PAYMASTER_POSTOP_GAS_OFFSET = 36
View Source
const PAYMASTER_VALIDATION_GAS_OFFSET = 20

Variables

View Source
var (
	DefaultCallGasLimit                  = uint64(2000000)
	DefaultVerificationGasLimit          = uint64(200000)
	DefaultPreVerificationGas            = uint64(20000)
	DefaultMaxFeePerGas                  = uint64(1000)
	DefaultMaxPriorityFeePerGas          = uint64(1000000)
	DefaultPaymasterVerificationGasLimit = uint64(1000)
	DefaultPaymasterPostOpGasLimit       = uint64(100)
)

Default Gas cost values

callGasLimit: 4000000,
 verificationGasLimit: 200000,
 preVerificationGas: 20000,
 maxFeePerGas: 1000,
 maxPriorityFeePerGas: 1000000,
 paymasterVerificationGasLimit: 0,
 paymasterPostOpGasLimit: 0,

Functions

func BytesToString

func BytesToString(bts []byte) string

func EncodeWithParams

func EncodeWithParams(abis *abi.ABI, method string, params ...interface{}) (data []byte, err error)

TODO Get rid of this function

func GetPaymasterV7Hash added in v0.2.0

func GetPaymasterV7Hash(puop *PackedUserOp, chainId, validAfter, validUntil uint64) ([]byte, []byte, error)

func GetUsOpLibPrehash

func GetUsOpLibPrehash(pUserOp *PackedUserOp) (hash [32]byte, err error)

func GetUsOpLibPrehashV6 added in v0.1.0

func GetUsOpLibPrehashV6(userOp *UserOperation) (hash [32]byte, err error)

func GetUserOpBytesToHash

func GetUserOpBytesToHash(userOp *PackedUserOp, entryPoint common.Address, chainid uint64) (encoded []byte, err error)

func GetUserOpBytesToHashV6 added in v0.1.0

func GetUserOpBytesToHashV6(userOp *UserOperation, entryPoint common.Address, chainid uint64) (encoded []byte, err error)

func GetUserOpHashV6 added in v0.1.0

func GetUserOpHashV6(userOp *UserOperation, entryPoint common.Address, chainid uint64) (hash [32]byte, err error)

keccak256(abi.encode(UserOperationLib.hash(userOp), address(this), block.chainid));

func GetUserOpHashV7 added in v0.2.0

func GetUserOpHashV7(userOp *PackedUserOp, entryPoint common.Address, chainid uint64) (hash [32]byte, err error)

keccak256(abi.encode(UserOperationLib.hash(userOp), address(this), block.chainid));

func JSAddressHex

func JSAddressHex(addr *common.Address) string

func JSBytesToString

func JSBytesToString(bts []byte) string

func PackUints

func PackUints(a, b uint64) [32]byte

func ParamToString

func ParamToString(p interface{}) string

func SliceToBytes32

func SliceToBytes32(s []byte) ([32]byte, error)

func ToRemixHex

func ToRemixHex(data []byte) string

func UnpackUints

func UnpackUints(buf [32]byte) (uint64, uint64)

func UnsafeSliceToBytes32

func UnsafeSliceToBytes32(s []byte) [32]byte

Types

type PackedUserOp

type PackedUserOp struct {
	Sender             *common.Address
	Nonce              *big.Int
	InitCode           []byte
	CallData           []byte
	AccountGasLimits   [32]byte
	PreVerificationGas *big.Int
	GasFees            [32]byte
	PaymasterAndData   []byte
	Signature          []byte
}

PackedUserOp is an EntryPoint viev of UserOp

sender address nonce uint256 initCode bytes concatenation of factory address and factoryData (or empty) callData bytes accountGasLimits bytes32 concatenation of verificationGas (16 bytes) and callGas (16 bytes) preVerificationGas uint256 gasFees bytes32 concatenation of maxPriorityFee (16 bytes) and maxFeePerGas (16 bytes) paymasterAndData bytes concatenation of paymaster fields (or empty) signature bytes

func (*PackedUserOp) EncodeToHash

func (puop *PackedUserOp) EncodeToHash() ([]byte, error)

func (*PackedUserOp) MarshalJSON

func (puop *PackedUserOp) MarshalJSON() ([]byte, error)

func (*PackedUserOp) MarshalRemix

func (u *PackedUserOp) MarshalRemix() string

type UsOpJsonAdapter added in v0.1.0

type UsOpJsonAdapter struct {
	Sender                        string `json:"sender"`
	Nonce                         uint64 `json:"nonce"`
	Factory                       string `json:"factory,omitempty"`
	FactoryData                   string `json:"factoryData,omitempty"`
	CallData                      string `json:"callData"`
	CallGasLimit                  uint64 `json:"callGasLimit"`
	VerificationGasLimit          uint64 `json:"verificationGasLimit"`
	PreVerificationGas            uint64 `json:"preVerificationGas"`
	MaxFeePerGas                  uint64 `json:"maxFeePerGas"`
	MaxPriorityFeePerGas          uint64 `json:"maxPriorityFeePerGas"`
	Paymaster                     string `json:"paymaster,omitempty"`
	PaymasterVerificationGasLimit uint64 `json:"paymasterVerificationGasLimit"`
	PaymasterPostOpGasLimit       uint64 `json:"paymasterPostOpGasLimit"`
	PaymasterData                 string `json:"paymasterData"`
	Signature                     string `json:"signature"`
}

type UserOperation added in v0.2.0

type UserOperation struct {
	Sender *common.Address `json:"sender"`
	Nonce  uint64          `json:"nonce"` // internaly, for the ease of increment, etc
	// Factory address, only for new accounts
	Factory *common.Address `json:"factory,omitempty"`
	// Data for account factory (only if account factory exists)
	FactoryData []byte `json:"factoryData,omitempty"`
	// Data to pass to the sender during the main execution call
	CallData []byte `json:"callData"`
	// The amount of gas to allocate the main execution call
	CallGasLimit uint64 `json:"callGasLimit"`
	// The amount of gas to allocate for the verification step
	VerificationGasLimit uint64 `json:"verificationGasLimit"`
	// Extra gas to pay the bunder
	PreVerificationGas uint64 `json:"preVerificationGas"`
	// Maximum fee per gas (similar to EIP-1559 max_fee_per_gas)
	MaxFeePerGas uint64 `json:"maxFeePerGas"`
	// Maximum priority fee per gas (similar to EIP-1559 max_priority_fee_per_gas)
	MaxPriorityFeePerGas uint64 `json:"maxPriorityFeePerGas"`
	// Address of paymaster contract, (or empty, if account pays for itself)
	Paymaster *common.Address `json:"paymaster,omitempty"`
	// The amount of gas to allocate for the paymaster validation code
	PaymasterVerificationGasLimit uint64 `json:"paymasterVerificationGasLimit"`
	// The amount of gas to allocate for the paymaster post-operation code
	PaymasterPostOpGasLimit uint64 `json:"paymasterPostOpGasLimit"`
	// Data for paymaster (only if paymaster exists)
	PaymasterData []byte `json:"paymasterData"`
	// Data passed into the account to verify authorization
	Signature []byte `json:"signature"`
}

func NewUserOperationWithDefaults added in v0.2.0

func NewUserOperationWithDefaults() *UserOperation

func (*UserOperation) EncodeToHash added in v0.2.0

func (uop *UserOperation) EncodeToHash() ([]byte, error)

func (*UserOperation) GetRequiredPrefund added in v0.2.0

func (mop *UserOperation) GetRequiredPrefund() *big.Int

func (*UserOperation) InitData added in v0.2.0

func (u *UserOperation) InitData() []byte

func (*UserOperation) MarshalAlchemy added in v0.2.1

func (u *UserOperation) MarshalAlchemy() string

func (UserOperation) MarshalJSON added in v0.2.0

func (u UserOperation) MarshalJSON() ([]byte, error)

func (*UserOperation) MarshalRemixV6 added in v0.2.0

func (u *UserOperation) MarshalRemixV6() string

func (*UserOperation) MarshalV6UserOp added in v0.2.1

func (u *UserOperation) MarshalV6UserOp() entrypointv6.UserOperation

func (*UserOperation) MarshalValuesV6 added in v0.2.0

func (u *UserOperation) MarshalValuesV6() []interface{}

func (*UserOperation) Pack added in v0.2.0

func (u *UserOperation) Pack() *PackedUserOp

func (*UserOperation) PaymasterAndData added in v0.2.0

func (u *UserOperation) PaymasterAndData() []byte

func (*UserOperation) TotalGasLimit added in v0.2.1

func (u *UserOperation) TotalGasLimit() uint64

func (*UserOperation) UnmarshalJSON added in v0.2.0

func (u *UserOperation) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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