@zoralabs/protocol-sdk 0.5.17 → 0.7.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 +19 -0
- package/README.md +1 -416
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +16 -55
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/contract-setup.d.ts +14 -0
- package/dist/create/contract-setup.d.ts.map +1 -0
- package/dist/create/token-setup.d.ts +27 -0
- package/dist/create/token-setup.d.ts.map +1 -0
- package/dist/create/types.d.ts +45 -0
- package/dist/create/types.d.ts.map +1 -0
- package/dist/index.cjs +1745 -891
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1698 -858
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +48 -51
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +38 -0
- package/dist/mint/mint-queries.d.ts.map +1 -0
- package/dist/mint/mint-transactions.d.ts +20 -0
- package/dist/mint/mint-transactions.d.ts.map +1 -0
- package/dist/mint/subgraph-mint-getter.d.ts +24 -0
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
- package/dist/mint/subgraph-queries.d.ts +55 -0
- package/dist/mint/subgraph-queries.d.ts.map +1 -0
- package/dist/mint/types.d.ts +177 -0
- package/dist/mint/types.d.ts.map +1 -0
- package/dist/mint/utils.d.ts +2 -0
- package/dist/mint/utils.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +27 -4518
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/premint/contract-types.d.ts +4 -4
- package/dist/premint/contract-types.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +15 -16
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +32 -16
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +76 -50
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +20 -8
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +45 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +24 -6869
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/constants.ts +0 -36
- package/src/create/1155-create-helper.test.ts +236 -55
- package/src/create/1155-create-helper.ts +141 -309
- package/src/create/contract-setup.ts +88 -0
- package/src/create/token-setup.ts +379 -0
- package/src/create/types.ts +57 -0
- package/src/index.ts +5 -1
- package/src/mint/mint-client.test.ts +116 -78
- package/src/mint/mint-client.ts +130 -234
- package/src/mint/mint-queries.ts +320 -0
- package/src/mint/mint-transactions.ts +253 -0
- package/src/mint/subgraph-mint-getter.ts +247 -0
- package/src/mint/subgraph-queries.ts +170 -0
- package/src/mint/types.ts +239 -0
- package/src/mint/utils.ts +14 -0
- package/src/mints/mints-contracts.test.ts +1 -1
- package/src/mints/mints-contracts.ts +4 -4
- package/src/premint/contract-types.ts +4 -4
- package/src/premint/conversions.ts +38 -4
- package/src/premint/premint-api-client.ts +92 -48
- package/src/premint/premint-client.test.ts +100 -84
- package/src/premint/premint-client.ts +186 -185
- package/src/premint/preminter.test.ts +4 -5
- package/src/premint/preminter.ts +63 -14
- package/src/sdk.ts +101 -0
- package/src/types.ts +18 -0
- package/src/utils.ts +54 -46
- package/test-integration/setup-test-contracts.ts +96 -0
- package/dist/mint/mint-api-client.d.ts +0 -35
- package/dist/mint/mint-api-client.d.ts.map +0 -1
- package/src/mint/mint-api-client.ts +0 -177
- package/test-integration/premint-client.test.ts +0 -148
|
@@ -28,11 +28,11 @@ export type ContractCreationConfigAndAddress = {
|
|
|
28
28
|
export type ContractCreationConfigOrAddress =
|
|
29
29
|
| {
|
|
30
30
|
/** Parameters for creating the contract for new premints. */
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
contract: ContractCreationConfigWithOptionalAdditionalAdmins;
|
|
32
|
+
contractAddress?: undefined;
|
|
33
33
|
}
|
|
34
34
|
| {
|
|
35
|
-
|
|
35
|
+
contract?: undefined;
|
|
36
36
|
/** Premint collection address */
|
|
37
|
-
|
|
37
|
+
contractAddress: Address;
|
|
38
38
|
};
|
|
@@ -9,7 +9,10 @@ import {
|
|
|
9
9
|
PremintConfigVersion,
|
|
10
10
|
PremintConfigWithVersion,
|
|
11
11
|
} from "@zoralabs/protocol-deployments";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
PremintSignatureGetOfCollectionResponse,
|
|
14
|
+
PremintSignatureGetResponse,
|
|
15
|
+
} from "./premint-api-client";
|
|
13
16
|
import { ContractCreationConfigOrAddress } from "./contract-types";
|
|
14
17
|
|
|
15
18
|
export const convertCollectionFromApi = (
|
|
@@ -84,13 +87,34 @@ export const convertPremintFromApi = (
|
|
|
84
87
|
}
|
|
85
88
|
};
|
|
86
89
|
|
|
90
|
+
export type PremintFromApi = ReturnType<typeof convertGetPremintApiResponse>;
|
|
91
|
+
|
|
87
92
|
export const convertGetPremintApiResponse = (
|
|
88
93
|
response: PremintSignatureGetResponse,
|
|
89
94
|
) => ({
|
|
90
|
-
...convertPremintFromApi(response.premint),
|
|
91
95
|
collection: convertCollectionFromApi(response.collection),
|
|
92
96
|
collectionAddress: response.collection_address as Address,
|
|
93
97
|
signature: response.signature as Hex,
|
|
98
|
+
signer: response.signer as Address,
|
|
99
|
+
premint: convertPremintFromApi(response.premint),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export type PremintCollectionFromApi = ReturnType<
|
|
103
|
+
typeof convertGetPremintOfCollectionApiResponse
|
|
104
|
+
>;
|
|
105
|
+
|
|
106
|
+
export const convertGetPremintOfCollectionApiResponse = (
|
|
107
|
+
response: PremintSignatureGetOfCollectionResponse,
|
|
108
|
+
) => ({
|
|
109
|
+
collection: convertCollectionFromApi({
|
|
110
|
+
contractAdmin: response.contract_admin,
|
|
111
|
+
contractName: response.contract_name,
|
|
112
|
+
contractURI: response.contract_uri,
|
|
113
|
+
}),
|
|
114
|
+
premints: response.premints.map((premint) => ({
|
|
115
|
+
premint: convertPremintFromApi(premint),
|
|
116
|
+
signature: premint.signature as Hex,
|
|
117
|
+
})),
|
|
94
118
|
});
|
|
95
119
|
|
|
96
120
|
const encodePremintV1ForAPI = ({
|
|
@@ -150,8 +174,8 @@ export type PremintSignatureResponse =
|
|
|
150
174
|
* @returns
|
|
151
175
|
*/
|
|
152
176
|
export const encodePostSignatureInput = <T extends PremintConfigVersion>({
|
|
153
|
-
collection,
|
|
154
|
-
collectionAddress,
|
|
177
|
+
contract: collection,
|
|
178
|
+
contractAddress: collectionAddress,
|
|
155
179
|
premintConfigVersion,
|
|
156
180
|
premintConfig,
|
|
157
181
|
signature,
|
|
@@ -172,3 +196,13 @@ export const encodePostSignatureInput = <T extends PremintConfigVersion>({
|
|
|
172
196
|
collection_address: collectionAddress,
|
|
173
197
|
chain_name: networkConfigByChain[chainId]!.zoraBackendChainName,
|
|
174
198
|
});
|
|
199
|
+
|
|
200
|
+
export const isPremintConfigV1 = (
|
|
201
|
+
premintConfigAndVersion: PremintConfigAndVersion,
|
|
202
|
+
): premintConfigAndVersion is PremintConfigWithVersion<PremintConfigVersion.V1> =>
|
|
203
|
+
premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V1;
|
|
204
|
+
|
|
205
|
+
export const isPremintConfigV2 = (
|
|
206
|
+
premintConfigAndVersion: PremintConfigAndVersion,
|
|
207
|
+
): premintConfigAndVersion is PremintConfigWithVersion<PremintConfigVersion.V2> =>
|
|
208
|
+
premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V2;
|
|
@@ -4,19 +4,19 @@ import {
|
|
|
4
4
|
} from "../apis/http-api-base";
|
|
5
5
|
import { components, paths } from "../apis/generated/premint-api-types";
|
|
6
6
|
import { ZORA_API_BASE } from "../constants";
|
|
7
|
-
import {
|
|
8
|
-
import { getApiNetworkConfigForChain } from "src/mint/mint-api-client";
|
|
7
|
+
import { getApiNetworkConfigForChain } from "src/mint/subgraph-mint-getter";
|
|
9
8
|
import {
|
|
10
|
-
ContractCreationConfig,
|
|
11
|
-
PremintConfigAndVersion,
|
|
12
9
|
PremintConfigVersion,
|
|
13
10
|
PremintConfigWithVersion,
|
|
14
11
|
} from "@zoralabs/protocol-deployments";
|
|
15
12
|
import { Address, Hex } from "viem";
|
|
16
13
|
import {
|
|
14
|
+
PremintCollectionFromApi,
|
|
15
|
+
PremintFromApi,
|
|
17
16
|
PremintSignatureRequestBody,
|
|
18
17
|
PremintSignatureResponse,
|
|
19
18
|
convertGetPremintApiResponse,
|
|
19
|
+
convertGetPremintOfCollectionApiResponse,
|
|
20
20
|
encodePostSignatureInput,
|
|
21
21
|
} from "./conversions";
|
|
22
22
|
import { ContractCreationConfigOrAddress } from "./contract-types";
|
|
@@ -30,11 +30,14 @@ export type PremintNextUIDGetResponse =
|
|
|
30
30
|
|
|
31
31
|
type SignaturePremintGetType =
|
|
32
32
|
paths["/signature/{chain_name}/{collection_address}/{uid}"]["get"];
|
|
33
|
-
type PremintSignatureGetPathParameters =
|
|
34
|
-
SignaturePremintGetType["parameters"]["path"];
|
|
35
33
|
export type PremintSignatureGetResponse =
|
|
36
34
|
SignaturePremintGetType["responses"][200]["content"]["application/json"];
|
|
37
35
|
|
|
36
|
+
type SignaturePremintGetOfCollectionType =
|
|
37
|
+
paths["/signature/{chain_name}/{collection_address}"]["get"];
|
|
38
|
+
export type PremintSignatureGetOfCollectionResponse =
|
|
39
|
+
SignaturePremintGetOfCollectionType["responses"][200]["content"]["application/json"];
|
|
40
|
+
|
|
38
41
|
export type PremintCollection = PremintSignatureGetResponse["collection"];
|
|
39
42
|
|
|
40
43
|
export type BackendChainNames = components["schemas"]["ChainName"];
|
|
@@ -50,57 +53,102 @@ const postSignature = async ({
|
|
|
50
53
|
);
|
|
51
54
|
|
|
52
55
|
const getNextUID = async ({
|
|
53
|
-
|
|
56
|
+
chainId,
|
|
54
57
|
collection_address,
|
|
55
58
|
httpClient: { retries, get } = defaultHttpClient,
|
|
56
|
-
}: PremintNextUIDGetPathParameters & {
|
|
59
|
+
}: Omit<PremintNextUIDGetPathParameters, "chain_name"> & {
|
|
60
|
+
chainId: number;
|
|
57
61
|
httpClient?: Pick<IHttpClient, "retries" | "get">;
|
|
58
62
|
}): Promise<PremintNextUIDGetResponse> =>
|
|
59
63
|
retries(() =>
|
|
60
64
|
get<PremintNextUIDGetResponse>(
|
|
61
|
-
`${ZORA_API_BASE}premint/signature/${
|
|
65
|
+
`${ZORA_API_BASE}premint/signature/${
|
|
66
|
+
getApiNetworkConfigForChain(chainId).zoraBackendChainName
|
|
67
|
+
}/${collection_address}/next_uid`,
|
|
62
68
|
),
|
|
63
69
|
);
|
|
64
70
|
|
|
65
|
-
const getSignature = async ({
|
|
66
|
-
|
|
71
|
+
export const getSignature = async ({
|
|
72
|
+
collectionAddress,
|
|
67
73
|
uid,
|
|
68
|
-
|
|
74
|
+
chainId,
|
|
69
75
|
httpClient: { retries, get } = defaultHttpClient,
|
|
70
|
-
}:
|
|
76
|
+
}: {
|
|
77
|
+
collectionAddress: Address;
|
|
78
|
+
uid: number;
|
|
79
|
+
chainId: number;
|
|
71
80
|
httpClient?: Pick<IHttpClient, "retries" | "get">;
|
|
72
|
-
}): Promise<
|
|
73
|
-
|
|
74
|
-
premint_config_version?: PremintConfigVersion;
|
|
75
|
-
}
|
|
76
|
-
> => {
|
|
81
|
+
}): Promise<PremintFromApi> => {
|
|
82
|
+
const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
|
|
77
83
|
const result = await retries(() =>
|
|
78
84
|
get<PremintSignatureGetResponse>(
|
|
79
|
-
`${ZORA_API_BASE}premint/signature/${
|
|
85
|
+
`${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}/${uid}`,
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return convertGetPremintApiResponse(result);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const getOfCollection = async ({
|
|
93
|
+
collectionAddress,
|
|
94
|
+
chainId,
|
|
95
|
+
httpClient: { retries, get } = defaultHttpClient,
|
|
96
|
+
}: {
|
|
97
|
+
collectionAddress: Address;
|
|
98
|
+
chainId: number;
|
|
99
|
+
httpClient?: Pick<IHttpClient, "retries" | "get">;
|
|
100
|
+
}) => {
|
|
101
|
+
const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
|
|
102
|
+
const result = await retries(() =>
|
|
103
|
+
get<PremintSignatureGetOfCollectionResponse>(
|
|
104
|
+
`${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}`,
|
|
80
105
|
),
|
|
81
106
|
);
|
|
82
107
|
|
|
83
|
-
return result;
|
|
108
|
+
return convertGetPremintOfCollectionApiResponse(result);
|
|
84
109
|
};
|
|
85
110
|
|
|
86
|
-
|
|
111
|
+
export interface IPremintGetter {
|
|
112
|
+
get(params: {
|
|
113
|
+
collectionAddress: Address;
|
|
114
|
+
uid: number;
|
|
115
|
+
}): Promise<PremintFromApi>;
|
|
116
|
+
|
|
117
|
+
getOfCollection(params: {
|
|
118
|
+
collectionAddress: Address;
|
|
119
|
+
}): Promise<PremintCollectionFromApi>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface IPremintAPI {
|
|
123
|
+
get: IPremintGetter["get"];
|
|
124
|
+
|
|
125
|
+
getOfCollection: IPremintGetter["getOfCollection"];
|
|
126
|
+
|
|
127
|
+
getNextUID(collectionAddress: Address): Promise<number>;
|
|
128
|
+
|
|
129
|
+
postSignature<T extends PremintConfigVersion>(
|
|
130
|
+
params: {
|
|
131
|
+
signature: Hex;
|
|
132
|
+
} & PremintConfigWithVersion<T> &
|
|
133
|
+
ContractCreationConfigOrAddress,
|
|
134
|
+
): Promise<PremintSignatureResponse>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
class PremintAPIClient implements IPremintAPI {
|
|
138
|
+
chainId: number;
|
|
87
139
|
httpClient: IHttpClient;
|
|
88
|
-
networkConfig: NetworkConfig;
|
|
89
140
|
|
|
90
141
|
constructor(chainId: number, httpClient?: IHttpClient) {
|
|
142
|
+
this.chainId = chainId;
|
|
91
143
|
this.httpClient = httpClient || defaultHttpClient;
|
|
92
|
-
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
93
144
|
}
|
|
94
|
-
postSignature =
|
|
145
|
+
postSignature: IPremintAPI["postSignature"] = ({
|
|
95
146
|
signature,
|
|
96
147
|
...rest
|
|
97
|
-
}: {
|
|
98
|
-
signature: Hex;
|
|
99
|
-
} & PremintConfigWithVersion<T> &
|
|
100
|
-
ContractCreationConfigOrAddress): Promise<PremintSignatureResponse> => {
|
|
148
|
+
}): Promise<PremintSignatureResponse> => {
|
|
101
149
|
const data = encodePostSignatureInput({
|
|
102
150
|
...rest,
|
|
103
|
-
chainId: this.
|
|
151
|
+
chainId: this.chainId,
|
|
104
152
|
signature,
|
|
105
153
|
});
|
|
106
154
|
return postSignature({
|
|
@@ -109,36 +157,32 @@ class PremintAPIClient {
|
|
|
109
157
|
});
|
|
110
158
|
};
|
|
111
159
|
|
|
112
|
-
getNextUID = async (collectionAddress
|
|
160
|
+
getNextUID: IPremintAPI["getNextUID"] = async (collectionAddress) =>
|
|
113
161
|
(
|
|
114
162
|
await getNextUID({
|
|
115
163
|
collection_address: collectionAddress.toLowerCase(),
|
|
116
|
-
|
|
164
|
+
chainId: this.chainId,
|
|
117
165
|
httpClient: this.httpClient,
|
|
118
166
|
})
|
|
119
167
|
).next_uid;
|
|
120
168
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}: {
|
|
125
|
-
collectionAddress: Address;
|
|
126
|
-
uid: number;
|
|
127
|
-
}): Promise<
|
|
128
|
-
{
|
|
129
|
-
signature: Hex;
|
|
130
|
-
collection: ContractCreationConfig | undefined;
|
|
131
|
-
collectionAddress: Address;
|
|
132
|
-
} & PremintConfigAndVersion
|
|
133
|
-
> => {
|
|
134
|
-
const response = await getSignature({
|
|
135
|
-
collection_address: collectionAddress.toLowerCase(),
|
|
169
|
+
get: IPremintAPI["get"] = async ({ collectionAddress, uid }) => {
|
|
170
|
+
return getSignature({
|
|
171
|
+
collectionAddress,
|
|
136
172
|
uid,
|
|
137
|
-
|
|
173
|
+
chainId: this.chainId,
|
|
138
174
|
httpClient: this.httpClient,
|
|
139
175
|
});
|
|
176
|
+
};
|
|
140
177
|
|
|
141
|
-
|
|
178
|
+
getOfCollection: IPremintAPI["getOfCollection"] = async ({
|
|
179
|
+
collectionAddress,
|
|
180
|
+
}) => {
|
|
181
|
+
return getOfCollection({
|
|
182
|
+
collectionAddress,
|
|
183
|
+
chainId: this.chainId,
|
|
184
|
+
httpClient: this.httpClient,
|
|
185
|
+
});
|
|
142
186
|
};
|
|
143
187
|
}
|
|
144
188
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { zoraSepolia } from "viem/chains";
|
|
2
2
|
import { describe, expect, vi } from "vitest";
|
|
3
3
|
|
|
4
|
-
import { createPremintClient } from "./premint-client";
|
|
5
4
|
import { PremintConfigVersion } from "./contract-types";
|
|
6
5
|
import {
|
|
7
6
|
getDefaultFixedPriceMinterAddress,
|
|
@@ -12,6 +11,8 @@ import {
|
|
|
12
11
|
ContractCreationConfig,
|
|
13
12
|
PremintConfigV2,
|
|
14
13
|
} from "@zoralabs/protocol-deployments";
|
|
14
|
+
import { PremintAPIClient } from "./premint-api-client";
|
|
15
|
+
import { createCollectorClient, createCreatorClient } from "src/sdk";
|
|
15
16
|
|
|
16
17
|
const anvilTest = makeAnvilTest({
|
|
17
18
|
forkUrl: forkUrls.zoraSepolia,
|
|
@@ -24,13 +25,11 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
24
25
|
"can mint premints",
|
|
25
26
|
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
26
27
|
const [deployerAccount] = await walletClient.getAddresses();
|
|
27
|
-
const premintClient = createPremintClient({
|
|
28
|
-
chain,
|
|
29
|
-
publicClient,
|
|
30
|
-
});
|
|
31
28
|
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const premintApiClient = new PremintAPIClient(chain.id);
|
|
30
|
+
|
|
31
|
+
premintApiClient.get = vi
|
|
32
|
+
.fn<any, ReturnType<typeof premintApiClient.get>>()
|
|
34
33
|
.mockResolvedValue({
|
|
35
34
|
collection: {
|
|
36
35
|
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
@@ -40,49 +39,55 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
40
39
|
additionalAdmins: [],
|
|
41
40
|
},
|
|
42
41
|
collectionAddress: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
premint: {
|
|
43
|
+
premintConfig: {
|
|
44
|
+
deleted: false,
|
|
45
|
+
tokenConfig: {
|
|
46
|
+
fixedPriceMinter: getDefaultFixedPriceMinterAddress(chain.id),
|
|
47
|
+
maxSupply: 18446744073709551615n,
|
|
48
|
+
maxTokensPerAddress: 0n,
|
|
49
|
+
mintDuration: 604800n,
|
|
50
|
+
mintStart: 0n,
|
|
51
|
+
pricePerToken: 0n,
|
|
52
|
+
royaltyBPS: 1000,
|
|
53
|
+
royaltyMintSchedule: 0,
|
|
54
|
+
royaltyRecipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
55
|
+
tokenURI:
|
|
56
|
+
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
57
|
+
},
|
|
58
|
+
uid: 3,
|
|
59
|
+
version: 0,
|
|
57
60
|
},
|
|
58
|
-
|
|
59
|
-
version: 0,
|
|
61
|
+
premintConfigVersion: PremintConfigVersion.V1,
|
|
60
62
|
},
|
|
61
|
-
|
|
63
|
+
signer: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
62
64
|
signature:
|
|
63
65
|
"0x4d191dd60d428adfe507932a1758bee8ac5bbb77dcd3c05840c237416a3a25035bb8cc7c62177a4e9acb5f40c4032cdb3dbfefdd1575f2c3b4c57945b2076e2e1c",
|
|
64
66
|
});
|
|
65
67
|
|
|
66
|
-
|
|
68
|
+
premintApiClient.postSignature = vi.fn();
|
|
67
69
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
70
|
+
const collectorClient = createCollectorClient({
|
|
71
|
+
chainId: chain.id,
|
|
72
|
+
publicClient,
|
|
73
|
+
premintGetter: premintApiClient,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const { parameters } = await collectorClient.mint({
|
|
77
|
+
mintType: "premint",
|
|
78
|
+
minterAccount: deployerAccount!,
|
|
79
|
+
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
80
|
+
uid: 3,
|
|
81
|
+
quantityToMint: 1,
|
|
82
|
+
mintComment: "",
|
|
83
|
+
});
|
|
84
|
+
const { request: simulateRequest } =
|
|
85
|
+
await publicClient.simulateContract(parameters);
|
|
82
86
|
const hash = await walletClient.writeContract(simulateRequest);
|
|
83
87
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
88
|
+
|
|
84
89
|
const { premintedLog, urls } =
|
|
85
|
-
|
|
90
|
+
collectorClient.getCollectDataFromPremintReceipt(receipt);
|
|
86
91
|
|
|
87
92
|
expect(urls).toEqual({
|
|
88
93
|
explorer:
|
|
@@ -112,26 +117,29 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
112
117
|
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
113
118
|
const [creatorAccount, createReferralAccount] =
|
|
114
119
|
await walletClient.getAddresses();
|
|
115
|
-
const
|
|
116
|
-
chain,
|
|
117
|
-
publicClient,
|
|
118
|
-
});
|
|
120
|
+
const premintApiClient = new PremintAPIClient(chain.id);
|
|
119
121
|
|
|
120
|
-
|
|
121
|
-
.fn<any, ReturnType<typeof
|
|
122
|
+
premintApiClient.getNextUID = vi
|
|
123
|
+
.fn<any, ReturnType<typeof premintApiClient.getNextUID>>()
|
|
122
124
|
.mockResolvedValue(3);
|
|
123
|
-
|
|
124
|
-
.fn<Parameters<typeof
|
|
125
|
+
premintApiClient.postSignature = vi
|
|
126
|
+
.fn<Parameters<typeof premintApiClient.postSignature>>()
|
|
125
127
|
.mockResolvedValue({ ok: true });
|
|
126
128
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
+
const creatorClient = createCreatorClient({
|
|
130
|
+
chainId: chain.id,
|
|
131
|
+
premintApi: premintApiClient,
|
|
132
|
+
publicClient,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const { signAndSubmit } = await creatorClient.createPremint({
|
|
136
|
+
contract: {
|
|
129
137
|
contractAdmin: creatorAccount!,
|
|
130
138
|
contractName: "Testing Contract Premint V2",
|
|
131
139
|
contractURI:
|
|
132
140
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
133
141
|
},
|
|
134
|
-
|
|
142
|
+
token: {
|
|
135
143
|
tokenURI:
|
|
136
144
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
137
145
|
payoutRecipient: creatorAccount!,
|
|
@@ -146,22 +154,22 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
146
154
|
});
|
|
147
155
|
|
|
148
156
|
const expectedPostSignatureArgs: Parameters<
|
|
149
|
-
typeof
|
|
157
|
+
typeof premintApiClient.postSignature
|
|
150
158
|
>[0] = {
|
|
151
|
-
|
|
159
|
+
contract: {
|
|
152
160
|
contractAdmin: creatorAccount!,
|
|
153
161
|
contractName: "Testing Contract Premint V2",
|
|
154
162
|
contractURI:
|
|
155
163
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
156
164
|
},
|
|
157
|
-
|
|
165
|
+
contractAddress: undefined,
|
|
158
166
|
premintConfig: {
|
|
159
167
|
deleted: false,
|
|
160
168
|
tokenConfig: {
|
|
161
169
|
fixedPriceMinter: "0x6d28164C3CE04A190D5F9f0f8881fc807EAD975A",
|
|
162
170
|
maxSupply: 18446744073709551615n,
|
|
163
171
|
maxTokensPerAddress: 0n,
|
|
164
|
-
mintDuration:
|
|
172
|
+
mintDuration: 0n,
|
|
165
173
|
mintStart: 0n,
|
|
166
174
|
pricePerToken: 0n,
|
|
167
175
|
royaltyBPS: 1000,
|
|
@@ -175,10 +183,10 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
175
183
|
},
|
|
176
184
|
premintConfigVersion: PremintConfigVersion.V2,
|
|
177
185
|
signature:
|
|
178
|
-
"
|
|
186
|
+
"0xfe5725c05754ad17a73cc9706bf940e30bd7b4a674bb1b283a66a1cc87022c8c13fcf8989f9feb675f8932a6a8ddb8d16af2abef28fa2fff3282487ef5385b3d1b",
|
|
179
187
|
};
|
|
180
188
|
|
|
181
|
-
expect(
|
|
189
|
+
expect(premintApiClient.postSignature).toHaveBeenCalledWith(
|
|
182
190
|
expectedPostSignatureArgs,
|
|
183
191
|
);
|
|
184
192
|
},
|
|
@@ -190,9 +198,19 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
190
198
|
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
191
199
|
const [deployerAccount, creatorAccount, additionalAdmin] =
|
|
192
200
|
await walletClient.getAddresses();
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
|
|
202
|
+
const premintApiClient = new PremintAPIClient(chain.id);
|
|
203
|
+
|
|
204
|
+
const collectorClient = createCollectorClient({
|
|
205
|
+
chainId: chain.id,
|
|
195
206
|
publicClient,
|
|
207
|
+
premintGetter: premintApiClient,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const creatorClient = createCreatorClient({
|
|
211
|
+
chainId: chain.id,
|
|
212
|
+
publicClient,
|
|
213
|
+
premintApi: premintApiClient,
|
|
196
214
|
});
|
|
197
215
|
|
|
198
216
|
const collection: ContractCreationConfig = {
|
|
@@ -204,14 +222,14 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
204
222
|
};
|
|
205
223
|
|
|
206
224
|
const collectionAddress = await getPremintCollectionAddress({
|
|
207
|
-
collection,
|
|
225
|
+
contract: collection,
|
|
208
226
|
publicClient,
|
|
209
227
|
});
|
|
210
228
|
|
|
211
229
|
const { premintConfig, typedDataDefinition } =
|
|
212
|
-
await
|
|
213
|
-
collection,
|
|
214
|
-
|
|
230
|
+
await creatorClient.createPremint({
|
|
231
|
+
contract: collection,
|
|
232
|
+
token: {
|
|
215
233
|
tokenURI:
|
|
216
234
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
217
235
|
payoutRecipient: creatorAccount!,
|
|
@@ -223,36 +241,34 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
223
241
|
account: additionalAdmin!,
|
|
224
242
|
});
|
|
225
243
|
|
|
226
|
-
|
|
227
|
-
.fn<any, ReturnType<typeof
|
|
244
|
+
premintApiClient.get = vi
|
|
245
|
+
.fn<any, ReturnType<typeof premintApiClient.get>>()
|
|
228
246
|
.mockResolvedValue({
|
|
229
247
|
collection,
|
|
230
248
|
collectionAddress,
|
|
231
|
-
|
|
232
|
-
|
|
249
|
+
premint: {
|
|
250
|
+
premintConfig: premintConfig as PremintConfigV2,
|
|
251
|
+
premintConfigVersion: PremintConfigVersion.V2,
|
|
252
|
+
},
|
|
253
|
+
signer: collection.contractAdmin,
|
|
233
254
|
signature,
|
|
234
255
|
});
|
|
235
256
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
);
|
|
249
|
-
const { request: simulateRequest } = await publicClient.simulateContract(
|
|
250
|
-
simulateContractParameters,
|
|
251
|
-
);
|
|
257
|
+
const { parameters } = await collectorClient.mint({
|
|
258
|
+
mintType: "premint",
|
|
259
|
+
uid: premintConfig.uid,
|
|
260
|
+
minterAccount: deployerAccount!,
|
|
261
|
+
tokenContract: collectionAddress,
|
|
262
|
+
quantityToMint: 1,
|
|
263
|
+
mintComment: "",
|
|
264
|
+
});
|
|
265
|
+
const { request: simulateRequest } =
|
|
266
|
+
await publicClient.simulateContract(parameters);
|
|
252
267
|
const hash = await walletClient.writeContract(simulateRequest);
|
|
253
268
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
269
|
+
|
|
254
270
|
const { premintedLog, urls } =
|
|
255
|
-
|
|
271
|
+
collectorClient.getCollectDataFromPremintReceipt(receipt);
|
|
256
272
|
|
|
257
273
|
expect(urls).toEqual({
|
|
258
274
|
explorer: `https://undefined/token/${collectionAddress}/instance/1`,
|