DelegationOwner

The DelegationOwner contract manages asset and signature delegation within the Unlockd Wallet. It allows the wallet owner to delegate specific assets to trusted parties for a defined duration and provides functionality for signature delegation.

Key Functions:

function initialize(
    address _guard, 
    address _safe, 
    address _owner, 
    address _delegationController, 
    address _protocolOwner
) public

Initializes the DelegationOwner contract with the necessary parameters.

Parameters:

_guard (address): The address of the TransactionGuard contract.

_safe (address): The address of the GnosisSafe contract.

_owner (address): The address of the wallet owner.

_delegationController (address): The address of the delegation controller.

_protocolOwner (address): The address of the protocol owner.


function setDelegationController(
    address _delegationController, 
    bool _allowed
) external;

Sets a delegation controller address as allowed or disallowed.

Parameters:

  • _delegationController (address): The address of the delegation controller.

  • _allowed (bool): Indicates whether the delegation controller is allowed or not.


function delegate(
    address _asset, 
    uint256 _id, 
    address _delegatee, 
    uint256 _duration
) external

Delegates the usage of an asset to a delegatee for a specified duration.

Parameters:

_asset (address): The address of the asset being delegated.

_id (uint256): The ID of the asset being delegated.

_delegatee (address): The address of the delegatee.

_duration (uint256): The duration of the delegation in seconds.


function endDelegate(
    address _asset, 
    uint256 _id
) external;

Ends the delegation of an asset.

Parameters:

_asset (address): The address of the delegated asset.

_id (uint256): The ID of the delegated asset.


function forceEndDelegation(
    address _asset, 
    uint256 _id
) external;

Forcefully ends the delegation of an asset by the protocol owner.

Parameters:

_asset (address): The address of the delegated asset.

_id (uint256): The ID of the delegated asset.


function delegateSignature(
    address[] calldata _assets, 
    uint256[] calldata _ids, 
    address _delegatee, 
    uint256 _duration
) external;

Delegates the usage of the signature to a delegatee for a specified duration, locking a group of assets.

Parameters:

_assets (address[]): An array of asset addresses being delegated.

_ids (uint256[]): An array of asset IDs being delegated.

_delegatee (address): The address of the delegatee.

_duration (uint256): The duration of the signature delegation, expressed in seconds.


function endDelegateSignature() external;

Ends the delegation of the signature, unlocking a group of assets.


function execTransaction(
    address _asset, 
    uint256 _id, 
    address _to, 
    uint256 _value, 
    bytes calldata _data, 
    uint256 _safeTxGas, 
    uint256 _baseGas, 
    uint256 _gasPrice, 
    address _gasToken, 
    address payable _refundReceiver
) external returns (bool success)

Executes a transaction through the GnosisSafe wallet, validating the delegatee and allowed functions.

Parameters:

_asset (address): The address of the delegated asset.

_id (uint256): The ID of the delegated asset.

_to (address): The destination address of the transaction.

_value (uint256): The amount of ETH to be sent with the transaction.

_data (bytes): The data payload of the transaction.

_safeTxGas (uint256): The gas limit for the transaction.

_baseGas (uint256): The base gas cost.

_gasPrice (uint256): The gas price used for the transaction.

_gasToken (address): The address of the token used for gas payment (0 for ETH).

_refundReceiver (address payable): The address that receives the gas payment refund.

Returns:

A boolean indicating the success of the transaction execution.


function isValidSignature(
    bytes memory _data, 
    bytes memory _signature
) public view override returns (bytes4);

Validates if a signature is valid based on the current signature delegation.

Parameters:

_data (bytes): The hash of the signed data.

_signature (bytes): The signature bytes.

Returns:

The EIP1271 magic value if the signature is valid.


function claimAsset(
    address _asset, 
    uint256 _id, 
    address _receiver
) external;

Sends an asset to a receiver if it is not delegated or locked.

Parameters:

_asset (address): The address of the asset being claimed.

_id (uint256): The ID of the asset being claimed.

_receiver (address): The address of the receiver.


function isAssetDelegated(
    address _asset, 
    uint256 _id
) external view returns (bool);

Returns if an asset is delegated or included in the current signature delegation.

Parameters:

_asset (address): The address of the asset.

_id (uint256): The ID of the asset. Returns:

(bool): Indicates whether the asset is delegated or not.


function isSignatureDelegated() 
external view returns (bool);

Returns if the signature is delegated.

Returns:

(bool): Indicates whether the signature is delegated or not.


function isAllowedFunction(
    address _asset, 
    address _contract, 
    bytes4 _selector
) public view returns (bool);

Checks if a function is allowed to be executed by a delegatee of a given asset.

Parameters:

_asset (address): The address of the delegated asset.

_contract (address): The address of the destination contract.

_selector (bytes4): The selector of the destination function.

Returns:

(bool): Indicates whether the function is allowed or not.


Interactions:

  • Interacts with the TransactionGuard contract to enforce delegation and locking rules.

  • Utilizes the DelegationRecipes contract to determine allowed functions for asset collections.

  • Integrates with the AllowedControllers contract to manage delegation and lock controllers.

  • Executes transactions through the GnosisSafe contract.

Last updated