@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
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
zeroAddress,
|
|
11
11
|
keccak256,
|
|
12
12
|
Account,
|
|
13
|
+
TransactionReceipt,
|
|
14
|
+
parseEventLogs,
|
|
13
15
|
} from "viem";
|
|
14
16
|
import { zoraCreator1155ImplABI } from "@zoralabs/zora-1155-contracts";
|
|
15
17
|
import { privateKeyToAccount } from "viem/accounts";
|
|
@@ -19,6 +21,9 @@ import { CommentIdentifier } from "../package/types";
|
|
|
19
21
|
import { getCommentsAddress } from "./getCommentsAddresses";
|
|
20
22
|
import { commentsImplABI } from "../package/wagmiGenerated";
|
|
21
23
|
import { getChainConfig } from "./utils";
|
|
24
|
+
// load env variables
|
|
25
|
+
import dotenv from "dotenv";
|
|
26
|
+
dotenv.config();
|
|
22
27
|
|
|
23
28
|
const MINT_FEE = parseEther("0.000111");
|
|
24
29
|
const SPARK_VALUE = parseEther("0.000001");
|
|
@@ -27,7 +32,7 @@ const TEST_TOKEN_ID = 3n;
|
|
|
27
32
|
const ZORA_TIMED_SALE_STRATEGY = "0x777777722D078c97c6ad07d9f36801e653E356Ae";
|
|
28
33
|
const GAS_FEE = parseEther("0.000001");
|
|
29
34
|
|
|
30
|
-
const getAccountFromEnv = (keyName: string) => {
|
|
35
|
+
const getAccountFromEnv = ({ keyName }: { keyName: string }) => {
|
|
31
36
|
const privateKey = process.env[keyName] as Address;
|
|
32
37
|
if (!privateKey) {
|
|
33
38
|
throw new Error(`${keyName} not found in environment`);
|
|
@@ -35,45 +40,68 @@ const getAccountFromEnv = (keyName: string) => {
|
|
|
35
40
|
return privateKeyToAccount(privateKey);
|
|
36
41
|
};
|
|
37
42
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
const getCommentIdentifierFromReceipt = ({
|
|
44
|
+
receipt,
|
|
45
|
+
}: {
|
|
46
|
+
receipt: TransactionReceipt;
|
|
47
|
+
}): CommentIdentifier => {
|
|
48
|
+
const logs = parseEventLogs({
|
|
49
|
+
abi: commentsImplABI,
|
|
50
|
+
logs: receipt.logs,
|
|
51
|
+
eventName: "Commented",
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (logs.length === 0) {
|
|
55
|
+
throw new Error("No Commented event found in receipt");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return logs[0]!.args.commentIdentifier;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const waitForReceiptAndEnsureSuccess = async ({
|
|
62
|
+
hash,
|
|
63
|
+
publicClient,
|
|
64
|
+
}: {
|
|
65
|
+
hash: Hex;
|
|
66
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
67
|
+
}) => {
|
|
42
68
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
43
69
|
if (receipt.status !== "success") {
|
|
44
70
|
throw new Error("Transaction failed");
|
|
45
71
|
}
|
|
72
|
+
|
|
73
|
+
return receipt;
|
|
46
74
|
};
|
|
47
75
|
|
|
48
|
-
const
|
|
49
|
-
walletClient
|
|
50
|
-
publicClient
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
76
|
+
const mintIfNotOwner = async ({
|
|
77
|
+
walletClient,
|
|
78
|
+
publicClient,
|
|
79
|
+
account,
|
|
80
|
+
commenter,
|
|
81
|
+
}: {
|
|
82
|
+
walletClient: WalletClient<Transport, Chain>;
|
|
83
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
84
|
+
account: Account;
|
|
85
|
+
commenter: Account;
|
|
86
|
+
}) => {
|
|
87
|
+
// check if commenter has a mint on 1155
|
|
58
88
|
const balance = await publicClient.readContract({
|
|
59
89
|
abi: zoraCreator1155ImplABI,
|
|
60
90
|
address: TEST_1155_CONTRACT,
|
|
61
91
|
functionName: "balanceOf",
|
|
62
|
-
args: [
|
|
92
|
+
args: [commenter.address, TEST_TOKEN_ID],
|
|
63
93
|
});
|
|
64
94
|
|
|
65
|
-
let tx: Hex;
|
|
66
|
-
|
|
67
95
|
if (balance === 0n) {
|
|
68
|
-
console.log("minting token to
|
|
96
|
+
console.log("minting token to commenter");
|
|
69
97
|
|
|
70
|
-
tx = await walletClient.writeContract({
|
|
98
|
+
const tx = await walletClient.writeContract({
|
|
71
99
|
abi: zoraTimedSaleStrategyImplABI,
|
|
72
100
|
address: ZORA_TIMED_SALE_STRATEGY,
|
|
73
101
|
functionName: "mint",
|
|
74
102
|
account,
|
|
75
103
|
args: [
|
|
76
|
-
|
|
104
|
+
commenter.address,
|
|
77
105
|
1n,
|
|
78
106
|
TEST_1155_CONTRACT,
|
|
79
107
|
TEST_TOKEN_ID,
|
|
@@ -83,8 +111,28 @@ const generateTestComments = async (
|
|
|
83
111
|
value: MINT_FEE,
|
|
84
112
|
});
|
|
85
113
|
|
|
86
|
-
await waitForReceiptAndEnsureSuccess(tx, publicClient);
|
|
114
|
+
await waitForReceiptAndEnsureSuccess({ hash: tx, publicClient });
|
|
87
115
|
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const generateTestComments = async ({
|
|
119
|
+
walletClient,
|
|
120
|
+
publicClient,
|
|
121
|
+
commentsAddress,
|
|
122
|
+
account,
|
|
123
|
+
commenter,
|
|
124
|
+
contractAddress,
|
|
125
|
+
tokenId,
|
|
126
|
+
}: {
|
|
127
|
+
walletClient: WalletClient<Transport, Chain>;
|
|
128
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
129
|
+
commentsAddress: Address;
|
|
130
|
+
account: Account;
|
|
131
|
+
commenter: Account;
|
|
132
|
+
contractAddress: Address;
|
|
133
|
+
tokenId: bigint;
|
|
134
|
+
}) => {
|
|
135
|
+
await mintIfNotOwner({ walletClient, publicClient, account, commenter });
|
|
88
136
|
|
|
89
137
|
const emptyCommentIdentifier: CommentIdentifier = {
|
|
90
138
|
commenter: zeroAddress,
|
|
@@ -96,50 +144,106 @@ const generateTestComments = async (
|
|
|
96
144
|
console.log("sending 2 sparks worth of eth to commenter");
|
|
97
145
|
|
|
98
146
|
// send 2 sparks worth of eth to commenter
|
|
99
|
-
tx = await walletClient.sendTransaction({
|
|
147
|
+
let tx = await walletClient.sendTransaction({
|
|
100
148
|
account,
|
|
101
|
-
to:
|
|
149
|
+
to: commenter.address,
|
|
102
150
|
value: (SPARK_VALUE + GAS_FEE) * 2n,
|
|
103
151
|
});
|
|
104
|
-
await waitForReceiptAndEnsureSuccess(tx, publicClient);
|
|
152
|
+
await waitForReceiptAndEnsureSuccess({ hash: tx, publicClient });
|
|
105
153
|
|
|
106
154
|
console.log("commenting");
|
|
107
155
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
emptyCommentIdentifier,
|
|
118
|
-
zeroAddress,
|
|
119
|
-
],
|
|
120
|
-
value: SPARK_VALUE,
|
|
156
|
+
const commentIdentifier = await writeCommentToContract({
|
|
157
|
+
walletClient,
|
|
158
|
+
publicClient,
|
|
159
|
+
commentsAddress,
|
|
160
|
+
commenter,
|
|
161
|
+
contractAddress,
|
|
162
|
+
tokenId,
|
|
163
|
+
text: "This is a test comment",
|
|
164
|
+
replyTo: emptyCommentIdentifier,
|
|
121
165
|
});
|
|
122
166
|
|
|
123
|
-
await waitForReceiptAndEnsureSuccess(tx, publicClient);
|
|
124
|
-
|
|
125
167
|
console.log("replying to comment");
|
|
126
168
|
|
|
127
|
-
|
|
169
|
+
const replyCommentIdentifier = await writeCommentToContract({
|
|
170
|
+
walletClient,
|
|
171
|
+
publicClient,
|
|
172
|
+
commentsAddress,
|
|
173
|
+
commenter,
|
|
174
|
+
contractAddress,
|
|
175
|
+
tokenId,
|
|
176
|
+
text: "This is a test reply",
|
|
177
|
+
replyTo: commentIdentifier,
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return { commentIdentifier, replyCommentIdentifier };
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const writeCommentToContract = async ({
|
|
184
|
+
walletClient,
|
|
185
|
+
publicClient,
|
|
186
|
+
commentsAddress,
|
|
187
|
+
commenter,
|
|
188
|
+
contractAddress,
|
|
189
|
+
tokenId,
|
|
190
|
+
text,
|
|
191
|
+
replyTo,
|
|
192
|
+
}: {
|
|
193
|
+
walletClient: WalletClient<Transport, Chain>;
|
|
194
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
195
|
+
commentsAddress: Address;
|
|
196
|
+
commenter: Account | Address;
|
|
197
|
+
contractAddress: Address;
|
|
198
|
+
tokenId: bigint;
|
|
199
|
+
text: string;
|
|
200
|
+
replyTo: CommentIdentifier;
|
|
201
|
+
}): Promise<CommentIdentifier> => {
|
|
202
|
+
const tx = await walletClient.writeContract({
|
|
128
203
|
abi: commentsImplABI,
|
|
129
204
|
address: commentsAddress,
|
|
130
205
|
functionName: "comment",
|
|
131
|
-
account:
|
|
206
|
+
account: commenter,
|
|
132
207
|
args: [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
208
|
+
typeof commenter === "string" ? commenter : commenter.address,
|
|
209
|
+
contractAddress,
|
|
210
|
+
tokenId,
|
|
211
|
+
text,
|
|
212
|
+
replyTo,
|
|
213
|
+
zeroAddress,
|
|
137
214
|
zeroAddress,
|
|
138
215
|
],
|
|
139
216
|
value: SPARK_VALUE,
|
|
140
217
|
});
|
|
141
218
|
|
|
142
|
-
await waitForReceiptAndEnsureSuccess(
|
|
219
|
+
const receipt = await waitForReceiptAndEnsureSuccess({
|
|
220
|
+
hash: tx,
|
|
221
|
+
publicClient,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
return getCommentIdentifierFromReceipt({ receipt });
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
const sendSparksEth = async ({
|
|
228
|
+
walletClient,
|
|
229
|
+
publicClient,
|
|
230
|
+
account,
|
|
231
|
+
recipient,
|
|
232
|
+
value,
|
|
233
|
+
}: {
|
|
234
|
+
walletClient: WalletClient<Transport, Chain>;
|
|
235
|
+
publicClient: PublicClient<Transport, Chain>;
|
|
236
|
+
account: Account;
|
|
237
|
+
recipient: Address;
|
|
238
|
+
value: bigint;
|
|
239
|
+
}) => {
|
|
240
|
+
console.log("sending sparks worth of eth to recipient + gas");
|
|
241
|
+
const tx = await walletClient.sendTransaction({
|
|
242
|
+
account,
|
|
243
|
+
to: recipient,
|
|
244
|
+
value,
|
|
245
|
+
});
|
|
246
|
+
await waitForReceiptAndEnsureSuccess({ hash: tx, publicClient });
|
|
143
247
|
};
|
|
144
248
|
|
|
145
249
|
const sparkComment = async ({
|
|
@@ -157,19 +261,18 @@ const sparkComment = async ({
|
|
|
157
261
|
sparker: Account;
|
|
158
262
|
commentIdentifier: CommentIdentifier;
|
|
159
263
|
}) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
264
|
+
await sendSparksEth({
|
|
265
|
+
walletClient,
|
|
266
|
+
publicClient,
|
|
163
267
|
account,
|
|
164
|
-
|
|
268
|
+
recipient: sparker.address,
|
|
165
269
|
value: SPARK_VALUE + GAS_FEE,
|
|
166
270
|
});
|
|
167
|
-
await waitForReceiptAndEnsureSuccess(tx, publicClient);
|
|
168
271
|
|
|
169
272
|
console.log("sparking comment");
|
|
170
273
|
|
|
171
274
|
// spark the comment
|
|
172
|
-
tx = await walletClient.writeContract({
|
|
275
|
+
const tx = await walletClient.writeContract({
|
|
173
276
|
abi: commentsImplABI,
|
|
174
277
|
address: commentsAddress,
|
|
175
278
|
functionName: "sparkComment",
|
|
@@ -178,7 +281,7 @@ const sparkComment = async ({
|
|
|
178
281
|
value: SPARK_VALUE,
|
|
179
282
|
});
|
|
180
283
|
|
|
181
|
-
await waitForReceiptAndEnsureSuccess(tx, publicClient);
|
|
284
|
+
await waitForReceiptAndEnsureSuccess({ hash: tx, publicClient });
|
|
182
285
|
};
|
|
183
286
|
|
|
184
287
|
export const generateCommentsTestData = async () => {
|
|
@@ -186,33 +289,21 @@ export const generateCommentsTestData = async () => {
|
|
|
186
289
|
|
|
187
290
|
const commentsAddress = (await getCommentsAddress(zoraSepolia.id)).COMMENTS;
|
|
188
291
|
|
|
189
|
-
const account = getAccountFromEnv("PRIVATE_KEY");
|
|
190
|
-
|
|
191
|
-
const commentor = getAccountFromEnv("COMMENTOR_PRIVATE_KEY");
|
|
192
|
-
const sparker = getAccountFromEnv("SPARKER_PRIVATE_KEY");
|
|
292
|
+
const account = getAccountFromEnv({ keyName: "PRIVATE_KEY" });
|
|
193
293
|
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
commenter: commentor.address,
|
|
197
|
-
contractAddress: TEST_1155_CONTRACT,
|
|
198
|
-
tokenId: TEST_TOKEN_ID,
|
|
199
|
-
nonce: keccak256(numberToHex(1)),
|
|
200
|
-
};
|
|
294
|
+
const commenter = getAccountFromEnv({ keyName: "COMMENTER_PRIVATE_KEY" });
|
|
295
|
+
const sparker = getAccountFromEnv({ keyName: "SPARKER_PRIVATE_KEY" });
|
|
201
296
|
|
|
202
|
-
const replyCommentIdentifier
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
commentor,
|
|
213
|
-
commentIdentifier,
|
|
214
|
-
replyCommentIdentifier,
|
|
215
|
-
);
|
|
297
|
+
const { commentIdentifier, replyCommentIdentifier } =
|
|
298
|
+
await generateTestComments({
|
|
299
|
+
walletClient,
|
|
300
|
+
publicClient,
|
|
301
|
+
commentsAddress,
|
|
302
|
+
account,
|
|
303
|
+
commenter,
|
|
304
|
+
contractAddress: TEST_1155_CONTRACT,
|
|
305
|
+
tokenId: TEST_TOKEN_ID,
|
|
306
|
+
});
|
|
216
307
|
|
|
217
308
|
// spark the comment twice
|
|
218
309
|
await sparkComment({
|