Skip to main content

LSP1UniversalReceiverDelegateUP

Standard Specifications

Implementation of a UniversalReceiverDelegate for the LSP-0-ERC725Account

The LSP1UniversalReceiverDelegateUP follows the LSP-1-UniversalReceiver standard and is designed for LSP-0-ERC725Account contracts. The LSP1UniversalReceiverDelegateUP is a contract called by the universalReceiver(...) function of the LSP-0-ERC725Account contract that:

  • Writes the data keys representing assets received from type LSP-7-DigitalAsset and LSP-8-IdentifiableDigitalAsset into the account storage, and removes them when the balance is zero according to the LSP-5-ReceivedAssets Standard.

  • Writes the data keys representing the owned vaults from type [LSP-9-Vault] into your account storage, and removes them when transferring ownership to other accounts according to the LSP-10-ReceivedVaults Standard.

Public Methods

Public methods are accessible externally from users, allowing interaction with this function from dApps or other smart contracts. When marked as 'public', a method can be called both externally and internally, on the other hand, when marked as 'external', a method can only be called externally.

VERSION

References
function VERSION() external view returns (string);

Contract version.

Returns

NameTypeDescription
0string-

supportsInterface

References
function supportsInterface(bytes4 interfaceId) external view returns (bool);

See IERC165-supportsInterface.

Parameters

NameTypeDescription
interfaceIdbytes4-

Returns

NameTypeDescription
0bool-

universalReceiverDelegate

References
info
  • If some issues occured with generating the dataKeys or dataValues the returnedMessage will be an error message, otherwise it will be empty.
  • If an error occured when trying to use setDataBatch(dataKeys,dataValues), it will return the raw error data back to the caller.
Warning

When the data stored in the ERC725Y storage of the LSP0 contract is corrupted (_e.g: (LSP-5-ReceivedAssets's Array length not 16 bytes long, the token received is already registered in LSP5ReceivetAssets[], the token being sent is not sent as full balance, etc...), the function call will still pass and return (not revert!) and not modify any data key on the storage of the LSP-0-ERC725Account.

function universalReceiverDelegate(
address notifier,
uint256,
bytes32 typeId,
bytes
) external nonpayable returns (bytes);

Reacted on received notification with typeId.

  1. Writes the data keys of the received LSP-7-DigitalAsset, LSP-8-IdentifiableDigitalAsset and [LSP-9-Vault] contract addresses into the account storage according to the LSP-5-ReceivedAssets and LSP-10-ReceivedVaults Standard.

  2. The data keys representing an asset/vault are cleared when the asset/vault is no longer owned by the account.

Requirements:

  • This contract should be allowed to use the setDataBatch(...) function in order to update the LSP5 and LSP10 Data Keys.
  • Cannot accept native tokens

Parameters

NameTypeDescription
notifieraddress-
_1uint256-
typeIdbytes32Unique identifier for a specific notification.
_3bytes-

Returns

NameTypeDescription
0bytesThe result of the reaction for typeId.

Internal Methods

Any method labeled as internal serves as utility function within the contract. They can be used when writing solidity contracts that inherit from this contract. These methods can be extended or modified by overriding their internal behavior to suit specific needs.

Internal functions cannot be called externally, whether from other smart contracts, dApp interfaces, or backend services. Their restricted accessibility ensures that they remain exclusively available within the context of the current contract, promoting controlled and encapsulated usage of these internal utilities.

_tokenSender

function _tokenSender(address notifier) internal nonpayable returns (bytes);

Handler for LSP7 and LSP8 token sender type id.

Parameters

NameTypeDescription
notifieraddressThe LSP7 or LSP8 token address.

_tokenRecipient

function _tokenRecipient(
address notifier,
bytes4 interfaceId
) internal nonpayable returns (bytes);

Handler for LSP7 and LSP8 token recipient type id.

Parameters

NameTypeDescription
notifieraddressThe LSP7 or LSP8 token address.
interfaceIdbytes4The LSP7 or LSP8 interface id.

_vaultSender

function _vaultSender(address notifier) internal nonpayable returns (bytes);

Handler for LSP9 vault sender type id.

Parameters

NameTypeDescription
notifieraddressThe LSP9 vault address.

_vaultRecipient

function _vaultRecipient(address notifier) internal nonpayable returns (bytes);

Handler for LSP9 vault recipient type id.

Parameters

NameTypeDescription
notifieraddressThe LSP9 vault address.

_setDataBatchWithoutReverting

info

If an the low-level transaction revert, the returned data will be forwarded. Th contract that uses this function can use the Address library to revert with the revert reason.

function _setDataBatchWithoutReverting(
bytes32[] dataKeys,
bytes[] dataValues
) internal nonpayable returns (bytes);

Calls bytes4(keccak256(setDataBatch(bytes32[],bytes[]))) without checking for bool success, but it returns all the data back.

Parameters

NameTypeDescription
dataKeysbytes32[]Data Keys to be set.
dataValuesbytes[]Data Values to be set.

Errors

CannotRegisterEOAsAsAssets

References
error CannotRegisterEOAsAsAssets(address caller);

EOA: caller cannot be registered as an asset.

Reverts when EOA calls the universalReceiver(..) function with an asset/vault typeId.

Parameters

NameTypeDescription
calleraddressThe address of the EOA