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

refactor!: remove LSP0Utils.sol in favour of moving the functions inside LSP1Utils.sol #683

Merged
merged 1 commit into from
Aug 22, 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
47 changes: 0 additions & 47 deletions contracts/LSP0ERC725Account/LSP0Utils.sol

This file was deleted.

45 changes: 44 additions & 1 deletion contracts/LSP1UniversalReceiver/LSP1Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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:<type-id>` for a specific `typeId`.
*
* @dev 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`.
*
* @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:<bytes32>` 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`.
*
Expand Down
75 changes: 0 additions & 75 deletions docs/libraries/LSP0ERC725Account/LSP0Utils.md

This file was deleted.

56 changes: 56 additions & 0 deletions docs/libraries/LSP1UniversalReceiver/LSP1Utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,62 @@ as additional informations in the calldata.

<br/>

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

<br/>

### getLSP1DelegateValueForTypeId

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

_Retrieving the value stored under the ERC725Y data key `LSP1UniversalReceiverDelegate:<type-id>` for a specific `typeId`._

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` | The bytes value stored under the `LSP1UniversalReceiverDelegate:<bytes32>` data key. |

<br/>

### getTransferDetails

```solidity
Expand Down
2 changes: 0 additions & 2 deletions dodoc/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
Loading