@zoralabs/protocol-sdk 0.3.4 → 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 +34 -0
- package/README.md +30 -58
- package/dist/anvil.d.ts +4 -2
- package/dist/anvil.d.ts.map +1 -1
- package/dist/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.cjs +819 -518
- 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 +788 -493
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-api-client.d.ts +16 -216
- package/dist/mint/mint-api-client.d.ts.map +1 -1
- package/dist/mint/mint-client.d.ts +7 -227
- package/dist/mint/mint-client.d.ts.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 +45 -115
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +102 -21
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/anvil.ts +7 -4
- package/src/constants.ts +7 -0
- package/src/index.ts +2 -0
- package/src/mint/mint-api-client.ts +72 -68
- package/src/mint/mint-client.test.ts +9 -11
- package/src/mint/mint-client.ts +51 -221
- package/src/premint/contract-types.ts +109 -0
- package/src/premint/premint-api-client.ts +162 -22
- package/src/premint/premint-client.test.ts +186 -84
- package/src/premint/premint-client.ts +357 -289
- package/src/premint/preminter.test.ts +209 -130
- package/src/premint/preminter.ts +377 -54
- package/src/types.ts +1 -0
- package/dist/apis/generated/discover-api-types.d.ts +0 -2131
- package/dist/apis/generated/discover-api-types.d.ts.map +0 -1
- package/src/apis/generated/discover-api-types.ts +0 -2180
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ExtractAbiFunction, AbiParametersToPrimitiveTypes } from "abitype";
|
|
2
|
+
import { zoraCreator1155PremintExecutorImplABI as preminterAbi } from "@zoralabs/protocol-deployments";
|
|
3
|
+
|
|
4
|
+
type PremintV1Inputs = ExtractAbiFunction<
|
|
5
|
+
typeof preminterAbi,
|
|
6
|
+
"premintV1"
|
|
7
|
+
>["inputs"];
|
|
8
|
+
|
|
9
|
+
type PremintV1HashDataTypes = AbiParametersToPrimitiveTypes<PremintV1Inputs>;
|
|
10
|
+
|
|
11
|
+
export type ContractCreationConfig = PremintV1HashDataTypes[0];
|
|
12
|
+
|
|
13
|
+
export type PremintConfigV1 = PremintV1HashDataTypes[1];
|
|
14
|
+
export type TokenCreationConfigV1 = PremintConfigV1["tokenConfig"];
|
|
15
|
+
|
|
16
|
+
export type MintArguments = PremintV1HashDataTypes[4];
|
|
17
|
+
|
|
18
|
+
type PremintV2Inputs = ExtractAbiFunction<
|
|
19
|
+
typeof preminterAbi,
|
|
20
|
+
"premintV2"
|
|
21
|
+
>["inputs"];
|
|
22
|
+
|
|
23
|
+
type PremintV2HashDataTypes = AbiParametersToPrimitiveTypes<PremintV2Inputs>;
|
|
24
|
+
|
|
25
|
+
export type PremintConfigV2 = PremintV2HashDataTypes[1];
|
|
26
|
+
export type TokenCreationConfigV2 = PremintConfigV2["tokenConfig"];
|
|
27
|
+
|
|
28
|
+
export const v1Types = {
|
|
29
|
+
CreatorAttribution: [
|
|
30
|
+
{ name: "tokenConfig", type: "TokenCreationConfig" },
|
|
31
|
+
// unique id scoped to the contract and token to create.
|
|
32
|
+
// ensure that a signature can be replaced, as long as the replacement
|
|
33
|
+
// has the same uid, and a newer version.
|
|
34
|
+
{ name: "uid", type: "uint32" },
|
|
35
|
+
{ name: "version", type: "uint32" },
|
|
36
|
+
// if this update should result in the signature being deleted.
|
|
37
|
+
{ name: "deleted", type: "bool" },
|
|
38
|
+
],
|
|
39
|
+
TokenCreationConfig: [
|
|
40
|
+
{ name: "tokenURI", type: "string" },
|
|
41
|
+
{ name: "maxSupply", type: "uint256" },
|
|
42
|
+
{ name: "maxTokensPerAddress", type: "uint64" },
|
|
43
|
+
{ name: "pricePerToken", type: "uint96" },
|
|
44
|
+
{ name: "mintStart", type: "uint64" },
|
|
45
|
+
{ name: "mintDuration", type: "uint64" },
|
|
46
|
+
{ name: "royaltyMintSchedule", type: "uint32" },
|
|
47
|
+
{ name: "royaltyBPS", type: "uint32" },
|
|
48
|
+
{ name: "royaltyRecipient", type: "address" },
|
|
49
|
+
{ name: "fixedPriceMinter", type: "address" },
|
|
50
|
+
],
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
export const v2Types = {
|
|
54
|
+
CreatorAttribution: [
|
|
55
|
+
{ name: "tokenConfig", type: "TokenCreationConfig" },
|
|
56
|
+
// unique id scoped to the contract and token to create.
|
|
57
|
+
// ensure that a signature can be replaced, as long as the replacement
|
|
58
|
+
// has the same uid, and a newer version.
|
|
59
|
+
{ name: "uid", type: "uint32" },
|
|
60
|
+
{ name: "version", type: "uint32" },
|
|
61
|
+
// if this update should result in the signature being deleted.
|
|
62
|
+
{ name: "deleted", type: "bool" },
|
|
63
|
+
],
|
|
64
|
+
TokenCreationConfig: [
|
|
65
|
+
{ name: "tokenURI", type: "string" },
|
|
66
|
+
{ name: "maxSupply", type: "uint256" },
|
|
67
|
+
{ name: "maxTokensPerAddress", type: "uint64" },
|
|
68
|
+
{ name: "pricePerToken", type: "uint96" },
|
|
69
|
+
{ name: "mintStart", type: "uint64" },
|
|
70
|
+
{ name: "mintDuration", type: "uint64" },
|
|
71
|
+
{ name: "royaltyBPS", type: "uint32" },
|
|
72
|
+
{ name: "payoutRecipient", type: "address" },
|
|
73
|
+
{ name: "fixedPriceMinter", type: "address" },
|
|
74
|
+
{ name: "createReferral", type: "address" },
|
|
75
|
+
],
|
|
76
|
+
} as const;
|
|
77
|
+
|
|
78
|
+
export const PreminterDomain = "Preminter";
|
|
79
|
+
|
|
80
|
+
export enum PremintConfigVersion {
|
|
81
|
+
V1 = "1",
|
|
82
|
+
V2 = "2",
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type PremintConfigForVersion<T extends PremintConfigVersion> =
|
|
86
|
+
T extends PremintConfigVersion.V1 ? PremintConfigV1 : PremintConfigV2;
|
|
87
|
+
|
|
88
|
+
export type PremintConfigWithVersion<T extends PremintConfigVersion> = {
|
|
89
|
+
premintConfig: PremintConfigForVersion<T>;
|
|
90
|
+
premintConfigVersion: T;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export type PremintConfigAndVersion =
|
|
94
|
+
| PremintConfigWithVersion<PremintConfigVersion.V1>
|
|
95
|
+
| PremintConfigWithVersion<PremintConfigVersion.V2>;
|
|
96
|
+
|
|
97
|
+
export type PremintConfig = PremintConfigV1 | PremintConfigV2;
|
|
98
|
+
export type TokenCreationConfig = TokenCreationConfigV1 | TokenCreationConfigV2;
|
|
99
|
+
|
|
100
|
+
export type PremintConfigForTokenCreationConfig<T extends TokenCreationConfig> =
|
|
101
|
+
T extends TokenCreationConfigV1 ? PremintConfigV1 : PremintConfigV2;
|
|
102
|
+
|
|
103
|
+
export type TokenConfigForVersion<T extends PremintConfigVersion> =
|
|
104
|
+
PremintConfigForVersion<T>["tokenConfig"];
|
|
105
|
+
|
|
106
|
+
export type TokenConfigWithVersion<T extends PremintConfigVersion> = {
|
|
107
|
+
tokenConfig: TokenConfigForVersion<T>;
|
|
108
|
+
premintConfigVersion: T;
|
|
109
|
+
};
|
|
@@ -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,11 +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 {
|
|
6
|
+
import { forkUrls, makeAnvilTest } from "src/anvil";
|
|
7
|
+
import {
|
|
8
|
+
ContractCreationConfig,
|
|
9
|
+
PremintConfigV1,
|
|
10
|
+
PremintConfigVersion,
|
|
11
|
+
} from "./contract-types";
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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",
|
|
9
21
|
async ({ viemClients: { walletClient, publicClient } }) => {
|
|
10
22
|
const [deployerAccount] = await walletClient.getAddresses();
|
|
11
23
|
const premintClient = createPremintClient({
|
|
@@ -14,15 +26,15 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
14
26
|
});
|
|
15
27
|
|
|
16
28
|
premintClient.apiClient.getNextUID = vi
|
|
17
|
-
.fn()
|
|
18
|
-
.mockResolvedValue(
|
|
29
|
+
.fn<any, ReturnType<typeof premintClient.apiClient.getNextUID>>()
|
|
30
|
+
.mockResolvedValue(3);
|
|
19
31
|
premintClient.apiClient.postSignature = vi
|
|
20
|
-
.fn()
|
|
32
|
+
.fn<Parameters<typeof premintClient.apiClient.postSignature>>()
|
|
21
33
|
.mockResolvedValue({ ok: true });
|
|
22
34
|
|
|
23
35
|
await premintClient.createPremint({
|
|
24
36
|
walletClient,
|
|
25
|
-
|
|
37
|
+
creatorAccount: deployerAccount!,
|
|
26
38
|
checkSignature: true,
|
|
27
39
|
collection: {
|
|
28
40
|
contractAdmin: deployerAccount!,
|
|
@@ -30,28 +42,30 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
30
42
|
contractURI:
|
|
31
43
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
32
44
|
},
|
|
33
|
-
|
|
45
|
+
tokenCreationConfig: {
|
|
34
46
|
tokenURI:
|
|
35
47
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
36
48
|
},
|
|
37
49
|
});
|
|
38
50
|
|
|
39
|
-
|
|
51
|
+
const expectedPostSignatureArgs: Parameters<
|
|
52
|
+
typeof premintClient.apiClient.postSignature
|
|
53
|
+
>[0] = {
|
|
40
54
|
collection: {
|
|
41
55
|
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
42
56
|
contractName: "Testing Contract",
|
|
43
57
|
contractURI:
|
|
44
58
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
45
59
|
},
|
|
46
|
-
|
|
60
|
+
premintConfig: {
|
|
47
61
|
deleted: false,
|
|
48
62
|
tokenConfig: {
|
|
49
63
|
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
50
|
-
maxSupply:
|
|
51
|
-
maxTokensPerAddress:
|
|
52
|
-
mintDuration:
|
|
53
|
-
mintStart:
|
|
54
|
-
pricePerToken:
|
|
64
|
+
maxSupply: 18446744073709551615n,
|
|
65
|
+
maxTokensPerAddress: 0n,
|
|
66
|
+
mintDuration: 604800n,
|
|
67
|
+
mintStart: 0n,
|
|
68
|
+
pricePerToken: 0n,
|
|
55
69
|
royaltyBPS: 1000,
|
|
56
70
|
royaltyMintSchedule: 0,
|
|
57
71
|
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
@@ -59,16 +73,21 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
59
73
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
60
74
|
},
|
|
61
75
|
uid: 3,
|
|
62
|
-
version:
|
|
76
|
+
version: 0,
|
|
63
77
|
},
|
|
78
|
+
premintConfigVersion: PremintConfigVersion.V1,
|
|
64
79
|
signature:
|
|
65
|
-
"
|
|
66
|
-
}
|
|
80
|
+
"0x8c6a9160a0917d98c201b37c9220c17ebaed23a5f905202341c1d0d4e8673c3913880907d6de48c9858fbeb40a9a38d5edda979e4dcb133643ca8ecb4afe0b691b",
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
expect(premintClient.apiClient.postSignature).toHaveBeenCalledWith(
|
|
84
|
+
expectedPostSignatureArgs,
|
|
85
|
+
);
|
|
67
86
|
},
|
|
68
87
|
20 * 1000,
|
|
69
88
|
);
|
|
70
89
|
|
|
71
|
-
|
|
90
|
+
zoraMainnetForkAnvilTest(
|
|
72
91
|
"can validate premint on network",
|
|
73
92
|
async ({ viemClients: { publicClient } }) => {
|
|
74
93
|
const premintClient = createPremintClient({
|
|
@@ -76,88 +95,92 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
76
95
|
publicClient,
|
|
77
96
|
});
|
|
78
97
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
102
|
-
},
|
|
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",
|
|
103
120
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const signature =
|
|
124
|
+
"0x588d19641de9ba1dade4d2bb5387c8dc96f4a990fef69787534b60caead759e6334975a6be10a796da948cd7d1d4f5580b3f84d49d9fa4e0b41c97759507975a1c" as Hex;
|
|
108
125
|
|
|
109
126
|
const signatureValid = await premintClient.isValidSignature({
|
|
110
|
-
|
|
111
|
-
|
|
127
|
+
collection: collection,
|
|
128
|
+
premintConfig: premint,
|
|
129
|
+
signature,
|
|
130
|
+
// default to premint config v1 version (we dont need to specify it here)
|
|
112
131
|
});
|
|
113
132
|
expect(signatureValid.isValid).toBe(true);
|
|
114
133
|
},
|
|
115
134
|
);
|
|
116
135
|
|
|
117
|
-
|
|
136
|
+
zoraMainnetForkAnvilTest(
|
|
118
137
|
"can execute premint on network",
|
|
119
138
|
async ({ viemClients: { walletClient, publicClient } }) => {
|
|
120
139
|
const [deployerAccount] = await walletClient.getAddresses();
|
|
121
|
-
const premintClient = createPremintClient({
|
|
140
|
+
const premintClient = createPremintClient({
|
|
141
|
+
chain: foundry,
|
|
142
|
+
publicClient,
|
|
143
|
+
});
|
|
122
144
|
|
|
123
|
-
premintClient.apiClient.getSignature = vi
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
premint: {
|
|
132
|
-
deleted: false,
|
|
133
|
-
tokenConfig: {
|
|
134
|
-
fixedPriceMinter: "0x04E2516A2c207E84a1839755675dfd8eF6302F0a",
|
|
135
|
-
maxSupply: "18446744073709551615",
|
|
136
|
-
maxTokensPerAddress: "0",
|
|
137
|
-
mintDuration: "604800",
|
|
138
|
-
mintStart: "0",
|
|
139
|
-
pricePerToken: "0",
|
|
140
|
-
royaltyBPS: 1000,
|
|
141
|
-
royaltyMintSchedule: 0,
|
|
142
|
-
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
143
|
-
tokenURI:
|
|
144
|
-
"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",
|
|
145
153
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
+
|
|
152
177
|
premintClient.apiClient.postSignature = vi.fn();
|
|
153
178
|
|
|
154
179
|
const simulateContractParameters = await premintClient.makeMintParameters(
|
|
155
180
|
{
|
|
156
181
|
account: deployerAccount!,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
uid: 3,
|
|
160
|
-
}),
|
|
182
|
+
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
183
|
+
uid: 3,
|
|
161
184
|
mintArguments: {
|
|
162
185
|
quantityToMint: 1,
|
|
163
186
|
mintComment: "",
|
|
@@ -212,3 +235,82 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
212
235
|
20 * 1000,
|
|
213
236
|
);
|
|
214
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
|
+
});
|