@zoralabs/protocol-sdk 0.7.6 → 0.9.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 +7 -7
- package/CHANGELOG.md +17 -0
- package/dist/allow-list/allow-list-client.d.ts +26 -0
- package/dist/allow-list/allow-list-client.d.ts.map +1 -0
- package/dist/allow-list/types.d.ts +14 -0
- package/dist/allow-list/types.d.ts.map +1 -0
- package/dist/apis/generated/allow-list-api-types.d.ts +288 -0
- package/dist/apis/generated/allow-list-api-types.d.ts.map +1 -0
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/apis/subgraph-querier.d.ts +18 -0
- package/dist/apis/subgraph-querier.d.ts.map +1 -0
- package/dist/create/1155-create-helper.d.ts +14 -11
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/contract-setup.d.ts +13 -8
- package/dist/create/contract-setup.d.ts.map +1 -1
- package/dist/create/minter-defaults.d.ts +5 -0
- package/dist/create/minter-defaults.d.ts.map +1 -0
- package/dist/create/minter-setup.d.ts +14 -0
- package/dist/create/minter-setup.d.ts.map +1 -0
- package/dist/create/token-setup.d.ts +4 -19
- package/dist/create/token-setup.d.ts.map +1 -1
- package/dist/create/types.d.ts +53 -13
- package/dist/create/types.d.ts.map +1 -1
- package/dist/create/update.d.ts +15 -0
- package/dist/create/update.d.ts.map +1 -0
- package/dist/index.cjs +1660 -1246
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1681 -1264
- package/dist/index.js.map +1 -1
- package/dist/ipfs/token-metadata.d.ts +1 -0
- package/dist/ipfs/token-metadata.d.ts.map +1 -1
- package/dist/mint/mint-client.d.ts +2 -6
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +3 -1
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +9 -7
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +5 -4
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +42 -15
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/mint/types.d.ts +32 -13
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/sdk.d.ts +2 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sparks/sparks-contracts.d.ts +96 -96
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -8
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/allow-list/allow-list-client.ts +105 -0
- package/src/allow-list/types.ts +15 -0
- package/src/apis/generated/allow-list-api-types.ts +288 -0
- package/src/apis/http-api-base.ts +12 -0
- package/src/apis/subgraph-querier.ts +38 -0
- package/src/create/1155-create-helper.test.ts +269 -113
- package/src/create/1155-create-helper.ts +204 -90
- package/src/create/contract-setup.ts +54 -44
- package/src/create/minter-defaults.test.ts +21 -0
- package/src/create/minter-defaults.ts +134 -0
- package/src/create/minter-setup.ts +293 -0
- package/src/create/token-setup.ts +14 -190
- package/src/create/types.ts +94 -25
- package/src/create/update.ts +93 -0
- package/src/index.ts +4 -0
- package/src/ipfs/token-metadata.ts +18 -0
- package/src/mint/mint-client.test.ts +219 -15
- package/src/mint/mint-client.ts +2 -34
- package/src/mint/mint-queries.ts +34 -13
- package/src/mint/mint-transactions.ts +104 -17
- package/src/mint/subgraph-mint-getter.ts +107 -50
- package/src/mint/subgraph-queries.ts +67 -37
- package/src/mint/types.ts +55 -16
- package/src/premint/premint-client.test.ts +6 -5
- package/src/sdk.ts +5 -2
- package/src/types.ts +1 -1
- package/src/utils.ts +1 -25
|
@@ -1,21 +1,78 @@
|
|
|
1
1
|
import { describe, expect } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
getContractAddressFromReceipt,
|
|
4
|
+
getTokenIdFromCreateReceipt,
|
|
5
|
+
} from "./1155-create-helper";
|
|
4
6
|
import { createCreatorClient } from "src/sdk";
|
|
5
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
zoraCreator1155ImplABI,
|
|
9
|
+
zoraTimedSaleStrategyAddress,
|
|
10
|
+
} from "@zoralabs/protocol-deployments";
|
|
6
11
|
import { waitForSuccess } from "src/test-utils";
|
|
7
|
-
import { parseEther } from "viem";
|
|
8
12
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
Address,
|
|
14
|
+
parseEther,
|
|
15
|
+
PublicClient,
|
|
16
|
+
TransactionReceipt,
|
|
17
|
+
zeroAddress,
|
|
18
|
+
} from "viem";
|
|
19
|
+
import { makePrepareMint1155TokenParams } from "src/mint/mint-transactions";
|
|
20
|
+
import { forkUrls, makeAnvilTest } from "src/anvil";
|
|
21
|
+
import { zora } from "viem/chains";
|
|
22
|
+
import { AllowList } from "src/allow-list/types";
|
|
23
|
+
import { createAllowList } from "src/allow-list/allow-list-client";
|
|
24
|
+
import { NewContractParams } from "./types";
|
|
25
|
+
|
|
26
|
+
export const demoTokenMetadataURI =
|
|
27
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u";
|
|
28
|
+
export const demoContractMetadataURI = "ipfs://DUMMY/contract.json";
|
|
29
|
+
|
|
30
|
+
const anvilTest = makeAnvilTest({
|
|
31
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
32
|
+
forkBlockNumber: 18094820,
|
|
33
|
+
anvilChainId: zora.id,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const PERMISSION_BITS = {
|
|
37
|
+
MINTER: 2n ** 2n,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const minterIsMinterOnToken = async ({
|
|
41
|
+
publicClient,
|
|
42
|
+
contractAddress,
|
|
43
|
+
tokenId,
|
|
44
|
+
minter,
|
|
45
|
+
}: {
|
|
46
|
+
publicClient: Pick<PublicClient, "readContract">;
|
|
47
|
+
contractAddress: Address;
|
|
48
|
+
tokenId: bigint;
|
|
49
|
+
minter: Address;
|
|
50
|
+
}) => {
|
|
51
|
+
return await publicClient.readContract({
|
|
52
|
+
abi: zoraCreator1155ImplABI,
|
|
53
|
+
address: contractAddress,
|
|
54
|
+
functionName: "isAdminOrRole",
|
|
55
|
+
args: [minter, tokenId, PERMISSION_BITS.MINTER],
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
function logFailure(receipt: TransactionReceipt) {
|
|
60
|
+
if (receipt.status !== "success") {
|
|
61
|
+
console.log("transaction failed");
|
|
62
|
+
console.log(receipt.logs);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
12
65
|
|
|
13
|
-
|
|
14
|
-
|
|
66
|
+
function randomNewContract(): NewContractParams {
|
|
67
|
+
return {
|
|
68
|
+
name: `testContract-${Math.round(Math.random() * 1_000_000)}`,
|
|
69
|
+
uri: demoContractMetadataURI,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
15
72
|
|
|
16
73
|
describe("create-helper", () => {
|
|
17
74
|
anvilTest(
|
|
18
|
-
"creates a new 1155 contract and token",
|
|
75
|
+
"when no sales config is provided, it creates a new 1155 contract and token using the timed sale strategy",
|
|
19
76
|
async ({ viemClients: { publicClient, walletClient, chain } }) => {
|
|
20
77
|
const addresses = await walletClient.getAddresses();
|
|
21
78
|
const creatorAddress = addresses[0]!;
|
|
@@ -24,61 +81,113 @@ describe("create-helper", () => {
|
|
|
24
81
|
chainId: chain.id,
|
|
25
82
|
publicClient: publicClient,
|
|
26
83
|
});
|
|
27
|
-
const { parameters
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
const
|
|
39
|
-
await publicClient.simulateContract(request);
|
|
40
|
-
const hash = await walletClient.writeContract(simulationResponse);
|
|
84
|
+
const { parameters, contractAddress, newTokenId } =
|
|
85
|
+
await creatorClient.create1155({
|
|
86
|
+
contract: randomNewContract(),
|
|
87
|
+
token: {
|
|
88
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
89
|
+
mintToCreatorCount: 1,
|
|
90
|
+
},
|
|
91
|
+
account: creatorAddress,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const { request } = await publicClient.simulateContract(parameters);
|
|
95
|
+
const hash = await walletClient.writeContract(request);
|
|
41
96
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
97
|
+
logFailure(receipt);
|
|
98
|
+
expect(receipt.status).toBe("success");
|
|
42
99
|
expect(receipt).not.toBeNull();
|
|
43
100
|
expect(receipt.to).to.equal("0x777777c338d93e2c7adf08d102d45ca7cc4ed021");
|
|
44
101
|
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(1n);
|
|
102
|
+
expect(getContractAddressFromReceipt(receipt)).to.be.equal(
|
|
103
|
+
contractAddress,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(
|
|
107
|
+
await minterIsMinterOnToken({
|
|
108
|
+
contractAddress,
|
|
109
|
+
tokenId: newTokenId,
|
|
110
|
+
publicClient,
|
|
111
|
+
minter:
|
|
112
|
+
zoraTimedSaleStrategyAddress[
|
|
113
|
+
chain.id as keyof typeof zoraTimedSaleStrategyAddress
|
|
114
|
+
],
|
|
115
|
+
}),
|
|
116
|
+
).toBe(true);
|
|
45
117
|
},
|
|
46
118
|
20 * 1000,
|
|
47
119
|
);
|
|
48
120
|
anvilTest(
|
|
49
|
-
"
|
|
121
|
+
"when price is set to 0, it creates a new 1155 contract and token using the timed sale strategy",
|
|
50
122
|
async ({ viemClients: { publicClient, walletClient, chain } }) => {
|
|
51
123
|
const addresses = await walletClient.getAddresses();
|
|
52
|
-
const
|
|
124
|
+
const creatorAddress = addresses[0]!;
|
|
53
125
|
|
|
54
126
|
const creatorClient = createCreatorClient({
|
|
55
127
|
chainId: chain.id,
|
|
56
128
|
publicClient: publicClient,
|
|
57
129
|
});
|
|
130
|
+
const { parameters, contractAddress, newTokenId } =
|
|
131
|
+
await creatorClient.create1155({
|
|
132
|
+
contract: randomNewContract(),
|
|
133
|
+
token: {
|
|
134
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
135
|
+
salesConfig: {
|
|
136
|
+
pricePerToken: 0n,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
account: creatorAddress,
|
|
140
|
+
});
|
|
58
141
|
|
|
59
|
-
const {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
142
|
+
const { request } = await publicClient.simulateContract(parameters);
|
|
143
|
+
const hash = await walletClient.writeContract(request);
|
|
144
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
145
|
+
|
|
146
|
+
logFailure(receipt);
|
|
147
|
+
|
|
148
|
+
expect(receipt.status).toBe("success");
|
|
149
|
+
|
|
150
|
+
expect(
|
|
151
|
+
await minterIsMinterOnToken({
|
|
152
|
+
contractAddress,
|
|
153
|
+
tokenId: newTokenId,
|
|
154
|
+
minter:
|
|
155
|
+
zoraTimedSaleStrategyAddress[
|
|
156
|
+
chain.id as keyof typeof zoraTimedSaleStrategyAddress
|
|
157
|
+
],
|
|
158
|
+
publicClient,
|
|
159
|
+
}),
|
|
160
|
+
).toBe(true);
|
|
161
|
+
},
|
|
162
|
+
20 * 1000,
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
anvilTest(
|
|
166
|
+
"can create a new contract, then can create a new token on this existing contract",
|
|
167
|
+
async ({ viemClients: { publicClient, walletClient, chain } }) => {
|
|
168
|
+
const addresses = await walletClient.getAddresses();
|
|
169
|
+
const creatorAccount = addresses[0]!;
|
|
170
|
+
|
|
171
|
+
const creatorClient = createCreatorClient({
|
|
172
|
+
chainId: chain.id,
|
|
173
|
+
publicClient: publicClient,
|
|
73
174
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
175
|
+
|
|
176
|
+
const { parameters: request, contractAddress: contractAddress } =
|
|
177
|
+
await creatorClient.create1155({
|
|
178
|
+
contract: randomNewContract(),
|
|
179
|
+
token: {
|
|
180
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
181
|
+
mintToCreatorCount: 3,
|
|
182
|
+
},
|
|
183
|
+
account: creatorAccount,
|
|
184
|
+
});
|
|
78
185
|
const { request: simulateResponse } =
|
|
79
186
|
await publicClient.simulateContract(request);
|
|
80
187
|
const hash = await walletClient.writeContract(simulateResponse);
|
|
81
188
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
189
|
+
logFailure(receipt);
|
|
190
|
+
expect(receipt.status).toBe("success");
|
|
82
191
|
const firstTokenId = getTokenIdFromCreateReceipt(receipt);
|
|
83
192
|
expect(firstTokenId).to.be.equal(1n);
|
|
84
193
|
expect(receipt).not.toBeNull();
|
|
@@ -93,21 +202,15 @@ describe("create-helper", () => {
|
|
|
93
202
|
}),
|
|
94
203
|
).toBe(3n);
|
|
95
204
|
|
|
96
|
-
const newTokenOnExistingContract =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
account: creatorAccount,
|
|
106
|
-
});
|
|
107
|
-
expect(newTokenOnExistingContract.collectionAddress).to.be.equal(
|
|
108
|
-
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3",
|
|
109
|
-
);
|
|
110
|
-
expect(newTokenOnExistingContract.contractExists).to.be.true;
|
|
205
|
+
const newTokenOnExistingContract =
|
|
206
|
+
await creatorClient.create1155OnExistingContract({
|
|
207
|
+
contractAddress: contractAddress,
|
|
208
|
+
token: {
|
|
209
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
210
|
+
mintToCreatorCount: 2,
|
|
211
|
+
},
|
|
212
|
+
account: creatorAccount,
|
|
213
|
+
});
|
|
111
214
|
const { request: simulateRequest } = await publicClient.simulateContract(
|
|
112
215
|
newTokenOnExistingContract.parameters,
|
|
113
216
|
);
|
|
@@ -115,9 +218,12 @@ describe("create-helper", () => {
|
|
|
115
218
|
const newReceipt = await publicClient.waitForTransactionReceipt({
|
|
116
219
|
hash: newHash,
|
|
117
220
|
});
|
|
221
|
+
|
|
222
|
+
logFailure(receipt);
|
|
223
|
+
|
|
224
|
+
expect(newReceipt.status).toBe("success");
|
|
118
225
|
const tokenId = getTokenIdFromCreateReceipt(newReceipt);
|
|
119
226
|
expect(tokenId).to.be.equal(2n);
|
|
120
|
-
expect(newReceipt).not.toBeNull();
|
|
121
227
|
},
|
|
122
228
|
20 * 1000,
|
|
123
229
|
);
|
|
@@ -132,11 +238,12 @@ describe("create-helper", () => {
|
|
|
132
238
|
chainId: chain.id,
|
|
133
239
|
publicClient: publicClient,
|
|
134
240
|
});
|
|
135
|
-
const {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
241
|
+
const {
|
|
242
|
+
parameters: request,
|
|
243
|
+
contractAddress: collectionAddress,
|
|
244
|
+
newTokenId,
|
|
245
|
+
} = await creatorClient.create1155({
|
|
246
|
+
contract: randomNewContract(),
|
|
140
247
|
token: {
|
|
141
248
|
tokenMetadataURI: demoTokenMetadataURI,
|
|
142
249
|
createReferral,
|
|
@@ -147,16 +254,16 @@ describe("create-helper", () => {
|
|
|
147
254
|
await publicClient.simulateContract(request);
|
|
148
255
|
const hash = await walletClient.writeContract(simulationResponse);
|
|
149
256
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
150
|
-
expect(receipt).
|
|
151
|
-
expect(receipt.to).to.equal("
|
|
152
|
-
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(
|
|
257
|
+
expect(receipt.status).toBe("success");
|
|
258
|
+
expect(receipt.to).to.equal("0x777777c338d93e2c7adf08d102d45ca7cc4ed021");
|
|
259
|
+
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(newTokenId);
|
|
153
260
|
|
|
154
261
|
expect(
|
|
155
262
|
await publicClient.readContract({
|
|
156
263
|
abi: zoraCreator1155ImplABI,
|
|
157
|
-
address:
|
|
264
|
+
address: collectionAddress,
|
|
158
265
|
functionName: "createReferrals",
|
|
159
|
-
args: [
|
|
266
|
+
args: [newTokenId],
|
|
160
267
|
}),
|
|
161
268
|
).to.be.equal(createReferral);
|
|
162
269
|
},
|
|
@@ -177,15 +284,12 @@ describe("create-helper", () => {
|
|
|
177
284
|
});
|
|
178
285
|
const {
|
|
179
286
|
parameters: request,
|
|
180
|
-
collectionAddress,
|
|
181
287
|
newTokenId,
|
|
182
|
-
newToken,
|
|
183
288
|
minter,
|
|
289
|
+
contractAddress: collectionAddress,
|
|
290
|
+
contractVersion,
|
|
184
291
|
} = await creatorClient.create1155({
|
|
185
|
-
contract:
|
|
186
|
-
name: "testContract",
|
|
187
|
-
uri: demoContractMetadataURI,
|
|
188
|
-
},
|
|
292
|
+
contract: randomNewContract(),
|
|
189
293
|
token: {
|
|
190
294
|
tokenMetadataURI: demoTokenMetadataURI,
|
|
191
295
|
},
|
|
@@ -198,20 +302,6 @@ describe("create-helper", () => {
|
|
|
198
302
|
publicClient,
|
|
199
303
|
);
|
|
200
304
|
|
|
201
|
-
const salesConfigAndTokenInfo: MintableParameters = {
|
|
202
|
-
mintFeePerQuantity: parseEther("0.000777"),
|
|
203
|
-
contractVersion: "2.8.0",
|
|
204
|
-
salesConfig: {
|
|
205
|
-
saleType: "fixedPrice",
|
|
206
|
-
address: minter,
|
|
207
|
-
pricePerToken: newToken.salesConfig.pricePerToken,
|
|
208
|
-
// these dont matter
|
|
209
|
-
maxTokensPerAddress: 0n,
|
|
210
|
-
saleEnd: "",
|
|
211
|
-
saleStart: "",
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
|
|
215
305
|
const quantityToMint = 5n;
|
|
216
306
|
|
|
217
307
|
// now try to mint a free mint
|
|
@@ -226,7 +316,21 @@ describe("create-helper", () => {
|
|
|
226
316
|
tokenContract: collectionAddress,
|
|
227
317
|
minterAccount: minterAddress,
|
|
228
318
|
tokenId: newTokenId,
|
|
229
|
-
salesConfigAndTokenInfo
|
|
319
|
+
salesConfigAndTokenInfo: {
|
|
320
|
+
contractVersion,
|
|
321
|
+
salesConfig: {
|
|
322
|
+
saleType: "timed",
|
|
323
|
+
address: minter,
|
|
324
|
+
// below fields arent used when determining mint price for minting
|
|
325
|
+
saleEnd: "",
|
|
326
|
+
saleStart: "",
|
|
327
|
+
erc20Z: zeroAddress,
|
|
328
|
+
pool: zeroAddress,
|
|
329
|
+
secondaryActivated: false,
|
|
330
|
+
mintFeePerQuantity: parseEther("0.000111"),
|
|
331
|
+
mintFee: 0n,
|
|
332
|
+
},
|
|
333
|
+
},
|
|
230
334
|
quantityToMint,
|
|
231
335
|
});
|
|
232
336
|
|
|
@@ -241,7 +345,7 @@ describe("create-helper", () => {
|
|
|
241
345
|
);
|
|
242
346
|
|
|
243
347
|
anvilTest(
|
|
244
|
-
"creates a new 1155 paid mint that can be minted",
|
|
348
|
+
"creates a new 1155 paid mint that can be minted using the fixed price minter",
|
|
245
349
|
async ({
|
|
246
350
|
viemClients: { testClient, publicClient, walletClient, chain },
|
|
247
351
|
}) => {
|
|
@@ -257,15 +361,12 @@ describe("create-helper", () => {
|
|
|
257
361
|
|
|
258
362
|
const {
|
|
259
363
|
parameters: request,
|
|
260
|
-
collectionAddress,
|
|
364
|
+
contractAddress: collectionAddress,
|
|
261
365
|
newTokenId,
|
|
262
|
-
newToken,
|
|
263
366
|
minter,
|
|
367
|
+
contractVersion,
|
|
264
368
|
} = await creatorClient.create1155({
|
|
265
|
-
contract:
|
|
266
|
-
name: "testContract",
|
|
267
|
-
uri: demoContractMetadataURI,
|
|
268
|
-
},
|
|
369
|
+
contract: randomNewContract(),
|
|
269
370
|
token: {
|
|
270
371
|
tokenMetadataURI: demoTokenMetadataURI,
|
|
271
372
|
salesConfig: {
|
|
@@ -281,20 +382,6 @@ describe("create-helper", () => {
|
|
|
281
382
|
publicClient,
|
|
282
383
|
);
|
|
283
384
|
|
|
284
|
-
const salesConfigAndTokenInfo: MintableParameters = {
|
|
285
|
-
mintFeePerQuantity: parseEther("0.000777"),
|
|
286
|
-
contractVersion: "2.8.0",
|
|
287
|
-
salesConfig: {
|
|
288
|
-
saleType: "fixedPrice",
|
|
289
|
-
address: minter,
|
|
290
|
-
pricePerToken: newToken.salesConfig.pricePerToken,
|
|
291
|
-
// these dont matter
|
|
292
|
-
maxTokensPerAddress: 0n,
|
|
293
|
-
saleEnd: "",
|
|
294
|
-
saleStart: "",
|
|
295
|
-
},
|
|
296
|
-
};
|
|
297
|
-
|
|
298
385
|
const quantityToMint = 5n;
|
|
299
386
|
|
|
300
387
|
// now try to mint a free mint
|
|
@@ -309,7 +396,23 @@ describe("create-helper", () => {
|
|
|
309
396
|
tokenContract: collectionAddress,
|
|
310
397
|
minterAccount: minterAddress,
|
|
311
398
|
tokenId: newTokenId,
|
|
312
|
-
salesConfigAndTokenInfo
|
|
399
|
+
salesConfigAndTokenInfo: {
|
|
400
|
+
contractVersion,
|
|
401
|
+
salesConfig: {
|
|
402
|
+
mintFeePerQuantity: await publicClient.readContract({
|
|
403
|
+
abi: zoraCreator1155ImplABI,
|
|
404
|
+
functionName: "mintFee",
|
|
405
|
+
address: collectionAddress,
|
|
406
|
+
}),
|
|
407
|
+
saleType: "fixedPrice",
|
|
408
|
+
address: minter,
|
|
409
|
+
pricePerToken,
|
|
410
|
+
// these dont matter
|
|
411
|
+
maxTokensPerAddress: 0n,
|
|
412
|
+
saleEnd: "",
|
|
413
|
+
saleStart: "",
|
|
414
|
+
},
|
|
415
|
+
},
|
|
313
416
|
quantityToMint,
|
|
314
417
|
});
|
|
315
418
|
|
|
@@ -322,4 +425,57 @@ describe("create-helper", () => {
|
|
|
322
425
|
},
|
|
323
426
|
20 * 1000,
|
|
324
427
|
);
|
|
428
|
+
|
|
429
|
+
anvilTest(
|
|
430
|
+
"creates an allow list mint contract",
|
|
431
|
+
async ({ viemClients: { publicClient, walletClient, chain } }) => {
|
|
432
|
+
const creator = (await walletClient.getAddresses())[0]!;
|
|
433
|
+
const allowList: AllowList = {
|
|
434
|
+
entries: [
|
|
435
|
+
{
|
|
436
|
+
user: "0xf69fEc6d858c77e969509843852178bd24CAd2B6",
|
|
437
|
+
price: 2n,
|
|
438
|
+
maxCanMint: 10000,
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
user: "0xcD08da546414dd463C89705B5E72CE1AeebF1567",
|
|
442
|
+
price: 3n,
|
|
443
|
+
maxCanMint: 10,
|
|
444
|
+
},
|
|
445
|
+
],
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
const root = await createAllowList({
|
|
449
|
+
allowList,
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
const creatorClient = createCreatorClient({
|
|
453
|
+
chainId: chain.id,
|
|
454
|
+
publicClient: publicClient,
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
const { parameters } = await creatorClient.create1155({
|
|
458
|
+
contract: {
|
|
459
|
+
name: "test allowlists",
|
|
460
|
+
uri: "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
461
|
+
},
|
|
462
|
+
token: {
|
|
463
|
+
tokenMetadataURI:
|
|
464
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
465
|
+
salesConfig: {
|
|
466
|
+
type: "allowlistMint",
|
|
467
|
+
presaleMerkleRoot: `0x${root}`,
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
account: creator,
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
const { request } = await publicClient.simulateContract(parameters);
|
|
474
|
+
|
|
475
|
+
await waitForSuccess(
|
|
476
|
+
await walletClient.writeContract(request),
|
|
477
|
+
publicClient,
|
|
478
|
+
);
|
|
479
|
+
},
|
|
480
|
+
);
|
|
325
481
|
});
|