operation

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDAppOpFromDoesNotMatchSessionKey = relayerror.NewError(2200, "dApp operation's 'from' field does not match user operation's session key")
	ErrDAppOpInvalidToField             = relayerror.NewError(2201, "dApp operation's 'to' field must be atlas contract address")
	ErrDAppOpDeadlineTooLow             = relayerror.NewError(2202, "dApp operation's deadline exceeded or lower than user operation's")
	ErrDAppOpDAppControlMismatch        = relayerror.NewError(2203, "dApp operation's dApp control does not match the user operation's")
	ErrDAppOpUserOpHashMismatch         = relayerror.NewError(2204, "dApp operation's user operation hash does not match the user operation's")
	ErrDAppOpInvalidCallChainHash       = relayerror.NewError(2205, "dApp operation's call chain hash is invalid")
	ErrDAppOpComputeProofHash           = relayerror.NewError(2206, "failed to compute dApp proof hash")
	ErrDappOpSignatureInvalid           = relayerror.NewError(2207, "dApp operation has invalid signature")
	ErrDAppOpGasLimitExceeded           = relayerror.NewError(2208, "dApp operation's gas limit exceeded")
)
View Source
var (
	ErrSolverOpInvalidToField      = relayerror.NewError(2100, "solver operation's 'to' field must be atlas contract address")
	ErrSolverOpGasLimitExceeded    = relayerror.NewError(2101, "solver operation's gas limit exceeded")
	ErrSolverOpMaxFeePerGasTooLow  = relayerror.NewError(2102, "solver operation's maxFeePerGas must be equal or higher the user operation")
	ErrSolverOpDeadlineTooLow      = relayerror.NewError(2103, "solver operation's deadline exceeded or lower than user operation's")
	ErrSolverOpDAppControlMismatch = relayerror.NewError(2104, "solver operation's dApp control does not match the user operation's")
	ErrSolverOpComputeProofHash    = relayerror.NewError(2105, "failed to compute solver proof hash")
	ErrSolverOpSignatureInvalid    = relayerror.NewError(2106, "solver operation has invalid signature")
	ErrSolverOpComputeHash         = relayerror.NewError(2107, "failed to compute solver operation hash")
)
View Source
var (
	ErrUserOpInvalidSignature = relayerror.NewError(2001, "user operation has invalid signature")
	ErrUserOpInvalidToField   = relayerror.NewError(2002, "user operation's 'to' field must be atlas contract address")
	ErrUserOpDeadlineExceeded = relayerror.NewError(2003, "user operation's deadline exceeded")
	ErrUserOpComputeHash      = relayerror.NewError(2004, "failed to compute user operation hash")
	ErrUserOpComputeProofHash = relayerror.NewError(2005, "failed to compute user proof hash")
	ErrUserOpSignatureInvalid = relayerror.NewError(2006, "user operation has invalid signature")
	ErrUserOpGasLimitExceeded = relayerror.NewError(2007, "user operation's gas limit exceeded")
)
View Source
var (
	DAPP_TYPE_HASH = crypto.Keccak256Hash([]byte("DAppApproval(address from,address to,uint256 value,uint256 gas,uint256 nonce,uint256 deadline,address control,address bundler,bytes32 userOpHash,bytes32 callChainHash)"))
)
View Source
var (
	SOLVER_TYPE_HASH = crypto.Keccak256Hash([]byte("SolverOperation(address from,address to,uint256 value,uint256 gas,uint256 maxFeePerGas,uint256 deadline,address dapp,address control,bytes32 userOpHash,address bidToken,uint256 bidAmount,bytes32 data)"))
)
View Source
var (
	USER_TYPE_HASH = crypto.Keccak256Hash([]byte("UserOperation(address from,address to,uint256 value,uint256 gas,uint256 maxFeePerGas,uint256 nonce,uint256 deadline,address dapp,address control,address sessionKey,bytes32 data)"))
)

Functions

This section is empty.

Types

type BundleOperations

type BundleOperations struct {
	UserOperation    *UserOperation
	SolverOperations []*SolverOperation
	DAppOperation    *DAppOperation
}

Internal representation of a bundle of operations

func (*BundleOperations) CallChainHash

func (b *BundleOperations) CallChainHash(callConfig uint32, dAppControl common.Address) (common.Hash, error)

func (*BundleOperations) EncodeToRaw

func (b *BundleOperations) EncodeToRaw() *BundleOperationsRaw

func (*BundleOperations) Validate

func (b *BundleOperations) Validate(ethClient *ethclient.Client, userOpHash common.Hash, atlas common.Address, atlasDomainSeparator common.Hash, userOpGasLimit *big.Int, dAppOpGasLimit *big.Int, dAppConfig *dAppControl.DAppConfig) *relayerror.Error

type BundleOperationsRaw

type BundleOperationsRaw struct {
	UserOperation    *UserOperationRaw     `json:"userOperation" validate:"required"`
	SolverOperations []*SolverOperationRaw `json:"solverOperations" validate:"required"`
	DAppOperation    *DAppOperationRaw     `json:"dAppOperation" validate:"required"`
}

External representation of a bundle of operations, the relay receives and broadcasts bundles in this format

func (*BundleOperationsRaw) Decode

func (args *BundleOperationsRaw) Decode() *BundleOperations

func (*BundleOperationsRaw) IsZero

func (bor *BundleOperationsRaw) IsZero() bool

type DAppOperation

type DAppOperation struct {
	From          common.Address
	To            common.Address
	Value         *big.Int
	Gas           *big.Int
	Nonce         *big.Int
	Deadline      *big.Int
	Control       common.Address
	Bundler       common.Address
	UserOpHash    common.Hash
	CallChainHash common.Hash
	Signature     []byte
}

Internal representation of a dApp operation

func GenerateSimulationDAppOperation

func GenerateSimulationDAppOperation(userOpHash common.Hash, userOp *UserOperation) *DAppOperation

func (*DAppOperation) EncodeToRaw

func (d *DAppOperation) EncodeToRaw() *DAppOperationRaw

func (*DAppOperation) ProofHash

func (d *DAppOperation) ProofHash() (common.Hash, error)

func (*DAppOperation) Validate

func (d *DAppOperation) Validate(userOpHash common.Hash, userOp *UserOperation, callChainHash common.Hash, atlas common.Address, atlasDomainSeparator common.Hash, gasLimit *big.Int) *relayerror.Error

type DAppOperationRaw

type DAppOperationRaw struct {
	From          common.Address `json:"from" validate:"required"`
	To            common.Address `json:"to" validate:"required"`
	Value         *hexutil.Big   `json:"value" validate:"required"`
	Gas           *hexutil.Big   `json:"gas" validate:"required"`
	Nonce         *hexutil.Big   `json:"nonce" validate:"required"`
	Deadline      *hexutil.Big   `json:"deadline" validate:"required"`
	Control       common.Address `json:"control" validate:"required"`
	Bundler       common.Address `json:"bundler"` // Optional (address(0) = any bundler)
	UserOpHash    common.Hash    `json:"userOpHash" validate:"required"`
	CallChainHash common.Hash    `json:"callChainHash" validate:"required"`
	Signature     hexutil.Bytes  `json:"signature" validate:"required"`
}

External representation of a dApp operation, the relay receives and broadcasts dApp operations in this format

func (*DAppOperationRaw) Decode

func (d *DAppOperationRaw) Decode() *DAppOperation

type SolverOperation

type SolverOperation struct {
	From         common.Address
	To           common.Address
	Value        *big.Int
	Gas          *big.Int
	MaxFeePerGas *big.Int
	Deadline     *big.Int
	Solver       common.Address
	Control      common.Address
	UserOpHash   common.Hash
	BidToken     common.Address
	BidAmount    *big.Int
	Data         []byte
	Signature    []byte
}

Internal representation of a solver operation

func (*SolverOperation) AbiEncode

func (s *SolverOperation) AbiEncode() ([]byte, error)

func (*SolverOperation) EncodeToRaw

func (s *SolverOperation) EncodeToRaw() *SolverOperationRaw

func (*SolverOperation) Hash added in v1.0.3

func (s *SolverOperation) Hash() (common.Hash, *relayerror.Error)

func (*SolverOperation) ProofHash

func (s *SolverOperation) ProofHash() (common.Hash, error)

func (*SolverOperation) Validate

func (s *SolverOperation) Validate(userOperation *UserOperation, atlas common.Address, atlasDomainSeparator common.Hash, gasLimit uint32) *relayerror.Error

type SolverOperationRaw

type SolverOperationRaw struct {
	From         common.Address `json:"from" validate:"required"`
	To           common.Address `json:"to" validate:"required"`
	Value        *hexutil.Big   `json:"value" validate:"required"`
	Gas          *hexutil.Big   `json:"gas" validate:"required"`
	MaxFeePerGas *hexutil.Big   `json:"maxFeePerGas" validate:"required"`
	Deadline     *hexutil.Big   `json:"deadline" validate:"required"`
	Solver       common.Address `json:"solver" validate:"required"`
	Control      common.Address `json:"control" validate:"required"`
	UserOpHash   common.Hash    `json:"userOpHash" validate:"required"`
	BidToken     common.Address `json:"bidToken"` // Optional (address(0) = ETH)
	BidAmount    *hexutil.Big   `json:"bidAmount" validate:"required"`
	Data         hexutil.Bytes  `json:"data" validate:"required"`
	Signature    hexutil.Bytes  `json:"signature" validate:"required"`
}

External representation of a solver operation, the relay receives and broadcasts solver operations in this format

func (*SolverOperationRaw) Decode

func (s *SolverOperationRaw) Decode() *SolverOperation

type SolverOperationWithScore added in v1.0.2

type SolverOperationWithScore struct {
	SolverOpHash    common.Hash
	SolverOperation *SolverOperation
	Score           int
}

func (*SolverOperationWithScore) EncodeToRaw added in v1.0.2

type SolverOperationWithScoreRaw added in v1.0.2

type SolverOperationWithScoreRaw struct {
	SolverOperation *SolverOperationRaw `json:"solverOperation"`
	Score           int                 `json:"score"`
}

type SolverOperationsWithScore added in v1.0.2

type SolverOperationsWithScore []*SolverOperationWithScore

func (SolverOperationsWithScore) EncodeToRaw added in v1.0.2

type UserOperation

type UserOperation struct {
	From         common.Address
	To           common.Address
	Value        *big.Int
	Gas          *big.Int
	MaxFeePerGas *big.Int
	Nonce        *big.Int
	Deadline     *big.Int
	Dapp         common.Address
	Control      common.Address
	SessionKey   common.Address
	Data         []byte
	Signature    []byte
}

Internal representation of a user operation

func (*UserOperation) AbiEncode

func (u *UserOperation) AbiEncode() ([]byte, error)

func (*UserOperation) EncodeToRaw

func (u *UserOperation) EncodeToRaw() *UserOperationRaw

func (*UserOperation) Hash

func (u *UserOperation) Hash(altHash bool) (common.Hash, *relayerror.Error)

func (*UserOperation) ProofHash

func (u *UserOperation) ProofHash() (common.Hash, error)

func (*UserOperation) Validate

func (u *UserOperation) Validate(ethClient *ethclient.Client, atlas common.Address, atlasDomainSeparator common.Hash, gasLimit *big.Int) *relayerror.Error

type UserOperationPartialRaw added in v1.0.2

type UserOperationPartialRaw struct {
	UserOpHash   common.Hash    `json:"userOpHash"`
	To           common.Address `json:"to"`
	Gas          *hexutil.Big   `json:"gas"`
	MaxFeePerGas *hexutil.Big   `json:"maxFeePerGas"`
	Deadline     *hexutil.Big   `json:"deadline"`
	Dapp         common.Address `json:"dapp"`
	Control      common.Address `json:"control"`

	//Exactly one of 1. Hints  2. (Value, Data, From) must be set
	Hints []common.Address `json:"hints,omitempty"`

	Value *hexutil.Big   `json:"value,omitempty"`
	Data  hexutil.Bytes  `json:"data,omitempty"`
	From  common.Address `json:"from,omitempty"`
}

func NewUserOperationPartialRaw added in v1.0.2

func NewUserOperationPartialRaw(userOpHash common.Hash, userOp *UserOperation, hints []common.Address) *UserOperationPartialRaw

type UserOperationRaw

type UserOperationRaw struct {
	From         common.Address `json:"from" validate:"required"`
	To           common.Address `json:"to" validate:"required"`
	Value        *hexutil.Big   `json:"value" validate:"required"`
	Gas          *hexutil.Big   `json:"gas" validate:"required"`
	MaxFeePerGas *hexutil.Big   `json:"maxFeePerGas" validate:"required"`
	Nonce        *hexutil.Big   `json:"nonce" validate:"required"`
	Deadline     *hexutil.Big   `json:"deadline" validate:"required"`
	Dapp         common.Address `json:"dapp" validate:"required"`
	Control      common.Address `json:"control" validate:"required"`
	SessionKey   common.Address `json:"sessionKey"` // Optional
	Data         hexutil.Bytes  `json:"data" validate:"required"`
	Signature    hexutil.Bytes  `json:"signature" validate:"required"`
}

External representation of a user operation, the relay receives and broadcasts user operations in this format

func (*UserOperationRaw) Decode

func (u *UserOperationRaw) Decode() *UserOperation

type UserOperationWithHintsRaw

type UserOperationWithHintsRaw struct {
	UserOperation *UserOperationRaw `json:"userOperation" validate:"required"`
	Hints         []common.Address  `json:"hints"` // Optional
}

func (*UserOperationWithHintsRaw) Decode

Jump to

Keyboard shortcuts

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