@0xsequence/marketplace-sdk 0.8.9 → 0.8.11

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 (196) hide show
  1. package/.changeset/fluffy-jokes-lay.md +5 -0
  2. package/.changeset/wise-bugs-boil.md +8 -0
  3. package/CHANGELOG.md +43 -0
  4. package/dist/{chunk-FMEEJFAF.js → chunk-5C6ZZ6WX.js} +1 -1
  5. package/dist/{chunk-YEGD7PWE.js → chunk-5O44EPXZ.js} +2 -2
  6. package/dist/chunk-6CTFVBKU.js +1 -0
  7. package/dist/{chunk-DWTLVJAW.js → chunk-6OPMUCGX.js} +1 -1
  8. package/dist/chunk-6OPMUCGX.js.map +1 -0
  9. package/dist/{chunk-O34GCB47.js → chunk-L6KWLCER.js} +4 -4
  10. package/dist/chunk-L6KWLCER.js.map +1 -0
  11. package/dist/{chunk-4XLXOEXQ.js → chunk-LAP2CKLN.js} +78 -4
  12. package/dist/chunk-LAP2CKLN.js.map +1 -0
  13. package/dist/{chunk-Y63BOO6M.js → chunk-LECCEZAO.js} +1 -1
  14. package/dist/{chunk-YALXP2PW.js → chunk-N7SQWS2R.js} +3 -3
  15. package/dist/{chunk-KGM2WLSP.js → chunk-OAOONM4S.js} +695 -440
  16. package/dist/chunk-OAOONM4S.js.map +1 -0
  17. package/dist/chunk-Q3ECVC4F.js +811 -0
  18. package/dist/chunk-Q3ECVC4F.js.map +1 -0
  19. package/dist/chunk-QY52UADF.js +107 -0
  20. package/dist/chunk-QY52UADF.js.map +1 -0
  21. package/dist/{chunk-I2BYHDFE.js → chunk-TNAR3XEF.js} +3898 -844
  22. package/dist/chunk-TNAR3XEF.js.map +1 -0
  23. package/dist/chunk-XABYNWXO.js +549 -0
  24. package/dist/chunk-XABYNWXO.js.map +1 -0
  25. package/dist/chunk-YB5UUF2G.js +11 -0
  26. package/dist/chunk-YB5UUF2G.js.map +1 -0
  27. package/dist/{chunk-35WWD5V6.js → chunk-YWGFI4PN.js} +88 -25
  28. package/dist/chunk-YWGFI4PN.js.map +1 -0
  29. package/dist/{create-config-DwrnzwpM.d.ts → create-config-DLMvMTkZ.d.ts} +2 -2
  30. package/dist/index.css +7 -7
  31. package/dist/index.css.map +1 -1
  32. package/dist/index.d.ts +8 -6
  33. package/dist/index.js +19 -14
  34. package/dist/{lowestListing-BQHIuvNF.d.ts → marketCurrencies-enNVYwBk.d.ts} +95 -3
  35. package/dist/{marketplace.gen-DQzWciwC.d.ts → marketplace.gen-D24veUQs.d.ts} +3 -2
  36. package/dist/marketplaceConfig-BwNAbLPw.d.ts +21 -0
  37. package/dist/new-marketplace-types-BCw19X9S.d.ts +102 -0
  38. package/dist/react/_internal/api/index.d.ts +4 -3
  39. package/dist/react/_internal/api/index.js +5 -1
  40. package/dist/react/_internal/databeat/index.css +2764 -0
  41. package/dist/react/_internal/databeat/index.css.map +1 -0
  42. package/dist/react/_internal/databeat/index.d.ts +1 -1
  43. package/dist/react/_internal/databeat/index.js +15 -14
  44. package/dist/react/_internal/index.d.ts +62 -9
  45. package/dist/react/_internal/index.js +7 -3
  46. package/dist/react/_internal/wagmi/index.d.ts +5 -6
  47. package/dist/react/_internal/wagmi/index.js +1 -1
  48. package/dist/react/hooks/index.css +2764 -0
  49. package/dist/react/hooks/index.css.map +1 -0
  50. package/dist/react/hooks/index.d.ts +74 -222
  51. package/dist/react/hooks/index.js +21 -22
  52. package/dist/react/hooks/options/index.d.ts +5 -4
  53. package/dist/react/hooks/options/index.js +9 -7
  54. package/dist/react/index.css +7 -7
  55. package/dist/react/index.css.map +1 -1
  56. package/dist/react/index.d.ts +12 -11
  57. package/dist/react/index.js +34 -37
  58. package/dist/react/queries/index.d.ts +4 -3
  59. package/dist/react/queries/index.js +19 -6
  60. package/dist/react/ssr/index.d.ts +3 -3
  61. package/dist/react/ssr/index.js +6 -5
  62. package/dist/react/ssr/index.js.map +1 -1
  63. package/dist/react/ui/components/collectible-card/index.css +7 -7
  64. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  65. package/dist/react/ui/components/collectible-card/index.d.ts +9 -6
  66. package/dist/react/ui/components/collectible-card/index.js +19 -23
  67. package/dist/react/ui/components/marketplace-logos/index.js +1 -1
  68. package/dist/react/ui/icons/index.js +9 -8
  69. package/dist/react/ui/index.css +7 -7
  70. package/dist/react/ui/index.css.map +1 -1
  71. package/dist/react/ui/index.d.ts +2 -2
  72. package/dist/react/ui/index.js +17 -21
  73. package/dist/react/ui/modals/_internal/components/actionModal/index.css +2764 -0
  74. package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -0
  75. package/dist/react/ui/modals/_internal/components/actionModal/index.js +15 -14
  76. package/dist/sdk-config-qorA0TgF.d.ts +165 -0
  77. package/dist/{services-BI_w8Eq4.d.ts → services-WrshxCqc.d.ts} +6 -3
  78. package/dist/types/index.d.ts +5 -4
  79. package/dist/types/index.js +7 -7
  80. package/dist/{index-DGsVBflk.d.ts → useCollection-YAdXfVO7.d.ts} +1 -2
  81. package/dist/utils/abi/index.d.ts +1 -0
  82. package/dist/utils/abi/index.js +7 -1
  83. package/dist/utils/abi/primary-sale/index.d.ts +1054 -0
  84. package/dist/utils/abi/primary-sale/index.js +9 -0
  85. package/dist/utils/index.d.ts +2 -1
  86. package/dist/utils/index.js +13 -6
  87. package/package.json +32 -32
  88. package/src/react/_internal/api/__mocks__/builder.msw.ts +157 -80
  89. package/src/react/_internal/api/builder-api.ts +2 -2
  90. package/src/react/_internal/api/builder.gen.ts +667 -112
  91. package/src/react/_internal/api/marketplace.gen.ts +1981 -1316
  92. package/src/react/_internal/api/services.ts +12 -1
  93. package/src/react/_internal/types.ts +1 -13
  94. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +99 -84
  95. package/src/react/_internal/wagmi/create-config.ts +8 -4
  96. package/src/react/_internal/wagmi/get-connectors.ts +24 -19
  97. package/src/react/hooks/__tests__/__snapshots__/useListCollections.test.tsx.snap +114 -0
  98. package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +85 -83
  99. package/src/react/hooks/__tests__/useFilters.test.tsx +0 -16
  100. package/src/react/hooks/__tests__/useInventory.test.tsx +16 -16
  101. package/src/react/hooks/__tests__/useListCollections.test.tsx +23 -56
  102. package/src/react/hooks/__tests__/{useCurrencies.test.tsx → useMarketCurrencies.test.tsx} +21 -15
  103. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +2 -59
  104. package/src/react/hooks/index.ts +3 -1
  105. package/src/react/hooks/useBalanceOfCollectible.tsx +5 -3
  106. package/src/react/hooks/useConvertPriceToUSD.tsx +1 -1
  107. package/src/react/hooks/useFilters.tsx +14 -22
  108. package/src/react/hooks/useGetTokenSuppliesMap.ts +28 -0
  109. package/src/react/hooks/useInventory.tsx +4 -3
  110. package/src/react/hooks/useList1155SaleSupplies.tsx +62 -0
  111. package/src/react/hooks/useListBalances.tsx +5 -3
  112. package/src/react/hooks/useListCollectibles.tsx +5 -3
  113. package/src/react/hooks/useListCollections.tsx +14 -76
  114. package/src/react/hooks/useListTokenMetadata.ts +19 -0
  115. package/src/react/hooks/useMarketCurrencies.tsx +8 -0
  116. package/src/react/hooks/useMarketplaceConfig.tsx +0 -2
  117. package/src/react/queries/index.ts +2 -0
  118. package/src/react/queries/inventory.ts +1 -1
  119. package/src/react/queries/listCollections.ts +118 -0
  120. package/src/react/queries/listTokenMetadata.ts +38 -0
  121. package/src/react/queries/marketCurrencies.ts +77 -0
  122. package/src/react/queries/marketplaceConfig.ts +83 -55
  123. package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +85 -83
  124. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -2
  125. package/src/react/ui/components/collectible-card/__tests__/{CollectibleAsset.test.tsx → Media.test.tsx} +48 -14
  126. package/src/react/ui/components/collectible-card/index.ts +1 -1
  127. package/src/react/ui/components/collectible-card/media/Media.tsx +211 -0
  128. package/src/react/ui/components/collectible-card/{collectible-asset/CollectibleAssetSkeleton.tsx → media/MediaSkeleton.tsx} +2 -2
  129. package/src/react/ui/components/collectible-card/media/types.ts +18 -0
  130. package/src/react/ui/components/collectible-card/{collectible-asset → media}/utils.ts +8 -3
  131. package/src/react/ui/index.ts +1 -1
  132. package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +9 -3
  133. package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +31 -21
  134. package/src/react/ui/modals/BuyModal/hooks/useFees.ts +3 -2
  135. package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +28 -3
  136. package/src/react/ui/modals/CreateListingModal/Modal.tsx +3 -5
  137. package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +5 -3
  138. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +2 -2
  139. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +2 -3
  140. package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +4 -3
  141. package/src/react/ui/modals/SellModal/Modal.tsx +0 -1
  142. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +2 -2
  143. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +1 -1
  144. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +0 -1
  145. package/src/react/ui/modals/TransferModal/index.tsx +0 -1
  146. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +2 -2
  147. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +7 -6
  148. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +13 -7
  149. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +3 -5
  150. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +5 -3
  151. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +2 -2
  152. package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +2 -12
  153. package/src/types/index.ts +1 -6
  154. package/src/types/new-marketplace-types.ts +119 -0
  155. package/src/types/sdk-config.ts +19 -2
  156. package/src/types/types.ts +1 -0
  157. package/src/utils/abi/index.ts +1 -0
  158. package/src/utils/abi/primary-sale/index.ts +2 -0
  159. package/src/utils/abi/primary-sale/sequence-1155-sales-contract.ts +450 -0
  160. package/src/utils/abi/primary-sale/sequence-721-sales-contract.ts +352 -0
  161. package/src/utils/abi/token/sequence-erc1155-items.ts +454 -0
  162. package/src/utils/fetchContentType.ts +5 -1
  163. package/tsconfig.tsbuildinfo +1 -1
  164. package/dist/chunk-35WWD5V6.js.map +0 -1
  165. package/dist/chunk-4XLXOEXQ.js.map +0 -1
  166. package/dist/chunk-D7RVSZAQ.js +0 -332
  167. package/dist/chunk-D7RVSZAQ.js.map +0 -1
  168. package/dist/chunk-DWTLVJAW.js.map +0 -1
  169. package/dist/chunk-EODKQL6Y.js +0 -76
  170. package/dist/chunk-EODKQL6Y.js.map +0 -1
  171. package/dist/chunk-G3447GIP.js +0 -2880
  172. package/dist/chunk-G3447GIP.js.map +0 -1
  173. package/dist/chunk-HHYNOPPI.js +0 -53
  174. package/dist/chunk-HHYNOPPI.js.map +0 -1
  175. package/dist/chunk-I2BYHDFE.js.map +0 -1
  176. package/dist/chunk-JKCF7HEA.js +0 -1
  177. package/dist/chunk-KGM2WLSP.js.map +0 -1
  178. package/dist/chunk-MAD64DLJ.js +0 -81
  179. package/dist/chunk-MAD64DLJ.js.map +0 -1
  180. package/dist/chunk-N7BPFK46.js +0 -1
  181. package/dist/chunk-O34GCB47.js.map +0 -1
  182. package/dist/chunk-UISBTKFF.js +0 -1
  183. package/dist/chunk-UISBTKFF.js.map +0 -1
  184. package/dist/chunk-YBOFRP65.js +0 -128
  185. package/dist/chunk-YBOFRP65.js.map +0 -1
  186. package/dist/marketplaceConfig-B4Fdsmxu.d.ts +0 -17
  187. package/dist/sdk-config-txlivEKe.d.ts +0 -133
  188. package/dist/types-isjvwapz.d.ts +0 -68
  189. package/src/react/hooks/useCurrencies.tsx +0 -77
  190. package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAsset.tsx +0 -174
  191. /package/dist/{chunk-FMEEJFAF.js.map → chunk-5C6ZZ6WX.js.map} +0 -0
  192. /package/dist/{chunk-YEGD7PWE.js.map → chunk-5O44EPXZ.js.map} +0 -0
  193. /package/dist/{chunk-JKCF7HEA.js.map → chunk-6CTFVBKU.js.map} +0 -0
  194. /package/dist/{chunk-Y63BOO6M.js.map → chunk-LECCEZAO.js.map} +0 -0
  195. /package/dist/{chunk-YALXP2PW.js.map → chunk-N7SQWS2R.js.map} +0 -0
  196. /package/dist/{chunk-N7BPFK46.js.map → utils/abi/primary-sale/index.js.map} +0 -0
@@ -1,39 +1,36 @@
1
1
  import type { PropertyFilter } from '@0xsequence/metadata';
2
2
  import { queryOptions, useQuery } from '@tanstack/react-query';
3
- import { z } from 'zod';
4
3
  import { FilterCondition, type SdkConfig } from '../../types';
5
4
  import { compareAddress } from '../../utils';
6
5
  import {
7
- AddressSchema,
8
- QueryArgSchema,
9
6
  collectableKeys,
10
7
  getMetadataClient,
11
8
  getQueryClient,
12
9
  } from '../_internal';
10
+ import { marketplaceConfigOptions } from '../queries/marketplaceConfig';
13
11
  import { useConfig } from './useConfig';
14
- import { marketplaceConfigOptions } from './useMarketplaceConfig';
15
12
 
16
- const UseFiltersSchema = z.object({
17
- chainId: z.number(),
18
- collectionAddress: AddressSchema,
19
- showAllFilters: z.boolean().default(false).optional(),
20
- query: QueryArgSchema,
21
- excludePropertyValues: z.boolean().default(false).optional(),
22
- });
23
-
24
- export type UseFiltersArgs = z.infer<typeof UseFiltersSchema>;
13
+ export type UseFiltersArgs = {
14
+ chainId: number;
15
+ collectionAddress: string;
16
+ showAllFilters?: boolean;
17
+ excludePropertyValues?: boolean;
18
+ query?: {
19
+ enabled?: boolean;
20
+ };
21
+ };
25
22
 
26
23
  export type UseFilterReturn = Awaited<ReturnType<typeof fetchFilters>>;
27
24
 
28
25
  export const fetchFilters = async (args: UseFiltersArgs, config: SdkConfig) => {
29
- const parsedArgs = UseFiltersSchema.parse(args);
26
+ const parsedArgs = args;
30
27
  const metadataClient = getMetadataClient(config);
31
28
 
32
29
  const filters = await metadataClient
33
30
  .getTokenMetadataPropertyFilters({
34
31
  chainID: parsedArgs.chainId.toString(),
35
32
  contractAddress: parsedArgs.collectionAddress,
36
- excludeProperties: [], // TODO: We can leverage this for some of the exclusion logic
33
+ excludeProperties: [],
37
34
  excludePropertyValues: parsedArgs.excludePropertyValues,
38
35
  })
39
36
  .then((resp) => resp.filters);
@@ -44,8 +41,8 @@ export const fetchFilters = async (args: UseFiltersArgs, config: SdkConfig) => {
44
41
  const marketplaceConfig = await queryClient.fetchQuery(
45
42
  marketplaceConfigOptions(config),
46
43
  );
47
- const collectionFilters = marketplaceConfig.collections.find((c) =>
48
- compareAddress(c.address, parsedArgs.collectionAddress),
44
+ const collectionFilters = marketplaceConfig.market.collections.find((c) =>
45
+ compareAddress(c.itemsAddress, parsedArgs.collectionAddress),
49
46
  )?.filterSettings;
50
47
 
51
48
  if (
@@ -58,7 +55,6 @@ export const fetchFilters = async (args: UseFiltersArgs, config: SdkConfig) => {
58
55
 
59
56
  const { filterOrder, exclusions } = collectionFilters;
60
57
 
61
- // Sort the filters based on the filterOrder, the filters that are not in the filterOrder are at the end
62
58
  const sortedFilters = filters.toSorted((a, b) => {
63
59
  const aIndex =
64
60
  filterOrder.indexOf(a.name) > -1
@@ -73,17 +69,14 @@ export const fetchFilters = async (args: UseFiltersArgs, config: SdkConfig) => {
73
69
 
74
70
  const filteredResults = sortedFilters.reduce<PropertyFilter[]>(
75
71
  (acc, filter) => {
76
- // Check if this filter should be excluded
77
72
  const exclusionRule = exclusions.find((rule) => rule.key === filter.name);
78
73
 
79
74
  if (!exclusionRule) {
80
- // No exclusion rule, include the filter
81
75
  acc.push(filter);
82
76
  return acc;
83
77
  }
84
78
 
85
79
  if (exclusionRule.condition === FilterCondition.ENTIRE_KEY) {
86
- // Skip this filter entirely
87
80
  return acc;
88
81
  }
89
82
 
@@ -91,7 +84,6 @@ export const fetchFilters = async (args: UseFiltersArgs, config: SdkConfig) => {
91
84
  exclusionRule.condition === FilterCondition.SPECIFIC_VALUE &&
92
85
  exclusionRule.value
93
86
  ) {
94
- // Filter out specific values while keeping the filter
95
87
  const filteredValues =
96
88
  filter.values?.filter((value) => value !== exclusionRule.value) || [];
97
89
  if (filteredValues.length > 0) {
@@ -0,0 +1,28 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+
3
+ import { useConfig } from '..';
4
+ import { getIndexerClient } from '../_internal';
5
+
6
+ export const useGetTokenSuppliesMap = ({
7
+ chainId,
8
+ tokenIds,
9
+ collectionAddress,
10
+ }: {
11
+ chainId: number;
12
+ tokenIds: string[];
13
+ collectionAddress: string;
14
+ }) => {
15
+ const config = useConfig();
16
+ const indexerClient = getIndexerClient(chainId, config);
17
+ return useQuery({
18
+ queryKey: ['indexer-tokenSupplies', tokenIds, collectionAddress, chainId],
19
+ queryFn: () => {
20
+ return indexerClient.getTokenSuppliesMap({
21
+ tokenMap: {
22
+ [collectionAddress]: tokenIds,
23
+ },
24
+ includeMetadata: false,
25
+ });
26
+ },
27
+ });
28
+ };
@@ -1,4 +1,5 @@
1
1
  import { useInfiniteQuery } from '@tanstack/react-query';
2
+ import { ContractType } from '../../types/api-types';
2
3
  import { type UseInventoryArgs, inventoryOptions } from '../queries/inventory';
3
4
  import { useConfig } from './useConfig';
4
5
  import { useMarketplaceConfig } from './useMarketplaceConfig';
@@ -7,9 +8,9 @@ export function useInventory(args: UseInventoryArgs) {
7
8
  const config = useConfig();
8
9
  const marketplaceConfig = useMarketplaceConfig();
9
10
  const isLaos721 =
10
- marketplaceConfig.data?.collections.find(
11
- (c) => c.address === args.collectionAddress,
12
- )?.isLAOSERC721 ?? false;
11
+ marketplaceConfig.data?.market.collections.find(
12
+ (c) => c.itemsAddress === args.collectionAddress,
13
+ )?.contractType === ContractType.LAOSERC721;
13
14
 
14
15
  return useInfiniteQuery(inventoryOptions({ ...args, isLaos721 }, config));
15
16
  }
@@ -0,0 +1,62 @@
1
+ import { getUnixTime } from 'date-fns';
2
+ import type { Address } from 'viem';
3
+ import { useReadContracts } from 'wagmi';
4
+ import { ERC1155_SALES_CONTRACT_ABI } from '../..';
5
+
6
+ interface UseSaleSupplyDataProps {
7
+ tokenIds: string[];
8
+ salesContractAddress: Address;
9
+ }
10
+
11
+ export function useList1155SaleSupplies({
12
+ tokenIds,
13
+ salesContractAddress,
14
+ }: UseSaleSupplyDataProps) {
15
+ const getReadContractsArgs = (tokenIds: string[]) =>
16
+ tokenIds.map((tokenId) => ({
17
+ address: salesContractAddress,
18
+ abi: ERC1155_SALES_CONTRACT_ABI,
19
+ functionName: 'tokenSaleDetails',
20
+ args: [tokenId],
21
+ }));
22
+
23
+ const {
24
+ data: supplyData,
25
+ isLoading: supplyDataLoading,
26
+ error: supplyDataError,
27
+ } = useReadContracts({
28
+ batchSize: 500_000, // Node gateway limit has a limit of 512kB, setting it to 500kB to be safe
29
+ contracts: getReadContractsArgs(tokenIds),
30
+ });
31
+
32
+ const extendedSupplyData = (supplyData || [])
33
+ .map((data, index) => ({
34
+ ...data,
35
+ tokenId: tokenIds[index],
36
+ }))
37
+ .filter((data) => data.status === 'success')
38
+ .filter((data) => {
39
+ if (typeof data.result !== 'object') return false;
40
+ const now = BigInt(getUnixTime(new Date()));
41
+ return data.result.endTime > now && data.result.startTime < now;
42
+ });
43
+
44
+ const getSupply = (tokenId: string): number | undefined => {
45
+ const found = extendedSupplyData.find((data) => data.tokenId === tokenId);
46
+ if (!found || typeof found.result !== 'object' || found.result === null)
47
+ return undefined;
48
+ const supply = found.result.supplyCap;
49
+ if (supply === undefined) return undefined;
50
+ // https://github.com/0xsequence/contracts-library/blob/ead1baf34270c76260d01cfc130bb7cc9d57518e/src/tokens/ERC1155/utility/sale/IERC1155Sale.sol#L8
51
+ // 0 means infinite
52
+ if (supply === 0n) return Number.POSITIVE_INFINITY;
53
+ return Number(supply);
54
+ };
55
+
56
+ return {
57
+ extendedSupplyData,
58
+ getSupply,
59
+ supplyDataLoading,
60
+ supplyDataError,
61
+ };
62
+ }
@@ -1,4 +1,5 @@
1
1
  import { useInfiniteQuery } from '@tanstack/react-query';
2
+ import { ContractType } from '../../types/api-types';
2
3
  import { listBalancesOptions } from '../queries/listBalances';
3
4
  import type { UseListBalancesArgs } from '../queries/listBalances';
4
5
  import { useConfig } from './useConfig';
@@ -27,9 +28,10 @@ export function useListBalances(args: UseListBalancesArgs) {
27
28
  const config = useConfig();
28
29
  const { data: marketplaceConfig } = useMarketplaceConfig();
29
30
 
30
- const isLaos721 = marketplaceConfig?.collections.find(
31
- (collection) => collection.address === args.contractAddress,
32
- )?.isLAOSERC721;
31
+ const isLaos721 =
32
+ marketplaceConfig?.market.collections.find(
33
+ (collection) => collection.itemsAddress === args.contractAddress,
34
+ )?.contractType === ContractType.LAOSERC721;
33
35
 
34
36
  if (isLaos721) {
35
37
  args.isLaos721 = true;
@@ -1,4 +1,5 @@
1
1
  import { useInfiniteQuery } from '@tanstack/react-query';
2
+ import { ContractType } from '../../types/api-types';
2
3
  import { listCollectiblesOptions } from '../queries/listCollectibles';
3
4
  import type { UseListCollectiblesArgs } from '../queries/listCollectibles';
4
5
  import { useConfig } from './useConfig';
@@ -27,9 +28,10 @@ export function useListCollectibles(args: UseListCollectiblesArgs) {
27
28
  const config = useConfig();
28
29
  const { data: marketplaceConfig } = useMarketplaceConfig();
29
30
 
30
- const isLaos721 = marketplaceConfig?.collections.find(
31
- (collection) => collection.address === args.collectionAddress,
32
- )?.isLAOSERC721;
31
+ const isLaos721 =
32
+ marketplaceConfig?.market.collections.find(
33
+ (collection) => collection.itemsAddress === args.collectionAddress,
34
+ )?.contractType === ContractType.LAOSERC721;
33
35
 
34
36
  if (isLaos721) {
35
37
  args.isLaos721 = true;
@@ -1,88 +1,26 @@
1
- import { queryOptions, useQuery } from '@tanstack/react-query';
2
- import { z } from 'zod';
3
- import type { MarketplaceConfig, SdkConfig } from '../../types';
4
- import {
5
- QueryArgSchema,
6
- collectionKeys,
7
- getMetadataClient,
8
- } from '../_internal';
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import type { MarketplaceType } from '../../types/new-marketplace-types';
3
+ import { listCollectionsOptions } from '../queries/listCollections';
9
4
  import { useConfig } from './useConfig';
10
5
  import { useMarketplaceConfig } from './useMarketplaceConfig';
11
6
 
12
- const UseListCollectionsSchema = z.object({
13
- query: QueryArgSchema.optional().default({}),
14
- });
15
-
16
- export type UseListCollectionsArgs = z.input<typeof UseListCollectionsSchema>;
17
-
18
- export type UseListCollectionsReturn = Awaited<
19
- ReturnType<typeof fetchListCollections>
20
- >;
21
-
22
- type FetchListCollectionsArgs = {
23
- marketplaceConfig: MarketplaceConfig;
24
- query?: z.infer<typeof QueryArgSchema>;
25
- };
26
-
27
- const fetchListCollections = async (
28
- { marketplaceConfig }: FetchListCollectionsArgs,
29
- config: SdkConfig,
30
- ) => {
31
- const metadataClient = getMetadataClient(config);
32
-
33
- if (!marketplaceConfig?.collections?.length) {
34
- return [];
35
- }
36
-
37
- // Group collections by chainId
38
- const collectionsByChain = marketplaceConfig.collections.reduce<
39
- Record<string, string[]>
40
- >((acc, curr) => {
41
- const { chainId, address } = curr;
42
- if (!acc[chainId]) {
43
- acc[chainId] = [];
44
- }
45
- acc[chainId].push(address);
46
- return acc;
47
- }, {});
48
-
49
- // Fetch collections for each chain
50
- const promises = Object.entries(collectionsByChain).map(
51
- ([chainId, addresses]) =>
52
- metadataClient
53
- .getContractInfoBatch({
54
- chainID: chainId,
55
- contractAddresses: addresses,
56
- })
57
- .then((resp) => Object.values(resp.contractInfoMap)),
58
- );
59
-
60
- const results = await Promise.all(promises);
61
- return results.flat();
62
- };
63
-
64
- export const listCollectionsOptions = (
65
- args: FetchListCollectionsArgs,
66
- config: SdkConfig,
67
- ) => {
68
- return queryOptions({
69
- ...args.query,
70
- queryKey: [...collectionKeys.list],
71
- queryFn: () => fetchListCollections(args, config),
72
- });
7
+ type UseListCollectionsArgs = {
8
+ marketplaceType?: MarketplaceType;
9
+ query?: {
10
+ enabled?: boolean;
11
+ };
73
12
  };
74
13
 
75
14
  export const useListCollections = (args: UseListCollectionsArgs = {}) => {
76
15
  const config = useConfig();
77
- const { data: marketplaceConfig, isLoading: isLoadingConfig } =
78
- useMarketplaceConfig();
16
+ const { data: marketplaceConfig } = useMarketplaceConfig();
79
17
 
80
18
  return useQuery({
81
- ...listCollectionsOptions(
82
- // biome-ignore lint/style/noNonNullAssertion: <explanation>
83
- { marketplaceConfig: marketplaceConfig!, query: args.query },
19
+ ...args.query,
20
+ ...listCollectionsOptions({
21
+ marketplaceType: args.marketplaceType,
22
+ marketplaceConfig,
84
23
  config,
85
- ),
86
- enabled: !isLoadingConfig && !!marketplaceConfig,
24
+ }),
87
25
  });
88
26
  };
@@ -0,0 +1,19 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { useConfig } from './useConfig';
3
+
4
+ import {
5
+ type FetchTokenMetadataArgs,
6
+ tokenMetadataOptions,
7
+ } from '../queries/listTokenMetadata';
8
+
9
+ export const useListTokenMetadata = (args: FetchTokenMetadataArgs) => {
10
+ const config = useConfig();
11
+ const { chainId, contractAddress, tokenIds, query } = args;
12
+
13
+ return useQuery({
14
+ ...tokenMetadataOptions(
15
+ { chainId, contractAddress, tokenIds, query },
16
+ config,
17
+ ),
18
+ });
19
+ };
@@ -0,0 +1,8 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { type UseMarketCurrenciesArgs, currenciesOptions } from '../queries';
3
+ import { useConfig } from './useConfig';
4
+
5
+ export const useMarketCurrencies = (args: UseMarketCurrenciesArgs) => {
6
+ const config = useConfig();
7
+ return useQuery(currenciesOptions(args, config));
8
+ };
@@ -2,8 +2,6 @@ import { useQuery } from '@tanstack/react-query';
2
2
  import { marketplaceConfigOptions } from '../queries/marketplaceConfig';
3
3
  import { useConfig } from './useConfig';
4
4
 
5
- export * from '../queries/marketplaceConfig';
6
-
7
5
  export const useMarketplaceConfig = () => {
8
6
  const config = useConfig();
9
7
  return useQuery(marketplaceConfigOptions(config));
@@ -5,3 +5,5 @@ export * from './listCollectibles';
5
5
  export * from './highestOffer';
6
6
  export * from './listBalances';
7
7
  export * from './lowestListing';
8
+ export * from './listTokenMetadata';
9
+ export * from './marketCurrencies';
@@ -82,7 +82,7 @@ function collectibleFromTokenBalance(
82
82
  audio: token.tokenMetadata?.audio,
83
83
  },
84
84
  contractInfo: token.contractInfo,
85
- contractType: token.contractType as
85
+ contractType: token.contractType as unknown as
86
86
  | ContractType.ERC1155
87
87
  | ContractType.ERC721,
88
88
  balance: token.balance,
@@ -0,0 +1,118 @@
1
+ import type { ContractInfo } from '@0xsequence/metadata';
2
+ import { queryOptions, skipToken } from '@tanstack/react-query';
3
+ import type { SdkConfig } from '../../types';
4
+ import type {
5
+ MarketCollection,
6
+ MarketplaceConfig,
7
+ MarketplaceType,
8
+ ShopCollection,
9
+ } from '../../types/new-marketplace-types';
10
+ import { compareAddress } from '../../utils';
11
+ import { collectionKeys, getMetadataClient } from '../_internal';
12
+
13
+ const allCollections = (marketplaceConfig: MarketplaceConfig) => {
14
+ return [
15
+ ...marketplaceConfig.market.collections,
16
+ ...marketplaceConfig.shop.collections,
17
+ ];
18
+ };
19
+
20
+ const fetchListCollections = async ({
21
+ marketplaceType,
22
+ marketplaceConfig,
23
+ config,
24
+ }: {
25
+ marketplaceType?: MarketplaceType;
26
+ marketplaceConfig: MarketplaceConfig;
27
+ config: SdkConfig;
28
+ }) => {
29
+ const metadataClient = getMetadataClient(config);
30
+
31
+ let collections = allCollections(marketplaceConfig);
32
+
33
+ if (!collections?.length) {
34
+ return [];
35
+ }
36
+
37
+ if (marketplaceType) {
38
+ collections = collections.filter(
39
+ (collection) => collection.marketplaceType === marketplaceType,
40
+ );
41
+ }
42
+
43
+ // Group collections by chainId
44
+ const collectionsByChain = collections.reduce<Record<string, string[]>>(
45
+ (acc, curr) => {
46
+ const { chainId, itemsAddress } = curr;
47
+ if (!acc[chainId]) {
48
+ acc[chainId] = [];
49
+ }
50
+ acc[chainId].push(itemsAddress);
51
+ return acc;
52
+ },
53
+ {},
54
+ );
55
+
56
+ // Fetch collections for each chain
57
+ const promises = Object.entries(collectionsByChain).map(
58
+ ([chainId, addresses]) =>
59
+ metadataClient
60
+ .getContractInfoBatch({
61
+ chainID: chainId,
62
+ contractAddresses: addresses,
63
+ })
64
+ .then((resp) => Object.values(resp.contractInfoMap)),
65
+ );
66
+
67
+ const settled = await Promise.allSettled(promises);
68
+ const results = settled
69
+ .filter(
70
+ (r): r is PromiseFulfilledResult<ContractInfo[]> =>
71
+ r.status === 'fulfilled',
72
+ )
73
+ .flatMap((r) => r.value);
74
+
75
+ const collectionsWithMetadata = collections
76
+ .map((collection) => {
77
+ const metadata = results.find((result) =>
78
+ compareAddress(result.address, collection.itemsAddress),
79
+ );
80
+ return { collection, metadata };
81
+ })
82
+ .filter(
83
+ (
84
+ item,
85
+ ): item is {
86
+ collection: MarketCollection | ShopCollection;
87
+ metadata: ContractInfo;
88
+ } => item.metadata !== undefined,
89
+ )
90
+ .map(({ collection, metadata }) => ({
91
+ ...collection,
92
+ ...metadata,
93
+ }));
94
+
95
+ return collectionsWithMetadata;
96
+ };
97
+
98
+ export const listCollectionsOptions = ({
99
+ marketplaceType,
100
+ marketplaceConfig,
101
+ config,
102
+ }: {
103
+ marketplaceType?: MarketplaceType;
104
+ marketplaceConfig: MarketplaceConfig | undefined;
105
+ config: SdkConfig;
106
+ }) => {
107
+ return queryOptions({
108
+ queryKey: [...collectionKeys.list, marketplaceType],
109
+ queryFn: marketplaceConfig
110
+ ? () =>
111
+ fetchListCollections({
112
+ marketplaceType,
113
+ marketplaceConfig,
114
+ config,
115
+ })
116
+ : skipToken,
117
+ });
118
+ };
@@ -0,0 +1,38 @@
1
+ import { queryOptions } from '@tanstack/react-query';
2
+ import type { SdkConfig } from '../../types';
3
+ import { getMetadataClient } from '../_internal';
4
+
5
+ export interface FetchTokenMetadataArgs {
6
+ chainId: number;
7
+ contractAddress: string;
8
+ tokenIds: string[];
9
+ query?: {
10
+ enabled?: boolean;
11
+ };
12
+ }
13
+
14
+ const fetchTokenMetadata = async (
15
+ { chainId, contractAddress, tokenIds }: FetchTokenMetadataArgs,
16
+ config: SdkConfig,
17
+ ) => {
18
+ const metadataClient = getMetadataClient(config);
19
+
20
+ const response = await metadataClient.getTokenMetadata({
21
+ chainID: chainId.toString(),
22
+ contractAddress: contractAddress,
23
+ tokenIDs: tokenIds,
24
+ });
25
+
26
+ return response.tokenMetadata;
27
+ };
28
+
29
+ export const tokenMetadataOptions = (
30
+ args: FetchTokenMetadataArgs,
31
+ config: SdkConfig,
32
+ ) => {
33
+ return queryOptions({
34
+ ...args.query,
35
+ queryKey: ['listTokenMetadata', args.chainId, args.contractAddress],
36
+ queryFn: () => fetchTokenMetadata(args, config),
37
+ });
38
+ };
@@ -0,0 +1,77 @@
1
+ import { queryOptions } from '@tanstack/react-query';
2
+ import { type Address, zeroAddress } from 'viem';
3
+ import type { SdkConfig } from '../../types';
4
+ import { compareAddress } from '../../utils';
5
+ import {
6
+ currencyKeys,
7
+ getMarketplaceClient,
8
+ getQueryClient,
9
+ } from '../_internal';
10
+ import { marketplaceConfigOptions } from './marketplaceConfig';
11
+
12
+ type QueryArg = {
13
+ enabled?: boolean;
14
+ };
15
+
16
+ export interface UseMarketCurrenciesArgs {
17
+ chainId: number;
18
+ includeNativeCurrency?: boolean;
19
+ collectionAddress?: Address;
20
+ query?: QueryArg;
21
+ }
22
+
23
+ const fetchMarketCurrencies = async (
24
+ args: UseMarketCurrenciesArgs,
25
+ config: SdkConfig,
26
+ ) => {
27
+ const includeNativeCurrency = args.includeNativeCurrency ?? true;
28
+ const marketplaceClient = getMarketplaceClient(args.chainId, config);
29
+
30
+ let currencies = await marketplaceClient.listCurrencies().then((resp) =>
31
+ resp.currencies.map((currency) => ({
32
+ ...currency,
33
+ contractAddress: currency.contractAddress || zeroAddress,
34
+ })),
35
+ );
36
+
37
+ if (args.collectionAddress) {
38
+ const queryClient = getQueryClient();
39
+ const marketplaceConfig = await queryClient.fetchQuery(
40
+ marketplaceConfigOptions(config),
41
+ );
42
+
43
+ const currenciesOptions = marketplaceConfig.market.collections.find(
44
+ (collection) =>
45
+ compareAddress(collection.itemsAddress, args.collectionAddress),
46
+ )?.currencyOptions;
47
+
48
+ // Filter currencies based on collection currency options
49
+ if (currenciesOptions) {
50
+ currencies = currencies.filter((currency) =>
51
+ currenciesOptions.includes(currency.contractAddress),
52
+ );
53
+ }
54
+ }
55
+
56
+ if (!includeNativeCurrency) {
57
+ currencies = currencies.filter((currency) => !currency.nativeCurrency);
58
+ }
59
+
60
+ return currencies;
61
+ };
62
+
63
+ export const currenciesOptions = (
64
+ args: UseMarketCurrenciesArgs,
65
+ config: SdkConfig,
66
+ ) => {
67
+ return queryOptions({
68
+ ...args.query,
69
+ queryKey: [
70
+ ...currencyKeys.lists,
71
+ args.chainId,
72
+ args.includeNativeCurrency ?? true,
73
+ args.collectionAddress,
74
+ ],
75
+ queryFn: () => fetchMarketCurrencies(args, config),
76
+ });
77
+ };