@zoralabs/protocol-sdk 0.5.16 → 0.5.17
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 +6 -6
- package/CHANGELOG.md +11 -0
- package/dist/apis/generated/premint-api-types.d.ts +9 -2
- package/dist/apis/generated/premint-api-types.d.ts.map +1 -1
- package/dist/index.cjs +204 -159
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +208 -161
- package/dist/index.js.map +1 -1
- package/dist/premint/contract-types.d.ts +21 -0
- package/dist/premint/contract-types.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +10 -22
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +5 -4
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +25 -25
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +28 -16
- package/dist/premint/preminter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/apis/generated/premint-api-types.ts +9 -2
- package/src/index.ts +6 -0
- package/src/mints/mints-contracts.test.ts +2 -2
- package/src/premint/contract-types.ts +32 -1
- package/src/premint/conversions.ts +20 -8
- package/src/premint/premint-api-client.ts +7 -7
- package/src/premint/premint-client.test.ts +105 -87
- package/src/premint/premint-client.ts +204 -191
- package/src/premint/preminter.test.ts +154 -2
- package/src/premint/preminter.ts +86 -35
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { zoraSepolia } from "viem/chains";
|
|
2
2
|
import { describe, expect, vi } from "vitest";
|
|
3
3
|
|
|
4
4
|
import { createPremintClient } from "./premint-client";
|
|
5
5
|
import { PremintConfigVersion } from "./contract-types";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getDefaultFixedPriceMinterAddress,
|
|
8
|
+
getPremintCollectionAddress,
|
|
9
|
+
} from "./preminter";
|
|
7
10
|
import { forkUrls, makeAnvilTest } from "src/anvil";
|
|
11
|
+
import {
|
|
12
|
+
ContractCreationConfig,
|
|
13
|
+
PremintConfigV2,
|
|
14
|
+
} from "@zoralabs/protocol-deployments";
|
|
8
15
|
|
|
9
16
|
const anvilTest = makeAnvilTest({
|
|
10
17
|
forkUrl: forkUrls.zoraSepolia,
|
|
11
|
-
forkBlockNumber:
|
|
18
|
+
forkBlockNumber: 9678162,
|
|
12
19
|
anvilChainId: zoraSepolia.id,
|
|
13
20
|
});
|
|
14
21
|
|
|
15
|
-
describe("ZoraCreator1155Premint
|
|
22
|
+
describe("ZoraCreator1155Premint", () => {
|
|
16
23
|
anvilTest(
|
|
17
|
-
"can
|
|
24
|
+
"can mint premints",
|
|
18
25
|
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
19
26
|
const [deployerAccount] = await walletClient.getAddresses();
|
|
20
27
|
const premintClient = createPremintClient({
|
|
@@ -22,82 +29,6 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
|
|
|
22
29
|
publicClient,
|
|
23
30
|
});
|
|
24
31
|
|
|
25
|
-
premintClient.apiClient.getNextUID = vi
|
|
26
|
-
.fn<any, ReturnType<typeof premintClient.apiClient.getNextUID>>()
|
|
27
|
-
.mockResolvedValue(3);
|
|
28
|
-
premintClient.apiClient.postSignature = vi
|
|
29
|
-
.fn<Parameters<typeof premintClient.apiClient.postSignature>>()
|
|
30
|
-
.mockResolvedValue({ ok: true });
|
|
31
|
-
|
|
32
|
-
const { signAndSubmit } = await premintClient.createPremint({
|
|
33
|
-
payoutRecipient: deployerAccount!,
|
|
34
|
-
collection: {
|
|
35
|
-
contractAdmin: deployerAccount!,
|
|
36
|
-
contractName: "Testing Contract",
|
|
37
|
-
contractURI:
|
|
38
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
39
|
-
},
|
|
40
|
-
tokenCreationConfig: {
|
|
41
|
-
tokenURI:
|
|
42
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
await signAndSubmit({
|
|
47
|
-
walletClient,
|
|
48
|
-
checkSignature: true,
|
|
49
|
-
account: deployerAccount!,
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const expectedPostSignatureArgs: Parameters<
|
|
53
|
-
typeof premintClient.apiClient.postSignature
|
|
54
|
-
>[0] = {
|
|
55
|
-
collection: {
|
|
56
|
-
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
57
|
-
contractName: "Testing Contract",
|
|
58
|
-
contractURI:
|
|
59
|
-
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
60
|
-
additionalAdmins: [],
|
|
61
|
-
},
|
|
62
|
-
premintConfig: {
|
|
63
|
-
deleted: false,
|
|
64
|
-
tokenConfig: {
|
|
65
|
-
fixedPriceMinter: getDefaultFixedPriceMinterAddress(chain.id),
|
|
66
|
-
maxSupply: 18446744073709551615n,
|
|
67
|
-
maxTokensPerAddress: 0n,
|
|
68
|
-
mintDuration: 604800n,
|
|
69
|
-
mintStart: 0n,
|
|
70
|
-
pricePerToken: 0n,
|
|
71
|
-
royaltyBPS: 1000,
|
|
72
|
-
royaltyMintSchedule: 0,
|
|
73
|
-
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
74
|
-
tokenURI:
|
|
75
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
76
|
-
},
|
|
77
|
-
uid: 3,
|
|
78
|
-
version: 0,
|
|
79
|
-
},
|
|
80
|
-
premintConfigVersion: PremintConfigVersion.V1,
|
|
81
|
-
signature:
|
|
82
|
-
"0x4d191dd60d428adfe507932a1758bee8ac5bbb77dcd3c05840c237416a3a25035bb8cc7c62177a4e9acb5f40c4032cdb3dbfefdd1575f2c3b4c57945b2076e2e1c",
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
|
|
86
|
-
expectedPostSignatureArgs,
|
|
87
|
-
);
|
|
88
|
-
},
|
|
89
|
-
20 * 1000,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
anvilTest(
|
|
93
|
-
"can execute premint on network",
|
|
94
|
-
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
95
|
-
const [deployerAccount] = await walletClient.getAddresses();
|
|
96
|
-
const premintClient = createPremintClient({
|
|
97
|
-
chain: foundry,
|
|
98
|
-
publicClient,
|
|
99
|
-
});
|
|
100
|
-
|
|
101
32
|
premintClient.apiClient.getSignature = vi
|
|
102
33
|
.fn<any, ReturnType<typeof premintClient.apiClient.getSignature>>()
|
|
103
34
|
.mockResolvedValue({
|
|
@@ -108,6 +39,7 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
|
|
|
108
39
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
109
40
|
additionalAdmins: [],
|
|
110
41
|
},
|
|
42
|
+
collectionAddress: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
111
43
|
premintConfig: {
|
|
112
44
|
deleted: false,
|
|
113
45
|
tokenConfig: {
|
|
@@ -156,9 +88,9 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
|
|
|
156
88
|
explorer:
|
|
157
89
|
"https://undefined/token/0xf8dA7f53c283d898818af7FB9d98103F559bDac2/instance/1",
|
|
158
90
|
zoraCollect:
|
|
159
|
-
"https://testnet.zora.co/collect/
|
|
91
|
+
"https://testnet.zora.co/collect/zsep:0xf8dA7f53c283d898818af7FB9d98103F559bDac2/1",
|
|
160
92
|
zoraManage:
|
|
161
|
-
"https://testnet.zora.co/collect/
|
|
93
|
+
"https://testnet.zora.co/collect/zsep:0xf8dA7f53c283d898818af7FB9d98103F559bDac2/1",
|
|
162
94
|
});
|
|
163
95
|
|
|
164
96
|
expect(premintedLog).toEqual({
|
|
@@ -176,7 +108,7 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
|
|
|
176
108
|
|
|
177
109
|
describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
178
110
|
anvilTest(
|
|
179
|
-
"can sign
|
|
111
|
+
"can sign and submit new premints on new contracts",
|
|
180
112
|
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
181
113
|
const [creatorAccount, createReferralAccount] =
|
|
182
114
|
await walletClient.getAddresses();
|
|
@@ -193,17 +125,16 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
193
125
|
.mockResolvedValue({ ok: true });
|
|
194
126
|
|
|
195
127
|
const { signAndSubmit } = await premintClient.createPremint({
|
|
196
|
-
payoutRecipient: creatorAccount!,
|
|
197
128
|
collection: {
|
|
198
129
|
contractAdmin: creatorAccount!,
|
|
199
130
|
contractName: "Testing Contract Premint V2",
|
|
200
131
|
contractURI:
|
|
201
132
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
202
133
|
},
|
|
203
|
-
premintConfigVersion: PremintConfigVersion.V2,
|
|
204
134
|
tokenCreationConfig: {
|
|
205
135
|
tokenURI:
|
|
206
136
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
137
|
+
payoutRecipient: creatorAccount!,
|
|
207
138
|
createReferral: createReferralAccount,
|
|
208
139
|
},
|
|
209
140
|
});
|
|
@@ -222,8 +153,8 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
222
153
|
contractName: "Testing Contract Premint V2",
|
|
223
154
|
contractURI:
|
|
224
155
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
225
|
-
additionalAdmins: [],
|
|
226
156
|
},
|
|
157
|
+
collectionAddress: undefined,
|
|
227
158
|
premintConfig: {
|
|
228
159
|
deleted: false,
|
|
229
160
|
tokenConfig: {
|
|
@@ -253,4 +184,91 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
253
184
|
},
|
|
254
185
|
20 * 1000,
|
|
255
186
|
);
|
|
187
|
+
|
|
188
|
+
anvilTest(
|
|
189
|
+
"can mint premints with additional admins",
|
|
190
|
+
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
191
|
+
const [deployerAccount, creatorAccount, additionalAdmin] =
|
|
192
|
+
await walletClient.getAddresses();
|
|
193
|
+
const premintClient = createPremintClient({
|
|
194
|
+
chain,
|
|
195
|
+
publicClient,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
const collection: ContractCreationConfig = {
|
|
199
|
+
contractAdmin: creatorAccount!,
|
|
200
|
+
contractName: "Testing Contract",
|
|
201
|
+
contractURI:
|
|
202
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
203
|
+
additionalAdmins: [additionalAdmin!],
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const collectionAddress = await getPremintCollectionAddress({
|
|
207
|
+
collection,
|
|
208
|
+
publicClient,
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const { premintConfig, typedDataDefinition } =
|
|
212
|
+
await premintClient.createPremint({
|
|
213
|
+
collection,
|
|
214
|
+
tokenCreationConfig: {
|
|
215
|
+
tokenURI:
|
|
216
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
217
|
+
payoutRecipient: creatorAccount!,
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
const signature = await walletClient.signTypedData({
|
|
222
|
+
...typedDataDefinition,
|
|
223
|
+
account: additionalAdmin!,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
premintClient.apiClient.getSignature = vi
|
|
227
|
+
.fn<any, ReturnType<typeof premintClient.apiClient.getSignature>>()
|
|
228
|
+
.mockResolvedValue({
|
|
229
|
+
collection,
|
|
230
|
+
collectionAddress,
|
|
231
|
+
premintConfig: premintConfig as PremintConfigV2,
|
|
232
|
+
premintConfigVersion: PremintConfigVersion.V2,
|
|
233
|
+
signature,
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
premintClient.apiClient.postSignature = vi.fn();
|
|
237
|
+
|
|
238
|
+
const simulateContractParameters = await premintClient.makeMintParameters(
|
|
239
|
+
{
|
|
240
|
+
minterAccount: deployerAccount!,
|
|
241
|
+
tokenContract: collectionAddress,
|
|
242
|
+
uid: premintConfig.uid,
|
|
243
|
+
mintArguments: {
|
|
244
|
+
quantityToMint: 1,
|
|
245
|
+
mintComment: "",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
);
|
|
249
|
+
const { request: simulateRequest } = await publicClient.simulateContract(
|
|
250
|
+
simulateContractParameters,
|
|
251
|
+
);
|
|
252
|
+
const hash = await walletClient.writeContract(simulateRequest);
|
|
253
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
254
|
+
const { premintedLog, urls } =
|
|
255
|
+
premintClient.getDataFromPremintReceipt(receipt);
|
|
256
|
+
|
|
257
|
+
expect(urls).toEqual({
|
|
258
|
+
explorer: `https://undefined/token/${collectionAddress}/instance/1`,
|
|
259
|
+
zoraCollect: `https://testnet.zora.co/collect/zsep:${collectionAddress}/1`,
|
|
260
|
+
zoraManage: `https://testnet.zora.co/collect/zsep:${collectionAddress}/1`,
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
expect(premintedLog).toEqual({
|
|
264
|
+
contractAddress: collectionAddress,
|
|
265
|
+
createdNewContract: expect.any(Boolean),
|
|
266
|
+
minter: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
267
|
+
quantityMinted: 1n,
|
|
268
|
+
tokenId: 1n,
|
|
269
|
+
uid: premintConfig.uid,
|
|
270
|
+
});
|
|
271
|
+
},
|
|
272
|
+
20 * 1000,
|
|
273
|
+
);
|
|
256
274
|
});
|