LSP1UniversalReceiverDelegateVault
Implementation of a UniversalReceiverDelegate for the [LSP9Vault]
The LSP1UniversalReceiverDelegateVault
follows the LSP-1-UniversalReceiver standard and is designed for [LSP9Vault] contracts. The LSP1UniversalReceiverDelegateVault
is a contract called by the universalReceiver(...)
function of the [LSP-9-Vault] 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.
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
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateVault.sol
- Function signature:
VERSION()
- Function selector:
0xffa1ad74
function VERSION() external view returns (string);
Contract version.
Returns
Name | Type | Description |
---|---|---|
0 | string | - |
supportsInterface
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateVault.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 | - |
universalReceiverDelegate
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateVault.sol
- Function signature:
universalReceiverDelegate(address,uint256,bytes32,bytes)
- Function selector:
0xa245bbda
- 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.
function universalReceiverDelegate(
address notifier,
uint256,
bytes32 typeId,
bytes
) external nonpayable returns (bytes);
Reacted on received notification with typeId
.
Handles two cases: Writes the received LSP-7-DigitalAsset or LSP-8-IdentifiableDigitalAsset assets into the vault storage according to the LSP-5-ReceivedAssets standard.
Requirements:
- Cannot accept native tokens.
Parameters
Name | Type | Description |
---|---|---|
notifier | address | - |
_1 | uint256 | - |
typeId | bytes32 | Unique identifier for a specific notification. |
_3 | 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. |
_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 succes
, 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. |
Errors
CannotRegisterEOAsAsAssets
- Specification details: LSP-1-UniversalReceiver
- Solidity implementation:
LSP1UniversalReceiverDelegateVault.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 |