@0xsequence/marketplace-sdk 0.4.3 → 0.4.5

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 (78) hide show
  1. package/dist/{chunk-VYSWBIWC.js → chunk-CKOWM2ZR.js} +3 -3
  2. package/dist/{chunk-4VS5NKDD.js → chunk-FT3J32ZV.js} +2 -2
  3. package/dist/{chunk-IQXJZBMR.js → chunk-HTFBQVLV.js} +2 -2
  4. package/dist/{chunk-URX7ZHX4.js → chunk-KILOCWY2.js} +2 -2
  5. package/dist/{chunk-YZE7RXC2.js → chunk-KL5JPUPS.js} +10 -8
  6. package/dist/chunk-KL5JPUPS.js.map +1 -0
  7. package/dist/{chunk-ST6RH2IB.js → chunk-KZGDOIZY.js} +24 -575
  8. package/dist/chunk-KZGDOIZY.js.map +1 -0
  9. package/dist/{chunk-2AMLJ2TA.js → chunk-SEISACMH.js} +461 -251
  10. package/dist/chunk-SEISACMH.js.map +1 -0
  11. package/dist/{chunk-DNDPYQKV.js → chunk-YUETNNZQ.js} +1 -144
  12. package/dist/{chunk-DNDPYQKV.js.map → chunk-YUETNNZQ.js.map} +1 -1
  13. package/dist/{create-config-8sffBvlt.d.ts → create-config-DMBOGsJp.d.ts} +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +16 -16
  16. package/dist/{marketplace-config-Bbxl-uKX.d.ts → marketplace-config-0Rft6_Hv.d.ts} +2 -0
  17. package/dist/react/_internal/api/index.js +2 -2
  18. package/dist/react/_internal/index.d.ts +2 -2
  19. package/dist/react/_internal/index.js +8 -8
  20. package/dist/react/_internal/wagmi/index.d.ts +3 -2
  21. package/dist/react/_internal/wagmi/index.js +2 -2
  22. package/dist/react/hooks/index.d.ts +4 -205
  23. package/dist/react/hooks/index.js +8 -11
  24. package/dist/react/index.d.ts +7 -4
  25. package/dist/react/index.js +16 -16
  26. package/dist/react/ssr/index.d.ts +14 -0
  27. package/dist/react/ssr/index.js +10 -32
  28. package/dist/react/ssr/index.js.map +1 -1
  29. package/dist/react/ui/components/index.js +11 -11
  30. package/dist/react/ui/index.d.ts +4 -1
  31. package/dist/react/ui/index.js +11 -11
  32. package/dist/react/ui/modals/_internal/components/actionModal/index.js +8 -8
  33. package/dist/react/ui/styles/index.d.ts +1 -1
  34. package/dist/styles/index.d.ts +1 -1
  35. package/dist/types/index.d.ts +1 -1
  36. package/dist/types/index.js +3 -3
  37. package/dist/utils/abi/index.js +5 -5
  38. package/dist/utils/index.js +7 -7
  39. package/package.json +1 -1
  40. package/src/react/hooks/index.ts +0 -1
  41. package/src/react/hooks/useCancelTransactionSteps.tsx +7 -4
  42. package/src/react/hooks/useCurrency.tsx +1 -1
  43. package/src/react/provider.tsx +18 -3
  44. package/src/react/ssr/create-ssr-client.ts +9 -5
  45. package/src/react/ui/modals/BuyModal/Modal.tsx +4 -0
  46. package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +29 -2
  47. package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +8 -3
  48. package/src/react/ui/modals/BuyModal/store.ts +14 -0
  49. package/src/react/ui/modals/CreateListingModal/Modal.tsx +1 -1
  50. package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +21 -5
  51. package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +34 -28
  52. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +43 -16
  53. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +43 -9
  54. package/src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx +34 -28
  55. package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +8 -8
  56. package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +64 -22
  57. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +30 -12
  58. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +38 -54
  59. package/src/react/ui/modals/_internal/components/currencyImage/index.tsx +8 -10
  60. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +9 -1
  61. package/src/react/ui/modals/_internal/components/priceInput/hooks/useBalanceCheck.ts +67 -0
  62. package/src/react/ui/modals/_internal/components/priceInput/hooks/usePriceInput.ts +54 -0
  63. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +48 -71
  64. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +2 -1
  65. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +2 -2
  66. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +18 -9
  67. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts +12 -1
  68. package/src/react/ui/modals/_internal/types.ts +1 -1
  69. package/src/types/marketplace-config.ts +3 -0
  70. package/tsconfig.tsbuildinfo +1 -1
  71. package/dist/chunk-2AMLJ2TA.js.map +0 -1
  72. package/dist/chunk-ST6RH2IB.js.map +0 -1
  73. package/dist/chunk-YZE7RXC2.js.map +0 -1
  74. package/src/react/hooks/useBuyCollectable.tsx +0 -61
  75. /package/dist/{chunk-VYSWBIWC.js.map → chunk-CKOWM2ZR.js.map} +0 -0
  76. /package/dist/{chunk-4VS5NKDD.js.map → chunk-FT3J32ZV.js.map} +0 -0
  77. /package/dist/{chunk-IQXJZBMR.js.map → chunk-HTFBQVLV.js.map} +0 -0
  78. /package/dist/{chunk-URX7ZHX4.js.map → chunk-KILOCWY2.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  ActionModal,
4
4
  CustomSelect,
5
5
  useCurrencyBalance
6
- } from "./chunk-VYSWBIWC.js";
6
+ } from "./chunk-CKOWM2ZR.js";
7
7
  import {
8
8
  CalendarIcon_default,
9
9
  MinusIcon_default,
@@ -53,13 +53,13 @@ import {
53
53
  useMarketplaceConfig,
54
54
  useRoyaltyPercentage,
55
55
  useTransferTokens
56
- } from "./chunk-ST6RH2IB.js";
56
+ } from "./chunk-KZGDOIZY.js";
57
57
  import {
58
58
  AlertMessage,
59
59
  switchChainModal_default,
60
60
  useSwitchChainModal,
61
61
  useWallet
62
- } from "./chunk-YZE7RXC2.js";
62
+ } from "./chunk-KL5JPUPS.js";
63
63
  import {
64
64
  iconVariants
65
65
  } from "./chunk-LF44FCG5.js";
@@ -67,16 +67,20 @@ import {
67
67
  calculatePriceDifferencePercentage,
68
68
  getPublicRpcClient,
69
69
  truncateMiddle
70
- } from "./chunk-4VS5NKDD.js";
70
+ } from "./chunk-FT3J32ZV.js";
71
+ import {
72
+ getProviderEl
73
+ } from "./chunk-ZEKRTFBU.js";
71
74
  import {
72
75
  balanceQueries,
76
+ collectableKeys,
73
77
  getMarketplaceClient,
74
78
  getQueryClient
75
- } from "./chunk-URX7ZHX4.js";
79
+ } from "./chunk-KILOCWY2.js";
76
80
  import {
77
81
  InvalidContractTypeError,
78
82
  InvalidStepError
79
- } from "./chunk-DNDPYQKV.js";
83
+ } from "./chunk-YUETNNZQ.js";
80
84
 
81
85
  // src/react/ui/modals/modal-provider.tsx
82
86
  import { observer as observer14 } from "@legendapp/state/react";
@@ -100,12 +104,15 @@ var AccountModal = observer(function AccountModal2() {
100
104
  });
101
105
 
102
106
  // src/react/ui/modals/MakeOfferModal/Modal.tsx
103
- import { Show, observer as observer7 } from "@legendapp/state/react";
104
- import { useState as useState6 } from "react";
105
- import { parseUnits as parseUnits2 } from "viem";
107
+ import { Show, observer as observer7, use$ } from "@legendapp/state/react";
108
+ import { useState as useState7 } from "react";
109
+ import { parseUnits as parseUnits2, zeroAddress } from "viem";
110
+
111
+ // src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx
112
+ import { useEffect as useEffect3 } from "react";
106
113
 
107
114
  // src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx
108
- import { useQuery } from "@tanstack/react-query";
115
+ import { skipToken, useQuery } from "@tanstack/react-query";
109
116
  var ONE_DAY_IN_SECONDS = 60 * 60 * 24;
110
117
  var useGetTokenApprovalData = (params) => {
111
118
  const config = useConfig();
@@ -118,9 +125,10 @@ var useGetTokenApprovalData = (params) => {
118
125
  pricePerToken: "100000",
119
126
  expiry: String(Number(dateToUnixTime(/* @__PURE__ */ new Date())) + ONE_DAY_IN_SECONDS)
120
127
  };
128
+ const isEnabled = wallet && params.query?.enabled !== false;
121
129
  const { data, isLoading, isSuccess } = useQuery({
122
130
  queryKey: ["token-approval-data", params.currencyAddress],
123
- queryFn: async () => {
131
+ queryFn: isEnabled ? async () => {
124
132
  const args = {
125
133
  collectionAddress: params.collectionAddress,
126
134
  maker: await wallet.address(),
@@ -141,7 +149,7 @@ var useGetTokenApprovalData = (params) => {
141
149
  return {
142
150
  step: tokenApprovalStep
143
151
  };
144
- },
152
+ } : skipToken,
145
153
  enabled: !!wallet && !!params.collectionAddress && !!params.currencyAddress
146
154
  });
147
155
  return {
@@ -151,6 +159,9 @@ var useGetTokenApprovalData = (params) => {
151
159
  };
152
160
  };
153
161
 
162
+ // src/react/_internal/transaction-machine/execute-transaction.ts
163
+ import { avalanche, optimism } from "viem/chains";
164
+
154
165
  // src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
155
166
  import {
156
167
  CloseIcon,
@@ -484,6 +495,9 @@ var closeButton3 = "fyvr11lw fyvr1tc fyvr1mo";
484
495
  var dialogOverlay3 = "fyvr1m0 fyvr1o8 fyvr1qg fyvr1so fyvr11vl fyvr11m0 fyvr11rs";
485
496
  var transactionStatusModalContent = "modal_dialogContent_wide__1ypl6nt3 modal_dialogContentBase__1ypl6nt1 fyvr11hg fyvr11i4 fyvr11g4 fyvr11gs fyvr11l8 fyvr11ul fyvr11m0 fyvr11rs fyvr1vo fyvr1xs fyvr1zw fyvr1120 fyvr11lc fyvr11mc fyvr11cw";
486
497
 
498
+ // src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts
499
+ import { formatUnits as formatUnits2 } from "viem";
500
+
487
501
  // src/react/ui/modals/_internal/components/transactionStatusModal/util/getFormattedType.ts
488
502
  function getFormattedType(transactionType, verb = false) {
489
503
  switch (transactionType) {
@@ -509,12 +523,17 @@ function getTransactionStatusModalMessage({
509
523
  transactionStatus,
510
524
  transactionType,
511
525
  collectibleName,
512
- orderId
526
+ orderId,
527
+ price
513
528
  }) {
514
529
  const hideCollectibleName = transactionType === "CANCEL";
530
+ const formattedPrice = price ? formatUnits2(BigInt(price.amountRaw), price.currency.decimals) : "";
515
531
  if (orderId) {
516
532
  return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ""}. It's been confirmed on the blockchain!`;
517
533
  }
534
+ if (transactionType === "OFFER" /* OFFER */) {
535
+ return `You just offered ${formattedPrice} ${price?.currency.symbol} for ${collectibleName}. It's been confirmed on the blockchain!`;
536
+ }
518
537
  switch (transactionStatus) {
519
538
  case "PENDING":
520
539
  return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ""}. It should be confirmed on the blockchain shortly.`;
@@ -566,6 +585,12 @@ var useTransactionStatusModal = () => {
566
585
  close: () => transactionStatusModal$.close()
567
586
  };
568
587
  };
588
+ var invalidateQueries = async (queriesToInvalidate) => {
589
+ const queryClient = getQueryClient();
590
+ for (const queryKey of queriesToInvalidate) {
591
+ await queryClient.invalidateQueries({ queryKey });
592
+ }
593
+ };
569
594
  var TransactionStatusModal = observer3(() => {
570
595
  const {
571
596
  type,
@@ -587,6 +612,7 @@ var TransactionStatusModal = observer3(() => {
587
612
  const [transactionStatus, setTransactionStatus] = useState2(
588
613
  orderId ? "SUCCESS" : "PENDING"
589
614
  );
615
+ const queryClient = getQueryClient();
590
616
  useEffect2(() => {
591
617
  if (!transactionStatusModal$.isOpen.get() || orderId) return;
592
618
  console.log("Waiting for transaction receipt ...");
@@ -595,10 +621,15 @@ var TransactionStatusModal = observer3(() => {
595
621
  console.log("receipt", receipt);
596
622
  setTransactionStatus("SUCCESS");
597
623
  if (callbacks?.onSuccess) {
598
- callbacks.onSuccess(hash || "0x");
624
+ callbacks.onSuccess({ hash: hash || "0x0" });
599
625
  } else {
600
626
  console.debug("onSuccess callback not provided:", hash);
601
627
  }
628
+ if (queriesToInvalidate) {
629
+ invalidateQueries(queriesToInvalidate);
630
+ } else {
631
+ queryClient.invalidateQueries();
632
+ }
602
633
  }
603
634
  }).catch((error) => {
604
635
  if (callbacks?.onError) {
@@ -612,9 +643,6 @@ var TransactionStatusModal = observer3(() => {
612
643
  }
613
644
  setTransactionStatus("FAILED");
614
645
  });
615
- if (queriesToInvalidate) {
616
- queryClient.invalidateQueries({ queryKey: [...queriesToInvalidate] });
617
- }
618
646
  return () => {
619
647
  setTransactionStatus("PENDING");
620
648
  };
@@ -635,15 +663,15 @@ var TransactionStatusModal = observer3(() => {
635
663
  transactionStatus,
636
664
  transactionType: type,
637
665
  collectibleName: collectible?.name || "",
638
- orderId
666
+ orderId,
667
+ price
639
668
  });
640
- const queryClient = getQueryClient();
641
669
  const publicClient = chainId ? getPublicRpcClient(chainId) : null;
642
670
  const waitForTransactionReceiptPromise = publicClient?.waitForTransactionReceipt({
643
671
  confirmations: confirmations || TRANSACTION_CONFIRMATIONS_DEFAULT,
644
672
  hash: hash || "0x"
645
673
  });
646
- return /* @__PURE__ */ jsx5(Root, { open: transactionStatusModal$.isOpen.get(), children: /* @__PURE__ */ jsxs4(Portal, { children: [
674
+ return /* @__PURE__ */ jsx5(Root, { open: transactionStatusModal$.isOpen.get(), children: /* @__PURE__ */ jsxs4(Portal, { container: getProviderEl(), children: [
647
675
  /* @__PURE__ */ jsx5(Overlay, { className: dialogOverlay3 }),
648
676
  /* @__PURE__ */ jsxs4(Content, { className: transactionStatusModalContent, children: [
649
677
  title ? /* @__PURE__ */ jsx5(
@@ -723,6 +751,10 @@ var useTransactionSteps = ({
723
751
  if (!steps) return;
724
752
  }
725
753
  });
754
+ const { data: currency } = useCurrency({
755
+ chainId,
756
+ currencyAddress: offerInput.offer.currencyAddress
757
+ });
726
758
  const getOfferSteps = async () => {
727
759
  if (!wallet) return;
728
760
  try {
@@ -745,7 +777,6 @@ var useTransactionSteps = ({
745
777
  } else {
746
778
  console.debug("onError callback not provided:", error);
747
779
  }
748
- throw error;
749
780
  }
750
781
  };
751
782
  const executeApproval = async () => {
@@ -766,18 +797,18 @@ var useTransactionSteps = ({
766
797
  }
767
798
  } catch (error) {
768
799
  steps$.approval.isExecuting.set(false);
769
- throw error;
770
800
  }
771
801
  };
772
802
  const makeOffer = async () => {
773
803
  if (!wallet) return;
774
804
  try {
775
805
  steps$.transaction.isExecuting.set(true);
776
- const transactionStep = await getOfferSteps().then(
777
- (steps) => steps?.find((step) => step.id === "createOffer" /* createOffer */)
806
+ const steps = await getOfferSteps();
807
+ const transactionStep = steps?.find(
808
+ (step) => step.id === "createOffer" /* createOffer */
778
809
  );
779
- const signatureStep = await getOfferSteps().then(
780
- (steps) => steps?.find((step) => step.id === "signEIP712" /* signEIP712 */)
810
+ const signatureStep = steps?.find(
811
+ (step) => step.id === "signEIP712" /* signEIP712 */
781
812
  );
782
813
  console.debug("transactionStep", transactionStep);
783
814
  console.debug("signatureStep", signatureStep);
@@ -799,12 +830,40 @@ var useTransactionSteps = ({
799
830
  collectibleId: offerInput.offer.tokenId,
800
831
  hash,
801
832
  orderId,
802
- callbacks
833
+ callbacks,
834
+ queriesToInvalidate: [
835
+ balanceQueries.all,
836
+ collectableKeys.highestOffers,
837
+ collectableKeys.offers,
838
+ collectableKeys.offersCount,
839
+ collectableKeys.userBalances
840
+ ],
841
+ price: {
842
+ amountRaw: offerInput.offer.pricePerToken,
843
+ currency
844
+ }
803
845
  });
804
- steps$.transaction.isExecuting.set(false);
846
+ if (hash) {
847
+ await waitForReceipt(hash);
848
+ steps$.transaction.isExecuting.set(false);
849
+ steps$.transaction.exist.set(false);
850
+ if (callbacks?.onSuccess && typeof callbacks.onSuccess === "function") {
851
+ callbacks.onSuccess({ hash });
852
+ }
853
+ }
854
+ if (orderId) {
855
+ steps$.transaction.isExecuting.set(false);
856
+ steps$.transaction.exist.set(false);
857
+ if (callbacks?.onSuccess && typeof callbacks.onSuccess === "function") {
858
+ callbacks.onSuccess({ orderId });
859
+ }
860
+ }
805
861
  } catch (error) {
806
862
  steps$.transaction.isExecuting.set(false);
807
- throw error;
863
+ steps$.transaction.exist.set(false);
864
+ if (callbacks?.onError && typeof callbacks.onError === "function") {
865
+ callbacks.onError(error);
866
+ }
808
867
  }
809
868
  };
810
869
  const executeTransaction = async ({
@@ -839,12 +898,11 @@ var useTransactionSteps = ({
839
898
  };
840
899
 
841
900
  // src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx
842
- import { useEffect as useEffect3 } from "react";
843
901
  var useMakeOffer = ({
844
902
  offerInput,
845
903
  chainId,
846
904
  collectionAddress,
847
- orderbookKind = "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
905
+ orderbookKind,
848
906
  callbacks,
849
907
  closeMainModal,
850
908
  steps$
@@ -1169,20 +1227,17 @@ function FloorPriceText({
1169
1227
  // src/react/ui/modals/_internal/components/priceInput/index.tsx
1170
1228
  import { Box as Box9, NumericInput, Text as Text8 } from "@0xsequence/design-system";
1171
1229
  import { observer as observer6 } from "@legendapp/state/react";
1172
- import { useEffect as useEffect5, useState as useState5 } from "react";
1173
- import { parseUnits } from "viem";
1230
+ import { useCallback, useMemo } from "react";
1174
1231
  import { useAccount as useAccount2 } from "wagmi";
1175
1232
 
1176
1233
  // src/react/ui/modals/_internal/components/currencyImage/index.tsx
1177
1234
  import { Box as Box8, TokenImage } from "@0xsequence/design-system";
1178
1235
  import { useState as useState4 } from "react";
1179
1236
  import { jsx as jsx12 } from "react/jsx-runtime";
1180
- function CurrencyImage({
1181
- $listingPrice
1182
- }) {
1237
+ function CurrencyImage({ price$ }) {
1183
1238
  const [imageLoadErrorCurrencyAddresses, setImageLoadErrorCurrencyAddresses] = useState4(null);
1184
1239
  if (imageLoadErrorCurrencyAddresses?.includes(
1185
- $listingPrice.currency.contractAddress.get()
1240
+ price$.currency.contractAddress.get()
1186
1241
  )) {
1187
1242
  return /* @__PURE__ */ jsx12(
1188
1243
  Box8,
@@ -1197,17 +1252,17 @@ function CurrencyImage({
1197
1252
  return /* @__PURE__ */ jsx12(
1198
1253
  TokenImage,
1199
1254
  {
1200
- src: $listingPrice.currency.imageUrl.get(),
1255
+ src: price$.currency.imageUrl.get(),
1201
1256
  onError: () => {
1202
- const listingPrice = $listingPrice?.get();
1203
- if (listingPrice) {
1257
+ const price = price$?.get();
1258
+ if (price) {
1204
1259
  setImageLoadErrorCurrencyAddresses((prev) => {
1205
1260
  if (!prev)
1206
- return [listingPrice.currency.contractAddress];
1207
- if (!prev.includes(listingPrice.currency.contractAddress)) {
1261
+ return [price$.currency.contractAddress.get()];
1262
+ if (!prev.includes(price$.currency.contractAddress.get())) {
1208
1263
  return [
1209
1264
  ...prev,
1210
- listingPrice.currency.contractAddress
1265
+ price$.currency.contractAddress.get()
1211
1266
  ];
1212
1267
  }
1213
1268
  return prev;
@@ -1228,6 +1283,7 @@ import { jsx as jsx13 } from "react/jsx-runtime";
1228
1283
  var CurrencyOptionsSelect = observer5(function CurrencyOptionsSelect2({
1229
1284
  chainId,
1230
1285
  collectionAddress,
1286
+ secondCurrencyAsDefault,
1231
1287
  selectedCurrency$
1232
1288
  }) {
1233
1289
  const currency = selectedCurrency$.get();
@@ -1238,7 +1294,11 @@ var CurrencyOptionsSelect = observer5(function CurrencyOptionsSelect2({
1238
1294
  });
1239
1295
  useEffect4(() => {
1240
1296
  if (currencies && currencies.length > 0 && !selectedCurrency$.get()?.contractAddress) {
1241
- selectedCurrency$.set(currencies[0]);
1297
+ if (secondCurrencyAsDefault) {
1298
+ selectedCurrency$.set(currencies[1]);
1299
+ } else {
1300
+ selectedCurrency$.set(currencies[0]);
1301
+ }
1242
1302
  }
1243
1303
  }, [currencies]);
1244
1304
  if (!currencies || currenciesLoading || !currency.symbol) {
@@ -1271,44 +1331,70 @@ var CurrencyOptionsSelect = observer5(function CurrencyOptionsSelect2({
1271
1331
  });
1272
1332
  var currencyOptionsSelect_default = CurrencyOptionsSelect;
1273
1333
 
1274
- // src/react/ui/modals/_internal/components/priceInput/index.tsx
1275
- import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1276
- var PriceInput = observer6(function PriceInput2({
1277
- chainId,
1278
- collectionAddress,
1279
- $listingPrice,
1280
- onPriceChange,
1281
- checkBalance
1282
- }) {
1283
- const [balanceError, setBalanceError] = useState5("");
1284
- const { address: accountAddress } = useAccount2();
1285
- const { data: balance, isSuccess: isBalanceSuccess } = useCurrencyBalance({
1286
- currencyAddress: $listingPrice.currency.contractAddress.get(),
1287
- chainId: Number(chainId),
1288
- userAddress: accountAddress
1289
- });
1290
- const currencyDecimals = $listingPrice.currency.decimals.get();
1334
+ // src/react/ui/modals/_internal/components/priceInput/hooks/usePriceInput.ts
1335
+ import { useState as useState5, useEffect as useEffect5 } from "react";
1336
+ import { parseUnits } from "viem";
1337
+ var usePriceInput = ({
1338
+ price$,
1339
+ currencyDecimals,
1340
+ onPriceChange
1341
+ }) => {
1291
1342
  const [value, setValue] = useState5("");
1292
- const changeListingPrice = (value2) => {
1293
- setValue(value2);
1294
- const trimmedValue = value2.replace(/,/g, "");
1295
- const parsedTrimmedValue = parseUnits(
1296
- trimmedValue,
1297
- Number(currencyDecimals)
1298
- );
1343
+ useEffect5(() => {
1344
+ const currentAmount = value.replace(/,/g, "");
1345
+ if (currentAmount) {
1346
+ try {
1347
+ const parsedAmount = parseUnits(
1348
+ currentAmount,
1349
+ Number(currencyDecimals)
1350
+ );
1351
+ price$.amountRaw.set(parsedAmount.toString());
1352
+ } catch {
1353
+ price$.amountRaw.set("0");
1354
+ }
1355
+ }
1356
+ }, [currencyDecimals, value, price$]);
1357
+ const handlePriceChange = (newValue) => {
1358
+ setValue(newValue);
1299
1359
  try {
1300
- const parsedAmount = parseUnits(value2, Number(currencyDecimals));
1301
- $listingPrice.amountRaw.set(parsedAmount.toString());
1302
- if (onPriceChange && parsedTrimmedValue !== 0n) {
1360
+ const parsedAmount = parseUnits(newValue, Number(currencyDecimals));
1361
+ price$.amountRaw.set(parsedAmount.toString());
1362
+ if (onPriceChange && parsedAmount !== 0n) {
1303
1363
  onPriceChange();
1304
1364
  }
1305
1365
  } catch {
1306
- $listingPrice.amountRaw.set("0");
1366
+ price$.amountRaw.set("0");
1307
1367
  }
1308
1368
  };
1309
- const checkInsufficientBalance = (priceAmountRaw) => {
1310
- const hasInsufficientBalance = isBalanceSuccess && priceAmountRaw && currencyDecimals && BigInt(priceAmountRaw) > (balance?.value || 0);
1311
- if (!checkBalance) return;
1369
+ return {
1370
+ value,
1371
+ handlePriceChange
1372
+ };
1373
+ };
1374
+
1375
+ // src/react/ui/modals/_internal/components/priceInput/hooks/useBalanceCheck.ts
1376
+ import { useState as useState6, useEffect as useEffect6 } from "react";
1377
+ var useBalanceCheck = ({
1378
+ checkBalance,
1379
+ price$,
1380
+ currencyAddress,
1381
+ chainId,
1382
+ userAddress,
1383
+ currencyDecimals
1384
+ }) => {
1385
+ const [balanceError, setBalanceError] = useState6("");
1386
+ const { data: balance, isSuccess: isBalanceSuccess } = useCurrencyBalance({
1387
+ currencyAddress,
1388
+ chainId,
1389
+ userAddress
1390
+ });
1391
+ useEffect6(() => {
1392
+ if (!checkBalance?.enabled) {
1393
+ setBalanceError("");
1394
+ return;
1395
+ }
1396
+ const priceAmountRaw = price$.amountRaw.get() || "0";
1397
+ const hasInsufficientBalance = isBalanceSuccess && priceAmountRaw && currencyDecimals && BigInt(priceAmountRaw) > (balance?.value || 0n);
1312
1398
  if (hasInsufficientBalance) {
1313
1399
  setBalanceError("Insufficient balance");
1314
1400
  checkBalance.callback(true);
@@ -1316,13 +1402,66 @@ var PriceInput = observer6(function PriceInput2({
1316
1402
  setBalanceError("");
1317
1403
  checkBalance.callback(false);
1318
1404
  }
1405
+ }, [
1406
+ price$.amountRaw.get(),
1407
+ currencyAddress,
1408
+ balance?.value,
1409
+ isBalanceSuccess,
1410
+ checkBalance,
1411
+ currencyDecimals
1412
+ ]);
1413
+ return {
1414
+ balanceError
1319
1415
  };
1320
- useEffect5(() => {
1321
- const priceAmountRaw = $listingPrice.amountRaw.get();
1322
- if (priceAmountRaw && priceAmountRaw !== "0") {
1323
- checkInsufficientBalance(priceAmountRaw);
1324
- }
1325
- }, [$listingPrice.currency.get()]);
1416
+ };
1417
+
1418
+ // src/react/ui/modals/_internal/components/priceInput/index.tsx
1419
+ import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1420
+ var PriceInput = observer6(function PriceInput2({
1421
+ chainId,
1422
+ collectionAddress,
1423
+ $price,
1424
+ onPriceChange,
1425
+ checkBalance,
1426
+ secondCurrencyAsDefault
1427
+ }) {
1428
+ const { address: accountAddress } = useAccount2();
1429
+ const currencyDecimals = $price.currency.decimals.get() || 18;
1430
+ const currencyAddress = $price.currency.contractAddress.get();
1431
+ const { value, handlePriceChange } = usePriceInput({
1432
+ price$: $price,
1433
+ currencyDecimals,
1434
+ onPriceChange
1435
+ });
1436
+ const { balanceError } = useBalanceCheck({
1437
+ checkBalance,
1438
+ price$: $price,
1439
+ currencyAddress,
1440
+ chainId: Number(chainId),
1441
+ userAddress: accountAddress,
1442
+ currencyDecimals
1443
+ });
1444
+ const renderBalanceError = useMemo(() => {
1445
+ if (!balanceError) return null;
1446
+ return /* @__PURE__ */ jsx14(
1447
+ Text8,
1448
+ {
1449
+ color: "negative",
1450
+ fontSize: "xsmall",
1451
+ fontFamily: "body",
1452
+ fontWeight: "semibold",
1453
+ position: "absolute",
1454
+ style: { bottom: "-13px" },
1455
+ children: balanceError
1456
+ }
1457
+ );
1458
+ }, [balanceError]);
1459
+ const handleChange = useCallback(
1460
+ (event) => {
1461
+ handlePriceChange(event.target.value);
1462
+ },
1463
+ [handlePriceChange]
1464
+ );
1326
1465
  return /* @__PURE__ */ jsxs7(Box9, { className: priceInputWrapper, position: "relative", children: [
1327
1466
  /* @__PURE__ */ jsx14(
1328
1467
  Box9,
@@ -1332,41 +1471,31 @@ var PriceInput = observer6(function PriceInput2({
1332
1471
  left: "2",
1333
1472
  display: "flex",
1334
1473
  alignItems: "center",
1335
- children: /* @__PURE__ */ jsx14(currencyImage_default, { $listingPrice })
1474
+ children: /* @__PURE__ */ jsx14(currencyImage_default, { price$: $price })
1336
1475
  }
1337
1476
  ),
1338
1477
  /* @__PURE__ */ jsx14(
1339
1478
  NumericInput,
1340
1479
  {
1341
- name: "listingPrice",
1480
+ name: "price-input",
1342
1481
  decimals: currencyDecimals,
1343
1482
  label: "Enter price",
1344
1483
  labelLocation: "top",
1345
1484
  controls: /* @__PURE__ */ jsx14(
1346
1485
  currencyOptionsSelect_default,
1347
1486
  {
1348
- selectedCurrency$: $listingPrice?.currency,
1487
+ selectedCurrency$: $price.currency,
1349
1488
  collectionAddress,
1350
- chainId
1489
+ chainId,
1490
+ secondCurrencyAsDefault
1351
1491
  }
1352
1492
  ),
1353
1493
  value,
1354
- onChange: (event) => changeListingPrice(event.target.value),
1494
+ onChange: handleChange,
1355
1495
  width: "full"
1356
1496
  }
1357
1497
  ),
1358
- balanceError && /* @__PURE__ */ jsx14(
1359
- Text8,
1360
- {
1361
- color: "negative",
1362
- fontSize: "xsmall",
1363
- fontFamily: "body",
1364
- fontWeight: "semibold",
1365
- position: "absolute",
1366
- style: { bottom: "-13px" },
1367
- children: balanceError
1368
- }
1369
- )
1498
+ renderBalanceError
1370
1499
  ] });
1371
1500
  });
1372
1501
  var priceInput_default = PriceInput;
@@ -1454,7 +1583,7 @@ function QuantityInput({
1454
1583
  /* @__PURE__ */ jsx15(
1455
1584
  IconButton2,
1456
1585
  {
1457
- disabled: !quantity || Number(quantity) <= 0,
1586
+ disabled: !quantity || Number(quantity) <= 1,
1458
1587
  onClick: handleDecrement,
1459
1588
  background: "buttonGlass",
1460
1589
  size: "xs",
@@ -1464,6 +1593,7 @@ function QuantityInput({
1464
1593
  /* @__PURE__ */ jsx15(
1465
1594
  IconButton2,
1466
1595
  {
1596
+ disabled: !quantity || Number(quantity) >= Number(maxQuantity),
1467
1597
  onClick: handleIncrement,
1468
1598
  background: "buttonGlass",
1469
1599
  size: "xs",
@@ -1595,6 +1725,7 @@ var makeOfferModal$ = observable3({
1595
1725
  });
1596
1726
 
1597
1727
  // src/react/ui/modals/MakeOfferModal/Modal.tsx
1728
+ import { Box as Box12 } from "@0xsequence/design-system";
1598
1729
  import { Fragment, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1599
1730
  var MakeOfferModal = () => {
1600
1731
  return /* @__PURE__ */ jsx17(Show, { if: makeOfferModal$.isOpen, children: () => /* @__PURE__ */ jsx17(Modal2, {}) });
@@ -1612,7 +1743,7 @@ var Modal2 = observer7(() => {
1612
1743
  callbacks
1613
1744
  } = state;
1614
1745
  const steps$ = makeOfferModal$.steps;
1615
- const [insufficientBalance, setInsufficientBalance] = useState6(false);
1746
+ const [insufficientBalance, setInsufficientBalance] = useState7(false);
1616
1747
  const {
1617
1748
  data: collectible,
1618
1749
  isLoading: collectableIsLoading,
@@ -1630,6 +1761,16 @@ var Modal2 = observer7(() => {
1630
1761
  chainId,
1631
1762
  collectionAddress
1632
1763
  });
1764
+ const currencyOptions = useCurrencyOptions({ collectionAddress });
1765
+ const {
1766
+ data: currencies,
1767
+ isLoading: currenciesLoading,
1768
+ isError: currenciesIsError
1769
+ } = useCurrencies({
1770
+ chainId,
1771
+ currencyOptions
1772
+ });
1773
+ const selectedCurrency = use$(makeOfferModal$.offerPrice.currency);
1633
1774
  const { isLoading, executeApproval, makeOffer } = useMakeOffer({
1634
1775
  offerInput: {
1635
1776
  contractType: collection?.type,
@@ -1651,7 +1792,7 @@ var Modal2 = observer7(() => {
1651
1792
  closeMainModal: () => makeOfferModal$.close(),
1652
1793
  steps$
1653
1794
  });
1654
- if (collectableIsLoading || collectionIsLoading) {
1795
+ if (collectableIsLoading || collectionIsLoading || currenciesLoading) {
1655
1796
  return /* @__PURE__ */ jsx17(
1656
1797
  LoadingModal,
1657
1798
  {
@@ -1662,7 +1803,7 @@ var Modal2 = observer7(() => {
1662
1803
  }
1663
1804
  );
1664
1805
  }
1665
- if (collectableIsError || collectionIsError) {
1806
+ if (collectableIsError || collectionIsError || currenciesIsError) {
1666
1807
  return /* @__PURE__ */ jsx17(
1667
1808
  ErrorModal,
1668
1809
  {
@@ -1673,6 +1814,7 @@ var Modal2 = observer7(() => {
1673
1814
  }
1674
1815
  );
1675
1816
  }
1817
+ const invalidCurrency = selectedCurrency?.contractAddress === zeroAddress && orderbookKind !== "sequence_marketplace_v2" /* sequence_marketplace_v2 */;
1676
1818
  const ctas = [
1677
1819
  {
1678
1820
  label: "Approve TOKEN",
@@ -1686,9 +1828,10 @@ var Modal2 = observer7(() => {
1686
1828
  label: "Make offer",
1687
1829
  onClick: () => makeOffer(),
1688
1830
  pending: steps$.transaction.isExecuting.get(),
1689
- disabled: steps$.approval.isExecuting.get() || steps$.approval.exist.get() || offerPrice.amountRaw === "0" || insufficientBalance || isLoading || invalidQuantity || offerPrice.amountRaw === "0"
1831
+ disabled: steps$.approval.isExecuting.get() || steps$.approval.exist.get() || offerPrice.amountRaw === "0" || insufficientBalance || isLoading || invalidQuantity || invalidCurrency
1690
1832
  }
1691
1833
  ];
1834
+ const secondCurrencyAsDefault = orderbookKind !== "sequence_marketplace_v2" /* sequence_marketplace_v2 */ && currencies && currencies[0]?.contractAddress === zeroAddress;
1692
1835
  return /* @__PURE__ */ jsx17(Fragment, { children: /* @__PURE__ */ jsxs10(
1693
1836
  ActionModal,
1694
1837
  {
@@ -1712,8 +1855,9 @@ var Modal2 = observer7(() => {
1712
1855
  {
1713
1856
  chainId,
1714
1857
  collectionAddress,
1715
- $listingPrice: makeOfferModal$.offerPrice,
1858
+ $price: makeOfferModal$.offerPrice,
1716
1859
  onPriceChange: () => makeOfferModal$.offerPriceChanged.set(true),
1860
+ secondCurrencyAsDefault,
1717
1861
  checkBalance: {
1718
1862
  enabled: true,
1719
1863
  callback: (state2) => setInsufficientBalance(state2)
@@ -1738,7 +1882,8 @@ var Modal2 = observer7(() => {
1738
1882
  price: offerPrice
1739
1883
  }
1740
1884
  ),
1741
- /* @__PURE__ */ jsx17(expirationDateSelect_default, { $date: makeOfferModal$.expiry })
1885
+ /* @__PURE__ */ jsx17(expirationDateSelect_default, { $date: makeOfferModal$.expiry }),
1886
+ invalidCurrency && /* @__PURE__ */ jsx17(Box12, { color: "negative", fontSize: "small", children: "Native currency offers are not supported on this marketplace. Please select another currency to continue" })
1742
1887
  ]
1743
1888
  }
1744
1889
  ) });
@@ -1749,8 +1894,8 @@ import { Show as Show2, observer as observer8 } from "@legendapp/state/react";
1749
1894
  import { parseUnits as parseUnits3 } from "viem";
1750
1895
 
1751
1896
  // src/react/ui/modals/_internal/components/transactionDetails/index.tsx
1752
- import { Box as Box12, Image as Image3, Skeleton as Skeleton6, Text as Text10 } from "@0xsequence/design-system";
1753
- import { formatUnits as formatUnits2 } from "viem";
1897
+ import { Box as Box13, Image as Image3, Skeleton as Skeleton6, Text as Text10 } from "@0xsequence/design-system";
1898
+ import { formatUnits as formatUnits3 } from "viem";
1754
1899
  import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
1755
1900
  var DEFAULT_MARKETPLACE_FEE_PERCENTAGE = 2.5;
1756
1901
  function TransactionDetails({
@@ -1771,7 +1916,7 @@ function TransactionDetails({
1771
1916
  collectibleId
1772
1917
  });
1773
1918
  const priceLoading = !price || marketplaceConfigLoading || royaltyPercentageLoading;
1774
- let formattedAmount = price && formatUnits2(BigInt(price.amountRaw), price.currency.decimals);
1919
+ let formattedAmount = price && formatUnits3(BigInt(price.amountRaw), price.currency.decimals);
1775
1920
  if (royaltyPercentage !== void 0 && formattedAmount && price) {
1776
1921
  formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royaltyPercentage) / 100).toFixed(price.currency.decimals);
1777
1922
  }
@@ -1779,7 +1924,7 @@ function TransactionDetails({
1779
1924
  formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * marketplaceFeePercentage / 100).toFixed(price.currency.decimals);
1780
1925
  }
1781
1926
  return /* @__PURE__ */ jsxs11(
1782
- Box12,
1927
+ Box13,
1783
1928
  {
1784
1929
  width: "full",
1785
1930
  display: "flex",
@@ -1787,7 +1932,7 @@ function TransactionDetails({
1787
1932
  alignItems: "center",
1788
1933
  children: [
1789
1934
  /* @__PURE__ */ jsx18(Text10, { fontSize: "small", color: "text50", fontFamily: "body", children: "Total earnings" }),
1790
- /* @__PURE__ */ jsxs11(Box12, { display: "flex", alignItems: "center", gap: "2", children: [
1935
+ /* @__PURE__ */ jsxs11(Box13, { display: "flex", alignItems: "center", gap: "2", children: [
1791
1936
  /* @__PURE__ */ jsx18(Image3, { src: currencyImageUrl, width: "3", height: "3" }),
1792
1937
  priceLoading ? /* @__PURE__ */ jsx18(Skeleton6, { width: "16", height: "4" }) : /* @__PURE__ */ jsxs11(Text10, { fontSize: "small", color: "text100", fontFamily: "body", children: [
1793
1938
  showPlaceholderPrice ? "0" : formattedAmount,
@@ -1801,7 +1946,7 @@ function TransactionDetails({
1801
1946
  }
1802
1947
 
1803
1948
  // src/react/ui/modals/_internal/components/transactionHeader/index.tsx
1804
- import { Box as Box13, Image as Image4, Skeleton as Skeleton7, Text as Text11 } from "@0xsequence/design-system";
1949
+ import { Box as Box14, Image as Image4, Skeleton as Skeleton7, Text as Text11 } from "@0xsequence/design-system";
1805
1950
  import { formatDistanceToNow as formatDistanceToNow2 } from "date-fns";
1806
1951
  import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
1807
1952
  function TransactionHeader({
@@ -1809,7 +1954,7 @@ function TransactionHeader({
1809
1954
  currencyImageUrl,
1810
1955
  date
1811
1956
  }) {
1812
- return /* @__PURE__ */ jsxs12(Box13, { display: "flex", alignItems: "center", width: "full", children: [
1957
+ return /* @__PURE__ */ jsxs12(Box14, { display: "flex", alignItems: "center", width: "full", children: [
1813
1958
  /* @__PURE__ */ jsx19(
1814
1959
  Text11,
1815
1960
  {
@@ -1879,7 +2024,7 @@ var sellModal$ = observable4(initialState3);
1879
2024
  import { useQuery as useQuery2 } from "@tanstack/react-query";
1880
2025
 
1881
2026
  // src/react/ui/modals/BuyModal/hooks/useFees.ts
1882
- import { avalanche, optimism } from "viem/chains";
2027
+ import { avalanche as avalanche2, optimism as optimism2 } from "viem/chains";
1883
2028
  var useFees = ({
1884
2029
  chainId,
1885
2030
  collectionAddress
@@ -1891,7 +2036,7 @@ var useFees = ({
1891
2036
  const collection = marketplaceConfig?.collections.find(
1892
2037
  (collection2) => collection2.collectionAddress.toLowerCase() === collectionAddress.toLowerCase() && chainId === Number(collection2.chainId)
1893
2038
  );
1894
- const avalancheOrOptimism = chainId === avalanche.id || chainId === optimism.id;
2039
+ const avalancheOrOptimism = chainId === avalanche2.id || chainId === optimism2.id;
1895
2040
  const receiver = avalancheOrOptimism ? avalancheAndOptimismPlatformFeeRecipient : defaultPlatformFeeRecipient;
1896
2041
  const percentageToBPS = (percentage) => Number(percentage) * 1e4 / 100;
1897
2042
  return {
@@ -1976,8 +2121,6 @@ var useTransactionSteps2 = ({
1976
2121
  if (!steps) return;
1977
2122
  }
1978
2123
  });
1979
- console.log("amount", amount);
1980
- console.log("receiver", receiver);
1981
2124
  const getSellSteps = async () => {
1982
2125
  if (!wallet) return;
1983
2126
  try {
@@ -2002,7 +2145,6 @@ var useTransactionSteps2 = ({
2002
2145
  } else {
2003
2146
  console.debug("onError callback not provided:", error);
2004
2147
  }
2005
- throw error;
2006
2148
  }
2007
2149
  };
2008
2150
  const executeApproval = async () => {
@@ -2023,18 +2165,16 @@ var useTransactionSteps2 = ({
2023
2165
  }
2024
2166
  } catch (error) {
2025
2167
  steps$.approval.isExecuting.set(false);
2026
- throw error;
2027
2168
  }
2028
2169
  };
2029
2170
  const sell = async () => {
2030
2171
  if (!wallet) return;
2031
2172
  try {
2032
2173
  steps$.transaction.isExecuting.set(true);
2033
- const transactionStep = await getSellSteps().then(
2034
- (steps) => steps?.find((step) => step.id === "sell" /* sell */)
2035
- );
2036
- const signatureStep = await getSellSteps().then(
2037
- (steps) => steps?.find((step) => step.id === "signEIP712" /* signEIP712 */)
2174
+ const steps = await getSellSteps();
2175
+ const transactionStep = steps?.find((step) => step.id === "sell" /* sell */);
2176
+ const signatureStep = steps?.find(
2177
+ (step) => step.id === "signEIP712" /* signEIP712 */
2038
2178
  );
2039
2179
  console.debug("transactionStep", transactionStep);
2040
2180
  console.debug("signatureStep", signatureStep);
@@ -2056,12 +2196,30 @@ var useTransactionSteps2 = ({
2056
2196
  collectibleId,
2057
2197
  hash,
2058
2198
  orderId,
2059
- callbacks
2199
+ callbacks,
2200
+ queriesToInvalidate: [balanceQueries.all, collectableKeys.userBalances]
2060
2201
  });
2061
- steps$.transaction.isExecuting.set(false);
2202
+ if (hash) {
2203
+ await waitForReceipt(hash);
2204
+ steps$.transaction.isExecuting.set(false);
2205
+ steps$.transaction.exist.set(false);
2206
+ if (callbacks?.onSuccess && typeof callbacks.onSuccess === "function") {
2207
+ callbacks.onSuccess({ hash });
2208
+ }
2209
+ }
2210
+ if (orderId) {
2211
+ steps$.transaction.isExecuting.set(false);
2212
+ steps$.transaction.exist.set(false);
2213
+ if (callbacks?.onSuccess && typeof callbacks.onSuccess === "function") {
2214
+ callbacks.onSuccess({ orderId });
2215
+ }
2216
+ }
2062
2217
  } catch (error) {
2063
2218
  steps$.transaction.isExecuting.set(false);
2064
- throw error;
2219
+ steps$.transaction.exist.set(false);
2220
+ if (callbacks?.onError && typeof callbacks.onError === "function") {
2221
+ callbacks.onError(error);
2222
+ }
2065
2223
  }
2066
2224
  };
2067
2225
  const executeTransaction = async ({
@@ -2096,7 +2254,7 @@ var useTransactionSteps2 = ({
2096
2254
  };
2097
2255
 
2098
2256
  // src/react/ui/modals/SellModal/hooks/useSell.tsx
2099
- import { useEffect as useEffect6 } from "react";
2257
+ import { useEffect as useEffect7 } from "react";
2100
2258
  var useSell = ({
2101
2259
  collectibleId,
2102
2260
  chainId,
@@ -2113,7 +2271,7 @@ var useSell = ({
2113
2271
  ordersData,
2114
2272
  marketplace
2115
2273
  });
2116
- useEffect6(() => {
2274
+ useEffect7(() => {
2117
2275
  if (tokenApproval?.step && !tokenApprovalIsLoading) {
2118
2276
  steps$.approval.exist.set(true);
2119
2277
  }
@@ -2267,7 +2425,7 @@ var Modal3 = observer8(() => {
2267
2425
 
2268
2426
  // src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
2269
2427
  import {
2270
- Box as Box14,
2428
+ Box as Box15,
2271
2429
  Button as Button3,
2272
2430
  CloseIcon as CloseIcon2,
2273
2431
  ExternalLinkIcon,
@@ -2332,7 +2490,7 @@ var SuccessfulPurchaseModal = observer9(() => {
2332
2490
  return /* @__PURE__ */ jsx21(Root3, { open: successfulPurchaseModal$.isOpen.get(), children: /* @__PURE__ */ jsxs14(Portal3, { children: [
2333
2491
  /* @__PURE__ */ jsx21(Overlay2, { className: dialogOverlay }),
2334
2492
  /* @__PURE__ */ jsxs14(Content3, { className: dialogContent.narrow, children: [
2335
- /* @__PURE__ */ jsxs14(Box14, { display: "flex", flexDirection: "column", gap: "4", width: "full", children: [
2493
+ /* @__PURE__ */ jsxs14(Box15, { display: "flex", flexDirection: "column", gap: "4", width: "full", children: [
2336
2494
  /* @__PURE__ */ jsx21(
2337
2495
  Text12,
2338
2496
  {
@@ -2349,7 +2507,7 @@ var SuccessfulPurchaseModal = observer9(() => {
2349
2507
  collectibles: successfulPurchaseModal$.state.get().collectibles
2350
2508
  }
2351
2509
  ),
2352
- /* @__PURE__ */ jsxs14(Box14, { display: "flex", alignItems: "center", gap: "1", children: [
2510
+ /* @__PURE__ */ jsxs14(Box15, { display: "flex", alignItems: "center", gap: "1", children: [
2353
2511
  /* @__PURE__ */ jsx21(Text12, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "You bought" }),
2354
2512
  /* @__PURE__ */ jsx21(Text12, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().collectibles.length }),
2355
2513
  /* @__PURE__ */ jsx21(Text12, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "items for" }),
@@ -2372,7 +2530,7 @@ var SuccessfulPurchaseModal = observer9(() => {
2372
2530
  ] }) });
2373
2531
  });
2374
2532
  function SuccessfulPurchaseActions() {
2375
- return /* @__PURE__ */ jsxs14(Box14, { display: "flex", flexDirection: "column", gap: "2", children: [
2533
+ return /* @__PURE__ */ jsxs14(Box15, { display: "flex", flexDirection: "column", gap: "2", children: [
2376
2534
  successfulPurchaseModal$.state.ctaOptions.get() && /* @__PURE__ */ jsx21(
2377
2535
  Button3,
2378
2536
  {
@@ -2401,10 +2559,10 @@ function SuccessfulPurchaseActions() {
2401
2559
  function CollectiblesGrid({ collectibles }) {
2402
2560
  const total = collectibles.length;
2403
2561
  const shownCollectibles = total > 4 ? collectibles.slice(0, 4) : collectibles;
2404
- return /* @__PURE__ */ jsx21(Box14, { className: collectiblesGrid, display: "grid", gap: "2", children: shownCollectibles.map((collectible) => {
2562
+ return /* @__PURE__ */ jsx21(Box15, { className: collectiblesGrid, display: "grid", gap: "2", children: shownCollectibles.map((collectible) => {
2405
2563
  const showPlus = total > 4 && collectibles.indexOf(collectible) === 3;
2406
2564
  return /* @__PURE__ */ jsxs14(
2407
- Box14,
2565
+ Box15,
2408
2566
  {
2409
2567
  className: collectiblesGridItem,
2410
2568
  position: "relative",
@@ -2421,7 +2579,7 @@ function CollectiblesGrid({ collectibles }) {
2421
2579
  }
2422
2580
  ),
2423
2581
  showPlus && /* @__PURE__ */ jsx21(
2424
- Box14,
2582
+ Box15,
2425
2583
  {
2426
2584
  position: "absolute",
2427
2585
  top: "0",
@@ -2506,7 +2664,7 @@ var initialState5 = {
2506
2664
  var transferModal$ = observable6(initialState5);
2507
2665
 
2508
2666
  // src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
2509
- import { Box as Box15, Button as Button4, Text as Text13, TextInput } from "@0xsequence/design-system";
2667
+ import { Box as Box16, Button as Button4, Text as Text13, TextInput } from "@0xsequence/design-system";
2510
2668
  import { observable as observable7 } from "@legendapp/state";
2511
2669
  import { isAddress } from "viem";
2512
2670
  import { useAccount as useAccount3 } from "wagmi";
@@ -2533,58 +2691,44 @@ var useHandleTransfer = () => {
2533
2691
  } = transferModal$.state.get();
2534
2692
  const { transferTokensAsync } = useTransferTokens();
2535
2693
  const { show: showTransactionStatusModal } = useTransactionStatusModal();
2694
+ const getHash = async () => {
2695
+ if (collectionType === "ERC721" /* ERC721 */) {
2696
+ return await transferTokensAsync({
2697
+ receiverAddress,
2698
+ collectionAddress,
2699
+ tokenId: collectibleId,
2700
+ chainId,
2701
+ contractType: "ERC721" /* ERC721 */
2702
+ });
2703
+ }
2704
+ return await transferTokensAsync({
2705
+ receiverAddress,
2706
+ collectionAddress,
2707
+ tokenId: collectibleId,
2708
+ chainId,
2709
+ contractType: "ERC1155" /* ERC1155 */,
2710
+ quantity: String(quantity)
2711
+ });
2712
+ };
2536
2713
  async function transfer() {
2537
2714
  if (collectionType !== "ERC721" /* ERC721 */ && collectionType !== "ERC1155" /* ERC1155 */) {
2538
2715
  throw new InvalidContractTypeError(collectionType);
2539
2716
  }
2540
- if (collectionType === "ERC721" /* ERC721 */) {
2541
- try {
2542
- const hash = await transferTokensAsync({
2543
- receiverAddress,
2544
- collectionAddress,
2545
- tokenId: collectibleId,
2546
- chainId,
2547
- contractType: "ERC721" /* ERC721 */
2548
- });
2549
- transferModal$.close();
2550
- showTransactionStatusModal({
2551
- hash,
2552
- collectionAddress,
2553
- chainId,
2554
- collectibleId,
2555
- price: void 0,
2556
- type: "TRANSFER" /* TRANSFER */,
2557
- queriesToInvalidate: balanceQueries.all
2558
- });
2559
- } catch (error) {
2560
- transferModal$.view.set("enterReceiverAddress");
2561
- callbacks?.onError?.(error);
2562
- }
2563
- }
2564
- if (collectionType === "ERC1155" /* ERC1155 */) {
2565
- try {
2566
- const hash = await transferTokensAsync({
2567
- receiverAddress,
2568
- collectionAddress,
2569
- tokenId: collectibleId,
2570
- chainId,
2571
- contractType: "ERC1155" /* ERC1155 */,
2572
- quantity: String(quantity)
2573
- });
2574
- transferModal$.close();
2575
- showTransactionStatusModal({
2576
- hash,
2577
- collectionAddress,
2578
- chainId,
2579
- collectibleId,
2580
- price: void 0,
2581
- type: "TRANSFER" /* TRANSFER */,
2582
- queriesToInvalidate: balanceQueries.all
2583
- });
2584
- } catch (error) {
2585
- transferModal$.view.set("enterReceiverAddress");
2586
- callbacks?.onError?.(error);
2587
- }
2717
+ try {
2718
+ const hash = await getHash();
2719
+ transferModal$.close();
2720
+ showTransactionStatusModal({
2721
+ hash,
2722
+ collectionAddress,
2723
+ chainId,
2724
+ collectibleId,
2725
+ price: void 0,
2726
+ type: "TRANSFER" /* TRANSFER */,
2727
+ queriesToInvalidate: [balanceQueries.all, collectableKeys.userBalances]
2728
+ });
2729
+ } catch (error) {
2730
+ transferModal$.view.set("enterReceiverAddress");
2731
+ callbacks?.onError?.(error);
2588
2732
  }
2589
2733
  }
2590
2734
  return { transfer };
@@ -2625,9 +2769,9 @@ var EnterWalletAddressView = () => {
2625
2769
  transfer();
2626
2770
  transferModal$.view.set("followWalletInstructions");
2627
2771
  }
2628
- return /* @__PURE__ */ jsxs15(Box15, { display: "grid", gap: "6", flexGrow: "1", children: [
2772
+ return /* @__PURE__ */ jsxs15(Box16, { display: "grid", gap: "6", flexGrow: "1", children: [
2629
2773
  /* @__PURE__ */ jsx22(Text13, { color: "white", fontSize: "large", fontWeight: "bold", fontFamily: "body", children: "Transfer your item" }),
2630
- /* @__PURE__ */ jsxs15(Box15, { display: "flex", flexDirection: "column", gap: "3", children: [
2774
+ /* @__PURE__ */ jsxs15(Box16, { display: "flex", flexDirection: "column", gap: "3", children: [
2631
2775
  /* @__PURE__ */ jsx22(
2632
2776
  AlertMessage,
2633
2777
  {
@@ -2687,13 +2831,13 @@ var EnterWalletAddressView = () => {
2687
2831
  var enterWalletAddress_default = EnterWalletAddressView;
2688
2832
 
2689
2833
  // src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx
2690
- import { Box as Box16, Button as Button5, Text as Text14 } from "@0xsequence/design-system";
2834
+ import { Box as Box17, Button as Button5, Text as Text14 } from "@0xsequence/design-system";
2691
2835
  import { observer as observer10 } from "@legendapp/state/react";
2692
2836
  import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
2693
2837
  var FollowWalletInstructionsView = observer10(() => {
2694
- return /* @__PURE__ */ jsxs16(Box16, { display: "grid", gap: "6", flexGrow: "1", children: [
2838
+ return /* @__PURE__ */ jsxs16(Box17, { display: "grid", gap: "6", flexGrow: "1", children: [
2695
2839
  /* @__PURE__ */ jsx23(Text14, { color: "white", fontSize: "large", fontWeight: "bold", fontFamily: "body", children: "Transfer your item" }),
2696
- /* @__PURE__ */ jsx23(Box16, { display: "flex", flexDirection: "column", gap: "3", children: /* @__PURE__ */ jsx23(
2840
+ /* @__PURE__ */ jsx23(Box17, { display: "flex", flexDirection: "column", gap: "3", children: /* @__PURE__ */ jsx23(
2697
2841
  AlertMessage,
2698
2842
  {
2699
2843
  message: getMessage("followWalletInstructions"),
@@ -2781,7 +2925,7 @@ var TransactionModalView = observer11(() => {
2781
2925
  });
2782
2926
 
2783
2927
  // src/react/ui/modals/CreateListingModal/Modal.tsx
2784
- import { Box as Box17 } from "@0xsequence/design-system";
2928
+ import { Box as Box18 } from "@0xsequence/design-system";
2785
2929
  import { Show as Show4, observer as observer12 } from "@legendapp/state/react";
2786
2930
  import { parseUnits as parseUnits4 } from "viem";
2787
2931
  import { useAccount as useAccount5 } from "wagmi";
@@ -2838,10 +2982,10 @@ var createListingModal$ = observable8({
2838
2982
  });
2839
2983
 
2840
2984
  // src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx
2841
- import { useEffect as useEffect7 } from "react";
2985
+ import { useEffect as useEffect8 } from "react";
2842
2986
 
2843
2987
  // src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts
2844
- import { useQuery as useQuery3 } from "@tanstack/react-query";
2988
+ import { skipToken as skipToken2, useQuery as useQuery3 } from "@tanstack/react-query";
2845
2989
  var ONE_DAY_IN_SECONDS2 = 60 * 60 * 24;
2846
2990
  var useGetTokenApprovalData3 = (params) => {
2847
2991
  const config = useConfig();
@@ -2854,9 +2998,10 @@ var useGetTokenApprovalData3 = (params) => {
2854
2998
  pricePerToken: "100000",
2855
2999
  expiry: String(Number(dateToUnixTime(/* @__PURE__ */ new Date())) + ONE_DAY_IN_SECONDS2)
2856
3000
  };
3001
+ const isEnabled = wallet && params.query?.enabled !== false;
2857
3002
  const { data, isLoading, isSuccess } = useQuery3({
2858
3003
  queryKey: ["token-approval-data", params.currencyAddress],
2859
- queryFn: async () => {
3004
+ queryFn: isEnabled ? async () => {
2860
3005
  const args = {
2861
3006
  collectionAddress: params.collectionAddress,
2862
3007
  owner: await wallet.address(),
@@ -2877,7 +3022,7 @@ var useGetTokenApprovalData3 = (params) => {
2877
3022
  return {
2878
3023
  step: tokenApprovalStep
2879
3024
  };
2880
- }
3025
+ } : skipToken2
2881
3026
  });
2882
3027
  return {
2883
3028
  data,
@@ -2891,7 +3036,7 @@ var useTransactionSteps3 = ({
2891
3036
  listingInput,
2892
3037
  chainId,
2893
3038
  collectionAddress,
2894
- orderbookKind = "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
3039
+ orderbookKind,
2895
3040
  callbacks,
2896
3041
  closeMainModal,
2897
3042
  steps$
@@ -2930,7 +3075,6 @@ var useTransactionSteps3 = ({
2930
3075
  } else {
2931
3076
  console.debug("onError callback not provided:", error);
2932
3077
  }
2933
- throw error;
2934
3078
  }
2935
3079
  };
2936
3080
  const executeApproval = async () => {
@@ -2951,7 +3095,6 @@ var useTransactionSteps3 = ({
2951
3095
  }
2952
3096
  } catch (error) {
2953
3097
  steps$.approval.isExecuting.set(false);
2954
- throw error;
2955
3098
  }
2956
3099
  };
2957
3100
  const createListing = async () => {
@@ -2985,12 +3128,36 @@ var useTransactionSteps3 = ({
2985
3128
  collectibleId: listingInput.listing.tokenId,
2986
3129
  hash,
2987
3130
  orderId,
2988
- callbacks
3131
+ callbacks,
3132
+ queriesToInvalidate: [
3133
+ balanceQueries.all,
3134
+ collectableKeys.lowestListings,
3135
+ collectableKeys.listings,
3136
+ collectableKeys.listingsCount,
3137
+ collectableKeys.userBalances
3138
+ ]
2989
3139
  });
2990
- steps$.transaction.isExecuting.set(false);
3140
+ if (hash) {
3141
+ await waitForReceipt(hash);
3142
+ steps$.transaction.isExecuting.set(false);
3143
+ steps$.transaction.exist.set(false);
3144
+ if (callbacks?.onSuccess && typeof callbacks.onSuccess === "function") {
3145
+ callbacks.onSuccess({ hash });
3146
+ }
3147
+ }
3148
+ if (orderId) {
3149
+ steps$.transaction.isExecuting.set(false);
3150
+ steps$.transaction.exist.set(false);
3151
+ if (callbacks?.onSuccess && typeof callbacks.onSuccess === "function") {
3152
+ callbacks.onSuccess({ orderId });
3153
+ }
3154
+ }
2991
3155
  } catch (error) {
2992
3156
  steps$.transaction.isExecuting.set(false);
2993
- throw error;
3157
+ steps$.transaction.exist.set(false);
3158
+ if (callbacks?.onError && typeof callbacks.onError === "function") {
3159
+ callbacks.onError(error);
3160
+ }
2994
3161
  }
2995
3162
  };
2996
3163
  const executeTransaction = async ({
@@ -3029,20 +3196,28 @@ var useCreateListing = ({
3029
3196
  listingInput,
3030
3197
  chainId,
3031
3198
  collectionAddress,
3032
- orderbookKind = "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
3199
+ orderbookKind,
3033
3200
  steps$,
3034
3201
  callbacks,
3035
3202
  closeMainModal
3036
3203
  }) => {
3204
+ const { data: marketplaceConfig, isLoading: marketplaceIsLoading } = useMarketplaceConfig();
3205
+ const collectionConfig = marketplaceConfig?.collections.find(
3206
+ (c) => c.collectionAddress === collectionAddress
3207
+ );
3208
+ orderbookKind = orderbookKind ?? collectionConfig?.destinationMarketplace ?? "sequence_marketplace_v2" /* sequence_marketplace_v2 */;
3037
3209
  const { data: tokenApproval, isLoading: tokenApprovalIsLoading } = useGetTokenApprovalData3({
3038
3210
  chainId,
3039
3211
  tokenId: listingInput.listing.tokenId,
3040
3212
  collectionAddress,
3041
3213
  currencyAddress: listingInput.listing.currencyAddress,
3042
3214
  contractType: listingInput.contractType,
3043
- orderbook: orderbookKind
3215
+ orderbook: orderbookKind,
3216
+ query: {
3217
+ enabled: !marketplaceIsLoading
3218
+ }
3044
3219
  });
3045
- useEffect7(() => {
3220
+ useEffect8(() => {
3046
3221
  if (tokenApproval?.step && !tokenApprovalIsLoading) {
3047
3222
  steps$.approval.exist.set(true);
3048
3223
  }
@@ -3182,13 +3357,13 @@ var Modal5 = observer12(() => {
3182
3357
  chainId
3183
3358
  }
3184
3359
  ),
3185
- /* @__PURE__ */ jsxs18(Box17, { display: "flex", flexDirection: "column", width: "full", gap: "1", children: [
3360
+ /* @__PURE__ */ jsxs18(Box18, { display: "flex", flexDirection: "column", width: "full", gap: "1", children: [
3186
3361
  /* @__PURE__ */ jsx25(
3187
3362
  priceInput_default,
3188
3363
  {
3189
3364
  chainId,
3190
3365
  collectionAddress,
3191
- $listingPrice: createListingModal$.listingPrice
3366
+ $price: createListingModal$.listingPrice
3192
3367
  }
3193
3368
  ),
3194
3369
  listingPrice.amountRaw !== "0" && /* @__PURE__ */ jsx25(
@@ -3227,7 +3402,7 @@ var Modal5 = observer12(() => {
3227
3402
  });
3228
3403
 
3229
3404
  // src/react/ui/modals/BuyModal/Modal.tsx
3230
- import { use$ } from "@legendapp/state/react";
3405
+ import { use$ as use$2 } from "@legendapp/state/react";
3231
3406
 
3232
3407
  // src/react/ui/modals/BuyModal/store.ts
3233
3408
  import { observable as observable9 } from "@legendapp/state";
@@ -3242,7 +3417,9 @@ var initialState7 = {
3242
3417
  quantity: args.order.quantityAvailableFormatted,
3243
3418
  order: args.order,
3244
3419
  modalId: buyModal$.state.modalId.get() + 1,
3245
- invalidQuantity: false
3420
+ invalidQuantity: false,
3421
+ checkoutModalIsLoading: false,
3422
+ checkoutModalLoaded: false
3246
3423
  });
3247
3424
  buyModal$.callbacks.set(callbacks || defaultCallbacks);
3248
3425
  buyModal$.isOpen.set(true);
@@ -3254,17 +3431,25 @@ var initialState7 = {
3254
3431
  order: void 0,
3255
3432
  quantity: "1",
3256
3433
  modalId: 0,
3257
- invalidQuantity: false
3434
+ invalidQuantity: false,
3435
+ checkoutModalIsLoading: false,
3436
+ checkoutModalLoaded: false
3437
+ },
3438
+ setCheckoutModalIsLoading: (isLoading) => {
3439
+ buyModal$.state.checkoutModalIsLoading.set(isLoading);
3440
+ },
3441
+ setCheckoutModalLoaded: (isLoaded) => {
3442
+ buyModal$.state.checkoutModalLoaded.set(isLoaded);
3258
3443
  },
3259
3444
  callbacks: void 0
3260
3445
  };
3261
3446
  var buyModal$ = observable9(initialState7);
3262
3447
 
3263
3448
  // src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx
3264
- import { useEffect as useEffect8 } from "react";
3449
+ import { useEffect as useEffect9 } from "react";
3265
3450
  import { parseUnits as parseUnits5 } from "viem";
3266
3451
  function CheckoutModal({ buy, collectable, order }) {
3267
- useEffect8(() => {
3452
+ useEffect9(() => {
3268
3453
  const executeBuy = () => {
3269
3454
  buy({
3270
3455
  orderId: order.orderId,
@@ -3279,15 +3464,12 @@ function CheckoutModal({ buy, collectable, order }) {
3279
3464
  }
3280
3465
 
3281
3466
  // src/react/ui/modals/BuyModal/modals/Modal1155.tsx
3282
- import { Box as Box18, Text as Text15, TokenImage as TokenImage2 } from "@0xsequence/design-system";
3467
+ import { Box as Box19, Text as Text15, TokenImage as TokenImage2 } from "@0xsequence/design-system";
3283
3468
  import { observer as observer13 } from "@legendapp/state/react";
3284
- import { formatUnits as formatUnits3, parseUnits as parseUnits6 } from "viem";
3469
+ import { formatUnits as formatUnits4, parseUnits as parseUnits6 } from "viem";
3285
3470
  import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
3286
3471
  var ERC1155QuantityModal = observer13(
3287
3472
  ({ buy, collectable, order }) => {
3288
- buyModal$.state.quantity.set(
3289
- Math.min(Number(order.quantityRemaining), 1).toString()
3290
- );
3291
3473
  const currencyOptions = useCurrencyOptions({
3292
3474
  collectionAddress: order.collectionContractAddress
3293
3475
  });
@@ -3301,6 +3483,9 @@ var ERC1155QuantityModal = observer13(
3301
3483
  const quantity = Number(buyModal$.state.quantity.get());
3302
3484
  const pricePerToken = order.priceAmount;
3303
3485
  const totalPrice = (BigInt(quantity) * BigInt(pricePerToken)).toString();
3486
+ if (buyModal$.state.checkoutModalLoaded.get()) {
3487
+ return null;
3488
+ }
3304
3489
  return /* @__PURE__ */ jsx26(
3305
3490
  ActionModal,
3306
3491
  {
@@ -3312,6 +3497,7 @@ var ERC1155QuantityModal = observer13(
3312
3497
  {
3313
3498
  label: "Buy now",
3314
3499
  onClick: () => {
3500
+ buyModal$.state.checkoutModalIsLoading.set(true);
3315
3501
  buy({
3316
3502
  quantity: parseUnits6(
3317
3503
  buyModal$.state.quantity.get(),
@@ -3321,10 +3507,12 @@ var ERC1155QuantityModal = observer13(
3321
3507
  collectableDecimals: collectable.decimals || 0,
3322
3508
  marketplace: order.marketplace
3323
3509
  });
3324
- }
3510
+ },
3511
+ disabled: buyModal$.state.checkoutModalIsLoading.get(),
3512
+ pending: buyModal$.state.checkoutModalIsLoading.get()
3325
3513
  }
3326
3514
  ],
3327
- children: /* @__PURE__ */ jsxs19(Box18, { display: "flex", flexDirection: "column", gap: "4", children: [
3515
+ children: /* @__PURE__ */ jsxs19(Box19, { display: "flex", flexDirection: "column", gap: "4", children: [
3328
3516
  /* @__PURE__ */ jsx26(
3329
3517
  QuantityInput,
3330
3518
  {
@@ -3334,11 +3522,11 @@ var ERC1155QuantityModal = observer13(
3334
3522
  maxQuantity: order.quantityRemaining
3335
3523
  }
3336
3524
  ),
3337
- /* @__PURE__ */ jsxs19(Box18, { display: "flex", justifyContent: "space-between", children: [
3525
+ /* @__PURE__ */ jsxs19(Box19, { display: "flex", justifyContent: "space-between", children: [
3338
3526
  /* @__PURE__ */ jsx26(Text15, { color: "text50", fontSize: "small", children: "Total Price" }),
3339
- /* @__PURE__ */ jsxs19(Box18, { display: "flex", alignItems: "center", gap: "2", children: [
3527
+ /* @__PURE__ */ jsxs19(Box19, { display: "flex", alignItems: "center", gap: "2", children: [
3340
3528
  /* @__PURE__ */ jsx26(TokenImage2, { src: currency?.imageUrl, size: "xs" }),
3341
- /* @__PURE__ */ jsx26(Text15, { color: "text100", fontSize: "small", fontWeight: "bold", children: formatUnits3(BigInt(totalPrice), currency?.decimals || 0) })
3529
+ /* @__PURE__ */ jsx26(Text15, { color: "text100", fontSize: "small", fontWeight: "bold", children: formatUnits4(BigInt(totalPrice), currency?.decimals || 0) })
3342
3530
  ] })
3343
3531
  ] })
3344
3532
  ] })
@@ -3433,7 +3621,9 @@ var useBuyCollectable = ({
3433
3621
  collectionAddress,
3434
3622
  tokenId,
3435
3623
  callbacks,
3436
- priceCurrencyAddress
3624
+ priceCurrencyAddress,
3625
+ setCheckoutModalIsLoading,
3626
+ setCheckoutModalLoaded
3437
3627
  }) => {
3438
3628
  const { openSelectPaymentModal } = useSelectPaymentModal();
3439
3629
  const config = useConfig();
@@ -3446,6 +3636,12 @@ var useBuyCollectable = ({
3446
3636
  if (isError || !wallet) {
3447
3637
  return { status: "error", buy: null, isLoading, isError: true };
3448
3638
  }
3639
+ const invalidateQueries2 = async (queriesToInvalidate) => {
3640
+ const queryClient = getQueryClient();
3641
+ for (const queryKey of queriesToInvalidate) {
3642
+ await queryClient.invalidateQueries({ queryKey });
3643
+ }
3644
+ };
3449
3645
  return {
3450
3646
  status: "ready",
3451
3647
  isLoading,
@@ -3464,6 +3660,8 @@ var useBuyCollectable = ({
3464
3660
  additionalFees: [fees],
3465
3661
  walletType: "unknown" /* unknown */
3466
3662
  });
3663
+ setCheckoutModalLoaded(true);
3664
+ setCheckoutModalIsLoading(false);
3467
3665
  const step = steps[0];
3468
3666
  openSelectPaymentModal({
3469
3667
  chain: chainId,
@@ -3483,10 +3681,18 @@ var useBuyCollectable = ({
3483
3681
  enableMainCurrencyPayment: true,
3484
3682
  enableSwapPayments: !!input.checkoutOptions.swap,
3485
3683
  creditCardProviders: input.checkoutOptions.nftCheckout || [],
3486
- onSuccess: (hash) => callbacks?.onSuccess?.(hash),
3684
+ onSuccess: (hash) => {
3685
+ invalidateQueries2([
3686
+ collectableKeys.listings,
3687
+ collectableKeys.listingsCount,
3688
+ collectableKeys.lists,
3689
+ collectableKeys.userBalances,
3690
+ balanceQueries.all
3691
+ ]);
3692
+ callbacks?.onSuccess?.({ hash });
3693
+ },
3487
3694
  onError: callbacks?.onError,
3488
3695
  onClose: () => {
3489
- console.log("onClose");
3490
3696
  buyModal$.close();
3491
3697
  }
3492
3698
  });
@@ -3497,20 +3703,22 @@ var useBuyCollectable = ({
3497
3703
  // src/react/ui/modals/BuyModal/Modal.tsx
3498
3704
  import { jsx as jsx27 } from "react/jsx-runtime";
3499
3705
  var BuyModal = () => {
3500
- const isOpen = use$(buyModal$.isOpen);
3706
+ const isOpen = use$2(buyModal$.isOpen);
3501
3707
  if (!isOpen) return null;
3502
3708
  return /* @__PURE__ */ jsx27(BuyModalContent, {});
3503
3709
  };
3504
3710
  var BuyModalContent = () => {
3505
- const chainId = String(use$(buyModal$.state.order.chainId));
3506
- const collectionAddress = use$(
3711
+ const chainId = String(use$2(buyModal$.state.order.chainId));
3712
+ const collectionAddress = use$2(
3507
3713
  buyModal$.state.order.collectionContractAddress
3508
3714
  );
3509
- const collectibleId = use$(buyModal$.state.order.tokenId);
3510
- const modalId = use$(buyModal$.state.modalId);
3511
- const callbacks = use$(buyModal$.callbacks);
3512
- const order = use$(buyModal$.state.order);
3513
- const isOpen = use$(buyModal$.isOpen);
3715
+ const collectibleId = use$2(buyModal$.state.order.tokenId);
3716
+ const modalId = use$2(buyModal$.state.modalId);
3717
+ const callbacks = use$2(buyModal$.callbacks);
3718
+ const order = use$2(buyModal$.state.order);
3719
+ const isOpen = use$2(buyModal$.isOpen);
3720
+ const setCheckoutModalIsLoading = use$2(buyModal$.setCheckoutModalIsLoading);
3721
+ const setCheckoutModalLoaded = use$2(buyModal$.setCheckoutModalLoaded);
3514
3722
  const { collection, collectable, checkoutOptions, isLoading, isError } = useLoadData({
3515
3723
  chainId: Number(chainId),
3516
3724
  collectionAddress,
@@ -3527,7 +3735,9 @@ var BuyModalContent = () => {
3527
3735
  collectionAddress,
3528
3736
  callbacks,
3529
3737
  tokenId: collectibleId,
3530
- priceCurrencyAddress: order.priceCurrencyAddress
3738
+ priceCurrencyAddress: order.priceCurrencyAddress,
3739
+ setCheckoutModalIsLoading,
3740
+ setCheckoutModalLoaded
3531
3741
  });
3532
3742
  if (isLoading || !collection || !collectable || !checkoutOptions || buyIsLoading) {
3533
3743
  return /* @__PURE__ */ jsx27(
@@ -3619,12 +3829,12 @@ var useBuyModal = (callbacks) => {
3619
3829
  };
3620
3830
 
3621
3831
  // src/react/ui/components/collectible-card/CollectibleCard.tsx
3622
- import { useState as useState7 } from "react";
3623
- import { Box as Box22, IconButton as IconButton6, Skeleton as Skeleton8 } from "@0xsequence/design-system";
3832
+ import { useState as useState8 } from "react";
3833
+ import { Box as Box23, IconButton as IconButton6, Skeleton as Skeleton8 } from "@0xsequence/design-system";
3624
3834
  import { useAccount as useAccount7 } from "wagmi";
3625
3835
 
3626
3836
  // src/react/ui/icons/DiamondEye.tsx
3627
- import { Box as Box19 } from "@0xsequence/design-system";
3837
+ import { Box as Box20 } from "@0xsequence/design-system";
3628
3838
  import { jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
3629
3839
  var Svg = () => /* @__PURE__ */ jsxs21(
3630
3840
  "svg",
@@ -3651,7 +3861,7 @@ var Svg = () => /* @__PURE__ */ jsxs21(
3651
3861
  }
3652
3862
  );
3653
3863
  var SvgDiamondEyeIcon = ({ size = "sm", ...props }) => /* @__PURE__ */ jsx29(
3654
- Box19,
3864
+ Box20,
3655
3865
  {
3656
3866
  as: Svg,
3657
3867
  className: iconVariants({
@@ -3776,12 +3986,12 @@ function ActionButtonBody({ label, onClick }) {
3776
3986
  }
3777
3987
 
3778
3988
  // src/react/ui/components/collectible-card/Footer.tsx
3779
- import { Box as Box21, IconButton as IconButton5, Image as Image6, Text as Text16 } from "@0xsequence/design-system";
3780
- import { formatUnits as formatUnits4 } from "viem";
3989
+ import { Box as Box22, IconButton as IconButton5, Image as Image6, Text as Text16 } from "@0xsequence/design-system";
3990
+ import { formatUnits as formatUnits5 } from "viem";
3781
3991
  import { useAccount as useAccount6 } from "wagmi";
3782
3992
 
3783
3993
  // src/react/ui/icons/Bell.tsx
3784
- import { Box as Box20 } from "@0xsequence/design-system";
3994
+ import { Box as Box21 } from "@0xsequence/design-system";
3785
3995
  import { jsx as jsx31, jsxs as jsxs22 } from "react/jsx-runtime";
3786
3996
  var Svg2 = () => /* @__PURE__ */ jsxs22(
3787
3997
  "svg",
@@ -3808,7 +4018,7 @@ var Svg2 = () => /* @__PURE__ */ jsxs22(
3808
4018
  }
3809
4019
  );
3810
4020
  var SvgBellIcon = ({ size = "sm", ...props }) => /* @__PURE__ */ jsx31(
3811
- Box20,
4021
+ Box21,
3812
4022
  {
3813
4023
  as: Svg2,
3814
4024
  className: iconVariants({
@@ -3840,7 +4050,7 @@ var Footer = ({
3840
4050
  name = `${name.substring(0, 17)}...`;
3841
4051
  }
3842
4052
  return /* @__PURE__ */ jsxs23(
3843
- Box21,
4053
+ Box22,
3844
4054
  {
3845
4055
  display: "flex",
3846
4056
  flexDirection: "column",
@@ -3852,7 +4062,7 @@ var Footer = ({
3852
4062
  className: !!address && isAnimated ? footer.animated : footer.static,
3853
4063
  children: [
3854
4064
  /* @__PURE__ */ jsxs23(
3855
- Box21,
4065
+ Box22,
3856
4066
  {
3857
4067
  display: "flex",
3858
4068
  alignItems: "center",
@@ -3890,7 +4100,7 @@ var Footer = ({
3890
4100
  ]
3891
4101
  }
3892
4102
  ),
3893
- /* @__PURE__ */ jsxs23(Box21, { display: "flex", alignItems: "center", gap: "1", children: [
4103
+ /* @__PURE__ */ jsxs23(Box22, { display: "flex", alignItems: "center", gap: "1", children: [
3894
4104
  listed && /* @__PURE__ */ jsx32(Image6, { src: lowestListingCurrency?.imageUrl, width: "3", height: "3" }),
3895
4105
  /* @__PURE__ */ jsxs23(
3896
4106
  Text16,
@@ -3901,7 +4111,7 @@ var Footer = ({
3901
4111
  textAlign: "left",
3902
4112
  fontFamily: "body",
3903
4113
  children: [
3904
- listed && `${formatUnits4(
4114
+ listed && `${formatUnits5(
3905
4115
  BigInt(lowestListingPriceAmount),
3906
4116
  lowestListingCurrency.decimals
3907
4117
  )} ${lowestListingCurrency.symbol}`,
@@ -3940,7 +4150,7 @@ var TokenTypeBalancePill = ({
3940
4150
  import { jsx as jsx33, jsxs as jsxs24 } from "react/jsx-runtime";
3941
4151
  function CollectibleSkeleton() {
3942
4152
  return /* @__PURE__ */ jsxs24(
3943
- Box22,
4153
+ Box23,
3944
4154
  {
3945
4155
  className: collectibleCard,
3946
4156
  borderRadius: "md",
@@ -3955,7 +4165,7 @@ function CollectibleSkeleton() {
3955
4165
  }
3956
4166
  ),
3957
4167
  /* @__PURE__ */ jsxs24(
3958
- Box22,
4168
+ Box23,
3959
4169
  {
3960
4170
  display: "flex",
3961
4171
  flexDirection: "column",
@@ -3987,7 +4197,7 @@ function CollectibleCard({
3987
4197
  }) {
3988
4198
  const { address: accountAddress } = useAccount7();
3989
4199
  const collectibleMetadata = lowestListing?.metadata;
3990
- const [imageLoadingError, setImageLoadingError] = useState7(false);
4200
+ const [imageLoadingError, setImageLoadingError] = useState8(false);
3991
4201
  const { data: highestOffer, isLoading: highestOfferLoading } = useHighestOffer({
3992
4202
  chainId: String(chainId),
3993
4203
  collectionAddress,
@@ -4006,14 +4216,14 @@ function CollectibleCard({
4006
4216
  const image = collectibleMetadata?.image;
4007
4217
  const externalUrl = collectibleMetadata?.external_url;
4008
4218
  return /* @__PURE__ */ jsx33(
4009
- Box22,
4219
+ Box23,
4010
4220
  {
4011
4221
  className: collectibleCard,
4012
4222
  borderRadius: "md",
4013
4223
  overflow: "hidden",
4014
4224
  background: "backgroundPrimary",
4015
4225
  children: /* @__PURE__ */ jsx33(
4016
- Box22,
4226
+ Box23,
4017
4227
  {
4018
4228
  display: "flex",
4019
4229
  flexDirection: "column",
@@ -4069,7 +4279,7 @@ function CollectibleCard({
4069
4279
  }
4070
4280
  ),
4071
4281
  accountAddress && (highestOffer || lowestListing) && /* @__PURE__ */ jsx33(
4072
- Box22,
4282
+ Box23,
4073
4283
  {
4074
4284
  display: "flex",
4075
4285
  alignItems: "center",
@@ -4108,4 +4318,4 @@ export {
4108
4318
  useBuyModal,
4109
4319
  CollectibleCard
4110
4320
  };
4111
- //# sourceMappingURL=chunk-2AMLJ2TA.js.map
4321
+ //# sourceMappingURL=chunk-SEISACMH.js.map