@zoralabs/comments-contracts 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/.env.example +11 -0
  2. package/.turbo/turbo-build.log +60 -0
  3. package/LICENSE +21 -0
  4. package/README.md +70 -0
  5. package/_imagine/Enjoy.sol +41 -0
  6. package/abis/AccessControlUpgradeable.json +250 -0
  7. package/abis/Address.json +29 -0
  8. package/abis/Comments.json +62 -0
  9. package/abis/CommentsDeployerBase.json +15 -0
  10. package/abis/CommentsImpl.json +1750 -0
  11. package/abis/CommentsPermitTest.json +847 -0
  12. package/abis/CommentsTest.json +986 -0
  13. package/abis/CommentsTestBase.json +577 -0
  14. package/abis/Comments_mintAndCommentTest.json +690 -0
  15. package/abis/ContextUpgradeable.json +25 -0
  16. package/abis/ContractVersionBase.json +15 -0
  17. package/abis/Create2.json +28 -0
  18. package/abis/DeployImpl.json +22 -0
  19. package/abis/DeployNonDeterministic.json +22 -0
  20. package/abis/DeployScript.json +22 -0
  21. package/abis/DeterministicDeployerAndCaller.json +315 -0
  22. package/abis/DeterministicUUPSProxyDeployer.json +167 -0
  23. package/abis/ECDSA.json +29 -0
  24. package/abis/EIP712.json +67 -0
  25. package/abis/EIP712UpgradeableWithChainId.json +25 -0
  26. package/abis/ERC1155.json +416 -0
  27. package/abis/ERC1155Holder.json +99 -0
  28. package/abis/ERC165.json +21 -0
  29. package/abis/ERC165Upgradeable.json +44 -0
  30. package/abis/ERC1967Proxy.json +67 -0
  31. package/abis/ERC1967Utils.json +85 -0
  32. package/abis/GenerateDeterministicParams.json +22 -0
  33. package/abis/IAccessControl.json +195 -0
  34. package/abis/IBeacon.json +15 -0
  35. package/abis/IComments.json +654 -0
  36. package/abis/IContractMetadata.json +28 -0
  37. package/abis/IERC1155.json +295 -0
  38. package/abis/IERC1155Errors.json +104 -0
  39. package/abis/IERC1155MetadataURI.json +314 -0
  40. package/abis/IERC1155Receiver.json +99 -0
  41. package/abis/IERC1271.json +26 -0
  42. package/abis/IERC165.json +21 -0
  43. package/abis/IERC1822Proxiable.json +15 -0
  44. package/abis/IERC20.json +224 -0
  45. package/abis/IERC20Errors.json +88 -0
  46. package/abis/IERC5267.json +51 -0
  47. package/abis/IERC721.json +287 -0
  48. package/abis/IERC721Enumerable.json +343 -0
  49. package/abis/IERC721Errors.json +105 -0
  50. package/abis/IERC721Metadata.json +332 -0
  51. package/abis/IERC721TokenReceiver.json +36 -0
  52. package/abis/IHasContractName.json +15 -0
  53. package/abis/IImmutableCreate2Factory.json +93 -0
  54. package/abis/IMulticall3.json +440 -0
  55. package/abis/IProtocolRewards.json +342 -0
  56. package/abis/ISafe.json +15 -0
  57. package/abis/ISymbol.json +15 -0
  58. package/abis/IVersionedContract.json +15 -0
  59. package/abis/IZoraCreator1155.json +343 -0
  60. package/abis/ImmutableCreate2FactoryUtils.json +15 -0
  61. package/abis/Initializable.json +25 -0
  62. package/abis/LibString.json +7 -0
  63. package/abis/Math.json +7 -0
  64. package/abis/Mock1155.json +547 -0
  65. package/abis/MockERC20.json +322 -0
  66. package/abis/MockERC721.json +350 -0
  67. package/abis/MockMinter.json +64 -0
  68. package/abis/OwnableUpgradeable.json +99 -0
  69. package/abis/ProtocolRewards.json +494 -0
  70. package/abis/Proxy.json +6 -0
  71. package/abis/ProxyDeployerScript.json +15 -0
  72. package/abis/ProxyShim.json +112 -0
  73. package/abis/Script.json +15 -0
  74. package/abis/ShortStrings.json +18 -0
  75. package/abis/StdAssertions.json +379 -0
  76. package/abis/StdInvariant.json +180 -0
  77. package/abis/Strings.json +18 -0
  78. package/abis/Test.json +570 -0
  79. package/abis/UUPSUpgradeable.json +130 -0
  80. package/abis/UnorderedNoncesUpgradeable.json +42 -0
  81. package/abis/Vm.json +8627 -0
  82. package/abis/VmSafe.json +7297 -0
  83. package/abis/stdError.json +119 -0
  84. package/abis/stdStorageSafe.json +52 -0
  85. package/addresses/999999999.json +4 -0
  86. package/deterministicConfig/comments.json +8 -0
  87. package/dist/index.cjs +935 -0
  88. package/dist/index.cjs.map +1 -0
  89. package/dist/index.d.ts +2 -0
  90. package/dist/index.d.ts.map +1 -0
  91. package/dist/index.js +908 -0
  92. package/dist/index.js.map +1 -0
  93. package/dist/types.d.ts +4 -0
  94. package/dist/types.d.ts.map +1 -0
  95. package/dist/wagmiGenerated.d.ts +1354 -0
  96. package/dist/wagmiGenerated.d.ts.map +1 -0
  97. package/foundry.toml +24 -0
  98. package/package/index.ts +4 -0
  99. package/package/types.ts +5 -0
  100. package/package/wagmiGenerated.ts +907 -0
  101. package/package.json +62 -0
  102. package/remappings.txt +8 -0
  103. package/script/CommentsDeployerBase.sol +60 -0
  104. package/script/Deploy.s.sol +66 -0
  105. package/script/DeployImpl.s.sol +26 -0
  106. package/script/DeployNonDeterministic.s.sol +43 -0
  107. package/script/GenerateDeterministicParams.s.sol +55 -0
  108. package/script/bundle-abis.ts +109 -0
  109. package/script/storage-check.sh +57 -0
  110. package/script/update-contract-version.ts +63 -0
  111. package/scripts/abis.ts +3 -0
  112. package/scripts/backfillComments.ts +176 -0
  113. package/scripts/generateCommentsTestData.ts +247 -0
  114. package/scripts/getCommentsAddresses.ts +10 -0
  115. package/scripts/queries.ts +73 -0
  116. package/scripts/queryAndSaveComments.ts +48 -0
  117. package/scripts/queryQuantityOfComments.ts +53 -0
  118. package/scripts/signDeployAndCall.ts +51 -0
  119. package/scripts/turnkey.ts +36 -0
  120. package/scripts/utils.ts +127 -0
  121. package/scripts/writeComments.ts +198 -0
  122. package/slither.config.json +7 -0
  123. package/src/CommentsImpl.sol +552 -0
  124. package/src/deployments/CommentsDeployment.sol +14 -0
  125. package/src/interfaces/IComments.sol +156 -0
  126. package/src/interfaces/IZoraCreator1155.sol +12 -0
  127. package/src/proxy/Comments.sol +43 -0
  128. package/src/utils/EIP712UpgradeableWithChainId.sol +36 -0
  129. package/src/version/ContractVersionBase.sol +14 -0
  130. package/test/Comments.t.sol +482 -0
  131. package/test/CommentsTestBase.sol +86 -0
  132. package/test/Comments_mintAndComment.t.sol +101 -0
  133. package/test/Comments_permit.t.sol +397 -0
  134. package/test/mocks/Mock1155.sol +50 -0
  135. package/test/mocks/MockMinter.sol +29 -0
  136. package/test/mocks/ProtocolRewards.sol +1497 -0
  137. package/tsconfig.build.json +10 -0
  138. package/tsconfig.json +9 -0
  139. package/tsup.config.ts +11 -0
  140. package/wagmi.config.ts +14 -0
@@ -0,0 +1,156 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ interface IComments {
5
+ struct CommentIdentifier {
6
+ address commenter;
7
+ address contractAddress;
8
+ uint256 tokenId;
9
+ bytes32 nonce;
10
+ }
11
+
12
+ struct Comment {
13
+ // has this comment been created
14
+ bool exists;
15
+ // total sparks for this comment
16
+ uint64 totalSparks;
17
+ }
18
+
19
+ // Event emitted when a comment is created
20
+ event Commented(
21
+ bytes32 indexed commentId, // Unique identifier for the comment
22
+ CommentIdentifier comment, // Struct containing details about the comment and commenter
23
+ bytes32 replyToId, // ID of the comment being replied to (if any)
24
+ CommentIdentifier replyTo, // Struct containing details about the comment being replied to (if any)
25
+ uint64 sparksQuantity, // Number of sparks associated with this comment
26
+ string text, // The actual text content of the comment
27
+ uint256 timestamp, // Timestamp when the comment was created
28
+ address referrer // Address of the referrer who referred the commenter
29
+ );
30
+
31
+ // Event emitted when a comment is backfilled
32
+ event BackfilledComment(
33
+ bytes32 indexed commentId, // Unique identifier for the backfilled comment
34
+ CommentIdentifier comment, // Struct containing details about the comment and commenter
35
+ string text, // The actual text content of the backfilled comment
36
+ uint256 timestamp, // Timestamp when the original comment was created
37
+ bytes32 originalTransactionId // Transaction ID of the original comment (before backfilling)
38
+ );
39
+
40
+ // Event emitted when a comment is Sparked
41
+ event SparkedComment(
42
+ bytes32 indexed commentId, // Unique identifier of the comment being sparked
43
+ CommentIdentifier commentIdentifier, // Struct containing details about the comment and commenter
44
+ uint64 sparksQuantity, // Number of sparks added to the comment
45
+ address sparker, // Address of the user who sparked the comment
46
+ uint256 timestamp // Timestamp when the spark action occurred
47
+ );
48
+
49
+ /// @notice Occurs when attempting to add a comment that already exists
50
+ /// @param commentId The unique identifier of the duplicate comment
51
+ error DuplicateComment(bytes32 commentId);
52
+
53
+ /// @notice Occurs when the amount of ETH sent with the transaction doesn't match the corresponding sparks quantity
54
+ error IncorrectETHAmountForSparks(uint256 actual, uint256 expected);
55
+
56
+ /// @notice Occurs when the commenter address doesn't match the expected address
57
+ /// @param expected The address that was expected to be the commenter
58
+ /// @param actual The actual address that attempted to comment
59
+ error CommenterMismatch(address expected, address actual);
60
+
61
+ /// @notice Occurs when a non-token holder or non-admin attempts an action restricted to token holders or admins
62
+ error NotTokenHolderOrAdmin();
63
+
64
+ /// @notice Occurs when attempting to spark a comment without sending at least one spark
65
+ error MustSendAtLeastOneSpark();
66
+
67
+ /// @notice Occurs when attempting to submit an empty comment
68
+ error EmptyComment();
69
+
70
+ /// @notice Occurs when trying to interact with a comment that doesn't exist
71
+ error CommentDoesntExist();
72
+
73
+ /// @notice Occurs when a transfer of funds fails
74
+ error TransferFailed();
75
+
76
+ /// @notice Occurs when a user attempts to spark their own comment
77
+ error CannotSparkOwnComment();
78
+
79
+ /// @notice Occurs when a function restricted to the Sparks contract is called by another address
80
+ error OnlySparksContract();
81
+
82
+ /// @notice Occurs when attempting to upgrade to a contract with a name that doesn't match the current contract's name
83
+ /// @param currentName The name of the current contract
84
+ /// @param newName The name of the contract being upgraded to
85
+ error UpgradeToMismatchedContractName(string currentName, string newName);
86
+
87
+ /// @notice Occurs when the lengths of arrays passed to a function do not match
88
+ error ArrayLengthMismatch();
89
+
90
+ /// @notice Occurs when the address or token IDs in a comment identifier do not match the expected values
91
+ /// @param commentAddress The address in the comment identifier
92
+ /// @param commentTokenId The token ID in the comment identifier
93
+ /// @param replyAddress The address in the reply identifier
94
+ /// @param replyTokenId The token ID in the reply identifier
95
+ error CommentAddressOrTokenIdsDoNotMatch(address commentAddress, uint256 commentTokenId, address replyAddress, uint256 replyTokenId);
96
+ /// @notice Occurs when the signature is invalid
97
+ error InvalidSignature();
98
+
99
+ /// @notice Occurs when the destination chain ID doesn't match the current chain ID in a permit
100
+ error IncorrectDestinationChain(uint256 wrongDestinationChainId);
101
+
102
+ /**
103
+ * @dev Permit deadline has expired.
104
+ */
105
+ error ERC2612ExpiredSignature(uint256 deadline);
106
+
107
+ function comment(
108
+ address commenter,
109
+ address contractAddress,
110
+ uint256 tokenId,
111
+ string calldata text,
112
+ CommentIdentifier calldata replyTo,
113
+ address referrer
114
+ ) external payable returns (CommentIdentifier memory);
115
+
116
+ function delegateComment(
117
+ address commenter,
118
+ address contractAddress,
119
+ uint256 tokenId,
120
+ string calldata text,
121
+ CommentIdentifier calldata replyTo
122
+ ) external returns (CommentIdentifier memory);
123
+
124
+ function sparkComment(CommentIdentifier calldata commentIdentifier, uint64 sparksQuantity, address referrer) external payable;
125
+
126
+ function sparkValue() external view returns (uint256);
127
+
128
+ function hashCommentIdentifier(CommentIdentifier calldata commentIdentifier) external view returns (bytes32);
129
+
130
+ function nextNonce() external view returns (bytes32);
131
+
132
+ struct PermitComment {
133
+ address commenter;
134
+ address contractAddress;
135
+ uint256 tokenId;
136
+ CommentIdentifier replyTo;
137
+ string text;
138
+ uint64 sparksQuantity;
139
+ uint256 deadline;
140
+ bytes32 nonce;
141
+ address referrer;
142
+ uint256 sourceChainId;
143
+ uint256 destinationChainId;
144
+ }
145
+
146
+ struct PermitSparkComment {
147
+ CommentIdentifier comment;
148
+ address sparker;
149
+ uint64 sparksQuantity;
150
+ uint256 deadline;
151
+ bytes32 nonce;
152
+ address referrer;
153
+ uint256 sourceChainId;
154
+ uint256 destinationChainId;
155
+ }
156
+ }
@@ -0,0 +1,12 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import {IERC1155} from "@openzeppelin/contracts/interfaces/IERC1155.sol";
5
+
6
+ interface IZoraCreator1155 is IERC1155 {
7
+ function isAdminOrRole(address user, uint256 tokenId, uint256 role) external view returns (bool);
8
+
9
+ function getCreatorRewardRecipient(uint256 tokenId) external view returns (address);
10
+
11
+ function supportsInterface(bytes4 interfaceId) external view returns (bool);
12
+ }
@@ -0,0 +1,43 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.23;
3
+
4
+ import {Enjoy} from "_imagine/Enjoy.sol";
5
+ import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
6
+
7
+ /*
8
+
9
+
10
+ ░░░░░░░░░░░░░░
11
+ ░░▒▒░░░░░░░░░░░░░░░░░░░░
12
+ ░░▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░
13
+ ░░▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░
14
+ ░▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░
15
+ ░▓▓▓▒▒▒▒░░░░░░░░░░░░ ░░░░░░░░
16
+ ░▓▓▓▒▒▒▒░░░░░░░░░░░░░░ ░░░░░░░░░░
17
+ ░▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░░
18
+ ░▓▓▓▓▓▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░░░░
19
+ ░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░░░░
20
+ ░░▓▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░░░░░
21
+ ░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒░░░░░░░░░▒▒▒▒▒░░
22
+ ░░▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░
23
+ ░░▓▓▓▓▓▓▓▓▓▓▓▓▒▒░░░
24
+
25
+ OURS TRULY,
26
+
27
+
28
+ */
29
+
30
+ /// @title Zora Comments Proxy Contract
31
+ /// @notice This is the proxy contract for the Zora Comments contract.
32
+ /// @dev Inherits from ERC1967Proxy to enable upgradeable functionality.
33
+ /// @notice Imagine. Mint. Enjoy.
34
+ /// @author @oveddan
35
+ contract Comments is Enjoy, ERC1967Proxy {
36
+ bytes32 internal immutable name;
37
+
38
+ constructor(address _logic) ERC1967Proxy(_logic, "") {
39
+ // added to create unique bytecode for this contract
40
+ // so that it can be properly verified as its own contract.
41
+ name = keccak256("Comments");
42
+ }
43
+ }
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.20;
3
+
4
+ import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5
+
6
+ abstract contract EIP712UpgradeableWithChainId is Initializable {
7
+ bytes32 private constant TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
8
+
9
+ struct EIP712Storage {
10
+ string _name;
11
+ string _version;
12
+ }
13
+
14
+ bytes32 private constant EIP712StorageLocation = 0xa16a46d94261c7517cc8ff89f61c0ce93598e3c849801011dee649a6a557d100;
15
+
16
+ function _getEIP712Storage() private pure returns (EIP712Storage storage $) {
17
+ assembly {
18
+ $.slot := EIP712StorageLocation
19
+ }
20
+ }
21
+
22
+ function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
23
+ EIP712Storage storage $ = _getEIP712Storage();
24
+ $._name = name;
25
+ $._version = version;
26
+ }
27
+
28
+ function _domainSeparatorV4(uint256 chainId) internal view returns (bytes32) {
29
+ EIP712Storage storage $ = _getEIP712Storage();
30
+ return keccak256(abi.encode(TYPE_HASH, keccak256(bytes($._name)), keccak256(bytes($._version)), chainId, address(this)));
31
+ }
32
+
33
+ function _hashTypedDataV4(bytes32 structHash, uint256 chainId) internal view returns (bytes32) {
34
+ return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(chainId), structHash));
35
+ }
36
+ }
@@ -0,0 +1,14 @@
1
+ // This file is automatically generated by code; do not manually update
2
+ // SPDX-License-Identifier: MIT
3
+ pragma solidity ^0.8.23;
4
+
5
+ import {IVersionedContract} from "@zoralabs/shared-contracts/interfaces/IVersionedContract.sol";
6
+
7
+ /// @title ContractVersionBase
8
+ /// @notice Base contract for versioning contracts
9
+ contract ContractVersionBase is IVersionedContract {
10
+ /// @notice The version of the contract
11
+ function contractVersion() external pure override returns (string memory) {
12
+ return "0.0.1";
13
+ }
14
+ }