@zoralabs/comments-contracts 0.0.1 → 0.0.2-COMMENTS.0
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.
- package/.turbo/turbo-build.log +48 -30
- package/CHANGELOG.md +8 -0
- package/README.md +10 -39
- package/abis/AddDelegateCommenterRole.json +22 -0
- package/abis/CallerAndCommenter.json +62 -0
- package/abis/CallerAndCommenterImpl.json +1218 -0
- package/abis/CallerAndCommenterMintAndCommentTest.json +771 -0
- package/abis/CallerAndCommenterSwapAndCommentTest.json +844 -0
- package/abis/CallerAndCommenterTestBase.json +577 -0
- package/abis/CommentsImpl.json +189 -59
- package/abis/CommentsImplConstants.json +106 -0
- package/abis/CommentsPermitTest.json +26 -6
- package/abis/CommentsTest.json +58 -10
- package/abis/Comments_mintAndCommentTest.json +11 -4
- package/abis/Comments_smartWallet.json +711 -0
- package/abis/DeployCallerAndCommenterImpl.json +22 -0
- package/abis/EIP712Upgradeable.json +74 -0
- package/abis/EIP712UpgradeableWithChainId.json +49 -0
- package/abis/ERC20.json +310 -0
- package/abis/ICallerAndCommenter.json +797 -0
- package/abis/IComments.json +629 -9
- package/abis/IERC20.json +39 -42
- package/abis/IERC20Metadata.json +224 -0
- package/abis/IMultiOwnable.json +21 -0
- package/abis/IProtocolRewards.json +19 -0
- package/abis/ISecondarySwap.json +45 -0
- package/abis/IZoraCreator1155.json +51 -0
- package/abis/IZoraTimedSaleStrategy.json +91 -0
- package/abis/Mock1155.json +75 -1
- package/abis/Mock1155NoCreatorRewardRecipient.json +605 -0
- package/abis/Mock1155NoOwner.json +566 -0
- package/abis/{MockMinter.json → MockDelegateCommenter.json} +12 -2
- package/abis/MockERC20z.json +315 -0
- package/abis/MockMultiOwnable.json +212 -0
- package/abis/MockSecondarySwap.json +95 -0
- package/abis/MockZoraTimedSale.json +139 -0
- package/abis/Ownable2StepUpgradeable.json +138 -0
- package/abis/UnorderedNoncesUpgradeable.json +4 -4
- package/addresses/10.json +9 -0
- package/addresses/11155111.json +9 -0
- package/addresses/11155420.json +9 -0
- package/addresses/42161.json +9 -0
- package/addresses/7777777.json +9 -0
- package/addresses/8453.json +9 -0
- package/addresses/84532.json +9 -0
- package/addresses/999999999.json +7 -2
- package/deterministicConfig/callerAndCommenter.json +8 -0
- package/deterministicConfig/comments.json +2 -2
- package/dist/index.cjs +724 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +723 -35
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/wagmiGenerated.d.ts +1102 -57
- package/dist/wagmiGenerated.d.ts.map +1 -1
- package/package/types.ts +4 -1
- package/package/wagmiGenerated.ts +728 -32
- package/package.json +11 -10
- package/script/AddDelegateCommenterRole.s.sol +24 -0
- package/script/CommentsDeployerBase.sol +101 -19
- package/script/Deploy.s.sol +2 -44
- package/script/DeployCallerAndCommenterImpl.s.sol +27 -0
- package/script/DeployImpl.s.sol +1 -0
- package/script/DeployNonDeterministic.s.sol +22 -13
- package/script/GenerateDeterministicParams.s.sol +32 -4
- package/scripts/generateCommentsTestData.ts +170 -79
- package/src/CommentsImpl.sol +267 -134
- package/src/CommentsImplConstants.sol +44 -0
- package/src/interfaces/ICallerAndCommenter.sol +215 -0
- package/src/interfaces/IComments.sol +189 -42
- package/src/interfaces/IMultiOwnable.sol +10 -0
- package/src/interfaces/ISecondarySwap.sol +40 -0
- package/src/interfaces/IZoraCreator1155.sol +6 -1
- package/src/interfaces/IZoraCreator1155TypesV1.sol +46 -0
- package/src/interfaces/IZoraTimedSaleStrategy.sol +25 -0
- package/src/proxy/CallerAndCommenter.sol +43 -0
- package/src/utils/CallerAndCommenterImpl.sol +376 -0
- package/src/utils/EIP712UpgradeableWithChainId.sol +12 -23
- package/src/version/ContractVersionBase.sol +1 -1
- package/test/CallerAndCommenterTestBase.sol +77 -0
- package/test/CallerAndCommenter_mintAndComment.t copy.sol +214 -0
- package/test/CallerAndCommenter_swapAndComment.t.sol +523 -0
- package/test/Comments.t.sol +166 -29
- package/test/CommentsTestBase.sol +12 -20
- package/test/Comments_delegateComment.t.sol +129 -0
- package/test/Comments_permit.t.sol +131 -44
- package/test/Comments_smartWallet.t.sol +152 -0
- package/test/mocks/Mock1155.sol +12 -1
- package/test/mocks/Mock1155NoCreatorRewardRecipient.sol +65 -0
- package/test/mocks/Mock1155NoOwner.sol +53 -0
- package/test/mocks/MockDelegateCommenter.sol +36 -0
- package/test/mocks/MockIZoraCreator1155.sol +16 -0
- package/test/mocks/MockSecondarySwap.sol +30 -0
- package/test/mocks/MockZoraTimedSale.sol +38 -0
- package/wagmi.config.ts +3 -1
- package/scripts/backfillComments.ts +0 -176
- package/scripts/queries.ts +0 -73
- package/scripts/queryAndSaveComments.ts +0 -48
- package/scripts/queryQuantityOfComments.ts +0 -53
- package/scripts/writeComments.ts +0 -198
- package/src/deployments/CommentsDeployment.sol +0 -14
- package/test/Comments_mintAndComment.t.sol +0 -101
- package/test/mocks/MockMinter.sol +0 -29
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
import {IComments} from "../src/interfaces/IComments.sol";
|
|
5
|
+
import {ICallerAndCommenter} from "../src/interfaces/ICallerAndCommenter.sol";
|
|
6
|
+
import {CallerAndCommenterTestBase} from "./CallerAndCommenterTestBase.sol";
|
|
7
|
+
|
|
8
|
+
contract CallerAndCommenterMintAndCommentTest is CallerAndCommenterTestBase {
|
|
9
|
+
function testCanTimedSaleMintAndComment() public {
|
|
10
|
+
uint256 quantityToMint = 1;
|
|
11
|
+
uint256 mintFee = 0.000111 ether;
|
|
12
|
+
|
|
13
|
+
address contractAddress = address(mock1155);
|
|
14
|
+
uint256 tokenId = tokenId1;
|
|
15
|
+
|
|
16
|
+
IComments.CommentIdentifier memory expectedCommentIdentifier = _expectedCommentIdentifier(commenter, contractAddress, tokenId);
|
|
17
|
+
|
|
18
|
+
bytes32 expectedCommentId = comments.hashCommentIdentifier(expectedCommentIdentifier);
|
|
19
|
+
bytes32 expectedReplyToId = bytes32(0);
|
|
20
|
+
|
|
21
|
+
uint64 sparksQuantity = 0;
|
|
22
|
+
|
|
23
|
+
address mintReferral = address(0);
|
|
24
|
+
|
|
25
|
+
vm.deal(commenter, mintFee * quantityToMint);
|
|
26
|
+
vm.expectEmit(true, true, true, true);
|
|
27
|
+
emit IComments.Commented(
|
|
28
|
+
expectedCommentId,
|
|
29
|
+
expectedCommentIdentifier,
|
|
30
|
+
expectedReplyToId,
|
|
31
|
+
emptyCommentIdentifier,
|
|
32
|
+
sparksQuantity,
|
|
33
|
+
"test",
|
|
34
|
+
block.timestamp,
|
|
35
|
+
address(0)
|
|
36
|
+
);
|
|
37
|
+
vm.expectEmit(true, true, true, true);
|
|
38
|
+
emit ICallerAndCommenter.MintedAndCommented(expectedCommentId, expectedCommentIdentifier, quantityToMint, "test");
|
|
39
|
+
vm.prank(commenter);
|
|
40
|
+
callerAndCommenter.timedSaleMintAndComment{value: mintFee * quantityToMint}(
|
|
41
|
+
commenter,
|
|
42
|
+
quantityToMint,
|
|
43
|
+
address(mock1155),
|
|
44
|
+
tokenId1,
|
|
45
|
+
mintReferral,
|
|
46
|
+
"test"
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// validate that the comment was created
|
|
50
|
+
(, bool exists) = comments.hashAndCheckCommentExists(expectedCommentIdentifier);
|
|
51
|
+
assertEq(exists, true);
|
|
52
|
+
// make sure mock 1155 got the full mint fee
|
|
53
|
+
assertEq(address(mock1155).balance, mintFee * quantityToMint);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function testWhenNoCommentDoesNotComment() public {
|
|
57
|
+
uint256 quantityToMint = 1;
|
|
58
|
+
uint256 mintFee = 0.000111 ether;
|
|
59
|
+
|
|
60
|
+
vm.deal(commenter, mintFee * quantityToMint);
|
|
61
|
+
vm.prank(commenter);
|
|
62
|
+
IComments.CommentIdentifier memory result = callerAndCommenter.timedSaleMintAndComment{value: mintFee * quantityToMint}(
|
|
63
|
+
commenter,
|
|
64
|
+
quantityToMint,
|
|
65
|
+
address(mock1155),
|
|
66
|
+
tokenId1,
|
|
67
|
+
address(0),
|
|
68
|
+
""
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
assertEq(result.commenter, address(0));
|
|
72
|
+
assertEq(result.contractAddress, address(0));
|
|
73
|
+
assertEq(result.tokenId, 0);
|
|
74
|
+
assertEq(result.nonce, bytes32(0));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function testPermitTimedSaleMintAndComment() public {
|
|
78
|
+
uint256 quantityToMint = 1;
|
|
79
|
+
uint256 mintFee = 0.000111 ether;
|
|
80
|
+
|
|
81
|
+
address contractAddress = address(mock1155);
|
|
82
|
+
uint256 tokenId = tokenId1;
|
|
83
|
+
|
|
84
|
+
string memory comment = "test comment";
|
|
85
|
+
|
|
86
|
+
ICallerAndCommenter.PermitTimedSaleMintAndComment memory permit = _createPermit(
|
|
87
|
+
commenter,
|
|
88
|
+
quantityToMint,
|
|
89
|
+
contractAddress,
|
|
90
|
+
tokenId,
|
|
91
|
+
address(0),
|
|
92
|
+
comment,
|
|
93
|
+
block.timestamp + 1 hours
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
bytes memory signature = _signPermit(permit, commenterPrivateKey);
|
|
97
|
+
|
|
98
|
+
IComments.CommentIdentifier memory expectedCommentIdentifier = _expectedCommentIdentifier(commenter, contractAddress, tokenId);
|
|
99
|
+
|
|
100
|
+
bytes32 expectedCommentId = comments.hashCommentIdentifier(expectedCommentIdentifier);
|
|
101
|
+
|
|
102
|
+
vm.deal(commenter, mintFee * quantityToMint);
|
|
103
|
+
vm.expectEmit(true, true, true, true);
|
|
104
|
+
emit IComments.Commented(expectedCommentId, expectedCommentIdentifier, bytes32(0), emptyCommentIdentifier, 0, comment, block.timestamp, address(0));
|
|
105
|
+
vm.expectEmit(true, true, true, true);
|
|
106
|
+
emit ICallerAndCommenter.MintedAndCommented(expectedCommentId, expectedCommentIdentifier, quantityToMint, comment);
|
|
107
|
+
IComments.CommentIdentifier memory result = callerAndCommenter.permitTimedSaleMintAndComment{value: mintFee * quantityToMint}(permit, signature);
|
|
108
|
+
|
|
109
|
+
assertEq(result.commenter, commenter);
|
|
110
|
+
assertEq(result.contractAddress, contractAddress);
|
|
111
|
+
assertEq(result.tokenId, tokenId);
|
|
112
|
+
assertEq(result.nonce, bytes32(0));
|
|
113
|
+
|
|
114
|
+
// validate that the comment was created
|
|
115
|
+
(, bool exists) = comments.hashAndCheckCommentExists(expectedCommentIdentifier);
|
|
116
|
+
assertEq(exists, true);
|
|
117
|
+
// make sure mock 1155 got the full mint fee
|
|
118
|
+
assertEq(address(mock1155).balance, mintFee * quantityToMint);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function testPermitTimedSaleMintAndComment_ExpiredDeadline() public {
|
|
122
|
+
uint256 quantityToMint = 1;
|
|
123
|
+
uint256 mintFee = 0.000111 ether;
|
|
124
|
+
|
|
125
|
+
ICallerAndCommenter.PermitTimedSaleMintAndComment memory permit = _createPermit(
|
|
126
|
+
commenter,
|
|
127
|
+
quantityToMint,
|
|
128
|
+
address(mock1155),
|
|
129
|
+
tokenId1,
|
|
130
|
+
address(0),
|
|
131
|
+
"test comment",
|
|
132
|
+
block.timestamp - 1 // Expired deadline
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
bytes memory signature = _signPermit(permit, commenterPrivateKey);
|
|
136
|
+
|
|
137
|
+
vm.deal(commenter, mintFee * quantityToMint);
|
|
138
|
+
vm.expectRevert(abi.encodeWithSelector(IComments.ERC2612ExpiredSignature.selector, permit.deadline));
|
|
139
|
+
callerAndCommenter.permitTimedSaleMintAndComment{value: mintFee * quantityToMint}(permit, signature);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function testPermitTimedSaleMintAndComment_InvalidSignature() public {
|
|
143
|
+
uint256 quantityToMint = 1;
|
|
144
|
+
uint256 mintFee = 0.000111 ether;
|
|
145
|
+
|
|
146
|
+
ICallerAndCommenter.PermitTimedSaleMintAndComment memory permit = _createPermit(
|
|
147
|
+
commenter,
|
|
148
|
+
quantityToMint,
|
|
149
|
+
address(mock1155),
|
|
150
|
+
tokenId1,
|
|
151
|
+
address(0),
|
|
152
|
+
"test comment",
|
|
153
|
+
block.timestamp + 1 hours
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
bytes memory signature = _signPermit(permit, 5); // Wrong signer
|
|
157
|
+
|
|
158
|
+
vm.deal(commenter, mintFee * quantityToMint);
|
|
159
|
+
vm.expectRevert(IComments.InvalidSignature.selector);
|
|
160
|
+
callerAndCommenter.permitTimedSaleMintAndComment{value: mintFee * quantityToMint}(permit, signature);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function testPermitTimedSaleMintAndComment_IncorrectDestinationChain() public {
|
|
164
|
+
uint256 quantityToMint = 1;
|
|
165
|
+
uint256 mintFee = 0.000111 ether;
|
|
166
|
+
|
|
167
|
+
ICallerAndCommenter.PermitTimedSaleMintAndComment memory permit = _createPermit(
|
|
168
|
+
commenter,
|
|
169
|
+
quantityToMint,
|
|
170
|
+
address(mock1155),
|
|
171
|
+
tokenId1,
|
|
172
|
+
address(0),
|
|
173
|
+
"test comment",
|
|
174
|
+
block.timestamp + 1 hours
|
|
175
|
+
);
|
|
176
|
+
permit.destinationChainId = uint32(block.chainid) + 1; // Incorrect destination chain
|
|
177
|
+
|
|
178
|
+
bytes memory signature = _signPermit(permit, commenterPrivateKey);
|
|
179
|
+
|
|
180
|
+
vm.deal(commenter, mintFee * quantityToMint);
|
|
181
|
+
vm.expectRevert(abi.encodeWithSelector(ICallerAndCommenter.IncorrectDestinationChain.selector, permit.destinationChainId));
|
|
182
|
+
callerAndCommenter.permitTimedSaleMintAndComment{value: mintFee * quantityToMint}(permit, signature);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function _createPermit(
|
|
186
|
+
address _commenter,
|
|
187
|
+
uint256 _quantity,
|
|
188
|
+
address _collection,
|
|
189
|
+
uint256 _tokenId,
|
|
190
|
+
address _mintReferral,
|
|
191
|
+
string memory _comment,
|
|
192
|
+
uint256 _deadline
|
|
193
|
+
) internal view returns (ICallerAndCommenter.PermitTimedSaleMintAndComment memory) {
|
|
194
|
+
return
|
|
195
|
+
ICallerAndCommenter.PermitTimedSaleMintAndComment({
|
|
196
|
+
commenter: _commenter,
|
|
197
|
+
quantity: _quantity,
|
|
198
|
+
collection: _collection,
|
|
199
|
+
tokenId: _tokenId,
|
|
200
|
+
mintReferral: _mintReferral,
|
|
201
|
+
comment: _comment,
|
|
202
|
+
deadline: _deadline,
|
|
203
|
+
nonce: bytes32(0),
|
|
204
|
+
sourceChainId: uint32(block.chainid),
|
|
205
|
+
destinationChainId: uint32(block.chainid)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function _signPermit(ICallerAndCommenter.PermitTimedSaleMintAndComment memory _permit, uint256 _privateKey) internal view returns (bytes memory) {
|
|
210
|
+
bytes32 digest = callerAndCommenter.hashPermitTimedSaleMintAndComment(_permit);
|
|
211
|
+
(uint8 v, bytes32 r, bytes32 s) = vm.sign(_privateKey, digest);
|
|
212
|
+
return abi.encodePacked(r, s, v);
|
|
213
|
+
}
|
|
214
|
+
}
|