@zoralabs/protocol-sdk 0.12.2 → 0.13.1
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 +13 -0
- package/dist/create/types.d.ts +1 -1
- package/dist/create/types.d.ts.map +1 -1
- package/dist/fixtures/contract-setup.d.ts.map +1 -1
- package/dist/index.cjs +2 -405
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -430
- package/dist/index.js.map +1 -1
- package/dist/premint/premint-api-client.d.ts +0 -2
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +11 -86
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +3 -84
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +0 -2
- package/dist/sdk.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/comments/comments.test.ts +18 -10
- package/src/create/create-client.test.ts +9 -5
- package/src/create/create-client.ts +2 -2
- package/src/create/types.ts +1 -1
- package/src/fixtures/contract-setup.ts +14 -11
- package/src/mint/mint-client.test.ts +5 -1
- package/src/premint/premint-api-client.ts +0 -29
- package/src/premint/premint-client.test.ts +17 -197
- package/src/premint/premint-client.ts +11 -324
- package/src/premint/preminter.test.ts +1 -158
- package/src/premint/preminter.ts +2 -273
- package/src/sdk.ts +0 -4
|
@@ -2,17 +2,12 @@ import { zoraSepolia } from "viem/chains";
|
|
|
2
2
|
import { describe, expect, vi } from "vitest";
|
|
3
3
|
|
|
4
4
|
import { PremintConfigVersion } from "./contract-types";
|
|
5
|
-
import {
|
|
6
|
-
getDefaultFixedPriceMinterAddress,
|
|
7
|
-
getPremintCollectionAddress,
|
|
8
|
-
} from "./preminter";
|
|
9
5
|
import { forkUrls, makeAnvilTest } from "src/anvil";
|
|
10
|
-
import {
|
|
11
|
-
ContractCreationConfig,
|
|
12
|
-
PremintConfigV2,
|
|
13
|
-
} from "@zoralabs/protocol-deployments";
|
|
14
6
|
import { PremintAPIClient } from "./premint-api-client";
|
|
15
|
-
import {
|
|
7
|
+
import { mint } from "../mint/mint-client";
|
|
8
|
+
import { getDataFromPremintReceipt } from "./premint-client";
|
|
9
|
+
import { zoraCreatorFixedPriceSaleStrategyAddress } from "@zoralabs/protocol-deployments";
|
|
10
|
+
import { Address } from "viem";
|
|
16
11
|
|
|
17
12
|
const anvilTest = makeAnvilTest({
|
|
18
13
|
forkUrl: forkUrls.zoraSepolia,
|
|
@@ -20,6 +15,12 @@ const anvilTest = makeAnvilTest({
|
|
|
20
15
|
anvilChainId: zoraSepolia.id,
|
|
21
16
|
});
|
|
22
17
|
|
|
18
|
+
function getDefaultFixedPriceMinterAddress(chainId: number): Address {
|
|
19
|
+
return zoraCreatorFixedPriceSaleStrategyAddress[
|
|
20
|
+
chainId as keyof typeof zoraCreatorFixedPriceSaleStrategyAddress
|
|
21
|
+
]!;
|
|
22
|
+
}
|
|
23
|
+
|
|
23
24
|
describe("ZoraCreator1155Premint", () => {
|
|
24
25
|
anvilTest(
|
|
25
26
|
"can mint premints",
|
|
@@ -67,27 +68,25 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
67
68
|
|
|
68
69
|
premintApiClient.postSignature = vi.fn();
|
|
69
70
|
|
|
70
|
-
const
|
|
71
|
-
chainId: chain.id,
|
|
72
|
-
publicClient,
|
|
73
|
-
premintGetter: premintApiClient,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
const { parameters } = await collectorClient.mint({
|
|
71
|
+
const { parameters } = await mint({
|
|
77
72
|
mintType: "premint",
|
|
78
73
|
minterAccount: deployerAccount!,
|
|
79
74
|
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
80
75
|
uid: 3,
|
|
81
76
|
quantityToMint: 1,
|
|
82
77
|
mintComment: "",
|
|
78
|
+
publicClient,
|
|
79
|
+
premintGetter: premintApiClient,
|
|
83
80
|
});
|
|
84
81
|
const { request: simulateRequest } =
|
|
85
82
|
await publicClient.simulateContract(parameters);
|
|
86
83
|
const hash = await walletClient.writeContract(simulateRequest);
|
|
87
84
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
88
85
|
|
|
89
|
-
const { premintedLog, urls } =
|
|
90
|
-
|
|
86
|
+
const { premintedLog, urls } = getDataFromPremintReceipt(
|
|
87
|
+
receipt,
|
|
88
|
+
publicClient.chain.id,
|
|
89
|
+
);
|
|
91
90
|
|
|
92
91
|
expect(urls).toEqual({
|
|
93
92
|
explorer:
|
|
@@ -110,182 +109,3 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
110
109
|
20 * 1000,
|
|
111
110
|
);
|
|
112
111
|
});
|
|
113
|
-
|
|
114
|
-
describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
115
|
-
anvilTest(
|
|
116
|
-
"can sign and submit new premints on new contracts",
|
|
117
|
-
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
118
|
-
const [creatorAccount, createReferralAccount] =
|
|
119
|
-
await walletClient.getAddresses();
|
|
120
|
-
const premintApiClient = new PremintAPIClient(chain.id);
|
|
121
|
-
|
|
122
|
-
premintApiClient.getNextUID = vi
|
|
123
|
-
.fn<typeof premintApiClient.getNextUID>()
|
|
124
|
-
.mockResolvedValue(3);
|
|
125
|
-
premintApiClient.postSignature = vi
|
|
126
|
-
.fn<typeof premintApiClient.postSignature>()
|
|
127
|
-
// @ts-ignore
|
|
128
|
-
.mockResolvedValue({});
|
|
129
|
-
|
|
130
|
-
const creatorClient = createCreatorClient({
|
|
131
|
-
chainId: chain.id,
|
|
132
|
-
premintApi: premintApiClient,
|
|
133
|
-
publicClient,
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const { signAndSubmit } = await creatorClient.createPremint({
|
|
137
|
-
contract: {
|
|
138
|
-
contractAdmin: creatorAccount!,
|
|
139
|
-
contractName: "Testing Contract Premint V2",
|
|
140
|
-
contractURI:
|
|
141
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
142
|
-
},
|
|
143
|
-
token: {
|
|
144
|
-
tokenURI:
|
|
145
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
146
|
-
payoutRecipient: creatorAccount!,
|
|
147
|
-
createReferral: createReferralAccount,
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
await signAndSubmit({
|
|
152
|
-
account: creatorAccount!,
|
|
153
|
-
walletClient,
|
|
154
|
-
checkSignature: true,
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
const expectedPostSignatureArgs: Parameters<
|
|
158
|
-
typeof premintApiClient.postSignature
|
|
159
|
-
>[0] = {
|
|
160
|
-
contract: {
|
|
161
|
-
contractAdmin: creatorAccount!,
|
|
162
|
-
contractName: "Testing Contract Premint V2",
|
|
163
|
-
contractURI:
|
|
164
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
165
|
-
},
|
|
166
|
-
contractAddress: undefined,
|
|
167
|
-
premintConfig: {
|
|
168
|
-
deleted: false,
|
|
169
|
-
tokenConfig: {
|
|
170
|
-
fixedPriceMinter: "0x6d28164C3CE04A190D5F9f0f8881fc807EAD975A",
|
|
171
|
-
maxSupply: 18446744073709551615n,
|
|
172
|
-
maxTokensPerAddress: 0n,
|
|
173
|
-
mintDuration: 0n,
|
|
174
|
-
mintStart: 0n,
|
|
175
|
-
pricePerToken: 0n,
|
|
176
|
-
royaltyBPS: 1000,
|
|
177
|
-
payoutRecipient: creatorAccount!,
|
|
178
|
-
createReferral: createReferralAccount!,
|
|
179
|
-
tokenURI:
|
|
180
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
181
|
-
},
|
|
182
|
-
uid: 3,
|
|
183
|
-
version: 0,
|
|
184
|
-
},
|
|
185
|
-
premintConfigVersion: PremintConfigVersion.V2,
|
|
186
|
-
signature:
|
|
187
|
-
"0xfe5725c05754ad17a73cc9706bf940e30bd7b4a674bb1b283a66a1cc87022c8c13fcf8989f9feb675f8932a6a8ddb8d16af2abef28fa2fff3282487ef5385b3d1b",
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
expect(premintApiClient.postSignature).toHaveBeenCalledWith(
|
|
191
|
-
expectedPostSignatureArgs,
|
|
192
|
-
);
|
|
193
|
-
},
|
|
194
|
-
20 * 1000,
|
|
195
|
-
);
|
|
196
|
-
|
|
197
|
-
anvilTest(
|
|
198
|
-
"can mint premints with additional admins",
|
|
199
|
-
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
200
|
-
const [deployerAccount, creatorAccount, additionalAdmin] =
|
|
201
|
-
await walletClient.getAddresses();
|
|
202
|
-
|
|
203
|
-
const premintApiClient = new PremintAPIClient(chain.id);
|
|
204
|
-
|
|
205
|
-
const collectorClient = createCollectorClient({
|
|
206
|
-
chainId: chain.id,
|
|
207
|
-
publicClient,
|
|
208
|
-
premintGetter: premintApiClient,
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
const creatorClient = createCreatorClient({
|
|
212
|
-
chainId: chain.id,
|
|
213
|
-
publicClient,
|
|
214
|
-
premintApi: premintApiClient,
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
const collection: ContractCreationConfig = {
|
|
218
|
-
contractAdmin: creatorAccount!,
|
|
219
|
-
contractName: "Testing Contract",
|
|
220
|
-
contractURI:
|
|
221
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
222
|
-
additionalAdmins: [additionalAdmin!],
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const collectionAddress = await getPremintCollectionAddress({
|
|
226
|
-
contract: collection,
|
|
227
|
-
publicClient,
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
const { premintConfig, typedDataDefinition } =
|
|
231
|
-
await creatorClient.createPremint({
|
|
232
|
-
contract: collection,
|
|
233
|
-
token: {
|
|
234
|
-
tokenURI:
|
|
235
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
236
|
-
payoutRecipient: creatorAccount!,
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
const signature = await walletClient.signTypedData({
|
|
241
|
-
...typedDataDefinition,
|
|
242
|
-
account: additionalAdmin!,
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
premintApiClient.get = vi
|
|
246
|
-
.fn<typeof premintApiClient.get>()
|
|
247
|
-
.mockResolvedValue({
|
|
248
|
-
collection,
|
|
249
|
-
collectionAddress,
|
|
250
|
-
premint: {
|
|
251
|
-
premintConfig: premintConfig as PremintConfigV2,
|
|
252
|
-
premintConfigVersion: PremintConfigVersion.V2,
|
|
253
|
-
},
|
|
254
|
-
signer: collection.contractAdmin,
|
|
255
|
-
signature,
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
const { parameters } = await collectorClient.mint({
|
|
259
|
-
mintType: "premint",
|
|
260
|
-
uid: premintConfig.uid,
|
|
261
|
-
minterAccount: deployerAccount!,
|
|
262
|
-
tokenContract: collectionAddress,
|
|
263
|
-
quantityToMint: 1,
|
|
264
|
-
mintComment: "",
|
|
265
|
-
});
|
|
266
|
-
const { request: simulateRequest } =
|
|
267
|
-
await publicClient.simulateContract(parameters);
|
|
268
|
-
const hash = await walletClient.writeContract(simulateRequest);
|
|
269
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
270
|
-
|
|
271
|
-
const { premintedLog, urls } =
|
|
272
|
-
collectorClient.getCollectDataFromPremintReceipt(receipt);
|
|
273
|
-
|
|
274
|
-
expect(urls).toEqual({
|
|
275
|
-
explorer: `https://undefined/token/${collectionAddress}/instance/1`,
|
|
276
|
-
zoraCollect: `https://testnet.zora.co/collect/zsep:${collectionAddress}/1`,
|
|
277
|
-
zoraManage: `https://testnet.zora.co/collect/zsep:${collectionAddress}/1`,
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
expect(premintedLog).toEqual({
|
|
281
|
-
contractAddress: collectionAddress,
|
|
282
|
-
createdNewContract: expect.any(Boolean),
|
|
283
|
-
minter: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
284
|
-
quantityMinted: 1n,
|
|
285
|
-
tokenId: 1n,
|
|
286
|
-
uid: premintConfig.uid,
|
|
287
|
-
});
|
|
288
|
-
},
|
|
289
|
-
20 * 1000,
|
|
290
|
-
);
|
|
291
|
-
});
|
|
@@ -9,8 +9,6 @@ import type {
|
|
|
9
9
|
WalletClient,
|
|
10
10
|
} from "viem";
|
|
11
11
|
import {
|
|
12
|
-
PremintConfigAndVersion,
|
|
13
|
-
TokenConfigWithVersion,
|
|
14
12
|
encodePremintConfig,
|
|
15
13
|
zoraCreator1155PremintExecutorImplABI,
|
|
16
14
|
} from "@zoralabs/protocol-deployments";
|
|
@@ -18,12 +16,8 @@ import {
|
|
|
18
16
|
getPremintCollectionAddress,
|
|
19
17
|
isAuthorizedToCreatePremint,
|
|
20
18
|
getPremintExecutorAddress,
|
|
21
|
-
applyUpdateToPremint,
|
|
22
|
-
makeNewPremint,
|
|
23
|
-
supportedPremintVersions,
|
|
24
19
|
getPremintMintCosts,
|
|
25
20
|
makeMintRewardsRecipient,
|
|
26
|
-
getDefaultFixedPriceMinterAddress,
|
|
27
21
|
emptyContractCreationConfig,
|
|
28
22
|
defaultAdditionalAdmins,
|
|
29
23
|
toContractCreationConfigOrAddress,
|
|
@@ -32,25 +26,18 @@ import {
|
|
|
32
26
|
import {
|
|
33
27
|
PremintConfigVersion,
|
|
34
28
|
ContractCreationConfig,
|
|
35
|
-
TokenCreationConfigV1,
|
|
36
|
-
TokenCreationConfigV2,
|
|
37
|
-
TokenCreationConfig,
|
|
38
29
|
PremintConfigWithVersion,
|
|
39
30
|
PremintMintArguments,
|
|
40
31
|
premintTypedDataDefinition,
|
|
41
32
|
} from "@zoralabs/protocol-deployments";
|
|
42
33
|
import { IPremintAPI, IPremintGetter } from "./premint-api-client";
|
|
43
34
|
import type { DecodeEventLogReturnType } from "viem";
|
|
44
|
-
import { OPEN_EDITION_MINT_SIZE } from "../constants";
|
|
45
35
|
import {
|
|
46
36
|
makeContractParameters,
|
|
47
37
|
mintRecipientOrAccount,
|
|
48
38
|
PublicClient,
|
|
49
39
|
} from "src/utils";
|
|
50
|
-
import {
|
|
51
|
-
ContractCreationConfigAndAddress,
|
|
52
|
-
ContractCreationConfigOrAddress,
|
|
53
|
-
} from "./contract-types";
|
|
40
|
+
import { ContractCreationConfigAndAddress } from "./contract-types";
|
|
54
41
|
import {
|
|
55
42
|
MakeMintParametersArgumentsBase,
|
|
56
43
|
MakePremintMintParametersArguments,
|
|
@@ -65,143 +52,19 @@ type PremintedV2LogType = DecodeEventLogReturnType<
|
|
|
65
52
|
"PremintedV2"
|
|
66
53
|
>["args"];
|
|
67
54
|
|
|
68
|
-
|
|
55
|
+
type URLSReturnType = {
|
|
69
56
|
explorer: null | string;
|
|
70
57
|
zoraCollect: null | string;
|
|
71
58
|
zoraManage: null | string;
|
|
72
59
|
};
|
|
73
60
|
|
|
74
|
-
export const defaultTokenConfigV1MintArguments = (): Omit<
|
|
75
|
-
TokenCreationConfigV1,
|
|
76
|
-
"fixedPriceMinter" | "tokenURI" | "royaltyRecipient"
|
|
77
|
-
> => ({
|
|
78
|
-
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
79
|
-
maxTokensPerAddress: 0n,
|
|
80
|
-
pricePerToken: 0n,
|
|
81
|
-
mintDuration: 0n,
|
|
82
|
-
mintStart: 0n,
|
|
83
|
-
royaltyMintSchedule: 0,
|
|
84
|
-
royaltyBPS: 1000, // 10%,
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const pickTokenConfigV1 = (tokenConfig: TokenConfigInput) => ({
|
|
88
|
-
maxSupply: tokenConfig.maxSupply,
|
|
89
|
-
maxTokensPerAddress: tokenConfig.maxTokensPerAddress,
|
|
90
|
-
pricePerToken: tokenConfig.pricePerToken,
|
|
91
|
-
mintDuration: tokenConfig.mintDuration,
|
|
92
|
-
mintStart: tokenConfig.mintStart,
|
|
93
|
-
royaltyBPS: tokenConfig.royaltyBPS,
|
|
94
|
-
tokenURI: tokenConfig.tokenURI,
|
|
95
|
-
royaltyRecipient: tokenConfig.payoutRecipient,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const pickTokenConfigV2 = (tokenConfig: TokenConfigInput) => ({
|
|
99
|
-
maxSupply: tokenConfig.maxSupply,
|
|
100
|
-
maxTokensPerAddress: tokenConfig.maxTokensPerAddress,
|
|
101
|
-
pricePerToken: tokenConfig.pricePerToken,
|
|
102
|
-
mintDuration: tokenConfig.mintDuration,
|
|
103
|
-
mintStart: tokenConfig.mintStart,
|
|
104
|
-
royaltyBPS: tokenConfig.royaltyBPS,
|
|
105
|
-
tokenURI: tokenConfig.tokenURI,
|
|
106
|
-
payoutRecipient: tokenConfig.payoutRecipient,
|
|
107
|
-
createReferral: tokenConfig.createReferral || zeroAddress,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const tokenConfigV1WithDefault = (
|
|
111
|
-
tokenConfig: TokenConfigInput,
|
|
112
|
-
fixedPriceMinter: Address,
|
|
113
|
-
): TokenCreationConfigV1 => ({
|
|
114
|
-
...pickTokenConfigV1(tokenConfig),
|
|
115
|
-
...defaultTokenConfigV1MintArguments(),
|
|
116
|
-
fixedPriceMinter,
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const tokenConfigV2WithDefault = (
|
|
120
|
-
tokenConfig: TokenConfigInput,
|
|
121
|
-
fixedPriceMinter: Address,
|
|
122
|
-
): TokenCreationConfigV2 => ({
|
|
123
|
-
...pickTokenConfigV2(tokenConfig),
|
|
124
|
-
...defaultTokenConfigV2MintArguments(),
|
|
125
|
-
fixedPriceMinter,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
export const defaultTokenConfigV2MintArguments = (): Omit<
|
|
129
|
-
TokenCreationConfigV2,
|
|
130
|
-
"fixedPriceMinter" | "tokenURI" | "payoutRecipient" | "createReferral"
|
|
131
|
-
> => ({
|
|
132
|
-
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
133
|
-
maxTokensPerAddress: 0n,
|
|
134
|
-
pricePerToken: 0n,
|
|
135
|
-
mintDuration: 0n,
|
|
136
|
-
mintStart: 0n,
|
|
137
|
-
royaltyBPS: 1000, // 10%,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
type TokenConfigInput = {
|
|
141
|
-
/** Metadata URI of the token to create. */
|
|
142
|
-
tokenURI: string;
|
|
143
|
-
/** Account to receive creator rewards if it's a free mint, and token price value if its a paid mint. Defaults to the premint signing account. */
|
|
144
|
-
payoutRecipient: Address;
|
|
145
|
-
/** Optional: account to receive the create referral award. */
|
|
146
|
-
createReferral?: Address;
|
|
147
|
-
/** Optional: max supply of tokens that can be minted. Defaults to unlimited. */
|
|
148
|
-
maxSupply?: bigint;
|
|
149
|
-
/** Optional: max tokens that can be minted for an address, 0 if unlimited. Defaults to unlimited. */
|
|
150
|
-
maxTokensPerAddress?: bigint;
|
|
151
|
-
/** Optional: price per token, if this is a paid mint. 0 if a free mint. Defaults to 0, or a free mint. */
|
|
152
|
-
pricePerToken?: bigint;
|
|
153
|
-
/** Optional: duration of the mint, starting from the time the premint is brought onchain. 0 for infinite. Defaults to infinite. */
|
|
154
|
-
mintDuration?: bigint;
|
|
155
|
-
/** Optional: earliest time the premint can be brought onchain and minted. 0 for immediately. Defaults to immediately. */
|
|
156
|
-
mintStart?: bigint;
|
|
157
|
-
/** Optional: The royalty amount in basis points for secondary sales, in basis points. Defaults to 1000. */
|
|
158
|
-
royaltyBPS?: number;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const makeTokenConfigWithDefaults = ({
|
|
162
|
-
chainId,
|
|
163
|
-
tokenCreationConfig,
|
|
164
|
-
supportedPremintVersions,
|
|
165
|
-
}: {
|
|
166
|
-
chainId: number;
|
|
167
|
-
tokenCreationConfig: TokenConfigInput;
|
|
168
|
-
supportedPremintVersions: PremintConfigVersion[];
|
|
169
|
-
}): TokenConfigWithVersion<
|
|
170
|
-
PremintConfigVersion.V1 | PremintConfigVersion.V2
|
|
171
|
-
> => {
|
|
172
|
-
const fixedPriceMinter = getDefaultFixedPriceMinterAddress(chainId);
|
|
173
|
-
|
|
174
|
-
if (!supportedPremintVersions.includes(PremintConfigVersion.V2)) {
|
|
175
|
-
// we need to return a token config v1
|
|
176
|
-
if (tokenCreationConfig.createReferral) {
|
|
177
|
-
throw new Error("Contract does not support create referral");
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
premintConfigVersion: PremintConfigVersion.V1,
|
|
182
|
-
tokenConfig: tokenConfigV1WithDefault(
|
|
183
|
-
tokenCreationConfig,
|
|
184
|
-
fixedPriceMinter,
|
|
185
|
-
),
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return {
|
|
190
|
-
premintConfigVersion: PremintConfigVersion.V2,
|
|
191
|
-
tokenConfig: tokenConfigV2WithDefault(
|
|
192
|
-
tokenCreationConfig,
|
|
193
|
-
fixedPriceMinter,
|
|
194
|
-
),
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
|
|
198
61
|
/**
|
|
199
62
|
* Gets the preminted log from receipt
|
|
200
63
|
*
|
|
201
64
|
* @param receipt Preminted log from receipt
|
|
202
65
|
* @returns Premint event arguments
|
|
203
66
|
*/
|
|
204
|
-
|
|
67
|
+
function getPremintedLogFromReceipt(
|
|
205
68
|
receipt: TransactionReceipt,
|
|
206
69
|
): PremintedV2LogType | undefined {
|
|
207
70
|
for (const data of receipt.logs) {
|
|
@@ -246,21 +109,6 @@ export class PremintClient {
|
|
|
246
109
|
return getDataFromPremintReceipt(receipt, this.chainId, blockExplorerUrl);
|
|
247
110
|
}
|
|
248
111
|
|
|
249
|
-
/**
|
|
250
|
-
* Prepares data for updating a premint
|
|
251
|
-
*
|
|
252
|
-
* @param parameters - Parameters for updating the premint {@link UpdatePremintParams}
|
|
253
|
-
* @returns A PremintReturn. {@link PremintReturn}
|
|
254
|
-
*/
|
|
255
|
-
async updatePremint(args: UpdatePremintParams): Promise<PremintReturn<any>> {
|
|
256
|
-
return await updatePremint({
|
|
257
|
-
...args,
|
|
258
|
-
apiClient: this.apiClient,
|
|
259
|
-
publicClient: this.publicClient,
|
|
260
|
-
chainId: this.chainId,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
112
|
/**
|
|
265
113
|
* Prepares data for deleting a premint
|
|
266
114
|
*
|
|
@@ -278,23 +126,6 @@ export class PremintClient {
|
|
|
278
126
|
});
|
|
279
127
|
}
|
|
280
128
|
|
|
281
|
-
/**
|
|
282
|
-
* Prepares data for creating a premint
|
|
283
|
-
*
|
|
284
|
-
* @param parameters - Parameters for creating the premint {@link CreatePremintParameters}
|
|
285
|
-
* @returns A PremintReturn. {@link PremintReturn}
|
|
286
|
-
*/
|
|
287
|
-
async createPremint(
|
|
288
|
-
parameters: CreatePremintParameters,
|
|
289
|
-
): Promise<PremintReturn<any>> {
|
|
290
|
-
return createPremint({
|
|
291
|
-
...parameters,
|
|
292
|
-
publicClient: this.publicClient,
|
|
293
|
-
apiClient: this.apiClient,
|
|
294
|
-
chainId: this.chainId,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
129
|
/**
|
|
299
130
|
* Fetches given premint data from the ZORA API.
|
|
300
131
|
*
|
|
@@ -394,19 +225,19 @@ type PremintContext = {
|
|
|
394
225
|
|
|
395
226
|
/** ======= ADMIN ======= */
|
|
396
227
|
|
|
397
|
-
|
|
228
|
+
type SignAndSubmitParams = {
|
|
398
229
|
/** The WalletClient used to sign the premint */
|
|
399
230
|
walletClient: WalletClient;
|
|
400
231
|
} & CheckSignatureParams;
|
|
401
232
|
|
|
402
|
-
|
|
233
|
+
type SignAndSubmitReturn = {
|
|
403
234
|
/** The signature of the Premint */
|
|
404
235
|
signature: Hex;
|
|
405
236
|
/** The account that signed the Premint */
|
|
406
237
|
signerAccount: Account | Address;
|
|
407
238
|
};
|
|
408
239
|
|
|
409
|
-
|
|
240
|
+
type CheckSignatureParams =
|
|
410
241
|
| {
|
|
411
242
|
/** If the premint signature should be validated before submitting to the API */
|
|
412
243
|
checkSignature: true;
|
|
@@ -419,7 +250,7 @@ export type CheckSignatureParams =
|
|
|
419
250
|
account?: Account | Address;
|
|
420
251
|
};
|
|
421
252
|
|
|
422
|
-
|
|
253
|
+
type SubmitParams = {
|
|
423
254
|
/** The signature of the Premint */
|
|
424
255
|
signature: Hex;
|
|
425
256
|
} & CheckSignatureParams;
|
|
@@ -551,153 +382,9 @@ async function signPremint({
|
|
|
551
382
|
};
|
|
552
383
|
}
|
|
553
384
|
|
|
554
|
-
/** CREATE */
|
|
555
|
-
|
|
556
|
-
type CreatePremintParameters = {
|
|
557
|
-
/** tokenCreationConfig Token creation settings, optional settings are overridden with sensible defaults */
|
|
558
|
-
token: TokenConfigInput;
|
|
559
|
-
/** uid the UID to use – optional and retrieved as a fresh UID from ZORA by default. */
|
|
560
|
-
uid?: number;
|
|
561
|
-
} & ContractCreationConfigOrAddress;
|
|
562
|
-
|
|
563
|
-
async function createPremint({
|
|
564
|
-
token: tokenCreationConfig,
|
|
565
|
-
uid,
|
|
566
|
-
publicClient,
|
|
567
|
-
apiClient,
|
|
568
|
-
chainId,
|
|
569
|
-
...collectionOrAddress
|
|
570
|
-
}: CreatePremintParameters & PremintContext) {
|
|
571
|
-
const {
|
|
572
|
-
premintConfig,
|
|
573
|
-
premintConfigVersion,
|
|
574
|
-
collectionAddress: collectionAddressToUse,
|
|
575
|
-
} = await prepareCreatePremintConfig({
|
|
576
|
-
...collectionOrAddress,
|
|
577
|
-
tokenCreationConfig,
|
|
578
|
-
uid,
|
|
579
|
-
publicClient,
|
|
580
|
-
apiClient,
|
|
581
|
-
chainId,
|
|
582
|
-
});
|
|
583
|
-
|
|
584
|
-
return makePremintReturn({
|
|
585
|
-
premintConfig,
|
|
586
|
-
premintConfigVersion,
|
|
587
|
-
collectionAddress: collectionAddressToUse,
|
|
588
|
-
collection: collectionOrAddress.contract,
|
|
589
|
-
publicClient,
|
|
590
|
-
apiClient,
|
|
591
|
-
chainId,
|
|
592
|
-
});
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
type PreparePremintReturn = {
|
|
596
|
-
collectionAddress: Address;
|
|
597
|
-
} & PremintConfigAndVersion;
|
|
598
|
-
|
|
599
|
-
async function prepareCreatePremintConfig({
|
|
600
|
-
tokenCreationConfig,
|
|
601
|
-
uid,
|
|
602
|
-
publicClient,
|
|
603
|
-
apiClient,
|
|
604
|
-
chainId,
|
|
605
|
-
...collectionOrAddress
|
|
606
|
-
}: {
|
|
607
|
-
tokenCreationConfig: TokenConfigInput;
|
|
608
|
-
uid?: number;
|
|
609
|
-
} & PremintContext &
|
|
610
|
-
ContractCreationConfigOrAddress): Promise<PreparePremintReturn> {
|
|
611
|
-
const newContractAddress = await getPremintCollectionAddress({
|
|
612
|
-
publicClient,
|
|
613
|
-
...collectionOrAddress,
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
let uidToUse = uid;
|
|
617
|
-
|
|
618
|
-
if (typeof uidToUse !== "number") {
|
|
619
|
-
uidToUse = await apiClient.getNextUID(newContractAddress);
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
const supportedVersions = await supportedPremintVersions({
|
|
623
|
-
tokenContract: newContractAddress,
|
|
624
|
-
publicClient,
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
const tokenConfigAndVersion = makeTokenConfigWithDefaults({
|
|
628
|
-
tokenCreationConfig,
|
|
629
|
-
chainId,
|
|
630
|
-
supportedPremintVersions: supportedVersions,
|
|
631
|
-
});
|
|
632
|
-
|
|
633
|
-
const premintConfig = makeNewPremint({
|
|
634
|
-
...tokenConfigAndVersion,
|
|
635
|
-
uid: uidToUse,
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
const premintConfigAndVersion = {
|
|
639
|
-
premintConfig,
|
|
640
|
-
premintConfigVersion: tokenConfigAndVersion.premintConfigVersion,
|
|
641
|
-
} as PremintConfigAndVersion;
|
|
642
|
-
|
|
643
|
-
return {
|
|
644
|
-
...premintConfigAndVersion,
|
|
645
|
-
collectionAddress: newContractAddress,
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/** UPDATE */
|
|
650
|
-
|
|
651
|
-
export type UpdatePremintParams = {
|
|
652
|
-
/** uid of the Premint to update */
|
|
653
|
-
uid: number;
|
|
654
|
-
/** address of the Premint to update */
|
|
655
|
-
collection: Address;
|
|
656
|
-
/** update to apply to the Premint */
|
|
657
|
-
tokenConfigUpdates: Partial<TokenCreationConfig>;
|
|
658
|
-
};
|
|
659
|
-
|
|
660
|
-
async function updatePremint({
|
|
661
|
-
uid,
|
|
662
|
-
collection,
|
|
663
|
-
tokenConfigUpdates,
|
|
664
|
-
apiClient,
|
|
665
|
-
publicClient,
|
|
666
|
-
chainId,
|
|
667
|
-
}: UpdatePremintParams & {
|
|
668
|
-
apiClient: IPremintAPI;
|
|
669
|
-
publicClient: PublicClient;
|
|
670
|
-
chainId: number;
|
|
671
|
-
}) {
|
|
672
|
-
const {
|
|
673
|
-
premint: { premintConfig, premintConfigVersion },
|
|
674
|
-
collection: collectionCreationConfig,
|
|
675
|
-
} = await apiClient.get({
|
|
676
|
-
collectionAddress: collection,
|
|
677
|
-
uid: uid,
|
|
678
|
-
});
|
|
679
|
-
|
|
680
|
-
const updatedPremint = applyUpdateToPremint({
|
|
681
|
-
uid: premintConfig.uid,
|
|
682
|
-
version: premintConfig.version,
|
|
683
|
-
tokenConfig: premintConfig.tokenConfig,
|
|
684
|
-
tokenConfigUpdates: tokenConfigUpdates,
|
|
685
|
-
});
|
|
686
|
-
|
|
687
|
-
return makePremintReturn({
|
|
688
|
-
premintConfig: updatedPremint,
|
|
689
|
-
premintConfigVersion,
|
|
690
|
-
collectionAddress: collection,
|
|
691
|
-
collection: collectionCreationConfig,
|
|
692
|
-
publicClient,
|
|
693
|
-
apiClient,
|
|
694
|
-
chainId,
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
|
|
698
385
|
/** DELETE */
|
|
699
386
|
|
|
700
|
-
|
|
387
|
+
type DeletePremintParams = {
|
|
701
388
|
/** id of the premint to delete */
|
|
702
389
|
uid: number;
|
|
703
390
|
/** collection address of the Premint to delete */
|
|
@@ -741,7 +428,7 @@ async function deletePremint({
|
|
|
741
428
|
});
|
|
742
429
|
}
|
|
743
430
|
|
|
744
|
-
|
|
431
|
+
type MakeMintParametersArguments = {
|
|
745
432
|
/** uid of the Premint to mint */
|
|
746
433
|
uid: number;
|
|
747
434
|
/** Premint contract address */
|
|
@@ -765,7 +452,7 @@ export type MakeMintParametersArguments = {
|
|
|
765
452
|
|
|
766
453
|
/** ======== MINTING ======== */
|
|
767
454
|
|
|
768
|
-
|
|
455
|
+
async function collectPremint({
|
|
769
456
|
uid,
|
|
770
457
|
tokenContract,
|
|
771
458
|
minterAccount,
|
|
@@ -887,7 +574,7 @@ export const buildPremintMintCall = ({
|
|
|
887
574
|
});
|
|
888
575
|
};
|
|
889
576
|
|
|
890
|
-
|
|
577
|
+
function makeUrls({
|
|
891
578
|
uid,
|
|
892
579
|
address,
|
|
893
580
|
tokenId,
|