AvoForwarder

AvoForwarder_V1

Handles executing authorized actions (through signatures) at Avocados, triggered by allow-listed broadcasters.

_Only compatible with forwarding cast calls to Avocado smart wallet contracts. This is not a generic forwarder. This is NOT a "TrustedForwarder" as proposed in EIP-2770, see info in Avocado smart wallet contracts.

Does not validate the EIP712 signature (instead this is done in the smart wallet itself).

Upgradeable through AvoForwarderProxy_

AvoForwarderConstants

avoFactory

contract IAvoFactory avoFactory

AvoFactory (proxy) used to deploy new Avocado smart wallets.

avocadoBytecode

bytes32 avocadoBytecode

cached Avocado Bytecode to directly compute address in this contract to optimize gas usage.

AvoForwarderVariables

AvoForwarderErrors

AvoForwarder__InvalidParams

error AvoForwarder__InvalidParams()

thrown when a method is called with invalid params (e.g. zero address)

AvoForwarder__Unauthorized

error AvoForwarder__Unauthorized()

thrown when a caller is not authorized to execute a certain action

AvoForwarder__LegacyVersionNotDeployed

error AvoForwarder__LegacyVersionNotDeployed()

thrown when trying to execute legacy methods for a not yet deployed Avocado smart wallet

AvoForwarder__Unsupported

error AvoForwarder__Unsupported()

thrown when an unsupported method is called (e.g. renounceOwnership)

AvoForwarderStructs

AddressBool

struct AddressBool {
  address addr;
  bool value;
}

AvoForwarderEvents

Executed

event Executed(address avocadoOwner, uint32 index, address avocadoAddress, address source, bytes metadata)

emitted when all actions for cast() in an execute() method are executed successfully

ExecuteFailed

event ExecuteFailed(address avocadoOwner, uint32 index, address avocadoAddress, address source, bytes metadata, string reason)

emitted if one of the actions for cast() in an execute() method fails

BroadcasterUpdated

event BroadcasterUpdated(address broadcaster, bool status)

emitted if a broadcaster's allowed status is updated

AuthUpdated

event AuthUpdated(address auth, bool status)

emitted if an auth's allowed status is updated

AvoForwarderCore

AvoForwarderViews

isBroadcaster

function isBroadcaster(address broadcaster_) external view returns (bool)

checks if a broadcaster_ address is an allowed broadcaster

isAuth

function isAuth(address auth_) external view returns (bool)

checks if an auth_ address is an allowed auth

AvoForwarderViewsAvocado

avoNonce

function avoNonce(address owner_, uint32 index_) external view returns (uint256)

Retrieves the current avoNonce of AvocadoMultisig for owner_ address. Needed for building signatures.

Parameters

NameTypeDescription
owner_addressAvocado owner to retrieve the nonce for.
index_uint32index number of Avocado for owner_ EOA

Return Values

NameTypeDescription
0uint256returns the avoNonce for the owner_ necessary to sign a meta transaction

avocadoVersionName

function avocadoVersionName(address owner_, uint32 index_) external view returns (string)

Retrieves the current AvocadoMultisig implementation name for owner_ address. Needed for building signatures.

Parameters

NameTypeDescription
owner_addressAvocado owner to retrieve the name for.
index_uint32index number of Avocado for owner_ EOA

Return Values

NameTypeDescription
0stringreturns the domain separator name for the owner_ necessary to sign a meta transaction

avocadoVersion

function avocadoVersion(address owner_, uint32 index_) external view returns (string)

Retrieves the current AvocadoMultisig implementation version for owner_ address. Needed for building signatures.

Parameters

NameTypeDescription
owner_addressAvocado owner to retrieve the version for.
index_uint32index number of Avocado for owner_ EOA

Return Values

NameTypeDescription
0stringreturns the domain separator version for the owner_ necessary to sign a meta transaction

computeAvocado

function computeAvocado(address owner_, uint32 index_) external view returns (address)

Computes the deterministic Avocado address for owner_ and index_

AvoForwarderV1

simulateV1

function simulateV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastParams params_, struct AvocadoMultisigStructs.CastForwardParams forwardParams_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_) external payable returns (uint256 castGasUsed_, uint256 deploymentGasUsed_, bool isDeployed_, bool success_, string revertReason_)

Simulates executeV1, callable only by msg.sender = dead address (0x000000000000000000000000000000000000dEaD) Helpful to estimate CastForwardParams.gas for an Avocado tx. For Avocado v1. Deploys the Avocado smart wallet if necessary.

Expected use with .estimateGas(). User signed CastForwardParams.gas should be set to the estimated amount minus gas used in AvoForwarder (until AvocadoMultisig logic where the gas param is validated). Best to simulate first with a .callstatic to determine success / error and other return values.

Parameters

NameTypeDescription
from_addressAvocadoMultisig owner
index_uint32index number of Avocado for owner_ EOA
params_struct AvocadoMultisigStructs.CastParamsCast params such as id, avoNonce and actions to execute
forwardParams_struct AvocadoMultisigStructs.CastForwardParamsCast params related to validity of forwarding as instructed and signed
signaturesParams_struct AvocadoMultisigStructs.SignatureParamsSignatureParams structs array for signature and signer: - signature: the EIP712 signature, 65 bytes ECDSA signature for a default EOA. For smart contract signatures it must fulfill the requirements for the relevant smart contract .isValidSignature() EIP1271 logic - signer: address of the signature signer. Must match the actual signature signer or refer to the smart contract that must be an allowed signer and validates signature via EIP1271

Return Values

NameTypeDescription
castGasUsed_uint256amount of gas used for executing cast
deploymentGasUsed_uint256amount of gas used for deployment (or for getting the contract if already deployed)
isDeployed_boolboolean flag indicating if Avocado is already deployed
success_boolboolean flag indicating whether executing actions reverts or not
revertReason_stringrevert reason original error in default format "<action_index>_error"

executeV1

function executeV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastParams params_, struct AvocadoMultisigStructs.CastForwardParams forwardParams_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_) external payable

Deploys Avocado for owner if necessary and calls cast() on it. For Avocado v1. Only callable by allowed broadcasters.

Parameters

NameTypeDescription
from_addressAvocado owner
index_uint32index number of Avocado for owner_ EOA
params_struct AvocadoMultisigStructs.CastParamsCast params such as id, avoNonce and actions to execute
forwardParams_struct AvocadoMultisigStructs.CastForwardParamsCast params related to validity of forwarding as instructed and signed
signaturesParams_struct AvocadoMultisigStructs.SignatureParamsSignatureParams structs array for signature and signer: - signature: the EIP712 signature, 65 bytes ECDSA signature for a default EOA. For smart contract signatures it must fulfill the requirements for the relevant smart contract .isValidSignature() EIP1271 logic - signer: address of the signature signer. Must match the actual signature signer or refer to the smart contract that must be an allowed signer and validates signature via EIP1271

verifyV1

function verifyV1(address from_, uint32 index_, struct AvocadoMultisigStructs.CastParams params_, struct AvocadoMultisigStructs.CastForwardParams forwardParams_, struct AvocadoMultisigStructs.SignatureParams[] signaturesParams_) external returns (bool)

Verify the transaction is valid and can be executed. IMPORTANT: Expected to be called via callStatic.

                     Returns true if valid, reverts otherwise:
                     e.g. if input params, signature or avoNonce etc. are invalid.

Parameters

NameTypeDescription
from_addressAvocado owner
index_uint32index number of Avocado for owner_ EOA
params_struct AvocadoMultisigStructs.CastParamsCast params such as id, avoNonce and actions to execute
forwardParams_struct AvocadoMultisigStructs.CastForwardParamsCast params related to validity of forwarding as instructed and signed
signaturesParams_struct AvocadoMultisigStructs.SignatureParamsSignatureParams structs array for signature and signer: - signature: the EIP712 signature, 65 bytes ECDSA signature for a default EOA. For smart contract signatures it must fulfill the requirements for the relevant smart contract .isValidSignature() EIP1271 logic - signer: address of the signature signer. Must match the actual signature signer or refer to the smart contract that must be an allowed signer and validates signature via EIP1271

Return Values

NameTypeDescription
0boolreturns true if everything is valid, otherwise reverts.

AvoForwarderOwnerActions

updateBroadcasters

function updateBroadcasters(struct AvoForwarderStructs.AddressBool[] broadcastersStatus_) external

updates allowed status for broadcasters based on broadcastersStatus_ and emits BroadcastersUpdated. Executable by allowed auths or owner only.

updateAuths

function updateAuths(struct AvoForwarderStructs.AddressBool[] authsStatus_) external

updates allowed status for a auths based on authsStatus_ and emits AuthsUpdated. Executable by allowed auths or owner only (auths can only remove themselves).

AvoForwarder

constructor

constructor(contract IAvoFactory avoFactory_) public

constructor sets the immutable avoFactory (proxy) address and cached bytecodes derived from it

initialize

function initialize(address owner_, address[] allowedBroadcasters_) public

initializes the contract, setting owner_ and initial allowedBroadcasters_

Parameters

NameTypeDescription
owner_addressaddress of owner_ allowed to executed auth limited methods
allowedBroadcasters_addressinitial list of allowed broadcasters to be enabled right away

renounceOwnership

function renounceOwnership() public view

override renounce ownership as it could leave the contract in an unwanted state if called by mistake.