@zoralabs/protocol-sdk 0.11.11 → 0.12.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 +17 -0
- package/dist/apis/network-config.d.ts +3 -0
- package/dist/apis/network-config.d.ts.map +1 -0
- package/dist/create/contract-setup.d.ts +3 -4
- package/dist/create/contract-setup.d.ts.map +1 -1
- package/dist/create/create-client.d.ts +53 -0
- package/dist/create/create-client.d.ts.map +1 -0
- package/dist/create/types.d.ts +11 -3
- package/dist/create/types.d.ts.map +1 -1
- package/dist/fixtures/contract-setup.d.ts +2 -2
- package/dist/fixtures/contract-setup.d.ts.map +1 -1
- package/dist/fixtures/rewards-query-results.d.ts +0 -1
- package/dist/fixtures/rewards-query-results.d.ts.map +1 -1
- package/dist/fixtures/secondary.d.ts +3 -6
- package/dist/fixtures/secondary.d.ts.map +1 -1
- package/dist/index.cjs +1509 -1396
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1559 -1465
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +21 -9
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +24 -22
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/strategies-parsing.d.ts +28 -0
- package/dist/mint/strategies-parsing.d.ts.map +1 -0
- package/dist/mint/subgraph-mint-getter.d.ts +2 -6
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/types.d.ts +25 -8
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/rewards/rewards-client.d.ts +7 -3
- package/dist/rewards/rewards-client.d.ts.map +1 -1
- package/dist/rewards/rewards-queries.d.ts +14 -11
- package/dist/rewards/rewards-queries.d.ts.map +1 -1
- package/dist/rewards/subgraph-queries.d.ts +0 -1
- package/dist/rewards/subgraph-queries.d.ts.map +1 -1
- package/dist/rewards/subgraph-rewards-getter.d.ts +2 -8
- package/dist/rewards/subgraph-rewards-getter.d.ts.map +1 -1
- package/dist/sdk.d.ts +9 -3
- package/dist/sdk.d.ts.map +1 -1
- package/dist/secondary/secondary-client.d.ts +7 -8
- package/dist/secondary/secondary-client.d.ts.map +1 -1
- package/dist/secondary/uniswap/uniswapQuote.d.ts +0 -1
- package/dist/secondary/uniswap/uniswapQuote.d.ts.map +1 -1
- package/dist/secondary/utils.d.ts +1 -2
- package/dist/secondary/utils.d.ts.map +1 -1
- package/dist/types.d.ts +6 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/apis/network-config.ts +8 -0
- package/src/apis/subgraph-getter.ts +1 -1
- package/src/comments/comments.test.ts +11 -22
- package/src/create/contract-setup.ts +3 -4
- package/src/create/{1155-create-helper.test.ts → create-client.test.ts} +52 -88
- package/src/create/{1155-create-helper.ts → create-client.ts} +129 -63
- package/src/create/types.ts +13 -3
- package/src/fixtures/contract-setup.ts +3 -3
- package/src/fixtures/rewards-query-results.ts +2 -9
- package/src/fixtures/secondary.ts +16 -10
- package/src/index.ts +34 -4
- package/src/mint/mint-client.test.ts +37 -64
- package/src/mint/mint-client.ts +36 -32
- package/src/mint/mint-queries.ts +73 -54
- package/src/mint/strategies-parsing.ts +311 -0
- package/src/mint/subgraph-mint-getter.ts +4 -304
- package/src/mint/types.ts +36 -7
- package/src/premint/premint-api-client.ts +1 -1
- package/src/premint/premint-client.ts +1 -1
- package/src/rewards/rewards-client.test.ts +318 -21
- package/src/rewards/rewards-client.ts +15 -16
- package/src/rewards/rewards-queries.ts +116 -36
- package/src/rewards/subgraph-queries.ts +0 -2
- package/src/rewards/subgraph-rewards-getter.ts +3 -13
- package/src/sdk.ts +9 -7
- package/src/secondary/secondary-client.test.ts +39 -40
- package/src/secondary/secondary-client.ts +14 -33
- package/src/secondary/uniswap/uniswapQuote.ts +3 -2
- package/src/secondary/utils.ts +2 -2
- package/src/types.ts +15 -4
- package/src/utils.ts +9 -3
- package/dist/create/1155-create-helper.d.ts +0 -29
- package/dist/create/1155-create-helper.d.ts.map +0 -1
|
@@ -58,7 +58,6 @@ async function makeBuy({
|
|
|
58
58
|
quantity,
|
|
59
59
|
account,
|
|
60
60
|
recipient,
|
|
61
|
-
chainId,
|
|
62
61
|
slippage,
|
|
63
62
|
publicClient,
|
|
64
63
|
comment,
|
|
@@ -71,7 +70,6 @@ async function makeBuy({
|
|
|
71
70
|
quantity: bigint;
|
|
72
71
|
account: Address | Account;
|
|
73
72
|
recipient?: Address;
|
|
74
|
-
chainId: number;
|
|
75
73
|
slippage: number;
|
|
76
74
|
comment: string | undefined;
|
|
77
75
|
publicClient: PublicClient;
|
|
@@ -95,7 +93,7 @@ async function makeBuy({
|
|
|
95
93
|
return handleBuyWithComment({
|
|
96
94
|
accountAddress,
|
|
97
95
|
recipient,
|
|
98
|
-
chainId,
|
|
96
|
+
chainId: publicClient.chain.id,
|
|
99
97
|
quantity,
|
|
100
98
|
contract,
|
|
101
99
|
tokenId,
|
|
@@ -111,7 +109,7 @@ async function makeBuy({
|
|
|
111
109
|
recipient,
|
|
112
110
|
accountAddress,
|
|
113
111
|
costWithSlippage,
|
|
114
|
-
chainId,
|
|
112
|
+
chainId: publicClient.chain.id,
|
|
115
113
|
account,
|
|
116
114
|
});
|
|
117
115
|
}
|
|
@@ -242,25 +240,22 @@ type BuyOrSellWithSlippageResult =
|
|
|
242
240
|
parameters?: undefined;
|
|
243
241
|
};
|
|
244
242
|
|
|
245
|
-
export async function
|
|
243
|
+
export async function buy1155OnSecondary({
|
|
246
244
|
contract,
|
|
247
245
|
tokenId,
|
|
248
246
|
publicClient,
|
|
249
247
|
quantity,
|
|
250
|
-
chainId,
|
|
251
248
|
account,
|
|
252
249
|
slippage = UNISWAP_SLIPPAGE,
|
|
253
250
|
recipient,
|
|
254
251
|
comment,
|
|
255
252
|
}: BuyWithSlippageInput & {
|
|
256
|
-
chainId: number;
|
|
257
253
|
publicClient: PublicClient;
|
|
258
254
|
}): Promise<BuyOrSellWithSlippageResult> {
|
|
259
255
|
const secondaryInfo = await getSecondaryInfo({
|
|
260
256
|
contract,
|
|
261
257
|
tokenId,
|
|
262
258
|
publicClient,
|
|
263
|
-
chainId,
|
|
264
259
|
});
|
|
265
260
|
|
|
266
261
|
if (!secondaryInfo) {
|
|
@@ -279,7 +274,6 @@ export async function buyWithSlippage({
|
|
|
279
274
|
quantity,
|
|
280
275
|
poolAddress: pool,
|
|
281
276
|
erc20z,
|
|
282
|
-
chainId,
|
|
283
277
|
},
|
|
284
278
|
publicClient,
|
|
285
279
|
);
|
|
@@ -293,7 +287,6 @@ export async function buyWithSlippage({
|
|
|
293
287
|
quantity,
|
|
294
288
|
account,
|
|
295
289
|
recipient,
|
|
296
|
-
chainId,
|
|
297
290
|
slippage,
|
|
298
291
|
comment,
|
|
299
292
|
publicClient,
|
|
@@ -313,7 +306,6 @@ async function makeSell({
|
|
|
313
306
|
quantity,
|
|
314
307
|
account,
|
|
315
308
|
recipient,
|
|
316
|
-
chainId,
|
|
317
309
|
slippage,
|
|
318
310
|
publicClient,
|
|
319
311
|
}: {
|
|
@@ -324,7 +316,6 @@ async function makeSell({
|
|
|
324
316
|
quantity: bigint;
|
|
325
317
|
account: Address | Account;
|
|
326
318
|
recipient?: Address;
|
|
327
|
-
chainId: number;
|
|
328
319
|
slippage: number;
|
|
329
320
|
publicClient: PublicClient;
|
|
330
321
|
}): Promise<Call> {
|
|
@@ -356,6 +347,8 @@ async function makeSell({
|
|
|
356
347
|
0n,
|
|
357
348
|
]);
|
|
358
349
|
|
|
350
|
+
const chainId = publicClient.chain.id;
|
|
351
|
+
|
|
359
352
|
return {
|
|
360
353
|
parameters: makeContractParameters({
|
|
361
354
|
abi: zoraCreator1155ImplABI,
|
|
@@ -373,24 +366,21 @@ async function makeSell({
|
|
|
373
366
|
};
|
|
374
367
|
}
|
|
375
368
|
|
|
376
|
-
export async function
|
|
369
|
+
export async function sell1155OnSecondary({
|
|
377
370
|
contract,
|
|
378
371
|
tokenId,
|
|
379
372
|
publicClient,
|
|
380
373
|
quantity,
|
|
381
|
-
chainId,
|
|
382
374
|
account,
|
|
383
375
|
slippage = UNISWAP_SLIPPAGE,
|
|
384
376
|
recipient,
|
|
385
377
|
}: SellWithSlippageInput & {
|
|
386
|
-
chainId: number;
|
|
387
378
|
publicClient: PublicClient;
|
|
388
379
|
}): Promise<BuyOrSellWithSlippageResult> {
|
|
389
380
|
const secondaryInfo = await getSecondaryInfo({
|
|
390
381
|
contract,
|
|
391
382
|
tokenId,
|
|
392
383
|
publicClient,
|
|
393
|
-
chainId,
|
|
394
384
|
});
|
|
395
385
|
|
|
396
386
|
if (!secondaryInfo) {
|
|
@@ -404,7 +394,7 @@ export async function sellWithSlippage({
|
|
|
404
394
|
}
|
|
405
395
|
|
|
406
396
|
const { poolBalance, amount, price } = await getUniswapQuote(
|
|
407
|
-
{ type: "sell", quantity, poolAddress: pool,
|
|
397
|
+
{ type: "sell", quantity, poolAddress: pool, erc20z },
|
|
408
398
|
publicClient,
|
|
409
399
|
);
|
|
410
400
|
|
|
@@ -416,7 +406,6 @@ export async function sellWithSlippage({
|
|
|
416
406
|
quantity,
|
|
417
407
|
account,
|
|
418
408
|
recipient,
|
|
419
|
-
chainId,
|
|
420
409
|
slippage,
|
|
421
410
|
publicClient,
|
|
422
411
|
});
|
|
@@ -428,26 +417,21 @@ export async function sellWithSlippage({
|
|
|
428
417
|
}
|
|
429
418
|
|
|
430
419
|
/**
|
|
431
|
-
*
|
|
420
|
+
* @deprecated Please use functions directly without creating a client.
|
|
421
|
+
* Example: Instead of `new SecondaryClient().buy1155OnSecondary()`, use `buy1155OnSecondary()`
|
|
422
|
+
* Import the functions you need directly from their respective modules:
|
|
423
|
+
* import { buy1155OnSecondary, sell1155OnSecondary, getSecondaryInfo } from '@zoralabs/protocol-sdk'
|
|
432
424
|
*/
|
|
433
425
|
export class SecondaryClient {
|
|
434
426
|
private publicClient: PublicClient;
|
|
435
|
-
private chainId: number;
|
|
436
427
|
|
|
437
428
|
/**
|
|
438
429
|
* Creates a new SecondaryClient instance.
|
|
439
430
|
* @param publicClient - The public client for interacting with the blockchain.
|
|
440
431
|
* @param chainId - The ID of the blockchain network.
|
|
441
432
|
*/
|
|
442
|
-
constructor({
|
|
443
|
-
publicClient,
|
|
444
|
-
chainId,
|
|
445
|
-
}: {
|
|
446
|
-
publicClient: PublicClient;
|
|
447
|
-
chainId: number;
|
|
448
|
-
}) {
|
|
433
|
+
constructor({ publicClient }: { publicClient: PublicClient }) {
|
|
449
434
|
this.publicClient = publicClient;
|
|
450
|
-
this.chainId = chainId;
|
|
451
435
|
}
|
|
452
436
|
|
|
453
437
|
/**
|
|
@@ -467,7 +451,6 @@ export class SecondaryClient {
|
|
|
467
451
|
contract,
|
|
468
452
|
tokenId,
|
|
469
453
|
publicClient: this.publicClient,
|
|
470
|
-
chainId: this.chainId,
|
|
471
454
|
});
|
|
472
455
|
}
|
|
473
456
|
|
|
@@ -480,10 +463,9 @@ export class SecondaryClient {
|
|
|
480
463
|
input: BuyWithSlippageInput,
|
|
481
464
|
): Promise<BuyOrSellWithSlippageResult> {
|
|
482
465
|
// Call the buyWithSlippage function with the provided input and client details
|
|
483
|
-
return
|
|
466
|
+
return buy1155OnSecondary({
|
|
484
467
|
...input,
|
|
485
468
|
publicClient: this.publicClient,
|
|
486
|
-
chainId: this.chainId,
|
|
487
469
|
});
|
|
488
470
|
}
|
|
489
471
|
|
|
@@ -496,10 +478,9 @@ export class SecondaryClient {
|
|
|
496
478
|
input: SellWithSlippageInput,
|
|
497
479
|
): Promise<BuyOrSellWithSlippageResult> {
|
|
498
480
|
// Call the sellWithSlippage function with the provided input and client details
|
|
499
|
-
return
|
|
481
|
+
return sell1155OnSecondary({
|
|
500
482
|
...input,
|
|
501
483
|
publicClient: this.publicClient,
|
|
502
|
-
chainId: this.chainId,
|
|
503
484
|
});
|
|
504
485
|
}
|
|
505
486
|
}
|
|
@@ -66,13 +66,14 @@ type GetQuoteInput = {
|
|
|
66
66
|
quantity: bigint;
|
|
67
67
|
poolAddress: Address;
|
|
68
68
|
erc20z: Address;
|
|
69
|
-
chainId: number;
|
|
70
69
|
};
|
|
71
70
|
export async function getUniswapQuote(
|
|
72
71
|
input: GetQuoteInput,
|
|
73
72
|
client: PublicClient,
|
|
74
73
|
): Promise<GetQuoteOutput> {
|
|
75
|
-
const { type, quantity, poolAddress,
|
|
74
|
+
const { type, quantity, poolAddress, erc20z } = input;
|
|
75
|
+
|
|
76
|
+
const chainId = client.chain.id;
|
|
76
77
|
|
|
77
78
|
const WETH = wethAddresses[chainId as keyof typeof wethAddresses];
|
|
78
79
|
|
package/src/secondary/utils.ts
CHANGED
|
@@ -14,15 +14,15 @@ export async function getSecondaryInfo({
|
|
|
14
14
|
contract,
|
|
15
15
|
tokenId,
|
|
16
16
|
publicClient,
|
|
17
|
-
chainId,
|
|
18
17
|
}: {
|
|
19
18
|
contract: Address;
|
|
20
19
|
tokenId: bigint;
|
|
21
20
|
publicClient: PublicClient;
|
|
22
|
-
chainId: number;
|
|
23
21
|
}): Promise<SecondaryInfo | undefined> {
|
|
24
22
|
let result;
|
|
25
23
|
|
|
24
|
+
const chainId = publicClient.chain.id;
|
|
25
|
+
|
|
26
26
|
try {
|
|
27
27
|
result = await publicClient.readContract({
|
|
28
28
|
abi: zoraTimedSaleStrategyABI,
|
package/src/types.ts
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Account,
|
|
3
|
+
Address,
|
|
4
|
+
PublicClient,
|
|
5
|
+
SimulateContractParameters,
|
|
6
|
+
Transport,
|
|
7
|
+
Chain,
|
|
8
|
+
} from "viem";
|
|
3
9
|
|
|
4
10
|
export type GenericTokenIdTypes = number | bigint | string;
|
|
5
11
|
|
|
6
12
|
export type IPublicClient = Pick<
|
|
7
|
-
PublicClient,
|
|
8
|
-
"readContract" | "getBlock" | "simulateContract" | "getBalance"
|
|
13
|
+
PublicClient<Transport, Chain>,
|
|
14
|
+
"readContract" | "getBlock" | "simulateContract" | "getBalance" | "chain"
|
|
9
15
|
>;
|
|
10
16
|
|
|
17
|
+
export type WithPublicClient<T> = T & {
|
|
18
|
+
/** Public client used to read data from the blockchain. Chain id will determine which chain is used. */
|
|
19
|
+
publicClient: IPublicClient;
|
|
20
|
+
};
|
|
21
|
+
|
|
11
22
|
export type SimulateContractParametersWithAccount = SimulateContractParameters<
|
|
12
23
|
any,
|
|
13
24
|
any,
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Account,
|
|
3
|
+
Address,
|
|
4
|
+
PublicClient as BasePublicClient,
|
|
5
|
+
Transport,
|
|
6
|
+
Chain,
|
|
7
|
+
} from "viem";
|
|
2
8
|
import { SimulateContractParametersWithAccount } from "./types";
|
|
3
9
|
|
|
4
10
|
export const makeContractParameters = (
|
|
@@ -6,8 +12,8 @@ export const makeContractParameters = (
|
|
|
6
12
|
) => args;
|
|
7
13
|
|
|
8
14
|
export type PublicClient = Pick<
|
|
9
|
-
BasePublicClient,
|
|
10
|
-
"readContract" | "getBlock" | "simulateContract" | "getBalance"
|
|
15
|
+
BasePublicClient<Transport, Chain>,
|
|
16
|
+
"readContract" | "getBlock" | "simulateContract" | "getBalance" | "chain"
|
|
11
17
|
>;
|
|
12
18
|
|
|
13
19
|
export type ClientConfig = {
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Account, Address, Hex, PublicClient, TransactionReceipt } from "viem";
|
|
2
|
-
import { CreateNew1155ContractAndTokenReturn, CreateNew1155ContractParams, CreateNew1155TokenParams, CreateNew1155TokenReturn, NewContractParams } from "./types";
|
|
3
|
-
import { IContractGetter } from "./contract-getter";
|
|
4
|
-
export declare const getTokenIdFromCreateReceipt: (receipt: TransactionReceipt) => bigint;
|
|
5
|
-
export declare const getContractAddressFromReceipt: (receipt: TransactionReceipt) => Address;
|
|
6
|
-
type MakeContractParametersBase = {
|
|
7
|
-
account: Address | Account;
|
|
8
|
-
tokenSetupActions: Hex[];
|
|
9
|
-
};
|
|
10
|
-
export declare function makeCreateContractAndTokenCall({ account, contract, royaltyBPS, fundsRecipient, tokenSetupActions, chainId, }: {
|
|
11
|
-
chainId: number;
|
|
12
|
-
contract: NewContractParams;
|
|
13
|
-
royaltyBPS?: number;
|
|
14
|
-
fundsRecipient?: Address;
|
|
15
|
-
} & MakeContractParametersBase): import("../types").SimulateContractParametersWithAccount;
|
|
16
|
-
export declare class Create1155Client {
|
|
17
|
-
private readonly chainId;
|
|
18
|
-
private readonly publicClient;
|
|
19
|
-
readonly contractGetter: IContractGetter;
|
|
20
|
-
constructor({ chainId, publicClient, contractGetter, }: {
|
|
21
|
-
chainId: number;
|
|
22
|
-
publicClient: Pick<PublicClient, "readContract">;
|
|
23
|
-
contractGetter: IContractGetter;
|
|
24
|
-
});
|
|
25
|
-
createNew1155(props: CreateNew1155ContractParams): Promise<CreateNew1155ContractAndTokenReturn>;
|
|
26
|
-
createNew1155OnExistingContract({ contractAddress: contract, account, token, getAdditionalSetupActions, }: CreateNew1155TokenParams): Promise<CreateNew1155TokenReturn>;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=1155-create-helper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"1155-create-helper.d.ts","sourceRoot":"","sources":["../../src/create/1155-create-helper.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,GAAG,EACH,YAAY,EACZ,kBAAkB,EACnB,MAAM,MAAM,CAAC;AAQd,OAAO,EACL,mCAAmC,EACnC,2BAA2B,EAE3B,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKpD,eAAO,MAAM,2BAA2B,YAC7B,kBAAkB,KAC1B,MAiBF,CAAC;AAEF,eAAO,MAAM,6BAA6B,YAC/B,kBAAkB,KAC1B,OAiBF,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAE3B,iBAAiB,EAAE,GAAG,EAAE,CAAC;CAC1B,CAAC;AAEF,wBAAgB,8BAA8B,CAAC,EAC7C,OAAO,EACP,QAAQ,EACR,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,OAAO,GACR,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,0BAA0B,4DAwB7B;AAkBD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAqC;IAClE,SAAgB,cAAc,EAAE,eAAe,CAAC;gBAEpC,EACV,OAAO,EACP,YAAY,EACZ,cAAc,GACf,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACjD,cAAc,EAAE,eAAe,CAAC;KACjC;IAMK,aAAa,CACjB,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,mCAAmC,CAAC;IAQzC,+BAA+B,CAAC,EACpC,eAAe,EAAE,QAAQ,EACzB,OAAO,EACP,KAAK,EACL,yBAAyB,GAC1B,EAAE,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAWhE"}
|