@0xsequence/marketplace-sdk 0.4.1 → 0.4.2

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 (67) hide show
  1. package/dist/{chunk-RZSZNVEH.js → chunk-2OJB35FS.js} +7 -7
  2. package/dist/{chunk-RZSZNVEH.js.map → chunk-2OJB35FS.js.map} +1 -1
  3. package/dist/{chunk-QMO2CUNM.js → chunk-4RKM3VUV.js} +2 -2
  4. package/dist/{chunk-7NJETFMF.js → chunk-FI723DGL.js} +3 -3
  5. package/dist/{chunk-7NJETFMF.js.map → chunk-FI723DGL.js.map} +1 -1
  6. package/dist/{chunk-UPLTM63S.js → chunk-MQ5WSFDH.js} +7 -7
  7. package/dist/{chunk-UPLTM63S.js.map → chunk-MQ5WSFDH.js.map} +1 -1
  8. package/dist/{chunk-IOTKCWOB.js → chunk-MTFS5SED.js} +1089 -1088
  9. package/dist/chunk-MTFS5SED.js.map +1 -0
  10. package/dist/{chunk-4ESPWOBV.js → chunk-NC4KGXXE.js} +3 -3
  11. package/dist/{chunk-4ESPWOBV.js.map → chunk-NC4KGXXE.js.map} +1 -1
  12. package/dist/{chunk-EVRILXOH.js → chunk-OPMDGQFB.js} +37 -35
  13. package/dist/{chunk-EVRILXOH.js.map → chunk-OPMDGQFB.js.map} +1 -1
  14. package/dist/{chunk-5GDO4ZBC.js → chunk-S5IPE7TH.js} +2 -2
  15. package/dist/{chunk-O642NH7U.js → chunk-TDTORZHC.js} +3 -3
  16. package/dist/{chunk-O642NH7U.js.map → chunk-TDTORZHC.js.map} +1 -1
  17. package/dist/{chunk-MIYMMP2K.js → chunk-WBJKZOQ7.js} +214 -134
  18. package/dist/chunk-WBJKZOQ7.js.map +1 -0
  19. package/dist/{chunk-KNX2LER4.js → chunk-ZWIRTV7A.js} +2 -2
  20. package/dist/index.js +4 -4
  21. package/dist/react/_internal/api/index.js +2 -2
  22. package/dist/react/_internal/index.js +3 -3
  23. package/dist/react/_internal/wagmi/index.js +2 -2
  24. package/dist/react/hooks/index.d.ts +5 -7
  25. package/dist/react/hooks/index.js +6 -6
  26. package/dist/react/index.js +10 -10
  27. package/dist/react/ui/components/index.js +10 -10
  28. package/dist/react/ui/index.d.ts +15 -8
  29. package/dist/react/ui/index.js +10 -10
  30. package/dist/react/ui/modals/_internal/components/actionModal/index.js +6 -6
  31. package/dist/react/ui/styles/index.js +1 -1
  32. package/dist/styles/index.js +4 -4
  33. package/dist/types/index.js +3 -3
  34. package/dist/utils/index.js +2 -2
  35. package/package.json +8 -8
  36. package/src/react/_internal/transaction-machine/execute-transaction.ts +70 -113
  37. package/src/react/_internal/transaction-machine/useTransactionMachine.ts +13 -32
  38. package/src/react/_internal/transaction-machine/utils.ts +50 -0
  39. package/src/react/_internal/transaction-machine/wallet.ts +180 -0
  40. package/src/react/hooks/useBuyCollectable.tsx +14 -5
  41. package/src/react/hooks/useCancelOrder.tsx +0 -3
  42. package/src/react/hooks/useCreateListing.tsx +0 -3
  43. package/src/react/hooks/useGenerateListingTransaction.tsx +1 -3
  44. package/src/react/hooks/useGenerateOfferTransaction.tsx +1 -3
  45. package/src/react/hooks/useMakeOffer.tsx +0 -3
  46. package/src/react/hooks/useSell.tsx +0 -3
  47. package/src/react/ui/modals/BuyModal/index.tsx +21 -5
  48. package/src/react/ui/modals/CreateListingModal/Modal.tsx +252 -0
  49. package/src/react/ui/modals/CreateListingModal/index.tsx +6 -284
  50. package/src/react/ui/modals/CreateListingModal/store.ts +76 -0
  51. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +254 -0
  52. package/src/react/ui/modals/MakeOfferModal/index.tsx +8 -262
  53. package/src/react/ui/modals/MakeOfferModal/{_store.ts → store.ts} +24 -14
  54. package/src/react/ui/modals/SellModal/Modal.tsx +218 -0
  55. package/src/react/ui/modals/SellModal/index.tsx +8 -238
  56. package/src/react/ui/modals/SellModal/{_store.ts → store.ts} +13 -9
  57. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +3 -2
  58. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +2 -1
  59. package/src/react/ui/modals/modal-provider.tsx +3 -3
  60. package/src/utils/date.ts +2 -0
  61. package/tsconfig.tsbuildinfo +1 -1
  62. package/dist/chunk-IOTKCWOB.js.map +0 -1
  63. package/dist/chunk-MIYMMP2K.js.map +0 -1
  64. package/src/react/ui/modals/CreateListingModal/_store.ts +0 -55
  65. /package/dist/{chunk-QMO2CUNM.js.map → chunk-4RKM3VUV.js.map} +0 -0
  66. /package/dist/{chunk-5GDO4ZBC.js.map → chunk-S5IPE7TH.js.map} +0 -0
  67. /package/dist/{chunk-KNX2LER4.js.map → chunk-ZWIRTV7A.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  ActionModal,
4
4
  CustomSelect,
5
5
  useCurrencyBalance
6
- } from "./chunk-UPLTM63S.js";
6
+ } from "./chunk-MQ5WSFDH.js";
7
7
  import {
8
8
  CalendarIcon_default,
9
9
  MinusIcon_default,
@@ -33,9 +33,10 @@ import {
33
33
  quantityInputWrapper,
34
34
  tokenPreview,
35
35
  transferModalContent
36
- } from "./chunk-RZSZNVEH.js";
36
+ } from "./chunk-2OJB35FS.js";
37
37
  import {
38
38
  AlertMessage,
39
+ dateToUnixTime,
39
40
  switchChainModal_default,
40
41
  useBalanceOfCollectible,
41
42
  useBuyCollectable,
@@ -51,7 +52,7 @@ import {
51
52
  useSwitchChainModal,
52
53
  useTransactionMachine,
53
54
  useTransferTokens
54
- } from "./chunk-MIYMMP2K.js";
55
+ } from "./chunk-WBJKZOQ7.js";
55
56
  import {
56
57
  iconVariants
57
58
  } from "./chunk-LF44FCG5.js";
@@ -59,16 +60,16 @@ import {
59
60
  calculatePriceDifferencePercentage,
60
61
  getPublicRpcClient,
61
62
  truncateMiddle
62
- } from "./chunk-KNX2LER4.js";
63
+ } from "./chunk-ZWIRTV7A.js";
63
64
  import {
64
65
  balanceQueries,
65
66
  collectableKeys,
66
67
  getQueryClient
67
- } from "./chunk-5GDO4ZBC.js";
68
+ } from "./chunk-S5IPE7TH.js";
68
69
  import {
69
70
  InvalidContractTypeError,
70
71
  InvalidStepError
71
- } from "./chunk-EVRILXOH.js";
72
+ } from "./chunk-OPMDGQFB.js";
72
73
 
73
74
  // src/react/ui/modals/modal-provider.tsx
74
75
  import { observer as observer14 } from "@legendapp/state/react";
@@ -92,9 +93,9 @@ var AccountModal = observer(function AccountModal2() {
92
93
  });
93
94
 
94
95
  // src/react/ui/modals/BuyModal/index.tsx
95
- import { Box as Box3, Text as Text2, TokenImage } from "@0xsequence/design-system";
96
+ import { Box as Box4, Text as Text2, TokenImage } from "@0xsequence/design-system";
96
97
  import { Show, observer as observer2, useSelector } from "@legendapp/state/react";
97
- import { useEffect } from "react";
98
+ import { useCallback, useEffect, useState } from "react";
98
99
  import { formatUnits, parseUnits } from "viem";
99
100
 
100
101
  // src/react/ui/modals/_internal/components/quantityInput/index.tsx
@@ -240,15 +241,35 @@ var initialState = {
240
241
  };
241
242
  var buyModal$ = observable2(initialState);
242
243
 
244
+ // src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx
245
+ import { Box as Box3, Spinner } from "@0xsequence/design-system";
246
+ import { jsx as jsx3 } from "react/jsx-runtime";
247
+ var LoadingModal = ({
248
+ isOpen,
249
+ chainId,
250
+ onClose,
251
+ title
252
+ }) => /* @__PURE__ */ jsx3(
253
+ ActionModal,
254
+ {
255
+ isOpen,
256
+ chainId,
257
+ onClose,
258
+ title,
259
+ ctas: [],
260
+ children: /* @__PURE__ */ jsx3(Box3, { display: "flex", justifyContent: "center", alignItems: "center", padding: "4", children: /* @__PURE__ */ jsx3(Spinner, { size: "lg" }) })
261
+ }
262
+ );
263
+
243
264
  // src/react/ui/modals/BuyModal/index.tsx
244
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
265
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
245
266
  var useBuyModal = (callbacks) => {
246
267
  return {
247
268
  show: (args) => buyModal$.open({ ...args, defaultCallbacks: callbacks }),
248
269
  close: () => buyModal$.close()
249
270
  };
250
271
  };
251
- var BuyModal = () => /* @__PURE__ */ jsx3(Show, { if: buyModal$.isOpen, children: /* @__PURE__ */ jsx3(BuyModalContent, {}) });
272
+ var BuyModal = () => /* @__PURE__ */ jsx4(Show, { if: buyModal$.isOpen, children: /* @__PURE__ */ jsx4(BuyModalContent, {}) });
252
273
  var BuyModalContent = () => {
253
274
  const chainId = String(useSelector(buyModal$.state.order.chainId));
254
275
  const collectionAddress = useSelector(
@@ -257,17 +278,21 @@ var BuyModalContent = () => {
257
278
  const collectibleId = useSelector(buyModal$.state.order.tokenId);
258
279
  const modalId = useSelector(buyModal$.state.modalId);
259
280
  const callbacks = useSelector(buyModal$.callbacks);
281
+ const [paymentLoadingModalOpen, setPaymentLoadingModalOpen] = useState(false);
260
282
  const { data: collection } = useCollection({
261
283
  chainId,
262
284
  collectionAddress
263
285
  });
286
+ const onPaymentModalLoaded = useCallback(() => {
287
+ buyModal$.close();
288
+ setPaymentLoadingModalOpen(false);
289
+ }, [setPaymentLoadingModalOpen]);
264
290
  const { buy, isLoading } = useBuyCollectable({
265
291
  chainId,
266
292
  collectionAddress,
267
293
  enabled: buyModal$.isOpen.get(),
268
- onSwitchChainRefused: () => {
269
- buyModal$.close();
270
- },
294
+ setPaymentLoadingModalOpen,
295
+ onPaymentModalLoaded,
271
296
  onError: (error) => {
272
297
  if (callbacks?.onError) {
273
298
  callbacks.onError(error);
@@ -290,7 +315,18 @@ var BuyModalContent = () => {
290
315
  collectibleId
291
316
  });
292
317
  if (modalId === 0 || !collection || !collectable || !buy) return null;
293
- return collection.type === "ERC721" /* ERC721 */ ? /* @__PURE__ */ jsx3(
318
+ if (paymentLoadingModalOpen) {
319
+ return /* @__PURE__ */ jsx4(
320
+ LoadingModal,
321
+ {
322
+ isOpen: buyModal$.isOpen.get(),
323
+ chainId: Number(chainId),
324
+ onClose: buyModal$.close,
325
+ title: "Loading Sequence Pay"
326
+ }
327
+ );
328
+ }
329
+ return collection.type === "ERC721" /* ERC721 */ ? /* @__PURE__ */ jsx4(
294
330
  CheckoutModal,
295
331
  {
296
332
  buy,
@@ -299,7 +335,7 @@ var BuyModalContent = () => {
299
335
  isLoading
300
336
  },
301
337
  modalId
302
- ) : /* @__PURE__ */ jsx3(
338
+ ) : /* @__PURE__ */ jsx4(
303
339
  ERC1155QuantityModal,
304
340
  {
305
341
  buy,
@@ -350,7 +386,7 @@ var ERC1155QuantityModal = observer2(
350
386
  const quantity = Number(buyModal$.state.quantity.get());
351
387
  const pricePerToken = order.priceAmount;
352
388
  const totalPrice = (BigInt(quantity) * BigInt(pricePerToken)).toString();
353
- return /* @__PURE__ */ jsx3(
389
+ return /* @__PURE__ */ jsx4(
354
390
  ActionModal,
355
391
  {
356
392
  isOpen: buyModal$.isOpen.get(),
@@ -370,12 +406,11 @@ var ERC1155QuantityModal = observer2(
370
406
  collectableDecimals: collectable.decimals || 0,
371
407
  marketplace: order.marketplace
372
408
  });
373
- buyModal$.close();
374
409
  }
375
410
  }
376
411
  ],
377
- children: /* @__PURE__ */ jsxs3(Box3, { display: "flex", flexDirection: "column", gap: "4", children: [
378
- /* @__PURE__ */ jsx3(
412
+ children: /* @__PURE__ */ jsxs3(Box4, { display: "flex", flexDirection: "column", gap: "4", children: [
413
+ /* @__PURE__ */ jsx4(
379
414
  QuantityInput,
380
415
  {
381
416
  $quantity: buyModal$.state.quantity,
@@ -384,11 +419,11 @@ var ERC1155QuantityModal = observer2(
384
419
  maxQuantity: order.quantityRemaining
385
420
  }
386
421
  ),
387
- /* @__PURE__ */ jsxs3(Box3, { display: "flex", justifyContent: "space-between", children: [
388
- /* @__PURE__ */ jsx3(Text2, { color: "text50", fontSize: "small", children: "Total Price" }),
389
- /* @__PURE__ */ jsxs3(Box3, { display: "flex", alignItems: "center", gap: "2", children: [
390
- /* @__PURE__ */ jsx3(TokenImage, { src: currency?.imageUrl, size: "xs" }),
391
- /* @__PURE__ */ jsx3(Text2, { color: "text100", fontSize: "small", fontWeight: "bold", children: formatUnits(BigInt(totalPrice), currency?.decimals || 0) })
422
+ /* @__PURE__ */ jsxs3(Box4, { display: "flex", justifyContent: "space-between", children: [
423
+ /* @__PURE__ */ jsx4(Text2, { color: "text50", fontSize: "small", children: "Total Price" }),
424
+ /* @__PURE__ */ jsxs3(Box4, { display: "flex", alignItems: "center", gap: "2", children: [
425
+ /* @__PURE__ */ jsx4(TokenImage, { src: currency?.imageUrl, size: "xs" }),
426
+ /* @__PURE__ */ jsx4(Text2, { color: "text100", fontSize: "small", fontWeight: "bold", children: formatUnits(BigInt(totalPrice), currency?.decimals || 0) })
392
427
  ] })
393
428
  ] })
394
429
  ] })
@@ -397,30 +432,27 @@ var ERC1155QuantityModal = observer2(
397
432
  }
398
433
  );
399
434
 
400
- // src/react/ui/modals/CreateListingModal/index.tsx
401
- import { Box as Box14 } from "@0xsequence/design-system";
435
+ // src/react/ui/modals/MakeOfferModal/Modal.tsx
402
436
  import { Show as Show2, observer as observer8 } from "@legendapp/state/react";
403
- import { useEffect as useEffect6, useState as useState7 } from "react";
437
+ import { useEffect as useEffect6, useState as useState8 } from "react";
404
438
  import { parseUnits as parseUnits3 } from "viem";
405
- import { useAccount as useAccount3 } from "wagmi";
406
439
 
407
- // src/react/hooks/useCreateListing.tsx
408
- import { useCallback, useState } from "react";
409
- var useCreateListing = ({
440
+ // src/react/hooks/useMakeOffer.tsx
441
+ import { useCallback as useCallback2, useState as useState2 } from "react";
442
+ var useMakeOffer = ({
410
443
  onSuccess,
411
444
  onError,
412
445
  onTransactionSent,
413
446
  onApprovalSuccess,
414
- onSwitchChainRefused,
415
447
  enabled,
416
448
  ...config
417
449
  }) => {
418
- const [isLoading, setIsLoading] = useState(false);
419
- const [steps, setSteps] = useState(null);
420
- const [executionState, setExecutionState] = useState(null);
450
+ const [isLoading, setIsLoading] = useState2(false);
451
+ const [steps, setSteps] = useState2(null);
452
+ const [executionState, setExecutionState] = useState2(null);
421
453
  const machineConfig = {
422
454
  ...config,
423
- type: "LISTING" /* LISTING */
455
+ type: "OFFER" /* OFFER */
424
456
  };
425
457
  const { machine, isLoading: isMachineLoading } = useTransactionMachine({
426
458
  config: machineConfig,
@@ -437,10 +469,9 @@ var useCreateListing = ({
437
469
  onApprovalSuccess: (hash) => {
438
470
  setExecutionState(null);
439
471
  onApprovalSuccess?.(hash);
440
- },
441
- onSwitchChainRefused
472
+ }
442
473
  });
443
- const loadSteps = useCallback(
474
+ const loadSteps = useCallback2(
444
475
  async (props) => {
445
476
  if (!machine) return;
446
477
  setIsLoading(true);
@@ -457,14 +488,14 @@ var useCreateListing = ({
457
488
  },
458
489
  transaction: {
459
490
  ...generatedSteps.transaction,
460
- isExecuting: executionState === "listing"
491
+ isExecuting: executionState === "offer"
461
492
  }
462
493
  });
463
494
  setIsLoading(false);
464
495
  },
465
496
  [machine, executionState]
466
497
  );
467
- const handleStepExecution = useCallback(
498
+ const handleStepExecution = useCallback2(
468
499
  async (type, execute) => {
469
500
  if (!type) return;
470
501
  setExecutionState(type);
@@ -478,8 +509,8 @@ var useCreateListing = ({
478
509
  []
479
510
  );
480
511
  return {
481
- createListing: (props) => machine?.start(props),
482
- getListingSteps: (props) => ({
512
+ makeOffer: (props) => machine?.start(props),
513
+ getMakeOfferSteps: (props) => ({
483
514
  isLoading,
484
515
  steps: steps ? {
485
516
  ...steps,
@@ -490,11 +521,8 @@ var useCreateListing = ({
490
521
  },
491
522
  transaction: {
492
523
  ...steps.transaction,
493
- isExecuting: executionState === "listing",
494
- execute: () => handleStepExecution(
495
- "listing",
496
- () => steps.transaction.execute()
497
- )
524
+ isExecuting: executionState === "offer",
525
+ execute: () => handleStepExecution("offer", () => steps.transaction.execute())
498
526
  }
499
527
  } : null,
500
528
  refreshSteps: () => loadSteps(props)
@@ -504,29 +532,9 @@ var useCreateListing = ({
504
532
  };
505
533
 
506
534
  // src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx
507
- import { Box as Box4 } from "@0xsequence/design-system";
508
- import { jsx as jsx4 } from "react/jsx-runtime";
509
- var ErrorModal = ({
510
- isOpen,
511
- chainId,
512
- onClose,
513
- title
514
- }) => /* @__PURE__ */ jsx4(
515
- ActionModal,
516
- {
517
- isOpen,
518
- chainId,
519
- onClose,
520
- title,
521
- ctas: [],
522
- children: /* @__PURE__ */ jsx4(Box4, { display: "flex", justifyContent: "center", alignItems: "center", padding: "4", children: "Error loading item details" })
523
- }
524
- );
525
-
526
- // src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx
527
- import { Box as Box5, Spinner } from "@0xsequence/design-system";
535
+ import { Box as Box5 } from "@0xsequence/design-system";
528
536
  import { jsx as jsx5 } from "react/jsx-runtime";
529
- var LoadingModal = ({
537
+ var ErrorModal = ({
530
538
  isOpen,
531
539
  chainId,
532
540
  onClose,
@@ -539,7 +547,7 @@ var LoadingModal = ({
539
547
  onClose,
540
548
  title,
541
549
  ctas: [],
542
- children: /* @__PURE__ */ jsx5(Box5, { display: "flex", justifyContent: "center", alignItems: "center", padding: "4", children: /* @__PURE__ */ jsx5(Spinner, { size: "lg" }) })
550
+ children: /* @__PURE__ */ jsx5(Box5, { display: "flex", justifyContent: "center", alignItems: "center", padding: "4", children: "Error loading item details" })
543
551
  }
544
552
  );
545
553
 
@@ -635,7 +643,7 @@ function CalendarPopover({
635
643
  }
636
644
 
637
645
  // src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx
638
- import { useState as useState2 } from "react";
646
+ import { useState as useState3 } from "react";
639
647
  import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
640
648
  var PRESET_RANGES = {
641
649
  TODAY: {
@@ -669,7 +677,7 @@ var ExpirationDateSelect = observer3(function ExpirationDateSelect2({
669
677
  $date
670
678
  }) {
671
679
  const defaultRange = "1_week";
672
- const [selectedRange, setSelectedRange] = useState2(defaultRange);
680
+ const [selectedRange, setSelectedRange] = useState3(defaultRange);
673
681
  function handleSelectPresetRange(range) {
674
682
  const presetRange = Object.values(PRESET_RANGES).find(
675
683
  (preset) => preset.value === range
@@ -792,18 +800,18 @@ function FloorPriceText({
792
800
  // src/react/ui/modals/_internal/components/priceInput/index.tsx
793
801
  import { Box as Box8, NumericInput as NumericInput2, Text as Text5 } from "@0xsequence/design-system";
794
802
  import { observer as observer5 } from "@legendapp/state/react";
795
- import { useEffect as useEffect3, useState as useState4 } from "react";
803
+ import { useEffect as useEffect3, useState as useState5 } from "react";
796
804
  import { parseUnits as parseUnits2 } from "viem";
797
805
  import { useAccount as useAccount2 } from "wagmi";
798
806
 
799
807
  // src/react/ui/modals/_internal/components/currencyImage/index.tsx
800
808
  import { Box as Box7, TokenImage as TokenImage2 } from "@0xsequence/design-system";
801
- import { useState as useState3 } from "react";
809
+ import { useState as useState4 } from "react";
802
810
  import { jsx as jsx10 } from "react/jsx-runtime";
803
811
  function CurrencyImage({
804
812
  $listingPrice
805
813
  }) {
806
- const [imageLoadErrorCurrencyAddresses, setImageLoadErrorCurrencyAddresses] = useState3(null);
814
+ const [imageLoadErrorCurrencyAddresses, setImageLoadErrorCurrencyAddresses] = useState4(null);
807
815
  if (imageLoadErrorCurrencyAddresses?.includes(
808
816
  $listingPrice.currency.contractAddress.get()
809
817
  )) {
@@ -903,7 +911,7 @@ var PriceInput = observer5(function PriceInput2({
903
911
  onPriceChange,
904
912
  checkBalance
905
913
  }) {
906
- const [balanceError, setBalanceError] = useState4("");
914
+ const [balanceError, setBalanceError] = useState5("");
907
915
  const { address: accountAddress } = useAccount2();
908
916
  const { data: balance, isSuccess: isBalanceSuccess } = useCurrencyBalance({
909
917
  currencyAddress: $listingPrice.currency.contractAddress.get(),
@@ -911,7 +919,7 @@ var PriceInput = observer5(function PriceInput2({
911
919
  userAddress: accountAddress
912
920
  });
913
921
  const currencyDecimals = $listingPrice.currency.decimals.get();
914
- const [value, setValue] = useState4("");
922
+ const [value, setValue] = useState5("");
915
923
  const changeListingPrice = (value2) => {
916
924
  setValue(value2);
917
925
  try {
@@ -1052,75 +1060,23 @@ function TokenPreview({
1052
1060
  ] });
1053
1061
  }
1054
1062
 
1055
- // src/react/ui/modals/_internal/components/transactionDetails/index.tsx
1056
- import { Box as Box10, Image as Image2, Skeleton as Skeleton4, Text as Text7 } from "@0xsequence/design-system";
1057
- import { formatUnits as formatUnits2 } from "viem";
1058
- import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1059
- var DEFAULT_MARKETPLACE_FEE_PERCENTAGE = 2.5;
1060
- function TransactionDetails({
1061
- collectibleId,
1062
- collectionAddress,
1063
- chainId,
1064
- price,
1065
- showPlaceholderPrice,
1066
- currencyImageUrl
1067
- }) {
1068
- const { data, isLoading: marketplaceConfigLoading } = useMarketplaceConfig();
1069
- const marketplaceFeePercentage = data?.collections.find(
1070
- (collection) => collection.collectionAddress === collectionAddress
1071
- )?.marketplaceFeePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
1072
- const { data: royaltyPercentage, isLoading: royaltyPercentageLoading } = useRoyaltyPercentage({
1073
- chainId,
1074
- collectionAddress,
1075
- collectibleId
1076
- });
1077
- const priceLoading = !price || marketplaceConfigLoading || royaltyPercentageLoading;
1078
- let formattedAmount = price && formatUnits2(BigInt(price.amountRaw), price.currency.decimals);
1079
- if (royaltyPercentage !== void 0 && formattedAmount && price) {
1080
- formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royaltyPercentage) / 100).toFixed(price.currency.decimals);
1081
- }
1082
- if (marketplaceFeePercentage !== void 0 && formattedAmount && price) {
1083
- formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * marketplaceFeePercentage / 100).toFixed(price.currency.decimals);
1084
- }
1085
- return /* @__PURE__ */ jsxs8(
1086
- Box10,
1087
- {
1088
- width: "full",
1089
- display: "flex",
1090
- justifyContent: "space-between",
1091
- alignItems: "center",
1092
- children: [
1093
- /* @__PURE__ */ jsx14(Text7, { fontSize: "small", color: "text50", fontFamily: "body", children: "Total earnings" }),
1094
- /* @__PURE__ */ jsxs8(Box10, { display: "flex", alignItems: "center", gap: "2", children: [
1095
- /* @__PURE__ */ jsx14(Image2, { src: currencyImageUrl, width: "3", height: "3" }),
1096
- priceLoading ? /* @__PURE__ */ jsx14(Skeleton4, { width: "16", height: "4" }) : /* @__PURE__ */ jsxs8(Text7, { fontSize: "small", color: "text100", fontFamily: "body", children: [
1097
- showPlaceholderPrice ? "0" : formattedAmount,
1098
- " ",
1099
- price.currency.symbol
1100
- ] })
1101
- ] })
1102
- ]
1103
- }
1104
- );
1105
- }
1106
-
1107
1063
  // src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
1108
1064
  import {
1109
1065
  CloseIcon,
1110
1066
  IconButton as IconButton2,
1111
- Skeleton as Skeleton6,
1112
- Text as Text11
1067
+ Skeleton as Skeleton5,
1068
+ Text as Text10
1113
1069
  } from "@0xsequence/design-system";
1114
1070
  import { TRANSACTION_CONFIRMATIONS_DEFAULT } from "@0xsequence/kit";
1115
1071
  import { observer as observer7 } from "@legendapp/state/react";
1116
1072
  import { Close, Content as Content2, Overlay, Portal as Portal2, Root as Root2 } from "@radix-ui/react-dialog";
1117
- import { useEffect as useEffect5, useState as useState6 } from "react";
1073
+ import { useEffect as useEffect5, useState as useState7 } from "react";
1118
1074
  import { WaitForTransactionReceiptTimeoutError } from "viem";
1119
1075
 
1120
1076
  // src/react/ui/modals/_internal/components/transaction-footer/index.tsx
1121
1077
  import { networks } from "@0xsequence/network";
1122
- import { Box as Box11, Text as Text8, Spinner as Spinner2 } from "@0xsequence/design-system";
1123
- import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
1078
+ import { Box as Box10, Text as Text7, Spinner as Spinner2 } from "@0xsequence/design-system";
1079
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1124
1080
  function TransactionFooter({
1125
1081
  transactionHash,
1126
1082
  orderId,
@@ -1130,13 +1086,13 @@ function TransactionFooter({
1130
1086
  isTimeout,
1131
1087
  chainId
1132
1088
  }) {
1133
- const icon = (isConfirmed || orderId) && /* @__PURE__ */ jsx15(PositiveCircleIcon_default, { size: "md" }) || isConfirming && /* @__PURE__ */ jsx15(Spinner2, { size: "md" });
1089
+ const icon = (isConfirmed || orderId) && /* @__PURE__ */ jsx14(PositiveCircleIcon_default, { size: "md" }) || isConfirming && /* @__PURE__ */ jsx14(Spinner2, { size: "md" });
1134
1090
  const title = (isConfirmed || orderId) && "Transaction complete" || isConfirming && "Processing transaction" || isFailed && "Transaction failed" || isTimeout && "Transaction took longer than expected";
1135
1091
  const transactionUrl = `${networks[chainId]?.blockExplorer?.rootUrl}tx/${transactionHash}`;
1136
- return /* @__PURE__ */ jsxs9(Box11, { display: "flex", alignItems: "center", children: [
1092
+ return /* @__PURE__ */ jsxs8(Box10, { display: "flex", alignItems: "center", children: [
1137
1093
  icon,
1138
- /* @__PURE__ */ jsx15(
1139
- Text8,
1094
+ /* @__PURE__ */ jsx14(
1095
+ Text7,
1140
1096
  {
1141
1097
  color: "text50",
1142
1098
  fontSize: "normal",
@@ -1146,8 +1102,8 @@ function TransactionFooter({
1146
1102
  children: title
1147
1103
  }
1148
1104
  ),
1149
- /* @__PURE__ */ jsx15(
1150
- Box11,
1105
+ /* @__PURE__ */ jsx14(
1106
+ Box10,
1151
1107
  {
1152
1108
  as: "a",
1153
1109
  flexGrow: "1",
@@ -1157,14 +1113,16 @@ function TransactionFooter({
1157
1113
  rel: "noopener noreferrer",
1158
1114
  textAlign: "right",
1159
1115
  textDecoration: "none",
1160
- children: /* @__PURE__ */ jsx15(
1161
- Text8,
1116
+ children: /* @__PURE__ */ jsx14(
1117
+ Text7,
1162
1118
  {
1163
- color: "polygonLight",
1164
1119
  textAlign: "right",
1165
1120
  fontSize: "normal",
1166
1121
  fontWeight: "medium",
1167
1122
  fontFamily: "body",
1123
+ style: {
1124
+ color: "hsla(247, 100%, 75%, 1)"
1125
+ },
1168
1126
  children: transactionHash && truncateMiddle(transactionHash, 4, 4)
1169
1127
  }
1170
1128
  )
@@ -1175,36 +1133,36 @@ function TransactionFooter({
1175
1133
 
1176
1134
  // src/react/ui/modals/_internal/components/transactionPreview/index.tsx
1177
1135
  import {
1178
- Box as Box13,
1179
- Image as Image3,
1136
+ Box as Box12,
1137
+ Image as Image2,
1180
1138
  NetworkImage,
1181
- Skeleton as Skeleton5,
1182
- Text as Text10
1139
+ Skeleton as Skeleton4,
1140
+ Text as Text9
1183
1141
  } from "@0xsequence/design-system";
1184
1142
  import { observer as observer6 } from "@legendapp/state/react";
1185
- import { formatUnits as formatUnits3 } from "viem";
1143
+ import { formatUnits as formatUnits2 } from "viem";
1186
1144
 
1187
1145
  // src/react/ui/modals/_internal/components/timeAgo/index.tsx
1188
- import { Box as Box12, Text as Text9 } from "@0xsequence/design-system";
1146
+ import { Box as Box11, Text as Text8 } from "@0xsequence/design-system";
1189
1147
  import { formatDistanceToNow } from "date-fns";
1190
- import { useEffect as useEffect4, useState as useState5 } from "react";
1191
- import { jsx as jsx16 } from "react/jsx-runtime";
1148
+ import { useEffect as useEffect4, useState as useState6 } from "react";
1149
+ import { jsx as jsx15 } from "react/jsx-runtime";
1192
1150
  function TimeAgo({ date }) {
1193
- const [timeAgo, setTimeAgo] = useState5("");
1151
+ const [timeAgo, setTimeAgo] = useState6("");
1194
1152
  useEffect4(() => {
1195
1153
  const interval = setInterval(() => {
1196
1154
  setTimeAgo(formatDistanceToNow(date));
1197
1155
  }, 1e3);
1198
1156
  return () => clearInterval(interval);
1199
1157
  }, [date]);
1200
- return /* @__PURE__ */ jsx16(
1201
- Box12,
1158
+ return /* @__PURE__ */ jsx15(
1159
+ Box11,
1202
1160
  {
1203
1161
  flexGrow: "1",
1204
1162
  display: "flex",
1205
1163
  alignItems: "center",
1206
1164
  justifyContent: "flex-end",
1207
- children: /* @__PURE__ */ jsx16(Text9, { color: "text50", fontSize: "small", children: timeAgo })
1165
+ children: /* @__PURE__ */ jsx15(Text8, { color: "text50", fontSize: "small", children: timeAgo })
1208
1166
  }
1209
1167
  );
1210
1168
  }
@@ -1311,7 +1269,7 @@ function useTransactionPreviewTitle(orderId, status, type) {
1311
1269
  }
1312
1270
 
1313
1271
  // src/react/ui/modals/_internal/components/transactionPreview/index.tsx
1314
- import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1272
+ import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
1315
1273
  var TransactionPreview = observer6(
1316
1274
  ({
1317
1275
  orderId,
@@ -1339,14 +1297,14 @@ var TransactionPreview = observer6(
1339
1297
  const collectibleImage2 = collectible?.image;
1340
1298
  const collectibleName = collectible?.name;
1341
1299
  const collectionName = collection?.name;
1342
- const priceFormatted = price ? formatUnits3(BigInt(price?.amountRaw), price?.currency.decimals) : void 0;
1300
+ const priceFormatted = price ? formatUnits2(BigInt(price?.amountRaw), price?.currency.decimals) : void 0;
1343
1301
  if (collectibleLoading || collectionLoading) {
1344
- return /* @__PURE__ */ jsx17(Box13, { style: { height: 83 }, width: "full", borderRadius: "md", children: /* @__PURE__ */ jsx17(Skeleton5, { style: { width: "100%", height: "100%" } }) });
1302
+ return /* @__PURE__ */ jsx16(Box12, { style: { height: 83 }, width: "full", borderRadius: "md", children: /* @__PURE__ */ jsx16(Skeleton4, { style: { width: "100%", height: "100%" } }) });
1345
1303
  }
1346
- return /* @__PURE__ */ jsxs10(Box13, { padding: "3", background: "backgroundSecondary", borderRadius: "md", children: [
1347
- /* @__PURE__ */ jsxs10(Box13, { display: "flex", alignItems: "center", children: [
1348
- /* @__PURE__ */ jsx17(
1349
- Text10,
1304
+ return /* @__PURE__ */ jsxs9(Box12, { padding: "3", background: "backgroundSecondary", borderRadius: "md", children: [
1305
+ /* @__PURE__ */ jsxs9(Box12, { display: "flex", alignItems: "center", children: [
1306
+ /* @__PURE__ */ jsx16(
1307
+ Text9,
1350
1308
  {
1351
1309
  color: "text50",
1352
1310
  fontSize: "small",
@@ -1356,12 +1314,12 @@ var TransactionPreview = observer6(
1356
1314
  children: title
1357
1315
  }
1358
1316
  ),
1359
- /* @__PURE__ */ jsx17(NetworkImage, { chainId: Number(chainId), size: "xs" }),
1360
- isConfirming && /* @__PURE__ */ jsx17(TimeAgo, { date: /* @__PURE__ */ new Date() })
1317
+ /* @__PURE__ */ jsx16(NetworkImage, { chainId: Number(chainId), size: "xs" }),
1318
+ isConfirming && /* @__PURE__ */ jsx16(TimeAgo, { date: /* @__PURE__ */ new Date() })
1361
1319
  ] }),
1362
- /* @__PURE__ */ jsxs10(Box13, { display: "flex", alignItems: "center", marginTop: "2", children: [
1363
- /* @__PURE__ */ jsx17(
1364
- Image3,
1320
+ /* @__PURE__ */ jsxs9(Box12, { display: "flex", alignItems: "center", marginTop: "2", children: [
1321
+ /* @__PURE__ */ jsx16(
1322
+ Image2,
1365
1323
  {
1366
1324
  src: collectibleImage2 || chess_tile_default,
1367
1325
  alt: collectibleName,
@@ -1372,16 +1330,16 @@ var TransactionPreview = observer6(
1372
1330
  style: { objectFit: "cover" }
1373
1331
  }
1374
1332
  ),
1375
- /* @__PURE__ */ jsxs10(
1376
- Box13,
1333
+ /* @__PURE__ */ jsxs9(
1334
+ Box12,
1377
1335
  {
1378
1336
  display: "flex",
1379
1337
  flexDirection: "column",
1380
1338
  alignItems: "flex-start",
1381
1339
  gap: "0.5",
1382
1340
  children: [
1383
- /* @__PURE__ */ jsx17(
1384
- Text10,
1341
+ /* @__PURE__ */ jsx16(
1342
+ Text9,
1385
1343
  {
1386
1344
  color: "text80",
1387
1345
  fontSize: "small",
@@ -1390,12 +1348,12 @@ var TransactionPreview = observer6(
1390
1348
  children: collectibleName
1391
1349
  }
1392
1350
  ),
1393
- /* @__PURE__ */ jsx17(Text10, { color: "text100", fontSize: "small", fontFamily: "body", children: collectionName })
1351
+ /* @__PURE__ */ jsx16(Text9, { color: "text100", fontSize: "small", fontFamily: "body", children: collectionName })
1394
1352
  ]
1395
1353
  }
1396
1354
  ),
1397
- price && /* @__PURE__ */ jsxs10(
1398
- Box13,
1355
+ price && /* @__PURE__ */ jsxs9(
1356
+ Box12,
1399
1357
  {
1400
1358
  flexGrow: "1",
1401
1359
  display: "flex",
@@ -1403,9 +1361,9 @@ var TransactionPreview = observer6(
1403
1361
  justifyContent: "flex-end",
1404
1362
  gap: "1",
1405
1363
  children: [
1406
- /* @__PURE__ */ jsx17(Image3, { src: currencyImageUrl, width: "3", height: "3" }),
1407
- /* @__PURE__ */ jsxs10(
1408
- Text10,
1364
+ /* @__PURE__ */ jsx16(Image2, { src: currencyImageUrl, width: "3", height: "3" }),
1365
+ /* @__PURE__ */ jsxs9(
1366
+ Text9,
1409
1367
  {
1410
1368
  color: "text80",
1411
1369
  fontSize: "small",
@@ -1429,8 +1387,8 @@ var transactionPreview_default = TransactionPreview;
1429
1387
 
1430
1388
  // src/react/ui/modals/_internal/components/transactionStatusModal/styles.css.ts
1431
1389
  var closeButton3 = "fyvr11lw fyvr1tc fyvr1mo";
1432
- var dialogOverlay3 = "fyvr1m0 fyvr1o8 fyvr1qg fyvr1so fyvr11xl fyvr11m0 fyvr11rs";
1433
- var transactionStatusModalContent = "modal_dialogContent_wide__1ypl6nt3 modal_dialogContentBase__1ypl6nt1 fyvr11hg fyvr11i4 fyvr11g4 fyvr11gs fyvr11l8 fyvr11wl fyvr11m0 fyvr11rs fyvr1vo fyvr1xs fyvr1zw fyvr1120 fyvr11lc fyvr11mc fyvr11cw";
1390
+ var dialogOverlay3 = "fyvr1m0 fyvr1o8 fyvr1qg fyvr1so fyvr11vl fyvr11m0 fyvr11rs";
1391
+ var transactionStatusModalContent = "modal_dialogContent_wide__1ypl6nt3 modal_dialogContentBase__1ypl6nt1 fyvr11hg fyvr11i4 fyvr11g4 fyvr11gs fyvr11l8 fyvr11ul fyvr11m0 fyvr11rs fyvr1vo fyvr1xs fyvr1zw fyvr1120 fyvr11lc fyvr11mc fyvr11cw";
1434
1392
 
1435
1393
  // src/react/ui/modals/_internal/components/transactionStatusModal/util/getFormattedType.ts
1436
1394
  function getFormattedType(transactionType, verb = false) {
@@ -1504,7 +1462,7 @@ function getTransactionStatusModalTitle({
1504
1462
  }
1505
1463
 
1506
1464
  // src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
1507
- import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
1465
+ import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
1508
1466
  var useTransactionStatusModal = () => {
1509
1467
  return {
1510
1468
  show: (args) => {
@@ -1532,11 +1490,11 @@ var TransactionStatusModal = observer7(() => {
1532
1490
  chainId,
1533
1491
  collectibleId
1534
1492
  });
1535
- const [transactionStatus, setTransactionStatus] = useState6(
1493
+ const [transactionStatus, setTransactionStatus] = useState7(
1536
1494
  orderId ? "SUCCESS" : "PENDING"
1537
1495
  );
1538
1496
  useEffect5(() => {
1539
- if (!transactionStatusModal$.isOpen.get()) return;
1497
+ if (!transactionStatusModal$.isOpen.get() || orderId) return;
1540
1498
  console.log("Waiting for transaction receipt ...");
1541
1499
  waitForTransactionReceiptPromise?.then((receipt) => {
1542
1500
  if (receipt.status === "success") {
@@ -1591,11 +1549,11 @@ var TransactionStatusModal = observer7(() => {
1591
1549
  confirmations: confirmations || TRANSACTION_CONFIRMATIONS_DEFAULT,
1592
1550
  hash: hash || "0x"
1593
1551
  });
1594
- return /* @__PURE__ */ jsx18(Root2, { open: transactionStatusModal$.isOpen.get(), children: /* @__PURE__ */ jsxs11(Portal2, { children: [
1595
- /* @__PURE__ */ jsx18(Overlay, { className: dialogOverlay3 }),
1596
- /* @__PURE__ */ jsxs11(Content2, { className: transactionStatusModalContent, children: [
1597
- title ? /* @__PURE__ */ jsx18(
1598
- Text11,
1552
+ return /* @__PURE__ */ jsx17(Root2, { open: transactionStatusModal$.isOpen.get(), children: /* @__PURE__ */ jsxs10(Portal2, { children: [
1553
+ /* @__PURE__ */ jsx17(Overlay, { className: dialogOverlay3 }),
1554
+ /* @__PURE__ */ jsxs10(Content2, { className: transactionStatusModalContent, children: [
1555
+ title ? /* @__PURE__ */ jsx17(
1556
+ Text10,
1599
1557
  {
1600
1558
  fontSize: "large",
1601
1559
  fontWeight: "bold",
@@ -1603,9 +1561,9 @@ var TransactionStatusModal = observer7(() => {
1603
1561
  fontFamily: "body",
1604
1562
  children: title
1605
1563
  }
1606
- ) : /* @__PURE__ */ jsx18(Skeleton6, { width: "16", height: "6" }),
1607
- message ? /* @__PURE__ */ jsx18(Text11, { fontSize: "small", color: "text80", fontFamily: "body", children: message }) : /* @__PURE__ */ jsx18(Skeleton6, { width: "20", height: "4" }),
1608
- /* @__PURE__ */ jsx18(
1564
+ ) : /* @__PURE__ */ jsx17(Skeleton5, { width: "16", height: "6" }),
1565
+ message ? /* @__PURE__ */ jsx17(Text10, { fontSize: "small", color: "text80", fontFamily: "body", children: message }) : /* @__PURE__ */ jsx17(Skeleton5, { width: "20", height: "4" }),
1566
+ /* @__PURE__ */ jsx17(
1609
1567
  transactionPreview_default,
1610
1568
  {
1611
1569
  orderId,
@@ -1621,7 +1579,7 @@ var TransactionStatusModal = observer7(() => {
1621
1579
  isTimeout: transactionStatus === "TIMEOUT"
1622
1580
  }
1623
1581
  ),
1624
- /* @__PURE__ */ jsx18(
1582
+ /* @__PURE__ */ jsx17(
1625
1583
  TransactionFooter,
1626
1584
  {
1627
1585
  transactionHash: hash,
@@ -1633,7 +1591,7 @@ var TransactionStatusModal = observer7(() => {
1633
1591
  chainId
1634
1592
  }
1635
1593
  ),
1636
- /* @__PURE__ */ jsx18(
1594
+ /* @__PURE__ */ jsx17(
1637
1595
  Close,
1638
1596
  {
1639
1597
  onClick: () => {
@@ -1641,7 +1599,7 @@ var TransactionStatusModal = observer7(() => {
1641
1599
  },
1642
1600
  className: closeButton3,
1643
1601
  asChild: true,
1644
- children: /* @__PURE__ */ jsx18(IconButton2, { size: "xs", "aria-label": "Close modal", icon: CloseIcon })
1602
+ children: /* @__PURE__ */ jsx17(IconButton2, { size: "xs", "aria-label": "Close modal", icon: CloseIcon })
1645
1603
  }
1646
1604
  )
1647
1605
  ] })
@@ -1649,7 +1607,7 @@ var TransactionStatusModal = observer7(() => {
1649
1607
  });
1650
1608
  var transactionStatusModal_default = TransactionStatusModal;
1651
1609
 
1652
- // src/react/ui/modals/CreateListingModal/_store.ts
1610
+ // src/react/ui/modals/MakeOfferModal/store.ts
1653
1611
  import { observable as observable4 } from "@legendapp/state";
1654
1612
  import { addDays as addDays2 } from "date-fns/addDays";
1655
1613
  var initialState3 = {
@@ -1657,66 +1615,60 @@ var initialState3 = {
1657
1615
  collectionAddress: "",
1658
1616
  chainId: "",
1659
1617
  collectibleId: "",
1660
- orderbookKind: "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
1661
- collectionName: "",
1662
- collectionType: void 0,
1663
- listingPrice: {
1664
- // to see if approval is needed when modal opens
1618
+ orderbookKind: "reservoir" /* reservoir */,
1619
+ callbacks: void 0,
1620
+ offerPrice: {
1665
1621
  amountRaw: "1",
1666
1622
  currency: {}
1667
1623
  },
1668
- // to track if the user has changed the price, so we know if it's 1 default or user input
1669
- listingPriceChanged: false,
1624
+ offerPriceChanged: false,
1670
1625
  quantity: "1",
1671
1626
  invalidQuantity: false,
1672
1627
  expiry: new Date(addDays2(/* @__PURE__ */ new Date(), 7).toJSON()),
1673
- callbacks: void 0,
1674
- onError: void 0,
1675
- onSuccess: void 0,
1628
+ collectionType: void 0
1629
+ };
1630
+ var actions = {
1676
1631
  open: (args) => {
1677
- createListingModal$.collectionAddress.set(args.collectionAddress);
1678
- createListingModal$.chainId.set(args.chainId);
1679
- createListingModal$.collectibleId.set(args.collectibleId);
1680
- createListingModal$.orderbookKind.set(args.orderbookKind);
1681
- createListingModal$.callbacks.set(args.callbacks || args.defaultCallbacks);
1682
- createListingModal$.onSuccess.set(args.onSuccess);
1683
- createListingModal$.onError.set(args.onError);
1684
- createListingModal$.isOpen.set(true);
1632
+ makeOfferModal$.collectionAddress.set(args.collectionAddress);
1633
+ makeOfferModal$.chainId.set(args.chainId);
1634
+ makeOfferModal$.collectibleId.set(args.collectibleId);
1635
+ makeOfferModal$.orderbookKind.set(args.orderbookKind);
1636
+ makeOfferModal$.callbacks.set(args.callbacks);
1637
+ makeOfferModal$.isOpen.set(true);
1685
1638
  },
1686
1639
  close: () => {
1687
- createListingModal$.isOpen.set(false);
1688
- createListingModal$.callbacks.set(void 0);
1640
+ makeOfferModal$.isOpen.set(false);
1641
+ makeOfferModal$.set({ ...initialState3, ...actions });
1689
1642
  }
1690
1643
  };
1691
- var createListingModal$ = observable4(initialState3);
1644
+ var makeOfferModal$ = observable4({
1645
+ ...initialState3,
1646
+ ...actions
1647
+ });
1692
1648
 
1693
- // src/react/ui/modals/CreateListingModal/index.tsx
1694
- import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
1695
- var useCreateListingModal = (callbacks) => {
1696
- return {
1697
- show: (args) => createListingModal$.open({ ...args, defaultCallbacks: callbacks }),
1698
- close: () => createListingModal$.close()
1699
- };
1700
- };
1701
- var CreateListingModal = () => {
1649
+ // src/react/ui/modals/MakeOfferModal/Modal.tsx
1650
+ import { Fragment, jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
1651
+ var MakeOfferModal = () => {
1702
1652
  const { show: showTransactionStatusModal } = useTransactionStatusModal();
1703
- return /* @__PURE__ */ jsx19(Show2, { if: createListingModal$.isOpen, children: /* @__PURE__ */ jsx19(Modal2, { showTransactionStatusModal }) });
1653
+ return /* @__PURE__ */ jsx18(Show2, { if: makeOfferModal$.isOpen, children: () => /* @__PURE__ */ jsx18(Modal2, { showTransactionStatusModal }) });
1704
1654
  };
1705
1655
  var Modal2 = observer8(
1706
1656
  ({
1707
1657
  showTransactionStatusModal
1708
1658
  }) => {
1709
- const state = createListingModal$.get();
1659
+ const state = makeOfferModal$.get();
1710
1660
  const {
1711
1661
  collectionAddress,
1712
1662
  chainId,
1713
- listingPrice,
1714
- listingPriceChanged,
1663
+ offerPrice,
1664
+ offerPriceChanged,
1665
+ invalidQuantity,
1715
1666
  collectibleId,
1716
1667
  orderbookKind,
1717
1668
  callbacks
1718
1669
  } = state;
1719
- const currencyAddress = listingPrice.currency.contractAddress;
1670
+ const [insufficientBalance, setInsufficientBalance] = useState8(false);
1671
+ const [approvalExecutedSuccess, setApprovalExecutedSuccess] = useState8(false);
1720
1672
  const {
1721
1673
  data: collectible,
1722
1674
  isLoading: collectableIsLoading,
@@ -1734,91 +1686,87 @@ var Modal2 = observer8(
1734
1686
  chainId,
1735
1687
  collectionAddress
1736
1688
  });
1737
- const [approvalExecutedSuccess, setApprovalExecutedSuccess] = useState7(false);
1738
- const { address } = useAccount3();
1739
- const { data: balance } = useBalanceOfCollectible({
1689
+ const currencyOptions = useCurrencyOptions({ collectionAddress });
1690
+ const { isLoading: currenciesIsLoading } = useCurrencies({
1740
1691
  chainId,
1741
- collectionAddress,
1742
- collectableId: collectibleId,
1743
- userAddress: address ?? void 0
1692
+ currencyOptions
1744
1693
  });
1745
- const { getListingSteps, isLoading: machineLoading, createListing } = useCreateListing({
1746
- orderbookKind,
1694
+ const { getMakeOfferSteps, isLoading: machineLoading } = useMakeOffer({
1747
1695
  chainId,
1748
1696
  collectionAddress,
1749
- enabled: createListingModal$.isOpen.get(),
1750
- onSwitchChainRefused: () => createListingModal$.close(),
1697
+ orderbookKind,
1698
+ enabled: makeOfferModal$.isOpen.get(),
1751
1699
  onApprovalSuccess: () => setApprovalExecutedSuccess(true),
1752
1700
  onTransactionSent: (hash, orderId) => {
1753
1701
  if (!hash && !orderId) return;
1754
1702
  showTransactionStatusModal({
1755
1703
  hash,
1756
1704
  orderId,
1705
+ price: makeOfferModal$.offerPrice.get(),
1757
1706
  collectionAddress,
1758
1707
  chainId,
1759
- price: createListingModal$.listingPrice.get(),
1760
1708
  collectibleId,
1761
- type: "LISTING" /* LISTING */,
1709
+ type: "OFFER" /* OFFER */,
1762
1710
  queriesToInvalidate: collectableKeys.all,
1763
1711
  callbacks
1764
1712
  });
1765
- createListingModal$.close();
1713
+ makeOfferModal$.close();
1714
+ }
1715
+ });
1716
+ const currencyAddress = offerPrice.currency.contractAddress;
1717
+ const { isLoading, steps, refreshSteps } = getMakeOfferSteps({
1718
+ contractType: collection?.type,
1719
+ offer: {
1720
+ tokenId: collectibleId,
1721
+ quantity: parseUnits3(
1722
+ makeOfferModal$.quantity.get(),
1723
+ collectible?.decimals || 0
1724
+ ).toString(),
1725
+ expiry: dateToUnixTime(makeOfferModal$.expiry.get()),
1726
+ currencyAddress,
1727
+ pricePerToken: offerPrice.amountRaw
1766
1728
  }
1767
1729
  });
1730
+ const approvalNeeded = steps?.approval.isPending;
1768
1731
  useEffect6(() => {
1769
1732
  if (!currencyAddress) return;
1770
1733
  refreshSteps();
1771
- }, [currencyAddress]);
1772
- const handleStepExecution = async (execute) => {
1773
- if (!execute) return;
1774
- try {
1775
- await refreshSteps();
1776
- await execute();
1777
- } catch (error) {
1778
- if (callbacks?.onError) {
1779
- callbacks.onError(error);
1780
- } else {
1781
- console.debug("onError callback not provided:", error);
1782
- }
1783
- }
1784
- };
1785
- if (collectableIsLoading || collectionIsLoading || machineLoading) {
1786
- return /* @__PURE__ */ jsx19(
1734
+ }, [currencyAddress, machineLoading]);
1735
+ if (collectableIsLoading || collectionIsLoading || currenciesIsLoading || machineLoading) {
1736
+ return /* @__PURE__ */ jsx18(
1787
1737
  LoadingModal,
1788
1738
  {
1789
- isOpen: createListingModal$.isOpen.get(),
1739
+ isOpen: makeOfferModal$.isOpen.get(),
1790
1740
  chainId: Number(chainId),
1791
- onClose: createListingModal$.close,
1792
- title: "List item for sale"
1741
+ onClose: makeOfferModal$.close,
1742
+ title: "Make an offer"
1793
1743
  }
1794
1744
  );
1795
1745
  }
1796
1746
  if (collectableIsError || collectionIsError) {
1797
- return /* @__PURE__ */ jsx19(
1747
+ return /* @__PURE__ */ jsx18(
1798
1748
  ErrorModal,
1799
1749
  {
1800
- isOpen: createListingModal$.isOpen.get(),
1750
+ isOpen: makeOfferModal$.isOpen.get(),
1801
1751
  chainId: Number(chainId),
1802
- onClose: createListingModal$.close,
1803
- title: "List item for sale"
1752
+ onClose: makeOfferModal$.close,
1753
+ title: "Make an offer"
1804
1754
  }
1805
1755
  );
1806
1756
  }
1807
- const dateToUnixTime = (date) => Math.floor(date.getTime() / 1e3).toString();
1808
- const { isLoading, steps, refreshSteps } = getListingSteps({
1809
- contractType: collection?.type,
1810
- listing: {
1811
- tokenId: collectibleId,
1812
- quantity: parseUnits3(
1813
- createListingModal$.quantity.get(),
1814
- collectible?.decimals || 0
1815
- ).toString(),
1816
- expiry: dateToUnixTime(createListingModal$.expiry.get()),
1817
- currencyAddress: listingPrice.currency.contractAddress,
1818
- pricePerToken: listingPrice.amountRaw
1757
+ const handleStepExecution = async (execute) => {
1758
+ if (!execute) return;
1759
+ try {
1760
+ await refreshSteps();
1761
+ await execute();
1762
+ } catch (error) {
1763
+ if (callbacks?.onError) {
1764
+ callbacks.onError(error);
1765
+ } else {
1766
+ console.debug("onError callback not provided:", error);
1767
+ }
1819
1768
  }
1820
- });
1821
- const approvalNeeded = steps?.approval.isPending;
1769
+ };
1822
1770
  const ctas = [
1823
1771
  {
1824
1772
  label: "Approve TOKEN",
@@ -1826,37 +1774,25 @@ var Modal2 = observer8(
1826
1774
  hidden: !approvalNeeded || approvalExecutedSuccess,
1827
1775
  pending: steps?.approval.isExecuting || isLoading,
1828
1776
  variant: "glass",
1829
- disabled: createListingModal$.invalidQuantity.get() || isLoading || !listingPriceChanged || listingPrice.amountRaw === "0" || steps?.transaction.isExecuting
1777
+ disabled: invalidQuantity || isLoading || steps?.transaction.isExecuting || insufficientBalance || offerPrice.amountRaw === "0" || !offerPriceChanged
1830
1778
  },
1831
1779
  {
1832
- label: "List item for sale",
1833
- onClick: () => createListing({
1834
- contractType: collection?.type,
1835
- listing: {
1836
- tokenId: collectibleId,
1837
- quantity: parseUnits3(
1838
- createListingModal$.quantity.get(),
1839
- collectible?.decimals || 0
1840
- ).toString(),
1841
- expiry: dateToUnixTime(createListingModal$.expiry.get()),
1842
- currencyAddress: listingPrice.currency.contractAddress,
1843
- pricePerToken: listingPrice.amountRaw
1844
- }
1845
- }),
1780
+ label: "Make offer",
1781
+ onClick: () => handleStepExecution(() => steps?.transaction.execute()),
1846
1782
  pending: steps?.transaction.isExecuting || isLoading,
1847
- disabled: !approvalExecutedSuccess && approvalNeeded || listingPrice.amountRaw === "0" || isLoading || createListingModal$.invalidQuantity.get() || !listingPriceChanged
1783
+ disabled: !approvalExecutedSuccess && approvalNeeded || offerPrice.amountRaw === "0" || insufficientBalance || isLoading || invalidQuantity || offerPrice.amountRaw === "0"
1848
1784
  }
1849
1785
  ];
1850
- return /* @__PURE__ */ jsxs12(
1786
+ return /* @__PURE__ */ jsx18(Fragment, { children: /* @__PURE__ */ jsxs11(
1851
1787
  ActionModal,
1852
1788
  {
1853
- isOpen: createListingModal$.isOpen.get(),
1789
+ isOpen: makeOfferModal$.isOpen.get(),
1854
1790
  chainId: Number(chainId),
1855
- onClose: () => createListingModal$.close(),
1856
- title: "List item for sale",
1791
+ onClose: () => makeOfferModal$.close(),
1792
+ title: "Make an offer",
1857
1793
  ctas,
1858
1794
  children: [
1859
- /* @__PURE__ */ jsx19(
1795
+ /* @__PURE__ */ jsx18(
1860
1796
  TokenPreview,
1861
1797
  {
1862
1798
  collectionName: collection?.name,
@@ -1865,75 +1801,65 @@ var Modal2 = observer8(
1865
1801
  chainId
1866
1802
  }
1867
1803
  ),
1868
- /* @__PURE__ */ jsxs12(Box14, { display: "flex", flexDirection: "column", width: "full", gap: "1", children: [
1869
- /* @__PURE__ */ jsx19(
1870
- priceInput_default,
1871
- {
1872
- chainId,
1873
- collectionAddress,
1874
- $listingPrice: createListingModal$.listingPrice,
1875
- onPriceChange: () => createListingModal$.listingPriceChanged.set(true)
1876
- }
1877
- ),
1878
- listingPrice.amountRaw !== "0" && listingPriceChanged && /* @__PURE__ */ jsx19(
1879
- FloorPriceText,
1880
- {
1881
- tokenId: collectibleId,
1882
- chainId,
1883
- collectionAddress,
1884
- price: listingPrice
1804
+ /* @__PURE__ */ jsx18(
1805
+ priceInput_default,
1806
+ {
1807
+ chainId,
1808
+ collectionAddress,
1809
+ $listingPrice: makeOfferModal$.offerPrice,
1810
+ onPriceChange: () => makeOfferModal$.offerPriceChanged.set(true),
1811
+ checkBalance: {
1812
+ enabled: true,
1813
+ callback: (state2) => setInsufficientBalance(state2)
1885
1814
  }
1886
- )
1887
- ] }),
1888
- collection?.type === "ERC1155" && balance && /* @__PURE__ */ jsx19(
1815
+ }
1816
+ ),
1817
+ collection?.type === "ERC1155" /* ERC1155 */ && /* @__PURE__ */ jsx18(
1889
1818
  QuantityInput,
1890
1819
  {
1891
- $quantity: createListingModal$.quantity,
1892
- $invalidQuantity: createListingModal$.invalidQuantity,
1820
+ $quantity: makeOfferModal$.quantity,
1821
+ $invalidQuantity: makeOfferModal$.invalidQuantity,
1893
1822
  decimals: collectible?.decimals || 0,
1894
- maxQuantity: balance?.balance
1823
+ maxQuantity: String(Number.MAX_SAFE_INTEGER)
1895
1824
  }
1896
1825
  ),
1897
- /* @__PURE__ */ jsx19(expirationDateSelect_default, { $date: createListingModal$.expiry }),
1898
- /* @__PURE__ */ jsx19(
1899
- TransactionDetails,
1826
+ offerPrice.amountRaw !== "0" && offerPriceChanged && !insufficientBalance && /* @__PURE__ */ jsx18(
1827
+ FloorPriceText,
1900
1828
  {
1901
- collectibleId,
1902
- collectionAddress,
1829
+ tokenId: collectibleId,
1903
1830
  chainId,
1904
- price: createListingModal$.listingPrice.get(),
1905
- showPlaceholderPrice: !listingPriceChanged,
1906
- currencyImageUrl: listingPrice.currency.imageUrl
1831
+ collectionAddress,
1832
+ price: offerPrice
1907
1833
  }
1908
- )
1834
+ ),
1835
+ /* @__PURE__ */ jsx18(expirationDateSelect_default, { $date: makeOfferModal$.expiry })
1909
1836
  ]
1910
1837
  }
1911
- );
1838
+ ) });
1912
1839
  }
1913
1840
  );
1914
1841
 
1915
- // src/react/ui/modals/MakeOfferModal/index.tsx
1842
+ // src/react/ui/modals/SellModal/Modal.tsx
1916
1843
  import { Show as Show3, observer as observer9 } from "@legendapp/state/react";
1917
- import { useEffect as useEffect7, useState as useState9 } from "react";
1844
+ import { useEffect as useEffect7, useState as useState10 } from "react";
1918
1845
  import { parseUnits as parseUnits4 } from "viem";
1919
1846
 
1920
- // src/react/hooks/useMakeOffer.tsx
1921
- import { useCallback as useCallback2, useState as useState8 } from "react";
1922
- var useMakeOffer = ({
1847
+ // src/react/hooks/useSell.tsx
1848
+ import { useCallback as useCallback3, useState as useState9 } from "react";
1849
+ var useSell = ({
1923
1850
  onSuccess,
1924
1851
  onError,
1925
1852
  onTransactionSent,
1926
1853
  onApprovalSuccess,
1927
- onSwitchChainRefused,
1928
1854
  enabled,
1929
1855
  ...config
1930
1856
  }) => {
1931
- const [isLoading, setIsLoading] = useState8(false);
1932
- const [steps, setSteps] = useState8(null);
1933
- const [executionState, setExecutionState] = useState8(null);
1857
+ const [isLoading, setIsLoading] = useState9(false);
1858
+ const [steps, setSteps] = useState9(null);
1859
+ const [executionState, setExecutionState] = useState9(null);
1934
1860
  const machineConfig = {
1935
1861
  ...config,
1936
- type: "OFFER" /* OFFER */
1862
+ type: "SELL" /* SELL */
1937
1863
  };
1938
1864
  const { machine, isLoading: isMachineLoading } = useTransactionMachine({
1939
1865
  config: machineConfig,
@@ -1950,10 +1876,9 @@ var useMakeOffer = ({
1950
1876
  onApprovalSuccess: (hash) => {
1951
1877
  setExecutionState(null);
1952
1878
  onApprovalSuccess?.(hash);
1953
- },
1954
- onSwitchChainRefused
1879
+ }
1955
1880
  });
1956
- const loadSteps = useCallback2(
1881
+ const loadSteps = useCallback3(
1957
1882
  async (props) => {
1958
1883
  if (!machine) return;
1959
1884
  setIsLoading(true);
@@ -1970,14 +1895,14 @@ var useMakeOffer = ({
1970
1895
  },
1971
1896
  transaction: {
1972
1897
  ...generatedSteps.transaction,
1973
- isExecuting: executionState === "offer"
1898
+ isExecuting: executionState === "sell"
1974
1899
  }
1975
1900
  });
1976
1901
  setIsLoading(false);
1977
1902
  },
1978
1903
  [machine, executionState]
1979
1904
  );
1980
- const handleStepExecution = useCallback2(
1905
+ const handleStepExecution = useCallback3(
1981
1906
  async (type, execute) => {
1982
1907
  if (!type) return;
1983
1908
  setExecutionState(type);
@@ -1991,8 +1916,8 @@ var useMakeOffer = ({
1991
1916
  []
1992
1917
  );
1993
1918
  return {
1994
- makeOffer: (props) => machine?.start(props),
1995
- getMakeOfferSteps: (props) => ({
1919
+ sell: (props) => machine?.start(props),
1920
+ getSellSteps: (props) => ({
1996
1921
  isLoading,
1997
1922
  steps: steps ? {
1998
1923
  ...steps,
@@ -2003,8 +1928,8 @@ var useMakeOffer = ({
2003
1928
  },
2004
1929
  transaction: {
2005
1930
  ...steps.transaction,
2006
- isExecuting: executionState === "offer",
2007
- execute: () => handleStepExecution("offer", () => steps.transaction.execute())
1931
+ isExecuting: executionState === "sell",
1932
+ execute: () => handleStepExecution("sell", () => steps.transaction.execute())
2008
1933
  }
2009
1934
  } : null,
2010
1935
  refreshSteps: () => loadSteps(props)
@@ -2013,154 +1938,201 @@ var useMakeOffer = ({
2013
1938
  };
2014
1939
  };
2015
1940
 
2016
- // src/react/ui/modals/MakeOfferModal/_store.ts
1941
+ // src/react/ui/modals/_internal/components/transactionDetails/index.tsx
1942
+ import { Box as Box13, Image as Image3, Skeleton as Skeleton6, Text as Text11 } from "@0xsequence/design-system";
1943
+ import { formatUnits as formatUnits3 } from "viem";
1944
+ import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
1945
+ var DEFAULT_MARKETPLACE_FEE_PERCENTAGE = 2.5;
1946
+ function TransactionDetails({
1947
+ collectibleId,
1948
+ collectionAddress,
1949
+ chainId,
1950
+ price,
1951
+ showPlaceholderPrice,
1952
+ currencyImageUrl
1953
+ }) {
1954
+ const { data, isLoading: marketplaceConfigLoading } = useMarketplaceConfig();
1955
+ const marketplaceFeePercentage = data?.collections.find(
1956
+ (collection) => collection.collectionAddress === collectionAddress
1957
+ )?.marketplaceFeePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
1958
+ const { data: royaltyPercentage, isLoading: royaltyPercentageLoading } = useRoyaltyPercentage({
1959
+ chainId,
1960
+ collectionAddress,
1961
+ collectibleId
1962
+ });
1963
+ const priceLoading = !price || marketplaceConfigLoading || royaltyPercentageLoading;
1964
+ let formattedAmount = price && formatUnits3(BigInt(price.amountRaw), price.currency.decimals);
1965
+ if (royaltyPercentage !== void 0 && formattedAmount && price) {
1966
+ formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royaltyPercentage) / 100).toFixed(price.currency.decimals);
1967
+ }
1968
+ if (marketplaceFeePercentage !== void 0 && formattedAmount && price) {
1969
+ formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * marketplaceFeePercentage / 100).toFixed(price.currency.decimals);
1970
+ }
1971
+ return /* @__PURE__ */ jsxs12(
1972
+ Box13,
1973
+ {
1974
+ width: "full",
1975
+ display: "flex",
1976
+ justifyContent: "space-between",
1977
+ alignItems: "center",
1978
+ children: [
1979
+ /* @__PURE__ */ jsx19(Text11, { fontSize: "small", color: "text50", fontFamily: "body", children: "Total earnings" }),
1980
+ /* @__PURE__ */ jsxs12(Box13, { display: "flex", alignItems: "center", gap: "2", children: [
1981
+ /* @__PURE__ */ jsx19(Image3, { src: currencyImageUrl, width: "3", height: "3" }),
1982
+ priceLoading ? /* @__PURE__ */ jsx19(Skeleton6, { width: "16", height: "4" }) : /* @__PURE__ */ jsxs12(Text11, { fontSize: "small", color: "text100", fontFamily: "body", children: [
1983
+ showPlaceholderPrice ? "0" : formattedAmount,
1984
+ " ",
1985
+ price.currency.symbol
1986
+ ] })
1987
+ ] })
1988
+ ]
1989
+ }
1990
+ );
1991
+ }
1992
+
1993
+ // src/react/ui/modals/_internal/components/transactionHeader/index.tsx
1994
+ import { Box as Box14, Image as Image4, Skeleton as Skeleton7, Text as Text12 } from "@0xsequence/design-system";
1995
+ import { formatDistanceToNow as formatDistanceToNow2 } from "date-fns";
1996
+ import { jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
1997
+ function TransactionHeader({
1998
+ title,
1999
+ currencyImageUrl,
2000
+ date
2001
+ }) {
2002
+ return /* @__PURE__ */ jsxs13(Box14, { display: "flex", alignItems: "center", width: "full", children: [
2003
+ /* @__PURE__ */ jsx20(
2004
+ Text12,
2005
+ {
2006
+ fontSize: "small",
2007
+ fontWeight: "medium",
2008
+ color: "text80",
2009
+ marginRight: "1",
2010
+ fontFamily: "body",
2011
+ children: title
2012
+ }
2013
+ ),
2014
+ /* @__PURE__ */ jsx20(Image4, { src: currencyImageUrl, width: "3", height: "3", marginRight: "1" }),
2015
+ date && /* @__PURE__ */ jsxs13(
2016
+ Text12,
2017
+ {
2018
+ fontSize: "small",
2019
+ color: "text50",
2020
+ flexGrow: "1",
2021
+ textAlign: "right",
2022
+ fontFamily: "body",
2023
+ children: [
2024
+ formatDistanceToNow2(date),
2025
+ " ago"
2026
+ ]
2027
+ }
2028
+ ) || /* @__PURE__ */ jsx20(Skeleton7, { width: "8", height: "4" })
2029
+ ] });
2030
+ }
2031
+
2032
+ // src/react/ui/modals/SellModal/store.ts
2017
2033
  import { observable as observable5 } from "@legendapp/state";
2018
- import { addDays as addDays3 } from "date-fns/addDays";
2019
2034
  var initialState4 = {
2020
2035
  isOpen: false,
2021
2036
  collectionAddress: "",
2022
2037
  chainId: "",
2023
- collectibleId: "",
2024
- orderbookKind: "reservoir" /* reservoir */,
2038
+ tokenId: "",
2039
+ order: void 0,
2025
2040
  callbacks: void 0,
2026
- offerPrice: {
2027
- amountRaw: "1",
2028
- currency: {}
2029
- },
2030
- // to track if the user has changed the price, so we know if it's 1 default or user input
2031
- offerPriceChanged: false,
2032
- quantity: "1",
2033
- invalidQuantity: false,
2034
- expiry: new Date(addDays3(/* @__PURE__ */ new Date(), 7).toJSON()),
2035
2041
  open: (args) => {
2036
- makeOfferModal$.collectionAddress.set(args.collectionAddress);
2037
- makeOfferModal$.chainId.set(args.chainId);
2038
- makeOfferModal$.collectibleId.set(args.collectibleId);
2039
- makeOfferModal$.orderbookKind.set(args.orderbookKind);
2040
- makeOfferModal$.callbacks.set(args.callbacks);
2041
- makeOfferModal$.isOpen.set(true);
2042
+ sellModal$.collectionAddress.set(args.collectionAddress);
2043
+ sellModal$.chainId.set(args.chainId);
2044
+ sellModal$.tokenId.set(args.tokenId);
2045
+ sellModal$.order.set(args.order);
2046
+ sellModal$.callbacks.set(args.callbacks);
2047
+ sellModal$.isOpen.set(true);
2042
2048
  },
2043
2049
  close: () => {
2044
- makeOfferModal$.isOpen.set(false);
2045
- makeOfferModal$.callbacks.set(void 0);
2050
+ sellModal$.isOpen.set(false);
2051
+ sellModal$.callbacks.set(void 0);
2046
2052
  }
2047
2053
  };
2048
- var makeOfferModal$ = observable5(initialState4);
2054
+ var sellModal$ = observable5(initialState4);
2049
2055
 
2050
- // src/react/ui/modals/MakeOfferModal/index.tsx
2051
- import { Fragment, jsx as jsx20, jsxs as jsxs13 } from "react/jsx-runtime";
2052
- var useMakeOfferModal = (defaultCallbacks) => ({
2053
- show: (args) => makeOfferModal$.open({ ...args, callbacks: defaultCallbacks }),
2054
- close: makeOfferModal$.close
2055
- });
2056
- var MakeOfferModal = () => {
2056
+ // src/react/ui/modals/SellModal/Modal.tsx
2057
+ import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
2058
+ var SellModal = () => {
2057
2059
  const { show: showTransactionStatusModal } = useTransactionStatusModal();
2058
- return /* @__PURE__ */ jsx20(Show3, { if: makeOfferModal$.isOpen, children: /* @__PURE__ */ jsx20(ModalContent, { showTransactionStatusModal }) });
2060
+ return /* @__PURE__ */ jsx21(Show3, { if: sellModal$.isOpen, children: () => /* @__PURE__ */ jsx21(Modal3, { showTransactionStatusModal }) });
2059
2061
  };
2060
- var ModalContent = observer9(
2062
+ var Modal3 = observer9(
2061
2063
  ({
2062
2064
  showTransactionStatusModal
2063
2065
  }) => {
2064
- const state = makeOfferModal$.get();
2065
- const {
2066
- collectionAddress,
2067
- chainId,
2068
- offerPrice,
2069
- offerPriceChanged,
2070
- invalidQuantity,
2071
- collectibleId,
2072
- orderbookKind,
2073
- callbacks
2074
- } = state;
2075
- const [insufficientBalance, setInsufficientBalance] = useState9(false);
2076
- const [approvalExecutedSuccess, setApprovalExecutedSuccess] = useState9(false);
2077
- const {
2078
- data: collectible,
2079
- isLoading: collectableIsLoading,
2080
- isError: collectableIsError
2081
- } = useCollectible({
2066
+ const { tokenId, collectionAddress, chainId, order, callbacks } = sellModal$.get();
2067
+ const { data: collectible } = useCollection({
2082
2068
  chainId,
2083
- collectionAddress,
2084
- collectibleId
2069
+ collectionAddress
2085
2070
  });
2071
+ const [approvalExecutedSuccess, setApprovalExecutedSuccess] = useState10(false);
2086
2072
  const {
2087
2073
  data: collection,
2088
- isLoading: collectionIsLoading,
2089
- isError: collectionIsError
2074
+ isLoading: collectionLoading,
2075
+ isError: collectionError
2090
2076
  } = useCollection({
2091
2077
  chainId,
2092
2078
  collectionAddress
2093
2079
  });
2094
2080
  const currencyOptions = useCurrencyOptions({ collectionAddress });
2095
- const { isLoading: currenciesIsLoading } = useCurrencies({
2081
+ const { data: currencies, isLoading: currenciesLoading } = useCurrencies({
2096
2082
  chainId,
2097
2083
  currencyOptions
2098
2084
  });
2099
- const { getMakeOfferSteps } = useMakeOffer({
2100
- chainId,
2085
+ const { getSellSteps, isLoading: machineLoading } = useSell({
2101
2086
  collectionAddress,
2102
- orderbookKind,
2103
- enabled: makeOfferModal$.isOpen.get(),
2104
- onSwitchChainRefused: () => makeOfferModal$.close(),
2087
+ chainId,
2088
+ enabled: sellModal$.isOpen.get(),
2105
2089
  onApprovalSuccess: () => setApprovalExecutedSuccess(true),
2106
- onTransactionSent: (hash, orderId) => {
2107
- if (!hash && !orderId) return;
2090
+ onTransactionSent: (hash) => {
2091
+ if (!hash) return;
2108
2092
  showTransactionStatusModal({
2109
2093
  hash,
2110
- orderId,
2111
- price: makeOfferModal$.offerPrice.get(),
2094
+ price: order ? {
2095
+ amountRaw: order.priceAmount,
2096
+ currency: currencies?.find(
2097
+ (currency2) => currency2.contractAddress === order.priceCurrencyAddress
2098
+ ) ?? {
2099
+ chainId: Number(chainId),
2100
+ contractAddress: order.priceCurrencyAddress,
2101
+ name: "Unknown",
2102
+ symbol: "UNK",
2103
+ decimals: 18,
2104
+ imageUrl: "",
2105
+ exchangeRate: 0,
2106
+ defaultChainCurrency: false,
2107
+ nativeCurrency: false,
2108
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2109
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2110
+ }
2111
+ } : void 0,
2112
2112
  collectionAddress,
2113
2113
  chainId,
2114
- collectibleId,
2115
- type: "OFFER" /* OFFER */,
2116
- queriesToInvalidate: collectableKeys.all,
2114
+ collectibleId: tokenId,
2115
+ type: "SELL" /* SELL */,
2116
+ queriesToInvalidate: [
2117
+ ...collectableKeys.all,
2118
+ balanceQueries.all
2119
+ ],
2117
2120
  callbacks
2118
2121
  });
2119
- makeOfferModal$.close();
2122
+ sellModal$.close();
2120
2123
  }
2121
2124
  });
2122
- const dateToUnixTime = (date) => Math.floor(date.getTime() / 1e3).toString();
2123
- const currencyAddress = offerPrice.currency.contractAddress;
2124
- const { isLoading, steps, refreshSteps } = getMakeOfferSteps({
2125
- contractType: collection?.type,
2126
- offer: {
2127
- tokenId: collectibleId,
2128
- quantity: parseUnits4(
2129
- makeOfferModal$.quantity.get(),
2130
- collectible?.decimals || 0
2131
- ).toString(),
2132
- expiry: dateToUnixTime(makeOfferModal$.expiry.get()),
2133
- currencyAddress,
2134
- pricePerToken: offerPrice.amountRaw
2135
- }
2125
+ const { isLoading, steps, refreshSteps } = getSellSteps({
2126
+ orderId: order?.orderId ?? "",
2127
+ marketplace: order?.marketplace,
2128
+ quantity: order?.quantityRemaining ? parseUnits4(
2129
+ order.quantityRemaining,
2130
+ collectible?.decimals || 0
2131
+ ).toString() : "1"
2136
2132
  });
2137
- const approvalNeeded = steps?.approval.isPending;
2138
2133
  useEffect7(() => {
2139
- if (!currencyAddress) return;
2140
2134
  refreshSteps();
2141
- }, [currencyAddress]);
2142
- if (collectableIsLoading || collectionIsLoading || currenciesIsLoading) {
2143
- return /* @__PURE__ */ jsx20(
2144
- LoadingModal,
2145
- {
2146
- isOpen: makeOfferModal$.isOpen.get(),
2147
- chainId: Number(chainId),
2148
- onClose: makeOfferModal$.close,
2149
- title: "Make an offer"
2150
- }
2151
- );
2152
- }
2153
- if (collectableIsError || collectionIsError) {
2154
- return /* @__PURE__ */ jsx20(
2155
- ErrorModal,
2156
- {
2157
- isOpen: makeOfferModal$.isOpen.get(),
2158
- chainId: Number(chainId),
2159
- onClose: makeOfferModal$.close,
2160
- title: "Make an offer"
2161
- }
2162
- );
2163
- }
2135
+ }, [order, machineLoading]);
2164
2136
  const handleStepExecution = async (execute) => {
2165
2137
  if (!execute) return;
2166
2138
  try {
@@ -2174,6 +2146,32 @@ var ModalContent = observer9(
2174
2146
  }
2175
2147
  }
2176
2148
  };
2149
+ if (collectionLoading || currenciesLoading || machineLoading) {
2150
+ return /* @__PURE__ */ jsx21(
2151
+ LoadingModal,
2152
+ {
2153
+ isOpen: sellModal$.isOpen.get(),
2154
+ chainId: Number(chainId),
2155
+ onClose: sellModal$.close,
2156
+ title: "You have an offer"
2157
+ }
2158
+ );
2159
+ }
2160
+ if (collectionError || order === void 0) {
2161
+ return /* @__PURE__ */ jsx21(
2162
+ ErrorModal,
2163
+ {
2164
+ isOpen: sellModal$.isOpen.get(),
2165
+ chainId: Number(chainId),
2166
+ onClose: sellModal$.close,
2167
+ title: "You have an offer"
2168
+ }
2169
+ );
2170
+ }
2171
+ const approvalNeeded = steps?.approval.isPending;
2172
+ const currency = currencies?.find(
2173
+ (c) => c.contractAddress === order?.priceCurrencyAddress
2174
+ );
2177
2175
  const ctas = [
2178
2176
  {
2179
2177
  label: "Approve TOKEN",
@@ -2181,438 +2179,76 @@ var ModalContent = observer9(
2181
2179
  hidden: !approvalNeeded || approvalExecutedSuccess,
2182
2180
  pending: steps?.approval.isExecuting || isLoading,
2183
2181
  variant: "glass",
2184
- disabled: invalidQuantity || isLoading || steps?.transaction.isExecuting || insufficientBalance || offerPrice.amountRaw === "0" || !offerPriceChanged
2182
+ disabled: isLoading || steps?.transaction.isExecuting
2185
2183
  },
2186
2184
  {
2187
- label: "Make offer",
2185
+ label: "Accept",
2188
2186
  onClick: () => handleStepExecution(() => steps?.transaction.execute()),
2189
2187
  pending: steps?.transaction.isExecuting || isLoading,
2190
- disabled: !approvalExecutedSuccess && approvalNeeded || offerPrice.amountRaw === "0" || insufficientBalance || isLoading || invalidQuantity || offerPrice.amountRaw === "0"
2188
+ disabled: !approvalExecutedSuccess && approvalNeeded || isLoading
2191
2189
  }
2192
2190
  ];
2193
- return /* @__PURE__ */ jsx20(Fragment, { children: /* @__PURE__ */ jsxs13(
2191
+ return /* @__PURE__ */ jsxs14(
2194
2192
  ActionModal,
2195
2193
  {
2196
- isOpen: makeOfferModal$.isOpen.get(),
2194
+ isOpen: sellModal$.isOpen.get(),
2197
2195
  chainId: Number(chainId),
2198
- onClose: () => makeOfferModal$.close(),
2199
- title: "Make an offer",
2196
+ onClose: sellModal$.close,
2197
+ title: "You have an offer",
2200
2198
  ctas,
2201
2199
  children: [
2202
- /* @__PURE__ */ jsx20(
2200
+ /* @__PURE__ */ jsx21(
2201
+ TransactionHeader,
2202
+ {
2203
+ title: "Offer received",
2204
+ currencyImageUrl: currency?.imageUrl,
2205
+ date: order && new Date(order.createdAt)
2206
+ }
2207
+ ),
2208
+ /* @__PURE__ */ jsx21(
2203
2209
  TokenPreview,
2204
2210
  {
2205
2211
  collectionName: collection?.name,
2206
2212
  collectionAddress,
2207
- collectibleId,
2213
+ collectibleId: tokenId,
2208
2214
  chainId
2209
2215
  }
2210
2216
  ),
2211
- /* @__PURE__ */ jsx20(
2212
- priceInput_default,
2217
+ /* @__PURE__ */ jsx21(
2218
+ TransactionDetails,
2213
2219
  {
2214
- chainId,
2220
+ collectibleId: tokenId,
2215
2221
  collectionAddress,
2216
- $listingPrice: makeOfferModal$.offerPrice,
2217
- onPriceChange: () => makeOfferModal$.offerPriceChanged.set(true),
2218
- checkBalance: {
2219
- enabled: true,
2220
- callback: (state2) => setInsufficientBalance(state2)
2221
- }
2222
- }
2223
- ),
2224
- collection?.type === "ERC1155" /* ERC1155 */ && /* @__PURE__ */ jsx20(
2225
- QuantityInput,
2226
- {
2227
- $quantity: makeOfferModal$.quantity,
2228
- $invalidQuantity: makeOfferModal$.invalidQuantity,
2229
- decimals: collectible?.decimals || 0,
2230
- maxQuantity: String(Number.MAX_SAFE_INTEGER)
2231
- }
2232
- ),
2233
- offerPrice.amountRaw !== "0" && offerPriceChanged && !insufficientBalance && /* @__PURE__ */ jsx20(
2234
- FloorPriceText,
2235
- {
2236
- tokenId: collectibleId,
2237
2222
  chainId,
2238
- collectionAddress,
2239
- price: offerPrice
2223
+ price: currency ? {
2224
+ amountRaw: order?.priceAmount,
2225
+ currency
2226
+ } : void 0,
2227
+ currencyImageUrl: currency?.imageUrl
2240
2228
  }
2241
- ),
2242
- /* @__PURE__ */ jsx20(expirationDateSelect_default, { $date: makeOfferModal$.expiry })
2229
+ )
2243
2230
  ]
2244
2231
  }
2245
- ) });
2232
+ );
2246
2233
  }
2247
2234
  );
2248
2235
 
2249
- // src/react/ui/modals/SellModal/index.tsx
2250
- import { Show as Show4, observer as observer10 } from "@legendapp/state/react";
2251
- import { parseUnits as parseUnits5 } from "viem";
2252
-
2253
- // src/react/hooks/useSell.tsx
2254
- import { useCallback as useCallback3, useState as useState10 } from "react";
2255
- var useSell = ({
2256
- onSuccess,
2257
- onError,
2258
- onTransactionSent,
2259
- onApprovalSuccess,
2260
- onSwitchChainRefused,
2261
- enabled,
2262
- ...config
2263
- }) => {
2264
- const [isLoading, setIsLoading] = useState10(false);
2265
- const [steps, setSteps] = useState10(null);
2266
- const [executionState, setExecutionState] = useState10(null);
2267
- const machineConfig = {
2268
- ...config,
2269
- type: "SELL" /* SELL */
2270
- };
2271
- const { machine, isLoading: isMachineLoading } = useTransactionMachine({
2272
- config: machineConfig,
2273
- enabled,
2274
- onSwitchChainRefused,
2275
- onSuccess: (hash) => {
2276
- setExecutionState(null);
2277
- onSuccess?.(hash);
2278
- },
2279
- onError: (error) => {
2280
- setExecutionState(null);
2281
- onError?.(error);
2282
- },
2283
- onTransactionSent,
2284
- onApprovalSuccess: (hash) => {
2285
- setExecutionState(null);
2286
- onApprovalSuccess?.(hash);
2287
- }
2288
- });
2289
- const loadSteps = useCallback3(
2290
- async (props) => {
2291
- if (!machine) return;
2292
- setIsLoading(true);
2293
- const generatedSteps = await machine.getTransactionSteps(props);
2294
- if (!generatedSteps) {
2295
- setIsLoading(false);
2296
- return;
2297
- }
2298
- setSteps({
2299
- ...generatedSteps,
2300
- approval: {
2301
- ...generatedSteps.approval,
2302
- isExecuting: executionState === "approval"
2303
- },
2304
- transaction: {
2305
- ...generatedSteps.transaction,
2306
- isExecuting: executionState === "sell"
2307
- }
2308
- });
2309
- setIsLoading(false);
2310
- },
2311
- [machine, executionState]
2312
- );
2313
- const handleStepExecution = useCallback3(
2314
- async (type, execute) => {
2315
- if (!type) return;
2316
- setExecutionState(type);
2317
- try {
2318
- await execute();
2319
- } catch (error) {
2320
- setExecutionState(null);
2321
- throw error;
2322
- }
2323
- },
2324
- []
2325
- );
2326
- return {
2327
- sell: (props) => machine?.start(props),
2328
- getSellSteps: (props) => ({
2329
- isLoading,
2330
- steps: steps ? {
2331
- ...steps,
2332
- approval: {
2333
- ...steps.approval,
2334
- isExecuting: executionState === "approval",
2335
- execute: () => handleStepExecution("approval", () => steps.approval.execute())
2336
- },
2337
- transaction: {
2338
- ...steps.transaction,
2339
- isExecuting: executionState === "sell",
2340
- execute: () => handleStepExecution("sell", () => steps.transaction.execute())
2341
- }
2342
- } : null,
2343
- refreshSteps: () => loadSteps(props)
2344
- }),
2345
- isLoading: isMachineLoading
2346
- };
2347
- };
2348
-
2349
- // src/react/ui/modals/_internal/components/transactionHeader/index.tsx
2350
- import { Box as Box15, Image as Image4, Skeleton as Skeleton7, Text as Text12 } from "@0xsequence/design-system";
2351
- import { formatDistanceToNow as formatDistanceToNow2 } from "date-fns";
2352
- import { jsx as jsx21, jsxs as jsxs14 } from "react/jsx-runtime";
2353
- function TransactionHeader({
2354
- title,
2355
- currencyImageUrl,
2356
- date
2357
- }) {
2358
- return /* @__PURE__ */ jsxs14(Box15, { display: "flex", alignItems: "center", width: "full", children: [
2359
- /* @__PURE__ */ jsx21(
2360
- Text12,
2361
- {
2362
- fontSize: "small",
2363
- fontWeight: "medium",
2364
- color: "text80",
2365
- marginRight: "1",
2366
- fontFamily: "body",
2367
- children: title
2368
- }
2369
- ),
2370
- /* @__PURE__ */ jsx21(Image4, { src: currencyImageUrl, width: "3", height: "3", marginRight: "1" }),
2371
- date && /* @__PURE__ */ jsxs14(
2372
- Text12,
2373
- {
2374
- fontSize: "small",
2375
- color: "text50",
2376
- flexGrow: "1",
2377
- textAlign: "right",
2378
- fontFamily: "body",
2379
- children: [
2380
- formatDistanceToNow2(date),
2381
- " ago"
2382
- ]
2383
- }
2384
- ) || /* @__PURE__ */ jsx21(Skeleton7, { width: "8", height: "4" })
2385
- ] });
2386
- }
2236
+ // src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
2237
+ import {
2238
+ Box as Box15,
2239
+ Button as Button3,
2240
+ CloseIcon as CloseIcon2,
2241
+ ExternalLinkIcon,
2242
+ IconButton as IconButton3,
2243
+ Image as Image5,
2244
+ Text as Text13
2245
+ } from "@0xsequence/design-system";
2246
+ import { observer as observer10 } from "@legendapp/state/react";
2247
+ import { Close as Close2, Content as Content3, Overlay as Overlay2, Portal as Portal3, Root as Root3 } from "@radix-ui/react-dialog";
2387
2248
 
2388
- // src/react/ui/modals/SellModal/_store.ts
2249
+ // src/react/ui/modals/SuccessfulPurchaseModal/_store.ts
2389
2250
  import { observable as observable6 } from "@legendapp/state";
2390
2251
  var initialState5 = {
2391
- isOpen: false,
2392
- collectionAddress: "",
2393
- chainId: "",
2394
- tokenId: "",
2395
- order: void 0,
2396
- callbacks: void 0,
2397
- open: (args) => {
2398
- sellModal$.collectionAddress.set(args.collectionAddress);
2399
- sellModal$.chainId.set(args.chainId);
2400
- sellModal$.tokenId.set(args.tokenId);
2401
- sellModal$.order.set(args.order);
2402
- sellModal$.callbacks.set(args.callbacks);
2403
- sellModal$.isOpen.set(true);
2404
- },
2405
- close: () => {
2406
- sellModal$.isOpen.set(false);
2407
- sellModal$.callbacks.set(void 0);
2408
- }
2409
- };
2410
- var sellModal$ = observable6(initialState5);
2411
-
2412
- // src/react/ui/modals/SellModal/index.tsx
2413
- import { useEffect as useEffect8, useState as useState11 } from "react";
2414
- import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
2415
- var useSellModal = (defaultCallbacks) => ({
2416
- show: (args) => sellModal$.open({ ...args, callbacks: defaultCallbacks }),
2417
- close: sellModal$.close
2418
- });
2419
- var SellModal = () => {
2420
- const { show: showTransactionStatusModal } = useTransactionStatusModal();
2421
- return /* @__PURE__ */ jsx22(Show4, { if: sellModal$.isOpen, children: /* @__PURE__ */ jsx22(ModalContent2, { showTransactionStatusModal }) });
2422
- };
2423
- var ModalContent2 = observer10(
2424
- ({
2425
- showTransactionStatusModal
2426
- }) => {
2427
- const { tokenId, collectionAddress, chainId, order, callbacks } = sellModal$.get();
2428
- const { data: collectible } = useCollection({
2429
- chainId,
2430
- collectionAddress
2431
- });
2432
- const [approvalExecutedSuccess, setApprovalExecutedSuccess] = useState11(false);
2433
- const {
2434
- data: collection,
2435
- isLoading: collectionLoading,
2436
- isError: collectionError
2437
- } = useCollection({
2438
- chainId,
2439
- collectionAddress
2440
- });
2441
- const currencyOptions = useCurrencyOptions({ collectionAddress });
2442
- const { data: currencies, isLoading: currenciesLoading } = useCurrencies({
2443
- chainId,
2444
- currencyOptions
2445
- });
2446
- const { getSellSteps, isLoading: machineLoading } = useSell({
2447
- collectionAddress,
2448
- chainId,
2449
- enabled: sellModal$.isOpen.get(),
2450
- onSwitchChainRefused: () => {
2451
- sellModal$.close();
2452
- },
2453
- onApprovalSuccess: () => setApprovalExecutedSuccess(true),
2454
- onTransactionSent: (hash) => {
2455
- if (!hash) return;
2456
- showTransactionStatusModal({
2457
- hash,
2458
- price: order ? {
2459
- amountRaw: order.priceAmount,
2460
- currency: currencies?.find(
2461
- (currency2) => currency2.contractAddress === order.priceCurrencyAddress
2462
- ) ?? {
2463
- chainId: Number(chainId),
2464
- contractAddress: order.priceCurrencyAddress,
2465
- name: "Unknown",
2466
- symbol: "UNK",
2467
- decimals: 18,
2468
- imageUrl: "",
2469
- exchangeRate: 0,
2470
- defaultChainCurrency: false,
2471
- nativeCurrency: false,
2472
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2473
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2474
- }
2475
- } : void 0,
2476
- collectionAddress,
2477
- chainId,
2478
- collectibleId: tokenId,
2479
- type: "SELL" /* SELL */,
2480
- queriesToInvalidate: [
2481
- ...collectableKeys.all,
2482
- balanceQueries.all
2483
- ],
2484
- callbacks
2485
- });
2486
- sellModal$.close();
2487
- }
2488
- });
2489
- const { isLoading, steps, refreshSteps } = getSellSteps({
2490
- orderId: order?.orderId ?? "",
2491
- marketplace: order?.marketplace,
2492
- quantity: order?.quantityRemaining ? parseUnits5(
2493
- order.quantityRemaining,
2494
- collectible?.decimals || 0
2495
- ).toString() : "1"
2496
- });
2497
- useEffect8(() => {
2498
- refreshSteps();
2499
- }, [order, machineLoading]);
2500
- const handleStepExecution = async (execute) => {
2501
- if (!execute) return;
2502
- try {
2503
- await refreshSteps();
2504
- await execute();
2505
- } catch (error) {
2506
- if (callbacks?.onError) {
2507
- callbacks.onError(error);
2508
- } else {
2509
- console.debug("onError callback not provided:", error);
2510
- }
2511
- }
2512
- };
2513
- if (collectionLoading || currenciesLoading || machineLoading) {
2514
- return /* @__PURE__ */ jsx22(
2515
- LoadingModal,
2516
- {
2517
- isOpen: sellModal$.isOpen.get(),
2518
- chainId: Number(chainId),
2519
- onClose: sellModal$.close,
2520
- title: "You have an offer"
2521
- }
2522
- );
2523
- }
2524
- if (collectionError || order === void 0) {
2525
- return /* @__PURE__ */ jsx22(
2526
- ErrorModal,
2527
- {
2528
- isOpen: sellModal$.isOpen.get(),
2529
- chainId: Number(chainId),
2530
- onClose: sellModal$.close,
2531
- title: "You have an offer"
2532
- }
2533
- );
2534
- }
2535
- const approvalNeeded = steps?.approval.isPending;
2536
- const currency = currencies?.find(
2537
- (c) => c.contractAddress === order?.priceCurrencyAddress
2538
- );
2539
- const ctas = [
2540
- {
2541
- label: "Approve TOKEN",
2542
- onClick: () => handleStepExecution(() => steps?.approval.execute()),
2543
- hidden: !approvalNeeded || approvalExecutedSuccess,
2544
- pending: steps?.approval.isExecuting || isLoading,
2545
- variant: "glass",
2546
- disabled: isLoading || steps?.transaction.isExecuting
2547
- },
2548
- {
2549
- label: "Accept",
2550
- onClick: () => handleStepExecution(() => steps?.transaction.execute()),
2551
- pending: steps?.transaction.isExecuting || isLoading,
2552
- disabled: !approvalExecutedSuccess && approvalNeeded || isLoading
2553
- }
2554
- ];
2555
- return /* @__PURE__ */ jsxs15(
2556
- ActionModal,
2557
- {
2558
- isOpen: sellModal$.isOpen.get(),
2559
- chainId: Number(chainId),
2560
- onClose: sellModal$.close,
2561
- title: "You have an offer",
2562
- ctas,
2563
- children: [
2564
- /* @__PURE__ */ jsx22(
2565
- TransactionHeader,
2566
- {
2567
- title: "Offer received",
2568
- currencyImageUrl: currency?.imageUrl,
2569
- date: order && new Date(order.createdAt)
2570
- }
2571
- ),
2572
- /* @__PURE__ */ jsx22(
2573
- TokenPreview,
2574
- {
2575
- collectionName: collection?.name,
2576
- collectionAddress,
2577
- collectibleId: tokenId,
2578
- chainId
2579
- }
2580
- ),
2581
- /* @__PURE__ */ jsx22(
2582
- TransactionDetails,
2583
- {
2584
- collectibleId: tokenId,
2585
- collectionAddress,
2586
- chainId,
2587
- price: currency ? {
2588
- amountRaw: order?.priceAmount,
2589
- currency
2590
- } : void 0,
2591
- currencyImageUrl: currency?.imageUrl
2592
- }
2593
- )
2594
- ]
2595
- }
2596
- );
2597
- }
2598
- );
2599
-
2600
- // src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
2601
- import {
2602
- Box as Box16,
2603
- Button as Button3,
2604
- CloseIcon as CloseIcon2,
2605
- ExternalLinkIcon,
2606
- IconButton as IconButton3,
2607
- Image as Image5,
2608
- Text as Text13
2609
- } from "@0xsequence/design-system";
2610
- import { observer as observer11 } from "@legendapp/state/react";
2611
- import { Close as Close2, Content as Content3, Overlay as Overlay2, Portal as Portal3, Root as Root3 } from "@radix-ui/react-dialog";
2612
-
2613
- // src/react/ui/modals/SuccessfulPurchaseModal/_store.ts
2614
- import { observable as observable7 } from "@legendapp/state";
2615
- var initialState6 = {
2616
2252
  isOpen: false,
2617
2253
  open: ({
2618
2254
  collectibles,
@@ -2638,7 +2274,7 @@ var initialState6 = {
2638
2274
  successfulPurchaseModal$.isOpen.set(false);
2639
2275
  successfulPurchaseModal$.callbacks.set(void 0);
2640
2276
  successfulPurchaseModal$.state.set({
2641
- ...initialState6.state
2277
+ ...initialState5.state
2642
2278
  });
2643
2279
  },
2644
2280
  state: {
@@ -2650,22 +2286,22 @@ var initialState6 = {
2650
2286
  },
2651
2287
  callbacks: void 0
2652
2288
  };
2653
- var successfulPurchaseModal$ = observable7(initialState6);
2289
+ var successfulPurchaseModal$ = observable6(initialState5);
2654
2290
 
2655
2291
  // src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
2656
- import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
2292
+ import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
2657
2293
  var useSuccessfulPurchaseModal = (callbacks) => {
2658
2294
  return {
2659
2295
  show: (args) => successfulPurchaseModal$.open({ ...args, defaultCallbacks: callbacks }),
2660
2296
  close: () => successfulPurchaseModal$.close()
2661
2297
  };
2662
2298
  };
2663
- var SuccessfulPurchaseModal = observer11(() => {
2664
- return /* @__PURE__ */ jsx23(Root3, { open: successfulPurchaseModal$.isOpen.get(), children: /* @__PURE__ */ jsxs16(Portal3, { children: [
2665
- /* @__PURE__ */ jsx23(Overlay2, { className: dialogOverlay }),
2666
- /* @__PURE__ */ jsxs16(Content3, { className: dialogContent.narrow, children: [
2667
- /* @__PURE__ */ jsxs16(Box16, { display: "flex", flexDirection: "column", gap: "4", width: "full", children: [
2668
- /* @__PURE__ */ jsx23(
2299
+ var SuccessfulPurchaseModal = observer10(() => {
2300
+ return /* @__PURE__ */ jsx22(Root3, { open: successfulPurchaseModal$.isOpen.get(), children: /* @__PURE__ */ jsxs15(Portal3, { children: [
2301
+ /* @__PURE__ */ jsx22(Overlay2, { className: dialogOverlay }),
2302
+ /* @__PURE__ */ jsxs15(Content3, { className: dialogContent.narrow, children: [
2303
+ /* @__PURE__ */ jsxs15(Box15, { display: "flex", flexDirection: "column", gap: "4", width: "full", children: [
2304
+ /* @__PURE__ */ jsx22(
2669
2305
  Text13,
2670
2306
  {
2671
2307
  textAlign: "center",
@@ -2675,21 +2311,21 @@ var SuccessfulPurchaseModal = observer11(() => {
2675
2311
  children: "Successful purchase!"
2676
2312
  }
2677
2313
  ),
2678
- /* @__PURE__ */ jsx23(
2314
+ /* @__PURE__ */ jsx22(
2679
2315
  CollectiblesGrid,
2680
2316
  {
2681
2317
  collectibles: successfulPurchaseModal$.state.get().collectibles
2682
2318
  }
2683
2319
  ),
2684
- /* @__PURE__ */ jsxs16(Box16, { display: "flex", alignItems: "center", gap: "1", children: [
2685
- /* @__PURE__ */ jsx23(Text13, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "You bought" }),
2686
- /* @__PURE__ */ jsx23(Text13, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().collectibles.length }),
2687
- /* @__PURE__ */ jsx23(Text13, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "items for" }),
2688
- /* @__PURE__ */ jsx23(Text13, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().totalPrice })
2320
+ /* @__PURE__ */ jsxs15(Box15, { display: "flex", alignItems: "center", gap: "1", children: [
2321
+ /* @__PURE__ */ jsx22(Text13, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "You bought" }),
2322
+ /* @__PURE__ */ jsx22(Text13, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().collectibles.length }),
2323
+ /* @__PURE__ */ jsx22(Text13, { fontSize: "normal", fontWeight: "medium", color: "text80", children: "items for" }),
2324
+ /* @__PURE__ */ jsx22(Text13, { fontSize: "normal", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().totalPrice })
2689
2325
  ] }),
2690
- /* @__PURE__ */ jsx23(SuccessfulPurchaseActions, {})
2326
+ /* @__PURE__ */ jsx22(SuccessfulPurchaseActions, {})
2691
2327
  ] }),
2692
- /* @__PURE__ */ jsx23(
2328
+ /* @__PURE__ */ jsx22(
2693
2329
  Close2,
2694
2330
  {
2695
2331
  onClick: () => {
@@ -2697,15 +2333,15 @@ var SuccessfulPurchaseModal = observer11(() => {
2697
2333
  },
2698
2334
  className: closeButton,
2699
2335
  asChild: true,
2700
- children: /* @__PURE__ */ jsx23(IconButton3, { size: "xs", "aria-label": "Close modal", icon: CloseIcon2 })
2336
+ children: /* @__PURE__ */ jsx22(IconButton3, { size: "xs", "aria-label": "Close modal", icon: CloseIcon2 })
2701
2337
  }
2702
2338
  )
2703
2339
  ] })
2704
2340
  ] }) });
2705
2341
  });
2706
2342
  function SuccessfulPurchaseActions() {
2707
- return /* @__PURE__ */ jsxs16(Box16, { display: "flex", flexDirection: "column", gap: "2", children: [
2708
- successfulPurchaseModal$.state.ctaOptions.get() && /* @__PURE__ */ jsx23(
2343
+ return /* @__PURE__ */ jsxs15(Box15, { display: "flex", flexDirection: "column", gap: "2", children: [
2344
+ successfulPurchaseModal$.state.ctaOptions.get() && /* @__PURE__ */ jsx22(
2709
2345
  Button3,
2710
2346
  {
2711
2347
  shape: "square",
@@ -2715,7 +2351,7 @@ function SuccessfulPurchaseActions() {
2715
2351
  onClick: successfulPurchaseModal$.state.ctaOptions.ctaOnClick.get() || void 0
2716
2352
  }
2717
2353
  ),
2718
- /* @__PURE__ */ jsx23(
2354
+ /* @__PURE__ */ jsx22(
2719
2355
  Button3,
2720
2356
  {
2721
2357
  as: "a",
@@ -2733,15 +2369,15 @@ function SuccessfulPurchaseActions() {
2733
2369
  function CollectiblesGrid({ collectibles }) {
2734
2370
  const total = collectibles.length;
2735
2371
  const shownCollectibles = total > 4 ? collectibles.slice(0, 4) : collectibles;
2736
- return /* @__PURE__ */ jsx23(Box16, { className: collectiblesGrid, display: "grid", gap: "2", children: shownCollectibles.map((collectible) => {
2372
+ return /* @__PURE__ */ jsx22(Box15, { className: collectiblesGrid, display: "grid", gap: "2", children: shownCollectibles.map((collectible) => {
2737
2373
  const showPlus = total > 4 && collectibles.indexOf(collectible) === 3;
2738
- return /* @__PURE__ */ jsxs16(
2739
- Box16,
2374
+ return /* @__PURE__ */ jsxs15(
2375
+ Box15,
2740
2376
  {
2741
2377
  className: collectiblesGridItem,
2742
2378
  position: "relative",
2743
2379
  children: [
2744
- /* @__PURE__ */ jsx23(
2380
+ /* @__PURE__ */ jsx22(
2745
2381
  Image5,
2746
2382
  {
2747
2383
  src: collectible.image,
@@ -2752,8 +2388,8 @@ function CollectiblesGrid({ collectibles }) {
2752
2388
  borderRadius: "sm"
2753
2389
  }
2754
2390
  ),
2755
- showPlus && /* @__PURE__ */ jsx23(
2756
- Box16,
2391
+ showPlus && /* @__PURE__ */ jsx22(
2392
+ Box15,
2757
2393
  {
2758
2394
  position: "absolute",
2759
2395
  top: "0",
@@ -2765,7 +2401,7 @@ function CollectiblesGrid({ collectibles }) {
2765
2401
  justifyContent: "center",
2766
2402
  background: "backgroundOverlay",
2767
2403
  backdropFilter: "blur",
2768
- children: /* @__PURE__ */ jsxs16(
2404
+ children: /* @__PURE__ */ jsxs15(
2769
2405
  Text13,
2770
2406
  {
2771
2407
  fontSize: "small",
@@ -2794,13 +2430,13 @@ var SuccessfulPurchaseModal_default = SuccessfulPurchaseModal;
2794
2430
 
2795
2431
  // src/react/ui/modals/TransferModal/index.tsx
2796
2432
  import { CloseIcon as CloseIcon3, IconButton as IconButton4 } from "@0xsequence/design-system";
2797
- import { Show as Show5, observer as observer13 } from "@legendapp/state/react";
2433
+ import { Show as Show4, observer as observer12 } from "@legendapp/state/react";
2798
2434
  import { Close as Close3, Content as Content4, Overlay as Overlay3, Portal as Portal4, Root as Root4 } from "@radix-ui/react-dialog";
2799
- import { useAccount as useAccount5 } from "wagmi";
2435
+ import { useAccount as useAccount4 } from "wagmi";
2800
2436
 
2801
2437
  // src/react/ui/modals/TransferModal/_store.ts
2802
- import { observable as observable8 } from "@legendapp/state";
2803
- var initialState7 = {
2438
+ import { observable as observable7 } from "@legendapp/state";
2439
+ var initialState6 = {
2804
2440
  isOpen: false,
2805
2441
  open: ({
2806
2442
  chainId,
@@ -2820,7 +2456,7 @@ var initialState7 = {
2820
2456
  close: () => {
2821
2457
  transferModal$.isOpen.set(false);
2822
2458
  transferModal$.state.set({
2823
- ...initialState7.state
2459
+ ...initialState6.state
2824
2460
  });
2825
2461
  transferModal$.view.set("enterReceiverAddress");
2826
2462
  transferModal$.hash.set(void 0);
@@ -2835,13 +2471,13 @@ var initialState7 = {
2835
2471
  view: "enterReceiverAddress",
2836
2472
  hash: void 0
2837
2473
  };
2838
- var transferModal$ = observable8(initialState7);
2474
+ var transferModal$ = observable7(initialState6);
2839
2475
 
2840
2476
  // src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
2841
- import { Box as Box17, Button as Button4, Text as Text14, TextInput } from "@0xsequence/design-system";
2842
- import { observable as observable9 } from "@legendapp/state";
2477
+ import { Box as Box16, Button as Button4, Text as Text14, TextInput } from "@0xsequence/design-system";
2478
+ import { observable as observable8 } from "@legendapp/state";
2843
2479
  import { isAddress } from "viem";
2844
- import { useAccount as useAccount4 } from "wagmi";
2480
+ import { useAccount as useAccount3 } from "wagmi";
2845
2481
 
2846
2482
  // src/react/ui/modals/TransferModal/messages.ts
2847
2483
  var baseMessages = {
@@ -2917,200 +2553,543 @@ var useHandleTransfer = () => {
2917
2553
  transferModal$.view.set("enterReceiverAddress");
2918
2554
  callbacks?.onError?.(error);
2919
2555
  }
2920
- }
2921
- }
2922
- return { transfer };
2923
- };
2924
- var useHandleTransfer_default = useHandleTransfer;
2925
-
2926
- // src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
2927
- import { Fragment as Fragment2, jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
2928
- var EnterWalletAddressView = () => {
2929
- const { address } = useAccount4();
2930
- const { collectionAddress, collectibleId, chainId, collectionType } = transferModal$.state.get();
2931
- const $quantity = transferModal$.state.quantity;
2932
- const $invalidQuantity = observable9(false);
2933
- const isWalletAddressValid = isAddress(
2934
- transferModal$.state.receiverAddress.get()
2935
- );
2936
- const { data: tokenBalance } = useListBalances({
2937
- chainId,
2938
- contractAddress: collectionAddress,
2939
- tokenId: collectibleId,
2940
- accountAddress: address ?? "",
2941
- query: { enabled: !!address }
2942
- });
2943
- const balanceAmount = tokenBalance?.pages[0].balances[0].balance;
2944
- const insufficientBalance = balanceAmount ? $quantity.get() > balanceAmount : true;
2945
- const { data: collection } = useCollection({
2946
- collectionAddress,
2947
- chainId
2948
- });
2949
- transferModal$.state.collectionType.set(
2950
- collection?.type
2951
- );
2952
- const { transfer } = useHandleTransfer_default();
2953
- function handleChangeWalletAddress(event) {
2954
- transferModal$.state.receiverAddress.set(event.target.value);
2955
- }
2956
- function handleChangeView() {
2957
- transfer();
2958
- transferModal$.view.set("followWalletInstructions");
2959
- }
2960
- return /* @__PURE__ */ jsxs17(Box17, { display: "grid", gap: "6", flexGrow: "1", children: [
2961
- /* @__PURE__ */ jsx24(Text14, { color: "white", fontSize: "large", fontWeight: "bold", fontFamily: "body", children: "Transfer your item" }),
2962
- /* @__PURE__ */ jsxs17(Box17, { display: "flex", flexDirection: "column", gap: "3", children: [
2963
- /* @__PURE__ */ jsx24(
2964
- AlertMessage,
2556
+ }
2557
+ }
2558
+ return { transfer };
2559
+ };
2560
+ var useHandleTransfer_default = useHandleTransfer;
2561
+
2562
+ // src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
2563
+ import { Fragment as Fragment2, jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
2564
+ var EnterWalletAddressView = () => {
2565
+ const { address } = useAccount3();
2566
+ const { collectionAddress, collectibleId, chainId, collectionType } = transferModal$.state.get();
2567
+ const $quantity = transferModal$.state.quantity;
2568
+ const $invalidQuantity = observable8(false);
2569
+ const isWalletAddressValid = isAddress(
2570
+ transferModal$.state.receiverAddress.get()
2571
+ );
2572
+ const { data: tokenBalance } = useListBalances({
2573
+ chainId,
2574
+ contractAddress: collectionAddress,
2575
+ tokenId: collectibleId,
2576
+ accountAddress: address ?? "",
2577
+ query: { enabled: !!address }
2578
+ });
2579
+ const balanceAmount = tokenBalance?.pages[0].balances[0].balance;
2580
+ const insufficientBalance = balanceAmount ? $quantity.get() > balanceAmount : true;
2581
+ const { data: collection } = useCollection({
2582
+ collectionAddress,
2583
+ chainId
2584
+ });
2585
+ transferModal$.state.collectionType.set(
2586
+ collection?.type
2587
+ );
2588
+ const { transfer } = useHandleTransfer_default();
2589
+ function handleChangeWalletAddress(event) {
2590
+ transferModal$.state.receiverAddress.set(event.target.value);
2591
+ }
2592
+ function handleChangeView() {
2593
+ transfer();
2594
+ transferModal$.view.set("followWalletInstructions");
2595
+ }
2596
+ return /* @__PURE__ */ jsxs16(Box16, { display: "grid", gap: "6", flexGrow: "1", children: [
2597
+ /* @__PURE__ */ jsx23(Text14, { color: "white", fontSize: "large", fontWeight: "bold", fontFamily: "body", children: "Transfer your item" }),
2598
+ /* @__PURE__ */ jsxs16(Box16, { display: "flex", flexDirection: "column", gap: "3", children: [
2599
+ /* @__PURE__ */ jsx23(
2600
+ AlertMessage,
2601
+ {
2602
+ message: getMessage("enterReceiverAddress"),
2603
+ type: "warning"
2604
+ }
2605
+ ),
2606
+ /* @__PURE__ */ jsx23(
2607
+ TextInput,
2608
+ {
2609
+ label: "Wallet address",
2610
+ labelLocation: "top",
2611
+ value: transferModal$.state.receiverAddress.get(),
2612
+ onChange: handleChangeWalletAddress,
2613
+ name: "walletAddress",
2614
+ placeholder: "Enter wallet address of recipient"
2615
+ }
2616
+ ),
2617
+ collectionType === "ERC1155" /* ERC1155 */ && balanceAmount && /* @__PURE__ */ jsxs16(Fragment2, { children: [
2618
+ /* @__PURE__ */ jsx23(
2619
+ QuantityInput,
2620
+ {
2621
+ $quantity,
2622
+ $invalidQuantity,
2623
+ decimals: collection?.decimals || 0,
2624
+ maxQuantity: balanceAmount
2625
+ }
2626
+ ),
2627
+ /* @__PURE__ */ jsx23(
2628
+ Text14,
2629
+ {
2630
+ color: insufficientBalance ? "negative" : "text50",
2631
+ fontSize: "small",
2632
+ fontWeight: "medium",
2633
+ fontFamily: "body",
2634
+ children: `You have ${balanceAmount} of this item`
2635
+ }
2636
+ )
2637
+ ] })
2638
+ ] }),
2639
+ /* @__PURE__ */ jsx23(
2640
+ Button4,
2641
+ {
2642
+ onClick: handleChangeView,
2643
+ disabled: !isWalletAddressValid || insufficientBalance || !$quantity.get(),
2644
+ title: "Transfer",
2645
+ label: "Transfer",
2646
+ variant: "primary",
2647
+ shape: "square",
2648
+ size: "sm",
2649
+ justifySelf: "flex-end",
2650
+ paddingX: "10"
2651
+ }
2652
+ )
2653
+ ] });
2654
+ };
2655
+ var enterWalletAddress_default = EnterWalletAddressView;
2656
+
2657
+ // src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx
2658
+ import { Box as Box17, Button as Button5, Text as Text15 } from "@0xsequence/design-system";
2659
+ import { observer as observer11 } from "@legendapp/state/react";
2660
+ import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
2661
+ var FollowWalletInstructionsView = observer11(() => {
2662
+ return /* @__PURE__ */ jsxs17(Box17, { display: "grid", gap: "6", flexGrow: "1", children: [
2663
+ /* @__PURE__ */ jsx24(Text15, { color: "white", fontSize: "large", fontWeight: "bold", fontFamily: "body", children: "Transfer your item" }),
2664
+ /* @__PURE__ */ jsx24(Box17, { display: "flex", flexDirection: "column", gap: "3", children: /* @__PURE__ */ jsx24(
2665
+ AlertMessage,
2666
+ {
2667
+ message: getMessage("followWalletInstructions"),
2668
+ type: "info"
2669
+ }
2670
+ ) }),
2671
+ /* @__PURE__ */ jsx24(
2672
+ Button5,
2673
+ {
2674
+ disabled: true,
2675
+ title: "Transfer",
2676
+ label: "Transfer",
2677
+ variant: "primary",
2678
+ shape: "square",
2679
+ size: "sm",
2680
+ justifySelf: "flex-end",
2681
+ paddingX: "10"
2682
+ }
2683
+ )
2684
+ ] });
2685
+ });
2686
+ var followWalletInstructions_default = FollowWalletInstructionsView;
2687
+
2688
+ // src/react/ui/modals/TransferModal/index.tsx
2689
+ import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
2690
+ var useTransferModal = () => {
2691
+ const { chainId: accountChainId } = useAccount4();
2692
+ const { show: showSwitchNetworkModal } = useSwitchChainModal();
2693
+ const openModal = (args) => {
2694
+ transferModal$.open(args);
2695
+ };
2696
+ const handleShowModal = (args) => {
2697
+ const isSameChain = accountChainId === Number(args.chainId);
2698
+ if (!isSameChain) {
2699
+ showSwitchNetworkModal({
2700
+ chainIdToSwitchTo: Number(args.chainId),
2701
+ onSuccess: () => openModal(args)
2702
+ });
2703
+ return;
2704
+ }
2705
+ openModal(args);
2706
+ };
2707
+ return {
2708
+ show: handleShowModal,
2709
+ close: () => transferModal$.close(),
2710
+ onError: (callbacks) => {
2711
+ transferModal$.state.set({
2712
+ ...transferModal$.state.get(),
2713
+ callbacks
2714
+ });
2715
+ },
2716
+ onSuccess: (callbacks) => {
2717
+ transferModal$.state.set({
2718
+ ...transferModal$.state.get(),
2719
+ callbacks
2720
+ });
2721
+ }
2722
+ };
2723
+ };
2724
+ var TransferModal = () => {
2725
+ return /* @__PURE__ */ jsx25(Show4, { if: transferModal$.isOpen, children: /* @__PURE__ */ jsx25(Modal4, {}) });
2726
+ };
2727
+ var Modal4 = () => {
2728
+ return /* @__PURE__ */ jsx25(ModalContent, {});
2729
+ };
2730
+ var ModalContent = observer12(() => {
2731
+ return /* @__PURE__ */ jsx25(Root4, { open: true, children: /* @__PURE__ */ jsxs18(Portal4, { children: [
2732
+ /* @__PURE__ */ jsx25(Overlay3, { className: dialogOverlay2 }),
2733
+ /* @__PURE__ */ jsxs18(Content4, { className: transferModalContent, children: [
2734
+ /* @__PURE__ */ jsx25(TransactionModalView, {}),
2735
+ /* @__PURE__ */ jsx25(Close3, { onClick: transferModal$.close, className: closeButton2, asChild: true, children: /* @__PURE__ */ jsx25(IconButton4, { size: "xs", "aria-label": "Close modal", icon: CloseIcon3 }) })
2736
+ ] })
2737
+ ] }) });
2738
+ });
2739
+ var TransactionModalView = observer12(() => {
2740
+ const { view } = transferModal$.get();
2741
+ switch (view) {
2742
+ case "enterReceiverAddress":
2743
+ return /* @__PURE__ */ jsx25(enterWalletAddress_default, {});
2744
+ case "followWalletInstructions":
2745
+ return /* @__PURE__ */ jsx25(followWalletInstructions_default, {});
2746
+ default:
2747
+ return null;
2748
+ }
2749
+ });
2750
+
2751
+ // src/react/ui/modals/CreateListingModal/Modal.tsx
2752
+ import { Box as Box18 } from "@0xsequence/design-system";
2753
+ import { Show as Show5, observer as observer13 } from "@legendapp/state/react";
2754
+ import { useEffect as useEffect8, useState as useState12 } from "react";
2755
+ import { parseUnits as parseUnits5 } from "viem";
2756
+ import { useAccount as useAccount5 } from "wagmi";
2757
+
2758
+ // src/react/hooks/useCreateListing.tsx
2759
+ import { useCallback as useCallback4, useState as useState11 } from "react";
2760
+ var useCreateListing = ({
2761
+ onSuccess,
2762
+ onError,
2763
+ onTransactionSent,
2764
+ onApprovalSuccess,
2765
+ enabled,
2766
+ ...config
2767
+ }) => {
2768
+ const [isLoading, setIsLoading] = useState11(false);
2769
+ const [steps, setSteps] = useState11(null);
2770
+ const [executionState, setExecutionState] = useState11(null);
2771
+ const machineConfig = {
2772
+ ...config,
2773
+ type: "LISTING" /* LISTING */
2774
+ };
2775
+ const { machine, isLoading: isMachineLoading } = useTransactionMachine({
2776
+ config: machineConfig,
2777
+ enabled,
2778
+ onSuccess: (hash) => {
2779
+ setExecutionState(null);
2780
+ onSuccess?.(hash);
2781
+ },
2782
+ onError: (error) => {
2783
+ setExecutionState(null);
2784
+ onError?.(error);
2785
+ },
2786
+ onTransactionSent,
2787
+ onApprovalSuccess: (hash) => {
2788
+ setExecutionState(null);
2789
+ onApprovalSuccess?.(hash);
2790
+ }
2791
+ });
2792
+ const loadSteps = useCallback4(
2793
+ async (props) => {
2794
+ if (!machine) return;
2795
+ setIsLoading(true);
2796
+ const generatedSteps = await machine.getTransactionSteps(props);
2797
+ if (!generatedSteps) {
2798
+ setIsLoading(false);
2799
+ return;
2800
+ }
2801
+ setSteps({
2802
+ ...generatedSteps,
2803
+ approval: {
2804
+ ...generatedSteps.approval,
2805
+ isExecuting: executionState === "approval"
2806
+ },
2807
+ transaction: {
2808
+ ...generatedSteps.transaction,
2809
+ isExecuting: executionState === "listing"
2810
+ }
2811
+ });
2812
+ setIsLoading(false);
2813
+ },
2814
+ [machine, executionState]
2815
+ );
2816
+ const handleStepExecution = useCallback4(
2817
+ async (type, execute) => {
2818
+ if (!type) return;
2819
+ setExecutionState(type);
2820
+ try {
2821
+ await execute();
2822
+ } catch (error) {
2823
+ setExecutionState(null);
2824
+ throw error;
2825
+ }
2826
+ },
2827
+ []
2828
+ );
2829
+ return {
2830
+ createListing: (props) => machine?.start(props),
2831
+ getListingSteps: (props) => ({
2832
+ isLoading,
2833
+ steps: steps ? {
2834
+ ...steps,
2835
+ approval: {
2836
+ ...steps.approval,
2837
+ isExecuting: executionState === "approval",
2838
+ execute: () => handleStepExecution("approval", () => steps.approval.execute())
2839
+ },
2840
+ transaction: {
2841
+ ...steps.transaction,
2842
+ isExecuting: executionState === "listing",
2843
+ execute: () => handleStepExecution(
2844
+ "listing",
2845
+ () => steps.transaction.execute()
2846
+ )
2847
+ }
2848
+ } : null,
2849
+ refreshSteps: () => loadSteps(props)
2850
+ }),
2851
+ isLoading: isMachineLoading
2852
+ };
2853
+ };
2854
+
2855
+ // src/react/ui/modals/CreateListingModal/store.ts
2856
+ import { observable as observable9 } from "@legendapp/state";
2857
+ import { addDays as addDays3 } from "date-fns/addDays";
2858
+ var initialState7 = {
2859
+ isOpen: false,
2860
+ collectionAddress: "",
2861
+ chainId: "",
2862
+ collectibleId: "",
2863
+ orderbookKind: "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
2864
+ collectionName: "",
2865
+ collectionType: void 0,
2866
+ listingPrice: {
2867
+ // to see if approval is needed when modal opens
2868
+ amountRaw: "1",
2869
+ currency: {}
2870
+ },
2871
+ quantity: "1",
2872
+ invalidQuantity: false,
2873
+ expiry: new Date(addDays3(/* @__PURE__ */ new Date(), 7).toJSON()),
2874
+ callbacks: void 0
2875
+ };
2876
+ var actions2 = {
2877
+ open: (args) => {
2878
+ createListingModal$.collectionAddress.set(args.collectionAddress);
2879
+ createListingModal$.chainId.set(args.chainId);
2880
+ createListingModal$.collectibleId.set(args.collectibleId);
2881
+ createListingModal$.orderbookKind.set(args.orderbookKind);
2882
+ createListingModal$.callbacks.set(args.callbacks);
2883
+ createListingModal$.isOpen.set(true);
2884
+ },
2885
+ close: () => {
2886
+ createListingModal$.isOpen.set(false);
2887
+ createListingModal$.set({ ...initialState7, ...actions2 });
2888
+ }
2889
+ };
2890
+ var createListingModal$ = observable9({
2891
+ ...initialState7,
2892
+ ...actions2
2893
+ });
2894
+
2895
+ // src/react/ui/modals/CreateListingModal/Modal.tsx
2896
+ import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
2897
+ var CreateListingModal = () => {
2898
+ const { show: showTransactionStatusModal } = useTransactionStatusModal();
2899
+ return /* @__PURE__ */ jsx26(Show5, { if: createListingModal$.isOpen, children: () => /* @__PURE__ */ jsx26(Modal5, { showTransactionStatusModal }) });
2900
+ };
2901
+ var Modal5 = observer13(
2902
+ ({
2903
+ showTransactionStatusModal
2904
+ }) => {
2905
+ const state = createListingModal$.get();
2906
+ const {
2907
+ collectionAddress,
2908
+ chainId,
2909
+ listingPrice,
2910
+ collectibleId,
2911
+ orderbookKind,
2912
+ callbacks
2913
+ } = state;
2914
+ const currencyAddress = listingPrice.currency.contractAddress;
2915
+ const {
2916
+ data: collectible,
2917
+ isLoading: collectableIsLoading,
2918
+ isError: collectableIsError
2919
+ } = useCollectible({
2920
+ chainId,
2921
+ collectionAddress,
2922
+ collectibleId
2923
+ });
2924
+ const {
2925
+ data: collection,
2926
+ isLoading: collectionIsLoading,
2927
+ isError: collectionIsError
2928
+ } = useCollection({
2929
+ chainId,
2930
+ collectionAddress
2931
+ });
2932
+ const [approvalExecutedSuccess, setApprovalExecutedSuccess] = useState12(false);
2933
+ const { address } = useAccount5();
2934
+ const { data: balance } = useBalanceOfCollectible({
2935
+ chainId,
2936
+ collectionAddress,
2937
+ collectableId: collectibleId,
2938
+ userAddress: address ?? void 0
2939
+ });
2940
+ const { getListingSteps, isLoading: machineLoading } = useCreateListing({
2941
+ orderbookKind,
2942
+ chainId,
2943
+ collectionAddress,
2944
+ enabled: createListingModal$.isOpen.get(),
2945
+ onApprovalSuccess: () => setApprovalExecutedSuccess(true),
2946
+ onTransactionSent: (hash, orderId) => {
2947
+ if (!hash && !orderId) return;
2948
+ showTransactionStatusModal({
2949
+ hash,
2950
+ orderId,
2951
+ collectionAddress,
2952
+ chainId,
2953
+ price: createListingModal$.listingPrice.get(),
2954
+ collectibleId,
2955
+ type: "LISTING" /* LISTING */,
2956
+ queriesToInvalidate: collectableKeys.all,
2957
+ callbacks
2958
+ });
2959
+ createListingModal$.close();
2960
+ }
2961
+ });
2962
+ const { isLoading, steps, refreshSteps } = getListingSteps({
2963
+ contractType: collection?.type,
2964
+ listing: {
2965
+ tokenId: collectibleId,
2966
+ quantity: parseUnits5(
2967
+ createListingModal$.quantity.get(),
2968
+ collectible?.decimals || 0
2969
+ ).toString(),
2970
+ expiry: dateToUnixTime(createListingModal$.expiry.get()),
2971
+ currencyAddress: listingPrice.currency.contractAddress,
2972
+ pricePerToken: listingPrice.amountRaw
2973
+ }
2974
+ });
2975
+ useEffect8(() => {
2976
+ if (!currencyAddress) return;
2977
+ refreshSteps();
2978
+ }, [currencyAddress]);
2979
+ const handleStepExecution = async (execute) => {
2980
+ if (!execute) return;
2981
+ try {
2982
+ await refreshSteps();
2983
+ await execute();
2984
+ } catch (error) {
2985
+ if (callbacks?.onError) {
2986
+ callbacks.onError(error);
2987
+ } else {
2988
+ console.debug("onError callback not provided:", error);
2989
+ }
2990
+ }
2991
+ };
2992
+ if (collectableIsLoading || collectionIsLoading || machineLoading) {
2993
+ return /* @__PURE__ */ jsx26(
2994
+ LoadingModal,
2965
2995
  {
2966
- message: getMessage("enterReceiverAddress"),
2967
- type: "warning"
2996
+ isOpen: createListingModal$.isOpen.get(),
2997
+ chainId: Number(chainId),
2998
+ onClose: createListingModal$.close,
2999
+ title: "List item for sale"
2968
3000
  }
2969
- ),
2970
- /* @__PURE__ */ jsx24(
2971
- TextInput,
3001
+ );
3002
+ }
3003
+ if (collectableIsError || collectionIsError) {
3004
+ return /* @__PURE__ */ jsx26(
3005
+ ErrorModal,
2972
3006
  {
2973
- label: "Wallet address",
2974
- labelLocation: "top",
2975
- value: transferModal$.state.receiverAddress.get(),
2976
- onChange: handleChangeWalletAddress,
2977
- name: "walletAddress",
2978
- placeholder: "Enter wallet address of recipient"
3007
+ isOpen: createListingModal$.isOpen.get(),
3008
+ chainId: Number(chainId),
3009
+ onClose: createListingModal$.close,
3010
+ title: "List item for sale"
2979
3011
  }
2980
- ),
2981
- collectionType === "ERC1155" /* ERC1155 */ && balanceAmount && /* @__PURE__ */ jsxs17(Fragment2, { children: [
2982
- /* @__PURE__ */ jsx24(
2983
- QuantityInput,
2984
- {
2985
- $quantity,
2986
- $invalidQuantity,
2987
- decimals: collection?.decimals || 0,
2988
- maxQuantity: balanceAmount
2989
- }
2990
- ),
2991
- /* @__PURE__ */ jsx24(
2992
- Text14,
2993
- {
2994
- color: insufficientBalance ? "negative" : "text50",
2995
- fontSize: "small",
2996
- fontWeight: "medium",
2997
- fontFamily: "body",
2998
- children: `You have ${balanceAmount} of this item`
2999
- }
3000
- )
3001
- ] })
3002
- ] }),
3003
- /* @__PURE__ */ jsx24(
3004
- Button4,
3012
+ );
3013
+ }
3014
+ const approvalNeeded = steps?.approval.isPending;
3015
+ const ctas = [
3005
3016
  {
3006
- onClick: handleChangeView,
3007
- disabled: !isWalletAddressValid || insufficientBalance || !$quantity.get(),
3008
- title: "Transfer",
3009
- label: "Transfer",
3010
- variant: "primary",
3011
- shape: "square",
3012
- size: "sm",
3013
- justifySelf: "flex-end",
3014
- paddingX: "10"
3015
- }
3016
- )
3017
- ] });
3018
- };
3019
- var enterWalletAddress_default = EnterWalletAddressView;
3020
-
3021
- // src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx
3022
- import { Box as Box18, Button as Button5, Text as Text15 } from "@0xsequence/design-system";
3023
- import { observer as observer12 } from "@legendapp/state/react";
3024
- import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
3025
- var FollowWalletInstructionsView = observer12(() => {
3026
- return /* @__PURE__ */ jsxs18(Box18, { display: "grid", gap: "6", flexGrow: "1", children: [
3027
- /* @__PURE__ */ jsx25(Text15, { color: "white", fontSize: "large", fontWeight: "bold", fontFamily: "body", children: "Transfer your item" }),
3028
- /* @__PURE__ */ jsx25(Box18, { display: "flex", flexDirection: "column", gap: "3", children: /* @__PURE__ */ jsx25(
3029
- AlertMessage,
3017
+ label: "Approve TOKEN",
3018
+ onClick: () => handleStepExecution(() => steps?.approval.execute()),
3019
+ hidden: !approvalNeeded || approvalExecutedSuccess,
3020
+ pending: steps?.approval.isExecuting || isLoading,
3021
+ variant: "glass",
3022
+ disabled: createListingModal$.invalidQuantity.get() || isLoading || listingPrice.amountRaw === "0" || steps?.transaction.isExecuting
3023
+ },
3030
3024
  {
3031
- message: getMessage("followWalletInstructions"),
3032
- type: "info"
3025
+ label: "List item for sale",
3026
+ onClick: () => handleStepExecution(() => steps?.transaction.execute()),
3027
+ pending: steps?.transaction.isExecuting || isLoading,
3028
+ disabled: !approvalExecutedSuccess && approvalNeeded || listingPrice.amountRaw === "0" || isLoading || createListingModal$.invalidQuantity.get()
3033
3029
  }
3034
- ) }),
3035
- /* @__PURE__ */ jsx25(
3036
- Button5,
3030
+ ];
3031
+ return /* @__PURE__ */ jsxs19(
3032
+ ActionModal,
3037
3033
  {
3038
- disabled: true,
3039
- title: "Transfer",
3040
- label: "Transfer",
3041
- variant: "primary",
3042
- shape: "square",
3043
- size: "sm",
3044
- justifySelf: "flex-end",
3045
- paddingX: "10"
3034
+ isOpen: createListingModal$.isOpen.get(),
3035
+ chainId: Number(chainId),
3036
+ onClose: () => createListingModal$.close(),
3037
+ title: "List item for sale",
3038
+ ctas,
3039
+ children: [
3040
+ /* @__PURE__ */ jsx26(
3041
+ TokenPreview,
3042
+ {
3043
+ collectionName: collection?.name,
3044
+ collectionAddress,
3045
+ collectibleId,
3046
+ chainId
3047
+ }
3048
+ ),
3049
+ /* @__PURE__ */ jsxs19(Box18, { display: "flex", flexDirection: "column", width: "full", gap: "1", children: [
3050
+ /* @__PURE__ */ jsx26(
3051
+ priceInput_default,
3052
+ {
3053
+ chainId,
3054
+ collectionAddress,
3055
+ $listingPrice: createListingModal$.listingPrice
3056
+ }
3057
+ ),
3058
+ listingPrice.amountRaw !== "0" && /* @__PURE__ */ jsx26(
3059
+ FloorPriceText,
3060
+ {
3061
+ tokenId: collectibleId,
3062
+ chainId,
3063
+ collectionAddress,
3064
+ price: listingPrice
3065
+ }
3066
+ )
3067
+ ] }),
3068
+ collection?.type === "ERC1155" && balance && /* @__PURE__ */ jsx26(
3069
+ QuantityInput,
3070
+ {
3071
+ $quantity: createListingModal$.quantity,
3072
+ $invalidQuantity: createListingModal$.invalidQuantity,
3073
+ decimals: collectible?.decimals || 0,
3074
+ maxQuantity: balance?.balance
3075
+ }
3076
+ ),
3077
+ /* @__PURE__ */ jsx26(expirationDateSelect_default, { $date: createListingModal$.expiry }),
3078
+ /* @__PURE__ */ jsx26(
3079
+ TransactionDetails,
3080
+ {
3081
+ collectibleId,
3082
+ collectionAddress,
3083
+ chainId,
3084
+ price: createListingModal$.listingPrice.get(),
3085
+ currencyImageUrl: listingPrice.currency.imageUrl
3086
+ }
3087
+ )
3088
+ ]
3046
3089
  }
3047
- )
3048
- ] });
3049
- });
3050
- var followWalletInstructions_default = FollowWalletInstructionsView;
3051
-
3052
- // src/react/ui/modals/TransferModal/index.tsx
3053
- import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
3054
- var useTransferModal = () => {
3055
- const { chainId: accountChainId } = useAccount5();
3056
- const { show: showSwitchNetworkModal } = useSwitchChainModal();
3057
- const openModal = (args) => {
3058
- transferModal$.open(args);
3059
- };
3060
- const handleShowModal = (args) => {
3061
- const isSameChain = accountChainId === Number(args.chainId);
3062
- if (!isSameChain) {
3063
- showSwitchNetworkModal({
3064
- chainIdToSwitchTo: Number(args.chainId),
3065
- onSuccess: () => openModal(args)
3066
- });
3067
- return;
3068
- }
3069
- openModal(args);
3070
- };
3071
- return {
3072
- show: handleShowModal,
3073
- close: () => transferModal$.close(),
3074
- onError: (callbacks) => {
3075
- transferModal$.state.set({
3076
- ...transferModal$.state.get(),
3077
- callbacks
3078
- });
3079
- },
3080
- onSuccess: (callbacks) => {
3081
- transferModal$.state.set({
3082
- ...transferModal$.state.get(),
3083
- callbacks
3084
- });
3085
- }
3086
- };
3087
- };
3088
- var TransferModal = () => {
3089
- return /* @__PURE__ */ jsx26(Show5, { if: transferModal$.isOpen, children: /* @__PURE__ */ jsx26(Modal3, {}) });
3090
- };
3091
- var Modal3 = () => {
3092
- return /* @__PURE__ */ jsx26(ModalContent3, {});
3093
- };
3094
- var ModalContent3 = observer13(() => {
3095
- return /* @__PURE__ */ jsx26(Root4, { open: true, children: /* @__PURE__ */ jsxs19(Portal4, { children: [
3096
- /* @__PURE__ */ jsx26(Overlay3, { className: dialogOverlay2 }),
3097
- /* @__PURE__ */ jsxs19(Content4, { className: transferModalContent, children: [
3098
- /* @__PURE__ */ jsx26(TransactionModalView, {}),
3099
- /* @__PURE__ */ jsx26(Close3, { onClick: transferModal$.close, className: closeButton2, asChild: true, children: /* @__PURE__ */ jsx26(IconButton4, { size: "xs", "aria-label": "Close modal", icon: CloseIcon3 }) })
3100
- ] })
3101
- ] }) });
3102
- });
3103
- var TransactionModalView = observer13(() => {
3104
- const { view } = transferModal$.get();
3105
- switch (view) {
3106
- case "enterReceiverAddress":
3107
- return /* @__PURE__ */ jsx26(enterWalletAddress_default, {});
3108
- case "followWalletInstructions":
3109
- return /* @__PURE__ */ jsx26(followWalletInstructions_default, {});
3110
- default:
3111
- return null;
3090
+ );
3112
3091
  }
3113
- });
3092
+ );
3114
3093
 
3115
3094
  // src/react/ui/modals/modal-provider.tsx
3116
3095
  import { Fragment as Fragment3, jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
@@ -3128,8 +3107,30 @@ var ModalProvider = observer14(() => {
3128
3107
  ] });
3129
3108
  });
3130
3109
 
3110
+ // src/react/ui/modals/CreateListingModal/index.tsx
3111
+ var useCreateListingModal = (callbacks) => {
3112
+ return {
3113
+ show: (args) => createListingModal$.open({ ...args, callbacks }),
3114
+ close: () => createListingModal$.close()
3115
+ };
3116
+ };
3117
+
3118
+ // src/react/ui/modals/MakeOfferModal/index.tsx
3119
+ var useMakeOfferModal = (callbacks) => ({
3120
+ show: (args) => makeOfferModal$.open({ ...args, callbacks }),
3121
+ close: () => makeOfferModal$.close()
3122
+ });
3123
+
3124
+ // src/react/ui/modals/SellModal/index.tsx
3125
+ var useSellModal = (callbacks) => {
3126
+ return {
3127
+ show: (args) => sellModal$.open({ ...args, callbacks }),
3128
+ close: () => sellModal$.close()
3129
+ };
3130
+ };
3131
+
3131
3132
  // src/react/ui/components/collectible-card/CollectibleCard.tsx
3132
- import { useState as useState12 } from "react";
3133
+ import { useState as useState13 } from "react";
3133
3134
  import { Box as Box22, IconButton as IconButton6, Skeleton as Skeleton8 } from "@0xsequence/design-system";
3134
3135
  import { useAccount as useAccount7 } from "wagmi";
3135
3136
 
@@ -3497,7 +3498,7 @@ function CollectibleCard({
3497
3498
  }) {
3498
3499
  const { address: accountAddress } = useAccount7();
3499
3500
  const collectibleMetadata = lowestListing?.metadata;
3500
- const [imageLoadingError, setImageLoadingError] = useState12(false);
3501
+ const [imageLoadingError, setImageLoadingError] = useState13(false);
3501
3502
  const { data: highestOffer, isLoading: highestOfferLoading } = useHighestOffer({
3502
3503
  chainId: String(chainId),
3503
3504
  collectionAddress,
@@ -3610,12 +3611,12 @@ function CollectibleCard({
3610
3611
 
3611
3612
  export {
3612
3613
  useBuyModal,
3613
- useCreateListingModal,
3614
- useMakeOfferModal,
3615
- useSellModal,
3616
3614
  useSuccessfulPurchaseModal,
3617
3615
  useTransferModal,
3618
3616
  ModalProvider,
3617
+ useCreateListingModal,
3618
+ useMakeOfferModal,
3619
+ useSellModal,
3619
3620
  CollectibleCard
3620
3621
  };
3621
- //# sourceMappingURL=chunk-IOTKCWOB.js.map
3622
+ //# sourceMappingURL=chunk-MTFS5SED.js.map