LSP1UniversalReceiverDelegateUP
LSP1UniversalReceiverDelegateUP
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.
supportsInterface​
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateUP.sol
- Function signature:
supportsInterface(bytes4)
- Function selector:
0x01ffc9a7
function supportsInterface(bytes4 interfaceId) external view returns (bool);
See IERC165-supportsInterface
.
Parameters​
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | - |
Returns​
Name | Type | Description |
---|---|---|
0 | bool | - |
universalReceiver​
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateUP.sol
- Function signature:
universalReceiver(bytes32,)
- Function selector:
0x534e72c8
- If some issues occured with generating the
dataKeys
ordataValues
thereturnedMessage
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.
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 universalReceiver(
bytes32 typeId,
bytes
) external payable returns (bytes);
Reacted on received notification with typeId
.
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.
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​
Name | Type | Description |
---|---|---|
typeId | bytes32 | Unique identifier for a specific notification. |
_1 | bytes | - |
Returns​
Name | Type | Description |
---|---|---|
0 | bytes | The 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​
Name | Type | Description |
---|---|---|
notifier | address | The 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​
Name | Type | Description |
---|---|---|
notifier | address | The LSP7 or LSP8 token address. |
interfaceId | bytes4 | The LSP7 or LSP8 interface id. |
_vaultSender​
function _vaultSender(address notifier) internal nonpayable returns (bytes);
Handler for LSP9 vault sender type id.
Parameters​
Name | Type | Description |
---|---|---|
notifier | address | The LSP9 vault address. |
_vaultRecipient​
function _vaultRecipient(address notifier) internal nonpayable returns (bytes);
Handler for LSP9 vault recipient type id.
Parameters​
Name | Type | Description |
---|---|---|
notifier | address | The LSP9 vault address. |
_setDataBatchWithoutReverting​
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​
Name | Type | Description |
---|---|---|
dataKeys | bytes32[] | Data Keys to be set. |
dataValues | bytes[] | Data Values to be set. |
Events​
UniversalReceiver​
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateUP.sol
- Event signature:
UniversalReceiver(address,uint256,bytes32,bytes,bytes)
- Event topic hash:
0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2
event UniversalReceiver(address indexed from, uint256 indexed value, bytes32 indexed typeId, bytes receivedData, bytes returnedValue);
*Address from
called the universalReceiver(...)
function while sending value
LYX. Notification type (typeId): typeId
- Data received:
receivedData
.*
Emitted when the universalReceiver
function was called with a specific typeId
and some receivedData
s
Parameters​
Name | Type | Description |
---|---|---|
from indexed | address | The address of the EOA or smart contract that called the {universalReceiver(...)} function. |
value indexed | uint256 | The amount sent to the {universalReceiver(...)} function. |
typeId indexed | bytes32 | A bytes32 unique identifier (= "hook")that describe the type of notification, information or transaction received by the contract. Can be related to a specific standard or a hook. |
receivedData | bytes | Any arbitrary data that was sent to the {universalReceiver(...)} function. |
returnedValue | bytes | The value returned by the {universalReceiver(...)} function. |
Errors​
CannotRegisterEOAsAsAssets​
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateUP.sol
- Error signature:
CannotRegisterEOAsAsAssets(address)
- Error hash:
0xa5295345
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​
Name | Type | Description |
---|---|---|
caller | address | The address of the EOA |
NativeTokensNotAccepted​
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateUP.sol
- Error signature:
NativeTokensNotAccepted()
- Error hash:
0x114b721a
error NativeTokensNotAccepted();
Cannot send native tokens to universalReceiver(...)
function of the delegated contract.
Reverts when the universalReceiver
function in the LSP1 Universal Receiver Delegate contract is called while sending some native tokens along the call (msg.value
different than 0
)