@0xsequence/marketplace-sdk 0.8.6 → 0.8.8

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 (138) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/chunk-2PSNAIAT.js +1 -0
  3. package/dist/chunk-2PSNAIAT.js.map +1 -0
  4. package/dist/{chunk-WXKV5N4T.js → chunk-35WWD5V6.js} +3 -3
  5. package/dist/{chunk-ZSCZLHKX.js → chunk-4XLXOEXQ.js} +2 -2
  6. package/dist/{chunk-TGFX3TMV.js → chunk-7IYKUVC3.js} +314 -147
  7. package/dist/chunk-7IYKUVC3.js.map +1 -0
  8. package/dist/{chunk-BB2PTJHI.js → chunk-D7RVSZAQ.js} +131 -83
  9. package/dist/chunk-D7RVSZAQ.js.map +1 -0
  10. package/dist/chunk-DWTLVJAW.js +42 -0
  11. package/dist/chunk-DWTLVJAW.js.map +1 -0
  12. package/dist/{chunk-SJU6QZHM.js → chunk-EODKQL6Y.js} +2 -2
  13. package/dist/{chunk-6SEJI7YS.js → chunk-G3447GIP.js} +39 -20
  14. package/dist/chunk-G3447GIP.js.map +1 -0
  15. package/dist/{chunk-QMWMJVTX.js → chunk-HHYNOPPI.js} +2 -2
  16. package/dist/{chunk-ALICO7NG.js → chunk-KGM2WLSP.js} +15 -158
  17. package/dist/chunk-KGM2WLSP.js.map +1 -0
  18. package/dist/chunk-MAD64DLJ.js +81 -0
  19. package/dist/chunk-MAD64DLJ.js.map +1 -0
  20. package/dist/chunk-N7BPFK46.js +1 -0
  21. package/dist/chunk-N7BPFK46.js.map +1 -0
  22. package/dist/chunk-NX52D7NX.js +135 -0
  23. package/dist/chunk-NX52D7NX.js.map +1 -0
  24. package/dist/chunk-O34GCB47.js +32 -0
  25. package/dist/chunk-O34GCB47.js.map +1 -0
  26. package/dist/{chunk-LDZZUYG7.js → chunk-YALXP2PW.js} +3 -3
  27. package/dist/{chunk-V3NVAVHV.js → chunk-YBOFRP65.js} +2 -2
  28. package/dist/{chunk-BGY4WXER.js → chunk-YEGD7PWE.js} +3 -2
  29. package/dist/{chunk-BGY4WXER.js.map → chunk-YEGD7PWE.js.map} +1 -1
  30. package/dist/{create-config-qDML4ZNn.d.ts → create-config-DwrnzwpM.d.ts} +2 -2
  31. package/dist/{index-DtWR0b_l.d.ts → index-DGsVBflk.d.ts} +3 -12
  32. package/dist/index.css +7 -5
  33. package/dist/index.css.map +1 -1
  34. package/dist/index.d.ts +13 -4
  35. package/dist/index.js +14 -6
  36. package/dist/{lowestListing-W7P4EkC3.d.ts → lowestListing-BQHIuvNF.d.ts} +2 -2
  37. package/dist/{marketplace.gen-DS-MmGEB.d.ts → marketplace.gen-DQzWciwC.d.ts} +5 -4
  38. package/dist/marketplaceConfig-B4Fdsmxu.d.ts +17 -0
  39. package/dist/react/_internal/api/index.d.ts +3 -3
  40. package/dist/react/_internal/api/index.js +4 -3
  41. package/dist/react/_internal/databeat/index.d.ts +2 -1
  42. package/dist/react/_internal/databeat/index.js +13 -9
  43. package/dist/react/_internal/index.d.ts +6 -6
  44. package/dist/react/_internal/index.js +13 -10
  45. package/dist/react/_internal/wagmi/index.d.ts +6 -5
  46. package/dist/react/_internal/wagmi/index.js +2 -2
  47. package/dist/react/hooks/index.d.ts +9 -8
  48. package/dist/react/hooks/index.js +12 -8
  49. package/dist/react/hooks/options/index.d.ts +4 -4
  50. package/dist/react/hooks/options/index.js +7 -4
  51. package/dist/react/index.css +2650 -0
  52. package/dist/react/index.css.map +1 -1
  53. package/dist/react/index.d.ts +8 -8
  54. package/dist/react/index.js +19 -14
  55. package/dist/react/queries/index.d.ts +3 -3
  56. package/dist/react/queries/index.js +6 -3
  57. package/dist/react/ssr/index.d.ts +3 -3
  58. package/dist/react/ssr/index.js +6 -3
  59. package/dist/react/ssr/index.js.map +1 -1
  60. package/dist/react/ui/components/collectible-card/index.css +2650 -0
  61. package/dist/react/ui/components/collectible-card/index.css.map +1 -1
  62. package/dist/react/ui/components/collectible-card/index.d.ts +1 -1
  63. package/dist/react/ui/components/collectible-card/index.js +17 -12
  64. package/dist/react/ui/icons/index.js +8 -5
  65. package/dist/react/ui/index.css +2650 -0
  66. package/dist/react/ui/index.css.map +1 -1
  67. package/dist/react/ui/index.d.ts +2 -1
  68. package/dist/react/ui/index.js +17 -12
  69. package/dist/react/ui/modals/_internal/components/actionModal/index.js +13 -9
  70. package/dist/sdk-config-txlivEKe.d.ts +133 -0
  71. package/dist/{services-BOX67E7W.d.ts → services-BI_w8Eq4.d.ts} +4 -4
  72. package/dist/types/index.d.ts +5 -4
  73. package/dist/types/index.js +9 -6
  74. package/dist/{types-CJLhc2VZ.d.ts → types-isjvwapz.d.ts} +3 -3
  75. package/dist/utils/index.d.ts +1 -1
  76. package/dist/utils/index.js +6 -3
  77. package/package.json +3 -3
  78. package/src/index.ts +1 -0
  79. package/src/react/{hooks/options/__mocks__/marketplaceConfig.msw.ts → _internal/api/__mocks__/builder.msw.ts} +70 -63
  80. package/src/react/_internal/api/__mocks__/metadata.msw.ts +30 -10
  81. package/src/react/_internal/api/builder-api.ts +32 -0
  82. package/src/react/_internal/api/builder.gen.ts +215 -0
  83. package/src/react/_internal/api/marketplace.gen.ts +6 -6
  84. package/src/react/_internal/api/services.ts +9 -2
  85. package/src/react/_internal/databeat/types.ts +1 -0
  86. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +16 -41
  87. package/src/react/_internal/wagmi/create-config.ts +3 -16
  88. package/src/react/_internal/wagmi/get-connectors.ts +31 -21
  89. package/src/react/_internal/wallet/__tests__/wallet.test.ts +30 -0
  90. package/src/react/_internal/wallet/wallet.ts +25 -2
  91. package/src/react/hooks/__tests__/__snapshots__/useMarketplaceConfig.test.tsx.snap +96 -0
  92. package/src/react/hooks/__tests__/useCollection.test.tsx +4 -5
  93. package/src/react/hooks/__tests__/useCurrencies.test.tsx +1 -1
  94. package/src/react/hooks/__tests__/useInventory.test.tsx +15 -16
  95. package/src/react/hooks/__tests__/useListCollections.test.tsx +18 -163
  96. package/src/react/hooks/__tests__/useMarketplaceConfig.test.tsx +10 -11
  97. package/src/react/hooks/options/index.ts +1 -1
  98. package/src/react/hooks/useAutoSelectFeeOption.tsx +1 -0
  99. package/src/react/hooks/useMarketplaceConfig.tsx +2 -2
  100. package/src/react/queries/marketplaceConfig.ts +101 -0
  101. package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +1 -0
  102. package/src/react/ssr/create-ssr-client.ts +1 -1
  103. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -2
  104. package/src/react/ui/components/collectible-card/__tests__/CollectibleAsset.test.tsx +72 -42
  105. package/src/react/ui/components/collectible-card/{CollectibleAsset.tsx → collectible-asset/CollectibleAsset.tsx} +44 -44
  106. package/src/react/ui/components/collectible-card/collectible-asset/CollectibleAssetSkeleton.tsx +14 -0
  107. package/src/react/ui/components/collectible-card/collectible-asset/utils.ts +36 -0
  108. package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +6 -1
  109. package/src/react/ui/modals/BuyModal/store.ts +1 -0
  110. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +20 -2
  111. package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +17 -1
  112. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +4 -0
  113. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +7 -1
  114. package/src/types/index.ts +7 -1
  115. package/src/types/sdk-config.ts +4 -9
  116. package/src/utils/fetchContentType.ts +101 -0
  117. package/src/utils/getMarketplaceDetails.ts +2 -1
  118. package/src/utils/getSequenceMarketRequestId.ts +32 -0
  119. package/test/mocks/wallet.ts +3 -1
  120. package/test/test-utils.tsx +1 -1
  121. package/tsconfig.tsbuildinfo +1 -1
  122. package/dist/builder-types-BY6eD6vD.d.ts +0 -82
  123. package/dist/chunk-6SEJI7YS.js.map +0 -1
  124. package/dist/chunk-ALICO7NG.js.map +0 -1
  125. package/dist/chunk-BB2PTJHI.js.map +0 -1
  126. package/dist/chunk-HGKWWZWY.js +0 -58
  127. package/dist/chunk-HGKWWZWY.js.map +0 -1
  128. package/dist/chunk-TGFX3TMV.js.map +0 -1
  129. package/dist/sdk-config-DIzJk_tI.d.ts +0 -26
  130. package/src/react/hooks/options/__tests__/marketplaceConfigOptions.test.tsx +0 -134
  131. package/src/react/hooks/options/marketplaceConfigOptions.ts +0 -71
  132. package/src/types/builder-types.ts +0 -88
  133. /package/dist/{chunk-WXKV5N4T.js.map → chunk-35WWD5V6.js.map} +0 -0
  134. /package/dist/{chunk-ZSCZLHKX.js.map → chunk-4XLXOEXQ.js.map} +0 -0
  135. /package/dist/{chunk-SJU6QZHM.js.map → chunk-EODKQL6Y.js.map} +0 -0
  136. /package/dist/{chunk-QMWMJVTX.js.map → chunk-HHYNOPPI.js.map} +0 -0
  137. /package/dist/{chunk-LDZZUYG7.js.map → chunk-YALXP2PW.js.map} +0 -0
  138. /package/dist/{chunk-V3NVAVHV.js.map → chunk-YBOFRP65.js.map} +0 -0
@@ -2,15 +2,15 @@
2
2
 
3
3
  import {
4
4
  ActionModal
5
- } from "./chunk-V3NVAVHV.js";
5
+ } from "./chunk-YBOFRP65.js";
6
6
  import {
7
7
  useAnalytics
8
- } from "./chunk-QMWMJVTX.js";
8
+ } from "./chunk-HHYNOPPI.js";
9
9
  import {
10
10
  BellIcon_default,
11
11
  CalendarIcon_default,
12
12
  CartIcon_default
13
- } from "./chunk-WXKV5N4T.js";
13
+ } from "./chunk-35WWD5V6.js";
14
14
  import {
15
15
  AlertMessage,
16
16
  MODAL_OVERLAY_PROPS,
@@ -33,7 +33,7 @@ import {
33
33
  useSwitchChainModal,
34
34
  useTransferTokens,
35
35
  useWallet
36
- } from "./chunk-6SEJI7YS.js";
36
+ } from "./chunk-G3447GIP.js";
37
37
  import {
38
38
  DEFAULT_MARKETPLACE_FEE_PERCENTAGE
39
39
  } from "./chunk-Y63BOO6M.js";
@@ -43,15 +43,20 @@ import {
43
43
  compareAddress,
44
44
  formatPriceWithFee,
45
45
  truncateMiddle
46
- } from "./chunk-BGY4WXER.js";
46
+ } from "./chunk-YEGD7PWE.js";
47
+ import {
48
+ SequenceMarketplaceV1_ABI
49
+ } from "./chunk-XX4EVWBF.js";
47
50
  import {
48
- InvalidContractTypeError,
49
- InvalidStepError,
50
51
  balanceQueries,
51
52
  collectableKeys,
52
53
  getMarketplaceClient,
53
54
  getQueryClient
54
- } from "./chunk-ALICO7NG.js";
55
+ } from "./chunk-KGM2WLSP.js";
56
+ import {
57
+ InvalidContractTypeError,
58
+ InvalidStepError
59
+ } from "./chunk-NX52D7NX.js";
55
60
 
56
61
  // src/react/ui/modals/modal-provider.tsx
57
62
  import { observer as observer17 } from "@legendapp/state/react";
@@ -552,7 +557,8 @@ var getBuyCollectableParams = async ({
552
557
  collectable,
553
558
  checkoutOptions,
554
559
  fee,
555
- skipNativeBalanceCheck
560
+ skipNativeBalanceCheck,
561
+ nativeTokenAddress
556
562
  }) => {
557
563
  const marketplaceClient = getMarketplaceClient(chainId, config);
558
564
  const { steps: steps3 } = await marketplaceClient.generateBuyTransaction({
@@ -598,7 +604,7 @@ var getBuyCollectableParams = async ({
598
604
  callbacks?.onSuccess?.({ hash });
599
605
  },
600
606
  supplementaryAnalyticsInfo: {
601
- orderId,
607
+ requestId: orderId,
602
608
  marketplaceKind: marketplace
603
609
  },
604
610
  onError: callbacks?.onError,
@@ -608,6 +614,7 @@ var getBuyCollectableParams = async ({
608
614
  buyModalStore.send({ type: "close" });
609
615
  },
610
616
  skipNativeBalanceCheck,
617
+ nativeTokenAddress,
611
618
  ...customCreditCardProviderCallback && {
612
619
  customProviderCallback: () => {
613
620
  customCreditCardProviderCallback(buyStep);
@@ -632,7 +639,8 @@ var usePaymentModalParams = (args) => {
632
639
  collectibleId,
633
640
  orderId,
634
641
  customCreditCardProviderCallback,
635
- skipNativeBalanceCheck
642
+ skipNativeBalanceCheck,
643
+ nativeTokenAddress
636
644
  } = buyModalProps;
637
645
  const config = useConfig();
638
646
  const fee = useFees({
@@ -662,7 +670,8 @@ var usePaymentModalParams = (args) => {
662
670
  onError
663
671
  },
664
672
  customCreditCardProviderCallback,
665
- skipNativeBalanceCheck
673
+ skipNativeBalanceCheck,
674
+ nativeTokenAddress
666
675
  }) : skipToken2
667
676
  });
668
677
  };
@@ -1915,6 +1924,29 @@ var useGetTokenApprovalData = (params) => {
1915
1924
  // src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx
1916
1925
  import { formatUnits as formatUnits5 } from "viem";
1917
1926
 
1927
+ // src/utils/getSequenceMarketRequestId.ts
1928
+ import {
1929
+ parseEventLogs
1930
+ } from "viem";
1931
+ var getSequenceMarketplaceRequestId = async (hash, publicClient, walletAddress) => {
1932
+ try {
1933
+ const receipt = await publicClient.getTransactionReceipt({
1934
+ hash
1935
+ });
1936
+ const logs = parseEventLogs({
1937
+ abi: SequenceMarketplaceV1_ABI,
1938
+ eventName: "RequestCreated",
1939
+ args: {
1940
+ creator: walletAddress
1941
+ },
1942
+ logs: receipt.logs
1943
+ });
1944
+ return logs[0].args.requestId.toString();
1945
+ } catch (error) {
1946
+ console.error(error);
1947
+ }
1948
+ };
1949
+
1918
1950
  // src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
1919
1951
  import { Modal, Skeleton as Skeleton8, Text as Text15 } from "@0xsequence/design-system";
1920
1952
  import { use$ as use$3 } from "@legendapp/state/react";
@@ -2590,12 +2622,22 @@ var useTransactionSteps = ({
2590
2622
  const currencyValueDecimal = Number(
2591
2623
  formatUnits5(BigInt(currencyValueRaw), currencyDecimal)
2592
2624
  );
2625
+ let requestId = orderId;
2626
+ if (hash && (orderbookKind === "sequence_marketplace_v1" /* sequence_marketplace_v1 */ || orderbookKind === "sequence_marketplace_v2" /* sequence_marketplace_v2 */)) {
2627
+ requestId = await getSequenceMarketplaceRequestId(
2628
+ hash,
2629
+ wallet.publicClient,
2630
+ await wallet.address()
2631
+ );
2632
+ }
2593
2633
  analytics.trackCreateListing({
2594
2634
  props: {
2595
2635
  orderbookKind,
2596
2636
  collectionAddress,
2597
2637
  currencyAddress: listingInput.listing.currencyAddress,
2598
- currencySymbol: "",
2638
+ currencySymbol: currency?.symbol || "",
2639
+ tokenId: listingInput.listing.tokenId,
2640
+ requestId: requestId || "",
2599
2641
  chainId: chainId.toString(),
2600
2642
  txnHash: hash || ""
2601
2643
  },
@@ -3181,6 +3223,14 @@ var useTransactionSteps2 = ({
3181
3223
  const currencyValueDecimal = Number(
3182
3224
  formatUnits6(BigInt(currencyValueRaw), currencyDecimal)
3183
3225
  );
3226
+ let requestId = orderId;
3227
+ if (hash && (orderbookKind === "sequence_marketplace_v1" /* sequence_marketplace_v1 */ || orderbookKind === "sequence_marketplace_v2" /* sequence_marketplace_v2 */)) {
3228
+ requestId = await getSequenceMarketplaceRequestId(
3229
+ hash,
3230
+ wallet.publicClient,
3231
+ await wallet.address()
3232
+ );
3233
+ }
3184
3234
  analytics.trackCreateOffer({
3185
3235
  props: {
3186
3236
  orderbookKind,
@@ -3188,6 +3238,7 @@ var useTransactionSteps2 = ({
3188
3238
  currencyAddress: offerInput.offer.currencyAddress,
3189
3239
  currencySymbol: currency?.symbol || "",
3190
3240
  chainId: chainId.toString(),
3241
+ requestId: requestId || "",
3191
3242
  txnHash: hash || ""
3192
3243
  },
3193
3244
  nums: {
@@ -3805,9 +3856,12 @@ var useTransactionSteps3 = ({
3805
3856
  analytics.trackSellItems({
3806
3857
  props: {
3807
3858
  marketplaceKind: marketplace,
3859
+ userId: await wallet.address(),
3808
3860
  collectionAddress,
3809
3861
  currencyAddress: ordersData[0].currencyAddress,
3810
3862
  currencySymbol,
3863
+ requestId: ordersData[0].orderId,
3864
+ tokenId: collectibleId,
3811
3865
  chainId: chainId.toString(),
3812
3866
  txnHash: hash || ""
3813
3867
  },
@@ -5078,111 +5132,6 @@ var ActionButton = observer18(
5078
5132
  }
5079
5133
  );
5080
5134
 
5081
- // src/react/ui/components/collectible-card/CollectibleAsset.tsx
5082
- import { Skeleton as Skeleton10 } from "@0xsequence/design-system";
5083
- import { useEffect as useEffect12, useRef as useRef3, useState as useState10 } from "react";
5084
- import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
5085
- function CollectibleAssetSkeleton() {
5086
- return /* @__PURE__ */ jsx40(
5087
- Skeleton10,
5088
- {
5089
- "data-testid": "collectible-asset-skeleton",
5090
- size: "lg",
5091
- className: "absolute inset-0 h-full w-full animate-shimmer",
5092
- style: {
5093
- borderRadius: 0
5094
- }
5095
- }
5096
- );
5097
- }
5098
- var isHtml = (fileName) => {
5099
- const isHtml2 = /.*\.(html\?.+|html)$/.test(fileName?.toLowerCase() || "");
5100
- return isHtml2;
5101
- };
5102
- var isVideo = (fileName) => {
5103
- const isVideo2 = /.*\.(mp4|ogg|webm)$/.test(fileName?.toLowerCase() || "");
5104
- return isVideo2;
5105
- };
5106
- function CollectibleAsset({
5107
- name,
5108
- collectibleMetadata,
5109
- assetSrcPrefixUrl
5110
- }) {
5111
- const [assetLoadFailed, setAssetLoadFailed] = useState10(false);
5112
- const [assetLoading, setAssetLoading] = useState10(true);
5113
- const videoRef = useRef3(null);
5114
- const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
5115
- const placeholderImage = chess_tile_default;
5116
- const assetUrl = collectibleMetadata?.image || collectibleMetadata?.video || collectibleMetadata?.animation_url || collectibleMetadata?.assets?.[0]?.url || placeholderImage;
5117
- const proxiedAssetUrl = assetSrcPrefixUrl ? `${assetSrcPrefixUrl}${assetUrl}` : assetUrl;
5118
- useEffect12(() => {
5119
- if (videoRef.current) {
5120
- videoRef.current.addEventListener("loadedmetadata", () => {
5121
- setAssetLoading(false);
5122
- });
5123
- }
5124
- }, []);
5125
- if (isHtml(assetUrl)) {
5126
- return /* @__PURE__ */ jsxs29("div", { className: "flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
5127
- assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5128
- /* @__PURE__ */ jsx40(
5129
- "iframe",
5130
- {
5131
- title: name || "Collectible",
5132
- className: "aspect-square w-full",
5133
- src: proxiedAssetUrl,
5134
- allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
5135
- sandbox: "allow-scripts",
5136
- style: {
5137
- border: "0px"
5138
- },
5139
- onError: () => setAssetLoadFailed(true),
5140
- onLoad: () => setAssetLoading(false)
5141
- }
5142
- )
5143
- ] });
5144
- }
5145
- if (isVideo(assetUrl)) {
5146
- return /* @__PURE__ */ jsxs29("div", { className: "relative flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
5147
- assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5148
- /* @__PURE__ */ jsx40(
5149
- "video",
5150
- {
5151
- ref: videoRef,
5152
- className: cn(
5153
- `absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${assetLoading ? "invisible" : "visible"}`,
5154
- // we can't hide the video controls in safari, when user hovers over the video they show up. `pointer-events-none` is the only way to hide them on hover
5155
- isSafari && "pointer-events-none"
5156
- ),
5157
- autoPlay: true,
5158
- loop: true,
5159
- controls: true,
5160
- playsInline: true,
5161
- muted: true,
5162
- controlsList: "nodownload noremoteplayback nofullscreen ",
5163
- onError: () => {
5164
- setAssetLoadFailed(true);
5165
- },
5166
- children: /* @__PURE__ */ jsx40("source", { src: proxiedAssetUrl })
5167
- }
5168
- )
5169
- ] });
5170
- }
5171
- return /* @__PURE__ */ jsxs29("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: [
5172
- assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5173
- /* @__PURE__ */ jsx40(
5174
- "img",
5175
- {
5176
- src: assetLoadFailed ? placeholderImage : proxiedAssetUrl,
5177
- alt: name || "Collectible",
5178
- className: `absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${assetLoading ? "invisible" : "visible"}`,
5179
- onError: () => setAssetLoadFailed(true),
5180
- onLoad: () => setAssetLoading(false)
5181
- }
5182
- )
5183
- ] });
5184
- }
5185
-
5186
5135
  // src/react/ui/components/collectible-card/Footer.tsx
5187
5136
  import {
5188
5137
  ChevronLeftIcon,
@@ -5192,22 +5141,22 @@ import {
5192
5141
  Text as Text21
5193
5142
  } from "@0xsequence/design-system";
5194
5143
  import { formatUnits as formatUnits8 } from "viem";
5195
- import { jsx as jsx41, jsxs as jsxs30 } from "react/jsx-runtime";
5144
+ import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
5196
5145
  var OVERFLOW_PRICE = 1e8;
5197
5146
  var UNDERFLOW_PRICE = 1e-4;
5198
5147
  var formatPrice = (amount, currency) => {
5199
5148
  const formattedPrice = formatUnits8(BigInt(amount), currency.decimals);
5200
5149
  const numericPrice = Number.parseFloat(formattedPrice);
5201
5150
  if (numericPrice < UNDERFLOW_PRICE) {
5202
- return /* @__PURE__ */ jsxs30("div", { className: "flex items-center", children: [
5203
- /* @__PURE__ */ jsx41(ChevronLeftIcon, { className: "h-3 w-3 text-text-100" }),
5204
- /* @__PURE__ */ jsx41(Text21, { children: `${UNDERFLOW_PRICE} ${currency.symbol}` })
5151
+ return /* @__PURE__ */ jsxs29("div", { className: "flex items-center", children: [
5152
+ /* @__PURE__ */ jsx40(ChevronLeftIcon, { className: "h-3 w-3 text-text-100" }),
5153
+ /* @__PURE__ */ jsx40(Text21, { children: `${UNDERFLOW_PRICE} ${currency.symbol}` })
5205
5154
  ] });
5206
5155
  }
5207
5156
  if (numericPrice > OVERFLOW_PRICE) {
5208
- return /* @__PURE__ */ jsxs30("div", { className: "flex items-center", children: [
5209
- /* @__PURE__ */ jsx41(ChevronRightIcon, { className: "h-3 w-3 text-text-100" }),
5210
- /* @__PURE__ */ jsx41(Text21, { children: `${OVERFLOW_PRICE.toLocaleString("en-US", {
5157
+ return /* @__PURE__ */ jsxs29("div", { className: "flex items-center", children: [
5158
+ /* @__PURE__ */ jsx40(ChevronRightIcon, { className: "h-3 w-3 text-text-100" }),
5159
+ /* @__PURE__ */ jsx40(Text21, { children: `${OVERFLOW_PRICE.toLocaleString("en-US", {
5211
5160
  maximumFractionDigits: 2
5212
5161
  })} ${currency.symbol}` })
5213
5162
  ] });
@@ -5217,7 +5166,7 @@ var formatPrice = (amount, currency) => {
5217
5166
  minimumFractionDigits: 0,
5218
5167
  maximumFractionDigits: maxDecimals
5219
5168
  });
5220
- return /* @__PURE__ */ jsx41("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs30(Text21, { children: [
5169
+ return /* @__PURE__ */ jsx40("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs29(Text21, { children: [
5221
5170
  formattedNumber,
5222
5171
  " ",
5223
5172
  currency.symbol
@@ -5240,10 +5189,10 @@ var Footer = ({
5240
5189
  if (name.length > 17 && !highestOffer) {
5241
5190
  name = `${name.substring(0, 17)}...`;
5242
5191
  }
5243
- return /* @__PURE__ */ jsxs30("div", { className: "relative flex flex-col items-start gap-2 whitespace-nowrap bg-background-primary p-4", children: [
5244
- /* @__PURE__ */ jsxs30("div", { className: "relative flex w-full items-center justify-between", children: [
5245
- /* @__PURE__ */ jsx41(Text21, { className: "text-left font-body font-bold text-sm text-text-100", children: name || "Untitled" }),
5246
- highestOffer && onOfferClick && /* @__PURE__ */ jsx41(
5192
+ return /* @__PURE__ */ jsxs29("div", { className: "relative flex flex-col items-start gap-2 whitespace-nowrap bg-background-primary p-4", children: [
5193
+ /* @__PURE__ */ jsxs29("div", { className: "relative flex w-full items-center justify-between", children: [
5194
+ /* @__PURE__ */ jsx40(Text21, { className: "text-left font-body font-bold text-sm text-text-100", children: name || "Untitled" }),
5195
+ highestOffer && onOfferClick && /* @__PURE__ */ jsx40(
5247
5196
  IconButton2,
5248
5197
  {
5249
5198
  className: "absolute top-0 right-0 h-[22px] w-[22px] hover:animate-bell-ring",
@@ -5252,12 +5201,12 @@ var Footer = ({
5252
5201
  onClick: (e) => {
5253
5202
  onOfferClick?.(e);
5254
5203
  },
5255
- icon: (props) => /* @__PURE__ */ jsx41(BellIcon_default, { ...props, size: "xs" })
5204
+ icon: (props) => /* @__PURE__ */ jsx40(BellIcon_default, { ...props, size: "xs" })
5256
5205
  }
5257
5206
  )
5258
5207
  ] }),
5259
- /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-1", children: [
5260
- listed && lowestListingCurrency.imageUrl && /* @__PURE__ */ jsx41(
5208
+ /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-1", children: [
5209
+ listed && lowestListingCurrency.imageUrl && /* @__PURE__ */ jsx40(
5261
5210
  Image7,
5262
5211
  {
5263
5212
  className: "h-3 w-3",
@@ -5267,7 +5216,7 @@ var Footer = ({
5267
5216
  }
5268
5217
  }
5269
5218
  ),
5270
- /* @__PURE__ */ jsxs30(
5219
+ /* @__PURE__ */ jsxs29(
5271
5220
  Text21,
5272
5221
  {
5273
5222
  className: `text-left font-body font-bold text-sm ${listed ? "text-text-100" : "text-text-50"}`,
@@ -5278,7 +5227,7 @@ var Footer = ({
5278
5227
  }
5279
5228
  )
5280
5229
  ] }),
5281
- /* @__PURE__ */ jsx41(
5230
+ /* @__PURE__ */ jsx40(
5282
5231
  TokenTypeBalancePill,
5283
5232
  {
5284
5233
  balance,
@@ -5294,11 +5243,229 @@ var TokenTypeBalancePill = ({
5294
5243
  decimals
5295
5244
  }) => {
5296
5245
  const displayText = type === "ERC1155" /* ERC1155 */ ? balance ? `Owned: ${formatUnits8(BigInt(balance), decimals ?? 0)}` : "ERC-1155" : "ERC-721";
5297
- return /* @__PURE__ */ jsx41(Text21, { className: "rounded-lg bg-background-secondary px-2 py-1 text-left font-medium text-text-80 text-xs", children: displayText });
5246
+ return /* @__PURE__ */ jsx40(Text21, { className: "rounded-lg bg-background-secondary px-2 py-1 text-left font-medium text-text-80 text-xs", children: displayText });
5298
5247
  };
5299
5248
 
5249
+ // src/react/ui/components/collectible-card/collectible-asset/CollectibleAsset.tsx
5250
+ import { useEffect as useEffect12, useRef as useRef3, useState as useState10 } from "react";
5251
+
5252
+ // src/utils/fetchContentType.ts
5253
+ function fetchContentType(url) {
5254
+ return new Promise((resolve, reject) => {
5255
+ if (typeof XMLHttpRequest === "undefined") {
5256
+ reject(new Error("XMLHttpRequest is not supported in this environment."));
5257
+ return;
5258
+ }
5259
+ const client = new XMLHttpRequest();
5260
+ let settled = false;
5261
+ const settle = (value) => {
5262
+ if (!settled) {
5263
+ settled = true;
5264
+ resolve(value);
5265
+ client.abort();
5266
+ }
5267
+ };
5268
+ const fail = (error) => {
5269
+ if (!settled) {
5270
+ settled = true;
5271
+ reject(error);
5272
+ }
5273
+ };
5274
+ client.open("HEAD", url, true);
5275
+ client.onreadystatechange = () => {
5276
+ if (settled || client.readyState < XMLHttpRequest.HEADERS_RECEIVED) {
5277
+ return;
5278
+ }
5279
+ if (client.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
5280
+ const status = client.status;
5281
+ if (status < 200 || status >= 300) {
5282
+ settle(null);
5283
+ return;
5284
+ }
5285
+ const contentType = client.getResponseHeader("Content-Type");
5286
+ if (!contentType) {
5287
+ settle(null);
5288
+ return;
5289
+ }
5290
+ const primaryType = contentType.split("/")[0].toLowerCase();
5291
+ let result = null;
5292
+ switch (primaryType) {
5293
+ case "image":
5294
+ result = "image";
5295
+ break;
5296
+ case "video":
5297
+ result = "video";
5298
+ break;
5299
+ case "text":
5300
+ if (contentType.toLowerCase().includes("html")) {
5301
+ result = "html";
5302
+ }
5303
+ break;
5304
+ }
5305
+ settle(result);
5306
+ return;
5307
+ }
5308
+ };
5309
+ client.onerror = (errorEvent) => {
5310
+ fail(
5311
+ new Error(`XMLHttpRequest network error for URL: ${url}`, {
5312
+ cause: errorEvent
5313
+ })
5314
+ );
5315
+ };
5316
+ client.onabort = () => {
5317
+ if (!settled) {
5318
+ settle(null);
5319
+ }
5320
+ };
5321
+ try {
5322
+ client.send();
5323
+ } catch (error) {
5324
+ fail(
5325
+ new Error(`Error sending XMLHttpRequest for URL: ${url}`, {
5326
+ cause: error
5327
+ })
5328
+ );
5329
+ }
5330
+ });
5331
+ }
5332
+
5333
+ // src/react/ui/components/collectible-card/collectible-asset/CollectibleAssetSkeleton.tsx
5334
+ import { Skeleton as Skeleton10 } from "@0xsequence/design-system";
5335
+ import { jsx as jsx41 } from "react/jsx-runtime";
5336
+ function CollectibleAssetSkeleton() {
5337
+ return /* @__PURE__ */ jsx41(
5338
+ Skeleton10,
5339
+ {
5340
+ "data-testid": "collectible-asset-skeleton",
5341
+ size: "lg",
5342
+ className: "absolute inset-0 h-full w-full animate-shimmer",
5343
+ style: {
5344
+ borderRadius: 0
5345
+ }
5346
+ }
5347
+ );
5348
+ }
5349
+
5350
+ // src/react/ui/components/collectible-card/collectible-asset/utils.ts
5351
+ var isImage = (fileName) => {
5352
+ const isImage2 = /.*\.(png|jpg|jpeg|gif|svg|webp)$/.test(
5353
+ fileName?.toLowerCase() || ""
5354
+ );
5355
+ return isImage2;
5356
+ };
5357
+ var isHtml = (fileName) => {
5358
+ const isHtml2 = /.*\.(html\?.+|html)$/.test(fileName?.toLowerCase() || "");
5359
+ return isHtml2;
5360
+ };
5361
+ var isVideo = (fileName) => {
5362
+ const isVideo2 = /.*\.(mp4|ogg|webm)$/.test(fileName?.toLowerCase() || "");
5363
+ return isVideo2;
5364
+ };
5365
+ var getContentType = (url) => {
5366
+ return new Promise((resolve) => {
5367
+ const type = isHtml(url) ? "html" : isVideo(url) ? "video" : isImage(url) ? "image" : null;
5368
+ resolve(type);
5369
+ });
5370
+ };
5371
+
5372
+ // src/react/ui/components/collectible-card/collectible-asset/CollectibleAsset.tsx
5373
+ import { jsx as jsx42, jsxs as jsxs30 } from "react/jsx-runtime";
5374
+ function CollectibleAsset({
5375
+ name,
5376
+ collectibleMetadata,
5377
+ assetSrcPrefixUrl
5378
+ }) {
5379
+ const [assetLoadFailed, setAssetLoadFailed] = useState10(false);
5380
+ const [assetLoading, setAssetLoading] = useState10(true);
5381
+ const [contentType, setContentType] = useState10({ type: null, loading: true, failed: false });
5382
+ const videoRef = useRef3(null);
5383
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
5384
+ const placeholderImage = chess_tile_default;
5385
+ const assetUrl = collectibleMetadata?.image || collectibleMetadata?.video || collectibleMetadata?.animation_url || collectibleMetadata?.assets?.[0]?.url || placeholderImage;
5386
+ const proxiedAssetUrl = assetSrcPrefixUrl ? `${assetSrcPrefixUrl}${assetUrl}` : assetUrl;
5387
+ useEffect12(() => {
5388
+ getContentType(proxiedAssetUrl).then((contentType2) => {
5389
+ setContentType({ type: contentType2, loading: false, failed: false });
5390
+ }).catch(() => {
5391
+ fetchContentType(proxiedAssetUrl).then((contentType2) => {
5392
+ setContentType({
5393
+ type: contentType2,
5394
+ loading: false,
5395
+ failed: false
5396
+ });
5397
+ }).catch(() => {
5398
+ setContentType({ type: null, loading: false, failed: true });
5399
+ });
5400
+ });
5401
+ }, [proxiedAssetUrl]);
5402
+ if (contentType.type === "html" && !assetLoadFailed) {
5403
+ return /* @__PURE__ */ jsxs30("div", { className: "flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
5404
+ (assetLoading || contentType.loading) && /* @__PURE__ */ jsx42(CollectibleAssetSkeleton, {}),
5405
+ /* @__PURE__ */ jsx42(
5406
+ "iframe",
5407
+ {
5408
+ title: name || "Collectible",
5409
+ className: "aspect-square w-full",
5410
+ src: proxiedAssetUrl,
5411
+ allow: "accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture",
5412
+ sandbox: "allow-scripts",
5413
+ style: {
5414
+ border: "0px"
5415
+ },
5416
+ onError: () => setAssetLoadFailed(true),
5417
+ onLoad: () => setAssetLoading(false)
5418
+ }
5419
+ )
5420
+ ] });
5421
+ }
5422
+ if (contentType.type === "video" && !assetLoadFailed) {
5423
+ return /* @__PURE__ */ jsxs30("div", { className: "relative flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
5424
+ (assetLoading || contentType.loading) && /* @__PURE__ */ jsx42(CollectibleAssetSkeleton, {}),
5425
+ /* @__PURE__ */ jsx42(
5426
+ "video",
5427
+ {
5428
+ ref: videoRef,
5429
+ className: cn(
5430
+ `absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${assetLoading ? "invisible" : "visible"}`,
5431
+ // we can't hide the video controls in safari, when user hovers over the video they show up. `pointer-events-none` is the only way to hide them on hover
5432
+ isSafari && "pointer-events-none"
5433
+ ),
5434
+ autoPlay: true,
5435
+ loop: true,
5436
+ controls: true,
5437
+ playsInline: true,
5438
+ muted: true,
5439
+ controlsList: "nodownload noremoteplayback nofullscreen ",
5440
+ onError: () => {
5441
+ setAssetLoadFailed(true);
5442
+ },
5443
+ onLoadedMetadata: () => {
5444
+ setAssetLoading(false);
5445
+ },
5446
+ "data-testid": "collectible-asset-video",
5447
+ children: /* @__PURE__ */ jsx42("source", { src: proxiedAssetUrl })
5448
+ }
5449
+ )
5450
+ ] });
5451
+ }
5452
+ return /* @__PURE__ */ jsxs30("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: [
5453
+ (assetLoading || contentType.loading) && /* @__PURE__ */ jsx42(CollectibleAssetSkeleton, {}),
5454
+ /* @__PURE__ */ jsx42(
5455
+ "img",
5456
+ {
5457
+ src: assetLoadFailed || contentType.failed ? placeholderImage : proxiedAssetUrl,
5458
+ alt: name || "Collectible",
5459
+ className: `absolute inset-0 h-full w-full object-cover transition-transform duration-200 ease-in-out group-hover:scale-hover ${assetLoading || contentType.loading ? "invisible" : "visible"}`,
5460
+ onError: () => setAssetLoadFailed(true),
5461
+ onLoad: () => setAssetLoading(false)
5462
+ }
5463
+ )
5464
+ ] });
5465
+ }
5466
+
5300
5467
  // src/react/ui/components/collectible-card/CollectibleCard.tsx
5301
- import { jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
5468
+ import { jsx as jsx43, jsxs as jsxs31 } from "react/jsx-runtime";
5302
5469
  function CollectibleSkeleton() {
5303
5470
  return /* @__PURE__ */ jsxs31(
5304
5471
  "div",
@@ -5306,7 +5473,7 @@ function CollectibleSkeleton() {
5306
5473
  "data-testid": "collectible-card-skeleton",
5307
5474
  className: "w-card-width overflow-hidden rounded-xl border border-border-base focus-visible:border-border-focus focus-visible:shadow-none focus-visible:outline-focus active:border-border-focus active:shadow-none",
5308
5475
  children: [
5309
- /* @__PURE__ */ jsx42("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: /* @__PURE__ */ jsx42(
5476
+ /* @__PURE__ */ jsx43("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: /* @__PURE__ */ jsx43(
5310
5477
  Skeleton11,
5311
5478
  {
5312
5479
  size: "lg",
@@ -5317,8 +5484,8 @@ function CollectibleSkeleton() {
5317
5484
  }
5318
5485
  ) }),
5319
5486
  /* @__PURE__ */ jsxs31("div", { className: "mt-2 flex flex-col gap-2 px-4 pb-4", children: [
5320
- /* @__PURE__ */ jsx42(Skeleton11, { size: "lg", className: "animate-shimmer" }),
5321
- /* @__PURE__ */ jsx42(Skeleton11, { size: "sm", className: "animate-shimmer" })
5487
+ /* @__PURE__ */ jsx43(Skeleton11, { size: "lg", className: "animate-shimmer" }),
5488
+ /* @__PURE__ */ jsx43(Skeleton11, { size: "sm", className: "animate-shimmer" })
5322
5489
  ] })
5323
5490
  ]
5324
5491
  }
@@ -5349,10 +5516,10 @@ function CollectibleCard({
5349
5516
  }
5350
5517
  });
5351
5518
  if (cardLoading) {
5352
- return /* @__PURE__ */ jsx42(CollectibleSkeleton, {});
5519
+ return /* @__PURE__ */ jsx43(CollectibleSkeleton, {});
5353
5520
  }
5354
5521
  const action = balance ? highestOffer && "Sell" /* SELL */ || !collectible?.listing && "Create listing" /* LIST */ || "Transfer" /* TRANSFER */ : collectible?.listing && "Buy" /* BUY */ || "Make an offer" /* OFFER */;
5355
- return /* @__PURE__ */ jsx42(
5522
+ return /* @__PURE__ */ jsx43(
5356
5523
  "div",
5357
5524
  {
5358
5525
  "data-testid": "collectible-card",
@@ -5363,8 +5530,8 @@ function CollectibleCard({
5363
5530
  onCollectibleClick?.(collectibleId);
5364
5531
  }
5365
5532
  },
5366
- children: /* @__PURE__ */ jsx42("div", { className: "group relative z-10 flex h-full w-full cursor-pointer flex-col items-start overflow-hidden rounded-xl border-none bg-none p-0 focus:outline-none [&:focus]:rounded-[10px] [&:focus]:outline-[3px] [&:focus]:outline-black [&:focus]:outline-offset-[-3px]", children: /* @__PURE__ */ jsxs31("article", { className: "w-full rounded-xl", children: [
5367
- /* @__PURE__ */ jsx42(
5533
+ children: /* @__PURE__ */ jsx43("div", { className: "group relative z-10 flex h-full w-full cursor-pointer flex-col items-start overflow-hidden rounded-xl border-none bg-none p-0 focus:outline-none [&:focus]:rounded-[10px] [&:focus]:outline-[3px] [&:focus]:outline-black [&:focus]:outline-offset-[-3px]", children: /* @__PURE__ */ jsxs31("article", { className: "w-full rounded-xl", children: [
5534
+ /* @__PURE__ */ jsx43(
5368
5535
  CollectibleAsset,
5369
5536
  {
5370
5537
  name: collectibleMetadata?.name || "",
@@ -5372,7 +5539,7 @@ function CollectibleCard({
5372
5539
  assetSrcPrefixUrl
5373
5540
  }
5374
5541
  ),
5375
- /* @__PURE__ */ jsx42(
5542
+ /* @__PURE__ */ jsx43(
5376
5543
  Footer,
5377
5544
  {
5378
5545
  name: collectibleMetadata?.name || "",
@@ -5385,7 +5552,7 @@ function CollectibleCard({
5385
5552
  decimals: collectibleMetadata?.decimals
5386
5553
  }
5387
5554
  ),
5388
- (highestOffer || collectible) && !balanceIsLoading && /* @__PURE__ */ jsx42("div", { className: "-bottom-action-offset absolute flex w-full items-center justify-center bg-overlay-light p-2 backdrop-blur transition-transform duration-200 ease-in-out group-hover:translate-y-[-44px]", children: /* @__PURE__ */ jsx42(
5555
+ (highestOffer || collectible) && !balanceIsLoading && /* @__PURE__ */ jsx43("div", { className: "-bottom-16 absolute flex w-full origin-bottom items-center justify-center bg-overlay-light p-2 backdrop-blur transition-transform duration-200 ease-in-out group-hover:translate-y-[-64px]", children: /* @__PURE__ */ jsx43(
5389
5556
  ActionButton,
5390
5557
  {
5391
5558
  chainId,
@@ -5414,4 +5581,4 @@ export {
5414
5581
  useSellModal,
5415
5582
  CollectibleCard
5416
5583
  };
5417
- //# sourceMappingURL=chunk-TGFX3TMV.js.map
5584
+ //# sourceMappingURL=chunk-7IYKUVC3.js.map