AvoFactory
AvoFactory_V1
Deploys Avocado smart wallet contracts at deterministic addresses using Create2.
Upgradeable through AvoFactoryProxy
AvoFactoryErrors
AvoFactory__NotEOA
error AvoFactory__NotEOA()
thrown when trying to deploy an Avocado for a smart contract as owner
AvoFactory__Unauthorized
error AvoFactory__Unauthorized()
thrown when a caller is not authorized to execute a certain action
AvoFactory__InvalidParams
error AvoFactory__InvalidParams()
thrown when a method is called with invalid params (e.g. zero address)
AvoFactory__IndexNonSequential
error AvoFactory__IndexNonSequential()
thrown when deploy is called with an index where index-1 is not deployed yet. After index > 5, index must be used sequential.
AvoFactory__ImplementationNotDefined
error AvoFactory__ImplementationNotDefined()
thrown when deploy methods are called before an implementation is defined
AvoFactoryConstants
avocadoCreationCode
bytes avocadoCreationCode
hardcoded Avocado creation code.
avocadoBytecode
bytes32 avocadoBytecode
cached avocado (proxy) bytecode hash to optimize gas usage
avoRegistry
contract IAvoRegistry avoRegistry
registry holding the valid versions (addresses) for Avocado smart wallet implementation contracts.
The registry is used to verify a valid version before setting a new avoImpl
as default for new deployments.
AvoFactoryVariables
avoImpl
address avoImpl
Avocado logic contract address that new Avocado deployments point to.
Modifiable only by avoRegistry
.
AvoFactoryEvents
AvocadoDeployed
event AvocadoDeployed(address owner, uint32 index, uint16 avoType, address avocado)
Emitted when a new Avocado has been deployed
AvocadoDeployedWithVersion
event AvocadoDeployedWithVersion(address owner, uint32 index, uint16 avoType, address avocado, address version)
Emitted when a new Avocado has been deployed with a non-default version
AvoFactoryCore
AvoFactory
constructor
constructor(contract IAvoRegistry avoRegistry_) public
constructor sets the immutable avoRegistry
address
initialize
function initialize() public
initializes the contract
isAvocado
function isAvocado(address avoSmartWallet_) external view returns (bool)
Checks if a certain address is an Avocado smart wallet. Only works for already deployed wallets.
Parameters
Name | Type | Description |
---|---|---|
avoSmartWallet_ | address | address to check |
Return Values
Name | Type | Description |
---|---|---|
0 | bool | true if address is an Avocado |
deploy
function deploy(address owner_, uint32 index_) external returns (address deployedAvocado_)
Deploys an Avocado for a certain owner_
deterministcally using Create2.
Does not check if contract at address already exists (AvoForwarder does that)
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | Avocado owner |
index_ | uint32 | index number of Avocado for owner_ EOA |
Return Values
Name | Type | Description |
---|---|---|
deployedAvocado_ | address | deployed address for the Avocado contract |
deployWithVersion
function deployWithVersion(address owner_, uint32 index_, address avoVersion_) external returns (address deployedAvocado_)
Deploys an Avocado with non-default version for an owner_
deterministcally using Create2.
Does not check if contract at address already exists (AvoForwarder does that)
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | Avocado owner |
index_ | uint32 | index number of Avocado for owner_ EOA |
avoVersion_ | address | Version of Avocado logic contract to deploy |
Return Values
Name | Type | Description |
---|---|---|
deployedAvocado_ | address | deployed address for the Avocado contract |
computeAvocado
function computeAvocado(address owner_, uint32 index_) public view returns (address computedAddress_)
Computes the deterministic Avocado address for owner_
based on Create2
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | Avocado owner |
index_ | uint32 | index number of Avocado for owner_ EOA |
Return Values
Name | Type | Description |
---|---|---|
computedAddress_ | address | computed address for the Avocado contract |
transientDeployData
function transientDeployData() external view returns (address version_, uint256 data_)
returns transient data used to pass variables into the Avocado proxy during deployment. Reduces gas cost and dependency of deterministic address on constructor args.
setAvoImpl
function setAvoImpl(address avoImpl_) external
registry can update the current Avocado implementation contract set as default
_avoImpl
logic contract address for new deployments
Parameters
Name | Type | Description |
---|---|---|
avoImpl_ | address | the new avoImpl address |