@zoralabs/protocol-sdk 0.5.17 → 0.6.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 (63) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +13 -0
  3. package/README.md +1 -416
  4. package/dist/create/1155-create-helper.d.ts +16 -55
  5. package/dist/create/1155-create-helper.d.ts.map +1 -1
  6. package/dist/create/contract-setup.d.ts +14 -0
  7. package/dist/create/contract-setup.d.ts.map +1 -0
  8. package/dist/create/token-setup.d.ts +27 -0
  9. package/dist/create/token-setup.d.ts.map +1 -0
  10. package/dist/create/types.d.ts +45 -0
  11. package/dist/create/types.d.ts.map +1 -0
  12. package/dist/index.cjs +1273 -857
  13. package/dist/index.cjs.map +1 -1
  14. package/dist/index.d.ts +3 -1
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +1233 -831
  17. package/dist/index.js.map +1 -1
  18. package/dist/mint/mint-client.d.ts +4083 -43
  19. package/dist/mint/mint-client.d.ts.map +1 -1
  20. package/dist/mint/subgraph-mint-getter.d.ts +17 -0
  21. package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
  22. package/dist/mint/types.d.ts +79 -0
  23. package/dist/mint/types.d.ts.map +1 -0
  24. package/dist/mints/mints-contracts.d.ts +24 -24
  25. package/dist/premint/contract-types.d.ts +4 -4
  26. package/dist/premint/contract-types.d.ts.map +1 -1
  27. package/dist/premint/conversions.d.ts +3 -1
  28. package/dist/premint/conversions.d.ts.map +1 -1
  29. package/dist/premint/premint-api-client.d.ts +27 -14
  30. package/dist/premint/premint-api-client.d.ts.map +1 -1
  31. package/dist/premint/premint-client.d.ts +62 -46
  32. package/dist/premint/premint-client.d.ts.map +1 -1
  33. package/dist/premint/preminter.d.ts +19 -7
  34. package/dist/premint/preminter.d.ts.map +1 -1
  35. package/dist/sdk.d.ts +43 -0
  36. package/dist/sdk.d.ts.map +1 -0
  37. package/dist/utils.d.ts +17 -6870
  38. package/dist/utils.d.ts.map +1 -1
  39. package/package.json +3 -2
  40. package/src/create/1155-create-helper.test.ts +235 -56
  41. package/src/create/1155-create-helper.ts +141 -309
  42. package/src/create/contract-setup.ts +88 -0
  43. package/src/create/token-setup.ts +379 -0
  44. package/src/create/types.ts +57 -0
  45. package/src/index.ts +5 -1
  46. package/src/mint/mint-client.test.ts +50 -61
  47. package/src/mint/mint-client.ts +321 -157
  48. package/src/mint/{mint-api-client.ts → subgraph-mint-getter.ts} +2 -25
  49. package/src/mint/types.ts +122 -0
  50. package/src/mints/mints-contracts.test.ts +1 -1
  51. package/src/mints/mints-contracts.ts +4 -4
  52. package/src/premint/contract-types.ts +4 -4
  53. package/src/premint/conversions.ts +12 -2
  54. package/src/premint/premint-api-client.ts +55 -43
  55. package/src/premint/premint-client.test.ts +75 -65
  56. package/src/premint/premint-client.ts +126 -153
  57. package/src/premint/preminter.test.ts +4 -5
  58. package/src/premint/preminter.ts +63 -13
  59. package/src/sdk.ts +98 -0
  60. package/src/utils.ts +30 -23
  61. package/test-integration/premint-client.test.ts +8 -8
  62. package/dist/mint/mint-api-client.d.ts +0 -35
  63. package/dist/mint/mint-api-client.d.ts.map +0 -1
@@ -0,0 +1,122 @@
1
+ import { Account, Address } from "viem";
2
+ import { GenericTokenIdTypes } from "src/types";
3
+
4
+ export type MintParameters<MintType> = {
5
+ /** Type of the collection to be minted. */
6
+ mintType: MintType;
7
+ };
8
+
9
+ export type Erc1155MintParameters = MintParameters<"1155"> & {
10
+ /** Token id to mint */
11
+ tokenId: GenericTokenIdTypes;
12
+ };
13
+
14
+ export type Erc721MintParameters = MintParameters<"721">;
15
+
16
+ export type OnChainMintParameters =
17
+ | Erc1155MintParameters
18
+ | Erc721MintParameters;
19
+
20
+ export type PremintMintParameters = MintParameters<"premint"> & {
21
+ /** uid of the Premint to mint */
22
+ uid: number;
23
+ };
24
+
25
+ export type MintType = "1155" | "721" | "premint";
26
+
27
+ export type MintTypes =
28
+ | Erc1155MintParameters
29
+ | Erc721MintParameters
30
+ | PremintMintParameters;
31
+
32
+ export const isOnChainMint = (mint: MintTypes): mint is OnChainMintParameters =>
33
+ mint.mintType !== "premint";
34
+
35
+ export const is1155Mint = (mint: MintTypes): mint is Erc1155MintParameters =>
36
+ mint.mintType === "1155";
37
+
38
+ export type MakeMintParametersArgumentsBase = {
39
+ /** Premint contract address */
40
+ tokenContract: Address;
41
+ /** Account to execute the mint */
42
+ minterAccount: Account | Address;
43
+ /** Quantity of tokens to mint. Defaults to 1 */
44
+ quantityToMint: number | bigint;
45
+ /** Comment to add to the mint */
46
+ mintComment?: string;
47
+ /** Address to receive the mint referral reward */
48
+ mintReferral?: Address;
49
+ /** Address to receive the minted tokens. Defaults to the minting account */
50
+ mintRecipient?: Address;
51
+ };
52
+
53
+ export type Make1155MintArguments = MakeMintParametersArgumentsBase &
54
+ Erc1155MintParameters & {
55
+ saleType?: SaleType;
56
+ };
57
+
58
+ export type Make721MintArguments = MakeMintParametersArgumentsBase &
59
+ Erc721MintParameters & {
60
+ saleType?: SaleType;
61
+ };
62
+
63
+ export type MakePremintMintParametersArguments =
64
+ MakeMintParametersArgumentsBase &
65
+ PremintMintParameters & {
66
+ /** Account to receive first minter reward, if this mint brings the premint onchain */
67
+ firstMinter?: Address;
68
+ };
69
+
70
+ export type MakeMintParametersArguments =
71
+ | Make1155MintArguments
72
+ | Make721MintArguments
73
+ | MakePremintMintParametersArguments;
74
+
75
+ export type GetMintCostsParameters = {
76
+ /** Address of token contract/collection to get the mint costs for */
77
+ collection: Address;
78
+ /** Quantity of tokens that will be minted */
79
+ quantityMinted: number | bigint;
80
+ } & MintTypes;
81
+
82
+ export type SaleType = "fixedPrice" | "erc20";
83
+
84
+ type SaleStrategy<T extends SaleType> = {
85
+ saleType: T;
86
+ address: Address;
87
+ pricePerToken: bigint;
88
+ saleEnd: string;
89
+ saleStart: string;
90
+ maxTokensPerAddress: bigint;
91
+ };
92
+
93
+ type FixedPriceSaleStrategy = SaleStrategy<"fixedPrice">;
94
+
95
+ type ERC20SaleStrategy = SaleStrategy<"erc20"> & {
96
+ currency: Address;
97
+ };
98
+
99
+ type SaleStrategies = FixedPriceSaleStrategy | ERC20SaleStrategy;
100
+
101
+ export function isErc20SaleStrategy(
102
+ salesConfig: SaleStrategies,
103
+ ): salesConfig is ERC20SaleStrategy {
104
+ return salesConfig.saleType === "erc20";
105
+ }
106
+
107
+ export type SalesConfigAndTokenInfo = {
108
+ salesConfig: SaleStrategies;
109
+ mintFeePerQuantity: bigint;
110
+ };
111
+
112
+ export interface IMintGetter {
113
+ getSalesConfigAndTokenInfo({
114
+ tokenAddress,
115
+ tokenId,
116
+ saleType,
117
+ }: {
118
+ tokenAddress: Address;
119
+ tokenId?: GenericTokenIdTypes;
120
+ saleType?: SaleType;
121
+ }): Promise<SalesConfigAndTokenInfo>;
122
+ }
@@ -77,7 +77,7 @@ const setupContractUsingPremint = async ({
77
77
  contractConfig.contractName = "Testing contract for MINTS";
78
78
 
79
79
  const contractAddress = await getPremintCollectionAddress({
80
- collection: contractConfig,
80
+ contract: contractConfig,
81
81
  publicClient,
82
82
  });
83
83
 
@@ -12,7 +12,7 @@ import {
12
12
  PremintConfigV2,
13
13
  } from "@zoralabs/protocol-deployments";
14
14
  import { ContractCreationConfig } from "src/preminter";
15
- import { makeSimulateContractParamaters } from "src/utils";
15
+ import { makeContractParameters } from "src/utils";
16
16
  import {
17
17
  Account,
18
18
  Address,
@@ -53,7 +53,7 @@ export const mintWithEthParams = ({
53
53
  pricePerMint: bigint;
54
54
  account: Address | Account;
55
55
  }) =>
56
- makeSimulateContractParamaters({
56
+ makeContractParameters({
57
57
  abi: zoraMintsManagerImplConfig.abi,
58
58
  address: zoraMintsManagerImplConfig.address[chainId],
59
59
  functionName: "mintWithEth",
@@ -152,7 +152,7 @@ export function collectWithMintsParams({
152
152
  mintArguments,
153
153
  });
154
154
 
155
- return makeSimulateContractParamaters({
155
+ return makeContractParameters({
156
156
  abi: zoraMints1155Config.abi,
157
157
  address: zoraMints1155Config.address[chainId],
158
158
  functionName: "transferBatchToManagerAndCall",
@@ -416,7 +416,7 @@ export function collectPremintV2WithMintsParams({
416
416
  ...rest,
417
417
  });
418
418
 
419
- return makeSimulateContractParamaters({
419
+ return makeContractParameters({
420
420
  abi: zoraMints1155Config.abi,
421
421
  address: zoraMints1155Config.address[chainId],
422
422
  functionName: "transferBatchToManagerAndCall",
@@ -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
  };
@@ -150,8 +150,8 @@ export type PremintSignatureResponse =
150
150
  * @returns
151
151
  */
152
152
  export const encodePostSignatureInput = <T extends PremintConfigVersion>({
153
- collection,
154
- collectionAddress,
153
+ contract: collection,
154
+ contractAddress: collectionAddress,
155
155
  premintConfigVersion,
156
156
  premintConfig,
157
157
  signature,
@@ -172,3 +172,13 @@ export const encodePostSignatureInput = <T extends PremintConfigVersion>({
172
172
  collection_address: collectionAddress,
173
173
  chain_name: networkConfigByChain[chainId]!.zoraBackendChainName,
174
174
  });
175
+
176
+ export const isPremintConfigV1 = (
177
+ premintConfigAndVersion: PremintConfigAndVersion,
178
+ ): premintConfigAndVersion is PremintConfigWithVersion<PremintConfigVersion.V1> =>
179
+ premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V1;
180
+
181
+ export const isPremintConfigV2 = (
182
+ premintConfigAndVersion: PremintConfigAndVersion,
183
+ ): premintConfigAndVersion is PremintConfigWithVersion<PremintConfigVersion.V2> =>
184
+ premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V2;
@@ -4,8 +4,7 @@ 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
9
  ContractCreationConfig,
11
10
  PremintConfigAndVersion,
@@ -30,8 +29,6 @@ export type PremintNextUIDGetResponse =
30
29
 
31
30
  type SignaturePremintGetType =
32
31
  paths["/signature/{chain_name}/{collection_address}/{uid}"]["get"];
33
- type PremintSignatureGetPathParameters =
34
- SignaturePremintGetType["parameters"]["path"];
35
32
  export type PremintSignatureGetResponse =
36
33
  SignaturePremintGetType["responses"][200]["content"]["application/json"];
37
34
 
@@ -50,57 +47,83 @@ const postSignature = async ({
50
47
  );
51
48
 
52
49
  const getNextUID = async ({
53
- chain_name,
50
+ chainId,
54
51
  collection_address,
55
52
  httpClient: { retries, get } = defaultHttpClient,
56
- }: PremintNextUIDGetPathParameters & {
53
+ }: Omit<PremintNextUIDGetPathParameters, "chain_name"> & {
54
+ chainId: number;
57
55
  httpClient?: Pick<IHttpClient, "retries" | "get">;
58
56
  }): Promise<PremintNextUIDGetResponse> =>
59
57
  retries(() =>
60
58
  get<PremintNextUIDGetResponse>(
61
- `${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/next_uid`,
59
+ `${ZORA_API_BASE}premint/signature/${
60
+ getApiNetworkConfigForChain(chainId).zoraBackendChainName
61
+ }/${collection_address}/next_uid`,
62
62
  ),
63
63
  );
64
64
 
65
- const getSignature = async ({
66
- collection_address,
65
+ export const getSignature = async ({
66
+ collectionAddress,
67
67
  uid,
68
- chain_name,
68
+ chainId,
69
69
  httpClient: { retries, get } = defaultHttpClient,
70
- }: PremintSignatureGetPathParameters & {
70
+ }: {
71
+ collectionAddress: Address;
72
+ uid: number;
73
+ chainId: number;
71
74
  httpClient?: Pick<IHttpClient, "retries" | "get">;
72
75
  }): Promise<
73
- PremintSignatureGetResponse & {
74
- premint_config_version?: PremintConfigVersion;
75
- }
76
+ {
77
+ signature: Hex;
78
+ collection: ContractCreationConfig | undefined;
79
+ collectionAddress: Address;
80
+ } & PremintConfigAndVersion
76
81
  > => {
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}`,
80
86
  ),
81
87
  );
82
88
 
83
- return result;
89
+ return convertGetPremintApiResponse(result);
84
90
  };
85
91
 
86
- class PremintAPIClient {
92
+ export interface IPremintGetter {
93
+ getSignature(params: {
94
+ collectionAddress: Address;
95
+ uid: number;
96
+ }): ReturnType<typeof getSignature>;
97
+ }
98
+
99
+ export interface IPremintAPI {
100
+ getSignature: IPremintGetter["getSignature"];
101
+
102
+ getNextUID(collectionAddress: Address): Promise<number>;
103
+
104
+ postSignature<T extends PremintConfigVersion>(
105
+ params: {
106
+ signature: Hex;
107
+ } & PremintConfigWithVersion<T> &
108
+ ContractCreationConfigOrAddress,
109
+ ): Promise<PremintSignatureResponse>;
110
+ }
111
+
112
+ class PremintAPIClient implements IPremintAPI {
113
+ chainId: number;
87
114
  httpClient: IHttpClient;
88
- networkConfig: NetworkConfig;
89
115
 
90
116
  constructor(chainId: number, httpClient?: IHttpClient) {
117
+ this.chainId = chainId;
91
118
  this.httpClient = httpClient || defaultHttpClient;
92
- this.networkConfig = getApiNetworkConfigForChain(chainId);
93
119
  }
94
- postSignature = async <T extends PremintConfigVersion>({
120
+ postSignature: IPremintAPI["postSignature"] = ({
95
121
  signature,
96
122
  ...rest
97
- }: {
98
- signature: Hex;
99
- } & PremintConfigWithVersion<T> &
100
- ContractCreationConfigOrAddress): Promise<PremintSignatureResponse> => {
123
+ }): Promise<PremintSignatureResponse> => {
101
124
  const data = encodePostSignatureInput({
102
125
  ...rest,
103
- chainId: this.networkConfig.chainId,
126
+ chainId: this.chainId,
104
127
  signature,
105
128
  });
106
129
  return postSignature({
@@ -109,36 +132,25 @@ class PremintAPIClient {
109
132
  });
110
133
  };
111
134
 
112
- getNextUID = async (collectionAddress: Address): Promise<number> =>
135
+ getNextUID: IPremintAPI["getNextUID"] = async (collectionAddress) =>
113
136
  (
114
137
  await getNextUID({
115
138
  collection_address: collectionAddress.toLowerCase(),
116
- chain_name: this.networkConfig.zoraBackendChainName,
139
+ chainId: this.chainId,
117
140
  httpClient: this.httpClient,
118
141
  })
119
142
  ).next_uid;
120
143
 
121
- getSignature = async ({
144
+ getSignature: IPremintAPI["getSignature"] = async ({
122
145
  collectionAddress,
123
146
  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(),
147
+ }) => {
148
+ return getSignature({
149
+ collectionAddress,
136
150
  uid,
137
- chain_name: this.networkConfig.zoraBackendChainName,
151
+ chainId: this.chainId,
138
152
  httpClient: this.httpClient,
139
153
  });
140
-
141
- return convertGetPremintApiResponse(response);
142
154
  };
143
155
  }
144
156
 
@@ -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.getSignature = vi
32
+ .fn<any, ReturnType<typeof premintApiClient.getSignature>>()
34
33
  .mockResolvedValue({
35
34
  collection: {
36
35
  contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
@@ -63,26 +62,29 @@ describe("ZoraCreator1155Premint", () => {
63
62
  "0x4d191dd60d428adfe507932a1758bee8ac5bbb77dcd3c05840c237416a3a25035bb8cc7c62177a4e9acb5f40c4032cdb3dbfefdd1575f2c3b4c57945b2076e2e1c",
64
63
  });
65
64
 
66
- premintClient.apiClient.postSignature = vi.fn();
65
+ premintApiClient.postSignature = vi.fn();
67
66
 
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
- );
67
+ const collectorClient = createCollectorClient({
68
+ chainId: chain.id,
69
+ publicClient,
70
+ premintGetter: premintApiClient,
71
+ });
72
+
73
+ const { parameters } = await collectorClient.mint({
74
+ mintType: "premint",
75
+ minterAccount: deployerAccount!,
76
+ tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
77
+ uid: 3,
78
+ quantityToMint: 1,
79
+ mintComment: "",
80
+ });
81
+ const { request: simulateRequest } =
82
+ await publicClient.simulateContract(parameters);
82
83
  const hash = await walletClient.writeContract(simulateRequest);
83
84
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
85
+
84
86
  const { premintedLog, urls } =
85
- premintClient.getDataFromPremintReceipt(receipt);
87
+ collectorClient.getCollectDataFromPremintReceipt(receipt);
86
88
 
87
89
  expect(urls).toEqual({
88
90
  explorer:
@@ -112,26 +114,29 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
112
114
  async ({ viemClients: { walletClient, publicClient, chain } }) => {
113
115
  const [creatorAccount, createReferralAccount] =
114
116
  await walletClient.getAddresses();
115
- const premintClient = createPremintClient({
116
- chain,
117
- publicClient,
118
- });
117
+ const premintApiClient = new PremintAPIClient(chain.id);
119
118
 
120
- premintClient.apiClient.getNextUID = vi
121
- .fn<any, ReturnType<typeof premintClient.apiClient.getNextUID>>()
119
+ premintApiClient.getNextUID = vi
120
+ .fn<any, ReturnType<typeof premintApiClient.getNextUID>>()
122
121
  .mockResolvedValue(3);
123
- premintClient.apiClient.postSignature = vi
124
- .fn<Parameters<typeof premintClient.apiClient.postSignature>>()
122
+ premintApiClient.postSignature = vi
123
+ .fn<Parameters<typeof premintApiClient.postSignature>>()
125
124
  .mockResolvedValue({ ok: true });
126
125
 
127
- const { signAndSubmit } = await premintClient.createPremint({
128
- collection: {
126
+ const creatorClient = createCreatorClient({
127
+ chainId: chain.id,
128
+ premintApi: premintApiClient,
129
+ publicClient,
130
+ });
131
+
132
+ const { signAndSubmit } = await creatorClient.createPremint({
133
+ contract: {
129
134
  contractAdmin: creatorAccount!,
130
135
  contractName: "Testing Contract Premint V2",
131
136
  contractURI:
132
137
  "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
133
138
  },
134
- tokenCreationConfig: {
139
+ token: {
135
140
  tokenURI:
136
141
  "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
137
142
  payoutRecipient: creatorAccount!,
@@ -146,22 +151,22 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
146
151
  });
147
152
 
148
153
  const expectedPostSignatureArgs: Parameters<
149
- typeof premintClient.apiClient.postSignature
154
+ typeof premintApiClient.postSignature
150
155
  >[0] = {
151
- collection: {
156
+ contract: {
152
157
  contractAdmin: creatorAccount!,
153
158
  contractName: "Testing Contract Premint V2",
154
159
  contractURI:
155
160
  "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
156
161
  },
157
- collectionAddress: undefined,
162
+ contractAddress: undefined,
158
163
  premintConfig: {
159
164
  deleted: false,
160
165
  tokenConfig: {
161
166
  fixedPriceMinter: "0x6d28164C3CE04A190D5F9f0f8881fc807EAD975A",
162
167
  maxSupply: 18446744073709551615n,
163
168
  maxTokensPerAddress: 0n,
164
- mintDuration: 604800n,
169
+ mintDuration: 0n,
165
170
  mintStart: 0n,
166
171
  pricePerToken: 0n,
167
172
  royaltyBPS: 1000,
@@ -175,10 +180,10 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
175
180
  },
176
181
  premintConfigVersion: PremintConfigVersion.V2,
177
182
  signature:
178
- "0x5cc8c0ab240920282cf936d8b5eb1dd151a91ad78cc4e89f8ddeae6ea432ce7904a38e145b734bdd438f18d457451cb1ae28beb2c44bda71d58638dfcc071e1b1c",
183
+ "0xfe5725c05754ad17a73cc9706bf940e30bd7b4a674bb1b283a66a1cc87022c8c13fcf8989f9feb675f8932a6a8ddb8d16af2abef28fa2fff3282487ef5385b3d1b",
179
184
  };
180
185
 
181
- expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
186
+ expect(premintApiClient.postSignature).toHaveBeenCalledWith(
182
187
  expectedPostSignatureArgs,
183
188
  );
184
189
  },
@@ -190,9 +195,19 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
190
195
  async ({ viemClients: { walletClient, publicClient, chain } }) => {
191
196
  const [deployerAccount, creatorAccount, additionalAdmin] =
192
197
  await walletClient.getAddresses();
193
- const premintClient = createPremintClient({
194
- chain,
198
+
199
+ const premintApiClient = new PremintAPIClient(chain.id);
200
+
201
+ const collectorClient = createCollectorClient({
202
+ chainId: chain.id,
195
203
  publicClient,
204
+ premintGetter: premintApiClient,
205
+ });
206
+
207
+ const creatorClient = createCreatorClient({
208
+ chainId: chain.id,
209
+ publicClient,
210
+ premintApi: premintApiClient,
196
211
  });
197
212
 
198
213
  const collection: ContractCreationConfig = {
@@ -204,14 +219,14 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
204
219
  };
205
220
 
206
221
  const collectionAddress = await getPremintCollectionAddress({
207
- collection,
222
+ contract: collection,
208
223
  publicClient,
209
224
  });
210
225
 
211
226
  const { premintConfig, typedDataDefinition } =
212
- await premintClient.createPremint({
213
- collection,
214
- tokenCreationConfig: {
227
+ await creatorClient.createPremint({
228
+ contract: collection,
229
+ token: {
215
230
  tokenURI:
216
231
  "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
217
232
  payoutRecipient: creatorAccount!,
@@ -223,8 +238,8 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
223
238
  account: additionalAdmin!,
224
239
  });
225
240
 
226
- premintClient.apiClient.getSignature = vi
227
- .fn<any, ReturnType<typeof premintClient.apiClient.getSignature>>()
241
+ premintApiClient.getSignature = vi
242
+ .fn<any, ReturnType<typeof premintApiClient.getSignature>>()
228
243
  .mockResolvedValue({
229
244
  collection,
230
245
  collectionAddress,
@@ -233,26 +248,21 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
233
248
  signature,
234
249
  });
235
250
 
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
- );
251
+ const { parameters } = await collectorClient.mint({
252
+ mintType: "premint",
253
+ uid: premintConfig.uid,
254
+ minterAccount: deployerAccount!,
255
+ tokenContract: collectionAddress,
256
+ quantityToMint: 1,
257
+ mintComment: "",
258
+ });
259
+ const { request: simulateRequest } =
260
+ await publicClient.simulateContract(parameters);
252
261
  const hash = await walletClient.writeContract(simulateRequest);
253
262
  const receipt = await publicClient.waitForTransactionReceipt({ hash });
263
+
254
264
  const { premintedLog, urls } =
255
- premintClient.getDataFromPremintReceipt(receipt);
265
+ collectorClient.getCollectDataFromPremintReceipt(receipt);
256
266
 
257
267
  expect(urls).toEqual({
258
268
  explorer: `https://undefined/token/${collectionAddress}/instance/1`,