@zoralabs/protocol-sdk 0.4.1 → 0.4.3
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 +14 -14
- package/.turbo/turbo-lint.log +5 -0
- package/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/dist/apis/generated/premint-api-types.d.ts +117 -13
- package/dist/apis/generated/premint-api-types.d.ts.map +1 -1
- package/dist/index.cjs +134 -107
- 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 +129 -107
- package/dist/index.js.map +1 -1
- package/dist/premint/conversions.d.ts +78 -0
- package/dist/premint/conversions.d.ts.map +1 -0
- package/dist/premint/premint-api-client.d.ts +2 -3
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +4 -83
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/anvil.ts +1 -1
- package/src/apis/generated/premint-api-types.ts +124 -12
- package/src/index.ts +2 -0
- package/src/mint/mint-client.test.ts +5 -2
- package/src/premint/conversions.ts +155 -0
- package/src/premint/premint-api-client.ts +19 -125
- package/src/premint/premint-client.test.ts +5 -34
- package/src/premint/premint-client.ts +23 -23
- package/src/premint/preminter.ts +6 -12
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { Account, Address, Chain, Hex, PublicClient, SimulateContractParameters, TransactionReceipt, WalletClient } from "viem";
|
|
2
2
|
import { zoraCreator1155PremintExecutorImplABI } from "@zoralabs/protocol-deployments";
|
|
3
3
|
import { PremintConfigVersion, ContractCreationConfig, TokenConfigForVersion, TokenCreationConfigV1, TokenCreationConfigV2, TokenCreationConfig, PremintConfigForVersion } from "./contract-types";
|
|
4
|
-
import type { PremintSignatureResponse } from "./premint-api-client";
|
|
5
4
|
import { PremintAPIClient } from "./premint-api-client";
|
|
6
5
|
import type { DecodeEventLogReturnType } from "viem";
|
|
7
6
|
import { IHttpClient } from "src/apis/http-api-base";
|
|
8
7
|
import { MintCosts } from "src/mint/mint-client";
|
|
9
|
-
type
|
|
8
|
+
type PremintedV2LogType = DecodeEventLogReturnType<typeof zoraCreator1155PremintExecutorImplABI, "PremintedV2">["args"];
|
|
10
9
|
type URLSReturnType = {
|
|
11
10
|
explorer: null | string;
|
|
12
11
|
zoraCollect: null | string;
|
|
@@ -16,7 +15,6 @@ type SignedPremintResponse = {
|
|
|
16
15
|
urls: URLSReturnType;
|
|
17
16
|
uid: number;
|
|
18
17
|
verifyingContract: Address;
|
|
19
|
-
premint: PremintSignatureResponse;
|
|
20
18
|
};
|
|
21
19
|
export declare const defaultTokenConfigV1MintArguments: () => Omit<TokenCreationConfigV1, "fixedPriceMinter" | "tokenURI" | "royaltyRecipient">;
|
|
22
20
|
export declare const defaultTokenConfigV2MintArguments: () => Omit<TokenCreationConfigV2, "fixedPriceMinter" | "tokenURI" | "payoutRecipient" | "createReferral">;
|
|
@@ -26,7 +24,7 @@ export declare const defaultTokenConfigV2MintArguments: () => Omit<TokenCreation
|
|
|
26
24
|
* @param receipt Preminted log from receipt
|
|
27
25
|
* @returns Premint event arguments
|
|
28
26
|
*/
|
|
29
|
-
export declare function getPremintedLogFromReceipt(receipt: TransactionReceipt):
|
|
27
|
+
export declare function getPremintedLogFromReceipt(receipt: TransactionReceipt): PremintedV2LogType | undefined;
|
|
30
28
|
/**
|
|
31
29
|
* Preminter API to access ZORA Premint functionality.
|
|
32
30
|
* Currently only supports V1 premints.
|
|
@@ -42,23 +40,6 @@ declare class PremintClient {
|
|
|
42
40
|
tokenId: bigint;
|
|
43
41
|
createdNewContract: boolean;
|
|
44
42
|
uid: number;
|
|
45
|
-
contractConfig: {
|
|
46
|
-
contractAdmin: `0x${string}`;
|
|
47
|
-
contractURI: string;
|
|
48
|
-
contractName: string;
|
|
49
|
-
};
|
|
50
|
-
tokenConfig: {
|
|
51
|
-
tokenURI: string;
|
|
52
|
-
maxSupply: bigint;
|
|
53
|
-
maxTokensPerAddress: bigint;
|
|
54
|
-
pricePerToken: bigint;
|
|
55
|
-
mintStart: bigint;
|
|
56
|
-
mintDuration: bigint;
|
|
57
|
-
royaltyMintSchedule: number;
|
|
58
|
-
royaltyBPS: number;
|
|
59
|
-
royaltyRecipient: `0x${string}`;
|
|
60
|
-
fixedPriceMinter: `0x${string}`;
|
|
61
|
-
};
|
|
62
43
|
minter: `0x${string}`;
|
|
63
44
|
quantityMinted: bigint;
|
|
64
45
|
} | undefined;
|
|
@@ -108,37 +89,7 @@ declare class PremintClient {
|
|
|
108
89
|
uid: number;
|
|
109
90
|
account?: Account | Address;
|
|
110
91
|
collection: Address;
|
|
111
|
-
}): Promise<
|
|
112
|
-
urls: URLSReturnType;
|
|
113
|
-
uid: number;
|
|
114
|
-
verifyingContract: `0x${string}`;
|
|
115
|
-
premint: {
|
|
116
|
-
collection: {
|
|
117
|
-
contractAdmin: string;
|
|
118
|
-
contractURI: string;
|
|
119
|
-
contractName: string;
|
|
120
|
-
};
|
|
121
|
-
premint: {
|
|
122
|
-
tokenConfig: {
|
|
123
|
-
tokenURI: string;
|
|
124
|
-
maxSupply: string;
|
|
125
|
-
maxTokensPerAddress: string;
|
|
126
|
-
pricePerToken: string;
|
|
127
|
-
mintStart: string;
|
|
128
|
-
mintDuration: string;
|
|
129
|
-
royaltyMintSchedule: number;
|
|
130
|
-
royaltyBPS: number;
|
|
131
|
-
royaltyRecipient: string;
|
|
132
|
-
fixedPriceMinter: string;
|
|
133
|
-
};
|
|
134
|
-
uid: number;
|
|
135
|
-
version: number;
|
|
136
|
-
deleted: boolean;
|
|
137
|
-
};
|
|
138
|
-
chain_name: "ETHEREUM-MAINNET" | "ETHEREUM-ROPSTEN" | "ETHEREUM-RINKEBY" | "ETHEREUM-GOERLI" | "ETHEREUM-SEPOLIA" | "OPTIMISM-MAINNET" | "OPTIMISM-GOERLI" | "ZORA-GOERLI" | "ZORA-MAINNET" | "BASE-MAINNET" | "BASE-GOERLI" | "PGN-MAINNET";
|
|
139
|
-
signature: string;
|
|
140
|
-
};
|
|
141
|
-
}>;
|
|
92
|
+
}): Promise<SignedPremintResponse>;
|
|
142
93
|
/**
|
|
143
94
|
* Internal function to sign and submit a premint request.
|
|
144
95
|
*
|
|
@@ -168,37 +119,7 @@ declare class PremintClient {
|
|
|
168
119
|
};
|
|
169
120
|
premintConfigVersion?: T;
|
|
170
121
|
uid?: number;
|
|
171
|
-
}): Promise<
|
|
172
|
-
urls: URLSReturnType;
|
|
173
|
-
uid: number;
|
|
174
|
-
verifyingContract: `0x${string}`;
|
|
175
|
-
premint: {
|
|
176
|
-
collection: {
|
|
177
|
-
contractAdmin: string;
|
|
178
|
-
contractURI: string;
|
|
179
|
-
contractName: string;
|
|
180
|
-
};
|
|
181
|
-
premint: {
|
|
182
|
-
tokenConfig: {
|
|
183
|
-
tokenURI: string;
|
|
184
|
-
maxSupply: string;
|
|
185
|
-
maxTokensPerAddress: string;
|
|
186
|
-
pricePerToken: string;
|
|
187
|
-
mintStart: string;
|
|
188
|
-
mintDuration: string;
|
|
189
|
-
royaltyMintSchedule: number;
|
|
190
|
-
royaltyBPS: number;
|
|
191
|
-
royaltyRecipient: string;
|
|
192
|
-
fixedPriceMinter: string;
|
|
193
|
-
};
|
|
194
|
-
uid: number;
|
|
195
|
-
version: number;
|
|
196
|
-
deleted: boolean;
|
|
197
|
-
};
|
|
198
|
-
chain_name: "ETHEREUM-MAINNET" | "ETHEREUM-ROPSTEN" | "ETHEREUM-RINKEBY" | "ETHEREUM-GOERLI" | "ETHEREUM-SEPOLIA" | "OPTIMISM-MAINNET" | "OPTIMISM-GOERLI" | "ZORA-GOERLI" | "ZORA-MAINNET" | "BASE-MAINNET" | "BASE-GOERLI" | "PGN-MAINNET";
|
|
199
|
-
signature: string;
|
|
200
|
-
};
|
|
201
|
-
}>;
|
|
122
|
+
}): Promise<SignedPremintResponse>;
|
|
202
123
|
/**
|
|
203
124
|
* Fetches given premint data from the ZORA API.
|
|
204
125
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"premint-client.d.ts","sourceRoot":"","sources":["../../src/premint/premint-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,GAAG,EACH,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,EAClB,YAAY,EACb,MAAM,MAAM,CAAC;AACd,OAAO,EACL,qCAAqC,EAEtC,MAAM,gCAAgC,CAAC;AAcxC,OAAO,EAEL,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EAErB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"premint-client.d.ts","sourceRoot":"","sources":["../../src/premint/premint-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,KAAK,EACL,GAAG,EACH,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,EAClB,YAAY,EACb,MAAM,MAAM,CAAC;AACd,OAAO,EACL,qCAAqC,EAEtC,MAAM,gCAAgC,CAAC;AAcxC,OAAO,EAEL,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EAErB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,MAAM,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,KAAK,kBAAkB,GAAG,wBAAwB,CAChD,OAAO,qCAAqC,EAC5C,aAAa,CACd,CAAC,MAAM,CAAC,CAAC;AAEV,KAAK,cAAc,GAAG;IACpB,QAAQ,EAAE,IAAI,GAAG,MAAM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,WAAW,EACX,kBAAkB,GACnB,EAAE;IACD,WAAW,EAAE,mBAAmB,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAClD,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,SAAS,CAAC,GAAG,aAAa,CAczD;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,mBAAmB,EAAE,EAC5D,WAAW,EACX,GAAG,GACJ,EAAE;IACD,WAAW,EAAE,CAAC,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,mCAAmC,CAAC,CAAC,CAAC,CAOzC;AAED,wBAAsB,iBAAiB,CAAC,EACtC,aAAa,EACb,YAAY,GACb,EAAE;IACD,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B,mBAeA;AAED,wBAAsB,mBAAmB,CAAC,EACxC,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,GACf,EAAE;IACD,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B,GAAG,OAAO,CAAC,SAAS,CAAC,CAQrB;AAED,wBAAgB,wBAAwB,CAAC,EACvC,YAA0B,EAC1B,gBAA8B,GAC/B,EAAE;IACD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GAAG,OAAO,EAAE,CAEZ"}
|
package/package.json
CHANGED
package/src/anvil.ts
CHANGED
|
@@ -44,6 +44,7 @@ export interface components {
|
|
|
44
44
|
| "OPTIMISM-MAINNET"
|
|
45
45
|
| "OPTIMISM-GOERLI"
|
|
46
46
|
| "ZORA-GOERLI"
|
|
47
|
+
| "ZORA-SEPOLIA"
|
|
47
48
|
| "ZORA-MAINNET"
|
|
48
49
|
| "BASE-MAINNET"
|
|
49
50
|
| "BASE-GOERLI"
|
|
@@ -95,10 +96,13 @@ export interface components {
|
|
|
95
96
|
/** Contract Name */
|
|
96
97
|
contract_name: string;
|
|
97
98
|
/** Premints */
|
|
98
|
-
premints:
|
|
99
|
+
premints: (
|
|
100
|
+
| components["schemas"]["SignedPremintConfigV1"]
|
|
101
|
+
| components["schemas"]["SignedPremintConfigV2"]
|
|
102
|
+
)[];
|
|
99
103
|
};
|
|
100
104
|
/**
|
|
101
|
-
*
|
|
105
|
+
* PremintConfigV1
|
|
102
106
|
* @description ObjectBase extends Pydantic's BaseModel class to support extra functionality
|
|
103
107
|
* (store_as, override_name), as well as provides other convinience methods.
|
|
104
108
|
* ObjectBase allows for validation and type enforcement, and should be used inheritedfor any
|
|
@@ -109,8 +113,41 @@ export interface components {
|
|
|
109
113
|
* ...: found_at_height: int = field(override_name="address", store_as=str)
|
|
110
114
|
* ...: other: str = "default"
|
|
111
115
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
PremintConfigV1: {
|
|
117
|
+
/**
|
|
118
|
+
* Config Version
|
|
119
|
+
* @default 1
|
|
120
|
+
* @enum {string}
|
|
121
|
+
*/
|
|
122
|
+
config_version?: "1";
|
|
123
|
+
tokenConfig: components["schemas"]["TokenCreationConfigV1"];
|
|
124
|
+
/** Uid */
|
|
125
|
+
uid: number;
|
|
126
|
+
/** Version */
|
|
127
|
+
version: number;
|
|
128
|
+
/** Deleted */
|
|
129
|
+
deleted: boolean;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* PremintConfigV2
|
|
133
|
+
* @description ObjectBase extends Pydantic's BaseModel class to support extra functionality
|
|
134
|
+
* (store_as, override_name), as well as provides other convinience methods.
|
|
135
|
+
* ObjectBase allows for validation and type enforcement, and should be used inheritedfor any
|
|
136
|
+
* complex type we include on a stored entity.
|
|
137
|
+
*
|
|
138
|
+
* Example::
|
|
139
|
+
* >>> class Foo(ObjectBase):
|
|
140
|
+
* ...: found_at_height: int = field(override_name="address", store_as=str)
|
|
141
|
+
* ...: other: str = "default"
|
|
142
|
+
*/
|
|
143
|
+
PremintConfigV2: {
|
|
144
|
+
/**
|
|
145
|
+
* Config Version
|
|
146
|
+
* @default 2
|
|
147
|
+
* @enum {string}
|
|
148
|
+
*/
|
|
149
|
+
config_version?: "2";
|
|
150
|
+
tokenConfig: components["schemas"]["TokenCreationConfigV2"];
|
|
114
151
|
/** Uid */
|
|
115
152
|
uid: number;
|
|
116
153
|
/** Version */
|
|
@@ -148,7 +185,10 @@ export interface components {
|
|
|
148
185
|
*/
|
|
149
186
|
PremintRequest: {
|
|
150
187
|
collection: components["schemas"]["CollectionCreationConfig"];
|
|
151
|
-
|
|
188
|
+
/** Premint */
|
|
189
|
+
premint:
|
|
190
|
+
| components["schemas"]["PremintConfigV1"]
|
|
191
|
+
| components["schemas"]["PremintConfigV2"];
|
|
152
192
|
chain_name: components["schemas"]["ChainName"];
|
|
153
193
|
/** Signature */
|
|
154
194
|
signature: string;
|
|
@@ -167,7 +207,10 @@ export interface components {
|
|
|
167
207
|
*/
|
|
168
208
|
PremintSignature: {
|
|
169
209
|
collection: components["schemas"]["CollectionCreationConfig"];
|
|
170
|
-
|
|
210
|
+
/** Premint */
|
|
211
|
+
premint:
|
|
212
|
+
| components["schemas"]["PremintConfigV1"]
|
|
213
|
+
| components["schemas"]["PremintConfigV2"];
|
|
171
214
|
chain_name: components["schemas"]["ChainName"];
|
|
172
215
|
/** Signature */
|
|
173
216
|
signature: string;
|
|
@@ -177,7 +220,7 @@ export interface components {
|
|
|
177
220
|
signer: string;
|
|
178
221
|
};
|
|
179
222
|
/**
|
|
180
|
-
*
|
|
223
|
+
* SignedPremintConfigV1
|
|
181
224
|
* @description ObjectBase extends Pydantic's BaseModel class to support extra functionality
|
|
182
225
|
* (store_as, override_name), as well as provides other convinience methods.
|
|
183
226
|
* ObjectBase allows for validation and type enforcement, and should be used inheritedfor any
|
|
@@ -188,8 +231,14 @@ export interface components {
|
|
|
188
231
|
* ...: found_at_height: int = field(override_name="address", store_as=str)
|
|
189
232
|
* ...: other: str = "default"
|
|
190
233
|
*/
|
|
191
|
-
|
|
192
|
-
|
|
234
|
+
SignedPremintConfigV1: {
|
|
235
|
+
/**
|
|
236
|
+
* Config Version
|
|
237
|
+
* @default 1
|
|
238
|
+
* @enum {string}
|
|
239
|
+
*/
|
|
240
|
+
config_version?: "1";
|
|
241
|
+
tokenConfig: components["schemas"]["TokenCreationConfigV1"];
|
|
193
242
|
/** Uid */
|
|
194
243
|
uid: number;
|
|
195
244
|
/** Version */
|
|
@@ -200,7 +249,7 @@ export interface components {
|
|
|
200
249
|
signature: string;
|
|
201
250
|
};
|
|
202
251
|
/**
|
|
203
|
-
*
|
|
252
|
+
* SignedPremintConfigV2
|
|
204
253
|
* @description ObjectBase extends Pydantic's BaseModel class to support extra functionality
|
|
205
254
|
* (store_as, override_name), as well as provides other convinience methods.
|
|
206
255
|
* ObjectBase allows for validation and type enforcement, and should be used inheritedfor any
|
|
@@ -211,7 +260,36 @@ export interface components {
|
|
|
211
260
|
* ...: found_at_height: int = field(override_name="address", store_as=str)
|
|
212
261
|
* ...: other: str = "default"
|
|
213
262
|
*/
|
|
214
|
-
|
|
263
|
+
SignedPremintConfigV2: {
|
|
264
|
+
/**
|
|
265
|
+
* Config Version
|
|
266
|
+
* @default 2
|
|
267
|
+
* @enum {string}
|
|
268
|
+
*/
|
|
269
|
+
config_version?: "2";
|
|
270
|
+
tokenConfig: components["schemas"]["TokenCreationConfigV2"];
|
|
271
|
+
/** Uid */
|
|
272
|
+
uid: number;
|
|
273
|
+
/** Version */
|
|
274
|
+
version: number;
|
|
275
|
+
/** Deleted */
|
|
276
|
+
deleted: boolean;
|
|
277
|
+
/** Signature */
|
|
278
|
+
signature: string;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* TokenCreationConfigV1
|
|
282
|
+
* @description ObjectBase extends Pydantic's BaseModel class to support extra functionality
|
|
283
|
+
* (store_as, override_name), as well as provides other convinience methods.
|
|
284
|
+
* ObjectBase allows for validation and type enforcement, and should be used inheritedfor any
|
|
285
|
+
* complex type we include on a stored entity.
|
|
286
|
+
*
|
|
287
|
+
* Example::
|
|
288
|
+
* >>> class Foo(ObjectBase):
|
|
289
|
+
* ...: found_at_height: int = field(override_name="address", store_as=str)
|
|
290
|
+
* ...: other: str = "default"
|
|
291
|
+
*/
|
|
292
|
+
TokenCreationConfigV1: {
|
|
215
293
|
/** Tokenuri */
|
|
216
294
|
tokenURI: string;
|
|
217
295
|
/** Maxsupply */
|
|
@@ -233,6 +311,40 @@ export interface components {
|
|
|
233
311
|
/** Fixedpriceminter */
|
|
234
312
|
fixedPriceMinter: string;
|
|
235
313
|
};
|
|
314
|
+
/**
|
|
315
|
+
* TokenCreationConfigV2
|
|
316
|
+
* @description ObjectBase extends Pydantic's BaseModel class to support extra functionality
|
|
317
|
+
* (store_as, override_name), as well as provides other convinience methods.
|
|
318
|
+
* ObjectBase allows for validation and type enforcement, and should be used inheritedfor any
|
|
319
|
+
* complex type we include on a stored entity.
|
|
320
|
+
*
|
|
321
|
+
* Example::
|
|
322
|
+
* >>> class Foo(ObjectBase):
|
|
323
|
+
* ...: found_at_height: int = field(override_name="address", store_as=str)
|
|
324
|
+
* ...: other: str = "default"
|
|
325
|
+
*/
|
|
326
|
+
TokenCreationConfigV2: {
|
|
327
|
+
/** Tokenuri */
|
|
328
|
+
tokenURI: string;
|
|
329
|
+
/** Maxsupply */
|
|
330
|
+
maxSupply: string;
|
|
331
|
+
/** Maxtokensperaddress */
|
|
332
|
+
maxTokensPerAddress: string;
|
|
333
|
+
/** Pricepertoken */
|
|
334
|
+
pricePerToken: string;
|
|
335
|
+
/** Mintstart */
|
|
336
|
+
mintStart: string;
|
|
337
|
+
/** Mintduration */
|
|
338
|
+
mintDuration: string;
|
|
339
|
+
/** Royaltybps */
|
|
340
|
+
royaltyBPS: number;
|
|
341
|
+
/** Fixedpriceminter */
|
|
342
|
+
fixedPriceMinter: string;
|
|
343
|
+
/** Payoutrecipient */
|
|
344
|
+
payoutRecipient: string;
|
|
345
|
+
/** Createreferral */
|
|
346
|
+
createReferral: string;
|
|
347
|
+
};
|
|
236
348
|
/** ValidationError */
|
|
237
349
|
ValidationError: {
|
|
238
350
|
/** Location */
|
|
@@ -266,7 +378,7 @@ export interface operations {
|
|
|
266
378
|
/** @description Successful Response */
|
|
267
379
|
200: {
|
|
268
380
|
content: {
|
|
269
|
-
"application/json": components["schemas"]["
|
|
381
|
+
"application/json": components["schemas"]["PremintSignature"];
|
|
270
382
|
};
|
|
271
383
|
};
|
|
272
384
|
/** @description Validation Error */
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { zora } from "viem/chains";
|
|
|
3
3
|
import { describe, expect } from "vitest";
|
|
4
4
|
import { createMintClient } from "./mint-client";
|
|
5
5
|
import { zoraCreator1155ImplABI } from "@zoralabs/protocol-deployments";
|
|
6
|
-
import { anvilTest } from "src/anvil";
|
|
6
|
+
import { anvilTest, forkUrls, makeAnvilTest } from "src/anvil";
|
|
7
7
|
|
|
8
8
|
const erc721ABI = parseAbi([
|
|
9
9
|
"function balanceOf(address owner) public view returns (uint256)",
|
|
@@ -58,7 +58,10 @@ describe("mint-helper", () => {
|
|
|
58
58
|
12 * 1000,
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
makeAnvilTest({
|
|
62
|
+
forkUrl: forkUrls.zoraMainnet,
|
|
63
|
+
forkBlockNumber: 6133407,
|
|
64
|
+
})(
|
|
62
65
|
"mints a new 721 token",
|
|
63
66
|
async ({ viemClients }) => {
|
|
64
67
|
const { testClient, walletClient, publicClient } = viemClients;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
2
|
+
import {
|
|
3
|
+
ContractCreationConfig,
|
|
4
|
+
PremintConfigAndVersion,
|
|
5
|
+
PremintConfigV1,
|
|
6
|
+
PremintConfigV2,
|
|
7
|
+
PremintConfigVersion,
|
|
8
|
+
PremintConfigWithVersion,
|
|
9
|
+
} from "./contract-types";
|
|
10
|
+
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
|
+
|
|
14
|
+
export const convertCollectionFromApi = (
|
|
15
|
+
collection: PremintSignatureGetResponse["collection"],
|
|
16
|
+
): ContractCreationConfig => ({
|
|
17
|
+
...collection,
|
|
18
|
+
contractAdmin: collection.contractAdmin as Address,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Convert server to on-chain types for a premint
|
|
23
|
+
*
|
|
24
|
+
* @param premint Premint object from the server to convert to one that's compatible with viem
|
|
25
|
+
* @returns Viem type-compatible premint object
|
|
26
|
+
*/
|
|
27
|
+
export const convertPremintFromApi = (
|
|
28
|
+
premint: PremintSignatureGetResponse["premint"],
|
|
29
|
+
): PremintConfigAndVersion => {
|
|
30
|
+
if (
|
|
31
|
+
premint.config_version === PremintConfigVersion.V1 ||
|
|
32
|
+
!premint.config_version
|
|
33
|
+
) {
|
|
34
|
+
const tokenConfig =
|
|
35
|
+
premint.tokenConfig as components["schemas"]["TokenCreationConfigV1"];
|
|
36
|
+
return {
|
|
37
|
+
premintConfigVersion: PremintConfigVersion.V1,
|
|
38
|
+
premintConfig: {
|
|
39
|
+
...premint,
|
|
40
|
+
tokenConfig: {
|
|
41
|
+
...tokenConfig,
|
|
42
|
+
fixedPriceMinter: tokenConfig.fixedPriceMinter as Address,
|
|
43
|
+
royaltyRecipient: tokenConfig.royaltyRecipient as Address,
|
|
44
|
+
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
45
|
+
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
46
|
+
mintStart: BigInt(tokenConfig.mintStart),
|
|
47
|
+
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
48
|
+
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
} else {
|
|
53
|
+
const tokenConfig =
|
|
54
|
+
premint.tokenConfig as components["schemas"]["TokenCreationConfigV2"];
|
|
55
|
+
return {
|
|
56
|
+
premintConfigVersion: PremintConfigVersion.V2,
|
|
57
|
+
premintConfig: {
|
|
58
|
+
...premint,
|
|
59
|
+
tokenConfig: {
|
|
60
|
+
...tokenConfig,
|
|
61
|
+
fixedPriceMinter: tokenConfig.fixedPriceMinter as Address,
|
|
62
|
+
payoutRecipient: tokenConfig.payoutRecipient as Address,
|
|
63
|
+
createReferral: tokenConfig.createReferral as Address,
|
|
64
|
+
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
65
|
+
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
66
|
+
mintStart: BigInt(tokenConfig.mintStart),
|
|
67
|
+
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
68
|
+
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress),
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const convertGetPremintApiResponse = (
|
|
76
|
+
response: PremintSignatureGetResponse,
|
|
77
|
+
) => ({
|
|
78
|
+
...convertPremintFromApi(response.premint),
|
|
79
|
+
collection: convertCollectionFromApi(response.collection),
|
|
80
|
+
signature: response.signature as Hex,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const encodePremintV1ForAPI = ({
|
|
84
|
+
tokenConfig,
|
|
85
|
+
...premint
|
|
86
|
+
}: PremintConfigV1): PremintSignatureGetResponse["premint"] => ({
|
|
87
|
+
...premint,
|
|
88
|
+
tokenConfig: {
|
|
89
|
+
...tokenConfig,
|
|
90
|
+
maxSupply: tokenConfig.maxSupply.toString(),
|
|
91
|
+
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
92
|
+
mintStart: tokenConfig.mintStart.toString(),
|
|
93
|
+
mintDuration: tokenConfig.mintDuration.toString(),
|
|
94
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString(),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const encodePremintV2ForAPI = ({
|
|
99
|
+
tokenConfig,
|
|
100
|
+
...premint
|
|
101
|
+
}: PremintConfigV2) => ({
|
|
102
|
+
...premint,
|
|
103
|
+
tokenConfig: {
|
|
104
|
+
...tokenConfig,
|
|
105
|
+
maxSupply: tokenConfig.maxSupply.toString(),
|
|
106
|
+
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
107
|
+
mintStart: tokenConfig.mintStart.toString(),
|
|
108
|
+
mintDuration: tokenConfig.mintDuration.toString(),
|
|
109
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString(),
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
export const encodePremintForAPI = <T extends PremintConfigVersion>({
|
|
114
|
+
premintConfig,
|
|
115
|
+
premintConfigVersion,
|
|
116
|
+
}: PremintConfigWithVersion<T>): PremintSignatureRequestBody["premint"] => {
|
|
117
|
+
if (premintConfigVersion === PremintConfigVersion.V1) {
|
|
118
|
+
return encodePremintV1ForAPI(premintConfig as PremintConfigV1);
|
|
119
|
+
}
|
|
120
|
+
if (premintConfigVersion === PremintConfigVersion.V2) {
|
|
121
|
+
return encodePremintV2ForAPI(premintConfig as PremintConfigV2);
|
|
122
|
+
}
|
|
123
|
+
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type SignaturePostType = paths["/signature"]["post"];
|
|
127
|
+
export type PremintSignatureRequestBody =
|
|
128
|
+
SignaturePostType["requestBody"]["content"]["application/json"];
|
|
129
|
+
export type PremintSignatureResponse =
|
|
130
|
+
SignaturePostType["responses"][200]["content"]["application/json"];
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Encode input for posting a premint signature to the premint api
|
|
134
|
+
* @param param0
|
|
135
|
+
* @returns
|
|
136
|
+
*/
|
|
137
|
+
export const encodePostSignatureInput = <T extends PremintConfigVersion>({
|
|
138
|
+
collection,
|
|
139
|
+
premintConfigVersion,
|
|
140
|
+
premintConfig,
|
|
141
|
+
signature,
|
|
142
|
+
chainId,
|
|
143
|
+
}: {
|
|
144
|
+
collection: ContractCreationConfig;
|
|
145
|
+
signature: Hex;
|
|
146
|
+
chainId: number;
|
|
147
|
+
} & PremintConfigWithVersion<T>): PremintSignatureRequestBody => ({
|
|
148
|
+
premint: encodePremintForAPI({
|
|
149
|
+
premintConfig,
|
|
150
|
+
premintConfigVersion,
|
|
151
|
+
}) as PremintSignatureRequestBody["premint"],
|
|
152
|
+
signature,
|
|
153
|
+
collection,
|
|
154
|
+
chain_name: networkConfigByChain[chainId]!.zoraBackendChainName,
|
|
155
|
+
});
|