Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add contract library auto-generated docs #587

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions docs/contracts/libraries/LSP0Utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# LSP0Utils

:::info Solidity contract

[`LSP0Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP0ERC725Account/LSP0Utils.sol)

:::

> Utility functions to query the storage of an LSP0ERC725Account.

---

## Internal Methods

### getLSP1DelegateValue

```solidity
function getLSP1DelegateValue(mapping(bytes32 => bytes) erc725YStorage) internal view returns (bytes);
```

Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve
the value set under the `LSP1UniversalReceiverDelegate` data key.

#### Parameters

| Name | Type | Description |
| ---------------- | :-------------------------: | ----------------------------------------------------------- |
| `erc725YStorage` | `mapping(bytes32 => bytes)` | A reference to the ERC725Y storage mapping of the contract. |

#### Returns

| Name | Type | Description |
| ---- | :-----: | ---------------------------------------------------------------------------------- |
| `0` | `bytes` | @return The bytes value stored under the `LSP1UniversalReceiverDelegate` data key. |

### getLSP1DelegateValueForTypeId

```solidity
function getLSP1DelegateValueForTypeId(mapping(bytes32 => bytes) erc725YStorage, bytes32 typeId) internal view returns (bytes);
```

Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve
the value set under the `LSP1UniversalReceiverDelegate:<bytes32>` data key for a specific LSP1 `typeId`.

#### Parameters

| Name | Type | Description |
| ---------------- | :-------------------------: | ----------------------------------------------------------- |
| `erc725YStorage` | `mapping(bytes32 => bytes)` | A reference to the ERC725Y storage mapping of the contract. |
| `typeId` | `bytes32` | A bytes32 LSP1 `typeId`; |

#### Returns

| Name | Type | Description |
| ---- | :-----: | -------------------------------------------------------------------------------------------------- |
| `0` | `bytes` | @return The bytes value stored under the `LSP1UniversalReceiverDelegate:&lt;bytes32&gt;` data key. |
87 changes: 87 additions & 0 deletions docs/contracts/libraries/LSP10Utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# LSP10Utils

:::info Solidity contract

[`LSP10Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP10ReceivedVaults/LSP10Utils.sol)

:::

> LSP10 Utility library.

LSP5Utils is a library of functions that can be used to register and manage vaults received by an ERC725Y smart contract. Based on the LSP10 Received Vaults standard.

---

## Internal Methods

### generateReceivedVaultKeys

```solidity
function generateReceivedVaultKeys(address receiver, address vault, bytes32 vaultMapKey) internal view returns (bytes32[] keys, bytes[] values);
```

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` | The address of the vault being received. |
| `vaultMapKey` | `bytes32` | The `LSP10VaultMap:&lt;vault&gt;` data key of the vault being received containing the interfaceId of the |

#### Returns

| Name | Type | Description |
| -------- | :---------: | ------------------------------------------------------------------------------------------------------------------- |
| `keys` | `bytes32[]` | An array of 3 x data keys: `LSP10Vaults[]`, `LSP10Vaults[index]` and `LSP10VaultMap:&lt;asset&gt;`. |
| `values` | `bytes[]` | An array of 3 x data values: the new length of `LSP10Vaults[]`, the address of the asset under `LSP10Vaults[index]` |

### 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:&lt;vault&gt;` 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:&lt;asset&gt;`. |
| `values` | `bytes[]` | An array of 3 x data values: the new length of `LSP10Vaults[]`, the address of the asset under `LSP10Vaults[index]` |

### getLSP10ReceivedVaultsCount

:::info

This function does not return a number but the raw bytes stored under the `LSP10Vaults[]` Array data key.

:::

```solidity
function getLSP10ReceivedVaultsCount(contract IERC725Y account) internal view returns (bytes);
```

Get the total number of vault addresses stored under the `LSP10Vaults[]` Array data key.

#### Parameters

| Name | Type | Description |
| --------- | :-----------------: | ---------------------------------------------------- |
| `account` | `contract IERC725Y` | The ERC725Y smart contract to read the storage from. |

#### Returns

| Name | Type | Description |
| ---- | :-----: | ---------------------------------------------------------------- |
| `0` | `bytes` | @return The raw bytes stored under the `LSP10Vaults[]` data key. |
23 changes: 23 additions & 0 deletions docs/contracts/libraries/LSP17Utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# LSP17Utils

:::info Solidity contract

[`LSP17Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP17ContractExtension/LSP17Utils.sol)

:::

> LSP17 Utility library to check an extension

---

## Internal Methods

### isExtension

```solidity
function isExtension(uint256 parametersLengthWithOffset, uint256 msgDataLength) internal pure returns (bool);
```

Returns whether the call is a normal call or an extension call by checking if
the `parametersLengthWithOffset` with an additional of 52 bytes supposed msg.sender
and msg.value appended is equal to the msgDataLength
80 changes: 80 additions & 0 deletions docs/contracts/libraries/LSP1Utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# LSP1Utils

:::info Solidity contract

[`LSP1Utils.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP1UniversalReceiver/LSP1Utils.sol)

:::

> LSP1 Utility library.

LSP1Utils is a library of utility functions that can be used to notify the `universalReceiver` function of a contract that implements LSP1 and retrieve informations related to LSP1 `typeId`. Based on LSP1 Universal Receiver standard.

---

## Internal Methods

### tryNotifyUniversalReceiver

```solidity
function tryNotifyUniversalReceiver(address lsp1Implementation, bytes32 typeId, bytes data) internal nonpayable;
```

Notify a contract at `lsp1Implementation` address by calling its `universalReceiver` function if this contract
supports the LSP1 interface.

#### Parameters

| Name | Type | Description |
| -------------------- | :-------: | -------------------------------------------------------------------------------------------------- |
| `lsp1Implementation` | `address` | The address of the contract to notify. |
| `typeId` | `bytes32` | A `bytes32` typeId. |
| `data` | `bytes` | Any optional data to send to the `universalReceiver` function to the `lsp1Implementation` address. |

### callUniversalReceiverWithCallerInfos

```solidity
function callUniversalReceiverWithCallerInfos(address universalReceiverDelegate, bytes32 typeId, bytes receivedData, address msgSender, uint256 msgValue) internal nonpayable returns (bytes);
```

Call a LSP1UniversalReceiverDelegate contract at `universalReceiverDelegate` address and append `msgSender` and `msgValue`
as additional informations in the calldata.

#### Parameters

| Name | Type | Description |
| --------------------------- | :-------: | ------------------------------------------------------------------------------------------------- |
| `universalReceiverDelegate` | `address` | The address of the LSP1UniversalReceiverDelegate to delegate the `universalReceiver` function to. |
| `typeId` | `bytes32` | A `bytes32` typeId. |
| `receivedData` | `bytes` | The data sent initially to the `universalReceiver` function. |
| `msgSender` | `address` | The address that initially called the `universalReceiver` function. |
| `msgValue` | `uint256` | The amount of native token received initially by the `universalReceiver` function. |

#### Returns

| Name | Type | Description |
| ---- | :-----: | ------------------------------------------------------------------------ |
| `0` | `bytes` | @return 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 |
Loading