Skip to content

Commit

Permalink
Merge pull request #705 from lukso-network/contracts-docs-sync
Browse files Browse the repository at this point in the history
[Auto-Sync] Update Smart Contracts Technical Docs
  • Loading branch information
CJ42 authored Nov 9, 2023
2 parents 89bd6f2 + da3db07 commit b03f772
Show file tree
Hide file tree
Showing 26 changed files with 597 additions and 1,024 deletions.
105 changes: 61 additions & 44 deletions docs/contracts/contracts/LSP0ERC725Account/LSP0ERC725Account.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ constructor(address initialOwner);

_Deploying a LSP0ERC725Account contract with owner set to address `initialOwner`._

Set `initialOwner` as the contract owner. The `constructor` also allows funding the contract on deployment.
Set `initialOwner` as the contract owner.

- The `constructor` also allows funding the contract on deployment.

- The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.

<blockquote>

Expand Down Expand Up @@ -82,6 +86,13 @@ Set `initialOwner` as the contract owner. The `constructor` also allows funding

:::

:::info

Whenever the call is associated with native tokens, the function will delegate the handling of native tokens internally to the [`universalReceiver`](#universalreceiver) function
passing `_TYPEID_LSP0_VALUE_RECEIVED` as typeId and the calldata as received data, except when the native token will be sent directly to the extension.

:::

```solidity
fallback(bytes calldata callData) external payable returns (bytes memory);
```
Expand Down Expand Up @@ -125,6 +136,13 @@ This function is executed when:

:::

:::info

This function internally delegates the handling of native tokens to the [`universalReceiver`](#universalreceiver) function
passing `_TYPEID_LSP0_VALUE_RECEIVED` as typeId and an empty bytes array as received data.

:::

```solidity
receive() external payable;
```
Expand All @@ -139,7 +157,7 @@ Executed:

**Emitted events:**

- [`UniversalReceiver`](#universalreceiver) event when receiving native tokens.
- Emits a [`UniversalReceiver`](#universalreceiver) event when the `universalReceiver` logic is executed upon receiving native tokens.

</blockquote>

Expand Down Expand Up @@ -197,6 +215,31 @@ function RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD()

<br/>

### VERSION

:::note References

- Specification details: [**LSP-0-ERC725Account**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-0-ERC725Account.md#version)
- Solidity implementation: [`LSP0ERC725Account.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP0ERC725Account/LSP0ERC725Account.sol)
- Function signature: `VERSION()`
- Function selector: `0xffa1ad74`

:::

```solidity
function VERSION() external view returns (string);
```

_Contract version._

#### Returns

| Name | Type | Description |
| ---- | :------: | ----------- |
| `0` | `string` | - |

<br/>

### acceptOwnership

:::note References
Expand Down Expand Up @@ -245,7 +288,7 @@ Transfer ownership of the contract from the current [`owner()`](#owner) to the [

:::info

It&#39;s not possible to send value along the functions call due to the use of `delegatecall`.
It's not possible to send value along the functions call due to the use of `delegatecall`.

:::

Expand Down Expand Up @@ -487,6 +530,12 @@ Get in the ERC725Y storage the bytes data stored at multiple data keys `dataKeys

:::

:::caution Warning

This function does not enforce by default the inclusion of the address of this contract in the signature digest. It is recommended that protocols or applications using this contract include the targeted address (= this contract) in the data to sign. To ensure that a signature is valid for a specific LSP0ERC725Account and prevent signatures from the same EOA to be replayed across different LSP0ERC725Accounts.

:::

```solidity
function isValidSignature(
bytes32 dataHash,
Expand Down Expand Up @@ -812,7 +861,7 @@ Achieves the goal of [LSP-1-UniversalReceiver] by allowing the account to be not

- If there is an address stored under the data key, check if this address supports the LSP1 interfaceId.

- If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function.
- If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function. This function delegates internally the handling of native tokens to the [`universalReceiver`](#universalreceiver) function itself passing `_TYPEID_LSP0_VALUE_RECEIVED` as typeId and the calldata as received data.

<blockquote>

Expand All @@ -838,33 +887,6 @@ Achieves the goal of [LSP-1-UniversalReceiver] by allowing the account to be not

<br/>

### version

:::note References

- Specification details: [**LSP-0-ERC725Account**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-0-ERC725Account.md#version)
- Solidity implementation: [`LSP0ERC725Account.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP0ERC725Account/LSP0ERC725Account.sol)
- Function signature: `version()`
- Function selector: `0x54fd4d50`

:::

```solidity
function version() external view returns (string);
```

_Contract version._

Get the version of the contract.

#### Returns

| Name | Type | Description |
| ---- | :------: | -------------------------------- |
| `0` | `string` | The version of the the contract. |

<br/>

## 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.
Expand Down Expand Up @@ -1180,26 +1202,21 @@ function _getExtensionAndForwardValue(
) internal view returns (address, bool);
```

Returns the extension address stored under the following data key:
Returns the extension address and the boolean indicating whether to forward the value received to the extension, stored under the following data key:

- [`_LSP17_EXTENSION_PREFIX`](#_lsp17_extension_prefix) + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).

- If no extension is stored, returns the address(0).

- If the stored value is 20 bytes, return false for the boolean

<br/>

### \_fallbackLSP17Extendable

:::tip Hint

This function does not forward to the extension contract the `msg.value` received by the contract that inherits `LSP17Extendable`.
If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow:

```solidity
(bool success, bytes memory result) = extension.call\{value: msg.value\}(
abi.encodePacked(callData, msg.sender, msg.value)
);
```
If you would like to forward the `msg.value` to the extension contract, you should store an additional `0x01` byte after the address of the extension under the corresponding LSP17 data key.

:::

Expand Down Expand Up @@ -1464,11 +1481,11 @@ Emitted when the [`universalReceiver`](#universalreceiver) function was called w

| 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. |
| `from` **`indexed`** | `address` | The address of the EOA or smart contract that called the [`universalReceiver(...)`](#universalreceiver) function. |
| `value` **`indexed`** | `uint256` | The amount sent to the [`universalReceiver(...)`](#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. |
| `receivedData` | `bytes` | Any arbitrary data that was sent to the [`universalReceiver(...)`](#universalreceiver) function. |
| `returnedValue` | `bytes` | The value returned by the [`universalReceiver(...)`](#universalreceiver) function. |

<br/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ If there is an extension for the function selector being called, it calls the ex

<br/>

### Additional Resources

- [🎥 BuildUP #2 | Adding Functionalities to Universal Profiles using LSP17 - Contract Extension (YouTube)](https://www.youtube.com/watch?v=0KxkLZHFa0E)

<!-- GLOBAL LINKS -->

<!-- prettier-ignore-start -->
Expand Down Expand Up @@ -317,4 +313,4 @@ If there is an extension for the function selector being called, it calls the ex
[`LSP10Utils.sol`]: https://github.com/lukso-network/lsp-smart-contracts/tree/main/contracts/LSP10ReceivedVaults/LSP10Utils.sol
[`LSP10Constants.sol`]: https://github.com/lukso-network/lsp-smart-contracts/tree/main/contracts/LSP10ReceivedVaults/LSP10Constants.sol

<!-- prettier-ignore-end -->
<!-- prettier-ignore-end -->
48 changes: 23 additions & 25 deletions docs/contracts/contracts/LSP17ContractExtension/LSP17Extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,61 +23,59 @@ Implementation of the extension logic according to LSP17ContractExtension. This
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
### VERSION

:::note References

- Specification details: [**LSP-17-ContractExtension**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-17-ContractExtension.md#supportsinterface)
- Specification details: [**LSP-17-ContractExtension**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-17-ContractExtension.md#version)
- Solidity implementation: [`LSP17Extension.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP17ContractExtension/LSP17Extension.sol)
- Function signature: `supportsInterface(bytes4)`
- Function selector: `0x01ffc9a7`
- Function signature: `VERSION()`
- Function selector: `0xffa1ad74`

:::

```solidity
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function VERSION() external view returns (string);
```

See [`IERC165-supportsInterface`](#ierc165-supportsinterface).

#### Parameters

| Name | Type | Description |
| ------------- | :------: | ----------- |
| `interfaceId` | `bytes4` | - |
_Contract version._

#### Returns

| Name | Type | Description |
| ---- | :----: | ----------- |
| `0` | `bool` | - |
| Name | Type | Description |
| ---- | :------: | ----------- |
| `0` | `string` | - |

<br/>

### version
### supportsInterface

:::note References

- Specification details: [**LSP-17-ContractExtension**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-17-ContractExtension.md#version)
- Specification details: [**LSP-17-ContractExtension**](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-17-ContractExtension.md#supportsinterface)
- Solidity implementation: [`LSP17Extension.sol`](https://github.com/lukso-network/lsp-smart-contracts/blob/develop/contracts/LSP17ContractExtension/LSP17Extension.sol)
- Function signature: `version()`
- Function selector: `0x54fd4d50`
- Function signature: `supportsInterface(bytes4)`
- Function selector: `0x01ffc9a7`

:::

```solidity
function version() external view returns (string);
function supportsInterface(bytes4 interfaceId) external view returns (bool);
```

_Contract version._
See [`IERC165-supportsInterface`](#ierc165-supportsinterface).

Get the version of the contract.
#### Parameters

| Name | Type | Description |
| ------------- | :------: | ----------- |
| `interfaceId` | `bytes4` | - |

#### Returns

| Name | Type | Description |
| ---- | :------: | -------------------------------- |
| `0` | `string` | The version of the the contract. |
| Name | Type | Description |
| ---- | :----: | ----------- |
| `0` | `bool` | - |

<br/>

Expand Down
Loading

0 comments on commit b03f772

Please sign in to comment.