@zoralabs/protocol-sdk 0.11.3 → 0.11.4-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 +5 -5
- package/CHANGELOG.md +9 -0
- package/dist/test-utils.d.ts +3 -1
- package/dist/test-utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/comments/comments.test.ts +342 -0
- package/src/create/1155-create-helper.test.ts +2 -12
- package/src/secondary/secondary-client.test.ts +2 -2
- package/src/test-utils.ts +12 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @zoralabs/protocol-sdk@0.11.
|
|
2
|
+
> @zoralabs/protocol-sdk@0.11.4-COMMENTS.0 build /home/runner/work/zora-protocol-private/zora-protocol-private/packages/protocol-sdk
|
|
3
3
|
> pnpm tsup
|
|
4
4
|
|
|
5
5
|
CLI Building entry: src/index.ts
|
|
@@ -10,9 +10,9 @@ CLI Target: es2021
|
|
|
10
10
|
CLI Cleaning output folder
|
|
11
11
|
CJS Build start
|
|
12
12
|
ESM Build start
|
|
13
|
-
ESM dist/index.js 218.03 KB
|
|
14
|
-
ESM dist/index.js.map 452.53 KB
|
|
15
|
-
ESM ⚡️ Build success in 335ms
|
|
16
13
|
CJS dist/index.cjs 224.30 KB
|
|
17
14
|
CJS dist/index.cjs.map 454.54 KB
|
|
18
|
-
CJS ⚡️ Build success in
|
|
15
|
+
CJS ⚡️ Build success in 335ms
|
|
16
|
+
ESM dist/index.js 218.03 KB
|
|
17
|
+
ESM dist/index.js.map 452.53 KB
|
|
18
|
+
ESM ⚡️ Build success in 343ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @zoralabs/protocol-sdk
|
|
2
2
|
|
|
3
|
+
## 0.11.4-COMMENTS.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [4928687d]
|
|
8
|
+
- Updated dependencies [7e285fb1]
|
|
9
|
+
- Updated dependencies [a141e322]
|
|
10
|
+
- @zoralabs/protocol-deployments@0.3.6-COMMENTS.0
|
|
11
|
+
|
|
3
12
|
## 0.11.3
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/test-utils.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { zoraCreator1155FactoryImplAddress } from "@zoralabs/protocol-deployments";
|
|
2
2
|
import { Address, Hex, PublicClient } from "viem";
|
|
3
|
-
|
|
3
|
+
import { NewContractParams } from "./create/types";
|
|
4
|
+
export declare const waitForSuccess: (hash: Hex, publicClient: PublicClient) => Promise<import("viem").TransactionReceipt>;
|
|
4
5
|
export declare const getFixedPricedMinter: ({ publicClient, chainId, }: {
|
|
5
6
|
publicClient: PublicClient;
|
|
6
7
|
chainId: keyof typeof zoraCreator1155FactoryImplAddress;
|
|
@@ -8,4 +9,5 @@ export declare const getFixedPricedMinter: ({ publicClient, chainId, }: {
|
|
|
8
9
|
export declare const fixedPriceMinterMinterArguments: ({ mintRecipient, }: {
|
|
9
10
|
mintRecipient: Address;
|
|
10
11
|
}) => `0x${string}`;
|
|
12
|
+
export declare function randomNewContract(): NewContractParams;
|
|
11
13
|
//# sourceMappingURL=test-utils.d.ts.map
|
package/dist/test-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iCAAiC,EAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,EACP,GAAG,EACH,YAAY,EAGb,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../src/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iCAAiC,EAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,EACP,GAAG,EACH,YAAY,EAGb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,eAAO,MAAM,cAAc,SAAgB,GAAG,gBAAgB,YAAY,+CAQzE,CAAC;AAEF,eAAO,MAAM,oBAAoB,+BAG9B;IACD,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,MAAM,OAAO,iCAAiC,CAAC;CACzD,2BAKG,CAAC;AAEL,eAAO,MAAM,+BAA+B,uBAEzC;IACD,aAAa,EAAE,OAAO,CAAC;CACxB,kBAAwE,CAAC;AAI1E,wBAAgB,iBAAiB,IAAI,iBAAiB,CAKrD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zoralabs/protocol-sdk",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4-COMMENTS.0",
|
|
4
4
|
"repository": "https://github.com/ourzora/zora-protocol",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"abitype": "^1.0.2",
|
|
20
|
-
"@zoralabs/protocol-deployments": "^0.3.
|
|
20
|
+
"@zoralabs/protocol-deployments": "^0.3.6-COMMENTS.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"viem": "^2.21.21"
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { describe, expect } from "vitest";
|
|
2
|
+
import { forkUrls, makeAnvilTest, writeContractWithRetries } from "src/anvil";
|
|
3
|
+
import { base, zora } from "viem/chains";
|
|
4
|
+
import {
|
|
5
|
+
commentsABI,
|
|
6
|
+
commentsAddress,
|
|
7
|
+
emptyCommentIdentifier,
|
|
8
|
+
PermitComment,
|
|
9
|
+
PermitSparkComment,
|
|
10
|
+
sparkValue,
|
|
11
|
+
CommentIdentifier,
|
|
12
|
+
permitSparkCommentTypedDataDefinition,
|
|
13
|
+
permitMintAndCommentTypedDataDefinition,
|
|
14
|
+
PermitMintAndComment,
|
|
15
|
+
callerAndCommenterAddress as callerAndCommenterAddresses,
|
|
16
|
+
callerAndCommenterABI,
|
|
17
|
+
zoraCreator1155ImplABI,
|
|
18
|
+
} from "@zoralabs/protocol-deployments";
|
|
19
|
+
import {
|
|
20
|
+
Address,
|
|
21
|
+
keccak256,
|
|
22
|
+
toBytes,
|
|
23
|
+
zeroAddress,
|
|
24
|
+
parseEther,
|
|
25
|
+
TransactionReceipt,
|
|
26
|
+
parseEventLogs,
|
|
27
|
+
hashTypedData,
|
|
28
|
+
} from "viem";
|
|
29
|
+
import { createCreatorClient } from "src/sdk";
|
|
30
|
+
import { randomNewContract, waitForSuccess } from "src/test-utils";
|
|
31
|
+
import { permitCommentTypedDataDefinition } from "@zoralabs/protocol-deployments";
|
|
32
|
+
import { demoTokenMetadataURI } from "src/fixtures/contract-setup";
|
|
33
|
+
|
|
34
|
+
const getCommentIdentifierFromReceipt = (
|
|
35
|
+
receipt: TransactionReceipt,
|
|
36
|
+
): CommentIdentifier => {
|
|
37
|
+
const logs = parseEventLogs({
|
|
38
|
+
abi: commentsABI,
|
|
39
|
+
logs: receipt.logs,
|
|
40
|
+
eventName: "Commented",
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (logs.length === 0) {
|
|
44
|
+
throw new Error("No Commented event found in receipt");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return logs[0]!.args.commentIdentifier;
|
|
48
|
+
};
|
|
49
|
+
const randomNonce = () => keccak256(toBytes(Math.round(Math.random() * 1000)));
|
|
50
|
+
const thirtySecondsFromNow =
|
|
51
|
+
BigInt(Math.round(new Date().getTime() / 1000)) + 30n;
|
|
52
|
+
// todo: move this to protocol-deployments
|
|
53
|
+
describe("comments", () => {
|
|
54
|
+
makeAnvilTest({
|
|
55
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
56
|
+
forkBlockNumber: 21297211,
|
|
57
|
+
anvilChainId: zora.id,
|
|
58
|
+
})(
|
|
59
|
+
"can sign and execute a cross-chain comment, and sign and execute a cross-chain spark comment",
|
|
60
|
+
async ({
|
|
61
|
+
viemClients: { publicClient, walletClient, chain, testClient },
|
|
62
|
+
}) => {
|
|
63
|
+
// Get the chain ID and set up addresses for different roles
|
|
64
|
+
const chainId = chain.id;
|
|
65
|
+
const [
|
|
66
|
+
collectorAddress,
|
|
67
|
+
creatorAddress,
|
|
68
|
+
executorAddress,
|
|
69
|
+
sparkerAddress,
|
|
70
|
+
] = (await walletClient.getAddresses()!) as [
|
|
71
|
+
Address,
|
|
72
|
+
Address,
|
|
73
|
+
Address,
|
|
74
|
+
Address,
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
// Create a creator client for interacting with the protocol
|
|
78
|
+
const creatorClient = createCreatorClient({
|
|
79
|
+
chainId,
|
|
80
|
+
publicClient,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Step 1: Create a new 1155 contract and token
|
|
84
|
+
const { contractAddress, newTokenId, parameters, prepareMint } =
|
|
85
|
+
await creatorClient.create1155({
|
|
86
|
+
contract: randomNewContract(),
|
|
87
|
+
token: {
|
|
88
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
89
|
+
},
|
|
90
|
+
account: creatorAddress,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Deploy the new contract
|
|
94
|
+
const { request } = await publicClient.simulateContract(parameters);
|
|
95
|
+
await writeContractWithRetries({
|
|
96
|
+
request,
|
|
97
|
+
walletClient,
|
|
98
|
+
publicClient,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Prepare to mint a token
|
|
102
|
+
const { parameters: collectParameters } = await prepareMint({
|
|
103
|
+
quantityToMint: 1n,
|
|
104
|
+
minterAccount: collectorAddress,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Step 2: Mint an 1155 token on the new contract
|
|
108
|
+
const { request: mintRequest } =
|
|
109
|
+
await publicClient.simulateContract(collectParameters);
|
|
110
|
+
await writeContractWithRetries({
|
|
111
|
+
request: mintRequest,
|
|
112
|
+
walletClient,
|
|
113
|
+
publicClient,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Set up cross-chain comment parameters
|
|
117
|
+
const sourceChainId = base.id; // The chain ID where the comment originates
|
|
118
|
+
|
|
119
|
+
const commentsAddressForChainId =
|
|
120
|
+
commentsAddress[chainId as keyof typeof commentsAddress];
|
|
121
|
+
|
|
122
|
+
// Step 3: Prepare a cross-chain comment
|
|
123
|
+
const permitComment: PermitComment = {
|
|
124
|
+
sourceChainId,
|
|
125
|
+
contractAddress,
|
|
126
|
+
destinationChainId: chainId,
|
|
127
|
+
tokenId: newTokenId,
|
|
128
|
+
commenter: collectorAddress,
|
|
129
|
+
text: "hello world",
|
|
130
|
+
deadline: thirtySecondsFromNow,
|
|
131
|
+
nonce: randomNonce(),
|
|
132
|
+
referrer: zeroAddress,
|
|
133
|
+
commenterSmartWallet: zeroAddress,
|
|
134
|
+
replyTo: emptyCommentIdentifier(),
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Generate typed data for signing
|
|
138
|
+
const typedData = permitCommentTypedDataDefinition(permitComment);
|
|
139
|
+
|
|
140
|
+
expect(typedData.domain!.chainId).toEqual(sourceChainId);
|
|
141
|
+
expect(typedData.account).toEqual(collectorAddress);
|
|
142
|
+
expect(typedData.domain!.verifyingContract).toEqual(
|
|
143
|
+
commentsAddressForChainId,
|
|
144
|
+
);
|
|
145
|
+
expect(typedData.domain!.verifyingContract).toEqual(
|
|
146
|
+
commentsAddressForChainId,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const hashed = await publicClient.readContract({
|
|
150
|
+
abi: commentsABI,
|
|
151
|
+
address: commentsAddressForChainId,
|
|
152
|
+
functionName: "hashPermitComment",
|
|
153
|
+
args: [permitComment],
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
expect(hashed).toEqual(hashTypedData(typedData));
|
|
157
|
+
|
|
158
|
+
// Ensure the commenter has enough balance for the spark value
|
|
159
|
+
await testClient.setBalance({
|
|
160
|
+
address: collectorAddress,
|
|
161
|
+
value: sparkValue(),
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// Step 4: Sign the cross-chain comment
|
|
165
|
+
const signature = await walletClient.signTypedData(typedData);
|
|
166
|
+
|
|
167
|
+
// Ensure the executor has enough balance to execute the transaction
|
|
168
|
+
await testClient.setBalance({
|
|
169
|
+
address: executorAddress,
|
|
170
|
+
value: parseEther("1"),
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Step 5: Simulate and execute the cross-chain comment
|
|
174
|
+
const { request: commentRequest } = await publicClient.simulateContract({
|
|
175
|
+
abi: commentsABI,
|
|
176
|
+
address: commentsAddressForChainId,
|
|
177
|
+
functionName: "permitComment",
|
|
178
|
+
args: [permitComment, signature],
|
|
179
|
+
account: executorAddress,
|
|
180
|
+
value: sparkValue(),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
const commentHash = await walletClient.writeContract(commentRequest);
|
|
184
|
+
const receipt = await publicClient.waitForTransactionReceipt({
|
|
185
|
+
hash: commentHash,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
expect(receipt.status).toBe("success");
|
|
189
|
+
|
|
190
|
+
// Extract the comment identifier from the transaction receipt
|
|
191
|
+
const commentIdentifier = getCommentIdentifierFromReceipt(receipt);
|
|
192
|
+
|
|
193
|
+
// Step 6: Prepare a spark (like) for the comment
|
|
194
|
+
const sparkComment: PermitSparkComment = {
|
|
195
|
+
sparksQuantity: 3n,
|
|
196
|
+
sparker: sparkerAddress,
|
|
197
|
+
deadline: thirtySecondsFromNow,
|
|
198
|
+
nonce: randomNonce(),
|
|
199
|
+
referrer: zeroAddress,
|
|
200
|
+
sourceChainId,
|
|
201
|
+
destinationChainId: chainId,
|
|
202
|
+
comment: commentIdentifier,
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const sparkTypedData =
|
|
206
|
+
permitSparkCommentTypedDataDefinition(sparkComment);
|
|
207
|
+
|
|
208
|
+
// Step 7: Sign the spark comment
|
|
209
|
+
const sparkSignature = await walletClient.signTypedData(sparkTypedData);
|
|
210
|
+
|
|
211
|
+
// Step 8: Simulate and execute the spark comment
|
|
212
|
+
const { request: sparkRequest } = await publicClient.simulateContract({
|
|
213
|
+
abi: commentsABI,
|
|
214
|
+
address: commentsAddressForChainId,
|
|
215
|
+
functionName: "permitSparkComment",
|
|
216
|
+
args: [sparkComment, sparkSignature],
|
|
217
|
+
account: executorAddress,
|
|
218
|
+
value: sparkValue() * sparkComment.sparksQuantity,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const sparkHash = await walletClient.writeContract(sparkRequest);
|
|
222
|
+
|
|
223
|
+
await waitForSuccess(sparkHash, publicClient);
|
|
224
|
+
|
|
225
|
+
// Step 9: Verify the spark count
|
|
226
|
+
const sparkCount = await publicClient.readContract({
|
|
227
|
+
abi: commentsABI,
|
|
228
|
+
address: commentsAddressForChainId,
|
|
229
|
+
functionName: "commentSparksQuantity",
|
|
230
|
+
args: [commentIdentifier],
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
expect(sparkCount).toEqual(sparkComment.sparksQuantity);
|
|
234
|
+
},
|
|
235
|
+
40_000,
|
|
236
|
+
);
|
|
237
|
+
makeAnvilTest({
|
|
238
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
239
|
+
forkBlockNumber: 21297211,
|
|
240
|
+
anvilChainId: zora.id,
|
|
241
|
+
})(
|
|
242
|
+
"can sign and execute a cross-chain timed sale mint and comment",
|
|
243
|
+
async ({
|
|
244
|
+
viemClients: { publicClient, walletClient, chain, testClient },
|
|
245
|
+
}) => {
|
|
246
|
+
// Get the chain ID and set up addresses for different roles
|
|
247
|
+
const chainId = chain.id;
|
|
248
|
+
const [commenterAddress, executorAddress] =
|
|
249
|
+
(await walletClient.getAddresses()!) as [Address, Address, Address];
|
|
250
|
+
|
|
251
|
+
// Create a creator client for interacting with the protocol
|
|
252
|
+
const creatorClient = createCreatorClient({
|
|
253
|
+
chainId,
|
|
254
|
+
publicClient,
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// Step 1: Create a new 1155 contract and token
|
|
258
|
+
const { contractAddress, newTokenId, parameters } =
|
|
259
|
+
await creatorClient.create1155({
|
|
260
|
+
contract: randomNewContract(),
|
|
261
|
+
token: {
|
|
262
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
263
|
+
},
|
|
264
|
+
account: commenterAddress,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Deploy the new contract
|
|
268
|
+
const { request } = await publicClient.simulateContract(parameters);
|
|
269
|
+
await writeContractWithRetries({
|
|
270
|
+
request,
|
|
271
|
+
walletClient,
|
|
272
|
+
publicClient,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
// Step 2: Prepare the permit data for timed sale mint and comment
|
|
276
|
+
const thirtySecondsFromNow = BigInt(Math.floor(Date.now() / 1000) + 30);
|
|
277
|
+
const quantity = 3n;
|
|
278
|
+
const mintReferral = zeroAddress;
|
|
279
|
+
const comment = "This is a test comment for timed sale mint";
|
|
280
|
+
|
|
281
|
+
const permitMintAndComment: PermitMintAndComment = {
|
|
282
|
+
commenter: commenterAddress,
|
|
283
|
+
quantity,
|
|
284
|
+
collection: contractAddress,
|
|
285
|
+
tokenId: newTokenId,
|
|
286
|
+
mintReferral,
|
|
287
|
+
comment,
|
|
288
|
+
deadline: thirtySecondsFromNow,
|
|
289
|
+
nonce: randomNonce(),
|
|
290
|
+
sourceChainId: chainId,
|
|
291
|
+
destinationChainId: chainId,
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
// Step 3: Generate the typed data for signing
|
|
295
|
+
const typedData =
|
|
296
|
+
permitMintAndCommentTypedDataDefinition(permitMintAndComment);
|
|
297
|
+
|
|
298
|
+
// Step 4: Sign the typed data
|
|
299
|
+
const signature = await walletClient.signTypedData(typedData);
|
|
300
|
+
|
|
301
|
+
await testClient.setBalance({
|
|
302
|
+
address: executorAddress,
|
|
303
|
+
value: parseEther("1"),
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// Step 5: Simulate and execute the permitTimedSaleMintAndComment function
|
|
307
|
+
const callerAndCommenterAddress =
|
|
308
|
+
callerAndCommenterAddresses[
|
|
309
|
+
chainId as keyof typeof callerAndCommenterAddresses
|
|
310
|
+
];
|
|
311
|
+
const { request: permitRequest } = await publicClient.simulateContract({
|
|
312
|
+
abi: callerAndCommenterABI,
|
|
313
|
+
address: callerAndCommenterAddress,
|
|
314
|
+
functionName: "permitTimedSaleMintAndComment",
|
|
315
|
+
args: [permitMintAndComment, signature],
|
|
316
|
+
account: executorAddress,
|
|
317
|
+
value: quantity * parseEther("0.000111"),
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
const receipt = await writeContractWithRetries({
|
|
321
|
+
publicClient,
|
|
322
|
+
walletClient,
|
|
323
|
+
request: permitRequest,
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// Step 6: Verify the comment was created
|
|
327
|
+
const commentIdentifier = getCommentIdentifierFromReceipt(receipt);
|
|
328
|
+
expect(commentIdentifier).toBeDefined();
|
|
329
|
+
|
|
330
|
+
// Step 7: Verify the token was minted
|
|
331
|
+
const balance = await publicClient.readContract({
|
|
332
|
+
abi: zoraCreator1155ImplABI,
|
|
333
|
+
address: contractAddress,
|
|
334
|
+
functionName: "balanceOf",
|
|
335
|
+
args: [commenterAddress, newTokenId],
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
expect(balance).toEqual(quantity);
|
|
339
|
+
},
|
|
340
|
+
40_000, // Increased timeout to 30 seconds
|
|
341
|
+
);
|
|
342
|
+
});
|
|
@@ -16,16 +16,13 @@ import { forkUrls, makeAnvilTest, writeContractWithRetries } from "src/anvil";
|
|
|
16
16
|
import { zora } from "viem/chains";
|
|
17
17
|
import { AllowList } from "src/allow-list/types";
|
|
18
18
|
import { createAllowList } from "src/allow-list/allow-list-client";
|
|
19
|
-
import { NewContractParams } from "./types";
|
|
20
19
|
import { SubgraphContractGetter } from "./contract-getter";
|
|
21
20
|
import {
|
|
22
21
|
DEFAULT_MINIMUM_MARKET_ETH,
|
|
23
22
|
DEFAULT_MARKET_COUNTDOWN,
|
|
24
23
|
} from "./minter-defaults";
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
demoTokenMetadataURI,
|
|
28
|
-
} from "src/fixtures/contract-setup";
|
|
24
|
+
import { randomNewContract } from "src/test-utils";
|
|
25
|
+
import { demoTokenMetadataURI } from "src/fixtures/contract-setup";
|
|
29
26
|
|
|
30
27
|
const anvilTest = makeAnvilTest({
|
|
31
28
|
forkUrl: forkUrls.zoraMainnet,
|
|
@@ -56,13 +53,6 @@ const minterIsMinterOnToken = async ({
|
|
|
56
53
|
});
|
|
57
54
|
};
|
|
58
55
|
|
|
59
|
-
function randomNewContract(): NewContractParams {
|
|
60
|
-
return {
|
|
61
|
-
name: `testContract-${Math.round(Math.random() * 1_000_000)}`,
|
|
62
|
-
uri: demoContractMetadataURI,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
56
|
describe("create-helper", () => {
|
|
67
57
|
anvilTest(
|
|
68
58
|
"when no sales config is provided, it creates a new 1155 contract and token using the timed sale strategy",
|
|
@@ -176,7 +176,7 @@ describe("secondary", () => {
|
|
|
176
176
|
});
|
|
177
177
|
|
|
178
178
|
// now get the price ot buy on secondary
|
|
179
|
-
const quantityToBuy =
|
|
179
|
+
const quantityToBuy = 10n;
|
|
180
180
|
|
|
181
181
|
const buyResult = await collectorClient.buy1155OnSecondary({
|
|
182
182
|
account: collectorAccount,
|
|
@@ -215,7 +215,7 @@ describe("secondary", () => {
|
|
|
215
215
|
expect(balance - balanceBefore).toBe(quantityToBuy);
|
|
216
216
|
|
|
217
217
|
// now sell 10_000n tokens
|
|
218
|
-
const quantityToSell =
|
|
218
|
+
const quantityToSell = 100n;
|
|
219
219
|
|
|
220
220
|
const sellResult = await collectorClient.sell1155OnSecondary({
|
|
221
221
|
account: collectorAccount,
|
package/src/test-utils.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
encodeAbiParameters,
|
|
10
10
|
parseAbiParameters,
|
|
11
11
|
} from "viem";
|
|
12
|
+
import { NewContractParams } from "./create/types";
|
|
12
13
|
import { expect } from "vitest";
|
|
13
14
|
|
|
14
15
|
export const waitForSuccess = async (hash: Hex, publicClient: PublicClient) => {
|
|
@@ -17,6 +18,8 @@ export const waitForSuccess = async (hash: Hex, publicClient: PublicClient) => {
|
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
expect(receipt.status).toBe("success");
|
|
21
|
+
|
|
22
|
+
return receipt;
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export const getFixedPricedMinter = async ({
|
|
@@ -37,3 +40,12 @@ export const fixedPriceMinterMinterArguments = ({
|
|
|
37
40
|
}: {
|
|
38
41
|
mintRecipient: Address;
|
|
39
42
|
}) => encodeAbiParameters(parseAbiParameters("address"), [mintRecipient]);
|
|
43
|
+
|
|
44
|
+
const demoContractMetadataURI = "ipfs://DUMMY/contract.json";
|
|
45
|
+
|
|
46
|
+
export function randomNewContract(): NewContractParams {
|
|
47
|
+
return {
|
|
48
|
+
name: `testContract-${Math.round(Math.random() * 1_000_000)}`,
|
|
49
|
+
uri: demoContractMetadataURI,
|
|
50
|
+
};
|
|
51
|
+
}
|