diff --git a/contracts/LSP0ERC725Account/LSP0Utils.sol b/contracts/LSP0ERC725Account/LSP0Utils.sol deleted file mode 100644 index 2bfcb7542..000000000 --- a/contracts/LSP0ERC725Account/LSP0Utils.sol +++ /dev/null @@ -1,47 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.4; - -// libraries -import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol"; - -// constants -import { - _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX, - _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY -} from "../LSP1UniversalReceiver/LSP1Constants.sol"; - -/** - * @title Utility functions to query the storage of an LSP0ERC725Account. - * @author Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi) - */ -library LSP0Utils { - /** - * @dev Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve - * the value set under the `LSP1UniversalReceiverDelegate` data key. - * @param erc725YStorage A reference to the ERC725Y storage mapping of the contract. - * @return The bytes value stored under the `LSP1UniversalReceiverDelegate` data key. - */ - function getLSP1DelegateValue( - mapping(bytes32 => bytes) storage erc725YStorage - ) internal view returns (bytes memory) { - return erc725YStorage[_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY]; - } - - /** - * @dev Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve - * the value set under the `LSP1UniversalReceiverDelegate:` data key for a specific LSP1 `typeId`. - * @param erc725YStorage A reference to the ERC725Y storage mapping of the contract. - * @param typeId A bytes32 LSP1 `typeId`; - * @return The bytes value stored under the `LSP1UniversalReceiverDelegate:` data key. - */ - function getLSP1DelegateValueForTypeId( - mapping(bytes32 => bytes) storage erc725YStorage, - bytes32 typeId - ) internal view returns (bytes memory) { - bytes32 lsp1TypeIdDataKey = LSP2Utils.generateMappingKey( - _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX, - bytes20(typeId) - ); - return erc725YStorage[lsp1TypeIdDataKey]; - } -} diff --git a/contracts/LSP1UniversalReceiver/LSP1Utils.sol b/contracts/LSP1UniversalReceiver/LSP1Utils.sol index 05223b548..a10d0a059 100644 --- a/contracts/LSP1UniversalReceiver/LSP1Utils.sol +++ b/contracts/LSP1UniversalReceiver/LSP1Utils.sol @@ -6,10 +6,17 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; +import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol"; // constants import "./ILSP1UniversalReceiver.sol"; -import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol"; + +// constants +import { + _INTERFACEID_LSP1, + _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY, + _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX +} from "../LSP1UniversalReceiver/LSP1Constants.sol"; import "../LSP0ERC725Account/LSP0Constants.sol"; import "../LSP5ReceivedAssets/LSP5Constants.sol"; import "../LSP7DigitalAsset/LSP7Constants.sol"; @@ -92,6 +99,42 @@ library LSP1Utils { return result.length != 0 ? abi.decode(result, (bytes)) : result; } + /** + * @notice Retrieving the value stored under the ERC725Y data key `LSP1UniversalReceiverDelegate`. + * + * @dev Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve + * the value set under the `LSP1UniversalReceiverDelegate` data key. + * + * @param erc725YStorage A reference to the ERC725Y storage mapping of the contract. + * @return The bytes value stored under the `LSP1UniversalReceiverDelegate` data key. + */ + function getLSP1DelegateValue( + mapping(bytes32 => bytes) storage erc725YStorage + ) internal view returns (bytes memory) { + return erc725YStorage[_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY]; + } + + /** + * @notice Retrieving the value stored under the ERC725Y data key `LSP1UniversalReceiverDelegate:` for a specific `typeId`. + * + * @dev Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve + * the value set under the `LSP1UniversalReceiverDelegate:` data key for a specific LSP1 `typeId`. + * + * @param erc725YStorage A reference to the ERC725Y storage mapping of the contract. + * @param typeId A bytes32 LSP1 `typeId`; + * @return The bytes value stored under the `LSP1UniversalReceiverDelegate:` data key. + */ + function getLSP1DelegateValueForTypeId( + mapping(bytes32 => bytes) storage erc725YStorage, + bytes32 typeId + ) internal view returns (bytes memory) { + bytes32 lsp1TypeIdDataKey = LSP2Utils.generateMappingKey( + _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX, + bytes20(typeId) + ); + return erc725YStorage[lsp1TypeIdDataKey]; + } + /** * @dev Gets all the transfer details based on the provided `bytes32 typeId`. * diff --git a/docs/libraries/LSP0ERC725Account/LSP0Utils.md b/docs/libraries/LSP0ERC725Account/LSP0Utils.md deleted file mode 100644 index 640955d49..000000000 --- a/docs/libraries/LSP0ERC725Account/LSP0Utils.md +++ /dev/null @@ -1,75 +0,0 @@ - - - -# LSP0Utils - -:::info Standard Specifications - -[`LSP-0-ERC725Account`](https://github.com/lukso-network/lips/tree/main/LSPs/LSP-0-ERC725Account.md) - -::: -:::info Solidity implementation - -[`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 - -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. - -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. - -### 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` | 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:` 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` | The bytes value stored under the `LSP1UniversalReceiverDelegate:` data key. | - -
diff --git a/docs/libraries/LSP1UniversalReceiver/LSP1Utils.md b/docs/libraries/LSP1UniversalReceiver/LSP1Utils.md index 211aefa68..bf450e5e3 100644 --- a/docs/libraries/LSP1UniversalReceiver/LSP1Utils.md +++ b/docs/libraries/LSP1UniversalReceiver/LSP1Utils.md @@ -80,6 +80,62 @@ as additional informations in the calldata.
+### getLSP1DelegateValue + +```solidity +function getLSP1DelegateValue( + mapping(bytes32 => bytes) erc725YStorage +) internal view returns (bytes); +``` + +_Retrieving the value stored under the ERC725Y data key `LSP1UniversalReceiverDelegate`._ + +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` | The bytes value stored under the `LSP1UniversalReceiverDelegate` data key. | + +
+ +### getLSP1DelegateValueForTypeId + +```solidity +function getLSP1DelegateValueForTypeId( + mapping(bytes32 => bytes) erc725YStorage, + bytes32 typeId +) internal view returns (bytes); +``` + +_Retrieving the value stored under the ERC725Y data key `LSP1UniversalReceiverDelegate:` for a specific `typeId`._ + +Query internally the ERC725Y storage of a `ERC725Y` smart contract to retrieve +the value set under the `LSP1UniversalReceiverDelegate:` 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` | The bytes value stored under the `LSP1UniversalReceiverDelegate:` data key. | + +
+ ### getTransferDetails ```solidity diff --git a/dodoc/config.ts b/dodoc/config.ts index 254dc7214..ce8863884 100644 --- a/dodoc/config.ts +++ b/dodoc/config.ts @@ -36,7 +36,6 @@ export const dodocConfig = { 'contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol', // libraries -------------------- - 'contracts/LSP0ERC725Account/LSP0Utils.sol', 'contracts/LSP1UniversalReceiver/LSP1Utils.sol', 'contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol', 'contracts/LSP5ReceivedAssets/LSP5Utils.sol', @@ -48,7 +47,6 @@ export const dodocConfig = { '@erc725/smart-contracts/contracts/ERC725.sol', ], libraries: [ - 'contracts/LSP0ERC725Account/LSP0Utils.sol', 'contracts/LSP1UniversalReceiver/LSP1Utils.sol', 'contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol', 'contracts/LSP5ReceivedAssets/LSP5Utils.sol',