@zoralabs/protocol-sdk 0.5.17 → 0.6.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 +13 -0
- package/README.md +1 -416
- 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 +1273 -857
- 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 +1233 -831
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +4083 -43
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +17 -0
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
- package/dist/mint/types.d.ts +79 -0
- package/dist/mint/types.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +24 -24
- 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 +3 -1
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +27 -14
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +62 -46
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +19 -7
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +43 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/utils.d.ts +17 -6870
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/create/1155-create-helper.test.ts +235 -56
- 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 +50 -61
- package/src/mint/mint-client.ts +321 -157
- package/src/mint/{mint-api-client.ts → subgraph-mint-getter.ts} +2 -25
- package/src/mint/types.ts +122 -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 +12 -2
- package/src/premint/premint-api-client.ts +55 -43
- package/src/premint/premint-client.test.ts +75 -65
- package/src/premint/premint-client.ts +126 -153
- package/src/premint/preminter.test.ts +4 -5
- package/src/premint/preminter.ts +63 -13
- package/src/sdk.ts +98 -0
- package/src/utils.ts +30 -23
- package/test-integration/premint-client.test.ts +8 -8
- package/dist/mint/mint-api-client.d.ts +0 -35
- package/dist/mint/mint-api-client.d.ts.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Account, Address } from "viem";
|
|
2
|
+
import { GenericTokenIdTypes } from "src/types";
|
|
3
|
+
|
|
4
|
+
export type MintParameters<MintType> = {
|
|
5
|
+
/** Type of the collection to be minted. */
|
|
6
|
+
mintType: MintType;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type Erc1155MintParameters = MintParameters<"1155"> & {
|
|
10
|
+
/** Token id to mint */
|
|
11
|
+
tokenId: GenericTokenIdTypes;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type Erc721MintParameters = MintParameters<"721">;
|
|
15
|
+
|
|
16
|
+
export type OnChainMintParameters =
|
|
17
|
+
| Erc1155MintParameters
|
|
18
|
+
| Erc721MintParameters;
|
|
19
|
+
|
|
20
|
+
export type PremintMintParameters = MintParameters<"premint"> & {
|
|
21
|
+
/** uid of the Premint to mint */
|
|
22
|
+
uid: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type MintType = "1155" | "721" | "premint";
|
|
26
|
+
|
|
27
|
+
export type MintTypes =
|
|
28
|
+
| Erc1155MintParameters
|
|
29
|
+
| Erc721MintParameters
|
|
30
|
+
| PremintMintParameters;
|
|
31
|
+
|
|
32
|
+
export const isOnChainMint = (mint: MintTypes): mint is OnChainMintParameters =>
|
|
33
|
+
mint.mintType !== "premint";
|
|
34
|
+
|
|
35
|
+
export const is1155Mint = (mint: MintTypes): mint is Erc1155MintParameters =>
|
|
36
|
+
mint.mintType === "1155";
|
|
37
|
+
|
|
38
|
+
export type MakeMintParametersArgumentsBase = {
|
|
39
|
+
/** Premint contract address */
|
|
40
|
+
tokenContract: Address;
|
|
41
|
+
/** Account to execute the mint */
|
|
42
|
+
minterAccount: Account | Address;
|
|
43
|
+
/** Quantity of tokens to mint. Defaults to 1 */
|
|
44
|
+
quantityToMint: number | bigint;
|
|
45
|
+
/** Comment to add to the mint */
|
|
46
|
+
mintComment?: string;
|
|
47
|
+
/** Address to receive the mint referral reward */
|
|
48
|
+
mintReferral?: Address;
|
|
49
|
+
/** Address to receive the minted tokens. Defaults to the minting account */
|
|
50
|
+
mintRecipient?: Address;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type Make1155MintArguments = MakeMintParametersArgumentsBase &
|
|
54
|
+
Erc1155MintParameters & {
|
|
55
|
+
saleType?: SaleType;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type Make721MintArguments = MakeMintParametersArgumentsBase &
|
|
59
|
+
Erc721MintParameters & {
|
|
60
|
+
saleType?: SaleType;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type MakePremintMintParametersArguments =
|
|
64
|
+
MakeMintParametersArgumentsBase &
|
|
65
|
+
PremintMintParameters & {
|
|
66
|
+
/** Account to receive first minter reward, if this mint brings the premint onchain */
|
|
67
|
+
firstMinter?: Address;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type MakeMintParametersArguments =
|
|
71
|
+
| Make1155MintArguments
|
|
72
|
+
| Make721MintArguments
|
|
73
|
+
| MakePremintMintParametersArguments;
|
|
74
|
+
|
|
75
|
+
export type GetMintCostsParameters = {
|
|
76
|
+
/** Address of token contract/collection to get the mint costs for */
|
|
77
|
+
collection: Address;
|
|
78
|
+
/** Quantity of tokens that will be minted */
|
|
79
|
+
quantityMinted: number | bigint;
|
|
80
|
+
} & MintTypes;
|
|
81
|
+
|
|
82
|
+
export type SaleType = "fixedPrice" | "erc20";
|
|
83
|
+
|
|
84
|
+
type SaleStrategy<T extends SaleType> = {
|
|
85
|
+
saleType: T;
|
|
86
|
+
address: Address;
|
|
87
|
+
pricePerToken: bigint;
|
|
88
|
+
saleEnd: string;
|
|
89
|
+
saleStart: string;
|
|
90
|
+
maxTokensPerAddress: bigint;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type FixedPriceSaleStrategy = SaleStrategy<"fixedPrice">;
|
|
94
|
+
|
|
95
|
+
type ERC20SaleStrategy = SaleStrategy<"erc20"> & {
|
|
96
|
+
currency: Address;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type SaleStrategies = FixedPriceSaleStrategy | ERC20SaleStrategy;
|
|
100
|
+
|
|
101
|
+
export function isErc20SaleStrategy(
|
|
102
|
+
salesConfig: SaleStrategies,
|
|
103
|
+
): salesConfig is ERC20SaleStrategy {
|
|
104
|
+
return salesConfig.saleType === "erc20";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type SalesConfigAndTokenInfo = {
|
|
108
|
+
salesConfig: SaleStrategies;
|
|
109
|
+
mintFeePerQuantity: bigint;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export interface IMintGetter {
|
|
113
|
+
getSalesConfigAndTokenInfo({
|
|
114
|
+
tokenAddress,
|
|
115
|
+
tokenId,
|
|
116
|
+
saleType,
|
|
117
|
+
}: {
|
|
118
|
+
tokenAddress: Address;
|
|
119
|
+
tokenId?: GenericTokenIdTypes;
|
|
120
|
+
saleType?: SaleType;
|
|
121
|
+
}): Promise<SalesConfigAndTokenInfo>;
|
|
122
|
+
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
PremintConfigV2,
|
|
13
13
|
} from "@zoralabs/protocol-deployments";
|
|
14
14
|
import { ContractCreationConfig } from "src/preminter";
|
|
15
|
-
import {
|
|
15
|
+
import { makeContractParameters } from "src/utils";
|
|
16
16
|
import {
|
|
17
17
|
Account,
|
|
18
18
|
Address,
|
|
@@ -53,7 +53,7 @@ export const mintWithEthParams = ({
|
|
|
53
53
|
pricePerMint: bigint;
|
|
54
54
|
account: Address | Account;
|
|
55
55
|
}) =>
|
|
56
|
-
|
|
56
|
+
makeContractParameters({
|
|
57
57
|
abi: zoraMintsManagerImplConfig.abi,
|
|
58
58
|
address: zoraMintsManagerImplConfig.address[chainId],
|
|
59
59
|
functionName: "mintWithEth",
|
|
@@ -152,7 +152,7 @@ export function collectWithMintsParams({
|
|
|
152
152
|
mintArguments,
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
return
|
|
155
|
+
return makeContractParameters({
|
|
156
156
|
abi: zoraMints1155Config.abi,
|
|
157
157
|
address: zoraMints1155Config.address[chainId],
|
|
158
158
|
functionName: "transferBatchToManagerAndCall",
|
|
@@ -416,7 +416,7 @@ export function collectPremintV2WithMintsParams({
|
|
|
416
416
|
...rest,
|
|
417
417
|
});
|
|
418
418
|
|
|
419
|
-
return
|
|
419
|
+
return makeContractParameters({
|
|
420
420
|
abi: zoraMints1155Config.abi,
|
|
421
421
|
address: zoraMints1155Config.address[chainId],
|
|
422
422
|
functionName: "transferBatchToManagerAndCall",
|
|
@@ -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
|
};
|
|
@@ -150,8 +150,8 @@ export type PremintSignatureResponse =
|
|
|
150
150
|
* @returns
|
|
151
151
|
*/
|
|
152
152
|
export const encodePostSignatureInput = <T extends PremintConfigVersion>({
|
|
153
|
-
collection,
|
|
154
|
-
collectionAddress,
|
|
153
|
+
contract: collection,
|
|
154
|
+
contractAddress: collectionAddress,
|
|
155
155
|
premintConfigVersion,
|
|
156
156
|
premintConfig,
|
|
157
157
|
signature,
|
|
@@ -172,3 +172,13 @@ export const encodePostSignatureInput = <T extends PremintConfigVersion>({
|
|
|
172
172
|
collection_address: collectionAddress,
|
|
173
173
|
chain_name: networkConfigByChain[chainId]!.zoraBackendChainName,
|
|
174
174
|
});
|
|
175
|
+
|
|
176
|
+
export const isPremintConfigV1 = (
|
|
177
|
+
premintConfigAndVersion: PremintConfigAndVersion,
|
|
178
|
+
): premintConfigAndVersion is PremintConfigWithVersion<PremintConfigVersion.V1> =>
|
|
179
|
+
premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V1;
|
|
180
|
+
|
|
181
|
+
export const isPremintConfigV2 = (
|
|
182
|
+
premintConfigAndVersion: PremintConfigAndVersion,
|
|
183
|
+
): premintConfigAndVersion is PremintConfigWithVersion<PremintConfigVersion.V2> =>
|
|
184
|
+
premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V2;
|
|
@@ -4,8 +4,7 @@ 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
9
|
ContractCreationConfig,
|
|
11
10
|
PremintConfigAndVersion,
|
|
@@ -30,8 +29,6 @@ export type PremintNextUIDGetResponse =
|
|
|
30
29
|
|
|
31
30
|
type SignaturePremintGetType =
|
|
32
31
|
paths["/signature/{chain_name}/{collection_address}/{uid}"]["get"];
|
|
33
|
-
type PremintSignatureGetPathParameters =
|
|
34
|
-
SignaturePremintGetType["parameters"]["path"];
|
|
35
32
|
export type PremintSignatureGetResponse =
|
|
36
33
|
SignaturePremintGetType["responses"][200]["content"]["application/json"];
|
|
37
34
|
|
|
@@ -50,57 +47,83 @@ const postSignature = async ({
|
|
|
50
47
|
);
|
|
51
48
|
|
|
52
49
|
const getNextUID = async ({
|
|
53
|
-
|
|
50
|
+
chainId,
|
|
54
51
|
collection_address,
|
|
55
52
|
httpClient: { retries, get } = defaultHttpClient,
|
|
56
|
-
}: PremintNextUIDGetPathParameters & {
|
|
53
|
+
}: Omit<PremintNextUIDGetPathParameters, "chain_name"> & {
|
|
54
|
+
chainId: number;
|
|
57
55
|
httpClient?: Pick<IHttpClient, "retries" | "get">;
|
|
58
56
|
}): Promise<PremintNextUIDGetResponse> =>
|
|
59
57
|
retries(() =>
|
|
60
58
|
get<PremintNextUIDGetResponse>(
|
|
61
|
-
`${ZORA_API_BASE}premint/signature/${
|
|
59
|
+
`${ZORA_API_BASE}premint/signature/${
|
|
60
|
+
getApiNetworkConfigForChain(chainId).zoraBackendChainName
|
|
61
|
+
}/${collection_address}/next_uid`,
|
|
62
62
|
),
|
|
63
63
|
);
|
|
64
64
|
|
|
65
|
-
const getSignature = async ({
|
|
66
|
-
|
|
65
|
+
export const getSignature = async ({
|
|
66
|
+
collectionAddress,
|
|
67
67
|
uid,
|
|
68
|
-
|
|
68
|
+
chainId,
|
|
69
69
|
httpClient: { retries, get } = defaultHttpClient,
|
|
70
|
-
}:
|
|
70
|
+
}: {
|
|
71
|
+
collectionAddress: Address;
|
|
72
|
+
uid: number;
|
|
73
|
+
chainId: number;
|
|
71
74
|
httpClient?: Pick<IHttpClient, "retries" | "get">;
|
|
72
75
|
}): Promise<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
{
|
|
77
|
+
signature: Hex;
|
|
78
|
+
collection: ContractCreationConfig | undefined;
|
|
79
|
+
collectionAddress: Address;
|
|
80
|
+
} & PremintConfigAndVersion
|
|
76
81
|
> => {
|
|
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}`,
|
|
80
86
|
),
|
|
81
87
|
);
|
|
82
88
|
|
|
83
|
-
return result;
|
|
89
|
+
return convertGetPremintApiResponse(result);
|
|
84
90
|
};
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
export interface IPremintGetter {
|
|
93
|
+
getSignature(params: {
|
|
94
|
+
collectionAddress: Address;
|
|
95
|
+
uid: number;
|
|
96
|
+
}): ReturnType<typeof getSignature>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface IPremintAPI {
|
|
100
|
+
getSignature: IPremintGetter["getSignature"];
|
|
101
|
+
|
|
102
|
+
getNextUID(collectionAddress: Address): Promise<number>;
|
|
103
|
+
|
|
104
|
+
postSignature<T extends PremintConfigVersion>(
|
|
105
|
+
params: {
|
|
106
|
+
signature: Hex;
|
|
107
|
+
} & PremintConfigWithVersion<T> &
|
|
108
|
+
ContractCreationConfigOrAddress,
|
|
109
|
+
): Promise<PremintSignatureResponse>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
class PremintAPIClient implements IPremintAPI {
|
|
113
|
+
chainId: number;
|
|
87
114
|
httpClient: IHttpClient;
|
|
88
|
-
networkConfig: NetworkConfig;
|
|
89
115
|
|
|
90
116
|
constructor(chainId: number, httpClient?: IHttpClient) {
|
|
117
|
+
this.chainId = chainId;
|
|
91
118
|
this.httpClient = httpClient || defaultHttpClient;
|
|
92
|
-
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
93
119
|
}
|
|
94
|
-
postSignature =
|
|
120
|
+
postSignature: IPremintAPI["postSignature"] = ({
|
|
95
121
|
signature,
|
|
96
122
|
...rest
|
|
97
|
-
}: {
|
|
98
|
-
signature: Hex;
|
|
99
|
-
} & PremintConfigWithVersion<T> &
|
|
100
|
-
ContractCreationConfigOrAddress): Promise<PremintSignatureResponse> => {
|
|
123
|
+
}): Promise<PremintSignatureResponse> => {
|
|
101
124
|
const data = encodePostSignatureInput({
|
|
102
125
|
...rest,
|
|
103
|
-
chainId: this.
|
|
126
|
+
chainId: this.chainId,
|
|
104
127
|
signature,
|
|
105
128
|
});
|
|
106
129
|
return postSignature({
|
|
@@ -109,36 +132,25 @@ class PremintAPIClient {
|
|
|
109
132
|
});
|
|
110
133
|
};
|
|
111
134
|
|
|
112
|
-
getNextUID = async (collectionAddress
|
|
135
|
+
getNextUID: IPremintAPI["getNextUID"] = async (collectionAddress) =>
|
|
113
136
|
(
|
|
114
137
|
await getNextUID({
|
|
115
138
|
collection_address: collectionAddress.toLowerCase(),
|
|
116
|
-
|
|
139
|
+
chainId: this.chainId,
|
|
117
140
|
httpClient: this.httpClient,
|
|
118
141
|
})
|
|
119
142
|
).next_uid;
|
|
120
143
|
|
|
121
|
-
getSignature = async ({
|
|
144
|
+
getSignature: IPremintAPI["getSignature"] = async ({
|
|
122
145
|
collectionAddress,
|
|
123
146
|
uid,
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
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(),
|
|
147
|
+
}) => {
|
|
148
|
+
return getSignature({
|
|
149
|
+
collectionAddress,
|
|
136
150
|
uid,
|
|
137
|
-
|
|
151
|
+
chainId: this.chainId,
|
|
138
152
|
httpClient: this.httpClient,
|
|
139
153
|
});
|
|
140
|
-
|
|
141
|
-
return convertGetPremintApiResponse(response);
|
|
142
154
|
};
|
|
143
155
|
}
|
|
144
156
|
|
|
@@ -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.getSignature = vi
|
|
32
|
+
.fn<any, ReturnType<typeof premintApiClient.getSignature>>()
|
|
34
33
|
.mockResolvedValue({
|
|
35
34
|
collection: {
|
|
36
35
|
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
@@ -63,26 +62,29 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
63
62
|
"0x4d191dd60d428adfe507932a1758bee8ac5bbb77dcd3c05840c237416a3a25035bb8cc7c62177a4e9acb5f40c4032cdb3dbfefdd1575f2c3b4c57945b2076e2e1c",
|
|
64
63
|
});
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
premintApiClient.postSignature = vi.fn();
|
|
67
66
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
67
|
+
const collectorClient = createCollectorClient({
|
|
68
|
+
chainId: chain.id,
|
|
69
|
+
publicClient,
|
|
70
|
+
premintGetter: premintApiClient,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const { parameters } = await collectorClient.mint({
|
|
74
|
+
mintType: "premint",
|
|
75
|
+
minterAccount: deployerAccount!,
|
|
76
|
+
tokenContract: "0xf8dA7f53c283d898818af7FB9d98103F559bDac2",
|
|
77
|
+
uid: 3,
|
|
78
|
+
quantityToMint: 1,
|
|
79
|
+
mintComment: "",
|
|
80
|
+
});
|
|
81
|
+
const { request: simulateRequest } =
|
|
82
|
+
await publicClient.simulateContract(parameters);
|
|
82
83
|
const hash = await walletClient.writeContract(simulateRequest);
|
|
83
84
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
85
|
+
|
|
84
86
|
const { premintedLog, urls } =
|
|
85
|
-
|
|
87
|
+
collectorClient.getCollectDataFromPremintReceipt(receipt);
|
|
86
88
|
|
|
87
89
|
expect(urls).toEqual({
|
|
88
90
|
explorer:
|
|
@@ -112,26 +114,29 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
112
114
|
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
113
115
|
const [creatorAccount, createReferralAccount] =
|
|
114
116
|
await walletClient.getAddresses();
|
|
115
|
-
const
|
|
116
|
-
chain,
|
|
117
|
-
publicClient,
|
|
118
|
-
});
|
|
117
|
+
const premintApiClient = new PremintAPIClient(chain.id);
|
|
119
118
|
|
|
120
|
-
|
|
121
|
-
.fn<any, ReturnType<typeof
|
|
119
|
+
premintApiClient.getNextUID = vi
|
|
120
|
+
.fn<any, ReturnType<typeof premintApiClient.getNextUID>>()
|
|
122
121
|
.mockResolvedValue(3);
|
|
123
|
-
|
|
124
|
-
.fn<Parameters<typeof
|
|
122
|
+
premintApiClient.postSignature = vi
|
|
123
|
+
.fn<Parameters<typeof premintApiClient.postSignature>>()
|
|
125
124
|
.mockResolvedValue({ ok: true });
|
|
126
125
|
|
|
127
|
-
const
|
|
128
|
-
|
|
126
|
+
const creatorClient = createCreatorClient({
|
|
127
|
+
chainId: chain.id,
|
|
128
|
+
premintApi: premintApiClient,
|
|
129
|
+
publicClient,
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const { signAndSubmit } = await creatorClient.createPremint({
|
|
133
|
+
contract: {
|
|
129
134
|
contractAdmin: creatorAccount!,
|
|
130
135
|
contractName: "Testing Contract Premint V2",
|
|
131
136
|
contractURI:
|
|
132
137
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
133
138
|
},
|
|
134
|
-
|
|
139
|
+
token: {
|
|
135
140
|
tokenURI:
|
|
136
141
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
137
142
|
payoutRecipient: creatorAccount!,
|
|
@@ -146,22 +151,22 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
146
151
|
});
|
|
147
152
|
|
|
148
153
|
const expectedPostSignatureArgs: Parameters<
|
|
149
|
-
typeof
|
|
154
|
+
typeof premintApiClient.postSignature
|
|
150
155
|
>[0] = {
|
|
151
|
-
|
|
156
|
+
contract: {
|
|
152
157
|
contractAdmin: creatorAccount!,
|
|
153
158
|
contractName: "Testing Contract Premint V2",
|
|
154
159
|
contractURI:
|
|
155
160
|
"ipfs://bafkreiainxen4b4wz4ubylvbhons6rembxdet4a262nf2lziclqvv7au3e",
|
|
156
161
|
},
|
|
157
|
-
|
|
162
|
+
contractAddress: undefined,
|
|
158
163
|
premintConfig: {
|
|
159
164
|
deleted: false,
|
|
160
165
|
tokenConfig: {
|
|
161
166
|
fixedPriceMinter: "0x6d28164C3CE04A190D5F9f0f8881fc807EAD975A",
|
|
162
167
|
maxSupply: 18446744073709551615n,
|
|
163
168
|
maxTokensPerAddress: 0n,
|
|
164
|
-
mintDuration:
|
|
169
|
+
mintDuration: 0n,
|
|
165
170
|
mintStart: 0n,
|
|
166
171
|
pricePerToken: 0n,
|
|
167
172
|
royaltyBPS: 1000,
|
|
@@ -175,10 +180,10 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
175
180
|
},
|
|
176
181
|
premintConfigVersion: PremintConfigVersion.V2,
|
|
177
182
|
signature:
|
|
178
|
-
"
|
|
183
|
+
"0xfe5725c05754ad17a73cc9706bf940e30bd7b4a674bb1b283a66a1cc87022c8c13fcf8989f9feb675f8932a6a8ddb8d16af2abef28fa2fff3282487ef5385b3d1b",
|
|
179
184
|
};
|
|
180
185
|
|
|
181
|
-
expect(
|
|
186
|
+
expect(premintApiClient.postSignature).toHaveBeenCalledWith(
|
|
182
187
|
expectedPostSignatureArgs,
|
|
183
188
|
);
|
|
184
189
|
},
|
|
@@ -190,9 +195,19 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
190
195
|
async ({ viemClients: { walletClient, publicClient, chain } }) => {
|
|
191
196
|
const [deployerAccount, creatorAccount, additionalAdmin] =
|
|
192
197
|
await walletClient.getAddresses();
|
|
193
|
-
|
|
194
|
-
|
|
198
|
+
|
|
199
|
+
const premintApiClient = new PremintAPIClient(chain.id);
|
|
200
|
+
|
|
201
|
+
const collectorClient = createCollectorClient({
|
|
202
|
+
chainId: chain.id,
|
|
195
203
|
publicClient,
|
|
204
|
+
premintGetter: premintApiClient,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const creatorClient = createCreatorClient({
|
|
208
|
+
chainId: chain.id,
|
|
209
|
+
publicClient,
|
|
210
|
+
premintApi: premintApiClient,
|
|
196
211
|
});
|
|
197
212
|
|
|
198
213
|
const collection: ContractCreationConfig = {
|
|
@@ -204,14 +219,14 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
204
219
|
};
|
|
205
220
|
|
|
206
221
|
const collectionAddress = await getPremintCollectionAddress({
|
|
207
|
-
collection,
|
|
222
|
+
contract: collection,
|
|
208
223
|
publicClient,
|
|
209
224
|
});
|
|
210
225
|
|
|
211
226
|
const { premintConfig, typedDataDefinition } =
|
|
212
|
-
await
|
|
213
|
-
collection,
|
|
214
|
-
|
|
227
|
+
await creatorClient.createPremint({
|
|
228
|
+
contract: collection,
|
|
229
|
+
token: {
|
|
215
230
|
tokenURI:
|
|
216
231
|
"ipfs://bafkreice23maski3x52tsfqgxstx3kbiifnt5jotg3a5ynvve53c4soi2u",
|
|
217
232
|
payoutRecipient: creatorAccount!,
|
|
@@ -223,8 +238,8 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
223
238
|
account: additionalAdmin!,
|
|
224
239
|
});
|
|
225
240
|
|
|
226
|
-
|
|
227
|
-
.fn<any, ReturnType<typeof
|
|
241
|
+
premintApiClient.getSignature = vi
|
|
242
|
+
.fn<any, ReturnType<typeof premintApiClient.getSignature>>()
|
|
228
243
|
.mockResolvedValue({
|
|
229
244
|
collection,
|
|
230
245
|
collectionAddress,
|
|
@@ -233,26 +248,21 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
233
248
|
signature,
|
|
234
249
|
});
|
|
235
250
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
);
|
|
249
|
-
const { request: simulateRequest } = await publicClient.simulateContract(
|
|
250
|
-
simulateContractParameters,
|
|
251
|
-
);
|
|
251
|
+
const { parameters } = await collectorClient.mint({
|
|
252
|
+
mintType: "premint",
|
|
253
|
+
uid: premintConfig.uid,
|
|
254
|
+
minterAccount: deployerAccount!,
|
|
255
|
+
tokenContract: collectionAddress,
|
|
256
|
+
quantityToMint: 1,
|
|
257
|
+
mintComment: "",
|
|
258
|
+
});
|
|
259
|
+
const { request: simulateRequest } =
|
|
260
|
+
await publicClient.simulateContract(parameters);
|
|
252
261
|
const hash = await walletClient.writeContract(simulateRequest);
|
|
253
262
|
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
263
|
+
|
|
254
264
|
const { premintedLog, urls } =
|
|
255
|
-
|
|
265
|
+
collectorClient.getCollectDataFromPremintReceipt(receipt);
|
|
256
266
|
|
|
257
267
|
expect(urls).toEqual({
|
|
258
268
|
explorer: `https://undefined/token/${collectionAddress}/instance/1`,
|