diff --git a/contracts/RMRK/emotable/EmotableRepository.sol b/contracts/RMRK/emotable/EmotableRepository.sol index 58f0783f..d84181b9 100644 --- a/contracts/RMRK/emotable/EmotableRepository.sol +++ b/contracts/RMRK/emotable/EmotableRepository.sol @@ -2,13 +2,13 @@ pragma solidity ^0.8.21; -import "./IERC6381Extended.sol"; +import "./IEmotableRepository.sol"; error BulkParametersOfUnequalLength(); error ExpiredPresignedEmote(); error InvalidSignature(); -contract EmotableRepository is IERC6381Extended { +contract EmotableRepository is IEmotableRepository { bytes32 public immutable DOMAIN_SEPARATOR = keccak256( abi.encode( @@ -25,6 +25,9 @@ contract EmotableRepository is IERC6381Extended { mapping(address => mapping(uint256 => mapping(string => uint256))) private _emotesPerToken; + /** + * inheritdoc IEmotableRepository + */ function emoteCountOf( address collection, uint256 tokenId, @@ -33,6 +36,9 @@ contract EmotableRepository is IERC6381Extended { return _emotesPerToken[collection][tokenId][emoji]; } + /** + * inheritdoc IEmotableRepository + */ function bulkEmoteCountOf( address[] memory collections, uint256[] memory tokenIds, @@ -55,6 +61,9 @@ contract EmotableRepository is IERC6381Extended { return counts; } + /** + * inheritdoc IEmotableRepository + */ function hasEmoterUsedEmote( address emoter, address collection, @@ -64,6 +73,9 @@ contract EmotableRepository is IERC6381Extended { return _emotesUsedByEmoter[emoter][collection][tokenId][emoji] == 1; } + /** + * inheritdoc IEmotableRepository + */ function haveEmotersUsedEmotes( address[] memory emoters, address[] memory collections, @@ -92,6 +104,9 @@ contract EmotableRepository is IERC6381Extended { return states; } + /** + * inheritdoc IEmotableRepository + */ function emote( address collection, uint256 tokenId, @@ -114,6 +129,9 @@ contract EmotableRepository is IERC6381Extended { } } + /** + * inheritdoc IEmotableRepository + */ function bulkEmote( address[] memory collections, uint256[] memory tokenIds, @@ -162,6 +180,9 @@ contract EmotableRepository is IERC6381Extended { } } + /** + * inheritdoc IEmotableRepository + */ function prepareMessageToPresignEmote( address collection, uint256 tokenId, @@ -182,6 +203,9 @@ contract EmotableRepository is IERC6381Extended { ); } + /** + * inheritdoc IEmotableRepository + */ function bulkPrepareMessagesToPresignEmote( address[] memory collections, uint256[] memory tokenIds, @@ -218,6 +242,9 @@ contract EmotableRepository is IERC6381Extended { return messages; } + /** + * inheritdoc IEmotableRepository + */ function presignedEmote( address emoter, address collection, @@ -268,6 +295,9 @@ contract EmotableRepository is IERC6381Extended { } } + /** + * inheritdoc IEmotableRepository + */ function bulkPresignedEmote( address[] memory emoters, address[] memory collections, @@ -351,11 +381,14 @@ contract EmotableRepository is IERC6381Extended { } } + /** + * inheritdoc IERC165 + */ function supportsInterface( bytes4 interfaceId ) public view virtual returns (bool) { return - interfaceId == type(IERC6381Extended).interfaceId || + interfaceId == type(IEmotableRepository).interfaceId || interfaceId == type(IERC165).interfaceId; } } diff --git a/contracts/RMRK/emotable/IERC6381Extended.sol b/contracts/RMRK/emotable/IERC6381Extended.sol deleted file mode 100644 index b831bac6..00000000 --- a/contracts/RMRK/emotable/IERC6381Extended.sol +++ /dev/null @@ -1,95 +0,0 @@ -// SPDX-License-Identifier: CC0-1.0 - -pragma solidity ^0.8.21; - -import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; - -interface IERC6381Extended is IERC165 { - event Emoted( - address indexed emoter, - address indexed collection, - uint256 indexed tokenId, - string emoji, - bool on - ); - - function emoteCountOf( - address collection, - uint256 tokenId, - string memory emoji - ) external view returns (uint256); - - function bulkEmoteCountOf( - address[] memory collections, - uint256[] memory tokenIds, - string[] memory emojis - ) external view returns (uint256[] memory); - - function hasEmoterUsedEmote( - address emoter, - address collection, - uint256 tokenId, - string memory emoji - ) external view returns (bool); - - function haveEmotersUsedEmotes( - address[] memory emoters, - address[] memory collections, - uint256[] memory tokenIds, - string[] memory emojis - ) external view returns (bool[] memory); - - function prepareMessageToPresignEmote( - address collection, - uint256 tokenId, - string memory emoji, - bool state, - uint256 deadline - ) external view returns (bytes32); - - function bulkPrepareMessagesToPresignEmote( - address[] memory collections, - uint256[] memory tokenIds, - string[] memory emojis, - bool[] memory states, - uint256[] memory deadlines - ) external view returns (bytes32[] memory); - - function emote( - address collection, - uint256 tokenId, - string memory emoji, - bool state - ) external; - - function bulkEmote( - address[] memory collections, - uint256[] memory tokenIds, - string[] memory emojis, - bool[] memory states - ) external; - - function presignedEmote( - address emoter, - address collection, - uint256 tokenId, - string memory emoji, - bool state, - uint256 deadline, - uint8 v, - bytes32 r, - bytes32 s - ) external; - - function bulkPresignedEmote( - address[] memory emoters, - address[] memory collections, - uint256[] memory tokenIds, - string[] memory emojis, - bool[] memory states, - uint256[] memory deadlines, - uint8[] memory v, - bytes32[] memory r, - bytes32[] memory s - ) external; -} diff --git a/contracts/RMRK/emotable/IEmotableRepository.sol b/contracts/RMRK/emotable/IEmotableRepository.sol new file mode 100644 index 00000000..0757c301 --- /dev/null +++ b/contracts/RMRK/emotable/IEmotableRepository.sol @@ -0,0 +1,212 @@ +// SPDX-License-Identifier: CC0-1.0 + +pragma solidity ^0.8.21; + +import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; + +interface IEmotableRepository is IERC165 { + /** + * @notice Used to notify listeners that the token with the specified ID has been emoted to or that the reaction has been revoked. + * @dev The event MUST only be emitted if the state of the emote is changed. + * @param emoter Address of the account that emoted or revoked the reaction to the token + * @param collection Address of the collection smart contract containing the token being emoted to or having the reaction revoked + * @param tokenId ID of the token + * @param emoji Unicode identifier of the emoji + * @param on Boolean value signifying whether the token was emoted to (`true`) or if the reaction has been revoked (`false`) + */ + event Emoted( + address indexed emoter, + address indexed collection, + uint256 indexed tokenId, + string emoji, + bool on + ); + + /** + * @notice Used to get the number of emotes for a specific emoji on a token. + * @param collection Address of the collection containing the token being checked for emoji count + * @param tokenId ID of the token to check for emoji count + * @param emoji Unicode identifier of the emoji + * @return Number of emotes with the emoji on the token + */ + function emoteCountOf( + address collection, + uint256 tokenId, + string memory emoji + ) external view returns (uint256); + + /** + * @notice Used to get the number of emotes for a specific emoji on a set of tokens. + * @param collections An array of addresses of the collections containing the tokens being checked for emoji count + * @param tokenIds An array of IDs of the tokens to check for emoji count + * @param emojis An array of unicode identifiers of the emojis + * @return An array of numbers of emotes with the emoji on the tokens + */ + function bulkEmoteCountOf( + address[] memory collections, + uint256[] memory tokenIds, + string[] memory emojis + ) external view returns (uint256[] memory); + + /** + * @notice Used to get the information on whether the specified address has used a specific emoji on a specific + * token. + * @param emoter Address of the account we are checking for a reaction to a token + * @param collection Address of the collection smart contract containing the token being checked for emoji reaction + * @param tokenId ID of the token being checked for emoji reaction + * @param emoji The ASCII emoji code being checked for reaction + * @return A boolean value indicating whether the `emoter` has used the `emoji` on the token (`true`) or not + * (`false`) + */ + function hasEmoterUsedEmote( + address emoter, + address collection, + uint256 tokenId, + string memory emoji + ) external view returns (bool); + + /** + * @notice Used to get the information on whether the specified addresses have used specific emojis on specific + * tokens. + * @param emoters An array of addresses of the accounts we are checking for reactions to tokens + * @param collections An array of addresses of the collection smart contracts containing the tokens being checked + * for emoji reactions + * @param tokenIds An array of IDs of the tokens being checked for emoji reactions + * @param emojis An array of the ASCII emoji codes being checked for reactions + * @return An array of boolean values indicating whether the `emoter`s has used the `emoji`s on the tokens (`true`) + * or not (`false`) + */ + function haveEmotersUsedEmotes( + address[] memory emoters, + address[] memory collections, + uint256[] memory tokenIds, + string[] memory emojis + ) external view returns (bool[] memory); + + /** + * @notice Used to get the message to be signed by the `emoter` in order for the reaction to be submitted by someone + * else. + * @param collection The address of the collection smart contract containing the token being emoted at + * @param tokenId ID of the token being emoted + * @param emoji Unicode identifier of the emoji + * @param state Boolean value signifying whether to emote (`true`) or undo (`false`) emote + * @param deadline UNIX timestamp of the deadline for the signature to be submitted + * @return The message to be signed by the `emoter` in order for the reaction to be submitted by someone else + */ + function prepareMessageToPresignEmote( + address collection, + uint256 tokenId, + string memory emoji, + bool state, + uint256 deadline + ) external view returns (bytes32); + + /** + * @notice Used to get multiple messages to be signed by the `emoter` in order for the reaction to be submitted by someone + * else. + * @param collections An array of addresses of the collection smart contracts containing the tokens being emoted at + * @param tokenIds An array of IDs of the tokens being emoted + * @param emojis An array of unicode identifiers of the emojis + * @param states An array of boolean values signifying whether to emote (`true`) or undo (`false`) emote + * @param deadlines An array of UNIX timestamps of the deadlines for the signatures to be submitted + * @return The array of messages to be signed by the `emoter` in order for the reaction to be submitted by someone else + */ + function bulkPrepareMessagesToPresignEmote( + address[] memory collections, + uint256[] memory tokenIds, + string[] memory emojis, + bool[] memory states, + uint256[] memory deadlines + ) external view returns (bytes32[] memory); + + /** + * @notice Used to emote or undo an emote on a token. + * @dev Does nothing if attempting to set a pre-existent state. + * @dev MUST emit the `Emoted` event is the state of the emote is changed. + * @param collection Address of the collection containing the token being emoted at + * @param tokenId ID of the token being emoted + * @param emoji Unicode identifier of the emoji + * @param state Boolean value signifying whether to emote (`true`) or undo (`false`) emote + */ + function emote( + address collection, + uint256 tokenId, + string memory emoji, + bool state + ) external; + + /** + * @notice Used to emote or undo an emote on multiple tokens. + * @dev Does nothing if attempting to set a pre-existent state. + * @dev MUST emit the `Emoted` event is the state of the emote is changed. + * @dev MUST revert if the lengths of the `collections`, `tokenIds`, `emojis` and `states` arrays are not equal. + * @param collections An array of addresses of the collections containing the tokens being emoted at + * @param tokenIds An array of IDs of the tokens being emoted + * @param emojis An array of unicode identifiers of the emojis + * @param states An array of boolean values signifying whether to emote (`true`) or undo (`false`) emote + */ + function bulkEmote( + address[] memory collections, + uint256[] memory tokenIds, + string[] memory emojis, + bool[] memory states + ) external; + + /** + * @notice Used to emote or undo an emote on someone else's behalf. + * @dev Does nothing if attempting to set a pre-existent state. + * @dev MUST emit the `Emoted` event is the state of the emote is changed. + * @dev MUST revert if the lengths of the `collections`, `tokenIds`, `emojis` and `states` arrays are not equal. + * @dev MUST revert if the `deadline` has passed. + * @dev MUST revert if the recovered address is the zero address. + * @param emoter The address that presigned the emote + * @param collection The address of the collection smart contract containing the token being emoted at + * @param tokenId IDs of the token being emoted + * @param emoji Unicode identifier of the emoji + * @param state Boolean value signifying whether to emote (`true`) or undo (`false`) emote + * @param deadline UNIX timestamp of the deadline for the signature to be submitted + * @param v `v` value of an ECDSA signature of the message obtained via `prepareMessageToPresignEmote` + * @param r `r` value of an ECDSA signature of the message obtained via `prepareMessageToPresignEmote` + * @param s `s` value of an ECDSA signature of the message obtained via `prepareMessageToPresignEmote` + */ + function presignedEmote( + address emoter, + address collection, + uint256 tokenId, + string memory emoji, + bool state, + uint256 deadline, + uint8 v, + bytes32 r, + bytes32 s + ) external; + + /** + * @notice Used to bulk emote or undo an emote on someone else's behalf. + * @dev Does nothing if attempting to set a pre-existent state. + * @dev MUST emit the `Emoted` event is the state of the emote is changed. + * @dev MUST revert if the lengths of the `collections`, `tokenIds`, `emojis` and `states` arrays are not equal. + * @dev MUST revert if the `deadline` has passed. + * @dev MUST revert if the recovered address is the zero address. + * @param emoters An array of addresses of the accounts that presigned the emotes + * @param collections An array of addresses of the collections containing the tokens being emoted at + * @param tokenIds An array of IDs of the tokens being emoted + * @param emojis An array of unicode identifiers of the emojis + * @param states An array of boolean values signifying whether to emote (`true`) or undo (`false`) emote + * @param deadlines UNIX timestamp of the deadline for the signature to be submitted + * @param v An array of `v` values of an ECDSA signatures of the messages obtained via `prepareMessageToPresignEmote` + * @param r An array of `r` values of an ECDSA signatures of the messages obtained via `prepareMessageToPresignEmote` + * @param s An array of `s` values of an ECDSA signatures of the messages obtained via `prepareMessageToPresignEmote` + */ + function bulkPresignedEmote( + address[] memory emoters, + address[] memory collections, + uint256[] memory tokenIds, + string[] memory emojis, + bool[] memory states, + uint256[] memory deadlines, + uint8[] memory v, + bytes32[] memory r, + bytes32[] memory s + ) external; +} diff --git a/contracts/RMRK/extension/RMRKRoyalties.sol b/contracts/RMRK/extension/RMRKRoyalties.sol index 0a074772..f90f4ebe 100644 --- a/contracts/RMRK/extension/RMRKRoyalties.sol +++ b/contracts/RMRK/extension/RMRKRoyalties.sol @@ -10,8 +10,8 @@ import "../library/RMRKErrors.sol"; * @author RMRK team * @notice Smart contract of the RMRK Royalties module. */ -/** is IERC2981 **/ abstract contract RMRKRoyalties { - // Inheritance is commmnted to prevent linearization issues +abstract contract RMRKRoyalties { + /** is IERC2981 **/ // Inheritance is commmnted to prevent linearization issues address private _royaltyRecipient; uint256 private _royaltyPercentageBps; diff --git a/contracts/RMRK/extension/tokenHolder/RMRKTokenHolder.sol b/contracts/RMRK/extension/tokenHolder/RMRKTokenHolder.sol index 20779b24..e2d3e816 100644 --- a/contracts/RMRK/extension/tokenHolder/RMRKTokenHolder.sol +++ b/contracts/RMRK/extension/tokenHolder/RMRKTokenHolder.sol @@ -20,7 +20,7 @@ error InsufficientBalance(); * @dev The RMRKTokenHolder extension is capable of holding ERC-20, ERC-721, and ERC-1155 tokens. */ abstract contract RMRKTokenHolder is IRMRKTokenHolder { - mapping(uint256 => mapping(address => mapping(TokenType => mapping(uint256 => uint256)))) + mapping(uint256 tokenId => mapping(address tokenAddress => mapping(TokenType tokenType => mapping(uint256 heldTokenId => uint256 balance)))) private _balances; /** diff --git a/docs/RMRK/emotable/EmotableRepository.md b/docs/RMRK/emotable/EmotableRepository.md index 23fac510..9ce0d692 100644 --- a/docs/RMRK/emotable/EmotableRepository.md +++ b/docs/RMRK/emotable/EmotableRepository.md @@ -33,7 +33,7 @@ function DOMAIN_SEPARATOR() external view returns (bytes32) function bulkEmote(address[] collections, uint256[] tokenIds, string[] emojis, bool[] states) external nonpayable ``` - +inheritdoc IEmotableRepository @@ -52,7 +52,7 @@ function bulkEmote(address[] collections, uint256[] tokenIds, string[] emojis, b function bulkEmoteCountOf(address[] collections, uint256[] tokenIds, string[] emojis) external view returns (uint256[]) ``` - +inheritdoc IEmotableRepository @@ -76,7 +76,7 @@ function bulkEmoteCountOf(address[] collections, uint256[] tokenIds, string[] em function bulkPrepareMessagesToPresignEmote(address[] collections, uint256[] tokenIds, string[] emojis, bool[] states, uint256[] deadlines) external view returns (bytes32[]) ``` - +inheritdoc IEmotableRepository @@ -102,7 +102,7 @@ function bulkPrepareMessagesToPresignEmote(address[] collections, uint256[] toke function bulkPresignedEmote(address[] emoters, address[] collections, uint256[] tokenIds, string[] emojis, bool[] states, uint256[] deadlines, uint8[] v, bytes32[] r, bytes32[] s) external nonpayable ``` - +inheritdoc IEmotableRepository @@ -126,7 +126,7 @@ function bulkPresignedEmote(address[] emoters, address[] collections, uint256[] function emote(address collection, uint256 tokenId, string emoji, bool state) external nonpayable ``` - +inheritdoc IEmotableRepository @@ -145,7 +145,7 @@ function emote(address collection, uint256 tokenId, string emoji, bool state) ex function emoteCountOf(address collection, uint256 tokenId, string emoji) external view returns (uint256) ``` - +inheritdoc IEmotableRepository @@ -169,7 +169,7 @@ function emoteCountOf(address collection, uint256 tokenId, string emoji) externa function hasEmoterUsedEmote(address emoter, address collection, uint256 tokenId, string emoji) external view returns (bool) ``` - +inheritdoc IEmotableRepository @@ -194,7 +194,7 @@ function hasEmoterUsedEmote(address emoter, address collection, uint256 tokenId, function haveEmotersUsedEmotes(address[] emoters, address[] collections, uint256[] tokenIds, string[] emojis) external view returns (bool[]) ``` - +inheritdoc IEmotableRepository @@ -219,7 +219,7 @@ function haveEmotersUsedEmotes(address[] emoters, address[] collections, uint256 function prepareMessageToPresignEmote(address collection, uint256 tokenId, string emoji, bool state, uint256 deadline) external view returns (bytes32) ``` - +inheritdoc IEmotableRepository @@ -245,7 +245,7 @@ function prepareMessageToPresignEmote(address collection, uint256 tokenId, strin function presignedEmote(address emoter, address collection, uint256 tokenId, string emoji, bool state, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable ``` - +inheritdoc IEmotableRepository @@ -269,9 +269,9 @@ function presignedEmote(address emoter, address collection, uint256 tokenId, str function supportsInterface(bytes4 interfaceId) external view returns (bool) ``` +inheritdoc IERC165 -*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* #### Parameters @@ -295,19 +295,19 @@ function supportsInterface(bytes4 interfaceId) external view returns (bool) event Emoted(address indexed emoter, address indexed collection, uint256 indexed tokenId, string emoji, bool on) ``` +Used to notify listeners that the token with the specified ID has been emoted to or that the reaction has been revoked. - - +*The event MUST only be emitted if the state of the emote is changed.* #### Parameters | Name | Type | Description | |---|---|---| -| emoter `indexed` | address | undefined | -| collection `indexed` | address | undefined | -| tokenId `indexed` | uint256 | undefined | -| emoji | string | undefined | -| on | bool | undefined | +| emoter `indexed` | address | Address of the account that emoted or revoked the reaction to the token | +| collection `indexed` | address | Address of the collection smart contract containing the token being emoted to or having the reaction revoked | +| tokenId `indexed` | uint256 | ID of the token | +| emoji | string | Unicode identifier of the emoji | +| on | bool | Boolean value signifying whether the token was emoted to (`true`) or if the reaction has been revoked (`false`) | diff --git a/docs/RMRK/emotable/IERC6381Extended.md b/docs/RMRK/emotable/IERC6381Extended.md deleted file mode 100644 index 05443c30..00000000 --- a/docs/RMRK/emotable/IERC6381Extended.md +++ /dev/null @@ -1,296 +0,0 @@ -# IERC6381Extended - - - - - - - - - -## Methods - -### bulkEmote - -```solidity -function bulkEmote(address[] collections, uint256[] tokenIds, string[] emojis, bool[] states) external nonpayable -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| collections | address[] | undefined | -| tokenIds | uint256[] | undefined | -| emojis | string[] | undefined | -| states | bool[] | undefined | - -### bulkEmoteCountOf - -```solidity -function bulkEmoteCountOf(address[] collections, uint256[] tokenIds, string[] emojis) external view returns (uint256[]) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| collections | address[] | undefined | -| tokenIds | uint256[] | undefined | -| emojis | string[] | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | uint256[] | undefined | - -### bulkPrepareMessagesToPresignEmote - -```solidity -function bulkPrepareMessagesToPresignEmote(address[] collections, uint256[] tokenIds, string[] emojis, bool[] states, uint256[] deadlines) external view returns (bytes32[]) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| collections | address[] | undefined | -| tokenIds | uint256[] | undefined | -| emojis | string[] | undefined | -| states | bool[] | undefined | -| deadlines | uint256[] | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bytes32[] | undefined | - -### bulkPresignedEmote - -```solidity -function bulkPresignedEmote(address[] emoters, address[] collections, uint256[] tokenIds, string[] emojis, bool[] states, uint256[] deadlines, uint8[] v, bytes32[] r, bytes32[] s) external nonpayable -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| emoters | address[] | undefined | -| collections | address[] | undefined | -| tokenIds | uint256[] | undefined | -| emojis | string[] | undefined | -| states | bool[] | undefined | -| deadlines | uint256[] | undefined | -| v | uint8[] | undefined | -| r | bytes32[] | undefined | -| s | bytes32[] | undefined | - -### emote - -```solidity -function emote(address collection, uint256 tokenId, string emoji, bool state) external nonpayable -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| collection | address | undefined | -| tokenId | uint256 | undefined | -| emoji | string | undefined | -| state | bool | undefined | - -### emoteCountOf - -```solidity -function emoteCountOf(address collection, uint256 tokenId, string emoji) external view returns (uint256) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| collection | address | undefined | -| tokenId | uint256 | undefined | -| emoji | string | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | uint256 | undefined | - -### hasEmoterUsedEmote - -```solidity -function hasEmoterUsedEmote(address emoter, address collection, uint256 tokenId, string emoji) external view returns (bool) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| emoter | address | undefined | -| collection | address | undefined | -| tokenId | uint256 | undefined | -| emoji | string | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bool | undefined | - -### haveEmotersUsedEmotes - -```solidity -function haveEmotersUsedEmotes(address[] emoters, address[] collections, uint256[] tokenIds, string[] emojis) external view returns (bool[]) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| emoters | address[] | undefined | -| collections | address[] | undefined | -| tokenIds | uint256[] | undefined | -| emojis | string[] | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bool[] | undefined | - -### prepareMessageToPresignEmote - -```solidity -function prepareMessageToPresignEmote(address collection, uint256 tokenId, string emoji, bool state, uint256 deadline) external view returns (bytes32) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| collection | address | undefined | -| tokenId | uint256 | undefined | -| emoji | string | undefined | -| state | bool | undefined | -| deadline | uint256 | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bytes32 | undefined | - -### presignedEmote - -```solidity -function presignedEmote(address emoter, address collection, uint256 tokenId, string emoji, bool state, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| emoter | address | undefined | -| collection | address | undefined | -| tokenId | uint256 | undefined | -| emoji | string | undefined | -| state | bool | undefined | -| deadline | uint256 | undefined | -| v | uint8 | undefined | -| r | bytes32 | undefined | -| s | bytes32 | undefined | - -### supportsInterface - -```solidity -function supportsInterface(bytes4 interfaceId) external view returns (bool) -``` - - - -*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| interfaceId | bytes4 | undefined | - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | bool | undefined | - - - -## Events - -### Emoted - -```solidity -event Emoted(address indexed emoter, address indexed collection, uint256 indexed tokenId, string emoji, bool on) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| emoter `indexed` | address | undefined | -| collection `indexed` | address | undefined | -| tokenId `indexed` | uint256 | undefined | -| emoji | string | undefined | -| on | bool | undefined | - - - diff --git a/docs/RMRK/emotable/IEmotableRepository.md b/docs/RMRK/emotable/IEmotableRepository.md new file mode 100644 index 00000000..49a0bac5 --- /dev/null +++ b/docs/RMRK/emotable/IEmotableRepository.md @@ -0,0 +1,296 @@ +# IEmotableRepository + + + + + + + + + +## Methods + +### bulkEmote + +```solidity +function bulkEmote(address[] collections, uint256[] tokenIds, string[] emojis, bool[] states) external nonpayable +``` + +Used to emote or undo an emote on multiple tokens. + +*Does nothing if attempting to set a pre-existent state.MUST emit the `Emoted` event is the state of the emote is changed.MUST revert if the lengths of the `collections`, `tokenIds`, `emojis` and `states` arrays are not equal.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| collections | address[] | An array of addresses of the collections containing the tokens being emoted at | +| tokenIds | uint256[] | An array of IDs of the tokens being emoted | +| emojis | string[] | An array of unicode identifiers of the emojis | +| states | bool[] | An array of boolean values signifying whether to emote (`true`) or undo (`false`) emote | + +### bulkEmoteCountOf + +```solidity +function bulkEmoteCountOf(address[] collections, uint256[] tokenIds, string[] emojis) external view returns (uint256[]) +``` + +Used to get the number of emotes for a specific emoji on a set of tokens. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| collections | address[] | An array of addresses of the collections containing the tokens being checked for emoji count | +| tokenIds | uint256[] | An array of IDs of the tokens to check for emoji count | +| emojis | string[] | An array of unicode identifiers of the emojis | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256[] | An array of numbers of emotes with the emoji on the tokens | + +### bulkPrepareMessagesToPresignEmote + +```solidity +function bulkPrepareMessagesToPresignEmote(address[] collections, uint256[] tokenIds, string[] emojis, bool[] states, uint256[] deadlines) external view returns (bytes32[]) +``` + +Used to get multiple messages to be signed by the `emoter` in order for the reaction to be submitted by someone else. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| collections | address[] | An array of addresses of the collection smart contracts containing the tokens being emoted at | +| tokenIds | uint256[] | An array of IDs of the tokens being emoted | +| emojis | string[] | An array of unicode identifiers of the emojis | +| states | bool[] | An array of boolean values signifying whether to emote (`true`) or undo (`false`) emote | +| deadlines | uint256[] | An array of UNIX timestamps of the deadlines for the signatures to be submitted | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32[] | The array of messages to be signed by the `emoter` in order for the reaction to be submitted by someone else | + +### bulkPresignedEmote + +```solidity +function bulkPresignedEmote(address[] emoters, address[] collections, uint256[] tokenIds, string[] emojis, bool[] states, uint256[] deadlines, uint8[] v, bytes32[] r, bytes32[] s) external nonpayable +``` + +Used to bulk emote or undo an emote on someone else's behalf. + +*Does nothing if attempting to set a pre-existent state.MUST emit the `Emoted` event is the state of the emote is changed.MUST revert if the lengths of the `collections`, `tokenIds`, `emojis` and `states` arrays are not equal.MUST revert if the `deadline` has passed.MUST revert if the recovered address is the zero address.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| emoters | address[] | An array of addresses of the accounts that presigned the emotes | +| collections | address[] | An array of addresses of the collections containing the tokens being emoted at | +| tokenIds | uint256[] | An array of IDs of the tokens being emoted | +| emojis | string[] | An array of unicode identifiers of the emojis | +| states | bool[] | An array of boolean values signifying whether to emote (`true`) or undo (`false`) emote | +| deadlines | uint256[] | UNIX timestamp of the deadline for the signature to be submitted | +| v | uint8[] | An array of `v` values of an ECDSA signatures of the messages obtained via `prepareMessageToPresignEmote` | +| r | bytes32[] | An array of `r` values of an ECDSA signatures of the messages obtained via `prepareMessageToPresignEmote` | +| s | bytes32[] | An array of `s` values of an ECDSA signatures of the messages obtained via `prepareMessageToPresignEmote` | + +### emote + +```solidity +function emote(address collection, uint256 tokenId, string emoji, bool state) external nonpayable +``` + +Used to emote or undo an emote on a token. + +*Does nothing if attempting to set a pre-existent state.MUST emit the `Emoted` event is the state of the emote is changed.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| collection | address | Address of the collection containing the token being emoted at | +| tokenId | uint256 | ID of the token being emoted | +| emoji | string | Unicode identifier of the emoji | +| state | bool | Boolean value signifying whether to emote (`true`) or undo (`false`) emote | + +### emoteCountOf + +```solidity +function emoteCountOf(address collection, uint256 tokenId, string emoji) external view returns (uint256) +``` + +Used to get the number of emotes for a specific emoji on a token. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| collection | address | Address of the collection containing the token being checked for emoji count | +| tokenId | uint256 | ID of the token to check for emoji count | +| emoji | string | Unicode identifier of the emoji | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | uint256 | Number of emotes with the emoji on the token | + +### hasEmoterUsedEmote + +```solidity +function hasEmoterUsedEmote(address emoter, address collection, uint256 tokenId, string emoji) external view returns (bool) +``` + +Used to get the information on whether the specified address has used a specific emoji on a specific token. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| emoter | address | Address of the account we are checking for a reaction to a token | +| collection | address | Address of the collection smart contract containing the token being checked for emoji reaction | +| tokenId | uint256 | ID of the token being checked for emoji reaction | +| emoji | string | The ASCII emoji code being checked for reaction | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | A boolean value indicating whether the `emoter` has used the `emoji` on the token (`true`) or not (`false`) | + +### haveEmotersUsedEmotes + +```solidity +function haveEmotersUsedEmotes(address[] emoters, address[] collections, uint256[] tokenIds, string[] emojis) external view returns (bool[]) +``` + +Used to get the information on whether the specified addresses have used specific emojis on specific tokens. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| emoters | address[] | An array of addresses of the accounts we are checking for reactions to tokens | +| collections | address[] | An array of addresses of the collection smart contracts containing the tokens being checked for emoji reactions | +| tokenIds | uint256[] | An array of IDs of the tokens being checked for emoji reactions | +| emojis | string[] | An array of the ASCII emoji codes being checked for reactions | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool[] | An array of boolean values indicating whether the `emoter`s has used the `emoji`s on the tokens (`true`) or not (`false`) | + +### prepareMessageToPresignEmote + +```solidity +function prepareMessageToPresignEmote(address collection, uint256 tokenId, string emoji, bool state, uint256 deadline) external view returns (bytes32) +``` + +Used to get the message to be signed by the `emoter` in order for the reaction to be submitted by someone else. + + + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| collection | address | The address of the collection smart contract containing the token being emoted at | +| tokenId | uint256 | ID of the token being emoted | +| emoji | string | Unicode identifier of the emoji | +| state | bool | Boolean value signifying whether to emote (`true`) or undo (`false`) emote | +| deadline | uint256 | UNIX timestamp of the deadline for the signature to be submitted | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bytes32 | The message to be signed by the `emoter` in order for the reaction to be submitted by someone else | + +### presignedEmote + +```solidity +function presignedEmote(address emoter, address collection, uint256 tokenId, string emoji, bool state, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external nonpayable +``` + +Used to emote or undo an emote on someone else's behalf. + +*Does nothing if attempting to set a pre-existent state.MUST emit the `Emoted` event is the state of the emote is changed.MUST revert if the lengths of the `collections`, `tokenIds`, `emojis` and `states` arrays are not equal.MUST revert if the `deadline` has passed.MUST revert if the recovered address is the zero address.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| emoter | address | The address that presigned the emote | +| collection | address | The address of the collection smart contract containing the token being emoted at | +| tokenId | uint256 | IDs of the token being emoted | +| emoji | string | Unicode identifier of the emoji | +| state | bool | Boolean value signifying whether to emote (`true`) or undo (`false`) emote | +| deadline | uint256 | UNIX timestamp of the deadline for the signature to be submitted | +| v | uint8 | `v` value of an ECDSA signature of the message obtained via `prepareMessageToPresignEmote` | +| r | bytes32 | `r` value of an ECDSA signature of the message obtained via `prepareMessageToPresignEmote` | +| s | bytes32 | `s` value of an ECDSA signature of the message obtained via `prepareMessageToPresignEmote` | + +### supportsInterface + +```solidity +function supportsInterface(bytes4 interfaceId) external view returns (bool) +``` + + + +*Returns true if this contract implements the interface defined by `interfaceId`. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| interfaceId | bytes4 | undefined | + +#### Returns + +| Name | Type | Description | +|---|---|---| +| _0 | bool | undefined | + + + +## Events + +### Emoted + +```solidity +event Emoted(address indexed emoter, address indexed collection, uint256 indexed tokenId, string emoji, bool on) +``` + +Used to notify listeners that the token with the specified ID has been emoted to or that the reaction has been revoked. + +*The event MUST only be emitted if the state of the emote is changed.* + +#### Parameters + +| Name | Type | Description | +|---|---|---| +| emoter `indexed` | address | Address of the account that emoted or revoked the reaction to the token | +| collection `indexed` | address | Address of the collection smart contract containing the token being emoted to or having the reaction revoked | +| tokenId `indexed` | uint256 | ID of the token | +| emoji | string | Unicode identifier of the emoji | +| on | bool | Boolean value signifying whether the token was emoted to (`true`) or if the reaction has been revoked (`false`) | + + + diff --git a/docs/RMRK/extension/RMRKRoyalties.md b/docs/RMRK/extension/RMRKRoyalties.md index 1be8a271..48db7eff 100644 --- a/docs/RMRK/extension/RMRKRoyalties.md +++ b/docs/RMRK/extension/RMRKRoyalties.md @@ -1,10 +1,10 @@ # RMRKRoyalties +*RMRK team* +> RMRKRoyalties - - -is IERC2981 * +Smart contract of the RMRK Royalties module. diff --git a/test/emotableRepository.ts b/test/emotableRepository.ts index 180d7f08..12c716ae 100644 --- a/test/emotableRepository.ts +++ b/test/emotableRepository.ts @@ -4,7 +4,7 @@ import { BigNumber, Contract } from 'ethers'; import { loadFixture } from '@nomicfoundation/hardhat-network-helpers'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { ERC721Mock, EmotableRepository } from '../typechain-types'; -import { IERC6381Extended, IERC165, IOtherInterface } from './interfaces'; +import { IEmotableRepository, IERC165, IOtherInterface } from './interfaces'; function bn(x: number): BigNumber { return BigNumber.from(x); @@ -41,8 +41,8 @@ describe('EmotableRepository', async function () { repository = await loadFixture(emotableRepositoryFixture); }); - it('can support IERC6381Extended', async function () { - expect(await repository.supportsInterface(IERC6381Extended)).to.equal(true); + it('can support IEmotableRepository', async function () { + expect(await repository.supportsInterface(IEmotableRepository)).to.equal(true); }); it('can support IERC165', async function () { diff --git a/test/implementations/generalBehavior.ts b/test/implementations/generalBehavior.ts index f6550fa0..706d285b 100644 --- a/test/implementations/generalBehavior.ts +++ b/test/implementations/generalBehavior.ts @@ -30,16 +30,17 @@ import { } from '../../typechain-types'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { BigNumber, Contract } from 'ethers'; - -const RMRK_INTERFACE = '0x524D524B'; -const IERC165 = '0x01ffc9a7'; -const IERC721 = '0x80ac58cd'; -const IERC721Metadata = '0x5b5e139f'; -const IERC2981 = '0x2a55205a'; -const IERC5773 = '0x06b4329a'; -const IERC6059 = '0x42b0e56f'; -const IERC6454 = '0x91a6262f'; -const IERC6220 = '0x28bc9ae4'; +import { + IRMRKImplementation, + IERC165, + IERC721, + IERC721Metadata, + IERC2981, + IERC5773, + IERC6059, + IERC6454, + IERC6220, +} from '../interfaces'; export enum LegoCombination { None, @@ -619,7 +620,7 @@ async function testInterfaceSupport(legoCombination: LegoCombination, isSoulboun }); it('supports RMRK interfaces', async function () { - expect(await contract.supportsInterface(RMRK_INTERFACE)).to.be.true; + expect(await contract.supportsInterface(IRMRKImplementation)).to.be.true; expect(await contract.supportsInterface(IERC2981)).to.be.true; if ( [ diff --git a/test/interfaces.ts b/test/interfaces.ts index 558ef429..bb928009 100644 --- a/test/interfaces.ts +++ b/test/interfaces.ts @@ -4,7 +4,8 @@ const IERC721 = '0x80ac58cd'; const IERC721Metadata = '0x5b5e139f'; const IOtherInterface = '0xffffffff'; const IRMRKCatalog = '0xd912401f'; // ERC6220 -const IERC6381Extended = '0x1b3327ab'; //ERC6381 +const IEmotableRepository = '0x1b3327ab'; //ERC6381 +const IERC2981 = '0x2a55205a'; // ERC6220 const IERC6220 = '0x28bc9ae4'; // ERC6220 const IERC5773 = '0x06b4329a'; // ERC5773 const IERC6059 = '0x42b0e56f'; // ERC6059 @@ -24,7 +25,8 @@ export { IERC721Metadata, IOtherInterface, IRMRKCatalog, - IERC6381Extended, + IEmotableRepository, + IERC2981, IERC6220, IERC5773, IERC6059,