Documentation ¶
Index ¶
- Variables
- func BuildCallData(swt Type, calls Calls) ([]byte, error)
- func GetAccountAddress(ctx context.Context, provider ethereum.ContractCaller, config Config, ...) (common.Address, error)
- func GetBiconomyFactoryCallData(owner common.Address, index decimal.Decimal, ecdsaValidator common.Address) ([]byte, error)
- func GetBiconomyInitCode(owner common.Address, index decimal.Decimal, ...) ([]byte, error)
- func GetBiconomyInitCodeFromFactoryCallData(factory common.Address, factoryCallData []byte) ([]byte, error)
- func GetFactoryCallData(smartWalletConfig Config, ownerAddress common.Address, index decimal.Decimal) ([]byte, error)
- func GetInitCode(smartWalletConfig Config, ownerAddress common.Address, index decimal.Decimal) ([]byte, error)
- func GetInitCodeFromFactoryCallData(smartWalletConfig Config, factoryCallData []byte) ([]byte, error)
- func GetKernelFactoryCallData(owner common.Address, index decimal.Decimal, ...) ([]byte, error)
- func GetKernelInitCode(owner common.Address, index decimal.Decimal, ...) ([]byte, error)
- func GetKernelInitCodeFromFactoryCallData(factory common.Address, factoryCallData []byte) ([]byte, error)
- func IsAccountDeployed(ctx context.Context, provider ethereum.ChainStateReader, ...) (bool, error)
- type Call
- type Calls
- type Config
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // SimpleAccountType represents a smart wallet type for a Simple Account wallet. SimpleAccountType = Type{"simple_account"} // BiconomyType represents a type for BiconomyType Smart Account wallet. BiconomyType = Type{"biconomy"} // KernelType represents a type for Zerodev KernelType wallet. KernelType = Type{"kernel"} )
var ( // ErrNoSmartWalletType is returned when no smart wallet type is specified. // Make sure to specify the smart wallet type in the configuration. ErrNoSmartWalletType = errors.New("no smart wallet type specified (nil)") // ErrSmartWalletNotSupported is returned on attempt to perform some actions with an unsupported smart wallet type. // Make sure that the smart wallet type you are trying to use // has no `unsupported` or `untested` tags in the source files. ErrSmartWalletNotSupported = errors.New("smart wallet not supported") )
var KernelExecuteABI = must(abi.JSON(strings.NewReader(`[
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
},
{
"internalType": "enum Operation",
"name": "",
"type": "uint8"
}
],
"name": "execute",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [{
"components": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"internalType": "struct Call[]",
"name": "calls",
"type": "tuple[]"
}],
"name": "executeBatch",
"outputs": [],
"stateMutability": "payable",
"type": "function"
}
]`)))
kernelExecuteABI is used to execute a transaction on Zerodev Kernel smart account.
Functions ¶
func GetAccountAddress ¶
func GetBiconomyFactoryCallData ¶ added in v0.0.40
func GetBiconomyFactoryCallData(owner common.Address, index decimal.Decimal, ecdsaValidator common.Address) ([]byte, error)
GetKernelInitData returns the calldata needed call the factory to deploy a Biconomy smart account.
func GetBiconomyInitCode ¶
func GetBiconomyInitCode(owner common.Address, index decimal.Decimal, factory, ecdsaValidator common.Address) ([]byte, error)
GetBiconomyInitCode returns the init code for a Biconomy smart account. The init code deploys a smart account if it is not already deployed. NOTE: this was NOT tested. Use at your own risk or wait for the package to be updated.
func GetBiconomyInitCodeFromFactoryCallData ¶ added in v0.0.40
func GetBiconomyInitCodeFromFactoryCallData(factory common.Address, factoryCallData []byte) ([]byte, error)
GetBiconomyInitCodeFromFactoryCallData returns the init code for a Biconomy smart account, given the Biconomy Factory calldata. The init code deploys a smart account if it is not already deployed.
func GetFactoryCallData ¶ added in v0.0.40
func GetFactoryCallData(smartWalletConfig Config, ownerAddress common.Address, index decimal.Decimal) ([]byte, error)
GetFactoryCallData returns the calldata for a smart wallet factory to deploy a wallet of a given type for a given smart wallet owner with a given wallet index. The smart wallet factory is later called with this calldata to deploy the smart wallet.
NOTE: this does NOT constitute an InitCode (defined by ERC-4337) sufficient to deploy a smart wallet in a user operation. For this purpose, use `GetInitCode` instead.
Parameters: - smartWalletConfig: the configuration for the smart wallet - ownerAddress: the address of the owner of the smart wallet - index: the index of the smart wallet
Returns: - the calldata for the smart wallet factory - an error if the calldata could not be built
func GetInitCode ¶
func GetInitCode(smartWalletConfig Config, ownerAddress common.Address, index decimal.Decimal) ([]byte, error)
GetInitCode builds the InitCode (defined in the ERC-4337) for a smart wallet. The InitCode is used to deploy a smart wallet if it is not already deployed.
Parameters: - smartWalletConfig: the configuration for the smart wallet - ownerAddress: the address of the owner of the smart wallet - index: the index of the smart wallet
Returns: - the InitCode for the smart wallet - an error if the InitCode could not be built
func GetInitCodeFromFactoryCallData ¶ added in v0.0.40
func GetInitCodeFromFactoryCallData(smartWalletConfig Config, factoryCallData []byte) ([]byte, error)
GetInitCodeFromFactoryCallData builds the InitCode (defined in the ERC-4337) from a factory calldata, that contains the deployment data for the smart wallet. This is another way to get the InitCode for a smart wallet, as owner and index are basically included in the factory call data.
Parameters: - smartWalletConfig: the configuration for the smart wallet - factoryCallData: the calldata for the factory
Returns: - the InitCode for the smart wallet - an error if the InitCode could not be built
func GetKernelFactoryCallData ¶ added in v0.0.40
func GetKernelFactoryCallData(owner common.Address, index decimal.Decimal, accountLogic, ecdsaValidator common.Address) ([]byte, error)
GetKernelInitData returns the calldata needed call the factory to deploy a Zerodev Kernel smart account.
func GetKernelInitCode ¶
func GetKernelInitCode(owner common.Address, index decimal.Decimal, factory, accountLogic, ecdsaValidator common.Address) ([]byte, error)
GetKernelInitCode the init code for a Zerodev Kernel smart account. The init code deploys a smart account if it is not already deployed.
func GetKernelInitCodeFromFactoryCallData ¶ added in v0.0.40
func GetKernelInitCodeFromFactoryCallData(factory common.Address, factoryCallData []byte) ([]byte, error)
GetKernelInitCodeFromFactoryCallData returns the init code for a Zerodev Kernel smart account, given the Kernel Factory calldata. The init code deploys a smart account if it is not already deployed.
Types ¶
type Call ¶
Call represents sufficient data to build a single transaction, which is a part of a user operation to be executed in a batch with other ones.
type Calls ¶
type Calls []Call
func UnpackCallsForKernel ¶
UnpackCallsForKernel unpacks CallData for Zerodev Kernel smart wallet.
func UnpackCallsForSimpleAccount ¶
UnpackCallsForSimpleAccount unpacks CallData for SimpleAccount smart wallet.
func (Calls) PackForKernel ¶
handleCallKernel packs calldata for Zerodev Kernel smart wallet.
func (Calls) PackForSimpleAccount ¶
PackForSimpleAccount packs CallData for SimpleAccount smart wallet.
type Config ¶
type Config struct { Type *Type `yaml:"type" env:"SMART_WALLET_TYPE"` ECDSAValidator common.Address `yaml:"ecdsa_validator" env:"SMART_WALLET_ECDSA_VALIDATOR"` Logic common.Address `yaml:"logic" env:"SMART_WALLET_LOGIC"` Factory common.Address `yaml:"factory" env:"SMART_WALLET_FACTORY"` }
SmartWalletConfig represents the configuration for the smart wallet to be used with the client.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents an enum for supported ERC-4337 smart wallets that can be used with the client to send user operations from.
func (*Type) UnmarshalJSON ¶
UnmarshalJSON unmarshals the JSON representation of a SmartWalletType.
func (*Type) UnmarshalYAML ¶
UnmarshalYAML unmarshals the YAML representation of a SmartWalletType.