@0xsequence/marketplace-sdk 0.4.8 → 0.5.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 (116) hide show
  1. package/dist/{chunk-2OJB35FS.js → chunk-5NORRVPM.js} +5 -5
  2. package/dist/{chunk-2OJB35FS.js.map → chunk-5NORRVPM.js.map} +1 -1
  3. package/dist/{chunk-ATDCYXXV.js → chunk-6YHHCGGY.js} +2 -2
  4. package/dist/{chunk-WRMJ5FZM.js → chunk-HV2X2VZN.js} +874 -194
  5. package/dist/chunk-HV2X2VZN.js.map +1 -0
  6. package/dist/{chunk-AQT3BQ67.js → chunk-J2XJZ6SJ.js} +12 -5
  7. package/dist/chunk-J2XJZ6SJ.js.map +1 -0
  8. package/dist/{chunk-JEOUQFT3.js → chunk-LJAB3S6U.js} +4 -3
  9. package/dist/chunk-LJAB3S6U.js.map +1 -0
  10. package/dist/{chunk-7WCZP6FN.js → chunk-OUVFTA63.js} +649 -386
  11. package/dist/chunk-OUVFTA63.js.map +1 -0
  12. package/dist/{chunk-XXML5K3X.js → chunk-QTJF5GDQ.js} +2 -2
  13. package/dist/{chunk-LF44FCG5.js → chunk-TQWM4ER6.js} +2 -2
  14. package/dist/{chunk-LF44FCG5.js.map → chunk-TQWM4ER6.js.map} +1 -1
  15. package/dist/{chunk-6R4G7J6Q.js → chunk-WSCUPAGR.js} +33 -5
  16. package/dist/chunk-WSCUPAGR.js.map +1 -0
  17. package/dist/{create-config-D5WqfUft.d.ts → create-config-BXvwUh55.d.ts} +2 -2
  18. package/dist/index.css +31 -17
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +1 -1
  21. package/dist/{marketplace-config-C_fDWzz0.d.ts → marketplace-config-znEu4L0K.d.ts} +1 -1
  22. package/dist/{marketplace.gen-B8S8fflj.d.ts → marketplace.gen-CCJ-URn2.d.ts} +16 -4
  23. package/dist/react/_internal/api/index.d.ts +3 -2
  24. package/dist/react/_internal/api/index.js +3 -1
  25. package/dist/react/_internal/index.d.ts +5 -5
  26. package/dist/react/_internal/index.js +3 -1
  27. package/dist/react/_internal/wagmi/index.d.ts +3 -3
  28. package/dist/react/hooks/index.d.ts +249 -74
  29. package/dist/react/hooks/index.js +18 -5
  30. package/dist/react/index.css +37 -17
  31. package/dist/react/index.css.map +1 -1
  32. package/dist/react/index.d.ts +6 -6
  33. package/dist/react/index.js +22 -9
  34. package/dist/react/ssr/index.js +4 -0
  35. package/dist/react/ssr/index.js.map +1 -1
  36. package/dist/react/ui/components/collectible-card/index.css +37 -17
  37. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  38. package/dist/react/ui/components/collectible-card/index.d.ts +27 -4
  39. package/dist/react/ui/components/collectible-card/index.js +8 -9
  40. package/dist/react/ui/icons/index.js +3 -3
  41. package/dist/react/ui/index.css +37 -17
  42. package/dist/react/ui/index.css.map +1 -1
  43. package/dist/react/ui/index.d.ts +3 -3
  44. package/dist/react/ui/index.js +8 -9
  45. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +3 -3
  46. package/dist/react/ui/modals/_internal/components/actionModal/index.js +5 -5
  47. package/dist/{sdk-config-BXVH8PS2.d.ts → sdk-config-B32_2bG3.d.ts} +29 -7
  48. package/dist/{services-CdXAIjt1.d.ts → services-BRBVE0mm.d.ts} +1 -1
  49. package/dist/styles/index.css +31 -17
  50. package/dist/styles/index.css.map +1 -1
  51. package/dist/styles/index.d.ts +2 -2
  52. package/dist/styles/index.js +2 -2
  53. package/dist/types/index.d.ts +3 -3
  54. package/dist/types/index.js +1 -1
  55. package/dist/{types-eX4P9xju.d.ts → types-Yto6KrTN.d.ts} +2 -2
  56. package/dist/utils/index.d.ts +3 -3
  57. package/dist/utils/index.js +1 -1
  58. package/package.json +16 -16
  59. package/src/react/_internal/api/__mocks__/marketplace.msw.ts +4 -0
  60. package/src/react/_internal/api/marketplace.gen.ts +45 -7
  61. package/src/react/_internal/api/query-keys.ts +4 -0
  62. package/src/react/_internal/wallet/useWallet.ts +30 -46
  63. package/src/react/_internal/wallet/wallet.ts +52 -6
  64. package/src/react/hooks/index.ts +4 -0
  65. package/src/react/hooks/options/__mocks__/marketplaceConfig.msw.ts +10 -1
  66. package/src/react/hooks/useAutoSelectFeeOption.tsx +104 -0
  67. package/src/react/hooks/useCancelOrder.tsx +57 -1
  68. package/src/react/hooks/useCollectionBalanceDetails.tsx +87 -0
  69. package/src/react/hooks/useCollectionDetails.tsx +35 -0
  70. package/src/react/hooks/useCollectionDetailsPolling.tsx +60 -0
  71. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +36 -118
  72. package/src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx +52 -0
  73. package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +72 -0
  74. package/src/react/ui/components/_internals/action-button/components/OwnerActions.tsx +81 -0
  75. package/src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts +93 -0
  76. package/src/react/ui/components/_internals/action-button/store.ts +47 -0
  77. package/src/react/ui/components/_internals/action-button/styles.css.ts +8 -0
  78. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +35 -18
  79. package/src/react/ui/components/collectible-card/Footer.tsx +5 -8
  80. package/src/react/ui/components/collectible-card/styles.css.ts +44 -31
  81. package/src/react/ui/icons/CartIcon.tsx +46 -0
  82. package/src/react/ui/modals/BuyModal/Modal.tsx +0 -2
  83. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +253 -0
  84. package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +100 -0
  85. package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +402 -0
  86. package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +267 -0
  87. package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +166 -0
  88. package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +209 -0
  89. package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +7 -4
  90. package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +19 -17
  91. package/src/react/ui/modals/BuyModal/hooks/useLoadData.ts +9 -7
  92. package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +36 -18
  93. package/src/react/ui/modals/BuyModal/modals/__tests__/CheckoutModal.test.tsx +162 -0
  94. package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +243 -0
  95. package/src/react/ui/modals/BuyModal/store.ts +11 -10
  96. package/src/react/ui/modals/CreateListingModal/Modal.tsx +26 -3
  97. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +141 -29
  98. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +5 -1
  99. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +20 -11
  100. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +13 -58
  101. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +2 -0
  102. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +18 -19
  103. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/utils.test.ts +2 -0
  104. package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +62 -0
  105. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +53 -100
  106. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +2 -10
  107. package/tsconfig.tsbuildinfo +1 -1
  108. package/dist/chunk-6R4G7J6Q.js.map +0 -1
  109. package/dist/chunk-7WCZP6FN.js.map +0 -1
  110. package/dist/chunk-AQT3BQ67.js.map +0 -1
  111. package/dist/chunk-FWN2MCLI.js +0 -425
  112. package/dist/chunk-FWN2MCLI.js.map +0 -1
  113. package/dist/chunk-JEOUQFT3.js.map +0 -1
  114. package/dist/chunk-WRMJ5FZM.js.map +0 -1
  115. /package/dist/{chunk-ATDCYXXV.js.map → chunk-6YHHCGGY.js.map} +0 -0
  116. /package/dist/{chunk-XXML5K3X.js.map → chunk-QTJF5GDQ.js.map} +0 -0
@@ -1,9 +1,21 @@
1
1
  "use client"
2
2
  import {
3
- useSwitchChainModal,
4
- useWallet
5
- } from "./chunk-FWN2MCLI.js";
3
+ InfoIcon_default
4
+ } from "./chunk-QTJF5GDQ.js";
5
+ import {
6
+ SEQUENCE_MARKET_V1_ADDRESS,
7
+ SEQUENCE_MARKET_V2_ADDRESS
8
+ } from "./chunk-Y75XGZOB.js";
9
+ import {
10
+ alertMessageBox,
11
+ alertMessageBoxVariants,
12
+ closeButton,
13
+ dialogOverlay,
14
+ switchChainCta,
15
+ switchChainModalContent
16
+ } from "./chunk-FI723DGL.js";
6
17
  import {
18
+ getPresentableChainName,
7
19
  getPublicRpcClient
8
20
  } from "./chunk-XP3WY5AX.js";
9
21
  import {
@@ -17,7 +29,8 @@ import {
17
29
  ChainIdSchema,
18
30
  CollectableIdSchema,
19
31
  PROVIDER_ID,
20
- QueryArgSchema
32
+ QueryArgSchema,
33
+ getProviderEl
21
34
  } from "./chunk-YOKGP2EQ.js";
22
35
  import {
23
36
  CollectibleStatus,
@@ -48,16 +61,91 @@ import {
48
61
  getMarketplaceClient,
49
62
  getMetadataClient,
50
63
  getQueryClient
51
- } from "./chunk-6R4G7J6Q.js";
64
+ } from "./chunk-WSCUPAGR.js";
52
65
  import {
53
66
  BaseError,
67
+ ChainSwitchError,
54
68
  ChainSwitchUserRejectedError,
55
69
  MarketplaceConfigFetchError,
56
70
  NoWalletConnectedError,
57
71
  ProjectNotFoundError,
72
+ TransactionConfirmationError,
73
+ TransactionExecutionError,
74
+ TransactionSignatureError,
75
+ UserRejectedRequestError,
58
76
  WalletInstanceNotFoundError
59
77
  } from "./chunk-WM4RGBFQ.js";
60
78
 
79
+ // src/react/hooks/useAutoSelectFeeOption.tsx
80
+ import { useAccount, useConfig } from "wagmi";
81
+ import { getBalance } from "wagmi/actions";
82
+ import { useCallback } from "react";
83
+ function useAutoSelectFeeOption({
84
+ pendingFeeOptionConfirmation
85
+ }) {
86
+ const { address: userAddress } = useAccount();
87
+ const config = useConfig();
88
+ const findAffordableOption = useCallback(async () => {
89
+ if (!userAddress) {
90
+ return {
91
+ selectedOption: null,
92
+ error: "User not connected",
93
+ isLoading: false
94
+ };
95
+ }
96
+ if (!pendingFeeOptionConfirmation.options) {
97
+ return {
98
+ selectedOption: null,
99
+ error: "No options provided",
100
+ isLoading: false
101
+ };
102
+ }
103
+ try {
104
+ for (const option of pendingFeeOptionConfirmation.options) {
105
+ if (!option.token.contractAddress) continue;
106
+ try {
107
+ const balance = await getBalance(config, {
108
+ address: userAddress,
109
+ token: option.token.contractAddress,
110
+ chainId: pendingFeeOptionConfirmation.chainId
111
+ });
112
+ const optionValue = BigInt(option.value);
113
+ if (balance.value >= optionValue) {
114
+ return {
115
+ selectedOption: option,
116
+ error: null,
117
+ isLoading: false
118
+ };
119
+ }
120
+ } catch (error) {
121
+ console.error(
122
+ "Error fetching balance for currency:",
123
+ option.token.contractAddress,
124
+ error
125
+ );
126
+ }
127
+ }
128
+ return {
129
+ selectedOption: null,
130
+ error: "Insufficient balance for any fee option",
131
+ isLoading: false
132
+ };
133
+ } catch (error) {
134
+ return {
135
+ selectedOption: null,
136
+ error: "Failed to check balances",
137
+ isLoading: false
138
+ };
139
+ }
140
+ }, [
141
+ pendingFeeOptionConfirmation.options,
142
+ pendingFeeOptionConfirmation.chainId,
143
+ userAddress,
144
+ config
145
+ ]);
146
+ return findAffordableOption();
147
+ }
148
+
61
149
  // src/react/hooks/useBalanceOfCollectible.tsx
62
150
  import { queryOptions, skipToken, useQuery } from "@tanstack/react-query";
63
151
  import { z } from "zod";
@@ -109,7 +197,7 @@ function MarketplaceProvider({
109
197
  }
110
198
 
111
199
  // src/react/hooks/useConfig.tsx
112
- function useConfig() {
200
+ function useConfig2() {
113
201
  const context = useContext(MarketplaceSdkContext);
114
202
  if (!context) {
115
203
  throw new MarketplaceSdkProviderNotFoundError();
@@ -155,7 +243,7 @@ var balanceOfCollectibleOptions = (args, config) => {
155
243
  });
156
244
  };
157
245
  var useBalanceOfCollectible = (args) => {
158
- const config = useConfig();
246
+ const config = useConfig2();
159
247
  return useQuery(balanceOfCollectibleOptions(args, config));
160
248
  };
161
249
 
@@ -749,7 +837,7 @@ var countOfCollectablesOptions = (args, config) => {
749
837
  });
750
838
  };
751
839
  var useCountOfCollectables = (args) => {
752
- const config = useConfig();
840
+ const config = useConfig2();
753
841
  return useQuery2(countOfCollectablesOptions(args, config));
754
842
  };
755
843
 
@@ -779,7 +867,7 @@ var collectibleOptions = (args, config) => {
779
867
  });
780
868
  };
781
869
  var useCollectible = (args) => {
782
- const config = useConfig();
870
+ const config = useConfig2();
783
871
  return useQuery3(collectibleOptions(args, config));
784
872
  };
785
873
 
@@ -807,19 +895,76 @@ var collectionOptions = (args, config) => {
807
895
  });
808
896
  };
809
897
  var useCollection = (args) => {
810
- const config = useConfig();
898
+ const config = useConfig2();
811
899
  return useQuery4(collectionOptions(args, config));
812
900
  };
813
901
 
814
- // src/react/hooks/useCurrencies.tsx
902
+ // src/react/hooks/useCollectionBalanceDetails.tsx
903
+ import { z as z6 } from "zod";
815
904
  import { queryOptions as queryOptions5, useQuery as useQuery5 } from "@tanstack/react-query";
905
+ var filterSchema2 = z6.object({
906
+ accountAddresses: z6.array(AddressSchema),
907
+ contractWhitelist: z6.array(AddressSchema).optional(),
908
+ omitNativeBalances: z6.boolean()
909
+ });
910
+ var useCollectionBalanceDetailsArgsSchema = z6.object({
911
+ chainId: ChainIdSchema.pipe(z6.coerce.number()),
912
+ filter: filterSchema2,
913
+ query: QueryArgSchema.optional()
914
+ });
915
+ var fetchCollectionBalanceDetails = async (args, indexerClient) => {
916
+ const promises = args.filter.accountAddresses.map(
917
+ (accountAddress) => indexerClient.getTokenBalancesDetails({
918
+ filter: {
919
+ accountAddresses: [accountAddress],
920
+ contractWhitelist: args.filter.contractWhitelist,
921
+ omitNativeBalances: args.filter.omitNativeBalances
922
+ }
923
+ })
924
+ );
925
+ const responses = await Promise.all(promises);
926
+ const mergedResponse = responses.reduce(
927
+ (acc, curr) => {
928
+ if (!curr) return acc;
929
+ return {
930
+ page: curr.page,
931
+ nativeBalances: [
932
+ ...acc.nativeBalances || [],
933
+ ...curr.nativeBalances || []
934
+ ],
935
+ balances: [...acc.balances || [], ...curr.balances || []]
936
+ };
937
+ },
938
+ { page: {}, nativeBalances: [], balances: [] }
939
+ );
940
+ if (!mergedResponse) {
941
+ throw new Error("Failed to fetch collection balance details");
942
+ }
943
+ return mergedResponse;
944
+ };
945
+ var collectionBalanceDetailsOptions = (args, config) => {
946
+ const parsedArgs = useCollectionBalanceDetailsArgsSchema.parse(args);
947
+ const indexerClient = getIndexerClient(parsedArgs.chainId, config);
948
+ return queryOptions5({
949
+ queryKey: [...balanceQueries.collectionBalanceDetails, args, config],
950
+ queryFn: () => fetchCollectionBalanceDetails(parsedArgs, indexerClient),
951
+ ...args.query
952
+ });
953
+ };
954
+ var useCollectionBalanceDetails = (args) => {
955
+ const config = useConfig2();
956
+ return useQuery5(collectionBalanceDetailsOptions(args, config));
957
+ };
958
+
959
+ // src/react/hooks/useCurrencies.tsx
960
+ import { queryOptions as queryOptions6, useQuery as useQuery6 } from "@tanstack/react-query";
816
961
  import { zeroAddress } from "viem";
817
- import { z as z6 } from "zod";
962
+ import { z as z7 } from "zod";
818
963
  var ChainIdCoerce = ChainIdSchema.transform((val) => val.toString());
819
- var UseCurrenciesArgsSchema = z6.object({
964
+ var UseCurrenciesArgsSchema = z7.object({
820
965
  chainId: ChainIdCoerce,
821
- includeNativeCurrency: z6.boolean().optional().default(true),
822
- currencyOptions: z6.array(AddressSchema).optional(),
966
+ includeNativeCurrency: z7.boolean().optional().default(true),
967
+ currencyOptions: z7.array(AddressSchema).optional(),
823
968
  query: QueryArgSchema
824
969
  });
825
970
  var fetchCurrencies = async (chainId, config) => {
@@ -850,7 +995,7 @@ var selectCurrencies = (data, args) => {
850
995
  return filteredData;
851
996
  };
852
997
  var currenciesOptions = (args, config) => {
853
- return queryOptions5({
998
+ return queryOptions6({
854
999
  ...args.query,
855
1000
  queryKey: [...currencyKeys.lists, args.chainId],
856
1001
  queryFn: () => fetchCurrencies(args.chainId, config),
@@ -859,15 +1004,15 @@ var currenciesOptions = (args, config) => {
859
1004
  });
860
1005
  };
861
1006
  var useCurrencies = (args) => {
862
- const config = useConfig();
863
- return useQuery5(currenciesOptions(args, config));
1007
+ const config = useConfig2();
1008
+ return useQuery6(currenciesOptions(args, config));
864
1009
  };
865
1010
 
866
1011
  // src/react/hooks/useMarketplaceConfig.tsx
867
- import { useQuery as useQuery6 } from "@tanstack/react-query";
1012
+ import { useQuery as useQuery7 } from "@tanstack/react-query";
868
1013
 
869
1014
  // src/react/hooks/options/marketplaceConfigOptions.ts
870
- import { queryOptions as queryOptions6 } from "@tanstack/react-query";
1015
+ import { queryOptions as queryOptions7 } from "@tanstack/react-query";
871
1016
  var fetchBuilderConfig = async (projectId, env) => {
872
1017
  const url = `${builderMarketplaceApi(projectId, env)}`;
873
1018
  const response = await fetch(`${url}/config.json`);
@@ -907,7 +1052,7 @@ var marketplaceConfigOptions = (config) => {
907
1052
  env = config._internal.builderEnv ?? env;
908
1053
  }
909
1054
  const projectId = config.projectId;
910
- return queryOptions6({
1055
+ return queryOptions7({
911
1056
  queryKey: [...configKeys.marketplace, env, projectId],
912
1057
  queryFn: () => fetchMarketplaceConfig(env, projectId)
913
1058
  });
@@ -915,8 +1060,8 @@ var marketplaceConfigOptions = (config) => {
915
1060
 
916
1061
  // src/react/hooks/useMarketplaceConfig.tsx
917
1062
  var useMarketplaceConfig = () => {
918
- const config = useConfig();
919
- return useQuery6(marketplaceConfigOptions(config));
1063
+ const config = useConfig2();
1064
+ return useQuery7(marketplaceConfigOptions(config));
920
1065
  };
921
1066
 
922
1067
  // src/react/hooks/useCurrencyOptions.tsx
@@ -932,10 +1077,10 @@ var useCurrencyOptions = ({
932
1077
  };
933
1078
 
934
1079
  // src/react/hooks/useCurrency.tsx
935
- import { queryOptions as queryOptions7, useQuery as useQuery7 } from "@tanstack/react-query";
936
- import { z as z7 } from "zod";
1080
+ import { queryOptions as queryOptions8, useQuery as useQuery8 } from "@tanstack/react-query";
1081
+ import { z as z8 } from "zod";
937
1082
  var ChainIdCoerce2 = ChainIdSchema.transform((val) => val.toString());
938
- var UseCurrencyArgsSchema = z7.object({
1083
+ var UseCurrencyArgsSchema = z8.object({
939
1084
  chainId: ChainIdCoerce2,
940
1085
  currencyAddress: AddressSchema,
941
1086
  query: QueryArgSchema
@@ -960,22 +1105,22 @@ var fetchCurrency = async (chainId, currencyAddress, config) => {
960
1105
  return currency;
961
1106
  };
962
1107
  var currencyOptions = (args, config) => {
963
- return queryOptions7({
1108
+ return queryOptions8({
964
1109
  ...args.query,
965
1110
  queryKey: [...currencyKeys.details, args.chainId, args.currencyAddress],
966
1111
  queryFn: () => fetchCurrency(args.chainId, args.currencyAddress, config)
967
1112
  });
968
1113
  };
969
1114
  var useCurrency = (args) => {
970
- const config = useConfig();
971
- return useQuery7(currencyOptions(args, config));
1115
+ const config = useConfig2();
1116
+ return useQuery8(currencyOptions(args, config));
972
1117
  };
973
1118
 
974
1119
  // src/react/hooks/useFilters.tsx
975
- import { queryOptions as queryOptions8, useQuery as useQuery8 } from "@tanstack/react-query";
976
- import { z as z8 } from "zod";
977
- var UseFiltersSchema = z8.object({
978
- chainId: ChainIdSchema.pipe(z8.coerce.string()),
1120
+ import { queryOptions as queryOptions9, useQuery as useQuery9 } from "@tanstack/react-query";
1121
+ import { z as z9 } from "zod";
1122
+ var UseFiltersSchema = z9.object({
1123
+ chainId: ChainIdSchema.pipe(z9.coerce.string()),
979
1124
  collectionAddress: AddressSchema,
980
1125
  query: QueryArgSchema
981
1126
  });
@@ -988,22 +1133,22 @@ var fetchFilters = async (args, config) => {
988
1133
  }).then((resp) => resp.filters);
989
1134
  };
990
1135
  var filtersOptions = (args, config) => {
991
- return queryOptions8({
1136
+ return queryOptions9({
992
1137
  ...args.query,
993
1138
  queryKey: [...collectableKeys.filter, args, config],
994
1139
  queryFn: () => fetchFilters(args, config)
995
1140
  });
996
1141
  };
997
1142
  var useFilters = (args) => {
998
- const config = useConfig();
999
- return useQuery8(filtersOptions(args, config));
1143
+ const config = useConfig2();
1144
+ return useQuery9(filtersOptions(args, config));
1000
1145
  };
1001
1146
 
1002
1147
  // src/react/hooks/useFloorOrder.tsx
1003
- import { queryOptions as queryOptions9, useQuery as useQuery9 } from "@tanstack/react-query";
1004
- import { z as z9 } from "zod";
1005
- var UseFloorOrderSchema = z9.object({
1006
- chainId: ChainIdSchema.pipe(z9.coerce.string()),
1148
+ import { queryOptions as queryOptions10, useQuery as useQuery10 } from "@tanstack/react-query";
1149
+ import { z as z10 } from "zod";
1150
+ var UseFloorOrderSchema = z10.object({
1151
+ chainId: ChainIdSchema.pipe(z10.coerce.string()),
1007
1152
  collectionAddress: AddressSchema,
1008
1153
  query: QueryArgSchema
1009
1154
  });
@@ -1012,24 +1157,24 @@ var fetchFloorOrder = async (args, config) => {
1012
1157
  return marketplaceClient.getFloorOrder({ contractAddress: args.collectionAddress }).then((data) => data.collectible);
1013
1158
  };
1014
1159
  var floorOrderOptions = (args, config) => {
1015
- return queryOptions9({
1160
+ return queryOptions10({
1016
1161
  queryKey: [...collectableKeys.floorOrders, args, config],
1017
1162
  queryFn: () => fetchFloorOrder(args, config)
1018
1163
  });
1019
1164
  };
1020
1165
  var useFloorOrder = (args) => {
1021
- const config = useConfig();
1022
- return useQuery9(floorOrderOptions(args, config));
1166
+ const config = useConfig2();
1167
+ return useQuery10(floorOrderOptions(args, config));
1023
1168
  };
1024
1169
 
1025
1170
  // src/react/hooks/useHighestOffer.tsx
1026
- import { queryOptions as queryOptions10, useQuery as useQuery10 } from "@tanstack/react-query";
1027
- import { z as z10 } from "zod";
1171
+ import { queryOptions as queryOptions11, useQuery as useQuery11 } from "@tanstack/react-query";
1172
+ import { z as z11 } from "zod";
1028
1173
  var UseHighestOfferArgsSchema = getCollectibleHighestOfferArgsSchema.omit({
1029
1174
  contractAddress: true
1030
1175
  }).extend({
1031
1176
  collectionAddress: AddressSchema,
1032
- chainId: ChainIdSchema.pipe(z10.coerce.string()),
1177
+ chainId: ChainIdSchema.pipe(z11.coerce.string()),
1033
1178
  query: QueryArgSchema
1034
1179
  });
1035
1180
  var fetchHighestOffer = async (args, config) => {
@@ -1041,48 +1186,48 @@ var fetchHighestOffer = async (args, config) => {
1041
1186
  });
1042
1187
  };
1043
1188
  var highestOfferOptions = (args, config) => {
1044
- return queryOptions10({
1189
+ return queryOptions11({
1045
1190
  ...args.query,
1046
1191
  queryKey: [...collectableKeys.highestOffers, args, config],
1047
1192
  queryFn: () => fetchHighestOffer(args, config)
1048
1193
  });
1049
1194
  };
1050
1195
  var useHighestOffer = (args) => {
1051
- const config = useConfig();
1052
- return useQuery10(highestOfferOptions(args, config));
1196
+ const config = useConfig2();
1197
+ return useQuery11(highestOfferOptions(args, config));
1053
1198
  };
1054
1199
 
1055
1200
  // src/react/hooks/useListBalances.tsx
1056
1201
  import { SortOrder as SortOrder2 } from "@0xsequence/indexer";
1057
1202
  import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
1058
- import { z as z11 } from "zod";
1059
- var metadataOptionsSchema = z11.object({
1060
- verifiedOnly: z11.boolean().optional(),
1061
- unverifiedOnly: z11.boolean().optional(),
1062
- includeContracts: z11.array(z11.string()).optional()
1063
- });
1064
- var sortOrderSchema2 = z11.nativeEnum(SortOrder2);
1065
- var sortBySchema2 = z11.object({
1066
- column: z11.string(),
1203
+ import { z as z12 } from "zod";
1204
+ var metadataOptionsSchema = z12.object({
1205
+ verifiedOnly: z12.boolean().optional(),
1206
+ unverifiedOnly: z12.boolean().optional(),
1207
+ includeContracts: z12.array(z12.string()).optional()
1208
+ });
1209
+ var sortOrderSchema2 = z12.nativeEnum(SortOrder2);
1210
+ var sortBySchema2 = z12.object({
1211
+ column: z12.string(),
1067
1212
  order: sortOrderSchema2
1068
1213
  });
1069
- var pageSchema2 = z11.object({
1070
- page: z11.number().optional(),
1071
- column: z11.string().optional(),
1072
- before: z11.any().optional(),
1073
- after: z11.any().optional(),
1074
- sort: z11.array(sortBySchema2).optional(),
1075
- pageSize: z11.number().optional(),
1076
- more: z11.boolean().optional()
1077
- });
1078
- var useListBalancesArgsSchema = z11.object({
1079
- chainId: ChainIdSchema.pipe(z11.coerce.number()),
1214
+ var pageSchema2 = z12.object({
1215
+ page: z12.number().optional(),
1216
+ column: z12.string().optional(),
1217
+ before: z12.any().optional(),
1218
+ after: z12.any().optional(),
1219
+ sort: z12.array(sortBySchema2).optional(),
1220
+ pageSize: z12.number().optional(),
1221
+ more: z12.boolean().optional()
1222
+ });
1223
+ var useListBalancesArgsSchema = z12.object({
1224
+ chainId: ChainIdSchema.pipe(z12.coerce.number()),
1080
1225
  accountAddress: AddressSchema.optional(),
1081
1226
  contractAddress: AddressSchema.optional(),
1082
- tokenId: z11.string().optional(),
1083
- includeMetadata: z11.boolean().optional(),
1227
+ tokenId: z12.string().optional(),
1228
+ includeMetadata: z12.boolean().optional(),
1084
1229
  metadataOptions: metadataOptionsSchema.optional(),
1085
- includeCollectionTokens: z11.boolean().optional(),
1230
+ includeCollectionTokens: z12.boolean().optional(),
1086
1231
  page: pageSchema2.optional(),
1087
1232
  query: QueryArgSchema
1088
1233
  });
@@ -1105,12 +1250,12 @@ var listBalancesOptions = (args, config) => {
1105
1250
  });
1106
1251
  };
1107
1252
  var useListBalances = (args) => {
1108
- const config = useConfig();
1253
+ const config = useConfig2();
1109
1254
  return useInfiniteQuery(listBalancesOptions(args, config));
1110
1255
  };
1111
1256
 
1112
1257
  // src/react/hooks/useListCollectibleActivities.tsx
1113
- import { queryOptions as queryOptions11, useQuery as useQuery11 } from "@tanstack/react-query";
1258
+ import { queryOptions as queryOptions12, useQuery as useQuery12 } from "@tanstack/react-query";
1114
1259
  var fetchCollectibleActivities = async (args, config) => {
1115
1260
  const marketplaceClient = getMarketplaceClient(args.chainId, config);
1116
1261
  return marketplaceClient.listCollectibleActivities({
@@ -1127,24 +1272,24 @@ var fetchCollectibleActivities = async (args, config) => {
1127
1272
  }));
1128
1273
  };
1129
1274
  var listCollectibleActivitiesOptions = (args, config) => {
1130
- return queryOptions11({
1275
+ return queryOptions12({
1131
1276
  queryKey: [...collectableKeys.collectibleActivities, args, config],
1132
1277
  queryFn: () => fetchCollectibleActivities(args, config)
1133
1278
  });
1134
1279
  };
1135
1280
  var useListCollectibleActivities = (args) => {
1136
- const config = useConfig();
1137
- return useQuery11(listCollectibleActivitiesOptions(args, config));
1281
+ const config = useConfig2();
1282
+ return useQuery12(listCollectibleActivitiesOptions(args, config));
1138
1283
  };
1139
1284
 
1140
1285
  // src/react/hooks/useListCollectibles.tsx
1141
1286
  import { infiniteQueryOptions as infiniteQueryOptions2, useInfiniteQuery as useInfiniteQuery2 } from "@tanstack/react-query";
1142
- import { z as z12 } from "zod";
1287
+ import { z as z13 } from "zod";
1143
1288
  var UseListCollectiblesArgsSchema = listCollectiblesArgsSchema.omit({
1144
1289
  contractAddress: true
1145
1290
  }).extend({
1146
1291
  collectionAddress: AddressSchema,
1147
- chainId: ChainIdSchema.pipe(z12.coerce.string()),
1292
+ chainId: ChainIdSchema.pipe(z13.coerce.string()),
1148
1293
  query: QueryArgSchema
1149
1294
  });
1150
1295
  var fetchCollectibles = async (args, marketplaceClient, page) => {
@@ -1166,12 +1311,12 @@ var listCollectiblesOptions = (args, config) => {
1166
1311
  });
1167
1312
  };
1168
1313
  var useListCollectibles = (args) => {
1169
- const config = useConfig();
1314
+ const config = useConfig2();
1170
1315
  return useInfiniteQuery2(listCollectiblesOptions(args, config));
1171
1316
  };
1172
1317
 
1173
1318
  // src/react/hooks/useListCollectionActivities.tsx
1174
- import { queryOptions as queryOptions12, useQuery as useQuery12 } from "@tanstack/react-query";
1319
+ import { queryOptions as queryOptions13, useQuery as useQuery13 } from "@tanstack/react-query";
1175
1320
  var fetchListCollectionActivities = async (args, config) => {
1176
1321
  const marketplaceClient = getMarketplaceClient(args.chainId, config);
1177
1322
  return marketplaceClient.listCollectionActivities({
@@ -1187,23 +1332,23 @@ var fetchListCollectionActivities = async (args, config) => {
1187
1332
  }));
1188
1333
  };
1189
1334
  var listCollectionActivitiesOptions = (args, config) => {
1190
- return queryOptions12({
1335
+ return queryOptions13({
1191
1336
  queryKey: [...collectionKeys.collectionActivities, args, config],
1192
1337
  queryFn: () => fetchListCollectionActivities(args, config)
1193
1338
  });
1194
1339
  };
1195
1340
  var useListCollectionActivities = (args) => {
1196
- const config = useConfig();
1197
- return useQuery12(listCollectionActivitiesOptions(args, config));
1341
+ const config = useConfig2();
1342
+ return useQuery13(listCollectionActivitiesOptions(args, config));
1198
1343
  };
1199
1344
 
1200
1345
  // src/react/hooks/useListOffersForCollectible.tsx
1201
- import { queryOptions as queryOptions13, useQuery as useQuery13 } from "@tanstack/react-query";
1202
- import { z as z13 } from "zod";
1346
+ import { queryOptions as queryOptions14, useQuery as useQuery14 } from "@tanstack/react-query";
1347
+ import { z as z14 } from "zod";
1203
1348
  var UseListOffersForCollectibleArgsSchema = listOffersForCollectibleArgsSchema.extend({
1204
- chainId: ChainIdSchema.pipe(z13.coerce.string()),
1205
- collectionAddress: z13.string(),
1206
- collectibleId: z13.string()
1349
+ chainId: ChainIdSchema.pipe(z14.coerce.string()),
1350
+ collectionAddress: z14.string(),
1351
+ collectibleId: z14.string()
1207
1352
  }).omit({ contractAddress: true, tokenId: true });
1208
1353
  var fetchListOffersForCollectible = async (config, args) => {
1209
1354
  const arg = {
@@ -1216,26 +1361,26 @@ var fetchListOffersForCollectible = async (config, args) => {
1216
1361
  return marketplaceClient.listCollectibleOffers(arg);
1217
1362
  };
1218
1363
  var listOffersForCollectibleOptions = (args, config) => {
1219
- return queryOptions13({
1364
+ return queryOptions14({
1220
1365
  queryKey: [...collectableKeys.offers, args, config],
1221
1366
  queryFn: () => fetchListOffersForCollectible(config, args)
1222
1367
  });
1223
1368
  };
1224
1369
  var useListOffersForCollectible = (args) => {
1225
- const config = useConfig();
1226
- return useQuery13(listOffersForCollectibleOptions(args, config));
1370
+ const config = useConfig2();
1371
+ return useQuery14(listOffersForCollectibleOptions(args, config));
1227
1372
  };
1228
1373
 
1229
1374
  // src/react/hooks/useCountOffersForCollectible.tsx
1230
- import { queryOptions as queryOptions14, useQuery as useQuery14 } from "@tanstack/react-query";
1231
- import { z as z14 } from "zod";
1375
+ import { queryOptions as queryOptions15, useQuery as useQuery15 } from "@tanstack/react-query";
1376
+ import { z as z15 } from "zod";
1232
1377
  var UseCountOffersForCollectibleArgsSchema = countOffersForCollectibleArgsSchema.omit({
1233
1378
  contractAddress: true,
1234
1379
  tokenId: true
1235
1380
  }).extend({
1236
1381
  collectionAddress: AddressSchema,
1237
- collectibleId: z14.string(),
1238
- chainId: ChainIdSchema.pipe(z14.coerce.string()),
1382
+ collectibleId: z15.string(),
1383
+ chainId: ChainIdSchema.pipe(z15.coerce.string()),
1239
1384
  query: QueryArgSchema
1240
1385
  });
1241
1386
  var fetchCountOffersForCollectible = async (args, config) => {
@@ -1248,24 +1393,24 @@ var fetchCountOffersForCollectible = async (args, config) => {
1248
1393
  });
1249
1394
  };
1250
1395
  var countOffersForCollectibleOptions = (args, config) => {
1251
- return queryOptions14({
1396
+ return queryOptions15({
1252
1397
  ...args.query,
1253
1398
  queryKey: [...collectableKeys.offersCount, args, config],
1254
1399
  queryFn: () => fetchCountOffersForCollectible(args, config)
1255
1400
  });
1256
1401
  };
1257
1402
  var useCountOffersForCollectible = (args) => {
1258
- const config = useConfig();
1259
- return useQuery14(countOffersForCollectibleOptions(args, config));
1403
+ const config = useConfig2();
1404
+ return useQuery15(countOffersForCollectibleOptions(args, config));
1260
1405
  };
1261
1406
 
1262
1407
  // src/react/hooks/useListListingsForCollectible.tsx
1263
- import { queryOptions as queryOptions15, useQuery as useQuery15 } from "@tanstack/react-query";
1264
- import { z as z15 } from "zod";
1408
+ import { queryOptions as queryOptions16, useQuery as useQuery16 } from "@tanstack/react-query";
1409
+ import { z as z16 } from "zod";
1265
1410
  var UseListListingsForCollectibleArgsSchema = listListingsForCollectibleArgsSchema.extend({
1266
- chainId: ChainIdSchema.pipe(z15.coerce.string()),
1267
- collectionAddress: z15.string(),
1268
- collectibleId: z15.string()
1411
+ chainId: ChainIdSchema.pipe(z16.coerce.string()),
1412
+ collectionAddress: z16.string(),
1413
+ collectibleId: z16.string()
1269
1414
  }).omit({ contractAddress: true, tokenId: true });
1270
1415
  var fetchListListingsForCollectible = async (config, args) => {
1271
1416
  const arg = {
@@ -1278,26 +1423,26 @@ var fetchListListingsForCollectible = async (config, args) => {
1278
1423
  return marketplaceClient.listCollectibleListings(arg);
1279
1424
  };
1280
1425
  var listListingsForCollectibleOptions = (args, config) => {
1281
- return queryOptions15({
1426
+ return queryOptions16({
1282
1427
  queryKey: [...collectableKeys.listings, args, config],
1283
1428
  queryFn: () => fetchListListingsForCollectible(config, args)
1284
1429
  });
1285
1430
  };
1286
1431
  var useListListingsForCollectible = (args) => {
1287
- const config = useConfig();
1288
- return useQuery15(listListingsForCollectibleOptions(args, config));
1432
+ const config = useConfig2();
1433
+ return useQuery16(listListingsForCollectibleOptions(args, config));
1289
1434
  };
1290
1435
 
1291
1436
  // src/react/hooks/useCountListingsForCollectible.tsx
1292
- import { queryOptions as queryOptions16, useQuery as useQuery16 } from "@tanstack/react-query";
1293
- import { z as z16 } from "zod";
1437
+ import { queryOptions as queryOptions17, useQuery as useQuery17 } from "@tanstack/react-query";
1438
+ import { z as z17 } from "zod";
1294
1439
  var UseCountListingsForCollectibleArgsSchema = countListingsForCollectibleArgsSchema.omit({
1295
1440
  contractAddress: true,
1296
1441
  tokenId: true
1297
1442
  }).extend({
1298
1443
  collectionAddress: AddressSchema,
1299
- collectibleId: z16.string(),
1300
- chainId: ChainIdSchema.pipe(z16.coerce.string()),
1444
+ collectibleId: z17.string(),
1445
+ chainId: ChainIdSchema.pipe(z17.coerce.string()),
1301
1446
  query: QueryArgSchema
1302
1447
  });
1303
1448
  var fetchCountListingsForCollectible = async (args, config) => {
@@ -1310,25 +1455,25 @@ var fetchCountListingsForCollectible = async (args, config) => {
1310
1455
  });
1311
1456
  };
1312
1457
  var countListingsForCollectibleOptions = (args, config) => {
1313
- return queryOptions16({
1458
+ return queryOptions17({
1314
1459
  ...args.query,
1315
1460
  queryKey: [...collectableKeys.listingsCount, args, config],
1316
1461
  queryFn: () => fetchCountListingsForCollectible(args, config)
1317
1462
  });
1318
1463
  };
1319
1464
  var useCountListingsForCollectible = (args) => {
1320
- const config = useConfig();
1321
- return useQuery16(countListingsForCollectibleOptions(args, config));
1465
+ const config = useConfig2();
1466
+ return useQuery17(countListingsForCollectibleOptions(args, config));
1322
1467
  };
1323
1468
 
1324
1469
  // src/react/hooks/useLowestListing.tsx
1325
- import { queryOptions as queryOptions17, useQuery as useQuery17 } from "@tanstack/react-query";
1326
- import { z as z17 } from "zod";
1470
+ import { queryOptions as queryOptions18, useQuery as useQuery18 } from "@tanstack/react-query";
1471
+ import { z as z18 } from "zod";
1327
1472
  var UseLowestListingSchema = getCollectibleLowestListingArgsSchema.omit({
1328
1473
  contractAddress: true
1329
1474
  }).extend({
1330
1475
  collectionAddress: AddressSchema,
1331
- chainId: ChainIdSchema.pipe(z17.coerce.string()),
1476
+ chainId: ChainIdSchema.pipe(z18.coerce.string()),
1332
1477
  query: QueryArgSchema
1333
1478
  });
1334
1479
  var fetchLowestListing = async (args, config) => {
@@ -1340,25 +1485,25 @@ var fetchLowestListing = async (args, config) => {
1340
1485
  });
1341
1486
  };
1342
1487
  var lowestListingOptions = (args, config) => {
1343
- return queryOptions17({
1488
+ return queryOptions18({
1344
1489
  ...args.query,
1345
1490
  queryKey: [...collectableKeys.lowestListings, args, config],
1346
1491
  queryFn: () => fetchLowestListing(args, config)
1347
1492
  });
1348
1493
  };
1349
1494
  var useLowestListing = (args) => {
1350
- const config = useConfig();
1351
- return useQuery17(lowestListingOptions(args, config));
1495
+ const config = useConfig2();
1496
+ return useQuery18(lowestListingOptions(args, config));
1352
1497
  };
1353
1498
 
1354
1499
  // src/react/hooks/useRoyaltyPercentage.tsx
1355
- import { queryOptions as queryOptions18, useQuery as useQuery18 } from "@tanstack/react-query";
1500
+ import { queryOptions as queryOptions19, useQuery as useQuery19 } from "@tanstack/react-query";
1356
1501
  import { getContract } from "viem";
1357
- import { z as z18 } from "zod";
1358
- var UseRoyaletyPercentageSchema = z18.object({
1359
- chainId: ChainIdSchema.pipe(z18.coerce.string()),
1502
+ import { z as z19 } from "zod";
1503
+ var UseRoyaletyPercentageSchema = z19.object({
1504
+ chainId: ChainIdSchema.pipe(z19.coerce.string()),
1360
1505
  collectionAddress: AddressSchema,
1361
- collectibleId: z18.string(),
1506
+ collectibleId: z19.string(),
1362
1507
  query: QueryArgSchema
1363
1508
  });
1364
1509
  var fetchRoyaletyPercentage = async (args) => {
@@ -1379,13 +1524,13 @@ var fetchRoyaletyPercentage = async (args) => {
1379
1524
  return 0n;
1380
1525
  }
1381
1526
  };
1382
- var royaletyPercentageOptions = (args) => queryOptions18({
1527
+ var royaletyPercentageOptions = (args) => queryOptions19({
1383
1528
  ...args.query,
1384
1529
  queryKey: [...collectableKeys.royaltyPercentage, args],
1385
1530
  queryFn: () => fetchRoyaletyPercentage(args)
1386
1531
  });
1387
1532
  var useRoyaltyPercentage = (args) => {
1388
- return useQuery18(royaletyPercentageOptions(args));
1533
+ return useQuery19(royaletyPercentageOptions(args));
1389
1534
  };
1390
1535
 
1391
1536
  // src/react/hooks/useGenerateListingTransaction.tsx
@@ -1407,7 +1552,7 @@ var generateListingTransaction = async (params, config, chainId) => {
1407
1552
  return (await marketplaceClient.generateListingTransaction(args)).steps;
1408
1553
  };
1409
1554
  var useGenerateListingTransaction = (params) => {
1410
- const config = useConfig();
1555
+ const config = useConfig2();
1411
1556
  const { mutate, mutateAsync, ...result } = useMutation({
1412
1557
  onSuccess: params.onSuccess,
1413
1558
  mutationFn: (args) => generateListingTransaction(args, config, params.chainId)
@@ -1430,7 +1575,7 @@ var generateOfferTransaction = async (params, config, chainId) => {
1430
1575
  return (await marketplaceClient.generateOfferTransaction(args)).steps;
1431
1576
  };
1432
1577
  var useGenerateOfferTransaction = (params) => {
1433
- const config = useConfig();
1578
+ const config = useConfig2();
1434
1579
  const { mutate, mutateAsync, ...result } = useMutation2({
1435
1580
  onSuccess: params.onSuccess,
1436
1581
  mutationFn: (args) => generateOfferTransaction(args, config, params.chainId)
@@ -1444,18 +1589,18 @@ var useGenerateOfferTransaction = (params) => {
1444
1589
 
1445
1590
  // src/react/hooks/useGenerateSellTransaction.tsx
1446
1591
  import { useMutation as useMutation3 } from "@tanstack/react-query";
1447
- import { z as z19 } from "zod";
1448
- var UserGeneratSellTransactionArgsSchema = z19.object({
1449
- chainId: ChainIdSchema.pipe(z19.coerce.string()),
1450
- onSuccess: z19.function().args(stepSchema.array().optional()).optional()
1592
+ import { z as z20 } from "zod";
1593
+ var UserGeneratSellTransactionArgsSchema = z20.object({
1594
+ chainId: ChainIdSchema.pipe(z20.coerce.string()),
1595
+ onSuccess: z20.function().args(stepSchema.array().optional()).optional()
1451
1596
  });
1452
1597
  var generateSellTransaction = async (args, config, chainId) => {
1453
- const parsedChainId = ChainIdSchema.pipe(z19.coerce.string()).parse(chainId);
1598
+ const parsedChainId = ChainIdSchema.pipe(z20.coerce.string()).parse(chainId);
1454
1599
  const marketplaceClient = getMarketplaceClient(parsedChainId, config);
1455
1600
  return marketplaceClient.generateSellTransaction(args).then((data) => data.steps);
1456
1601
  };
1457
1602
  var useGenerateSellTransaction = (params) => {
1458
- const config = useConfig();
1603
+ const config = useConfig2();
1459
1604
  const { mutate, mutateAsync, ...result } = useMutation3({
1460
1605
  onSuccess: params.onSuccess,
1461
1606
  mutationFn: (args) => generateSellTransaction(args, config, params.chainId)
@@ -1469,18 +1614,18 @@ var useGenerateSellTransaction = (params) => {
1469
1614
 
1470
1615
  // src/react/hooks/useGenerateCancelTransaction.tsx
1471
1616
  import { useMutation as useMutation4 } from "@tanstack/react-query";
1472
- import { z as z20 } from "zod";
1473
- var UserGenerateCancelTransactionArgsSchema = z20.object({
1474
- chainId: ChainIdSchema.pipe(z20.coerce.string()),
1475
- onSuccess: z20.function().args(stepSchema.array().optional()).optional()
1617
+ import { z as z21 } from "zod";
1618
+ var UserGenerateCancelTransactionArgsSchema = z21.object({
1619
+ chainId: ChainIdSchema.pipe(z21.coerce.string()),
1620
+ onSuccess: z21.function().args(stepSchema.array().optional()).optional()
1476
1621
  });
1477
1622
  var generateCancelTransaction = async (args, config, chainId) => {
1478
- const parsedChainId = ChainIdSchema.pipe(z20.coerce.string()).parse(chainId);
1623
+ const parsedChainId = ChainIdSchema.pipe(z21.coerce.string()).parse(chainId);
1479
1624
  const marketplaceClient = getMarketplaceClient(parsedChainId, config);
1480
1625
  return marketplaceClient.generateCancelTransaction(args).then((data) => data.steps);
1481
1626
  };
1482
1627
  var useGenerateCancelTransaction = (params) => {
1483
- const config = useConfig();
1628
+ const config = useConfig2();
1484
1629
  const { mutate, mutateAsync, ...result } = useMutation4({
1485
1630
  onSuccess: params.onSuccess,
1486
1631
  mutationFn: (args) => generateCancelTransaction(args, config, params.chainId)
@@ -1494,7 +1639,7 @@ var useGenerateCancelTransaction = (params) => {
1494
1639
 
1495
1640
  // src/react/hooks/useTransferTokens.tsx
1496
1641
  import { erc721Abi } from "viem";
1497
- import { useAccount, useWriteContract } from "wagmi";
1642
+ import { useAccount as useAccount2, useWriteContract } from "wagmi";
1498
1643
  var prepareTransferConfig = (params, accountAddress) => {
1499
1644
  if (params.contractType === "ERC721") {
1500
1645
  return {
@@ -1523,7 +1668,7 @@ var prepareTransferConfig = (params, accountAddress) => {
1523
1668
  };
1524
1669
  };
1525
1670
  var useTransferTokens = () => {
1526
- const { address: accountAddress } = useAccount();
1671
+ const { address: accountAddress } = useAccount2();
1527
1672
  const {
1528
1673
  writeContractAsync,
1529
1674
  data: hash,
@@ -1548,16 +1693,16 @@ var useTransferTokens = () => {
1548
1693
  };
1549
1694
 
1550
1695
  // src/react/hooks/useCheckoutOptions.tsx
1551
- import { queryOptions as queryOptions19, useQuery as useQuery19 } from "@tanstack/react-query";
1552
- import { useAccount as useAccount2 } from "wagmi";
1553
- import { z as z21 } from "zod";
1554
- var UseCheckoutOptionsSchema = z21.object({
1555
- chainId: ChainIdSchema.pipe(z21.coerce.string()),
1556
- orders: z21.array(
1557
- z21.object({
1696
+ import { queryOptions as queryOptions20, useQuery as useQuery20 } from "@tanstack/react-query";
1697
+ import { useAccount as useAccount3 } from "wagmi";
1698
+ import { z as z22 } from "zod";
1699
+ var UseCheckoutOptionsSchema = z22.object({
1700
+ chainId: ChainIdSchema.pipe(z22.coerce.string()),
1701
+ orders: z22.array(
1702
+ z22.object({
1558
1703
  collectionAddress: AddressSchema,
1559
- orderId: z21.string(),
1560
- marketplace: z21.nativeEnum(MarketplaceKind)
1704
+ orderId: z22.string(),
1705
+ marketplace: z22.nativeEnum(MarketplaceKind)
1561
1706
  })
1562
1707
  ),
1563
1708
  query: QueryArgSchema
@@ -1576,24 +1721,24 @@ var fetchCheckoutOptions = async (args, config) => {
1576
1721
  });
1577
1722
  };
1578
1723
  var checkoutOptionsOptions = (args, config) => {
1579
- return queryOptions19({
1724
+ return queryOptions20({
1580
1725
  queryKey: ["checkoutOptions", args],
1581
1726
  queryFn: () => fetchCheckoutOptions(args, config)
1582
1727
  });
1583
1728
  };
1584
1729
  var useCheckoutOptions = (args) => {
1585
- const { address } = useAccount2();
1586
- const config = useConfig();
1587
- return useQuery19(
1730
+ const { address } = useAccount3();
1731
+ const config = useConfig2();
1732
+ return useQuery20(
1588
1733
  // biome-ignore lint/style/noNonNullAssertion: <explanation>
1589
1734
  checkoutOptionsOptions({ walletAddress: address, ...args }, config)
1590
1735
  );
1591
1736
  };
1592
1737
 
1593
1738
  // src/react/hooks/useListCollections.tsx
1594
- import { queryOptions as queryOptions20, useQuery as useQuery20 } from "@tanstack/react-query";
1595
- import { z as z22 } from "zod";
1596
- var UseListCollectionsSchema = z22.object({
1739
+ import { queryOptions as queryOptions21, useQuery as useQuery21 } from "@tanstack/react-query";
1740
+ import { z as z23 } from "zod";
1741
+ var UseListCollectionsSchema = z23.object({
1597
1742
  query: QueryArgSchema.optional().default({})
1598
1743
  });
1599
1744
  var fetchListCollections = async ({ marketplaceConfig }, config) => {
@@ -1619,16 +1764,16 @@ var fetchListCollections = async ({ marketplaceConfig }, config) => {
1619
1764
  return results.flat();
1620
1765
  };
1621
1766
  var listCollectionsOptions = (args, config) => {
1622
- return queryOptions20({
1767
+ return queryOptions21({
1623
1768
  ...args.query,
1624
1769
  queryKey: [...collectionKeys.list],
1625
1770
  queryFn: () => fetchListCollections(args, config)
1626
1771
  });
1627
1772
  };
1628
1773
  var useListCollections = (args = {}) => {
1629
- const config = useConfig();
1774
+ const config = useConfig2();
1630
1775
  const { data: marketplaceConfig, isLoading: isLoadingConfig } = useMarketplaceConfig();
1631
- return useQuery20({
1776
+ return useQuery21({
1632
1777
  ...listCollectionsOptions(
1633
1778
  // biome-ignore lint/style/noNonNullAssertion: <explanation>
1634
1779
  { marketplaceConfig, query: args.query },
@@ -1639,21 +1784,21 @@ var useListCollections = (args = {}) => {
1639
1784
  };
1640
1785
 
1641
1786
  // src/react/hooks/useGenerateBuyTransaction.tsx
1642
- import { queryOptions as queryOptions21, useQuery as useQuery21 } from "@tanstack/react-query";
1643
- import { useAccount as useAccount3 } from "wagmi";
1644
- import { z as z23 } from "zod";
1645
- var UseGenerateBuyTransactionArgsSchema = z23.object({
1646
- chainId: ChainIdSchema.pipe(z23.coerce.string()),
1787
+ import { queryOptions as queryOptions22, useQuery as useQuery22 } from "@tanstack/react-query";
1788
+ import { useAccount as useAccount4 } from "wagmi";
1789
+ import { z as z24 } from "zod";
1790
+ var UseGenerateBuyTransactionArgsSchema = z24.object({
1791
+ chainId: ChainIdSchema.pipe(z24.coerce.string()),
1647
1792
  collectionAddress: AddressSchema,
1648
- marketplace: z23.nativeEnum(MarketplaceKind),
1649
- ordersData: z23.array(
1650
- z23.object({
1651
- orderId: z23.string(),
1652
- quantity: z23.string(),
1653
- marketplace: z23.string()
1793
+ marketplace: z24.nativeEnum(MarketplaceKind),
1794
+ ordersData: z24.array(
1795
+ z24.object({
1796
+ orderId: z24.string(),
1797
+ quantity: z24.string(),
1798
+ marketplace: z24.string()
1654
1799
  })
1655
1800
  ),
1656
- walletType: z23.nativeEnum(WalletKind).optional(),
1801
+ walletType: z24.nativeEnum(WalletKind).optional(),
1657
1802
  query: QueryArgSchema
1658
1803
  });
1659
1804
  var fetchGenerateBuyTransaction = async (args, config) => {
@@ -1667,23 +1812,443 @@ var fetchGenerateBuyTransaction = async (args, config) => {
1667
1812
  }).then((data) => data.steps);
1668
1813
  };
1669
1814
  var generateBuyTransactionOptions = (args, config) => {
1670
- return queryOptions21({
1815
+ return queryOptions22({
1671
1816
  queryKey: ["generateBuyTransaction", args],
1672
1817
  queryFn: () => fetchGenerateBuyTransaction(args, config),
1673
1818
  ...args.query
1674
1819
  });
1675
1820
  };
1676
1821
  var useGenerateBuyTransaction = (args) => {
1677
- const { address } = useAccount3();
1678
- const config = useConfig();
1679
- return useQuery21(
1822
+ const { address } = useAccount4();
1823
+ const config = useConfig2();
1824
+ return useQuery22(
1680
1825
  // biome-ignore lint/style/noNonNullAssertion: <explanation>
1681
1826
  generateBuyTransactionOptions({ buyer: address, ...args }, config)
1682
1827
  );
1683
1828
  };
1684
1829
 
1685
1830
  // src/react/hooks/useCancelOrder.tsx
1686
- import { useState } from "react";
1831
+ import { useState, useEffect } from "react";
1832
+
1833
+ // src/react/_internal/wallet/useWallet.ts
1834
+ import { useAccount as useAccount5, useChainId, useSwitchChain, useWalletClient } from "wagmi";
1835
+ import { useQuery as useQuery23 } from "@tanstack/react-query";
1836
+
1837
+ // src/react/_internal/wallet/wallet.ts
1838
+ import {
1839
+ TransactionReceiptNotFoundError,
1840
+ WaitForTransactionReceiptTimeoutError,
1841
+ custom,
1842
+ erc20Abi,
1843
+ erc721Abi as erc721Abi2,
1844
+ hexToBigInt,
1845
+ isHex
1846
+ } from "viem";
1847
+
1848
+ // src/react/_internal/logger.ts
1849
+ var TransactionLogger = class {
1850
+ constructor(context, enabled = true) {
1851
+ this.context = context;
1852
+ this.enabled = enabled;
1853
+ }
1854
+ formatData(data) {
1855
+ if (data instanceof Error) {
1856
+ return {
1857
+ name: data.name,
1858
+ message: data.message,
1859
+ cause: data.cause instanceof Error ? this.formatData(data.cause) : data.cause,
1860
+ stack: data.stack?.split("\n").slice(0, 3)
1861
+ };
1862
+ }
1863
+ if (Array.isArray(data)) {
1864
+ return data.map((item) => this.formatData(item));
1865
+ }
1866
+ if (typeof data === "object" && data !== null) {
1867
+ return Object.fromEntries(
1868
+ Object.entries(data).map(([key, value]) => [
1869
+ key,
1870
+ this.formatData(value)
1871
+ ])
1872
+ );
1873
+ }
1874
+ return data;
1875
+ }
1876
+ log(level, message, data) {
1877
+ if (!this.enabled) return;
1878
+ console[level](
1879
+ `[${this.context}] ${message}`,
1880
+ data ? this.formatData(data) : ""
1881
+ );
1882
+ }
1883
+ debug(message, data) {
1884
+ this.log("debug", message, data);
1885
+ }
1886
+ error(message, error) {
1887
+ this.log("error", message, error);
1888
+ }
1889
+ info(message, data) {
1890
+ this.log("info", message, data);
1891
+ }
1892
+ state(from, to) {
1893
+ this.info(`State transition: ${from} -> ${to}`);
1894
+ }
1895
+ };
1896
+ var createLogger = (context, enabled = true) => new TransactionLogger(context, enabled);
1897
+
1898
+ // src/react/_internal/wallet/wallet.ts
1899
+ var wallet = ({
1900
+ wallet: wallet2,
1901
+ chains,
1902
+ connector,
1903
+ sdkConfig
1904
+ }) => {
1905
+ const logger = createLogger("Wallet");
1906
+ const walletInstance = {
1907
+ transport: custom(wallet2.transport),
1908
+ isWaaS: connector.id.endsWith("waas"),
1909
+ walletKind: connector.id === "sequence" ? "sequence" /* sequence */ : "unknown" /* unknown */,
1910
+ getChainId: wallet2.getChainId,
1911
+ address: async () => {
1912
+ let address = wallet2.account?.address;
1913
+ if (!address) {
1914
+ [address] = await wallet2.getAddresses();
1915
+ }
1916
+ return address;
1917
+ },
1918
+ switchChain: async (chainId) => {
1919
+ logger.debug("Switching chain", { targetChainId: chainId });
1920
+ try {
1921
+ await wallet2.switchChain({
1922
+ id: chainId
1923
+ });
1924
+ logger.info("Chain switch successful", { chainId });
1925
+ return;
1926
+ } catch (e) {
1927
+ const error = e;
1928
+ logger.error("Chain switch failed", error);
1929
+ switch (error.name) {
1930
+ case "SwitchChainNotSupportedError":
1931
+ throw new ChainSwitchError(await wallet2.getChainId(), chainId);
1932
+ case "UserRejectedRequestError":
1933
+ throw new UserRejectedRequestError();
1934
+ case "ChainNotConfiguredError":
1935
+ return;
1936
+ default:
1937
+ throw new ChainSwitchError(await wallet2.getChainId(), chainId);
1938
+ }
1939
+ }
1940
+ },
1941
+ handleSignMessageStep: async (stepItem) => {
1942
+ try {
1943
+ if (stepItem.id === "signEIP191" /* signEIP191 */) {
1944
+ logger.debug("Signing with EIP-191", { data: stepItem.data });
1945
+ const message = isHex(stepItem.data) ? { raw: stepItem.data } : stepItem.data;
1946
+ return await wallet2.signMessage({
1947
+ account: wallet2.account,
1948
+ message
1949
+ });
1950
+ } else if (stepItem.id === "signEIP712" /* signEIP712 */) {
1951
+ logger.debug("Signing with EIP-712", {
1952
+ domain: stepItem.domain,
1953
+ types: stepItem.signature?.types
1954
+ });
1955
+ return await wallet2.signTypedData({
1956
+ account: wallet2.account,
1957
+ domain: stepItem.signature.domain,
1958
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
1959
+ types: stepItem.signature.types,
1960
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
1961
+ primaryType: stepItem.signature.primaryType,
1962
+ // biome-ignore lint/style/noNonNullAssertion: <explanation>
1963
+ message: stepItem.signature.value
1964
+ });
1965
+ }
1966
+ } catch (error) {
1967
+ logger.error("Signature failed", error);
1968
+ throw new TransactionSignatureError(stepItem.id, error);
1969
+ }
1970
+ },
1971
+ handleSendTransactionStep: async (chainId, stepItem) => {
1972
+ logger.debug("Sending transaction", {
1973
+ chainId,
1974
+ to: stepItem.to,
1975
+ value: stepItem.value
1976
+ });
1977
+ const chain = chains.find((chain2) => chain2.id === chainId);
1978
+ try {
1979
+ return await wallet2.sendTransaction({
1980
+ chain,
1981
+ data: stepItem.data,
1982
+ account: wallet2.account,
1983
+ to: stepItem.to,
1984
+ value: hexToBigInt(stepItem.value || "0x0"),
1985
+ ...stepItem.maxFeePerGas && {
1986
+ maxFeePerGas: hexToBigInt(stepItem.maxFeePerGas)
1987
+ },
1988
+ ...stepItem.maxPriorityFeePerGas && {
1989
+ maxPriorityFeePerGas: hexToBigInt(stepItem.maxPriorityFeePerGas)
1990
+ },
1991
+ ...stepItem.gas && {
1992
+ gas: hexToBigInt(stepItem.gas)
1993
+ }
1994
+ });
1995
+ } catch (error) {
1996
+ logger.error("Transaction failed", error);
1997
+ throw new TransactionExecutionError(stepItem.id, error);
1998
+ }
1999
+ },
2000
+ handleConfirmTransactionStep: async (txHash, chainId) => {
2001
+ logger.debug("Confirming transaction", { txHash, chainId });
2002
+ try {
2003
+ const receipt = await awaitTransactionReceipt({
2004
+ txHash,
2005
+ chainId,
2006
+ sdkConfig
2007
+ });
2008
+ logger.info("Transaction confirmed", { txHash, receipt });
2009
+ return receipt;
2010
+ } catch (error) {
2011
+ logger.error("Transaction confirmation failed", error);
2012
+ throw new TransactionConfirmationError(txHash, error);
2013
+ }
2014
+ },
2015
+ hasTokenApproval: async ({
2016
+ tokenType,
2017
+ contractAddress,
2018
+ spender
2019
+ }) => {
2020
+ const publicClient = getPublicRpcClient(await wallet2.getChainId());
2021
+ const walletAddress = await walletInstance.address();
2022
+ const spenderAddress = spender === "sequenceMarketV1" ? SEQUENCE_MARKET_V1_ADDRESS : spender === "sequenceMarketV2" ? SEQUENCE_MARKET_V2_ADDRESS : spender;
2023
+ switch (tokenType) {
2024
+ case "ERC20":
2025
+ return await publicClient.readContract({
2026
+ address: contractAddress,
2027
+ abi: erc20Abi,
2028
+ functionName: "allowance",
2029
+ args: [walletAddress, spenderAddress]
2030
+ });
2031
+ case "ERC721":
2032
+ return await publicClient.readContract({
2033
+ address: contractAddress,
2034
+ abi: erc721Abi2,
2035
+ functionName: "isApprovedForAll",
2036
+ args: [walletAddress, spenderAddress]
2037
+ });
2038
+ case "ERC1155":
2039
+ return await publicClient.readContract({
2040
+ address: contractAddress,
2041
+ abi: ERC1155_ABI,
2042
+ functionName: "isApprovedForAll",
2043
+ args: [walletAddress, spenderAddress]
2044
+ });
2045
+ default:
2046
+ throw new Error("Unsupported contract type for approval checking");
2047
+ }
2048
+ }
2049
+ };
2050
+ return walletInstance;
2051
+ };
2052
+ var ONE_MIN = 60 * 1e3;
2053
+ var THREE_MIN = 3 * ONE_MIN;
2054
+ var awaitTransactionReceipt = async ({
2055
+ txHash,
2056
+ chainId,
2057
+ sdkConfig,
2058
+ timeout = THREE_MIN
2059
+ }) => {
2060
+ const indexer = getIndexerClient(chainId, sdkConfig);
2061
+ return Promise.race([
2062
+ new Promise((resolve, reject) => {
2063
+ indexer.subscribeReceipts(
2064
+ {
2065
+ filter: {
2066
+ txnHash: txHash
2067
+ }
2068
+ },
2069
+ {
2070
+ onMessage: ({ receipt }) => {
2071
+ resolve(receipt);
2072
+ },
2073
+ onError: () => {
2074
+ reject(TransactionReceiptNotFoundError);
2075
+ }
2076
+ }
2077
+ );
2078
+ }),
2079
+ new Promise((_, reject) => {
2080
+ setTimeout(() => {
2081
+ reject(WaitForTransactionReceiptTimeoutError);
2082
+ }, timeout);
2083
+ })
2084
+ ]);
2085
+ };
2086
+
2087
+ // src/react/_internal/wallet/useWallet.ts
2088
+ var useWallet = () => {
2089
+ const { chains } = useSwitchChain();
2090
+ const { data: walletClient, isLoading: wagmiWalletIsLoading } = useWalletClient();
2091
+ const { connector, isConnected, isConnecting } = useAccount5();
2092
+ const sdkConfig = useConfig2();
2093
+ const chainId = useChainId();
2094
+ const { data, isLoading, isError } = useQuery23({
2095
+ queryKey: ["wallet", chainId, connector?.uid],
2096
+ queryFn: () => {
2097
+ if (!walletClient || !connector || !isConnected) {
2098
+ return null;
2099
+ }
2100
+ return wallet({
2101
+ wallet: walletClient,
2102
+ chains,
2103
+ connector,
2104
+ sdkConfig
2105
+ });
2106
+ },
2107
+ staleTime: Number.POSITIVE_INFINITY,
2108
+ enabled: Boolean(walletClient && connector && isConnected)
2109
+ });
2110
+ return {
2111
+ wallet: data,
2112
+ isLoading: isLoading || isConnecting || wagmiWalletIsLoading,
2113
+ isError
2114
+ };
2115
+ };
2116
+
2117
+ // src/react/ui/modals/_internal/components/switchChainModal/index.tsx
2118
+ import {
2119
+ Button,
2120
+ CloseIcon,
2121
+ IconButton,
2122
+ Spinner,
2123
+ Text as Text2
2124
+ } from "@0xsequence/design-system";
2125
+ import { observer } from "@legendapp/state/react";
2126
+ import { Close, Content, Overlay, Portal, Root } from "@radix-ui/react-dialog";
2127
+ import { useSwitchChain as useSwitchChain2 } from "wagmi";
2128
+
2129
+ // src/react/ui/modals/_internal/components/alertMessage/index.tsx
2130
+ import { Box, Text, WarningIcon } from "@0xsequence/design-system";
2131
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
2132
+ function AlertMessage({ message, type }) {
2133
+ return /* @__PURE__ */ jsxs(Box, { className: `${alertMessageBox} ${alertMessageBoxVariants[type]}`, children: [
2134
+ /* @__PURE__ */ jsx2(
2135
+ Text,
2136
+ {
2137
+ color: "white",
2138
+ fontSize: "normal",
2139
+ fontWeight: "medium",
2140
+ fontFamily: "body",
2141
+ children: message
2142
+ }
2143
+ ),
2144
+ type === "warning" && /* @__PURE__ */ jsx2(WarningIcon, { size: "sm", color: "white" }),
2145
+ type === "info" && /* @__PURE__ */ jsx2(InfoIcon_default, { size: "sm", color: "white" })
2146
+ ] });
2147
+ }
2148
+
2149
+ // src/react/ui/modals/_internal/components/switchChainModal/store.ts
2150
+ import { observable } from "@legendapp/state";
2151
+ var initialState = {
2152
+ isOpen: false,
2153
+ open: ({ chainIdToSwitchTo, onError, onSuccess, onClose }) => {
2154
+ switchChainModal$.state.set({
2155
+ ...switchChainModal$.state.get(),
2156
+ chainIdToSwitchTo,
2157
+ onError,
2158
+ onSuccess,
2159
+ onClose
2160
+ });
2161
+ switchChainModal$.isOpen.set(true);
2162
+ },
2163
+ close: () => {
2164
+ switchChainModal$.isOpen.set(false);
2165
+ },
2166
+ state: {
2167
+ chainIdToSwitchTo: void 0,
2168
+ onError: void 0,
2169
+ onSuccess: void 0,
2170
+ onClose: void 0,
2171
+ isSwitching: false
2172
+ }
2173
+ };
2174
+ var switchChainModal$ = observable(initialState);
2175
+
2176
+ // src/react/ui/modals/_internal/components/switchChainModal/index.tsx
2177
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
2178
+ var useSwitchChainModal = () => {
2179
+ return {
2180
+ show: (args) => switchChainModal$.open(args),
2181
+ close: () => switchChainModal$.delete(),
2182
+ isSwitching$: switchChainModal$.state.isSwitching
2183
+ };
2184
+ };
2185
+ var SwitchChainModal = observer(() => {
2186
+ const chainIdToSwitchTo = switchChainModal$.state.chainIdToSwitchTo.get();
2187
+ const isSwitching$ = switchChainModal$.state.isSwitching;
2188
+ const chainName = chainIdToSwitchTo ? getPresentableChainName(chainIdToSwitchTo) : "";
2189
+ const { switchChainAsync } = useSwitchChain2();
2190
+ async function handleSwitchChain() {
2191
+ isSwitching$.set(true);
2192
+ try {
2193
+ if (!chainIdToSwitchTo) return;
2194
+ await switchChainAsync({ chainId: Number(chainIdToSwitchTo) });
2195
+ if (switchChainModal$.state.onSuccess && typeof switchChainModal$.state.onSuccess === "function") {
2196
+ switchChainModal$.state.onSuccess();
2197
+ }
2198
+ switchChainModal$.delete();
2199
+ } catch (error) {
2200
+ if (error instanceof Error && switchChainModal$.state.onError.get() && typeof switchChainModal$.state.onError.get() === "function") {
2201
+ switchChainModal$.state.onError.get()?.(error);
2202
+ }
2203
+ } finally {
2204
+ isSwitching$.set(false);
2205
+ }
2206
+ }
2207
+ return /* @__PURE__ */ jsx3(Root, { open: switchChainModal$.isOpen.get(), children: /* @__PURE__ */ jsxs2(Portal, { container: getProviderEl(), children: [
2208
+ /* @__PURE__ */ jsx3(Overlay, { className: dialogOverlay }),
2209
+ /* @__PURE__ */ jsxs2(Content, { className: switchChainModalContent, children: [
2210
+ /* @__PURE__ */ jsx3(Text2, { fontSize: "large", fontWeight: "bold", color: "text100", children: "Wrong network" }),
2211
+ /* @__PURE__ */ jsx3(
2212
+ AlertMessage,
2213
+ {
2214
+ type: "warning",
2215
+ message: `You need to switch to ${chainName} network before completing the transaction`
2216
+ }
2217
+ ),
2218
+ /* @__PURE__ */ jsx3(
2219
+ Button,
2220
+ {
2221
+ name: "switch-chain",
2222
+ id: "switch-chain-button",
2223
+ size: "sm",
2224
+ label: isSwitching$.get() ? /* @__PURE__ */ jsx3(Spinner, { "data-testid": "switch-chain-spinner" }) : "Switch Network",
2225
+ variant: "primary",
2226
+ pending: isSwitching$.get(),
2227
+ shape: "square",
2228
+ className: isSwitching$.get() ? switchChainCta.pending : switchChainCta.default,
2229
+ justifySelf: "flex-end",
2230
+ onClick: handleSwitchChain
2231
+ }
2232
+ ),
2233
+ /* @__PURE__ */ jsx3(
2234
+ Close,
2235
+ {
2236
+ "data-testid": "switch-chain-modal-close-button",
2237
+ onClick: () => {
2238
+ if (switchChainModal$.state.onClose && typeof switchChainModal$.state.onClose === "function") {
2239
+ switchChainModal$.state.onClose();
2240
+ }
2241
+ switchChainModal$.delete();
2242
+ },
2243
+ className: closeButton,
2244
+ asChild: true,
2245
+ children: /* @__PURE__ */ jsx3(IconButton, { size: "xs", "aria-label": "Close modal", icon: CloseIcon })
2246
+ }
2247
+ )
2248
+ ] })
2249
+ ] }) });
2250
+ });
2251
+ var switchChainModal_default = SwitchChainModal;
1687
2252
 
1688
2253
  // src/react/hooks/useCancelTransactionSteps.tsx
1689
2254
  var useCancelTransactionSteps = ({
@@ -1695,22 +2260,22 @@ var useCancelTransactionSteps = ({
1695
2260
  onError
1696
2261
  }) => {
1697
2262
  const { show: showSwitchChainModal } = useSwitchChainModal();
1698
- const { wallet, isLoading, isError } = useWallet();
1699
- const walletIsInitialized = wallet && !isLoading && !isError;
1700
- const sdkConfig = useConfig();
2263
+ const { wallet: wallet2, isLoading, isError } = useWallet();
2264
+ const walletIsInitialized = wallet2 && !isLoading && !isError;
2265
+ const sdkConfig = useConfig2();
1701
2266
  const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
1702
2267
  const { generateCancelTransactionAsync } = useGenerateCancelTransaction({
1703
2268
  chainId
1704
2269
  });
1705
2270
  const getWalletChainId = async () => {
1706
- return await wallet.getChainId();
2271
+ return await wallet2.getChainId();
1707
2272
  };
1708
2273
  const switchChain = async () => {
1709
- await wallet.switchChain(Number(chainId));
2274
+ await wallet2.switchChain(Number(chainId));
1710
2275
  };
1711
2276
  const checkAndSwitchChain = async () => {
1712
2277
  const walletChainId = await getWalletChainId();
1713
- const isWaaS = wallet?.isWaaS;
2278
+ const isWaaS = wallet2?.isWaaS;
1714
2279
  const chainIdMismatch = walletChainId !== Number(chainId);
1715
2280
  return new Promise((resolve, reject) => {
1716
2281
  if (chainIdMismatch) {
@@ -1734,7 +2299,7 @@ var useCancelTransactionSteps = ({
1734
2299
  marketplace
1735
2300
  }) => {
1736
2301
  try {
1737
- const address = await wallet.address();
2302
+ const address = await wallet2.address();
1738
2303
  const steps = await generateCancelTransactionAsync({
1739
2304
  collectionAddress,
1740
2305
  maker: address,
@@ -1780,10 +2345,10 @@ var useCancelTransactionSteps = ({
1780
2345
  throw new Error("No transaction or signature step found");
1781
2346
  }
1782
2347
  let hash, reservoirOrderId;
1783
- if (transactionStep && wallet) {
2348
+ if (transactionStep && wallet2) {
1784
2349
  hash = await executeTransaction({ transactionStep });
1785
2350
  if (hash) {
1786
- await wallet.handleConfirmTransactionStep(hash, Number(chainId));
2351
+ await wallet2.handleConfirmTransactionStep(hash, Number(chainId));
1787
2352
  if (onSuccess && typeof onSuccess === "function") {
1788
2353
  onSuccess({ hash });
1789
2354
  }
@@ -1818,7 +2383,7 @@ var useCancelTransactionSteps = ({
1818
2383
  const executeTransaction = async ({
1819
2384
  transactionStep
1820
2385
  }) => {
1821
- const hash = await wallet.handleSendTransactionStep(
2386
+ const hash = await wallet2.handleSendTransactionStep(
1822
2387
  Number(chainId),
1823
2388
  transactionStep
1824
2389
  );
@@ -1827,7 +2392,7 @@ var useCancelTransactionSteps = ({
1827
2392
  const executeSignature = async ({
1828
2393
  signatureStep
1829
2394
  }) => {
1830
- const signature = await wallet.handleSignMessageStep(
2395
+ const signature = await wallet2.handleSignMessageStep(
1831
2396
  signatureStep
1832
2397
  );
1833
2398
  const result = await marketplaceClient.execute({
@@ -1843,6 +2408,7 @@ var useCancelTransactionSteps = ({
1843
2408
  };
1844
2409
 
1845
2410
  // src/react/hooks/useCancelOrder.tsx
2411
+ import { useWaasFeeOptions } from "@0xsequence/kit";
1846
2412
  var useCancelOrder = ({
1847
2413
  collectionAddress,
1848
2414
  chainId,
@@ -1857,6 +2423,49 @@ var useCancelOrder = ({
1857
2423
  const [cancellingOrderId, setCancellingOrderId] = useState(
1858
2424
  null
1859
2425
  );
2426
+ const [pendingFeeOptionConfirmation, confirmPendingFeeOption] = useWaasFeeOptions();
2427
+ const autoSelectFeeOptionResult = useAutoSelectFeeOption({
2428
+ pendingFeeOptionConfirmation: pendingFeeOptionConfirmation ? {
2429
+ id: pendingFeeOptionConfirmation.id,
2430
+ options: pendingFeeOptionConfirmation.options?.map((opt) => ({
2431
+ ...opt,
2432
+ token: {
2433
+ ...opt.token,
2434
+ contractAddress: opt.token.contractAddress || null,
2435
+ decimals: opt.token.decimals || 0,
2436
+ tokenID: opt.token.tokenID || null
2437
+ }
2438
+ })),
2439
+ chainId: Number(chainId)
2440
+ } : {
2441
+ id: "",
2442
+ options: void 0,
2443
+ chainId: Number(chainId)
2444
+ }
2445
+ });
2446
+ useEffect(() => {
2447
+ const handleFeeOptionSelection = async () => {
2448
+ if (!pendingFeeOptionConfirmation) return;
2449
+ const { selectedOption, error } = await autoSelectFeeOptionResult;
2450
+ if (error) {
2451
+ console.error("Error selecting fee option:", error);
2452
+ onError?.(new Error(`Failed to select fee option: ${error}`));
2453
+ return;
2454
+ }
2455
+ if (selectedOption?.token.contractAddress && pendingFeeOptionConfirmation.id) {
2456
+ confirmPendingFeeOption(
2457
+ pendingFeeOptionConfirmation.id,
2458
+ selectedOption.token.contractAddress
2459
+ );
2460
+ }
2461
+ };
2462
+ handleFeeOptionSelection();
2463
+ }, [
2464
+ pendingFeeOptionConfirmation,
2465
+ autoSelectFeeOptionResult,
2466
+ confirmPendingFeeOption,
2467
+ onError
2468
+ ]);
1860
2469
  const { cancelOrder: cancelOrderBase } = useCancelTransactionSteps({
1861
2470
  collectionAddress,
1862
2471
  chainId,
@@ -1881,11 +2490,72 @@ var useCancelOrder = ({
1881
2490
  };
1882
2491
  };
1883
2492
 
2493
+ // src/react/hooks/useCollectionDetails.tsx
2494
+ import { queryOptions as queryOptions23, useQuery as useQuery24 } from "@tanstack/react-query";
2495
+ var fetchCollectionDetails = async (args, marketplaceClient) => {
2496
+ const { collection } = await marketplaceClient.getCollectionDetail({
2497
+ contractAddress: args.collectionAddress
2498
+ });
2499
+ return collection;
2500
+ };
2501
+ var collectionDetailsOptions = (args, config) => {
2502
+ const marketplaceClient = getMarketplaceClient(args.chainId, config);
2503
+ return queryOptions23({
2504
+ queryKey: ["collectionDetails", args],
2505
+ queryFn: () => fetchCollectionDetails(args, marketplaceClient)
2506
+ });
2507
+ };
2508
+ var useCollectionDetails = (args) => {
2509
+ const config = useConfig2();
2510
+ return useQuery24(collectionDetailsOptions(args, config));
2511
+ };
2512
+
2513
+ // src/react/hooks/useCollectionDetailsPolling.tsx
2514
+ import { queryOptions as queryOptions24, useQuery as useQuery25 } from "@tanstack/react-query";
2515
+ var INITIAL_POLLING_INTERVAL = 2e3;
2516
+ var MAX_POLLING_INTERVAL = 3e4;
2517
+ var MAX_ATTEMPTS = 30;
2518
+ var isTerminalState = (status) => {
2519
+ return [
2520
+ "active" /* active */,
2521
+ "failed" /* failed */,
2522
+ "inactive" /* inactive */,
2523
+ "incompatible_type" /* incompatible_type */
2524
+ ].includes(status);
2525
+ };
2526
+ var collectionDetailsPollingOptions = (args, config) => {
2527
+ return queryOptions24({
2528
+ ...collectionDetailsOptions(args, config),
2529
+ refetchInterval: (query) => {
2530
+ const data = query.state.data;
2531
+ if (data && isTerminalState(data.status)) {
2532
+ return false;
2533
+ }
2534
+ const currentAttempt = (query.state.dataUpdateCount || 0) + 1;
2535
+ if (currentAttempt >= MAX_ATTEMPTS) {
2536
+ return false;
2537
+ }
2538
+ const interval = Math.min(
2539
+ INITIAL_POLLING_INTERVAL * Math.pow(1.5, currentAttempt),
2540
+ MAX_POLLING_INTERVAL
2541
+ );
2542
+ return interval;
2543
+ },
2544
+ refetchOnWindowFocus: false,
2545
+ retry: false
2546
+ });
2547
+ };
2548
+ var useCollectionDetailsPolling = (args) => {
2549
+ const config = useConfig2();
2550
+ return useQuery25(collectionDetailsPollingOptions(args, config));
2551
+ };
2552
+
1884
2553
  export {
1885
2554
  MarketplaceSdkContext,
1886
2555
  MarketplaceQueryClientProvider,
1887
2556
  MarketplaceProvider,
1888
- useConfig,
2557
+ useAutoSelectFeeOption,
2558
+ useConfig2 as useConfig,
1889
2559
  balanceOfCollectibleOptions,
1890
2560
  useBalanceOfCollectible,
1891
2561
  countOfCollectablesOptions,
@@ -1894,6 +2564,8 @@ export {
1894
2564
  useCollectible,
1895
2565
  collectionOptions,
1896
2566
  useCollection,
2567
+ collectionBalanceDetailsOptions,
2568
+ useCollectionBalanceDetails,
1897
2569
  currenciesOptions,
1898
2570
  useCurrencies,
1899
2571
  marketplaceConfigOptions,
@@ -1947,6 +2619,14 @@ export {
1947
2619
  fetchGenerateBuyTransaction,
1948
2620
  generateBuyTransactionOptions,
1949
2621
  useGenerateBuyTransaction,
1950
- useCancelOrder
1951
- };
1952
- //# sourceMappingURL=chunk-WRMJ5FZM.js.map
2622
+ useWallet,
2623
+ AlertMessage,
2624
+ useSwitchChainModal,
2625
+ switchChainModal_default,
2626
+ useCancelOrder,
2627
+ collectionDetailsOptions,
2628
+ useCollectionDetails,
2629
+ collectionDetailsPollingOptions,
2630
+ useCollectionDetailsPolling
2631
+ };
2632
+ //# sourceMappingURL=chunk-HV2X2VZN.js.map