@zoralabs/protocol-sdk 0.4.3 → 0.5.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.
Files changed (39) hide show
  1. package/.turbo/turbo-build.log +15 -14
  2. package/CHANGELOG.md +28 -1
  3. package/README.md +1 -1
  4. package/dist/anvil.d.ts +6 -2
  5. package/dist/anvil.d.ts.map +1 -1
  6. package/dist/apis/chain-constants.d.ts +4 -12
  7. package/dist/apis/chain-constants.d.ts.map +1 -1
  8. package/dist/index.cjs +55 -66
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.js +58 -71
  11. package/dist/index.js.map +1 -1
  12. package/dist/premint/conversions.d.ts +1 -1
  13. package/dist/premint/conversions.d.ts.map +1 -1
  14. package/dist/premint/premint-client.d.ts +4 -4
  15. package/dist/premint/premint-client.d.ts.map +1 -1
  16. package/dist/premint/preminter.d.ts +3 -3
  17. package/dist/premint/preminter.d.ts.map +1 -1
  18. package/package.json +10 -8
  19. package/src/anvil.ts +10 -3
  20. package/src/apis/chain-constants.ts +31 -32
  21. package/src/mint/mint-client.test.ts +1 -1
  22. package/src/premint/conversions.ts +12 -6
  23. package/src/premint/premint-client.test.ts +14 -64
  24. package/src/premint/premint-client.ts +25 -27
  25. package/src/premint/preminter.test.ts +1 -1
  26. package/src/premint/preminter.ts +9 -23
  27. package/test-integration/premint-client.test.ts +146 -0
  28. package/tsconfig.build.json +10 -0
  29. package/tsconfig.json +1 -1
  30. package/tsup.config.js +2 -1
  31. package/.turbo/turbo-lint.log +0 -5
  32. package/dist/create/1155-create-helper.test.d.ts +0 -2
  33. package/dist/create/1155-create-helper.test.d.ts.map +0 -1
  34. package/dist/mint/mint-client.test.d.ts +0 -2
  35. package/dist/mint/mint-client.test.d.ts.map +0 -1
  36. package/dist/premint/premint-client.test.d.ts +0 -2
  37. package/dist/premint/premint-client.test.d.ts.map +0 -1
  38. package/dist/premint/preminter.test.d.ts +0 -2
  39. package/dist/premint/preminter.test.d.ts.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zoralabs/protocol-sdk",
3
- "version": "0.4.3",
3
+ "version": "0.5.1",
4
4
  "repository": "https://github.com/ourzora/zora-protocol",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -10,22 +10,24 @@
10
10
  "build": "tsup",
11
11
  "prepack": "yarn build",
12
12
  "test:js": "vitest src",
13
- "generate-types": "npx openapi-typescript https://api.zora.co/premint/openapi.json -o src/generated/premint-api-types.ts && npx openapi-typescript https://api.zora.co/discover/openapi.json -o src/generated/discover-api-types.ts",
14
- "prettier": "prettier --write 'src/**/*.ts'",
15
- "lint": "prettier --check 'src/**/*.ts'"
13
+ "test:integration": "vitest test-integration",
14
+ "generate-types": "echo 'npx is used here because this is a rare operation' && npx openapi-typescript https://api.zora.co/premint/openapi.json -o src/generated/premint-api-types.ts && yarn openapi-typescript https://api.zora.co/discover/openapi.json -o src/generated/discover-api-types.ts",
15
+ "prettier": "prettier --write 'src/**/*.ts' 'test-integration/**/*.ts'",
16
+ "lint": "prettier --check 'src/**/*.ts' 'test-integration/**/*.ts'"
16
17
  },
17
18
  "dependencies": {
18
19
  "@zoralabs/protocol-deployments": "*",
19
- "abitype": "^0.8.7",
20
+ "abitype": "^0.10.3",
20
21
  "vite": "4.5.0"
21
22
  },
22
23
  "peerDependencies": {
23
- "viem": "^1.16.6"
24
+ "viem": "^1.19.15"
24
25
  },
25
26
  "devDependencies": {
27
+ "@lavamoat/preinstall-always-fail": "2.0.0",
26
28
  "zoralabs-tsconfig": "*",
27
29
  "typescript": "^5.2.2",
28
- "vite": "4.5.0",
29
- "vitest": "0.34.6"
30
+ "vite": "^4.5.0",
31
+ "vitest": "^0.34.6"
30
32
  }
31
33
  }
package/src/anvil.ts CHANGED
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
2
2
  import { join } from "path";
3
3
  import { test } from "vitest";
4
4
  import {
5
+ Chain,
5
6
  PublicClient,
6
7
  TestClient,
7
8
  WalletClient,
@@ -10,13 +11,14 @@ import {
10
11
  createWalletClient,
11
12
  http,
12
13
  } from "viem";
13
- import { foundry } from "viem/chains";
14
+ import { foundry, zora } from "viem/chains";
14
15
 
15
16
  export interface AnvilViemClientsTest {
16
17
  viemClients: {
17
18
  walletClient: WalletClient;
18
19
  publicClient: PublicClient;
19
20
  testClient: TestClient;
21
+ chain: Chain;
20
22
  };
21
23
  }
22
24
 
@@ -31,11 +33,13 @@ async function waitForAnvilInit(anvil: any) {
31
33
  export type AnvilTestForkSettings = {
32
34
  forkUrl: string;
33
35
  forkBlockNumber: number;
36
+ anvilChainId?: number;
34
37
  };
35
38
 
36
39
  export const makeAnvilTest = ({
37
40
  forkUrl,
38
41
  forkBlockNumber,
42
+ anvilChainId = 31337,
39
43
  }: AnvilTestForkSettings) =>
40
44
  test.extend<AnvilViemClientsTest>({
41
45
  viemClients: async ({ task }, use) => {
@@ -51,7 +55,7 @@ export const makeAnvilTest = ({
51
55
  "--fork-block-number",
52
56
  `${forkBlockNumber}`,
53
57
  "--chain-id",
54
- "31337",
58
+ anvilChainId.toString(),
55
59
  ],
56
60
  {
57
61
  cwd: join(__dirname, ".."),
@@ -61,8 +65,9 @@ export const makeAnvilTest = ({
61
65
  const anvilHost = `http://0.0.0.0:${port}`;
62
66
  await waitForAnvilInit(anvil);
63
67
 
64
- const chain = {
68
+ const chain: Chain = {
65
69
  ...foundry,
70
+ id: anvilChainId,
66
71
  };
67
72
 
68
73
  const walletClient = createWalletClient({
@@ -85,6 +90,7 @@ export const makeAnvilTest = ({
85
90
  publicClient,
86
91
  walletClient,
87
92
  testClient,
93
+ chain,
88
94
  });
89
95
 
90
96
  // clean up function, called once after all tests run
@@ -101,4 +107,5 @@ export const forkUrls = {
101
107
  export const anvilTest = makeAnvilTest({
102
108
  forkUrl: forkUrls.zoraMainnet,
103
109
  forkBlockNumber: 7866332,
110
+ anvilChainId: zora.id,
104
111
  });
@@ -7,95 +7,94 @@ import {
7
7
  optimism,
8
8
  optimismGoerli,
9
9
  zora,
10
+ zoraSepolia,
10
11
  zoraTestnet,
11
12
  } from "viem/chains";
12
13
  import type { components } from "./generated/premint-api-types";
13
14
  import { parseEther } from "viem";
14
15
  import { getSubgraph } from "../constants";
15
16
 
17
+ type BackendChainName = components["schemas"]["ChainName"];
18
+
16
19
  export type NetworkConfig = {
17
20
  chainId: number;
18
- zoraPathChainName: string;
19
- zoraBackendChainName: components["schemas"]["ChainName"];
21
+ zoraCollectPathChainName: string;
22
+ zoraBackendChainName: BackendChainName;
20
23
  isTestnet: boolean;
21
24
  subgraphUrl: string;
22
25
  };
23
26
 
24
27
  export const REWARD_PER_TOKEN = parseEther("0.000777");
25
28
 
26
- export const BackendChainNamesLookup = {
27
- ZORA_MAINNET: "ZORA-MAINNET",
28
- ZORA_GOERLI: "ZORA-GOERLI",
29
- OPTIMISM_MAINNET: "OPTIMISM-MAINNET",
30
- OPTIMISM_GOERLI: "OPTIMISM-GOERLI",
31
- ETHEREUM_MAINNET: "ETHEREUM-MAINNET",
32
- ETHEREUM_GOERLI: "ETHEREUM-GOERLI",
33
- BASE_MAINNET: "BASE-MAINNET",
34
- BASE_GOERLI: "BASE-GOERLI",
35
- } as const;
36
-
37
29
  export const networkConfigByChain: Record<number, NetworkConfig> = {
38
30
  [mainnet.id]: {
39
31
  chainId: mainnet.id,
40
32
  isTestnet: false,
41
- zoraPathChainName: "eth",
42
- zoraBackendChainName: BackendChainNamesLookup.ETHEREUM_MAINNET,
33
+ zoraCollectPathChainName: "eth",
34
+ zoraBackendChainName: "ETHEREUM-MAINNET",
43
35
  subgraphUrl: getSubgraph("zora-create-mainnet", "stable"),
44
36
  },
45
37
  [goerli.id]: {
46
38
  chainId: goerli.id,
47
39
  isTestnet: true,
48
- zoraPathChainName: "gor",
49
- zoraBackendChainName: BackendChainNamesLookup.ETHEREUM_GOERLI,
40
+ zoraCollectPathChainName: "gor",
41
+ zoraBackendChainName: "ETHEREUM-GOERLI",
50
42
  subgraphUrl: getSubgraph("zora-create-goerli", "stable"),
51
43
  },
52
44
  [zora.id]: {
53
45
  chainId: zora.id,
54
46
  isTestnet: false,
55
- zoraPathChainName: "zora",
56
- zoraBackendChainName: BackendChainNamesLookup.ZORA_MAINNET,
47
+ zoraCollectPathChainName: "zora",
48
+ zoraBackendChainName: "ZORA-MAINNET",
57
49
  subgraphUrl: getSubgraph("zora-create-zora-mainnet", "stable"),
58
50
  },
59
51
  [zoraTestnet.id]: {
60
- chainId: zora.id,
52
+ chainId: zoraTestnet.id,
61
53
  isTestnet: true,
62
- zoraPathChainName: "zgor",
63
- zoraBackendChainName: BackendChainNamesLookup.ZORA_GOERLI,
54
+ zoraCollectPathChainName: "zgor",
55
+ zoraBackendChainName: "ZORA-GOERLI",
64
56
  subgraphUrl: getSubgraph("zora-create-zora-testnet", "stable"),
65
57
  },
58
+ [zoraSepolia.id]: {
59
+ chainId: zoraSepolia.id,
60
+ isTestnet: true,
61
+ zoraCollectPathChainName: "zsep",
62
+ zoraBackendChainName: "ZORA-SEPOLIA",
63
+ subgraphUrl: getSubgraph("zora-create-zora-sepolia", "stable"),
64
+ },
66
65
  [optimism.id]: {
67
66
  chainId: optimism.id,
68
67
  isTestnet: false,
69
- zoraPathChainName: "opt",
70
- zoraBackendChainName: BackendChainNamesLookup.OPTIMISM_MAINNET,
68
+ zoraCollectPathChainName: "opt",
69
+ zoraBackendChainName: "OPTIMISM-MAINNET",
71
70
  subgraphUrl: getSubgraph("zora-create-optimism", "stable"),
72
71
  },
73
72
  [optimismGoerli.id]: {
74
73
  chainId: optimismGoerli.id,
75
74
  isTestnet: true,
76
- zoraPathChainName: "ogor",
77
- zoraBackendChainName: BackendChainNamesLookup.OPTIMISM_GOERLI,
75
+ zoraCollectPathChainName: "ogor",
76
+ zoraBackendChainName: "OPTIMISM-GOERLI",
78
77
  subgraphUrl: getSubgraph("zora-create-optimism-goerli", "stable"),
79
78
  },
80
79
  [base.id]: {
81
80
  chainId: base.id,
82
81
  isTestnet: false,
83
- zoraPathChainName: "base",
84
- zoraBackendChainName: BackendChainNamesLookup.BASE_MAINNET,
82
+ zoraCollectPathChainName: "base",
83
+ zoraBackendChainName: "BASE-MAINNET",
85
84
  subgraphUrl: getSubgraph("zora-create-base-mainnet", "stable"),
86
85
  },
87
86
  [baseGoerli.id]: {
88
87
  chainId: baseGoerli.id,
89
88
  isTestnet: true,
90
- zoraPathChainName: "bgor",
91
- zoraBackendChainName: BackendChainNamesLookup.BASE_GOERLI,
89
+ zoraCollectPathChainName: "bgor",
90
+ zoraBackendChainName: "BASE-GOERLI",
92
91
  subgraphUrl: getSubgraph("zora-create-base-goerli", "stable"),
93
92
  },
94
93
  [foundry.id]: {
95
94
  chainId: foundry.id,
96
95
  isTestnet: true,
97
- zoraPathChainName: "zgor",
98
- zoraBackendChainName: BackendChainNamesLookup.ZORA_GOERLI,
96
+ zoraCollectPathChainName: "zgor",
97
+ zoraBackendChainName: "ZORA-GOERLI",
99
98
  subgraphUrl: getSubgraph("zora-create-zora-testnet", "stable"),
100
99
  },
101
100
  };
@@ -96,7 +96,7 @@ describe("mint-helper", () => {
96
96
 
97
97
  const hash = await walletClient.writeContract(simulated.request);
98
98
 
99
- const receipt = await publicClient.getTransactionReceipt({ hash });
99
+ const receipt = await publicClient.waitForTransactionReceipt({ hash });
100
100
  expect(receipt).not.to.be.null;
101
101
 
102
102
  const newBalance = await publicClient.readContract({
@@ -1,3 +1,5 @@
1
+ import { networkConfigByChain } from "src/apis/chain-constants";
2
+ import { components, paths } from "src/apis/generated/premint-api-types";
1
3
  import { Address, Hex } from "viem";
2
4
  import {
3
5
  ContractCreationConfig,
@@ -8,8 +10,6 @@ import {
8
10
  PremintConfigWithVersion,
9
11
  } from "./contract-types";
10
12
  import { PremintSignatureGetResponse } from "./premint-api-client";
11
- import { components, paths } from "src/apis/generated/premint-api-types";
12
- import { networkConfigByChain } from "src/apis/chain-constants";
13
13
 
14
14
  export const convertCollectionFromApi = (
15
15
  collection: PremintSignatureGetResponse["collection"],
@@ -36,7 +36,9 @@ export const convertPremintFromApi = (
36
36
  return {
37
37
  premintConfigVersion: PremintConfigVersion.V1,
38
38
  premintConfig: {
39
- ...premint,
39
+ deleted: premint.deleted,
40
+ uid: premint.uid,
41
+ version: premint.version,
40
42
  tokenConfig: {
41
43
  ...tokenConfig,
42
44
  fixedPriceMinter: tokenConfig.fixedPriceMinter as Address,
@@ -55,7 +57,9 @@ export const convertPremintFromApi = (
55
57
  return {
56
58
  premintConfigVersion: PremintConfigVersion.V2,
57
59
  premintConfig: {
58
- ...premint,
60
+ deleted: premint.deleted,
61
+ uid: premint.uid,
62
+ version: premint.version,
59
63
  tokenConfig: {
60
64
  ...tokenConfig,
61
65
  fixedPriceMinter: tokenConfig.fixedPriceMinter as Address,
@@ -85,6 +89,7 @@ const encodePremintV1ForAPI = ({
85
89
  ...premint
86
90
  }: PremintConfigV1): PremintSignatureGetResponse["premint"] => ({
87
91
  ...premint,
92
+ config_version: "1",
88
93
  tokenConfig: {
89
94
  ...tokenConfig,
90
95
  maxSupply: tokenConfig.maxSupply.toString(),
@@ -98,8 +103,9 @@ const encodePremintV1ForAPI = ({
98
103
  const encodePremintV2ForAPI = ({
99
104
  tokenConfig,
100
105
  ...premint
101
- }: PremintConfigV2) => ({
106
+ }: PremintConfigV2): PremintSignatureRequestBody["premint"] => ({
102
107
  ...premint,
108
+ config_version: "2",
103
109
  tokenConfig: {
104
110
  ...tokenConfig,
105
111
  maxSupply: tokenConfig.maxSupply.toString(),
@@ -148,7 +154,7 @@ export const encodePostSignatureInput = <T extends PremintConfigVersion>({
148
154
  premint: encodePremintForAPI({
149
155
  premintConfig,
150
156
  premintConfigVersion,
151
- }) as PremintSignatureRequestBody["premint"],
157
+ }),
152
158
  signature,
153
159
  collection,
154
160
  chain_name: networkConfigByChain[chainId]!.zoraBackendChainName,
@@ -1,22 +1,18 @@
1
1
  import { foundry } from "viem/chains";
2
2
  import { describe, expect, vi } from "vitest";
3
3
 
4
- import { Address, Hex } from "viem";
5
4
  import { createPremintClient } from "./premint-client";
6
5
  import { anvilTest } from "src/anvil";
7
- import {
8
- ContractCreationConfig,
9
- PremintConfigV1,
10
- PremintConfigVersion,
11
- } from "./contract-types";
6
+ import { PremintConfigVersion } from "./contract-types";
7
+ import { getDefaultFixedPriceMinterAddress } from "./preminter";
12
8
 
13
9
  describe("ZoraCreator1155Premint - v1 signatures", () => {
14
10
  anvilTest(
15
11
  "can sign by default v1 on the forked premint contract",
16
- async ({ viemClients: { walletClient, publicClient } }) => {
12
+ async ({ viemClients: { walletClient, publicClient, chain } }) => {
17
13
  const [deployerAccount] = await walletClient.getAddresses();
18
14
  const premintClient = createPremintClient({
19
- chain: foundry,
15
+ chain,
20
16
  publicClient,
21
17
  });
22
18
 
@@ -55,7 +51,7 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
55
51
  premintConfig: {
56
52
  deleted: false,
57
53
  tokenConfig: {
58
- fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
54
+ fixedPriceMinter: getDefaultFixedPriceMinterAddress(chain.id),
59
55
  maxSupply: 18446744073709551615n,
60
56
  maxTokensPerAddress: 0n,
61
57
  mintDuration: 604800n,
@@ -72,7 +68,7 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
72
68
  },
73
69
  premintConfigVersion: PremintConfigVersion.V1,
74
70
  signature:
75
- "0x8c6a9160a0917d98c201b37c9220c17ebaed23a5f905202341c1d0d4e8673c3913880907d6de48c9858fbeb40a9a38d5edda979e4dcb133643ca8ecb4afe0b691b",
71
+ "0x70fc1d6e862c42f2b0e4a062f4eb973cc8692df58a24b71b4fe91ae7baa5a26d2c99b1b8ab61f64ff431bf30b0897877b11b7405542c90b89b041808f1561a6c1c",
76
72
  };
77
73
 
78
74
  expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
@@ -82,55 +78,9 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
82
78
  20 * 1000,
83
79
  );
84
80
 
85
- anvilTest(
86
- "can validate premint on network",
87
- async ({ viemClients: { publicClient } }) => {
88
- const premintClient = createPremintClient({
89
- chain: foundry,
90
- publicClient,
91
- });
92
-
93
- const collection: ContractCreationConfig = {
94
- contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" as Address,
95
- contractName: "Testing Contract",
96
- contractURI:
97
- "ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
98
- };
99
- const premint: PremintConfigV1 = {
100
- uid: 3,
101
- version: 1,
102
- deleted: false,
103
- tokenConfig: {
104
- maxSupply: 18446744073709551615n,
105
- maxTokensPerAddress: 0n,
106
- pricePerToken: 0n,
107
- mintDuration: 604800n,
108
- mintStart: 0n,
109
- royaltyMintSchedule: 0,
110
- royaltyBPS: 1000,
111
- fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
112
- royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
113
- tokenURI:
114
- "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
115
- },
116
- };
117
-
118
- const signature =
119
- "0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c" as Hex;
120
-
121
- const signatureValid = await premintClient.isValidSignature({
122
- collection: collection,
123
- premintConfig: premint,
124
- signature,
125
- // default to premint config v1 version (we dont need to specify it here)
126
- });
127
- expect(signatureValid.isValid).toBe(true);
128
- },
129
- );
130
-
131
81
  anvilTest(
132
82
  "can execute premint on network",
133
- async ({ viemClients: { walletClient, publicClient } }) => {
83
+ async ({ viemClients: { walletClient, publicClient, chain } }) => {
134
84
  const [deployerAccount] = await walletClient.getAddresses();
135
85
  const premintClient = createPremintClient({
136
86
  chain: foundry,
@@ -149,7 +99,7 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
149
99
  premintConfig: {
150
100
  deleted: false,
151
101
  tokenConfig: {
152
- fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
102
+ fixedPriceMinter: getDefaultFixedPriceMinterAddress(chain.id),
153
103
  maxSupply: 18446744073709551615n,
154
104
  maxTokensPerAddress: 0n,
155
105
  mintDuration: 604800n,
@@ -162,18 +112,18 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
162
112
  "ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
163
113
  },
164
114
  uid: 3,
165
- version: 1,
115
+ version: 0,
166
116
  },
167
117
  premintConfigVersion: PremintConfigVersion.V1,
168
118
  signature:
169
- "0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c",
119
+ "0x70fc1d6e862c42f2b0e4a062f4eb973cc8692df58a24b71b4fe91ae7baa5a26d2c99b1b8ab61f64ff431bf30b0897877b11b7405542c90b89b041808f1561a6c1c",
170
120
  });
171
121
 
172
122
  premintClient.apiClient.postSignature = vi.fn();
173
123
 
174
124
  const simulateContractParameters = await premintClient.makeMintParameters(
175
125
  {
176
- account: deployerAccount!,
126
+ minterAccount: deployerAccount!,
177
127
  tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
178
128
  uid: 3,
179
129
  mintArguments: {
@@ -215,11 +165,11 @@ describe("ZoraCreator1155Premint - v1 signatures", () => {
215
165
  describe("ZoraCreator1155Premint - v2 signatures", () => {
216
166
  anvilTest(
217
167
  "can sign on the forked premint contract",
218
- async ({ viemClients: { walletClient, publicClient } }) => {
168
+ async ({ viemClients: { walletClient, publicClient, chain } }) => {
219
169
  const [creatorAccount, createReferralAccount] =
220
170
  await walletClient.getAddresses();
221
171
  const premintClient = createPremintClient({
222
- chain: foundry,
172
+ chain,
223
173
  publicClient,
224
174
  });
225
175
 
@@ -277,7 +227,7 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
277
227
  },
278
228
  premintConfigVersion: PremintConfigVersion.V2,
279
229
  signature:
280
- "0xd0a9d8164911237430fe2c76ccfd4f53925a9e14e29da19b98ed5ed59e262b0d6ef24efe8b828b79e7b2fe5a60b81c3ce0f40b58d88619dcca131c87703d9f1f1c",
230
+ "0x8be7932b0b31bdb7fc9269b756e0d0c9514519f083d86576e23b73c033d8ed8440ea363bc8bba0ec5c30eb6bbdf796163a324201bc7520965037102518fb5e991c",
281
231
  };
282
232
 
283
233
  expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
@@ -9,10 +9,7 @@ import type {
9
9
  TransactionReceipt,
10
10
  WalletClient,
11
11
  } from "viem";
12
- import {
13
- zoraCreator1155PremintExecutorImplABI,
14
- zoraCreatorFixedPriceSaleStrategyAddress,
15
- } from "@zoralabs/protocol-deployments";
12
+ import { zoraCreator1155PremintExecutorImplABI } from "@zoralabs/protocol-deployments";
16
13
  import {
17
14
  getPremintCollectionAddress,
18
15
  premintTypedDataDefinition,
@@ -25,9 +22,9 @@ import {
25
22
  supportsPremintVersion,
26
23
  getPremintMintCosts,
27
24
  makeMintRewardsRecipient,
25
+ getDefaultFixedPriceMinterAddress,
28
26
  } from "./preminter";
29
27
  import {
30
- PremintConfigV2,
31
28
  PremintConfigVersion,
32
29
  ContractCreationConfig,
33
30
  TokenConfigForVersion,
@@ -88,16 +85,19 @@ export const defaultTokenConfigV2MintArguments = (): Omit<
88
85
  });
89
86
 
90
87
  const makeTokenConfigWithDefaults = <T extends PremintConfigVersion>({
88
+ chainId,
91
89
  premintConfigVersion,
92
90
  tokenCreationConfig,
93
91
  creatorAccount,
94
92
  }: {
93
+ chainId: number;
95
94
  premintConfigVersion: PremintConfigVersion;
96
95
  tokenCreationConfig: Partial<TokenConfigForVersion<T>> & { tokenURI: string };
97
96
  creatorAccount: Address;
98
97
  }): TokenConfigForVersion<T> => {
99
98
  const fixedPriceMinter =
100
- tokenCreationConfig.fixedPriceMinter || getDefaultFixedPriceMinterAddress();
99
+ tokenCreationConfig.fixedPriceMinter ||
100
+ getDefaultFixedPriceMinterAddress(chainId);
101
101
 
102
102
  if (premintConfigVersion === PremintConfigVersion.V1) {
103
103
  return {
@@ -365,6 +365,7 @@ class PremintClient {
365
365
  premintConfigVersion: actualVersion,
366
366
  tokenCreationConfig,
367
367
  creatorAccount,
368
+ chainId: this.chain.id,
368
369
  }),
369
370
  uid: uidToUse,
370
371
  });
@@ -464,17 +465,17 @@ class PremintClient {
464
465
  async getMintCosts({
465
466
  tokenContract,
466
467
  quantityToMint,
467
- tokenCreationConfig,
468
+ pricePerToken,
468
469
  }: {
469
470
  quantityToMint: bigint;
470
471
  tokenContract: Address;
471
- tokenCreationConfig: TokenCreationConfig;
472
+ pricePerToken: bigint;
472
473
  }): Promise<MintCosts> {
473
474
  return await getPremintMintCosts({
474
475
  publicClient: this.publicClient,
475
476
  quantityToMint,
476
477
  tokenContract,
477
- tokenPrice: tokenCreationConfig.pricePerToken,
478
+ tokenPrice: pricePerToken,
478
479
  });
479
480
  }
480
481
 
@@ -493,12 +494,12 @@ class PremintClient {
493
494
  async makeMintParameters({
494
495
  uid,
495
496
  tokenContract,
496
- account,
497
+ minterAccount,
497
498
  mintArguments,
498
499
  }: {
499
500
  uid: number;
500
501
  tokenContract: Address;
501
- account: Account | Address;
502
+ minterAccount: Account | Address;
502
503
  mintArguments?: {
503
504
  quantityToMint: number;
504
505
  mintComment?: string;
@@ -511,7 +512,7 @@ class PremintClient {
511
512
  throw new Error("Quantity to mint cannot be below 1");
512
513
  }
513
514
 
514
- if (!account) {
515
+ if (!minterAccount) {
515
516
  throw new Error("Wallet not passed in");
516
517
  }
517
518
 
@@ -536,7 +537,9 @@ class PremintClient {
536
537
  mintComment: mintArguments?.mintComment || "",
537
538
  mintRecipient:
538
539
  mintArguments?.mintRecipient ||
539
- (typeof account === "string" ? account : account.address),
540
+ (typeof minterAccount === "string"
541
+ ? minterAccount
542
+ : minterAccount.address),
540
543
  mintRewardsRecipients: makeMintRewardsRecipient({
541
544
  mintReferral: mintArguments?.mintReferral,
542
545
  platformReferral: mintArguments?.platformReferral,
@@ -545,7 +548,7 @@ class PremintClient {
545
548
 
546
549
  if (premintConfigVersion === PremintConfigVersion.V1) {
547
550
  return {
548
- account,
551
+ account: minterAccount,
549
552
  abi: zoraCreator1155PremintExecutorImplABI,
550
553
  functionName: "premintV1",
551
554
  value,
@@ -562,18 +565,15 @@ class PremintClient {
562
565
  "premintV1"
563
566
  >;
564
567
  } else if (premintConfigVersion === PremintConfigVersion.V2) {
565
- const toPost = premintConfig as PremintConfigV2;
566
-
567
568
  return {
568
- account,
569
+ account: minterAccount,
569
570
  abi: zoraCreator1155PremintExecutorImplABI,
570
571
  functionName: "premintV2",
571
572
  value,
572
573
  address: getPremintExecutorAddress(),
573
- // args are: ContractCreationConfig calldata contractConfig, PremintConfigV2 calldata premintConfig, bytes calldata signature, uint256 quantityToMint, MintArguments calldata mintArguments
574
574
  args: [
575
575
  collection,
576
- toPost,
576
+ premintConfig,
577
577
  signature,
578
578
  numberToMint,
579
579
  mintArgumentsContract,
@@ -625,10 +625,14 @@ function makeUrls({
625
625
  : null,
626
626
  zoraCollect: `https://${
627
627
  network.isTestnet ? "testnet." : ""
628
- }zora.co/collect/${network.zoraPathChainName}:${address}/${zoraTokenPath}`,
628
+ }zora.co/collect/${
629
+ network.zoraCollectPathChainName
630
+ }:${address}/${zoraTokenPath}`,
629
631
  zoraManage: `https://${
630
632
  network.isTestnet ? "testnet." : ""
631
- }zora.co/collect/${network.zoraPathChainName}:${address}/${zoraTokenPath}`,
633
+ }zora.co/collect/${
634
+ network.zoraCollectPathChainName
635
+ }:${address}/${zoraTokenPath}`,
632
636
  };
633
637
  }
634
638
 
@@ -674,14 +678,12 @@ async function signAndSubmitPremint<T extends PremintConfigVersion>({
674
678
  if (checkSignature) {
675
679
  const isAuthorized = await isAuthorizedToCreatePremint({
676
680
  collection,
677
- signature,
678
681
  publicClient,
679
682
  signer: typeof account === "string" ? account : account.address,
680
683
  collectionAddress: await getPremintCollectionAddress({
681
684
  collection,
682
685
  publicClient,
683
686
  }),
684
- ...premintConfigAndVersion,
685
687
  });
686
688
  if (!isAuthorized) {
687
689
  throw new Error("Not authorized to create premint");
@@ -696,7 +698,3 @@ async function signAndSubmitPremint<T extends PremintConfigVersion>({
696
698
 
697
699
  return { premint, verifyingContract };
698
700
  }
699
-
700
- function getDefaultFixedPriceMinterAddress() {
701
- return zoraCreatorFixedPriceSaleStrategyAddress[999];
702
- }
@@ -141,7 +141,7 @@ async function setupContracts({
141
141
 
142
142
  const zoraSepoliaAnvilTest = makeAnvilTest({
143
143
  forkUrl: forkUrls.zoraSepolia,
144
- forkBlockNumber: 1905837,
144
+ forkBlockNumber: 3118200,
145
145
  });
146
146
 
147
147
  describe("ZoraCreator1155Preminter", () => {