@0xsequence/marketplace-sdk 0.7.0 → 0.8.0

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 (228) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.changeset/fuzzy-forks-smoke.md +5 -0
  4. package/CHANGELOG.md +7 -0
  5. package/dist/chunk-2MSBZYLW.js +128 -0
  6. package/dist/chunk-2MSBZYLW.js.map +1 -0
  7. package/dist/{chunk-MPBN3E54.js → chunk-2VHHJNXY.js} +3 -3
  8. package/dist/{chunk-FBUMNJQ4.js → chunk-3II5GLHE.js} +2 -2
  9. package/dist/chunk-3JU7SQVE.js +182 -0
  10. package/dist/chunk-3JU7SQVE.js.map +1 -0
  11. package/dist/{chunk-XNA64MZQ.js → chunk-BCO4CYE4.js} +2 -2
  12. package/dist/{chunk-4XK7XNJ7.js → chunk-BNAUZXPV.js} +73 -2
  13. package/dist/chunk-BNAUZXPV.js.map +1 -0
  14. package/dist/{chunk-Q5URKSC4.js → chunk-FMEEJFAF.js} +1 -1
  15. package/dist/{chunk-BBASZVT3.js → chunk-GBQVYNCD.js} +5 -6
  16. package/dist/chunk-GBQVYNCD.js.map +1 -0
  17. package/dist/{chunk-3AKOPSON.js → chunk-IZ44XPBH.js} +2 -9
  18. package/dist/chunk-IZ44XPBH.js.map +1 -0
  19. package/dist/{chunk-EAJ5K7QV.js → chunk-Q5RKAMYF.js} +3 -4
  20. package/dist/chunk-Q5RKAMYF.js.map +1 -0
  21. package/dist/{chunk-RBEPPVLT.js → chunk-QKGZXS4T.js} +147 -357
  22. package/dist/chunk-QKGZXS4T.js.map +1 -0
  23. package/dist/{chunk-HTFORA4Q.js → chunk-SBI52HTX.js} +1880 -1010
  24. package/dist/chunk-SBI52HTX.js.map +1 -0
  25. package/dist/{chunk-XTGMMNV5.js → chunk-WHFXVREI.js} +2 -2
  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 +9 -9
  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 +11 -10
  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 +10 -19
  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 +14 -23
  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 +14 -13
  50. package/dist/react/ui/components/marketplace-logos/index.js +1 -1
  51. package/dist/react/ui/icons/index.js +7 -7
  52. package/dist/react/ui/index.d.ts +18 -22
  53. package/dist/react/ui/index.js +14 -13
  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 +11 -10
  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/abi/index.js +5 -5
  59. package/dist/utils/index.d.ts +1 -5
  60. package/dist/utils/index.js +9 -9
  61. package/package.json +22 -16
  62. package/src/react/_internal/api/__mocks__/indexer.msw.ts +3 -1
  63. package/src/react/_internal/api/__mocks__/marketplace.msw.ts +1 -1
  64. package/src/react/_internal/api/__mocks__/metadata.msw.ts +14 -12
  65. package/src/react/_internal/api/index.ts +1 -0
  66. package/src/react/_internal/api/laos-api.ts +103 -0
  67. package/src/react/_internal/api/zod-schema.ts +3 -3
  68. package/src/react/_internal/types.ts +1 -10
  69. package/src/react/_internal/wallet/__tests__/wallet.test.ts +43 -0
  70. package/src/react/_internal/wallet/useWallet.ts +6 -3
  71. package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +1 -1
  72. package/src/react/hooks/__tests__/useCancelOrder.test.tsx +1 -1
  73. package/src/react/hooks/__tests__/useCancelTransactionSteps.test.tsx +1 -1
  74. package/src/react/hooks/__tests__/useCollectible.test.tsx +2 -2
  75. package/src/react/hooks/__tests__/useCollection.test.tsx +2 -2
  76. package/src/react/hooks/__tests__/useComparePrices.test.tsx +1 -1
  77. package/src/react/hooks/__tests__/useConvertPriceToUSD.test.tsx +1 -1
  78. package/src/react/hooks/__tests__/useCountListingsForCollectible.test.tsx +1 -1
  79. package/src/react/hooks/__tests__/useCountOfCollectables.test.tsx +2 -2
  80. package/src/react/hooks/__tests__/useCountOffersForCollectible.test.tsx +1 -1
  81. package/src/react/hooks/__tests__/useCurrencies.test.tsx +2 -2
  82. package/src/react/hooks/__tests__/useCurrency.test.tsx +2 -2
  83. package/src/react/hooks/__tests__/useFilters.test.tsx +2 -2
  84. package/src/react/hooks/__tests__/useFloorOrder.test.tsx +2 -2
  85. package/src/react/hooks/__tests__/useGenerateCancelTransaction.test.tsx +1 -1
  86. package/src/react/hooks/__tests__/useGenerateListingTransaction.test.tsx +1 -1
  87. package/src/react/hooks/__tests__/useGenerateOfferTransaction.test.tsx +1 -1
  88. package/src/react/hooks/__tests__/useGenerateSellTransaction.test.tsx +1 -1
  89. package/src/react/hooks/__tests__/useListCollectibleActivities.test.tsx +2 -2
  90. package/src/react/hooks/__tests__/useListCollectibles.test.tsx +3 -2
  91. package/src/react/hooks/__tests__/useListCollectiblesPaginated.test.tsx +1 -1
  92. package/src/react/hooks/__tests__/useListCollectionActivities.test.tsx +1 -1
  93. package/src/react/hooks/__tests__/useListListingsForCollectible.test.tsx +1 -1
  94. package/src/react/hooks/__tests__/useListOffersForCollectible.test.tsx +1 -1
  95. package/src/react/hooks/__tests__/useLowestListing.test.tsx +1 -1
  96. package/src/react/hooks/__tests__/useRoyalty.test.tsx +1 -2
  97. package/src/react/hooks/index.ts +0 -1
  98. package/src/react/hooks/options/collectionOptions.ts +2 -3
  99. package/src/react/hooks/useAutoSelectFeeOption.tsx +1 -1
  100. package/src/react/hooks/useCancelOrder.tsx +3 -3
  101. package/src/react/hooks/useCancelTransactionSteps.tsx +1 -1
  102. package/src/react/hooks/useCheckoutOptions.tsx +1 -2
  103. package/src/react/hooks/useCollectible.tsx +2 -3
  104. package/src/react/hooks/useCollectionBalanceDetails.tsx +1 -2
  105. package/src/react/hooks/useComparePrices.tsx +2 -9
  106. package/src/react/hooks/useConvertPriceToUSD.tsx +1 -4
  107. package/src/react/hooks/useCountListingsForCollectible.tsx +1 -2
  108. package/src/react/hooks/useCountOfCollectables.tsx +1 -2
  109. package/src/react/hooks/useCountOffersForCollectible.tsx +1 -2
  110. package/src/react/hooks/useCurrencies.tsx +1 -4
  111. package/src/react/hooks/useCurrency.tsx +3 -8
  112. package/src/react/hooks/useFilters.tsx +5 -4
  113. package/src/react/hooks/useFloorOrder.tsx +1 -2
  114. package/src/react/hooks/useGenerateCancelTransaction.tsx +3 -6
  115. package/src/react/hooks/useGenerateListingTransaction.tsx +2 -3
  116. package/src/react/hooks/useGenerateOfferTransaction.tsx +2 -3
  117. package/src/react/hooks/useGenerateSellTransaction.tsx +3 -6
  118. package/src/react/hooks/useHighestOffer.tsx +1 -1
  119. package/src/react/hooks/useListCollectibles.tsx +33 -61
  120. package/src/react/hooks/useListCollectiblesPaginated.tsx +2 -6
  121. package/src/react/hooks/useListListingsForCollectible.tsx +1 -2
  122. package/src/react/hooks/useListOffersForCollectible.tsx +1 -2
  123. package/src/react/hooks/useLowestListing.tsx +1 -2
  124. package/src/react/hooks/useRoyalty.tsx +3 -8
  125. package/src/react/hooks/useTransferTokens.tsx +2 -2
  126. package/src/react/queries/balanceOfCollectible.ts +9 -32
  127. package/src/react/queries/getTokenSupplies.ts +38 -0
  128. package/src/react/queries/index.ts +5 -0
  129. package/src/react/queries/listCollectibles.ts +96 -0
  130. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +1 -1
  131. package/src/react/ui/components/_internals/action-button/__tests__/ActionButton.test.tsx +1 -1
  132. package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +4 -3
  133. package/src/react/ui/components/_internals/action-button/components/OwnerActions.tsx +1 -1
  134. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +2 -3
  135. package/src/react/ui/components/collectible-card/__tests__/CollectibleCard.test.tsx +1 -1
  136. package/src/react/ui/modals/BuyModal/ERC1155QuantityModal.tsx +127 -0
  137. package/src/react/ui/modals/BuyModal/Modal.tsx +67 -85
  138. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +85 -226
  139. package/src/react/ui/modals/BuyModal/__tests__/Modal1155.test.tsx +140 -0
  140. package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +67 -76
  141. package/src/react/ui/modals/BuyModal/hooks/__tests__/useCheckoutOptions.test.tsx +1 -60
  142. package/src/react/ui/modals/BuyModal/hooks/__tests__/useFees.test.tsx +1 -1
  143. package/src/react/ui/modals/BuyModal/hooks/useCheckoutOptions.ts +29 -13
  144. package/src/react/ui/modals/BuyModal/hooks/useLoadData.ts +26 -21
  145. package/src/react/ui/modals/BuyModal/hooks/usePaymentModalParams.ts +200 -0
  146. package/src/react/ui/modals/BuyModal/index.tsx +4 -14
  147. package/src/react/ui/modals/BuyModal/store.ts +71 -76
  148. package/src/react/ui/modals/CreateListingModal/Modal.tsx +71 -7
  149. package/src/react/ui/modals/CreateListingModal/__tests__/Modal.test.tsx +2 -2
  150. package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +1 -1
  151. package/src/react/ui/modals/CreateListingModal/hooks/useGetTokenApproval.ts +1 -1
  152. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +9 -5
  153. package/src/react/ui/modals/CreateListingModal/store.ts +7 -2
  154. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +103 -6
  155. package/src/react/ui/modals/MakeOfferModal/__tests__/Modal.test.tsx +1 -1
  156. package/src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx +1 -1
  157. package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +1 -1
  158. package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +8 -4
  159. package/src/react/ui/modals/MakeOfferModal/store.ts +5 -3
  160. package/src/react/ui/modals/SellModal/Modal.tsx +76 -4
  161. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +1 -1
  162. package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +1 -1
  163. package/src/react/ui/modals/SellModal/hooks/useSell.tsx +1 -1
  164. package/src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx +16 -8
  165. package/src/react/ui/modals/SellModal/store.ts +5 -3
  166. package/src/react/ui/modals/TransferModal/_store.ts +15 -3
  167. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TokenQuantityInput.tsx +58 -0
  168. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TransferButton.tsx +56 -0
  169. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx +50 -0
  170. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/index.tsx +94 -66
  171. package/src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx +22 -14
  172. package/src/react/ui/modals/TransferModal/index.tsx +72 -38
  173. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.tsx +43 -42
  174. package/src/react/ui/modals/_internal/components/actionModal/store.ts +1 -2
  175. package/src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx +2 -2
  176. package/src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx +9 -1
  177. package/src/react/ui/modals/_internal/components/floorPriceText/index.tsx +27 -12
  178. package/src/react/ui/modals/_internal/components/priceInput/__tests__/index.test.tsx +1 -1
  179. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +19 -3
  180. package/src/react/ui/modals/_internal/components/quantityInput/index.tsx +3 -0
  181. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/ActionButtons.tsx +60 -0
  182. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/BalanceIndicator.tsx +30 -0
  183. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx +126 -0
  184. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/store.ts +25 -0
  185. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx +74 -0
  186. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +1 -2
  187. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +1 -2
  188. package/src/react/ui/modals/_internal/components/tokenPreview/index.tsx +1 -1
  189. package/src/react/ui/modals/_internal/components/transaction-footer/index.tsx +4 -7
  190. package/src/react/ui/modals/_internal/components/transactionDetails/index.tsx +1 -1
  191. package/src/react/ui/modals/_internal/components/transactionPreview/index.tsx +1 -1
  192. package/src/react/ui/modals/_internal/components/transactionStatusModal/__tests__/TransactionStatusModal.test.tsx +1 -1
  193. package/src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts +1 -1
  194. package/src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx +6 -1
  195. package/src/react/ui/modals/_internal/components/transactionStatusModal/store.ts +2 -2
  196. package/src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx +10 -31
  197. package/src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts +53 -0
  198. package/src/react/ui/modals/_internal/types.ts +2 -1
  199. package/src/types/waas-types.ts +38 -0
  200. package/src/utils/network.ts +2 -4
  201. package/test/const.ts +1 -1
  202. package/test/setup.ts +10 -0
  203. package/test/test-utils.tsx +31 -5
  204. package/tsconfig.tsbuildinfo +1 -1
  205. package/dist/chunk-3AKOPSON.js.map +0 -1
  206. package/dist/chunk-4XK7XNJ7.js.map +0 -1
  207. package/dist/chunk-BBASZVT3.js.map +0 -1
  208. package/dist/chunk-EAJ5K7QV.js.map +0 -1
  209. package/dist/chunk-HTFORA4Q.js.map +0 -1
  210. package/dist/chunk-OFY7OFTL.js +0 -458
  211. package/dist/chunk-OFY7OFTL.js.map +0 -1
  212. package/dist/chunk-RBEPPVLT.js.map +0 -1
  213. package/src/react/hooks/__tests__/useGenerateBuyTransaction.test.tsx +0 -172
  214. package/src/react/hooks/useGenerateBuyTransaction.tsx +0 -80
  215. package/src/react/ui/modals/BuyModal/hooks/__tests__/useBuyCollectable.test.tsx +0 -349
  216. package/src/react/ui/modals/BuyModal/hooks/__tests__/useLoadData.test.tsx +0 -185
  217. package/src/react/ui/modals/BuyModal/hooks/useBuyCollectable.ts +0 -170
  218. package/src/react/ui/modals/BuyModal/modals/CheckoutModal.tsx +0 -47
  219. package/src/react/ui/modals/BuyModal/modals/Modal1155.tsx +0 -140
  220. package/src/react/ui/modals/BuyModal/modals/__tests__/CheckoutModal.test.tsx +0 -162
  221. package/src/react/ui/modals/BuyModal/modals/__tests__/Modal1155.test.tsx +0 -327
  222. package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/index.tsx +0 -124
  223. package/src/react/ui/modals/_internal/components/waasFeeOptionsBox/store.ts +0 -12
  224. /package/dist/{chunk-MPBN3E54.js.map → chunk-2VHHJNXY.js.map} +0 -0
  225. /package/dist/{chunk-FBUMNJQ4.js.map → chunk-3II5GLHE.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
  228. /package/dist/{chunk-XTGMMNV5.js.map → chunk-WHFXVREI.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-2MSBZYLW.js";
8
6
  import {
9
7
  useAnalytics
10
- } from "./chunk-XTGMMNV5.js";
8
+ } from "./chunk-WHFXVREI.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-QKGZXS4T.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,359 @@ 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 } = 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(paymentModalParams);
735
733
  }
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
734
  };
755
735
 
756
736
  // 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";
737
+ import { Show, observer as observer7 } from "@legendapp/state/react";
738
+ import { parseUnits as parseUnits2 } from "viem";
739
+ import { useAccount as useAccount4 } from "wagmi";
760
740
 
761
741
  // src/react/ui/modals/_internal/components/expirationDateSelect/index.tsx
762
742
  import { Skeleton, Text as Text3 } from "@0xsequence/design-system";
763
- import { observer as observer3 } from "@legendapp/state/react";
743
+ import { observer as observer2 } from "@legendapp/state/react";
764
744
  import { addDays } from "date-fns";
765
745
  import { useState as useState2 } from "react";
766
746
 
@@ -943,9 +923,10 @@ var PRESET_RANGES = {
943
923
  offset: 30
944
924
  }
945
925
  };
946
- var ExpirationDateSelect = observer3(function ExpirationDateSelect2({
926
+ var ExpirationDateSelect = observer2(function ExpirationDateSelect2({
947
927
  className,
948
- $date
928
+ $date,
929
+ disabled
949
930
  }) {
950
931
  const [calendarDropdownOpen, setCalendarDropdownOpen] = useState2(false);
951
932
  function handleSelectPresetRange(range) {
@@ -965,44 +946,54 @@ var ExpirationDateSelect = observer3(function ExpirationDateSelect2({
965
946
  if (!$date.get()) {
966
947
  return /* @__PURE__ */ jsx8(Skeleton, { className: "mr-3 h-7 w-20 rounded-2xl" });
967
948
  }
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,
949
+ return /* @__PURE__ */ jsxs4(
950
+ "div",
951
+ {
952
+ className: cn(
953
+ "relative w-full",
954
+ disabled && "pointer-events-none opacity-50"
955
+ ),
956
+ children: [
957
+ /* @__PURE__ */ jsx8(
958
+ Text3,
984
959
  {
985
- selectedDate: $date.get(),
986
- setSelectedDate: handleDateValueChange,
987
- onSelectPreset: handleSelectPresetRange,
988
- isOpen: calendarDropdownOpen,
989
- setIsOpen: setCalendarDropdownOpen
960
+ className: "w-full text-left font-body font-medium text-xs",
961
+ fontWeight: "medium",
962
+ color: "text100",
963
+ children: "Set expiry"
964
+ }
965
+ ),
966
+ /* @__PURE__ */ jsx8(
967
+ "div",
968
+ {
969
+ className: `${className} mt-0.5 flex w-full items-center gap-2 rounded-sm border border-border-base`,
970
+ children: /* @__PURE__ */ jsx8(
971
+ CalendarDropdown,
972
+ {
973
+ selectedDate: $date.get(),
974
+ setSelectedDate: handleDateValueChange,
975
+ onSelectPreset: handleSelectPresetRange,
976
+ isOpen: calendarDropdownOpen,
977
+ setIsOpen: setCalendarDropdownOpen
978
+ }
979
+ )
990
980
  }
991
981
  )
992
- }
993
- )
994
- ] });
982
+ ]
983
+ }
984
+ );
995
985
  });
996
986
  var expirationDateSelect_default = ExpirationDateSelect;
997
987
 
998
988
  // 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";
989
+ import { Button as Button2, Text as Text4 } from "@0xsequence/design-system";
990
+ import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
1001
991
  function FloorPriceText({
1002
992
  chainId,
1003
993
  collectionAddress,
1004
994
  tokenId,
1005
- price
995
+ price,
996
+ onBuyNow
1006
997
  }) {
1007
998
  const { data: listing, isLoading: listingLoading } = useLowestListing({
1008
999
  tokenId,
@@ -1013,6 +1004,7 @@ function FloorPriceText({
1013
1004
  }
1014
1005
  });
1015
1006
  const floorPriceRaw = listing?.order?.priceAmount;
1007
+ const floorPriceFormatted = listing?.order?.priceAmountFormatted;
1016
1008
  const { data: priceComparison, isLoading: comparisonLoading } = useComparePrices({
1017
1009
  chainId,
1018
1010
  priceAmountRaw: price.amountRaw || "0",
@@ -1027,31 +1019,88 @@ function FloorPriceText({
1027
1019
  return null;
1028
1020
  }
1029
1021
  let floorPriceDifferenceText = "Same as floor price";
1022
+ let showBuyNowButton = false;
1030
1023
  if (priceComparison) {
1031
1024
  if (priceComparison.status === "same") {
1032
1025
  floorPriceDifferenceText = "Same as floor price";
1026
+ showBuyNowButton = true;
1027
+ } else if (priceComparison.status === "below") {
1028
+ floorPriceDifferenceText = `${priceComparison.percentageDifferenceFormatted}% below floor price`;
1033
1029
  } else {
1034
- floorPriceDifferenceText = `${priceComparison.percentageDifferenceFormatted}% ${priceComparison.status === "below" ? "below" : "above"} floor price`;
1030
+ floorPriceDifferenceText = `${priceComparison.percentageDifferenceFormatted}% above floor price`;
1031
+ showBuyNowButton = true;
1035
1032
  }
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
- );
1033
+ }
1034
+ return /* @__PURE__ */ jsxs5("div", { className: "flex w-full items-center justify-between gap-2", children: [
1035
+ /* @__PURE__ */ jsx9(Text4, { className: "text-left font-body font-medium text-muted text-xs", children: floorPriceDifferenceText }),
1036
+ showBuyNowButton && onBuyNow && /* @__PURE__ */ jsxs5(
1037
+ Button2,
1038
+ {
1039
+ size: "xs",
1040
+ variant: "text",
1041
+ className: "text-indigo-400 text-xs",
1042
+ onClick: onBuyNow,
1043
+ children: [
1044
+ "Buy for ",
1045
+ floorPriceFormatted,
1046
+ " ",
1047
+ price.currency.symbol
1048
+ ]
1049
+ }
1050
+ )
1051
+ ] });
1046
1052
  }
1047
1053
 
1048
1054
  // src/react/ui/modals/_internal/components/priceInput/index.tsx
1049
- import { NumericInput as NumericInput2, Text as Text5 } from "@0xsequence/design-system";
1055
+ import { NumericInput as NumericInput2, Text as Text6 } from "@0xsequence/design-system";
1050
1056
  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";
1057
+ import { useEffect as useEffect3, useRef, useState as useState5 } from "react";
1058
+ import { parseUnits } from "viem";
1053
1059
  import { useAccount } from "wagmi";
1054
1060
 
1061
+ // src/react/hooks/useCurrencyBalance.tsx
1062
+ import { skipToken as skipToken3, useQuery as useQuery3 } from "@tanstack/react-query";
1063
+ import { erc20Abi as erc20Abi2, formatUnits, zeroAddress } from "viem";
1064
+ import { usePublicClient } from "wagmi";
1065
+ function useCurrencyBalance({
1066
+ currencyAddress,
1067
+ chainId,
1068
+ userAddress
1069
+ }) {
1070
+ const publicClient = usePublicClient({ chainId });
1071
+ return useQuery3({
1072
+ queryKey: ["balance", currencyAddress, chainId, userAddress],
1073
+ queryFn: !!userAddress && !!chainId && !!currencyAddress && !!publicClient ? async () => {
1074
+ if (currencyAddress === zeroAddress) {
1075
+ const balance2 = await publicClient.getBalance({
1076
+ address: userAddress
1077
+ });
1078
+ return {
1079
+ value: balance2,
1080
+ formatted: formatUnits(balance2, 18)
1081
+ };
1082
+ }
1083
+ const [balance, decimals] = await Promise.all([
1084
+ publicClient.readContract({
1085
+ address: currencyAddress,
1086
+ abi: erc20Abi2,
1087
+ functionName: "balanceOf",
1088
+ args: [userAddress]
1089
+ }),
1090
+ publicClient.readContract({
1091
+ address: currencyAddress,
1092
+ abi: erc20Abi2,
1093
+ functionName: "decimals"
1094
+ })
1095
+ ]);
1096
+ return {
1097
+ value: balance,
1098
+ formatted: formatUnits(balance, decimals)
1099
+ };
1100
+ } : skipToken3
1101
+ });
1102
+ }
1103
+
1055
1104
  // src/react/ui/modals/_internal/components/currencyImage/index.tsx
1056
1105
  import { TokenImage as TokenImage2 } from "@0xsequence/design-system";
1057
1106
  import { useState as useState3 } from "react";
@@ -1091,10 +1140,97 @@ var currencyImage_default = CurrencyImage;
1091
1140
 
1092
1141
  // src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx
1093
1142
  import { Skeleton as Skeleton2 } from "@0xsequence/design-system";
1094
- import { observer as observer4 } from "@legendapp/state/react";
1143
+ import { observer as observer3 } from "@legendapp/state/react";
1095
1144
  import { useEffect as useEffect2 } from "react";
1096
- import { jsx as jsx11 } from "react/jsx-runtime";
1097
- var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
1145
+
1146
+ // src/react/ui/components/_internals/custom-select/CustomSelect.tsx
1147
+ import {
1148
+ Button as Button3,
1149
+ ChevronDownIcon,
1150
+ DropdownMenuCheckboxItem,
1151
+ DropdownMenuContent as DropdownMenuContent2,
1152
+ DropdownMenuPortal as DropdownMenuPortal2,
1153
+ DropdownMenuRoot as DropdownMenuRoot2,
1154
+ DropdownMenuTrigger as DropdownMenuTrigger2,
1155
+ Text as Text5
1156
+ } from "@0xsequence/design-system";
1157
+ import { useState as useState4 } from "react";
1158
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1159
+ var CustomSelect = ({
1160
+ items,
1161
+ onValueChange,
1162
+ defaultValue,
1163
+ placeholder = "Select an option",
1164
+ disabled = false,
1165
+ className,
1166
+ testId = "custom-select"
1167
+ }) => {
1168
+ const [selectedItem, setSelectedItem] = useState4(
1169
+ defaultValue
1170
+ );
1171
+ const handleValueChange = (item) => {
1172
+ setSelectedItem(item);
1173
+ onValueChange?.(item.value);
1174
+ };
1175
+ return /* @__PURE__ */ jsxs6(DropdownMenuRoot2, { children: [
1176
+ /* @__PURE__ */ jsx11(DropdownMenuTrigger2, { asChild: true, disabled, children: /* @__PURE__ */ jsx11(
1177
+ Button3,
1178
+ {
1179
+ size: "xs",
1180
+ label: /* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-center gap-1 truncate pr-3", children: [
1181
+ /* @__PURE__ */ jsx11(Text5, { variant: "xsmall", color: "text100", fontWeight: "bold", children: selectedItem ? selectedItem.content : placeholder }),
1182
+ /* @__PURE__ */ jsx11(ChevronDownIcon, { size: "xs" })
1183
+ ] }),
1184
+ shape: "circle",
1185
+ opacity: "100",
1186
+ className: `bg-overlay-light py-1.5 pl-3 ${className || ""}`,
1187
+ "data-testid": `${testId}-trigger`
1188
+ }
1189
+ ) }),
1190
+ /* @__PURE__ */ jsx11(DropdownMenuPortal2, { children: /* @__PURE__ */ jsx11(
1191
+ DropdownMenuContent2,
1192
+ {
1193
+ align: "end",
1194
+ side: "bottom",
1195
+ sideOffset: 8,
1196
+ className: "z-[1000] overflow-hidden rounded-xl border border-border-base bg-color-overlay-glass shadow-lg backdrop-blur-md",
1197
+ "data-testid": `${testId}-content`,
1198
+ children: /* @__PURE__ */ jsx11("div", { className: "max-h-[240px] overflow-auto", children: items.map((item) => /* @__PURE__ */ jsx11(
1199
+ DropdownMenuCheckboxItem,
1200
+ {
1201
+ checked: selectedItem?.value === item.value,
1202
+ onCheckedChange: () => handleValueChange(item),
1203
+ disabled: item.disabled,
1204
+ 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",
1205
+ "data-testid": `${testId}-option-${item.value}`,
1206
+ 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(
1207
+ Text5,
1208
+ {
1209
+ variant: "small",
1210
+ color: selectedItem?.value === item.value ? "text100" : "text80",
1211
+ className: `truncate ${selectedItem?.value === item.value ? "font-bold" : ""}`,
1212
+ "data-testid": `${testId}-option-text-${item.value}`,
1213
+ children: item.content
1214
+ }
1215
+ ) : /* @__PURE__ */ jsx11(
1216
+ "div",
1217
+ {
1218
+ className: "truncate",
1219
+ "data-testid": `${testId}-option-content-${item.value}`,
1220
+ children: item.content
1221
+ }
1222
+ ) }) })
1223
+ },
1224
+ item.value
1225
+ )) })
1226
+ }
1227
+ ) })
1228
+ ] });
1229
+ };
1230
+
1231
+ // src/react/ui/modals/_internal/components/currencyOptionsSelect/index.tsx
1232
+ import { jsx as jsx12 } from "react/jsx-runtime";
1233
+ var CurrencyOptionsSelect = observer3(function CurrencyOptionsSelect2({
1098
1234
  chainId,
1099
1235
  collectionAddress,
1100
1236
  secondCurrencyAsDefault,
@@ -1117,7 +1253,7 @@ var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
1117
1253
  }
1118
1254
  }, [currencies]);
1119
1255
  if (!currencies || currenciesLoading || !currency?.symbol) {
1120
- return /* @__PURE__ */ jsx11(Skeleton2, { className: "mr-3 h-7 w-20 rounded-2xl" });
1256
+ return /* @__PURE__ */ jsx12(Skeleton2, { className: "mr-3 h-7 w-20 rounded-2xl" });
1121
1257
  }
1122
1258
  const options = currencies.map(
1123
1259
  (currency2) => ({
@@ -1132,7 +1268,7 @@ var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
1132
1268
  );
1133
1269
  selectedCurrency$.set(selectedCurrency);
1134
1270
  };
1135
- return /* @__PURE__ */ jsx11(
1271
+ return /* @__PURE__ */ jsx12(
1136
1272
  CustomSelect,
1137
1273
  {
1138
1274
  items: options,
@@ -1148,7 +1284,7 @@ var CurrencyOptionsSelect = observer4(function CurrencyOptionsSelect2({
1148
1284
  var currencyOptionsSelect_default = CurrencyOptionsSelect;
1149
1285
 
1150
1286
  // src/react/ui/modals/_internal/components/priceInput/index.tsx
1151
- import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
1287
+ import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
1152
1288
  function PriceInput({
1153
1289
  chainId,
1154
1290
  collectionAddress,
@@ -1156,27 +1292,34 @@ function PriceInput({
1156
1292
  onPriceChange,
1157
1293
  checkBalance,
1158
1294
  secondCurrencyAsDefault,
1159
- includeNativeCurrency
1295
+ includeNativeCurrency,
1296
+ disabled
1160
1297
  }) {
1161
1298
  const { address: accountAddress } = useAccount();
1299
+ const inputRef = useRef(null);
1162
1300
  const currencyDecimals = use$2($price.currency.decimals);
1163
1301
  const currencyAddress = use$2($price.currency.contractAddress);
1164
1302
  const priceAmountRaw = use$2($price.amountRaw);
1303
+ useEffect3(() => {
1304
+ if (inputRef.current) {
1305
+ inputRef.current.focus();
1306
+ }
1307
+ }, []);
1165
1308
  const { data: balance, isSuccess: isBalanceSuccess } = useCurrencyBalance({
1166
1309
  currencyAddress,
1167
- chainId: Number(chainId),
1310
+ chainId,
1168
1311
  userAddress: accountAddress
1169
1312
  });
1170
1313
  const balanceError = !!checkBalance?.enabled && !!isBalanceSuccess && !!priceAmountRaw && !!currencyDecimals && BigInt(priceAmountRaw) > BigInt(balance?.value || 0n);
1171
1314
  if (checkBalance?.enabled) {
1172
1315
  checkBalance.callback(balanceError);
1173
1316
  }
1174
- const [value, setValue] = useState4("0");
1317
+ const [value, setValue] = useState5("0");
1175
1318
  const prevCurrencyDecimals = useRef(currencyDecimals);
1176
1319
  useEffect3(() => {
1177
1320
  if (prevCurrencyDecimals.current !== currencyDecimals && value !== "0") {
1178
1321
  try {
1179
- const parsedAmount = parseUnits2(value, Number(currencyDecimals));
1322
+ const parsedAmount = parseUnits(value, Number(currencyDecimals));
1180
1323
  $price.amountRaw.set(parsedAmount.toString());
1181
1324
  if (onPriceChange && parsedAmount !== 0n) {
1182
1325
  onPriceChange();
@@ -1191,7 +1334,7 @@ function PriceInput({
1191
1334
  const newValue = event.target.value;
1192
1335
  setValue(newValue);
1193
1336
  try {
1194
- const parsedAmount = parseUnits2(newValue, Number(currencyDecimals));
1337
+ const parsedAmount = parseUnits(newValue, Number(currencyDecimals));
1195
1338
  $price.amountRaw.set(parsedAmount.toString());
1196
1339
  if (onPriceChange && parsedAmount !== 0n) {
1197
1340
  onPriceChange();
@@ -1200,49 +1343,378 @@ function PriceInput({
1200
1343
  $price.amountRaw.set("0");
1201
1344
  }
1202
1345
  };
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,
1346
+ return /* @__PURE__ */ jsxs7(
1347
+ "div",
1348
+ {
1349
+ className: cn(
1350
+ "relative flex w-full flex-col",
1351
+ disabled && "pointer-events-none opacity-50"
1352
+ ),
1353
+ children: [
1354
+ /* @__PURE__ */ jsx13("div", { className: "absolute top-8 left-2 flex items-center", children: /* @__PURE__ */ jsx13(currencyImage_default, { price$: $price }) }),
1355
+ /* @__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(
1356
+ NumericInput2,
1215
1357
  {
1216
- selectedCurrency$: $price.currency,
1217
- collectionAddress,
1218
- chainId,
1219
- secondCurrencyAsDefault,
1220
- includeNativeCurrency
1358
+ ref: inputRef,
1359
+ className: "ml-5 w-full text-xs",
1360
+ name: "price-input",
1361
+ decimals: currencyDecimals,
1362
+ label: "Enter price",
1363
+ labelLocation: "top",
1364
+ controls: /* @__PURE__ */ jsx13(
1365
+ currencyOptionsSelect_default,
1366
+ {
1367
+ selectedCurrency$: $price.currency,
1368
+ collectionAddress,
1369
+ chainId,
1370
+ secondCurrencyAsDefault,
1371
+ includeNativeCurrency
1372
+ }
1373
+ ),
1374
+ value,
1375
+ onChange: handleChange
1221
1376
  }
1222
- ),
1223
- value,
1224
- onChange: handleChange
1377
+ ) }),
1378
+ balanceError && /* @__PURE__ */ jsx13(
1379
+ Text6,
1380
+ {
1381
+ className: "-bottom-5 absolute font-body font-medium text-xs",
1382
+ color: "negative",
1383
+ children: "Insufficient balance"
1384
+ }
1385
+ )
1386
+ ]
1387
+ }
1388
+ );
1389
+ }
1390
+
1391
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx
1392
+ import { getNetwork } from "@0xsequence/connect";
1393
+ import { Divider, Skeleton as Skeleton4, Text as Text9 } from "@0xsequence/design-system";
1394
+ import { NetworkType } from "@0xsequence/network";
1395
+ import { observer as observer5 } from "@legendapp/state/react";
1396
+
1397
+ // src/react/ui/modals/_internal/components/waasFeeOptionsSelect/WaasFeeOptionsSelect.tsx
1398
+ import { Image, Select, Text as Text7 } from "@0xsequence/design-system";
1399
+ import { observer as observer4 } from "@legendapp/state/react";
1400
+ import { useEffect as useEffect4 } from "react";
1401
+ import { formatUnits as formatUnits2, zeroAddress as zeroAddress2 } from "viem";
1402
+ import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
1403
+ var WaasFeeOptionsSelect = observer4(
1404
+ ({
1405
+ options,
1406
+ selectedFeeOption$
1407
+ }) => {
1408
+ options = options.map((option) => ({
1409
+ ...option,
1410
+ token: {
1411
+ ...option.token,
1412
+ contractAddress: option.token.contractAddress || zeroAddress2
1225
1413
  }
1226
- ) }),
1227
- balanceError && /* @__PURE__ */ jsx12(
1228
- Text5,
1414
+ }));
1415
+ const feeOptions = options.map((option) => {
1416
+ const value = option.token.contractAddress ?? "";
1417
+ return FeeOptionSelectItem({ value, option });
1418
+ });
1419
+ useEffect4(() => {
1420
+ if (options.length > 0 && !selectedFeeOption$.get())
1421
+ selectedFeeOption$.set(options[0]);
1422
+ }, [options]);
1423
+ if (options.length === 0 || !selectedFeeOption$.get()?.token) return null;
1424
+ return /* @__PURE__ */ jsx14(
1425
+ Select,
1229
1426
  {
1230
- className: "-bottom-5 absolute font-body font-medium text-xs",
1231
- color: "negative",
1232
- children: "Insufficient balance"
1427
+ items: feeOptions,
1428
+ name: "fee-option",
1429
+ options: feeOptions.map((option) => ({
1430
+ label: option.content,
1431
+ value: option.value
1432
+ })),
1433
+ onValueChange: (value) => {
1434
+ const selectedOption = options.find(
1435
+ (option) => option.token.contractAddress === value
1436
+ );
1437
+ selectedFeeOption$.set(selectedOption);
1438
+ },
1439
+ defaultValue: options[0].token.contractAddress ?? void 0
1233
1440
  }
1234
- )
1235
- ] });
1441
+ );
1442
+ }
1443
+ );
1444
+ function FeeOptionSelectItem({
1445
+ value,
1446
+ option
1447
+ }) {
1448
+ return {
1449
+ value,
1450
+ content: /* @__PURE__ */ jsxs8("div", { className: "flex items-center gap-2", children: [
1451
+ /* @__PURE__ */ jsx14(
1452
+ Image,
1453
+ {
1454
+ className: "h-3 w-3",
1455
+ src: option.token.logoURL,
1456
+ alt: option.token.symbol
1457
+ }
1458
+ ),
1459
+ /* @__PURE__ */ jsxs8("div", { className: "flex gap-1", children: [
1460
+ /* @__PURE__ */ jsx14(Text7, { className: "font-body text-sm", color: "text100", children: "Fee" }),
1461
+ /* @__PURE__ */ jsxs8(
1462
+ Text7,
1463
+ {
1464
+ className: "font-body text-sm",
1465
+ color: "text50",
1466
+ fontWeight: "semibold",
1467
+ children: [
1468
+ "(in ",
1469
+ option.token.symbol,
1470
+ ")"
1471
+ ]
1472
+ }
1473
+ ),
1474
+ /* @__PURE__ */ jsx14(Text7, { className: "font-body text-sm", color: "text100", children: ":" })
1475
+ ] }),
1476
+ /* @__PURE__ */ jsx14(Text7, { className: "font-body text-sm", children: formatUnits2(BigInt(option.value), option.token.decimals || 0) })
1477
+ ] })
1478
+ };
1236
1479
  }
1480
+ var WaasFeeOptionsSelect_default = WaasFeeOptionsSelect;
1481
+
1482
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/ActionButtons.tsx
1483
+ import { Button as Button4, Skeleton as Skeleton3, Spinner as Spinner2 } from "@0xsequence/design-system";
1484
+ import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
1485
+ var ActionButtons = ({
1486
+ onCancel,
1487
+ onConfirm,
1488
+ disabled,
1489
+ loading,
1490
+ confirmed,
1491
+ tokenSymbol
1492
+ }) => /* @__PURE__ */ jsxs9("div", { className: "mt-4 flex w-full items-center justify-end gap-2", children: [
1493
+ /* @__PURE__ */ jsx15(
1494
+ Button4,
1495
+ {
1496
+ pending: loading,
1497
+ onClick: onCancel,
1498
+ label: /* @__PURE__ */ jsx15("div", { className: "flex items-center gap-2", children: "Cancel" }),
1499
+ variant: "ghost",
1500
+ shape: "square",
1501
+ size: "md"
1502
+ }
1503
+ ),
1504
+ /* @__PURE__ */ jsx15(
1505
+ Button4,
1506
+ {
1507
+ disabled,
1508
+ pending: loading || confirmed,
1509
+ onClick: onConfirm,
1510
+ 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: [
1511
+ "Continue with",
1512
+ /* @__PURE__ */ jsx15(Skeleton3, { className: "h-[20px] w-6 animate-shimmer" })
1513
+ ] }) : /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2", children: [
1514
+ /* @__PURE__ */ jsx15(Spinner2, { size: "sm" }),
1515
+ "Confirming"
1516
+ ] }) }),
1517
+ variant: "primary",
1518
+ shape: "square",
1519
+ size: "md"
1520
+ }
1521
+ )
1522
+ ] });
1523
+ var ActionButtons_default = ActionButtons;
1524
+
1525
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/_components/BalanceIndicator.tsx
1526
+ import { Text as Text8, WarningIcon } from "@0xsequence/design-system";
1527
+ import { CheckmarkIcon } from "@0xsequence/design-system";
1528
+ import { jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
1529
+ var BalanceIndicator = ({
1530
+ insufficientBalance,
1531
+ currencyBalance,
1532
+ selectedFeeOption
1533
+ }) => /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
1534
+ insufficientBalance ? /* @__PURE__ */ jsx16(WarningIcon, { className: "text-negative", size: "xs" }) : /* @__PURE__ */ jsx16(CheckmarkIcon, { className: "text-positive", size: "xs" }),
1535
+ /* @__PURE__ */ jsxs10(
1536
+ Text8,
1537
+ {
1538
+ className: "font-body font-medium text-xs",
1539
+ color: insufficientBalance ? "negative" : "text100",
1540
+ children: [
1541
+ "You have ",
1542
+ currencyBalance?.formatted || "0",
1543
+ " ",
1544
+ selectedFeeOption?.token.symbol
1545
+ ]
1546
+ }
1547
+ )
1548
+ ] });
1549
+ var BalanceIndicator_default = BalanceIndicator;
1550
+
1551
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/store.ts
1552
+ import { observable } from "@legendapp/state";
1553
+ var initialState = {
1554
+ selectedFeeOption: void 0,
1555
+ pendingFeeOptionConfirmation: void 0,
1556
+ isVisible: false,
1557
+ hide: () => {
1558
+ selectWaasFeeOptions$.isVisible.set(false);
1559
+ selectWaasFeeOptions$.selectedFeeOption.set(void 0);
1560
+ selectWaasFeeOptions$.pendingFeeOptionConfirmation.set(void 0);
1561
+ }
1562
+ };
1563
+ var selectWaasFeeOptions$ = observable(initialState);
1564
+
1565
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/useWaasFeeOptionManager.tsx
1566
+ import { useWaasFeeOptions } from "@0xsequence/connect";
1567
+ import { useEffect as useEffect5, useState as useState6 } from "react";
1568
+ import { zeroAddress as zeroAddress3 } from "viem";
1569
+ import { useAccount as useAccount2 } from "wagmi";
1570
+ var useWaasFeeOptionManager = (chainId) => {
1571
+ const { address: userAddress } = useAccount2();
1572
+ const selectedFeeOption$ = selectWaasFeeOptions$.selectedFeeOption;
1573
+ const [pendingFeeOptionConfirmation, confirmPendingFeeOption] = useWaasFeeOptions();
1574
+ const [feeOptionsConfirmed, setFeeOptionsConfirmed] = useState6(false);
1575
+ const selectedFeeOption = selectedFeeOption$.get();
1576
+ const { data: currencyBalance, isLoading: currencyBalanceLoading } = useCurrencyBalance({
1577
+ chainId,
1578
+ currencyAddress: selectedFeeOption?.token.contractAddress || zeroAddress3,
1579
+ userAddress
1580
+ });
1581
+ useEffect5(() => {
1582
+ if (!selectedFeeOption && pendingFeeOptionConfirmation) {
1583
+ selectedFeeOption$.set(
1584
+ pendingFeeOptionConfirmation.options[0]
1585
+ );
1586
+ }
1587
+ }, [pendingFeeOptionConfirmation]);
1588
+ const insufficientBalance = (() => {
1589
+ if (!selectedFeeOption?.value || !selectedFeeOption.token.decimals) {
1590
+ return false;
1591
+ }
1592
+ if (!currencyBalance?.value && currencyBalance?.value !== 0n) {
1593
+ return true;
1594
+ }
1595
+ try {
1596
+ const feeValue = BigInt(selectedFeeOption.value);
1597
+ return currencyBalance.value === 0n || currencyBalance.value < feeValue;
1598
+ } catch {
1599
+ return true;
1600
+ }
1601
+ })();
1602
+ const handleConfirmFeeOption = () => {
1603
+ if (!selectedFeeOption?.token || !pendingFeeOptionConfirmation?.id) return;
1604
+ confirmPendingFeeOption(
1605
+ pendingFeeOptionConfirmation?.id,
1606
+ selectedFeeOption.token.contractAddress || zeroAddress3
1607
+ );
1608
+ setFeeOptionsConfirmed(true);
1609
+ };
1610
+ return {
1611
+ selectedFeeOption$,
1612
+ selectedFeeOption,
1613
+ pendingFeeOptionConfirmation,
1614
+ currencyBalance,
1615
+ currencyBalanceLoading,
1616
+ insufficientBalance,
1617
+ feeOptionsConfirmed,
1618
+ handleConfirmFeeOption
1619
+ };
1620
+ };
1621
+ var useWaasFeeOptionManager_default = useWaasFeeOptionManager;
1622
+
1623
+ // src/react/ui/modals/_internal/components/selectWaasFeeOptions/index.tsx
1624
+ import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
1625
+ var SelectWaasFeeOptions = observer5(
1626
+ ({
1627
+ chainId,
1628
+ onCancel,
1629
+ titleOnConfirm,
1630
+ className
1631
+ }) => {
1632
+ const network = getNetwork(chainId);
1633
+ const isTestnet = network.type === NetworkType.TESTNET;
1634
+ const {
1635
+ selectedFeeOption$,
1636
+ selectedFeeOption,
1637
+ pendingFeeOptionConfirmation,
1638
+ currencyBalance,
1639
+ currencyBalanceLoading,
1640
+ insufficientBalance,
1641
+ feeOptionsConfirmed,
1642
+ handleConfirmFeeOption
1643
+ } = useWaasFeeOptionManager_default(chainId);
1644
+ console.log("pendingFeeOptionConfirmation", pendingFeeOptionConfirmation);
1645
+ const handleCancelFeeOption = () => {
1646
+ selectWaasFeeOptions$.hide();
1647
+ onCancel?.();
1648
+ };
1649
+ if (!selectWaasFeeOptions$.isVisible.get() || isTestnet || !selectedFeeOption) {
1650
+ return null;
1651
+ }
1652
+ return /* @__PURE__ */ jsxs11(
1653
+ "div",
1654
+ {
1655
+ className: cn(
1656
+ "flex w-full flex-col gap-2 rounded-2xl bg-button-emphasis p-0 backdrop-blur-md",
1657
+ className
1658
+ ),
1659
+ children: [
1660
+ /* @__PURE__ */ jsx17(Divider, { className: "mt-0 mb-4" }),
1661
+ /* @__PURE__ */ jsx17(Text9, { className: "mb-2 font-body text-large", fontWeight: "bold", children: feeOptionsConfirmed ? titleOnConfirm : "Select a fee option" }),
1662
+ !feeOptionsConfirmed && !pendingFeeOptionConfirmation && /* @__PURE__ */ jsx17(Skeleton4, { className: "h-[52px] w-full animate-shimmer rounded-xl" }),
1663
+ (feeOptionsConfirmed || pendingFeeOptionConfirmation) && /* @__PURE__ */ jsx17(
1664
+ "div",
1665
+ {
1666
+ className: cn(
1667
+ "[&>label>button>span]:overflow-hidden [&>label>button]:w-full [&>label>button]:text-xs [&>label]:flex [&>label]:w-full",
1668
+ feeOptionsConfirmed && "pointer-events-none opacity-70"
1669
+ ),
1670
+ children: /* @__PURE__ */ jsx17(
1671
+ WaasFeeOptionsSelect_default,
1672
+ {
1673
+ options: pendingFeeOptionConfirmation?.options || [
1674
+ selectedFeeOption
1675
+ ],
1676
+ selectedFeeOption$
1677
+ }
1678
+ )
1679
+ }
1680
+ ),
1681
+ /* @__PURE__ */ jsxs11("div", { className: "flex w-full items-start justify-between", children: [
1682
+ !feeOptionsConfirmed && (!pendingFeeOptionConfirmation || currencyBalanceLoading) && /* @__PURE__ */ jsx17(Skeleton4, { className: "h-[20px] w-2/3 animate-shimmer rounded-xl" }),
1683
+ (feeOptionsConfirmed || pendingFeeOptionConfirmation && !currencyBalanceLoading) && /* @__PURE__ */ jsx17(
1684
+ BalanceIndicator_default,
1685
+ {
1686
+ insufficientBalance,
1687
+ currencyBalance,
1688
+ selectedFeeOption
1689
+ }
1690
+ )
1691
+ ] }),
1692
+ /* @__PURE__ */ jsx17(
1693
+ ActionButtons_default,
1694
+ {
1695
+ onCancel: handleCancelFeeOption,
1696
+ onConfirm: handleConfirmFeeOption,
1697
+ disabled: !selectedFeeOption?.token || insufficientBalance || currencyBalanceLoading,
1698
+ loading: currencyBalanceLoading,
1699
+ confirmed: feeOptionsConfirmed,
1700
+ tokenSymbol: selectedFeeOption?.token.symbol
1701
+ }
1702
+ )
1703
+ ]
1704
+ }
1705
+ );
1706
+ }
1707
+ );
1708
+ var selectWaasFeeOptions_default = SelectWaasFeeOptions;
1237
1709
 
1238
1710
  // src/react/ui/modals/_internal/components/tokenPreview/index.tsx
1239
- import { Image, Skeleton as Skeleton3, Text as Text6 } from "@0xsequence/design-system";
1711
+ import { Image as Image2, Skeleton as Skeleton5, Text as Text10 } from "@0xsequence/design-system";
1240
1712
 
1241
1713
  // src/react/ui/images/chess-tile.png
1242
1714
  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
1715
 
1244
1716
  // src/react/ui/modals/_internal/components/tokenPreview/index.tsx
1245
- import { jsx as jsx13, jsxs as jsxs6 } from "react/jsx-runtime";
1717
+ import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
1246
1718
  function TokenPreview({
1247
1719
  collectionName,
1248
1720
  collectionAddress,
@@ -1255,17 +1727,17 @@ function TokenPreview({
1255
1727
  collectibleId
1256
1728
  });
1257
1729
  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" })
1730
+ return /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center gap-3", children: [
1731
+ /* @__PURE__ */ jsx18(Skeleton5, { className: "h-9 w-9 rounded-sm" }),
1732
+ /* @__PURE__ */ jsxs12("div", { className: "flex grow flex-col gap-1", children: [
1733
+ /* @__PURE__ */ jsx18(Skeleton5, { className: "h-3 w-1/3" }),
1734
+ /* @__PURE__ */ jsx18(Skeleton5, { className: "h-3 w-1/2" })
1263
1735
  ] })
1264
1736
  ] });
1265
1737
  }
1266
- return /* @__PURE__ */ jsxs6("div", { className: "flex w-full items-center", children: [
1267
- /* @__PURE__ */ jsx13(
1268
- Image,
1738
+ return /* @__PURE__ */ jsxs12("div", { className: "flex w-full items-center", children: [
1739
+ /* @__PURE__ */ jsx18(
1740
+ Image2,
1269
1741
  {
1270
1742
  className: "h-9 w-9 rounded-sm",
1271
1743
  src: collectable?.image || chess_tile_default,
@@ -1273,10 +1745,10 @@ function TokenPreview({
1273
1745
  style: { objectFit: "cover" }
1274
1746
  }
1275
1747
  ),
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,
1748
+ /* @__PURE__ */ jsxs12("div", { className: "ml-3 flex flex-col", children: [
1749
+ /* @__PURE__ */ jsx18(Text10, { className: "font-body font-medium text-xs", color: "text80", children: collectionName }),
1750
+ /* @__PURE__ */ jsx18(
1751
+ Text10,
1280
1752
  {
1281
1753
  className: "font-body font-bold text-xs",
1282
1754
  fontWeight: "bold",
@@ -1289,9 +1761,9 @@ function TokenPreview({
1289
1761
  }
1290
1762
 
1291
1763
  // 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";
1764
+ import { Image as Image3, Skeleton as Skeleton6, Text as Text11 } from "@0xsequence/design-system";
1765
+ import { formatUnits as formatUnits3 } from "viem";
1766
+ import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
1295
1767
  function TransactionDetails({
1296
1768
  collectibleId,
1297
1769
  collectionAddress,
@@ -1311,18 +1783,18 @@ function TransactionDetails({
1311
1783
  collectibleId
1312
1784
  });
1313
1785
  const priceLoading = !price || marketplaceConfigLoading || royaltyLoading;
1314
- let formattedAmount = price && formatUnits(BigInt(price.amountRaw), price.currency.decimals);
1786
+ let formattedAmount = price && formatUnits3(BigInt(price.amountRaw), price.currency.decimals);
1315
1787
  if (royalty !== null && formattedAmount && price) {
1316
1788
  formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * Number(royalty.percentage) / 100).toFixed(price.currency.decimals);
1317
1789
  }
1318
1790
  if (marketplaceFeePercentage !== void 0 && formattedAmount && price) {
1319
1791
  formattedAmount = (Number.parseFloat(formattedAmount) - Number.parseFloat(formattedAmount) * marketplaceFeePercentage / 100).toFixed(price.currency.decimals);
1320
1792
  }
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: [
1793
+ return /* @__PURE__ */ jsxs13("div", { className: "flex w-full items-center justify-between", children: [
1794
+ /* @__PURE__ */ jsx19(Text11, { className: "font-body font-medium text-xs", color: "text50", children: "Total earnings" }),
1795
+ /* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
1796
+ /* @__PURE__ */ jsx19(Image3, { className: "h-3 w-3", src: currencyImageUrl }),
1797
+ 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
1798
  showPlaceholderPrice ? "0" : formattedAmount,
1327
1799
  " ",
1328
1800
  price.currency.symbol
@@ -1331,17 +1803,50 @@ function TransactionDetails({
1331
1803
  ] });
1332
1804
  }
1333
1805
 
1806
+ // src/react/ui/modals/_internal/hooks/useSelectWaasFeeOptions.ts
1807
+ import { getNetwork as getNetwork2 } from "@0xsequence/connect";
1808
+ import { NetworkType as NetworkType2 } from "@0xsequence/network";
1809
+ var useSelectWaasFeeOptions = ({
1810
+ chainId,
1811
+ isProcessing,
1812
+ feeOptionsVisible,
1813
+ selectedFeeOption
1814
+ }) => {
1815
+ const { wallet } = useWallet();
1816
+ const network = chainId ? getNetwork2(Number(chainId)) : void 0;
1817
+ const isTestnet = network?.type === NetworkType2.TESTNET;
1818
+ const isWaaS = wallet?.isWaaS;
1819
+ const isProcessingWithWaaS = isProcessing && isWaaS;
1820
+ const shouldHideActionButton = !isTestnet && isProcessingWithWaaS && feeOptionsVisible === true && !!selectedFeeOption;
1821
+ const waasFeeOptionsShown = wallet?.isWaaS && isProcessing && feeOptionsVisible;
1822
+ const getActionLabel = (defaultLabel, loadingLabel = "Loading fee options") => {
1823
+ if (isProcessing) {
1824
+ return isWaaS && !isTestnet ? loadingLabel : defaultLabel;
1825
+ }
1826
+ return defaultLabel;
1827
+ };
1828
+ return {
1829
+ isWaaS,
1830
+ isTestnet,
1831
+ feeOptionsVisible,
1832
+ shouldHideActionButton,
1833
+ waasFeeOptionsShown,
1834
+ isProcessingWithWaaS,
1835
+ getActionLabel
1836
+ };
1837
+ };
1838
+
1334
1839
  // src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx
1335
- import { useEffect as useEffect6 } from "react";
1840
+ import { useEffect as useEffect8 } from "react";
1336
1841
 
1337
1842
  // 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";
1843
+ import { skipToken as skipToken4, useQuery as useQuery4 } from "@tanstack/react-query";
1844
+ import { useAccount as useAccount3 } from "wagmi";
1340
1845
  var ONE_DAY_IN_SECONDS = 60 * 60 * 24;
1341
1846
  var useGetTokenApprovalData = (params) => {
1342
1847
  const config = useConfig();
1343
1848
  const { wallet } = useWallet();
1344
- const { address } = useAccount2();
1849
+ const { address } = useAccount3();
1345
1850
  const marketplaceClient = getMarketplaceClient(params.chainId, config);
1346
1851
  const listing = {
1347
1852
  tokenId: params.tokenId,
@@ -1351,7 +1856,7 @@ var useGetTokenApprovalData = (params) => {
1351
1856
  expiry: String(Number(dateToUnixTime(/* @__PURE__ */ new Date())) + ONE_DAY_IN_SECONDS)
1352
1857
  };
1353
1858
  const isEnabled = wallet && address && (params.query?.enabled ?? true) && !!params.currencyAddress;
1354
- const { data, isLoading, isSuccess } = useQuery2({
1859
+ const { data, isLoading, isSuccess } = useQuery4({
1355
1860
  queryKey: ["token-approval-data", params, address],
1356
1861
  queryFn: isEnabled ? async () => {
1357
1862
  const args = {
@@ -1374,7 +1879,7 @@ var useGetTokenApprovalData = (params) => {
1374
1879
  return {
1375
1880
  step: tokenApprovalStep
1376
1881
  };
1377
- } : skipToken2
1882
+ } : skipToken4
1378
1883
  });
1379
1884
  return {
1380
1885
  data,
@@ -1384,16 +1889,16 @@ var useGetTokenApprovalData = (params) => {
1384
1889
  };
1385
1890
 
1386
1891
  // src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx
1387
- import { formatUnits as formatUnits4 } from "viem";
1892
+ import { formatUnits as formatUnits6 } from "viem";
1388
1893
 
1389
1894
  // src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
1390
- import { Modal, Skeleton as Skeleton6, Text as Text11 } from "@0xsequence/design-system";
1895
+ import { Modal, Skeleton as Skeleton8, Text as Text15 } from "@0xsequence/design-system";
1391
1896
  import { use$ as use$3 } from "@legendapp/state/react";
1392
1897
 
1393
1898
  // src/react/ui/modals/_internal/components/transaction-footer/index.tsx
1394
- import { CheckmarkIcon, Spinner as Spinner2, Text as Text8 } from "@0xsequence/design-system";
1899
+ import { CheckmarkIcon as CheckmarkIcon2, Spinner as Spinner3, Text as Text12 } from "@0xsequence/design-system";
1395
1900
  import { networks } from "@0xsequence/network";
1396
- import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
1901
+ import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
1397
1902
  function TransactionFooter({
1398
1903
  transactionHash,
1399
1904
  orderId,
@@ -1403,35 +1908,32 @@ function TransactionFooter({
1403
1908
  isTimeout,
1404
1909
  chainId
1405
1910
  }) {
1406
- const icon = (isConfirmed || orderId) && /* @__PURE__ */ jsx15(PositiveCircle, {}) || isConfirming && /* @__PURE__ */ jsx15(Spinner2, { size: "md" });
1911
+ const icon = (isConfirmed || orderId) && /* @__PURE__ */ jsx20(PositiveCircle, {}) || isConfirming && /* @__PURE__ */ jsx20(Spinner3, { size: "md" });
1407
1912
  const title = (isConfirmed || orderId) && "Transaction complete" || isConfirming && "Processing transaction" || isFailed && "Transaction failed" || isTimeout && "Transaction took longer than expected";
1408
1913
  const transactionUrl = `${networks[chainId]?.blockExplorer?.rootUrl}tx/${transactionHash}`;
1409
- return /* @__PURE__ */ jsxs8("div", { className: "flex items-center", children: [
1914
+ return /* @__PURE__ */ jsxs14("div", { className: "flex items-center", children: [
1410
1915
  icon,
1411
- /* @__PURE__ */ jsx15(
1412
- Text8,
1916
+ /* @__PURE__ */ jsx20(
1917
+ Text12,
1413
1918
  {
1414
- className: "ml-2 font-body text-base",
1919
+ className: "ml-2 grow font-body text-sm",
1415
1920
  color: "text50",
1416
1921
  fontWeight: "medium",
1417
1922
  children: title
1418
1923
  }
1419
1924
  ),
1420
- /* @__PURE__ */ jsx15(
1925
+ /* @__PURE__ */ jsx20(
1421
1926
  "a",
1422
1927
  {
1423
- className: "ml-2 grow text-right no-underline",
1928
+ className: "ml-2 text-right no-underline",
1424
1929
  href: transactionUrl,
1425
1930
  target: "_blank",
1426
1931
  rel: "noopener noreferrer",
1427
- children: /* @__PURE__ */ jsx15(
1428
- Text8,
1932
+ children: /* @__PURE__ */ jsx20(
1933
+ Text12,
1429
1934
  {
1430
- className: "text-right font-body text-base",
1935
+ className: "text-right font-body text-sm text-violet-400",
1431
1936
  fontWeight: "medium",
1432
- style: {
1433
- color: "hsla(247, 100%, 75%, 1)"
1434
- },
1435
1937
  children: transactionHash && truncateMiddle(transactionHash, 4, 4)
1436
1938
  }
1437
1939
  )
@@ -1439,27 +1941,27 @@ function TransactionFooter({
1439
1941
  )
1440
1942
  ] });
1441
1943
  }
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" }) });
1944
+ 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
1945
 
1444
1946
  // 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";
1947
+ import { Image as Image4, NetworkImage, Skeleton as Skeleton7, Text as Text14 } from "@0xsequence/design-system";
1948
+ import { observer as observer6 } from "@legendapp/state/react";
1949
+ import { formatUnits as formatUnits4 } from "viem";
1448
1950
 
1449
1951
  // src/react/ui/modals/_internal/components/timeAgo/index.tsx
1450
- import { Text as Text9 } from "@0xsequence/design-system";
1952
+ import { Text as Text13 } from "@0xsequence/design-system";
1451
1953
  import { formatDistanceToNow } from "date-fns";
1452
- import { useEffect as useEffect4, useState as useState5 } from "react";
1453
- import { jsx as jsx16 } from "react/jsx-runtime";
1954
+ import { useEffect as useEffect6, useState as useState7 } from "react";
1955
+ import { jsx as jsx21 } from "react/jsx-runtime";
1454
1956
  function TimeAgo({ date }) {
1455
- const [timeAgo, setTimeAgo] = useState5("");
1456
- useEffect4(() => {
1957
+ const [timeAgo, setTimeAgo] = useState7("");
1958
+ useEffect6(() => {
1457
1959
  const interval = setInterval(() => {
1458
1960
  setTimeAgo(formatDistanceToNow(date));
1459
1961
  }, 1e3);
1460
1962
  return () => clearInterval(interval);
1461
1963
  }, [date]);
1462
- return /* @__PURE__ */ jsx16("div", { className: "flex grow items-center justify-end", children: /* @__PURE__ */ jsx16(Text9, { className: "text-sm", color: "text50", children: timeAgo }) });
1964
+ return /* @__PURE__ */ jsx21("div", { className: "flex grow items-center justify-end", children: /* @__PURE__ */ jsx21(Text13, { className: "text-sm", color: "text50", children: timeAgo }) });
1463
1965
  }
1464
1966
 
1465
1967
  // src/react/ui/modals/_internal/components/transactionStatusModal/store.ts
@@ -1503,7 +2005,7 @@ var initialState2 = {
1503
2005
  status: "PENDING",
1504
2006
  price: void 0,
1505
2007
  collectionAddress: "",
1506
- chainId: "",
2008
+ chainId: 0,
1507
2009
  collectibleId: "",
1508
2010
  type: void 0,
1509
2011
  callbacks: void 0,
@@ -1558,8 +2060,8 @@ function useTransactionPreviewTitle(orderId, status, type) {
1558
2060
  }
1559
2061
 
1560
2062
  // 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(
2063
+ import { jsx as jsx22, jsxs as jsxs15 } from "react/jsx-runtime";
2064
+ var TransactionPreview = observer6(
1563
2065
  ({
1564
2066
  orderId,
1565
2067
  price,
@@ -1586,19 +2088,19 @@ var TransactionPreview = observer5(
1586
2088
  const collectibleImage = collectible?.image;
1587
2089
  const collectibleName = collectible?.name;
1588
2090
  const collectionName = collection?.name;
1589
- const priceFormatted = price ? formatUnits2(BigInt(price?.amountRaw), price?.currency.decimals) : void 0;
2091
+ const priceFormatted = price ? formatUnits4(BigInt(price?.amountRaw), price?.currency.decimals) : void 0;
1590
2092
  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%" } }) });
2093
+ return /* @__PURE__ */ jsx22("div", { className: "w-full rounded-xl", style: { height: 83 }, children: /* @__PURE__ */ jsx22(Skeleton7, { style: { width: "100%", height: "100%" } }) });
1592
2094
  }
1593
- return /* @__PURE__ */ jsxs9(
2095
+ return /* @__PURE__ */ jsxs15(
1594
2096
  "div",
1595
2097
  {
1596
2098
  className: "rounded-xl bg-background-secondary p-3",
1597
2099
  "data-testid": "transaction-preview",
1598
2100
  children: [
1599
- /* @__PURE__ */ jsxs9("div", { className: "flex items-center", children: [
1600
- /* @__PURE__ */ jsx17(
1601
- Text10,
2101
+ /* @__PURE__ */ jsxs15("div", { className: "flex items-center", children: [
2102
+ /* @__PURE__ */ jsx22(
2103
+ Text14,
1602
2104
  {
1603
2105
  className: "mr-1 font-body text-xs",
1604
2106
  color: "text80",
@@ -1607,12 +2109,12 @@ var TransactionPreview = observer5(
1607
2109
  children: title
1608
2110
  }
1609
2111
  ),
1610
- /* @__PURE__ */ jsx17(NetworkImage, { chainId: Number(chainId), size: "xs" }),
1611
- isConfirming && /* @__PURE__ */ jsx17(TimeAgo, { date: /* @__PURE__ */ new Date() })
2112
+ /* @__PURE__ */ jsx22(NetworkImage, { chainId: Number(chainId), size: "xs" }),
2113
+ isConfirming && /* @__PURE__ */ jsx22(TimeAgo, { date: /* @__PURE__ */ new Date() })
1612
2114
  ] }),
1613
- /* @__PURE__ */ jsxs9("div", { className: "mt-2 flex items-center", children: [
1614
- /* @__PURE__ */ jsx17(
1615
- Image3,
2115
+ /* @__PURE__ */ jsxs15("div", { className: "mt-2 flex items-center", children: [
2116
+ /* @__PURE__ */ jsx22(
2117
+ Image4,
1616
2118
  {
1617
2119
  className: "mr-3 h-9 w-9 rounded-sm",
1618
2120
  src: collectibleImage || chess_tile_default,
@@ -1621,9 +2123,9 @@ var TransactionPreview = observer5(
1621
2123
  "data-testid": "transaction-preview-image"
1622
2124
  }
1623
2125
  ),
1624
- /* @__PURE__ */ jsxs9("div", { className: "flex flex-col items-start gap-0.5", children: [
1625
- /* @__PURE__ */ jsx17(
1626
- Text10,
2126
+ /* @__PURE__ */ jsxs15("div", { className: "flex flex-col items-start gap-0.5", children: [
2127
+ /* @__PURE__ */ jsx22(
2128
+ Text14,
1627
2129
  {
1628
2130
  className: "font-body text-xs",
1629
2131
  color: "text80",
@@ -1632,8 +2134,8 @@ var TransactionPreview = observer5(
1632
2134
  children: collectionName
1633
2135
  }
1634
2136
  ),
1635
- /* @__PURE__ */ jsx17(
1636
- Text10,
2137
+ /* @__PURE__ */ jsx22(
2138
+ Text14,
1637
2139
  {
1638
2140
  className: "font-body text-xs",
1639
2141
  color: "text100",
@@ -1643,15 +2145,15 @@ var TransactionPreview = observer5(
1643
2145
  }
1644
2146
  )
1645
2147
  ] }),
1646
- price && /* @__PURE__ */ jsxs9(
2148
+ price && /* @__PURE__ */ jsxs15(
1647
2149
  "div",
1648
2150
  {
1649
2151
  className: "flex grow items-center justify-end gap-1",
1650
2152
  "data-testid": "transaction-preview-price",
1651
2153
  children: [
1652
- /* @__PURE__ */ jsx17(Image3, { className: "h-3 w-3", src: currencyImageUrl }),
1653
- /* @__PURE__ */ jsxs9(
1654
- Text10,
2154
+ /* @__PURE__ */ jsx22(Image4, { className: "h-3 w-3", src: currencyImageUrl }),
2155
+ /* @__PURE__ */ jsxs15(
2156
+ Text14,
1655
2157
  {
1656
2158
  className: "font-body text-xs",
1657
2159
  color: "text100",
@@ -1676,19 +2178,19 @@ var transactionPreview_default = TransactionPreview;
1676
2178
 
1677
2179
  // src/react/ui/modals/_internal/components/transactionStatusModal/hooks/useTransactionStatus.ts
1678
2180
  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";
2181
+ import { skipToken as skipToken5, useQuery as useQuery5 } from "@tanstack/react-query";
2182
+ import { useEffect as useEffect7, useState as useState8 } from "react";
1681
2183
  import { WaitForTransactionReceiptTimeoutError } from "viem";
1682
2184
  var useTransactionStatus = (hash, chainId, callbacks) => {
1683
2185
  const { wallet } = useWallet();
1684
- const [status, setStatus] = useState6(
2186
+ const [status, setStatus] = useState8(
1685
2187
  hash ? "PENDING" : "SUCCESS"
1686
2188
  );
1687
- const { data: confirmationResult } = useQuery3({
2189
+ const { data: confirmationResult } = useQuery5({
1688
2190
  queryKey: ["transaction-confirmation", hash, chainId, !!wallet],
1689
- queryFn: !!wallet && hash ? async () => await wallet.handleConfirmTransactionStep(hash, Number(chainId)) : skipToken3
2191
+ queryFn: !!wallet && hash ? async () => await wallet.handleConfirmTransactionStep(hash, Number(chainId)) : skipToken5
1690
2192
  });
1691
- useEffect5(() => {
2193
+ useEffect7(() => {
1692
2194
  if (!hash) {
1693
2195
  setStatus("SUCCESS");
1694
2196
  return;
@@ -1717,7 +2219,7 @@ var useTransactionStatus = (hash, chainId, callbacks) => {
1717
2219
  var useTransactionStatus_default = useTransactionStatus;
1718
2220
 
1719
2221
  // src/react/ui/modals/_internal/components/transactionStatusModal/util/getMessage.ts
1720
- import { formatUnits as formatUnits3 } from "viem";
2222
+ import { formatUnits as formatUnits5 } from "viem";
1721
2223
 
1722
2224
  // src/react/ui/modals/_internal/components/transactionStatusModal/util/getFormattedType.ts
1723
2225
  function getFormattedType(transactionType, verb = false) {
@@ -1748,7 +2250,7 @@ function getTransactionStatusModalMessage({
1748
2250
  price
1749
2251
  }) {
1750
2252
  const hideCollectibleName = transactionType === "CANCEL";
1751
- const formattedPrice = price ? formatUnits3(BigInt(price.amountRaw), price.currency.decimals) : "";
2253
+ const formattedPrice = price ? formatUnits5(BigInt(price.amountRaw), price.currency.decimals) : "";
1752
2254
  if (orderId) {
1753
2255
  return `You just ${getFormattedType(transactionType, true)}${!hideCollectibleName ? ` ${collectibleName}` : ""}. It's been confirmed on the blockchain!`;
1754
2256
  }
@@ -1796,7 +2298,7 @@ function getTransactionStatusModalTitle({
1796
2298
  }
1797
2299
 
1798
2300
  // src/react/ui/modals/_internal/components/transactionStatusModal/index.tsx
1799
- import { jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
2301
+ import { jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
1800
2302
  var invalidateQueries = async (queriesToInvalidate) => {
1801
2303
  const queryClient = getQueryClient();
1802
2304
  if (!queriesToInvalidate) {
@@ -1817,7 +2319,7 @@ var useTransactionStatusModal = () => {
1817
2319
  };
1818
2320
  var TransactionStatusModal = () => {
1819
2321
  const isOpen = use$3(transactionStatusModal$.isOpen);
1820
- return isOpen ? /* @__PURE__ */ jsx18(TransactionStatusModalContent, {}) : null;
2322
+ return isOpen ? /* @__PURE__ */ jsx23(TransactionStatusModalContent, {}) : null;
1821
2323
  };
1822
2324
  function TransactionStatusModalContent() {
1823
2325
  const {
@@ -1851,9 +2353,12 @@ function TransactionStatusModalContent() {
1851
2353
  });
1852
2354
  const handleClose = () => {
1853
2355
  invalidateQueries(queriesToInvalidate);
2356
+ if (selectWaasFeeOptions$.isVisible.get()) {
2357
+ selectWaasFeeOptions$.hide();
2358
+ }
1854
2359
  transactionStatusModal$.close();
1855
2360
  };
1856
- return /* @__PURE__ */ jsx18(
2361
+ return /* @__PURE__ */ jsx23(
1857
2362
  Modal,
1858
2363
  {
1859
2364
  isDismissible: true,
@@ -1861,9 +2366,9 @@ function TransactionStatusModalContent() {
1861
2366
  size: "sm",
1862
2367
  overlayProps: MODAL_OVERLAY_PROPS,
1863
2368
  "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,
2369
+ children: /* @__PURE__ */ jsxs16("div", { className: "grid flex-col gap-6 p-7", children: [
2370
+ title ? /* @__PURE__ */ jsx23(
2371
+ Text15,
1867
2372
  {
1868
2373
  className: "font-body text-xl",
1869
2374
  fontWeight: "bold",
@@ -1871,29 +2376,29 @@ function TransactionStatusModalContent() {
1871
2376
  "data-testid": "transaction-status-title",
1872
2377
  children: title
1873
2378
  }
1874
- ) : /* @__PURE__ */ jsx18(
1875
- Skeleton6,
2379
+ ) : /* @__PURE__ */ jsx23(
2380
+ Skeleton8,
1876
2381
  {
1877
2382
  className: "h-6 w-16",
1878
2383
  "data-testid": "transaction-modal-title-skeleton"
1879
2384
  }
1880
2385
  ),
1881
- message ? /* @__PURE__ */ jsx18(
1882
- Text11,
2386
+ message ? /* @__PURE__ */ jsx23(
2387
+ Text15,
1883
2388
  {
1884
2389
  className: "font-body text-sm",
1885
2390
  color: "text80",
1886
2391
  "data-testid": "transaction-status-message",
1887
2392
  children: message
1888
2393
  }
1889
- ) : /* @__PURE__ */ jsx18(
1890
- Skeleton6,
2394
+ ) : /* @__PURE__ */ jsx23(
2395
+ Skeleton8,
1891
2396
  {
1892
2397
  className: "h-4 w-20",
1893
2398
  "data-testid": "transaction-modal-content-skeleton"
1894
2399
  }
1895
2400
  ),
1896
- /* @__PURE__ */ jsx18(
2401
+ /* @__PURE__ */ jsx23(
1897
2402
  transactionPreview_default,
1898
2403
  {
1899
2404
  orderId,
@@ -1909,7 +2414,7 @@ function TransactionStatusModalContent() {
1909
2414
  isTimeout: transactionStatus === "TIMEOUT"
1910
2415
  }
1911
2416
  ),
1912
- /* @__PURE__ */ jsx18(
2417
+ /* @__PURE__ */ jsx23(
1913
2418
  TransactionFooter,
1914
2419
  {
1915
2420
  transactionHash: hash,
@@ -1942,7 +2447,7 @@ var useTransactionSteps = ({
1942
2447
  const { show: showTransactionStatusModal } = useTransactionStatusModal();
1943
2448
  const sdkConfig = useConfig();
1944
2449
  const { data: currencies } = useCurrencies({
1945
- chainId: Number(chainId)
2450
+ chainId
1946
2451
  });
1947
2452
  const currency = currencies?.find(
1948
2453
  (currency2) => currency2.contractAddress === listingInput.listing.currencyAddress
@@ -1997,10 +2502,12 @@ var useTransactionSteps = ({
1997
2502
  steps$.approval.isExecuting.set(false);
1998
2503
  }
1999
2504
  };
2000
- const createListing = async () => {
2505
+ const createListing = async ({
2506
+ isTransactionExecuting
2507
+ }) => {
2001
2508
  if (!wallet) return;
2002
2509
  try {
2003
- steps$.transaction.isExecuting.set(true);
2510
+ steps$.transaction.isExecuting.set(isTransactionExecuting);
2004
2511
  const steps3 = await getListingSteps();
2005
2512
  const transactionStep = steps3?.find(
2006
2513
  (step) => step.id === "createListing" /* createListing */
@@ -2057,7 +2564,7 @@ var useTransactionSteps = ({
2057
2564
  )?.decimals || 0;
2058
2565
  const currencyValueRaw = Number(listingInput.listing.pricePerToken);
2059
2566
  const currencyValueDecimal = Number(
2060
- formatUnits4(BigInt(currencyValueRaw), currencyDecimal)
2567
+ formatUnits6(BigInt(currencyValueRaw), currencyDecimal)
2061
2568
  );
2062
2569
  analytics.trackCreateListing({
2063
2570
  props: {
@@ -2065,7 +2572,7 @@ var useTransactionSteps = ({
2065
2572
  collectionAddress,
2066
2573
  currencyAddress: listingInput.listing.currencyAddress,
2067
2574
  currencySymbol: "",
2068
- chainId,
2575
+ chainId: chainId.toString(),
2069
2576
  txnHash: hash || ""
2070
2577
  },
2071
2578
  nums: {
@@ -2139,7 +2646,7 @@ var useCreateListing = ({
2139
2646
  enabled: !marketplaceIsLoading
2140
2647
  }
2141
2648
  });
2142
- useEffect6(() => {
2649
+ useEffect8(() => {
2143
2650
  if (tokenApproval?.step && !tokenApprovalIsLoading) {
2144
2651
  steps$.approval.exist.set(true);
2145
2652
  }
@@ -2186,7 +2693,7 @@ var steps = {
2186
2693
  var initialState3 = {
2187
2694
  isOpen: false,
2188
2695
  collectionAddress: "",
2189
- chainId: "",
2696
+ chainId: 0,
2190
2697
  collectibleId: "",
2191
2698
  orderbookKind: "sequence_marketplace_v2" /* sequence_marketplace_v2 */,
2192
2699
  collectionName: "",
@@ -2196,7 +2703,8 @@ var initialState3 = {
2196
2703
  invalidQuantity: false,
2197
2704
  expiry: new Date(addDays2(/* @__PURE__ */ new Date(), 7).toJSON()),
2198
2705
  callbacks: void 0,
2199
- steps: { ...steps }
2706
+ steps: { ...steps },
2707
+ listingIsBeingProcessed: false
2200
2708
  };
2201
2709
  var actions = {
2202
2710
  open: (args) => {
@@ -2212,6 +2720,9 @@ var actions = {
2212
2720
  createListingModal$.set({ ...initialState3, ...actions });
2213
2721
  createListingModal$.listingPrice.set({ ...listingPrice });
2214
2722
  createListingModal$.steps.set({ ...steps });
2723
+ createListingModal$.listingIsBeingProcessed.set(false);
2724
+ createListingModal$.steps.approval.isExecuting.set(false);
2725
+ createListingModal$.steps.transaction.isExecuting.set(false);
2215
2726
  }
2216
2727
  };
2217
2728
  var createListingModal$ = observable3({
@@ -2220,11 +2731,11 @@ var createListingModal$ = observable3({
2220
2731
  });
2221
2732
 
2222
2733
  // src/react/ui/modals/CreateListingModal/Modal.tsx
2223
- import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
2734
+ import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
2224
2735
  var CreateListingModal = () => {
2225
- return /* @__PURE__ */ jsx19(Show, { if: createListingModal$.isOpen, children: () => /* @__PURE__ */ jsx19(Modal2, {}) });
2736
+ return /* @__PURE__ */ jsx24(Show, { if: createListingModal$.isOpen, children: () => /* @__PURE__ */ jsx24(Modal2, {}) });
2226
2737
  };
2227
- var Modal2 = observer6(() => {
2738
+ var Modal2 = observer7(() => {
2228
2739
  const state = createListingModal$.get();
2229
2740
  const {
2230
2741
  collectionAddress,
@@ -2232,9 +2743,22 @@ var Modal2 = observer6(() => {
2232
2743
  listingPrice: listingPrice2,
2233
2744
  collectibleId,
2234
2745
  orderbookKind,
2235
- callbacks
2746
+ callbacks,
2747
+ listingIsBeingProcessed
2236
2748
  } = state;
2237
2749
  const steps$ = createListingModal$.steps;
2750
+ const { wallet } = useWallet();
2751
+ const {
2752
+ shouldHideActionButton: shouldHideListButton,
2753
+ waasFeeOptionsShown,
2754
+ getActionLabel,
2755
+ isTestnet
2756
+ } = useSelectWaasFeeOptions({
2757
+ chainId,
2758
+ isProcessing: listingIsBeingProcessed,
2759
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
2760
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
2761
+ });
2238
2762
  const {
2239
2763
  data: collectible,
2240
2764
  isLoading: collectableIsLoading,
@@ -2262,9 +2786,9 @@ var Modal2 = observer6(() => {
2262
2786
  collectionAddress
2263
2787
  });
2264
2788
  const modalLoading = collectableIsLoading || collectionIsLoading || currenciesLoading;
2265
- const { address } = useAccount3();
2789
+ const { address } = useAccount4();
2266
2790
  const { data: balance } = useBalanceOfCollectible({
2267
- chainId: Number(chainId),
2791
+ chainId,
2268
2792
  collectionAddress,
2269
2793
  collectableId: collectibleId,
2270
2794
  userAddress: address ?? void 0
@@ -2274,7 +2798,7 @@ var Modal2 = observer6(() => {
2274
2798
  contractType: collection?.type,
2275
2799
  listing: {
2276
2800
  tokenId: collectibleId,
2277
- quantity: parseUnits3(
2801
+ quantity: parseUnits2(
2278
2802
  createListingModal$.quantity.get(),
2279
2803
  collectible?.decimals || 0
2280
2804
  ).toString(),
@@ -2291,7 +2815,7 @@ var Modal2 = observer6(() => {
2291
2815
  steps$
2292
2816
  });
2293
2817
  if (collectableIsError || collectionIsError || currenciesIsError) {
2294
- return /* @__PURE__ */ jsx19(
2818
+ return /* @__PURE__ */ jsx24(
2295
2819
  ErrorModal,
2296
2820
  {
2297
2821
  isOpen: createListingModal$.isOpen.get(),
@@ -2302,7 +2826,7 @@ var Modal2 = observer6(() => {
2302
2826
  );
2303
2827
  }
2304
2828
  if (!modalLoading && (!currencies || currencies.length === 0)) {
2305
- return /* @__PURE__ */ jsx19(
2829
+ return /* @__PURE__ */ jsx24(
2306
2830
  ErrorModal,
2307
2831
  {
2308
2832
  isOpen: createListingModal$.isOpen.get(),
@@ -2313,6 +2837,23 @@ var Modal2 = observer6(() => {
2313
2837
  }
2314
2838
  );
2315
2839
  }
2840
+ const handleCreateListing = async () => {
2841
+ createListingModal$.listingIsBeingProcessed.set(true);
2842
+ try {
2843
+ if (wallet?.isWaaS) {
2844
+ selectWaasFeeOptions$.isVisible.set(true);
2845
+ }
2846
+ await createListing({
2847
+ isTransactionExecuting: wallet?.isWaaS ? !isTestnet : false
2848
+ });
2849
+ } catch (error) {
2850
+ console.error("Create listing failed:", error);
2851
+ } finally {
2852
+ createListingModal$.listingIsBeingProcessed.set(false);
2853
+ steps$.transaction.isExecuting.set(false);
2854
+ }
2855
+ };
2856
+ const listCtaLabel = getActionLabel("List item for sale");
2316
2857
  const ctas = [
2317
2858
  {
2318
2859
  label: "Approve TOKEN",
@@ -2323,25 +2864,29 @@ var Modal2 = observer6(() => {
2323
2864
  disabled: createListingModal$.invalidQuantity.get() || listingPrice2.amountRaw === "0" || steps$?.approval.isExecuting.get() || tokenApprovalIsLoading || isLoading
2324
2865
  },
2325
2866
  {
2326
- label: "List item for sale",
2327
- onClick: () => createListing(),
2328
- pending: steps$?.transaction.isExecuting.get(),
2867
+ label: listCtaLabel,
2868
+ onClick: handleCreateListing,
2869
+ pending: steps$?.transaction.isExecuting.get() || createListingModal$.listingIsBeingProcessed.get(),
2329
2870
  testid: "create-listing-submit-button",
2330
- disabled: steps$.approval.exist.get() || tokenApprovalIsLoading || listingPrice2.amountRaw === "0" || createListingModal$.invalidQuantity.get() || isLoading
2871
+ disabled: steps$.approval.exist.get() || tokenApprovalIsLoading || listingPrice2.amountRaw === "0" || createListingModal$.invalidQuantity.get() || isLoading || listingIsBeingProcessed
2331
2872
  }
2332
2873
  ];
2333
- return /* @__PURE__ */ jsxs11(
2874
+ return /* @__PURE__ */ jsxs17(
2334
2875
  ActionModal,
2335
2876
  {
2336
2877
  isOpen: createListingModal$.isOpen.get(),
2337
2878
  chainId: Number(chainId),
2338
- onClose: () => createListingModal$.close(),
2879
+ onClose: () => {
2880
+ createListingModal$.close();
2881
+ selectWaasFeeOptions$.hide();
2882
+ },
2339
2883
  title: "List item for sale",
2340
2884
  ctas,
2341
2885
  modalLoading,
2342
2886
  spinnerContainerClassname: "h-[220px]",
2887
+ hideCtas: shouldHideListButton,
2343
2888
  children: [
2344
- /* @__PURE__ */ jsx19(
2889
+ /* @__PURE__ */ jsx24(
2345
2890
  TokenPreview,
2346
2891
  {
2347
2892
  collectionName: collection?.name,
@@ -2350,16 +2895,17 @@ var Modal2 = observer6(() => {
2350
2895
  chainId
2351
2896
  }
2352
2897
  ),
2353
- /* @__PURE__ */ jsxs11("div", { className: "flex w-full flex-col gap-1", children: [
2354
- /* @__PURE__ */ jsx19(
2898
+ /* @__PURE__ */ jsxs17("div", { className: "flex w-full flex-col gap-1", children: [
2899
+ /* @__PURE__ */ jsx24(
2355
2900
  PriceInput,
2356
2901
  {
2357
2902
  chainId,
2358
2903
  collectionAddress,
2359
- $price: createListingModal$.listingPrice
2904
+ $price: createListingModal$.listingPrice,
2905
+ disabled: shouldHideListButton
2360
2906
  }
2361
2907
  ),
2362
- listingPrice2.amountRaw !== "0" && /* @__PURE__ */ jsx19(
2908
+ listingPrice2.amountRaw !== "0" && /* @__PURE__ */ jsx24(
2363
2909
  FloorPriceText,
2364
2910
  {
2365
2911
  tokenId: collectibleId,
@@ -2369,17 +2915,24 @@ var Modal2 = observer6(() => {
2369
2915
  }
2370
2916
  )
2371
2917
  ] }),
2372
- collection?.type === "ERC1155" && balance && /* @__PURE__ */ jsx19(
2918
+ collection?.type === "ERC1155" && balance && /* @__PURE__ */ jsx24(
2373
2919
  quantityInput_default,
2374
2920
  {
2375
2921
  $quantity: createListingModal$.quantity,
2376
2922
  $invalidQuantity: createListingModal$.invalidQuantity,
2377
2923
  decimals: collectible?.decimals || 0,
2378
- maxQuantity: balance?.balance
2924
+ maxQuantity: balance?.balance,
2925
+ disabled: shouldHideListButton
2379
2926
  }
2380
2927
  ),
2381
- /* @__PURE__ */ jsx19(expirationDateSelect_default, { $date: createListingModal$.expiry }),
2382
- /* @__PURE__ */ jsx19(
2928
+ /* @__PURE__ */ jsx24(
2929
+ expirationDateSelect_default,
2930
+ {
2931
+ $date: createListingModal$.expiry,
2932
+ disabled: shouldHideListButton
2933
+ }
2934
+ ),
2935
+ /* @__PURE__ */ jsx24(
2383
2936
  TransactionDetails,
2384
2937
  {
2385
2938
  collectibleId,
@@ -2389,6 +2942,17 @@ var Modal2 = observer6(() => {
2389
2942
  currencyImageUrl: listingPrice2.currency.imageUrl,
2390
2943
  includeMarketplaceFee: false
2391
2944
  }
2945
+ ),
2946
+ waasFeeOptionsShown && /* @__PURE__ */ jsx24(
2947
+ selectWaasFeeOptions_default,
2948
+ {
2949
+ chainId: Number(chainId),
2950
+ onCancel: () => {
2951
+ createListingModal$.listingIsBeingProcessed.set(false);
2952
+ steps$.transaction.isExecuting.set(false);
2953
+ },
2954
+ titleOnConfirm: "Processing listing..."
2955
+ }
2392
2956
  )
2393
2957
  ]
2394
2958
  }
@@ -2396,15 +2960,25 @@ var Modal2 = observer6(() => {
2396
2960
  });
2397
2961
 
2398
2962
  // 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";
2963
+ import { getNetwork as getNetwork3 } from "@0xsequence/connect";
2964
+ import { NetworkType as NetworkType3 } from "@0xsequence/network";
2965
+ import { Show as Show2, observer as observer8 } from "@legendapp/state/react";
2966
+ import { useState as useState9 } from "react";
2967
+ import { parseUnits as parseUnits3 } from "viem";
2968
+
2969
+ // src/react/ui/modals/BuyModal/index.tsx
2970
+ var useBuyModal = (callbacks) => {
2971
+ return {
2972
+ show: (args) => buyModalStore.send({ type: "open", props: args, ...callbacks }),
2973
+ close: () => buyModalStore.send({ type: "close" })
2974
+ };
2975
+ };
2402
2976
 
2403
2977
  // src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx
2404
- import { useEffect as useEffect7 } from "react";
2978
+ import { useEffect as useEffect9 } from "react";
2405
2979
 
2406
2980
  // src/react/ui/modals/MakeOfferModal/hooks/useGetTokenApproval.tsx
2407
- import { skipToken as skipToken4, useQuery as useQuery4 } from "@tanstack/react-query";
2981
+ import { skipToken as skipToken6, useQuery as useQuery6 } from "@tanstack/react-query";
2408
2982
  var ONE_DAY_IN_SECONDS2 = 60 * 60 * 24;
2409
2983
  var useGetTokenApprovalData2 = (params) => {
2410
2984
  const config = useConfig();
@@ -2418,7 +2992,7 @@ var useGetTokenApprovalData2 = (params) => {
2418
2992
  expiry: String(Number(dateToUnixTime(/* @__PURE__ */ new Date())) + ONE_DAY_IN_SECONDS2)
2419
2993
  };
2420
2994
  const isEnabled = wallet && params.query?.enabled !== false;
2421
- const { data, isLoading, isSuccess } = useQuery4({
2995
+ const { data, isLoading, isSuccess } = useQuery6({
2422
2996
  queryKey: ["token-approval-data", params.currencyAddress],
2423
2997
  queryFn: isEnabled ? async () => {
2424
2998
  const args = {
@@ -2441,7 +3015,7 @@ var useGetTokenApprovalData2 = (params) => {
2441
3015
  return {
2442
3016
  step: tokenApprovalStep
2443
3017
  };
2444
- } : skipToken4,
3018
+ } : skipToken6,
2445
3019
  enabled: !!wallet && !!params.collectionAddress && !!params.currencyAddress
2446
3020
  });
2447
3021
  return {
@@ -2452,7 +3026,7 @@ var useGetTokenApprovalData2 = (params) => {
2452
3026
  };
2453
3027
 
2454
3028
  // src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx
2455
- import { formatUnits as formatUnits5 } from "viem";
3029
+ import { formatUnits as formatUnits7 } from "viem";
2456
3030
  var useTransactionSteps2 = ({
2457
3031
  offerInput,
2458
3032
  chainId,
@@ -2520,10 +3094,12 @@ var useTransactionSteps2 = ({
2520
3094
  steps$.approval.isExecuting.set(false);
2521
3095
  }
2522
3096
  };
2523
- const makeOffer = async () => {
3097
+ const makeOffer = async ({
3098
+ isTransactionExecuting
3099
+ }) => {
2524
3100
  if (!wallet) return;
2525
3101
  try {
2526
- steps$.transaction.isExecuting.set(true);
3102
+ steps$.transaction.isExecuting.set(isTransactionExecuting);
2527
3103
  const steps3 = await getOfferSteps();
2528
3104
  const transactionStep = steps3?.find(
2529
3105
  (step) => step.id === "createOffer" /* createOffer */
@@ -2578,7 +3154,7 @@ var useTransactionSteps2 = ({
2578
3154
  const currencyDecimal = currency?.decimals || 0;
2579
3155
  const currencyValueRaw = Number(offerInput.offer.pricePerToken);
2580
3156
  const currencyValueDecimal = Number(
2581
- formatUnits5(BigInt(currencyValueRaw), currencyDecimal)
3157
+ formatUnits7(BigInt(currencyValueRaw), currencyDecimal)
2582
3158
  );
2583
3159
  analytics.trackCreateOffer({
2584
3160
  props: {
@@ -2586,7 +3162,7 @@ var useTransactionSteps2 = ({
2586
3162
  collectionAddress,
2587
3163
  currencyAddress: offerInput.offer.currencyAddress,
2588
3164
  currencySymbol: currency?.symbol || "",
2589
- chainId,
3165
+ chainId: chainId.toString(),
2590
3166
  txnHash: hash || ""
2591
3167
  },
2592
3168
  nums: {
@@ -2660,7 +3236,7 @@ var useMakeOffer = ({
2660
3236
  enabled: !marketplaceIsLoading
2661
3237
  }
2662
3238
  });
2663
- useEffect7(() => {
3239
+ useEffect9(() => {
2664
3240
  if (tokenApproval?.step && !tokenApprovalIsLoading) {
2665
3241
  steps$.approval.exist.set(true);
2666
3242
  }
@@ -2707,7 +3283,7 @@ var steps2 = {
2707
3283
  var initialState4 = {
2708
3284
  isOpen: false,
2709
3285
  collectionAddress: "",
2710
- chainId: "",
3286
+ chainId: 0,
2711
3287
  collectibleId: "",
2712
3288
  orderbookKind: void 0,
2713
3289
  callbacks: void 0,
@@ -2717,7 +3293,8 @@ var initialState4 = {
2717
3293
  invalidQuantity: false,
2718
3294
  expiry: new Date(addDays3(/* @__PURE__ */ new Date(), 7).toJSON()),
2719
3295
  collectionType: void 0,
2720
- steps: { ...steps2 }
3296
+ steps: { ...steps2 },
3297
+ offerIsBeingProcessed: false
2721
3298
  };
2722
3299
  var actions2 = {
2723
3300
  open: (args) => {
@@ -2733,7 +3310,7 @@ var actions2 = {
2733
3310
  makeOfferModal$.set({ ...initialState4, ...actions2 });
2734
3311
  makeOfferModal$.steps.set({ ...steps2 });
2735
3312
  makeOfferModal$.offerPrice.set({ ...offerPrice });
2736
- makeOfferModal$.steps.set({ ...steps2 });
3313
+ makeOfferModal$.offerIsBeingProcessed.set(false);
2737
3314
  }
2738
3315
  };
2739
3316
  var makeOfferModal$ = observable4({
@@ -2742,11 +3319,11 @@ var makeOfferModal$ = observable4({
2742
3319
  });
2743
3320
 
2744
3321
  // src/react/ui/modals/MakeOfferModal/Modal.tsx
2745
- import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
3322
+ import { Fragment as Fragment2, jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
2746
3323
  var MakeOfferModal = () => {
2747
- return /* @__PURE__ */ jsx20(Show2, { if: makeOfferModal$.isOpen, children: () => /* @__PURE__ */ jsx20(Modal3, {}) });
3324
+ return /* @__PURE__ */ jsx25(Show2, { if: makeOfferModal$.isOpen, children: () => /* @__PURE__ */ jsx25(Modal3, {}) });
2748
3325
  };
2749
- var Modal3 = observer7(() => {
3326
+ var Modal3 = observer8(() => {
2750
3327
  const state = makeOfferModal$.get();
2751
3328
  const {
2752
3329
  collectionAddress,
@@ -2759,7 +3336,7 @@ var Modal3 = observer7(() => {
2759
3336
  callbacks
2760
3337
  } = state;
2761
3338
  const steps$ = makeOfferModal$.steps;
2762
- const [insufficientBalance, setInsufficientBalance] = useState7(false);
3339
+ const [insufficientBalance, setInsufficientBalance] = useState9(false);
2763
3340
  const {
2764
3341
  data: collectible,
2765
3342
  isLoading: collectableIsLoading,
@@ -2769,6 +3346,18 @@ var Modal3 = observer7(() => {
2769
3346
  collectionAddress,
2770
3347
  collectibleId
2771
3348
  });
3349
+ const { wallet } = useWallet();
3350
+ const isProcessing = makeOfferModal$.offerIsBeingProcessed.get();
3351
+ const {
3352
+ shouldHideActionButton: shouldHideOfferButton,
3353
+ waasFeeOptionsShown,
3354
+ getActionLabel
3355
+ } = useSelectWaasFeeOptions({
3356
+ chainId,
3357
+ isProcessing,
3358
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
3359
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
3360
+ });
2772
3361
  const {
2773
3362
  data: collection,
2774
3363
  isLoading: collectionIsLoading,
@@ -2791,7 +3380,7 @@ var Modal3 = observer7(() => {
2791
3380
  contractType: collection?.type,
2792
3381
  offer: {
2793
3382
  tokenId: collectibleId,
2794
- quantity: parseUnits4(
3383
+ quantity: parseUnits3(
2795
3384
  makeOfferModal$.quantity.get(),
2796
3385
  collectible?.decimals || 0
2797
3386
  ).toString(),
@@ -2807,8 +3396,17 @@ var Modal3 = observer7(() => {
2807
3396
  closeMainModal: () => makeOfferModal$.close(),
2808
3397
  steps$
2809
3398
  });
3399
+ const buyModal = useBuyModal(callbacks);
3400
+ const { data: lowestListing } = useLowestListing({
3401
+ tokenId: collectibleId,
3402
+ chainId,
3403
+ collectionAddress,
3404
+ filters: {
3405
+ currencies: [offerPrice2.currency.contractAddress]
3406
+ }
3407
+ });
2810
3408
  if (collectableIsError || collectionIsError || currenciesIsError) {
2811
- return /* @__PURE__ */ jsx20(
3409
+ return /* @__PURE__ */ jsx25(
2812
3410
  ErrorModal,
2813
3411
  {
2814
3412
  isOpen: makeOfferModal$.isOpen.get(),
@@ -2819,7 +3417,7 @@ var Modal3 = observer7(() => {
2819
3417
  );
2820
3418
  }
2821
3419
  if (!modalLoading && (!currencies || currencies.length === 0)) {
2822
- return /* @__PURE__ */ jsx20(
3420
+ return /* @__PURE__ */ jsx25(
2823
3421
  ErrorModal,
2824
3422
  {
2825
3423
  isOpen: makeOfferModal$.isOpen.get(),
@@ -2830,6 +3428,23 @@ var Modal3 = observer7(() => {
2830
3428
  }
2831
3429
  );
2832
3430
  }
3431
+ const handleMakeOffer = async () => {
3432
+ makeOfferModal$.offerIsBeingProcessed.set(true);
3433
+ try {
3434
+ if (wallet?.isWaaS) {
3435
+ selectWaasFeeOptions$.isVisible.set(true);
3436
+ }
3437
+ await makeOffer({
3438
+ isTransactionExecuting: wallet?.isWaaS ? getNetwork3(Number(chainId)).type !== NetworkType3.TESTNET : false
3439
+ });
3440
+ } catch (error) {
3441
+ console.error("Make offer failed:", error);
3442
+ } finally {
3443
+ makeOfferModal$.offerIsBeingProcessed.set(false);
3444
+ steps$.transaction.isExecuting.set(false);
3445
+ }
3446
+ };
3447
+ const offerCtaLabel = getActionLabel("Make offer");
2833
3448
  const ctas = [
2834
3449
  {
2835
3450
  label: "Approve TOKEN",
@@ -2840,24 +3455,29 @@ var Modal3 = observer7(() => {
2840
3455
  disabled: invalidQuantity || isLoading || insufficientBalance || offerPrice2.amountRaw === "0" || !offerPriceChanged
2841
3456
  },
2842
3457
  {
2843
- label: "Make offer",
2844
- onClick: () => makeOffer(),
2845
- pending: steps$.transaction.isExecuting.get(),
3458
+ label: offerCtaLabel,
3459
+ onClick: () => handleMakeOffer(),
3460
+ pending: steps$?.transaction.isExecuting.get() || makeOfferModal$.offerIsBeingProcessed.get(),
2846
3461
  disabled: steps$.approval.isExecuting.get() || steps$.approval.exist.get() || offerPrice2.amountRaw === "0" || insufficientBalance || isLoading || invalidQuantity
2847
3462
  }
2848
3463
  ];
2849
- return /* @__PURE__ */ jsx20(Fragment2, { children: /* @__PURE__ */ jsxs12(
3464
+ return /* @__PURE__ */ jsx25(Fragment2, { children: /* @__PURE__ */ jsxs18(
2850
3465
  ActionModal,
2851
3466
  {
2852
3467
  isOpen: makeOfferModal$.isOpen.get(),
2853
3468
  chainId: Number(chainId),
2854
- onClose: () => makeOfferModal$.close(),
3469
+ onClose: () => {
3470
+ makeOfferModal$.close();
3471
+ selectWaasFeeOptions$.hide();
3472
+ steps$.transaction.isExecuting.set(false);
3473
+ },
2855
3474
  title: "Make an offer",
2856
3475
  ctas,
2857
3476
  modalLoading,
2858
3477
  spinnerContainerClassname: "h-[188px]",
3478
+ hideCtas: shouldHideOfferButton,
2859
3479
  children: [
2860
- /* @__PURE__ */ jsx20(
3480
+ /* @__PURE__ */ jsx25(
2861
3481
  TokenPreview,
2862
3482
  {
2863
3483
  collectionName: collection?.name,
@@ -2866,7 +3486,7 @@ var Modal3 = observer7(() => {
2866
3486
  chainId
2867
3487
  }
2868
3488
  ),
2869
- /* @__PURE__ */ jsx20(
3489
+ /* @__PURE__ */ jsx25(
2870
3490
  PriceInput,
2871
3491
  {
2872
3492
  chainId,
@@ -2877,49 +3497,82 @@ var Modal3 = observer7(() => {
2877
3497
  checkBalance: {
2878
3498
  enabled: true,
2879
3499
  callback: (state2) => setInsufficientBalance(state2)
2880
- }
3500
+ },
3501
+ disabled: shouldHideOfferButton
2881
3502
  }
2882
3503
  ),
2883
- collection?.type === "ERC1155" /* ERC1155 */ && /* @__PURE__ */ jsx20(
3504
+ collection?.type === "ERC1155" /* ERC1155 */ && /* @__PURE__ */ jsx25(
2884
3505
  quantityInput_default,
2885
3506
  {
2886
3507
  $quantity: makeOfferModal$.quantity,
2887
3508
  $invalidQuantity: makeOfferModal$.invalidQuantity,
2888
3509
  decimals: collectible?.decimals || 0,
2889
- maxQuantity: String(Number.MAX_SAFE_INTEGER)
3510
+ maxQuantity: String(Number.MAX_SAFE_INTEGER),
3511
+ disabled: shouldHideOfferButton
2890
3512
  }
2891
3513
  ),
2892
- offerPrice2.amountRaw !== "0" && offerPriceChanged && !insufficientBalance && /* @__PURE__ */ jsx20(
3514
+ offerPrice2.amountRaw !== "0" && offerPriceChanged && !insufficientBalance && /* @__PURE__ */ jsx25(
2893
3515
  FloorPriceText,
2894
3516
  {
2895
3517
  tokenId: collectibleId,
2896
3518
  chainId,
2897
3519
  collectionAddress,
2898
- price: offerPrice2
3520
+ price: offerPrice2,
3521
+ onBuyNow: () => {
3522
+ makeOfferModal$.close();
3523
+ if (lowestListing?.order) {
3524
+ buyModal.show({
3525
+ chainId,
3526
+ collectionAddress,
3527
+ collectibleId,
3528
+ orderId: lowestListing.order.orderId,
3529
+ marketplace: lowestListing.order.marketplace
3530
+ });
3531
+ }
3532
+ }
3533
+ }
3534
+ ),
3535
+ /* @__PURE__ */ jsx25(
3536
+ expirationDateSelect_default,
3537
+ {
3538
+ $date: makeOfferModal$.expiry,
3539
+ disabled: shouldHideOfferButton
2899
3540
  }
2900
3541
  ),
2901
- /* @__PURE__ */ jsx20(expirationDateSelect_default, { $date: makeOfferModal$.expiry })
3542
+ waasFeeOptionsShown && /* @__PURE__ */ jsx25(
3543
+ selectWaasFeeOptions_default,
3544
+ {
3545
+ chainId: Number(chainId),
3546
+ onCancel: () => {
3547
+ makeOfferModal$.offerIsBeingProcessed.set(false);
3548
+ steps$.transaction.isExecuting.set(false);
3549
+ },
3550
+ titleOnConfirm: "Processing offer..."
3551
+ }
3552
+ )
2902
3553
  ]
2903
3554
  }
2904
3555
  ) });
2905
3556
  });
2906
3557
 
2907
3558
  // 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";
3559
+ import { getNetwork as getNetwork4 } from "@0xsequence/connect";
3560
+ import { NetworkType as NetworkType4 } from "@0xsequence/network";
3561
+ import { Show as Show3, observer as observer9 } from "@legendapp/state/react";
3562
+ import { parseUnits as parseUnits4 } from "viem";
2910
3563
 
2911
3564
  // src/react/ui/modals/_internal/components/transactionHeader/index.tsx
2912
- import { Image as Image4, Skeleton as Skeleton7, Text as Text12 } from "@0xsequence/design-system";
3565
+ import { Image as Image5, Skeleton as Skeleton9, Text as Text16 } from "@0xsequence/design-system";
2913
3566
  import { formatDistanceToNow as formatDistanceToNow2 } from "date-fns";
2914
- import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
3567
+ import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
2915
3568
  function TransactionHeader({
2916
3569
  title,
2917
3570
  currencyImageUrl,
2918
3571
  date
2919
3572
  }) {
2920
- return /* @__PURE__ */ jsxs13("div", { className: "flex w-full items-center", children: [
2921
- /* @__PURE__ */ jsx21(
2922
- Text12,
3573
+ return /* @__PURE__ */ jsxs19("div", { className: "flex w-full items-center", children: [
3574
+ /* @__PURE__ */ jsx26(
3575
+ Text16,
2923
3576
  {
2924
3577
  className: "mr-1 font-body text-sm",
2925
3578
  fontWeight: "medium",
@@ -2927,9 +3580,9 @@ function TransactionHeader({
2927
3580
  children: title
2928
3581
  }
2929
3582
  ),
2930
- /* @__PURE__ */ jsx21(Image4, { className: "mr-1 h-3 w-3", src: currencyImageUrl }),
2931
- date && /* @__PURE__ */ jsxs13(
2932
- Text12,
3583
+ /* @__PURE__ */ jsx26(Image5, { className: "mr-1 h-3 w-3", src: currencyImageUrl }),
3584
+ date && /* @__PURE__ */ jsxs19(
3585
+ Text16,
2933
3586
  {
2934
3587
  className: "grow text-right font-body text-xs",
2935
3588
  fontWeight: "medium",
@@ -2939,15 +3592,15 @@ function TransactionHeader({
2939
3592
  " ago"
2940
3593
  ]
2941
3594
  }
2942
- ) || /* @__PURE__ */ jsx21(Skeleton7, { className: "h-4 w-8" })
3595
+ ) || /* @__PURE__ */ jsx26(Skeleton9, { className: "h-4 w-8" })
2943
3596
  ] });
2944
3597
  }
2945
3598
 
2946
3599
  // src/react/ui/modals/SellModal/hooks/useSell.tsx
2947
- import { useEffect as useEffect8 } from "react";
3600
+ import { useEffect as useEffect10 } from "react";
2948
3601
 
2949
3602
  // src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx
2950
- import { skipToken as skipToken5, useQuery as useQuery5 } from "@tanstack/react-query";
3603
+ import { skipToken as skipToken7, useQuery as useQuery7 } from "@tanstack/react-query";
2951
3604
  var useGetTokenApprovalData3 = (params) => {
2952
3605
  const config = useConfig();
2953
3606
  const { wallet } = useWallet();
@@ -2956,7 +3609,7 @@ var useGetTokenApprovalData3 = (params) => {
2956
3609
  chainId: Number(params.chainId),
2957
3610
  collectionAddress: params.collectionAddress
2958
3611
  });
2959
- const { data, isLoading, isSuccess } = useQuery5({
3612
+ const { data, isLoading, isSuccess } = useQuery7({
2960
3613
  queryKey: ["token-approval-data", params.ordersData],
2961
3614
  queryFn: wallet ? async () => {
2962
3615
  const address = await wallet.address();
@@ -2985,7 +3638,7 @@ var useGetTokenApprovalData3 = (params) => {
2985
3638
  return {
2986
3639
  step: tokenApprovalStep
2987
3640
  };
2988
- } : skipToken5,
3641
+ } : skipToken7,
2989
3642
  enabled: !!wallet && !!params.collectionAddress
2990
3643
  });
2991
3644
  return {
@@ -2996,7 +3649,7 @@ var useGetTokenApprovalData3 = (params) => {
2996
3649
  };
2997
3650
 
2998
3651
  // src/react/ui/modals/SellModal/hooks/useTransactionSteps.tsx
2999
- import { formatUnits as formatUnits6 } from "viem";
3652
+ import { formatUnits as formatUnits8 } from "viem";
3000
3653
  var useTransactionSteps3 = ({
3001
3654
  collectibleId,
3002
3655
  chainId,
@@ -3013,11 +3666,11 @@ var useTransactionSteps3 = ({
3013
3666
  const marketplaceClient = getMarketplaceClient(chainId, sdkConfig);
3014
3667
  const analytics = useAnalytics();
3015
3668
  const { amount, receiver } = useFees({
3016
- chainId: Number(chainId),
3669
+ chainId,
3017
3670
  collectionAddress
3018
3671
  });
3019
3672
  const { data: currencies } = useCurrencies({
3020
- chainId: Number(chainId)
3673
+ chainId
3021
3674
  });
3022
3675
  const { generateSellTransactionAsync, isPending: generatingSteps } = useGenerateSellTransaction({
3023
3676
  chainId,
@@ -3069,10 +3722,12 @@ var useTransactionSteps3 = ({
3069
3722
  steps$.approval.isExecuting.set(false);
3070
3723
  }
3071
3724
  };
3072
- const sell = async () => {
3725
+ const sell = async ({
3726
+ isTransactionExecuting
3727
+ }) => {
3073
3728
  if (!wallet) return;
3074
3729
  try {
3075
- steps$.transaction.isExecuting.set(true);
3730
+ steps$.transaction.isExecuting.set(isTransactionExecuting);
3076
3731
  const steps3 = await getSellSteps();
3077
3732
  const transactionStep = steps3?.find((step) => step.id === "sell" /* sell */);
3078
3733
  const signatureStep = steps3?.find(
@@ -3119,7 +3774,7 @@ var useTransactionSteps3 = ({
3119
3774
  const currencySymbol = currency?.symbol || "";
3120
3775
  const currencyValueRaw = Number(ordersData[0].pricePerToken);
3121
3776
  const currencyValueDecimal = Number(
3122
- formatUnits6(BigInt(currencyValueRaw), currencyDecimal)
3777
+ formatUnits8(BigInt(currencyValueRaw), currencyDecimal)
3123
3778
  );
3124
3779
  analytics.trackSellItems({
3125
3780
  props: {
@@ -3127,7 +3782,7 @@ var useTransactionSteps3 = ({
3127
3782
  collectionAddress,
3128
3783
  currencyAddress: ordersData[0].currencyAddress,
3129
3784
  currencySymbol,
3130
- chainId,
3785
+ chainId: chainId.toString(),
3131
3786
  txnHash: hash || ""
3132
3787
  },
3133
3788
  nums: {
@@ -3192,7 +3847,7 @@ var useSell = ({
3192
3847
  ordersData,
3193
3848
  marketplace
3194
3849
  });
3195
- useEffect8(() => {
3850
+ useEffect10(() => {
3196
3851
  if (tokenApproval?.step && !tokenApprovalIsLoading) {
3197
3852
  steps$.approval.exist.set(true);
3198
3853
  }
@@ -3221,10 +3876,11 @@ import { observable as observable5 } from "@legendapp/state";
3221
3876
  var initialState5 = {
3222
3877
  isOpen: false,
3223
3878
  collectionAddress: "",
3224
- chainId: "",
3879
+ chainId: 0,
3225
3880
  tokenId: "",
3226
3881
  order: void 0,
3227
3882
  callbacks: void 0,
3883
+ sellIsBeingProcessed: false,
3228
3884
  open: (args) => {
3229
3885
  sellModal$.collectionAddress.set(args.collectionAddress);
3230
3886
  sellModal$.chainId.set(args.chainId);
@@ -3236,6 +3892,7 @@ var initialState5 = {
3236
3892
  close: () => {
3237
3893
  sellModal$.isOpen.set(false);
3238
3894
  sellModal$.callbacks.set(void 0);
3895
+ sellModal$.sellIsBeingProcessed.set(false);
3239
3896
  },
3240
3897
  steps: {
3241
3898
  approval: {
@@ -3253,11 +3910,11 @@ var initialState5 = {
3253
3910
  var sellModal$ = observable5(initialState5);
3254
3911
 
3255
3912
  // src/react/ui/modals/SellModal/Modal.tsx
3256
- import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
3913
+ import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
3257
3914
  var SellModal = () => {
3258
- return /* @__PURE__ */ jsx22(Show3, { if: sellModal$.isOpen, children: () => /* @__PURE__ */ jsx22(Modal4, {}) });
3915
+ return /* @__PURE__ */ jsx27(Show3, { if: sellModal$.isOpen, children: () => /* @__PURE__ */ jsx27(Modal4, {}) });
3259
3916
  };
3260
- var Modal4 = observer8(() => {
3917
+ var Modal4 = observer9(() => {
3261
3918
  const { tokenId, collectionAddress, chainId, order, callbacks } = sellModal$.get();
3262
3919
  const steps$ = sellModal$.steps;
3263
3920
  const { data: collectible } = useCollection({
@@ -3280,6 +3937,18 @@ var Modal4 = observer8(() => {
3280
3937
  chainId,
3281
3938
  currencyAddress: order?.priceCurrencyAddress ?? ""
3282
3939
  });
3940
+ const { wallet } = useWallet();
3941
+ const feeOptionsVisible = selectWaasFeeOptions$.isVisible.get();
3942
+ const network = getNetwork4(Number(chainId));
3943
+ const isTestnet = network.type === NetworkType4.TESTNET;
3944
+ const isProcessing = sellModal$.sellIsBeingProcessed.get();
3945
+ const isWaaS = wallet?.isWaaS;
3946
+ const { shouldHideActionButton: shouldHideSellButton } = useSelectWaasFeeOptions({
3947
+ chainId,
3948
+ isProcessing,
3949
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
3950
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
3951
+ });
3283
3952
  const { isLoading, executeApproval, sell } = useSell({
3284
3953
  collectionAddress,
3285
3954
  chainId,
@@ -3288,7 +3957,7 @@ var Modal4 = observer8(() => {
3288
3957
  ordersData: [
3289
3958
  {
3290
3959
  orderId: order?.orderId ?? "",
3291
- quantity: order?.quantityRemaining ? parseUnits5(
3960
+ quantity: order?.quantityRemaining ? parseUnits4(
3292
3961
  order.quantityRemaining,
3293
3962
  collectible?.decimals || 0
3294
3963
  ).toString() : "1",
@@ -3302,7 +3971,7 @@ var Modal4 = observer8(() => {
3302
3971
  });
3303
3972
  const modalLoading = collectionLoading || currencyLoading;
3304
3973
  if ((collectionError || order === void 0 || currencyError) && !modalLoading) {
3305
- return /* @__PURE__ */ jsx22(
3974
+ return /* @__PURE__ */ jsx27(
3306
3975
  ErrorModal,
3307
3976
  {
3308
3977
  isOpen: sellModal$.isOpen.get(),
@@ -3312,6 +3981,23 @@ var Modal4 = observer8(() => {
3312
3981
  }
3313
3982
  );
3314
3983
  }
3984
+ const handleSell = async () => {
3985
+ sellModal$.sellIsBeingProcessed.set(true);
3986
+ try {
3987
+ if (wallet?.isWaaS) {
3988
+ selectWaasFeeOptions$.isVisible.set(true);
3989
+ }
3990
+ await sell({
3991
+ isTransactionExecuting: wallet?.isWaaS ? !isTestnet : false
3992
+ });
3993
+ } catch (error) {
3994
+ console.error("Sell failed:", error);
3995
+ } finally {
3996
+ sellModal$.sellIsBeingProcessed.set(false);
3997
+ steps$.transaction.isExecuting.set(false);
3998
+ }
3999
+ };
4000
+ const sellCtaLabel = isProcessing ? isWaaS && !isTestnet ? "Loading fee options" : "Accept" : "Accept";
3315
4001
  const ctas = [
3316
4002
  {
3317
4003
  label: "Approve TOKEN",
@@ -3322,24 +4008,30 @@ var Modal4 = observer8(() => {
3322
4008
  disabled: isLoading || order?.quantityRemaining === "0"
3323
4009
  },
3324
4010
  {
3325
- label: "Accept",
3326
- onClick: () => sell(),
3327
- pending: steps$.transaction.isExecuting.get(),
4011
+ label: sellCtaLabel,
4012
+ onClick: () => handleSell(),
4013
+ pending: steps$?.transaction.isExecuting.get() || sellModal$.sellIsBeingProcessed.get(),
3328
4014
  disabled: isLoading || steps$.approval.isExecuting.get() || steps$.approval.exist.get() || order?.quantityRemaining === "0"
3329
4015
  }
3330
4016
  ];
3331
- return /* @__PURE__ */ jsxs14(
4017
+ const showWaasFeeOptions = wallet?.isWaaS && sellModal$.sellIsBeingProcessed.get() && feeOptionsVisible;
4018
+ return /* @__PURE__ */ jsxs20(
3332
4019
  ActionModal,
3333
4020
  {
3334
4021
  isOpen: sellModal$.isOpen.get(),
3335
4022
  chainId: Number(chainId),
3336
- onClose: sellModal$.close,
4023
+ onClose: () => {
4024
+ sellModal$.close();
4025
+ selectWaasFeeOptions$.hide();
4026
+ steps$.transaction.isExecuting.set(false);
4027
+ },
3337
4028
  title: "You have an offer",
3338
4029
  ctas,
3339
4030
  modalLoading,
3340
4031
  spinnerContainerClassname: "h-[104px]",
4032
+ hideCtas: shouldHideSellButton,
3341
4033
  children: [
3342
- /* @__PURE__ */ jsx22(
4034
+ /* @__PURE__ */ jsx27(
3343
4035
  TransactionHeader,
3344
4036
  {
3345
4037
  title: "Offer received",
@@ -3347,7 +4039,7 @@ var Modal4 = observer8(() => {
3347
4039
  date: order && new Date(order.createdAt)
3348
4040
  }
3349
4041
  ),
3350
- /* @__PURE__ */ jsx22(
4042
+ /* @__PURE__ */ jsx27(
3351
4043
  TokenPreview,
3352
4044
  {
3353
4045
  collectionName: collection?.name,
@@ -3356,7 +4048,7 @@ var Modal4 = observer8(() => {
3356
4048
  chainId
3357
4049
  }
3358
4050
  ),
3359
- /* @__PURE__ */ jsx22(
4051
+ /* @__PURE__ */ jsx27(
3360
4052
  TransactionDetails,
3361
4053
  {
3362
4054
  collectibleId: tokenId,
@@ -3369,6 +4061,17 @@ var Modal4 = observer8(() => {
3369
4061
  } : void 0,
3370
4062
  currencyImageUrl: currency?.imageUrl
3371
4063
  }
4064
+ ),
4065
+ showWaasFeeOptions && /* @__PURE__ */ jsx27(
4066
+ selectWaasFeeOptions_default,
4067
+ {
4068
+ chainId: Number(chainId),
4069
+ onCancel: () => {
4070
+ sellModal$.sellIsBeingProcessed.set(false);
4071
+ steps$.transaction.isExecuting.set(false);
4072
+ },
4073
+ titleOnConfirm: "Accepting offer..."
4074
+ }
3372
4075
  )
3373
4076
  ]
3374
4077
  }
@@ -3377,13 +4080,13 @@ var Modal4 = observer8(() => {
3377
4080
 
3378
4081
  // src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
3379
4082
  import {
3380
- Button as Button2,
4083
+ Button as Button5,
3381
4084
  ExternalLinkIcon,
3382
- Image as Image5,
4085
+ Image as Image6,
3383
4086
  Modal as Modal5,
3384
- Text as Text13
4087
+ Text as Text17
3385
4088
  } from "@0xsequence/design-system";
3386
- import { observer as observer9, use$ as use$4 } from "@legendapp/state/react";
4089
+ import { observer as observer10, use$ as use$4 } from "@legendapp/state/react";
3387
4090
 
3388
4091
  // src/react/ui/modals/SuccessfulPurchaseModal/_store.ts
3389
4092
  import { observable as observable6 } from "@legendapp/state";
@@ -3428,29 +4131,29 @@ var initialState6 = {
3428
4131
  var successfulPurchaseModal$ = observable6(initialState6);
3429
4132
 
3430
4133
  // src/react/ui/modals/SuccessfulPurchaseModal/index.tsx
3431
- import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
4134
+ import { jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
3432
4135
  var useSuccessfulPurchaseModal = (callbacks) => {
3433
4136
  return {
3434
4137
  show: (args) => successfulPurchaseModal$.open({ ...args, defaultCallbacks: callbacks }),
3435
4138
  close: () => successfulPurchaseModal$.close()
3436
4139
  };
3437
4140
  };
3438
- var SuccessfulPurchaseModal = observer9(() => {
4141
+ var SuccessfulPurchaseModal = observer10(() => {
3439
4142
  const handleClose = () => {
3440
4143
  successfulPurchaseModal$.close();
3441
4144
  };
3442
4145
  const isOpen = use$4(successfulPurchaseModal$.isOpen);
3443
4146
  if (!isOpen) return null;
3444
- return /* @__PURE__ */ jsx23(
4147
+ return /* @__PURE__ */ jsx28(
3445
4148
  Modal5,
3446
4149
  {
3447
4150
  isDismissible: true,
3448
4151
  onClose: handleClose,
3449
4152
  size: "sm",
3450
4153
  backdropColor: "backgroundBackdrop",
3451
- children: /* @__PURE__ */ jsxs15("div", { className: "flex w-full flex-col gap-4 p-6", children: [
3452
- /* @__PURE__ */ jsx23(
3453
- Text13,
4154
+ children: /* @__PURE__ */ jsxs21("div", { className: "flex w-full flex-col gap-4 p-6", children: [
4155
+ /* @__PURE__ */ jsx28(
4156
+ Text17,
3454
4157
  {
3455
4158
  className: "text-center text-large",
3456
4159
  fontWeight: "bold",
@@ -3458,27 +4161,27 @@ var SuccessfulPurchaseModal = observer9(() => {
3458
4161
  children: "Successful purchase!"
3459
4162
  }
3460
4163
  ),
3461
- /* @__PURE__ */ jsx23(
4164
+ /* @__PURE__ */ jsx28(
3462
4165
  CollectiblesGrid,
3463
4166
  {
3464
4167
  collectibles: successfulPurchaseModal$.state.get().collectibles
3465
4168
  }
3466
4169
  ),
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 })
4170
+ /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-1", children: [
4171
+ /* @__PURE__ */ jsx28(Text17, { className: "text-base", fontWeight: "medium", color: "text80", children: "You bought" }),
4172
+ /* @__PURE__ */ jsx28(Text17, { className: "text-base", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().collectibles.length }),
4173
+ /* @__PURE__ */ jsx28(Text17, { className: "text-base", fontWeight: "medium", color: "text80", children: "items for" }),
4174
+ /* @__PURE__ */ jsx28(Text17, { className: "text-base", fontWeight: "medium", color: "text100", children: successfulPurchaseModal$.state.get().totalPrice })
3472
4175
  ] }),
3473
- /* @__PURE__ */ jsx23(SuccessfulPurchaseActions, {})
4176
+ /* @__PURE__ */ jsx28(SuccessfulPurchaseActions, {})
3474
4177
  ] })
3475
4178
  }
3476
4179
  );
3477
4180
  });
3478
4181
  function SuccessfulPurchaseActions() {
3479
- return /* @__PURE__ */ jsxs15("div", { className: "flex flex-col gap-2", children: [
3480
- successfulPurchaseModal$.state.ctaOptions.get() && /* @__PURE__ */ jsx23(
3481
- Button2,
4182
+ return /* @__PURE__ */ jsxs21("div", { className: "flex flex-col gap-2", children: [
4183
+ successfulPurchaseModal$.state.ctaOptions.get() && /* @__PURE__ */ jsx28(
4184
+ Button5,
3482
4185
  {
3483
4186
  className: "w-full",
3484
4187
  shape: "square",
@@ -3487,8 +4190,8 @@ function SuccessfulPurchaseActions() {
3487
4190
  onClick: successfulPurchaseModal$.state.ctaOptions.ctaOnClick.get() || void 0
3488
4191
  }
3489
4192
  ),
3490
- /* @__PURE__ */ jsx23(
3491
- Button2,
4193
+ /* @__PURE__ */ jsx28(
4194
+ Button5,
3492
4195
  {
3493
4196
  className: "w-full",
3494
4197
  as: "a",
@@ -3505,23 +4208,23 @@ function SuccessfulPurchaseActions() {
3505
4208
  function CollectiblesGrid({ collectibles }) {
3506
4209
  const total = collectibles.length;
3507
4210
  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) => {
4211
+ 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
4212
  const showPlus = total > 4 && collectibles.indexOf(collectible) === 3;
3510
- return /* @__PURE__ */ jsxs15(
4213
+ return /* @__PURE__ */ jsxs21(
3511
4214
  "div",
3512
4215
  {
3513
4216
  className: "relative h-[150px] w-[150px]",
3514
4217
  children: [
3515
- /* @__PURE__ */ jsx23(
3516
- Image5,
4218
+ /* @__PURE__ */ jsx28(
4219
+ Image6,
3517
4220
  {
3518
4221
  className: `aspect-square h-full w-full rounded-lg bg-background-secondary object-contain ${showPlus ? "opacity-[0.4_!important]" : ""}`,
3519
4222
  src: collectible.image,
3520
4223
  alt: collectible.name
3521
4224
  }
3522
4225
  ),
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,
4226
+ 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(
4227
+ Text17,
3525
4228
  {
3526
4229
  className: "rounded-lg bg-background-secondary px-2 py-1.5 text-sm backdrop-blur-md",
3527
4230
  fontWeight: "medium",
@@ -3542,8 +4245,8 @@ var SuccessfulPurchaseModal_default = SuccessfulPurchaseModal;
3542
4245
 
3543
4246
  // src/react/ui/modals/TransferModal/index.tsx
3544
4247
  import { Modal as Modal6 } from "@0xsequence/design-system";
3545
- import { observer as observer11 } from "@legendapp/state/react";
3546
- import { useAccount as useAccount5 } from "wagmi";
4248
+ import { observer as observer16 } from "@legendapp/state/react";
4249
+ import { useAccount as useAccount7, useSwitchChain } from "wagmi";
3547
4250
 
3548
4251
  // src/react/ui/modals/TransferModal/_store.ts
3549
4252
  import { observable as observable7 } from "@legendapp/state";
@@ -3569,15 +4272,18 @@ var initialState7 = {
3569
4272
  transferModal$.state.set({
3570
4273
  ...initialState7.state
3571
4274
  });
4275
+ transferModal$.state.receiverAddress.set("");
4276
+ transferModal$.state.transferIsBeingProcessed.set(false);
3572
4277
  transferModal$.view.set("enterReceiverAddress");
3573
4278
  transferModal$.hash.set(void 0);
3574
4279
  },
3575
4280
  state: {
3576
4281
  receiverAddress: "",
3577
4282
  collectionAddress: "0x",
3578
- chainId: "",
4283
+ chainId: 0,
3579
4284
  collectibleId: "",
3580
- quantity: "1"
4285
+ quantity: "1",
4286
+ transferIsBeingProcessed: false
3581
4287
  },
3582
4288
  view: "enterReceiverAddress",
3583
4289
  hash: void 0
@@ -3585,10 +4291,10 @@ var initialState7 = {
3585
4291
  var transferModal$ = observable7(initialState7);
3586
4292
 
3587
4293
  // 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";
4294
+ import { Text as Text19 } from "@0xsequence/design-system";
4295
+ import { observer as observer14 } from "@legendapp/state/react";
4296
+ import { isAddress as isAddress2 } from "viem";
4297
+ import { useAccount as useAccount6 } from "wagmi";
3592
4298
 
3593
4299
  // src/react/ui/modals/TransferModal/messages.ts
3594
4300
  var baseMessages = {
@@ -3599,7 +4305,142 @@ function getMessage(key) {
3599
4305
  return baseMessages[key];
3600
4306
  }
3601
4307
 
4308
+ // src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TokenQuantityInput.tsx
4309
+ import { cn as cn2 } from "@0xsequence/design-system";
4310
+ import { Text as Text18 } from "@0xsequence/design-system";
4311
+ import { observable as observable8 } from "@legendapp/state";
4312
+ import { observer as observer11 } from "@legendapp/state/react";
4313
+ import { jsx as jsx29, jsxs as jsxs22 } from "react/jsx-runtime";
4314
+ var TokenQuantityInput = observer11(
4315
+ ({
4316
+ balanceAmount,
4317
+ collection,
4318
+ isProcessingWithWaaS
4319
+ }) => {
4320
+ const $quantity = transferModal$.state.quantity;
4321
+ const $invalidQuantity = observable8(false);
4322
+ let insufficientBalance = true;
4323
+ if (balanceAmount !== void 0 && $quantity.get()) {
4324
+ try {
4325
+ const quantityBigInt = BigInt($quantity.get());
4326
+ insufficientBalance = quantityBigInt > balanceAmount;
4327
+ } catch (e) {
4328
+ insufficientBalance = true;
4329
+ }
4330
+ }
4331
+ return /* @__PURE__ */ jsxs22(
4332
+ "div",
4333
+ {
4334
+ className: cn2(
4335
+ "flex flex-col gap-3",
4336
+ isProcessingWithWaaS && "pointer-events-none opacity-50"
4337
+ ),
4338
+ children: [
4339
+ /* @__PURE__ */ jsx29(
4340
+ quantityInput_default,
4341
+ {
4342
+ $quantity,
4343
+ $invalidQuantity,
4344
+ decimals: collection?.decimals || 0,
4345
+ maxQuantity: balanceAmount ? String(balanceAmount) : "0",
4346
+ 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"
4347
+ }
4348
+ ),
4349
+ /* @__PURE__ */ jsx29(
4350
+ Text18,
4351
+ {
4352
+ className: "font-body text-xs",
4353
+ color: insufficientBalance ? "negative" : "text50",
4354
+ fontWeight: "medium",
4355
+ children: `You have ${balanceAmount?.toString() || "0"} of this item`
4356
+ }
4357
+ )
4358
+ ]
4359
+ }
4360
+ );
4361
+ }
4362
+ );
4363
+ var TokenQuantityInput_default = TokenQuantityInput;
4364
+
4365
+ // src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/TransferButton.tsx
4366
+ import { getNetwork as getNetwork5 } from "@0xsequence/connect";
4367
+ import { Button as Button6, Spinner as Spinner4 } from "@0xsequence/design-system";
4368
+ import { NetworkType as NetworkType5 } from "@0xsequence/network";
4369
+ import { observer as observer12 } from "@legendapp/state/react";
4370
+ import { jsx as jsx30, jsxs as jsxs23 } from "react/jsx-runtime";
4371
+ var TransferButton = observer12(
4372
+ ({
4373
+ onClick,
4374
+ isDisabled,
4375
+ chainId
4376
+ }) => {
4377
+ const { wallet } = useWallet();
4378
+ const network = getNetwork5(chainId);
4379
+ const isWaaS = wallet?.isWaaS;
4380
+ const isTestnet = network.type === NetworkType5.TESTNET;
4381
+ const isProcessing = transferModal$.state.transferIsBeingProcessed.get();
4382
+ const label = isProcessing ? isWaaS && !isTestnet ? /* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-center gap-2", children: [
4383
+ /* @__PURE__ */ jsx30(Spinner4, { size: "sm", className: "text-white" }),
4384
+ /* @__PURE__ */ jsx30("span", { children: "Loading fee options" })
4385
+ ] }) : /* @__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: "Transferring" })
4388
+ ] }) : "Transfer";
4389
+ return /* @__PURE__ */ jsx30(
4390
+ Button6,
4391
+ {
4392
+ className: "flex justify-self-end px-10",
4393
+ onClick,
4394
+ disabled: !!isDisabled,
4395
+ title: "Transfer",
4396
+ label,
4397
+ variant: "primary",
4398
+ shape: "square",
4399
+ size: "sm"
4400
+ }
4401
+ );
4402
+ }
4403
+ );
4404
+ var TransferButton_default = TransferButton;
4405
+
4406
+ // src/react/ui/modals/TransferModal/_views/enterWalletAddress/_components/WalletAddressInput.tsx
4407
+ import { TextInput } from "@0xsequence/design-system";
4408
+ import { observer as observer13 } from "@legendapp/state/react";
4409
+ import { isAddress } from "viem";
4410
+ import { useAccount as useAccount5 } from "wagmi";
4411
+ import { jsx as jsx31, jsxs as jsxs24 } from "react/jsx-runtime";
4412
+ var MAX_WALLET_ADDRESS_LENGTH = 42;
4413
+ var WalletAddressInput = observer13(() => {
4414
+ const { address: connectedAddress } = useAccount5();
4415
+ const receiverAddress = transferModal$.state.receiverAddress.get();
4416
+ const isWalletAddressValid = isAddress(receiverAddress);
4417
+ const isProcessing = transferModal$.state.transferIsBeingProcessed.get();
4418
+ const isSelfTransfer = isWalletAddressValid && connectedAddress && receiverAddress.toLowerCase() === connectedAddress.toLowerCase();
4419
+ const handleChangeWalletAddress = (event) => {
4420
+ transferModal$.state.receiverAddress.set(event.target.value);
4421
+ };
4422
+ return /* @__PURE__ */ jsxs24("div", { className: "[&>label>div>span]:text-sm [&>label>div>span]:text-text-80 [&>label]:gap-1", children: [
4423
+ /* @__PURE__ */ jsx31(
4424
+ TextInput,
4425
+ {
4426
+ label: "Wallet address",
4427
+ labelLocation: "top",
4428
+ autoFocus: true,
4429
+ value: receiverAddress,
4430
+ maxLength: MAX_WALLET_ADDRESS_LENGTH,
4431
+ onChange: handleChangeWalletAddress,
4432
+ name: "walletAddress",
4433
+ placeholder: "Enter wallet address",
4434
+ disabled: isProcessing
4435
+ }
4436
+ ),
4437
+ isSelfTransfer && /* @__PURE__ */ jsx31("div", { className: "mt-1 text-negative text-sm", children: "You cannot transfer to your own address" })
4438
+ ] });
4439
+ });
4440
+ var WalletAddressInput_default = WalletAddressInput;
4441
+
3602
4442
  // src/react/ui/modals/TransferModal/_views/enterWalletAddress/useHandleTransfer.tsx
4443
+ import { useWaasFeeOptions as useWaasFeeOptions2 } from "@0xsequence/connect";
3603
4444
  var useHandleTransfer = () => {
3604
4445
  const {
3605
4446
  receiverAddress,
@@ -3612,29 +4453,34 @@ var useHandleTransfer = () => {
3612
4453
  } = transferModal$.state.get();
3613
4454
  const { transferTokensAsync } = useTransferTokens();
3614
4455
  const { show: showTransactionStatusModal } = useTransactionStatusModal();
4456
+ const { wallet } = useWallet();
4457
+ const [pendingFeeOptionConfirmation] = useWaasFeeOptions2();
3615
4458
  const getHash = async () => {
4459
+ const baseParams = {
4460
+ receiverAddress,
4461
+ collectionAddress,
4462
+ tokenId: collectibleId,
4463
+ chainId
4464
+ };
3616
4465
  if (collectionType === "ERC721" /* ERC721 */) {
3617
4466
  return await transferTokensAsync({
3618
- receiverAddress,
3619
- collectionAddress,
3620
- tokenId: collectibleId,
3621
- chainId,
4467
+ ...baseParams,
3622
4468
  contractType: "ERC721" /* ERC721 */
3623
4469
  });
3624
4470
  }
3625
4471
  return await transferTokensAsync({
3626
- receiverAddress,
3627
- collectionAddress,
3628
- tokenId: collectibleId,
3629
- chainId,
4472
+ ...baseParams,
3630
4473
  contractType: "ERC1155" /* ERC1155 */,
3631
4474
  quantity: String(quantity)
3632
4475
  });
3633
4476
  };
3634
- async function transfer() {
4477
+ const transfer = async () => {
3635
4478
  if (collectionType !== "ERC721" /* ERC721 */ && collectionType !== "ERC1155" /* ERC1155 */) {
3636
4479
  throw new InvalidContractTypeError(collectionType);
3637
4480
  }
4481
+ if (wallet?.isWaaS && pendingFeeOptionConfirmation) {
4482
+ return;
4483
+ }
3638
4484
  try {
3639
4485
  const hash = await getHash();
3640
4486
  transferModal$.close();
@@ -3654,30 +4500,47 @@ var useHandleTransfer = () => {
3654
4500
  transferModal$.view.set("enterReceiverAddress");
3655
4501
  callbacks?.onError?.(error);
3656
4502
  }
3657
- }
4503
+ };
3658
4504
  return { transfer };
3659
4505
  };
3660
4506
  var useHandleTransfer_default = useHandleTransfer;
3661
4507
 
3662
4508
  // 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();
4509
+ import { jsx as jsx32, jsxs as jsxs25 } from "react/jsx-runtime";
4510
+ var EnterWalletAddressView = observer14(() => {
4511
+ const { address: connectedAddress } = useAccount6();
3666
4512
  const { collectionAddress, collectibleId, chainId, collectionType } = transferModal$.state.get();
3667
4513
  const $quantity = transferModal$.state.quantity;
3668
- const $invalidQuantity = observable8(false);
3669
- const isWalletAddressValid = isAddress(
3670
- transferModal$.state.receiverAddress.get()
3671
- );
4514
+ const receiverAddress = transferModal$.state.receiverAddress.get();
4515
+ const isWalletAddressValid = isAddress2(receiverAddress);
4516
+ const {
4517
+ isWaaS,
4518
+ isProcessingWithWaaS,
4519
+ shouldHideActionButton: shouldHideTransferButton
4520
+ } = useSelectWaasFeeOptions({
4521
+ chainId,
4522
+ isProcessing: transferModal$.state.transferIsBeingProcessed.get(),
4523
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
4524
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
4525
+ });
4526
+ const isSelfTransfer = isWalletAddressValid && connectedAddress && compareAddress(receiverAddress, connectedAddress);
3672
4527
  const { data: tokenBalance } = useListBalances({
3673
- chainId: Number(chainId),
4528
+ chainId,
3674
4529
  contractAddress: collectionAddress,
3675
4530
  tokenId: collectibleId,
3676
- accountAddress: address,
3677
- query: { enabled: !!address }
4531
+ accountAddress: connectedAddress,
4532
+ query: { enabled: !!connectedAddress }
3678
4533
  });
3679
4534
  const balanceAmount = tokenBalance?.pages[0].balances[0].balance;
3680
- const insufficientBalance = balanceAmount ? $quantity.get() > balanceAmount : true;
4535
+ let insufficientBalance = true;
4536
+ if (balanceAmount !== void 0 && $quantity.get()) {
4537
+ try {
4538
+ const quantityBigInt = BigInt($quantity.get());
4539
+ insufficientBalance = quantityBigInt > BigInt(balanceAmount);
4540
+ } catch (e) {
4541
+ insufficientBalance = true;
4542
+ }
4543
+ }
3681
4544
  const { data: collection } = useCollection({
3682
4545
  collectionAddress,
3683
4546
  chainId
@@ -3686,90 +4549,75 @@ var EnterWalletAddressView = () => {
3686
4549
  collection?.type
3687
4550
  );
3688
4551
  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(
4552
+ const onTransferClick = async () => {
4553
+ transferModal$.state.transferIsBeingProcessed.set(true);
4554
+ try {
4555
+ if (!isWaaS) {
4556
+ transferModal$.view.set("followWalletInstructions");
4557
+ } else {
4558
+ selectWaasFeeOptions$.isVisible.set(true);
4559
+ }
4560
+ await transfer();
4561
+ } catch (error) {
4562
+ console.error("Transfer failed:", error);
4563
+ } finally {
4564
+ if (transferModal$.view.get() === "enterReceiverAddress") {
4565
+ transferModal$.state.transferIsBeingProcessed.set(false);
4566
+ }
4567
+ }
4568
+ };
4569
+ const isErc1155 = collectionType === "ERC1155" /* ERC1155 */;
4570
+ const showQuantityInput = isErc1155 && !!balanceAmount;
4571
+ const isProcessing = !!transferModal$.state.transferIsBeingProcessed.get();
4572
+ const isTransferDisabled = isProcessing || !isWalletAddressValid || insufficientBalance || !$quantity.get() || Number($quantity.get()) === 0 || isSelfTransfer;
4573
+ return /* @__PURE__ */ jsxs25("div", { className: "grid grow gap-6", children: [
4574
+ /* @__PURE__ */ jsx32(Text19, { className: "font-body text-xl", color: "white", fontWeight: "bold", children: "Transfer your item" }),
4575
+ /* @__PURE__ */ jsxs25("div", { className: "flex flex-col gap-3", children: [
4576
+ /* @__PURE__ */ jsx32(
3700
4577
  AlertMessage,
3701
4578
  {
3702
4579
  message: getMessage("enterReceiverAddress"),
3703
4580
  type: "warning"
3704
4581
  }
3705
4582
  ),
3706
- /* @__PURE__ */ jsx24("div", { className: "[&>label>div>span]:text-sm [&>label>div>span]:text-text-80 [&>label]:gap-1", children: /* @__PURE__ */ jsx24(
3707
- TextInput,
4583
+ /* @__PURE__ */ jsx32(WalletAddressInput_default, {}),
4584
+ showQuantityInput && /* @__PURE__ */ jsx32(
4585
+ TokenQuantityInput_default,
3708
4586
  {
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"
4587
+ balanceAmount: balanceAmount ? BigInt(balanceAmount) : void 0,
4588
+ collection,
4589
+ isProcessingWithWaaS: isProcessingWithWaaS ?? false
3716
4590
  }
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
- ] })
4591
+ )
3739
4592
  ] }),
3740
- /* @__PURE__ */ jsx24(
3741
- Button3,
4593
+ !shouldHideTransferButton && /* @__PURE__ */ jsx32(
4594
+ TransferButton_default,
3742
4595
  {
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"
4596
+ onClick: onTransferClick,
4597
+ isDisabled: isTransferDisabled,
4598
+ chainId
3751
4599
  }
3752
4600
  )
3753
4601
  ] });
3754
- };
4602
+ });
3755
4603
  var enterWalletAddress_default = EnterWalletAddressView;
3756
4604
 
3757
4605
  // 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(
4606
+ import { Button as Button7, Text as Text20 } from "@0xsequence/design-system";
4607
+ import { observer as observer15 } from "@legendapp/state/react";
4608
+ import { jsx as jsx33, jsxs as jsxs26 } from "react/jsx-runtime";
4609
+ var FollowWalletInstructionsView = observer15(() => {
4610
+ return /* @__PURE__ */ jsxs26("div", { className: "grid grow gap-6", children: [
4611
+ /* @__PURE__ */ jsx33(Text20, { className: "font-body text-xl", color: "white", fontWeight: "bold", children: "Transfer your item" }),
4612
+ /* @__PURE__ */ jsx33("div", { className: "flex flex-col gap-3", children: /* @__PURE__ */ jsx33(
3765
4613
  AlertMessage,
3766
4614
  {
3767
4615
  message: getMessage("followWalletInstructions"),
3768
4616
  type: "info"
3769
4617
  }
3770
4618
  ) }),
3771
- /* @__PURE__ */ jsx25(
3772
- Button4,
4619
+ /* @__PURE__ */ jsx33(
4620
+ Button7,
3773
4621
  {
3774
4622
  className: "flex justify-self-end px-10",
3775
4623
  disabled: true,
@@ -3785,84 +4633,113 @@ var FollowWalletInstructionsView = observer10(() => {
3785
4633
  var followWalletInstructions_default = FollowWalletInstructionsView;
3786
4634
 
3787
4635
  // src/react/ui/modals/TransferModal/index.tsx
3788
- import { jsx as jsx26 } from "react/jsx-runtime";
4636
+ import { jsx as jsx34, jsxs as jsxs27 } from "react/jsx-runtime";
3789
4637
  var useTransferModal = () => {
3790
- const { chainId: accountChainId } = useAccount5();
4638
+ const { chainId: accountChainId } = useAccount7();
3791
4639
  const { show: showSwitchNetworkModal } = useSwitchChainModal();
4640
+ const { wallet } = useWallet();
4641
+ const { switchChain } = useSwitchChain();
3792
4642
  const openModal = (args) => {
3793
4643
  transferModal$.open(args);
3794
4644
  };
3795
4645
  const handleShowModal = (args) => {
3796
- const isSameChain = accountChainId === Number(args.chainId);
4646
+ const targetChainId = Number(args.chainId);
4647
+ const isSameChain = accountChainId === targetChainId;
3797
4648
  if (!isSameChain) {
3798
- showSwitchNetworkModal({
3799
- chainIdToSwitchTo: Number(args.chainId),
3800
- onSuccess: () => openModal(args)
3801
- });
4649
+ if (wallet?.isWaaS) {
4650
+ switchChain({ chainId: targetChainId });
4651
+ openModal(args);
4652
+ } else {
4653
+ showSwitchNetworkModal({
4654
+ chainIdToSwitchTo: targetChainId,
4655
+ onSuccess: () => openModal(args)
4656
+ });
4657
+ }
3802
4658
  return;
3803
4659
  }
3804
4660
  openModal(args);
3805
4661
  };
4662
+ const updateCallbacks = (callbacks) => {
4663
+ transferModal$.state.set({
4664
+ ...transferModal$.state.get(),
4665
+ callbacks
4666
+ });
4667
+ };
3806
4668
  return {
3807
4669
  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
- }
4670
+ close: transferModal$.close,
4671
+ onError: updateCallbacks,
4672
+ onSuccess: updateCallbacks
3821
4673
  };
3822
4674
  };
3823
- var TransferModal = observer11(() => {
4675
+ var TransactionModalView = observer16(() => {
4676
+ const { view } = transferModal$.get();
4677
+ switch (view) {
4678
+ case "enterReceiverAddress":
4679
+ return /* @__PURE__ */ jsx34(enterWalletAddress_default, {});
4680
+ case "followWalletInstructions":
4681
+ return /* @__PURE__ */ jsx34(followWalletInstructions_default, {});
4682
+ default:
4683
+ return null;
4684
+ }
4685
+ });
4686
+ var TransferModal = observer16(() => {
3824
4687
  const isOpen = transferModal$.isOpen.get();
4688
+ const chainId = transferModal$.state.chainId.get();
4689
+ const isTransferBeingProcessed = transferModal$.state.transferIsBeingProcessed.get();
4690
+ const { waasFeeOptionsShown } = useSelectWaasFeeOptions({
4691
+ chainId,
4692
+ isProcessing: isTransferBeingProcessed,
4693
+ feeOptionsVisible: selectWaasFeeOptions$.isVisible.get(),
4694
+ selectedFeeOption: selectWaasFeeOptions$.selectedFeeOption.get()
4695
+ });
3825
4696
  if (!isOpen) return null;
3826
- return /* @__PURE__ */ jsx26(
4697
+ return /* @__PURE__ */ jsxs27(
3827
4698
  Modal6,
3828
4699
  {
3829
4700
  isDismissible: true,
3830
- onClose: transferModal$.close,
4701
+ onClose: () => {
4702
+ transferModal$.close();
4703
+ selectWaasFeeOptions$.hide();
4704
+ },
3831
4705
  size: "sm",
3832
4706
  overlayProps: MODAL_OVERLAY_PROPS,
3833
4707
  contentProps: {
3834
4708
  style: {
3835
- height: "auto"
4709
+ height: "auto",
4710
+ overflow: "auto"
3836
4711
  }
3837
4712
  },
3838
- children: /* @__PURE__ */ jsx26("div", { className: "flex w-full flex-col p-7", children: /* @__PURE__ */ jsx26(TransactionModalView, {}) })
4713
+ children: [
4714
+ /* @__PURE__ */ jsx34("div", { className: "flex w-full flex-col p-7", children: /* @__PURE__ */ jsx34(TransactionModalView, {}) }),
4715
+ waasFeeOptionsShown && /* @__PURE__ */ jsx34(
4716
+ selectWaasFeeOptions_default,
4717
+ {
4718
+ chainId: Number(chainId),
4719
+ onCancel: () => {
4720
+ transferModal$.state.transferIsBeingProcessed.set(false);
4721
+ },
4722
+ titleOnConfirm: "Processing transfer...",
4723
+ className: "p-7 pt-0"
4724
+ }
4725
+ )
4726
+ ]
3839
4727
  }
3840
4728
  );
3841
4729
  });
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
4730
 
3854
4731
  // 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, {})
4732
+ import { Fragment as Fragment3, jsx as jsx35, jsxs as jsxs28 } from "react/jsx-runtime";
4733
+ var ModalProvider = observer17(() => {
4734
+ return /* @__PURE__ */ jsxs28(Fragment3, { children: [
4735
+ /* @__PURE__ */ jsx35(CreateListingModal, {}),
4736
+ /* @__PURE__ */ jsx35(MakeOfferModal, {}),
4737
+ /* @__PURE__ */ jsx35(TransferModal, {}),
4738
+ /* @__PURE__ */ jsx35(SellModal, {}),
4739
+ /* @__PURE__ */ jsx35(BuyModal, {}),
4740
+ /* @__PURE__ */ jsx35(SuccessfulPurchaseModal_default, {}),
4741
+ /* @__PURE__ */ jsx35(switchChainModal_default, {}),
4742
+ /* @__PURE__ */ jsx35(transactionStatusModal_default, {})
3866
4743
  ] });
3867
4744
  });
3868
4745
 
@@ -3888,24 +4765,16 @@ var useSellModal = (callbacks) => {
3888
4765
  };
3889
4766
  };
3890
4767
 
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
4768
  // src/react/ui/components/collectible-card/CollectibleCard.tsx
3900
- import { Skeleton as Skeleton9 } from "@0xsequence/design-system";
4769
+ import { Skeleton as Skeleton11 } from "@0xsequence/design-system";
3901
4770
 
3902
4771
  // src/react/ui/components/_internals/action-button/ActionButton.tsx
3903
- import { observer as observer13 } from "@legendapp/state/react";
4772
+ import { observer as observer18 } from "@legendapp/state/react";
3904
4773
 
3905
4774
  // src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx
3906
4775
  import { useOpenConnectModal } from "@0xsequence/connect";
3907
- import { Button as Button5 } from "@0xsequence/design-system";
3908
- import { useAccount as useAccount6 } from "wagmi";
4776
+ import { Button as Button8 } from "@0xsequence/design-system";
4777
+ import { useAccount as useAccount8 } from "wagmi";
3909
4778
 
3910
4779
  // src/react/ui/components/_internals/action-button/store.ts
3911
4780
  import { observable as observable9 } from "@legendapp/state";
@@ -3934,7 +4803,7 @@ var executePendingActionIfExists = () => {
3934
4803
  };
3935
4804
 
3936
4805
  // src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx
3937
- import { jsx as jsx28 } from "react/jsx-runtime";
4806
+ import { jsx as jsx36 } from "react/jsx-runtime";
3938
4807
  function ActionButtonBody({
3939
4808
  tokenId,
3940
4809
  label,
@@ -3942,7 +4811,7 @@ function ActionButtonBody({
3942
4811
  icon,
3943
4812
  action
3944
4813
  }) {
3945
- const { address } = useAccount6();
4814
+ const { address } = useAccount8();
3946
4815
  const { setOpenConnectModal } = useOpenConnectModal();
3947
4816
  const handleClick = (e) => {
3948
4817
  e.preventDefault();
@@ -3954,8 +4823,8 @@ function ActionButtonBody({
3954
4823
  onClick();
3955
4824
  }
3956
4825
  };
3957
- return /* @__PURE__ */ jsx28(
3958
- Button5,
4826
+ return /* @__PURE__ */ jsx36(
4827
+ Button8,
3959
4828
  {
3960
4829
  className: "flex w-full items-center justify-center",
3961
4830
  variant: "primary",
@@ -3969,7 +4838,7 @@ function ActionButtonBody({
3969
4838
  }
3970
4839
 
3971
4840
  // src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx
3972
- import { jsx as jsx29 } from "react/jsx-runtime";
4841
+ import { jsx as jsx37 } from "react/jsx-runtime";
3973
4842
  function NonOwnerActions({
3974
4843
  action,
3975
4844
  tokenId,
@@ -3984,7 +4853,7 @@ function NonOwnerActions({
3984
4853
  if (!lowestListing) {
3985
4854
  throw new InvalidStepError("BUY", "lowestListing is required");
3986
4855
  }
3987
- return /* @__PURE__ */ jsx29(
4856
+ return /* @__PURE__ */ jsx37(
3988
4857
  ActionButtonBody,
3989
4858
  {
3990
4859
  action: "Buy" /* BUY */,
@@ -3993,15 +4862,16 @@ function NonOwnerActions({
3993
4862
  onClick: () => showBuyModal({
3994
4863
  collectionAddress,
3995
4864
  chainId,
3996
- tokenId,
3997
- order: lowestListing
4865
+ collectibleId: tokenId,
4866
+ orderId: lowestListing.orderId,
4867
+ marketplace: lowestListing.marketplace
3998
4868
  }),
3999
4869
  icon: CartIcon_default
4000
4870
  }
4001
4871
  );
4002
4872
  }
4003
4873
  if (action === "Make an offer" /* OFFER */) {
4004
- return /* @__PURE__ */ jsx29(
4874
+ return /* @__PURE__ */ jsx37(
4005
4875
  ActionButtonBody,
4006
4876
  {
4007
4877
  action: "Make an offer" /* OFFER */,
@@ -4020,7 +4890,7 @@ function NonOwnerActions({
4020
4890
  }
4021
4891
 
4022
4892
  // src/react/ui/components/_internals/action-button/components/OwnerActions.tsx
4023
- import { jsx as jsx30 } from "react/jsx-runtime";
4893
+ import { jsx as jsx38 } from "react/jsx-runtime";
4024
4894
  function OwnerActions({
4025
4895
  action,
4026
4896
  tokenId,
@@ -4033,7 +4903,7 @@ function OwnerActions({
4033
4903
  const { show: showSellModal } = useSellModal();
4034
4904
  const { show: showTransferModal } = useTransferModal();
4035
4905
  if (action === "Create listing" /* LIST */) {
4036
- return /* @__PURE__ */ jsx30(
4906
+ return /* @__PURE__ */ jsx38(
4037
4907
  ActionButtonBody,
4038
4908
  {
4039
4909
  label: "Create listing",
@@ -4048,7 +4918,7 @@ function OwnerActions({
4048
4918
  );
4049
4919
  }
4050
4920
  if (action === "Sell" /* SELL */ && highestOffer) {
4051
- return /* @__PURE__ */ jsx30(
4921
+ return /* @__PURE__ */ jsx38(
4052
4922
  ActionButtonBody,
4053
4923
  {
4054
4924
  tokenId,
@@ -4063,7 +4933,7 @@ function OwnerActions({
4063
4933
  );
4064
4934
  }
4065
4935
  if (action === "Transfer" /* TRANSFER */) {
4066
- return /* @__PURE__ */ jsx30(
4936
+ return /* @__PURE__ */ jsx38(
4067
4937
  ActionButtonBody,
4068
4938
  {
4069
4939
  label: "Transfer",
@@ -4080,21 +4950,21 @@ function OwnerActions({
4080
4950
  }
4081
4951
 
4082
4952
  // src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts
4083
- import { useEffect as useEffect9 } from "react";
4084
- import { useAccount as useAccount7 } from "wagmi";
4953
+ import { useEffect as useEffect11 } from "react";
4954
+ import { useAccount as useAccount9 } from "wagmi";
4085
4955
  var useActionButtonLogic = ({
4086
4956
  tokenId,
4087
4957
  owned,
4088
4958
  action,
4089
4959
  onCannotPerformAction
4090
4960
  }) => {
4091
- const { address } = useAccount7();
4961
+ const { address } = useAccount9();
4092
4962
  const actionsThatOwnersCannotPerform = [
4093
4963
  "Buy" /* BUY */,
4094
4964
  "Make an offer" /* OFFER */
4095
4965
  ];
4096
4966
  const pendingActionType = actionButtonStore.pendingAction.type.get();
4097
- useEffect9(() => {
4967
+ useEffect11(() => {
4098
4968
  if (owned && actionButtonStore.pendingAction.get() && address && !actionsThatOwnersCannotPerform.includes(action) && actionButtonStore.pendingAction.get()?.collectibleId === tokenId) {
4099
4969
  onCannotPerformAction?.(
4100
4970
  pendingActionType
@@ -4110,7 +4980,7 @@ var useActionButtonLogic = ({
4110
4980
  onCannotPerformAction,
4111
4981
  pendingActionType
4112
4982
  ]);
4113
- useEffect9(() => {
4983
+ useEffect11(() => {
4114
4984
  if (address && !owned && actionButtonStore.pendingAction.get() && actionButtonStore.pendingAction.get()?.collectibleId === tokenId) {
4115
4985
  setTimeout(() => {
4116
4986
  executePendingActionIfExists();
@@ -4132,8 +5002,8 @@ var useActionButtonLogic = ({
4132
5002
  };
4133
5003
 
4134
5004
  // src/react/ui/components/_internals/action-button/ActionButton.tsx
4135
- import { jsx as jsx31 } from "react/jsx-runtime";
4136
- var ActionButton = observer13(
5005
+ import { jsx as jsx39 } from "react/jsx-runtime";
5006
+ var ActionButton = observer18(
4137
5007
  ({
4138
5008
  collectionAddress,
4139
5009
  chainId,
@@ -4155,7 +5025,7 @@ var ActionButton = observer13(
4155
5025
  return null;
4156
5026
  }
4157
5027
  if (isOwnerAction) {
4158
- return /* @__PURE__ */ jsx31(
5028
+ return /* @__PURE__ */ jsx39(
4159
5029
  OwnerActions,
4160
5030
  {
4161
5031
  action,
@@ -4167,7 +5037,7 @@ var ActionButton = observer13(
4167
5037
  }
4168
5038
  );
4169
5039
  }
4170
- return /* @__PURE__ */ jsx31(
5040
+ return /* @__PURE__ */ jsx39(
4171
5041
  NonOwnerActions,
4172
5042
  {
4173
5043
  action,
@@ -4182,12 +5052,12 @@ var ActionButton = observer13(
4182
5052
  );
4183
5053
 
4184
5054
  // 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";
5055
+ import { Skeleton as Skeleton10 } from "@0xsequence/design-system";
5056
+ import { useEffect as useEffect12, useRef as useRef2, useState as useState10 } from "react";
5057
+ import { jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
4188
5058
  function CollectibleAssetSkeleton() {
4189
- return /* @__PURE__ */ jsx32(
4190
- Skeleton8,
5059
+ return /* @__PURE__ */ jsx40(
5060
+ Skeleton10,
4191
5061
  {
4192
5062
  size: "lg",
4193
5063
  className: "absolute inset-0 h-full w-full animate-shimmer",
@@ -4210,14 +5080,14 @@ function CollectibleAsset({
4210
5080
  collectibleMetadata,
4211
5081
  assetSrcPrefixUrl
4212
5082
  }) {
4213
- const [assetLoadFailed, setAssetLoadFailed] = useState8(false);
4214
- const [assetLoading, setAssetLoading] = useState8(true);
5083
+ const [assetLoadFailed, setAssetLoadFailed] = useState10(false);
5084
+ const [assetLoading, setAssetLoading] = useState10(true);
4215
5085
  const videoRef = useRef2(null);
4216
5086
  const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
4217
5087
  const placeholderImage = chess_tile_default;
4218
5088
  const assetUrl = collectibleMetadata?.image || collectibleMetadata?.video || collectibleMetadata?.animation_url || collectibleMetadata?.assets?.[0]?.url || placeholderImage;
4219
5089
  const proxiedAssetUrl = assetSrcPrefixUrl ? `${assetSrcPrefixUrl}${assetUrl}` : assetUrl;
4220
- useEffect10(() => {
5090
+ useEffect12(() => {
4221
5091
  if (videoRef.current) {
4222
5092
  videoRef.current.addEventListener("loadedmetadata", () => {
4223
5093
  setAssetLoading(false);
@@ -4225,9 +5095,9 @@ function CollectibleAsset({
4225
5095
  }
4226
5096
  }, []);
4227
5097
  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(
5098
+ return /* @__PURE__ */ jsxs29("div", { className: "flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
5099
+ assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5100
+ /* @__PURE__ */ jsx40(
4231
5101
  "iframe",
4232
5102
  {
4233
5103
  title: name || "Collectible",
@@ -4245,9 +5115,9 @@ function CollectibleAsset({
4245
5115
  ] });
4246
5116
  }
4247
5117
  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(
5118
+ return /* @__PURE__ */ jsxs29("div", { className: "relative flex aspect-square w-full items-center justify-center overflow-hidden rounded-lg bg-background-secondary", children: [
5119
+ assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5120
+ /* @__PURE__ */ jsx40(
4251
5121
  "video",
4252
5122
  {
4253
5123
  ref: videoRef,
@@ -4265,14 +5135,14 @@ function CollectibleAsset({
4265
5135
  onError: () => {
4266
5136
  setAssetLoadFailed(true);
4267
5137
  },
4268
- children: /* @__PURE__ */ jsx32("source", { src: proxiedAssetUrl })
5138
+ children: /* @__PURE__ */ jsx40("source", { src: proxiedAssetUrl })
4269
5139
  }
4270
5140
  )
4271
5141
  ] });
4272
5142
  }
4273
- return /* @__PURE__ */ jsxs19("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: [
4274
- assetLoading && /* @__PURE__ */ jsx32(CollectibleAssetSkeleton, {}),
4275
- /* @__PURE__ */ jsx32(
5143
+ return /* @__PURE__ */ jsxs29("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: [
5144
+ assetLoading && /* @__PURE__ */ jsx40(CollectibleAssetSkeleton, {}),
5145
+ /* @__PURE__ */ jsx40(
4276
5146
  "img",
4277
5147
  {
4278
5148
  src: assetLoadFailed ? placeholderImage : proxiedAssetUrl,
@@ -4290,26 +5160,26 @@ import {
4290
5160
  ChevronLeftIcon,
4291
5161
  ChevronRightIcon,
4292
5162
  IconButton as IconButton2,
4293
- Image as Image6,
4294
- Text as Text16
5163
+ Image as Image7,
5164
+ Text as Text21
4295
5165
  } from "@0xsequence/design-system";
4296
- import { formatUnits as formatUnits7 } from "viem";
4297
- import { jsx as jsx33, jsxs as jsxs20 } from "react/jsx-runtime";
5166
+ import { formatUnits as formatUnits9 } from "viem";
5167
+ import { jsx as jsx41, jsxs as jsxs30 } from "react/jsx-runtime";
4298
5168
  var OVERFLOW_PRICE = 1e8;
4299
5169
  var UNDERFLOW_PRICE = 1e-4;
4300
5170
  var formatPrice = (amount, currency) => {
4301
- const formattedPrice = formatUnits7(BigInt(amount), currency.decimals);
5171
+ const formattedPrice = formatUnits9(BigInt(amount), currency.decimals);
4302
5172
  const numericPrice = Number.parseFloat(formattedPrice);
4303
5173
  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}` })
5174
+ return /* @__PURE__ */ jsxs30("div", { className: "flex items-center", children: [
5175
+ /* @__PURE__ */ jsx41(ChevronLeftIcon, { className: "h-3 w-3 text-text-100" }),
5176
+ /* @__PURE__ */ jsx41(Text21, { children: `${UNDERFLOW_PRICE} ${currency.symbol}` })
4307
5177
  ] });
4308
5178
  }
4309
5179
  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", {
5180
+ return /* @__PURE__ */ jsxs30("div", { className: "flex items-center", children: [
5181
+ /* @__PURE__ */ jsx41(ChevronRightIcon, { className: "h-3 w-3 text-text-100" }),
5182
+ /* @__PURE__ */ jsx41(Text21, { children: `${OVERFLOW_PRICE.toLocaleString("en-US", {
4313
5183
  maximumFractionDigits: 2
4314
5184
  })} ${currency.symbol}` })
4315
5185
  ] });
@@ -4319,7 +5189,7 @@ var formatPrice = (amount, currency) => {
4319
5189
  minimumFractionDigits: 0,
4320
5190
  maximumFractionDigits: maxDecimals
4321
5191
  });
4322
- return /* @__PURE__ */ jsx33("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs20(Text16, { children: [
5192
+ return /* @__PURE__ */ jsx41("div", { className: "flex items-center gap-1", children: /* @__PURE__ */ jsxs30(Text21, { children: [
4323
5193
  formattedNumber,
4324
5194
  " ",
4325
5195
  currency.symbol
@@ -4342,10 +5212,10 @@ var Footer = ({
4342
5212
  if (name.length > 17 && !highestOffer) {
4343
5213
  name = `${name.substring(0, 17)}...`;
4344
5214
  }
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(
5215
+ return /* @__PURE__ */ jsxs30("div", { className: "relative flex flex-col items-start gap-2 whitespace-nowrap bg-background-primary p-4", children: [
5216
+ /* @__PURE__ */ jsxs30("div", { className: "relative flex w-full items-center justify-between", children: [
5217
+ /* @__PURE__ */ jsx41(Text21, { className: "text-left font-body font-bold text-sm text-text-100", children: name || "Untitled" }),
5218
+ highestOffer && onOfferClick && /* @__PURE__ */ jsx41(
4349
5219
  IconButton2,
4350
5220
  {
4351
5221
  className: "absolute top-0 right-0 h-[22px] w-[22px] hover:animate-bell-ring",
@@ -4354,13 +5224,13 @@ var Footer = ({
4354
5224
  onClick: (e) => {
4355
5225
  onOfferClick?.(e);
4356
5226
  },
4357
- icon: (props) => /* @__PURE__ */ jsx33(BellIcon_default, { ...props, size: "xs" })
5227
+ icon: (props) => /* @__PURE__ */ jsx41(BellIcon_default, { ...props, size: "xs" })
4358
5228
  }
4359
5229
  )
4360
5230
  ] }),
4361
- /* @__PURE__ */ jsxs20("div", { className: "flex items-center gap-1", children: [
4362
- listed && lowestListingCurrency.imageUrl && /* @__PURE__ */ jsx33(
4363
- Image6,
5231
+ /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-1", children: [
5232
+ listed && lowestListingCurrency.imageUrl && /* @__PURE__ */ jsx41(
5233
+ Image7,
4364
5234
  {
4365
5235
  className: "h-3 w-3",
4366
5236
  src: lowestListingCurrency.imageUrl,
@@ -4369,8 +5239,8 @@ var Footer = ({
4369
5239
  }
4370
5240
  }
4371
5241
  ),
4372
- /* @__PURE__ */ jsxs20(
4373
- Text16,
5242
+ /* @__PURE__ */ jsxs30(
5243
+ Text21,
4374
5244
  {
4375
5245
  className: `text-left font-body font-bold text-sm ${listed ? "text-text-100" : "text-text-50"}`,
4376
5246
  children: [
@@ -4380,7 +5250,7 @@ var Footer = ({
4380
5250
  }
4381
5251
  )
4382
5252
  ] }),
4383
- /* @__PURE__ */ jsx33(
5253
+ /* @__PURE__ */ jsx41(
4384
5254
  TokenTypeBalancePill,
4385
5255
  {
4386
5256
  balance,
@@ -4395,16 +5265,16 @@ var TokenTypeBalancePill = ({
4395
5265
  type,
4396
5266
  decimals
4397
5267
  }) => {
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 });
5268
+ const displayText = type === "ERC1155" /* ERC1155 */ ? balance ? `Owned: ${formatUnits9(BigInt(balance), decimals ?? 0)}` : "ERC-1155" : "ERC-721";
5269
+ 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
5270
  };
4401
5271
 
4402
5272
  // src/react/ui/components/collectible-card/CollectibleCard.tsx
4403
- import { jsx as jsx34, jsxs as jsxs21 } from "react/jsx-runtime";
5273
+ import { jsx as jsx42, jsxs as jsxs31 } from "react/jsx-runtime";
4404
5274
  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,
5275
+ 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: [
5276
+ /* @__PURE__ */ jsx42("div", { className: "relative aspect-square overflow-hidden bg-background-secondary", children: /* @__PURE__ */ jsx42(
5277
+ Skeleton11,
4408
5278
  {
4409
5279
  size: "lg",
4410
5280
  className: "absolute inset-0 h-full w-full animate-shimmer",
@@ -4413,9 +5283,9 @@ function CollectibleSkeleton() {
4413
5283
  }
4414
5284
  }
4415
5285
  ) }),
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" })
5286
+ /* @__PURE__ */ jsxs31("div", { className: "mt-2 flex flex-col gap-2 px-4 pb-4", children: [
5287
+ /* @__PURE__ */ jsx42(Skeleton11, { size: "lg", className: "animate-shimmer" }),
5288
+ /* @__PURE__ */ jsx42(Skeleton11, { size: "sm", className: "animate-shimmer" })
4419
5289
  ] })
4420
5290
  ] });
4421
5291
  }
@@ -4443,10 +5313,10 @@ function CollectibleCard({
4443
5313
  }
4444
5314
  });
4445
5315
  if (cardLoading) {
4446
- return /* @__PURE__ */ jsx34(CollectibleSkeleton, {});
5316
+ return /* @__PURE__ */ jsx42(CollectibleSkeleton, {});
4447
5317
  }
4448
5318
  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(
5319
+ return /* @__PURE__ */ jsx42(
4450
5320
  "div",
4451
5321
  {
4452
5322
  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 +5326,8 @@ function CollectibleCard({
4456
5326
  onCollectibleClick?.(collectibleId);
4457
5327
  }
4458
5328
  },
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(
5329
+ 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: [
5330
+ /* @__PURE__ */ jsx42(
4461
5331
  CollectibleAsset,
4462
5332
  {
4463
5333
  name: collectibleMetadata?.name || "",
@@ -4465,7 +5335,7 @@ function CollectibleCard({
4465
5335
  assetSrcPrefixUrl
4466
5336
  }
4467
5337
  ),
4468
- /* @__PURE__ */ jsx34(
5338
+ /* @__PURE__ */ jsx42(
4469
5339
  Footer,
4470
5340
  {
4471
5341
  name: collectibleMetadata?.name || "",
@@ -4478,10 +5348,10 @@ function CollectibleCard({
4478
5348
  decimals: collectibleMetadata?.decimals
4479
5349
  }
4480
5350
  ),
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(
5351
+ (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
5352
  ActionButton,
4483
5353
  {
4484
- chainId: String(chainId),
5354
+ chainId,
4485
5355
  collectionAddress,
4486
5356
  tokenId: collectibleId,
4487
5357
  orderbookKind,
@@ -4498,13 +5368,13 @@ function CollectibleCard({
4498
5368
  }
4499
5369
 
4500
5370
  export {
5371
+ useBuyModal,
4501
5372
  useSuccessfulPurchaseModal,
4502
5373
  useTransferModal,
4503
5374
  ModalProvider,
4504
5375
  useCreateListingModal,
4505
5376
  useMakeOfferModal,
4506
5377
  useSellModal,
4507
- useBuyModal,
4508
5378
  CollectibleCard
4509
5379
  };
4510
- //# sourceMappingURL=chunk-HTFORA4Q.js.map
5380
+ //# sourceMappingURL=chunk-SBI52HTX.js.map