@zoralabs/comments-contracts 0.0.1 → 0.0.2

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 (110) hide show
  1. package/.turbo/turbo-build.log +49 -31
  2. package/README.md +10 -39
  3. package/abis/AddDelegateCommenterRole.json +9 -0
  4. package/abis/CallerAndCommenter.json +62 -0
  5. package/abis/CallerAndCommenterImpl.json +1218 -0
  6. package/abis/CallerAndCommenterMintAndCommentTest.json +771 -0
  7. package/abis/CallerAndCommenterSwapAndCommentTest.json +844 -0
  8. package/abis/CallerAndCommenterTestBase.json +577 -0
  9. package/abis/CommentsImpl.json +189 -59
  10. package/abis/CommentsImplConstants.json +106 -0
  11. package/abis/CommentsPermitTest.json +26 -6
  12. package/abis/CommentsTest.json +58 -10
  13. package/abis/Comments_mintAndCommentTest.json +11 -4
  14. package/abis/Comments_smartWallet.json +711 -0
  15. package/abis/DeployCallerAndCommenterImpl.json +9 -0
  16. package/abis/DeployImpl.json +0 -13
  17. package/abis/DeployNonDeterministic.json +0 -13
  18. package/abis/DeployScript.json +0 -13
  19. package/abis/EIP712Upgradeable.json +74 -0
  20. package/abis/EIP712UpgradeableWithChainId.json +49 -0
  21. package/abis/ERC20.json +310 -0
  22. package/abis/GenerateDeterministicParams.json +0 -13
  23. package/abis/ICallerAndCommenter.json +797 -0
  24. package/abis/IComments.json +629 -9
  25. package/abis/IERC20.json +39 -42
  26. package/abis/IERC20Metadata.json +224 -0
  27. package/abis/{CommentsDeployerBase.json → IMultiOwnable.json} +8 -2
  28. package/abis/IProtocolRewards.json +19 -0
  29. package/abis/ISecondarySwap.json +45 -0
  30. package/abis/IZoraCreator1155.json +51 -0
  31. package/abis/IZoraTimedSaleStrategy.json +91 -0
  32. package/abis/Mock1155.json +75 -1
  33. package/abis/Mock1155NoCreatorRewardRecipient.json +605 -0
  34. package/abis/Mock1155NoOwner.json +566 -0
  35. package/abis/{MockMinter.json → MockDelegateCommenter.json} +12 -2
  36. package/abis/MockERC20z.json +315 -0
  37. package/abis/MockMultiOwnable.json +212 -0
  38. package/abis/MockSecondarySwap.json +95 -0
  39. package/abis/MockZoraTimedSale.json +139 -0
  40. package/abis/Ownable2StepUpgradeable.json +138 -0
  41. package/abis/UnorderedNoncesUpgradeable.json +4 -4
  42. package/addresses/1.json +9 -0
  43. package/addresses/10.json +9 -0
  44. package/addresses/11155111.json +9 -0
  45. package/addresses/11155420.json +9 -0
  46. package/addresses/42161.json +9 -0
  47. package/addresses/7777777.json +9 -0
  48. package/addresses/81457.json +9 -0
  49. package/addresses/8453.json +9 -0
  50. package/addresses/84532.json +9 -0
  51. package/addresses/999999999.json +7 -2
  52. package/deterministicConfig/callerAndCommenter.json +8 -0
  53. package/deterministicConfig/comments.json +2 -2
  54. package/dist/index.cjs +724 -35
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.js +723 -35
  57. package/dist/index.js.map +1 -1
  58. package/dist/types.d.ts +1 -1
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/wagmiGenerated.d.ts +1102 -57
  61. package/dist/wagmiGenerated.d.ts.map +1 -1
  62. package/package/types.ts +4 -1
  63. package/package/wagmiGenerated.ts +728 -32
  64. package/package.json +12 -11
  65. package/script/AddDelegateCommenterRole.s.sol +24 -0
  66. package/script/CommentsDeployerBase.sol +102 -19
  67. package/script/Deploy.s.sol +2 -44
  68. package/script/DeployCallerAndCommenterImpl.s.sol +29 -0
  69. package/script/DeployImpl.s.sol +1 -0
  70. package/script/DeployNonDeterministic.s.sol +22 -13
  71. package/script/GenerateDeterministicParams.s.sol +32 -4
  72. package/scripts/generateCommentsTestData.ts +170 -79
  73. package/src/CommentsImpl.sol +267 -134
  74. package/src/CommentsImplConstants.sol +44 -0
  75. package/src/interfaces/ICallerAndCommenter.sol +215 -0
  76. package/src/interfaces/IComments.sol +189 -42
  77. package/src/interfaces/IMultiOwnable.sol +10 -0
  78. package/src/interfaces/ISecondarySwap.sol +40 -0
  79. package/src/interfaces/IZoraCreator1155.sol +6 -1
  80. package/src/interfaces/IZoraCreator1155TypesV1.sol +46 -0
  81. package/src/interfaces/IZoraTimedSaleStrategy.sol +25 -0
  82. package/src/proxy/CallerAndCommenter.sol +43 -0
  83. package/src/utils/CallerAndCommenterImpl.sol +376 -0
  84. package/src/utils/EIP712UpgradeableWithChainId.sol +12 -23
  85. package/src/version/ContractVersionBase.sol +1 -1
  86. package/test/CallerAndCommenterTestBase.sol +77 -0
  87. package/test/CallerAndCommenter_mintAndComment.t copy.sol +214 -0
  88. package/test/CallerAndCommenter_swapAndComment.t.sol +523 -0
  89. package/test/Comments.t.sol +166 -29
  90. package/test/CommentsTestBase.sol +12 -20
  91. package/test/Comments_delegateComment.t.sol +129 -0
  92. package/test/Comments_permit.t.sol +131 -44
  93. package/test/Comments_smartWallet.t.sol +152 -0
  94. package/test/mocks/Mock1155.sol +12 -1
  95. package/test/mocks/Mock1155NoCreatorRewardRecipient.sol +65 -0
  96. package/test/mocks/Mock1155NoOwner.sol +53 -0
  97. package/test/mocks/MockDelegateCommenter.sol +36 -0
  98. package/test/mocks/MockIZoraCreator1155.sol +16 -0
  99. package/test/mocks/MockSecondarySwap.sol +30 -0
  100. package/test/mocks/MockZoraTimedSale.sol +38 -0
  101. package/wagmi.config.ts +3 -1
  102. package/abis/ProxyDeployerScript.json +0 -15
  103. package/scripts/backfillComments.ts +0 -176
  104. package/scripts/queries.ts +0 -73
  105. package/scripts/queryAndSaveComments.ts +0 -48
  106. package/scripts/queryQuantityOfComments.ts +0 -53
  107. package/scripts/writeComments.ts +0 -198
  108. package/src/deployments/CommentsDeployment.sol +0 -14
  109. package/test/Comments_mintAndComment.t.sol +0 -101
  110. package/test/mocks/MockMinter.sol +0 -29
@@ -1,14 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.13;
3
-
4
- import {CommentsImpl} from "../CommentsImpl.sol";
5
-
6
- library CommentsDeployment {
7
- address internal constant SPARKS_1155 = 0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B;
8
- uint256 internal constant SPARKS_TOKEN_ID = 1;
9
- uint256 internal constant SPARK_VALUE = 0.000001 ether;
10
-
11
- function commentsImplCreationCode() internal pure returns (bytes memory) {
12
- return abi.encodePacked(type(CommentsImpl).creationCode, abi.encode(SPARKS_1155, SPARKS_TOKEN_ID, SPARK_VALUE));
13
- }
14
- }
@@ -1,101 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.20;
3
-
4
- import "forge-std/Test.sol";
5
-
6
- import {CommentsImpl} from "../src/CommentsImpl.sol";
7
- import {Comments} from "../src/proxy/Comments.sol";
8
- import {IComments} from "../src/interfaces/IComments.sol";
9
- import {Mock1155} from "./mocks/Mock1155.sol";
10
- import {IProtocolRewards} from "@zoralabs/protocol-rewards/src/interfaces/IProtocolRewards.sol";
11
- import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
12
- import {MockMinter} from "./mocks/MockMinter.sol";
13
-
14
- contract Comments_mintAndCommentTest is Test {
15
- Mock1155 mock1155;
16
- CommentsImpl comments;
17
-
18
- uint256 constant SPARKS_VALUE = 0.000001 ether;
19
-
20
- address zoraRecipient = makeAddr("zoraRecipient");
21
- address commentsAdmin = makeAddr("commentsAdmin");
22
- address commentor = makeAddr("commentor");
23
- address tokenAdmin = makeAddr("tokenAdmin");
24
-
25
- uint256 tokenId1 = 1;
26
-
27
- address constant protocolRewards = 0x7777777F279eba3d3Ad8F4E708545291A6fDBA8B;
28
- MockMinter mockMinter;
29
-
30
- function setUp() public {
31
- vm.createSelectFork("zora_sepolia", 14562731);
32
-
33
- CommentsImpl commentsImpl = new CommentsImpl(SPARKS_VALUE, protocolRewards);
34
-
35
- comments = CommentsImpl(payable(address(new Comments(address(commentsImpl)))));
36
-
37
- // create mock minter, which will mint and comment on the comments contract.
38
- // mock minter will be granted permission to do a delegateComment on the comments contract
39
- mockMinter = new MockMinter(IComments(address(comments)));
40
- address[] memory delegateCommenters = new address[](1);
41
- delegateCommenters[0] = address(mockMinter);
42
-
43
- comments.initialize({_zoraRecipient: zoraRecipient, defaultAdmin: commentsAdmin, backfiller: address(0), delegateCommenters: delegateCommenters});
44
-
45
- mock1155 = new Mock1155();
46
-
47
- mock1155.createToken(tokenId1, tokenAdmin);
48
- }
49
-
50
- function _expectedCommentIdentifier(
51
- address commenter,
52
- address contractAddress,
53
- uint256 tokenId
54
- ) internal view returns (IComments.CommentIdentifier memory) {
55
- return IComments.CommentIdentifier({commenter: commenter, contractAddress: contractAddress, tokenId: tokenId, nonce: comments.nextNonce()});
56
- }
57
-
58
- function testCanMintAndCommentWithNoSparks() public {
59
- uint256 quantityToMint = 1;
60
- uint256 mintFee = 0.000111 ether;
61
-
62
- address commenter = commentor;
63
- address contractAddress = address(mock1155);
64
- uint256 tokenId = tokenId1;
65
-
66
- IComments.CommentIdentifier memory emptyReplyTo;
67
-
68
- IComments.CommentIdentifier memory expectedCommentIdentifier = _expectedCommentIdentifier(commenter, contractAddress, tokenId);
69
-
70
- bytes32 expectedCommentId = comments.hashCommentIdentifier(expectedCommentIdentifier);
71
- bytes32 expectedReplyToId = bytes32(0);
72
-
73
- uint64 sparksQuantity = 0;
74
-
75
- vm.deal(commentor, mintFee * quantityToMint);
76
- vm.expectEmit(true, true, true, true);
77
- emit IComments.Commented(
78
- expectedCommentId,
79
- _expectedCommentIdentifier(commenter, contractAddress, tokenId),
80
- expectedReplyToId,
81
- emptyReplyTo,
82
- sparksQuantity,
83
- "test",
84
- block.timestamp,
85
- address(0)
86
- );
87
- vm.prank(commentor);
88
- mockMinter.mintAndComment(quantityToMint, address(mock1155), tokenId1, "test");
89
-
90
- // validate that the comment was created
91
- (, bool exists) = comments.hashAndCheckCommentExists(expectedCommentIdentifier);
92
- assertEq(exists, true);
93
- }
94
-
95
- function test_delegateComment_revertsWhenNotOwnerOrCreator() public {
96
- address notOwner = makeAddr("notOwner");
97
- vm.prank(notOwner);
98
- vm.expectRevert(IComments.NotTokenHolderOrAdmin.selector);
99
- mockMinter.forwardComment(address(mock1155), tokenId1, "test");
100
- }
101
- }
@@ -1,29 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.20;
3
-
4
- import {Mock1155} from "./Mock1155.sol";
5
- import {IComments} from "../../src/interfaces/IComments.sol";
6
-
7
- contract MockMinter {
8
- uint256 MINT_FEE = 0.00111 ether;
9
- uint256 constant SPARKS_VALUE = 0.000001 ether;
10
-
11
- IComments immutable comments;
12
-
13
- constructor(IComments _comments) {
14
- comments = _comments;
15
- }
16
-
17
- IComments.CommentIdentifier internal emptyCommentIdentifier;
18
-
19
- function mintAndComment(uint256 quantity, address collection, uint256 tokenId, string calldata comment) external payable {
20
- Mock1155(collection).mint(msg.sender, tokenId, quantity, "");
21
-
22
- // get sparks value to send to comments contract
23
- comments.delegateComment(msg.sender, collection, tokenId, comment, emptyCommentIdentifier);
24
- }
25
-
26
- function forwardComment(address collection, uint256 tokenId, string calldata comment) external {
27
- comments.delegateComment(msg.sender, collection, tokenId, comment, emptyCommentIdentifier);
28
- }
29
- }