@0xsequence/marketplace-sdk 0.7.0 → 0.8.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 (227) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.changeset/seven-doors-taste.md +5 -0
  4. package/CHANGELOG.md +13 -0
  5. package/dist/{chunk-MPBN3E54.js → chunk-2VHHJNXY.js} +3 -3
  6. package/dist/{chunk-FBUMNJQ4.js → chunk-3II5GLHE.js} +2 -2
  7. package/dist/chunk-3JU7SQVE.js +182 -0
  8. package/dist/chunk-3JU7SQVE.js.map +1 -0
  9. package/dist/{chunk-XTGMMNV5.js → chunk-A5ACY5YV.js} +2 -2
  10. package/dist/chunk-ABSYNRT5.js +128 -0
  11. package/dist/chunk-ABSYNRT5.js.map +1 -0
  12. package/dist/{chunk-XNA64MZQ.js → chunk-BCO4CYE4.js} +2 -2
  13. package/dist/{chunk-HTFORA4Q.js → chunk-BN36GABQ.js} +1883 -1010
  14. package/dist/chunk-BN36GABQ.js.map +1 -0
  15. package/dist/{chunk-4XK7XNJ7.js → chunk-BNAUZXPV.js} +73 -2
  16. package/dist/chunk-BNAUZXPV.js.map +1 -0
  17. package/dist/{chunk-Q5URKSC4.js → chunk-FMEEJFAF.js} +1 -1
  18. package/dist/{chunk-BBASZVT3.js → chunk-GBQVYNCD.js} +5 -6
  19. package/dist/chunk-GBQVYNCD.js.map +1 -0
  20. package/dist/{chunk-3AKOPSON.js → chunk-IZ44XPBH.js} +2 -9
  21. package/dist/chunk-IZ44XPBH.js.map +1 -0
  22. package/dist/{chunk-EAJ5K7QV.js → chunk-Q5RKAMYF.js} +3 -4
  23. package/dist/chunk-Q5RKAMYF.js.map +1 -0
  24. package/dist/{chunk-RBEPPVLT.js → chunk-X3QNSQER.js} +145 -355
  25. package/dist/chunk-X3QNSQER.js.map +1 -0
  26. package/dist/{index-CzTANLaA.d.ts → index-CnaFSNE9.d.ts} +6 -7
  27. package/dist/index.css +113 -31
  28. package/dist/index.css.map +1 -1
  29. package/dist/index.d.ts +2 -4
  30. package/dist/index.js +4 -4
  31. package/dist/listCollectibles-B0tbqnRd.d.ts +155 -0
  32. package/dist/react/_internal/api/index.d.ts +28 -2
  33. package/dist/react/_internal/api/index.js +3 -1
  34. package/dist/react/_internal/databeat/index.js +10 -9
  35. package/dist/react/_internal/index.d.ts +2 -3
  36. package/dist/react/_internal/index.js +4 -4
  37. package/dist/react/_internal/wagmi/index.js +2 -2
  38. package/dist/react/hooks/index.d.ts +259 -674
  39. package/dist/react/hooks/index.js +11 -20
  40. package/dist/react/hooks/options/index.d.ts +1 -2
  41. package/dist/react/hooks/options/index.js +4 -4
  42. package/dist/react/index.d.ts +7 -7
  43. package/dist/react/index.js +15 -24
  44. package/dist/react/queries/index.d.ts +25 -0
  45. package/dist/react/queries/index.js +48 -0
  46. package/dist/react/queries/index.js.map +1 -0
  47. package/dist/react/ssr/index.js +3 -3
  48. package/dist/react/ui/components/collectible-card/index.d.ts +1 -6
  49. package/dist/react/ui/components/collectible-card/index.js +13 -12
  50. package/dist/react/ui/components/marketplace-logos/index.js +1 -1
  51. package/dist/react/ui/icons/index.js +6 -6
  52. package/dist/react/ui/index.d.ts +18 -22
  53. package/dist/react/ui/index.js +13 -12
  54. package/dist/react/ui/modals/_internal/components/actionModal/index.d.ts +6 -11
  55. package/dist/react/ui/modals/_internal/components/actionModal/index.js +10 -9
  56. package/dist/types/index.js +2 -2
  57. package/dist/{types-Ct1uCT3M.d.ts → types-o_pKUpQG.d.ts} +2 -5
  58. package/dist/utils/index.d.ts +1 -5
  59. package/dist/utils/index.js +4 -4
  60. package/package.json +22 -16
  61. package/src/react/_internal/api/__mocks__/indexer.msw.ts +3 -1
  62. package/src/react/_internal/api/__mocks__/marketplace.msw.ts +1 -1
  63. package/src/react/_internal/api/__mocks__/metadata.msw.ts +14 -12
  64. package/src/react/_internal/api/index.ts +1 -0
  65. package/src/react/_internal/api/laos-api.ts +103 -0
  66. package/src/react/_internal/api/zod-schema.ts +3 -3
  67. package/src/react/_internal/types.ts +1 -10
  68. package/src/react/_internal/wallet/__tests__/wallet.test.ts +43 -0
  69. package/src/react/_internal/wallet/useWallet.ts +6 -3
  70. package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +1 -1
  71. package/src/react/hooks/__tests__/useCancelOrder.test.tsx +1 -1
  72. package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +1 -1
  73. package/src/react/hooks/__tests__/useCollectible.test.tsx +2 -2
  74. package/src/react/hooks/__tests__/useCollection.test.tsx +2 -2
  75. package/src/react/hooks/__tests__/useComparePrices.test.tsx +1 -1
  76. package/src/react/hooks/__tests__/useConvertPriceToUSD.test.tsx +1 -1
  77. package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +1 -1
  78. package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +2 -2
  79. package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +1 -1
  80. package/src/react/hooks/__tests__/useCurrencies.test.tsx +2 -2
  81. package/src/react/hooks/__tests__/useCurrency.test.tsx +2 -2
  82. package/src/react/hooks/__tests__/useFilters.test.tsx +2 -2
  83. package/src/react/hooks/__tests__/useFloorOrder.test.tsx +2 -2
  84. package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +1 -1
  85. package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +1 -1
  86. package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +1 -1
  87. package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +1 -1
  88. package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +2 -2
  89. package/src/react/hooks/__tests__/useListCollectibles.test.tsx +3 -2
  90. package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +1 -1
  91. package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +1 -1
  92. package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +1 -1
  93. package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +1 -1
  94. package/src/react/hooks/__tests__/useLowestListing.test.tsx +1 -1
  95. package/src/react/hooks/__tests__/useRoyalty.test.tsx +1 -2
  96. package/src/react/hooks/index.ts +0 -1
  97. package/src/react/hooks/options/collectionOptions.ts +2 -3
  98. package/src/react/hooks/useAutoSelectFeeOption.tsx +1 -1
  99. package/src/react/hooks/useCancelOrder.tsx +3 -3
  100. package/src/react/hooks/useCancelTransactionSteps.tsx +1 -1
  101. package/src/react/hooks/useCheckoutOptions.tsx +1 -2
  102. package/src/react/hooks/useCollectible.tsx +2 -3
  103. package/src/react/hooks/useCollectionBalanceDetails.tsx +1 -2
  104. package/src/react/hooks/useComparePrices.tsx +2 -9
  105. package/src/react/hooks/useConvertPriceToUSD.tsx +1 -4
  106. package/src/react/hooks/useCountListingsForCollectible.tsx +1 -2
  107. package/src/react/hooks/useCountOfCollectables.tsx +1 -2
  108. package/src/react/hooks/useCountOffersForCollectible.tsx +1 -2
  109. package/src/react/hooks/useCurrencies.tsx +1 -4
  110. package/src/react/hooks/useCurrency.tsx +3 -8
  111. package/src/react/hooks/useFilters.tsx +5 -4
  112. package/src/react/hooks/useFloorOrder.tsx +1 -2
  113. package/src/react/hooks/useGenerateCancelTransaction.tsx +3 -6
  114. package/src/react/hooks/useGenerateListingTransaction.tsx +2 -3
  115. package/src/react/hooks/useGenerateOfferTransaction.tsx +2 -3
  116. package/src/react/hooks/useGenerateSellTransaction.tsx +3 -6
  117. package/src/react/hooks/useHighestOffer.tsx +1 -1
  118. package/src/react/hooks/useListCollectibles.tsx +33 -61
  119. package/src/react/hooks/useListCollectiblesPaginated.tsx +2 -6
  120. package/src/react/hooks/useListListingsForCollectible.tsx +1 -2
  121. package/src/react/hooks/useListOffersForCollectible.tsx +1 -2
  122. package/src/react/hooks/useLowestListing.tsx +1 -2
  123. package/src/react/hooks/useRoyalty.tsx +3 -8
  124. package/src/react/hooks/useTransferTokens.tsx +2 -2
  125. package/src/react/queries/balanceOfCollectible.ts +9 -32
  126. package/src/react/queries/getTokenSupplies.ts +38 -0
  127. package/src/react/queries/index.ts +5 -0
  128. package/src/react/queries/listCollectibles.ts +96 -0
  129. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +1 -1
  130. package/src/react/ui/components/_internals/action-button/__tests__/ActionButton.test.tsx +1 -1
  131. package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +4 -3
  132. package/src/react/ui/components/_internals/action-button/components/OwnerActions.tsx +1 -1
  133. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -3
  134. package/src/react/ui/components/collectible-card/__tests__/CollectibleCard.test.tsx +1 -1
  135. package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +127 -0
  136. package/src/react/ui/modals/BuyModal/Modal.tsx +70 -85
  137. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +85 -226
  138. package/src/react/ui/modals/BuyModal/__tests__/Modal1155.test.tsx +140 -0
  139. package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +67 -76
  140. package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +1 -60
  141. package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +1 -1
  142. package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +29 -13
  143. package/src/react/ui/modals/BuyModal/hooks/useLoadData.ts +26 -21
  144. package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +200 -0
  145. package/src/react/ui/modals/BuyModal/index.tsx +4 -14
  146. package/src/react/ui/modals/BuyModal/store.ts +71 -76
  147. package/src/react/ui/modals/CreateListingModal/Modal.tsx +71 -7
  148. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +2 -2
  149. package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +1 -1
  150. package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +1 -1
  151. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +9 -5
  152. package/src/react/ui/modals/CreateListingModal/store.ts +7 -2
  153. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +103 -6
  154. package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +1 -1
  155. package/src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx +1 -1
  156. package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +1 -1
  157. package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +8 -4
  158. package/src/react/ui/modals/MakeOfferModal/store.ts +5 -3
  159. package/src/react/ui/modals/SellModal/Modal.tsx +76 -4
  160. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +1 -1
  161. package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +1 -1
  162. package/src/react/ui/modals/SellModal/hooks/useSell.tsx +1 -1
  163. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +16 -8
  164. package/src/react/ui/modals/SellModal/store.ts +5 -3
  165. package/src/react/ui/modals/TransferModal/_store.ts +15 -3
  166. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TokenQuantityInput.tsx +58 -0
  167. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TransferButton.tsx +56 -0
  168. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +50 -0
  169. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +94 -66
  170. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +22 -14
  171. package/src/react/ui/modals/TransferModal/index.tsx +72 -38
  172. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +43 -42
  173. package/src/react/ui/modals/_internal/components/actionModal/store.ts +1 -2
  174. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +2 -2
  175. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +9 -1
  176. package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +27 -12
  177. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -1
  178. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +19 -3
  179. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +3 -0
  180. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/ActionButtons.tsx +60 -0
  181. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/BalanceIndicator.tsx +30 -0
  182. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +126 -0
  183. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/store.ts +25 -0
  184. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +74 -0
  185. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +1 -2
  186. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +1 -2
  187. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
  188. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +4 -7
  189. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +1 -1
  190. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +1 -1
  191. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +1 -1
  192. package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +1 -1
  193. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +6 -1
  194. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +2 -2
  195. package/src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx +10 -31
  196. package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +53 -0
  197. package/src/react/ui/modals/_internal/types.ts +2 -1
  198. package/src/types/waas-types.ts +38 -0
  199. package/src/utils/network.ts +2 -4
  200. package/test/const.ts +1 -1
  201. package/test/setup.ts +10 -0
  202. package/test/test-utils.tsx +31 -5
  203. package/tsconfig.tsbuildinfo +1 -1
  204. package/dist/chunk-3AKOPSON.js.map +0 -1
  205. package/dist/chunk-4XK7XNJ7.js.map +0 -1
  206. package/dist/chunk-BBASZVT3.js.map +0 -1
  207. package/dist/chunk-EAJ5K7QV.js.map +0 -1
  208. package/dist/chunk-HTFORA4Q.js.map +0 -1
  209. package/dist/chunk-OFY7OFTL.js +0 -458
  210. package/dist/chunk-OFY7OFTL.js.map +0 -1
  211. package/dist/chunk-RBEPPVLT.js.map +0 -1
  212. package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +0 -172
  213. package/src/react/hooks/useGenerateBuyTransaction.tsx +0 -80
  214. package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +0 -349
  215. package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +0 -185
  216. package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +0 -170
  217. package/src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx +0 -47
  218. package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +0 -140
  219. package/src/react/ui/modals/BuyModal/modals/__tests__/CheckoutModal.test.tsx +0 -162
  220. package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +0 -327
  221. package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/index.tsx +0 -124
  222. package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/store.ts +0 -12
  223. /package/dist/{chunk-MPBN3E54.js.map → chunk-2VHHJNXY.js.map} +0 -0
  224. /package/dist/{chunk-FBUMNJQ4.js.map → chunk-3II5GLHE.js.map} +0 -0
  225. /package/dist/{chunk-XTGMMNV5.js.map → chunk-A5ACY5YV.js.map} +0 -0
  226. /package/dist/{chunk-XNA64MZQ.js.map → chunk-BCO4CYE4.js.map} +0 -0
  227. /package/dist/{chunk-Q5URKSC4.js.map → chunk-FMEEJFAF.js.map} +0 -0
@@ -1,18 +1,16 @@
1
1
  'use client';
2
2
 
3
3
  import {
4
- ActionModal,
5
- CustomSelect,
6
- useCurrencyBalance
7
- } from "./chunk-OFY7OFTL.js";
4
+ ActionModal
5
+ } from "./chunk-ABSYNRT5.js";
8
6
  import {
9
7
  useAnalytics
10
- } from "./chunk-XTGMMNV5.js";
8
+ } from "./chunk-A5ACY5YV.js";
11
9
  import {
12
10
  BellIcon_default,
13
11
  CalendarIcon_default,
14
12
  CartIcon_default
15
- } from "./chunk-MPBN3E54.js";
13
+ } from "./chunk-2VHHJNXY.js";
16
14
  import {
17
15
  AlertMessage,
18
16
  MODAL_OVERLAY_PROPS,
@@ -35,7 +33,7 @@ import {
35
33
  useSwitchChainModal,
36
34
  useTransferTokens,
37
35
  useWallet
38
- } from "./chunk-RBEPPVLT.js";
36
+ } from "./chunk-X3QNSQER.js";
39
37
  import {
40
38
  DEFAULT_MARKETPLACE_FEE_PERCENTAGE
41
39
  } from "./chunk-Y63BOO6M.js";
@@ -43,7 +41,7 @@ import {
43
41
  cn,
44
42
  compareAddress,
45
43
  truncateMiddle
46
- } from "./chunk-EAJ5K7QV.js";
44
+ } from "./chunk-Q5RKAMYF.js";
47
45
  import {
48
46
  InvalidContractTypeError,
49
47
  InvalidStepError,
@@ -51,13 +49,14 @@ import {
51
49
  collectableKeys,
52
50
  getMarketplaceClient,
53
51
  getQueryClient
54
- } from "./chunk-4XK7XNJ7.js";
52
+ } from "./chunk-BNAUZXPV.js";
55
53
 
56
54
  // src/react/ui/modals/modal-provider.tsx
57
- import { observer as observer12 } from "@legendapp/state/react";
55
+ import { observer as observer17 } from "@legendapp/state/react";
58
56
 
59
57
  // src/react/ui/modals/BuyModal/Modal.tsx
60
- import { use$ } from "@legendapp/state/react";
58
+ import { useSelectPaymentModal } from "@0xsequence/checkout";
59
+ import { useEffect } from "react";
61
60
 
62
61
  // src/react/ui/modals/_internal/components/actionModal/ErrorModal.tsx
63
62
  import { Text } from "@0xsequence/design-system";
@@ -115,310 +114,8 @@ var LoadingModal = ({
115
114
  }
116
115
  );
117
116
 
118
- // src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts
119
- import { useSelectPaymentModal } from "@0xsequence/checkout";
120
-
121
- // src/utils/decode/erc20.ts
122
- import { decodeFunctionData, erc20Abi } from "viem";
123
- function decodeERC20Approval(calldata) {
124
- const decoded = decodeFunctionData({
125
- abi: erc20Abi,
126
- data: calldata
127
- });
128
- if (decoded.functionName !== "approve") {
129
- throw new Error("Not an ERC20 approval transaction");
130
- }
131
- const [spender, value] = decoded.args;
132
- return {
133
- spender,
134
- value
135
- };
136
- }
137
-
138
- // src/react/ui/modals/BuyModal/store.ts
139
- import { observable } from "@legendapp/state";
140
- var buyState = {
141
- order: void 0,
142
- quantity: "1",
143
- invalidQuantity: false,
144
- checkoutModalIsLoading: false,
145
- checkoutModalLoaded: false,
146
- purchaseProcessing: false,
147
- customProviderCallback: null
148
- };
149
- var initialState = {
150
- isOpen: false,
151
- open: ({
152
- callbacks,
153
- defaultCallbacks,
154
- ...args
155
- }) => {
156
- buyModal$.state.set({
157
- quantity: args.order.quantityAvailableFormatted,
158
- order: args.order,
159
- invalidQuantity: false,
160
- checkoutModalIsLoading: false,
161
- checkoutModalLoaded: false,
162
- purchaseProcessing: false,
163
- customProviderCallback: args.customProviderCallback
164
- });
165
- buyModal$.callbacks.set(callbacks || defaultCallbacks);
166
- buyModal$.isOpen.set(true);
167
- },
168
- close: () => {
169
- buyModal$.isOpen.set(false);
170
- buyModal$.callbacks.set(void 0);
171
- buyModal$.state.set(buyState);
172
- },
173
- state: buyState,
174
- setCheckoutModalIsLoading: (isLoading) => {
175
- buyModal$.state.checkoutModalIsLoading.set(isLoading);
176
- },
177
- setCheckoutModalLoaded: (isLoaded) => {
178
- buyModal$.state.checkoutModalLoaded.set(isLoaded);
179
- },
180
- setPurchaseProcessing: (isProcessing) => {
181
- buyModal$.state.purchaseProcessing.set(isProcessing);
182
- },
183
- callbacks: void 0
184
- };
185
- var buyModal$ = observable(initialState);
186
-
187
- // src/react/ui/modals/BuyModal/hooks/useFees.ts
188
- import { avalanche, optimism } from "viem/chains";
189
- var useFees = ({
190
- chainId,
191
- collectionAddress
192
- }) => {
193
- const defaultFee = 2.5;
194
- const defaultPlatformFeeRecipient = "0x858dB1cbF6D09D447C96A11603189b49B2D1C219";
195
- const avalancheAndOptimismPlatformFeeRecipient = "0x400cdab4676c17aec07e8ec748a5fc3b674bca41";
196
- const { data: marketplaceConfig } = useMarketplaceConfig();
197
- const collection = marketplaceConfig?.collections.find(
198
- (collection2) => collection2.address.toLowerCase() === collectionAddress.toLowerCase() && chainId === Number(collection2.chainId)
199
- );
200
- const avalancheOrOptimism = chainId === avalanche.id || chainId === optimism.id;
201
- const receiver = avalancheOrOptimism ? avalancheAndOptimismPlatformFeeRecipient : defaultPlatformFeeRecipient;
202
- const percentageToBPS = (percentage) => Number(percentage) * 1e4 / 100;
203
- return {
204
- amount: percentageToBPS(collection?.feePercentage || defaultFee).toString(),
205
- receiver
206
- };
207
- };
208
-
209
- // src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts
210
- var useBuyCollectable = ({
211
- chainId,
212
- collectionAddress,
213
- tokenId,
214
- callbacks,
215
- priceCurrencyAddress,
216
- setCheckoutModalIsLoading,
217
- setCheckoutModalLoaded,
218
- customProviderCallback
219
- }) => {
220
- const { openSelectPaymentModal } = useSelectPaymentModal();
221
- const config = useConfig();
222
- const marketplaceClient = getMarketplaceClient(Number(chainId), config);
223
- const fees = useFees({ chainId: Number(chainId), collectionAddress });
224
- const { wallet, isLoading, isError } = useWallet();
225
- if (isLoading) {
226
- return { status: "loading", buy: null, isLoading, isError: false };
227
- }
228
- if (isError || !wallet || !tokenId) {
229
- return { status: "error", buy: null, isLoading, isError: true };
230
- }
231
- const invalidateQueries2 = async (queriesToInvalidate) => {
232
- const queryClient = getQueryClient();
233
- for (const queryKey of queriesToInvalidate) {
234
- await queryClient.invalidateQueries({ queryKey });
235
- }
236
- };
237
- return {
238
- status: "ready",
239
- isLoading,
240
- isError,
241
- buy: async (input) => {
242
- setCheckoutModalIsLoading(true);
243
- const { steps: steps3 } = await marketplaceClient.generateBuyTransaction({
244
- collectionAddress,
245
- buyer: await wallet.address(),
246
- marketplace: input.marketplace,
247
- ordersData: [
248
- {
249
- orderId: input.orderId,
250
- quantity: input.quantity,
251
- tokenId
252
- }
253
- ],
254
- additionalFees: [fees],
255
- walletType: "unknown" /* unknown */
256
- });
257
- setCheckoutModalLoaded(true);
258
- setCheckoutModalIsLoading(false);
259
- const buyStep = steps3.find((step) => step.id === "buy" /* buy */);
260
- const approveStep = steps3.find(
261
- (step) => step.id === "tokenApproval" /* tokenApproval */
262
- );
263
- const approvedSpenderAddress = approveStep ? decodeERC20Approval(approveStep.data).spender : void 0;
264
- if (!buyStep) {
265
- throw new Error("Buy step not found");
266
- }
267
- const openSelectPaymentModalConfig = {
268
- chain: chainId,
269
- collectibles: [
270
- {
271
- tokenId,
272
- quantity: input.quantity,
273
- decimals: input.collectableDecimals
274
- }
275
- ],
276
- currencyAddress: priceCurrencyAddress,
277
- price: buyStep.price,
278
- targetContractAddress: buyStep.to,
279
- approvedSpenderAddress,
280
- txData: buyStep.data,
281
- collectionAddress,
282
- recipientAddress: await wallet.address(),
283
- enableMainCurrencyPayment: true,
284
- enableSwapPayments: !!input.checkoutOptions.swap,
285
- creditCardProviders: customProviderCallback ? ["custom"] : input.checkoutOptions.nftCheckout || [],
286
- onSuccess: (hash) => {
287
- callbacks?.onSuccess?.({ hash });
288
- },
289
- supplementaryAnalyticsInfo: {
290
- orderId: input.orderId,
291
- marketplaceKind: input.marketplace
292
- },
293
- onError: callbacks?.onError,
294
- onClose: () => {
295
- invalidateQueries2([
296
- collectableKeys.listings,
297
- collectableKeys.lowestListings,
298
- collectableKeys.listingsCount,
299
- collectableKeys.lists,
300
- collectableKeys.userBalances,
301
- balanceQueries.all,
302
- balanceQueries.collectionBalanceDetails
303
- ]);
304
- buyModal$.close();
305
- },
306
- ...customProviderCallback && {
307
- customProviderCallback: () => {
308
- customProviderCallback(buyStep);
309
- buyModal$.close();
310
- }
311
- }
312
- };
313
- openSelectPaymentModal(openSelectPaymentModalConfig);
314
- }
315
- };
316
- };
317
-
318
- // src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts
319
- import { skipToken, useQuery } from "@tanstack/react-query";
320
- var useCheckoutOptions = (input) => {
321
- const config = useConfig();
322
- const { wallet } = useWallet();
323
- const fees = useFees({
324
- chainId: input.chainId,
325
- collectionAddress: input.collectionAddress
326
- });
327
- return useQuery({
328
- queryKey: [
329
- "checkoutOptions",
330
- input.chainId,
331
- input.collectionAddress,
332
- input.orderId,
333
- input.marketplace
334
- ],
335
- queryFn: wallet ? async () => {
336
- const marketplaceClient = getMarketplaceClient(input.chainId, config);
337
- return marketplaceClient.checkoutOptionsMarketplace({
338
- wallet: await wallet.address(),
339
- orders: [
340
- {
341
- contractAddress: input.collectionAddress,
342
- orderId: input.orderId,
343
- marketplace: input.marketplace
344
- }
345
- ],
346
- additionalFee: Number(fees.amount)
347
- }).then((res) => res.options);
348
- } : skipToken,
349
- enabled: !!wallet
350
- });
351
- };
352
-
353
- // src/react/ui/modals/BuyModal/hooks/useLoadData.ts
354
- var useLoadData = ({
355
- chainId,
356
- collectionAddress,
357
- collectibleId,
358
- orderId,
359
- marketplace
360
- }) => {
361
- const {
362
- data: collection,
363
- isLoading: collectionLoading,
364
- isError: collectionError
365
- } = useCollection({
366
- chainId,
367
- collectionAddress
368
- });
369
- const {
370
- data: collectable,
371
- isLoading: collectableLoading,
372
- isError: collectableError
373
- } = useCollectible({
374
- chainId: String(chainId),
375
- collectionAddress,
376
- collectibleId,
377
- query: {
378
- enabled: !!collectibleId
379
- }
380
- });
381
- const {
382
- data: checkoutOptions,
383
- isLoading: checkoutOptionsLoading,
384
- isError: checkoutOptionsError
385
- } = useCheckoutOptions({
386
- chainId,
387
- collectionAddress,
388
- orderId,
389
- marketplace
390
- });
391
- return {
392
- collection,
393
- collectable,
394
- checkoutOptions,
395
- isLoading: collectionLoading || collectableLoading || checkoutOptionsLoading,
396
- isError: collectionError || collectableError || checkoutOptionsError
397
- };
398
- };
399
-
400
- // src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx
401
- import { useEffect } from "react";
402
- import { parseUnits } from "viem";
403
- function CheckoutModal({ buy, collectable, order }) {
404
- useEffect(() => {
405
- if (buyModal$.state.checkoutModalIsLoading.get() || buyModal$.state.checkoutModalLoaded.get())
406
- return;
407
- const executeBuy = () => {
408
- buy({
409
- orderId: order.orderId,
410
- collectableDecimals: collectable.decimals || 0,
411
- quantity: parseUnits("1", collectable.decimals || 0).toString(),
412
- marketplace: order.marketplace
413
- });
414
- };
415
- executeBuy();
416
- }, []);
417
- return null;
418
- }
419
-
420
- // src/react/ui/modals/BuyModal/modals/Modal1155.tsx
421
- import { observer as observer2 } from "@legendapp/state/react";
117
+ // src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx
118
+ import { use$, useObservable } from "@legendapp/state/react";
422
119
  import * as dn2 from "dnum";
423
120
  import { Text as Text2, TokenImage } from "@0xsequence/design-system";
424
121
 
@@ -438,7 +135,8 @@ var quantityInput_default = observer(function QuantityInput({
438
135
  $invalidQuantity,
439
136
  decimals,
440
137
  maxQuantity,
441
- className
138
+ className,
139
+ disabled
442
140
  }) {
443
141
  const dnMaxQuantity = dn.from(maxQuantity, decimals);
444
142
  const dnOne = dn.from("1", decimals);
@@ -526,7 +224,8 @@ var quantityInput_default = observer(function QuantityInput({
526
224
  {
527
225
  className: cn(
528
226
  "flex w-full flex-col [&>label>div>div:has(:disabled):hover]:opacity-100 [&>label>div>div:has(:disabled)]:opacity-100 [&>label>div>div>input]:text-xs [&>label>div>div]:h-9 [&>label>div>div]:rounded [&>label>div>div]:pr-0 [&>label>div>div]:pl-3 [&>label>div>div]:text-xs [&>label]:gap-[2px]",
529
- className
227
+ className,
228
+ disabled && "pointer-events-none opacity-50"
530
229
  ),
531
230
  children: [
532
231
  /* @__PURE__ */ jsx3(
@@ -569,85 +268,119 @@ var quantityInput_default = observer(function QuantityInput({
569
268
  );
570
269
  });
571
270
 
572
- // src/react/ui/modals/BuyModal/modals/Modal1155.tsx
271
+ // src/react/ui/modals/BuyModal/store.ts
272
+ import { createStore } from "@xstate/store";
273
+ import { useSelector } from "@xstate/store/react";
274
+ var initialContext = {
275
+ isOpen: false,
276
+ props: null,
277
+ onError: () => {
278
+ },
279
+ onSuccess: () => {
280
+ },
281
+ quantity: void 0
282
+ };
283
+ var buyModalStore = createStore({
284
+ context: { ...initialContext },
285
+ on: {
286
+ open: (context, event) => ({
287
+ ...context,
288
+ props: event.props,
289
+ onError: event.onError ?? context.onError,
290
+ onSuccess: event.onSuccess ?? context.onSuccess,
291
+ isOpen: true
292
+ }),
293
+ close: (context) => ({
294
+ ...context,
295
+ isOpen: false,
296
+ quantity: void 0
297
+ }),
298
+ setQuantity: (context, event) => ({
299
+ ...context,
300
+ quantity: event.quantity
301
+ })
302
+ }
303
+ });
304
+ var useIsOpen = () => useSelector(buyModalStore, (state) => state.context.isOpen);
305
+ var useBuyModalProps = () => useSelector(buyModalStore, (state) => state.context.props);
306
+ var useOnError = () => useSelector(buyModalStore, (state) => state.context.onError);
307
+ var useOnSuccess = () => useSelector(buyModalStore, (state) => state.context.onSuccess);
308
+ var useQuantity = () => useSelector(buyModalStore, (state) => state.context.quantity);
309
+
310
+ // src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx
573
311
  import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
574
- var ERC1155QuantityModal = observer2(
575
- ({ buy, collectable, order }) => {
576
- if (buyModal$.state.checkoutModalLoaded.get() && buyModal$.isOpen.get() && buyModal$.state.checkoutModalIsLoading.get() && buyModal$.state.purchaseProcessing.get()) {
577
- return null;
578
- }
579
- return /* @__PURE__ */ jsx4(
580
- ActionModal,
581
- {
582
- isOpen: buyModal$.isOpen.get(),
583
- chainId: order.chainId,
584
- onClose: () => buyModal$.close(),
585
- title: "Select Quantity",
586
- disableAnimation: true,
587
- ctas: [
312
+ var ERC1155QuantityModal = ({ order }) => {
313
+ const { chainId } = useBuyModalProps();
314
+ const isOpen = useIsOpen();
315
+ const localQuantity$ = useObservable("1");
316
+ const localQuantity = use$(localQuantity$);
317
+ const invalidQuantity$ = useObservable(false);
318
+ const invalidQuantity = use$(invalidQuantity$);
319
+ return /* @__PURE__ */ jsx4(
320
+ ActionModal,
321
+ {
322
+ isOpen,
323
+ chainId,
324
+ onClose: () => buyModalStore.send({ type: "close" }),
325
+ title: "Select Quantity",
326
+ disableAnimation: true,
327
+ ctas: [
328
+ {
329
+ label: "Buy now",
330
+ onClick: () => {
331
+ buyModalStore.send({
332
+ type: "setQuantity",
333
+ quantity: Number(localQuantity)
334
+ });
335
+ },
336
+ disabled: invalidQuantity
337
+ }
338
+ ],
339
+ children: /* @__PURE__ */ jsxs2("div", { className: "flex w-full flex-col gap-4", children: [
340
+ /* @__PURE__ */ jsx4(
341
+ quantityInput_default,
588
342
  {
589
- label: "Buy now",
590
- onClick: () => {
591
- buyModal$.state.checkoutModalIsLoading.set(true);
592
- buyModal$.state.purchaseProcessing.set(true);
593
- buy({
594
- quantity: buyModal$.state.quantity.get(),
595
- orderId: order.orderId,
596
- collectableDecimals: collectable.decimals || 0,
597
- marketplace: order.marketplace
598
- });
599
- },
600
- disabled: buyModal$.state.checkoutModalIsLoading.get(),
601
- pending: buyModal$.state.checkoutModalIsLoading.get()
343
+ $quantity: localQuantity$,
344
+ $invalidQuantity: invalidQuantity$,
345
+ decimals: order.quantityDecimals,
346
+ maxQuantity: order.quantityRemaining
602
347
  }
603
- ],
604
- children: /* @__PURE__ */ jsxs2("div", { className: "flex w-full flex-col gap-4", children: [
605
- /* @__PURE__ */ jsx4(
606
- quantityInput_default,
607
- {
608
- $quantity: buyModal$.state.quantity,
609
- $invalidQuantity: buyModal$.state.invalidQuantity,
610
- decimals: order.quantityDecimals,
611
- maxQuantity: order.quantityRemaining
612
- }
613
- ),
614
- /* @__PURE__ */ jsx4(TotalPrice, { order })
615
- ] })
616
- }
617
- );
618
- }
619
- );
620
- var TotalPrice = observer2(({ order }) => {
348
+ ),
349
+ /* @__PURE__ */ jsx4(TotalPrice, { order, quantityStr: localQuantity })
350
+ ] })
351
+ }
352
+ );
353
+ };
354
+ var TotalPrice = ({
355
+ order,
356
+ quantityStr
357
+ }) => {
621
358
  const { data: marketplaceConfig } = useMarketplaceConfig();
622
359
  const { data: currency, isLoading: isCurrencyLoading } = useCurrency({
623
360
  chainId: order.chainId,
624
361
  currencyAddress: order.priceCurrencyAddress
625
362
  });
626
- const quantityStr = buyModal$.state.quantity.get();
363
+ let error = null;
627
364
  let formattedPrice = "0";
628
365
  if (currency) {
629
- const quantity = BigInt(quantityStr);
630
- const totalPriceWithoutFees = dn2.format(
631
- dn2.multiply(quantity, order.priceAmountFormatted),
632
- {
633
- digits: currency.decimals,
634
- trailingZeros: false
635
- }
636
- );
637
- const marketplaceFeePercentage = marketplaceConfig?.collections.find(
638
- (collection) => compareAddress(collection.address, order.collectionContractAddress)
639
- )?.feePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
640
- const feeMultiplier = dn2.from(1 + marketplaceFeePercentage / 100);
641
- const totalPrice = dn2.format(
642
- dn2.multiply(totalPriceWithoutFees, feeMultiplier),
643
- {
644
- digits: currency.decimals,
645
- trailingZeros: false
646
- }
647
- );
648
- formattedPrice = totalPrice;
366
+ try {
367
+ const price = dn2.from(order.priceAmount, currency.decimals);
368
+ const totalPriceWithoutFees = dn2.multiply(quantityStr, price);
369
+ const marketplaceFeePercentage = marketplaceConfig?.collections.find(
370
+ (collection) => compareAddress(collection.address, order.collectionContractAddress)
371
+ )?.feePercentage || DEFAULT_MARKETPLACE_FEE_PERCENTAGE;
372
+ const feeMultiplier = dn2.from(
373
+ 1 + marketplaceFeePercentage / 100,
374
+ currency.decimals
375
+ );
376
+ const totalPrice = dn2.multiply(totalPriceWithoutFees, feeMultiplier);
377
+ formattedPrice = dn2.format(totalPrice, { trailingZeros: false });
378
+ } catch (e) {
379
+ console.error("Error formatting price", e);
380
+ error = "Unable to calculate total price";
381
+ }
649
382
  }
650
- return /* @__PURE__ */ jsxs2("div", { className: "flex justify-between", children: [
383
+ return error ? /* @__PURE__ */ jsx4(Text2, { className: "font-body font-medium text-xs", color: "text50", children: error }) : /* @__PURE__ */ jsxs2("div", { className: "flex justify-between", children: [
651
384
  /* @__PURE__ */ jsx4(Text2, { className: "font-body font-medium text-xs", color: "text50", children: "Total Price" }),
652
385
  /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-0.5", children: isCurrencyLoading || !currency ? /* @__PURE__ */ jsx4("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx4(Text2, { className: "font-body text-text-50 text-xs", children: "Loading..." }) }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
653
386
  currency.imageUrl && /* @__PURE__ */ jsx4(TokenImage, { src: currency.imageUrl, size: "xs" }),
@@ -655,112 +388,362 @@ var TotalPrice = observer2(({ order }) => {
655
388
  /* @__PURE__ */ jsx4(Text2, { className: "font-body font-bold text-text-80 text-xs", children: currency?.symbol })
656
389
  ] }) })
657
390
  ] });
658
- });
659
-
660
- // src/react/ui/modals/BuyModal/Modal.tsx
661
- import { jsx as jsx5 } from "react/jsx-runtime";
662
- var BuyModal = () => {
663
- const isOpen = use$(buyModal$.isOpen);
664
- if (!isOpen) return null;
665
- return /* @__PURE__ */ jsx5(BuyModalContent, {});
666
391
  };
667
- var BuyModalContent = () => {
668
- const chainId = String(use$(buyModal$.state.order.chainId));
669
- const collectionAddress = use$(
670
- buyModal$.state.order.collectionContractAddress
392
+
393
+ // src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts
394
+ import { skipToken, useQuery } from "@tanstack/react-query";
395
+
396
+ // src/react/ui/modals/BuyModal/hooks/useFees.ts
397
+ import { avalanche, optimism } from "viem/chains";
398
+ var useFees = ({
399
+ chainId,
400
+ collectionAddress
401
+ }) => {
402
+ const defaultFee = 2.5;
403
+ const defaultPlatformFeeRecipient = "0x858dB1cbF6D09D447C96A11603189b49B2D1C219";
404
+ const avalancheAndOptimismPlatformFeeRecipient = "0x400cdab4676c17aec07e8ec748a5fc3b674bca41";
405
+ const { data: marketplaceConfig } = useMarketplaceConfig();
406
+ const collection = marketplaceConfig?.collections.find(
407
+ (collection2) => collection2.address.toLowerCase() === collectionAddress.toLowerCase() && chainId === Number(collection2.chainId)
671
408
  );
672
- const buyModalState = use$(buyModal$.state);
673
- const collectibleId = use$(buyModal$.state.order.tokenId);
674
- const callbacks = use$(buyModal$.callbacks);
675
- const order = use$(buyModal$.state.order);
676
- const isOpen = use$(buyModal$.isOpen);
677
- const checkoutModalIsLoading = use$(buyModal$.state.checkoutModalIsLoading);
678
- const setCheckoutModalIsLoading = use$(buyModal$.setCheckoutModalIsLoading);
679
- const setCheckoutModalLoaded = use$(buyModal$.setCheckoutModalLoaded);
680
- const { collection, collectable, checkoutOptions, isLoading, isError } = useLoadData({
681
- chainId: Number(chainId),
409
+ const avalancheOrOptimism = chainId === avalanche.id || chainId === optimism.id;
410
+ const receiver = avalancheOrOptimism ? avalancheAndOptimismPlatformFeeRecipient : defaultPlatformFeeRecipient;
411
+ const percentageToBPS = (percentage) => Number(percentage) * 1e4 / 100;
412
+ return {
413
+ amount: percentageToBPS(collection?.feePercentage || defaultFee).toString(),
414
+ receiver
415
+ };
416
+ };
417
+
418
+ // src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts
419
+ var useCheckoutOptions = (input) => {
420
+ const config = useConfig();
421
+ const { wallet } = useWallet();
422
+ const fees = useFees({
423
+ chainId: input.chainId,
424
+ collectionAddress: input.collectionAddress
425
+ });
426
+ return useQuery({
427
+ queryKey: [
428
+ "checkoutOptions",
429
+ input.chainId,
430
+ input.collectionAddress,
431
+ input.orderId,
432
+ input.marketplace
433
+ ],
434
+ queryFn: wallet ? async () => {
435
+ const marketplaceClient = getMarketplaceClient(input.chainId, config);
436
+ const response = await marketplaceClient.checkoutOptionsMarketplace({
437
+ wallet: await wallet.address(),
438
+ orders: [
439
+ {
440
+ contractAddress: input.collectionAddress,
441
+ orderId: input.orderId,
442
+ marketplace: input.marketplace
443
+ }
444
+ ],
445
+ additionalFee: Number(fees.amount)
446
+ });
447
+ const orderResponse = await marketplaceClient.getOrders({
448
+ input: [
449
+ {
450
+ contractAddress: input.collectionAddress,
451
+ orderId: input.orderId,
452
+ marketplace: input.marketplace
453
+ }
454
+ ]
455
+ });
456
+ const order = orderResponse.orders[0];
457
+ return {
458
+ ...response.options,
459
+ order
460
+ };
461
+ } : skipToken,
462
+ enabled: !!wallet
463
+ });
464
+ };
465
+
466
+ // src/react/ui/modals/BuyModal/hooks/useLoadData.ts
467
+ var useLoadData = () => {
468
+ const { chainId, collectionAddress, collectibleId, orderId, marketplace } = useBuyModalProps();
469
+ const {
470
+ wallet,
471
+ isLoading: walletLoading,
472
+ isError: walletError
473
+ } = useWallet();
474
+ const {
475
+ data: collection,
476
+ isLoading: collectionLoading,
477
+ isError: collectionError
478
+ } = useCollection({
479
+ chainId,
480
+ collectionAddress
481
+ });
482
+ const {
483
+ data: collectable,
484
+ isLoading: collectableLoading,
485
+ isError: collectableError
486
+ } = useCollectible({
487
+ chainId,
682
488
  collectionAddress,
683
489
  collectibleId,
684
- orderId: order.orderId,
685
- marketplace: order.marketplace
490
+ query: {
491
+ enabled: !!collectibleId
492
+ }
686
493
  });
687
494
  const {
688
- buy,
689
- isLoading: buyIsLoading,
690
- isError: buyIsError
691
- } = useBuyCollectable({
495
+ data: checkoutOptions,
496
+ isLoading: checkoutOptionsLoading,
497
+ isError: checkoutOptionsError
498
+ // TODO: rename this... its order and checkout options
499
+ } = useCheckoutOptions({
692
500
  chainId,
693
501
  collectionAddress,
694
- callbacks,
695
- tokenId: collectibleId,
696
- priceCurrencyAddress: order.priceCurrencyAddress,
697
- setCheckoutModalIsLoading,
698
- setCheckoutModalLoaded,
699
- ...buyModalState?.customProviderCallback && {
700
- customProviderCallback: buyModalState.customProviderCallback
701
- }
502
+ orderId,
503
+ marketplace
702
504
  });
703
- const buyAction = (input) => {
704
- if (buy && checkoutOptions) {
705
- buy({ ...input, checkoutOptions });
706
- buyModal$.state.purchaseProcessing.set(true);
707
- } else {
708
- console.error("buy is null or undefined");
505
+ return {
506
+ collection,
507
+ collectable,
508
+ order: checkoutOptions?.order,
509
+ checkoutOptions,
510
+ wallet,
511
+ isLoading: collectionLoading || collectableLoading || checkoutOptionsLoading || walletLoading,
512
+ // TODO: we should have a way to determine what is causing the error
513
+ isError: collectionError || collectableError || checkoutOptionsError || walletError
514
+ };
515
+ };
516
+
517
+ // src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts
518
+ import { skipToken as skipToken2, useQuery as useQuery2 } from "@tanstack/react-query";
519
+
520
+ // src/utils/decode/erc20.ts
521
+ import { decodeFunctionData, erc20Abi } from "viem";
522
+ function decodeERC20Approval(calldata) {
523
+ const decoded = decodeFunctionData({
524
+ abi: erc20Abi,
525
+ data: calldata
526
+ });
527
+ if (decoded.functionName !== "approve") {
528
+ throw new Error("Not an ERC20 approval transaction");
529
+ }
530
+ const [spender, value] = decoded.args;
531
+ return {
532
+ spender,
533
+ value
534
+ };
535
+ }
536
+
537
+ // src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts
538
+ var getBuyCollectableParams = async ({
539
+ chainId,
540
+ collectionAddress,
541
+ collectibleId,
542
+ callbacks,
543
+ priceCurrencyAddress,
544
+ customCreditCardProviderCallback,
545
+ config,
546
+ wallet,
547
+ marketplace,
548
+ orderId,
549
+ quantity,
550
+ collectable,
551
+ checkoutOptions,
552
+ fee
553
+ }) => {
554
+ const marketplaceClient = getMarketplaceClient(chainId, config);
555
+ const { steps: steps3 } = await marketplaceClient.generateBuyTransaction({
556
+ collectionAddress,
557
+ buyer: await wallet.address(),
558
+ marketplace,
559
+ ordersData: [
560
+ {
561
+ orderId,
562
+ quantity: quantity.toString(),
563
+ tokenId: collectibleId
564
+ }
565
+ ],
566
+ additionalFees: [fee],
567
+ walletType: "unknown" /* unknown */
568
+ });
569
+ const buyStep = steps3.find((step) => step.id === "buy" /* buy */);
570
+ const approveStep = steps3.find((step) => step.id === "tokenApproval" /* tokenApproval */);
571
+ const approvedSpenderAddress = approveStep ? decodeERC20Approval(approveStep.data).spender : void 0;
572
+ if (!buyStep) {
573
+ throw new Error("Buy step not found");
574
+ }
575
+ return {
576
+ chain: chainId,
577
+ collectibles: [
578
+ {
579
+ tokenId: collectibleId,
580
+ quantity: quantity.toString(),
581
+ decimals: collectable.decimals
582
+ }
583
+ ],
584
+ currencyAddress: priceCurrencyAddress,
585
+ price: buyStep.price,
586
+ targetContractAddress: buyStep.to,
587
+ approvedSpenderAddress,
588
+ txData: buyStep.data,
589
+ collectionAddress,
590
+ recipientAddress: await wallet.address(),
591
+ enableMainCurrencyPayment: true,
592
+ enableSwapPayments: !!checkoutOptions.swap,
593
+ creditCardProviders: customCreditCardProviderCallback ? ["custom"] : checkoutOptions.nftCheckout || [],
594
+ onSuccess: (hash) => {
595
+ callbacks?.onSuccess?.({ hash });
596
+ },
597
+ supplementaryAnalyticsInfo: {
598
+ orderId,
599
+ marketplaceKind: marketplace
600
+ },
601
+ onError: callbacks?.onError,
602
+ onClose: () => {
603
+ const queryClient = getQueryClient();
604
+ queryClient.invalidateQueries();
605
+ buyModalStore.send({ type: "close" });
606
+ },
607
+ ...customCreditCardProviderCallback && {
608
+ customProviderCallback: () => {
609
+ customCreditCardProviderCallback(buyStep);
610
+ buyModalStore.send({ type: "close" });
611
+ }
709
612
  }
710
613
  };
711
- if (isLoading || checkoutModalIsLoading || !collection || !collectable || !checkoutOptions || buyIsLoading) {
614
+ };
615
+ var usePaymentModalParams = (args) => {
616
+ const {
617
+ wallet,
618
+ marketplace,
619
+ collectable,
620
+ checkoutOptions,
621
+ priceCurrencyAddress,
622
+ quantity
623
+ } = args;
624
+ const {
625
+ chainId,
626
+ collectionAddress,
627
+ collectibleId,
628
+ orderId,
629
+ customCreditCardProviderCallback,
630
+ skipNativeBalanceCheck
631
+ } = useBuyModalProps();
632
+ const config = useConfig();
633
+ const fee = useFees({
634
+ chainId,
635
+ collectionAddress
636
+ });
637
+ const onSuccess = useOnSuccess();
638
+ const onError = useOnError();
639
+ const enabled = !!wallet && !!marketplace && !!collectable && !!checkoutOptions && !!priceCurrencyAddress && !!quantity;
640
+ return useQuery2({
641
+ queryKey: ["buyCollectableParams", args, quantity, fee],
642
+ queryFn: enabled ? () => getBuyCollectableParams({
643
+ chainId,
644
+ config,
645
+ wallet,
646
+ collectionAddress,
647
+ collectibleId,
648
+ marketplace,
649
+ orderId,
650
+ quantity,
651
+ collectable,
652
+ checkoutOptions,
653
+ fee,
654
+ priceCurrencyAddress,
655
+ callbacks: {
656
+ onSuccess,
657
+ onError
658
+ },
659
+ customCreditCardProviderCallback,
660
+ skipNativeBalanceCheck
661
+ }) : skipToken2
662
+ });
663
+ };
664
+
665
+ // src/react/ui/modals/BuyModal/Modal.tsx
666
+ import { jsx as jsx5 } from "react/jsx-runtime";
667
+ var BuyModal = () => {
668
+ const isOpen = useIsOpen();
669
+ if (!isOpen) {
670
+ return null;
671
+ }
672
+ return /* @__PURE__ */ jsx5(BuyModalContent, {});
673
+ };
674
+ var BuyModalContent = () => {
675
+ const { chainId, skipNativeBalanceCheck } = useBuyModalProps();
676
+ const onError = useOnError();
677
+ const { openSelectPaymentModal } = useSelectPaymentModal();
678
+ const quantity = useQuantity();
679
+ const {
680
+ collection,
681
+ collectable,
682
+ wallet,
683
+ isLoading,
684
+ isError,
685
+ order,
686
+ checkoutOptions
687
+ } = useLoadData();
688
+ const {
689
+ data: paymentModalParams,
690
+ isLoading: isPaymentModalParamsLoading,
691
+ isError: isPaymentModalParamsError
692
+ } = usePaymentModalParams({
693
+ wallet,
694
+ quantity,
695
+ marketplace: order?.marketplace,
696
+ collectable,
697
+ checkoutOptions,
698
+ priceCurrencyAddress: order?.priceCurrencyAddress
699
+ });
700
+ useEffect(() => {
701
+ if (collection?.type === "ERC721" /* ERC721 */ && !quantity) {
702
+ buyModalStore.send({ type: "setQuantity", quantity: 1 });
703
+ }
704
+ }, [collection]);
705
+ if (isError || isPaymentModalParamsError) {
706
+ onError(new Error("Error loading data"));
712
707
  return /* @__PURE__ */ jsx5(
713
- LoadingModal,
708
+ ErrorModal,
714
709
  {
715
- isOpen,
716
- chainId: Number(chainId),
717
- onClose: buyModal$.close,
718
- title: "Loading Sequence Pay"
710
+ isOpen: true,
711
+ chainId,
712
+ onClose: () => buyModalStore.send({ type: "close" }),
713
+ title: "Error"
719
714
  }
720
715
  );
721
716
  }
722
- if (buyIsError || isError) {
717
+ if (isLoading || isPaymentModalParamsLoading || !collection || !collectable || !order) {
723
718
  return /* @__PURE__ */ jsx5(
724
- ErrorModal,
719
+ LoadingModal,
725
720
  {
726
- isOpen,
727
- chainId: Number(chainId),
728
- onClose: buyModal$.close,
729
- title: "Error"
721
+ isOpen: true,
722
+ chainId,
723
+ onClose: () => buyModalStore.send({ type: "close" }),
724
+ title: "Loading Sequence Pay"
730
725
  }
731
726
  );
732
727
  }
733
- if (buyModal$.state.purchaseProcessing.get()) {
734
- return null;
728
+ if (collection.type === "ERC1155" /* ERC1155 */ && !quantity) {
729
+ return /* @__PURE__ */ jsx5(ERC1155QuantityModal, { order });
730
+ }
731
+ if (paymentModalParams) {
732
+ openSelectPaymentModal({
733
+ ...paymentModalParams,
734
+ skipNativeBalanceCheck
735
+ });
735
736
  }
736
- return collection.type === "ERC721" /* ERC721 */ ? /* @__PURE__ */ jsx5(
737
- CheckoutModal,
738
- {
739
- buy: buyAction,
740
- collectable,
741
- order
742
- }
743
- ) : /* @__PURE__ */ jsx5(
744
- ERC1155QuantityModal,
745
- {
746
- buy: buyAction,
747
- collectable,
748
- order,
749
- chainId,
750
- collectionAddress,
751
- collectibleId
752
- }
753
- );
754
737
  };
755
738
 
756
739
  // src/react/ui/modals/CreateListingModal/Modal.tsx
757
- import { Show, observer as observer6 } from "@legendapp/state/react";
758
- import { parseUnits as parseUnits3 } from "viem";
759
- import { useAccount as useAccount3 } from "wagmi";
740
+ import { Show, observer as observer7 } from "@legendapp/state/react";
741
+ import { parseUnits as parseUnits2 } from "viem";
742
+ import { useAccount as useAccount4 } from "wagmi";
760
743
 
761
744
  // src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx
762
745
  import { Skeleton, Text as Text3 } from "@0xsequence/design-system";
763
- import { observer as observer3 } from "@legendapp/state/react";
746
+ import { observer as observer2 } from "@legendapp/state/react";
764
747
  import { addDays } from "date-fns";
765
748
  import { useState as useState2 } from "react";
766
749
 
@@ -943,9 +926,10 @@ var PRESET_RANGES = {
943
926
  offset: 30
944
927
  }
945
928
  };
946
- var ExpirationDateSelect = observer3(function ExpirationDateSelect2({
929
+ var ExpirationDateSelect = observer2(function ExpirationDateSelect2({
947
930
  className,
948
- $date
931
+ $date,
932
+ disabled
949
933
  }) {
950
934
  const [calendarDropdownOpen, setCalendarDropdownOpen] = useState2(false);
951
935
  function handleSelectPresetRange(range) {
@@ -965,44 +949,54 @@ var ExpirationDateSelect = observer3(function ExpirationDateSelect2({
965
949
  if (!$date.get()) {
966
950
  return /* @__PURE__ */ jsx8(Skeleton, { className: "mr-3 h-7 w-20 rounded-2xl" });
967
951
  }
968
- return /* @__PURE__ */ jsxs4("div", { className: "relative w-full", children: [
969
- /* @__PURE__ */ jsx8(
970
- Text3,
971
- {
972
- className: "w-full text-left font-body font-medium text-xs",
973
- fontWeight: "medium",
974
- color: "text100",
975
- children: "Set expiry"
976
- }
977
- ),
978
- /* @__PURE__ */ jsx8(
979
- "div",
980
- {
981
- className: `${className} mt-0.5 flex w-full items-center gap-2 rounded-sm border border-border-base`,
982
- children: /* @__PURE__ */ jsx8(
983
- CalendarDropdown,
952
+ return /* @__PURE__ */ jsxs4(
953
+ "div",
954
+ {
955
+ className: cn(
956
+ "relative w-full",
957
+ disabled && "pointer-events-none opacity-50"
958
+ ),
959
+ children: [
960
+ /* @__PURE__ */ jsx8(
961
+ Text3,
984
962
  {
985
- selectedDate: $date.get(),
986
- setSelectedDate: handleDateValueChange,
987
- onSelectPreset: handleSelectPresetRange,
988
- isOpen: calendarDropdownOpen,
989
- setIsOpen: setCalendarDropdownOpen
963
+ className: "w-full text-left font-body font-medium text-xs",
964
+ fontWeight: "medium",
965
+ color: "text100",
966
+ children: "Set expiry"
967
+ }
968
+ ),
969
+ /* @__PURE__ */ jsx8(
970
+ "div",
971
+ {
972
+ className: `${className} mt-0.5 flex w-full items-center gap-2 rounded-sm border border-border-base`,
973
+ children: /* @__PURE__ */ jsx8(
974
+ CalendarDropdown,
975
+ {
976
+ selectedDate: $date.get(),
977
+ setSelectedDate: handleDateValueChange,
978
+ onSelectPreset: handleSelectPresetRange,
979
+ isOpen: calendarDropdownOpen,
980
+ setIsOpen: setCalendarDropdownOpen
981
+ }
982
+ )
990
983
  }
991
984
  )
992
- }
993
- )
994
- ] });
985
+ ]
986
+ }
987
+ );
995
988
  });
996
989
  var expirationDateSelect_default = ExpirationDateSelect;
997
990
 
998
991
  // src/react/ui/modals/_internal/components/floorPriceText/index.tsx
999
- import { Text as Text4 } from "@0xsequence/design-system";
1000
- import { jsx as jsx9 } from "react/jsx-runtime";
992
+ import { Button as Button2, Text as Text4 } from "@0xsequence/design-system";
993
+ import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1001
994
  function FloorPriceText({
1002
995
  chainId,
1003
996
  collectionAddress,
1004
997
  tokenId,
1005
- price
998
+ price,
999
+ onBuyNow
1006
1000
  }) {
1007
1001
  const { data: listing, isLoading: listingLoading } = useLowestListing({
1008
1002
  tokenId,
@@ -1013,6 +1007,7 @@ function FloorPriceText({
1013
1007
  }
1014
1008
  });
1015
1009
  const floorPriceRaw = listing?.order?.priceAmount;
1010
+ const floorPriceFormatted = listing?.order?.priceAmountFormatted;
1016
1011
  const { data: priceComparison, isLoading: comparisonLoading } = useComparePrices({
1017
1012
  chainId,
1018
1013
  priceAmountRaw: price.amountRaw || "0",
@@ -1027,31 +1022,88 @@ function FloorPriceText({
1027
1022
  return null;
1028
1023
  }
1029
1024
  let floorPriceDifferenceText = "Same as floor price";
1025
+ let showBuyNowButton = false;
1030
1026
  if (priceComparison) {
1031
1027
  if (priceComparison.status === "same") {
1032
1028
  floorPriceDifferenceText = "Same as floor price";
1029
+ showBuyNowButton = true;
1030
+ } else if (priceComparison.status === "below") {
1031
+ floorPriceDifferenceText = `${priceComparison.percentageDifferenceFormatted}% below floor price`;
1033
1032
  } else {
1034
- floorPriceDifferenceText = `${priceComparison.percentageDifferenceFormatted}% ${priceComparison.status === "below" ? "below" : "above"} floor price`;
1033
+ floorPriceDifferenceText = `${priceComparison.percentageDifferenceFormatted}% above floor price`;
1034
+ showBuyNowButton = true;
1035
1035
  }
1036
- }
1037
- return /* @__PURE__ */ jsx9(
1038
- Text4,
1039
- {
1040
- className: "w-full text-left font-body text-sm",
1041
- fontWeight: "medium",
1042
- color: "text50",
1043
- children: floorPriceDifferenceText
1044
- }
1045
- );
1036
+ }
1037
+ return /* @__PURE__ */ jsxs5("div", { className: "flex w-full items-center justify-between gap-2", children: [
1038
+ /* @__PURE__ */ jsx9(Text4, { className: "text-left font-body font-medium text-muted text-xs", children: floorPriceDifferenceText }),
1039
+ showBuyNowButton && onBuyNow && /* @__PURE__ */ jsxs5(
1040
+ Button2,
1041
+ {
1042
+ size: "xs",
1043
+ variant: "text",
1044
+ className: "text-indigo-400 text-xs",
1045
+ onClick: onBuyNow,
1046
+ children: [
1047
+ "Buy for ",
1048
+ floorPriceFormatted,
1049
+ " ",
1050
+ price.currency.symbol
1051
+ ]
1052
+ }
1053
+ )
1054
+ ] });
1046
1055
  }
1047
1056
 
1048
1057
  // src/react/ui/modals/_internal/components/priceInput/index.tsx
1049
- import { NumericInput as NumericInput2, Text as Text5 } from "@0xsequence/design-system";
1058
+ import { NumericInput as NumericInput2, Text as Text6 } from "@0xsequence/design-system";
1050
1059
  import { use$ as use$2 } from "@legendapp/state/react";
1051
- import { useEffect as useEffect3, useRef, useState as useState4 } from "react";
1052
- import { parseUnits as parseUnits2 } from "viem";
1060
+ import { useEffect as useEffect3, useRef, useState as useState5 } from "react";
1061
+ import { parseUnits } from "viem";
1053
1062
  import { useAccount } from "wagmi";
1054
1063
 
1064
+ // src/react/hooks/useCurrencyBalance.tsx
1065
+ import { skipToken as skipToken3, useQuery as useQuery3 } from "@tanstack/react-query";
1066
+ import { erc20Abi as erc20Abi2, formatUnits, zeroAddress } from "viem";
1067
+ import { usePublicClient } from "wagmi";
1068
+ function useCurrencyBalance({
1069
+ currencyAddress,
1070
+ chainId,
1071
+ userAddress
1072
+ }) {
1073
+ const publicClient = usePublicClient({ chainId });
1074
+ return useQuery3({
1075
+ queryKey: ["balance", currencyAddress, chainId, userAddress],
1076
+ queryFn: !!userAddress && !!chainId && !!currencyAddress && !!publicClient ? async () => {
1077
+ if (currencyAddress === zeroAddress) {
1078
+ const balance2 = await publicClient.getBalance({
1079
+ address: userAddress
1080
+ });
1081
+ return {
1082
+ value: balance2,
1083
+ formatted: formatUnits(balance2, 18)
1084
+ };
1085
+ }
1086
+ const [balance, decimals] = await Promise.all([
1087
+ publicClient.readContract({
1088
+ address: currencyAddress,
1089
+ abi: erc20Abi2,
1090
+ functionName: "balanceOf",
1091
+ args: [userAddress]
1092
+ }),
1093
+ publicClient.readContract({
1094
+ address: currencyAddress,
1095
+ abi: erc20Abi2,
1096
+ functionName: "decimals"
1097
+ })
1098
+ ]);
1099
+ return {
1100
+ value: balance,
1101
+ formatted: formatUnits(balance, decimals)
1102
+ };
1103
+ } : skipToken3
1104
+ });
1105
+ }
1106
+
1055
1107
  // src/react/ui/modals/_internal/components/currencyImage/index.tsx
1056
1108
  import { TokenImage as TokenImage2 } from "@0xsequence/design-system";
1057
1109
  import { useState as useState3 } from "react";
@@ -1091,10 +1143,97 @@ var currencyImage_default = CurrencyImage;
1091
1143
 
1092
1144
  // src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx
1093
1145
  import { Skeleton as Skeleton2 } from "@0xsequence/design-system";
1094
- import { observer as observer4 } from "@legendapp/state/react";
1146
+ import { observer as observer3 } from "@legendapp/state/react";
1095
1147
  import { useEffect as useEffect2 } from "react";
1096
- import { jsx as jsx11 } from "react/jsx-runtime";
1097
- var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
1148
+
1149
+ // src/react/ui/components/_internals/custom-select/CustomSelect.tsx
1150
+ import {
1151
+ Button as Button3,
1152
+ ChevronDownIcon,
1153
+ DropdownMenuCheckboxItem,
1154
+ DropdownMenuContent as DropdownMenuContent2,
1155
+ DropdownMenuPortal as DropdownMenuPortal2,
1156
+ DropdownMenuRoot as DropdownMenuRoot2,
1157
+ DropdownMenuTrigger as DropdownMenuTrigger2,
1158
+ Text as Text5
1159
+ } from "@0xsequence/design-system";
1160
+ import { useState as useState4 } from "react";
1161
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1162
+ var CustomSelect = ({
1163
+ items,
1164
+ onValueChange,
1165
+ defaultValue,
1166
+ placeholder = "Select an option",
1167
+ disabled = false,
1168
+ className,
1169
+ testId = "custom-select"
1170
+ }) => {
1171
+ const [selectedItem, setSelectedItem] = useState4(
1172
+ defaultValue
1173
+ );
1174
+ const handleValueChange = (item) => {
1175
+ setSelectedItem(item);
1176
+ onValueChange?.(item.value);
1177
+ };
1178
+ return /* @__PURE__ */ jsxs6(DropdownMenuRoot2, { children: [
1179
+ /* @__PURE__ */ jsx11(DropdownMenuTrigger2, { asChild: true, disabled, children: /* @__PURE__ */ jsx11(
1180
+ Button3,
1181
+ {
1182
+ size: "xs",
1183
+ label: /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-center gap-1 truncate pr-3", children: [
1184
+ /* @__PURE__ */ jsx11(Text5, { variant: "xsmall", color: "text100", fontWeight: "bold", children: selectedItem ? selectedItem.content : placeholder }),
1185
+ /* @__PURE__ */ jsx11(ChevronDownIcon, { size: "xs" })
1186
+ ] }),
1187
+ shape: "circle",
1188
+ opacity: "100",
1189
+ className: `bg-overlay-light py-1.5 pl-3 ${className || ""}`,
1190
+ "data-testid": `${testId}-trigger`
1191
+ }
1192
+ ) }),
1193
+ /* @__PURE__ */ jsx11(DropdownMenuPortal2, { children: /* @__PURE__ */ jsx11(
1194
+ DropdownMenuContent2,
1195
+ {
1196
+ align: "end",
1197
+ side: "bottom",
1198
+ sideOffset: 8,
1199
+ className: "z-[1000] overflow-hidden rounded-xl border border-border-base bg-color-overlay-glass shadow-lg backdrop-blur-md",
1200
+ "data-testid": `${testId}-content`,
1201
+ children: /* @__PURE__ */ jsx11("div", { className: "max-h-[240px] overflow-auto", children: items.map((item) => /* @__PURE__ */ jsx11(
1202
+ DropdownMenuCheckboxItem,
1203
+ {
1204
+ checked: selectedItem?.value === item.value,
1205
+ onCheckedChange: () => handleValueChange(item),
1206
+ disabled: item.disabled,
1207
+ className: "group relative flex cursor-pointer select-none items-center rounded-lg px-2 py-1.5 outline-none transition-colors hover:bg-background-hover data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span[data-state='checked']]:hidden",
1208
+ "data-testid": `${testId}-option-${item.value}`,
1209
+ children: /* @__PURE__ */ jsx11("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx11("div", { className: "flex items-center gap-2 truncate", children: typeof item.content === "string" ? /* @__PURE__ */ jsx11(
1210
+ Text5,
1211
+ {
1212
+ variant: "small",
1213
+ color: selectedItem?.value === item.value ? "text100" : "text80",
1214
+ className: `truncate ${selectedItem?.value === item.value ? "font-bold" : ""}`,
1215
+ "data-testid": `${testId}-option-text-${item.value}`,
1216
+ children: item.content
1217
+ }
1218
+ ) : /* @__PURE__ */ jsx11(
1219
+ "div",
1220
+ {
1221
+ className: "truncate",
1222
+ "data-testid": `${testId}-option-content-${item.value}`,
1223
+ children: item.content
1224
+ }
1225
+ ) }) })
1226
+ },
1227
+ item.value
1228
+ )) })
1229
+ }
1230
+ ) })
1231
+ ] });
1232
+ };
1233
+
1234
+ // src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx
1235
+ import { jsx as jsx12 } from "react/jsx-runtime";
1236
+ var CurrencyOptionsSelect = observer3(function CurrencyOptionsSelect2({
1098
1237
  chainId,
1099
1238
  collectionAddress,
1100
1239
  secondCurrencyAsDefault,
@@ -1117,7 +1256,7 @@ var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
1117
1256
  }
1118
1257
  }, [currencies]);
1119
1258
  if (!currencies || currenciesLoading || !currency?.symbol) {
1120
- return /* @__PURE__ */ jsx11(Skeleton2, { className: "mr-3 h-7 w-20 rounded-2xl" });
1259
+ return /* @__PURE__ */ jsx12(Skeleton2, { className: "mr-3 h-7 w-20 rounded-2xl" });
1121
1260
  }
1122
1261
  const options = currencies.map(
1123
1262
  (currency2) => ({
@@ -1132,7 +1271,7 @@ var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
1132
1271
  );
1133
1272
  selectedCurrency$.set(selectedCurrency);
1134
1273
  };
1135
- return /* @__PURE__ */ jsx11(
1274
+ return /* @__PURE__ */ jsx12(
1136
1275
  CustomSelect,
1137
1276
  {
1138
1277
  items: options,
@@ -1148,7 +1287,7 @@ var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
1148
1287
  var currencyOptionsSelect_default = CurrencyOptionsSelect;
1149
1288
 
1150
1289
  // src/react/ui/modals/_internal/components/priceInput/index.tsx
1151
- import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
1290
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
1152
1291
  function PriceInput({
1153
1292
  chainId,
1154
1293
  collectionAddress,
@@ -1156,27 +1295,34 @@ function PriceInput({
1156
1295
  onPriceChange,
1157
1296
  checkBalance,
1158
1297
  secondCurrencyAsDefault,
1159
- includeNativeCurrency
1298
+ includeNativeCurrency,
1299
+ disabled
1160
1300
  }) {
1161
1301
  const { address: accountAddress } = useAccount();
1302
+ const inputRef = useRef(null);
1162
1303
  const currencyDecimals = use$2($price.currency.decimals);
1163
1304
  const currencyAddress = use$2($price.currency.contractAddress);
1164
1305
  const priceAmountRaw = use$2($price.amountRaw);
1306
+ useEffect3(() => {
1307
+ if (inputRef.current) {
1308
+ inputRef.current.focus();
1309
+ }
1310
+ }, []);
1165
1311
  const { data: balance, isSuccess: isBalanceSuccess } = useCurrencyBalance({
1166
1312
  currencyAddress,
1167
- chainId: Number(chainId),
1313
+ chainId,
1168
1314
  userAddress: accountAddress
1169
1315
  });
1170
1316
  const balanceError = !!checkBalance?.enabled && !!isBalanceSuccess && !!priceAmountRaw && !!currencyDecimals && BigInt(priceAmountRaw) > BigInt(balance?.value || 0n);
1171
1317
  if (checkBalance?.enabled) {
1172
1318
  checkBalance.callback(balanceError);
1173
1319
  }
1174
- const [value, setValue] = useState4("0");
1320
+ const [value, setValue] = useState5("0");
1175
1321
  const prevCurrencyDecimals = useRef(currencyDecimals);
1176
1322
  useEffect3(() => {
1177
1323
  if (prevCurrencyDecimals.current !== currencyDecimals && value !== "0") {
1178
1324
  try {
1179
- const parsedAmount = parseUnits2(value, Number(currencyDecimals));
1325
+ const parsedAmount = parseUnits(value, Number(currencyDecimals));
1180
1326
  $price.amountRaw.set(parsedAmount.toString());
1181
1327
  if (onPriceChange && parsedAmount !== 0n) {
1182
1328
  onPriceChange();
@@ -1191,7 +1337,7 @@ function PriceInput({
1191
1337
  const newValue = event.target.value;
1192
1338
  setValue(newValue);
1193
1339
  try {
1194
- const parsedAmount = parseUnits2(newValue, Number(currencyDecimals));
1340
+ const parsedAmount = parseUnits(newValue, Number(currencyDecimals));
1195
1341
  $price.amountRaw.set(parsedAmount.toString());
1196
1342
  if (onPriceChange && parsedAmount !== 0n) {
1197
1343
  onPriceChange();
@@ -1200,49 +1346,378 @@ function PriceInput({
1200
1346
  $price.amountRaw.set("0");
1201
1347
  }
1202
1348
  };
1203
- return /* @__PURE__ */ jsxs5("div", { className: "relative flex w-full flex-col", children: [
1204
- /* @__PURE__ */ jsx12("div", { className: "absolute top-8 left-2 flex items-center", children: /* @__PURE__ */ jsx12(currencyImage_default, { price$: $price }) }),
1205
- /* @__PURE__ */ jsx12("div", { className: "[&>label>div>.rounded-xl]:h-9 [&>label>div>.rounded-xl]:rounded-sm [&>label>div>.rounded-xl]:px-2 [&>label]:gap-1", children: /* @__PURE__ */ jsx12(
1206
- NumericInput2,
1207
- {
1208
- className: "ml-5 w-full text-xs",
1209
- name: "price-input",
1210
- decimals: currencyDecimals,
1211
- label: "Enter price",
1212
- labelLocation: "top",
1213
- controls: /* @__PURE__ */ jsx12(
1214
- currencyOptionsSelect_default,
1349
+ return /* @__PURE__ */ jsxs7(
1350
+ "div",
1351
+ {
1352
+ className: cn(
1353
+ "relative flex w-full flex-col",
1354
+ disabled && "pointer-events-none opacity-50"
1355
+ ),
1356
+ children: [
1357
+ /* @__PURE__ */ jsx13("div", { className: "absolute top-8 left-2 flex items-center", children: /* @__PURE__ */ jsx13(currencyImage_default, { price$: $price }) }),
1358
+ /* @__PURE__ */ jsx13("div", { className: "[&>label>div>.rounded-xl]:h-9 [&>label>div>.rounded-xl]:rounded-sm [&>label>div>.rounded-xl]:px-2 [&>label]:gap-1", children: /* @__PURE__ */ jsx13(
1359
+ NumericInput2,
1215
1360
  {
1216
- selectedCurrency$: $price.currency,
1217
- collectionAddress,
1218
- chainId,
1219
- secondCurrencyAsDefault,
1220
- includeNativeCurrency
1361
+ ref: inputRef,
1362
+ className: "ml-5 w-full text-xs",
1363
+ name: "price-input",
1364
+ decimals: currencyDecimals,
1365
+ label: "Enter price",
1366
+ labelLocation: "top",
1367
+ controls: /* @__PURE__ */ jsx13(
1368
+ currencyOptionsSelect_default,
1369
+ {
1370
+ selectedCurrency$: $price.currency,
1371
+ collectionAddress,
1372
+ chainId,
1373
+ secondCurrencyAsDefault,
1374
+ includeNativeCurrency
1375
+ }
1376
+ ),
1377
+ value,
1378
+ onChange: handleChange
1221
1379
  }
1222
- ),
1223
- value,
1224
- onChange: handleChange
1380
+ ) }),
1381
+ balanceError && /* @__PURE__ */ jsx13(
1382
+ Text6,
1383
+ {
1384
+ className: "-bottom-5 absolute font-body font-medium text-xs",
1385
+ color: "negative",
1386
+ children: "Insufficient balance"
1387
+ }
1388
+ )
1389
+ ]
1390
+ }
1391
+ );
1392
+ }
1393
+
1394
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx
1395
+ import { getNetwork } from "@0xsequence/connect";
1396
+ import { Divider, Skeleton as Skeleton4, Text as Text9 } from "@0xsequence/design-system";
1397
+ import { NetworkType } from "@0xsequence/network";
1398
+ import { observer as observer5 } from "@legendapp/state/react";
1399
+
1400
+ // src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx
1401
+ import { Image, Select, Text as Text7 } from "@0xsequence/design-system";
1402
+ import { observer as observer4 } from "@legendapp/state/react";
1403
+ import { useEffect as useEffect4 } from "react";
1404
+ import { formatUnits as formatUnits2, zeroAddress as zeroAddress2 } from "viem";
1405
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1406
+ var WaasFeeOptionsSelect = observer4(
1407
+ ({
1408
+ options,
1409
+ selectedFeeOption$
1410
+ }) => {
1411
+ options = options.map((option) => ({
1412
+ ...option,
1413
+ token: {
1414
+ ...option.token,
1415
+ contractAddress: option.token.contractAddress || zeroAddress2
1225
1416
  }
1226
- ) }),
1227
- balanceError && /* @__PURE__ */ jsx12(
1228
- Text5,
1417
+ }));
1418
+ const feeOptions = options.map((option) => {
1419
+ const value = option.token.contractAddress ?? "";
1420
+ return FeeOptionSelectItem({ value, option });
1421
+ });
1422
+ useEffect4(() => {
1423
+ if (options.length > 0 && !selectedFeeOption$.get())
1424
+ selectedFeeOption$.set(options[0]);
1425
+ }, [options]);
1426
+ if (options.length === 0 || !selectedFeeOption$.get()?.token) return null;
1427
+ return /* @__PURE__ */ jsx14(
1428
+ Select,
1229
1429
  {
1230
- className: "-bottom-5 absolute font-body font-medium text-xs",
1231
- color: "negative",
1232
- children: "Insufficient balance"
1430
+ items: feeOptions,
1431
+ name: "fee-option",
1432
+ options: feeOptions.map((option) => ({
1433
+ label: option.content,
1434
+ value: option.value
1435
+ })),
1436
+ onValueChange: (value) => {
1437
+ const selectedOption = options.find(
1438
+ (option) => option.token.contractAddress === value
1439
+ );
1440
+ selectedFeeOption$.set(selectedOption);
1441
+ },
1442
+ defaultValue: options[0].token.contractAddress ?? void 0
1233
1443
  }
1234
- )
1235
- ] });
1444
+ );
1445
+ }
1446
+ );
1447
+ function FeeOptionSelectItem({
1448
+ value,
1449
+ option
1450
+ }) {
1451
+ return {
1452
+ value,
1453
+ content: /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
1454
+ /* @__PURE__ */ jsx14(
1455
+ Image,
1456
+ {
1457
+ className: "h-3 w-3",
1458
+ src: option.token.logoURL,
1459
+ alt: option.token.symbol
1460
+ }
1461
+ ),
1462
+ /* @__PURE__ */ jsxs8("div", { className: "flex gap-1", children: [
1463
+ /* @__PURE__ */ jsx14(Text7, { className: "font-body text-sm", color: "text100", children: "Fee" }),
1464
+ /* @__PURE__ */ jsxs8(
1465
+ Text7,
1466
+ {
1467
+ className: "font-body text-sm",
1468
+ color: "text50",
1469
+ fontWeight: "semibold",
1470
+ children: [
1471
+ "(in ",
1472
+ option.token.symbol,
1473
+ ")"
1474
+ ]
1475
+ }
1476
+ ),
1477
+ /* @__PURE__ */ jsx14(Text7, { className: "font-body text-sm", color: "text100", children: ":" })
1478
+ ] }),
1479
+ /* @__PURE__ */ jsx14(Text7, { className: "font-body text-sm", children: formatUnits2(BigInt(option.value), option.token.decimals || 0) })
1480
+ ] })
1481
+ };
1236
1482
  }
1483
+ var WaasFeeOptionsSelect_default = WaasFeeOptionsSelect;
1484
+
1485
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/ActionButtons.tsx
1486
+ import { Button as Button4, Skeleton as Skeleton3, Spinner as Spinner2 } from "@0xsequence/design-system";
1487
+ import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
1488
+ var ActionButtons = ({
1489
+ onCancel,
1490
+ onConfirm,
1491
+ disabled,
1492
+ loading,
1493
+ confirmed,
1494
+ tokenSymbol
1495
+ }) => /* @__PURE__ */ jsxs9("div", { className: "mt-4 flex w-full items-center justify-end gap-2", children: [
1496
+ /* @__PURE__ */ jsx15(
1497
+ Button4,
1498
+ {
1499
+ pending: loading,
1500
+ onClick: onCancel,
1501
+ label: /* @__PURE__ */ jsx15("div", { className: "flex items-center gap-2", children: "Cancel" }),
1502
+ variant: "ghost",
1503
+ shape: "square",
1504
+ size: "md"
1505
+ }
1506
+ ),
1507
+ /* @__PURE__ */ jsx15(
1508
+ Button4,
1509
+ {
1510
+ disabled,
1511
+ pending: loading || confirmed,
1512
+ onClick: onConfirm,
1513
+ label: /* @__PURE__ */ jsx15("div", { className: "flex items-center gap-2", children: !confirmed ? tokenSymbol ? `Continue with ${tokenSymbol}` : /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", children: [
1514
+ "Continue with",
1515
+ /* @__PURE__ */ jsx15(Skeleton3, { className: "h-[20px] w-6 animate-shimmer" })
1516
+ ] }) : /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", children: [
1517
+ /* @__PURE__ */ jsx15(Spinner2, { size: "sm" }),
1518
+ "Confirming"
1519
+ ] }) }),
1520
+ variant: "primary",
1521
+ shape: "square",
1522
+ size: "md"
1523
+ }
1524
+ )
1525
+ ] });
1526
+ var ActionButtons_default = ActionButtons;
1527
+
1528
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/BalanceIndicator.tsx
1529
+ import { Text as Text8, WarningIcon } from "@0xsequence/design-system";
1530
+ import { CheckmarkIcon } from "@0xsequence/design-system";
1531
+ import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
1532
+ var BalanceIndicator = ({
1533
+ insufficientBalance,
1534
+ currencyBalance,
1535
+ selectedFeeOption
1536
+ }) => /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
1537
+ insufficientBalance ? /* @__PURE__ */ jsx16(WarningIcon, { className: "text-negative", size: "xs" }) : /* @__PURE__ */ jsx16(CheckmarkIcon, { className: "text-positive", size: "xs" }),
1538
+ /* @__PURE__ */ jsxs10(
1539
+ Text8,
1540
+ {
1541
+ className: "font-body font-medium text-xs",
1542
+ color: insufficientBalance ? "negative" : "text100",
1543
+ children: [
1544
+ "You have ",
1545
+ currencyBalance?.formatted || "0",
1546
+ " ",
1547
+ selectedFeeOption?.token.symbol
1548
+ ]
1549
+ }
1550
+ )
1551
+ ] });
1552
+ var BalanceIndicator_default = BalanceIndicator;
1553
+
1554
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/store.ts
1555
+ import { observable } from "@legendapp/state";
1556
+ var initialState = {
1557
+ selectedFeeOption: void 0,
1558
+ pendingFeeOptionConfirmation: void 0,
1559
+ isVisible: false,
1560
+ hide: () => {
1561
+ selectWaasFeeOptions$.isVisible.set(false);
1562
+ selectWaasFeeOptions$.selectedFeeOption.set(void 0);
1563
+ selectWaasFeeOptions$.pendingFeeOptionConfirmation.set(void 0);
1564
+ }
1565
+ };
1566
+ var selectWaasFeeOptions$ = observable(initialState);
1567
+
1568
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx
1569
+ import { useWaasFeeOptions } from "@0xsequence/connect";
1570
+ import { useEffect as useEffect5, useState as useState6 } from "react";
1571
+ import { zeroAddress as zeroAddress3 } from "viem";
1572
+ import { useAccount as useAccount2 } from "wagmi";
1573
+ var useWaasFeeOptionManager = (chainId) => {
1574
+ const { address: userAddress } = useAccount2();
1575
+ const selectedFeeOption$ = selectWaasFeeOptions$.selectedFeeOption;
1576
+ const [pendingFeeOptionConfirmation, confirmPendingFeeOption] = useWaasFeeOptions();
1577
+ const [feeOptionsConfirmed, setFeeOptionsConfirmed] = useState6(false);
1578
+ const selectedFeeOption = selectedFeeOption$.get();
1579
+ const { data: currencyBalance, isLoading: currencyBalanceLoading } = useCurrencyBalance({
1580
+ chainId,
1581
+ currencyAddress: selectedFeeOption?.token.contractAddress || zeroAddress3,
1582
+ userAddress
1583
+ });
1584
+ useEffect5(() => {
1585
+ if (!selectedFeeOption && pendingFeeOptionConfirmation) {
1586
+ selectedFeeOption$.set(
1587
+ pendingFeeOptionConfirmation.options[0]
1588
+ );
1589
+ }
1590
+ }, [pendingFeeOptionConfirmation]);
1591
+ const insufficientBalance = (() => {
1592
+ if (!selectedFeeOption?.value || !selectedFeeOption.token.decimals) {
1593
+ return false;
1594
+ }
1595
+ if (!currencyBalance?.value && currencyBalance?.value !== 0n) {
1596
+ return true;
1597
+ }
1598
+ try {
1599
+ const feeValue = BigInt(selectedFeeOption.value);
1600
+ return currencyBalance.value === 0n || currencyBalance.value < feeValue;
1601
+ } catch {
1602
+ return true;
1603
+ }
1604
+ })();
1605
+ const handleConfirmFeeOption = () => {
1606
+ if (!selectedFeeOption?.token || !pendingFeeOptionConfirmation?.id) return;
1607
+ confirmPendingFeeOption(
1608
+ pendingFeeOptionConfirmation?.id,
1609
+ selectedFeeOption.token.contractAddress || zeroAddress3
1610
+ );
1611
+ setFeeOptionsConfirmed(true);
1612
+ };
1613
+ return {
1614
+ selectedFeeOption$,
1615
+ selectedFeeOption,
1616
+ pendingFeeOptionConfirmation,
1617
+ currencyBalance,
1618
+ currencyBalanceLoading,
1619
+ insufficientBalance,
1620
+ feeOptionsConfirmed,
1621
+ handleConfirmFeeOption
1622
+ };
1623
+ };
1624
+ var useWaasFeeOptionManager_default = useWaasFeeOptionManager;
1625
+
1626
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx
1627
+ import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
1628
+ var SelectWaasFeeOptions = observer5(
1629
+ ({
1630
+ chainId,
1631
+ onCancel,
1632
+ titleOnConfirm,
1633
+ className
1634
+ }) => {
1635
+ const network = getNetwork(chainId);
1636
+ const isTestnet = network.type === NetworkType.TESTNET;
1637
+ const {
1638
+ selectedFeeOption$,
1639
+ selectedFeeOption,
1640
+ pendingFeeOptionConfirmation,
1641
+ currencyBalance,
1642
+ currencyBalanceLoading,
1643
+ insufficientBalance,
1644
+ feeOptionsConfirmed,
1645
+ handleConfirmFeeOption
1646
+ } = useWaasFeeOptionManager_default(chainId);
1647
+ console.log("pendingFeeOptionConfirmation", pendingFeeOptionConfirmation);
1648
+ const handleCancelFeeOption = () => {
1649
+ selectWaasFeeOptions$.hide();
1650
+ onCancel?.();
1651
+ };
1652
+ if (!selectWaasFeeOptions$.isVisible.get() || isTestnet || !selectedFeeOption) {
1653
+ return null;
1654
+ }
1655
+ return /* @__PURE__ */ jsxs11(
1656
+ "div",
1657
+ {
1658
+ className: cn(
1659
+ "flex w-full flex-col gap-2 rounded-2xl bg-button-emphasis p-0 backdrop-blur-md",
1660
+ className
1661
+ ),
1662
+ children: [
1663
+ /* @__PURE__ */ jsx17(Divider, { className: "mt-0 mb-4" }),
1664
+ /* @__PURE__ */ jsx17(Text9, { className: "mb-2 font-body text-large", fontWeight: "bold", children: feeOptionsConfirmed ? titleOnConfirm : "Select a fee option" }),
1665
+ !feeOptionsConfirmed && !pendingFeeOptionConfirmation && /* @__PURE__ */ jsx17(Skeleton4, { className: "h-[52px] w-full animate-shimmer rounded-xl" }),
1666
+ (feeOptionsConfirmed || pendingFeeOptionConfirmation) && /* @__PURE__ */ jsx17(
1667
+ "div",
1668
+ {
1669
+ className: cn(
1670
+ "[&>label>button>span]:overflow-hidden [&>label>button]:w-full [&>label>button]:text-xs [&>label]:flex [&>label]:w-full",
1671
+ feeOptionsConfirmed && "pointer-events-none opacity-70"
1672
+ ),
1673
+ children: /* @__PURE__ */ jsx17(
1674
+ WaasFeeOptionsSelect_default,
1675
+ {
1676
+ options: pendingFeeOptionConfirmation?.options || [
1677
+ selectedFeeOption
1678
+ ],
1679
+ selectedFeeOption$
1680
+ }
1681
+ )
1682
+ }
1683
+ ),
1684
+ /* @__PURE__ */ jsxs11("div", { className: "flex w-full items-start justify-between", children: [
1685
+ !feeOptionsConfirmed && (!pendingFeeOptionConfirmation || currencyBalanceLoading) && /* @__PURE__ */ jsx17(Skeleton4, { className: "h-[20px] w-2/3 animate-shimmer rounded-xl" }),
1686
+ (feeOptionsConfirmed || pendingFeeOptionConfirmation && !currencyBalanceLoading) && /* @__PURE__ */ jsx17(
1687
+ BalanceIndicator_default,
1688
+ {
1689
+ insufficientBalance,
1690
+ currencyBalance,
1691
+ selectedFeeOption
1692
+ }
1693
+ )
1694
+ ] }),
1695
+ /* @__PURE__ */ jsx17(
1696
+ ActionButtons_default,
1697
+ {
1698
+ onCancel: handleCancelFeeOption,
1699
+ onConfirm: handleConfirmFeeOption,
1700
+ disabled: !selectedFeeOption?.token || insufficientBalance || currencyBalanceLoading,
1701
+ loading: currencyBalanceLoading,
1702
+ confirmed: feeOptionsConfirmed,
1703
+ tokenSymbol: selectedFeeOption?.token.symbol
1704
+ }
1705
+ )
1706
+ ]
1707
+ }
1708
+ );
1709
+ }
1710
+ );
1711
+ var selectWaasFeeOptions_default = SelectWaasFeeOptions;
1237
1712
 
1238
1713
  // src/react/ui/modals/_internal/components/tokenPreview/index.tsx
1239
- import { Image, Skeleton as Skeleton3, Text as Text6 } from "@0xsequence/design-system";
1714
+ import { Image as Image2, Skeleton as Skeleton5, Text as Text10 } from "@0xsequence/design-system";
1240
1715
 
1241
1716
  // src/react/ui/images/chess-tile.png
1242
1717
  var chess_tile_default = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAK8AAACuCAYAAABAzl3QAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAInSURBVHgB7dyxbUMxEAXBs6FEjagv91/AD+keeNFCMw1csmBEvJ/P53Nm4Xme2Xi/37Ph/nfeP+f8/Q5EiZcs8ZIlXrLES5Z4yRIvWeIlS7xkiZcs8ZIlXrLES5Z4yRIvWS//Ud2v3vfykiVessRLlnjJEi9Z4iVLvGSJlyzxkiVessRLlnjJEi9Z4iVLvGS9/Ed1v3j/nOPlpUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMmyz+v+bNjnhQviJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWfV73Z8M+L1wQL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6y7PO6Pxv2eeGCeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSZZ/X/dmwzwsXxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPu87s+GfV64IF6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZNnndX827PPCBfGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1niJcs+r/uzYZ8XLoiXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6yxEuWeMkSL1n2ed2fDfu8cEG8ZImXLPGSJV6yxEuWeMkSL1niJUu8ZImXLPGSJV6y/gF97MkwfJRH7QAAAABJRU5ErkJggg==";
1243
1718
 
1244
1719
  // src/react/ui/modals/_internal/components/tokenPreview/index.tsx
1245
- import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
1720
+ import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
1246
1721
  function TokenPreview({
1247
1722
  collectionName,
1248
1723
  collectionAddress,
@@ -1255,17 +1730,17 @@ function TokenPreview({
1255
1730
  collectibleId
1256
1731
  });
1257
1732
  if (collectibleLoading) {
1258
- return /* @__PURE__ */ jsxs6("div", { className: "flex w-full items-center gap-3", children: [
1259
- /* @__PURE__ */ jsx13(Skeleton3, { className: "h-9 w-9 rounded-sm" }),
1260
- /* @__PURE__ */ jsxs6("div", { className: "flex grow flex-col gap-1", children: [
1261
- /* @__PURE__ */ jsx13(Skeleton3, { className: "h-3 w-1/3" }),
1262
- /* @__PURE__ */ jsx13(Skeleton3, { className: "h-3 w-1/2" })
1733
+ return /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center gap-3", children: [
1734
+ /* @__PURE__ */ jsx18(Skeleton5, { className: "h-9 w-9 rounded-sm" }),
1735
+ /* @__PURE__ */ jsxs12("div", { className: "flex grow flex-col gap-1", children: [
1736
+ /* @__PURE__ */ jsx18(Skeleton5, { className: "h-3 w-1/3" }),
1737
+ /* @__PURE__ */ jsx18(Skeleton5, { className: "h-3 w-1/2" })
1263
1738
  ] })
1264
1739
  ] });
1265
1740
  }
1266
- return /* @__PURE__ */ jsxs6("div", { className: "flex w-full items-center", children: [
1267
- /* @__PURE__ */ jsx13(
1268
- Image,
1741
+ return /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center", children: [
1742
+ /* @__PURE__ */ jsx18(
1743
+ Image2,
1269
1744
  {
1270
1745
  className: "h-9 w-9 rounded-sm",
1271
1746
  src: collectable?.image || chess_tile_default,
@@ -1273,10 +1748,10 @@ function TokenPreview({
1273
1748
  style: { objectFit: "cover" }
1274
1749
  }
1275
1750
  ),
1276
- /* @__PURE__ */ jsxs6("div", { className: "ml-3 flex flex-col", children: [
1277
- /* @__PURE__ */ jsx13(Text6, { className: "font-body font-medium text-xs", color: "text80", children: collectionName }),
1278
- /* @__PURE__ */ jsx13(
1279
- Text6,
1751
+ /* @__PURE__ */ jsxs12("div", { className: "ml-3 flex flex-col", children: [
1752
+ /* @__PURE__ */ jsx18(Text10, { className: "font-body font-medium text-xs", color: "text80", children: collectionName }),
1753
+ /* @__PURE__ */ jsx18(
1754
+ Text10,
1280
1755
  {
1281
1756
  className: "font-body font-bold text-xs",
1282
1757
  fontWeight: "bold",
@@ -1289,9 +1764,9 @@ function TokenPreview({
1289
1764
  }
1290
1765
 
1291
1766
  // src/react/ui/modals/_internal/components/transactionDetails/index.tsx
1292
- import { Image as Image2, Skeleton as Skeleton4, Text as Text7 } from "@0xsequence/design-system";
1293
- import { formatUnits } from "viem";
1294
- import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
1767
+ import { Image as Image3, Skeleton as Skeleton6, Text as Text11 } from "@0xsequence/design-system";
1768
+ import { formatUnits as formatUnits3 } from "viem";
1769
+ import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
1295
1770
  function TransactionDetails({
1296
1771
  collectibleId,
1297
1772
  collectionAddress,
@@ -1311,18 +1786,18 @@ function TransactionDetails({
1311
1786
  collectibleId
1312
1787
  });
1313
1788
  const priceLoading = !price || marketplaceConfigLoading || royaltyLoading;
1314
- let formattedAmount = price && formatUnits(BigInt(price.amountRaw), price.currency.decimals);
1789
+ let formattedAmount = price && formatUnits3(BigInt(price.amountRaw), price.currency.decimals);
1315
1790
  if (royalty !== null && formattedAmount && price) {
1316
1791
  formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royalty.percentage) / 100).toFixed(price.currency.decimals);
1317
1792
  }
1318
1793
  if (marketplaceFeePercentage !== void 0 && formattedAmount && price) {
1319
1794
  formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * marketplaceFeePercentage / 100).toFixed(price.currency.decimals);
1320
1795
  }
1321
- return /* @__PURE__ */ jsxs7("div", { className: "flex w-full items-center justify-between", children: [
1322
- /* @__PURE__ */ jsx14(Text7, { className: "font-body font-medium text-xs", color: "text50", children: "Total earnings" }),
1323
- /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-2", children: [
1324
- /* @__PURE__ */ jsx14(Image2, { className: "h-3 w-3", src: currencyImageUrl }),
1325
- priceLoading ? /* @__PURE__ */ jsx14(Skeleton4, { className: "h-4 w-24 animate-shimmer" }) : /* @__PURE__ */ jsxs7(Text7, { className: "font-body font-medium text-xs", color: "text100", children: [
1796
+ return /* @__PURE__ */ jsxs13("div", { className: "flex w-full items-center justify-between", children: [
1797
+ /* @__PURE__ */ jsx19(Text11, { className: "font-body font-medium text-xs", color: "text50", children: "Total earnings" }),
1798
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
1799
+ /* @__PURE__ */ jsx19(Image3, { className: "h-3 w-3", src: currencyImageUrl }),
1800
+ priceLoading ? /* @__PURE__ */ jsx19(Skeleton6, { className: "h-4 w-24 animate-shimmer" }) : /* @__PURE__ */ jsxs13(Text11, { className: "font-body font-medium text-xs", color: "text100", children: [
1326
1801
  showPlaceholderPrice ? "0" : formattedAmount,
1327
1802
  " ",
1328
1803
  price.currency.symbol
@@ -1331,17 +1806,50 @@ function TransactionDetails({
1331
1806
  ] });
1332
1807
  }
1333
1808
 
1809
+ // src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts
1810
+ import { getNetwork as getNetwork2 } from "@0xsequence/connect";
1811
+ import { NetworkType as NetworkType2 } from "@0xsequence/network";
1812
+ var useSelectWaasFeeOptions = ({
1813
+ chainId,
1814
+ isProcessing,
1815
+ feeOptionsVisible,
1816
+ selectedFeeOption
1817
+ }) => {
1818
+ const { wallet } = useWallet();
1819
+ const network = chainId ? getNetwork2(Number(chainId)) : void 0;
1820
+ const isTestnet = network?.type === NetworkType2.TESTNET;
1821
+ const isWaaS = wallet?.isWaaS;
1822
+ const isProcessingWithWaaS = isProcessing && isWaaS;
1823
+ const shouldHideActionButton = !isTestnet && isProcessingWithWaaS && feeOptionsVisible === true && !!selectedFeeOption;
1824
+ const waasFeeOptionsShown = wallet?.isWaaS && isProcessing && feeOptionsVisible;
1825
+ const getActionLabel = (defaultLabel, loadingLabel = "Loading fee options") => {
1826
+ if (isProcessing) {
1827
+ return isWaaS && !isTestnet ? loadingLabel : defaultLabel;
1828
+ }
1829
+ return defaultLabel;
1830
+ };
1831
+ return {
1832
+ isWaaS,
1833
+ isTestnet,
1834
+ feeOptionsVisible,
1835
+ shouldHideActionButton,
1836
+ waasFeeOptionsShown,
1837
+ isProcessingWithWaaS,
1838
+ getActionLabel
1839
+ };
1840
+ };
1841
+
1334
1842
  // src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx
1335
- import { useEffect as useEffect6 } from "react";
1843
+ import { useEffect as useEffect8 } from "react";
1336
1844
 
1337
1845
  // src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts
1338
- import { skipToken as skipToken2, useQuery as useQuery2 } from "@tanstack/react-query";
1339
- import { useAccount as useAccount2 } from "wagmi";
1846
+ import { skipToken as skipToken4, useQuery as useQuery4 } from "@tanstack/react-query";
1847
+ import { useAccount as useAccount3 } from "wagmi";
1340
1848
  var ONE_DAY_IN_SECONDS = 60 * 60 * 24;
1341
1849
  var useGetTokenApprovalData = (params) => {
1342
1850
  const config = useConfig();
1343
1851
  const { wallet } = useWallet();
1344
- const { address } = useAccount2();
1852
+ const { address } = useAccount3();
1345
1853
  const marketplaceClient = getMarketplaceClient(params.chainId, config);
1346
1854
  const listing = {
1347
1855
  tokenId: params.tokenId,
@@ -1351,7 +1859,7 @@ var useGetTokenApprovalData = (params) => {
1351
1859
  expiry: String(Number(dateToUnixTime(/* @__PURE__ */ new Date())) + ONE_DAY_IN_SECONDS)
1352
1860
  };
1353
1861
  const isEnabled = wallet && address && (params.query?.enabled ?? true) && !!params.currencyAddress;
1354
- const { data, isLoading, isSuccess } = useQuery2({
1862
+ const { data, isLoading, isSuccess } = useQuery4({
1355
1863
  queryKey: ["token-approval-data", params, address],
1356
1864
  queryFn: isEnabled ? async () => {
1357
1865
  const args = {
@@ -1374,7 +1882,7 @@ var useGetTokenApprovalData = (params) => {
1374
1882
  return {
1375
1883
  step: tokenApprovalStep
1376
1884
  };
1377
- } : skipToken2
1885
+ } : skipToken4
1378
1886
  });
1379
1887
  return {
1380
1888
  data,
@@ -1384,16 +1892,16 @@ var useGetTokenApprovalData = (params) => {
1384
1892
  };
1385
1893
 
1386
1894
  // src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx
1387
- import { formatUnits as formatUnits4 } from "viem";
1895
+ import { formatUnits as formatUnits6 } from "viem";
1388
1896
 
1389
1897
  // src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
1390
- import { Modal, Skeleton as Skeleton6, Text as Text11 } from "@0xsequence/design-system";
1898
+ import { Modal, Skeleton as Skeleton8, Text as Text15 } from "@0xsequence/design-system";
1391
1899
  import { use$ as use$3 } from "@legendapp/state/react";
1392
1900
 
1393
1901
  // src/react/ui/modals/_internal/components/transaction-footer/index.tsx
1394
- import { CheckmarkIcon, Spinner as Spinner2, Text as Text8 } from "@0xsequence/design-system";
1902
+ import { CheckmarkIcon as CheckmarkIcon2, Spinner as Spinner3, Text as Text12 } from "@0xsequence/design-system";
1395
1903
  import { networks } from "@0xsequence/network";
1396
- import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
1904
+ import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
1397
1905
  function TransactionFooter({
1398
1906
  transactionHash,
1399
1907
  orderId,
@@ -1403,35 +1911,32 @@ function TransactionFooter({
1403
1911
  isTimeout,
1404
1912
  chainId
1405
1913
  }) {
1406
- const icon = (isConfirmed || orderId) && /* @__PURE__ */ jsx15(PositiveCircle, {}) || isConfirming && /* @__PURE__ */ jsx15(Spinner2, { size: "md" });
1914
+ const icon = (isConfirmed || orderId) && /* @__PURE__ */ jsx20(PositiveCircle, {}) || isConfirming && /* @__PURE__ */ jsx20(Spinner3, { size: "md" });
1407
1915
  const title = (isConfirmed || orderId) && "Transaction complete" || isConfirming && "Processing transaction" || isFailed && "Transaction failed" || isTimeout && "Transaction took longer than expected";
1408
1916
  const transactionUrl = `${networks[chainId]?.blockExplorer?.rootUrl}tx/${transactionHash}`;
1409
- return /* @__PURE__ */ jsxs8("div", { className: "flex items-center", children: [
1917
+ return /* @__PURE__ */ jsxs14("div", { className: "flex items-center", children: [
1410
1918
  icon,
1411
- /* @__PURE__ */ jsx15(
1412
- Text8,
1919
+ /* @__PURE__ */ jsx20(
1920
+ Text12,
1413
1921
  {
1414
- className: "ml-2 font-body text-base",
1922
+ className: "ml-2 grow font-body text-sm",
1415
1923
  color: "text50",
1416
1924
  fontWeight: "medium",
1417
1925
  children: title
1418
1926
  }
1419
1927
  ),
1420
- /* @__PURE__ */ jsx15(
1928
+ /* @__PURE__ */ jsx20(
1421
1929
  "a",
1422
1930
  {
1423
- className: "ml-2 grow text-right no-underline",
1931
+ className: "ml-2 text-right no-underline",
1424
1932
  href: transactionUrl,
1425
1933
  target: "_blank",
1426
1934
  rel: "noopener noreferrer",
1427
- children: /* @__PURE__ */ jsx15(
1428
- Text8,
1935
+ children: /* @__PURE__ */ jsx20(
1936
+ Text12,
1429
1937
  {
1430
- className: "text-right font-body text-base",
1938
+ className: "text-right font-body text-sm text-violet-400",
1431
1939
  fontWeight: "medium",
1432
- style: {
1433
- color: "hsla(247, 100%, 75%, 1)"
1434
- },
1435
1940
  children: transactionHash && truncateMiddle(transactionHash, 4, 4)
1436
1941
  }
1437
1942
  )
@@ -1439,27 +1944,27 @@ function TransactionFooter({
1439
1944
  )
1440
1945
  ] });
1441
1946
  }
1442
- var PositiveCircle = () => /* @__PURE__ */ jsx15("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-[#35a554]", children: /* @__PURE__ */ jsx15(CheckmarkIcon, { size: "xs", color: "white" }) });
1947
+ var PositiveCircle = () => /* @__PURE__ */ jsx20("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-[#35a554]", children: /* @__PURE__ */ jsx20(CheckmarkIcon2, { size: "xs", color: "white" }) });
1443
1948
 
1444
1949
  // src/react/ui/modals/_internal/components/transactionPreview/index.tsx
1445
- import { Image as Image3, NetworkImage, Skeleton as Skeleton5, Text as Text10 } from "@0xsequence/design-system";
1446
- import { observer as observer5 } from "@legendapp/state/react";
1447
- import { formatUnits as formatUnits2 } from "viem";
1950
+ import { Image as Image4, NetworkImage, Skeleton as Skeleton7, Text as Text14 } from "@0xsequence/design-system";
1951
+ import { observer as observer6 } from "@legendapp/state/react";
1952
+ import { formatUnits as formatUnits4 } from "viem";
1448
1953
 
1449
1954
  // src/react/ui/modals/_internal/components/timeAgo/index.tsx
1450
- import { Text as Text9 } from "@0xsequence/design-system";
1955
+ import { Text as Text13 } from "@0xsequence/design-system";
1451
1956
  import { formatDistanceToNow } from "date-fns";
1452
- import { useEffect as useEffect4, useState as useState5 } from "react";
1453
- import { jsx as jsx16 } from "react/jsx-runtime";
1957
+ import { useEffect as useEffect6, useState as useState7 } from "react";
1958
+ import { jsx as jsx21 } from "react/jsx-runtime";
1454
1959
  function TimeAgo({ date }) {
1455
- const [timeAgo, setTimeAgo] = useState5("");
1456
- useEffect4(() => {
1960
+ const [timeAgo, setTimeAgo] = useState7("");
1961
+ useEffect6(() => {
1457
1962
  const interval = setInterval(() => {
1458
1963
  setTimeAgo(formatDistanceToNow(date));
1459
1964
  }, 1e3);
1460
1965
  return () => clearInterval(interval);
1461
1966
  }, [date]);
1462
- return /* @__PURE__ */ jsx16("div", { className: "flex grow items-center justify-end", children: /* @__PURE__ */ jsx16(Text9, { className: "text-sm", color: "text50", children: timeAgo }) });
1967
+ return /* @__PURE__ */ jsx21("div", { className: "flex grow items-center justify-end", children: /* @__PURE__ */ jsx21(Text13, { className: "text-sm", color: "text50", children: timeAgo }) });
1463
1968
  }
1464
1969
 
1465
1970
  // src/react/ui/modals/_internal/components/transactionStatusModal/store.ts
@@ -1503,7 +2008,7 @@ var initialState2 = {
1503
2008
  status: "PENDING",
1504
2009
  price: void 0,
1505
2010
  collectionAddress: "",
1506
- chainId: "",
2011
+ chainId: 0,
1507
2012
  collectibleId: "",
1508
2013
  type: void 0,
1509
2014
  callbacks: void 0,
@@ -1558,8 +2063,8 @@ function useTransactionPreviewTitle(orderId, status, type) {
1558
2063
  }
1559
2064
 
1560
2065
  // src/react/ui/modals/_internal/components/transactionPreview/index.tsx
1561
- import { jsx as jsx17, jsxs as jsxs9 } from "react/jsx-runtime";
1562
- var TransactionPreview = observer5(
2066
+ import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
2067
+ var TransactionPreview = observer6(
1563
2068
  ({
1564
2069
  orderId,
1565
2070
  price,
@@ -1586,19 +2091,19 @@ var TransactionPreview = observer5(
1586
2091
  const collectibleImage = collectible?.image;
1587
2092
  const collectibleName = collectible?.name;
1588
2093
  const collectionName = collection?.name;
1589
- const priceFormatted = price ? formatUnits2(BigInt(price?.amountRaw), price?.currency.decimals) : void 0;
2094
+ const priceFormatted = price ? formatUnits4(BigInt(price?.amountRaw), price?.currency.decimals) : void 0;
1590
2095
  if (collectibleLoading || collectionLoading) {
1591
- return /* @__PURE__ */ jsx17("div", { className: "w-full rounded-xl", style: { height: 83 }, children: /* @__PURE__ */ jsx17(Skeleton5, { style: { width: "100%", height: "100%" } }) });
2096
+ return /* @__PURE__ */ jsx22("div", { className: "w-full rounded-xl", style: { height: 83 }, children: /* @__PURE__ */ jsx22(Skeleton7, { style: { width: "100%", height: "100%" } }) });
1592
2097
  }
1593
- return /* @__PURE__ */ jsxs9(
2098
+ return /* @__PURE__ */ jsxs15(
1594
2099
  "div",
1595
2100
  {
1596
2101
  className: "rounded-xl bg-background-secondary p-3",
1597
2102
  "data-testid": "transaction-preview",
1598
2103
  children: [
1599
- /* @__PURE__ */ jsxs9("div", { className: "flex items-center", children: [
1600
- /* @__PURE__ */ jsx17(
1601
- Text10,
2104
+ /* @__PURE__ */ jsxs15("div", { className: "flex items-center", children: [
2105
+ /* @__PURE__ */ jsx22(
2106
+ Text14,
1602
2107
  {
1603
2108
  className: "mr-1 font-body text-xs",
1604
2109
  color: "text80",
@@ -1607,12 +2112,12 @@ var TransactionPreview = observer5(
1607
2112
  children: title
1608
2113
  }
1609
2114
  ),
1610
- /* @__PURE__ */ jsx17(NetworkImage, { chainId: Number(chainId), size: "xs" }),
1611
- isConfirming && /* @__PURE__ */ jsx17(TimeAgo, { date: /* @__PURE__ */ new Date() })
2115
+ /* @__PURE__ */ jsx22(NetworkImage, { chainId: Number(chainId), size: "xs" }),
2116
+ isConfirming && /* @__PURE__ */ jsx22(TimeAgo, { date: /* @__PURE__ */ new Date() })
1612
2117
  ] }),
1613
- /* @__PURE__ */ jsxs9("div", { className: "mt-2 flex items-center", children: [
1614
- /* @__PURE__ */ jsx17(
1615
- Image3,
2118
+ /* @__PURE__ */ jsxs15("div", { className: "mt-2 flex items-center", children: [
2119
+ /* @__PURE__ */ jsx22(
2120
+ Image4,
1616
2121
  {
1617
2122
  className: "mr-3 h-9 w-9 rounded-sm",
1618
2123
  src: collectibleImage || chess_tile_default,
@@ -1621,9 +2126,9 @@ var TransactionPreview = observer5(
1621
2126
  "data-testid": "transaction-preview-image"
1622
2127
  }
1623
2128
  ),
1624
- /* @__PURE__ */ jsxs9("div", { className: "flex flex-col items-start gap-0.5", children: [
1625
- /* @__PURE__ */ jsx17(
1626
- Text10,
2129
+ /* @__PURE__ */ jsxs15("div", { className: "flex flex-col items-start gap-0.5", children: [
2130
+ /* @__PURE__ */ jsx22(
2131
+ Text14,
1627
2132
  {
1628
2133
  className: "font-body text-xs",
1629
2134
  color: "text80",
@@ -1632,8 +2137,8 @@ var TransactionPreview = observer5(
1632
2137
  children: collectionName
1633
2138
  }
1634
2139
  ),
1635
- /* @__PURE__ */ jsx17(
1636
- Text10,
2140
+ /* @__PURE__ */ jsx22(
2141
+ Text14,
1637
2142
  {
1638
2143
  className: "font-body text-xs",
1639
2144
  color: "text100",
@@ -1643,15 +2148,15 @@ var TransactionPreview = observer5(
1643
2148
  }
1644
2149
  )
1645
2150
  ] }),
1646
- price && /* @__PURE__ */ jsxs9(
2151
+ price && /* @__PURE__ */ jsxs15(
1647
2152
  "div",
1648
2153
  {
1649
2154
  className: "flex grow items-center justify-end gap-1",
1650
2155
  "data-testid": "transaction-preview-price",
1651
2156
  children: [
1652
- /* @__PURE__ */ jsx17(Image3, { className: "h-3 w-3", src: currencyImageUrl }),
1653
- /* @__PURE__ */ jsxs9(
1654
- Text10,
2157
+ /* @__PURE__ */ jsx22(Image4, { className: "h-3 w-3", src: currencyImageUrl }),
2158
+ /* @__PURE__ */ jsxs15(
2159
+ Text14,
1655
2160
  {
1656
2161
  className: "font-body text-xs",
1657
2162
  color: "text100",
@@ -1676,19 +2181,19 @@ var transactionPreview_default = TransactionPreview;
1676
2181
 
1677
2182
  // src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts
1678
2183
  import { TransactionStatus as IndexerTransactionStatus } from "@0xsequence/indexer";
1679
- import { skipToken as skipToken3, useQuery as useQuery3 } from "@tanstack/react-query";
1680
- import { useEffect as useEffect5, useState as useState6 } from "react";
2184
+ import { skipToken as skipToken5, useQuery as useQuery5 } from "@tanstack/react-query";
2185
+ import { useEffect as useEffect7, useState as useState8 } from "react";
1681
2186
  import { WaitForTransactionReceiptTimeoutError } from "viem";
1682
2187
  var useTransactionStatus = (hash, chainId, callbacks) => {
1683
2188
  const { wallet } = useWallet();
1684
- const [status, setStatus] = useState6(
2189
+ const [status, setStatus] = useState8(
1685
2190
  hash ? "PENDING" : "SUCCESS"
1686
2191
  );
1687
- const { data: confirmationResult } = useQuery3({
2192
+ const { data: confirmationResult } = useQuery5({
1688
2193
  queryKey: ["transaction-confirmation", hash, chainId, !!wallet],
1689
- queryFn: !!wallet && hash ? async () => await wallet.handleConfirmTransactionStep(hash, Number(chainId)) : skipToken3
2194
+ queryFn: !!wallet && hash ? async () => await wallet.handleConfirmTransactionStep(hash, Number(chainId)) : skipToken5
1690
2195
  });
1691
- useEffect5(() => {
2196
+ useEffect7(() => {
1692
2197
  if (!hash) {
1693
2198
  setStatus("SUCCESS");
1694
2199
  return;
@@ -1717,7 +2222,7 @@ var useTransactionStatus = (hash, chainId, callbacks) => {
1717
2222
  var useTransactionStatus_default = useTransactionStatus;
1718
2223
 
1719
2224
  // src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts
1720
- import { formatUnits as formatUnits3 } from "viem";
2225
+ import { formatUnits as formatUnits5 } from "viem";
1721
2226
 
1722
2227
  // src/react/ui/modals/_internal/components/transactionStatusModal/util/getFormattedType.ts
1723
2228
  function getFormattedType(transactionType, verb = false) {
@@ -1748,7 +2253,7 @@ function getTransactionStatusModalMessage({
1748
2253
  price
1749
2254
  }) {
1750
2255
  const hideCollectibleName = transactionType === "CANCEL";
1751
- const formattedPrice = price ? formatUnits3(BigInt(price.amountRaw), price.currency.decimals) : "";
2256
+ const formattedPrice = price ? formatUnits5(BigInt(price.amountRaw), price.currency.decimals) : "";
1752
2257
  if (orderId) {
1753
2258
  return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ""}. It's been confirmed on the blockchain!`;
1754
2259
  }
@@ -1796,7 +2301,7 @@ function getTransactionStatusModalTitle({
1796
2301
  }
1797
2302
 
1798
2303
  // src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
1799
- import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
2304
+ import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
1800
2305
  var invalidateQueries = async (queriesToInvalidate) => {
1801
2306
  const queryClient = getQueryClient();
1802
2307
  if (!queriesToInvalidate) {
@@ -1817,7 +2322,7 @@ var useTransactionStatusModal = () => {
1817
2322
  };
1818
2323
  var TransactionStatusModal = () => {
1819
2324
  const isOpen = use$3(transactionStatusModal$.isOpen);
1820
- return isOpen ? /* @__PURE__ */ jsx18(TransactionStatusModalContent, {}) : null;
2325
+ return isOpen ? /* @__PURE__ */ jsx23(TransactionStatusModalContent, {}) : null;
1821
2326
  };
1822
2327
  function TransactionStatusModalContent() {
1823
2328
  const {
@@ -1851,9 +2356,12 @@ function TransactionStatusModalContent() {
1851
2356
  });
1852
2357
  const handleClose = () => {
1853
2358
  invalidateQueries(queriesToInvalidate);
2359
+ if (selectWaasFeeOptions$.isVisible.get()) {
2360
+ selectWaasFeeOptions$.hide();
2361
+ }
1854
2362
  transactionStatusModal$.close();
1855
2363
  };
1856
- return /* @__PURE__ */ jsx18(
2364
+ return /* @__PURE__ */ jsx23(
1857
2365
  Modal,
1858
2366
  {
1859
2367
  isDismissible: true,
@@ -1861,9 +2369,9 @@ function TransactionStatusModalContent() {
1861
2369
  size: "sm",
1862
2370
  overlayProps: MODAL_OVERLAY_PROPS,
1863
2371
  "data-testid": "transaction-status-modal",
1864
- children: /* @__PURE__ */ jsxs10("div", { className: "grid flex-col gap-6 p-7", children: [
1865
- title ? /* @__PURE__ */ jsx18(
1866
- Text11,
2372
+ children: /* @__PURE__ */ jsxs16("div", { className: "grid flex-col gap-6 p-7", children: [
2373
+ title ? /* @__PURE__ */ jsx23(
2374
+ Text15,
1867
2375
  {
1868
2376
  className: "font-body text-xl",
1869
2377
  fontWeight: "bold",
@@ -1871,29 +2379,29 @@ function TransactionStatusModalContent() {
1871
2379
  "data-testid": "transaction-status-title",
1872
2380
  children: title
1873
2381
  }
1874
- ) : /* @__PURE__ */ jsx18(
1875
- Skeleton6,
2382
+ ) : /* @__PURE__ */ jsx23(
2383
+ Skeleton8,
1876
2384
  {
1877
2385
  className: "h-6 w-16",
1878
2386
  "data-testid": "transaction-modal-title-skeleton"
1879
2387
  }
1880
2388
  ),
1881
- message ? /* @__PURE__ */ jsx18(
1882
- Text11,
2389
+ message ? /* @__PURE__ */ jsx23(
2390
+ Text15,
1883
2391
  {
1884
2392
  className: "font-body text-sm",
1885
2393
  color: "text80",
1886
2394
  "data-testid": "transaction-status-message",
1887
2395
  children: message
1888
2396
  }
1889
- ) : /* @__PURE__ */ jsx18(
1890
- Skeleton6,
2397
+ ) : /* @__PURE__ */ jsx23(
2398
+ Skeleton8,
1891
2399
  {
1892
2400
  className: "h-4 w-20",
1893
2401
  "data-testid": "transaction-modal-content-skeleton"
1894
2402
  }
1895
2403
  ),
1896
- /* @__PURE__ */ jsx18(
2404
+ /* @__PURE__ */ jsx23(
1897
2405
  transactionPreview_default,
1898
2406
  {
1899
2407
  orderId,
@@ -1909,7 +2417,7 @@ function TransactionStatusModalContent() {
1909
2417
  isTimeout: transactionStatus === "TIMEOUT"
1910
2418
  }
1911
2419
  ),
1912
- /* @__PURE__ */ jsx18(
2420
+ /* @__PURE__ */ jsx23(
1913
2421
  TransactionFooter,
1914
2422
  {
1915
2423
  transactionHash: hash,
@@ -1942,7 +2450,7 @@ var useTransactionSteps = ({
1942
2450
  const { show: showTransactionStatusModal } = useTransactionStatusModal();
1943
2451
  const sdkConfig = useConfig();
1944
2452
  const { data: currencies } = useCurrencies({
1945
- chainId: Number(chainId)
2453
+ chainId
1946
2454
  });
1947
2455
  const currency = currencies?.find(
1948
2456
  (currency2) => currency2.contractAddress === listingInput.listing.currencyAddress
@@ -1997,10 +2505,12 @@ var useTransactionSteps = ({
1997
2505
  steps$.approval.isExecuting.set(false);
1998
2506
  }
1999
2507
  };
2000
- const createListing = async () => {
2508
+ const createListing = async ({
2509
+ isTransactionExecuting
2510
+ }) => {
2001
2511
  if (!wallet) return;
2002
2512
  try {
2003
- steps$.transaction.isExecuting.set(true);
2513
+ steps$.transaction.isExecuting.set(isTransactionExecuting);
2004
2514
  const steps3 = await getListingSteps();
2005
2515
  const transactionStep = steps3?.find(
2006
2516
  (step) => step.id === "createListing" /* createListing */
@@ -2057,7 +2567,7 @@ var useTransactionSteps = ({
2057
2567
  )?.decimals || 0;
2058
2568
  const currencyValueRaw = Number(listingInput.listing.pricePerToken);
2059
2569
  const currencyValueDecimal = Number(
2060
- formatUnits4(BigInt(currencyValueRaw), currencyDecimal)
2570
+ formatUnits6(BigInt(currencyValueRaw), currencyDecimal)
2061
2571
  );
2062
2572
  analytics.trackCreateListing({
2063
2573
  props: {
@@ -2065,7 +2575,7 @@ var useTransactionSteps = ({
2065
2575
  collectionAddress,
2066
2576
  currencyAddress: listingInput.listing.currencyAddress,
2067
2577
  currencySymbol: "",
2068
- chainId,
2578
+ chainId: chainId.toString(),
2069
2579
  txnHash: hash || ""
2070
2580
  },
2071
2581
  nums: {
@@ -2139,7 +2649,7 @@ var useCreateListing = ({
2139
2649
  enabled: !marketplaceIsLoading
2140
2650
  }
2141
2651
  });
2142
- useEffect6(() => {
2652
+ useEffect8(() => {
2143
2653
  if (tokenApproval?.step && !tokenApprovalIsLoading) {
2144
2654
  steps$.approval.exist.set(true);
2145
2655
  }
@@ -2186,7 +2696,7 @@ var steps = {
2186
2696
  var initialState3 = {
2187
2697
  isOpen: false,
2188
2698
  collectionAddress: "",
2189
- chainId: "",
2699
+ chainId: 0,
2190
2700
  collectibleId: "",
2191
2701
  orderbookKind: "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
2192
2702
  collectionName: "",
@@ -2196,7 +2706,8 @@ var initialState3 = {
2196
2706
  invalidQuantity: false,
2197
2707
  expiry: new Date(addDays2(/* @__PURE__ */ new Date(), 7).toJSON()),
2198
2708
  callbacks: void 0,
2199
- steps: { ...steps }
2709
+ steps: { ...steps },
2710
+ listingIsBeingProcessed: false
2200
2711
  };
2201
2712
  var actions = {
2202
2713
  open: (args) => {
@@ -2212,6 +2723,9 @@ var actions = {
2212
2723
  createListingModal$.set({ ...initialState3, ...actions });
2213
2724
  createListingModal$.listingPrice.set({ ...listingPrice });
2214
2725
  createListingModal$.steps.set({ ...steps });
2726
+ createListingModal$.listingIsBeingProcessed.set(false);
2727
+ createListingModal$.steps.approval.isExecuting.set(false);
2728
+ createListingModal$.steps.transaction.isExecuting.set(false);
2215
2729
  }
2216
2730
  };
2217
2731
  var createListingModal$ = observable3({
@@ -2220,11 +2734,11 @@ var createListingModal$ = observable3({
2220
2734
  });
2221
2735
 
2222
2736
  // src/react/ui/modals/CreateListingModal/Modal.tsx
2223
- import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
2737
+ import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
2224
2738
  var CreateListingModal = () => {
2225
- return /* @__PURE__ */ jsx19(Show, { if: createListingModal$.isOpen, children: () => /* @__PURE__ */ jsx19(Modal2, {}) });
2739
+ return /* @__PURE__ */ jsx24(Show, { if: createListingModal$.isOpen, children: () => /* @__PURE__ */ jsx24(Modal2, {}) });
2226
2740
  };
2227
- var Modal2 = observer6(() => {
2741
+ var Modal2 = observer7(() => {
2228
2742
  const state = createListingModal$.get();
2229
2743
  const {
2230
2744
  collectionAddress,
@@ -2232,9 +2746,22 @@ var Modal2 = observer6(() => {
2232
2746
  listingPrice: listingPrice2,
2233
2747
  collectibleId,
2234
2748
  orderbookKind,
2235
- callbacks
2749
+ callbacks,
2750
+ listingIsBeingProcessed
2236
2751
  } = state;
2237
2752
  const steps$ = createListingModal$.steps;
2753
+ const { wallet } = useWallet();
2754
+ const {
2755
+ shouldHideActionButton: shouldHideListButton,
2756
+ waasFeeOptionsShown,
2757
+ getActionLabel,
2758
+ isTestnet
2759
+ } = useSelectWaasFeeOptions({
2760
+ chainId,
2761
+ isProcessing: listingIsBeingProcessed,
2762
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
2763
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
2764
+ });
2238
2765
  const {
2239
2766
  data: collectible,
2240
2767
  isLoading: collectableIsLoading,
@@ -2262,9 +2789,9 @@ var Modal2 = observer6(() => {
2262
2789
  collectionAddress
2263
2790
  });
2264
2791
  const modalLoading = collectableIsLoading || collectionIsLoading || currenciesLoading;
2265
- const { address } = useAccount3();
2792
+ const { address } = useAccount4();
2266
2793
  const { data: balance } = useBalanceOfCollectible({
2267
- chainId: Number(chainId),
2794
+ chainId,
2268
2795
  collectionAddress,
2269
2796
  collectableId: collectibleId,
2270
2797
  userAddress: address ?? void 0
@@ -2274,7 +2801,7 @@ var Modal2 = observer6(() => {
2274
2801
  contractType: collection?.type,
2275
2802
  listing: {
2276
2803
  tokenId: collectibleId,
2277
- quantity: parseUnits3(
2804
+ quantity: parseUnits2(
2278
2805
  createListingModal$.quantity.get(),
2279
2806
  collectible?.decimals || 0
2280
2807
  ).toString(),
@@ -2291,7 +2818,7 @@ var Modal2 = observer6(() => {
2291
2818
  steps$
2292
2819
  });
2293
2820
  if (collectableIsError || collectionIsError || currenciesIsError) {
2294
- return /* @__PURE__ */ jsx19(
2821
+ return /* @__PURE__ */ jsx24(
2295
2822
  ErrorModal,
2296
2823
  {
2297
2824
  isOpen: createListingModal$.isOpen.get(),
@@ -2302,7 +2829,7 @@ var Modal2 = observer6(() => {
2302
2829
  );
2303
2830
  }
2304
2831
  if (!modalLoading && (!currencies || currencies.length === 0)) {
2305
- return /* @__PURE__ */ jsx19(
2832
+ return /* @__PURE__ */ jsx24(
2306
2833
  ErrorModal,
2307
2834
  {
2308
2835
  isOpen: createListingModal$.isOpen.get(),
@@ -2313,6 +2840,23 @@ var Modal2 = observer6(() => {
2313
2840
  }
2314
2841
  );
2315
2842
  }
2843
+ const handleCreateListing = async () => {
2844
+ createListingModal$.listingIsBeingProcessed.set(true);
2845
+ try {
2846
+ if (wallet?.isWaaS) {
2847
+ selectWaasFeeOptions$.isVisible.set(true);
2848
+ }
2849
+ await createListing({
2850
+ isTransactionExecuting: wallet?.isWaaS ? !isTestnet : false
2851
+ });
2852
+ } catch (error) {
2853
+ console.error("Create listing failed:", error);
2854
+ } finally {
2855
+ createListingModal$.listingIsBeingProcessed.set(false);
2856
+ steps$.transaction.isExecuting.set(false);
2857
+ }
2858
+ };
2859
+ const listCtaLabel = getActionLabel("List item for sale");
2316
2860
  const ctas = [
2317
2861
  {
2318
2862
  label: "Approve TOKEN",
@@ -2323,25 +2867,29 @@ var Modal2 = observer6(() => {
2323
2867
  disabled: createListingModal$.invalidQuantity.get() || listingPrice2.amountRaw === "0" || steps$?.approval.isExecuting.get() || tokenApprovalIsLoading || isLoading
2324
2868
  },
2325
2869
  {
2326
- label: "List item for sale",
2327
- onClick: () => createListing(),
2328
- pending: steps$?.transaction.isExecuting.get(),
2870
+ label: listCtaLabel,
2871
+ onClick: handleCreateListing,
2872
+ pending: steps$?.transaction.isExecuting.get() || createListingModal$.listingIsBeingProcessed.get(),
2329
2873
  testid: "create-listing-submit-button",
2330
- disabled: steps$.approval.exist.get() || tokenApprovalIsLoading || listingPrice2.amountRaw === "0" || createListingModal$.invalidQuantity.get() || isLoading
2874
+ disabled: steps$.approval.exist.get() || tokenApprovalIsLoading || listingPrice2.amountRaw === "0" || createListingModal$.invalidQuantity.get() || isLoading || listingIsBeingProcessed
2331
2875
  }
2332
2876
  ];
2333
- return /* @__PURE__ */ jsxs11(
2877
+ return /* @__PURE__ */ jsxs17(
2334
2878
  ActionModal,
2335
2879
  {
2336
2880
  isOpen: createListingModal$.isOpen.get(),
2337
2881
  chainId: Number(chainId),
2338
- onClose: () => createListingModal$.close(),
2882
+ onClose: () => {
2883
+ createListingModal$.close();
2884
+ selectWaasFeeOptions$.hide();
2885
+ },
2339
2886
  title: "List item for sale",
2340
2887
  ctas,
2341
2888
  modalLoading,
2342
2889
  spinnerContainerClassname: "h-[220px]",
2890
+ hideCtas: shouldHideListButton,
2343
2891
  children: [
2344
- /* @__PURE__ */ jsx19(
2892
+ /* @__PURE__ */ jsx24(
2345
2893
  TokenPreview,
2346
2894
  {
2347
2895
  collectionName: collection?.name,
@@ -2350,16 +2898,17 @@ var Modal2 = observer6(() => {
2350
2898
  chainId
2351
2899
  }
2352
2900
  ),
2353
- /* @__PURE__ */ jsxs11("div", { className: "flex w-full flex-col gap-1", children: [
2354
- /* @__PURE__ */ jsx19(
2901
+ /* @__PURE__ */ jsxs17("div", { className: "flex w-full flex-col gap-1", children: [
2902
+ /* @__PURE__ */ jsx24(
2355
2903
  PriceInput,
2356
2904
  {
2357
2905
  chainId,
2358
2906
  collectionAddress,
2359
- $price: createListingModal$.listingPrice
2907
+ $price: createListingModal$.listingPrice,
2908
+ disabled: shouldHideListButton
2360
2909
  }
2361
2910
  ),
2362
- listingPrice2.amountRaw !== "0" && /* @__PURE__ */ jsx19(
2911
+ listingPrice2.amountRaw !== "0" && /* @__PURE__ */ jsx24(
2363
2912
  FloorPriceText,
2364
2913
  {
2365
2914
  tokenId: collectibleId,
@@ -2369,17 +2918,24 @@ var Modal2 = observer6(() => {
2369
2918
  }
2370
2919
  )
2371
2920
  ] }),
2372
- collection?.type === "ERC1155" && balance && /* @__PURE__ */ jsx19(
2921
+ collection?.type === "ERC1155" && balance && /* @__PURE__ */ jsx24(
2373
2922
  quantityInput_default,
2374
2923
  {
2375
2924
  $quantity: createListingModal$.quantity,
2376
2925
  $invalidQuantity: createListingModal$.invalidQuantity,
2377
2926
  decimals: collectible?.decimals || 0,
2378
- maxQuantity: balance?.balance
2927
+ maxQuantity: balance?.balance,
2928
+ disabled: shouldHideListButton
2379
2929
  }
2380
2930
  ),
2381
- /* @__PURE__ */ jsx19(expirationDateSelect_default, { $date: createListingModal$.expiry }),
2382
- /* @__PURE__ */ jsx19(
2931
+ /* @__PURE__ */ jsx24(
2932
+ expirationDateSelect_default,
2933
+ {
2934
+ $date: createListingModal$.expiry,
2935
+ disabled: shouldHideListButton
2936
+ }
2937
+ ),
2938
+ /* @__PURE__ */ jsx24(
2383
2939
  TransactionDetails,
2384
2940
  {
2385
2941
  collectibleId,
@@ -2389,6 +2945,17 @@ var Modal2 = observer6(() => {
2389
2945
  currencyImageUrl: listingPrice2.currency.imageUrl,
2390
2946
  includeMarketplaceFee: false
2391
2947
  }
2948
+ ),
2949
+ waasFeeOptionsShown && /* @__PURE__ */ jsx24(
2950
+ selectWaasFeeOptions_default,
2951
+ {
2952
+ chainId: Number(chainId),
2953
+ onCancel: () => {
2954
+ createListingModal$.listingIsBeingProcessed.set(false);
2955
+ steps$.transaction.isExecuting.set(false);
2956
+ },
2957
+ titleOnConfirm: "Processing listing..."
2958
+ }
2392
2959
  )
2393
2960
  ]
2394
2961
  }
@@ -2396,15 +2963,25 @@ var Modal2 = observer6(() => {
2396
2963
  });
2397
2964
 
2398
2965
  // src/react/ui/modals/MakeOfferModal/Modal.tsx
2399
- import { Show as Show2, observer as observer7 } from "@legendapp/state/react";
2400
- import { useState as useState7 } from "react";
2401
- import { parseUnits as parseUnits4 } from "viem";
2966
+ import { getNetwork as getNetwork3 } from "@0xsequence/connect";
2967
+ import { NetworkType as NetworkType3 } from "@0xsequence/network";
2968
+ import { Show as Show2, observer as observer8 } from "@legendapp/state/react";
2969
+ import { useState as useState9 } from "react";
2970
+ import { parseUnits as parseUnits3 } from "viem";
2971
+
2972
+ // src/react/ui/modals/BuyModal/index.tsx
2973
+ var useBuyModal = (callbacks) => {
2974
+ return {
2975
+ show: (args) => buyModalStore.send({ type: "open", props: args, ...callbacks }),
2976
+ close: () => buyModalStore.send({ type: "close" })
2977
+ };
2978
+ };
2402
2979
 
2403
2980
  // src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx
2404
- import { useEffect as useEffect7 } from "react";
2981
+ import { useEffect as useEffect9 } from "react";
2405
2982
 
2406
2983
  // src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx
2407
- import { skipToken as skipToken4, useQuery as useQuery4 } from "@tanstack/react-query";
2984
+ import { skipToken as skipToken6, useQuery as useQuery6 } from "@tanstack/react-query";
2408
2985
  var ONE_DAY_IN_SECONDS2 = 60 * 60 * 24;
2409
2986
  var useGetTokenApprovalData2 = (params) => {
2410
2987
  const config = useConfig();
@@ -2418,7 +2995,7 @@ var useGetTokenApprovalData2 = (params) => {
2418
2995
  expiry: String(Number(dateToUnixTime(/* @__PURE__ */ new Date())) + ONE_DAY_IN_SECONDS2)
2419
2996
  };
2420
2997
  const isEnabled = wallet && params.query?.enabled !== false;
2421
- const { data, isLoading, isSuccess } = useQuery4({
2998
+ const { data, isLoading, isSuccess } = useQuery6({
2422
2999
  queryKey: ["token-approval-data", params.currencyAddress],
2423
3000
  queryFn: isEnabled ? async () => {
2424
3001
  const args = {
@@ -2441,7 +3018,7 @@ var useGetTokenApprovalData2 = (params) => {
2441
3018
  return {
2442
3019
  step: tokenApprovalStep
2443
3020
  };
2444
- } : skipToken4,
3021
+ } : skipToken6,
2445
3022
  enabled: !!wallet && !!params.collectionAddress && !!params.currencyAddress
2446
3023
  });
2447
3024
  return {
@@ -2452,7 +3029,7 @@ var useGetTokenApprovalData2 = (params) => {
2452
3029
  };
2453
3030
 
2454
3031
  // src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx
2455
- import { formatUnits as formatUnits5 } from "viem";
3032
+ import { formatUnits as formatUnits7 } from "viem";
2456
3033
  var useTransactionSteps2 = ({
2457
3034
  offerInput,
2458
3035
  chainId,
@@ -2520,10 +3097,12 @@ var useTransactionSteps2 = ({
2520
3097
  steps$.approval.isExecuting.set(false);
2521
3098
  }
2522
3099
  };
2523
- const makeOffer = async () => {
3100
+ const makeOffer = async ({
3101
+ isTransactionExecuting
3102
+ }) => {
2524
3103
  if (!wallet) return;
2525
3104
  try {
2526
- steps$.transaction.isExecuting.set(true);
3105
+ steps$.transaction.isExecuting.set(isTransactionExecuting);
2527
3106
  const steps3 = await getOfferSteps();
2528
3107
  const transactionStep = steps3?.find(
2529
3108
  (step) => step.id === "createOffer" /* createOffer */
@@ -2578,7 +3157,7 @@ var useTransactionSteps2 = ({
2578
3157
  const currencyDecimal = currency?.decimals || 0;
2579
3158
  const currencyValueRaw = Number(offerInput.offer.pricePerToken);
2580
3159
  const currencyValueDecimal = Number(
2581
- formatUnits5(BigInt(currencyValueRaw), currencyDecimal)
3160
+ formatUnits7(BigInt(currencyValueRaw), currencyDecimal)
2582
3161
  );
2583
3162
  analytics.trackCreateOffer({
2584
3163
  props: {
@@ -2586,7 +3165,7 @@ var useTransactionSteps2 = ({
2586
3165
  collectionAddress,
2587
3166
  currencyAddress: offerInput.offer.currencyAddress,
2588
3167
  currencySymbol: currency?.symbol || "",
2589
- chainId,
3168
+ chainId: chainId.toString(),
2590
3169
  txnHash: hash || ""
2591
3170
  },
2592
3171
  nums: {
@@ -2660,7 +3239,7 @@ var useMakeOffer = ({
2660
3239
  enabled: !marketplaceIsLoading
2661
3240
  }
2662
3241
  });
2663
- useEffect7(() => {
3242
+ useEffect9(() => {
2664
3243
  if (tokenApproval?.step && !tokenApprovalIsLoading) {
2665
3244
  steps$.approval.exist.set(true);
2666
3245
  }
@@ -2707,7 +3286,7 @@ var steps2 = {
2707
3286
  var initialState4 = {
2708
3287
  isOpen: false,
2709
3288
  collectionAddress: "",
2710
- chainId: "",
3289
+ chainId: 0,
2711
3290
  collectibleId: "",
2712
3291
  orderbookKind: void 0,
2713
3292
  callbacks: void 0,
@@ -2717,7 +3296,8 @@ var initialState4 = {
2717
3296
  invalidQuantity: false,
2718
3297
  expiry: new Date(addDays3(/* @__PURE__ */ new Date(), 7).toJSON()),
2719
3298
  collectionType: void 0,
2720
- steps: { ...steps2 }
3299
+ steps: { ...steps2 },
3300
+ offerIsBeingProcessed: false
2721
3301
  };
2722
3302
  var actions2 = {
2723
3303
  open: (args) => {
@@ -2733,7 +3313,7 @@ var actions2 = {
2733
3313
  makeOfferModal$.set({ ...initialState4, ...actions2 });
2734
3314
  makeOfferModal$.steps.set({ ...steps2 });
2735
3315
  makeOfferModal$.offerPrice.set({ ...offerPrice });
2736
- makeOfferModal$.steps.set({ ...steps2 });
3316
+ makeOfferModal$.offerIsBeingProcessed.set(false);
2737
3317
  }
2738
3318
  };
2739
3319
  var makeOfferModal$ = observable4({
@@ -2742,11 +3322,11 @@ var makeOfferModal$ = observable4({
2742
3322
  });
2743
3323
 
2744
3324
  // src/react/ui/modals/MakeOfferModal/Modal.tsx
2745
- import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
3325
+ import { Fragment as Fragment2, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
2746
3326
  var MakeOfferModal = () => {
2747
- return /* @__PURE__ */ jsx20(Show2, { if: makeOfferModal$.isOpen, children: () => /* @__PURE__ */ jsx20(Modal3, {}) });
3327
+ return /* @__PURE__ */ jsx25(Show2, { if: makeOfferModal$.isOpen, children: () => /* @__PURE__ */ jsx25(Modal3, {}) });
2748
3328
  };
2749
- var Modal3 = observer7(() => {
3329
+ var Modal3 = observer8(() => {
2750
3330
  const state = makeOfferModal$.get();
2751
3331
  const {
2752
3332
  collectionAddress,
@@ -2759,7 +3339,7 @@ var Modal3 = observer7(() => {
2759
3339
  callbacks
2760
3340
  } = state;
2761
3341
  const steps$ = makeOfferModal$.steps;
2762
- const [insufficientBalance, setInsufficientBalance] = useState7(false);
3342
+ const [insufficientBalance, setInsufficientBalance] = useState9(false);
2763
3343
  const {
2764
3344
  data: collectible,
2765
3345
  isLoading: collectableIsLoading,
@@ -2769,6 +3349,18 @@ var Modal3 = observer7(() => {
2769
3349
  collectionAddress,
2770
3350
  collectibleId
2771
3351
  });
3352
+ const { wallet } = useWallet();
3353
+ const isProcessing = makeOfferModal$.offerIsBeingProcessed.get();
3354
+ const {
3355
+ shouldHideActionButton: shouldHideOfferButton,
3356
+ waasFeeOptionsShown,
3357
+ getActionLabel
3358
+ } = useSelectWaasFeeOptions({
3359
+ chainId,
3360
+ isProcessing,
3361
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
3362
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
3363
+ });
2772
3364
  const {
2773
3365
  data: collection,
2774
3366
  isLoading: collectionIsLoading,
@@ -2791,7 +3383,7 @@ var Modal3 = observer7(() => {
2791
3383
  contractType: collection?.type,
2792
3384
  offer: {
2793
3385
  tokenId: collectibleId,
2794
- quantity: parseUnits4(
3386
+ quantity: parseUnits3(
2795
3387
  makeOfferModal$.quantity.get(),
2796
3388
  collectible?.decimals || 0
2797
3389
  ).toString(),
@@ -2807,8 +3399,17 @@ var Modal3 = observer7(() => {
2807
3399
  closeMainModal: () => makeOfferModal$.close(),
2808
3400
  steps$
2809
3401
  });
3402
+ const buyModal = useBuyModal(callbacks);
3403
+ const { data: lowestListing } = useLowestListing({
3404
+ tokenId: collectibleId,
3405
+ chainId,
3406
+ collectionAddress,
3407
+ filters: {
3408
+ currencies: [offerPrice2.currency.contractAddress]
3409
+ }
3410
+ });
2810
3411
  if (collectableIsError || collectionIsError || currenciesIsError) {
2811
- return /* @__PURE__ */ jsx20(
3412
+ return /* @__PURE__ */ jsx25(
2812
3413
  ErrorModal,
2813
3414
  {
2814
3415
  isOpen: makeOfferModal$.isOpen.get(),
@@ -2819,7 +3420,7 @@ var Modal3 = observer7(() => {
2819
3420
  );
2820
3421
  }
2821
3422
  if (!modalLoading && (!currencies || currencies.length === 0)) {
2822
- return /* @__PURE__ */ jsx20(
3423
+ return /* @__PURE__ */ jsx25(
2823
3424
  ErrorModal,
2824
3425
  {
2825
3426
  isOpen: makeOfferModal$.isOpen.get(),
@@ -2830,6 +3431,23 @@ var Modal3 = observer7(() => {
2830
3431
  }
2831
3432
  );
2832
3433
  }
3434
+ const handleMakeOffer = async () => {
3435
+ makeOfferModal$.offerIsBeingProcessed.set(true);
3436
+ try {
3437
+ if (wallet?.isWaaS) {
3438
+ selectWaasFeeOptions$.isVisible.set(true);
3439
+ }
3440
+ await makeOffer({
3441
+ isTransactionExecuting: wallet?.isWaaS ? getNetwork3(Number(chainId)).type !== NetworkType3.TESTNET : false
3442
+ });
3443
+ } catch (error) {
3444
+ console.error("Make offer failed:", error);
3445
+ } finally {
3446
+ makeOfferModal$.offerIsBeingProcessed.set(false);
3447
+ steps$.transaction.isExecuting.set(false);
3448
+ }
3449
+ };
3450
+ const offerCtaLabel = getActionLabel("Make offer");
2833
3451
  const ctas = [
2834
3452
  {
2835
3453
  label: "Approve TOKEN",
@@ -2840,24 +3458,29 @@ var Modal3 = observer7(() => {
2840
3458
  disabled: invalidQuantity || isLoading || insufficientBalance || offerPrice2.amountRaw === "0" || !offerPriceChanged
2841
3459
  },
2842
3460
  {
2843
- label: "Make offer",
2844
- onClick: () => makeOffer(),
2845
- pending: steps$.transaction.isExecuting.get(),
3461
+ label: offerCtaLabel,
3462
+ onClick: () => handleMakeOffer(),
3463
+ pending: steps$?.transaction.isExecuting.get() || makeOfferModal$.offerIsBeingProcessed.get(),
2846
3464
  disabled: steps$.approval.isExecuting.get() || steps$.approval.exist.get() || offerPrice2.amountRaw === "0" || insufficientBalance || isLoading || invalidQuantity
2847
3465
  }
2848
3466
  ];
2849
- return /* @__PURE__ */ jsx20(Fragment2, { children: /* @__PURE__ */ jsxs12(
3467
+ return /* @__PURE__ */ jsx25(Fragment2, { children: /* @__PURE__ */ jsxs18(
2850
3468
  ActionModal,
2851
3469
  {
2852
3470
  isOpen: makeOfferModal$.isOpen.get(),
2853
3471
  chainId: Number(chainId),
2854
- onClose: () => makeOfferModal$.close(),
3472
+ onClose: () => {
3473
+ makeOfferModal$.close();
3474
+ selectWaasFeeOptions$.hide();
3475
+ steps$.transaction.isExecuting.set(false);
3476
+ },
2855
3477
  title: "Make an offer",
2856
3478
  ctas,
2857
3479
  modalLoading,
2858
3480
  spinnerContainerClassname: "h-[188px]",
3481
+ hideCtas: shouldHideOfferButton,
2859
3482
  children: [
2860
- /* @__PURE__ */ jsx20(
3483
+ /* @__PURE__ */ jsx25(
2861
3484
  TokenPreview,
2862
3485
  {
2863
3486
  collectionName: collection?.name,
@@ -2866,7 +3489,7 @@ var Modal3 = observer7(() => {
2866
3489
  chainId
2867
3490
  }
2868
3491
  ),
2869
- /* @__PURE__ */ jsx20(
3492
+ /* @__PURE__ */ jsx25(
2870
3493
  PriceInput,
2871
3494
  {
2872
3495
  chainId,
@@ -2877,49 +3500,82 @@ var Modal3 = observer7(() => {
2877
3500
  checkBalance: {
2878
3501
  enabled: true,
2879
3502
  callback: (state2) => setInsufficientBalance(state2)
2880
- }
3503
+ },
3504
+ disabled: shouldHideOfferButton
2881
3505
  }
2882
3506
  ),
2883
- collection?.type === "ERC1155" /* ERC1155 */ && /* @__PURE__ */ jsx20(
3507
+ collection?.type === "ERC1155" /* ERC1155 */ && /* @__PURE__ */ jsx25(
2884
3508
  quantityInput_default,
2885
3509
  {
2886
3510
  $quantity: makeOfferModal$.quantity,
2887
3511
  $invalidQuantity: makeOfferModal$.invalidQuantity,
2888
3512
  decimals: collectible?.decimals || 0,
2889
- maxQuantity: String(Number.MAX_SAFE_INTEGER)
3513
+ maxQuantity: String(Number.MAX_SAFE_INTEGER),
3514
+ disabled: shouldHideOfferButton
2890
3515
  }
2891
3516
  ),
2892
- offerPrice2.amountRaw !== "0" && offerPriceChanged && !insufficientBalance && /* @__PURE__ */ jsx20(
3517
+ offerPrice2.amountRaw !== "0" && offerPriceChanged && !insufficientBalance && /* @__PURE__ */ jsx25(
2893
3518
  FloorPriceText,
2894
3519
  {
2895
3520
  tokenId: collectibleId,
2896
3521
  chainId,
2897
3522
  collectionAddress,
2898
- price: offerPrice2
3523
+ price: offerPrice2,
3524
+ onBuyNow: () => {
3525
+ makeOfferModal$.close();
3526
+ if (lowestListing?.order) {
3527
+ buyModal.show({
3528
+ chainId,
3529
+ collectionAddress,
3530
+ collectibleId,
3531
+ orderId: lowestListing.order.orderId,
3532
+ marketplace: lowestListing.order.marketplace
3533
+ });
3534
+ }
3535
+ }
3536
+ }
3537
+ ),
3538
+ /* @__PURE__ */ jsx25(
3539
+ expirationDateSelect_default,
3540
+ {
3541
+ $date: makeOfferModal$.expiry,
3542
+ disabled: shouldHideOfferButton
2899
3543
  }
2900
3544
  ),
2901
- /* @__PURE__ */ jsx20(expirationDateSelect_default, { $date: makeOfferModal$.expiry })
3545
+ waasFeeOptionsShown && /* @__PURE__ */ jsx25(
3546
+ selectWaasFeeOptions_default,
3547
+ {
3548
+ chainId: Number(chainId),
3549
+ onCancel: () => {
3550
+ makeOfferModal$.offerIsBeingProcessed.set(false);
3551
+ steps$.transaction.isExecuting.set(false);
3552
+ },
3553
+ titleOnConfirm: "Processing offer..."
3554
+ }
3555
+ )
2902
3556
  ]
2903
3557
  }
2904
3558
  ) });
2905
3559
  });
2906
3560
 
2907
3561
  // src/react/ui/modals/SellModal/Modal.tsx
2908
- import { Show as Show3, observer as observer8 } from "@legendapp/state/react";
2909
- import { parseUnits as parseUnits5 } from "viem";
3562
+ import { getNetwork as getNetwork4 } from "@0xsequence/connect";
3563
+ import { NetworkType as NetworkType4 } from "@0xsequence/network";
3564
+ import { Show as Show3, observer as observer9 } from "@legendapp/state/react";
3565
+ import { parseUnits as parseUnits4 } from "viem";
2910
3566
 
2911
3567
  // src/react/ui/modals/_internal/components/transactionHeader/index.tsx
2912
- import { Image as Image4, Skeleton as Skeleton7, Text as Text12 } from "@0xsequence/design-system";
3568
+ import { Image as Image5, Skeleton as Skeleton9, Text as Text16 } from "@0xsequence/design-system";
2913
3569
  import { formatDistanceToNow as formatDistanceToNow2 } from "date-fns";
2914
- import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
3570
+ import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
2915
3571
  function TransactionHeader({
2916
3572
  title,
2917
3573
  currencyImageUrl,
2918
3574
  date
2919
3575
  }) {
2920
- return /* @__PURE__ */ jsxs13("div", { className: "flex w-full items-center", children: [
2921
- /* @__PURE__ */ jsx21(
2922
- Text12,
3576
+ return /* @__PURE__ */ jsxs19("div", { className: "flex w-full items-center", children: [
3577
+ /* @__PURE__ */ jsx26(
3578
+ Text16,
2923
3579
  {
2924
3580
  className: "mr-1 font-body text-sm",
2925
3581
  fontWeight: "medium",
@@ -2927,9 +3583,9 @@ function TransactionHeader({
2927
3583
  children: title
2928
3584
  }
2929
3585
  ),
2930
- /* @__PURE__ */ jsx21(Image4, { className: "mr-1 h-3 w-3", src: currencyImageUrl }),
2931
- date && /* @__PURE__ */ jsxs13(
2932
- Text12,
3586
+ /* @__PURE__ */ jsx26(Image5, { className: "mr-1 h-3 w-3", src: currencyImageUrl }),
3587
+ date && /* @__PURE__ */ jsxs19(
3588
+ Text16,
2933
3589
  {
2934
3590
  className: "grow text-right font-body text-xs",
2935
3591
  fontWeight: "medium",
@@ -2939,15 +3595,15 @@ function TransactionHeader({
2939
3595
  " ago"
2940
3596
  ]
2941
3597
  }
2942
- ) || /* @__PURE__ */ jsx21(Skeleton7, { className: "h-4 w-8" })
3598
+ ) || /* @__PURE__ */ jsx26(Skeleton9, { className: "h-4 w-8" })
2943
3599
  ] });
2944
3600
  }
2945
3601
 
2946
3602
  // src/react/ui/modals/SellModal/hooks/useSell.tsx
2947
- import { useEffect as useEffect8 } from "react";
3603
+ import { useEffect as useEffect10 } from "react";
2948
3604
 
2949
3605
  // src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx
2950
- import { skipToken as skipToken5, useQuery as useQuery5 } from "@tanstack/react-query";
3606
+ import { skipToken as skipToken7, useQuery as useQuery7 } from "@tanstack/react-query";
2951
3607
  var useGetTokenApprovalData3 = (params) => {
2952
3608
  const config = useConfig();
2953
3609
  const { wallet } = useWallet();
@@ -2956,7 +3612,7 @@ var useGetTokenApprovalData3 = (params) => {
2956
3612
  chainId: Number(params.chainId),
2957
3613
  collectionAddress: params.collectionAddress
2958
3614
  });
2959
- const { data, isLoading, isSuccess } = useQuery5({
3615
+ const { data, isLoading, isSuccess } = useQuery7({
2960
3616
  queryKey: ["token-approval-data", params.ordersData],
2961
3617
  queryFn: wallet ? async () => {
2962
3618
  const address = await wallet.address();
@@ -2985,7 +3641,7 @@ var useGetTokenApprovalData3 = (params) => {
2985
3641
  return {
2986
3642
  step: tokenApprovalStep
2987
3643
  };
2988
- } : skipToken5,
3644
+ } : skipToken7,
2989
3645
  enabled: !!wallet && !!params.collectionAddress
2990
3646
  });
2991
3647
  return {
@@ -2996,7 +3652,7 @@ var useGetTokenApprovalData3 = (params) => {
2996
3652
  };
2997
3653
 
2998
3654
  // src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx
2999
- import { formatUnits as formatUnits6 } from "viem";
3655
+ import { formatUnits as formatUnits8 } from "viem";
3000
3656
  var useTransactionSteps3 = ({
3001
3657
  collectibleId,
3002
3658
  chainId,
@@ -3013,11 +3669,11 @@ var useTransactionSteps3 = ({
3013
3669
  const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
3014
3670
  const analytics = useAnalytics();
3015
3671
  const { amount, receiver } = useFees({
3016
- chainId: Number(chainId),
3672
+ chainId,
3017
3673
  collectionAddress
3018
3674
  });
3019
3675
  const { data: currencies } = useCurrencies({
3020
- chainId: Number(chainId)
3676
+ chainId
3021
3677
  });
3022
3678
  const { generateSellTransactionAsync, isPending: generatingSteps } = useGenerateSellTransaction({
3023
3679
  chainId,
@@ -3069,10 +3725,12 @@ var useTransactionSteps3 = ({
3069
3725
  steps$.approval.isExecuting.set(false);
3070
3726
  }
3071
3727
  };
3072
- const sell = async () => {
3728
+ const sell = async ({
3729
+ isTransactionExecuting
3730
+ }) => {
3073
3731
  if (!wallet) return;
3074
3732
  try {
3075
- steps$.transaction.isExecuting.set(true);
3733
+ steps$.transaction.isExecuting.set(isTransactionExecuting);
3076
3734
  const steps3 = await getSellSteps();
3077
3735
  const transactionStep = steps3?.find((step) => step.id === "sell" /* sell */);
3078
3736
  const signatureStep = steps3?.find(
@@ -3119,7 +3777,7 @@ var useTransactionSteps3 = ({
3119
3777
  const currencySymbol = currency?.symbol || "";
3120
3778
  const currencyValueRaw = Number(ordersData[0].pricePerToken);
3121
3779
  const currencyValueDecimal = Number(
3122
- formatUnits6(BigInt(currencyValueRaw), currencyDecimal)
3780
+ formatUnits8(BigInt(currencyValueRaw), currencyDecimal)
3123
3781
  );
3124
3782
  analytics.trackSellItems({
3125
3783
  props: {
@@ -3127,7 +3785,7 @@ var useTransactionSteps3 = ({
3127
3785
  collectionAddress,
3128
3786
  currencyAddress: ordersData[0].currencyAddress,
3129
3787
  currencySymbol,
3130
- chainId,
3788
+ chainId: chainId.toString(),
3131
3789
  txnHash: hash || ""
3132
3790
  },
3133
3791
  nums: {
@@ -3192,7 +3850,7 @@ var useSell = ({
3192
3850
  ordersData,
3193
3851
  marketplace
3194
3852
  });
3195
- useEffect8(() => {
3853
+ useEffect10(() => {
3196
3854
  if (tokenApproval?.step && !tokenApprovalIsLoading) {
3197
3855
  steps$.approval.exist.set(true);
3198
3856
  }
@@ -3221,10 +3879,11 @@ import { observable as observable5 } from "@legendapp/state";
3221
3879
  var initialState5 = {
3222
3880
  isOpen: false,
3223
3881
  collectionAddress: "",
3224
- chainId: "",
3882
+ chainId: 0,
3225
3883
  tokenId: "",
3226
3884
  order: void 0,
3227
3885
  callbacks: void 0,
3886
+ sellIsBeingProcessed: false,
3228
3887
  open: (args) => {
3229
3888
  sellModal$.collectionAddress.set(args.collectionAddress);
3230
3889
  sellModal$.chainId.set(args.chainId);
@@ -3236,6 +3895,7 @@ var initialState5 = {
3236
3895
  close: () => {
3237
3896
  sellModal$.isOpen.set(false);
3238
3897
  sellModal$.callbacks.set(void 0);
3898
+ sellModal$.sellIsBeingProcessed.set(false);
3239
3899
  },
3240
3900
  steps: {
3241
3901
  approval: {
@@ -3253,11 +3913,11 @@ var initialState5 = {
3253
3913
  var sellModal$ = observable5(initialState5);
3254
3914
 
3255
3915
  // src/react/ui/modals/SellModal/Modal.tsx
3256
- import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
3916
+ import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
3257
3917
  var SellModal = () => {
3258
- return /* @__PURE__ */ jsx22(Show3, { if: sellModal$.isOpen, children: () => /* @__PURE__ */ jsx22(Modal4, {}) });
3918
+ return /* @__PURE__ */ jsx27(Show3, { if: sellModal$.isOpen, children: () => /* @__PURE__ */ jsx27(Modal4, {}) });
3259
3919
  };
3260
- var Modal4 = observer8(() => {
3920
+ var Modal4 = observer9(() => {
3261
3921
  const { tokenId, collectionAddress, chainId, order, callbacks } = sellModal$.get();
3262
3922
  const steps$ = sellModal$.steps;
3263
3923
  const { data: collectible } = useCollection({
@@ -3280,6 +3940,18 @@ var Modal4 = observer8(() => {
3280
3940
  chainId,
3281
3941
  currencyAddress: order?.priceCurrencyAddress ?? ""
3282
3942
  });
3943
+ const { wallet } = useWallet();
3944
+ const feeOptionsVisible = selectWaasFeeOptions$.isVisible.get();
3945
+ const network = getNetwork4(Number(chainId));
3946
+ const isTestnet = network.type === NetworkType4.TESTNET;
3947
+ const isProcessing = sellModal$.sellIsBeingProcessed.get();
3948
+ const isWaaS = wallet?.isWaaS;
3949
+ const { shouldHideActionButton: shouldHideSellButton } = useSelectWaasFeeOptions({
3950
+ chainId,
3951
+ isProcessing,
3952
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
3953
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
3954
+ });
3283
3955
  const { isLoading, executeApproval, sell } = useSell({
3284
3956
  collectionAddress,
3285
3957
  chainId,
@@ -3288,7 +3960,7 @@ var Modal4 = observer8(() => {
3288
3960
  ordersData: [
3289
3961
  {
3290
3962
  orderId: order?.orderId ?? "",
3291
- quantity: order?.quantityRemaining ? parseUnits5(
3963
+ quantity: order?.quantityRemaining ? parseUnits4(
3292
3964
  order.quantityRemaining,
3293
3965
  collectible?.decimals || 0
3294
3966
  ).toString() : "1",
@@ -3302,7 +3974,7 @@ var Modal4 = observer8(() => {
3302
3974
  });
3303
3975
  const modalLoading = collectionLoading || currencyLoading;
3304
3976
  if ((collectionError || order === void 0 || currencyError) && !modalLoading) {
3305
- return /* @__PURE__ */ jsx22(
3977
+ return /* @__PURE__ */ jsx27(
3306
3978
  ErrorModal,
3307
3979
  {
3308
3980
  isOpen: sellModal$.isOpen.get(),
@@ -3312,6 +3984,23 @@ var Modal4 = observer8(() => {
3312
3984
  }
3313
3985
  );
3314
3986
  }
3987
+ const handleSell = async () => {
3988
+ sellModal$.sellIsBeingProcessed.set(true);
3989
+ try {
3990
+ if (wallet?.isWaaS) {
3991
+ selectWaasFeeOptions$.isVisible.set(true);
3992
+ }
3993
+ await sell({
3994
+ isTransactionExecuting: wallet?.isWaaS ? !isTestnet : false
3995
+ });
3996
+ } catch (error) {
3997
+ console.error("Sell failed:", error);
3998
+ } finally {
3999
+ sellModal$.sellIsBeingProcessed.set(false);
4000
+ steps$.transaction.isExecuting.set(false);
4001
+ }
4002
+ };
4003
+ const sellCtaLabel = isProcessing ? isWaaS && !isTestnet ? "Loading fee options" : "Accept" : "Accept";
3315
4004
  const ctas = [
3316
4005
  {
3317
4006
  label: "Approve TOKEN",
@@ -3322,24 +4011,30 @@ var Modal4 = observer8(() => {
3322
4011
  disabled: isLoading || order?.quantityRemaining === "0"
3323
4012
  },
3324
4013
  {
3325
- label: "Accept",
3326
- onClick: () => sell(),
3327
- pending: steps$.transaction.isExecuting.get(),
4014
+ label: sellCtaLabel,
4015
+ onClick: () => handleSell(),
4016
+ pending: steps$?.transaction.isExecuting.get() || sellModal$.sellIsBeingProcessed.get(),
3328
4017
  disabled: isLoading || steps$.approval.isExecuting.get() || steps$.approval.exist.get() || order?.quantityRemaining === "0"
3329
4018
  }
3330
4019
  ];
3331
- return /* @__PURE__ */ jsxs14(
4020
+ const showWaasFeeOptions = wallet?.isWaaS && sellModal$.sellIsBeingProcessed.get() && feeOptionsVisible;
4021
+ return /* @__PURE__ */ jsxs20(
3332
4022
  ActionModal,
3333
4023
  {
3334
4024
  isOpen: sellModal$.isOpen.get(),
3335
4025
  chainId: Number(chainId),
3336
- onClose: sellModal$.close,
4026
+ onClose: () => {
4027
+ sellModal$.close();
4028
+ selectWaasFeeOptions$.hide();
4029
+ steps$.transaction.isExecuting.set(false);
4030
+ },
3337
4031
  title: "You have an offer",
3338
4032
  ctas,
3339
4033
  modalLoading,
3340
4034
  spinnerContainerClassname: "h-[104px]",
4035
+ hideCtas: shouldHideSellButton,
3341
4036
  children: [
3342
- /* @__PURE__ */ jsx22(
4037
+ /* @__PURE__ */ jsx27(
3343
4038
  TransactionHeader,
3344
4039
  {
3345
4040
  title: "Offer received",
@@ -3347,7 +4042,7 @@ var Modal4 = observer8(() => {
3347
4042
  date: order && new Date(order.createdAt)
3348
4043
  }
3349
4044
  ),
3350
- /* @__PURE__ */ jsx22(
4045
+ /* @__PURE__ */ jsx27(
3351
4046
  TokenPreview,
3352
4047
  {
3353
4048
  collectionName: collection?.name,
@@ -3356,7 +4051,7 @@ var Modal4 = observer8(() => {
3356
4051
  chainId
3357
4052
  }
3358
4053
  ),
3359
- /* @__PURE__ */ jsx22(
4054
+ /* @__PURE__ */ jsx27(
3360
4055
  TransactionDetails,
3361
4056
  {
3362
4057
  collectibleId: tokenId,
@@ -3369,6 +4064,17 @@ var Modal4 = observer8(() => {
3369
4064
  } : void 0,
3370
4065
  currencyImageUrl: currency?.imageUrl
3371
4066
  }
4067
+ ),
4068
+ showWaasFeeOptions && /* @__PURE__ */ jsx27(
4069
+ selectWaasFeeOptions_default,
4070
+ {
4071
+ chainId: Number(chainId),
4072
+ onCancel: () => {
4073
+ sellModal$.sellIsBeingProcessed.set(false);
4074
+ steps$.transaction.isExecuting.set(false);
4075
+ },
4076
+ titleOnConfirm: "Accepting offer..."
4077
+ }
3372
4078
  )
3373
4079
  ]
3374
4080
  }
@@ -3377,13 +4083,13 @@ var Modal4 = observer8(() => {
3377
4083
 
3378
4084
  // src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
3379
4085
  import {
3380
- Button as Button2,
4086
+ Button as Button5,
3381
4087
  ExternalLinkIcon,
3382
- Image as Image5,
4088
+ Image as Image6,
3383
4089
  Modal as Modal5,
3384
- Text as Text13
4090
+ Text as Text17
3385
4091
  } from "@0xsequence/design-system";
3386
- import { observer as observer9, use$ as use$4 } from "@legendapp/state/react";
4092
+ import { observer as observer10, use$ as use$4 } from "@legendapp/state/react";
3387
4093
 
3388
4094
  // src/react/ui/modals/SuccessfulPurchaseModal/_store.ts
3389
4095
  import { observable as observable6 } from "@legendapp/state";
@@ -3428,29 +4134,29 @@ var initialState6 = {
3428
4134
  var successfulPurchaseModal$ = observable6(initialState6);
3429
4135
 
3430
4136
  // src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
3431
- import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
4137
+ import { jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
3432
4138
  var useSuccessfulPurchaseModal = (callbacks) => {
3433
4139
  return {
3434
4140
  show: (args) => successfulPurchaseModal$.open({ ...args, defaultCallbacks: callbacks }),
3435
4141
  close: () => successfulPurchaseModal$.close()
3436
4142
  };
3437
4143
  };
3438
- var SuccessfulPurchaseModal = observer9(() => {
4144
+ var SuccessfulPurchaseModal = observer10(() => {
3439
4145
  const handleClose = () => {
3440
4146
  successfulPurchaseModal$.close();
3441
4147
  };
3442
4148
  const isOpen = use$4(successfulPurchaseModal$.isOpen);
3443
4149
  if (!isOpen) return null;
3444
- return /* @__PURE__ */ jsx23(
4150
+ return /* @__PURE__ */ jsx28(
3445
4151
  Modal5,
3446
4152
  {
3447
4153
  isDismissible: true,
3448
4154
  onClose: handleClose,
3449
4155
  size: "sm",
3450
4156
  backdropColor: "backgroundBackdrop",
3451
- children: /* @__PURE__ */ jsxs15("div", { className: "flex w-full flex-col gap-4 p-6", children: [
3452
- /* @__PURE__ */ jsx23(
3453
- Text13,
4157
+ children: /* @__PURE__ */ jsxs21("div", { className: "flex w-full flex-col gap-4 p-6", children: [
4158
+ /* @__PURE__ */ jsx28(
4159
+ Text17,
3454
4160
  {
3455
4161
  className: "text-center text-large",
3456
4162
  fontWeight: "bold",
@@ -3458,27 +4164,27 @@ var SuccessfulPurchaseModal = observer9(() => {
3458
4164
  children: "Successful purchase!"
3459
4165
  }
3460
4166
  ),
3461
- /* @__PURE__ */ jsx23(
4167
+ /* @__PURE__ */ jsx28(
3462
4168
  CollectiblesGrid,
3463
4169
  {
3464
4170
  collectibles: successfulPurchaseModal$.state.get().collectibles
3465
4171
  }
3466
4172
  ),
3467
- /* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-1", children: [
3468
- /* @__PURE__ */ jsx23(Text13, { className: "text-base", fontWeight: "medium", color: "text80", children: "You bought" }),
3469
- /* @__PURE__ */ jsx23(Text13, { className: "text-base", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().collectibles.length }),
3470
- /* @__PURE__ */ jsx23(Text13, { className: "text-base", fontWeight: "medium", color: "text80", children: "items for" }),
3471
- /* @__PURE__ */ jsx23(Text13, { className: "text-base", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().totalPrice })
4173
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-1", children: [
4174
+ /* @__PURE__ */ jsx28(Text17, { className: "text-base", fontWeight: "medium", color: "text80", children: "You bought" }),
4175
+ /* @__PURE__ */ jsx28(Text17, { className: "text-base", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().collectibles.length }),
4176
+ /* @__PURE__ */ jsx28(Text17, { className: "text-base", fontWeight: "medium", color: "text80", children: "items for" }),
4177
+ /* @__PURE__ */ jsx28(Text17, { className: "text-base", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().totalPrice })
3472
4178
  ] }),
3473
- /* @__PURE__ */ jsx23(SuccessfulPurchaseActions, {})
4179
+ /* @__PURE__ */ jsx28(SuccessfulPurchaseActions, {})
3474
4180
  ] })
3475
4181
  }
3476
4182
  );
3477
4183
  });
3478
4184
  function SuccessfulPurchaseActions() {
3479
- return /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-2", children: [
3480
- successfulPurchaseModal$.state.ctaOptions.get() && /* @__PURE__ */ jsx23(
3481
- Button2,
4185
+ return /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-2", children: [
4186
+ successfulPurchaseModal$.state.ctaOptions.get() && /* @__PURE__ */ jsx28(
4187
+ Button5,
3482
4188
  {
3483
4189
  className: "w-full",
3484
4190
  shape: "square",
@@ -3487,8 +4193,8 @@ function SuccessfulPurchaseActions() {
3487
4193
  onClick: successfulPurchaseModal$.state.ctaOptions.ctaOnClick.get() || void 0
3488
4194
  }
3489
4195
  ),
3490
- /* @__PURE__ */ jsx23(
3491
- Button2,
4196
+ /* @__PURE__ */ jsx28(
4197
+ Button5,
3492
4198
  {
3493
4199
  className: "w-full",
3494
4200
  as: "a",
@@ -3505,23 +4211,23 @@ function SuccessfulPurchaseActions() {
3505
4211
  function CollectiblesGrid({ collectibles }) {
3506
4212
  const total = collectibles.length;
3507
4213
  const shownCollectibles = total > 4 ? collectibles.slice(0, 4) : collectibles;
3508
- return /* @__PURE__ */ jsx23("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-2 [&:has(div:nth-child(4))>div]:col-[unset] [&>div:nth-child(1):only-child]:h-[312px] [&>div:nth-child(1):only-child]:w-[312px] [&>div:nth-child(3)]:col-[1/-1] [&>div:nth-child(3)]:justify-self-center", children: shownCollectibles.map((collectible) => {
4214
+ return /* @__PURE__ */ jsx28("div", { className: "grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] gap-2 [&:has(div:nth-child(4))>div]:col-[unset] [&>div:nth-child(1):only-child]:h-[312px] [&>div:nth-child(1):only-child]:w-[312px] [&>div:nth-child(3)]:col-[1/-1] [&>div:nth-child(3)]:justify-self-center", children: shownCollectibles.map((collectible) => {
3509
4215
  const showPlus = total > 4 && collectibles.indexOf(collectible) === 3;
3510
- return /* @__PURE__ */ jsxs15(
4216
+ return /* @__PURE__ */ jsxs21(
3511
4217
  "div",
3512
4218
  {
3513
4219
  className: "relative h-[150px] w-[150px]",
3514
4220
  children: [
3515
- /* @__PURE__ */ jsx23(
3516
- Image5,
4221
+ /* @__PURE__ */ jsx28(
4222
+ Image6,
3517
4223
  {
3518
4224
  className: `aspect-square h-full w-full rounded-lg bg-background-secondary object-contain ${showPlus ? "opacity-[0.4_!important]" : ""}`,
3519
4225
  src: collectible.image,
3520
4226
  alt: collectible.name
3521
4227
  }
3522
4228
  ),
3523
- showPlus && /* @__PURE__ */ jsx23("div", { className: "absolute top-0 right-0 bottom-0 left-0 flex items-center justify-center bg-background-overlay backdrop-blur-md", children: /* @__PURE__ */ jsxs15(
3524
- Text13,
4229
+ showPlus && /* @__PURE__ */ jsx28("div", { className: "absolute top-0 right-0 bottom-0 left-0 flex items-center justify-center bg-background-overlay backdrop-blur-md", children: /* @__PURE__ */ jsxs21(
4230
+ Text17,
3525
4231
  {
3526
4232
  className: "rounded-lg bg-background-secondary px-2 py-1.5 text-sm backdrop-blur-md",
3527
4233
  fontWeight: "medium",
@@ -3542,8 +4248,8 @@ var SuccessfulPurchaseModal_default = SuccessfulPurchaseModal;
3542
4248
 
3543
4249
  // src/react/ui/modals/TransferModal/index.tsx
3544
4250
  import { Modal as Modal6 } from "@0xsequence/design-system";
3545
- import { observer as observer11 } from "@legendapp/state/react";
3546
- import { useAccount as useAccount5 } from "wagmi";
4251
+ import { observer as observer16 } from "@legendapp/state/react";
4252
+ import { useAccount as useAccount7, useSwitchChain } from "wagmi";
3547
4253
 
3548
4254
  // src/react/ui/modals/TransferModal/_store.ts
3549
4255
  import { observable as observable7 } from "@legendapp/state";
@@ -3569,15 +4275,18 @@ var initialState7 = {
3569
4275
  transferModal$.state.set({
3570
4276
  ...initialState7.state
3571
4277
  });
4278
+ transferModal$.state.receiverAddress.set("");
4279
+ transferModal$.state.transferIsBeingProcessed.set(false);
3572
4280
  transferModal$.view.set("enterReceiverAddress");
3573
4281
  transferModal$.hash.set(void 0);
3574
4282
  },
3575
4283
  state: {
3576
4284
  receiverAddress: "",
3577
4285
  collectionAddress: "0x",
3578
- chainId: "",
4286
+ chainId: 0,
3579
4287
  collectibleId: "",
3580
- quantity: "1"
4288
+ quantity: "1",
4289
+ transferIsBeingProcessed: false
3581
4290
  },
3582
4291
  view: "enterReceiverAddress",
3583
4292
  hash: void 0
@@ -3585,10 +4294,10 @@ var initialState7 = {
3585
4294
  var transferModal$ = observable7(initialState7);
3586
4295
 
3587
4296
  // src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
3588
- import { Button as Button3, Text as Text14, TextInput } from "@0xsequence/design-system";
3589
- import { observable as observable8 } from "@legendapp/state";
3590
- import { isAddress } from "viem";
3591
- import { useAccount as useAccount4 } from "wagmi";
4297
+ import { Text as Text19 } from "@0xsequence/design-system";
4298
+ import { observer as observer14 } from "@legendapp/state/react";
4299
+ import { isAddress as isAddress2 } from "viem";
4300
+ import { useAccount as useAccount6 } from "wagmi";
3592
4301
 
3593
4302
  // src/react/ui/modals/TransferModal/messages.ts
3594
4303
  var baseMessages = {
@@ -3599,7 +4308,142 @@ function getMessage(key) {
3599
4308
  return baseMessages[key];
3600
4309
  }
3601
4310
 
4311
+ // src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TokenQuantityInput.tsx
4312
+ import { cn as cn2 } from "@0xsequence/design-system";
4313
+ import { Text as Text18 } from "@0xsequence/design-system";
4314
+ import { observable as observable8 } from "@legendapp/state";
4315
+ import { observer as observer11 } from "@legendapp/state/react";
4316
+ import { jsx as jsx29, jsxs as jsxs22 } from "react/jsx-runtime";
4317
+ var TokenQuantityInput = observer11(
4318
+ ({
4319
+ balanceAmount,
4320
+ collection,
4321
+ isProcessingWithWaaS
4322
+ }) => {
4323
+ const $quantity = transferModal$.state.quantity;
4324
+ const $invalidQuantity = observable8(false);
4325
+ let insufficientBalance = true;
4326
+ if (balanceAmount !== void 0 && $quantity.get()) {
4327
+ try {
4328
+ const quantityBigInt = BigInt($quantity.get());
4329
+ insufficientBalance = quantityBigInt > balanceAmount;
4330
+ } catch (e) {
4331
+ insufficientBalance = true;
4332
+ }
4333
+ }
4334
+ return /* @__PURE__ */ jsxs22(
4335
+ "div",
4336
+ {
4337
+ className: cn2(
4338
+ "flex flex-col gap-3",
4339
+ isProcessingWithWaaS && "pointer-events-none opacity-50"
4340
+ ),
4341
+ children: [
4342
+ /* @__PURE__ */ jsx29(
4343
+ quantityInput_default,
4344
+ {
4345
+ $quantity,
4346
+ $invalidQuantity,
4347
+ decimals: collection?.decimals || 0,
4348
+ maxQuantity: balanceAmount ? String(balanceAmount) : "0",
4349
+ className: "[&>label>div>div]:h-13 [&>label>div>div]:rounded-xl [&>label>div>span]:text-sm [&>label>div>span]:text-text-80 [&>label]:gap-1"
4350
+ }
4351
+ ),
4352
+ /* @__PURE__ */ jsx29(
4353
+ Text18,
4354
+ {
4355
+ className: "font-body text-xs",
4356
+ color: insufficientBalance ? "negative" : "text50",
4357
+ fontWeight: "medium",
4358
+ children: `You have ${balanceAmount?.toString() || "0"} of this item`
4359
+ }
4360
+ )
4361
+ ]
4362
+ }
4363
+ );
4364
+ }
4365
+ );
4366
+ var TokenQuantityInput_default = TokenQuantityInput;
4367
+
4368
+ // src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TransferButton.tsx
4369
+ import { getNetwork as getNetwork5 } from "@0xsequence/connect";
4370
+ import { Button as Button6, Spinner as Spinner4 } from "@0xsequence/design-system";
4371
+ import { NetworkType as NetworkType5 } from "@0xsequence/network";
4372
+ import { observer as observer12 } from "@legendapp/state/react";
4373
+ import { jsx as jsx30, jsxs as jsxs23 } from "react/jsx-runtime";
4374
+ var TransferButton = observer12(
4375
+ ({
4376
+ onClick,
4377
+ isDisabled,
4378
+ chainId
4379
+ }) => {
4380
+ const { wallet } = useWallet();
4381
+ const network = getNetwork5(chainId);
4382
+ const isWaaS = wallet?.isWaaS;
4383
+ const isTestnet = network.type === NetworkType5.TESTNET;
4384
+ const isProcessing = transferModal$.state.transferIsBeingProcessed.get();
4385
+ const label = isProcessing ? isWaaS && !isTestnet ? /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-center gap-2", children: [
4386
+ /* @__PURE__ */ jsx30(Spinner4, { size: "sm", className: "text-white" }),
4387
+ /* @__PURE__ */ jsx30("span", { children: "Loading fee options" })
4388
+ ] }) : /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-center gap-2", children: [
4389
+ /* @__PURE__ */ jsx30(Spinner4, { size: "sm", className: "text-white" }),
4390
+ /* @__PURE__ */ jsx30("span", { children: "Transferring" })
4391
+ ] }) : "Transfer";
4392
+ return /* @__PURE__ */ jsx30(
4393
+ Button6,
4394
+ {
4395
+ className: "flex justify-self-end px-10",
4396
+ onClick,
4397
+ disabled: !!isDisabled,
4398
+ title: "Transfer",
4399
+ label,
4400
+ variant: "primary",
4401
+ shape: "square",
4402
+ size: "sm"
4403
+ }
4404
+ );
4405
+ }
4406
+ );
4407
+ var TransferButton_default = TransferButton;
4408
+
4409
+ // src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx
4410
+ import { TextInput } from "@0xsequence/design-system";
4411
+ import { observer as observer13 } from "@legendapp/state/react";
4412
+ import { isAddress } from "viem";
4413
+ import { useAccount as useAccount5 } from "wagmi";
4414
+ import { jsx as jsx31, jsxs as jsxs24 } from "react/jsx-runtime";
4415
+ var MAX_WALLET_ADDRESS_LENGTH = 42;
4416
+ var WalletAddressInput = observer13(() => {
4417
+ const { address: connectedAddress } = useAccount5();
4418
+ const receiverAddress = transferModal$.state.receiverAddress.get();
4419
+ const isWalletAddressValid = isAddress(receiverAddress);
4420
+ const isProcessing = transferModal$.state.transferIsBeingProcessed.get();
4421
+ const isSelfTransfer = isWalletAddressValid && connectedAddress && receiverAddress.toLowerCase() === connectedAddress.toLowerCase();
4422
+ const handleChangeWalletAddress = (event) => {
4423
+ transferModal$.state.receiverAddress.set(event.target.value);
4424
+ };
4425
+ return /* @__PURE__ */ jsxs24("div", { className: "[&>label>div>span]:text-sm [&>label>div>span]:text-text-80 [&>label]:gap-1", children: [
4426
+ /* @__PURE__ */ jsx31(
4427
+ TextInput,
4428
+ {
4429
+ label: "Wallet address",
4430
+ labelLocation: "top",
4431
+ autoFocus: true,
4432
+ value: receiverAddress,
4433
+ maxLength: MAX_WALLET_ADDRESS_LENGTH,
4434
+ onChange: handleChangeWalletAddress,
4435
+ name: "walletAddress",
4436
+ placeholder: "Enter wallet address",
4437
+ disabled: isProcessing
4438
+ }
4439
+ ),
4440
+ isSelfTransfer && /* @__PURE__ */ jsx31("div", { className: "mt-1 text-negative text-sm", children: "You cannot transfer to your own address" })
4441
+ ] });
4442
+ });
4443
+ var WalletAddressInput_default = WalletAddressInput;
4444
+
3602
4445
  // src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx
4446
+ import { useWaasFeeOptions as useWaasFeeOptions2 } from "@0xsequence/connect";
3603
4447
  var useHandleTransfer = () => {
3604
4448
  const {
3605
4449
  receiverAddress,
@@ -3612,29 +4456,34 @@ var useHandleTransfer = () => {
3612
4456
  } = transferModal$.state.get();
3613
4457
  const { transferTokensAsync } = useTransferTokens();
3614
4458
  const { show: showTransactionStatusModal } = useTransactionStatusModal();
4459
+ const { wallet } = useWallet();
4460
+ const [pendingFeeOptionConfirmation] = useWaasFeeOptions2();
3615
4461
  const getHash = async () => {
4462
+ const baseParams = {
4463
+ receiverAddress,
4464
+ collectionAddress,
4465
+ tokenId: collectibleId,
4466
+ chainId
4467
+ };
3616
4468
  if (collectionType === "ERC721" /* ERC721 */) {
3617
4469
  return await transferTokensAsync({
3618
- receiverAddress,
3619
- collectionAddress,
3620
- tokenId: collectibleId,
3621
- chainId,
4470
+ ...baseParams,
3622
4471
  contractType: "ERC721" /* ERC721 */
3623
4472
  });
3624
4473
  }
3625
4474
  return await transferTokensAsync({
3626
- receiverAddress,
3627
- collectionAddress,
3628
- tokenId: collectibleId,
3629
- chainId,
4475
+ ...baseParams,
3630
4476
  contractType: "ERC1155" /* ERC1155 */,
3631
4477
  quantity: String(quantity)
3632
4478
  });
3633
4479
  };
3634
- async function transfer() {
4480
+ const transfer = async () => {
3635
4481
  if (collectionType !== "ERC721" /* ERC721 */ && collectionType !== "ERC1155" /* ERC1155 */) {
3636
4482
  throw new InvalidContractTypeError(collectionType);
3637
4483
  }
4484
+ if (wallet?.isWaaS && pendingFeeOptionConfirmation) {
4485
+ return;
4486
+ }
3638
4487
  try {
3639
4488
  const hash = await getHash();
3640
4489
  transferModal$.close();
@@ -3654,30 +4503,47 @@ var useHandleTransfer = () => {
3654
4503
  transferModal$.view.set("enterReceiverAddress");
3655
4504
  callbacks?.onError?.(error);
3656
4505
  }
3657
- }
4506
+ };
3658
4507
  return { transfer };
3659
4508
  };
3660
4509
  var useHandleTransfer_default = useHandleTransfer;
3661
4510
 
3662
4511
  // src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx
3663
- import { Fragment as Fragment3, jsx as jsx24, jsxs as jsxs16 } from "react/jsx-runtime";
3664
- var EnterWalletAddressView = () => {
3665
- const { address } = useAccount4();
4512
+ import { jsx as jsx32, jsxs as jsxs25 } from "react/jsx-runtime";
4513
+ var EnterWalletAddressView = observer14(() => {
4514
+ const { address: connectedAddress } = useAccount6();
3666
4515
  const { collectionAddress, collectibleId, chainId, collectionType } = transferModal$.state.get();
3667
4516
  const $quantity = transferModal$.state.quantity;
3668
- const $invalidQuantity = observable8(false);
3669
- const isWalletAddressValid = isAddress(
3670
- transferModal$.state.receiverAddress.get()
3671
- );
4517
+ const receiverAddress = transferModal$.state.receiverAddress.get();
4518
+ const isWalletAddressValid = isAddress2(receiverAddress);
4519
+ const {
4520
+ isWaaS,
4521
+ isProcessingWithWaaS,
4522
+ shouldHideActionButton: shouldHideTransferButton
4523
+ } = useSelectWaasFeeOptions({
4524
+ chainId,
4525
+ isProcessing: transferModal$.state.transferIsBeingProcessed.get(),
4526
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
4527
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
4528
+ });
4529
+ const isSelfTransfer = isWalletAddressValid && connectedAddress && compareAddress(receiverAddress, connectedAddress);
3672
4530
  const { data: tokenBalance } = useListBalances({
3673
- chainId: Number(chainId),
4531
+ chainId,
3674
4532
  contractAddress: collectionAddress,
3675
4533
  tokenId: collectibleId,
3676
- accountAddress: address,
3677
- query: { enabled: !!address }
4534
+ accountAddress: connectedAddress,
4535
+ query: { enabled: !!connectedAddress }
3678
4536
  });
3679
4537
  const balanceAmount = tokenBalance?.pages[0].balances[0].balance;
3680
- const insufficientBalance = balanceAmount ? $quantity.get() > balanceAmount : true;
4538
+ let insufficientBalance = true;
4539
+ if (balanceAmount !== void 0 && $quantity.get()) {
4540
+ try {
4541
+ const quantityBigInt = BigInt($quantity.get());
4542
+ insufficientBalance = quantityBigInt > BigInt(balanceAmount);
4543
+ } catch (e) {
4544
+ insufficientBalance = true;
4545
+ }
4546
+ }
3681
4547
  const { data: collection } = useCollection({
3682
4548
  collectionAddress,
3683
4549
  chainId
@@ -3686,90 +4552,75 @@ var EnterWalletAddressView = () => {
3686
4552
  collection?.type
3687
4553
  );
3688
4554
  const { transfer } = useHandleTransfer_default();
3689
- function handleChangeWalletAddress(event) {
3690
- transferModal$.state.receiverAddress.set(event.target.value);
3691
- }
3692
- function handleChangeView() {
3693
- transfer();
3694
- transferModal$.view.set("followWalletInstructions");
3695
- }
3696
- return /* @__PURE__ */ jsxs16("div", { className: "grid grow gap-6", children: [
3697
- /* @__PURE__ */ jsx24(Text14, { className: "font-body text-xl", color: "white", fontWeight: "bold", children: "Transfer your item" }),
3698
- /* @__PURE__ */ jsxs16("div", { className: "flex flex-col gap-3", children: [
3699
- /* @__PURE__ */ jsx24(
4555
+ const onTransferClick = async () => {
4556
+ transferModal$.state.transferIsBeingProcessed.set(true);
4557
+ try {
4558
+ if (!isWaaS) {
4559
+ transferModal$.view.set("followWalletInstructions");
4560
+ } else {
4561
+ selectWaasFeeOptions$.isVisible.set(true);
4562
+ }
4563
+ await transfer();
4564
+ } catch (error) {
4565
+ console.error("Transfer failed:", error);
4566
+ } finally {
4567
+ if (transferModal$.view.get() === "enterReceiverAddress") {
4568
+ transferModal$.state.transferIsBeingProcessed.set(false);
4569
+ }
4570
+ }
4571
+ };
4572
+ const isErc1155 = collectionType === "ERC1155" /* ERC1155 */;
4573
+ const showQuantityInput = isErc1155 && !!balanceAmount;
4574
+ const isProcessing = !!transferModal$.state.transferIsBeingProcessed.get();
4575
+ const isTransferDisabled = isProcessing || !isWalletAddressValid || insufficientBalance || !$quantity.get() || Number($quantity.get()) === 0 || isSelfTransfer;
4576
+ return /* @__PURE__ */ jsxs25("div", { className: "grid grow gap-6", children: [
4577
+ /* @__PURE__ */ jsx32(Text19, { className: "font-body text-xl", color: "white", fontWeight: "bold", children: "Transfer your item" }),
4578
+ /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-3", children: [
4579
+ /* @__PURE__ */ jsx32(
3700
4580
  AlertMessage,
3701
4581
  {
3702
4582
  message: getMessage("enterReceiverAddress"),
3703
4583
  type: "warning"
3704
4584
  }
3705
4585
  ),
3706
- /* @__PURE__ */ jsx24("div", { className: "[&>label>div>span]:text-sm [&>label>div>span]:text-text-80 [&>label]:gap-1", children: /* @__PURE__ */ jsx24(
3707
- TextInput,
4586
+ /* @__PURE__ */ jsx32(WalletAddressInput_default, {}),
4587
+ showQuantityInput && /* @__PURE__ */ jsx32(
4588
+ TokenQuantityInput_default,
3708
4589
  {
3709
- label: "Wallet address",
3710
- labelLocation: "top",
3711
- autoFocus: true,
3712
- value: transferModal$.state.receiverAddress.get(),
3713
- onChange: handleChangeWalletAddress,
3714
- name: "walletAddress",
3715
- placeholder: "Enter wallet address"
4590
+ balanceAmount: balanceAmount ? BigInt(balanceAmount) : void 0,
4591
+ collection,
4592
+ isProcessingWithWaaS: isProcessingWithWaaS ?? false
3716
4593
  }
3717
- ) }),
3718
- collectionType === "ERC1155" /* ERC1155 */ && balanceAmount && /* @__PURE__ */ jsxs16(Fragment3, { children: [
3719
- /* @__PURE__ */ jsx24(
3720
- quantityInput_default,
3721
- {
3722
- $quantity,
3723
- $invalidQuantity,
3724
- decimals: collection?.decimals || 0,
3725
- maxQuantity: balanceAmount,
3726
- className: "[&>label>div>div]:h-13 [&>label>div>div]:rounded-xl [&>label>div>span]:text-sm [&>label>div>span]:text-text-80 [&>label]:gap-1"
3727
- }
3728
- ),
3729
- /* @__PURE__ */ jsx24(
3730
- Text14,
3731
- {
3732
- className: "font-body text-xs",
3733
- color: insufficientBalance ? "negative" : "text50",
3734
- fontWeight: "medium",
3735
- children: `You have ${balanceAmount} of this item`
3736
- }
3737
- )
3738
- ] })
4594
+ )
3739
4595
  ] }),
3740
- /* @__PURE__ */ jsx24(
3741
- Button3,
4596
+ !shouldHideTransferButton && /* @__PURE__ */ jsx32(
4597
+ TransferButton_default,
3742
4598
  {
3743
- className: "flex justify-self-end px-10",
3744
- onClick: handleChangeView,
3745
- disabled: !isWalletAddressValid || insufficientBalance || !$quantity.get(),
3746
- title: "Transfer",
3747
- label: "Transfer",
3748
- variant: "primary",
3749
- shape: "square",
3750
- size: "sm"
4599
+ onClick: onTransferClick,
4600
+ isDisabled: isTransferDisabled,
4601
+ chainId
3751
4602
  }
3752
4603
  )
3753
4604
  ] });
3754
- };
4605
+ });
3755
4606
  var enterWalletAddress_default = EnterWalletAddressView;
3756
4607
 
3757
4608
  // src/react/ui/modals/TransferModal/_views/followWalletInstructions/index.tsx
3758
- import { Button as Button4, Text as Text15 } from "@0xsequence/design-system";
3759
- import { observer as observer10 } from "@legendapp/state/react";
3760
- import { jsx as jsx25, jsxs as jsxs17 } from "react/jsx-runtime";
3761
- var FollowWalletInstructionsView = observer10(() => {
3762
- return /* @__PURE__ */ jsxs17("div", { className: "grid grow gap-6", children: [
3763
- /* @__PURE__ */ jsx25(Text15, { className: "font-body text-xl", color: "white", fontWeight: "bold", children: "Transfer your item" }),
3764
- /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ jsx25(
4609
+ import { Button as Button7, Text as Text20 } from "@0xsequence/design-system";
4610
+ import { observer as observer15 } from "@legendapp/state/react";
4611
+ import { jsx as jsx33, jsxs as jsxs26 } from "react/jsx-runtime";
4612
+ var FollowWalletInstructionsView = observer15(() => {
4613
+ return /* @__PURE__ */ jsxs26("div", { className: "grid grow gap-6", children: [
4614
+ /* @__PURE__ */ jsx33(Text20, { className: "font-body text-xl", color: "white", fontWeight: "bold", children: "Transfer your item" }),
4615
+ /* @__PURE__ */ jsx33("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ jsx33(
3765
4616
  AlertMessage,
3766
4617
  {
3767
4618
  message: getMessage("followWalletInstructions"),
3768
4619
  type: "info"
3769
4620
  }
3770
4621
  ) }),
3771
- /* @__PURE__ */ jsx25(
3772
- Button4,
4622
+ /* @__PURE__ */ jsx33(
4623
+ Button7,
3773
4624
  {
3774
4625
  className: "flex justify-self-end px-10",
3775
4626
  disabled: true,
@@ -3785,84 +4636,113 @@ var FollowWalletInstructionsView = observer10(() => {
3785
4636
  var followWalletInstructions_default = FollowWalletInstructionsView;
3786
4637
 
3787
4638
  // src/react/ui/modals/TransferModal/index.tsx
3788
- import { jsx as jsx26 } from "react/jsx-runtime";
4639
+ import { jsx as jsx34, jsxs as jsxs27 } from "react/jsx-runtime";
3789
4640
  var useTransferModal = () => {
3790
- const { chainId: accountChainId } = useAccount5();
4641
+ const { chainId: accountChainId } = useAccount7();
3791
4642
  const { show: showSwitchNetworkModal } = useSwitchChainModal();
4643
+ const { wallet } = useWallet();
4644
+ const { switchChain } = useSwitchChain();
3792
4645
  const openModal = (args) => {
3793
4646
  transferModal$.open(args);
3794
4647
  };
3795
4648
  const handleShowModal = (args) => {
3796
- const isSameChain = accountChainId === Number(args.chainId);
4649
+ const targetChainId = Number(args.chainId);
4650
+ const isSameChain = accountChainId === targetChainId;
3797
4651
  if (!isSameChain) {
3798
- showSwitchNetworkModal({
3799
- chainIdToSwitchTo: Number(args.chainId),
3800
- onSuccess: () => openModal(args)
3801
- });
4652
+ if (wallet?.isWaaS) {
4653
+ switchChain({ chainId: targetChainId });
4654
+ openModal(args);
4655
+ } else {
4656
+ showSwitchNetworkModal({
4657
+ chainIdToSwitchTo: targetChainId,
4658
+ onSuccess: () => openModal(args)
4659
+ });
4660
+ }
3802
4661
  return;
3803
4662
  }
3804
4663
  openModal(args);
3805
4664
  };
4665
+ const updateCallbacks = (callbacks) => {
4666
+ transferModal$.state.set({
4667
+ ...transferModal$.state.get(),
4668
+ callbacks
4669
+ });
4670
+ };
3806
4671
  return {
3807
4672
  show: handleShowModal,
3808
- close: () => transferModal$.close(),
3809
- onError: (callbacks) => {
3810
- transferModal$.state.set({
3811
- ...transferModal$.state.get(),
3812
- callbacks
3813
- });
3814
- },
3815
- onSuccess: (callbacks) => {
3816
- transferModal$.state.set({
3817
- ...transferModal$.state.get(),
3818
- callbacks
3819
- });
3820
- }
4673
+ close: transferModal$.close,
4674
+ onError: updateCallbacks,
4675
+ onSuccess: updateCallbacks
3821
4676
  };
3822
4677
  };
3823
- var TransferModal = observer11(() => {
4678
+ var TransactionModalView = observer16(() => {
4679
+ const { view } = transferModal$.get();
4680
+ switch (view) {
4681
+ case "enterReceiverAddress":
4682
+ return /* @__PURE__ */ jsx34(enterWalletAddress_default, {});
4683
+ case "followWalletInstructions":
4684
+ return /* @__PURE__ */ jsx34(followWalletInstructions_default, {});
4685
+ default:
4686
+ return null;
4687
+ }
4688
+ });
4689
+ var TransferModal = observer16(() => {
3824
4690
  const isOpen = transferModal$.isOpen.get();
4691
+ const chainId = transferModal$.state.chainId.get();
4692
+ const isTransferBeingProcessed = transferModal$.state.transferIsBeingProcessed.get();
4693
+ const { waasFeeOptionsShown } = useSelectWaasFeeOptions({
4694
+ chainId,
4695
+ isProcessing: isTransferBeingProcessed,
4696
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
4697
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
4698
+ });
3825
4699
  if (!isOpen) return null;
3826
- return /* @__PURE__ */ jsx26(
4700
+ return /* @__PURE__ */ jsxs27(
3827
4701
  Modal6,
3828
4702
  {
3829
4703
  isDismissible: true,
3830
- onClose: transferModal$.close,
4704
+ onClose: () => {
4705
+ transferModal$.close();
4706
+ selectWaasFeeOptions$.hide();
4707
+ },
3831
4708
  size: "sm",
3832
4709
  overlayProps: MODAL_OVERLAY_PROPS,
3833
4710
  contentProps: {
3834
4711
  style: {
3835
- height: "auto"
4712
+ height: "auto",
4713
+ overflow: "auto"
3836
4714
  }
3837
4715
  },
3838
- children: /* @__PURE__ */ jsx26("div", { className: "flex w-full flex-col p-7", children: /* @__PURE__ */ jsx26(TransactionModalView, {}) })
4716
+ children: [
4717
+ /* @__PURE__ */ jsx34("div", { className: "flex w-full flex-col p-7", children: /* @__PURE__ */ jsx34(TransactionModalView, {}) }),
4718
+ waasFeeOptionsShown && /* @__PURE__ */ jsx34(
4719
+ selectWaasFeeOptions_default,
4720
+ {
4721
+ chainId: Number(chainId),
4722
+ onCancel: () => {
4723
+ transferModal$.state.transferIsBeingProcessed.set(false);
4724
+ },
4725
+ titleOnConfirm: "Processing transfer...",
4726
+ className: "p-7 pt-0"
4727
+ }
4728
+ )
4729
+ ]
3839
4730
  }
3840
4731
  );
3841
4732
  });
3842
- var TransactionModalView = observer11(() => {
3843
- const { view } = transferModal$.get();
3844
- switch (view) {
3845
- case "enterReceiverAddress":
3846
- return /* @__PURE__ */ jsx26(enterWalletAddress_default, {});
3847
- case "followWalletInstructions":
3848
- return /* @__PURE__ */ jsx26(followWalletInstructions_default, {});
3849
- default:
3850
- return null;
3851
- }
3852
- });
3853
4733
 
3854
4734
  // src/react/ui/modals/modal-provider.tsx
3855
- import { Fragment as Fragment4, jsx as jsx27, jsxs as jsxs18 } from "react/jsx-runtime";
3856
- var ModalProvider = observer12(() => {
3857
- return /* @__PURE__ */ jsxs18(Fragment4, { children: [
3858
- /* @__PURE__ */ jsx27(CreateListingModal, {}),
3859
- /* @__PURE__ */ jsx27(MakeOfferModal, {}),
3860
- /* @__PURE__ */ jsx27(TransferModal, {}),
3861
- /* @__PURE__ */ jsx27(SellModal, {}),
3862
- /* @__PURE__ */ jsx27(BuyModal, {}),
3863
- /* @__PURE__ */ jsx27(SuccessfulPurchaseModal_default, {}),
3864
- /* @__PURE__ */ jsx27(switchChainModal_default, {}),
3865
- /* @__PURE__ */ jsx27(transactionStatusModal_default, {})
4735
+ import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs28 } from "react/jsx-runtime";
4736
+ var ModalProvider = observer17(() => {
4737
+ return /* @__PURE__ */ jsxs28(Fragment3, { children: [
4738
+ /* @__PURE__ */ jsx35(CreateListingModal, {}),
4739
+ /* @__PURE__ */ jsx35(MakeOfferModal, {}),
4740
+ /* @__PURE__ */ jsx35(TransferModal, {}),
4741
+ /* @__PURE__ */ jsx35(SellModal, {}),
4742
+ /* @__PURE__ */ jsx35(BuyModal, {}),
4743
+ /* @__PURE__ */ jsx35(SuccessfulPurchaseModal_default, {}),
4744
+ /* @__PURE__ */ jsx35(switchChainModal_default, {}),
4745
+ /* @__PURE__ */ jsx35(transactionStatusModal_default, {})
3866
4746
  ] });
3867
4747
  });
3868
4748
 
@@ -3888,24 +4768,16 @@ var useSellModal = (callbacks) => {
3888
4768
  };
3889
4769
  };
3890
4770
 
3891
- // src/react/ui/modals/BuyModal/index.tsx
3892
- var useBuyModal = (callbacks) => {
3893
- return {
3894
- show: (args) => buyModal$.open({ ...args, defaultCallbacks: callbacks }),
3895
- close: () => buyModal$.close()
3896
- };
3897
- };
3898
-
3899
4771
  // src/react/ui/components/collectible-card/CollectibleCard.tsx
3900
- import { Skeleton as Skeleton9 } from "@0xsequence/design-system";
4772
+ import { Skeleton as Skeleton11 } from "@0xsequence/design-system";
3901
4773
 
3902
4774
  // src/react/ui/components/_internals/action-button/ActionButton.tsx
3903
- import { observer as observer13 } from "@legendapp/state/react";
4775
+ import { observer as observer18 } from "@legendapp/state/react";
3904
4776
 
3905
4777
  // src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx
3906
4778
  import { useOpenConnectModal } from "@0xsequence/connect";
3907
- import { Button as Button5 } from "@0xsequence/design-system";
3908
- import { useAccount as useAccount6 } from "wagmi";
4779
+ import { Button as Button8 } from "@0xsequence/design-system";
4780
+ import { useAccount as useAccount8 } from "wagmi";
3909
4781
 
3910
4782
  // src/react/ui/components/_internals/action-button/store.ts
3911
4783
  import { observable as observable9 } from "@legendapp/state";
@@ -3934,7 +4806,7 @@ var executePendingActionIfExists = () => {
3934
4806
  };
3935
4807
 
3936
4808
  // src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx
3937
- import { jsx as jsx28 } from "react/jsx-runtime";
4809
+ import { jsx as jsx36 } from "react/jsx-runtime";
3938
4810
  function ActionButtonBody({
3939
4811
  tokenId,
3940
4812
  label,
@@ -3942,7 +4814,7 @@ function ActionButtonBody({
3942
4814
  icon,
3943
4815
  action
3944
4816
  }) {
3945
- const { address } = useAccount6();
4817
+ const { address } = useAccount8();
3946
4818
  const { setOpenConnectModal } = useOpenConnectModal();
3947
4819
  const handleClick = (e) => {
3948
4820
  e.preventDefault();
@@ -3954,8 +4826,8 @@ function ActionButtonBody({
3954
4826
  onClick();
3955
4827
  }
3956
4828
  };
3957
- return /* @__PURE__ */ jsx28(
3958
- Button5,
4829
+ return /* @__PURE__ */ jsx36(
4830
+ Button8,
3959
4831
  {
3960
4832
  className: "flex w-full items-center justify-center",
3961
4833
  variant: "primary",
@@ -3969,7 +4841,7 @@ function ActionButtonBody({
3969
4841
  }
3970
4842
 
3971
4843
  // src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx
3972
- import { jsx as jsx29 } from "react/jsx-runtime";
4844
+ import { jsx as jsx37 } from "react/jsx-runtime";
3973
4845
  function NonOwnerActions({
3974
4846
  action,
3975
4847
  tokenId,
@@ -3984,7 +4856,7 @@ function NonOwnerActions({
3984
4856
  if (!lowestListing) {
3985
4857
  throw new InvalidStepError("BUY", "lowestListing is required");
3986
4858
  }
3987
- return /* @__PURE__ */ jsx29(
4859
+ return /* @__PURE__ */ jsx37(
3988
4860
  ActionButtonBody,
3989
4861
  {
3990
4862
  action: "Buy" /* BUY */,
@@ -3993,15 +4865,16 @@ function NonOwnerActions({
3993
4865
  onClick: () => showBuyModal({
3994
4866
  collectionAddress,
3995
4867
  chainId,
3996
- tokenId,
3997
- order: lowestListing
4868
+ collectibleId: tokenId,
4869
+ orderId: lowestListing.orderId,
4870
+ marketplace: lowestListing.marketplace
3998
4871
  }),
3999
4872
  icon: CartIcon_default
4000
4873
  }
4001
4874
  );
4002
4875
  }
4003
4876
  if (action === "Make an offer" /* OFFER */) {
4004
- return /* @__PURE__ */ jsx29(
4877
+ return /* @__PURE__ */ jsx37(
4005
4878
  ActionButtonBody,
4006
4879
  {
4007
4880
  action: "Make an offer" /* OFFER */,
@@ -4020,7 +4893,7 @@ function NonOwnerActions({
4020
4893
  }
4021
4894
 
4022
4895
  // src/react/ui/components/_internals/action-button/components/OwnerActions.tsx
4023
- import { jsx as jsx30 } from "react/jsx-runtime";
4896
+ import { jsx as jsx38 } from "react/jsx-runtime";
4024
4897
  function OwnerActions({
4025
4898
  action,
4026
4899
  tokenId,
@@ -4033,7 +4906,7 @@ function OwnerActions({
4033
4906
  const { show: showSellModal } = useSellModal();
4034
4907
  const { show: showTransferModal } = useTransferModal();
4035
4908
  if (action === "Create listing" /* LIST */) {
4036
- return /* @__PURE__ */ jsx30(
4909
+ return /* @__PURE__ */ jsx38(
4037
4910
  ActionButtonBody,
4038
4911
  {
4039
4912
  label: "Create listing",
@@ -4048,7 +4921,7 @@ function OwnerActions({
4048
4921
  );
4049
4922
  }
4050
4923
  if (action === "Sell" /* SELL */ && highestOffer) {
4051
- return /* @__PURE__ */ jsx30(
4924
+ return /* @__PURE__ */ jsx38(
4052
4925
  ActionButtonBody,
4053
4926
  {
4054
4927
  tokenId,
@@ -4063,7 +4936,7 @@ function OwnerActions({
4063
4936
  );
4064
4937
  }
4065
4938
  if (action === "Transfer" /* TRANSFER */) {
4066
- return /* @__PURE__ */ jsx30(
4939
+ return /* @__PURE__ */ jsx38(
4067
4940
  ActionButtonBody,
4068
4941
  {
4069
4942
  label: "Transfer",
@@ -4080,21 +4953,21 @@ function OwnerActions({
4080
4953
  }
4081
4954
 
4082
4955
  // src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts
4083
- import { useEffect as useEffect9 } from "react";
4084
- import { useAccount as useAccount7 } from "wagmi";
4956
+ import { useEffect as useEffect11 } from "react";
4957
+ import { useAccount as useAccount9 } from "wagmi";
4085
4958
  var useActionButtonLogic = ({
4086
4959
  tokenId,
4087
4960
  owned,
4088
4961
  action,
4089
4962
  onCannotPerformAction
4090
4963
  }) => {
4091
- const { address } = useAccount7();
4964
+ const { address } = useAccount9();
4092
4965
  const actionsThatOwnersCannotPerform = [
4093
4966
  "Buy" /* BUY */,
4094
4967
  "Make an offer" /* OFFER */
4095
4968
  ];
4096
4969
  const pendingActionType = actionButtonStore.pendingAction.type.get();
4097
- useEffect9(() => {
4970
+ useEffect11(() => {
4098
4971
  if (owned && actionButtonStore.pendingAction.get() && address && !actionsThatOwnersCannotPerform.includes(action) && actionButtonStore.pendingAction.get()?.collectibleId === tokenId) {
4099
4972
  onCannotPerformAction?.(
4100
4973
  pendingActionType
@@ -4110,7 +4983,7 @@ var useActionButtonLogic = ({
4110
4983
  onCannotPerformAction,
4111
4984
  pendingActionType
4112
4985
  ]);
4113
- useEffect9(() => {
4986
+ useEffect11(() => {
4114
4987
  if (address && !owned && actionButtonStore.pendingAction.get() && actionButtonStore.pendingAction.get()?.collectibleId === tokenId) {
4115
4988
  setTimeout(() => {
4116
4989
  executePendingActionIfExists();
@@ -4132,8 +5005,8 @@ var useActionButtonLogic = ({
4132
5005
  };
4133
5006
 
4134
5007
  // src/react/ui/components/_internals/action-button/ActionButton.tsx
4135
- import { jsx as jsx31 } from "react/jsx-runtime";
4136
- var ActionButton = observer13(
5008
+ import { jsx as jsx39 } from "react/jsx-runtime";
5009
+ var ActionButton = observer18(
4137
5010
  ({
4138
5011
  collectionAddress,
4139
5012
  chainId,
@@ -4155,7 +5028,7 @@ var ActionButton = observer13(
4155
5028
  return null;
4156
5029
  }
4157
5030
  if (isOwnerAction) {
4158
- return /* @__PURE__ */ jsx31(
5031
+ return /* @__PURE__ */ jsx39(
4159
5032
  OwnerActions,
4160
5033
  {
4161
5034
  action,
@@ -4167,7 +5040,7 @@ var ActionButton = observer13(
4167
5040
  }
4168
5041
  );
4169
5042
  }
4170
- return /* @__PURE__ */ jsx31(
5043
+ return /* @__PURE__ */ jsx39(
4171
5044
  NonOwnerActions,
4172
5045
  {
4173
5046
  action,
@@ -4182,12 +5055,12 @@ var ActionButton = observer13(
4182
5055
  );
4183
5056
 
4184
5057
  // src/react/ui/components/collectible-card/CollectibleAsset.tsx
4185
- import { Skeleton as Skeleton8 } from "@0xsequence/design-system";
4186
- import { useEffect as useEffect10, useRef as useRef2, useState as useState8 } from "react";
4187
- import { jsx as jsx32, jsxs as jsxs19 } from "react/jsx-runtime";
5058
+ import { Skeleton as Skeleton10 } from "@0xsequence/design-system";
5059
+ import { useEffect as useEffect12, useRef as useRef2, useState as useState10 } from "react";
5060
+ import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
4188
5061
  function CollectibleAssetSkeleton() {
4189
- return /* @__PURE__ */ jsx32(
4190
- Skeleton8,
5062
+ return /* @__PURE__ */ jsx40(
5063
+ Skeleton10,
4191
5064
  {
4192
5065
  size: "lg",
4193
5066
  className: "absolute inset-0 h-full w-full animate-shimmer",
@@ -4210,14 +5083,14 @@ function CollectibleAsset({
4210
5083
  collectibleMetadata,
4211
5084
  assetSrcPrefixUrl
4212
5085
  }) {
4213
- const [assetLoadFailed, setAssetLoadFailed] = useState8(false);
4214
- const [assetLoading, setAssetLoading] = useState8(true);
5086
+ const [assetLoadFailed, setAssetLoadFailed] = useState10(false);
5087
+ const [assetLoading, setAssetLoading] = useState10(true);
4215
5088
  const videoRef = useRef2(null);
4216
5089
  const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
4217
5090
  const placeholderImage = chess_tile_default;
4218
5091
  const assetUrl = collectibleMetadata?.image || collectibleMetadata?.video || collectibleMetadata?.animation_url || collectibleMetadata?.assets?.[0]?.url || placeholderImage;
4219
5092
  const proxiedAssetUrl = assetSrcPrefixUrl ? `${assetSrcPrefixUrl}${assetUrl}` : assetUrl;
4220
- useEffect10(() => {
5093
+ useEffect12(() => {
4221
5094
  if (videoRef.current) {
4222
5095
  videoRef.current.addEventListener("loadedmetadata", () => {
4223
5096
  setAssetLoading(false);
@@ -4225,9 +5098,9 @@ function CollectibleAsset({
4225
5098
  }
4226
5099
  }, []);
4227
5100
  if (isHtml(assetUrl)) {
4228
- return /* @__PURE__ */ jsxs19("div", { className: "flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
4229
- assetLoading && /* @__PURE__ */ jsx32(CollectibleAssetSkeleton, {}),
4230
- /* @__PURE__ */ jsx32(
5101
+ return /* @__PURE__ */ jsxs29("div", { className: "flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
5102
+ assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5103
+ /* @__PURE__ */ jsx40(
4231
5104
  "iframe",
4232
5105
  {
4233
5106
  title: name || "Collectible",
@@ -4245,9 +5118,9 @@ function CollectibleAsset({
4245
5118
  ] });
4246
5119
  }
4247
5120
  if (isVideo(assetUrl)) {
4248
- return /* @__PURE__ */ jsxs19("div", { className: "relative flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
4249
- assetLoading && /* @__PURE__ */ jsx32(CollectibleAssetSkeleton, {}),
4250
- /* @__PURE__ */ jsx32(
5121
+ return /* @__PURE__ */ jsxs29("div", { className: "relative flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
5122
+ assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5123
+ /* @__PURE__ */ jsx40(
4251
5124
  "video",
4252
5125
  {
4253
5126
  ref: videoRef,
@@ -4265,14 +5138,14 @@ function CollectibleAsset({
4265
5138
  onError: () => {
4266
5139
  setAssetLoadFailed(true);
4267
5140
  },
4268
- children: /* @__PURE__ */ jsx32("source", { src: proxiedAssetUrl })
5141
+ children: /* @__PURE__ */ jsx40("source", { src: proxiedAssetUrl })
4269
5142
  }
4270
5143
  )
4271
5144
  ] });
4272
5145
  }
4273
- return /* @__PURE__ */ jsxs19("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: [
4274
- assetLoading && /* @__PURE__ */ jsx32(CollectibleAssetSkeleton, {}),
4275
- /* @__PURE__ */ jsx32(
5146
+ return /* @__PURE__ */ jsxs29("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: [
5147
+ assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5148
+ /* @__PURE__ */ jsx40(
4276
5149
  "img",
4277
5150
  {
4278
5151
  src: assetLoadFailed ? placeholderImage : proxiedAssetUrl,
@@ -4290,26 +5163,26 @@ import {
4290
5163
  ChevronLeftIcon,
4291
5164
  ChevronRightIcon,
4292
5165
  IconButton as IconButton2,
4293
- Image as Image6,
4294
- Text as Text16
5166
+ Image as Image7,
5167
+ Text as Text21
4295
5168
  } from "@0xsequence/design-system";
4296
- import { formatUnits as formatUnits7 } from "viem";
4297
- import { jsx as jsx33, jsxs as jsxs20 } from "react/jsx-runtime";
5169
+ import { formatUnits as formatUnits9 } from "viem";
5170
+ import { jsx as jsx41, jsxs as jsxs30 } from "react/jsx-runtime";
4298
5171
  var OVERFLOW_PRICE = 1e8;
4299
5172
  var UNDERFLOW_PRICE = 1e-4;
4300
5173
  var formatPrice = (amount, currency) => {
4301
- const formattedPrice = formatUnits7(BigInt(amount), currency.decimals);
5174
+ const formattedPrice = formatUnits9(BigInt(amount), currency.decimals);
4302
5175
  const numericPrice = Number.parseFloat(formattedPrice);
4303
5176
  if (numericPrice < UNDERFLOW_PRICE) {
4304
- return /* @__PURE__ */ jsxs20("div", { className: "flex items-center", children: [
4305
- /* @__PURE__ */ jsx33(ChevronLeftIcon, { className: "h-3 w-3 text-text-100" }),
4306
- /* @__PURE__ */ jsx33(Text16, { children: `${UNDERFLOW_PRICE} ${currency.symbol}` })
5177
+ return /* @__PURE__ */ jsxs30("div", { className: "flex items-center", children: [
5178
+ /* @__PURE__ */ jsx41(ChevronLeftIcon, { className: "h-3 w-3 text-text-100" }),
5179
+ /* @__PURE__ */ jsx41(Text21, { children: `${UNDERFLOW_PRICE} ${currency.symbol}` })
4307
5180
  ] });
4308
5181
  }
4309
5182
  if (numericPrice > OVERFLOW_PRICE) {
4310
- return /* @__PURE__ */ jsxs20("div", { className: "flex items-center", children: [
4311
- /* @__PURE__ */ jsx33(ChevronRightIcon, { className: "h-3 w-3 text-text-100" }),
4312
- /* @__PURE__ */ jsx33(Text16, { children: `${OVERFLOW_PRICE.toLocaleString("en-US", {
5183
+ return /* @__PURE__ */ jsxs30("div", { className: "flex items-center", children: [
5184
+ /* @__PURE__ */ jsx41(ChevronRightIcon, { className: "h-3 w-3 text-text-100" }),
5185
+ /* @__PURE__ */ jsx41(Text21, { children: `${OVERFLOW_PRICE.toLocaleString("en-US", {
4313
5186
  maximumFractionDigits: 2
4314
5187
  })} ${currency.symbol}` })
4315
5188
  ] });
@@ -4319,7 +5192,7 @@ var formatPrice = (amount, currency) => {
4319
5192
  minimumFractionDigits: 0,
4320
5193
  maximumFractionDigits: maxDecimals
4321
5194
  });
4322
- return /* @__PURE__ */ jsx33("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs20(Text16, { children: [
5195
+ return /* @__PURE__ */ jsx41("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs30(Text21, { children: [
4323
5196
  formattedNumber,
4324
5197
  " ",
4325
5198
  currency.symbol
@@ -4342,10 +5215,10 @@ var Footer = ({
4342
5215
  if (name.length > 17 && !highestOffer) {
4343
5216
  name = `${name.substring(0, 17)}...`;
4344
5217
  }
4345
- return /* @__PURE__ */ jsxs20("div", { className: "relative flex flex-col items-start gap-2 whitespace-nowrap bg-background-primary p-4", children: [
4346
- /* @__PURE__ */ jsxs20("div", { className: "relative flex w-full items-center justify-between", children: [
4347
- /* @__PURE__ */ jsx33(Text16, { className: "text-left font-body font-bold text-sm text-text-100", children: name || "Untitled" }),
4348
- highestOffer && onOfferClick && /* @__PURE__ */ jsx33(
5218
+ return /* @__PURE__ */ jsxs30("div", { className: "relative flex flex-col items-start gap-2 whitespace-nowrap bg-background-primary p-4", children: [
5219
+ /* @__PURE__ */ jsxs30("div", { className: "relative flex w-full items-center justify-between", children: [
5220
+ /* @__PURE__ */ jsx41(Text21, { className: "text-left font-body font-bold text-sm text-text-100", children: name || "Untitled" }),
5221
+ highestOffer && onOfferClick && /* @__PURE__ */ jsx41(
4349
5222
  IconButton2,
4350
5223
  {
4351
5224
  className: "absolute top-0 right-0 h-[22px] w-[22px] hover:animate-bell-ring",
@@ -4354,13 +5227,13 @@ var Footer = ({
4354
5227
  onClick: (e) => {
4355
5228
  onOfferClick?.(e);
4356
5229
  },
4357
- icon: (props) => /* @__PURE__ */ jsx33(BellIcon_default, { ...props, size: "xs" })
5230
+ icon: (props) => /* @__PURE__ */ jsx41(BellIcon_default, { ...props, size: "xs" })
4358
5231
  }
4359
5232
  )
4360
5233
  ] }),
4361
- /* @__PURE__ */ jsxs20("div", { className: "flex items-center gap-1", children: [
4362
- listed && lowestListingCurrency.imageUrl && /* @__PURE__ */ jsx33(
4363
- Image6,
5234
+ /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-1", children: [
5235
+ listed && lowestListingCurrency.imageUrl && /* @__PURE__ */ jsx41(
5236
+ Image7,
4364
5237
  {
4365
5238
  className: "h-3 w-3",
4366
5239
  src: lowestListingCurrency.imageUrl,
@@ -4369,8 +5242,8 @@ var Footer = ({
4369
5242
  }
4370
5243
  }
4371
5244
  ),
4372
- /* @__PURE__ */ jsxs20(
4373
- Text16,
5245
+ /* @__PURE__ */ jsxs30(
5246
+ Text21,
4374
5247
  {
4375
5248
  className: `text-left font-body font-bold text-sm ${listed ? "text-text-100" : "text-text-50"}`,
4376
5249
  children: [
@@ -4380,7 +5253,7 @@ var Footer = ({
4380
5253
  }
4381
5254
  )
4382
5255
  ] }),
4383
- /* @__PURE__ */ jsx33(
5256
+ /* @__PURE__ */ jsx41(
4384
5257
  TokenTypeBalancePill,
4385
5258
  {
4386
5259
  balance,
@@ -4395,16 +5268,16 @@ var TokenTypeBalancePill = ({
4395
5268
  type,
4396
5269
  decimals
4397
5270
  }) => {
4398
- const displayText = type === "ERC1155" /* ERC1155 */ ? balance ? `Owned: ${formatUnits7(BigInt(balance), decimals ?? 0)}` : "ERC-1155" : "ERC-721";
4399
- return /* @__PURE__ */ jsx33(Text16, { className: "rounded-lg bg-background-secondary px-2 py-1 text-left font-medium text-text-80 text-xs", children: displayText });
5271
+ const displayText = type === "ERC1155" /* ERC1155 */ ? balance ? `Owned: ${formatUnits9(BigInt(balance), decimals ?? 0)}` : "ERC-1155" : "ERC-721";
5272
+ 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 });
4400
5273
  };
4401
5274
 
4402
5275
  // src/react/ui/components/collectible-card/CollectibleCard.tsx
4403
- import { jsx as jsx34, jsxs as jsxs21 } from "react/jsx-runtime";
5276
+ import { jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
4404
5277
  function CollectibleSkeleton() {
4405
- return /* @__PURE__ */ jsxs21("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: [
4406
- /* @__PURE__ */ jsx34("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: /* @__PURE__ */ jsx34(
4407
- Skeleton9,
5278
+ 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: [
5279
+ /* @__PURE__ */ jsx42("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: /* @__PURE__ */ jsx42(
5280
+ Skeleton11,
4408
5281
  {
4409
5282
  size: "lg",
4410
5283
  className: "absolute inset-0 h-full w-full animate-shimmer",
@@ -4413,9 +5286,9 @@ function CollectibleSkeleton() {
4413
5286
  }
4414
5287
  }
4415
5288
  ) }),
4416
- /* @__PURE__ */ jsxs21("div", { className: "mt-2 flex flex-col gap-2 px-4 pb-4", children: [
4417
- /* @__PURE__ */ jsx34(Skeleton9, { size: "lg", className: "animate-shimmer" }),
4418
- /* @__PURE__ */ jsx34(Skeleton9, { size: "sm", className: "animate-shimmer" })
5289
+ /* @__PURE__ */ jsxs31("div", { className: "mt-2 flex flex-col gap-2 px-4 pb-4", children: [
5290
+ /* @__PURE__ */ jsx42(Skeleton11, { size: "lg", className: "animate-shimmer" }),
5291
+ /* @__PURE__ */ jsx42(Skeleton11, { size: "sm", className: "animate-shimmer" })
4419
5292
  ] })
4420
5293
  ] });
4421
5294
  }
@@ -4443,10 +5316,10 @@ function CollectibleCard({
4443
5316
  }
4444
5317
  });
4445
5318
  if (cardLoading) {
4446
- return /* @__PURE__ */ jsx34(CollectibleSkeleton, {});
5319
+ return /* @__PURE__ */ jsx42(CollectibleSkeleton, {});
4447
5320
  }
4448
5321
  const action = balance ? highestOffer && "Sell" /* SELL */ || !lowestListing?.order && "Create listing" /* LIST */ || "Transfer" /* TRANSFER */ : lowestListing?.order && "Buy" /* BUY */ || "Make an offer" /* OFFER */;
4449
- return /* @__PURE__ */ jsx34(
5322
+ return /* @__PURE__ */ jsx42(
4450
5323
  "div",
4451
5324
  {
4452
5325
  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",
@@ -4456,8 +5329,8 @@ function CollectibleCard({
4456
5329
  onCollectibleClick?.(collectibleId);
4457
5330
  }
4458
5331
  },
4459
- children: /* @__PURE__ */ jsx34("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__ */ jsxs21("article", { className: "w-full rounded-xl", children: [
4460
- /* @__PURE__ */ jsx34(
5332
+ 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: [
5333
+ /* @__PURE__ */ jsx42(
4461
5334
  CollectibleAsset,
4462
5335
  {
4463
5336
  name: collectibleMetadata?.name || "",
@@ -4465,7 +5338,7 @@ function CollectibleCard({
4465
5338
  assetSrcPrefixUrl
4466
5339
  }
4467
5340
  ),
4468
- /* @__PURE__ */ jsx34(
5341
+ /* @__PURE__ */ jsx42(
4469
5342
  Footer,
4470
5343
  {
4471
5344
  name: collectibleMetadata?.name || "",
@@ -4478,10 +5351,10 @@ function CollectibleCard({
4478
5351
  decimals: collectibleMetadata?.decimals
4479
5352
  }
4480
5353
  ),
4481
- (highestOffer || lowestListing) && /* @__PURE__ */ jsx34("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__ */ jsx34(
5354
+ (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(
4482
5355
  ActionButton,
4483
5356
  {
4484
- chainId: String(chainId),
5357
+ chainId,
4485
5358
  collectionAddress,
4486
5359
  tokenId: collectibleId,
4487
5360
  orderbookKind,
@@ -4498,13 +5371,13 @@ function CollectibleCard({
4498
5371
  }
4499
5372
 
4500
5373
  export {
5374
+ useBuyModal,
4501
5375
  useSuccessfulPurchaseModal,
4502
5376
  useTransferModal,
4503
5377
  ModalProvider,
4504
5378
  useCreateListingModal,
4505
5379
  useMakeOfferModal,
4506
5380
  useSellModal,
4507
- useBuyModal,
4508
5381
  CollectibleCard
4509
5382
  };
4510
- //# sourceMappingURL=chunk-HTFORA4Q.js.map
5383
+ //# sourceMappingURL=chunk-BN36GABQ.js.map