@zoralabs/protocol-sdk 0.8.0 → 0.9.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 +7 -7
- package/CHANGELOG.md +11 -0
- package/dist/allow-list/allow-list-client.d.ts +26 -0
- package/dist/allow-list/allow-list-client.d.ts.map +1 -0
- package/dist/allow-list/types.d.ts +14 -0
- package/dist/allow-list/types.d.ts.map +1 -0
- package/dist/apis/generated/allow-list-api-types.d.ts +288 -0
- package/dist/apis/generated/allow-list-api-types.d.ts.map +1 -0
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/apis/subgraph-querier.d.ts +18 -0
- package/dist/apis/subgraph-querier.d.ts.map +1 -0
- package/dist/create/contract-setup.d.ts +1 -0
- package/dist/create/contract-setup.d.ts.map +1 -1
- package/dist/create/minter-defaults.d.ts +5 -0
- package/dist/create/minter-defaults.d.ts.map +1 -0
- package/dist/create/minter-setup.d.ts +14 -0
- package/dist/create/minter-setup.d.ts.map +1 -0
- package/dist/create/token-setup.d.ts +4 -19
- package/dist/create/token-setup.d.ts.map +1 -1
- package/dist/create/types.d.ts +32 -7
- package/dist/create/types.d.ts.map +1 -1
- package/dist/create/update.d.ts +15 -0
- package/dist/create/update.d.ts.map +1 -0
- package/dist/index.cjs +2249 -1936
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2284 -1966
- package/dist/index.js.map +1 -1
- package/dist/ipfs/token-metadata.d.ts +1 -0
- package/dist/ipfs/token-metadata.d.ts.map +1 -1
- package/dist/mint/mint-client.d.ts +2 -6
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +3 -1
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +9 -7
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +5 -4
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +42 -15
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/mint/types.d.ts +32 -13
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/sparks/sparks-contracts.d.ts +96 -96
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -8
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/allow-list/allow-list-client.ts +105 -0
- package/src/allow-list/types.ts +15 -0
- package/src/apis/generated/allow-list-api-types.ts +288 -0
- package/src/apis/http-api-base.ts +12 -0
- package/src/apis/subgraph-querier.ts +38 -0
- package/src/create/1155-create-helper.test.ts +216 -66
- package/src/create/1155-create-helper.ts +4 -4
- package/src/create/contract-setup.ts +8 -0
- package/src/create/minter-defaults.test.ts +21 -0
- package/src/create/minter-defaults.ts +134 -0
- package/src/create/minter-setup.ts +293 -0
- package/src/create/token-setup.ts +14 -190
- package/src/create/types.ts +56 -9
- package/src/create/update.ts +93 -0
- package/src/index.ts +4 -0
- package/src/ipfs/token-metadata.ts +18 -0
- package/src/mint/mint-client.test.ts +219 -15
- package/src/mint/mint-client.ts +2 -34
- package/src/mint/mint-queries.ts +34 -13
- package/src/mint/mint-transactions.ts +104 -17
- package/src/mint/subgraph-mint-getter.ts +107 -50
- package/src/mint/subgraph-queries.ts +67 -37
- package/src/mint/types.ts +55 -16
- package/src/premint/premint-client.test.ts +6 -5
- package/src/types.ts +1 -1
- package/src/utils.ts +1 -25
package/src/mint/types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
GenericTokenIdTypes,
|
|
4
4
|
SimulateContractParametersWithAccount,
|
|
5
5
|
} from "src/types";
|
|
6
|
+
import { AllowListEntry } from "src/allow-list/types";
|
|
6
7
|
|
|
7
8
|
export type MintParameters<MintType> = {
|
|
8
9
|
/** Type of the collection to be minted. */
|
|
@@ -25,7 +26,7 @@ export type PremintMintParameters = MintParameters<"premint"> & {
|
|
|
25
26
|
uid: number;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
export type MintType = "1155" | "721" | "premint";
|
|
29
|
+
export type MintType = "1155" | "721" | "allowlist" | "premint";
|
|
29
30
|
|
|
30
31
|
export type MintTypes =
|
|
31
32
|
| Erc1155MintParameters
|
|
@@ -63,6 +64,8 @@ export type MintParametersBase = {
|
|
|
63
64
|
mintRecipient?: Address;
|
|
64
65
|
/** If this is a premint, the address to get the first minter reward */
|
|
65
66
|
firstMinter?: Address;
|
|
67
|
+
/** If this is an allow list mint, the info for the allow list entry */
|
|
68
|
+
allowListEntry?: AllowListEntry;
|
|
66
69
|
};
|
|
67
70
|
|
|
68
71
|
export type MakeMintParametersArgumentsBase = MintParametersBase & {
|
|
@@ -99,44 +102,81 @@ export type GetMintCostsParameters = {
|
|
|
99
102
|
quantityMinted: number | bigint;
|
|
100
103
|
} & MintTypes;
|
|
101
104
|
|
|
102
|
-
export type SaleType =
|
|
105
|
+
export type SaleType =
|
|
106
|
+
| "fixedPrice"
|
|
107
|
+
| "erc20"
|
|
108
|
+
| "allowlist"
|
|
109
|
+
| "premint"
|
|
110
|
+
| "timed";
|
|
103
111
|
|
|
104
112
|
type SaleStrategy<T extends SaleType> = {
|
|
105
113
|
saleType: T;
|
|
114
|
+
mintFeePerQuantity: bigint;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
type PricedSaleStrategy = {
|
|
106
118
|
pricePerToken: bigint;
|
|
107
119
|
maxTokensPerAddress: bigint;
|
|
108
120
|
};
|
|
109
121
|
|
|
110
|
-
type
|
|
111
|
-
address: Address;
|
|
122
|
+
export type StartAndEnd = {
|
|
112
123
|
saleStart: string;
|
|
113
124
|
saleEnd: string;
|
|
114
125
|
};
|
|
115
126
|
|
|
116
|
-
type
|
|
127
|
+
type FixedPriceSaleStrategy = SaleStrategy<"fixedPrice"> &
|
|
128
|
+
PricedSaleStrategy &
|
|
129
|
+
StartAndEnd & {
|
|
130
|
+
address: Address;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
type ERC20SaleStrategy = SaleStrategy<"erc20"> &
|
|
134
|
+
PricedSaleStrategy &
|
|
135
|
+
StartAndEnd & {
|
|
136
|
+
address: Address;
|
|
137
|
+
currency: Address;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
type AllowListSaleStrategy = SaleStrategy<"allowlist"> & {
|
|
117
141
|
address: Address;
|
|
118
142
|
saleStart: string;
|
|
119
143
|
saleEnd: string;
|
|
120
|
-
|
|
144
|
+
merkleRoot: string;
|
|
121
145
|
};
|
|
122
146
|
|
|
123
|
-
type
|
|
124
|
-
|
|
125
|
-
|
|
147
|
+
type ZoraTimedSaleStrategy = SaleStrategy<"timed"> & {
|
|
148
|
+
mintFee: bigint;
|
|
149
|
+
erc20Z: Address;
|
|
150
|
+
pool: Address;
|
|
151
|
+
secondaryActivated: boolean;
|
|
152
|
+
address: Address;
|
|
153
|
+
} & StartAndEnd;
|
|
154
|
+
|
|
155
|
+
type PremintSaleStrategy = SaleStrategy<"premint"> &
|
|
156
|
+
PricedSaleStrategy & {
|
|
157
|
+
duration: bigint;
|
|
158
|
+
};
|
|
126
159
|
|
|
127
|
-
export type
|
|
160
|
+
export type OnchainSalesStrategies =
|
|
128
161
|
| FixedPriceSaleStrategy
|
|
129
162
|
| ERC20SaleStrategy
|
|
130
|
-
|
|
|
163
|
+
| AllowListSaleStrategy
|
|
164
|
+
| ZoraTimedSaleStrategy;
|
|
131
165
|
|
|
132
|
-
export type
|
|
166
|
+
export type SaleStrategies = OnchainSalesStrategies | PremintSaleStrategy;
|
|
133
167
|
|
|
134
168
|
export function isErc20SaleStrategy(
|
|
135
|
-
salesConfig:
|
|
169
|
+
salesConfig: SaleStrategies,
|
|
136
170
|
): salesConfig is ERC20SaleStrategy {
|
|
137
171
|
return salesConfig.saleType === "erc20";
|
|
138
172
|
}
|
|
139
173
|
|
|
174
|
+
export function isTimedSaleStrategy(
|
|
175
|
+
salesConfig: SaleStrategies,
|
|
176
|
+
): salesConfig is ZoraTimedSaleStrategy {
|
|
177
|
+
return salesConfig.saleType === "timed";
|
|
178
|
+
}
|
|
179
|
+
|
|
140
180
|
export type ContractInfo = {
|
|
141
181
|
/** Address of the contract */
|
|
142
182
|
address: Address;
|
|
@@ -151,8 +191,6 @@ export type MintableBase = {
|
|
|
151
191
|
contract: ContractInfo;
|
|
152
192
|
/** Token metadata URI */
|
|
153
193
|
tokenURI: string;
|
|
154
|
-
/** Price in eth to mint 1 item */
|
|
155
|
-
mintFeePerQuantity: bigint;
|
|
156
194
|
/** Creator of the mintable item */
|
|
157
195
|
creator: Address;
|
|
158
196
|
/** Maximum total number of items that can be minted */
|
|
@@ -173,7 +211,7 @@ export type PremintMintable = MintableBase & {
|
|
|
173
211
|
};
|
|
174
212
|
|
|
175
213
|
export type OnchainSalesConfigAndTokenInfo = {
|
|
176
|
-
salesConfig
|
|
214
|
+
salesConfig?: OnchainSalesStrategies;
|
|
177
215
|
} & OnchainMintable;
|
|
178
216
|
|
|
179
217
|
export type PremintSalesConfigAndTokenInfo = {
|
|
@@ -189,6 +227,7 @@ export interface IOnchainMintGetter {
|
|
|
189
227
|
tokenAddress: Address;
|
|
190
228
|
tokenId?: GenericTokenIdTypes;
|
|
191
229
|
preferredSaleType?: SaleType;
|
|
230
|
+
blockTime: bigint;
|
|
192
231
|
}): Promise<OnchainSalesConfigAndTokenInfo>;
|
|
193
232
|
|
|
194
233
|
getContractMintable(params: {
|
|
@@ -29,7 +29,7 @@ describe("ZoraCreator1155Premint", () => {
|
|
|
29
29
|
const premintApiClient = new PremintAPIClient(chain.id);
|
|
30
30
|
|
|
31
31
|
premintApiClient.get = vi
|
|
32
|
-
.fn<
|
|
32
|
+
.fn<typeof premintApiClient.get>()
|
|
33
33
|
.mockResolvedValue({
|
|
34
34
|
collection: {
|
|
35
35
|
contractAdmin: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
@@ -120,11 +120,12 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
120
120
|
const premintApiClient = new PremintAPIClient(chain.id);
|
|
121
121
|
|
|
122
122
|
premintApiClient.getNextUID = vi
|
|
123
|
-
.fn<
|
|
123
|
+
.fn<typeof premintApiClient.getNextUID>()
|
|
124
124
|
.mockResolvedValue(3);
|
|
125
125
|
premintApiClient.postSignature = vi
|
|
126
|
-
.fn<
|
|
127
|
-
|
|
126
|
+
.fn<typeof premintApiClient.postSignature>()
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
.mockResolvedValue({});
|
|
128
129
|
|
|
129
130
|
const creatorClient = createCreatorClient({
|
|
130
131
|
chainId: chain.id,
|
|
@@ -242,7 +243,7 @@ describe("ZoraCreator1155Premint - v2 signatures", () => {
|
|
|
242
243
|
});
|
|
243
244
|
|
|
244
245
|
premintApiClient.get = vi
|
|
245
|
-
.fn<
|
|
246
|
+
.fn<typeof premintApiClient.get>()
|
|
246
247
|
.mockResolvedValue({
|
|
247
248
|
collection,
|
|
248
249
|
collectionAddress,
|
package/src/types.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
|
|
8
8
|
export type GenericTokenIdTypes = number | bigint | string;
|
|
9
9
|
|
|
10
|
-
export type IPublicClient = Pick<PublicClient, "readContract">;
|
|
10
|
+
export type IPublicClient = Pick<PublicClient, "readContract" | "getBlock">;
|
|
11
11
|
|
|
12
12
|
export type SimulateContractParametersWithAccount = SimulateContractParameters<
|
|
13
13
|
any,
|
package/src/utils.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Account, Address, PublicClient as BasePublicClient } from "viem";
|
|
2
|
-
import { IHttpClient } from "./apis/http-api-base";
|
|
3
2
|
import { SimulateContractParametersWithAccount } from "./types";
|
|
4
3
|
|
|
5
4
|
export const makeContractParameters = (
|
|
6
5
|
args: SimulateContractParametersWithAccount,
|
|
7
6
|
) => args;
|
|
8
7
|
|
|
9
|
-
export type PublicClient = Pick<BasePublicClient, "readContract">;
|
|
8
|
+
export type PublicClient = Pick<BasePublicClient, "readContract" | "getBlock">;
|
|
10
9
|
|
|
11
10
|
export type ClientConfig = {
|
|
12
11
|
/** The chain that the client is to run on. */
|
|
@@ -38,26 +37,3 @@ export function mintRecipientOrAccount({
|
|
|
38
37
|
export type Concrete<Type> = {
|
|
39
38
|
[Property in keyof Type]-?: Type[Property];
|
|
40
39
|
};
|
|
41
|
-
|
|
42
|
-
export async function querySubgraphWithRetries({
|
|
43
|
-
httpClient,
|
|
44
|
-
subgraphUrl,
|
|
45
|
-
query,
|
|
46
|
-
variables,
|
|
47
|
-
}: {
|
|
48
|
-
httpClient: IHttpClient;
|
|
49
|
-
subgraphUrl: string;
|
|
50
|
-
query: string;
|
|
51
|
-
variables: any;
|
|
52
|
-
}) {
|
|
53
|
-
const { retries, post } = httpClient;
|
|
54
|
-
|
|
55
|
-
const result = await retries(async () => {
|
|
56
|
-
return await post<any>(subgraphUrl, {
|
|
57
|
-
query,
|
|
58
|
-
variables,
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
return result?.data;
|
|
63
|
-
}
|