Skip to content

Commit

Permalink
docs: update auto-generated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
b00ste committed Aug 21, 2023
1 parent 4ad4d4e commit 096da32
Show file tree
Hide file tree
Showing 6 changed files with 335 additions and 606 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand All @@ -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`._
Expand All @@ -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`. |

<br/>

Expand All @@ -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)

<br/>
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. |

<br/>

## 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. |

<br/>

## 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. |

<br/>

### 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. |

<br/>

### 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. |

<br/>

### 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. |

<br/>

### 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. |

<br/>

## Errors

### NativeTokensNotAccepted

:::note References
Expand All @@ -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`)

<br/>

### 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. |

<br/>

### 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. |

<br/>
Loading

0 comments on commit 096da32

Please sign in to comment.