@0xsequence/marketplace-sdk 0.0.1 → 0.2.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.
Files changed (144) hide show
  1. package/.ctirc +32 -0
  2. package/dist/{chunk-TZGLKJRF.js → chunk-4E34HVSA.js} +2 -2
  3. package/dist/chunk-5EOVZAKT.js +1325 -0
  4. package/dist/chunk-5EOVZAKT.js.map +1 -0
  5. package/dist/{chunk-RNUHUVLC.js → chunk-6JWGELXL.js} +1 -1
  6. package/dist/chunk-6JWGELXL.js.map +1 -0
  7. package/dist/{chunk-4PFMUVE4.js → chunk-CSN7YD5Q.js} +2 -2
  8. package/dist/chunk-CSN7YD5Q.js.map +1 -0
  9. package/dist/{chunk-G3D572BT.js → chunk-FCQCNLFZ.js} +24 -1
  10. package/dist/chunk-FCQCNLFZ.js.map +1 -0
  11. package/dist/{chunk-HGBEC3WX.js → chunk-GZIA25G4.js} +1 -1
  12. package/dist/chunk-GZIA25G4.js.map +1 -0
  13. package/dist/{chunk-QOJXWHRZ.js → chunk-LFQB477Y.js} +3 -1
  14. package/dist/chunk-LFQB477Y.js.map +1 -0
  15. package/dist/{chunk-SM7V6ZWI.js → chunk-MD4JHPMH.js} +493 -418
  16. package/dist/chunk-MD4JHPMH.js.map +1 -0
  17. package/dist/{chunk-EDTC7UES.js → chunk-NII6JJGH.js} +9 -4
  18. package/dist/chunk-NII6JJGH.js.map +1 -0
  19. package/dist/{chunk-BBB3XUB4.js → chunk-PE2LLUTJ.js} +1 -1
  20. package/dist/chunk-PE2LLUTJ.js.map +1 -0
  21. package/dist/chunk-Q2BVDQ3G.js +41 -0
  22. package/dist/chunk-Q2BVDQ3G.js.map +1 -0
  23. package/dist/{chunk-3TYUQEFM.js → chunk-VEX7FDL6.js} +2 -2
  24. package/dist/chunk-VEX7FDL6.js.map +1 -0
  25. package/dist/{create-config-Dz0gCiQ0.d.ts → create-config-CgtmCzvb.d.ts} +2 -2
  26. package/dist/index.css +4 -1
  27. package/dist/index.d.ts +3 -2
  28. package/dist/index.js +4 -4
  29. package/dist/{marketplace-config-DZbtyrma.d.ts → marketplace-config-Bbxl-uKX.d.ts} +2 -1
  30. package/dist/react/_internal/api/index.d.ts +1 -1
  31. package/dist/react/_internal/api/index.js +1 -1
  32. package/dist/react/_internal/index.d.ts +5 -4
  33. package/dist/react/_internal/index.js +16 -8
  34. package/dist/react/_internal/wagmi/index.d.ts +3 -3
  35. package/dist/react/_internal/wagmi/index.js +1 -1
  36. package/dist/react/hooks/index.d.ts +1691 -103
  37. package/dist/react/hooks/index.js +34 -22
  38. package/dist/react/index.css +4 -1
  39. package/dist/react/index.css.map +1 -1
  40. package/dist/react/index.d.ts +7 -6
  41. package/dist/react/index.js +43 -31
  42. package/dist/react/ssr/index.d.ts +26 -25
  43. package/dist/react/ssr/index.js +34 -4
  44. package/dist/react/ssr/index.js.map +1 -1
  45. package/dist/react/ui/icons/index.js +2 -2
  46. package/dist/react/ui/index.css +4 -1
  47. package/dist/react/ui/index.css.map +1 -1
  48. package/dist/react/ui/index.d.ts +47 -42
  49. package/dist/react/ui/index.js +10 -10
  50. package/dist/react/ui/modals/_internal/components/actionModal/index.js +4 -4
  51. package/dist/{services-BIwQ1C1c.d.ts → services-Dei25J6_.d.ts} +1 -1
  52. package/dist/styles/index.css +4 -1
  53. package/dist/styles/index.css.map +1 -1
  54. package/dist/styles/index.d.ts +2 -1
  55. package/dist/styles/index.js +4 -4973
  56. package/dist/styles/index.js.map +1 -1
  57. package/dist/types/index.d.ts +2 -1
  58. package/dist/types/index.js +3 -3
  59. package/dist/types-BzZVURNL.d.ts +19 -0
  60. package/dist/utils/abi/clients/index.js +1 -1
  61. package/dist/utils/index.d.ts +2 -1
  62. package/dist/utils/index.js +2 -2
  63. package/package.json +19 -25
  64. package/src/react/_internal/api/marketplace.gen.ts +4 -1
  65. package/src/react/_internal/api/zod-schema.ts +636 -0
  66. package/src/react/_internal/types.ts +33 -9
  67. package/src/react/_internal/wagmi/create-config.ts +9 -3
  68. package/src/react/_internal/wagmi/embedded.ts +1 -1
  69. package/src/react/_internal/wagmi/universal.ts +1 -1
  70. package/src/react/hooks/index.ts +3 -0
  71. package/src/react/hooks/options/marketplaceConfigOptions.ts +2 -2
  72. package/src/react/hooks/useBalanceOfCollectible.tsx +47 -21
  73. package/src/react/hooks/useCheckoutOptions.tsx +63 -0
  74. package/src/react/hooks/useCollectible.tsx +20 -14
  75. package/src/react/hooks/useCollection.tsx +18 -12
  76. package/src/react/hooks/useCountOfCollectables.tsx +77 -0
  77. package/src/react/hooks/useCurrencies.tsx +67 -56
  78. package/src/react/hooks/useFilters.tsx +18 -12
  79. package/src/react/hooks/useFloorOrder.tsx +24 -9
  80. package/src/react/hooks/useGenerateListingTransaction.tsx +8 -7
  81. package/src/react/hooks/useGenerateOfferTransaction.tsx +5 -5
  82. package/src/react/hooks/useGenerateSellTransaction.tsx +19 -12
  83. package/src/react/hooks/useHighestOffer.tsx +26 -16
  84. package/src/react/hooks/useListBalances.tsx +60 -29
  85. package/src/react/hooks/useListCollectibles.tsx +28 -15
  86. package/src/react/hooks/useListOffersForCollectible.tsx +17 -8
  87. package/src/react/hooks/useLowestListing.tsx +26 -17
  88. package/src/react/hooks/useRoyaltyPercentage.tsx +18 -8
  89. package/src/react/hooks/useTransferTokens.tsx +3 -3
  90. package/src/react/provider.tsx +1 -1
  91. package/src/react/ssr/create-ssr-client.ts +1 -1
  92. package/src/react/ui/modals/CreateListingModal/_store.ts +39 -40
  93. package/src/react/ui/modals/CreateListingModal/index.tsx +152 -130
  94. package/src/react/ui/modals/MakeOfferModal/_store.ts +38 -43
  95. package/src/react/ui/modals/MakeOfferModal/index.tsx +39 -28
  96. package/src/react/ui/modals/SellModal/_store.ts +59 -57
  97. package/src/react/ui/modals/SellModal/index.tsx +34 -12
  98. package/src/react/ui/modals/SuccessfulPurchaseModal/_store.ts +1 -1
  99. package/src/react/ui/modals/SuccessfulPurchaseModal/index.tsx +14 -14
  100. package/src/react/ui/modals/TransferModal/_store.ts +11 -11
  101. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +92 -89
  102. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +114 -0
  103. package/src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx +0 -96
  104. package/src/react/ui/modals/TransferModal/index.tsx +24 -3
  105. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +1 -1
  106. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +4 -4
  107. package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +4 -3
  108. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +55 -12
  109. package/src/react/ui/modals/_internal/components/priceInput/styles.css.ts +4 -0
  110. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +3 -2
  111. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +4 -4
  112. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +4 -4
  113. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +3 -2
  114. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +7 -5
  115. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +6 -6
  116. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +47 -14
  117. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +14 -6
  118. package/src/types/api-types.ts +2 -2
  119. package/src/types/callbacks.ts +51 -0
  120. package/src/types/marketplace-config.ts +2 -1
  121. package/src/types/types.ts +1 -1
  122. package/src/utils/get-public-rpc-client.ts +1 -1
  123. package/tsconfig.json +24 -0
  124. package/tsconfig.tsbuildinfo +1 -0
  125. package/tsup.config.ts +35 -0
  126. package/README.md +0 -8
  127. package/dist/chunk-3TYUQEFM.js.map +0 -1
  128. package/dist/chunk-4PFMUVE4.js.map +0 -1
  129. package/dist/chunk-BBB3XUB4.js.map +0 -1
  130. package/dist/chunk-EDTC7UES.js.map +0 -1
  131. package/dist/chunk-G3D572BT.js.map +0 -1
  132. package/dist/chunk-HGBEC3WX.js.map +0 -1
  133. package/dist/chunk-QOJXWHRZ.js.map +0 -1
  134. package/dist/chunk-RNUHUVLC.js.map +0 -1
  135. package/dist/chunk-SM7V6ZWI.js.map +0 -1
  136. package/dist/chunk-STO74F2I.js +0 -14
  137. package/dist/chunk-STO74F2I.js.map +0 -1
  138. package/dist/chunk-VPGWEMWL.js +0 -162
  139. package/dist/chunk-VPGWEMWL.js.map +0 -1
  140. package/dist/chunk-ZE2LNX65.js +0 -394
  141. package/dist/chunk-ZE2LNX65.js.map +0 -1
  142. package/dist/types-BrAQ8-w4.d.ts +0 -12
  143. package/src/react/hooks/useCollectionCounts.tsx +0 -61
  144. /package/dist/{chunk-TZGLKJRF.js.map → chunk-4E34HVSA.js.map} +0 -0
@@ -0,0 +1,1325 @@
1
+ "use client"
2
+ import {
3
+ getPublicRpcClient
4
+ } from "./chunk-6JWGELXL.js";
5
+ import {
6
+ EIP2981_ABI
7
+ } from "./chunk-DBFOPEV6.js";
8
+ import {
9
+ ERC1155_ABI
10
+ } from "./chunk-O5JXKTWP.js";
11
+ import {
12
+ AddressSchema,
13
+ ChainIdSchema,
14
+ CollectableIdSchema,
15
+ PROVIDER_ID,
16
+ QueryArgSchema
17
+ } from "./chunk-Q2BVDQ3G.js";
18
+ import {
19
+ CollectibleStatus,
20
+ CollectionStatus,
21
+ ContractType,
22
+ ExecuteType,
23
+ MarketplaceKind,
24
+ OrderSide,
25
+ OrderStatus,
26
+ OrderbookKind,
27
+ ProjectStatus,
28
+ PropertyType,
29
+ SortOrder,
30
+ SourceKind,
31
+ StepType,
32
+ TransactionCrypto,
33
+ TransactionNFTCheckoutProvider,
34
+ TransactionOnRampProvider,
35
+ TransactionSwapProvider,
36
+ WalletKind,
37
+ balanceQueries,
38
+ builderMarketplaceApi,
39
+ collectableKeys,
40
+ collectionKeys,
41
+ configKeys,
42
+ currencyKeys,
43
+ getIndexerClient,
44
+ getMarketplaceClient,
45
+ getMetadataClient,
46
+ getQueryClient
47
+ } from "./chunk-GZIA25G4.js";
48
+
49
+ // src/react/hooks/useBalanceOfCollectible.tsx
50
+ import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
51
+ import { z } from "zod";
52
+
53
+ // src/react/hooks/useConfig.tsx
54
+ import { useContext } from "react";
55
+
56
+ // src/react/provider.tsx
57
+ import { createContext } from "react";
58
+ import "@0xsequence/design-system/styles.css";
59
+ import { jsx } from "react/jsx-runtime";
60
+ var MarketplaceSdkContext = createContext({});
61
+ function MarketplaceProvider({
62
+ config,
63
+ children
64
+ }) {
65
+ return /* @__PURE__ */ jsx(MarketplaceSdkContext.Provider, { value: config, children: /* @__PURE__ */ jsx("div", { id: PROVIDER_ID, children }) });
66
+ }
67
+
68
+ // src/react/hooks/useConfig.tsx
69
+ function useConfig() {
70
+ const context = useContext(MarketplaceSdkContext);
71
+ if (!context) {
72
+ throw new Error(
73
+ "Marketplace SDK must be used within a MarketplaceSdkProvider"
74
+ );
75
+ }
76
+ return context;
77
+ }
78
+
79
+ // src/react/hooks/useBalanceOfCollectible.tsx
80
+ var fetchBalanceOfCollectibleSchema = z.object({
81
+ collectionAddress: AddressSchema,
82
+ collectableId: CollectableIdSchema.pipe(z.coerce.string()),
83
+ userAddress: AddressSchema,
84
+ chainId: ChainIdSchema.pipe(z.coerce.number())
85
+ });
86
+ var fetchBalanceOfCollectible = async (args, config) => {
87
+ const parsedArgs = fetchBalanceOfCollectibleSchema.parse(args);
88
+ const indexerClient = getIndexerClient(parsedArgs.chainId, config);
89
+ return indexerClient.getTokenBalances({
90
+ accountAddress: parsedArgs.userAddress,
91
+ contractAddress: parsedArgs.collectionAddress,
92
+ tokenID: parsedArgs.collectableId,
93
+ includeMetadata: false,
94
+ metadataOptions: {
95
+ verifiedOnly: true,
96
+ includeContracts: [parsedArgs.collectionAddress]
97
+ }
98
+ }).then((res) => res.balances[0] || null);
99
+ };
100
+ var balanceOfCollectibleOptions = (args, config) => {
101
+ const enabled = !!args.userAddress && (args.query?.enabled ?? true);
102
+ return queryOptions({
103
+ ...args.query,
104
+ queryKey: [...collectableKeys.userBalances, args],
105
+ queryFn: enabled ? () => fetchBalanceOfCollectible(
106
+ {
107
+ ...args,
108
+ // biome-ignore lint/style/noNonNullAssertion: this is guaranteed by the userAddress check above
109
+ userAddress: args.userAddress
110
+ },
111
+ config
112
+ ) : skipToken,
113
+ enabled
114
+ });
115
+ };
116
+ var useBalanceOfCollectible = (args) => {
117
+ const config = useConfig();
118
+ return useQuery(balanceOfCollectibleOptions(args, config));
119
+ };
120
+
121
+ // src/react/hooks/useCountOfCollectables.tsx
122
+ import { queryOptions as queryOptions2, useQuery as useQuery2 } from "@tanstack/react-query";
123
+ import { z as z3 } from "zod";
124
+
125
+ // src/react/_internal/api/zod-schema.ts
126
+ import { z as z2 } from "zod";
127
+ var assetSchema = z2.object({
128
+ id: z2.number(),
129
+ collectionId: z2.number(),
130
+ tokenId: z2.string(),
131
+ url: z2.string().optional(),
132
+ metadataField: z2.string(),
133
+ name: z2.string().optional(),
134
+ filesize: z2.number().optional(),
135
+ mimeType: z2.string().optional(),
136
+ width: z2.number().optional(),
137
+ height: z2.number().optional(),
138
+ updatedAt: z2.string().optional()
139
+ });
140
+ var sortOrderSchema = z2.nativeEnum(SortOrder);
141
+ var propertyTypeSchema = z2.nativeEnum(PropertyType);
142
+ var marketplaceKindSchema = z2.nativeEnum(MarketplaceKind);
143
+ var orderbookKindSchema = z2.nativeEnum(OrderbookKind);
144
+ var sourceKindSchema = z2.nativeEnum(SourceKind);
145
+ var orderSideSchema = z2.nativeEnum(OrderSide);
146
+ var orderStatusSchema = z2.nativeEnum(OrderStatus);
147
+ var contractTypeSchema = z2.nativeEnum(ContractType);
148
+ var collectionStatusSchema = z2.nativeEnum(CollectionStatus);
149
+ var projectStatusSchema = z2.nativeEnum(ProjectStatus);
150
+ var collectibleStatusSchema = z2.nativeEnum(CollectibleStatus);
151
+ var walletKindSchema = z2.nativeEnum(WalletKind);
152
+ var stepTypeSchema = z2.nativeEnum(StepType);
153
+ var transactionCryptoSchema = z2.nativeEnum(TransactionCrypto);
154
+ var transactionNFTCheckoutProviderSchema = z2.nativeEnum(
155
+ TransactionNFTCheckoutProvider
156
+ );
157
+ var transactionOnRampProviderSchema = z2.nativeEnum(
158
+ TransactionOnRampProvider
159
+ );
160
+ var transactionSwapProviderSchema = z2.nativeEnum(
161
+ TransactionSwapProvider
162
+ );
163
+ var executeTypeSchema = z2.nativeEnum(ExecuteType);
164
+ var sortBySchema = z2.object({
165
+ column: z2.string(),
166
+ order: sortOrderSchema
167
+ });
168
+ var propertyFilterSchema = z2.object({
169
+ name: z2.string(),
170
+ type: propertyTypeSchema,
171
+ min: z2.number().optional(),
172
+ max: z2.number().optional(),
173
+ values: z2.array(z2.any()).optional()
174
+ });
175
+ var collectiblesFilterSchema = z2.object({
176
+ includeEmpty: z2.boolean(),
177
+ searchText: z2.string().optional(),
178
+ properties: z2.array(propertyFilterSchema).optional(),
179
+ marketplaces: z2.array(marketplaceKindSchema).optional(),
180
+ inAccounts: z2.array(z2.string()).optional(),
181
+ notInAccounts: z2.array(z2.string()).optional(),
182
+ ordersCreatedBy: z2.array(z2.string()).optional(),
183
+ ordersNotCreatedBy: z2.array(z2.string()).optional()
184
+ });
185
+ var feeBreakdownSchema = z2.object({
186
+ kind: z2.string(),
187
+ recipientAddress: z2.string(),
188
+ bps: z2.number()
189
+ });
190
+ var orderFilterSchema = z2.object({
191
+ createdBy: z2.array(z2.string()).optional(),
192
+ marketplace: z2.array(marketplaceKindSchema).optional(),
193
+ currencies: z2.array(z2.string()).optional()
194
+ });
195
+ var collectionLastSyncedSchema = z2.object({
196
+ allOrders: z2.string(),
197
+ newOrders: z2.string()
198
+ });
199
+ var projectSchema = z2.object({
200
+ projectId: z2.number(),
201
+ chainId: z2.number(),
202
+ contractAddress: z2.string(),
203
+ status: projectStatusSchema,
204
+ createdAt: z2.string(),
205
+ updatedAt: z2.string(),
206
+ deletedAt: z2.string().optional()
207
+ });
208
+ var collectibleSchema = z2.object({
209
+ chainId: z2.number(),
210
+ contractAddress: z2.string(),
211
+ status: collectibleStatusSchema,
212
+ tokenId: z2.string(),
213
+ createdAt: z2.string(),
214
+ updatedAt: z2.string(),
215
+ deletedAt: z2.string().optional()
216
+ });
217
+ var currencySchema = z2.object({
218
+ chainId: z2.number(),
219
+ contractAddress: z2.string(),
220
+ name: z2.string(),
221
+ symbol: z2.string(),
222
+ decimals: z2.number(),
223
+ imageUrl: z2.string(),
224
+ exchangeRate: z2.number(),
225
+ defaultChainCurrency: z2.boolean(),
226
+ nativeCurrency: z2.boolean(),
227
+ createdAt: z2.string(),
228
+ updatedAt: z2.string(),
229
+ deletedAt: z2.string().optional()
230
+ });
231
+ var orderDataSchema = z2.object({
232
+ orderId: z2.string(),
233
+ quantity: z2.string()
234
+ });
235
+ var additionalFeeSchema = z2.object({
236
+ amount: z2.string(),
237
+ receiver: z2.string()
238
+ });
239
+ var postRequestSchema = z2.object({
240
+ endpoint: z2.string(),
241
+ method: z2.string(),
242
+ body: z2.any()
243
+ });
244
+ var createReqSchema = z2.object({
245
+ tokenId: z2.string(),
246
+ quantity: z2.string(),
247
+ expiry: z2.string(),
248
+ currencyAddress: z2.string(),
249
+ pricePerToken: z2.string()
250
+ });
251
+ var getOrdersInputSchema = z2.object({
252
+ contractAddress: z2.string(),
253
+ orderId: z2.string(),
254
+ marketplace: marketplaceKindSchema
255
+ });
256
+ var domainSchema = z2.object({
257
+ name: z2.string(),
258
+ version: z2.string(),
259
+ chainId: z2.number(),
260
+ verifyingContract: z2.string()
261
+ });
262
+ var checkoutOptionsMarketplaceOrderSchema = z2.object({
263
+ contractAddress: z2.string(),
264
+ orderId: z2.string(),
265
+ marketplace: marketplaceKindSchema
266
+ });
267
+ var checkoutOptionsItemSchema = z2.object({
268
+ tokenId: z2.string(),
269
+ quantity: z2.string()
270
+ });
271
+ var checkoutOptionsSchema = z2.object({
272
+ crypto: transactionCryptoSchema,
273
+ swap: z2.array(transactionSwapProviderSchema),
274
+ nftCheckout: z2.array(transactionNFTCheckoutProviderSchema),
275
+ onRamp: z2.array(transactionOnRampProviderSchema)
276
+ });
277
+ var listCurrenciesArgsSchema = z2.object({});
278
+ var listCurrenciesReturnSchema = z2.object({
279
+ currencies: z2.array(currencySchema)
280
+ });
281
+ var getCollectibleArgsSchema = z2.object({
282
+ contractAddress: z2.string(),
283
+ tokenId: z2.string()
284
+ });
285
+ var getLowestPriceOfferForCollectibleArgsSchema = z2.object({
286
+ contractAddress: z2.string(),
287
+ tokenId: z2.string(),
288
+ filter: orderFilterSchema.optional()
289
+ });
290
+ var getHighestPriceOfferForCollectibleArgsSchema = z2.object({
291
+ contractAddress: z2.string(),
292
+ tokenId: z2.string(),
293
+ filter: orderFilterSchema.optional()
294
+ });
295
+ var getLowestPriceListingForCollectibleArgsSchema = z2.object({
296
+ contractAddress: z2.string(),
297
+ tokenId: z2.string(),
298
+ filter: orderFilterSchema.optional()
299
+ });
300
+ var getHighestPriceListingForCollectibleArgsSchema = z2.object({
301
+ contractAddress: z2.string(),
302
+ tokenId: z2.string(),
303
+ filter: orderFilterSchema.optional()
304
+ });
305
+ var getCollectibleLowestOfferArgsSchema = z2.object({
306
+ contractAddress: z2.string(),
307
+ tokenId: z2.string(),
308
+ filter: orderFilterSchema.optional()
309
+ });
310
+ var getCollectibleHighestOfferArgsSchema = z2.object({
311
+ contractAddress: z2.string(),
312
+ tokenId: z2.string(),
313
+ filter: orderFilterSchema.optional()
314
+ });
315
+ var getCollectibleLowestListingArgsSchema = z2.object({
316
+ contractAddress: z2.string(),
317
+ tokenId: z2.string(),
318
+ filters: orderFilterSchema.optional()
319
+ });
320
+ var getCollectibleHighestListingArgsSchema = z2.object({
321
+ contractAddress: z2.string(),
322
+ tokenId: z2.string(),
323
+ filter: orderFilterSchema.optional()
324
+ });
325
+ var generateBuyTransactionArgsSchema = z2.object({
326
+ collectionAddress: z2.string(),
327
+ buyer: z2.string(),
328
+ marketplace: marketplaceKindSchema,
329
+ ordersData: z2.array(orderDataSchema),
330
+ additionalFees: z2.array(additionalFeeSchema),
331
+ walletType: walletKindSchema.optional()
332
+ });
333
+ var generateSellTransactionArgsSchema = z2.object({
334
+ collectionAddress: z2.string(),
335
+ seller: z2.string(),
336
+ marketplace: marketplaceKindSchema,
337
+ ordersData: z2.array(orderDataSchema),
338
+ additionalFees: z2.array(additionalFeeSchema),
339
+ walletType: walletKindSchema.optional()
340
+ });
341
+ var generateListingTransactionArgsSchema = z2.object({
342
+ collectionAddress: z2.string(),
343
+ owner: z2.string(),
344
+ contractType: contractTypeSchema,
345
+ orderbook: orderbookKindSchema,
346
+ listing: createReqSchema,
347
+ walletType: walletKindSchema.optional()
348
+ });
349
+ var generateOfferTransactionArgsSchema = z2.object({
350
+ collectionAddress: z2.string(),
351
+ maker: z2.string(),
352
+ contractType: contractTypeSchema,
353
+ orderbook: orderbookKindSchema,
354
+ offer: createReqSchema,
355
+ walletType: walletKindSchema.optional()
356
+ });
357
+ var executeArgsSchema = z2.object({
358
+ signature: z2.string(),
359
+ executeType: executeTypeSchema,
360
+ body: z2.any()
361
+ });
362
+ var executeReturnSchema = z2.object({
363
+ orderId: z2.string()
364
+ });
365
+ var getCountOfAllCollectiblesArgsSchema = z2.object({
366
+ contractAddress: z2.string()
367
+ });
368
+ var getCountOfAllCollectiblesReturnSchema = z2.object({
369
+ count: z2.number()
370
+ });
371
+ var getCountOfFilteredCollectiblesArgsSchema = z2.object({
372
+ side: orderSideSchema,
373
+ contractAddress: z2.string(),
374
+ filter: collectiblesFilterSchema.optional()
375
+ });
376
+ var getCountOfFilteredCollectiblesReturnSchema = z2.object({
377
+ count: z2.number()
378
+ });
379
+ var getFloorOrderArgsSchema = z2.object({
380
+ contractAddress: z2.string(),
381
+ filter: collectiblesFilterSchema.optional()
382
+ });
383
+ var syncOrderReturnSchema = z2.object({});
384
+ var syncOrdersReturnSchema = z2.object({});
385
+ var checkoutOptionsMarketplaceArgsSchema = z2.object({
386
+ wallet: z2.string(),
387
+ orders: z2.array(checkoutOptionsMarketplaceOrderSchema),
388
+ additionalFee: z2.number()
389
+ });
390
+ var checkoutOptionsMarketplaceReturnSchema = z2.object({
391
+ options: checkoutOptionsSchema
392
+ });
393
+ var checkoutOptionsSalesContractArgsSchema = z2.object({
394
+ wallet: z2.string(),
395
+ contractAddress: z2.string(),
396
+ collectionAddress: z2.string(),
397
+ items: z2.array(checkoutOptionsItemSchema)
398
+ });
399
+ var checkoutOptionsSalesContractReturnSchema = z2.object({
400
+ options: checkoutOptionsSchema
401
+ });
402
+ var tokenMetadataSchema = z2.object({
403
+ tokenId: z2.string(),
404
+ name: z2.string(),
405
+ description: z2.string().optional(),
406
+ image: z2.string().optional(),
407
+ video: z2.string().optional(),
408
+ audio: z2.string().optional(),
409
+ properties: z2.record(z2.any()).optional(),
410
+ attributes: z2.array(z2.record(z2.any())),
411
+ image_data: z2.string().optional(),
412
+ external_url: z2.string().optional(),
413
+ background_color: z2.string().optional(),
414
+ animation_url: z2.string().optional(),
415
+ decimals: z2.number().optional(),
416
+ updatedAt: z2.string().optional(),
417
+ assets: z2.array(assetSchema).optional()
418
+ });
419
+ var pageSchema = z2.object({
420
+ page: z2.number(),
421
+ pageSize: z2.number(),
422
+ more: z2.boolean().optional(),
423
+ sort: z2.array(sortBySchema).optional()
424
+ });
425
+ var filterSchema = z2.object({
426
+ text: z2.string().optional(),
427
+ properties: z2.array(propertyFilterSchema).optional()
428
+ });
429
+ var orderSchema = z2.object({
430
+ orderId: z2.string(),
431
+ marketplace: marketplaceKindSchema,
432
+ side: orderSideSchema,
433
+ status: orderStatusSchema,
434
+ chainId: z2.number(),
435
+ collectionContractAddress: z2.string(),
436
+ tokenId: z2.string(),
437
+ createdBy: z2.string(),
438
+ priceAmount: z2.string(),
439
+ priceAmountFormatted: z2.string(),
440
+ priceAmountNet: z2.string(),
441
+ priceAmountNetFormatted: z2.string(),
442
+ priceCurrencyAddress: z2.string(),
443
+ priceDecimals: z2.number(),
444
+ priceUSD: z2.number(),
445
+ quantityInitial: z2.string(),
446
+ quantityInitialFormatted: z2.string(),
447
+ quantityRemaining: z2.string(),
448
+ quantityRemainingFormatted: z2.string(),
449
+ quantityAvailable: z2.string(),
450
+ quantityAvailableFormatted: z2.string(),
451
+ quantityDecimals: z2.number(),
452
+ feeBps: z2.number(),
453
+ feeBreakdown: z2.array(feeBreakdownSchema),
454
+ validFrom: z2.string(),
455
+ validUntil: z2.string(),
456
+ blockNumber: z2.number(),
457
+ orderCreatedAt: z2.string().optional(),
458
+ orderUpdatedAt: z2.string().optional(),
459
+ createdAt: z2.string(),
460
+ updatedAt: z2.string(),
461
+ deletedAt: z2.string().optional()
462
+ });
463
+ var collectibleOrderSchema = z2.object({
464
+ metadata: tokenMetadataSchema,
465
+ order: orderSchema.optional()
466
+ });
467
+ var activitySchema = z2.object({
468
+ type: z2.string(),
469
+ fromAddress: z2.string(),
470
+ toAddress: z2.string(),
471
+ txHash: z2.string(),
472
+ timestamp: z2.number(),
473
+ tokenId: z2.string(),
474
+ tokenImage: z2.string(),
475
+ tokenName: z2.string(),
476
+ currency: currencySchema.optional()
477
+ });
478
+ var collectionConfigSchema = z2.object({
479
+ lastSynced: z2.record(collectionLastSyncedSchema),
480
+ collectiblesSynced: z2.string()
481
+ });
482
+ var signatureSchema = z2.object({
483
+ domain: domainSchema,
484
+ types: z2.any(),
485
+ primaryType: z2.string(),
486
+ value: z2.any()
487
+ });
488
+ var getCollectibleReturnSchema = z2.object({
489
+ metadata: tokenMetadataSchema
490
+ });
491
+ var getLowestPriceOfferForCollectibleReturnSchema = z2.object({
492
+ order: orderSchema
493
+ });
494
+ var getHighestPriceOfferForCollectibleReturnSchema = z2.object({
495
+ order: orderSchema
496
+ });
497
+ var getLowestPriceListingForCollectibleReturnSchema = z2.object({
498
+ order: orderSchema
499
+ });
500
+ var getHighestPriceListingForCollectibleReturnSchema = z2.object({
501
+ order: orderSchema
502
+ });
503
+ var listListingsForCollectibleArgsSchema = z2.object({
504
+ contractAddress: z2.string(),
505
+ tokenId: z2.string(),
506
+ filter: orderFilterSchema.optional(),
507
+ page: pageSchema.optional()
508
+ });
509
+ var listListingsForCollectibleReturnSchema = z2.object({
510
+ listings: z2.array(orderSchema),
511
+ page: pageSchema.optional()
512
+ });
513
+ var listOffersForCollectibleArgsSchema = z2.object({
514
+ contractAddress: z2.string(),
515
+ tokenId: z2.string(),
516
+ filter: orderFilterSchema.optional(),
517
+ page: pageSchema.optional()
518
+ });
519
+ var listOffersForCollectibleReturnSchema = z2.object({
520
+ offers: z2.array(orderSchema),
521
+ page: pageSchema.optional()
522
+ });
523
+ var getCollectibleLowestOfferReturnSchema = z2.object({
524
+ order: orderSchema.optional()
525
+ });
526
+ var getCollectibleHighestOfferReturnSchema = z2.object({
527
+ order: orderSchema.optional()
528
+ });
529
+ var getCollectibleLowestListingReturnSchema = z2.object({
530
+ order: orderSchema.optional()
531
+ });
532
+ var getCollectibleHighestListingReturnSchema = z2.object({
533
+ order: orderSchema.optional()
534
+ });
535
+ var listCollectibleListingsArgsSchema = z2.object({
536
+ contractAddress: z2.string(),
537
+ tokenId: z2.string(),
538
+ filter: orderFilterSchema.optional(),
539
+ page: pageSchema.optional()
540
+ });
541
+ var listCollectibleListingsReturnSchema = z2.object({
542
+ listings: z2.array(orderSchema),
543
+ page: pageSchema.optional()
544
+ });
545
+ var listCollectibleOffersArgsSchema = z2.object({
546
+ contractAddress: z2.string(),
547
+ tokenId: z2.string(),
548
+ filter: orderFilterSchema.optional(),
549
+ page: pageSchema.optional()
550
+ });
551
+ var listCollectibleOffersReturnSchema = z2.object({
552
+ offers: z2.array(orderSchema),
553
+ page: pageSchema.optional()
554
+ });
555
+ var listCollectiblesArgsSchema = z2.object({
556
+ side: orderSideSchema,
557
+ contractAddress: z2.string(),
558
+ filter: collectiblesFilterSchema.optional(),
559
+ page: pageSchema.optional()
560
+ });
561
+ var listCollectiblesReturnSchema = z2.object({
562
+ collectibles: z2.array(collectibleOrderSchema),
563
+ page: pageSchema.optional()
564
+ });
565
+ var getFloorOrderReturnSchema = z2.object({
566
+ collectible: collectibleOrderSchema
567
+ });
568
+ var listCollectiblesWithLowestListingArgsSchema = z2.object({
569
+ contractAddress: z2.string(),
570
+ filter: collectiblesFilterSchema.optional(),
571
+ page: pageSchema.optional()
572
+ });
573
+ var listCollectiblesWithLowestListingReturnSchema = z2.object({
574
+ collectibles: z2.array(collectibleOrderSchema),
575
+ page: pageSchema.optional()
576
+ });
577
+ var listCollectiblesWithHighestOfferArgsSchema = z2.object({
578
+ contractAddress: z2.string(),
579
+ filter: collectiblesFilterSchema.optional(),
580
+ page: pageSchema.optional()
581
+ });
582
+ var listCollectiblesWithHighestOfferReturnSchema = z2.object({
583
+ collectibles: z2.array(collectibleOrderSchema),
584
+ page: pageSchema.optional()
585
+ });
586
+ var syncOrderArgsSchema = z2.object({
587
+ order: orderSchema
588
+ });
589
+ var syncOrdersArgsSchema = z2.object({
590
+ orders: z2.array(orderSchema)
591
+ });
592
+ var getOrdersArgsSchema = z2.object({
593
+ input: z2.array(getOrdersInputSchema),
594
+ page: pageSchema.optional()
595
+ });
596
+ var getOrdersReturnSchema = z2.object({
597
+ orders: z2.array(orderSchema),
598
+ page: pageSchema.optional()
599
+ });
600
+ var collectionSchema = z2.object({
601
+ status: collectionStatusSchema,
602
+ chainId: z2.number(),
603
+ contractAddress: z2.string(),
604
+ contractType: contractTypeSchema,
605
+ tokenQuantityDecimals: z2.number(),
606
+ config: collectionConfigSchema,
607
+ createdAt: z2.string(),
608
+ updatedAt: z2.string(),
609
+ deletedAt: z2.string().optional()
610
+ });
611
+ var stepSchema = z2.object({
612
+ id: stepTypeSchema,
613
+ data: z2.string(),
614
+ to: z2.string(),
615
+ value: z2.string(),
616
+ signature: signatureSchema.optional(),
617
+ post: postRequestSchema.optional(),
618
+ executeType: executeTypeSchema.optional()
619
+ });
620
+ var generateBuyTransactionReturnSchema = z2.object({
621
+ steps: z2.array(stepSchema)
622
+ });
623
+ var generateSellTransactionReturnSchema = z2.object({
624
+ steps: z2.array(stepSchema)
625
+ });
626
+ var generateListingTransactionReturnSchema = z2.object({
627
+ steps: z2.array(stepSchema)
628
+ });
629
+ var generateOfferTransactionReturnSchema = z2.object({
630
+ steps: z2.array(stepSchema)
631
+ });
632
+
633
+ // src/react/hooks/useCountOfCollectables.tsx
634
+ var BaseSchema = z3.object({
635
+ chainId: ChainIdSchema.pipe(z3.coerce.string()),
636
+ collectionAddress: AddressSchema,
637
+ query: QueryArgSchema
638
+ });
639
+ var UseCountOfCollectableSchema = BaseSchema.extend({
640
+ filter: collectiblesFilterSchema,
641
+ side: z3.nativeEnum(OrderSide)
642
+ }).or(
643
+ BaseSchema.extend({
644
+ filter: z3.undefined(),
645
+ side: z3.undefined()
646
+ })
647
+ );
648
+ var fetchCountOfCollectables = async (args, config) => {
649
+ const parsedArgs = UseCountOfCollectableSchema.parse(args);
650
+ const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
651
+ if (parsedArgs.filter) {
652
+ return marketplaceClient.getCountOfFilteredCollectibles({
653
+ ...parsedArgs,
654
+ contractAddress: parsedArgs.collectionAddress,
655
+ // biome-ignore lint/style/noNonNullAssertion: safe to assert here, as it's validated
656
+ side: parsedArgs.side
657
+ }).then((resp) => resp.count);
658
+ }
659
+ return marketplaceClient.getCountOfAllCollectibles({
660
+ ...parsedArgs,
661
+ contractAddress: parsedArgs.collectionAddress
662
+ }).then((resp) => resp.count);
663
+ };
664
+ var countOfCollectablesOptions = (args, config) => {
665
+ return queryOptions2({
666
+ ...args.query,
667
+ queryKey: [...collectableKeys.counts, args],
668
+ queryFn: () => fetchCountOfCollectables(args, config)
669
+ });
670
+ };
671
+ var useCountOfCollectables = (args) => {
672
+ const config = useConfig();
673
+ return useQuery2(countOfCollectablesOptions(args, config));
674
+ };
675
+
676
+ // src/react/hooks/useCollectible.tsx
677
+ import { queryOptions as queryOptions3, useQuery as useQuery3 } from "@tanstack/react-query";
678
+ import { z as z4 } from "zod";
679
+ var UseCollectibleSchema = z4.object({
680
+ chainId: ChainIdSchema.pipe(z4.coerce.string()),
681
+ collectionAddress: AddressSchema,
682
+ collectibleId: z4.string(),
683
+ query: QueryArgSchema
684
+ });
685
+ var fetchCollectible = async (args, config) => {
686
+ const parsedArgs = UseCollectibleSchema.parse(args);
687
+ const metadataClient = getMetadataClient(config);
688
+ return metadataClient.getTokenMetadata({
689
+ chainID: parsedArgs.chainId,
690
+ contractAddress: parsedArgs.collectionAddress,
691
+ tokenIDs: [parsedArgs.collectibleId]
692
+ }).then((resp) => resp.tokenMetadata[0]);
693
+ };
694
+ var collectibleOptions = (args, config) => {
695
+ return queryOptions3({
696
+ ...args.query,
697
+ queryKey: [...collectableKeys.details, args, config],
698
+ queryFn: () => fetchCollectible(args, config)
699
+ });
700
+ };
701
+ var useCollectible = (args) => {
702
+ const config = useConfig();
703
+ return useQuery3(collectibleOptions(args, config));
704
+ };
705
+
706
+ // src/react/hooks/useCollection.tsx
707
+ import { queryOptions as queryOptions4, useQuery as useQuery4 } from "@tanstack/react-query";
708
+ import { z as z5 } from "zod";
709
+ var UseCollectionSchema = z5.object({
710
+ chainId: ChainIdSchema.pipe(z5.coerce.string()),
711
+ collectionAddress: AddressSchema,
712
+ query: QueryArgSchema
713
+ });
714
+ var fetchCollection = async (args, config) => {
715
+ const parsedArgs = UseCollectionSchema.parse(args);
716
+ const metadataClient = getMetadataClient(config);
717
+ return metadataClient.getContractInfo({
718
+ chainID: parsedArgs.chainId,
719
+ contractAddress: parsedArgs.collectionAddress
720
+ }).then((resp) => resp.contractInfo);
721
+ };
722
+ var collectionOptions = (args, config) => {
723
+ return queryOptions4({
724
+ ...args.query,
725
+ queryKey: [...collectionKeys.detail, args, config],
726
+ queryFn: () => fetchCollection(args, config)
727
+ });
728
+ };
729
+ var useCollection = (args) => {
730
+ const config = useConfig();
731
+ return useQuery4(collectionOptions(args, config));
732
+ };
733
+
734
+ // src/react/hooks/useCurrencies.tsx
735
+ import { queryOptions as queryOptions5, useQuery as useQuery5 } from "@tanstack/react-query";
736
+ import { z as z6 } from "zod";
737
+ var ChainIdCoerce = ChainIdSchema.transform((val) => val.toString());
738
+ var UseCurrenciesArgsSchema = z6.object({
739
+ chainId: ChainIdCoerce,
740
+ collectionAddress: AddressSchema.optional(),
741
+ includeNativeCurrency: z6.boolean().optional(),
742
+ query: QueryArgSchema
743
+ });
744
+ var fetchCurrencies = async (chainId, config) => {
745
+ const parsedChainId = ChainIdCoerce.parse(chainId);
746
+ const marketplaceClient = getMarketplaceClient(parsedChainId, config);
747
+ return marketplaceClient.listCurrencies().then((resp) => resp.currencies);
748
+ };
749
+ var selectCurrencies = (data, args) => {
750
+ const argsParsed = UseCurrenciesArgsSchema.parse(args);
751
+ if (argsParsed.collectionAddress) {
752
+ const queryClient = getQueryClient();
753
+ const marketplaceConfigCache = queryClient.getQueriesData({
754
+ queryKey: configKeys.marketplace
755
+ })[0][1];
756
+ const collection = marketplaceConfigCache?.collections.find(
757
+ (collection2) => collection2.collectionAddress === argsParsed.collectionAddress
758
+ );
759
+ if (!collection) {
760
+ throw new Error("Collection doesn't exist");
761
+ }
762
+ return data.filter(
763
+ (currency) => collection.currencyOptions?.includes(currency.contractAddress) || // biome-ignore lint/suspicious/noDoubleEquals: <explanation>
764
+ currency.nativeCurrency == argsParsed.includeNativeCurrency || currency.defaultChainCurrency
765
+ );
766
+ }
767
+ if (argsParsed.includeNativeCurrency) {
768
+ return data;
769
+ }
770
+ return data.filter((currency) => !currency.nativeCurrency);
771
+ };
772
+ var currenciesOptions = (args, config) => {
773
+ return queryOptions5({
774
+ ...args.query,
775
+ queryKey: [...currencyKeys.lists, args.chainId],
776
+ queryFn: () => fetchCurrencies(args.chainId, config),
777
+ select: (data) => selectCurrencies(data, args),
778
+ enabled: args.query?.enabled
779
+ });
780
+ };
781
+ var useCurrencies = (args) => {
782
+ const config = useConfig();
783
+ return useQuery5(currenciesOptions(args, config));
784
+ };
785
+
786
+ // src/react/hooks/useFilters.tsx
787
+ import { queryOptions as queryOptions6, useQuery as useQuery6 } from "@tanstack/react-query";
788
+ import { z as z7 } from "zod";
789
+ var UseFiltersSchema = z7.object({
790
+ chainId: ChainIdSchema.pipe(z7.coerce.string()),
791
+ collectionAddress: AddressSchema,
792
+ query: QueryArgSchema
793
+ });
794
+ var fetchFilters = async (args, config) => {
795
+ const parsedArgs = UseFiltersSchema.parse(args);
796
+ const metadataClient = getMetadataClient(config);
797
+ return metadataClient.tokenCollectionFilters({
798
+ chainID: parsedArgs.chainId,
799
+ contractAddress: parsedArgs.collectionAddress
800
+ }).then((resp) => resp.filters);
801
+ };
802
+ var filtersOptions = (args, config) => {
803
+ return queryOptions6({
804
+ ...args.query,
805
+ queryKey: [...collectableKeys.filter, args, config],
806
+ queryFn: () => fetchFilters(args, config)
807
+ });
808
+ };
809
+ var useFilters = (args) => {
810
+ const config = useConfig();
811
+ return useQuery6(filtersOptions(args, config));
812
+ };
813
+
814
+ // src/react/hooks/useFloorOrder.tsx
815
+ import { queryOptions as queryOptions7, useQuery as useQuery7 } from "@tanstack/react-query";
816
+ import { z as z8 } from "zod";
817
+ var UseFloorOrderSchema = z8.object({
818
+ chainId: ChainIdSchema.pipe(z8.coerce.string()),
819
+ collectionAddress: AddressSchema,
820
+ query: QueryArgSchema
821
+ });
822
+ var fetchFloorOrder = async (args, config) => {
823
+ const marketplaceClient = getMarketplaceClient(args.chainId, config);
824
+ return marketplaceClient.getFloorOrder({ contractAddress: args.collectionAddress }).then((data) => data.collectible);
825
+ };
826
+ var floorOrderOptions = (args, config) => {
827
+ return queryOptions7({
828
+ queryKey: [...collectableKeys.floorOrders, args, config],
829
+ queryFn: () => fetchFloorOrder(args, config)
830
+ });
831
+ };
832
+ var useFloorOrder = (args) => {
833
+ const config = useConfig();
834
+ return useQuery7(floorOrderOptions(args, config));
835
+ };
836
+
837
+ // src/react/hooks/useHighestOffer.tsx
838
+ import { queryOptions as queryOptions8, useQuery as useQuery8 } from "@tanstack/react-query";
839
+ import { z as z9 } from "zod";
840
+ var UseHighestOfferArgsSchema = getCollectibleHighestOfferArgsSchema.omit({
841
+ contractAddress: true
842
+ }).extend({
843
+ collectionAddress: AddressSchema,
844
+ chainId: ChainIdSchema.pipe(z9.coerce.string()),
845
+ query: QueryArgSchema
846
+ });
847
+ var fetchHighestOffer = async (args, config) => {
848
+ const parsedArgs = UseHighestOfferArgsSchema.parse(args);
849
+ const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
850
+ return marketplaceClient.getCollectibleHighestOffer({
851
+ ...parsedArgs,
852
+ contractAddress: parsedArgs.collectionAddress
853
+ });
854
+ };
855
+ var highestOfferOptions = (args, config) => {
856
+ return queryOptions8({
857
+ ...args.query,
858
+ queryKey: [...collectableKeys.highestOffers, args, config],
859
+ queryFn: () => fetchHighestOffer(args, config)
860
+ });
861
+ };
862
+ var useHighestOffer = (args) => {
863
+ const config = useConfig();
864
+ return useQuery8(highestOfferOptions(args, config));
865
+ };
866
+
867
+ // src/react/hooks/useListBalances.tsx
868
+ import { SortOrder as SortOrder2 } from "@0xsequence/indexer";
869
+ import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
870
+ import { z as z10 } from "zod";
871
+ var metadataOptionsSchema = z10.object({
872
+ verifiedOnly: z10.boolean().optional(),
873
+ unverifiedOnly: z10.boolean().optional(),
874
+ includeContracts: z10.array(z10.string()).optional()
875
+ });
876
+ var sortOrderSchema2 = z10.nativeEnum(SortOrder2);
877
+ var sortBySchema2 = z10.object({
878
+ column: z10.string(),
879
+ order: sortOrderSchema2
880
+ });
881
+ var pageSchema2 = z10.object({
882
+ page: z10.number().optional(),
883
+ column: z10.string().optional(),
884
+ before: z10.any().optional(),
885
+ after: z10.any().optional(),
886
+ sort: z10.array(sortBySchema2).optional(),
887
+ pageSize: z10.number().optional(),
888
+ more: z10.boolean().optional()
889
+ });
890
+ var useListBalancesArgsSchema = z10.object({
891
+ chainId: ChainIdSchema.pipe(z10.coerce.number()),
892
+ accountAddress: AddressSchema.optional(),
893
+ contractAddress: AddressSchema.optional(),
894
+ tokenId: z10.string().optional(),
895
+ includeMetadata: z10.boolean().optional(),
896
+ metadataOptions: metadataOptionsSchema.optional(),
897
+ includeCollectionTokens: z10.boolean().optional(),
898
+ page: pageSchema2.optional(),
899
+ query: QueryArgSchema
900
+ });
901
+ var fetchBalances = async (args, page, config) => {
902
+ const parsedArgs = useListBalancesArgsSchema.parse(args);
903
+ const indexerClient = getIndexerClient(parsedArgs.chainId, config);
904
+ return indexerClient.getTokenBalances({
905
+ ...parsedArgs,
906
+ tokenID: parsedArgs.tokenId,
907
+ page
908
+ });
909
+ };
910
+ var listBalancesOptions = (args, config) => {
911
+ return infiniteQueryOptions({
912
+ ...args.query,
913
+ queryKey: [...balanceQueries.lists, args, config],
914
+ queryFn: ({ pageParam }) => fetchBalances(args, pageParam, config),
915
+ initialPageParam: { page: 1, pageSize: 30 },
916
+ getNextPageParam: (lastPage) => lastPage.page.after
917
+ });
918
+ };
919
+ var useListBalances = (args) => {
920
+ const config = useConfig();
921
+ return useInfiniteQuery(listBalancesOptions(args, config));
922
+ };
923
+
924
+ // src/react/hooks/useListCollectibles.tsx
925
+ import { infiniteQueryOptions as infiniteQueryOptions2, useInfiniteQuery as useInfiniteQuery2 } from "@tanstack/react-query";
926
+ import { z as z11 } from "zod";
927
+ var UseListCollectiblesArgsSchema = listCollectiblesArgsSchema.omit({
928
+ contractAddress: true
929
+ }).extend({
930
+ collectionAddress: AddressSchema,
931
+ chainId: ChainIdSchema.pipe(z11.coerce.string()),
932
+ query: QueryArgSchema
933
+ });
934
+ var fetchCollectibles = async (args, page, marketplaceClient) => {
935
+ const parsedArgs = UseListCollectiblesArgsSchema.parse(args);
936
+ const arg = {
937
+ ...parsedArgs,
938
+ contractAddress: parsedArgs.collectionAddress,
939
+ page
940
+ };
941
+ return marketplaceClient.listCollectibles(arg);
942
+ };
943
+ var listCollectiblesOptions = (args, config) => {
944
+ const marketplaceClient = getMarketplaceClient(args.chainId, config);
945
+ return infiniteQueryOptions2({
946
+ queryKey: [...collectableKeys.lists, args, marketplaceClient],
947
+ queryFn: ({ pageParam }) => fetchCollectibles(args, pageParam, marketplaceClient),
948
+ initialPageParam: { page: 1, pageSize: 30 },
949
+ getNextPageParam: (lastPage) => lastPage.page?.more ? lastPage.page : void 0
950
+ });
951
+ };
952
+ var useListCollectibles = (args) => {
953
+ const config = useConfig();
954
+ return useInfiniteQuery2(listCollectiblesOptions(args, config));
955
+ };
956
+
957
+ // src/react/hooks/useListOffersForCollectible.tsx
958
+ import { infiniteQueryOptions as infiniteQueryOptions3, useInfiniteQuery as useInfiniteQuery3 } from "@tanstack/react-query";
959
+ import { z as z12 } from "zod";
960
+ var UseListOffersForCollectibleArgsSchema = listOffersForCollectibleArgsSchema.extend({
961
+ chainId: ChainIdSchema.pipe(z12.coerce.string())
962
+ });
963
+ var fetchListOffersForCollectible = async (config, args, page) => {
964
+ const arg = {
965
+ contractAddress: args.contractAddress,
966
+ tokenId: args.tokenId,
967
+ filter: args.filter,
968
+ page
969
+ };
970
+ const marketplaceClient = getMarketplaceClient(args.chainId, config);
971
+ return marketplaceClient.listCollectibleOffers(arg);
972
+ };
973
+ var listOffersForCollectibleOptions = (args, config) => {
974
+ return infiniteQueryOptions3({
975
+ queryKey: [...collectableKeys.offers, args, config],
976
+ queryFn: ({ pageParam }) => fetchListOffersForCollectible(config, args, pageParam),
977
+ initialPageParam: { page: 1, pageSize: 30 },
978
+ getNextPageParam: (lastPage) => lastPage.page?.more ? lastPage.page : void 0
979
+ });
980
+ };
981
+ var useListOffersForCollectible = (args) => {
982
+ const config = useConfig();
983
+ return useInfiniteQuery3(listOffersForCollectibleOptions(args, config));
984
+ };
985
+
986
+ // src/react/hooks/useLowestListing.tsx
987
+ import { queryOptions as queryOptions9, useQuery as useQuery9 } from "@tanstack/react-query";
988
+ import { z as z13 } from "zod";
989
+ var UseLowestListingSchema = getCollectibleLowestListingArgsSchema.omit({
990
+ contractAddress: true
991
+ }).extend({
992
+ collectionAddress: AddressSchema,
993
+ chainId: ChainIdSchema.pipe(z13.coerce.string()),
994
+ query: QueryArgSchema
995
+ });
996
+ var fetchLowestListing = async (args, config) => {
997
+ const parsedArgs = UseLowestListingSchema.parse(args);
998
+ const marketplaceClient = getMarketplaceClient(parsedArgs.chainId, config);
999
+ return marketplaceClient.getCollectibleLowestListing({
1000
+ ...parsedArgs,
1001
+ contractAddress: parsedArgs.collectionAddress
1002
+ });
1003
+ };
1004
+ var lowestListingOptions = (args, config) => {
1005
+ return queryOptions9({
1006
+ ...args.query,
1007
+ queryKey: [...collectableKeys.lowestListings, args, config],
1008
+ queryFn: () => fetchLowestListing(args, config)
1009
+ });
1010
+ };
1011
+ var useLowestListing = (args) => {
1012
+ const config = useConfig();
1013
+ return useQuery9(lowestListingOptions(args, config));
1014
+ };
1015
+
1016
+ // src/react/hooks/useMarketplaceConfig.tsx
1017
+ import { useQuery as useQuery10 } from "@tanstack/react-query";
1018
+
1019
+ // src/react/hooks/options/marketplaceConfigOptions.ts
1020
+ import { queryOptions as queryOptions10 } from "@tanstack/react-query";
1021
+ var fetchBuilderConfig = async (projectId, env) => {
1022
+ const url = `${builderMarketplaceApi(projectId, env)}`;
1023
+ const response = await fetch(`${url}/config.json`);
1024
+ const json = await response.json();
1025
+ if (!response.ok) {
1026
+ console.error("Failed to fetch marketplace config:", response.status, json);
1027
+ switch (json.code) {
1028
+ case 3e3:
1029
+ throw new Error(`Project id: ${projectId} not found, ${url}`);
1030
+ default:
1031
+ throw new Error(`Failed to fetch marketplace config: ${json.msg}`);
1032
+ }
1033
+ }
1034
+ return json;
1035
+ };
1036
+ var fetchStyles = async (projectId, env) => {
1037
+ const response = await fetch(
1038
+ `${builderMarketplaceApi(projectId, env)}/styles.css`
1039
+ );
1040
+ const styles = await response.text();
1041
+ return styles.replaceAll(/['"]/g, "");
1042
+ };
1043
+ var fetchMarketplaceConfig = async (env, projectId) => {
1044
+ const [marketplaceConfig, cssString] = await Promise.all([
1045
+ fetchBuilderConfig(projectId, env),
1046
+ fetchStyles(projectId, env)
1047
+ ]);
1048
+ return {
1049
+ ...marketplaceConfig,
1050
+ cssString,
1051
+ manifestUrl: `${builderMarketplaceApi(projectId, env)}/manifest.json`
1052
+ };
1053
+ };
1054
+ var marketplaceConfigOptions = (config) => {
1055
+ let env = "production";
1056
+ if ("_internal" in config && config._internal !== void 0) {
1057
+ env = config._internal.builderEnv ?? env;
1058
+ }
1059
+ const projectId = config.projectId;
1060
+ return queryOptions10({
1061
+ queryKey: [...configKeys.marketplace, env, projectId],
1062
+ queryFn: () => fetchMarketplaceConfig(env, projectId)
1063
+ });
1064
+ };
1065
+
1066
+ // src/react/hooks/useMarketplaceConfig.tsx
1067
+ var useMarketplaceConfig = () => {
1068
+ const config = useConfig();
1069
+ return useQuery10(marketplaceConfigOptions(config));
1070
+ };
1071
+
1072
+ // src/react/hooks/useRoyaltyPercentage.tsx
1073
+ import { queryOptions as queryOptions11, useQuery as useQuery11 } from "@tanstack/react-query";
1074
+ import { getContract } from "viem";
1075
+ import { z as z14 } from "zod";
1076
+ var UseRoyaletyPercentageSchema = z14.object({
1077
+ chainId: ChainIdSchema.pipe(z14.coerce.string()),
1078
+ collectionAddress: AddressSchema,
1079
+ collectibleId: z14.string(),
1080
+ query: QueryArgSchema
1081
+ });
1082
+ var fetchRoyaletyPercentage = async (args) => {
1083
+ const parsedArgs = UseRoyaletyPercentageSchema.parse(args);
1084
+ const publicClient = getPublicRpcClient(parsedArgs.chainId);
1085
+ const contract = getContract({
1086
+ address: parsedArgs.collectionAddress,
1087
+ abi: EIP2981_ABI,
1088
+ client: publicClient
1089
+ });
1090
+ try {
1091
+ const [_, royaltyPercentage] = await contract.read.royaltyInfo([
1092
+ BigInt(args.collectibleId),
1093
+ 100n
1094
+ ]);
1095
+ return royaltyPercentage;
1096
+ } catch {
1097
+ return 0n;
1098
+ }
1099
+ };
1100
+ var royaletyPercentageOptions = (args) => queryOptions11({
1101
+ ...args.query,
1102
+ queryKey: [...collectableKeys.royaltyPercentage, args],
1103
+ queryFn: () => fetchRoyaletyPercentage(args)
1104
+ });
1105
+ var useRoyaltyPercentage = (args) => {
1106
+ return useQuery11(royaletyPercentageOptions(args));
1107
+ };
1108
+
1109
+ // src/react/hooks/useGenerateListingTransaction.tsx
1110
+ import { useMutation } from "@tanstack/react-query";
1111
+ var dateToUnixTime = (date) => Math.floor(date.getTime() / 1e3).toString();
1112
+ var generateListingTransaction = async (params, config, chainId) => {
1113
+ const args = {
1114
+ ...params,
1115
+ listing: {
1116
+ ...params.listing,
1117
+ expiry: dateToUnixTime(params.listing.expiry)
1118
+ }
1119
+ };
1120
+ const marketplaceClient = getMarketplaceClient(chainId, config);
1121
+ return (await marketplaceClient.generateListingTransaction(args)).steps;
1122
+ };
1123
+ var useGenerateListingTransaction = (params) => {
1124
+ const config = useConfig();
1125
+ const { mutate, mutateAsync, ...result } = useMutation({
1126
+ onSuccess: params.onSuccess,
1127
+ mutationFn: (args) => generateListingTransaction(args, config, params.chainId)
1128
+ });
1129
+ return {
1130
+ ...result,
1131
+ generateListingTransaction: mutate,
1132
+ generateListingTransactionAsync: mutateAsync
1133
+ };
1134
+ };
1135
+
1136
+ // src/react/hooks/useGenerateOfferTransaction.tsx
1137
+ import { useMutation as useMutation2 } from "@tanstack/react-query";
1138
+ var dateToUnixTime2 = (date) => Math.floor(date.getTime() / 1e3).toString();
1139
+ var generateOfferTransaction = async (params, config, chainId) => {
1140
+ const args = {
1141
+ ...params,
1142
+ offer: { ...params.offer, expiry: dateToUnixTime2(params.offer.expiry) }
1143
+ };
1144
+ const marketplaceClient = getMarketplaceClient(chainId, config);
1145
+ return (await marketplaceClient.generateOfferTransaction(args)).steps;
1146
+ };
1147
+ var useGenerateOfferTransaction = (params) => {
1148
+ const config = useConfig();
1149
+ const { mutate, mutateAsync, ...result } = useMutation2({
1150
+ onSuccess: params.onSuccess,
1151
+ mutationFn: (args) => generateOfferTransaction(args, config, params.chainId)
1152
+ });
1153
+ return {
1154
+ ...result,
1155
+ generateOfferTransaction: mutate,
1156
+ generateOfferTransactionAsync: mutateAsync
1157
+ };
1158
+ };
1159
+
1160
+ // src/react/hooks/useGenerateSellTransaction.tsx
1161
+ import { useMutation as useMutation3 } from "@tanstack/react-query";
1162
+ import { z as z15 } from "zod";
1163
+ var UserGeneratSellTransactionArgsSchema = z15.object({
1164
+ chainId: ChainIdSchema.pipe(z15.coerce.string()),
1165
+ onSuccess: z15.function().args(stepSchema.array().optional()).optional()
1166
+ });
1167
+ var generateSellTransaction = async (args, config, chainId) => {
1168
+ const parsedChainId = ChainIdSchema.pipe(z15.coerce.string()).parse(chainId);
1169
+ const marketplaceClient = getMarketplaceClient(parsedChainId, config);
1170
+ return marketplaceClient.generateSellTransaction(args).then((data) => data.steps);
1171
+ };
1172
+ var useGenerateSellTransaction = (params) => {
1173
+ const config = useConfig();
1174
+ const { mutate, mutateAsync, ...result } = useMutation3({
1175
+ onSuccess: params.onSuccess,
1176
+ mutationFn: (args) => generateSellTransaction(args, config, params.chainId)
1177
+ });
1178
+ return {
1179
+ ...result,
1180
+ generateSellTransaction: mutate,
1181
+ generateSellTransactionAsync: mutateAsync
1182
+ };
1183
+ };
1184
+
1185
+ // src/react/hooks/useTransferTokens.tsx
1186
+ import { erc721Abi } from "viem";
1187
+ import { useAccount, useWriteContract } from "wagmi";
1188
+ var prepareTransferConfig = (params, accountAddress) => {
1189
+ if (params.contractType === "ERC721") {
1190
+ return {
1191
+ abi: erc721Abi,
1192
+ address: params.collectionAddress,
1193
+ functionName: "safeTransferFrom",
1194
+ args: [
1195
+ accountAddress,
1196
+ params.receiverAddress,
1197
+ BigInt(params.tokenId)
1198
+ ]
1199
+ };
1200
+ }
1201
+ return {
1202
+ abi: ERC1155_ABI,
1203
+ address: params.collectionAddress,
1204
+ functionName: "safeTransferFrom",
1205
+ args: [
1206
+ accountAddress,
1207
+ params.receiverAddress,
1208
+ BigInt(params.tokenId),
1209
+ params.quantity,
1210
+ "0x"
1211
+ // data
1212
+ ]
1213
+ };
1214
+ };
1215
+ var useTransferTokens = () => {
1216
+ const { address: accountAddress } = useAccount();
1217
+ const {
1218
+ writeContractAsync,
1219
+ data: hash,
1220
+ isPending,
1221
+ isError,
1222
+ isSuccess
1223
+ } = useWriteContract();
1224
+ const transferTokensAsync = async (params) => {
1225
+ if (!accountAddress) {
1226
+ throw new Error("No wallet connected");
1227
+ }
1228
+ const config = prepareTransferConfig(params, accountAddress);
1229
+ return await writeContractAsync(config);
1230
+ };
1231
+ return {
1232
+ transferTokensAsync,
1233
+ hash,
1234
+ transferring: isPending,
1235
+ transferFailed: isError,
1236
+ transferSuccess: isSuccess
1237
+ };
1238
+ };
1239
+
1240
+ // src/react/hooks/useCheckoutOptions.tsx
1241
+ import { queryOptions as queryOptions12, useQuery as useQuery12 } from "@tanstack/react-query";
1242
+ import { z as z16 } from "zod";
1243
+ var UseCheckoutOptionsSchema = z16.object({
1244
+ chainId: ChainIdSchema.pipe(z16.coerce.string()),
1245
+ walletAddress: AddressSchema,
1246
+ orders: z16.array(
1247
+ z16.object({
1248
+ collectionAddress: AddressSchema,
1249
+ orderId: z16.string(),
1250
+ quantity: z16.number(),
1251
+ marketplace: z16.nativeEnum(MarketplaceKind)
1252
+ })
1253
+ ),
1254
+ query: QueryArgSchema
1255
+ });
1256
+ var fetchCheckoutOptions = async (args, config) => {
1257
+ const marketplaceClient = getMarketplaceClient(args.chainId, config);
1258
+ return marketplaceClient.checkoutOptionsMarketplace({
1259
+ wallet: args.walletAddress,
1260
+ orders: args.orders.map((order) => ({
1261
+ contractAddress: order.collectionAddress,
1262
+ orderId: order.orderId,
1263
+ marketplace: order.marketplace,
1264
+ quantity: order.quantity
1265
+ })),
1266
+ additionalFee: 0
1267
+ //TODO: add additional fee
1268
+ });
1269
+ };
1270
+ var checkoutOptionsOptions = (args, config) => {
1271
+ return queryOptions12({
1272
+ queryKey: ["checkoutOptions", args],
1273
+ queryFn: () => fetchCheckoutOptions(args, config)
1274
+ });
1275
+ };
1276
+ var useCheckoutOptions = (args) => {
1277
+ const config = useConfig();
1278
+ return useQuery12(checkoutOptionsOptions(args, config));
1279
+ };
1280
+
1281
+ export {
1282
+ MarketplaceSdkContext,
1283
+ MarketplaceProvider,
1284
+ useConfig,
1285
+ balanceOfCollectibleOptions,
1286
+ useBalanceOfCollectible,
1287
+ countOfCollectablesOptions,
1288
+ useCountOfCollectables,
1289
+ collectibleOptions,
1290
+ useCollectible,
1291
+ collectionOptions,
1292
+ useCollection,
1293
+ currenciesOptions,
1294
+ useCurrencies,
1295
+ fetchFilters,
1296
+ filtersOptions,
1297
+ useFilters,
1298
+ floorOrderOptions,
1299
+ useFloorOrder,
1300
+ highestOfferOptions,
1301
+ useHighestOffer,
1302
+ metadataOptionsSchema,
1303
+ listBalancesOptions,
1304
+ useListBalances,
1305
+ listCollectiblesOptions,
1306
+ useListCollectibles,
1307
+ listOffersForCollectibleOptions,
1308
+ useListOffersForCollectible,
1309
+ lowestListingOptions,
1310
+ useLowestListing,
1311
+ marketplaceConfigOptions,
1312
+ useMarketplaceConfig,
1313
+ royaletyPercentageOptions,
1314
+ useRoyaltyPercentage,
1315
+ generateListingTransaction,
1316
+ useGenerateListingTransaction,
1317
+ generateOfferTransaction,
1318
+ useGenerateOfferTransaction,
1319
+ generateSellTransaction,
1320
+ useGenerateSellTransaction,
1321
+ useTransferTokens,
1322
+ checkoutOptionsOptions,
1323
+ useCheckoutOptions
1324
+ };
1325
+ //# sourceMappingURL=chunk-5EOVZAKT.js.map