@0xsequence/marketplace-sdk 1.0.0 → 1.1.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 (304) hide show
  1. package/.storybook/main.ts +1 -1
  2. package/.storybook/preview.tsx +0 -1
  3. package/CHANGELOG.md +62 -13
  4. package/dist/BellIcon-IpHHEy8h.js +45 -0
  5. package/dist/BellIcon-IpHHEy8h.js.map +1 -0
  6. package/dist/{BellIcon-Cb9YEUzJ.js → CartIcon-C8zbor8H.js} +10 -49
  7. package/dist/CartIcon-C8zbor8H.js.map +1 -0
  8. package/dist/CollectibleCard-C2EWF0zo.d.ts +8 -0
  9. package/dist/{_internal-DslqcNC1.js → _internal-DkS2VUn5.js} +1 -1
  10. package/dist/{_internal-DslqcNC1.js.map → _internal-DkS2VUn5.js.map} +1 -1
  11. package/dist/{alien_swap-DJ98gZQp.js → alien_swap-BTJ7mSR-.js} +1 -1
  12. package/dist/{alien_swap-DJ98gZQp.js.map → alien_swap-BTJ7mSR-.js.map} +1 -1
  13. package/dist/{api-BmEQfSQa.js → api-DuLKn__v.js} +5 -3
  14. package/dist/api-DuLKn__v.js.map +1 -0
  15. package/dist/{aqua-xyz-n1PcCCZ0.js → aqua-xyz-BYJ9WSP_.js} +1 -1
  16. package/dist/{aqua-xyz-n1PcCCZ0.js.map → aqua-xyz-BYJ9WSP_.js.map} +1 -1
  17. package/dist/{aura-Bevk_YkS.js → aura-D7SUjgro.js} +1 -1
  18. package/dist/{aura-Bevk_YkS.js.map → aura-D7SUjgro.js.map} +1 -1
  19. package/dist/{blur-B5sHErx5.js → blur-BcnRFCaV.js} +1 -1
  20. package/dist/{blur-B5sHErx5.js.map → blur-BcnRFCaV.js.map} +1 -1
  21. package/dist/builder-api-BFuZNOaN.js.map +1 -1
  22. package/dist/builder.gen-B9wR2nvF.js.map +1 -1
  23. package/dist/{coinbase-D30W-lxA.js → coinbase-ChoX9Hw2.js} +1 -1
  24. package/dist/{coinbase-D30W-lxA.js.map → coinbase-ChoX9Hw2.js.map} +1 -1
  25. package/dist/components-CUv-wQr8.js +119 -0
  26. package/dist/components-CUv-wQr8.js.map +1 -0
  27. package/dist/{contracts-DPHFT2TA.js → contracts-D72LBOX3.js} +4 -5
  28. package/dist/{contracts-DPHFT2TA.js.map → contracts-D72LBOX3.js.map} +1 -1
  29. package/dist/{create-config-6uynwTeb.js → create-config-CIfejoCk.js} +6 -11
  30. package/dist/create-config-CIfejoCk.js.map +1 -0
  31. package/dist/{create-config-lLSrnkbb.d.ts → create-config-DV_dtaLt.d.ts} +24 -31
  32. package/dist/{element-C2NJexro.js → element-Dbcv5qya.js} +1 -1
  33. package/dist/{element-C2NJexro.js.map → element-Dbcv5qya.js.map} +1 -1
  34. package/dist/{filters-B8XS4tFH.d.ts → filters-zkMJaPey.d.ts} +6 -6
  35. package/dist/{foundation-QgY1lvUj.js → foundation-QPhUEUy8.js} +1 -1
  36. package/dist/{foundation-QgY1lvUj.js.map → foundation-QPhUEUy8.js.map} +1 -1
  37. package/dist/{index-ChSKFOMx.d.ts → index-B6aSbaw2.d.ts} +1 -1
  38. package/dist/{index-PSPpUxCE.d.ts → index-B8vaT3_s.d.ts} +4 -4
  39. package/dist/{index-DonXiSg2.d.ts → index-BaytncQc.d.ts} +100 -56
  40. package/dist/{index-CY5UEX4h.d.ts → index-BoNNplSx.d.ts} +2 -2
  41. package/dist/{index-QxxS6f9r.d.ts → index-Bv5XVLjH.d.ts} +1 -1
  42. package/dist/{index-CIkpYltz.d.ts → index-C768pAfu.d.ts} +3 -3
  43. package/dist/{index-DX0Vm8HY.d.ts → index-CM0ZTePs.d.ts} +1 -1
  44. package/dist/index-CMPUveNz.d.ts +64 -0
  45. package/dist/{index-ThUIs-Sy.d.ts → index-CQecU53t.d.ts} +28 -23
  46. package/dist/{index-CtF7EE2z.d.ts → index-CT8ZorFd.d.ts} +1 -1
  47. package/dist/{index-Dpyp7fQz.d.ts → index-CXscCUg7.d.ts} +12 -12
  48. package/dist/{index-ByW08-Z7.d.ts → index-D-UXGo5d.d.ts} +2 -2
  49. package/dist/{index-D71J5Ghd.d.ts → index-D6YMj82n.d.ts} +79 -79
  50. package/dist/{index-CQnGIGb5.d.ts → index-DJG0kiII.d.ts} +33 -33
  51. package/dist/{index-D2HohSwO.d.ts → index-DLUjc7Bx.d.ts} +52 -29
  52. package/dist/{index-C7xKVIr4.d.ts → index-DMBMM16q.d.ts} +37 -37
  53. package/dist/{index-DNU9xoGK.d.ts → index-DpeWm_vF.d.ts} +5 -5
  54. package/dist/{index-BuY_NKSX.d.ts → index-Yobo6icm.d.ts} +40 -28
  55. package/dist/{index-BGJXqdg6.d.ts → index-jGgfEHfQ.d.ts} +8 -8
  56. package/dist/index.d.ts +8 -8
  57. package/dist/index.js +12 -11
  58. package/dist/{listCollectiblesPaginated--AgXjajA.d.ts → listCollectiblesPaginated-Bq0QSOjJ.d.ts} +28 -26
  59. package/dist/{listCollections-Bbzbz7qW.d.ts → listCollections-dTCq00l5.d.ts} +168 -123
  60. package/dist/{looks-rare-CMVPny4v.js → looks-rare-C7cQztTR.js} +1 -1
  61. package/dist/{looks-rare-CMVPny4v.js.map → looks-rare-C7cQztTR.js.map} +1 -1
  62. package/dist/{lowestListing-BQHfQpfg.d.ts → lowestListing-CB5Te-Q9.d.ts} +41 -17
  63. package/dist/{magic-eden-IrWp2ZXk.js → magic-eden-D3r7jiBG.js} +1 -1
  64. package/dist/{magic-eden-IrWp2ZXk.js.map → magic-eden-D3r7jiBG.js.map} +1 -1
  65. package/dist/{manifold-DeOE-p2G.js → manifold-DsX0CBP-.js} +1 -1
  66. package/dist/{manifold-DeOE-p2G.js.map → manifold-DsX0CBP-.js.map} +1 -1
  67. package/dist/{marketCurrencies-CmOMCCOr.d.ts → marketCurrencies-Bzj8X4TL.d.ts} +8 -8
  68. package/dist/{marketplace-B5Z8G03R.js → marketplace-BYY8OloA.js} +1 -1
  69. package/dist/{marketplace-B5Z8G03R.js.map → marketplace-BYY8OloA.js.map} +1 -1
  70. package/dist/{marketplace-logos-D8t86gsW.js → marketplace-logos-Csv2MBwf.js} +21 -21
  71. package/dist/marketplace-logos-Csv2MBwf.js.map +1 -0
  72. package/dist/{marketplace.gen-JzNYpM0U.js → marketplace.gen-w2YvbEEo.js} +2 -2
  73. package/dist/marketplace.gen-w2YvbEEo.js.map +1 -0
  74. package/dist/{marketplaceConfig-sNh-MA5M.js → marketplaceConfig-BTy75Mbf.js} +8 -9
  75. package/dist/marketplaceConfig-BTy75Mbf.js.map +1 -0
  76. package/dist/{mintify-DG3GrljJ.js → mintify-DiOoDmO1.js} +1 -1
  77. package/dist/{mintify-DG3GrljJ.js.map → mintify-DiOoDmO1.js.map} +1 -1
  78. package/dist/{network-DnBEe1Ur.js → network-DtmiMhcg.js} +2 -2
  79. package/dist/network-DtmiMhcg.js.map +1 -0
  80. package/dist/networkconfigToWagmiChain-DbUf6HiO.js +15 -0
  81. package/dist/networkconfigToWagmiChain-DbUf6HiO.js.map +1 -0
  82. package/dist/{nftx-B3LH-ZYM.js → nftx-CP82jNra.js} +1 -1
  83. package/dist/{nftx-B3LH-ZYM.js.map → nftx-CP82jNra.js.map} +1 -1
  84. package/dist/{okx-CRFLrT3Z.js → okx-p9-4xRjs.js} +1 -1
  85. package/dist/{okx-CRFLrT3Z.js.map → okx-p9-4xRjs.js.map} +1 -1
  86. package/dist/{open-sea-cOpfl366.js → open-sea-D2GwAmKS.js} +1 -1
  87. package/dist/{open-sea-cOpfl366.js.map → open-sea-D2GwAmKS.js.map} +1 -1
  88. package/dist/{primary-sale-CLjXRrDj.js → primary-sale-DOmNDq2P.js} +1 -1
  89. package/dist/{primary-sale-CLjXRrDj.js.map → primary-sale-DOmNDq2P.js.map} +1 -1
  90. package/dist/{queries-BYT4GJw3.js → queries-EMA5CcwY.js} +208 -287
  91. package/dist/queries-EMA5CcwY.js.map +1 -0
  92. package/dist/{query-BTe7Wkrs.d.ts → query-BG-MA1MB.d.ts} +1 -1
  93. package/dist/{rarible-guwUx4cn.js → rarible-DqiiW9ki.js} +1 -1
  94. package/dist/{rarible-guwUx4cn.js.map → rarible-DqiiW9ki.js.map} +1 -1
  95. package/dist/react/_internal/api/index.d.ts +1 -1
  96. package/dist/react/_internal/api/index.js +4 -4
  97. package/dist/react/_internal/databeat/index.d.ts +1 -1
  98. package/dist/react/_internal/databeat/index.js +24 -21
  99. package/dist/react/_internal/index.d.ts +1 -1
  100. package/dist/react/_internal/index.js +8 -7
  101. package/dist/react/_internal/wagmi/index.d.ts +1 -1
  102. package/dist/react/_internal/wagmi/index.js +4 -3
  103. package/dist/react/hooks/config/index.d.ts +8 -8
  104. package/dist/react/hooks/config/index.js +24 -21
  105. package/dist/react/hooks/contracts/index.d.ts +6 -6
  106. package/dist/react/hooks/contracts/index.js +13 -12
  107. package/dist/react/hooks/data/collectibles/index.d.ts +4 -4
  108. package/dist/react/hooks/data/collectibles/index.js +24 -21
  109. package/dist/react/hooks/data/collections/index.d.ts +10 -10
  110. package/dist/react/hooks/data/collections/index.js +24 -21
  111. package/dist/react/hooks/data/index.d.ts +29 -29
  112. package/dist/react/hooks/data/index.js +25 -22
  113. package/dist/react/hooks/data/inventory/index.d.ts +28 -28
  114. package/dist/react/hooks/data/inventory/index.js +24 -21
  115. package/dist/react/hooks/data/market/index.d.ts +5 -11
  116. package/dist/react/hooks/data/market/index.js +24 -21
  117. package/dist/react/hooks/data/orders/index.d.ts +5 -11
  118. package/dist/react/hooks/data/orders/index.js +25 -22
  119. package/dist/react/hooks/data/primary-sales/index.d.ts +28 -28
  120. package/dist/react/hooks/data/primary-sales/index.js +24 -21
  121. package/dist/react/hooks/data/tokens/index.d.ts +4 -4
  122. package/dist/react/hooks/data/tokens/index.js +24 -21
  123. package/dist/react/hooks/index.d.ts +29 -29
  124. package/dist/react/hooks/index.js +25 -22
  125. package/dist/react/hooks/transactions/index.d.ts +2 -2
  126. package/dist/react/hooks/transactions/index.js +24 -21
  127. package/dist/react/hooks/ui/index.d.ts +4 -4
  128. package/dist/react/hooks/ui/index.js +24 -21
  129. package/dist/react/hooks/utils/index.d.ts +29 -29
  130. package/dist/react/hooks/utils/index.js +25 -22
  131. package/dist/react/index.d.ts +29 -29
  132. package/dist/react/index.js +25 -22
  133. package/dist/react/queries/index.d.ts +16 -16
  134. package/dist/react/queries/index.js +18 -17
  135. package/dist/react/ssr/index.d.ts +7 -7
  136. package/dist/react/ssr/index.js +9 -8
  137. package/dist/react/ssr/index.js.map +1 -1
  138. package/dist/react/ui/components/marketplace-collectible-card/components/footer/components/index.d.ts +3 -0
  139. package/dist/react/ui/components/marketplace-collectible-card/components/footer/components/index.js +22 -0
  140. package/dist/react/ui/components/marketplace-collectible-card/components/footer/index.d.ts +54 -0
  141. package/dist/react/ui/components/marketplace-collectible-card/components/footer/index.js +29 -0
  142. package/dist/react/ui/components/marketplace-collectible-card/index.d.ts +5 -5
  143. package/dist/react/ui/components/marketplace-collectible-card/index.js +24 -21
  144. package/dist/react/ui/components/marketplace-collectible-card/utils/index.d.ts +2 -2
  145. package/dist/react/ui/components/marketplace-collectible-card/utils/index.js +9 -8
  146. package/dist/react/ui/components/marketplace-logos/index.d.ts +21 -21
  147. package/dist/react/ui/components/marketplace-logos/index.js +1 -1
  148. package/dist/react/ui/icons/index.js +13 -11
  149. package/dist/react/ui/index.d.ts +5 -5
  150. package/dist/react/ui/index.js +24 -21
  151. package/dist/react/ui/modals/_internal/components/actionModal/index.js +24 -21
  152. package/dist/react/utils/index.d.ts +1 -1
  153. package/dist/react/utils/index.js +5 -5
  154. package/dist/{react-Ceq8mamy.js → react-BLJ4DkPx.js} +723 -807
  155. package/dist/react-BLJ4DkPx.js.map +1 -0
  156. package/dist/{react-CbqXKOpt.css → react-F03jPjPk.css} +1 -1
  157. package/dist/{react-CbqXKOpt.css.map → react-F03jPjPk.css.map} +1 -1
  158. package/dist/{sequence-Dt2Xo7Fa.js → sequence-Bbb-TFKg.js} +1 -1
  159. package/dist/{sequence-Dt2Xo7Fa.js.map → sequence-Bbb-TFKg.js.map} +1 -1
  160. package/dist/styles/index.css +46 -24
  161. package/dist/{sudo-swap-CGoARONs.js → sudo-swap-CEPIM3Js.js} +1 -1
  162. package/dist/{sudo-swap-CGoARONs.js.map → sudo-swap-CEPIM3Js.js.map} +1 -1
  163. package/dist/{super-rare-NeQtZjcn.js → super-rare-CMEn9PoO.js} +1 -1
  164. package/dist/{super-rare-NeQtZjcn.js.map → super-rare-CMEn9PoO.js.map} +1 -1
  165. package/dist/{token-D9gZVqbX.js → token-CcyLz8Z8.js} +1 -1
  166. package/dist/{token-D9gZVqbX.js.map → token-CcyLz8Z8.js.map} +1 -1
  167. package/dist/{tokenSupplies-DXtkRYNO.d.ts → tokenSupplies-C470zTT0.d.ts} +23 -23
  168. package/dist/{transaction-CC2KxNF6.js → transaction-DZUW5RHu.js} +2 -8
  169. package/dist/transaction-DZUW5RHu.js.map +1 -0
  170. package/dist/types/index.d.ts +2 -2
  171. package/dist/types/index.js +2 -2
  172. package/dist/{types-G2PWxiJR.js → types-B_-cnkcP.js} +1 -1
  173. package/dist/types-B_-cnkcP.js.map +1 -0
  174. package/dist/{types-BlCa0TVE.d.ts → types-D6LkVrF0.d.ts} +18 -10
  175. package/dist/utils/abi/index.d.ts +4 -4
  176. package/dist/utils/abi/index.js +4 -4
  177. package/dist/utils/abi/marketplace/index.d.ts +1 -1
  178. package/dist/utils/abi/marketplace/index.js +1 -1
  179. package/dist/utils/abi/primary-sale/index.d.ts +1 -1
  180. package/dist/utils/abi/primary-sale/index.js +1 -1
  181. package/dist/utils/abi/token/index.d.ts +1 -1
  182. package/dist/utils/abi/token/index.js +1 -1
  183. package/dist/utils/index.d.ts +6 -6
  184. package/dist/utils/index.js +11 -10
  185. package/dist/{utils-CKJd-CRf.js → utils-BZEkdqWK.js} +7 -24
  186. package/dist/utils-BZEkdqWK.js.map +1 -0
  187. package/dist/{utils-wquIhK6T.js → utils-oVZxdK0o.js} +2 -2
  188. package/dist/utils-oVZxdK0o.js.map +1 -0
  189. package/dist/{waitForTransactionReceipt-DZxAuR9N.js → waitForTransactionReceipt-B08YZiDY.js} +3 -4
  190. package/dist/{waitForTransactionReceipt-DZxAuR9N.js.map → waitForTransactionReceipt-B08YZiDY.js.map} +1 -1
  191. package/dist/{x2y2-CQdg24VP.js → x2y2-DNe6JgtG.js} +1 -1
  192. package/dist/{x2y2-CQdg24VP.js.map → x2y2-DNe6JgtG.js.map} +1 -1
  193. package/dist/{zora-DdEydy4L.js → zora-w0Zqxxs4.js} +1 -1
  194. package/dist/{zora-DdEydy4L.js.map → zora-w0Zqxxs4.js.map} +1 -1
  195. package/package.json +35 -35
  196. package/src/react/_internal/api/marketplace.gen.ts +1 -1
  197. package/src/react/_internal/api/query-keys.ts +2 -0
  198. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +19 -8
  199. package/src/react/_internal/wagmi/create-config.ts +6 -17
  200. package/src/react/hooks/config/__snapshots__/useMarketplaceConfig.test.tsx.snap +4 -4
  201. package/src/react/hooks/data/collectibles/useBalanceOfCollectible.laos.test.tsx +2 -2
  202. package/src/react/hooks/data/collectibles/useTokenBalances.test.tsx +151 -0
  203. package/src/react/hooks/data/collectibles/useTokenBalances.tsx +47 -0
  204. package/src/react/hooks/data/collections/__snapshots__/useListCollections.test.tsx.snap +6 -6
  205. package/src/react/hooks/data/inventory/useInventory.test.tsx +3 -98
  206. package/src/react/hooks/data/inventory/useInventory.tsx +2 -2
  207. package/src/react/hooks/data/market/useListMarketCardData.tsx +1 -1
  208. package/src/react/hooks/data/orders/useListOffersForCollectible.tsx +70 -45
  209. package/src/react/hooks/data/primary-sales/useList1155ShopCardData.tsx +21 -37
  210. package/src/react/hooks/data/primary-sales/useList721ShopCardData.tsx +14 -3
  211. package/src/react/hooks/data/tokens/useSearchTokenMetadata.tsx +4 -1
  212. package/src/react/hooks/transactions/useCancelOrder.test.tsx +7 -4
  213. package/src/react/hooks/transactions/useCancelOrder.tsx +2 -1
  214. package/src/react/hooks/transactions/useCancelTransactionSteps.tsx +2 -2
  215. package/src/react/hooks/transactions/useProcessStep.test.tsx +2 -2
  216. package/src/react/hooks/utils/__tests__/useEnsureCorrectChain.test.tsx +75 -0
  217. package/src/react/hooks/utils/index.ts +0 -1
  218. package/src/react/hooks/utils/useEnsureCorrectChain.ts +31 -34
  219. package/src/react/providers/index.tsx +12 -14
  220. package/src/react/providers/modal-provider.tsx +2 -2
  221. package/src/react/queries/__tests__/balanceOfCollectible.laos.test.ts +3 -3
  222. package/src/react/queries/__tests__/inventory.laos.test.ts +6 -3
  223. package/src/react/queries/__tests__/tokenBalances.laos.test.ts +123 -0
  224. package/src/react/queries/balanceOfCollectible.ts +2 -1
  225. package/src/react/queries/filters.ts +23 -28
  226. package/src/react/queries/index.ts +1 -0
  227. package/src/react/queries/inventory.ts +63 -243
  228. package/src/react/queries/listCollectibles.ts +22 -48
  229. package/src/react/queries/listCollections.ts +10 -13
  230. package/src/react/queries/listOffersForCollectible.ts +101 -0
  231. package/src/react/queries/marketplaceConfig.ts +6 -2
  232. package/src/react/queries/tokenBalances.ts +85 -0
  233. package/src/react/ssr/__tests__/__snapshots__/create-ssr-client.test.ts.snap +4 -4
  234. package/src/react/ui/components/_internals/action-button/ActionButton.stories.tsx +8 -8
  235. package/src/react/ui/components/_internals/action-button/ActionButton.tsx +6 -9
  236. package/src/react/ui/components/_internals/action-button/__tests__/NonOwnerActions.test.tsx +4 -4
  237. package/src/react/ui/components/_internals/action-button/components/NonOwnerActions.tsx +6 -6
  238. package/src/react/ui/components/_internals/custom-select/__tests__/CustomSelect.test.tsx +1 -1
  239. package/src/react/ui/components/marketplace-collectible-card/CollectibleCard.tsx +4 -3
  240. package/src/react/ui/components/marketplace-collectible-card/CollectibleCardSkeleton.tsx +13 -2
  241. package/src/react/ui/components/marketplace-collectible-card/components/ActionButtonWrapper.tsx +4 -7
  242. package/src/react/ui/components/marketplace-collectible-card/components/BaseCard.tsx +14 -5
  243. package/src/react/ui/components/marketplace-collectible-card/components/footer/Footer.tsx +179 -0
  244. package/src/react/ui/components/marketplace-collectible-card/components/footer/components/FooterName.tsx +103 -0
  245. package/src/react/ui/components/marketplace-collectible-card/components/footer/components/PriceDisplay.tsx +80 -0
  246. package/src/react/ui/components/marketplace-collectible-card/components/footer/components/SaleDetailsPill.tsx +29 -0
  247. package/src/react/ui/components/marketplace-collectible-card/components/footer/components/TokenTypeBalancePill.tsx +30 -0
  248. package/src/react/ui/components/marketplace-collectible-card/components/footer/components/index.ts +4 -0
  249. package/src/react/ui/components/marketplace-collectible-card/components/footer/index.ts +2 -0
  250. package/src/react/ui/components/marketplace-collectible-card/types.ts +18 -6
  251. package/src/react/ui/components/marketplace-collectible-card/variants/MarketCard.tsx +11 -23
  252. package/src/react/ui/components/marketplace-collectible-card/variants/NonTradableInventoryCard.tsx +42 -0
  253. package/src/react/ui/components/marketplace-collectible-card/variants/ShopCard.tsx +15 -12
  254. package/src/react/ui/modals/BuyModal/__tests__/BuyModalRouter.test.tsx +10 -10
  255. package/src/react/ui/modals/BuyModal/__tests__/ERC1155ShopModal.test.tsx +3 -3
  256. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx.bak +3 -3
  257. package/src/react/ui/modals/BuyModal/__tests__/Modal1155.test.tsx +6 -6
  258. package/src/react/ui/modals/BuyModal/__tests__/store.test.ts +3 -3
  259. package/src/react/ui/modals/BuyModal/components/BuyModalRouter.tsx +5 -5
  260. package/src/react/ui/modals/BuyModal/components/ERC1155BuyModal.tsx +2 -2
  261. package/src/react/ui/modals/BuyModal/components/ERC1155QuantityModal.tsx +8 -8
  262. package/src/react/ui/modals/BuyModal/components/ERC1155ShopModal.tsx +2 -2
  263. package/src/react/ui/modals/BuyModal/hooks/useERC1155Checkout.ts +13 -2
  264. package/src/react/ui/modals/BuyModal/store.ts +6 -6
  265. package/src/react/ui/modals/CreateListingModal/hooks/useCreateListing.tsx +2 -1
  266. package/src/react/ui/modals/CreateListingModal/hooks/useTransactionSteps.tsx +1 -1
  267. package/src/react/ui/modals/MakeOfferModal/Modal.tsx +87 -89
  268. package/src/react/ui/modals/MakeOfferModal/hooks/useMakeOffer.tsx +2 -1
  269. package/src/react/ui/modals/MakeOfferModal/hooks/useTransactionSteps.tsx +1 -1
  270. package/src/react/ui/modals/SellModal/hooks/useGetTokenApproval.tsx +2 -1
  271. package/src/react/ui/modals/SellModal/hooks/useSell.tsx +2 -1
  272. package/src/react/ui/modals/_internal/components/actionModal/ActionModal.test.tsx +20 -9
  273. package/src/react/ui/modals/_internal/components/priceInput/index.tsx +2 -2
  274. package/src/react/ui/modals/_internal/components/switchChainErrorModal/__tests__/SwitchChainErrorModal.test.tsx +80 -0
  275. package/src/react/ui/modals/_internal/components/switchChainErrorModal/index.tsx +64 -0
  276. package/src/react/ui/modals/_internal/components/switchChainErrorModal/store.ts +42 -0
  277. package/src/react/ui/modals/_internal/types.ts +0 -1
  278. package/src/styles/styles.ts +46 -24
  279. package/src/types/new-marketplace-types.ts +9 -18
  280. package/src/types/types.ts +1 -1
  281. package/test/globalSetup.ts +1 -1
  282. package/test/test-utils.tsx +1 -0
  283. package/dist/BellIcon-Cb9YEUzJ.js.map +0 -1
  284. package/dist/CollectibleCard-CYyWzk6u.d.ts +0 -8
  285. package/dist/api-BmEQfSQa.js.map +0 -1
  286. package/dist/create-config-6uynwTeb.js.map +0 -1
  287. package/dist/marketplace-logos-D8t86gsW.js.map +0 -1
  288. package/dist/marketplace.gen-JzNYpM0U.js.map +0 -1
  289. package/dist/marketplaceConfig-sNh-MA5M.js.map +0 -1
  290. package/dist/network-DnBEe1Ur.js.map +0 -1
  291. package/dist/queries-BYT4GJw3.js.map +0 -1
  292. package/dist/react-Ceq8mamy.js.map +0 -1
  293. package/dist/transaction-CC2KxNF6.js.map +0 -1
  294. package/dist/types-G2PWxiJR.js.map +0 -1
  295. package/dist/utils-CKJd-CRf.js.map +0 -1
  296. package/dist/utils-wquIhK6T.js.map +0 -1
  297. package/src/react/hooks/utils/useSwitchChainWithModal.ts +0 -38
  298. package/src/react/ui/components/marketplace-collectible-card/Footer.tsx +0 -238
  299. package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +0 -117
  300. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +0 -124
  301. package/src/react/ui/modals/_internal/components/switchChainModal/store.ts +0 -71
  302. /package/dist/{abi-Wr_aTZFi.js → abi-DYsUABe6.js} +0 -0
  303. /package/dist/{index-q7f-WDBS.d.ts → index-Cg5cFzs-.d.ts} +0 -0
  304. /package/dist/{wagmi-BhP3mdhP.js → wagmi-Bseovd6Q.js} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction-CC2KxNF6.js","names":["shortMessage: string","options: BaseErrorOptions","currentChainId: number","targetChainId: number","stepId: string","cause?: Error","contractType: string | undefined","configName: string"],"sources":["../src/utils/_internal/error/base.ts","../src/utils/_internal/error/transaction.ts"],"sourcesContent":["export type ErrorType<name extends string = 'Error'> = Error & { name: name };\n\nexport type Compute<type> = { [key in keyof type]: type[key] } & unknown;\n\ntype BaseErrorOptions = Compute<\n\t{ details?: string | undefined } | { cause: BaseError | Error }\n>;\n\nexport class BaseError extends Error {\n\tdetails: string;\n\tshortMessage: string;\n\n\tname = 'MarketplaceSdkBaseError';\n\n\tconstructor(shortMessage: string, options: BaseErrorOptions = {}) {\n\t\tsuper();\n\n\t\tconst details = 'details' in options ? options.details : '';\n\t\tthis.message = [\n\t\t\tshortMessage || 'An error occurred.',\n\t\t\t'',\n\t\t\t...(details ? [`Details: ${details}`] : []),\n\t\t].join('\\n');\n\n\t\tif ('cause' in options && options.cause) {\n\t\t\tthis.cause = options.cause;\n\t\t}\n\n\t\tthis.details = details || '';\n\t\tthis.shortMessage = shortMessage;\n\t}\n}\n","import type { Address } from 'viem';\nimport { BaseError } from './base';\n\nexport type TransactionErrorType<name extends string = 'TransactionError'> =\n\tBaseError & { name: name };\n\nexport class TransactionError extends BaseError {\n\toverride name = 'TransactionError';\n}\n\nexport class ChainSwitchError extends TransactionError {\n\toverride name = 'ChainSwitchError';\n\tconstructor(currentChainId: number, targetChainId: number) {\n\t\tsuper(\n\t\t\t`Failed to switch network from ${currentChainId} to ${targetChainId}`,\n\t\t\t{\n\t\t\t\tdetails:\n\t\t\t\t\t'The user may have rejected the network switch or there might be a network connectivity issue.',\n\t\t\t},\n\t\t);\n\t}\n}\n\nexport class ChainSwitchUserRejectedError extends TransactionError {\n\toverride name = 'ChainSwitchUserRejectedError';\n\tconstructor() {\n\t\tsuper('User rejected chain switch', {\n\t\t\tdetails: 'The user rejected the chain switch request.',\n\t\t});\n\t}\n}\n\nexport class TransactionExecutionError extends TransactionError {\n\toverride name = 'TransactionExecutionError';\n\tconstructor(stepId: string, cause?: Error) {\n\t\tsuper(`Failed to execute transaction step: ${stepId}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'The transaction may have been rejected or failed during execution.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class TransactionSignatureError extends TransactionError {\n\toverride name = 'TransactionSignatureError';\n\tconstructor(stepId: string, cause?: Error) {\n\t\tsuper(`Failed to sign transaction step: ${stepId}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'The signature request may have been rejected by the user.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class NoWalletConnectedError extends TransactionError {\n\toverride name = 'NoWalletConnectedError';\n\tconstructor() {\n\t\tsuper('No wallet connected', {\n\t\t\tdetails: 'Please connect your wallet before attempting this transaction.',\n\t\t});\n\t}\n}\n\nexport class NoMarketplaceConfigError extends TransactionError {\n\toverride name = 'NoMarketplaceConfigError';\n\tconstructor() {\n\t\tsuper('Marketplace configuration not found', {\n\t\t\tdetails:\n\t\t\t\t'The marketplace configuration is missing or invalid. This could be due to an initialization error.',\n\t\t});\n\t}\n}\n\nexport class UserRejectedRequestError extends TransactionError {\n\toverride name = 'UserRejectedRequestError';\n\tconstructor() {\n\t\tsuper('User rejected the request', {\n\t\t\tdetails: 'The user cancelled or rejected the transaction request.',\n\t\t});\n\t}\n}\n\nexport class InsufficientFundsError extends TransactionError {\n\toverride name = 'InsufficientFundsError';\n\tconstructor(cause?: Error) {\n\t\tsuper('Insufficient funds for transaction', {\n\t\t\tdetails:\n\t\t\t\t'The wallet does not have enough funds to complete this transaction.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class SignatureExecutionError extends TransactionError {\n\toverride name = 'SignatureExecutionError';\n\tconstructor(signature: string, cause?: Error) {\n\t\tsuper(`Failed to execute signature: ${signature}`, {\n\t\t\tdetails: cause?.message || 'The execution of the signature failed.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class StepExecutionError extends TransactionError {\n\toverride name = 'StepExecutionError';\n\tconstructor(stepId: string, cause?: Error) {\n\t\tsuper(`Failed to execute step ${stepId})`, {\n\t\t\tdetails: cause?.message || 'The step execution failed unexpectedly.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class StepGenerationError extends TransactionError {\n\toverride name = 'StepGenerationError';\n\tconstructor(transactionType: string, cause?: Error) {\n\t\tsuper(`Failed to generate steps for ${transactionType}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message || 'Could not generate the required transaction steps.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class PaymentModalError extends TransactionError {\n\toverride name = 'PaymentModalError';\n\tconstructor(cause?: Error) {\n\t\tsuper('Payment modal operation failed', {\n\t\t\tdetails:\n\t\t\t\tcause?.message || 'The payment modal operation was unsuccessful.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class InvalidStepError extends TransactionError {\n\toverride name = 'InvalidStepError';\n\tconstructor(stepId: string, reason: string) {\n\t\tsuper(`Invalid step configuration for ${stepId}`, {\n\t\t\tdetails: reason,\n\t\t});\n\t}\n}\n\nexport class TransactionConfirmationError extends TransactionError {\n\toverride name = 'TransactionConfirmationError';\n\tconstructor(hash: string, cause?: Error) {\n\t\tsuper(`Failed to confirm transaction ${hash}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'The transaction could not be confirmed on the network.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class OrderNotFoundError extends TransactionError {\n\toverride name = 'OrderNotFoundError';\n\tconstructor(orderId: string) {\n\t\tsuper(`Order ${orderId} not found`, {\n\t\t\tdetails: 'The requested order could not be found in the marketplace.',\n\t\t});\n\t}\n}\n\nexport class MissingStepDataError extends TransactionError {\n\toverride name = 'MissingStepDataError';\n\tconstructor() {\n\t\tsuper('Step is missing required data', {\n\t\t\tdetails:\n\t\t\t\t'The transaction step is missing required \"to\" or \"signature\" data.',\n\t\t});\n\t}\n}\n\nexport class MissingSignatureDataError extends TransactionError {\n\toverride name = 'MissingSignatureDataError';\n\tconstructor() {\n\t\tsuper('Step is missing signature data', {\n\t\t\tdetails:\n\t\t\t\t'The signature step is missing required signature data configuration.',\n\t\t});\n\t}\n}\n\nexport class InvalidSignatureStepError extends TransactionError {\n\toverride name = 'InvalidSignatureStepError';\n\tconstructor(stepId: string) {\n\t\tsuper(`Invalid signature step type: ${stepId}`, {\n\t\t\tdetails: 'The signature step type is not supported.',\n\t\t});\n\t}\n}\n\nexport class MissingPostStepError extends TransactionError {\n\toverride name = 'MissingPostStepError';\n\tconstructor() {\n\t\tsuper('Missing post step configuration', {\n\t\t\tdetails:\n\t\t\t\t'The signature step is missing required post-step configuration.',\n\t\t});\n\t}\n}\n\nexport class UnexpectedStepsError extends TransactionError {\n\toverride name = 'UnexpectedStepsError';\n\tconstructor() {\n\t\tsuper('Unexpected steps found', {\n\t\t\tdetails: 'The transaction contains more steps than expected.',\n\t\t});\n\t}\n}\n\nexport class NoExecutionStepError extends TransactionError {\n\toverride name = 'NoExecutionStepError';\n\tconstructor() {\n\t\tsuper('No execution step found', {\n\t\t\tdetails: 'The transaction is missing the required execution step.',\n\t\t});\n\t}\n}\n\nexport class NoStepsFoundError extends TransactionError {\n\toverride name = 'NoStepsFoundError';\n\tconstructor() {\n\t\tsuper('No steps found', {\n\t\t\tdetails: 'The transaction contains no steps to execute.',\n\t\t});\n\t}\n}\n\nexport class UnknownTransactionTypeError extends TransactionError {\n\toverride name = 'UnknownTransactionTypeError';\n\tconstructor(type: string) {\n\t\tsuper(`Unknown transaction type: ${type}`, {\n\t\t\tdetails: 'The specified transaction type is not supported.',\n\t\t});\n\t}\n}\n\nexport class InvalidContractTypeError extends TransactionError {\n\toverride name = 'InvalidContractTypeError';\n\tconstructor(contractType: string | undefined) {\n\t\tsuper(`Invalid contract type: ${contractType}`, {\n\t\t\tdetails: 'The contract type must be either ERC721 or ERC1155.',\n\t\t});\n\t}\n}\n\nexport class CollectionNotFoundError extends TransactionError {\n\toverride name = 'CollectionNotFoundError';\n\tconstructor(collectionAddress: string) {\n\t\tsuper(`Collection not found: ${collectionAddress}`, {\n\t\t\tdetails:\n\t\t\t\t'The specified collection address could not be found in the marketplace configuration.',\n\t\t});\n\t}\n}\n\nexport class InvalidCurrencyOptionsError extends TransactionError {\n\toverride name = 'InvalidCurrencyOptionsError';\n\tconstructor(currencyOptions: Address[]) {\n\t\tsuper(`Invalid currency options: ${currencyOptions}`, {\n\t\t\tdetails:\n\t\t\t\t'The currency options must be an array of valid currency contract addresses.',\n\t\t});\n\t}\n}\n\nexport class ProjectNotFoundError extends TransactionError {\n\toverride name = 'ProjectNotFoundError';\n\tconstructor(projectId: string, url: string) {\n\t\tsuper('Project not found', {\n\t\t\tdetails: `Project id: ${projectId} not found at ${url}`,\n\t\t});\n\t}\n}\n\nexport class MarketplaceConfigFetchError extends TransactionError {\n\toverride name = 'MarketplaceConfigFetchError';\n\tconstructor(message: string) {\n\t\tsuper('Failed to fetch marketplace config', {\n\t\t\tdetails: message,\n\t\t});\n\t}\n}\n\nexport class MissingConfigError extends TransactionError {\n\toverride name = 'MissingConfigError';\n\tconstructor(configName: string) {\n\t\tsuper(`Missing required config: ${configName}`, {\n\t\t\tdetails: 'A required configuration parameter is missing.',\n\t\t});\n\t}\n}\n\nexport class TransactionValidationError extends TransactionError {\n\toverride name = 'TransactionValidationError';\n\tconstructor(reason: string) {\n\t\tsuper('Transaction validation failed', {\n\t\t\tdetails: reason,\n\t\t});\n\t}\n}\n\nexport class ChainIdUnavailableError extends TransactionError {\n\toverride name = 'ChainIdUnavailableError';\n\tconstructor() {\n\t\tsuper('Chain ID is not available', {\n\t\t\tdetails: 'Could not determine the current chain ID from the wallet.',\n\t\t});\n\t}\n}\n\nexport class TransactionReceiptError extends TransactionError {\n\toverride name = 'TransactionReceiptError';\n\tconstructor(hash: string, cause?: Error) {\n\t\tsuper(`Failed to get transaction receipt for ${hash}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'Could not retrieve the transaction receipt from the network.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class PaymentModalTransactionError extends TransactionError {\n\toverride name = 'PaymentModalTransactionError';\n\tconstructor(hash: string, cause?: Error) {\n\t\tsuper(`Payment modal transaction failed for ${hash}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'The transaction initiated from the payment modal failed.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class CheckoutOptionsError extends TransactionError {\n\toverride name = 'CheckoutOptionsError';\n\tconstructor(cause?: Error) {\n\t\tsuper('Failed to get checkout options', {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'Could not retrieve the checkout options from the marketplace.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class OrdersFetchError extends TransactionError {\n\toverride name = 'OrdersFetchError';\n\tconstructor(orderId: string, cause?: Error) {\n\t\tsuper(`Failed to fetch order ${orderId}`, {\n\t\t\tdetails:\n\t\t\t\tcause?.message ||\n\t\t\t\t'Could not retrieve the order details from the marketplace.',\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class SalesContractError extends TransactionError {\n\toverride name = 'SalesContractError';\n\tconstructor(contractAddress: string, method?: string, cause?: Error) {\n\t\tsuper(`Sales contract operation failed: ${contractAddress}`, {\n\t\t\tdetails: `Failed to interact with sales contract${\n\t\t\t\tmethod ? ` on method: ${method}` : ''\n\t\t\t}. ${cause?.message || 'Contract may be paused or misconfigured.'}`,\n\t\t\tcause,\n\t\t});\n\t}\n}\n\nexport class QuantityValidationError extends TransactionError {\n\toverride name = 'QuantityValidationError';\n\tconstructor(provided: number, available: number, tokenId?: string) {\n\t\tsuper(`Invalid quantity: ${provided}`, {\n\t\t\tdetails: `Requested quantity (${provided}) exceeds available supply (${available})${\n\t\t\t\ttokenId ? ` for token ${tokenId}` : ''\n\t\t\t}.`,\n\t\t});\n\t}\n}\n\nexport class ShopDataValidationError extends TransactionError {\n\toverride name = 'ShopDataValidationError';\n\tconstructor(missingField: string) {\n\t\tsuper(`Invalid shop configuration: missing ${missingField}`, {\n\t\t\tdetails: `The shop is missing required field: ${missingField}. Check your marketplace configuration.`,\n\t\t});\n\t}\n}\n\nexport type TransactionErrorTypes =\n\t| ChainIdUnavailableError\n\t| TransactionReceiptError\n\t| PaymentModalTransactionError\n\t| CheckoutOptionsError\n\t| OrdersFetchError\n\t| TransactionConfirmationError\n\t| TransactionValidationError\n\t| MissingConfigError\n\t| MarketplaceConfigFetchError\n\t| ProjectNotFoundError\n\t| CollectionNotFoundError\n\t| InvalidCurrencyOptionsError\n\t| InvalidContractTypeError\n\t| UnknownTransactionTypeError\n\t| NoStepsFoundError\n\t| NoExecutionStepError\n\t| UnexpectedStepsError\n\t| MissingPostStepError\n\t| InvalidSignatureStepError\n\t| MissingSignatureDataError\n\t| MissingStepDataError\n\t| OrderNotFoundError\n\t| TransactionConfirmationError\n\t| InvalidStepError\n\t| PaymentModalError\n\t| StepGenerationError\n\t| StepExecutionError\n\t| UserRejectedRequestError\n\t| NoMarketplaceConfigError\n\t| InsufficientFundsError\n\t| ChainSwitchUserRejectedError\n\t| ChainSwitchError\n\t| TransactionSignatureError\n\t| TransactionExecutionError\n\t| NoWalletConnectedError\n\t| TransactionError\n\t| SalesContractError\n\t| QuantityValidationError\n\t| ShopDataValidationError;\n"],"mappings":";AAQA,IAAa,YAAb,cAA+B,MAAM;CACpC;CACA;CAEA,OAAO;CAEP,YAAYA,cAAsBC,UAA4B,CAAE,GAAE;EACjE,OAAO;EAEP,MAAM,UAAU,aAAa,UAAU,QAAQ,UAAU;EACzD,KAAK,UAAU;GACd,gBAAgB;GAChB;GACA,GAAI,UAAU,CAAC,CAAC,SAAS,EAAE,SAAS,AAAC,IAAG,CAAE;EAC1C,EAAC,KAAK,KAAK;AAEZ,MAAI,WAAW,WAAW,QAAQ,OACjC,KAAK,QAAQ,QAAQ;EAGtB,KAAK,UAAU,WAAW;EAC1B,KAAK,eAAe;CACpB;AACD;;;;ACzBD,IAAa,mBAAb,cAAsC,UAAU;CAC/C,AAAS,OAAO;AAChB;AAED,IAAa,mBAAb,cAAsC,iBAAiB;CACtD,AAAS,OAAO;CAChB,YAAYC,gBAAwBC,eAAuB;EAC1D,MACC,CAAC,8BAA8B,EAAE,eAAe,IAAI,EAAE,eAAe,EACrE,EACC,SACC,gGACD,EACD;CACD;AACD;AAED,IAAa,+BAAb,cAAkD,iBAAiB;CAClE,AAAS,OAAO;CAChB,cAAc;EACb,MAAM,8BAA8B,EACnC,SAAS,8CACT,EAAC;CACF;AACD;AAED,IAAa,4BAAb,cAA+C,iBAAiB;CAC/D,AAAS,OAAO;CAChB,YAAYC,QAAgBC,OAAe;EAC1C,MAAM,CAAC,oCAAoC,EAAE,QAAQ,EAAE;GACtD,SACC,OAAO,WACP;GACD;EACA,EAAC;CACF;AACD;AAED,IAAa,4BAAb,cAA+C,iBAAiB;CAC/D,AAAS,OAAO;CAChB,YAAYD,QAAgBC,OAAe;EAC1C,MAAM,CAAC,iCAAiC,EAAE,QAAQ,EAAE;GACnD,SACC,OAAO,WACP;GACD;EACA,EAAC;CACF;AACD;AAED,IAAa,yBAAb,cAA4C,iBAAiB;CAC5D,AAAS,OAAO;CAChB,cAAc;EACb,MAAM,uBAAuB,EAC5B,SAAS,iEACT,EAAC;CACF;AACD;AAYD,IAAa,2BAAb,cAA8C,iBAAiB;CAC9D,AAAS,OAAO;CAChB,cAAc;EACb,MAAM,6BAA6B,EAClC,SAAS,0DACT,EAAC;CACF;AACD;AAgKD,IAAa,2BAAb,cAA8C,iBAAiB;CAC9D,AAAS,OAAO;CAChB,YAAYC,cAAkC;EAC7C,MAAM,CAAC,uBAAuB,EAAE,cAAc,EAAE,EAC/C,SAAS,sDACT,EAAC;CACF;AACD;AAwCD,IAAa,qBAAb,cAAwC,iBAAiB;CACxD,AAAS,OAAO;CAChB,YAAYC,YAAoB;EAC/B,MAAM,CAAC,yBAAyB,EAAE,YAAY,EAAE,EAC/C,SAAS,iDACT,EAAC;CACF;AACD"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-G2PWxiJR.js","names":[],"sources":["../src/types/types.ts"],"sourcesContent":["import type { Currency } from './api-types';\nimport type { MarketplaceConfig } from './new-marketplace-types';\n\nexport * from './new-marketplace-types';\n\nexport type Price = {\n\tamountRaw: string;\n\tcurrency: Currency;\n};\n\nexport type MarketplaceType = 'market' | 'shop';\n\nexport enum CollectibleCardAction {\n\tBUY = 'Buy',\n\tSELL = 'Sell',\n\tLIST = 'Create listing',\n\tOFFER = 'Make an offer',\n\tTRANSFER = 'Transfer',\n}\n\nexport type MarketCollection =\n\tMarketplaceConfig['market']['collections'][number];\n\nexport type ShopCollection = MarketplaceConfig['shop']['collections'][number];\n\n// export type Order = Omit<APIOrder, 'priceAmount' | 'priceAmountNet'> & {\n// \tpriceAmount: bigint;\n// \tpriceAmountNet: bigint;\n// };\n"],"mappings":";AAYA,IAAY,0EAAL;;;;;;;AAMN"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-CKJd-CRf.js","names":["address: string","text: string | undefined","truncateAt: number","MARKETPLACES: Record<string, Marketplace>","KIND_TO_MARKETPLACE: Partial<\n\tRecord<MarketplaceKind, keyof typeof MARKETPLACES>\n>","url: string","network: NetworkConfig","amount: bigint","decimals: number","fees: number[]","feePercentage: number"],"sources":["../src/utils/address.ts","../src/utils/cn.ts","../src/utils/getMarketplaceDetails.ts","../src/utils/networkconfigToWagmiChain.ts","../src/utils/price.ts"],"sourcesContent":["export const truncateMiddle = (\n\taddress: string,\n\tminPrefix = 20,\n\tminSuffix = 3,\n): string => {\n\tif (minPrefix + minSuffix >= 40) {\n\t\treturn address;\n\t}\n\treturn `${address.substring(0, 2 + minPrefix)}…${address.substring(address.length - minSuffix)}`;\n};\n\nexport const truncateEnd = (text: string | undefined, truncateAt: number) => {\n\tif (!text) return '';\n\n\tlet finalText = text;\n\n\tif (text.length >= truncateAt) {\n\t\tfinalText = `${text.slice(0, truncateAt)}...`;\n\t}\n\n\treturn finalText;\n};\n\nexport const compareAddress = (a = '', b = '') => {\n\treturn a.toLowerCase() === b.toLowerCase();\n};\n","import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","import type { Image } from '@0xsequence/design-system';\nimport type { ComponentType } from 'react';\nimport {\n\tAlienSwapLogo,\n\tBlurLogo,\n\tLooksRareLogo,\n\tMagicEdenLogo,\n\tMintifyLogo,\n\tOpenSeaLogo,\n\tSequenceLogo,\n\tX2y2Logo,\n} from '../react/ui/components/marketplace-logos';\nimport { MarketplaceKind } from '../types';\n\ninterface Marketplace {\n\tlogo: ComponentType<React.ComponentProps<typeof Image>>;\n\tdisplayName: string;\n}\n\nconst MARKETPLACES: Record<string, Marketplace> = {\n\tsequence: {\n\t\tlogo: SequenceLogo,\n\t\tdisplayName: 'Sequence',\n\t},\n\topensea: {\n\t\tlogo: OpenSeaLogo,\n\t\tdisplayName: 'OpenSea',\n\t},\n\tmagiceden: {\n\t\tlogo: MagicEdenLogo,\n\t\tdisplayName: 'Magic Eden',\n\t},\n\tmintify: {\n\t\tlogo: MintifyLogo,\n\t\tdisplayName: 'Mintify',\n\t},\n\tlooksrare: {\n\t\tlogo: LooksRareLogo,\n\t\tdisplayName: 'Looks Rare',\n\t},\n\tx2y2: {\n\t\tlogo: X2y2Logo,\n\t\tdisplayName: 'X2Y2',\n\t},\n\tblur: {\n\t\tlogo: BlurLogo,\n\t\tdisplayName: 'Blur',\n\t},\n\talienswap: {\n\t\tlogo: AlienSwapLogo,\n\t\tdisplayName: 'AlienSwap',\n\t},\n} as const;\n\nconst KIND_TO_MARKETPLACE: Partial<\n\tRecord<MarketplaceKind, keyof typeof MARKETPLACES>\n> = {\n\t[MarketplaceKind.sequence_marketplace_v1]: 'sequence',\n\t[MarketplaceKind.sequence_marketplace_v2]: 'sequence',\n\t[MarketplaceKind.opensea]: 'opensea',\n\t[MarketplaceKind.mintify]: 'mintify',\n\t[MarketplaceKind.looks_rare]: 'looksrare',\n\t[MarketplaceKind.x2y2]: 'x2y2',\n\t[MarketplaceKind.blur]: 'blur',\n\t[MarketplaceKind.magic_eden]: 'magiceden',\n};\n\ntype MarketplaceDetailsProp = {\n\toriginName: string;\n\tkind: MarketplaceKind;\n};\n\n// TODO: add support for more marketplaces and improve detection of marketplace\nexport function getMarketplaceDetails({\n\toriginName,\n\tkind,\n}: MarketplaceDetailsProp) {\n\tif (\n\t\tkind === MarketplaceKind.sequence_marketplace_v1 ||\n\t\tkind === MarketplaceKind.sequence_marketplace_v2\n\t) {\n\t\treturn MARKETPLACES.sequence;\n\t}\n\n\tlet name = originName.toLowerCase();\n\n\ttry {\n\t\t//Check if the name can be parsed as a url\n\t\tnew URL(name);\n\t\t// if it can we are naively trying to extract the root domain\n\t\tname = getRootDomain(name) || name;\n\t} catch {}\n\n\tname = name.replace(/ /g, '');\n\n\tconst details = MARKETPLACES[name];\n\n\tif (details) {\n\t\treturn details;\n\t}\n\n\tif (KIND_TO_MARKETPLACE[kind]) {\n\t\treturn MARKETPLACES[KIND_TO_MARKETPLACE[kind]];\n\t}\n}\n\nfunction getRootDomain(url: string) {\n\tconst domain = url.replace(/^(https?:\\/\\/)?(www\\.)?/, '');\n\tconst parts = domain.split('.');\n\treturn parts[parts.length - 2] || parts[0];\n}\n","import type { NetworkConfig } from '@0xsequence/network';\nimport type { Chain } from 'viem';\n\nexport const networkToWagmiChain = (network: NetworkConfig): Chain => ({\n\t...network,\n\tid: Number(network.chainId),\n\tname: network.name,\n\tnativeCurrency: { ...network.nativeToken },\n\trpcUrls: {\n\t\tdefault: {\n\t\t\thttp: [network.rpcUrl],\n\t\t},\n\t\tpublic: {\n\t\t\thttp: [network.rpcUrl],\n\t\t},\n\t},\n});\n","import * as dn from 'dnum';\nimport { formatUnits } from 'viem';\n\ntype CalculatePriceDifferencePercentageArgs = {\n\tinputPriceRaw: bigint;\n\tbasePriceRaw: bigint;\n\tdecimals: number;\n};\n\n/**\n * Calculates the percentage difference between two prices\n * @param args - Object containing input price, base price, and decimals\n * @returns The percentage difference as a string with 2 decimal places\n * @example\n * ```ts\n * const diff = calculatePriceDifferencePercentage({\n * inputPriceRaw: 1000000n,\n * basePriceRaw: 900000n,\n * decimals: 6\n * }); // Returns \"11.11\"\n * ```\n */\nexport const calculatePriceDifferencePercentage = ({\n\tinputPriceRaw,\n\tbasePriceRaw,\n\tdecimals,\n}: CalculatePriceDifferencePercentageArgs) => {\n\tconst inputPrice = Number(formatUnits(inputPriceRaw, decimals));\n\tconst basePrice = Number(formatUnits(basePriceRaw, decimals));\n\tconst difference = inputPrice - basePrice;\n\tconst percentageDifference = (difference / basePrice) * 100;\n\n\treturn percentageDifference.toFixed(2);\n};\n\n/**\n * Formats a raw price amount with the specified number of decimal places\n * @param amount - The raw price amount as a bigint\n * @param decimals - Number of decimal places to format to\n * @returns Formatted price string with proper decimal and thousands separators\n * @example\n * ```ts\n * const formatted = formatPrice(1000000n, 6); // Returns \"1.000000\"\n * ```\n */\nexport const formatPrice = (amount: bigint, decimals: number): string => {\n\tconst formattedUnits = Number(formatUnits(amount, decimals));\n\treturn formattedUnits.toLocaleString('en-US', {\n\t\tminimumFractionDigits: 0,\n\t\tmaximumFractionDigits: decimals,\n\t});\n};\n\n/**\n * Calculates the final earnings amount after applying multiple fee percentages\n * @param amount - The raw amount as a bigint (e.g., from a blockchain transaction)\n * @param decimals - The number of decimal places for the currency (e.g., 18 for ETH, 6 for USDC)\n * @param fees - Array of fee percentages to apply (e.g., [2.5, 1.0] for 2.5% and 1% fees)\n * @returns Formatted string representing the final earnings after all fees are applied\n * @throws Will return '0' if there's an error in calculation\n * @example\n * ```ts\n * const earnings = calculateEarningsAfterFees(\n * 1000000000000000000n, // 1 ETH\n * 18, // ETH decimals\n * [2.5, 1.0] // 2.5% and 1% fees\n * ); // Returns \"0.96525\" (1 ETH after 2.5% and 1% fees)\n * ```\n */\nexport const calculateEarningsAfterFees = (\n\tamount: bigint,\n\tdecimals: number,\n\tfees: number[],\n): string => {\n\ttry {\n\t\tconst decimalAmount = Number(formatUnits(amount, decimals));\n\t\tlet earnings = dn.from(decimalAmount.toString(), decimals);\n\n\t\tfor (const fee of fees) {\n\t\t\tif (fee > 0) {\n\t\t\t\tconst feeMultiplier = dn.from((1 - fee / 100).toString(), decimals);\n\t\t\t\tearnings = dn.multiply(earnings, feeMultiplier);\n\t\t\t}\n\t\t}\n\n\t\treturn dn.format(earnings, {\n\t\t\tdigits: decimals,\n\t\t\ttrailingZeros: false,\n\t\t\tlocale: 'en-US',\n\t\t});\n\t} catch (error) {\n\t\tconsole.error('Error calculating earnings after fees:', error);\n\t\treturn '0';\n\t}\n};\n\n/**\n * Formats a price amount with fee applied\n * @param amount - The raw price amount as a bigint\n * @param decimals - Number of decimal places for the currency\n * @param feePercentage - Fee percentage to apply (e.g., 3.5 for 3.5%)\n * @returns Formatted price string with fee applied and proper decimal/thousands separators\n * @example\n * ```ts\n * const priceWithFee = formatPriceWithFee(1000000n, 6, 3.5); // Returns \"1.035\"\n * ```\n */\nexport const formatPriceWithFee = (\n\tamount: bigint,\n\tdecimals: number,\n\tfeePercentage: number,\n): string => {\n\ttry {\n\t\tconst decimalAmount = Number(formatUnits(amount, decimals));\n\t\tconst price = dn.from(decimalAmount.toString(), decimals);\n\t\tconst feeMultiplier = dn.from(\n\t\t\t(1 + feePercentage / 100).toString(),\n\t\t\tdecimals,\n\t\t);\n\t\tconst totalPrice = dn.multiply(price, feeMultiplier);\n\n\t\treturn dn.format(totalPrice, {\n\t\t\tdigits: decimals,\n\t\t\ttrailingZeros: false,\n\t\t\tlocale: 'en-US',\n\t\t});\n\t} catch (error) {\n\t\tconsole.error('Error formatting price with fee:', error);\n\t\treturn '0';\n\t}\n};\n"],"mappings":"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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils-wquIhK6T.js","names":["amount: string","decimals: number"],"sources":["../src/react/ui/components/marketplace-collectible-card/utils/formatPrice.ts","../src/react/ui/components/marketplace-collectible-card/utils/supplyStatus.ts"],"sourcesContent":["import { formatUnits } from 'viem';\n\nexport const OVERFLOW_PRICE = 100000000;\nexport const UNDERFLOW_PRICE = 0.0001;\n\nexport const formatPriceNumber = (\n\tamount: string,\n\tdecimals: number,\n): {\n\tformattedNumber: string;\n\tisUnderflow: boolean;\n\tisOverflow: boolean;\n} => {\n\tconst formattedPrice = formatUnits(BigInt(amount), decimals);\n\tconst numericPrice = Number.parseFloat(formattedPrice);\n\n\tif (numericPrice < UNDERFLOW_PRICE) {\n\t\treturn {\n\t\t\tformattedNumber: UNDERFLOW_PRICE.toString(),\n\t\t\tisUnderflow: true,\n\t\t\tisOverflow: false,\n\t\t};\n\t}\n\n\tif (numericPrice > OVERFLOW_PRICE) {\n\t\treturn {\n\t\t\tformattedNumber: OVERFLOW_PRICE.toLocaleString('en-US', {\n\t\t\t\tmaximumFractionDigits: 2,\n\t\t\t}),\n\t\t\tisUnderflow: false,\n\t\t\tisOverflow: true,\n\t\t};\n\t}\n\n\tconst maxDecimals = numericPrice < 0.01 ? 6 : 4;\n\n\treturn {\n\t\tformattedNumber: numericPrice.toLocaleString('en-US', {\n\t\t\tminimumFractionDigits: 0,\n\t\t\tmaximumFractionDigits: maxDecimals,\n\t\t}),\n\t\tisUnderflow: false,\n\t\tisOverflow: false,\n\t};\n};\n","import { ContractType } from '../../../../_internal';\n\nexport const getSupplyStatusText = ({\n\tquantityRemaining,\n\tcollectionType,\n\tunlimitedSupply,\n}: {\n\tquantityRemaining: string | undefined;\n\tcollectionType: ContractType;\n\tunlimitedSupply?: boolean;\n}): string => {\n\tif (unlimitedSupply) {\n\t\treturn 'Unlimited Supply';\n\t}\n\n\tif (\n\t\tcollectionType === ContractType.ERC721 &&\n\t\tquantityRemaining === undefined\n\t) {\n\t\treturn 'Out of stock';\n\t}\n\n\tif (\n\t\tcollectionType === ContractType.ERC1155 &&\n\t\t!unlimitedSupply &&\n\t\tquantityRemaining === '0'\n\t) {\n\t\treturn 'Out of stock';\n\t}\n\n\tif (quantityRemaining && Number(quantityRemaining) > 0) {\n\t\treturn `Supply: ${quantityRemaining}`;\n\t}\n\n\treturn 'Out of stock';\n};\n"],"mappings":";;;;AAEA,MAAa,iBAAiB;AAC9B,MAAa,kBAAkB;AAE/B,MAAa,oBAAoB,CAChCA,QACAC,aAKI;CACJ,MAAM,iBAAiB,YAAY,OAAO,OAAO,EAAE,SAAS;CAC5D,MAAM,eAAe,OAAO,WAAW,eAAe;AAEtD,KAAI,eAAe,gBAClB,QAAO;EACN,iBAAiB,gBAAgB,UAAU;EAC3C,aAAa;EACb,YAAY;CACZ;AAGF,KAAI,eAAe,eAClB,QAAO;EACN,iBAAiB,eAAe,eAAe,SAAS,EACvD,uBAAuB,EACvB,EAAC;EACF,aAAa;EACb,YAAY;CACZ;CAGF,MAAM,cAAc,eAAe,MAAO,IAAI;AAE9C,QAAO;EACN,iBAAiB,aAAa,eAAe,SAAS;GACrD,uBAAuB;GACvB,uBAAuB;EACvB,EAAC;EACF,aAAa;EACb,YAAY;CACZ;AACD;;;;AC1CD,MAAa,sBAAsB,CAAC,EACnC,mBACA,gBACA,iBAKA,KAAa;AACb,KAAI,gBACH,QAAO;AAGR,KACC,mBAAmB,aAAa,UAChC,sBAAsB,OAEtB,QAAO;AAGR,KACC,mBAAmB,aAAa,WAChC,CAAC,mBACD,sBAAsB,IAEtB,QAAO;AAGR,KAAI,qBAAqB,OAAO,kBAAkB,GAAG,EACpD,QAAO,CAAC,QAAQ,EAAE,mBAAmB;AAGtC,QAAO;AACP"}
@@ -1,38 +0,0 @@
1
- import { useSwitchChain } from 'wagmi';
2
- import { ChainSwitchUserRejectedError } from '../../../utils/_internal/error/transaction';
3
- import { useSwitchChainModal } from '../../ui/modals/_internal/components/switchChainModal';
4
- import { useConnectorMetadata } from '../config/useConnectorMetadata';
5
-
6
- export const useSwitchChainWithModal = () => {
7
- const { show: showSwitchChainModal } = useSwitchChainModal();
8
- const { isWaaS } = useConnectorMetadata();
9
- const { switchChainAsync } = useSwitchChain();
10
-
11
- return {
12
- switchChainWithModal: async (
13
- currentChainId: number,
14
- targetChainId: number,
15
- ) => {
16
- const chainIdMismatch = currentChainId !== Number(targetChainId);
17
-
18
- return new Promise((resolve, reject) => {
19
- if (chainIdMismatch) {
20
- if (isWaaS) {
21
- switchChainAsync({ chainId: targetChainId })
22
- .then(resolve)
23
- .catch(reject);
24
- } else {
25
- showSwitchChainModal({
26
- chainIdToSwitchTo: targetChainId,
27
- onSuccess: () => resolve({ chainId: targetChainId }),
28
- onError: (error) => reject(error),
29
- onClose: () => reject(new ChainSwitchUserRejectedError()),
30
- });
31
- }
32
- } else {
33
- resolve({ chainId: targetChainId });
34
- }
35
- });
36
- },
37
- };
38
- };
@@ -1,238 +0,0 @@
1
- 'use client';
2
-
3
- import {
4
- ChevronLeftIcon,
5
- ChevronRightIcon,
6
- cn,
7
- IconButton,
8
- Image,
9
- Text,
10
- } from '@0xsequence/design-system';
11
- import { formatUnits } from 'viem';
12
- import type { MarketplaceType } from '../../../../types';
13
- import { ContractType, type Currency, type Order } from '../../../_internal';
14
- import SvgBellIcon from '../../icons/BellIcon';
15
- import { formatPriceNumber, getSupplyStatusText } from './utils';
16
-
17
- const formatPrice = (amount: string, currency: Currency): React.ReactNode => {
18
- const { formattedNumber, isUnderflow, isOverflow } = formatPriceNumber(
19
- amount,
20
- currency.decimals,
21
- );
22
- const isFree = amount === '0';
23
-
24
- if (isFree) {
25
- return <Text>Free</Text>;
26
- }
27
-
28
- if (isUnderflow) {
29
- return (
30
- <div className="flex items-center">
31
- <ChevronLeftIcon className="h-3 w-3 text-text-100" />
32
- <Text>{`${formattedNumber} ${currency.symbol}`}</Text>
33
- </div>
34
- );
35
- }
36
-
37
- if (isOverflow) {
38
- return (
39
- <div className="flex items-center">
40
- <ChevronRightIcon className="h-3 w-3 text-text-100" />
41
- <Text>{`${formattedNumber} ${currency.symbol}`}</Text>
42
- </div>
43
- );
44
- }
45
-
46
- return (
47
- <div className="flex items-center gap-1">
48
- <Text>
49
- {formattedNumber} {currency.symbol}
50
- </Text>
51
- </div>
52
- );
53
- };
54
-
55
- type FooterProps = {
56
- name: string;
57
- type?: ContractType;
58
- decimals?: number;
59
- onOfferClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
60
- highestOffer?: Order;
61
- lowestListingPriceAmount?: string;
62
- lowestListingCurrency?: Currency;
63
- balance?: string;
64
- quantityInitial: string | undefined;
65
- quantityRemaining: string | undefined;
66
- unlimitedSupply?: boolean;
67
- marketplaceType: MarketplaceType;
68
- salePriceAmount?: string;
69
- salePriceCurrency?: Currency;
70
- };
71
-
72
- export const Footer = ({
73
- name,
74
- type,
75
- decimals,
76
- onOfferClick,
77
- highestOffer,
78
- lowestListingPriceAmount,
79
- lowestListingCurrency,
80
- balance,
81
- quantityInitial,
82
- quantityRemaining,
83
- unlimitedSupply,
84
- marketplaceType,
85
- salePriceAmount,
86
- salePriceCurrency,
87
- }: FooterProps) => {
88
- const listed = !!lowestListingPriceAmount && !!lowestListingCurrency;
89
- const isShop = marketplaceType === 'shop';
90
- const isMarketplace = marketplaceType === 'market';
91
-
92
- const displayName = (() => {
93
- if (name.length > 15 && highestOffer && !isShop) {
94
- return `${name.substring(0, 13)}...`;
95
- }
96
- if (name.length > 17 && !highestOffer && !isShop) {
97
- return `${name.substring(0, 17)}...`;
98
- }
99
- return name;
100
- })();
101
-
102
- return (
103
- <div className="relative flex flex-col items-start gap-2 whitespace-nowrap bg-background-primary p-4">
104
- <div className="relative flex w-full items-center justify-between">
105
- <Text
106
- className={cn(
107
- 'overflow-hidden text-ellipsis text-left font-body font-bold text-sm text-text-100',
108
- isShop &&
109
- (quantityInitial === undefined ||
110
- quantityRemaining === undefined) &&
111
- 'text-text-50',
112
- )}
113
- >
114
- {displayName || 'Untitled'}
115
- </Text>
116
-
117
- {highestOffer && onOfferClick && !isShop && (
118
- <IconButton
119
- className="absolute top-0 right-0 h-[22px] w-[22px] hover:animate-bell-ring"
120
- size="xs"
121
- variant="primary"
122
- onClick={(e) => {
123
- onOfferClick?.(e);
124
- }}
125
- icon={(props) => <SvgBellIcon {...props} size="xs" />}
126
- />
127
- )}
128
- </div>
129
-
130
- <div
131
- className={cn(
132
- 'flex items-center gap-1',
133
- isShop && !salePriceAmount && 'hidden',
134
- isShop && type === ContractType.ERC721 && 'hidden',
135
- )}
136
- >
137
- {((isMarketplace && listed && lowestListingCurrency?.imageUrl) ||
138
- (isShop && salePriceCurrency && salePriceCurrency.imageUrl)) && (
139
- <Image
140
- alt={lowestListingCurrency?.symbol || salePriceCurrency?.symbol}
141
- className="h-3 w-3"
142
- src={lowestListingCurrency?.imageUrl || salePriceCurrency?.imageUrl}
143
- onError={(e) => {
144
- e.currentTarget.style.display = 'none';
145
- }}
146
- />
147
- )}
148
-
149
- <Text
150
- className={cn(
151
- 'text-left font-body font-bold text-sm',
152
- listed && isMarketplace ? 'text-text-100' : 'text-text-50',
153
- isShop &&
154
- salePriceAmount &&
155
- salePriceCurrency &&
156
- type === ContractType.ERC1155 &&
157
- 'text-text-100',
158
- )}
159
- >
160
- {listed &&
161
- isMarketplace &&
162
- formatPrice(lowestListingPriceAmount, lowestListingCurrency)}
163
-
164
- {!listed && isMarketplace && 'Not listed yet'}
165
-
166
- {isShop &&
167
- salePriceAmount &&
168
- salePriceCurrency &&
169
- type === ContractType.ERC1155 &&
170
- formatPrice(salePriceAmount, salePriceCurrency)}
171
- </Text>
172
- </div>
173
-
174
- {isShop && (
175
- <SaleDetailsPill
176
- quantityRemaining={quantityRemaining}
177
- collectionType={type as ContractType}
178
- unlimitedSupply={unlimitedSupply}
179
- />
180
- )}
181
-
182
- {isShop && !salePriceAmount && <div className="h-5 w-full" />}
183
-
184
- {isMarketplace && (
185
- <TokenTypeBalancePill
186
- balance={balance}
187
- type={type as ContractType}
188
- decimals={decimals}
189
- />
190
- )}
191
- </div>
192
- );
193
- };
194
-
195
- const TokenTypeBalancePill = ({
196
- balance,
197
- type,
198
- decimals,
199
- }: {
200
- balance?: string;
201
- type: ContractType;
202
- decimals?: number;
203
- }) => {
204
- const displayText =
205
- type === ContractType.ERC1155
206
- ? balance
207
- ? `Owned: ${formatUnits(BigInt(balance), decimals ?? 0)}`
208
- : 'ERC-1155'
209
- : 'ERC-721';
210
-
211
- return (
212
- <Text className="rounded-lg bg-background-secondary px-2 py-1 text-left font-medium text-text-80 text-xs">
213
- {displayText}
214
- </Text>
215
- );
216
- };
217
-
218
- const SaleDetailsPill = ({
219
- quantityRemaining,
220
- collectionType,
221
- unlimitedSupply,
222
- }: {
223
- quantityRemaining: string | undefined;
224
- collectionType: ContractType;
225
- unlimitedSupply?: boolean;
226
- }) => {
227
- const supplyText = getSupplyStatusText({
228
- quantityRemaining,
229
- collectionType,
230
- unlimitedSupply,
231
- });
232
-
233
- return (
234
- <Text className="rounded-lg bg-background-secondary px-2 py-1 text-left font-medium text-text-80 text-xs">
235
- {supplyText}
236
- </Text>
237
- );
238
- };
@@ -1,117 +0,0 @@
1
- import {
2
- fireEvent,
3
- render,
4
- renderHook,
5
- screen,
6
- wagmiConfig,
7
- waitFor,
8
- } from '@test';
9
- import { beforeEach, describe, expect, test, vi } from 'vitest';
10
- import { useChainId } from 'wagmi';
11
- import SwitchChainModal, { useSwitchChainModal } from '../index';
12
- import { switchChainModalStore } from '../store';
13
-
14
- const chainToSwitchTo = wagmiConfig.chains[1];
15
-
16
- describe('SwitchChainModal', () => {
17
- beforeEach(() => {
18
- // Reset store to initial state
19
- switchChainModalStore.send({ type: 'close' });
20
- });
21
-
22
- test('opens switch chain modal with correct chain', async () => {
23
- const { result } = renderHook(() => useSwitchChainModal());
24
-
25
- result.current.show({ chainIdToSwitchTo: chainToSwitchTo.id });
26
- render(<SwitchChainModal />);
27
-
28
- await waitFor(() => {
29
- const titleElement = screen.getByText('Wrong network');
30
- expect(titleElement).toBeInTheDocument();
31
- });
32
-
33
- const titleElement = await screen.findByText('Wrong network');
34
- expect(titleElement).toBeInTheDocument();
35
-
36
- const messageElement = await screen.findByText(
37
- `You need to switch to ${chainToSwitchTo.name} network before completing the transaction`,
38
- );
39
- expect(messageElement).toBeInTheDocument();
40
-
41
- const buttonElement = await screen.findByRole('button', {
42
- name: /switch network/i,
43
- });
44
- expect(buttonElement).toBeInTheDocument();
45
- });
46
-
47
- test('closes switch chain modal using close callback', async () => {
48
- const { result } = renderHook(() => useSwitchChainModal());
49
-
50
- result.current.show({ chainIdToSwitchTo: chainToSwitchTo.id });
51
- render(<SwitchChainModal />);
52
-
53
- result.current.close();
54
-
55
- const titleElement = screen.queryByText('Wrong network');
56
- await waitFor(() => {
57
- expect(titleElement).not.toBeInTheDocument();
58
- });
59
- });
60
-
61
- test('clicking Switch Network button triggers chain switch', async () => {
62
- render(<SwitchChainModal />);
63
- const { show } = useSwitchChainModal();
64
-
65
- show({ chainIdToSwitchTo: chainToSwitchTo.id });
66
-
67
- const switchButton = await screen.findByRole('button', {
68
- name: /switch network/i,
69
- });
70
- expect(switchButton).toBeInTheDocument();
71
-
72
- fireEvent.click(switchButton);
73
-
74
- await waitFor(() => {
75
- const chainId = renderHook(() => useChainId()).result.current;
76
- expect(chainId).toBe(chainToSwitchTo.id);
77
- });
78
- });
79
-
80
- test('shows spinner while switching chain', async () => {
81
- // Open modal and set isSwitching to true
82
- switchChainModalStore.send({
83
- type: 'open',
84
- chainIdToSwitchTo: chainToSwitchTo.id,
85
- });
86
- switchChainModalStore.send({
87
- type: 'setSwitching',
88
- isSwitching: true,
89
- });
90
-
91
- render(<SwitchChainModal />);
92
-
93
- const spinner = screen.getByTestId('switch-chain-spinner');
94
- expect(spinner).toBeInTheDocument();
95
- });
96
-
97
- test('shows error message when chain switch fails', async () => {
98
- const mockOnError = vi.fn();
99
- const { result } = renderHook(() => useSwitchChainModal());
100
-
101
- result.current.show({
102
- // @ts-expect-error - invalid chain id to trigger error
103
- chainIdToSwitchTo: 'invalid-chain-id',
104
- onError: mockOnError,
105
- });
106
- render(<SwitchChainModal />);
107
-
108
- const button = await screen.findByRole('button', {
109
- name: /switch network/i,
110
- });
111
- fireEvent.click(button);
112
-
113
- await waitFor(() => {
114
- expect(mockOnError).toHaveBeenCalledOnce();
115
- });
116
- });
117
- });
@@ -1,124 +0,0 @@
1
- 'use client';
2
-
3
- import { Button, Modal, Spinner, Text } from '@0xsequence/design-system';
4
- import type { SwitchChainError } from 'viem';
5
- import { useSwitchChain } from 'wagmi';
6
- import { getPresentableChainName } from '../../../../../../utils/network';
7
- import AlertMessage from '../alertMessage';
8
- import { MODAL_OVERLAY_PROPS } from '../consts';
9
- import {
10
- switchChainModalStore,
11
- useChainIdToSwitchTo,
12
- useIsOpen,
13
- useIsSwitching,
14
- useOnClose,
15
- useOnError,
16
- useOnSuccess,
17
- } from './store';
18
-
19
- export type ShowSwitchChainModalArgs = {
20
- chainIdToSwitchTo: number;
21
- onSuccess?: () => void;
22
- onError?: (error: SwitchChainError) => void;
23
- onClose?: () => void;
24
- };
25
-
26
- export const useSwitchChainModal = () => {
27
- return {
28
- show: (args: ShowSwitchChainModalArgs) =>
29
- switchChainModalStore.send({ type: 'open', ...args }),
30
- close: () => switchChainModalStore.send({ type: 'close' }),
31
- };
32
- };
33
-
34
- const SwitchChainModal = () => {
35
- const isOpen = useIsOpen();
36
- const chainIdToSwitchTo = useChainIdToSwitchTo();
37
- const isSwitching = useIsSwitching();
38
- const onSuccess = useOnSuccess();
39
- const onError = useOnError();
40
- const onClose = useOnClose();
41
-
42
- const chainName = chainIdToSwitchTo
43
- ? getPresentableChainName(chainIdToSwitchTo)
44
- : '';
45
- const { switchChainAsync } = useSwitchChain();
46
-
47
- async function handleSwitchChain() {
48
- switchChainModalStore.send({ type: 'setSwitching', isSwitching: true });
49
-
50
- try {
51
- if (!chainIdToSwitchTo) return;
52
- await switchChainAsync({ chainId: Number(chainIdToSwitchTo) });
53
-
54
- if (onSuccess && typeof onSuccess === 'function') {
55
- onSuccess();
56
- }
57
-
58
- switchChainModalStore.send({ type: 'close' });
59
- } catch (error) {
60
- if (error instanceof Error && onError && typeof onError === 'function') {
61
- onError(error as SwitchChainError);
62
- }
63
- } finally {
64
- switchChainModalStore.send({ type: 'setSwitching', isSwitching: false });
65
- }
66
- }
67
-
68
- const handleClose = () => {
69
- if (onClose && typeof onClose === 'function') {
70
- onClose();
71
- }
72
- switchChainModalStore.send({ type: 'close' });
73
- };
74
-
75
- if (!isOpen || !chainIdToSwitchTo) return null;
76
-
77
- return (
78
- <Modal
79
- isDismissible={true}
80
- onClose={handleClose}
81
- disableAnimation
82
- size="sm"
83
- overlayProps={MODAL_OVERLAY_PROPS}
84
- >
85
- <div className="grid flex-col gap-6 p-7">
86
- <Text className="text-xl" fontWeight="bold" color="text100">
87
- Wrong network
88
- </Text>
89
-
90
- <AlertMessage
91
- type="warning"
92
- message={`You need to switch to ${chainName} network before completing the transaction`}
93
- />
94
-
95
- <Button
96
- className={`${
97
- isSwitching
98
- ? 'flex w-[147px] items-center justify-center [&>div]:justify-center'
99
- : 'w-[147px]'
100
- } flex justify-self-end`}
101
- name="switch-chain"
102
- id="switch-chain-button"
103
- size="sm"
104
- label={
105
- isSwitching ? (
106
- <div data-testid="switch-chain-spinner">
107
- <Spinner className="spinner" />
108
- </div>
109
- ) : (
110
- 'Switch Network'
111
- )
112
- }
113
- variant="primary"
114
- pending={isSwitching}
115
- shape="square"
116
- onClick={handleSwitchChain}
117
- data-testid="switch-chain-button"
118
- />
119
- </div>
120
- </Modal>
121
- );
122
- };
123
-
124
- export default SwitchChainModal;
@@ -1,71 +0,0 @@
1
- import { createStore } from '@xstate/store';
2
- import { useSelector } from '@xstate/store/react';
3
- import type { SwitchChainError } from 'viem';
4
- import type { ShowSwitchChainModalArgs } from '.';
5
-
6
- export interface SwitchChainModalState {
7
- isOpen: boolean;
8
- chainIdToSwitchTo: number | undefined;
9
- isSwitching: boolean;
10
- onSuccess: (() => void) | undefined;
11
- onError: undefined | ((error: SwitchChainError) => void);
12
- onClose: (() => void) | undefined;
13
- }
14
-
15
- const initialContext: SwitchChainModalState = {
16
- isOpen: false,
17
- chainIdToSwitchTo: undefined,
18
- isSwitching: false,
19
- onSuccess: undefined,
20
- onError: undefined,
21
- onClose: undefined,
22
- };
23
-
24
- export const switchChainModalStore = createStore({
25
- context: initialContext,
26
- on: {
27
- open: (context, event: ShowSwitchChainModalArgs) => ({
28
- ...context,
29
- isOpen: true,
30
- chainIdToSwitchTo: event.chainIdToSwitchTo,
31
- onSuccess: event.onSuccess,
32
- onError: event.onError,
33
- onClose: event.onClose,
34
- }),
35
- close: (context) => ({
36
- ...context,
37
- isOpen: false,
38
- chainIdToSwitchTo: undefined,
39
- isSwitching: false,
40
- onSuccess: undefined,
41
- onError: undefined,
42
- onClose: undefined,
43
- }),
44
- setSwitching: (context, event: { isSwitching: boolean }) => ({
45
- ...context,
46
- isSwitching: event.isSwitching,
47
- }),
48
- },
49
- });
50
-
51
- // Selector hooks
52
- export const useIsOpen = () =>
53
- useSelector(switchChainModalStore, (state) => state.context.isOpen);
54
-
55
- export const useChainIdToSwitchTo = () =>
56
- useSelector(
57
- switchChainModalStore,
58
- (state) => state.context.chainIdToSwitchTo,
59
- );
60
-
61
- export const useIsSwitching = () =>
62
- useSelector(switchChainModalStore, (state) => state.context.isSwitching);
63
-
64
- export const useOnSuccess = () =>
65
- useSelector(switchChainModalStore, (state) => state.context.onSuccess);
66
-
67
- export const useOnError = () =>
68
- useSelector(switchChainModalStore, (state) => state.context.onError);
69
-
70
- export const useOnClose = () =>
71
- useSelector(switchChainModalStore, (state) => state.context.onClose);
File without changes
File without changes