@zoralabs/protocol-sdk 0.5.17 → 0.7.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.
Files changed (84) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +1 -416
  4. package/dist/constants.d.ts +0 -1
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/create/1155-create-helper.d.ts +16 -55
  7. package/dist/create/1155-create-helper.d.ts.map +1 -1
  8. package/dist/create/contract-setup.d.ts +14 -0
  9. package/dist/create/contract-setup.d.ts.map +1 -0
  10. package/dist/create/token-setup.d.ts +27 -0
  11. package/dist/create/token-setup.d.ts.map +1 -0
  12. package/dist/create/types.d.ts +45 -0
  13. package/dist/create/types.d.ts.map +1 -0
  14. package/dist/index.cjs +1745 -891
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.ts +3 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1698 -858
  19. package/dist/index.js.map +1 -1
  20. package/dist/mint/mint-client.d.ts +48 -51
  21. package/dist/mint/mint-client.d.ts.map +1 -1
  22. package/dist/mint/mint-queries.d.ts +38 -0
  23. package/dist/mint/mint-queries.d.ts.map +1 -0
  24. package/dist/mint/mint-transactions.d.ts +20 -0
  25. package/dist/mint/mint-transactions.d.ts.map +1 -0
  26. package/dist/mint/subgraph-mint-getter.d.ts +24 -0
  27. package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
  28. package/dist/mint/subgraph-queries.d.ts +55 -0
  29. package/dist/mint/subgraph-queries.d.ts.map +1 -0
  30. package/dist/mint/types.d.ts +177 -0
  31. package/dist/mint/types.d.ts.map +1 -0
  32. package/dist/mint/utils.d.ts +2 -0
  33. package/dist/mint/utils.d.ts.map +1 -0
  34. package/dist/mints/mints-contracts.d.ts +27 -4518
  35. package/dist/mints/mints-contracts.d.ts.map +1 -1
  36. package/dist/premint/contract-types.d.ts +4 -4
  37. package/dist/premint/contract-types.d.ts.map +1 -1
  38. package/dist/premint/conversions.d.ts +15 -16
  39. package/dist/premint/conversions.d.ts.map +1 -1
  40. package/dist/premint/premint-api-client.d.ts +32 -16
  41. package/dist/premint/premint-api-client.d.ts.map +1 -1
  42. package/dist/premint/premint-client.d.ts +76 -50
  43. package/dist/premint/premint-client.d.ts.map +1 -1
  44. package/dist/premint/preminter.d.ts +20 -8
  45. package/dist/premint/preminter.d.ts.map +1 -1
  46. package/dist/sdk.d.ts +45 -0
  47. package/dist/sdk.d.ts.map +1 -0
  48. package/dist/types.d.ts +3 -0
  49. package/dist/types.d.ts.map +1 -1
  50. package/dist/utils.d.ts +24 -6869
  51. package/dist/utils.d.ts.map +1 -1
  52. package/package.json +3 -2
  53. package/src/constants.ts +0 -36
  54. package/src/create/1155-create-helper.test.ts +236 -55
  55. package/src/create/1155-create-helper.ts +141 -309
  56. package/src/create/contract-setup.ts +88 -0
  57. package/src/create/token-setup.ts +379 -0
  58. package/src/create/types.ts +57 -0
  59. package/src/index.ts +5 -1
  60. package/src/mint/mint-client.test.ts +116 -78
  61. package/src/mint/mint-client.ts +130 -234
  62. package/src/mint/mint-queries.ts +320 -0
  63. package/src/mint/mint-transactions.ts +253 -0
  64. package/src/mint/subgraph-mint-getter.ts +247 -0
  65. package/src/mint/subgraph-queries.ts +170 -0
  66. package/src/mint/types.ts +239 -0
  67. package/src/mint/utils.ts +14 -0
  68. package/src/mints/mints-contracts.test.ts +1 -1
  69. package/src/mints/mints-contracts.ts +4 -4
  70. package/src/premint/contract-types.ts +4 -4
  71. package/src/premint/conversions.ts +38 -4
  72. package/src/premint/premint-api-client.ts +92 -48
  73. package/src/premint/premint-client.test.ts +100 -84
  74. package/src/premint/premint-client.ts +186 -185
  75. package/src/premint/preminter.test.ts +4 -5
  76. package/src/premint/preminter.ts +63 -14
  77. package/src/sdk.ts +101 -0
  78. package/src/types.ts +18 -0
  79. package/src/utils.ts +54 -46
  80. package/test-integration/setup-test-contracts.ts +96 -0
  81. package/dist/mint/mint-api-client.d.ts +0 -35
  82. package/dist/mint/mint-api-client.d.ts.map +0 -1
  83. package/src/mint/mint-api-client.ts +0 -177
  84. package/test-integration/premint-client.test.ts +0 -148
@@ -28,11 +28,11 @@ export type ContractCreationConfigAndAddress = {
28
28
  export type ContractCreationConfigOrAddress =
29
29
  | {
30
30
  /** Parameters for creating the contract for new premints. */
31
- collection: ContractCreationConfigWithOptionalAdditionalAdmins;
32
- collectionAddress?: undefined;
31
+ contract: ContractCreationConfigWithOptionalAdditionalAdmins;
32
+ contractAddress?: undefined;
33
33
  }
34
34
  | {
35
- collection?: undefined;
35
+ contract?: undefined;
36
36
  /** Premint collection address */
37
- collectionAddress: Address;
37
+ contractAddress: Address;
38
38
  };
@@ -9,7 +9,10 @@ import {
9
9
  PremintConfigVersion,
10
10
  PremintConfigWithVersion,
11
11
  } from "@zoralabs/protocol-deployments";
12
- import { PremintSignatureGetResponse } from "./premint-api-client";
12
+ import {
13
+ PremintSignatureGetOfCollectionResponse,
14
+ PremintSignatureGetResponse,
15
+ } from "./premint-api-client";
13
16
  import { ContractCreationConfigOrAddress } from "./contract-types";
14
17
 
15
18
  export const convertCollectionFromApi = (
@@ -84,13 +87,34 @@ export const convertPremintFromApi = (
84
87
  }
85
88
  };
86
89
 
90
+ export type PremintFromApi = ReturnType<typeof convertGetPremintApiResponse>;
91
+
87
92
  export const convertGetPremintApiResponse = (
88
93
  response: PremintSignatureGetResponse,
89
94
  ) => ({
90
- ...convertPremintFromApi(response.premint),
91
95
  collection: convertCollectionFromApi(response.collection),
92
96
  collectionAddress: response.collection_address as Address,
93
97
  signature: response.signature as Hex,
98
+ signer: response.signer as Address,
99
+ premint: convertPremintFromApi(response.premint),
100
+ });
101
+
102
+ export type PremintCollectionFromApi = ReturnType<
103
+ typeof convertGetPremintOfCollectionApiResponse
104
+ >;
105
+
106
+ export const convertGetPremintOfCollectionApiResponse = (
107
+ response: PremintSignatureGetOfCollectionResponse,
108
+ ) => ({
109
+ collection: convertCollectionFromApi({
110
+ contractAdmin: response.contract_admin,
111
+ contractName: response.contract_name,
112
+ contractURI: response.contract_uri,
113
+ }),
114
+ premints: response.premints.map((premint) => ({
115
+ premint: convertPremintFromApi(premint),
116
+ signature: premint.signature as Hex,
117
+ })),
94
118
  });
95
119
 
96
120
  const encodePremintV1ForAPI = ({
@@ -150,8 +174,8 @@ export type PremintSignatureResponse =
150
174
  * @returns
151
175
  */
152
176
  export const encodePostSignatureInput = <T extends PremintConfigVersion>({
153
- collection,
154
- collectionAddress,
177
+ contract: collection,
178
+ contractAddress: collectionAddress,
155
179
  premintConfigVersion,
156
180
  premintConfig,
157
181
  signature,
@@ -172,3 +196,13 @@ export const encodePostSignatureInput = <T extends PremintConfigVersion>({
172
196
  collection_address: collectionAddress,
173
197
  chain_name: networkConfigByChain[chainId]!.zoraBackendChainName,
174
198
  });
199
+
200
+ export const isPremintConfigV1 = (
201
+ premintConfigAndVersion: PremintConfigAndVersion,
202
+ ): premintConfigAndVersion is PremintConfigWithVersion<PremintConfigVersion.V1> =>
203
+ premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V1;
204
+
205
+ export const isPremintConfigV2 = (
206
+ premintConfigAndVersion: PremintConfigAndVersion,
207
+ ): premintConfigAndVersion is PremintConfigWithVersion<PremintConfigVersion.V2> =>
208
+ premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V2;
@@ -4,19 +4,19 @@ import {
4
4
  } from "../apis/http-api-base";
5
5
  import { components, paths } from "../apis/generated/premint-api-types";
6
6
  import { ZORA_API_BASE } from "../constants";
7
- import { NetworkConfig } from "src/apis/chain-constants";
8
- import { getApiNetworkConfigForChain } from "src/mint/mint-api-client";
7
+ import { getApiNetworkConfigForChain } from "src/mint/subgraph-mint-getter";
9
8
  import {
10
- ContractCreationConfig,
11
- PremintConfigAndVersion,
12
9
  PremintConfigVersion,
13
10
  PremintConfigWithVersion,
14
11
  } from "@zoralabs/protocol-deployments";
15
12
  import { Address, Hex } from "viem";
16
13
  import {
14
+ PremintCollectionFromApi,
15
+ PremintFromApi,
17
16
  PremintSignatureRequestBody,
18
17
  PremintSignatureResponse,
19
18
  convertGetPremintApiResponse,
19
+ convertGetPremintOfCollectionApiResponse,
20
20
  encodePostSignatureInput,
21
21
  } from "./conversions";
22
22
  import { ContractCreationConfigOrAddress } from "./contract-types";
@@ -30,11 +30,14 @@ export type PremintNextUIDGetResponse =
30
30
 
31
31
  type SignaturePremintGetType =
32
32
  paths["/signature/{chain_name}/{collection_address}/{uid}"]["get"];
33
- type PremintSignatureGetPathParameters =
34
- SignaturePremintGetType["parameters"]["path"];
35
33
  export type PremintSignatureGetResponse =
36
34
  SignaturePremintGetType["responses"][200]["content"]["application/json"];
37
35
 
36
+ type SignaturePremintGetOfCollectionType =
37
+ paths["/signature/{chain_name}/{collection_address}"]["get"];
38
+ export type PremintSignatureGetOfCollectionResponse =
39
+ SignaturePremintGetOfCollectionType["responses"][200]["content"]["application/json"];
40
+
38
41
  export type PremintCollection = PremintSignatureGetResponse["collection"];
39
42
 
40
43
  export type BackendChainNames = components["schemas"]["ChainName"];
@@ -50,57 +53,102 @@ const postSignature = async ({
50
53
  );
51
54
 
52
55
  const getNextUID = async ({
53
- chain_name,
56
+ chainId,
54
57
  collection_address,
55
58
  httpClient: { retries, get } = defaultHttpClient,
56
- }: PremintNextUIDGetPathParameters & {
59
+ }: Omit<PremintNextUIDGetPathParameters, "chain_name"> & {
60
+ chainId: number;
57
61
  httpClient?: Pick<IHttpClient, "retries" | "get">;
58
62
  }): Promise<PremintNextUIDGetResponse> =>
59
63
  retries(() =>
60
64
  get<PremintNextUIDGetResponse>(
61
- `${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/next_uid`,
65
+ `${ZORA_API_BASE}premint/signature/${
66
+ getApiNetworkConfigForChain(chainId).zoraBackendChainName
67
+ }/${collection_address}/next_uid`,
62
68
  ),
63
69
  );
64
70
 
65
- const getSignature = async ({
66
- collection_address,
71
+ export const getSignature = async ({
72
+ collectionAddress,
67
73
  uid,
68
- chain_name,
74
+ chainId,
69
75
  httpClient: { retries, get } = defaultHttpClient,
70
- }: PremintSignatureGetPathParameters & {
76
+ }: {
77
+ collectionAddress: Address;
78
+ uid: number;
79
+ chainId: number;
71
80
  httpClient?: Pick<IHttpClient, "retries" | "get">;
72
- }): Promise<
73
- PremintSignatureGetResponse & {
74
- premint_config_version?: PremintConfigVersion;
75
- }
76
- > => {
81
+ }): Promise<PremintFromApi> => {
82
+ const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
77
83
  const result = await retries(() =>
78
84
  get<PremintSignatureGetResponse>(
79
- `${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/${uid}`,
85
+ `${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}/${uid}`,
86
+ ),
87
+ );
88
+
89
+ return convertGetPremintApiResponse(result);
90
+ };
91
+
92
+ const getOfCollection = async ({
93
+ collectionAddress,
94
+ chainId,
95
+ httpClient: { retries, get } = defaultHttpClient,
96
+ }: {
97
+ collectionAddress: Address;
98
+ chainId: number;
99
+ httpClient?: Pick<IHttpClient, "retries" | "get">;
100
+ }) => {
101
+ const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
102
+ const result = await retries(() =>
103
+ get<PremintSignatureGetOfCollectionResponse>(
104
+ `${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}`,
80
105
  ),
81
106
  );
82
107
 
83
- return result;
108
+ return convertGetPremintOfCollectionApiResponse(result);
84
109
  };
85
110
 
86
- class PremintAPIClient {
111
+ export interface IPremintGetter {
112
+ get(params: {
113
+ collectionAddress: Address;
114
+ uid: number;
115
+ }): Promise<PremintFromApi>;
116
+
117
+ getOfCollection(params: {
118
+ collectionAddress: Address;
119
+ }): Promise<PremintCollectionFromApi>;
120
+ }
121
+
122
+ export interface IPremintAPI {
123
+ get: IPremintGetter["get"];
124
+
125
+ getOfCollection: IPremintGetter["getOfCollection"];
126
+
127
+ getNextUID(collectionAddress: Address): Promise<number>;
128
+
129
+ postSignature<T extends PremintConfigVersion>(
130
+ params: {
131
+ signature: Hex;
132
+ } & PremintConfigWithVersion<T> &
133
+ ContractCreationConfigOrAddress,
134
+ ): Promise<PremintSignatureResponse>;
135
+ }
136
+
137
+ class PremintAPIClient implements IPremintAPI {
138
+ chainId: number;
87
139
  httpClient: IHttpClient;
88
- networkConfig: NetworkConfig;
89
140
 
90
141
  constructor(chainId: number, httpClient?: IHttpClient) {
142
+ this.chainId = chainId;
91
143
  this.httpClient = httpClient || defaultHttpClient;
92
- this.networkConfig = getApiNetworkConfigForChain(chainId);
93
144
  }
94
- postSignature = async <T extends PremintConfigVersion>({
145
+ postSignature: IPremintAPI["postSignature"] = ({
95
146
  signature,
96
147
  ...rest
97
- }: {
98
- signature: Hex;
99
- } & PremintConfigWithVersion<T> &
100
- ContractCreationConfigOrAddress): Promise<PremintSignatureResponse> => {
148
+ }): Promise<PremintSignatureResponse> => {
101
149
  const data = encodePostSignatureInput({
102
150
  ...rest,
103
- chainId: this.networkConfig.chainId,
151
+ chainId: this.chainId,
104
152
  signature,
105
153
  });
106
154
  return postSignature({
@@ -109,36 +157,32 @@ class PremintAPIClient {
109
157
  });
110
158
  };
111
159
 
112
- getNextUID = async (collectionAddress: Address): Promise<number> =>
160
+ getNextUID: IPremintAPI["getNextUID"] = async (collectionAddress) =>
113
161
  (
114
162
  await getNextUID({
115
163
  collection_address: collectionAddress.toLowerCase(),
116
- chain_name: this.networkConfig.zoraBackendChainName,
164
+ chainId: this.chainId,
117
165
  httpClient: this.httpClient,
118
166
  })
119
167
  ).next_uid;
120
168
 
121
- getSignature = async ({
122
- collectionAddress,
123
- uid,
124
- }: {
125
- collectionAddress: Address;
126
- uid: number;
127
- }): Promise<
128
- {
129
- signature: Hex;
130
- collection: ContractCreationConfig | undefined;
131
- collectionAddress: Address;
132
- } & PremintConfigAndVersion
133
- > => {
134
- const response = await getSignature({
135
- collection_address: collectionAddress.toLowerCase(),
169
+ get: IPremintAPI["get"] = async ({ collectionAddress, uid }) => {
170
+ return getSignature({
171
+ collectionAddress,
136
172
  uid,
137
- chain_name: this.networkConfig.zoraBackendChainName,
173
+ chainId: this.chainId,
138
174
  httpClient: this.httpClient,
139
175
  });
176
+ };
140
177
 
141
- return convertGetPremintApiResponse(response);
178
+ getOfCollection: IPremintAPI["getOfCollection"] = async ({
179
+ collectionAddress,
180
+ }) => {
181
+ return getOfCollection({
182
+ collectionAddress,
183
+ chainId: this.chainId,
184
+ httpClient: this.httpClient,
185
+ });
142
186
  };
143
187
  }
144
188
 
@@ -1,7 +1,6 @@
1
1
  import { zoraSepolia } from "viem/chains";
2
2
  import { describe, expect, vi } from "vitest";
3
3
 
4
- import { createPremintClient } from "./premint-client";
5
4
  import { PremintConfigVersion } from "./contract-types";
6
5
  import {
7
6
  getDefaultFixedPriceMinterAddress,
@@ -12,6 +11,8 @@ import {
12
11
  ContractCreationConfig,
13
12
  PremintConfigV2,
14
13
  } from "@zoralabs/protocol-deployments";
14
+ import { PremintAPIClient } from "./premint-api-client";
15
+ import { createCollectorClient, createCreatorClient } from "src/sdk";
15
16
 
16
17
  const anvilTest = makeAnvilTest({
17
18
  forkUrl: forkUrls.zoraSepolia,
@@ -24,13 +25,11 @@ describe("ZoraCreator1155Premint", () => {
24
25
  "can mint premints",
25
26
  async ({ viemClients: { walletClient, publicClient, chain } }) => {
26
27
  const [deployerAccount] = await walletClient.getAddresses();
27
- const premintClient = createPremintClient({
28
- chain,
29
- publicClient,
30
- });
31
28
 
32
- premintClient.apiClient.getSignature = vi
33
- .fn<any, ReturnType<typeof premintClient.apiClient.getSignature>>()
29
+ const premintApiClient = new PremintAPIClient(chain.id);
30
+
31
+ premintApiClient.get = vi
32
+ .fn<any, ReturnType<typeof premintApiClient.get>>()
34
33
  .mockResolvedValue({
35
34
  collection: {
36
35
  contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
@@ -40,49 +39,55 @@ describe("ZoraCreator1155Premint", () => {
40
39
  additionalAdmins: [],
41
40
  },
42
41
  collectionAddress: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
43
- premintConfig: {
44
- deleted: false,
45
- tokenConfig: {
46
- fixedPriceMinter: getDefaultFixedPriceMinterAddress(chain.id),
47
- maxSupply: 18446744073709551615n,
48
- maxTokensPerAddress: 0n,
49
- mintDuration: 604800n,
50
- mintStart: 0n,
51
- pricePerToken: 0n,
52
- royaltyBPS: 1000,
53
- royaltyMintSchedule: 0,
54
- royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
55
- tokenURI:
56
- "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
42
+ premint: {
43
+ premintConfig: {
44
+ deleted: false,
45
+ tokenConfig: {
46
+ fixedPriceMinter: getDefaultFixedPriceMinterAddress(chain.id),
47
+ maxSupply: 18446744073709551615n,
48
+ maxTokensPerAddress: 0n,
49
+ mintDuration: 604800n,
50
+ mintStart: 0n,
51
+ pricePerToken: 0n,
52
+ royaltyBPS: 1000,
53
+ royaltyMintSchedule: 0,
54
+ royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
55
+ tokenURI:
56
+ "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
57
+ },
58
+ uid: 3,
59
+ version: 0,
57
60
  },
58
- uid: 3,
59
- version: 0,
61
+ premintConfigVersion: PremintConfigVersion.V1,
60
62
  },
61
- premintConfigVersion: PremintConfigVersion.V1,
63
+ signer: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
62
64
  signature:
63
65
  "0x4d191dd60d428adfe507932a1758bee8ac5bbb77dcd3c05840c237416a3a25035bb8cc7c62177a4e9acb5f40c4032cdb3dbfefdd1575f2c3b4c57945b2076e2e1c",
64
66
  });
65
67
 
66
- premintClient.apiClient.postSignature = vi.fn();
68
+ premintApiClient.postSignature = vi.fn();
67
69
 
68
- const simulateContractParameters = await premintClient.makeMintParameters(
69
- {
70
- minterAccount: deployerAccount!,
71
- tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
72
- uid: 3,
73
- mintArguments: {
74
- quantityToMint: 1,
75
- mintComment: "",
76
- },
77
- },
78
- );
79
- const { request: simulateRequest } = await publicClient.simulateContract(
80
- simulateContractParameters,
81
- );
70
+ const collectorClient = createCollectorClient({
71
+ chainId: chain.id,
72
+ publicClient,
73
+ premintGetter: premintApiClient,
74
+ });
75
+
76
+ const { parameters } = await collectorClient.mint({
77
+ mintType: "premint",
78
+ minterAccount: deployerAccount!,
79
+ tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
80
+ uid: 3,
81
+ quantityToMint: 1,
82
+ mintComment: "",
83
+ });
84
+ const { request: simulateRequest } =
85
+ await publicClient.simulateContract(parameters);
82
86
  const hash = await walletClient.writeContract(simulateRequest);
83
87
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
88
+
84
89
  const { premintedLog, urls } =
85
- premintClient.getDataFromPremintReceipt(receipt);
90
+ collectorClient.getCollectDataFromPremintReceipt(receipt);
86
91
 
87
92
  expect(urls).toEqual({
88
93
  explorer:
@@ -112,26 +117,29 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
112
117
  async ({ viemClients: { walletClient, publicClient, chain } }) => {
113
118
  const [creatorAccount, createReferralAccount] =
114
119
  await walletClient.getAddresses();
115
- const premintClient = createPremintClient({
116
- chain,
117
- publicClient,
118
- });
120
+ const premintApiClient = new PremintAPIClient(chain.id);
119
121
 
120
- premintClient.apiClient.getNextUID = vi
121
- .fn<any, ReturnType<typeof premintClient.apiClient.getNextUID>>()
122
+ premintApiClient.getNextUID = vi
123
+ .fn<any, ReturnType<typeof premintApiClient.getNextUID>>()
122
124
  .mockResolvedValue(3);
123
- premintClient.apiClient.postSignature = vi
124
- .fn<Parameters<typeof premintClient.apiClient.postSignature>>()
125
+ premintApiClient.postSignature = vi
126
+ .fn<Parameters<typeof premintApiClient.postSignature>>()
125
127
  .mockResolvedValue({ ok: true });
126
128
 
127
- const { signAndSubmit } = await premintClient.createPremint({
128
- collection: {
129
+ const creatorClient = createCreatorClient({
130
+ chainId: chain.id,
131
+ premintApi: premintApiClient,
132
+ publicClient,
133
+ });
134
+
135
+ const { signAndSubmit } = await creatorClient.createPremint({
136
+ contract: {
129
137
  contractAdmin: creatorAccount!,
130
138
  contractName: "Testing Contract Premint V2",
131
139
  contractURI:
132
140
  "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
133
141
  },
134
- tokenCreationConfig: {
142
+ token: {
135
143
  tokenURI:
136
144
  "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
137
145
  payoutRecipient: creatorAccount!,
@@ -146,22 +154,22 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
146
154
  });
147
155
 
148
156
  const expectedPostSignatureArgs: Parameters<
149
- typeof premintClient.apiClient.postSignature
157
+ typeof premintApiClient.postSignature
150
158
  >[0] = {
151
- collection: {
159
+ contract: {
152
160
  contractAdmin: creatorAccount!,
153
161
  contractName: "Testing Contract Premint V2",
154
162
  contractURI:
155
163
  "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
156
164
  },
157
- collectionAddress: undefined,
165
+ contractAddress: undefined,
158
166
  premintConfig: {
159
167
  deleted: false,
160
168
  tokenConfig: {
161
169
  fixedPriceMinter: "0x6d28164C3CE04A190D5F9f0f8881fc807EAD975A",
162
170
  maxSupply: 18446744073709551615n,
163
171
  maxTokensPerAddress: 0n,
164
- mintDuration: 604800n,
172
+ mintDuration: 0n,
165
173
  mintStart: 0n,
166
174
  pricePerToken: 0n,
167
175
  royaltyBPS: 1000,
@@ -175,10 +183,10 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
175
183
  },
176
184
  premintConfigVersion: PremintConfigVersion.V2,
177
185
  signature:
178
- "0x5cc8c0ab240920282cf936d8b5eb1dd151a91ad78cc4e89f8ddeae6ea432ce7904a38e145b734bdd438f18d457451cb1ae28beb2c44bda71d58638dfcc071e1b1c",
186
+ "0xfe5725c05754ad17a73cc9706bf940e30bd7b4a674bb1b283a66a1cc87022c8c13fcf8989f9feb675f8932a6a8ddb8d16af2abef28fa2fff3282487ef5385b3d1b",
179
187
  };
180
188
 
181
- expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
189
+ expect(premintApiClient.postSignature).toHaveBeenCalledWith(
182
190
  expectedPostSignatureArgs,
183
191
  );
184
192
  },
@@ -190,9 +198,19 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
190
198
  async ({ viemClients: { walletClient, publicClient, chain } }) => {
191
199
  const [deployerAccount, creatorAccount, additionalAdmin] =
192
200
  await walletClient.getAddresses();
193
- const premintClient = createPremintClient({
194
- chain,
201
+
202
+ const premintApiClient = new PremintAPIClient(chain.id);
203
+
204
+ const collectorClient = createCollectorClient({
205
+ chainId: chain.id,
195
206
  publicClient,
207
+ premintGetter: premintApiClient,
208
+ });
209
+
210
+ const creatorClient = createCreatorClient({
211
+ chainId: chain.id,
212
+ publicClient,
213
+ premintApi: premintApiClient,
196
214
  });
197
215
 
198
216
  const collection: ContractCreationConfig = {
@@ -204,14 +222,14 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
204
222
  };
205
223
 
206
224
  const collectionAddress = await getPremintCollectionAddress({
207
- collection,
225
+ contract: collection,
208
226
  publicClient,
209
227
  });
210
228
 
211
229
  const { premintConfig, typedDataDefinition } =
212
- await premintClient.createPremint({
213
- collection,
214
- tokenCreationConfig: {
230
+ await creatorClient.createPremint({
231
+ contract: collection,
232
+ token: {
215
233
  tokenURI:
216
234
  "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
217
235
  payoutRecipient: creatorAccount!,
@@ -223,36 +241,34 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
223
241
  account: additionalAdmin!,
224
242
  });
225
243
 
226
- premintClient.apiClient.getSignature = vi
227
- .fn<any, ReturnType<typeof premintClient.apiClient.getSignature>>()
244
+ premintApiClient.get = vi
245
+ .fn<any, ReturnType<typeof premintApiClient.get>>()
228
246
  .mockResolvedValue({
229
247
  collection,
230
248
  collectionAddress,
231
- premintConfig: premintConfig as PremintConfigV2,
232
- premintConfigVersion: PremintConfigVersion.V2,
249
+ premint: {
250
+ premintConfig: premintConfig as PremintConfigV2,
251
+ premintConfigVersion: PremintConfigVersion.V2,
252
+ },
253
+ signer: collection.contractAdmin,
233
254
  signature,
234
255
  });
235
256
 
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
- );
257
+ const { parameters } = await collectorClient.mint({
258
+ mintType: "premint",
259
+ uid: premintConfig.uid,
260
+ minterAccount: deployerAccount!,
261
+ tokenContract: collectionAddress,
262
+ quantityToMint: 1,
263
+ mintComment: "",
264
+ });
265
+ const { request: simulateRequest } =
266
+ await publicClient.simulateContract(parameters);
252
267
  const hash = await walletClient.writeContract(simulateRequest);
253
268
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
269
+
254
270
  const { premintedLog, urls } =
255
- premintClient.getDataFromPremintReceipt(receipt);
271
+ collectorClient.getCollectDataFromPremintReceipt(receipt);
256
272
 
257
273
  expect(urls).toEqual({
258
274
  explorer: `https://undefined/token/${collectionAddress}/instance/1`,