@zoralabs/protocol-sdk 0.7.2-ALLOWLIST.0 → 0.7.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.
- package/.turbo/turbo-build.log +15 -0
- package/CHANGELOG.md +2 -2
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/constants.d.ts +27 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +0 -1
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/token-setup.d.ts +4 -3
- package/dist/create/token-setup.d.ts.map +1 -1
- package/dist/create/types.d.ts +4 -24
- package/dist/create/types.d.ts.map +1 -1
- package/dist/index.cjs +127 -237
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +128 -238
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-queries.d.ts +1 -3
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +3 -5
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +2 -1
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +14 -27
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/mint/types.d.ts +11 -22
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/mints/mints-contracts.d.ts +16 -0
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +8 -0
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/apis/http-api-base.ts +0 -12
- package/src/constants.ts +36 -0
- package/src/create/1155-create-helper.test.ts +325 -0
- package/src/create/1155-create-helper.ts +0 -17
- package/src/create/token-setup.ts +19 -116
- package/src/create/types.ts +4 -32
- package/src/index.ts +0 -4
- package/src/mint/mint-client.test.ts +263 -0
- package/src/mint/mint-queries.ts +0 -6
- package/src/mint/mint-transactions.ts +8 -74
- package/src/mint/subgraph-mint-getter.ts +41 -17
- package/src/mint/subgraph-queries.ts +36 -39
- package/src/mint/types.ts +12 -38
- package/src/mints/mints-contracts.test.ts +529 -0
- package/src/mints/mints-eth-unwrapper-and-caller.test.ts +467 -0
- package/src/mints/mints-queries.test.ts +105 -0
- package/src/premint/premint-client.test.ts +290 -0
- package/src/premint/preminter.test.ts +866 -0
- package/test-integration/setup-test-contracts.ts +96 -0
- package/tsconfig.build.json +10 -0
- package/tsup.config.ts +12 -0
- package/dist/allow-list/allow-list-client.d.ts +0 -25
- package/dist/allow-list/allow-list-client.d.ts.map +0 -1
- package/dist/allow-list/types.d.ts +0 -14
- package/dist/allow-list/types.d.ts.map +0 -1
- package/dist/apis/generated/allow-list-api-types.d.ts +0 -288
- package/dist/apis/generated/allow-list-api-types.d.ts.map +0 -1
- package/src/allow-list/allow-list-client.ts +0 -102
- package/src/allow-list/types.ts +0 -15
- package/src/apis/generated/allow-list-api-types.ts +0 -288
- package/yarn-error.log +0 -8602
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { describe, expect } from "vitest";
|
|
2
|
+
import { getTokenIdFromCreateReceipt } from "./1155-create-helper";
|
|
3
|
+
import { anvilTest } from "src/anvil";
|
|
4
|
+
import { createCreatorClient } from "src/sdk";
|
|
5
|
+
import { zoraCreator1155ImplABI } from "@zoralabs/protocol-deployments";
|
|
6
|
+
import { waitForSuccess } from "src/test-utils";
|
|
7
|
+
import { parseEther } from "viem";
|
|
8
|
+
import {
|
|
9
|
+
MintableParameters,
|
|
10
|
+
makePrepareMint1155TokenParams,
|
|
11
|
+
} from "src/mint/mint-transactions";
|
|
12
|
+
|
|
13
|
+
const demoTokenMetadataURI = "ipfs://DUMMY/token.json";
|
|
14
|
+
const demoContractMetadataURI = "ipfs://DUMMY/contract.json";
|
|
15
|
+
|
|
16
|
+
describe("create-helper", () => {
|
|
17
|
+
anvilTest(
|
|
18
|
+
"creates a new 1155 contract and token",
|
|
19
|
+
async ({ viemClients: { publicClient, walletClient, chain } }) => {
|
|
20
|
+
const addresses = await walletClient.getAddresses();
|
|
21
|
+
const creatorAddress = addresses[0]!;
|
|
22
|
+
|
|
23
|
+
const creatorClient = createCreatorClient({
|
|
24
|
+
chainId: chain.id,
|
|
25
|
+
publicClient: publicClient,
|
|
26
|
+
});
|
|
27
|
+
const { parameters: request } = await creatorClient.create1155({
|
|
28
|
+
contract: {
|
|
29
|
+
name: "testContract",
|
|
30
|
+
uri: demoContractMetadataURI,
|
|
31
|
+
},
|
|
32
|
+
token: {
|
|
33
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
34
|
+
mintToCreatorCount: 1,
|
|
35
|
+
},
|
|
36
|
+
account: creatorAddress,
|
|
37
|
+
});
|
|
38
|
+
const { request: simulationResponse } =
|
|
39
|
+
await publicClient.simulateContract(request);
|
|
40
|
+
const hash = await walletClient.writeContract(simulationResponse);
|
|
41
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
42
|
+
expect(receipt).not.toBeNull();
|
|
43
|
+
expect(receipt.to).to.equal("0x777777c338d93e2c7adf08d102d45ca7cc4ed021");
|
|
44
|
+
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(1n);
|
|
45
|
+
},
|
|
46
|
+
20 * 1000,
|
|
47
|
+
);
|
|
48
|
+
anvilTest(
|
|
49
|
+
"creates a new contract, then can create a new token on this existing contract",
|
|
50
|
+
async ({ viemClients: { publicClient, walletClient, chain } }) => {
|
|
51
|
+
const addresses = await walletClient.getAddresses();
|
|
52
|
+
const creatorAccount = addresses[0]!;
|
|
53
|
+
|
|
54
|
+
const creatorClient = createCreatorClient({
|
|
55
|
+
chainId: chain.id,
|
|
56
|
+
publicClient: publicClient,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
parameters: request,
|
|
61
|
+
collectionAddress: contractAddress,
|
|
62
|
+
contractExists,
|
|
63
|
+
} = await creatorClient.create1155({
|
|
64
|
+
contract: {
|
|
65
|
+
name: "testContract2",
|
|
66
|
+
uri: demoContractMetadataURI,
|
|
67
|
+
},
|
|
68
|
+
token: {
|
|
69
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
70
|
+
mintToCreatorCount: 3,
|
|
71
|
+
},
|
|
72
|
+
account: creatorAccount,
|
|
73
|
+
});
|
|
74
|
+
expect(contractAddress).to.be.equal(
|
|
75
|
+
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3",
|
|
76
|
+
);
|
|
77
|
+
expect(contractExists).to.be.false;
|
|
78
|
+
const { request: simulateResponse } =
|
|
79
|
+
await publicClient.simulateContract(request);
|
|
80
|
+
const hash = await walletClient.writeContract(simulateResponse);
|
|
81
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
82
|
+
const firstTokenId = getTokenIdFromCreateReceipt(receipt);
|
|
83
|
+
expect(firstTokenId).to.be.equal(1n);
|
|
84
|
+
expect(receipt).not.toBeNull();
|
|
85
|
+
|
|
86
|
+
// creator should have mint to creator count balance
|
|
87
|
+
expect(
|
|
88
|
+
await publicClient.readContract({
|
|
89
|
+
address: contractAddress,
|
|
90
|
+
abi: zoraCreator1155ImplABI,
|
|
91
|
+
functionName: "balanceOf",
|
|
92
|
+
args: [creatorAccount, firstTokenId!],
|
|
93
|
+
}),
|
|
94
|
+
).toBe(3n);
|
|
95
|
+
|
|
96
|
+
const newTokenOnExistingContract = await creatorClient.create1155({
|
|
97
|
+
contract: {
|
|
98
|
+
name: "testContract2",
|
|
99
|
+
uri: demoContractMetadataURI,
|
|
100
|
+
},
|
|
101
|
+
token: {
|
|
102
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
103
|
+
mintToCreatorCount: 2,
|
|
104
|
+
},
|
|
105
|
+
account: creatorAccount,
|
|
106
|
+
});
|
|
107
|
+
expect(newTokenOnExistingContract.collectionAddress).to.be.equal(
|
|
108
|
+
"0xb1A8928dF830C21eD682949Aa8A83C1C215194d3",
|
|
109
|
+
);
|
|
110
|
+
expect(newTokenOnExistingContract.contractExists).to.be.true;
|
|
111
|
+
const { request: simulateRequest } = await publicClient.simulateContract(
|
|
112
|
+
newTokenOnExistingContract.parameters,
|
|
113
|
+
);
|
|
114
|
+
const newHash = await walletClient.writeContract(simulateRequest);
|
|
115
|
+
const newReceipt = await publicClient.waitForTransactionReceipt({
|
|
116
|
+
hash: newHash,
|
|
117
|
+
});
|
|
118
|
+
const tokenId = getTokenIdFromCreateReceipt(newReceipt);
|
|
119
|
+
expect(tokenId).to.be.equal(2n);
|
|
120
|
+
expect(newReceipt).not.toBeNull();
|
|
121
|
+
},
|
|
122
|
+
20 * 1000,
|
|
123
|
+
);
|
|
124
|
+
anvilTest(
|
|
125
|
+
"creates a new token with a create referral address",
|
|
126
|
+
async ({ viemClients: { publicClient, walletClient, chain } }) => {
|
|
127
|
+
const addresses = await walletClient.getAddresses();
|
|
128
|
+
const creatorAddress = addresses[0]!;
|
|
129
|
+
const createReferral = addresses[1]!;
|
|
130
|
+
|
|
131
|
+
const creatorClient = createCreatorClient({
|
|
132
|
+
chainId: chain.id,
|
|
133
|
+
publicClient: publicClient,
|
|
134
|
+
});
|
|
135
|
+
const { parameters: request } = await creatorClient.create1155({
|
|
136
|
+
contract: {
|
|
137
|
+
name: "testContract",
|
|
138
|
+
uri: demoContractMetadataURI,
|
|
139
|
+
},
|
|
140
|
+
token: {
|
|
141
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
142
|
+
createReferral,
|
|
143
|
+
},
|
|
144
|
+
account: creatorAddress,
|
|
145
|
+
});
|
|
146
|
+
const { request: simulationResponse } =
|
|
147
|
+
await publicClient.simulateContract(request);
|
|
148
|
+
const hash = await walletClient.writeContract(simulationResponse);
|
|
149
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
150
|
+
expect(receipt).not.toBeNull();
|
|
151
|
+
expect(receipt.to).to.equal("0xa72724cc3dcef210141a1b84c61824074151dc99");
|
|
152
|
+
expect(getTokenIdFromCreateReceipt(receipt)).to.be.equal(2n);
|
|
153
|
+
|
|
154
|
+
expect(
|
|
155
|
+
await publicClient.readContract({
|
|
156
|
+
abi: zoraCreator1155ImplABI,
|
|
157
|
+
address: "0xa72724cc3dcef210141a1b84c61824074151dc99",
|
|
158
|
+
functionName: "createReferrals",
|
|
159
|
+
args: [2n],
|
|
160
|
+
}),
|
|
161
|
+
).to.be.equal(createReferral);
|
|
162
|
+
},
|
|
163
|
+
20 * 1000,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
anvilTest(
|
|
167
|
+
"creates a new 1155 free mint that can be minted",
|
|
168
|
+
async ({
|
|
169
|
+
viemClients: { testClient, publicClient, walletClient, chain },
|
|
170
|
+
}) => {
|
|
171
|
+
const addresses = await walletClient.getAddresses();
|
|
172
|
+
const creatorAddress = addresses[0]!;
|
|
173
|
+
|
|
174
|
+
const creatorClient = createCreatorClient({
|
|
175
|
+
chainId: chain.id,
|
|
176
|
+
publicClient: publicClient,
|
|
177
|
+
});
|
|
178
|
+
const {
|
|
179
|
+
parameters: request,
|
|
180
|
+
collectionAddress,
|
|
181
|
+
newTokenId,
|
|
182
|
+
newToken,
|
|
183
|
+
minter,
|
|
184
|
+
} = await creatorClient.create1155({
|
|
185
|
+
contract: {
|
|
186
|
+
name: "testContract",
|
|
187
|
+
uri: demoContractMetadataURI,
|
|
188
|
+
},
|
|
189
|
+
token: {
|
|
190
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
191
|
+
},
|
|
192
|
+
account: creatorAddress,
|
|
193
|
+
});
|
|
194
|
+
const { request: createSimulation } =
|
|
195
|
+
await publicClient.simulateContract(request);
|
|
196
|
+
await waitForSuccess(
|
|
197
|
+
await walletClient.writeContract(createSimulation),
|
|
198
|
+
publicClient,
|
|
199
|
+
);
|
|
200
|
+
|
|
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
|
+
const quantityToMint = 5n;
|
|
216
|
+
|
|
217
|
+
// now try to mint a free mint
|
|
218
|
+
const minterAddress = addresses[1]!;
|
|
219
|
+
|
|
220
|
+
await testClient.setBalance({
|
|
221
|
+
address: minterAddress,
|
|
222
|
+
value: parseEther("10"),
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const mintParams = makePrepareMint1155TokenParams({
|
|
226
|
+
tokenContract: collectionAddress,
|
|
227
|
+
minterAccount: minterAddress,
|
|
228
|
+
tokenId: newTokenId,
|
|
229
|
+
salesConfigAndTokenInfo,
|
|
230
|
+
quantityToMint,
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const { request: collectSimulation } =
|
|
234
|
+
await publicClient.simulateContract(mintParams);
|
|
235
|
+
await waitForSuccess(
|
|
236
|
+
await walletClient.writeContract(collectSimulation),
|
|
237
|
+
publicClient,
|
|
238
|
+
);
|
|
239
|
+
},
|
|
240
|
+
20 * 1000,
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
anvilTest(
|
|
244
|
+
"creates a new 1155 paid mint that can be minted",
|
|
245
|
+
async ({
|
|
246
|
+
viemClients: { testClient, publicClient, walletClient, chain },
|
|
247
|
+
}) => {
|
|
248
|
+
const addresses = await walletClient.getAddresses();
|
|
249
|
+
const creatorAddress = addresses[0]!;
|
|
250
|
+
|
|
251
|
+
const creatorClient = createCreatorClient({
|
|
252
|
+
chainId: chain.id,
|
|
253
|
+
publicClient: publicClient,
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const pricePerToken = parseEther("0.01");
|
|
257
|
+
|
|
258
|
+
const {
|
|
259
|
+
parameters: request,
|
|
260
|
+
collectionAddress,
|
|
261
|
+
newTokenId,
|
|
262
|
+
newToken,
|
|
263
|
+
minter,
|
|
264
|
+
} = await creatorClient.create1155({
|
|
265
|
+
contract: {
|
|
266
|
+
name: "testContract",
|
|
267
|
+
uri: demoContractMetadataURI,
|
|
268
|
+
},
|
|
269
|
+
token: {
|
|
270
|
+
tokenMetadataURI: demoTokenMetadataURI,
|
|
271
|
+
salesConfig: {
|
|
272
|
+
pricePerToken,
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
account: creatorAddress,
|
|
276
|
+
});
|
|
277
|
+
const { request: createSimulation } =
|
|
278
|
+
await publicClient.simulateContract(request);
|
|
279
|
+
await waitForSuccess(
|
|
280
|
+
await walletClient.writeContract(createSimulation),
|
|
281
|
+
publicClient,
|
|
282
|
+
);
|
|
283
|
+
|
|
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
|
+
const quantityToMint = 5n;
|
|
299
|
+
|
|
300
|
+
// now try to mint a free mint
|
|
301
|
+
const minterAddress = addresses[1]!;
|
|
302
|
+
|
|
303
|
+
await testClient.setBalance({
|
|
304
|
+
address: minterAddress,
|
|
305
|
+
value: parseEther("10"),
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
const mintParams = makePrepareMint1155TokenParams({
|
|
309
|
+
tokenContract: collectionAddress,
|
|
310
|
+
minterAccount: minterAddress,
|
|
311
|
+
tokenId: newTokenId,
|
|
312
|
+
salesConfigAndTokenInfo,
|
|
313
|
+
quantityToMint,
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const { request: collectSimulation } =
|
|
317
|
+
await publicClient.simulateContract(mintParams);
|
|
318
|
+
await waitForSuccess(
|
|
319
|
+
await walletClient.writeContract(collectSimulation),
|
|
320
|
+
publicClient,
|
|
321
|
+
);
|
|
322
|
+
},
|
|
323
|
+
20 * 1000,
|
|
324
|
+
);
|
|
325
|
+
});
|
|
@@ -37,23 +37,6 @@ export const getTokenIdFromCreateReceipt = (
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
export const getContractAddressFromCreateReceipt = (
|
|
41
|
-
receipt: TransactionReceipt,
|
|
42
|
-
): Address | undefined => {
|
|
43
|
-
for (const data of receipt.logs) {
|
|
44
|
-
try {
|
|
45
|
-
const decodedLog = decodeEventLog({
|
|
46
|
-
abi: zoraCreator1155FactoryImplABI,
|
|
47
|
-
eventName: "SetupNewContract",
|
|
48
|
-
...data,
|
|
49
|
-
});
|
|
50
|
-
if (decodedLog && decodedLog.eventName === "SetupNewContract") {
|
|
51
|
-
return decodedLog.args.newContract;
|
|
52
|
-
}
|
|
53
|
-
} catch (err: any) {}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
40
|
type CreateNew1155TokenReturn = {
|
|
58
41
|
parameters: SimulateContractParameters<
|
|
59
42
|
any,
|
|
@@ -4,17 +4,13 @@ import {
|
|
|
4
4
|
zoraCreator1155ImplABI,
|
|
5
5
|
zoraCreatorFixedPriceSaleStrategyABI,
|
|
6
6
|
zoraCreatorFixedPriceSaleStrategyAddress,
|
|
7
|
-
zoraCreatorMerkleMinterStrategyABI,
|
|
8
|
-
zoraCreatorMerkleMinterStrategyAddress,
|
|
9
7
|
} from "@zoralabs/protocol-deployments";
|
|
10
8
|
import { Address, encodeFunctionData, zeroAddress, Hex } from "viem";
|
|
11
9
|
import * as semver from "semver";
|
|
12
10
|
import {
|
|
13
|
-
AllowlistData,
|
|
14
11
|
ContractProps,
|
|
15
12
|
CreateNew1155TokenProps,
|
|
16
13
|
New1155Token,
|
|
17
|
-
SalesConfigOrAllowList,
|
|
18
14
|
SalesConfigParamsType,
|
|
19
15
|
} from "./types";
|
|
20
16
|
import { OPEN_EDITION_MINT_SIZE } from "src/constants";
|
|
@@ -28,15 +24,16 @@ type SetupMintersProps = {
|
|
|
28
24
|
tokenId: bigint;
|
|
29
25
|
chainId: number;
|
|
30
26
|
fundsRecipient: Address;
|
|
31
|
-
|
|
27
|
+
salesConfig: Concrete<SalesConfigParamsType>;
|
|
32
28
|
};
|
|
33
29
|
|
|
34
30
|
// Sales end forever amount (uint64 max)
|
|
35
|
-
const SALE_END_FOREVER = 18446744073709551615n;
|
|
36
31
|
|
|
37
32
|
const saleSettingsOrDefault = (
|
|
38
33
|
saleSettings?: SalesConfigParamsType,
|
|
39
34
|
): Concrete<SalesConfigParamsType> => {
|
|
35
|
+
const SALE_END_FOREVER = 18446744073709551615n;
|
|
36
|
+
|
|
40
37
|
const DEFAULT_SALE_SETTINGS: Concrete<SalesConfigParamsType> = {
|
|
41
38
|
currency: zeroAddress,
|
|
42
39
|
// Free Mint
|
|
@@ -54,36 +51,6 @@ const saleSettingsOrDefault = (
|
|
|
54
51
|
};
|
|
55
52
|
};
|
|
56
53
|
|
|
57
|
-
const allowListWithDefaults = (allowlist: AllowlistData) => {
|
|
58
|
-
const defaultAllowListSettings: Concrete<
|
|
59
|
-
Omit<AllowlistData, "presaleMerkleRoot">
|
|
60
|
-
> = {
|
|
61
|
-
// Sale start time – defaults to beginning of unix time
|
|
62
|
-
saleStart: 0n,
|
|
63
|
-
// This is the end of uint64, plenty of time
|
|
64
|
-
saleEnd: SALE_END_FOREVER,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
...defaultAllowListSettings,
|
|
69
|
-
...allowlist,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const getSalesConfigOrAllowListWithDefaults = ({
|
|
74
|
-
salesConfig,
|
|
75
|
-
allowlist,
|
|
76
|
-
}: Pick<CreateNew1155TokenProps, "salesConfig" | "allowlist">) => {
|
|
77
|
-
if (!allowlist) {
|
|
78
|
-
return {
|
|
79
|
-
salesConfig: saleSettingsOrDefault(salesConfig),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
allowlist: allowListWithDefaults(allowlist),
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
54
|
function applyNew1155Defaults(
|
|
88
55
|
props: CreateNew1155TokenProps,
|
|
89
56
|
ownerAddress: Address,
|
|
@@ -101,11 +68,8 @@ function applyNew1155Defaults(
|
|
|
101
68
|
? OPEN_EDITION_MINT_SIZE
|
|
102
69
|
: BigInt(props.maxSupply),
|
|
103
70
|
royaltyBPS: props.royaltyBPS || 1000,
|
|
71
|
+
salesConfig: saleSettingsOrDefault(props.salesConfig),
|
|
104
72
|
tokenMetadataURI: props.tokenMetadataURI,
|
|
105
|
-
salesConfigOrAllowList: getSalesConfigOrAllowListWithDefaults({
|
|
106
|
-
salesConfig: props.salesConfig,
|
|
107
|
-
allowlist: props.allowlist,
|
|
108
|
-
}),
|
|
109
73
|
};
|
|
110
74
|
}
|
|
111
75
|
|
|
@@ -223,84 +187,24 @@ function setupFixedPriceMinter({
|
|
|
223
187
|
};
|
|
224
188
|
}
|
|
225
189
|
|
|
226
|
-
function
|
|
227
|
-
chainId,
|
|
228
|
-
tokenId: nextTokenId,
|
|
229
|
-
allowlist,
|
|
230
|
-
fundsRecipient,
|
|
231
|
-
}: {
|
|
232
|
-
chainId: number;
|
|
233
|
-
tokenId: bigint;
|
|
234
|
-
allowlist: Concrete<AllowlistData>;
|
|
235
|
-
fundsRecipient: Address;
|
|
236
|
-
}) {
|
|
237
|
-
const merkleSaleStrategyAddress =
|
|
238
|
-
zoraCreatorMerkleMinterStrategyAddress[
|
|
239
|
-
chainId as keyof typeof zoraCreatorMerkleMinterStrategyAddress
|
|
240
|
-
];
|
|
241
|
-
|
|
242
|
-
const merkleApproval = encodeFunctionData({
|
|
243
|
-
abi: zoraCreator1155ImplABI,
|
|
244
|
-
functionName: "addPermission",
|
|
245
|
-
args: [nextTokenId, merkleSaleStrategyAddress, PERMISSION_BITS.MINTER],
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
const merkleRoot = allowlist.presaleMerkleRoot.startsWith("0x")
|
|
249
|
-
? allowlist.presaleMerkleRoot
|
|
250
|
-
: (`0x${allowlist.presaleMerkleRoot}` as Hex);
|
|
251
|
-
|
|
252
|
-
const saleData = encodeFunctionData({
|
|
253
|
-
abi: zoraCreatorMerkleMinterStrategyABI,
|
|
254
|
-
functionName: "setSale",
|
|
255
|
-
args: [
|
|
256
|
-
BigInt(nextTokenId),
|
|
257
|
-
{
|
|
258
|
-
presaleStart: allowlist.saleStart,
|
|
259
|
-
presaleEnd: allowlist.saleEnd,
|
|
260
|
-
merkleRoot,
|
|
261
|
-
fundsRecipient: fundsRecipient,
|
|
262
|
-
},
|
|
263
|
-
],
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
const callSaleMerkle = encodeFunctionData({
|
|
267
|
-
abi: zoraCreator1155ImplABI,
|
|
268
|
-
functionName: "callSale",
|
|
269
|
-
args: [BigInt(nextTokenId), merkleSaleStrategyAddress, saleData],
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
return {
|
|
273
|
-
minter: merkleSaleStrategyAddress,
|
|
274
|
-
setupActions: [merkleApproval, callSaleMerkle],
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export function setupMinters({
|
|
279
|
-
salesConfigOrAllowList: { salesConfig, allowlist },
|
|
280
|
-
...rest
|
|
281
|
-
}: SetupMintersProps): {
|
|
190
|
+
export function setupMinters({ salesConfig, ...rest }: SetupMintersProps): {
|
|
282
191
|
minter: Address;
|
|
283
192
|
setupActions: Hex[];
|
|
284
193
|
} {
|
|
285
|
-
if (salesConfig)
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
194
|
+
if (!salesConfig) throw new Error("No sales config for token");
|
|
195
|
+
const { currency: currencyAddress } = salesConfig;
|
|
196
|
+
|
|
197
|
+
if (currencyAddress === zeroAddress) {
|
|
198
|
+
return setupFixedPriceMinter({
|
|
199
|
+
...salesConfig,
|
|
200
|
+
...rest,
|
|
201
|
+
});
|
|
202
|
+
} else {
|
|
203
|
+
return setupErc20Minter({
|
|
204
|
+
...salesConfig,
|
|
205
|
+
...rest,
|
|
206
|
+
});
|
|
299
207
|
}
|
|
300
|
-
return setupAllowListMinter({
|
|
301
|
-
allowlist: allowlist as Concrete<AllowlistData>,
|
|
302
|
-
...rest,
|
|
303
|
-
});
|
|
304
208
|
}
|
|
305
209
|
|
|
306
210
|
function buildSetupNewToken({
|
|
@@ -431,8 +335,7 @@ export function constructCreate1155TokenCalls(
|
|
|
431
335
|
tokenId: nextTokenId,
|
|
432
336
|
chainId,
|
|
433
337
|
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
434
|
-
|
|
435
|
-
new1155TokenPropsWithDefaults.salesConfigOrAllowList,
|
|
338
|
+
salesConfig: new1155TokenPropsWithDefaults.salesConfig,
|
|
436
339
|
});
|
|
437
340
|
|
|
438
341
|
const adminMintCall = makeAdminMintCall({
|
package/src/create/types.ts
CHANGED
|
@@ -32,54 +32,26 @@ export type CreateNew1155Params = {
|
|
|
32
32
|
token: CreateNew1155TokenProps;
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
export
|
|
36
|
-
saleStart?: bigint;
|
|
37
|
-
saleEnd?: bigint;
|
|
38
|
-
presaleMerkleRoot: `0x${string}`;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export type CreateNew1155TokenProps = {
|
|
35
|
+
export interface CreateNew1155TokenProps {
|
|
42
36
|
maxSupply?: bigint | number;
|
|
43
37
|
tokenMetadataURI: string;
|
|
44
38
|
royaltyBPS?: number;
|
|
39
|
+
salesConfig?: SalesConfigParamsType;
|
|
45
40
|
createReferral?: Address;
|
|
46
41
|
mintToCreatorCount?: number;
|
|
47
42
|
payoutRecipient?: Address;
|
|
48
|
-
}
|
|
49
|
-
| {
|
|
50
|
-
salesConfig: SalesConfigParamsType;
|
|
51
|
-
allowlist?: undefined;
|
|
52
|
-
}
|
|
53
|
-
| {
|
|
54
|
-
salesConfig?: undefined;
|
|
55
|
-
allowlist: AllowlistData;
|
|
56
|
-
}
|
|
57
|
-
| {
|
|
58
|
-
salesConfig?: undefined;
|
|
59
|
-
allowlist?: undefined;
|
|
60
|
-
}
|
|
61
|
-
);
|
|
43
|
+
}
|
|
62
44
|
|
|
63
45
|
export interface ContractProps {
|
|
64
46
|
nextTokenId: bigint;
|
|
65
47
|
contractVersion: string;
|
|
66
48
|
}
|
|
67
49
|
|
|
68
|
-
export type SalesConfigOrAllowList =
|
|
69
|
-
| {
|
|
70
|
-
salesConfig: Concrete<SalesConfigParamsType>;
|
|
71
|
-
allowlist?: undefined;
|
|
72
|
-
}
|
|
73
|
-
| {
|
|
74
|
-
salesConfig: undefined;
|
|
75
|
-
allowlist: Concrete<AllowlistData>;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
50
|
export type New1155Token = {
|
|
79
51
|
payoutRecipient: Address;
|
|
80
52
|
createReferral: Address;
|
|
81
53
|
maxSupply: bigint;
|
|
82
54
|
royaltyBPS: number;
|
|
55
|
+
salesConfig: Concrete<SalesConfigParamsType>;
|
|
83
56
|
tokenMetadataURI: string;
|
|
84
|
-
salesConfigOrAllowList: SalesConfigOrAllowList;
|
|
85
57
|
};
|