@0xsequence/marketplace-sdk 0.3.11 → 0.4.1

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 (133) hide show
  1. package/dist/{chunk-3LOJQCTV.js → chunk-5GDO4ZBC.js} +5 -4
  2. package/dist/{chunk-3LOJQCTV.js.map → chunk-5GDO4ZBC.js.map} +1 -1
  3. package/dist/{chunk-E3ZFT6WR.js → chunk-EVRILXOH.js} +12 -2
  4. package/dist/chunk-EVRILXOH.js.map +1 -0
  5. package/dist/{chunk-N5F6IEAK.js → chunk-GSDUAHL3.js} +1 -1
  6. package/dist/chunk-GSDUAHL3.js.map +1 -0
  7. package/dist/{chunk-IRN77TJW.js → chunk-IOTKCWOB.js} +925 -667
  8. package/dist/chunk-IOTKCWOB.js.map +1 -0
  9. package/dist/{chunk-KRMV6FJE.js → chunk-KNX2LER4.js} +5 -6
  10. package/dist/{chunk-4FC3IG7C.js.map → chunk-KNX2LER4.js.map} +1 -1
  11. package/dist/{chunk-SBVLWSRZ.js → chunk-LF44FCG5.js} +2 -2
  12. package/dist/{chunk-SBVLWSRZ.js.map → chunk-LF44FCG5.js.map} +1 -1
  13. package/dist/{chunk-4FC3IG7C.js → chunk-LSMQVX77.js} +5 -6
  14. package/dist/{chunk-KRMV6FJE.js.map → chunk-LSMQVX77.js.map} +1 -1
  15. package/dist/{chunk-B3LFJJVS.js → chunk-MIYMMP2K.js} +90 -40
  16. package/dist/chunk-MIYMMP2K.js.map +1 -0
  17. package/dist/{chunk-Z7NLKEXF.js → chunk-QMO2CUNM.js} +2 -2
  18. package/dist/{chunk-L6GSYPCR.js → chunk-RZSZNVEH.js} +5 -5
  19. package/dist/{chunk-L6GSYPCR.js.map → chunk-RZSZNVEH.js.map} +1 -1
  20. package/dist/chunk-T5T6JNB2.js +171 -0
  21. package/dist/chunk-T5T6JNB2.js.map +1 -0
  22. package/dist/chunk-UPLTM63S.js +435 -0
  23. package/dist/chunk-UPLTM63S.js.map +1 -0
  24. package/dist/{chunk-Y7YO5TLE.js → chunk-XXML5K3X.js} +5 -2
  25. package/dist/chunk-XXML5K3X.js.map +1 -0
  26. package/dist/{create-config-CgtmCzvb.d.ts → create-config-8sffBvlt.d.ts} +1 -1
  27. package/dist/index.js +5 -5
  28. package/dist/react/_internal/api/index.js +2 -2
  29. package/dist/react/_internal/index.d.ts +1 -1
  30. package/dist/react/_internal/index.js +3 -3
  31. package/dist/react/_internal/wagmi/index.d.ts +1 -1
  32. package/dist/react/_internal/wagmi/index.js +2 -2
  33. package/dist/react/hooks/index.d.ts +666 -77
  34. package/dist/react/hooks/index.js +8 -8
  35. package/dist/react/index.css +17 -0
  36. package/dist/react/index.css.map +1 -1
  37. package/dist/react/index.d.ts +1 -1
  38. package/dist/react/index.js +12 -12
  39. package/dist/react/ssr/index.js +1 -1
  40. package/dist/react/ssr/index.js.map +1 -1
  41. package/dist/react/ui/components/index.css +17 -0
  42. package/dist/react/ui/components/index.css.map +1 -1
  43. package/dist/react/ui/components/index.js +12 -12
  44. package/dist/react/ui/icons/index.js +4 -4
  45. package/dist/react/ui/icons/index.js.map +1 -1
  46. package/dist/react/ui/index.css +17 -0
  47. package/dist/react/ui/index.css.map +1 -1
  48. package/dist/react/ui/index.js +12 -12
  49. package/dist/react/ui/modals/_internal/components/actionModal/index.css +22 -0
  50. package/dist/react/ui/modals/_internal/components/actionModal/index.css.map +1 -1
  51. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +17 -9
  52. package/dist/react/ui/modals/_internal/components/actionModal/index.js +8 -4
  53. package/dist/react/ui/styles/index.d.ts +1 -1
  54. package/dist/styles/index.d.ts +1 -1
  55. package/dist/styles/index.js +2 -2
  56. package/dist/types/index.js +3 -3
  57. package/dist/utils/index.js +2 -2
  58. package/package.json +25 -25
  59. package/src/react/_internal/api/marketplace-api.ts +3 -2
  60. package/src/react/_internal/transaction-machine/execute-transaction.ts +41 -19
  61. package/src/react/_internal/transaction-machine/useTransactionMachine.ts +43 -8
  62. package/src/react/hooks/useBuyCollectable.tsx +15 -8
  63. package/src/react/hooks/useCancelOrder.tsx +15 -7
  64. package/src/react/hooks/useCreateListing.tsx +75 -11
  65. package/src/react/hooks/useCurrencies.tsx +1 -2
  66. package/src/react/hooks/useCurrencyBalance.tsx +1 -1
  67. package/src/react/hooks/useCurrencyOptions.tsx +1 -1
  68. package/src/react/hooks/useMakeOffer.tsx +74 -12
  69. package/src/react/hooks/useSell.tsx +73 -12
  70. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +1 -7
  71. package/src/react/ui/components/_internals/action-button/types.ts +7 -0
  72. package/src/react/ui/components/_internals/custom-select/CustomSelect.tsx +18 -15
  73. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +5 -7
  74. package/src/react/ui/components/collectible-card/Footer.tsx +5 -7
  75. package/src/react/ui/components/collectible-card/styles.css.ts +1 -1
  76. package/src/react/ui/icons/ArrowUp.tsx +3 -0
  77. package/src/react/ui/icons/Bell.tsx +3 -0
  78. package/src/react/ui/icons/CalendarIcon.tsx +3 -0
  79. package/src/react/ui/icons/DiamondEye.tsx +3 -0
  80. package/src/react/ui/icons/InfoIcon.tsx +3 -0
  81. package/src/react/ui/icons/InventoryIcon.tsx +3 -0
  82. package/src/react/ui/icons/MinusIcon.tsx +3 -0
  83. package/src/react/ui/icons/PlusIcon.tsx +3 -0
  84. package/src/react/ui/icons/PositiveCircleIcon.tsx +3 -0
  85. package/src/react/ui/modals/BuyModal/index.tsx +25 -8
  86. package/src/react/ui/modals/CreateListingModal/_store.ts +5 -2
  87. package/src/react/ui/modals/CreateListingModal/index.tsx +66 -25
  88. package/src/react/ui/modals/MakeOfferModal/_store.ts +5 -2
  89. package/src/react/ui/modals/MakeOfferModal/index.tsx +87 -67
  90. package/src/react/ui/modals/SellModal/index.tsx +107 -57
  91. package/src/react/ui/modals/TransferModal/_store.ts +1 -1
  92. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +4 -2
  93. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +5 -5
  94. package/src/react/ui/modals/TransferModal/index.tsx +1 -1
  95. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +29 -8
  96. package/src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx +15 -5
  97. package/src/react/ui/modals/_internal/components/actionModal/LoadingModal.tsx +15 -5
  98. package/src/react/ui/modals/_internal/components/actionModal/store.ts +6 -0
  99. package/src/react/ui/modals/_internal/components/calendar/index.tsx +1 -1
  100. package/src/react/ui/modals/_internal/components/currencyImage/index.tsx +3 -3
  101. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +11 -16
  102. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +14 -19
  103. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +34 -12
  104. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +3 -3
  105. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +7 -4
  106. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -0
  107. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +10 -8
  108. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +9 -5
  109. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +7 -4
  110. package/src/react/ui/modals/_internal/components/transactionPreview/useTransactionPreviewTitle.tsx +9 -11
  111. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +60 -31
  112. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +6 -2
  113. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getFormattedType.ts +1 -1
  114. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts +8 -2
  115. package/src/react/ui/modals/_internal/components/transactionStatusModal/util/getTitle.ts +12 -3
  116. package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/index.tsx +146 -0
  117. package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/store.ts +12 -0
  118. package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/styles.css.ts +53 -0
  119. package/src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx +117 -0
  120. package/src/utils/_internal/error/transaction.ts +12 -2
  121. package/src/utils/price.ts +3 -4
  122. package/tsconfig.json +1 -21
  123. package/tsconfig.tsbuildinfo +1 -1
  124. package/dist/chunk-B3LFJJVS.js.map +0 -1
  125. package/dist/chunk-E3ZFT6WR.js.map +0 -1
  126. package/dist/chunk-FFCNYF3S.js +0 -153
  127. package/dist/chunk-FFCNYF3S.js.map +0 -1
  128. package/dist/chunk-IRN77TJW.js.map +0 -1
  129. package/dist/chunk-N5F6IEAK.js.map +0 -1
  130. package/dist/chunk-NMCGA2TB.js +0 -98
  131. package/dist/chunk-NMCGA2TB.js.map +0 -1
  132. package/dist/chunk-Y7YO5TLE.js.map +0 -1
  133. /package/dist/{chunk-Z7NLKEXF.js.map → chunk-QMO2CUNM.js.map} +0 -0
@@ -11,12 +11,11 @@ import type {
11
11
  OrderbookKind,
12
12
  } from '../../../_internal';
13
13
  import { useCurrencies, useHighestOffer } from '../../../hooks';
14
+ import { useCurrencyOptions } from '../../../hooks/useCurrencyOptions';
14
15
  import SvgDiamondEyeIcon from '../../icons/DiamondEye';
15
16
  import ChessTileImage from '../../images/chess-tile.png';
16
- import {
17
- ActionButton,
18
- CollectibleCardAction,
19
- } from '../_internals/action-button/ActionButton';
17
+ import { ActionButton } from '../_internals/action-button/ActionButton';
18
+ import { CollectibleCardAction } from '../_internals/action-button/types';
20
19
  import { Footer } from './Footer';
21
20
  import {
22
21
  actionWrapper,
@@ -24,7 +23,6 @@ import {
24
23
  collectibleImage,
25
24
  collectibleTileWrapper,
26
25
  } from './styles.css';
27
- import { useCurrencyOptions } from '../../../hooks/useCurrencyOptions';
28
26
 
29
27
  function CollectibleSkeleton() {
30
28
  return (
@@ -101,7 +99,7 @@ export function CollectibleCard({
101
99
  }
102
100
 
103
101
  const action = (
104
- !!balance
102
+ balance
105
103
  ? (highestOffer?.order && CollectibleCardAction.SELL) ||
106
104
  (!lowestListing?.order && CollectibleCardAction.LIST) ||
107
105
  CollectibleCardAction.TRANSFER
@@ -161,7 +159,7 @@ export function CollectibleCard({
161
159
  />
162
160
 
163
161
  <Footer
164
- name={name!}
162
+ name={name || ''}
165
163
  type={collectionType}
166
164
  onOfferClick={() => onOfferClick?.({ order: highestOffer?.order })}
167
165
  highestOffer={highestOffer?.order}
@@ -30,10 +30,10 @@ export const Footer = ({
30
30
  const listed = !!lowestListingPriceAmount && !!lowestListingCurrency;
31
31
 
32
32
  if (name.length > 15 && highestOffer) {
33
- name = name.substring(0, 13) + '...';
33
+ name = `${name.substring(0, 13)}...`;
34
34
  }
35
35
  if (name.length > 17 && !highestOffer) {
36
- name = name.substring(0, 17) + '...';
36
+ name = `${name.substring(0, 17)}...`;
37
37
  }
38
38
 
39
39
  return (
@@ -94,12 +94,10 @@ export const Footer = ({
94
94
  fontFamily="body"
95
95
  >
96
96
  {listed &&
97
- formatUnits(
97
+ `${formatUnits(
98
98
  BigInt(lowestListingPriceAmount),
99
99
  lowestListingCurrency.decimals,
100
- ) +
101
- ' ' +
102
- lowestListingCurrency.symbol}
100
+ )} ${lowestListingCurrency.symbol}`}
103
101
 
104
102
  {!listed && 'Not listed yet'}
105
103
  </Text>
@@ -116,7 +114,7 @@ const TokenTypeBalancePill = ({
116
114
  }: { balance?: string; type: ContractType }) => {
117
115
  const displayText =
118
116
  type === ContractType.ERC1155
119
- ? !!balance
117
+ ? balance
120
118
  ? `Owned: ${balance}`
121
119
  : 'ERC-1155'
122
120
  : 'ERC-721';
@@ -21,7 +21,7 @@ export const collectibleTileWrapper = style({
21
21
  background: 'none',
22
22
  position: 'relative',
23
23
  selectors: {
24
- [`&:focus`]: {
24
+ '&:focus': {
25
25
  outline: 'none',
26
26
  },
27
27
  },
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 12 12"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-label="Arrow up"
11
13
  >
14
+ <title>Arrow up icon</title>
12
15
  <path
13
16
  d="M8.65039 6.03638L9.28679 5.39999L5.96859 2.08179L2.65039 5.39999L3.28679 6.03638L5.51859 3.80458V9.91822H6.41859V3.80458L8.65039 6.03638Z"
14
17
  fill="#D1D1D1"
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 17 17"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-labelledby="bell-title"
11
13
  >
14
+ <title id="bell-title">Notification Bell</title>
12
15
  <path
13
16
  fillRule="evenodd"
14
17
  clipRule="evenodd"
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 20 20"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-label="Calendar icon"
11
13
  >
14
+ <title>Calendar icon</title>
12
15
  <path
13
16
  d="M4.57634 17.5C3.73146 17.5 3.08946 17.2816 2.65034 16.8449C2.21678 16.4081 2 15.7586 2 14.8965V5.10352C2 4.24135 2.21678 3.59189 2.65034 3.15513C3.08946 2.71838 3.73146 2.5 4.57634 2.5H15.4237C16.2741 2.5 16.9161 2.72121 17.3497 3.16364C17.7832 3.6004 18 4.24702 18 5.10352V14.8965C18 15.753 17.7832 16.3996 17.3497 16.8364C16.9161 17.2788 16.2741 17.5 15.4237 17.5H4.57634ZM4.55133 15.9515H15.4403C15.7738 15.9515 16.0295 15.8636 16.2074 15.6877C16.3908 15.5062 16.4825 15.2396 16.4825 14.888V7.44328C16.4825 7.08593 16.3908 6.81934 16.2074 6.64351C16.0295 6.46767 15.7738 6.37975 15.4403 6.37975H4.55133C4.21782 6.37975 3.96213 6.46767 3.78426 6.64351C3.61195 6.81934 3.52579 7.08593 3.52579 7.44328V14.888C3.52579 15.2396 3.61195 15.5062 3.78426 15.6877C3.96213 15.8636 4.21782 15.9515 4.55133 15.9515ZM8.48671 9.17896C8.34775 9.17896 8.25048 9.15343 8.19489 9.10238C8.13931 9.05133 8.11152 8.95207 8.11152 8.80459V8.33664C8.11152 8.19484 8.13931 8.09841 8.19489 8.04736C8.25048 7.99064 8.34775 7.96228 8.48671 7.96228H8.94528C9.0898 7.96228 9.18708 7.99064 9.2371 8.04736C9.29269 8.09841 9.32048 8.19484 9.32048 8.33664V8.80459C9.32048 8.95207 9.29269 9.05133 9.2371 9.10238C9.18708 9.15343 9.0898 9.17896 8.94528 9.17896H8.48671ZM11.0714 9.17896C10.9269 9.17896 10.8268 9.15343 10.7712 9.10238C10.7212 9.05133 10.6962 8.95207 10.6962 8.80459V8.33664C10.6962 8.19484 10.7212 8.09841 10.7712 8.04736C10.8268 7.99064 10.9269 7.96228 11.0714 7.96228H11.5383C11.6773 7.96228 11.7745 7.99064 11.8301 8.04736C11.8857 8.09841 11.9135 8.19484 11.9135 8.33664V8.80459C11.9135 8.95207 11.8857 9.05133 11.8301 9.10238C11.7745 9.15343 11.6773 9.17896 11.5383 9.17896H11.0714ZM13.6477 9.17896C13.5088 9.17896 13.4115 9.15343 13.3559 9.10238C13.3003 9.05133 13.2725 8.95207 13.2725 8.80459V8.33664C13.2725 8.19484 13.3003 8.09841 13.3559 8.04736C13.4115 7.99064 13.5088 7.96228 13.6477 7.96228H14.1146C14.2592 7.96228 14.3564 7.99064 14.4065 8.04736C14.462 8.09841 14.4898 8.19484 14.4898 8.33664V8.80459C14.4898 8.95207 14.462 9.05133 14.4065 9.10238C14.3564 9.15343 14.2592 9.17896 14.1146 9.17896H13.6477ZM5.90203 11.7825C5.75751 11.7825 5.65746 11.7541 5.60188 11.6974C5.55185 11.6407 5.52684 11.5442 5.52684 11.4081V10.9317C5.52684 10.7842 5.55185 10.6849 5.60188 10.6339C5.65746 10.5828 5.75751 10.5573 5.90203 10.5573H6.36894C6.5079 10.5573 6.60518 10.5828 6.66076 10.6339C6.71635 10.6849 6.74414 10.7842 6.74414 10.9317V11.4081C6.74414 11.5442 6.71635 11.6407 6.66076 11.6974C6.60518 11.7541 6.5079 11.7825 6.36894 11.7825H5.90203ZM8.48671 11.7825C8.34775 11.7825 8.25048 11.7541 8.19489 11.6974C8.13931 11.6407 8.11152 11.5442 8.11152 11.4081V10.9317C8.11152 10.7842 8.13931 10.6849 8.19489 10.6339C8.25048 10.5828 8.34775 10.5573 8.48671 10.5573H8.94528C9.0898 10.5573 9.18708 10.5828 9.2371 10.6339C9.29269 10.6849 9.32048 10.7842 9.32048 10.9317V11.4081C9.32048 11.5442 9.29269 11.6407 9.2371 11.6974C9.18708 11.7541 9.0898 11.7825 8.94528 11.7825H8.48671ZM11.0714 11.7825C10.9269 11.7825 10.8268 11.7541 10.7712 11.6974C10.7212 11.6407 10.6962 11.5442 10.6962 11.4081V10.9317C10.6962 10.7842 10.7212 10.6849 10.7712 10.6339C10.8268 10.5828 10.9269 10.5573 11.0714 10.5573H11.5383C11.6773 10.5573 11.7745 10.5828 11.8301 10.6339C11.8857 10.6849 11.9135 10.7842 11.9135 10.9317V11.4081C11.9135 11.5442 11.8857 11.6407 11.8301 11.6974C11.7745 11.7541 11.6773 11.7825 11.5383 11.7825H11.0714ZM13.6477 11.7825C13.5088 11.7825 13.4115 11.7541 13.3559 11.6974C13.3003 11.6407 13.2725 11.5442 13.2725 11.4081V10.9317C13.2725 10.7842 13.3003 10.6849 13.3559 10.6339C13.4115 10.5828 13.5088 10.5573 13.6477 10.5573H14.1146C14.2592 10.5573 14.3564 10.5828 14.4065 10.6339C14.462 10.6849 14.4898 10.7842 14.4898 10.9317V11.4081C14.4898 11.5442 14.462 11.6407 14.4065 11.6974C14.3564 11.7541 14.2592 11.7825 14.1146 11.7825H13.6477ZM5.90203 14.369C5.75751 14.369 5.65746 14.3434 5.60188 14.2924C5.55185 14.2414 5.52684 14.1421 5.52684 13.9946V13.5267C5.52684 13.3849 5.55185 13.2884 5.60188 13.2374C5.65746 13.1807 5.75751 13.1523 5.90203 13.1523H6.36894C6.5079 13.1523 6.60518 13.1807 6.66076 13.2374C6.71635 13.2884 6.74414 13.3849 6.74414 13.5267V13.9946C6.74414 14.1421 6.71635 14.2414 6.66076 14.2924C6.60518 14.3434 6.5079 14.369 6.36894 14.369H5.90203ZM8.48671 14.369C8.34775 14.369 8.25048 14.3434 8.19489 14.2924C8.13931 14.2414 8.11152 14.1421 8.11152 13.9946V13.5267C8.11152 13.3849 8.13931 13.2884 8.19489 13.2374C8.25048 13.1807 8.34775 13.1523 8.48671 13.1523H8.94528C9.0898 13.1523 9.18708 13.1807 9.2371 13.2374C9.29269 13.2884 9.32048 13.3849 9.32048 13.5267V13.9946C9.32048 14.1421 9.29269 14.2414 9.2371 14.2924C9.18708 14.3434 9.0898 14.369 8.94528 14.369H8.48671ZM11.0714 14.369C10.9269 14.369 10.8268 14.3434 10.7712 14.2924C10.7212 14.2414 10.6962 14.1421 10.6962 13.9946V13.5267C10.6962 13.3849 10.7212 13.2884 10.7712 13.2374C10.8268 13.1807 10.9269 13.1523 11.0714 13.1523H11.5383C11.6773 13.1523 11.7745 13.1807 11.8301 13.2374C11.8857 13.2884 11.9135 13.3849 11.9135 13.5267V13.9946C11.9135 14.1421 11.8857 14.2414 11.8301 14.2924C11.7745 14.3434 11.6773 14.369 11.5383 14.369H11.0714Z"
14
17
  fill="white"
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 16 12"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-labelledby="diamond-eye-title"
11
13
  >
14
+ <title id="diamond-eye-title">Diamond Eye Icon</title>
12
15
  <path
13
16
  fillRule="evenodd"
14
17
  clipRule="evenodd"
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 20 20"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-label="Information"
11
13
  >
14
+ <title>Information icon</title>
12
15
  <path d="M10.75 8.75V13.75H9.25V8.75H10.75Z" fill="white" />
13
16
  <path
14
17
  d="M9.37508 7.47656C9.55997 7.65885 9.78263 7.75 10.043 7.75C10.2097 7.75 10.3634 7.70833 10.504 7.625C10.6446 7.53906 10.7579 7.42578 10.8438 7.28516C10.9324 7.14193 10.9779 6.98438 10.9805 6.8125C10.9779 6.55729 10.8829 6.33854 10.6954 6.15625C10.5079 5.97396 10.2904 5.88281 10.043 5.88281C9.78263 5.88281 9.55997 5.97396 9.37508 6.15625C9.19279 6.33854 9.10294 6.55729 9.10555 6.8125C9.10294 7.07031 9.19279 7.29167 9.37508 7.47656Z"
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 20 20"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-label="Inventory"
11
13
  >
14
+ <title>Inventory icon</title>
12
15
  <path
13
16
  d="M2 4C2 2.89543 2.85961 2 3.92 2H6.48C7.54039 2 8.4 2.89543 8.4 4V6.66667C8.4 7.77124 7.54039 8.66667 6.48 8.66667H3.92C2.85961 8.66667 2 7.77124 2 6.66667V4Z"
14
17
  fill="white"
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 16 16"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-labelledby="minus-title"
11
13
  >
14
+ <title id="minus-title">Minus Icon</title>
12
15
  <path
13
16
  fillRule="evenodd"
14
17
  clipRule="evenodd"
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 16 16"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-labelledby="plus-title"
11
13
  >
14
+ <title id="plus-title">Plus Icon</title>
12
15
  <path
13
16
  d="M8.65529 7.45725V2.40039H7.45529V7.45724H2.39844V8.65725H7.45529V13.7141H8.65529V8.65725H13.7121V7.45725H8.65529Z"
14
17
  fill="white"
@@ -8,7 +8,10 @@ const Svg = () => (
8
8
  viewBox="0 0 24 24"
9
9
  fill="none"
10
10
  xmlns="http://www.w3.org/2000/svg"
11
+ role="img"
12
+ aria-labelledby="positive-circle-title"
11
13
  >
14
+ <title id="positive-circle-title">Positive Circle Icon</title>
12
15
  <path
13
16
  d="M21.6004 11.9999C21.6004 17.3018 17.3023 21.5999 12.0004 21.5999C6.69846 21.5999 2.40039 17.3018 2.40039 11.9999C2.40039 6.69797 6.69846 2.3999 12.0004 2.3999C17.3023 2.3999 21.6004 6.69797 21.6004 11.9999Z"
14
17
  fill="#14A554"
@@ -1,19 +1,19 @@
1
- import type { TokenMetadata } from '@0xsequence/indexer';
2
1
  import { Box, Text, TokenImage } from '@0xsequence/design-system';
2
+ import type { TokenMetadata } from '@0xsequence/indexer';
3
3
  import { Show, observer, useSelector } from '@legendapp/state/react';
4
4
  import { useEffect } from 'react';
5
5
  import type { Address, Hex } from 'viem';
6
+ import { formatUnits, parseUnits } from 'viem';
6
7
  import { ContractType, type Order } from '../../../_internal';
7
8
  import type { BuyInput } from '../../../_internal/transaction-machine/execute-transaction';
8
9
  import { useCollectible, useCollection } from '../../../hooks';
10
+ import { useCurrencies } from '../../../hooks';
9
11
  import { useBuyCollectable } from '../../../hooks/useBuyCollectable';
12
+ import { useCurrencyOptions } from '../../../hooks/useCurrencyOptions';
10
13
  import QuantityInput from '..//_internal/components/quantityInput';
11
14
  import { ActionModal } from '../_internal/components/actionModal';
12
15
  import type { ModalCallbacks } from '../_internal/types';
13
16
  import { buyModal$ } from './_store';
14
- import { formatUnits, parseUnits } from 'viem';
15
- import { useCurrencies } from '../../../hooks';
16
- import { useCurrencyOptions } from '../../../hooks/useCurrencyOptions';
17
17
 
18
18
  export type ShowBuyModalArgs = {
19
19
  chainId: string;
@@ -43,6 +43,7 @@ export const BuyModalContent = () => {
43
43
  ) as Hex;
44
44
  const collectibleId = useSelector(buyModal$.state.order.tokenId);
45
45
  const modalId = useSelector(buyModal$.state.modalId);
46
+ const callbacks = useSelector(buyModal$.callbacks);
46
47
 
47
48
  const { data: collection } = useCollection({
48
49
  chainId,
@@ -52,9 +53,23 @@ export const BuyModalContent = () => {
52
53
  const { buy, isLoading } = useBuyCollectable({
53
54
  chainId,
54
55
  collectionAddress,
55
- onError: buyModal$.callbacks.get()?.onError,
56
+ enabled: buyModal$.isOpen.get(),
57
+ onSwitchChainRefused: () => {
58
+ buyModal$.close();
59
+ },
60
+ onError: (error) => {
61
+ if (callbacks?.onError) {
62
+ callbacks.onError(error);
63
+ } else {
64
+ console.debug('onError callback not provided', error);
65
+ }
66
+ },
56
67
  onSuccess: (hash) => {
57
- buyModal$.callbacks.get()?.onSuccess?.(hash);
68
+ if (callbacks?.onSuccess) {
69
+ callbacks.onSuccess(hash);
70
+ } else {
71
+ console.debug('onSuccess callback not provided', hash);
72
+ }
58
73
  buyModal$.close();
59
74
  },
60
75
  });
@@ -65,7 +80,7 @@ export const BuyModalContent = () => {
65
80
  collectibleId,
66
81
  });
67
82
 
68
- if (modalId == 0 || !collection || !collectable || !buy) return null;
83
+ if (modalId === 0 || !collection || !collectable || !buy) return null;
69
84
 
70
85
  return collection.type === ContractType.ERC721 ? (
71
86
  <CheckoutModal
@@ -101,6 +116,7 @@ function CheckoutModal({
101
116
  order,
102
117
  isLoading,
103
118
  }: CheckoutModalProps) {
119
+ // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
104
120
  useEffect(() => {
105
121
  const executeBuy = () => {
106
122
  if (isLoading) return;
@@ -147,7 +163,8 @@ const ERC1155QuantityModal = observer(
147
163
 
148
164
  return (
149
165
  <ActionModal
150
- store={buyModal$}
166
+ isOpen={buyModal$.isOpen.get()}
167
+ chainId={order.chainId}
151
168
  onClose={() => buyModal$.close()}
152
169
  title="Select Quantity"
153
170
  ctas={[
@@ -1,7 +1,7 @@
1
1
  import { observable } from '@legendapp/state';
2
2
  import { addDays } from 'date-fns/addDays';
3
3
  import type { Hash, Hex } from 'viem';
4
- import { OrderbookKind, type Currency } from '../../../../types';
4
+ import { type Currency, OrderbookKind } from '../../../../types';
5
5
  import type { ModalCallbacks } from '../_internal/types';
6
6
 
7
7
  const initialState = {
@@ -13,9 +13,12 @@ const initialState = {
13
13
  collectionName: '',
14
14
  collectionType: undefined,
15
15
  listingPrice: {
16
- amountRaw: '0',
16
+ // to see if approval is needed when modal opens
17
+ amountRaw: '1',
17
18
  currency: {} as Currency,
18
19
  },
20
+ // to track if the user has changed the price, so we know if it's 1 default or user input
21
+ listingPriceChanged: false,
19
22
  quantity: '1',
20
23
  invalidQuantity: false,
21
24
  expiry: new Date(addDays(new Date(), 7).toJSON()),
@@ -1,14 +1,16 @@
1
1
  import { Box } from '@0xsequence/design-system';
2
2
  import { Show, observer } from '@legendapp/state/react';
3
3
  import type { QueryKey } from '@tanstack/react-query';
4
+ import { useEffect, useState } from 'react';
4
5
  import type { Hash, Hex } from 'viem';
5
6
  import { parseUnits } from 'viem';
6
7
  import { useAccount } from 'wagmi';
7
8
  import {
8
9
  type ContractType,
9
- OrderbookKind,
10
+ type OrderbookKind,
10
11
  collectableKeys,
11
12
  } from '../../../_internal';
13
+ import { TransactionType } from '../../../_internal/transaction-machine/execute-transaction';
12
14
  import {
13
15
  useBalanceOfCollectible,
14
16
  useCollectible,
@@ -30,7 +32,6 @@ import TransactionDetails from '../_internal/components/transactionDetails';
30
32
  import { useTransactionStatusModal } from '../_internal/components/transactionStatusModal';
31
33
  import type { ModalCallbacks } from '../_internal/types';
32
34
  import { createListingModal$ } from './_store';
33
- import { TransactionType } from '../../../_internal/transaction-machine/execute-transaction';
34
35
 
35
36
  export type ShowCreateListingModalArgs = {
36
37
  collectionAddress: Hex;
@@ -73,9 +74,12 @@ export const Modal = observer(
73
74
  collectionAddress,
74
75
  chainId,
75
76
  listingPrice,
77
+ listingPriceChanged,
76
78
  collectibleId,
77
79
  orderbookKind,
80
+ callbacks,
78
81
  } = state;
82
+ const currencyAddress = listingPrice.currency.contractAddress;
79
83
  const {
80
84
  data: collectible,
81
85
  isLoading: collectableIsLoading,
@@ -85,6 +89,7 @@ export const Modal = observer(
85
89
  collectionAddress,
86
90
  collectibleId,
87
91
  });
92
+
88
93
  const {
89
94
  data: collection,
90
95
  isLoading: collectionIsLoading,
@@ -93,6 +98,8 @@ export const Modal = observer(
93
98
  chainId,
94
99
  collectionAddress,
95
100
  });
101
+ const [approvalExecutedSuccess, setApprovalExecutedSuccess] =
102
+ useState(false);
96
103
 
97
104
  const { address } = useAccount();
98
105
 
@@ -100,35 +107,40 @@ export const Modal = observer(
100
107
  chainId,
101
108
  collectionAddress,
102
109
  collectableId: collectibleId,
103
- userAddress: address!,
110
+ userAddress: address ?? undefined,
104
111
  });
105
112
 
106
- const { getListingSteps, isLoading: machineLoading } = useCreateListing({
113
+ const { getListingSteps, isLoading: machineLoading, createListing} = useCreateListing({
107
114
  orderbookKind,
108
115
  chainId,
109
116
  collectionAddress,
110
- onTransactionSent: (hash) => {
111
- if (!hash) return;
117
+ enabled: createListingModal$.isOpen.get(),
118
+ onSwitchChainRefused: () => createListingModal$.close(),
119
+ onApprovalSuccess: () => setApprovalExecutedSuccess(true),
120
+ onTransactionSent: (hash, orderId) => {
121
+ if (!hash && !orderId) return;
122
+
112
123
  showTransactionStatusModal({
113
124
  hash,
125
+ orderId,
114
126
  collectionAddress,
115
127
  chainId,
116
128
  price: createListingModal$.listingPrice.get(),
117
129
  collectibleId,
118
130
  type: TransactionType.LISTING,
119
131
  queriesToInvalidate: collectableKeys.all as unknown as QueryKey[],
132
+ callbacks,
120
133
  });
121
134
  createListingModal$.close();
122
135
  },
123
- onError: (error) => {
124
- if (typeof createListingModal$.callbacks?.onError === 'function') {
125
- createListingModal$.onError(error);
126
- } else {
127
- console.debug('onError callback not provided:', error);
128
- }
129
- },
130
136
  });
131
137
 
138
+ useEffect(() => {
139
+ if (!currencyAddress) return;
140
+
141
+ refreshSteps();
142
+ }, [currencyAddress]);
143
+
132
144
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
133
145
  const handleStepExecution = async (execute?: any) => {
134
146
  if (!execute) return;
@@ -136,14 +148,19 @@ export const Modal = observer(
136
148
  await refreshSteps();
137
149
  await execute();
138
150
  } catch (error) {
139
- createListingModal$.onError?.(error as Error);
151
+ if (callbacks?.onError) {
152
+ callbacks.onError(error as Error);
153
+ } else {
154
+ console.debug('onError callback not provided:', error);
155
+ }
140
156
  }
141
157
  };
142
158
 
143
159
  if (collectableIsLoading || collectionIsLoading || machineLoading) {
144
160
  return (
145
161
  <LoadingModal
146
- store={createListingModal$}
162
+ isOpen={createListingModal$.isOpen.get()}
163
+ chainId={Number(chainId)}
147
164
  onClose={createListingModal$.close}
148
165
  title="List item for sale"
149
166
  />
@@ -153,7 +170,8 @@ export const Modal = observer(
153
170
  if (collectableIsError || collectionIsError) {
154
171
  return (
155
172
  <ErrorModal
156
- store={createListingModal$}
173
+ isOpen={createListingModal$.isOpen.get()}
174
+ chainId={Number(chainId)}
157
175
  onClose={createListingModal$.close}
158
176
  title="List item for sale"
159
177
  />
@@ -164,7 +182,7 @@ export const Modal = observer(
164
182
  Math.floor(date.getTime() / 1000).toString();
165
183
 
166
184
  const { isLoading, steps, refreshSteps } = getListingSteps({
167
- contractType: collection!.type as ContractType,
185
+ contractType: collection?.type as ContractType,
168
186
  listing: {
169
187
  tokenId: collectibleId,
170
188
  quantity: parseUnits(
@@ -176,31 +194,51 @@ export const Modal = observer(
176
194
  pricePerToken: listingPrice.amountRaw,
177
195
  },
178
196
  });
197
+ const approvalNeeded = steps?.approval.isPending;
179
198
 
180
199
  const ctas = [
181
200
  {
182
201
  label: 'Approve TOKEN',
183
202
  onClick: () => handleStepExecution(() => steps?.approval.execute()),
184
- hidden: !steps?.approval.isPending,
185
- pending: steps?.approval.isExecuting,
203
+ hidden: !approvalNeeded || approvalExecutedSuccess,
204
+ pending: steps?.approval.isExecuting || isLoading,
186
205
  variant: 'glass' as const,
187
- disabled: createListingModal$.invalidQuantity.get(),
206
+ disabled:
207
+ createListingModal$.invalidQuantity.get() ||
208
+ isLoading ||
209
+ !listingPriceChanged ||
210
+ listingPrice.amountRaw === '0' ||
211
+ steps?.transaction.isExecuting,
188
212
  },
189
213
  {
190
214
  label: 'List item for sale',
191
- onClick: () => handleStepExecution(() => steps?.transaction.execute()),
215
+ onClick: () => createListing({
216
+ contractType: collection?.type as ContractType,
217
+ listing: {
218
+ tokenId: collectibleId,
219
+ quantity: parseUnits(
220
+ createListingModal$.quantity.get(),
221
+ collectible?.decimals || 0,
222
+ ).toString(),
223
+ expiry: dateToUnixTime(createListingModal$.expiry.get()),
224
+ currencyAddress: listingPrice.currency.contractAddress,
225
+ pricePerToken: listingPrice.amountRaw,
226
+ },
227
+ }),
192
228
  pending: steps?.transaction.isExecuting || isLoading,
193
229
  disabled:
194
- steps?.approval.isPending ||
230
+ (!approvalExecutedSuccess && approvalNeeded) ||
195
231
  listingPrice.amountRaw === '0' ||
196
232
  isLoading ||
197
- createListingModal$.invalidQuantity.get(),
233
+ createListingModal$.invalidQuantity.get() ||
234
+ !listingPriceChanged,
198
235
  },
199
236
  ] satisfies ActionModalProps['ctas'];
200
237
 
201
238
  return (
202
239
  <ActionModal
203
- store={createListingModal$}
240
+ isOpen={createListingModal$.isOpen.get()}
241
+ chainId={Number(chainId)}
204
242
  onClose={() => createListingModal$.close()}
205
243
  title="List item for sale"
206
244
  ctas={ctas}
@@ -217,8 +255,10 @@ export const Modal = observer(
217
255
  chainId={chainId}
218
256
  collectionAddress={collectionAddress}
219
257
  $listingPrice={createListingModal$.listingPrice}
258
+ onPriceChange={() => createListingModal$.listingPriceChanged.set(true)}
220
259
  />
221
- {!!listingPrice && (
260
+
261
+ {listingPrice.amountRaw !== '0' && listingPriceChanged && (
222
262
  <FloorPriceText
223
263
  tokenId={collectibleId}
224
264
  chainId={chainId}
@@ -244,6 +284,7 @@ export const Modal = observer(
244
284
  collectionAddress={collectionAddress}
245
285
  chainId={chainId}
246
286
  price={createListingModal$.listingPrice.get()}
287
+ showPlaceholderPrice={!listingPriceChanged}
247
288
  currencyImageUrl={listingPrice.currency.imageUrl}
248
289
  />
249
290
  </ActionModal>
@@ -1,13 +1,14 @@
1
1
  import { observable } from '@legendapp/state';
2
2
  import { addDays } from 'date-fns/addDays';
3
3
  import type { Hex } from 'viem';
4
- import { Currency, OrderbookKind, Price } from '../../../../types';
4
+ import { type Currency, OrderbookKind, type Price } from '../../../../types';
5
5
  import type { BaseModalState, ModalCallbacks } from '../_internal/types';
6
6
 
7
7
  type MakeOfferModalState = BaseModalState & {
8
8
  orderbookKind: OrderbookKind;
9
9
  collectibleId: string;
10
10
  offerPrice: Price;
11
+ offerPriceChanged: boolean;
11
12
  quantity: string;
12
13
  expiry: Date;
13
14
  invalidQuantity: boolean;
@@ -27,12 +28,14 @@ const initialState: MakeOfferModalState & {
27
28
  collectionAddress: '' as Hex,
28
29
  chainId: '',
29
30
  collectibleId: '',
30
- orderbookKind: OrderbookKind.sequence_marketplace_v2,
31
+ orderbookKind: OrderbookKind.reservoir,
31
32
  callbacks: undefined,
32
33
  offerPrice: {
33
34
  amountRaw: '1',
34
35
  currency: {} as Currency,
35
36
  },
37
+ // to track if the user has changed the price, so we know if it's 1 default or user input
38
+ offerPriceChanged: false,
36
39
  quantity: '1',
37
40
  invalidQuantity: false,
38
41
  expiry: new Date(addDays(new Date(), 7).toJSON()),