DelegationFacet
Inherits: MultiOwnable
Handles delegation of transaction execution to other wallets with proper authorization
Functions
onlyOwner
modifier onlyOwner() override;
onlyActiveDelegator
modifier onlyActiveDelegator();
configureDelegation
Configure delegation for another wallet
function configureDelegation(
address delegatedWallet,
uint256 maxValue,
uint256 dailyLimit,
bytes4[] calldata allowedSelectors
) external onlyOwner;
Parameters
delegatedWallet
address
The wallet that can execute transactions on behalf of this wallet
maxValue
uint256
Maximum value per transaction
dailyLimit
uint256
Maximum daily spending limit
allowedSelectors
bytes4[]
Array of function selectors that can be delegated
revokeDelegation
Revoke delegation for a wallet
function revokeDelegation(address delegatedWallet) external onlyOwner;
Parameters
delegatedWallet
address
The wallet to revoke delegation from
setFunctionDelegation
Allow/disallow a specific function for delegation
function setFunctionDelegation(address delegatedWallet, bytes4 selector, bool allowed) external onlyOwner;
Parameters
delegatedWallet
address
The delegated wallet
selector
bytes4
Function selector
allowed
bool
Whether the function is allowed
executeDelegated
Execute a transaction as a delegated wallet
function executeDelegated(address target, uint256 value, bytes calldata data, bytes calldata ownerSignature)
external
onlyActiveDelegator
returns (bool success, bytes memory result);
Parameters
target
address
Target contract address
value
uint256
ETH value to send
data
bytes
Transaction data
ownerSignature
bytes
Signature from an owner of the delegating wallet
executeDelegatedBatch
Execute multiple transactions as a delegated wallet
function executeDelegatedBatch(
address[] calldata targets,
uint256[] calldata values,
bytes[] calldata datas,
bytes calldata ownerSignature
) external onlyActiveDelegator;
Parameters
targets
address[]
Array of target addresses
values
uint256[]
Array of ETH values
datas
bytes[]
Array of transaction data
ownerSignature
bytes
Signature from an owner of the delegating wallet
getDelegationConfig
Get delegation configuration for a wallet
function getDelegationConfig(address delegatedWallet)
external
view
returns (uint256 maxValue, uint256 dailyLimit, uint256 dailySpent, uint256 lastResetTime, bool active);
Parameters
delegatedWallet
address
The delegated wallet
Returns
maxValue
uint256
Maximum value per transaction
dailyLimit
uint256
Daily spending limit
dailySpent
uint256
Amount spent today
lastResetTime
uint256
Last time daily limit was reset
active
bool
Whether delegation is active
isFunctionDelegated
Check if a function is delegated to a wallet
function isFunctionDelegated(address delegatedWallet, bytes4 selector) external view returns (bool);
Parameters
delegatedWallet
address
The delegated wallet
selector
bytes4
Function selector
Returns
<none>
bool
Whether the function is delegated
getDelegatedWallets
Get all delegated wallets
function getDelegatedWallets() external view returns (address[] memory);
Returns
<none>
address[]
Array of delegated wallet addresses
updateDailyLimit
Update daily limit for a delegated wallet
function updateDailyLimit(address delegatedWallet, uint256 newDailyLimit) external onlyOwner;
Parameters
delegatedWallet
address
The delegated wallet
newDailyLimit
uint256
New daily limit
resetDailySpending
Reset daily spending for a delegated wallet (emergency function)
function resetDailySpending(address delegatedWallet) external onlyOwner;
Parameters
delegatedWallet
address
The delegated wallet
canDelegate
Check if delegation is allowed for a specific transaction
function canDelegate(address delegatedWallet, bytes4 selector, uint256 value) external view returns (bool);
Parameters
delegatedWallet
address
The delegated wallet
selector
bytes4
Function selector
value
uint256
Transaction value
Returns
<none>
bool
Whether delegation is allowed
_verifyOwnerSignature
Verify owner signature for delegated transaction
function _verifyOwnerSignature(bytes32 hash, bytes calldata signature) internal view returns (bool);
Parameters
hash
bytes32
Transaction hash
signature
bytes
Owner signature
Returns
<none>
bool
Whether signature is valid
Events
DelegationConfigured
event DelegationConfigured(address indexed delegatedWallet, uint256 maxValue, uint256 dailyLimit);
DelegationRevoked
event DelegationRevoked(address indexed delegatedWallet);
FunctionDelegated
event FunctionDelegated(address indexed delegatedWallet, bytes4 indexed selector, bool allowed);
DelegatedTransactionExecuted
event DelegatedTransactionExecuted(
address indexed delegatedWallet, address indexed target, uint256 value, bytes4 selector, bool success
);
DailyLimitReset
event DailyLimitReset(address indexed delegatedWallet, uint256 newLimit);
Errors
NotAuthorizedDelegator
error NotAuthorizedDelegator();
DelegationNotActive
error DelegationNotActive();
FunctionNotDelegated
error FunctionNotDelegated();
ValueExceedsLimit
error ValueExceedsLimit();
DailyLimitExceeded
error DailyLimitExceeded();
InvalidDelegationConfig
error InvalidDelegationConfig();
Last updated
Was this helpful?