@zoralabs/protocol-sdk 0.3.5 → 0.4.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.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +12 -0
- package/README.md +23 -32
- package/dist/anvil.d.ts +1 -1
- package/dist/index.cjs +423 -254
- 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 +420 -253
- 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 +39 -155
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +28 -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 +188 -87
- package/src/premint/premint-client.ts +330 -314
- package/src/premint/preminter.test.ts +9 -7
- package/src/premint/preminter.ts +107 -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,23 @@
|
|
|
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
|
+
import { forkUrls, makeAnvilTest } from "src/anvil";
|
|
7
|
+
import {
|
|
8
|
+
ContractCreationConfig,
|
|
9
|
+
PremintConfigV1,
|
|
10
|
+
PremintConfigVersion,
|
|
11
|
+
} from "./contract-types";
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
const zoraMainnetForkAnvilTest = makeAnvilTest({
|
|
14
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
15
|
+
forkBlockNumber: 7550118,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe("ZoraCreator1155Premint - v1 signatures", () => {
|
|
19
|
+
zoraMainnetForkAnvilTest(
|
|
20
|
+
"can sign by default v1 on the forked premint contract",
|
|
13
21
|
async ({ viemClients: { walletClient, publicClient } }) => {
|
|
14
22
|
const [deployerAccount] = await walletClient.getAddresses();
|
|
15
23
|
const premintClient = createPremintClient({
|
|
@@ -18,15 +26,15 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
18
26
|
});
|
|
19
27
|
|
|
20
28
|
premintClient.apiClient.getNextUID = vi
|
|
21
|
-
.fn()
|
|
22
|
-
.mockResolvedValue(
|
|
29
|
+
.fn<any, ReturnType<typeof premintClient.apiClient.getNextUID>>()
|
|
30
|
+
.mockResolvedValue(3);
|
|
23
31
|
premintClient.apiClient.postSignature = vi
|
|
24
|
-
.fn()
|
|
32
|
+
.fn<Parameters<typeof premintClient.apiClient.postSignature>>()
|
|
25
33
|
.mockResolvedValue({ ok: true });
|
|
26
34
|
|
|
27
35
|
await premintClient.createPremint({
|
|
28
36
|
walletClient,
|
|
29
|
-
|
|
37
|
+
creatorAccount: deployerAccount!,
|
|
30
38
|
checkSignature: true,
|
|
31
39
|
collection: {
|
|
32
40
|
contractAdmin: deployerAccount!,
|
|
@@ -34,28 +42,30 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
34
42
|
contractURI:
|
|
35
43
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
36
44
|
},
|
|
37
|
-
|
|
45
|
+
tokenCreationConfig: {
|
|
38
46
|
tokenURI:
|
|
39
47
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
40
48
|
},
|
|
41
49
|
});
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
const expectedPostSignatureArgs: Parameters<
|
|
52
|
+
typeof premintClient.apiClient.postSignature
|
|
53
|
+
>[0] = {
|
|
44
54
|
collection: {
|
|
45
55
|
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
46
56
|
contractName: "Testing Contract",
|
|
47
57
|
contractURI:
|
|
48
58
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
49
59
|
},
|
|
50
|
-
|
|
60
|
+
premintConfig: {
|
|
51
61
|
deleted: false,
|
|
52
62
|
tokenConfig: {
|
|
53
63
|
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
54
|
-
maxSupply:
|
|
55
|
-
maxTokensPerAddress:
|
|
56
|
-
mintDuration:
|
|
57
|
-
mintStart:
|
|
58
|
-
pricePerToken:
|
|
64
|
+
maxSupply: 18446744073709551615n,
|
|
65
|
+
maxTokensPerAddress: 0n,
|
|
66
|
+
mintDuration: 604800n,
|
|
67
|
+
mintStart: 0n,
|
|
68
|
+
pricePerToken: 0n,
|
|
59
69
|
royaltyBPS: 1000,
|
|
60
70
|
royaltyMintSchedule: 0,
|
|
61
71
|
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
@@ -63,16 +73,21 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
63
73
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
64
74
|
},
|
|
65
75
|
uid: 3,
|
|
66
|
-
version:
|
|
76
|
+
version: 0,
|
|
67
77
|
},
|
|
78
|
+
premintConfigVersion: PremintConfigVersion.V1,
|
|
68
79
|
signature:
|
|
69
|
-
"
|
|
70
|
-
}
|
|
80
|
+
"0x8c6a9160a0917d98c201b37c9220c17ebaed23a5f905202341c1d0d4e8673c3913880907d6de48c9858fbeb40a9a38d5edda979e4dcb133643ca8ecb4afe0b691b",
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
|
|
84
|
+
expectedPostSignatureArgs,
|
|
85
|
+
);
|
|
71
86
|
},
|
|
72
87
|
20 * 1000,
|
|
73
88
|
);
|
|
74
89
|
|
|
75
|
-
|
|
90
|
+
zoraMainnetForkAnvilTest(
|
|
76
91
|
"can validate premint on network",
|
|
77
92
|
async ({ viemClients: { publicClient } }) => {
|
|
78
93
|
const premintClient = createPremintClient({
|
|
@@ -80,85 +95,92 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
80
95
|
publicClient,
|
|
81
96
|
});
|
|
82
97
|
|
|
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
|
-
},
|
|
98
|
+
const collection: ContractCreationConfig = {
|
|
99
|
+
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" as Address,
|
|
100
|
+
contractName: "Testing Contract",
|
|
101
|
+
contractURI:
|
|
102
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
103
|
+
};
|
|
104
|
+
const premint: PremintConfigV1 = {
|
|
105
|
+
uid: 3,
|
|
106
|
+
version: 1,
|
|
107
|
+
deleted: false,
|
|
108
|
+
tokenConfig: {
|
|
109
|
+
maxSupply: 18446744073709551615n,
|
|
110
|
+
maxTokensPerAddress: 0n,
|
|
111
|
+
pricePerToken: 0n,
|
|
112
|
+
mintDuration: 604800n,
|
|
113
|
+
mintStart: 0n,
|
|
114
|
+
royaltyMintSchedule: 0,
|
|
115
|
+
royaltyBPS: 1000,
|
|
116
|
+
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
117
|
+
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
118
|
+
tokenURI:
|
|
119
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
107
120
|
},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const signature =
|
|
124
|
+
"0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c" as Hex;
|
|
112
125
|
|
|
113
|
-
const signatureValid = await premintClient.isValidSignature(
|
|
126
|
+
const signatureValid = await premintClient.isValidSignature({
|
|
127
|
+
collection: collection,
|
|
128
|
+
premintConfig: premint,
|
|
129
|
+
signature,
|
|
130
|
+
// default to premint config v1 version (we dont need to specify it here)
|
|
131
|
+
});
|
|
114
132
|
expect(signatureValid.isValid).toBe(true);
|
|
115
133
|
},
|
|
116
134
|
);
|
|
117
135
|
|
|
118
|
-
|
|
136
|
+
zoraMainnetForkAnvilTest(
|
|
119
137
|
"can execute premint on network",
|
|
120
138
|
async ({ viemClients: { walletClient, publicClient } }) => {
|
|
121
139
|
const [deployerAccount] = await walletClient.getAddresses();
|
|
122
|
-
const premintClient = createPremintClient({
|
|
140
|
+
const premintClient = createPremintClient({
|
|
141
|
+
chain: foundry,
|
|
142
|
+
publicClient,
|
|
143
|
+
});
|
|
123
144
|
|
|
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",
|
|
145
|
+
premintClient.apiClient.getSignature = vi
|
|
146
|
+
.fn<any, ReturnType<typeof premintClient.apiClient.getSignature>>()
|
|
147
|
+
.mockResolvedValue({
|
|
148
|
+
collection: {
|
|
149
|
+
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
150
|
+
contractName: "Testing Contract",
|
|
151
|
+
contractURI:
|
|
152
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
146
153
|
},
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
154
|
+
premintConfig: {
|
|
155
|
+
deleted: false,
|
|
156
|
+
tokenConfig: {
|
|
157
|
+
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
158
|
+
maxSupply: 18446744073709551615n,
|
|
159
|
+
maxTokensPerAddress: 0n,
|
|
160
|
+
mintDuration: 604800n,
|
|
161
|
+
mintStart: 0n,
|
|
162
|
+
pricePerToken: 0n,
|
|
163
|
+
royaltyBPS: 1000,
|
|
164
|
+
royaltyMintSchedule: 0,
|
|
165
|
+
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
166
|
+
tokenURI:
|
|
167
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
168
|
+
},
|
|
169
|
+
uid: 3,
|
|
170
|
+
version: 1,
|
|
171
|
+
},
|
|
172
|
+
premintConfigVersion: PremintConfigVersion.V1,
|
|
173
|
+
signature:
|
|
174
|
+
"0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c",
|
|
175
|
+
});
|
|
176
|
+
|
|
153
177
|
premintClient.apiClient.postSignature = vi.fn();
|
|
154
178
|
|
|
155
179
|
const simulateContractParameters = await premintClient.makeMintParameters(
|
|
156
180
|
{
|
|
157
181
|
account: deployerAccount!,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
uid: 3,
|
|
161
|
-
}),
|
|
182
|
+
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
183
|
+
uid: 3,
|
|
162
184
|
mintArguments: {
|
|
163
185
|
quantityToMint: 1,
|
|
164
186
|
mintComment: "",
|
|
@@ -213,3 +235,82 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
213
235
|
20 * 1000,
|
|
214
236
|
);
|
|
215
237
|
});
|
|
238
|
+
|
|
239
|
+
describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
240
|
+
makeAnvilTest({
|
|
241
|
+
forkUrl: forkUrls.zoraSepolia,
|
|
242
|
+
forkBlockNumber: 1865004,
|
|
243
|
+
})(
|
|
244
|
+
"can sign on the forked premint contract",
|
|
245
|
+
async ({ viemClients: { walletClient, publicClient } }) => {
|
|
246
|
+
const [creatorAccount, createReferralAccount] =
|
|
247
|
+
await walletClient.getAddresses();
|
|
248
|
+
const premintClient = createPremintClient({
|
|
249
|
+
chain: foundry,
|
|
250
|
+
publicClient,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
premintClient.apiClient.getNextUID = vi
|
|
254
|
+
.fn<any, ReturnType<typeof premintClient.apiClient.getNextUID>>()
|
|
255
|
+
.mockResolvedValue(3);
|
|
256
|
+
premintClient.apiClient.postSignature = vi
|
|
257
|
+
.fn<Parameters<typeof premintClient.apiClient.postSignature>>()
|
|
258
|
+
.mockResolvedValue({ ok: true });
|
|
259
|
+
|
|
260
|
+
await premintClient.createPremint({
|
|
261
|
+
walletClient,
|
|
262
|
+
creatorAccount: creatorAccount!,
|
|
263
|
+
checkSignature: true,
|
|
264
|
+
collection: {
|
|
265
|
+
contractAdmin: creatorAccount!,
|
|
266
|
+
contractName: "Testing Contract Premint V2",
|
|
267
|
+
contractURI:
|
|
268
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
269
|
+
},
|
|
270
|
+
premintConfigVersion: PremintConfigVersion.V2,
|
|
271
|
+
tokenCreationConfig: {
|
|
272
|
+
tokenURI:
|
|
273
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
274
|
+
createReferral: createReferralAccount,
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
const expectedPostSignatureArgs: Parameters<
|
|
279
|
+
typeof premintClient.apiClient.postSignature
|
|
280
|
+
>[0] = {
|
|
281
|
+
collection: {
|
|
282
|
+
contractAdmin: creatorAccount!,
|
|
283
|
+
contractName: "Testing Contract Premint V2",
|
|
284
|
+
contractURI:
|
|
285
|
+
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
286
|
+
},
|
|
287
|
+
premintConfig: {
|
|
288
|
+
deleted: false,
|
|
289
|
+
tokenConfig: {
|
|
290
|
+
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
291
|
+
maxSupply: 18446744073709551615n,
|
|
292
|
+
maxTokensPerAddress: 0n,
|
|
293
|
+
mintDuration: 604800n,
|
|
294
|
+
mintStart: 0n,
|
|
295
|
+
pricePerToken: 0n,
|
|
296
|
+
royaltyBPS: 1000,
|
|
297
|
+
payoutRecipient: creatorAccount!,
|
|
298
|
+
createReferral: createReferralAccount!,
|
|
299
|
+
tokenURI:
|
|
300
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
301
|
+
},
|
|
302
|
+
uid: 3,
|
|
303
|
+
version: 0,
|
|
304
|
+
},
|
|
305
|
+
premintConfigVersion: PremintConfigVersion.V2,
|
|
306
|
+
signature:
|
|
307
|
+
"0xd0a9d8164911237430fe2c76ccfd4f53925a9e14e29da19b98ed5ed59e262b0d6ef24efe8b828b79e7b2fe5a60b81c3ce0f40b58d88619dcca131c87703d9f1f1c",
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
|
|
311
|
+
expectedPostSignatureArgs,
|
|
312
|
+
);
|
|
313
|
+
},
|
|
314
|
+
20 * 1000,
|
|
315
|
+
);
|
|
316
|
+
});
|