@0xsequence/marketplace-sdk 0.8.3 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/dist/{chunk-25CAMYCG.js → chunk-BB2PTJHI.js} +22 -20
  3. package/dist/chunk-BB2PTJHI.js.map +1 -0
  4. package/dist/{chunk-5ATGT5S4.js → chunk-EZFCQZHU.js} +14 -6
  5. package/dist/chunk-EZFCQZHU.js.map +1 -0
  6. package/dist/{chunk-DFI52A2E.js → chunk-KCLMSSPS.js} +364 -242
  7. package/dist/chunk-KCLMSSPS.js.map +1 -0
  8. package/dist/{chunk-XUNDLCEH.js → chunk-LDZZUYG7.js} +2 -2
  9. package/dist/{chunk-QTV77W42.js → chunk-SFSFIGHM.js} +45 -35
  10. package/dist/chunk-SFSFIGHM.js.map +1 -0
  11. package/dist/{chunk-FSJKN4YN.js → chunk-ZSCZLHKX.js} +194 -2
  12. package/dist/chunk-ZSCZLHKX.js.map +1 -0
  13. package/dist/{chunk-FH4TZRDV.js → chunk-ZVTG6US2.js} +2 -2
  14. package/dist/index.css +4 -4
  15. package/dist/index.css.map +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/{lowestListing-DUZ_nYml.d.ts → lowestListing-W7P4EkC3.d.ts} +34 -11
  18. package/dist/react/_internal/databeat/index.js +5 -5
  19. package/dist/react/_internal/index.d.ts +1 -1
  20. package/dist/react/_internal/index.js +3 -1
  21. package/dist/react/_internal/wagmi/index.d.ts +3 -2
  22. package/dist/react/_internal/wagmi/index.js +3 -1
  23. package/dist/react/hooks/index.d.ts +8 -5
  24. package/dist/react/hooks/index.js +6 -4
  25. package/dist/react/hooks/options/index.js +2 -2
  26. package/dist/react/index.d.ts +2 -2
  27. package/dist/react/index.js +9 -7
  28. package/dist/react/queries/index.d.ts +1 -1
  29. package/dist/react/queries/index.js +6 -2
  30. package/dist/react/ssr/index.js +1 -1
  31. package/dist/react/ui/components/collectible-card/index.d.ts +3 -2
  32. package/dist/react/ui/components/collectible-card/index.js +7 -7
  33. package/dist/react/ui/icons/index.js +1 -1
  34. package/dist/react/ui/index.js +7 -7
  35. package/dist/react/ui/modals/_internal/components/actionModal/index.js +5 -5
  36. package/dist/types/index.js +1 -1
  37. package/dist/utils/index.js +1 -1
  38. package/package.json +19 -19
  39. package/src/react/_internal/api/__mocks__/marketplace.msw.ts +35 -21
  40. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +1 -11
  41. package/src/react/_internal/wagmi/get-connectors.ts +27 -24
  42. package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +4 -9
  43. package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +5 -4
  44. package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +14 -10
  45. package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +115 -65
  46. package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +10 -7
  47. package/src/react/hooks/__tests__/useInventory.test.tsx +294 -0
  48. package/src/react/hooks/index.ts +1 -0
  49. package/src/react/hooks/useAutoSelectFeeOption.tsx +10 -3
  50. package/src/react/hooks/useCancelOrder.tsx +1 -0
  51. package/src/react/hooks/useCancelTransactionSteps.tsx +18 -4
  52. package/src/react/hooks/useGenerateOfferTransaction.tsx +11 -1
  53. package/src/react/hooks/useInventory.tsx +15 -0
  54. package/src/react/hooks/util/optimisticCancelUpdates.ts +115 -0
  55. package/src/react/queries/index.ts +1 -0
  56. package/src/react/queries/inventory.ts +303 -0
  57. package/src/react/queries/listBalances.ts +1 -8
  58. package/src/react/queries/listCollectibles.ts +12 -3
  59. package/src/react/ui/components/_internals/action-button/__tests__/ActionButtonBody.test.tsx +27 -94
  60. package/src/react/ui/components/_internals/action-button/__tests__/NonOwnerActions.test.tsx +59 -0
  61. package/src/react/ui/components/_internals/action-button/__tests__/OwnerActions.test.tsx +73 -0
  62. package/src/react/ui/components/_internals/action-button/__tests__/useActionButtonLogic.test.tsx +77 -0
  63. package/src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx +3 -2
  64. package/src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts +4 -3
  65. package/src/react/ui/components/collectible-card/CollectibleAsset.tsx +1 -0
  66. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +18 -12
  67. package/src/react/ui/components/collectible-card/__tests__/CollectibleAsset.test.tsx +200 -0
  68. package/src/react/ui/components/collectible-card/__tests__/CollectibleCard.test.tsx +92 -123
  69. package/src/react/ui/components/collectible-card/__tests__/Footer.test.tsx +136 -0
  70. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +2 -8
  71. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +74 -104
  72. package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +108 -78
  73. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +72 -135
  74. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +286 -0
  75. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +16 -4
  76. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/__tests__/index.test.tsx +35 -132
  77. package/src/react/ui/modals/_internal/components/floorPriceText/__tests__/FloorPriceText.test.tsx +199 -0
  78. package/src/react/ui/modals/_internal/components/priceInput/__tests__/PriceInput.test.tsx +55 -0
  79. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +1 -1
  80. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/ActionButtons.test.tsx +72 -0
  81. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/BalanceIndicator.test.tsx +50 -0
  82. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +193 -0
  83. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +2 -2
  84. package/test/const.ts +24 -0
  85. package/test/test-utils.tsx +85 -47
  86. package/.changeset/flat-parks-clean.md +0 -8
  87. package/.changeset/red-buckets-deny.md +0 -6
  88. package/.changeset/seven-doors-taste.md +0 -5
  89. package/dist/chunk-25CAMYCG.js.map +0 -1
  90. package/dist/chunk-5ATGT5S4.js.map +0 -1
  91. package/dist/chunk-DFI52A2E.js.map +0 -1
  92. package/dist/chunk-FSJKN4YN.js.map +0 -1
  93. package/dist/chunk-QTV77W42.js.map +0 -1
  94. package/src/react/ui/components/_internals/action-button/__tests__/ActionButton.test.tsx +0 -107
  95. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +0 -164
  96. /package/dist/{chunk-XUNDLCEH.js.map → chunk-LDZZUYG7.js.map} +0 -0
  97. /package/dist/{chunk-FH4TZRDV.js.map → chunk-ZVTG6US2.js.map} +0 -0
@@ -2,10 +2,10 @@
2
2
 
3
3
  import {
4
4
  ActionModal
5
- } from "./chunk-5ATGT5S4.js";
5
+ } from "./chunk-EZFCQZHU.js";
6
6
  import {
7
7
  useAnalytics
8
- } from "./chunk-FH4TZRDV.js";
8
+ } from "./chunk-ZVTG6US2.js";
9
9
  import {
10
10
  BellIcon_default,
11
11
  CalendarIcon_default,
@@ -33,7 +33,7 @@ import {
33
33
  useSwitchChainModal,
34
34
  useTransferTokens,
35
35
  useWallet
36
- } from "./chunk-DFI52A2E.js";
36
+ } from "./chunk-KCLMSSPS.js";
37
37
  import {
38
38
  DEFAULT_MARKETPLACE_FEE_PERCENTAGE
39
39
  } from "./chunk-Y63BOO6M.js";
@@ -1364,7 +1364,7 @@ function PriceInput({
1364
1364
  "div",
1365
1365
  {
1366
1366
  className: cn(
1367
- "relative flex w-full flex-col",
1367
+ "price-input relative flex w-full flex-col",
1368
1368
  disabled && "pointer-events-none opacity-50"
1369
1369
  ),
1370
1370
  children: [
@@ -4801,7 +4801,6 @@ import { observer as observer18 } from "@legendapp/state/react";
4801
4801
  // src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx
4802
4802
  import { useOpenConnectModal } from "@0xsequence/connect";
4803
4803
  import { Button as Button8 } from "@0xsequence/design-system";
4804
- import { useAccount as useAccount8 } from "wagmi";
4805
4804
 
4806
4805
  // src/react/ui/components/_internals/action-button/store.ts
4807
4806
  import { observable as observable9 } from "@legendapp/state";
@@ -4838,7 +4837,8 @@ function ActionButtonBody({
4838
4837
  icon,
4839
4838
  action
4840
4839
  }) {
4841
- const { address } = useAccount8();
4840
+ const { wallet } = useWallet();
4841
+ const address = wallet?.address;
4842
4842
  const { setOpenConnectModal } = useOpenConnectModal();
4843
4843
  const handleClick = (e) => {
4844
4844
  e.preventDefault();
@@ -4978,21 +4978,21 @@ function OwnerActions({
4978
4978
 
4979
4979
  // src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts
4980
4980
  import { useEffect as useEffect11 } from "react";
4981
- import { useAccount as useAccount9 } from "wagmi";
4982
4981
  var useActionButtonLogic = ({
4983
4982
  tokenId,
4984
4983
  owned,
4985
4984
  action,
4986
4985
  onCannotPerformAction
4987
4986
  }) => {
4988
- const { address } = useAccount9();
4987
+ const { wallet } = useWallet();
4988
+ const address = wallet?.address;
4989
4989
  const actionsThatOwnersCannotPerform = [
4990
4990
  "Buy" /* BUY */,
4991
4991
  "Make an offer" /* OFFER */
4992
4992
  ];
4993
4993
  const pendingActionType = actionButtonStore.pendingAction.type.get();
4994
4994
  useEffect11(() => {
4995
- if (owned && actionButtonStore.pendingAction.get() && address && !actionsThatOwnersCannotPerform.includes(action) && actionButtonStore.pendingAction.get()?.collectibleId === tokenId) {
4995
+ if (owned && actionButtonStore.pendingAction.get() && address && actionsThatOwnersCannotPerform.includes(action) && actionButtonStore.pendingAction.get()?.collectibleId === tokenId) {
4996
4996
  onCannotPerformAction?.(
4997
4997
  pendingActionType
4998
4998
  );
@@ -5086,6 +5086,7 @@ function CollectibleAssetSkeleton() {
5086
5086
  return /* @__PURE__ */ jsx40(
5087
5087
  Skeleton10,
5088
5088
  {
5089
+ "data-testid": "collectible-asset-skeleton",
5089
5090
  size: "lg",
5090
5091
  className: "absolute inset-0 h-full w-full animate-shimmer",
5091
5092
  style: {
@@ -5299,22 +5300,29 @@ var TokenTypeBalancePill = ({
5299
5300
  // src/react/ui/components/collectible-card/CollectibleCard.tsx
5300
5301
  import { jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
5301
5302
  function CollectibleSkeleton() {
5302
- return /* @__PURE__ */ jsxs31("div", { 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", children: [
5303
- /* @__PURE__ */ jsx42("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: /* @__PURE__ */ jsx42(
5304
- Skeleton11,
5305
- {
5306
- size: "lg",
5307
- className: "absolute inset-0 h-full w-full animate-shimmer",
5308
- style: {
5309
- borderRadius: 0
5310
- }
5311
- }
5312
- ) }),
5313
- /* @__PURE__ */ jsxs31("div", { className: "mt-2 flex flex-col gap-2 px-4 pb-4", children: [
5314
- /* @__PURE__ */ jsx42(Skeleton11, { size: "lg", className: "animate-shimmer" }),
5315
- /* @__PURE__ */ jsx42(Skeleton11, { size: "sm", className: "animate-shimmer" })
5316
- ] })
5317
- ] });
5303
+ return /* @__PURE__ */ jsxs31(
5304
+ "div",
5305
+ {
5306
+ "data-testid": "collectible-card-skeleton",
5307
+ 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
+ children: [
5309
+ /* @__PURE__ */ jsx42("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: /* @__PURE__ */ jsx42(
5310
+ Skeleton11,
5311
+ {
5312
+ size: "lg",
5313
+ className: "absolute inset-0 h-full w-full animate-shimmer",
5314
+ style: {
5315
+ borderRadius: 0
5316
+ }
5317
+ }
5318
+ ) }),
5319
+ /* @__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" })
5322
+ ] })
5323
+ ]
5324
+ }
5325
+ );
5318
5326
  }
5319
5327
  function CollectibleCard({
5320
5328
  collectibleId,
@@ -5322,30 +5330,32 @@ function CollectibleCard({
5322
5330
  collectionAddress,
5323
5331
  orderbookKind,
5324
5332
  collectionType,
5325
- lowestListing,
5333
+ collectible,
5326
5334
  onCollectibleClick,
5327
5335
  onOfferClick,
5328
5336
  balance,
5337
+ balanceIsLoading,
5329
5338
  cardLoading,
5330
5339
  onCannotPerformAction,
5331
5340
  assetSrcPrefixUrl
5332
5341
  }) {
5333
- const collectibleMetadata = lowestListing?.metadata;
5334
- const highestOffer = lowestListing?.offer;
5342
+ const collectibleMetadata = collectible?.metadata;
5343
+ const highestOffer = collectible?.offer;
5335
5344
  const { data: lowestListingCurrency } = useCurrency({
5336
5345
  chainId,
5337
- currencyAddress: lowestListing?.order?.priceCurrencyAddress,
5346
+ currencyAddress: collectible?.listing?.priceCurrencyAddress,
5338
5347
  query: {
5339
- enabled: !!lowestListing?.order?.priceCurrencyAddress
5348
+ enabled: !!collectible?.listing?.priceCurrencyAddress
5340
5349
  }
5341
5350
  });
5342
5351
  if (cardLoading) {
5343
5352
  return /* @__PURE__ */ jsx42(CollectibleSkeleton, {});
5344
5353
  }
5345
- const action = balance ? highestOffer && "Sell" /* SELL */ || !lowestListing?.order && "Create listing" /* LIST */ || "Transfer" /* TRANSFER */ : lowestListing?.order && "Buy" /* BUY */ || "Make an offer" /* OFFER */;
5354
+ const action = balance ? highestOffer && "Sell" /* SELL */ || !collectible?.listing && "Create listing" /* LIST */ || "Transfer" /* TRANSFER */ : collectible?.listing && "Buy" /* BUY */ || "Make an offer" /* OFFER */;
5346
5355
  return /* @__PURE__ */ jsx42(
5347
5356
  "div",
5348
5357
  {
5358
+ "data-testid": "collectible-card",
5349
5359
  className: "w-card-width overflow-hidden rounded-xl border border-border-base bg-background-primary focus-visible:border-border-focus focus-visible:shadow-focus-ring focus-visible:outline-focus active:border-border-focus active:shadow-active-ring",
5350
5360
  onClick: () => onCollectibleClick?.(collectibleId),
5351
5361
  onKeyDown: (e) => {
@@ -5369,13 +5379,13 @@ function CollectibleCard({
5369
5379
  type: collectionType,
5370
5380
  onOfferClick: (e) => onOfferClick?.({ order: highestOffer, e }),
5371
5381
  highestOffer,
5372
- lowestListingPriceAmount: lowestListing?.order?.priceAmount,
5382
+ lowestListingPriceAmount: collectible?.listing?.priceAmount,
5373
5383
  lowestListingCurrency,
5374
5384
  balance,
5375
5385
  decimals: collectibleMetadata?.decimals
5376
5386
  }
5377
5387
  ),
5378
- (highestOffer || lowestListing) && /* @__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(
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(
5379
5389
  ActionButton,
5380
5390
  {
5381
5391
  chainId,
@@ -5384,7 +5394,7 @@ function CollectibleCard({
5384
5394
  orderbookKind,
5385
5395
  action,
5386
5396
  highestOffer,
5387
- lowestListing: lowestListing?.order,
5397
+ lowestListing: collectible?.listing,
5388
5398
  owned: !!balance,
5389
5399
  onCannotPerformAction
5390
5400
  }
@@ -5404,4 +5414,4 @@ export {
5404
5414
  useSellModal,
5405
5415
  CollectibleCard
5406
5416
  };
5407
- //# sourceMappingURL=chunk-QTV77W42.js.map
5417
+ //# sourceMappingURL=chunk-SFSFIGHM.js.map