@zoralabs/protocol-sdk 0.5.15 → 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.
Files changed (46) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +19 -0
  3. package/dist/anvil.d.ts +4 -4
  4. package/dist/anvil.d.ts.map +1 -1
  5. package/dist/apis/generated/premint-api-types.d.ts +9 -2
  6. package/dist/apis/generated/premint-api-types.d.ts.map +1 -1
  7. package/dist/create/1155-create-helper.d.ts +3 -4
  8. package/dist/create/1155-create-helper.d.ts.map +1 -1
  9. package/dist/index.cjs +495 -371
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +478 -352
  14. package/dist/index.js.map +1 -1
  15. package/dist/mint/mint-client.d.ts +22 -17
  16. package/dist/mint/mint-client.d.ts.map +1 -1
  17. package/dist/mints/mints-contracts.d.ts +688 -3
  18. package/dist/mints/mints-contracts.d.ts.map +1 -1
  19. package/dist/premint/contract-types.d.ts +21 -0
  20. package/dist/premint/contract-types.d.ts.map +1 -1
  21. package/dist/premint/conversions.d.ts +10 -22
  22. package/dist/premint/conversions.d.ts.map +1 -1
  23. package/dist/premint/premint-api-client.d.ts +5 -4
  24. package/dist/premint/premint-api-client.d.ts.map +1 -1
  25. package/dist/premint/premint-client.d.ts +122 -1476
  26. package/dist/premint/premint-client.d.ts.map +1 -1
  27. package/dist/premint/preminter.d.ts +29 -16
  28. package/dist/premint/preminter.d.ts.map +1 -1
  29. package/dist/utils.d.ts +6872 -1
  30. package/dist/utils.d.ts.map +1 -1
  31. package/package.json +2 -2
  32. package/src/apis/generated/premint-api-types.ts +9 -2
  33. package/src/create/1155-create-helper.test.ts +10 -3
  34. package/src/create/1155-create-helper.ts +8 -7
  35. package/src/index.ts +6 -0
  36. package/src/mint/mint-client.ts +31 -30
  37. package/src/mints/mints-contracts.test.ts +2 -2
  38. package/src/premint/contract-types.ts +32 -1
  39. package/src/premint/conversions.ts +20 -8
  40. package/src/premint/premint-api-client.ts +7 -7
  41. package/src/premint/premint-client.test.ts +112 -88
  42. package/src/premint/premint-client.ts +614 -409
  43. package/src/premint/preminter.test.ts +154 -2
  44. package/src/premint/preminter.ts +87 -36
  45. package/src/utils.ts +25 -0
  46. package/test-integration/premint-client.test.ts +2 -2
@@ -1,20 +1,27 @@
1
- import { foundry, zoraSepolia } from "viem/chains";
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 { getDefaultFixedPriceMinterAddress } from "./preminter";
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: 8869648,
18
+ forkBlockNumber: 9678162,
12
19
  anvilChainId: zoraSepolia.id,
13
20
  });
14
21
 
15
- describe("ZoraCreator1155Premint - v1 signatures", () => {
22
+ describe("ZoraCreator1155Premint", () => {
16
23
  anvilTest(
17
- "can sign by default v1 on the forked premint contract",
24
+ "can mint premints",
18
25
  async ({ viemClients: { walletClient, publicClient, chain } }) => {
19
26
  const [deployerAccount] = await walletClient.getAddresses();
20
27
  const premintClient = createPremintClient({
@@ -22,79 +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
- await premintClient.createPremint({
33
- walletClient,
34
- creatorAccount: deployerAccount!,
35
- checkSignature: true,
36
- collection: {
37
- contractAdmin: deployerAccount!,
38
- contractName: "Testing Contract",
39
- contractURI:
40
- "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
41
- additionalAdmins: [],
42
- },
43
- tokenCreationConfig: {
44
- tokenURI:
45
- "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
46
- },
47
- });
48
-
49
- const expectedPostSignatureArgs: Parameters<
50
- typeof premintClient.apiClient.postSignature
51
- >[0] = {
52
- collection: {
53
- contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
54
- contractName: "Testing Contract",
55
- contractURI:
56
- "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
57
- additionalAdmins: [],
58
- },
59
- premintConfig: {
60
- deleted: false,
61
- tokenConfig: {
62
- fixedPriceMinter: getDefaultFixedPriceMinterAddress(chain.id),
63
- maxSupply: 18446744073709551615n,
64
- maxTokensPerAddress: 0n,
65
- mintDuration: 604800n,
66
- mintStart: 0n,
67
- pricePerToken: 0n,
68
- royaltyBPS: 1000,
69
- royaltyMintSchedule: 0,
70
- royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
71
- tokenURI:
72
- "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
73
- },
74
- uid: 3,
75
- version: 0,
76
- },
77
- premintConfigVersion: PremintConfigVersion.V1,
78
- signature:
79
- "0x4d191dd60d428adfe507932a1758bee8ac5bbb77dcd3c05840c237416a3a25035bb8cc7c62177a4e9acb5f40c4032cdb3dbfefdd1575f2c3b4c57945b2076e2e1c",
80
- };
81
-
82
- expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
83
- expectedPostSignatureArgs,
84
- );
85
- },
86
- 20 * 1000,
87
- );
88
-
89
- anvilTest(
90
- "can execute premint on network",
91
- async ({ viemClients: { walletClient, publicClient, chain } }) => {
92
- const [deployerAccount] = await walletClient.getAddresses();
93
- const premintClient = createPremintClient({
94
- chain: foundry,
95
- publicClient,
96
- });
97
-
98
32
  premintClient.apiClient.getSignature = vi
99
33
  .fn<any, ReturnType<typeof premintClient.apiClient.getSignature>>()
100
34
  .mockResolvedValue({
@@ -105,6 +39,7 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
105
39
  "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
106
40
  additionalAdmins: [],
107
41
  },
42
+ collectionAddress: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
108
43
  premintConfig: {
109
44
  deleted: false,
110
45
  tokenConfig: {
@@ -153,9 +88,9 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
153
88
  explorer:
154
89
  "https://undefined/token/0xf8dA7f53c283d898818af7FB9d98103F559bDac2/instance/1",
155
90
  zoraCollect:
156
- "https://testnet.zora.co/collect/zgor:0xf8dA7f53c283d898818af7FB9d98103F559bDac2/1",
91
+ "https://testnet.zora.co/collect/zsep:0xf8dA7f53c283d898818af7FB9d98103F559bDac2/1",
157
92
  zoraManage:
158
- "https://testnet.zora.co/collect/zgor:0xf8dA7f53c283d898818af7FB9d98103F559bDac2/1",
93
+ "https://testnet.zora.co/collect/zsep:0xf8dA7f53c283d898818af7FB9d98103F559bDac2/1",
159
94
  });
160
95
 
161
96
  expect(premintedLog).toEqual({
@@ -173,7 +108,7 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
173
108
 
174
109
  describe("ZoraCreator1155Premint - v2 signatures", () => {
175
110
  anvilTest(
176
- "can sign on the forked premint contract",
111
+ "can sign and submit new premints on new contracts",
177
112
  async ({ viemClients: { walletClient, publicClient, chain } }) => {
178
113
  const [creatorAccount, createReferralAccount] =
179
114
  await walletClient.getAddresses();
@@ -189,25 +124,27 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
189
124
  .fn<Parameters<typeof premintClient.apiClient.postSignature>>()
190
125
  .mockResolvedValue({ ok: true });
191
126
 
192
- await premintClient.createPremint({
193
- walletClient,
194
- creatorAccount: creatorAccount!,
195
- checkSignature: true,
127
+ const { signAndSubmit } = await premintClient.createPremint({
196
128
  collection: {
197
129
  contractAdmin: creatorAccount!,
198
130
  contractName: "Testing Contract Premint V2",
199
131
  contractURI:
200
132
  "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
201
- additionalAdmins: [],
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
  });
210
141
 
142
+ await signAndSubmit({
143
+ account: creatorAccount!,
144
+ walletClient,
145
+ checkSignature: true,
146
+ });
147
+
211
148
  const expectedPostSignatureArgs: Parameters<
212
149
  typeof premintClient.apiClient.postSignature
213
150
  >[0] = {
@@ -216,8 +153,8 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
216
153
  contractName: "Testing Contract Premint V2",
217
154
  contractURI:
218
155
  "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
219
- additionalAdmins: [],
220
156
  },
157
+ collectionAddress: undefined,
221
158
  premintConfig: {
222
159
  deleted: false,
223
160
  tokenConfig: {
@@ -247,4 +184,91 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
247
184
  },
248
185
  20 * 1000,
249
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
+ );
250
274
  });