@zoralabs/protocol-sdk 0.3.5 → 0.4.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.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +21 -0
- package/README.md +23 -32
- package/dist/anvil.d.ts +1 -1
- package/dist/index.cjs +485 -255
- 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 +483 -257
- package/dist/index.js.map +1 -1
- package/dist/premint/contract-types.d.ts +125 -0
- package/dist/premint/contract-types.d.ts.map +1 -0
- package/dist/premint/premint-api-client.d.ts +14 -7
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +46 -155
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +43 -34
- package/dist/premint/preminter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/anvil.ts +1 -1
- package/src/index.ts +2 -0
- package/src/premint/contract-types.ts +109 -0
- package/src/premint/premint-api-client.ts +162 -22
- package/src/premint/premint-client.test.ts +191 -88
- package/src/premint/premint-client.ts +361 -315
- package/src/premint/preminter.test.ts +44 -26
- package/src/premint/preminter.ts +162 -121
|
@@ -6,6 +6,16 @@ import { components, paths } from "../apis/generated/premint-api-types";
|
|
|
6
6
|
import { ZORA_API_BASE } from "../constants";
|
|
7
7
|
import { NetworkConfig } from "src/apis/chain-constants";
|
|
8
8
|
import { getApiNetworkConfigForChain } from "src/mint/mint-api-client";
|
|
9
|
+
import {
|
|
10
|
+
ContractCreationConfig,
|
|
11
|
+
PremintConfigAndVersion,
|
|
12
|
+
PremintConfigForVersion,
|
|
13
|
+
PremintConfigV1,
|
|
14
|
+
PremintConfigV2,
|
|
15
|
+
PremintConfigVersion,
|
|
16
|
+
PremintConfigWithVersion,
|
|
17
|
+
} from "./contract-types";
|
|
18
|
+
import { Address, Hex } from "viem";
|
|
9
19
|
|
|
10
20
|
type SignaturePostType = paths["/signature"]["post"];
|
|
11
21
|
type PremintSignatureRequestBody =
|
|
@@ -61,15 +71,96 @@ const getSignature = async ({
|
|
|
61
71
|
httpClient: { retries, get } = defaultHttpClient,
|
|
62
72
|
}: PremintSignatureGetPathParameters & {
|
|
63
73
|
httpClient?: Pick<IHttpClient, "retries" | "get">;
|
|
64
|
-
}): Promise<
|
|
65
|
-
|
|
74
|
+
}): Promise<
|
|
75
|
+
PremintSignatureGetResponse & {
|
|
76
|
+
premint_config_version?: PremintConfigVersion;
|
|
77
|
+
}
|
|
78
|
+
> => {
|
|
79
|
+
const result = await retries(() =>
|
|
66
80
|
get<PremintSignatureGetResponse>(
|
|
67
81
|
`${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/${uid}`,
|
|
68
82
|
),
|
|
69
83
|
);
|
|
70
84
|
|
|
85
|
+
return {
|
|
86
|
+
...result,
|
|
87
|
+
// for now - we stub the backend api to simulate returning v1
|
|
88
|
+
premint_config_version: PremintConfigVersion.V1,
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
71
92
|
type OmitChainName<T> = Omit<T, "chain_name">;
|
|
72
93
|
|
|
94
|
+
const convertCollection = (
|
|
95
|
+
collection: PremintSignatureGetResponse["collection"],
|
|
96
|
+
): ContractCreationConfig => ({
|
|
97
|
+
...collection,
|
|
98
|
+
contractAdmin: collection.contractAdmin as Address,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Convert server to on-chain types for a premint
|
|
103
|
+
*
|
|
104
|
+
* @param premint Premint object from the server to convert to one that's compatible with viem
|
|
105
|
+
* @returns Viem type-compatible premint object
|
|
106
|
+
*/
|
|
107
|
+
const convertPremintV1 = (premint: PremintSignatureGetResponse["premint"]) => ({
|
|
108
|
+
...premint,
|
|
109
|
+
tokenConfig: {
|
|
110
|
+
...premint.tokenConfig,
|
|
111
|
+
fixedPriceMinter: premint.tokenConfig.fixedPriceMinter as Address,
|
|
112
|
+
royaltyRecipient: premint.tokenConfig.royaltyRecipient as Address,
|
|
113
|
+
maxSupply: BigInt(premint.tokenConfig.maxSupply),
|
|
114
|
+
pricePerToken: BigInt(premint.tokenConfig.pricePerToken),
|
|
115
|
+
mintStart: BigInt(premint.tokenConfig.mintStart),
|
|
116
|
+
mintDuration: BigInt(premint.tokenConfig.mintDuration),
|
|
117
|
+
maxTokensPerAddress: BigInt(premint.tokenConfig.maxTokensPerAddress),
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const encodePremintV1ForAPI = ({
|
|
122
|
+
tokenConfig,
|
|
123
|
+
...premint
|
|
124
|
+
}: PremintConfigV1): PremintSignatureGetResponse["premint"] => ({
|
|
125
|
+
...premint,
|
|
126
|
+
tokenConfig: {
|
|
127
|
+
...tokenConfig,
|
|
128
|
+
maxSupply: tokenConfig.maxSupply.toString(),
|
|
129
|
+
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
130
|
+
mintStart: tokenConfig.mintStart.toString(),
|
|
131
|
+
mintDuration: tokenConfig.mintDuration.toString(),
|
|
132
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString(),
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const encodePremintV2ForAPI = ({
|
|
137
|
+
tokenConfig,
|
|
138
|
+
...premint
|
|
139
|
+
}: PremintConfigV2) => ({
|
|
140
|
+
...premint,
|
|
141
|
+
tokenConfig: {
|
|
142
|
+
...tokenConfig,
|
|
143
|
+
maxSupply: tokenConfig.maxSupply.toString(),
|
|
144
|
+
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
145
|
+
mintStart: tokenConfig.mintStart.toString(),
|
|
146
|
+
mintDuration: tokenConfig.mintDuration.toString(),
|
|
147
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString(),
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const encodePremintForAPI = <T extends PremintConfigVersion>({
|
|
152
|
+
premintConfig,
|
|
153
|
+
premintConfigVersion,
|
|
154
|
+
}: PremintConfigWithVersion<T>) => {
|
|
155
|
+
if (premintConfigVersion === PremintConfigVersion.V1) {
|
|
156
|
+
return encodePremintV1ForAPI(premintConfig as PremintConfigV1);
|
|
157
|
+
}
|
|
158
|
+
if (premintConfigVersion === PremintConfigVersion.V2) {
|
|
159
|
+
return encodePremintV2ForAPI(premintConfig as PremintConfigV2);
|
|
160
|
+
}
|
|
161
|
+
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
162
|
+
};
|
|
163
|
+
|
|
73
164
|
class PremintAPIClient {
|
|
74
165
|
httpClient: IHttpClient;
|
|
75
166
|
networkConfig: NetworkConfig;
|
|
@@ -78,34 +169,83 @@ class PremintAPIClient {
|
|
|
78
169
|
this.httpClient = httpClient || defaultHttpClient;
|
|
79
170
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
80
171
|
}
|
|
81
|
-
postSignature = async (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
172
|
+
postSignature = async <T extends PremintConfigVersion>({
|
|
173
|
+
collection,
|
|
174
|
+
premintConfigVersion,
|
|
175
|
+
premintConfig,
|
|
176
|
+
signature,
|
|
177
|
+
}: {
|
|
178
|
+
collection: ContractCreationConfig;
|
|
179
|
+
signature: Hex;
|
|
180
|
+
} & PremintConfigWithVersion<T>): Promise<PremintSignatureResponse> => {
|
|
181
|
+
if (premintConfigVersion === PremintConfigVersion.V1) {
|
|
182
|
+
const data: OmitChainName<PremintSignatureRequestBody> = {
|
|
183
|
+
premint: encodePremintForAPI<T>({
|
|
184
|
+
premintConfig,
|
|
185
|
+
premintConfigVersion,
|
|
186
|
+
}) as PremintSignatureRequestBody["premint"],
|
|
187
|
+
signature,
|
|
188
|
+
collection,
|
|
189
|
+
};
|
|
190
|
+
return postSignature({
|
|
191
|
+
...data,
|
|
192
|
+
chain_name: this.networkConfig.zoraBackendChainName,
|
|
193
|
+
httpClient: this.httpClient,
|
|
194
|
+
});
|
|
195
|
+
} else {
|
|
196
|
+
// TODO: support posting premint v2 sig when backend is ready
|
|
197
|
+
throw new Error("Unsupported premint config version");
|
|
198
|
+
}
|
|
199
|
+
};
|
|
89
200
|
|
|
90
|
-
getNextUID = async (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
201
|
+
getNextUID = async (collectionAddress: Address): Promise<number> =>
|
|
202
|
+
(
|
|
203
|
+
await getNextUID({
|
|
204
|
+
collection_address: collectionAddress.toLowerCase(),
|
|
205
|
+
chain_name: this.networkConfig.zoraBackendChainName,
|
|
206
|
+
httpClient: this.httpClient,
|
|
207
|
+
})
|
|
208
|
+
).next_uid;
|
|
98
209
|
|
|
99
210
|
getSignature = async ({
|
|
100
|
-
|
|
211
|
+
collectionAddress,
|
|
101
212
|
uid,
|
|
102
|
-
}:
|
|
103
|
-
|
|
104
|
-
|
|
213
|
+
}: {
|
|
214
|
+
collectionAddress: Address;
|
|
215
|
+
uid: number;
|
|
216
|
+
}): Promise<
|
|
217
|
+
{
|
|
218
|
+
signature: Hex;
|
|
219
|
+
collection: ContractCreationConfig;
|
|
220
|
+
} & PremintConfigAndVersion
|
|
221
|
+
> => {
|
|
222
|
+
const response = await getSignature({
|
|
223
|
+
collection_address: collectionAddress.toLowerCase(),
|
|
105
224
|
uid,
|
|
106
225
|
chain_name: this.networkConfig.zoraBackendChainName,
|
|
107
226
|
httpClient: this.httpClient,
|
|
108
227
|
});
|
|
228
|
+
|
|
229
|
+
const premintConfigVersion =
|
|
230
|
+
response.premint_config_version || PremintConfigVersion.V1;
|
|
231
|
+
|
|
232
|
+
let premintConfig: PremintConfigForVersion<typeof premintConfigVersion>;
|
|
233
|
+
|
|
234
|
+
if (premintConfigVersion === PremintConfigVersion.V1) {
|
|
235
|
+
premintConfig = convertPremintV1(response.premint);
|
|
236
|
+
} else {
|
|
237
|
+
throw new Error(
|
|
238
|
+
`Unsupported premint config version: ${premintConfigVersion}`,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
signature: response.signature as Hex,
|
|
244
|
+
collection: convertCollection(response.collection),
|
|
245
|
+
premintConfig,
|
|
246
|
+
premintConfigVersion: premintConfigVersion,
|
|
247
|
+
};
|
|
248
|
+
};
|
|
109
249
|
}
|
|
110
250
|
|
|
111
251
|
export { ZORA_API_BASE, PremintAPIClient };
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { foundry } from "viem/chains";
|
|
2
2
|
import { describe, expect, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { Address, Hex } from "viem";
|
|
3
5
|
import { createPremintClient } from "./premint-client";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import { forkUrls, makeAnvilTest } from "src/anvil";
|
|
7
|
+
import {
|
|
8
|
+
ContractCreationConfig,
|
|
9
|
+
PremintConfigV1,
|
|
10
|
+
PremintConfigVersion,
|
|
11
|
+
} from "./contract-types";
|
|
12
|
+
|
|
13
|
+
const zoraMainnetForkAnvilTest = makeAnvilTest({
|
|
14
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
15
|
+
forkBlockNumber: 7550118,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const zoraSepoliaAnvilTest = makeAnvilTest({
|
|
19
|
+
forkUrl: forkUrls.zoraSepolia,
|
|
20
|
+
forkBlockNumber: 1904731,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe("ZoraCreator1155Premint - v1 signatures", () => {
|
|
24
|
+
zoraMainnetForkAnvilTest(
|
|
25
|
+
"can sign by default v1 on the forked premint contract",
|
|
13
26
|
async ({ viemClients: { walletClient, publicClient } }) => {
|
|
14
27
|
const [deployerAccount] = await walletClient.getAddresses();
|
|
15
28
|
const premintClient = createPremintClient({
|
|
@@ -18,15 +31,15 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
18
31
|
});
|
|
19
32
|
|
|
20
33
|
premintClient.apiClient.getNextUID = vi
|
|
21
|
-
.fn()
|
|
22
|
-
.mockResolvedValue(
|
|
34
|
+
.fn<any, ReturnType<typeof premintClient.apiClient.getNextUID>>()
|
|
35
|
+
.mockResolvedValue(3);
|
|
23
36
|
premintClient.apiClient.postSignature = vi
|
|
24
|
-
.fn()
|
|
37
|
+
.fn<Parameters<typeof premintClient.apiClient.postSignature>>()
|
|
25
38
|
.mockResolvedValue({ ok: true });
|
|
26
39
|
|
|
27
40
|
await premintClient.createPremint({
|
|
28
41
|
walletClient,
|
|
29
|
-
|
|
42
|
+
creatorAccount: deployerAccount!,
|
|
30
43
|
checkSignature: true,
|
|
31
44
|
collection: {
|
|
32
45
|
contractAdmin: deployerAccount!,
|
|
@@ -34,28 +47,30 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
34
47
|
contractURI:
|
|
35
48
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
36
49
|
},
|
|
37
|
-
|
|
50
|
+
tokenCreationConfig: {
|
|
38
51
|
tokenURI:
|
|
39
52
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
40
53
|
},
|
|
41
54
|
});
|
|
42
55
|
|
|
43
|
-
|
|
56
|
+
const expectedPostSignatureArgs: Parameters<
|
|
57
|
+
typeof premintClient.apiClient.postSignature
|
|
58
|
+
>[0] = {
|
|
44
59
|
collection: {
|
|
45
60
|
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
46
61
|
contractName: "Testing Contract",
|
|
47
62
|
contractURI:
|
|
48
63
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
49
64
|
},
|
|
50
|
-
|
|
65
|
+
premintConfig: {
|
|
51
66
|
deleted: false,
|
|
52
67
|
tokenConfig: {
|
|
53
68
|
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
54
|
-
maxSupply:
|
|
55
|
-
maxTokensPerAddress:
|
|
56
|
-
mintDuration:
|
|
57
|
-
mintStart:
|
|
58
|
-
pricePerToken:
|
|
69
|
+
maxSupply: 18446744073709551615n,
|
|
70
|
+
maxTokensPerAddress: 0n,
|
|
71
|
+
mintDuration: 604800n,
|
|
72
|
+
mintStart: 0n,
|
|
73
|
+
pricePerToken: 0n,
|
|
59
74
|
royaltyBPS: 1000,
|
|
60
75
|
royaltyMintSchedule: 0,
|
|
61
76
|
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
@@ -63,16 +78,21 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
63
78
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
64
79
|
},
|
|
65
80
|
uid: 3,
|
|
66
|
-
version:
|
|
81
|
+
version: 0,
|
|
67
82
|
},
|
|
83
|
+
premintConfigVersion: PremintConfigVersion.V1,
|
|
68
84
|
signature:
|
|
69
|
-
"
|
|
70
|
-
}
|
|
85
|
+
"0x8c6a9160a0917d98c201b37c9220c17ebaed23a5f905202341c1d0d4e8673c3913880907d6de48c9858fbeb40a9a38d5edda979e4dcb133643ca8ecb4afe0b691b",
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
|
|
89
|
+
expectedPostSignatureArgs,
|
|
90
|
+
);
|
|
71
91
|
},
|
|
72
92
|
20 * 1000,
|
|
73
93
|
);
|
|
74
94
|
|
|
75
|
-
|
|
95
|
+
zoraMainnetForkAnvilTest(
|
|
76
96
|
"can validate premint on network",
|
|
77
97
|
async ({ viemClients: { publicClient } }) => {
|
|
78
98
|
const premintClient = createPremintClient({
|
|
@@ -80,85 +100,92 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
80
100
|
publicClient,
|
|
81
101
|
});
|
|
82
102
|
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
106
|
-
},
|
|
103
|
+
const collection: ContractCreationConfig = {
|
|
104
|
+
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" as Address,
|
|
105
|
+
contractName: "Testing Contract",
|
|
106
|
+
contractURI:
|
|
107
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
108
|
+
};
|
|
109
|
+
const premint: PremintConfigV1 = {
|
|
110
|
+
uid: 3,
|
|
111
|
+
version: 1,
|
|
112
|
+
deleted: false,
|
|
113
|
+
tokenConfig: {
|
|
114
|
+
maxSupply: 18446744073709551615n,
|
|
115
|
+
maxTokensPerAddress: 0n,
|
|
116
|
+
pricePerToken: 0n,
|
|
117
|
+
mintDuration: 604800n,
|
|
118
|
+
mintStart: 0n,
|
|
119
|
+
royaltyMintSchedule: 0,
|
|
120
|
+
royaltyBPS: 1000,
|
|
121
|
+
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
122
|
+
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
123
|
+
tokenURI:
|
|
124
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
107
125
|
},
|
|
108
|
-
|
|
109
|
-
signature:
|
|
110
|
-
"0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c",
|
|
111
|
-
} as const;
|
|
126
|
+
};
|
|
112
127
|
|
|
113
|
-
const
|
|
128
|
+
const signature =
|
|
129
|
+
"0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c" as Hex;
|
|
130
|
+
|
|
131
|
+
const signatureValid = await premintClient.isValidSignature({
|
|
132
|
+
collection: collection,
|
|
133
|
+
premintConfig: premint,
|
|
134
|
+
signature,
|
|
135
|
+
// default to premint config v1 version (we dont need to specify it here)
|
|
136
|
+
});
|
|
114
137
|
expect(signatureValid.isValid).toBe(true);
|
|
115
138
|
},
|
|
116
139
|
);
|
|
117
140
|
|
|
118
|
-
|
|
141
|
+
zoraMainnetForkAnvilTest(
|
|
119
142
|
"can execute premint on network",
|
|
120
143
|
async ({ viemClients: { walletClient, publicClient } }) => {
|
|
121
144
|
const [deployerAccount] = await walletClient.getAddresses();
|
|
122
|
-
const premintClient = createPremintClient({
|
|
145
|
+
const premintClient = createPremintClient({
|
|
146
|
+
chain: foundry,
|
|
147
|
+
publicClient,
|
|
148
|
+
});
|
|
123
149
|
|
|
124
|
-
premintClient.apiClient.getSignature = vi
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
premint: {
|
|
133
|
-
deleted: false,
|
|
134
|
-
tokenConfig: {
|
|
135
|
-
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
136
|
-
maxSupply: "18446744073709551615",
|
|
137
|
-
maxTokensPerAddress: "0",
|
|
138
|
-
mintDuration: "604800",
|
|
139
|
-
mintStart: "0",
|
|
140
|
-
pricePerToken: "0",
|
|
141
|
-
royaltyBPS: 1000,
|
|
142
|
-
royaltyMintSchedule: 0,
|
|
143
|
-
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
144
|
-
tokenURI:
|
|
145
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
150
|
+
premintClient.apiClient.getSignature = vi
|
|
151
|
+
.fn<any, ReturnType<typeof premintClient.apiClient.getSignature>>()
|
|
152
|
+
.mockResolvedValue({
|
|
153
|
+
collection: {
|
|
154
|
+
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
155
|
+
contractName: "Testing Contract",
|
|
156
|
+
contractURI:
|
|
157
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
146
158
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
premintConfig: {
|
|
160
|
+
deleted: false,
|
|
161
|
+
tokenConfig: {
|
|
162
|
+
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
163
|
+
maxSupply: 18446744073709551615n,
|
|
164
|
+
maxTokensPerAddress: 0n,
|
|
165
|
+
mintDuration: 604800n,
|
|
166
|
+
mintStart: 0n,
|
|
167
|
+
pricePerToken: 0n,
|
|
168
|
+
royaltyBPS: 1000,
|
|
169
|
+
royaltyMintSchedule: 0,
|
|
170
|
+
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
171
|
+
tokenURI:
|
|
172
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
173
|
+
},
|
|
174
|
+
uid: 3,
|
|
175
|
+
version: 1,
|
|
176
|
+
},
|
|
177
|
+
premintConfigVersion: PremintConfigVersion.V1,
|
|
178
|
+
signature:
|
|
179
|
+
"0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c",
|
|
180
|
+
});
|
|
181
|
+
|
|
153
182
|
premintClient.apiClient.postSignature = vi.fn();
|
|
154
183
|
|
|
155
184
|
const simulateContractParameters = await premintClient.makeMintParameters(
|
|
156
185
|
{
|
|
157
186
|
account: deployerAccount!,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
uid: 3,
|
|
161
|
-
}),
|
|
187
|
+
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
188
|
+
uid: 3,
|
|
162
189
|
mintArguments: {
|
|
163
190
|
quantityToMint: 1,
|
|
164
191
|
mintComment: "",
|
|
@@ -213,3 +240,79 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
213
240
|
20 * 1000,
|
|
214
241
|
);
|
|
215
242
|
});
|
|
243
|
+
|
|
244
|
+
describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
245
|
+
zoraSepoliaAnvilTest(
|
|
246
|
+
"can sign on the forked premint contract",
|
|
247
|
+
async ({ viemClients: { walletClient, publicClient } }) => {
|
|
248
|
+
const [creatorAccount, createReferralAccount] =
|
|
249
|
+
await walletClient.getAddresses();
|
|
250
|
+
const premintClient = createPremintClient({
|
|
251
|
+
chain: foundry,
|
|
252
|
+
publicClient,
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
premintClient.apiClient.getNextUID = vi
|
|
256
|
+
.fn<any, ReturnType<typeof premintClient.apiClient.getNextUID>>()
|
|
257
|
+
.mockResolvedValue(3);
|
|
258
|
+
premintClient.apiClient.postSignature = vi
|
|
259
|
+
.fn<Parameters<typeof premintClient.apiClient.postSignature>>()
|
|
260
|
+
.mockResolvedValue({ ok: true });
|
|
261
|
+
|
|
262
|
+
await premintClient.createPremint({
|
|
263
|
+
walletClient,
|
|
264
|
+
creatorAccount: creatorAccount!,
|
|
265
|
+
checkSignature: true,
|
|
266
|
+
collection: {
|
|
267
|
+
contractAdmin: creatorAccount!,
|
|
268
|
+
contractName: "Testing Contract Premint V2",
|
|
269
|
+
contractURI:
|
|
270
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
271
|
+
},
|
|
272
|
+
premintConfigVersion: PremintConfigVersion.V2,
|
|
273
|
+
tokenCreationConfig: {
|
|
274
|
+
tokenURI:
|
|
275
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
276
|
+
createReferral: createReferralAccount,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const expectedPostSignatureArgs: Parameters<
|
|
281
|
+
typeof premintClient.apiClient.postSignature
|
|
282
|
+
>[0] = {
|
|
283
|
+
collection: {
|
|
284
|
+
contractAdmin: creatorAccount!,
|
|
285
|
+
contractName: "Testing Contract Premint V2",
|
|
286
|
+
contractURI:
|
|
287
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
288
|
+
},
|
|
289
|
+
premintConfig: {
|
|
290
|
+
deleted: false,
|
|
291
|
+
tokenConfig: {
|
|
292
|
+
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
293
|
+
maxSupply: 18446744073709551615n,
|
|
294
|
+
maxTokensPerAddress: 0n,
|
|
295
|
+
mintDuration: 604800n,
|
|
296
|
+
mintStart: 0n,
|
|
297
|
+
pricePerToken: 0n,
|
|
298
|
+
royaltyBPS: 1000,
|
|
299
|
+
payoutRecipient: creatorAccount!,
|
|
300
|
+
createReferral: createReferralAccount!,
|
|
301
|
+
tokenURI:
|
|
302
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
303
|
+
},
|
|
304
|
+
uid: 3,
|
|
305
|
+
version: 0,
|
|
306
|
+
},
|
|
307
|
+
premintConfigVersion: PremintConfigVersion.V2,
|
|
308
|
+
signature:
|
|
309
|
+
"0xd0a9d8164911237430fe2c76ccfd4f53925a9e14e29da19b98ed5ed59e262b0d6ef24efe8b828b79e7b2fe5a60b81c3ce0f40b58d88619dcca131c87703d9f1f1c",
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
|
|
313
|
+
expectedPostSignatureArgs,
|
|
314
|
+
);
|
|
315
|
+
},
|
|
316
|
+
20 * 1000,
|
|
317
|
+
);
|
|
318
|
+
});
|