From 096da3295b47152c9c4e3be737eb9f4bc81bcdf0 Mon Sep 17 00:00:00 2001 From: b00ste Date: Tue, 15 Aug 2023 13:40:01 +0300 Subject: [PATCH] docs: update auto-generated docs --- .../LSP1UniversalReceiverDelegateUP.md | 268 +++++------------- .../LSP1UniversalReceiverDelegateVault.md | 161 ++++------- .../LSP10ReceivedVaults/LSP10Utils.md | 168 ++--------- .../LSP1UniversalReceiver/LSP1Utils.md | 35 --- .../LSP2ERC725YJSONSchema/LSP2Utils.md | 137 +++++++++ .../libraries/LSP5ReceivedAssets/LSP5Utils.md | 172 +++-------- 6 files changed, 335 insertions(+), 606 deletions(-) diff --git a/docs/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.md b/docs/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.md index 0fbba0571..439ecf302 100644 --- a/docs/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.md +++ b/docs/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.md @@ -69,6 +69,13 @@ See [`IERC165-supportsInterface`](#ierc165-supportsinterface). ::: +:::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. + +::: + :::caution 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]. @@ -79,7 +86,7 @@ When the data stored in the ERC725Y storage of the LSP0 contract is corrupted (\ function universalReceiver( bytes32 typeId, bytes -) external payable returns (bytes result); +) external payable returns (bytes); ``` _Reacted on received notification with `typeId`._ @@ -106,9 +113,9 @@ _Reacted on received notification with `typeId`._ #### Returns -| Name | Type | Description | -| -------- | :-----: | ---------------------------------------- | -| `result` | `bytes` | The result of the reaction for `typeId`. | +| Name | Type | Description | +| ---- | :-----: | -------------------------------------------------------- | +| `0` | `bytes` | returnedMessage The result of the reaction for `typeId`. |
@@ -118,220 +125,137 @@ Any method labeled as `internal` serves as utility function within the contract. 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. -### \_whenReceiving +### \_tokenSender ```solidity -function _whenReceiving( - bytes32 typeId, - address notifier, - bytes32 notifierMapKey, - bytes4 interfaceID -) internal nonpayable returns (bytes); +function _tokenSender(address notifier) internal nonpayable returns (bytes); ``` -To avoid stack too deep error -Generate the keys/values of the asset/vault received to set and set them -on the account depending on the type of the transfer (asset/vault) - -
+Handler for LSP7 and LSP8 token sender type id. -### \_whenSending - -```solidity -function _whenSending( - bytes32 typeId, - address notifier, - bytes32 notifierMapKey, - uint128 arrayIndex -) internal nonpayable returns (bytes); -``` +#### Parameters -To avoid stack too deep error -Generate the keys/values of the asset/vault sent to set and set them -on the account depending on the type of the transfer (asset/vault) +| Name | Type | Description | +| ---------- | :-------: | ------------------------------- | +| `notifier` | `address` | The LSP7 or LSP8 token address. |
-## Events - -### UniversalReceiver - -:::note References - -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#universalreceiver) -- Solidity implementation: [`LSP1UniversalReceiverDelegateUP.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol) -- Event signature: `UniversalReceiver(address,uint256,bytes32,bytes,bytes)` -- Event topic hash: `0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2` - -::: +### \_tokenRecipient ```solidity -event UniversalReceiver(address indexed from, uint256 indexed value, bytes32 indexed typeId, bytes receivedData, bytes returnedValue); +function _tokenRecipient( + address notifier, + bytes4 interfaceId +) internal nonpayable returns (bytes); ``` -\*Address `from` called the `universalReceiver(...)` function while sending `value` LYX. Notification type (typeId): `typeId` - -- Data received: `receivedData`.\* - -Emitted when the [`universalReceiver`](#universalreceiver) function was called with a specific `typeId` and some `receivedData` s +Handler for LSP7 and LSP8 token recipient type id. #### 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. | +| Name | Type | Description | +| ------------- | :-------: | ------------------------------- | +| `notifier` | `address` | The LSP7 or LSP8 token address. | +| `interfaceId` | `bytes4` | The LSP7 or LSP8 interface id. |
-## Errors - -### CannotRegisterEOAsAsAssets - -:::note References - -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#cannotregistereoasasassets) -- Solidity implementation: [`LSP1UniversalReceiverDelegateUP.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol) -- Error signature: `CannotRegisterEOAsAsAssets(address)` -- Error hash: `0xa5295345` - -::: +### \_vaultSender ```solidity -error CannotRegisterEOAsAsAssets(address caller); +function _vaultSender(address notifier) internal nonpayable returns (bytes); ``` -_EOA: `caller` cannot be registered as an asset._ - -Reverts when EOA calls the [`universalReceiver(..)`](#universalreceiver) function with an asset/vault typeId. +Handler for LSP9 vault sender type id. #### Parameters -| Name | Type | Description | -| -------- | :-------: | ---------------------- | -| `caller` | `address` | The address of the EOA | +| Name | Type | Description | +| ---------- | :-------: | ----------------------- | +| `notifier` | `address` | The LSP9 vault address. |
-### InvalidLSP10ReceivedVaultsArrayLength - -:::note References - -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#invalidlsp10receivedvaultsarraylength) -- Solidity implementation: [`LSP1UniversalReceiverDelegateUP.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol) -- Error signature: `InvalidLSP10ReceivedVaultsArrayLength(bytes,uint256)` -- Error hash: `0x12ce1c39` - -::: +### \_vaultRecipient ```solidity -error InvalidLSP10ReceivedVaultsArrayLength( - bytes invalidValueStored, - uint256 invalidValueLength -); +function _vaultRecipient(address notifier) internal nonpayable returns (bytes); ``` -Reverts when the value stored under the 'LSP10ReceivedVaults[]' Array data key is not valid. The value stored under this data key should be exactly 16 bytes long. Only possible valid values are: - -- any valid uint128 values _e.g: `0x00000000000000000000000000000000` (zero), meaning empty array, no vaults received._ _e.g: `0x00000000000000000000000000000005` (non-zero), meaning 5 array elements, 5 vaults received._ - -- `0x` (nothing stored under this data key, equivalent to empty array). +Handler for LSP9 vault recipient type id. #### Parameters -| Name | Type | Description | -| -------------------- | :-------: | ------------------------------------------------------------------------------------------------------------ | -| `invalidValueStored` | `bytes` | The invalid value stored under the `LSP10ReceivedVaults[]` Array data key. | -| `invalidValueLength` | `uint256` | The invalid number of bytes stored under the `LSP10ReceivedVaults[]` Array data key (MUST be 16 bytes long). | +| Name | Type | Description | +| ---------- | :-------: | ----------------------- | +| `notifier` | `address` | The LSP9 vault address. |
-### InvalidLSP5ReceivedAssetsArrayLength +### \_setDataBatchWithoutReverting -:::note References +:::info -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#invalidlsp5receivedassetsarraylength) -- Solidity implementation: [`LSP1UniversalReceiverDelegateUP.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol) -- Error signature: `InvalidLSP5ReceivedAssetsArrayLength(bytes,uint256)` -- Error hash: `0xecba7af8` +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. ::: ```solidity -error InvalidLSP5ReceivedAssetsArrayLength( - bytes invalidValueStored, - uint256 invalidValueLength -); +function _setDataBatchWithoutReverting( + bytes32[] dataKeys, + bytes[] dataValues +) internal nonpayable returns (bytes); ``` -Reverts when the value stored under the 'LSP5ReceivedAssets[]' Array data key is not valid. The value stored under this data key should be exactly 16 bytes long. Only possible valid values are: - -- any valid uint128 values _e.g: `0x00000000000000000000000000000000` (zero), empty array, no assets received._ _e.g. `0x00000000000000000000000000000005` (non-zero), 5 array elements, 5 assets received._ - -- `0x` (nothing stored under this data key, equivalent to empty array) +Calls `bytes4(keccak256(setDataBatch(bytes32[],bytes[])))` without checking for `bool success`, but it returns all the data back. #### Parameters -| Name | Type | Description | -| -------------------- | :-------: | ------------------------------------------------------------------------------------------------------------- | -| `invalidValueStored` | `bytes` | The invalid value stored under the `LSP5ReceivedAssets[]` Array data key. | -| `invalidValueLength` | `uint256` | The invalid number of bytes stored under the `LSP5ReceivedAssets[]` data key (MUST be exactly 16 bytes long). | +| Name | Type | Description | +| ------------ | :---------: | ---------------------- | +| `dataKeys` | `bytes32[]` | Data Keys to be set. | +| `dataValues` | `bytes[]` | Data Values to be set. |
-### MaxLSP10VaultsCountReached +## Events + +### UniversalReceiver :::note References -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#maxlsp10vaultscountreached) +- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#universalreceiver) - Solidity implementation: [`LSP1UniversalReceiverDelegateUP.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol) -- Error signature: `MaxLSP10VaultsCountReached(address)` -- Error hash: `0x11610270` +- Event signature: `UniversalReceiver(address,uint256,bytes32,bytes,bytes)` +- Event topic hash: `0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2` ::: ```solidity -error MaxLSP10VaultsCountReached(address notRegisteredVault); +event UniversalReceiver(address indexed from, uint256 indexed value, bytes32 indexed typeId, bytes receivedData, bytes returnedValue); ``` -Reverts when the `LSP10Vaults[]` Array reaches its maximum limit (`max(uint128)`). - -#### Parameters - -| Name | Type | Description | -| -------------------- | :-------: | ---------------------------------------------------------- | -| `notRegisteredVault` | `address` | The address of the LSP9Vault that could not be registered. | - -
- -### MaxLSP5ReceivedAssetsCountReached - -:::note References - -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#maxlsp5receivedassetscountreached) -- Solidity implementation: [`LSP1UniversalReceiverDelegateUP.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol) -- Error signature: `MaxLSP5ReceivedAssetsCountReached(address)` -- Error hash: `0x0b51a2d0` - -::: +\*Address `from` called the `universalReceiver(...)` function while sending `value` LYX. Notification type (typeId): `typeId` -```solidity -error MaxLSP5ReceivedAssetsCountReached(address notRegisteredAsset); -``` +- Data received: `receivedData`.\* -Reverts when the `LSP5ReceivedAssets[]` Array reaches its maximum limit (`max(uint128)`). +Emitted when the [`universalReceiver`](#universalreceiver) function was called with a specific `typeId` and some `receivedData` s #### Parameters -| Name | Type | Description | -| -------------------- | :-------: | ------------------------------------------------------ | -| `notRegisteredAsset` | `address` | The address of the asset that could not be registered. | +| 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 + ### NativeTokensNotAccepted :::note References @@ -352,53 +276,3 @@ _Cannot send native tokens to [`universalReceiver(...)`](#universalreceiver) fun Reverts when the [`universalReceiver`](#universalreceiver) function in the LSP1 Universal Receiver Delegate contract is called while sending some native tokens along the call (`msg.value` different than `0`)
- -### ReceivedAssetsIndexSuperiorToUint128 - -:::note References - -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#receivedassetsindexsuperiortouint128) -- Solidity implementation: [`LSP1UniversalReceiverDelegateUP.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol) -- Error signature: `ReceivedAssetsIndexSuperiorToUint128(uint256)` -- Error hash: `0xe8a4fba0` - -::: - -```solidity -error ReceivedAssetsIndexSuperiorToUint128(uint256 index); -``` - -Reverts when the received assets index is superior to `max(uint128)`. - -#### Parameters - -| Name | Type | Description | -| ------- | :-------: | -------------------------- | -| `index` | `uint256` | The received assets index. | - -
- -### VaultIndexSuperiorToUint128 - -:::note References - -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#vaultindexsuperiortouint128) -- Solidity implementation: [`LSP1UniversalReceiverDelegateUP.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol) -- Error signature: `VaultIndexSuperiorToUint128(uint256)` -- Error hash: `0x76f9db1b` - -::: - -```solidity -error VaultIndexSuperiorToUint128(uint256 index); -``` - -Reverts when the vault index is superior to `max(uint128)`. - -#### Parameters - -| Name | Type | Description | -| ------- | :-------: | ---------------- | -| `index` | `uint256` | The vault index. | - -
diff --git a/docs/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.md b/docs/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.md index 3fa240854..c08a278e0 100644 --- a/docs/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.md +++ b/docs/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.md @@ -67,11 +67,18 @@ See [`IERC165-supportsInterface`](#ierc165-supportsinterface). ::: +:::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. + +::: + ```solidity function universalReceiver( bytes32 typeId, bytes -) external payable returns (bytes result); +) external payable returns (bytes); ``` _Reacted on received notification with `typeId`._ @@ -95,134 +102,117 @@ Handles two cases: Writes the received [LSP-7-DigitalAsset] or [LSP-8-Identifiab #### Returns -| Name | Type | Description | -| -------- | :-----: | ---------------------------------------- | -| `result` | `bytes` | The result of the reaction for `typeId`. | +| Name | Type | Description | +| ---- | :-----: | -------------------------------------------------------- | +| `0` | `bytes` | returnedMessage The result of the reaction for `typeId`. |
-## Events +## Internal Methods -### UniversalReceiver +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. -:::note References +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. -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#universalreceiver) -- Solidity implementation: [`LSP1UniversalReceiverDelegateVault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol) -- Event signature: `UniversalReceiver(address,uint256,bytes32,bytes,bytes)` -- Event topic hash: `0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2` - -::: +### \_tokenSender ```solidity -event UniversalReceiver(address indexed from, uint256 indexed value, bytes32 indexed typeId, bytes receivedData, bytes returnedValue); +function _tokenSender(address notifier) internal nonpayable returns (bytes); ``` -\*Address `from` called the `universalReceiver(...)` function while sending `value` LYX. Notification type (typeId): `typeId` - -- Data received: `receivedData`.\* - -Emitted when the [`universalReceiver`](#universalreceiver) function was called with a specific `typeId` and some `receivedData` s +Handler for LSP7 and LSP8 token sender type id. #### 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. | +| Name | Type | Description | +| ---------- | :-------: | ------------------------------- | +| `notifier` | `address` | The LSP7 or LSP8 token address. |
-## Errors - -### CannotRegisterEOAsAsAssets - -:::note References - -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#cannotregistereoasasassets) -- Solidity implementation: [`LSP1UniversalReceiverDelegateVault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol) -- Error signature: `CannotRegisterEOAsAsAssets(address)` -- Error hash: `0xa5295345` - -::: +### \_tokenRecipient ```solidity -error CannotRegisterEOAsAsAssets(address caller); +function _tokenRecipient( + address notifier, + bytes4 interfaceId +) internal nonpayable returns (bytes); ``` -_EOA: `caller` cannot be registered as an asset._ - -Reverts when EOA calls the [`universalReceiver(..)`](#universalreceiver) function with an asset/vault typeId. +Handler for LSP7 and LSP8 token recipient type id. #### Parameters -| Name | Type | Description | -| -------- | :-------: | ---------------------- | -| `caller` | `address` | The address of the EOA | +| Name | Type | Description | +| ------------- | :-------: | ------------------------------- | +| `notifier` | `address` | The LSP7 or LSP8 token address. | +| `interfaceId` | `bytes4` | The LSP7 or LSP8 interface id. |
-### InvalidLSP5ReceivedAssetsArrayLength +### \_setDataBatchWithoutReverting -:::note References +:::info -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#invalidlsp5receivedassetsarraylength) -- Solidity implementation: [`LSP1UniversalReceiverDelegateVault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol) -- Error signature: `InvalidLSP5ReceivedAssetsArrayLength(bytes,uint256)` -- Error hash: `0xecba7af8` +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. ::: ```solidity -error InvalidLSP5ReceivedAssetsArrayLength( - bytes invalidValueStored, - uint256 invalidValueLength -); +function _setDataBatchWithoutReverting( + bytes32[] dataKeys, + bytes[] dataValues +) internal nonpayable returns (bytes); ``` -Reverts when the value stored under the 'LSP5ReceivedAssets[]' Array data key is not valid. The value stored under this data key should be exactly 16 bytes long. Only possible valid values are: - -- any valid uint128 values _e.g: `0x00000000000000000000000000000000` (zero), empty array, no assets received._ _e.g. `0x00000000000000000000000000000005` (non-zero), 5 array elements, 5 assets received._ - -- `0x` (nothing stored under this data key, equivalent to empty array) +Calls `bytes4(keccak256(setDataBatch(bytes32[],bytes[])))` without checking for `bool succes`, but it returns all the data back. #### Parameters -| Name | Type | Description | -| -------------------- | :-------: | ------------------------------------------------------------------------------------------------------------- | -| `invalidValueStored` | `bytes` | The invalid value stored under the `LSP5ReceivedAssets[]` Array data key. | -| `invalidValueLength` | `uint256` | The invalid number of bytes stored under the `LSP5ReceivedAssets[]` data key (MUST be exactly 16 bytes long). | +| Name | Type | Description | +| ------------ | :---------: | ---------------------- | +| `dataKeys` | `bytes32[]` | Data Keys to be set. | +| `dataValues` | `bytes[]` | Data Values to be set. |
-### MaxLSP5ReceivedAssetsCountReached +## Events + +### UniversalReceiver :::note References -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#maxlsp5receivedassetscountreached) +- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#universalreceiver) - Solidity implementation: [`LSP1UniversalReceiverDelegateVault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol) -- Error signature: `MaxLSP5ReceivedAssetsCountReached(address)` -- Error hash: `0x0b51a2d0` +- Event signature: `UniversalReceiver(address,uint256,bytes32,bytes,bytes)` +- Event topic hash: `0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2` ::: ```solidity -error MaxLSP5ReceivedAssetsCountReached(address notRegisteredAsset); +event UniversalReceiver(address indexed from, uint256 indexed value, bytes32 indexed typeId, bytes receivedData, bytes returnedValue); ``` -Reverts when the `LSP5ReceivedAssets[]` Array reaches its maximum limit (`max(uint128)`). +\*Address `from` called the `universalReceiver(...)` function while sending `value` LYX. Notification type (typeId): `typeId` + +- Data received: `receivedData`.\* + +Emitted when the [`universalReceiver`](#universalreceiver) function was called with a specific `typeId` and some `receivedData` s #### Parameters -| Name | Type | Description | -| -------------------- | :-------: | ------------------------------------------------------ | -| `notRegisteredAsset` | `address` | The address of the asset that could not be registered. | +| 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 + ### NativeTokensNotAccepted :::note References @@ -243,28 +233,3 @@ _Cannot send native tokens to [`universalReceiver(...)`](#universalreceiver) fun Reverts when the [`universalReceiver`](#universalreceiver) function in the LSP1 Universal Receiver Delegate contract is called while sending some native tokens along the call (`msg.value` different than `0`)
- -### ReceivedAssetsIndexSuperiorToUint128 - -:::note References - -- Specification details: [**LSP-1-UniversalReceiver**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-1-UniversalReceiver.md#receivedassetsindexsuperiortouint128) -- Solidity implementation: [`LSP1UniversalReceiverDelegateVault.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol) -- Error signature: `ReceivedAssetsIndexSuperiorToUint128(uint256)` -- Error hash: `0xe8a4fba0` - -::: - -```solidity -error ReceivedAssetsIndexSuperiorToUint128(uint256 index); -``` - -Reverts when the received assets index is superior to `max(uint128)`. - -#### Parameters - -| Name | Type | Description | -| ------- | :-------: | -------------------------- | -| `index` | `uint256` | The received assets index. | - -
diff --git a/docs/libraries/LSP10ReceivedVaults/LSP10Utils.md b/docs/libraries/LSP10ReceivedVaults/LSP10Utils.md index a7fd193be..989abbed7 100644 --- a/docs/libraries/LSP10ReceivedVaults/LSP10Utils.md +++ b/docs/libraries/LSP10ReceivedVaults/LSP10Utils.md @@ -26,172 +26,66 @@ Internal functions cannot be called externally, whether from other smart contrac ### generateReceivedVaultKeys +:::caution Warning + +Returns empty arrays when encountering errors. Otherwise the arrays must have 3 data keys and 3 data values. + +::: + ```solidity function generateReceivedVaultKeys( address receiver, - address vault, - bytes32 vaultMapKey -) internal view returns (bytes32[] keys, bytes[] values); + bytes20 vaultAddress +) internal view returns (bytes32[] lsp10DataKeys, bytes[] lsp10DataValues); ``` Generate an array of data keys/values pairs to be set on the receiver address after receiving vaults. #### Parameters -| Name | Type | Description | -| ------------- | :-------: | --------------------------------------------------------------------------------------------------------------------- | -| `receiver` | `address` | The address receiving the vault and where the LSP10 data keys should be added. | -| `vault` | `address` | @param vaultMapKey The `LSP10VaultMap:` data key of the vault being received containing the interfaceId of the | -| `vaultMapKey` | `bytes32` | The `LSP10VaultMap:` data key of the vault being received containing the interfaceId of the | +| Name | Type | Description | +| -------------- | :-------: | ------------------------------------------------------------------------------ | +| `receiver` | `address` | The address receiving the vault and where the LSP10 data keys should be added. | +| `vaultAddress` | `bytes20` | The address of the vault being received. | #### Returns -| Name | Type | Description | -| -------- | :---------: | ------------------------------------------------------------------------------------------------------------------- | -| `keys` | `bytes32[]` | An array of 3 x data keys: `LSP10Vaults[]`, `LSP10Vaults[index]` and `LSP10VaultMap:`. | -| `values` | `bytes[]` | An array of 3 x data values: the new length of `LSP10Vaults[]`, the address of the asset under `LSP10Vaults[index]` | +| Name | Type | Description | +| ----------------- | :---------: | --------------------------------------------------------------------- | +| `lsp10DataKeys` | `bytes32[]` | An array Data Keys used to update the [LSP-10-ReceivedAssets] data. | +| `lsp10DataValues` | `bytes[]` | An array Data Values used to update the [LSP-10-ReceivedAssets] data. |
### generateSentVaultKeys -```solidity -function generateSentVaultKeys( - address sender, - bytes32 vaultMapKey, - uint128 vaultIndex -) internal view returns (bytes32[] keys, bytes[] values); -``` - -Generate an array of data key/value pairs to be set on the sender address after sending vaults. - -#### Parameters - -| Name | Type | Description | -| ------------- | :-------: | ---------------------------------------------------------------------------------------------- | -| `sender` | `address` | The address sending the vault and where the LSP10 data keys should be updated. | -| `vaultMapKey` | `bytes32` | The `LSP10VaultMap:` data key of the vault being sent containing the interfaceId of the | -| `vaultIndex` | `uint128` | The index at which the vault address is stored under `LSP10Vaults[]` Array. | - -#### Returns - -| Name | Type | Description | -| -------- | :---------: | ------------------------------------------------------------------------------------------------------------------- | -| `keys` | `bytes32[]` | An array of 3 x data keys: `LSP10Vaults[]`, `LSP10Vaults[index]` and `LSP10VaultsMap:`. | -| `values` | `bytes[]` | An array of 3 x data values: the new length of `LSP10Vaults[]`, the address of the asset under `LSP10Vaults[index]` | - -
- -### getLSP10ReceivedVaultsCount - -:::info +:::caution Warning -This function does not return a number but the raw bytes stored under the `LSP10Vaults[]` Array data key. +Returns empty arrays when encountering errors. Otherwise the arrays must have at least 3 data keys and 3 data values. ::: ```solidity -function getLSP10ReceivedVaultsCount(contract IERC725Y account) internal view returns (bytes); +function generateSentVaultKeys( + address sender, + bytes20 vaultAddress +) internal view returns (bytes32[] lsp10DataKeys, bytes[] lsp10DataValues); ``` -Get the total number of vault addresses stored under the `LSP10Vaults[]` Array data key. +Generate an array of data key/value pairs to be set on the sender address after sending vaults. #### Parameters -| Name | Type | Description | -| --------- | :-----------------: | ---------------------------------------------------- | -| `account` | `contract IERC725Y` | The ERC725Y smart contract to read the storage from. | +| Name | Type | Description | +| -------------- | :-------: | ------------------------------------------------------------------------------ | +| `sender` | `address` | The address sending the vault and where the LSP10 data keys should be updated. | +| `vaultAddress` | `bytes20` | The address of the vault that is being sent. | #### Returns -| Name | Type | Description | -| ---- | :-----: | -------------------------------------------------------- | -| `0` | `bytes` | The raw bytes stored under the `LSP10Vaults[]` data key. | - -
- -## Errors - -### InvalidLSP10ReceivedVaultsArrayLength - -:::note References - -- Specification details: [**LSP-10-ReceivedVaults**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-10-ReceivedVaults.md#,)) -- Solidity implementation: [`LSP10Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP10ReceivedVaults/LSP10Utils.sol) -- Error signature: `,)` -- Error hash: `0x9f47dbd3` - -::: - -```solidity -InvalidLSP10ReceivedVaultsArrayLength(bytes,uint256); -``` - -Reverts when the value stored under the 'LSP10ReceivedVaults[]' Array data key is not valid. -The value stored under this data key should be exactly 16 bytes long. -Only possible valid values are: - -- any valid uint128 values - _e.g: `0x00000000000000000000000000000000` (zero), meaning empty array, no vaults received._ - _e.g: `0x00000000000000000000000000000005` (non-zero), meaning 5 array elements, 5 vaults received._ - -- `0x` (nothing stored under this data key, equivalent to empty array) - -#### Parameters - -| Name | Type | Description | -| -------------------- | :-------: | ------------------------------------------------------------------------------------------------------------------------------- | -| `invalidValueStored` | `bytes` | invalidValueLength The invalid number of bytes stored under the `LSP10ReceivedVaults[]` Array data key (MUST be 16 bytes long). | -| `invalidValueLength` | `uint256` | The invalid number of bytes stored under the `LSP10ReceivedVaults[]` Array data key (MUST be 16 bytes long). | - -
- -### MaxLSP10VaultsCountReached - -:::note References - -- Specification details: [**LSP-10-ReceivedVaults**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-10-ReceivedVaults.md#)) -- Solidity implementation: [`LSP10Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP10ReceivedVaults/LSP10Utils.sol) -- Error signature: `)` -- Error hash: `0x59d76dc3` - -::: - -```solidity -MaxLSP10VaultsCountReached(address); -``` - -Reverts when the `LSP10Vaults[]` Array reaches its maximum limit (`max(uint128)`) - -#### Parameters - -| Name | Type | Description | -| -------------------- | :-------: | ---------------------------------------------------------- | -| `notRegisteredVault` | `address` | The address of the LSP9Vault that could not be registered. | - -
- -### VaultIndexSuperiorToUint128 - -:::note References - -- Specification details: [**LSP-10-ReceivedVaults**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-10-ReceivedVaults.md#)) -- Solidity implementation: [`LSP10Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP10ReceivedVaults/LSP10Utils.sol) -- Error signature: `)` -- Error hash: `0x59d76dc3` - -::: - -```solidity -VaultIndexSuperiorToUint128(uint256); -``` - -Reverts when the vault index is superior to `max(uint128)` - -#### Parameters - -| Name | Type | Description | -| ------- | :-------: | ---------------- | -| `index` | `uint256` | The vault index. | +| Name | Type | Description | +| ----------------- | :---------: | --------------------------------------------------------------------- | +| `lsp10DataKeys` | `bytes32[]` | An array Data Keys used to update the [LSP-10-ReceivedAssets] data. | +| `lsp10DataValues` | `bytes[]` | An array Data Values used to update the [LSP-10-ReceivedAssets] data. |
diff --git a/docs/libraries/LSP1UniversalReceiver/LSP1Utils.md b/docs/libraries/LSP1UniversalReceiver/LSP1Utils.md index 211aefa68..f71caf118 100644 --- a/docs/libraries/LSP1UniversalReceiver/LSP1Utils.md +++ b/docs/libraries/LSP1UniversalReceiver/LSP1Utils.md @@ -79,38 +79,3 @@ as additional informations in the calldata. | `0` | `bytes` | The data returned by the LSP1UniversalReceiverDelegate contract. |
- -### getTransferDetails - -```solidity -function getTransferDetails( - bytes32 typeId -) - internal - pure - returns ( - bool invalid, - bytes10 mapPrefix, - bytes4 interfaceId, - bool isReceiving - ); -``` - -Gets all the transfer details based on the provided `bytes32 typeId`. - -#### Parameters - -| Name | Type | Description | -| -------- | :-------: | ------------------------------------------------------------------- | -| `typeId` | `bytes32` | A `bytes32` unique identifier for a specific action or information. | - -#### Returns - -| Name | Type | Description | -| ------------- | :-------: | --------------------------------------------------------------------------------------------- | -| `invalid` | `bool` | `true` if the `typeId` was not recognised, `false otherwise. | -| `mapPrefix` | `bytes10` | The standard 10 bytes defined in a LSP standard associated with the specific `typeId`. | -| `interfaceId` | `bytes4` | The bytes4 ERC165 interface ID defined in a LSP standard associated with a specific `typeId`. | -| `isReceiving` | `bool` | When the typeId relate to LSP7/8 tokens or LSP9 Vaults, describe if the `typeId` relates | - -
diff --git a/docs/libraries/LSP2ERC725YJSONSchema/LSP2Utils.md b/docs/libraries/LSP2ERC725YJSONSchema/LSP2Utils.md index 6ea73d42b..4adf287e0 100644 --- a/docs/libraries/LSP2ERC725YJSONSchema/LSP2Utils.md +++ b/docs/libraries/LSP2ERC725YJSONSchema/LSP2Utils.md @@ -428,3 +428,140 @@ Verify if `data` is a valid array of value encoded as a `CompactBytesArray` acco | `0` | `bool` | `true` if the `data` is correctly encoded CompactBytesArray, `false` otherwise. |
+ +### validateArrayLength + +:::info + +If the returned value has a length of 16 bytes, it means the value is valid. Otherwise the retuned value will be `0x` which means that the value is invalid as the length of a LSP2 Array. + +::: + +```solidity +function validateArrayLength(bytes arrayLength) internal pure returns (bytes); +``` + +Validates plain bytes to be the length of an LSP2 Array + +#### Parameters + +| Name | Type | Description | +| ------------- | :-----: | ------------------------------------- | +| `arrayLength` | `bytes` | Plain bytes that should be validated. | + +#### Returns + +| Name | Type | Description | +| ---- | :-----: | ---------------------------------------------- | +| `0` | `bytes` | Raw bytes of length 0 (invalid) or 16 (valid). | + +
+ +### getArrayLength + +:::info + +If the returned value has a length of 16 bytes, it means the value is valid. Otherwise the retuned value will be `0x` which means that the value is invalid as the length of a LSP2 Array. + +::: + +```solidity +function getArrayLength(contract IERC725Y ERC725YContract, bytes32 arrayKey) internal view returns (bytes); +``` + +Get validated length for a LSP2 Array + +#### Parameters + +| Name | Type | Description | +| ----------------- | :-----------------: | ------------------------------------------------------ | +| `ERC725YContract` | `contract IERC725Y` | An ERC725Y Contract. | +| `arrayKey` | `bytes32` | The data key of key type Array that you want to query. | + +#### Returns + +| Name | Type | Description | +| ---- | :-----: | ---------------------------------------------- | +| `0` | `bytes` | Raw bytes of length 0 (invalid) or 16 (valid). | + +
+ +### getDecrementedArrayLength + +:::info + +If the returned value has a length of 16 bytes, it means the value is valid. Otherwise the retuned value will be `0x` which means that the value is invalid as the length of a LSP2 Array. + +::: + +```solidity +function getDecrementedArrayLength(contract IERC725Y ERC725YContract, bytes32 arrayKey) internal view returns (bytes); +``` + +Get validated decremented length for a LSP2 Array. Additionally checks for underflow. + +#### Parameters + +| Name | Type | Description | +| ----------------- | :-----------------: | ------------------------------------------------------ | +| `ERC725YContract` | `contract IERC725Y` | An ERC725Y Contract. | +| `arrayKey` | `bytes32` | The data key of key type Array that you want to query. | + +#### Returns + +| Name | Type | Description | +| ---- | :-----: | ---------------------------------------------- | +| `0` | `bytes` | Raw bytes of length 0 (invalid) or 16 (valid). | + +
+ +### removeLastElementFromArrayAndMap + +```solidity +function removeLastElementFromArrayAndMap( + bytes32 arrayKey, + uint128 newArrayLength, + bytes32 removedElementIndexKey, + bytes32 removedElementMapKey +) internal pure returns (bytes32[] dataKeys, bytes[] dataValues); +``` + +Generates Data Key/Value pairs for removing the last element from an LSP2 Array and a mapping Data Key. + +#### Parameters + +| Name | Type | Description | +| ------------------------ | :-------: | ------------------------------------------------------------- | +| `arrayKey` | `bytes32` | The Data Key of Key Type Array. | +| `newArrayLength` | `uint128` | The new Array Length for the `arrayKey`. | +| `removedElementIndexKey` | `bytes32` | The Data Key of Key Type Array Index for the removed element. | +| `removedElementMapKey` | `bytes32` | The Data Key of a mapping to be removed. | + +
+ +### removeElementFromArrayAndMap + +:::info + +The function assumes that the Data Value stored under the mapping Data Key is of length 20 where the last 16 bytes are the index of the element in the array. + +::: + +```solidity +function removeElementFromArrayAndMap(contract IERC725Y ERC725YContract, bytes32 arrayKey, uint128 newArrayLength, bytes32 removedElementIndexKey, uint128 removedElementIndex, bytes32 removedElementMapKey) internal view returns (bytes32[] dataKeys, bytes[] dataValues); +``` + +Generates Data Key/Value pairs for removing an element from an LSP2 Array and a mapping Data Key. + +#### Parameters + +| Name | Type | Description | +| ------------------------ | :-----------------: | ------------------------------------------------------------- | +| `ERC725YContract` | `contract IERC725Y` | The ERC725Y contract. | +| `arrayKey` | `bytes32` | The Data Key of Key Type Array. | +| `newArrayLength` | `uint128` | The new Array Length for the `arrayKey`. | +| `removedElementIndexKey` | `bytes32` | The Data Key of Key Type Array Index for the removed element. | +| `removedElementIndex` | `uint128` | the index of the removed element. | +| `removedElementMapKey` | `bytes32` | The Data Key of a mapping to be removed. | + +
diff --git a/docs/libraries/LSP5ReceivedAssets/LSP5Utils.md b/docs/libraries/LSP5ReceivedAssets/LSP5Utils.md index 66016b611..9f8113593 100644 --- a/docs/libraries/LSP5ReceivedAssets/LSP5Utils.md +++ b/docs/libraries/LSP5ReceivedAssets/LSP5Utils.md @@ -26,174 +26,68 @@ Internal functions cannot be called externally, whether from other smart contrac ### generateReceivedAssetKeys +:::caution Warning + +Returns empty arrays when encountering errors. Otherwise the arrays must have 3 data keys and 3 data values. + +::: + ```solidity function generateReceivedAssetKeys( address receiver, - address asset, - bytes32 assetMapKey, - bytes4 interfaceID -) internal view returns (bytes32[] keys, bytes[] values); + bytes20 assetAddress, + bytes4 assetInterfaceId +) internal view returns (bytes32[] lsp5DataKeys, bytes[] lsp5DataValues); ``` Generate an array of data key/value pairs to be set on the receiver address after receiving assets. #### Parameters -| Name | Type | Description | -| ------------- | :-------: | ---------------------------------------------------------------------------------------------------------------------------- | -| `receiver` | `address` | The address receiving the asset and where the LSP5 data keys should be added. | -| `asset` | `address` | @param assetMapKey The `LSP5ReceivedAssetMap:` data key of the asset being received containing the interfaceId of the | -| `assetMapKey` | `bytes32` | The `LSP5ReceivedAssetMap:` data key of the asset being received containing the interfaceId of the | -| `interfaceID` | `bytes4` | The interfaceID of the asset being received. | +| Name | Type | Description | +| ------------------ | :-------: | ----------------------------------------------------------------------------- | +| `receiver` | `address` | The address receiving the asset and where the LSP5 data keys should be added. | +| `assetAddress` | `bytes20` | The address of the asset being received (_e.g: an LSP7 or LSP8 token_). | +| `assetInterfaceId` | `bytes4` | The interfaceID of the asset being received. | #### Returns -| Name | Type | Description | -| -------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------- | -| `keys` | `bytes32[]` | An array of 3 x data keys: `LSP5ReceivedAssets[]`, `LSP5ReceivedAssets[index]` and `LSP5ReceivedAssetsMap:`. | -| `values` | `bytes[]` | An array of 3 x data values: the new length of `LSP5ReceivedAssets[]`, the address of the asset under `LSP5ReceivedAssets[index]` | +| Name | Type | Description | +| ---------------- | :---------: | -------------------------------------------------------------------- | +| `lsp5DataKeys` | `bytes32[]` | An array Data Keys used to update the [LSP-5-ReceivedAssets] data. | +| `lsp5DataValues` | `bytes[]` | An array Data Values used to update the [LSP-5-ReceivedAssets] data. |
### generateSentAssetKeys -```solidity -function generateSentAssetKeys( - address sender, - bytes32 assetMapKey, - uint128 assetIndex -) internal view returns (bytes32[] keys, bytes[] values); -``` - -Generate an array of data key/value pairs to be set on the sender address after sending assets. - -#### Parameters - -| Name | Type | Description | -| ------------- | :-------: | ----------------------------------------------------------------------------------------------------- | -| `sender` | `address` | The address sending the asset and where the LSP5 data keys should be updated. | -| `assetMapKey` | `bytes32` | The `LSP5ReceivedAssetMap:` data key of the asset being sent containing the interfaceId of the | -| `assetIndex` | `uint128` | The index at which the asset is stored under the `LSP5ReceivedAssets[]` Array. | - -#### Returns - -| Name | Type | Description | -| -------- | :---------: | --------------------------------------------------------------------------------------------------------------------------------- | -| `keys` | `bytes32[]` | An array of 3 x data keys: `LSP5ReceivedAssets[]`, `LSP5ReceivedAssets[index]` and `LSP5ReceivedAssetsMap:`. | -| `values` | `bytes[]` | An array of 3 x data values: the new length of `LSP5ReceivedAssets[]`, the address of the asset under `LSP5ReceivedAssets[index]` | - -
+:::caution Warning -### getLSP5ReceivedAssetsCount - -:::info - -This function does not return a number but the raw bytes stored under the `LSP5ReceivedAssets[]` Array data key. +Returns empty arrays when encountering errors. Otherwise the arrays must have at least 3 data keys and 3 data values. ::: ```solidity -function getLSP5ReceivedAssetsCount(contract IERC725Y account) internal view returns (bytes); +function generateSentAssetKeys( + address sender, + bytes20 assetAddress +) internal view returns (bytes32[] lsp5DataKeys, bytes[] lsp5DataValues); ``` -Get the total number of asset addresses stored under the `LSP5ReceivedAssets[]` Array data key. +Generate an array of Data Key/Value pairs to be set on the sender address after sending assets. #### Parameters -| Name | Type | Description | -| --------- | :-----------------: | ---------------------------------------------------- | -| `account` | `contract IERC725Y` | The ERC725Y smart contract to read the storage from. | +| Name | Type | Description | +| -------------- | :-------: | ----------------------------------------------------------------------------- | +| `sender` | `address` | The address sending the asset and where the LSP5 data keys should be updated. | +| `assetAddress` | `bytes20` | The address of the asset that is being sent. | #### Returns -| Name | Type | Description | -| ---- | :-----: | --------------------------------------------------------------- | -| `0` | `bytes` | The raw bytes stored under the `LSP5ReceivedAssets[]` data key. | - -
- -## Errors - -### InvalidLSP5ReceivedAssetsArrayLength - -:::note References - -- Specification details: [**LSP-5-ReceivedAssets**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-5-ReceivedAssets.md#,)) -- Solidity implementation: [`LSP5Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP5ReceivedAssets/LSP5Utils.sol) -- Error signature: `,)` -- Error hash: `0x9f47dbd3` - -::: - -```solidity -InvalidLSP5ReceivedAssetsArrayLength(bytes,uint256); -``` - -Reverts when the value stored under the 'LSP5ReceivedAssets[]' Array data key is not valid. -The value stored under this data key should be exactly 16 bytes long. -Only possible valid values are: - -- any valid uint128 values - _e.g: `0x00000000000000000000000000000000` (zero), empty array, no assets received._ - _e.g. `0x00000000000000000000000000000005` (non-zero), 5 array elements, 5 assets received._ - -- `0x` (nothing stored under this data key, equivalent to empty array - -#### Parameters - -| Name | Type | Description | -| -------------------- | :-------: | -------------------------------------------------------------------------------------------------------------------------------- | -| `invalidValueStored` | `bytes` | invalidValueLength The invalid number of bytes stored under the `LSP5ReceivedAssets[]` data key (MUST be exactly 16 bytes long). | -| `invalidValueLength` | `uint256` | The invalid number of bytes stored under the `LSP5ReceivedAssets[]` data key (MUST be exactly 16 bytes long). | - -
- -### MaxLSP5ReceivedAssetsCountReached - -:::note References - -- Specification details: [**LSP-5-ReceivedAssets**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-5-ReceivedAssets.md#)) -- Solidity implementation: [`LSP5Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP5ReceivedAssets/LSP5Utils.sol) -- Error signature: `)` -- Error hash: `0x59d76dc3` - -::: - -```solidity -MaxLSP5ReceivedAssetsCountReached(address); -``` - -Reverts when the `LSP5ReceivedAssets[]` Array reaches its maximum limit (`max(uint128)`) - -#### Parameters - -| Name | Type | Description | -| -------------------- | :-------: | ------------------------------------------------------ | -| `notRegisteredAsset` | `address` | The address of the asset that could not be registered. | - -
- -### ReceivedAssetsIndexSuperiorToUint128 - -:::note References - -- Specification details: [**LSP-5-ReceivedAssets**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-5-ReceivedAssets.md#)) -- Solidity implementation: [`LSP5Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP5ReceivedAssets/LSP5Utils.sol) -- Error signature: `)` -- Error hash: `0x59d76dc3` - -::: - -```solidity -ReceivedAssetsIndexSuperiorToUint128(uint256); -``` - -Reverts when the received assets index is superior to `max(uint128)` - -#### Parameters - -| Name | Type | Description | -| ------- | :-------: | -------------------------- | -| `index` | `uint256` | The received assets index. | +| Name | Type | Description | +| ---------------- | :---------: | -------------------------------------------------------------------- | +| `lsp5DataKeys` | `bytes32[]` | An array Data Keys used to update the [LSP-5-ReceivedAssets] data. | +| `lsp5DataValues` | `bytes[]` | An array Data Values used to update the [LSP-5-ReceivedAssets] data. |