Skip to content

Commit

Permalink
docs: add links to overview docs
Browse files Browse the repository at this point in the history
  • Loading branch information
b00ste committed Sep 21, 2023
1 parent a88bbe9 commit b0d47d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions docs/contracts/overview/LSP17ContractExtension.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Contracts that use the LSP17 standard are called **Extendable Contracts**. Meani

The list of extensions for specific functions are stored under the specific data keys under their ERC725Y storage. You can think of them as **Extension Hosts**.

You can inherit the `LSP17Extendable.sol` contract to create an extendable contract.
You can inherit the [`LSP17Extendable.sol`](../contracts/LSP17ContractExtension/LSP17Extendable.md) contract to create an extendable contract.

:::warning

Be aware that adding an extension that can `selfdestruct` itself can be dangerous. This can make the `LSP17Extendable` contract vulnerable to [metamorphic contracts](https://twitter.com/samczsun/status/1660012956632104960).
Be aware that adding an extension that can `selfdestruct` itself can be dangerous. This can make the [`LSP17Extendable`](../contracts/LSP17ContractExtension/LSP17Extendable.md) contract vulnerable to [metamorphic contracts](https://twitter.com/samczsun/status/1660012956632104960).

If this extension contract has been deployed at a pre-determined address with `CREATE2`, an attacker could `selfdestruct` it and deploy a new one with different runtime bytecode using `CREATE2` and the same salt and initialization code as on the first deployment.

Expand All @@ -26,9 +26,9 @@ This can result in the new contract to have the same address but different funct

### Forwarding native tokens received to extensions

The `LSP17Extendable` contract implementation does not forward by default the native tokens received by the contract to the extension contract.
The [`LSP17Extendable`](../contracts/LSP17ContractExtension/LSP17Extendable.md) contract implementation does not forward by default the native tokens received by the contract to the extension contract.

If you want your extension to receive native tokens, by forwarding them to the extension contract (for instance, for extensions that require native tokens as part of their logic, or to make the extendable contract to fully work as a _"proxy forwarder contract"_), you can override the `_fallbackLSP17Extendable(...)` function.
If you want your extension to receive native tokens, by forwarding them to the extension contract (for instance, for extensions that require native tokens as part of their logic, or to make the extendable contract to fully work as a _"proxy forwarder contract"_), you can override the [`_fallbackLSP17Extendable`](../contracts/LSP17ContractExtension/LSP17Extendable.md#_fallbacklsp17extendable) function.



Expand All @@ -37,7 +37,7 @@ If you want your extension to receive native tokens, by forwarding them to the e

Extension contracts are contracts deployed on the network that aim to be used for extending functionalities that use the LSP17 standard.

You can inherit the `LSP17Extension.sol` contract to create a contract extension.
You can inherit the [`LSP17Extendable.sol`](../contracts/LSP17ContractExtension/LSP17Extendable.md) contract to create a contract extension.

:::warning

Expand All @@ -55,7 +55,7 @@ if (msg.value == 0) revert(...)

### Checking the amount of native tokens received by the extended contract

You can use the function `_extendableMsgValue()` function to check the amount of native tokens received by the extended contract in the first place.
You can use the function [`_extendableMsgValue()`](../contracts/LSP17ContractExtension/LSP17Extension.md#_extendablemsgvalue) function to check the amount of native tokens received by the extended contract in the first place.

This function can be useful if you want to create a behaviour in your extension contract that takes into account that the `msg.value` received. For instance:

Expand Down
16 changes: 8 additions & 8 deletions docs/contracts/overview/UniversalProfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ A `UniversalProfile` has all the basic functionalities of an _Externally Owned A
- [`universalReceiver(...)`](#universalreceiver): brings notification of incoming calls and assets.
- [`setData(...)`](#setdata): offers to set information in the account storage.

All ownable functions such as `execute(..)`, `setData(..)`, `transferOwnership(..)`, and `renounceOwnership(..)` can be called by the owner
All ownable functions such as [`execute(..)`](../contracts/UniversalProfile.md#execute), [`executeBatch(..)`](../contracts/UniversalProfile.md#executebatch), [`setData(..)`](../contracts/UniversalProfile.md#setdata), [`setDataBatch(..)`](../contracts/UniversalProfile.md#setdatabatch), [`transferOwnership(..)`](../contracts/UniversalProfile.md#transferownership), and [`renounceOwnership(..)`](../contracts/UniversalProfile.md#renounceownership) can be called by the owner

The contract also includes the [LSP20-CallVerification](../../standards/universal-profile/lsp0-erc725account.md#lsp20---call-verification) at its core. Meaning if the contract is owned by an other contract, LSP20 enables to interact with the contract directly without having to resolve through its owner first. This allows seamless integrations with other contracts, protocols and dApps, as the contract can be called directly, making the developer experience easier.

To illustrate, if an other address than the owner calls the `execute(..)` function, the account contract will:
To illustrate, if an other address than the owner calls the [`execute(..)`](../contracts/UniversalProfile.md#execute) function, the account contract will:

1. Forward the call to the owner.
2. The execution of the function will only continue if the owner returns the `LSP20 MAGIC VALUE`, indicating that the caller is allowed to execute the function.
Expand All @@ -36,7 +36,7 @@ The structure allows the account to have a more dynamic and adaptable approach f

## Extensions

An `LSP0ERC725Account` has the functionalities of `LSP17Extendable` built-in. This allows extending its behavior with functions it does not support natively in its interface.
An [`LSP0ERC725Account`](../contracts/LSP0ERC725Account/LSP0ERC725Account.md) has the functionalities of [`LSP17Extendable`](../contracts/LSP17ContractExtension/LSP17Extendable.md) built-in. This allows extending its behavior with functions it does not support natively in its interface.

However, calls to the `fallback` function will revert if no extension is registered for the function selector that was called.

Expand All @@ -49,29 +49,29 @@ The only exception is the `0x00000000` function selector, which returns in order
:::caution

If your Universal Profile calls an extension to perform some security check, verification or validation, you should not rely on the extension to revert to ensure
the validation failed, but check the `bytes` returned by the extension through `_fallbackLSP17Extendable`.
the validation failed, but check the `bytes` returned by the extension through [`_fallbackLSP17Extendable`](../contracts/LSP17ContractExtension/LSP17Extendable.md#_fallbacklsp17extendable).

:::

:::caution

Be aware of phantom functions for functions in extensions with the `0x00000000` selector.
Be aware of [phantom functions](https://media.dedaub.com/phantom-functions-and-the-billion-dollar-no-op-c56f062ae49f) for functions in extensions with the `0x00000000` selector.

For example, a contract might perform some kind of validation in an extension (_e.g: checking for permissions_), and expect the function to revert if the user is not authorized.

However, since the function's selector is `0x00000000` and the LSP0 account doesn't have this extension registered, the `fallback` function will `return` instead of reverting, giving the contract the impression that the user is authorized.

> See `_fallbackLSP17Extendable` for more details.
> See [`_fallbackLSP17Extendable`](../contracts/LSP17ContractExtension/LSP17Extendable.md#_fallbacklsp17extendable) for more details.
In such case, make sure to double that an extension is registered first for the `0x00000000` selector via `_getExtension`.
In such case, make sure to double that an extension is registered first for the `0x00000000` selector via [`_getExtension`](../contracts/LSP17ContractExtension/LSP17Extendable.md#_getextension).

:::

## Adding metadata

Unlike private keys and EOAs that cannot hold any metadata, a UniversalProfile is a blockchain based account that can have any info attached to it.

You can do so using the `setData(bytes32,bytes)` and `setDataBatch(bytes32[],bytes[])` functions to add, update or delete any metadata in your Universal Profile.
You can do so using the [`setData(bytes32,bytes)`](../contracts/UniversalProfile.md#setdata) and [`setDataBatch(bytes32[],bytes[])`](../contracts/UniversalProfile.md#setdatabatch) functions to add, update or delete any metadata in your Universal Profile.

### Updating your `LSP3Profile` metadata.

Expand Down

0 comments on commit b0d47d7

Please sign in to comment.