thirdweb 5.108.6 → 5.108.8

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 (391) hide show
  1. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  2. package/dist/cjs/react/core/hooks/usePaymentMethods.js +1 -2
  3. package/dist/cjs/react/core/hooks/usePaymentMethods.js.map +1 -1
  4. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +1 -1
  5. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  6. package/dist/cjs/react/web/ui/Bridge/BuyWidget.js +185 -99
  7. package/dist/cjs/react/web/ui/Bridge/BuyWidget.js.map +1 -1
  8. package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js +210 -56
  9. package/dist/cjs/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
  10. package/dist/cjs/react/web/ui/Bridge/DirectPayment.js +7 -7
  11. package/dist/cjs/react/web/ui/Bridge/DirectPayment.js.map +1 -1
  12. package/dist/cjs/react/web/ui/Bridge/FundWallet.js +233 -105
  13. package/dist/cjs/react/web/ui/Bridge/FundWallet.js.map +1 -1
  14. package/dist/cjs/react/web/ui/Bridge/QuoteLoader.js +1 -7
  15. package/dist/cjs/react/web/ui/Bridge/QuoteLoader.js.map +1 -1
  16. package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js +16 -12
  17. package/dist/cjs/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
  18. package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js +199 -36
  19. package/dist/cjs/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
  20. package/dist/cjs/react/web/ui/Bridge/bridge-widget/bridge-widget.js +2 -2
  21. package/dist/cjs/react/web/ui/Bridge/bridge-widget/bridge-widget.js.map +1 -1
  22. package/dist/cjs/react/web/ui/Bridge/common/WithHeader.js +4 -5
  23. package/dist/cjs/react/web/ui/Bridge/common/WithHeader.js.map +1 -1
  24. package/dist/cjs/react/web/ui/Bridge/common/active-wallet-details.js +52 -0
  25. package/dist/cjs/react/web/ui/Bridge/common/active-wallet-details.js.map +1 -0
  26. package/dist/cjs/react/web/ui/Bridge/common/decimal-input.js +36 -0
  27. package/dist/cjs/react/web/ui/Bridge/common/decimal-input.js.map +1 -0
  28. package/dist/cjs/react/web/ui/Bridge/common/selected-token-button.js +58 -0
  29. package/dist/cjs/react/web/ui/Bridge/common/selected-token-button.js.map +1 -0
  30. package/dist/cjs/react/web/ui/Bridge/common/token-balance.js +20 -0
  31. package/dist/cjs/react/web/ui/Bridge/common/token-balance.js.map +1 -0
  32. package/dist/cjs/react/web/ui/Bridge/common/token-query.js +34 -0
  33. package/dist/cjs/react/web/ui/Bridge/common/token-query.js.map +1 -0
  34. package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentDetails.js +3 -3
  35. package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentDetails.js.map +1 -1
  36. package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentOverview.js +7 -7
  37. package/dist/cjs/react/web/ui/Bridge/payment-details/PaymentOverview.js.map +1 -1
  38. package/dist/cjs/react/web/ui/Bridge/payment-selection/PaymentSelection.js +1 -4
  39. package/dist/cjs/react/web/ui/Bridge/payment-selection/PaymentSelection.js.map +1 -1
  40. package/dist/cjs/react/web/ui/Bridge/payment-selection/TokenSelection.js.map +1 -1
  41. package/dist/cjs/react/web/ui/Bridge/payment-success/SuccessScreen.js +3 -3
  42. package/dist/cjs/react/web/ui/Bridge/payment-success/SuccessScreen.js.map +1 -1
  43. package/dist/cjs/react/web/ui/Bridge/swap-widget/SwapWidget.js +8 -11
  44. package/dist/cjs/react/web/ui/Bridge/swap-widget/SwapWidget.js.map +1 -1
  45. package/dist/cjs/react/web/ui/Bridge/swap-widget/swap-ui.js +19 -147
  46. package/dist/cjs/react/web/ui/Bridge/swap-widget/swap-ui.js.map +1 -1
  47. package/dist/cjs/react/web/ui/Bridge/types.js +3 -0
  48. package/dist/cjs/react/web/ui/Bridge/types.js.map +1 -0
  49. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +4 -2
  50. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  51. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +1 -1
  52. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  53. package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
  54. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js +1 -1
  55. package/dist/cjs/react/web/ui/TransactionButton/DepositScreen.js.map +1 -1
  56. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +17 -10
  57. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
  58. package/dist/cjs/react/web/ui/components/CopyIcon.js +1 -1
  59. package/dist/cjs/react/web/ui/components/CopyIcon.js.map +1 -1
  60. package/dist/cjs/stories/Bridge/CheckoutWidget.stories.js +115 -0
  61. package/dist/cjs/stories/Bridge/CheckoutWidget.stories.js.map +1 -0
  62. package/dist/cjs/stories/Bridge/ErrorBanner.stories.js +7 -111
  63. package/dist/cjs/stories/Bridge/ErrorBanner.stories.js.map +1 -1
  64. package/dist/cjs/stories/Bridge/PaymentDetails.stories.js +27 -306
  65. package/dist/cjs/stories/Bridge/PaymentDetails.stories.js.map +1 -1
  66. package/dist/cjs/stories/Bridge/PaymentSelection.stories.js +21 -128
  67. package/dist/cjs/stories/Bridge/PaymentSelection.stories.js.map +1 -1
  68. package/dist/cjs/stories/Bridge/StepRunner.stories.js +13 -39
  69. package/dist/cjs/stories/Bridge/StepRunner.stories.js.map +1 -1
  70. package/dist/cjs/stories/Bridge/SuccessScreen.stories.js +13 -101
  71. package/dist/cjs/stories/Bridge/SuccessScreen.stories.js.map +1 -1
  72. package/dist/cjs/stories/Bridge/Transaction/TransactionWidget.stories.js +49 -0
  73. package/dist/cjs/stories/Bridge/Transaction/TransactionWidget.stories.js.map +1 -0
  74. package/dist/cjs/stories/Bridge/Transaction/useSendTransactionModal.stories.js +53 -0
  75. package/dist/cjs/stories/Bridge/Transaction/useSendTransactionModal.stories.js.map +1 -0
  76. package/dist/cjs/stories/Bridge/UnsupportedTokenScreen.stories.js +11 -79
  77. package/dist/cjs/stories/Bridge/UnsupportedTokenScreen.stories.js.map +1 -1
  78. package/dist/cjs/stories/Bridge/fixtures.js +21 -62
  79. package/dist/cjs/stories/Bridge/fixtures.js.map +1 -1
  80. package/dist/cjs/stories/BuyWidget.stories.js +44 -8
  81. package/dist/cjs/stories/BuyWidget.stories.js.map +1 -1
  82. package/dist/cjs/stories/utils.js +5 -2
  83. package/dist/cjs/stories/utils.js.map +1 -1
  84. package/dist/cjs/version.js +1 -1
  85. package/dist/cjs/x402/common.js +3 -5
  86. package/dist/cjs/x402/common.js.map +1 -1
  87. package/dist/cjs/x402/facilitator.js +3 -4
  88. package/dist/cjs/x402/facilitator.js.map +1 -1
  89. package/dist/cjs/x402/schemas.js +4 -0
  90. package/dist/cjs/x402/schemas.js.map +1 -1
  91. package/dist/cjs/x402/settle-payment.js +6 -5
  92. package/dist/cjs/x402/settle-payment.js.map +1 -1
  93. package/dist/cjs/x402/sign.js +2 -6
  94. package/dist/cjs/x402/sign.js.map +1 -1
  95. package/dist/cjs/x402/types.js.map +1 -1
  96. package/dist/cjs/x402/verify-payment.js +6 -5
  97. package/dist/cjs/x402/verify-payment.js.map +1 -1
  98. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  99. package/dist/esm/react/core/hooks/usePaymentMethods.js +1 -2
  100. package/dist/esm/react/core/hooks/usePaymentMethods.js.map +1 -1
  101. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +1 -1
  102. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  103. package/dist/esm/react/web/ui/Bridge/BuyWidget.js +185 -99
  104. package/dist/esm/react/web/ui/Bridge/BuyWidget.js.map +1 -1
  105. package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js +211 -57
  106. package/dist/esm/react/web/ui/Bridge/CheckoutWidget.js.map +1 -1
  107. package/dist/esm/react/web/ui/Bridge/DirectPayment.js +7 -7
  108. package/dist/esm/react/web/ui/Bridge/DirectPayment.js.map +1 -1
  109. package/dist/esm/react/web/ui/Bridge/FundWallet.js +237 -109
  110. package/dist/esm/react/web/ui/Bridge/FundWallet.js.map +1 -1
  111. package/dist/esm/react/web/ui/Bridge/QuoteLoader.js +1 -7
  112. package/dist/esm/react/web/ui/Bridge/QuoteLoader.js.map +1 -1
  113. package/dist/esm/react/web/ui/Bridge/TransactionPayment.js +16 -12
  114. package/dist/esm/react/web/ui/Bridge/TransactionPayment.js.map +1 -1
  115. package/dist/esm/react/web/ui/Bridge/TransactionWidget.js +198 -36
  116. package/dist/esm/react/web/ui/Bridge/TransactionWidget.js.map +1 -1
  117. package/dist/esm/react/web/ui/Bridge/bridge-widget/bridge-widget.js +2 -2
  118. package/dist/esm/react/web/ui/Bridge/bridge-widget/bridge-widget.js.map +1 -1
  119. package/dist/esm/react/web/ui/Bridge/common/WithHeader.js +4 -5
  120. package/dist/esm/react/web/ui/Bridge/common/WithHeader.js.map +1 -1
  121. package/dist/esm/react/web/ui/Bridge/common/active-wallet-details.js +49 -0
  122. package/dist/esm/react/web/ui/Bridge/common/active-wallet-details.js.map +1 -0
  123. package/dist/esm/react/web/ui/Bridge/common/decimal-input.js +33 -0
  124. package/dist/esm/react/web/ui/Bridge/common/decimal-input.js.map +1 -0
  125. package/dist/esm/react/web/ui/Bridge/common/selected-token-button.js +55 -0
  126. package/dist/esm/react/web/ui/Bridge/common/selected-token-button.js.map +1 -0
  127. package/dist/esm/react/web/ui/Bridge/common/token-balance.js +17 -0
  128. package/dist/esm/react/web/ui/Bridge/common/token-balance.js.map +1 -0
  129. package/dist/esm/react/web/ui/Bridge/common/token-query.js +31 -0
  130. package/dist/esm/react/web/ui/Bridge/common/token-query.js.map +1 -0
  131. package/dist/esm/react/web/ui/Bridge/payment-details/PaymentDetails.js +3 -3
  132. package/dist/esm/react/web/ui/Bridge/payment-details/PaymentDetails.js.map +1 -1
  133. package/dist/esm/react/web/ui/Bridge/payment-details/PaymentOverview.js +7 -7
  134. package/dist/esm/react/web/ui/Bridge/payment-details/PaymentOverview.js.map +1 -1
  135. package/dist/esm/react/web/ui/Bridge/payment-selection/PaymentSelection.js +1 -4
  136. package/dist/esm/react/web/ui/Bridge/payment-selection/PaymentSelection.js.map +1 -1
  137. package/dist/esm/react/web/ui/Bridge/payment-selection/TokenSelection.js.map +1 -1
  138. package/dist/esm/react/web/ui/Bridge/payment-success/SuccessScreen.js +3 -3
  139. package/dist/esm/react/web/ui/Bridge/payment-success/SuccessScreen.js.map +1 -1
  140. package/dist/esm/react/web/ui/Bridge/swap-widget/SwapWidget.js +8 -11
  141. package/dist/esm/react/web/ui/Bridge/swap-widget/SwapWidget.js.map +1 -1
  142. package/dist/esm/react/web/ui/Bridge/swap-widget/swap-ui.js +16 -144
  143. package/dist/esm/react/web/ui/Bridge/swap-widget/swap-ui.js.map +1 -1
  144. package/dist/esm/react/web/ui/Bridge/types.js +2 -0
  145. package/dist/esm/react/web/ui/Bridge/types.js.map +1 -0
  146. package/dist/esm/react/web/ui/ConnectWallet/Details.js +4 -2
  147. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  148. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +1 -1
  149. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  150. package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
  151. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js +1 -1
  152. package/dist/esm/react/web/ui/TransactionButton/DepositScreen.js.map +1 -1
  153. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +17 -10
  154. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -1
  155. package/dist/esm/react/web/ui/components/CopyIcon.js +1 -1
  156. package/dist/esm/react/web/ui/components/CopyIcon.js.map +1 -1
  157. package/dist/esm/stories/Bridge/CheckoutWidget.stories.js +112 -0
  158. package/dist/esm/stories/Bridge/CheckoutWidget.stories.js.map +1 -0
  159. package/dist/esm/stories/Bridge/ErrorBanner.stories.js +7 -111
  160. package/dist/esm/stories/Bridge/ErrorBanner.stories.js.map +1 -1
  161. package/dist/esm/stories/Bridge/PaymentDetails.stories.js +28 -307
  162. package/dist/esm/stories/Bridge/PaymentDetails.stories.js.map +1 -1
  163. package/dist/esm/stories/Bridge/PaymentSelection.stories.js +22 -129
  164. package/dist/esm/stories/Bridge/PaymentSelection.stories.js.map +1 -1
  165. package/dist/esm/stories/Bridge/StepRunner.stories.js +12 -38
  166. package/dist/esm/stories/Bridge/StepRunner.stories.js.map +1 -1
  167. package/dist/esm/stories/Bridge/SuccessScreen.stories.js +14 -102
  168. package/dist/esm/stories/Bridge/SuccessScreen.stories.js.map +1 -1
  169. package/dist/esm/stories/Bridge/Transaction/TransactionWidget.stories.js +46 -0
  170. package/dist/esm/stories/Bridge/Transaction/TransactionWidget.stories.js.map +1 -0
  171. package/dist/esm/stories/Bridge/Transaction/useSendTransactionModal.stories.js +50 -0
  172. package/dist/esm/stories/Bridge/Transaction/useSendTransactionModal.stories.js.map +1 -0
  173. package/dist/esm/stories/Bridge/UnsupportedTokenScreen.stories.js +12 -80
  174. package/dist/esm/stories/Bridge/UnsupportedTokenScreen.stories.js.map +1 -1
  175. package/dist/esm/stories/Bridge/fixtures.js +15 -56
  176. package/dist/esm/stories/Bridge/fixtures.js.map +1 -1
  177. package/dist/esm/stories/BuyWidget.stories.js +37 -9
  178. package/dist/esm/stories/BuyWidget.stories.js.map +1 -1
  179. package/dist/esm/stories/utils.js +6 -3
  180. package/dist/esm/stories/utils.js.map +1 -1
  181. package/dist/esm/version.js +1 -1
  182. package/dist/esm/x402/common.js +3 -5
  183. package/dist/esm/x402/common.js.map +1 -1
  184. package/dist/esm/x402/facilitator.js +3 -4
  185. package/dist/esm/x402/facilitator.js.map +1 -1
  186. package/dist/esm/x402/schemas.js +5 -1
  187. package/dist/esm/x402/schemas.js.map +1 -1
  188. package/dist/esm/x402/settle-payment.js +6 -5
  189. package/dist/esm/x402/settle-payment.js.map +1 -1
  190. package/dist/esm/x402/sign.js +2 -6
  191. package/dist/esm/x402/sign.js.map +1 -1
  192. package/dist/esm/x402/types.js.map +1 -1
  193. package/dist/esm/x402/verify-payment.js +6 -5
  194. package/dist/esm/x402/verify-payment.js.map +1 -1
  195. package/dist/scripts/bridge-widget.d.ts +3 -3
  196. package/dist/scripts/bridge-widget.js +113 -150
  197. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +6 -0
  198. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  199. package/dist/types/react/core/hooks/usePaymentMethods.d.ts +1 -2
  200. package/dist/types/react/core/hooks/usePaymentMethods.d.ts.map +1 -1
  201. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  202. package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts +7 -12
  203. package/dist/types/react/web/ui/Bridge/BuyWidget.d.ts.map +1 -1
  204. package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts +5 -8
  205. package/dist/types/react/web/ui/Bridge/CheckoutWidget.d.ts.map +1 -1
  206. package/dist/types/react/web/ui/Bridge/DirectPayment.d.ts +15 -12
  207. package/dist/types/react/web/ui/Bridge/DirectPayment.d.ts.map +1 -1
  208. package/dist/types/react/web/ui/Bridge/FundWallet.d.ts +33 -15
  209. package/dist/types/react/web/ui/Bridge/FundWallet.d.ts.map +1 -1
  210. package/dist/types/react/web/ui/Bridge/QuoteLoader.d.ts +9 -12
  211. package/dist/types/react/web/ui/Bridge/QuoteLoader.d.ts.map +1 -1
  212. package/dist/types/react/web/ui/Bridge/StepRunner.d.ts +7 -7
  213. package/dist/types/react/web/ui/Bridge/StepRunner.d.ts.map +1 -1
  214. package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts +14 -7
  215. package/dist/types/react/web/ui/Bridge/TransactionPayment.d.ts.map +1 -1
  216. package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts +3 -5
  217. package/dist/types/react/web/ui/Bridge/TransactionWidget.d.ts.map +1 -1
  218. package/dist/types/react/web/ui/Bridge/UnsupportedTokenScreen.d.ts +4 -3
  219. package/dist/types/react/web/ui/Bridge/UnsupportedTokenScreen.d.ts.map +1 -1
  220. package/dist/types/react/web/ui/Bridge/bridge-widget/bridge-widget.d.ts +3 -3
  221. package/dist/types/react/web/ui/Bridge/bridge-widget/bridge-widget.d.ts.map +1 -1
  222. package/dist/types/react/web/ui/Bridge/common/WithHeader.d.ts +4 -4
  223. package/dist/types/react/web/ui/Bridge/common/WithHeader.d.ts.map +1 -1
  224. package/dist/types/react/web/ui/Bridge/common/active-wallet-details.d.ts +8 -0
  225. package/dist/types/react/web/ui/Bridge/common/active-wallet-details.d.ts.map +1 -0
  226. package/dist/types/react/web/ui/Bridge/common/decimal-input.d.ts +6 -0
  227. package/dist/types/react/web/ui/Bridge/common/decimal-input.d.ts.map +1 -0
  228. package/dist/types/react/web/ui/Bridge/common/selected-token-button.d.ts +13 -0
  229. package/dist/types/react/web/ui/Bridge/common/selected-token-button.d.ts.map +1 -0
  230. package/dist/types/react/web/ui/Bridge/common/token-balance.d.ts +8 -0
  231. package/dist/types/react/web/ui/Bridge/common/token-balance.d.ts.map +1 -0
  232. package/dist/types/react/web/ui/Bridge/common/token-query.d.ts +15 -0
  233. package/dist/types/react/web/ui/Bridge/common/token-query.d.ts.map +1 -0
  234. package/dist/types/react/web/ui/Bridge/payment-details/PaymentDetails.d.ts +13 -11
  235. package/dist/types/react/web/ui/Bridge/payment-details/PaymentDetails.d.ts.map +1 -1
  236. package/dist/types/react/web/ui/Bridge/payment-details/PaymentOverview.d.ts +8 -3
  237. package/dist/types/react/web/ui/Bridge/payment-details/PaymentOverview.d.ts.map +1 -1
  238. package/dist/types/react/web/ui/Bridge/payment-selection/PaymentSelection.d.ts +12 -16
  239. package/dist/types/react/web/ui/Bridge/payment-selection/PaymentSelection.d.ts.map +1 -1
  240. package/dist/types/react/web/ui/Bridge/payment-selection/TokenSelection.d.ts +1 -1
  241. package/dist/types/react/web/ui/Bridge/payment-selection/TokenSelection.d.ts.map +1 -1
  242. package/dist/types/react/web/ui/Bridge/payment-success/SuccessScreen.d.ts +6 -6
  243. package/dist/types/react/web/ui/Bridge/payment-success/SuccessScreen.d.ts.map +1 -1
  244. package/dist/types/react/web/ui/Bridge/swap-widget/swap-ui.d.ts.map +1 -1
  245. package/dist/types/react/web/ui/Bridge/types.d.ts +39 -0
  246. package/dist/types/react/web/ui/Bridge/types.d.ts.map +1 -0
  247. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  248. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -1
  249. package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts +2 -1
  250. package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts.map +1 -1
  251. package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts +0 -1
  252. package/dist/types/react/web/ui/TransactionButton/DepositScreen.d.ts.map +1 -1
  253. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +3 -1
  254. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -1
  255. package/dist/types/react/web/ui/components/CopyIcon.d.ts +1 -0
  256. package/dist/types/react/web/ui/components/CopyIcon.d.ts.map +1 -1
  257. package/dist/types/script-exports/bridge-widget-script.d.ts +3 -3
  258. package/dist/types/script-exports/bridge-widget-script.d.ts.map +1 -1
  259. package/dist/types/stories/Bridge/CheckoutWidget.stories.d.ts +25 -0
  260. package/dist/types/stories/Bridge/CheckoutWidget.stories.d.ts.map +1 -0
  261. package/dist/types/stories/Bridge/ErrorBanner.stories.d.ts +3 -47
  262. package/dist/types/stories/Bridge/ErrorBanner.stories.d.ts.map +1 -1
  263. package/dist/types/stories/Bridge/PaymentDetails.stories.d.ts +3 -56
  264. package/dist/types/stories/Bridge/PaymentDetails.stories.d.ts.map +1 -1
  265. package/dist/types/stories/Bridge/PaymentSelection.stories.d.ts +5 -63
  266. package/dist/types/stories/Bridge/PaymentSelection.stories.d.ts.map +1 -1
  267. package/dist/types/stories/Bridge/StepRunner.stories.d.ts +4 -52
  268. package/dist/types/stories/Bridge/StepRunner.stories.d.ts.map +1 -1
  269. package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts +4 -54
  270. package/dist/types/stories/Bridge/SuccessScreen.stories.d.ts.map +1 -1
  271. package/dist/types/stories/Bridge/Transaction/TransactionWidget.stories.d.ts +11 -0
  272. package/dist/types/stories/Bridge/Transaction/TransactionWidget.stories.d.ts.map +1 -0
  273. package/dist/types/stories/Bridge/Transaction/useSendTransactionModal.stories.d.ts +18 -0
  274. package/dist/types/stories/Bridge/Transaction/useSendTransactionModal.stories.d.ts.map +1 -0
  275. package/dist/types/stories/Bridge/UnsupportedTokenScreen.stories.d.ts +3 -34
  276. package/dist/types/stories/Bridge/UnsupportedTokenScreen.stories.d.ts.map +1 -1
  277. package/dist/types/stories/Bridge/fixtures.d.ts +19 -17
  278. package/dist/types/stories/Bridge/fixtures.d.ts.map +1 -1
  279. package/dist/types/stories/BuyWidget.stories.d.ts +9 -1
  280. package/dist/types/stories/BuyWidget.stories.d.ts.map +1 -1
  281. package/dist/types/stories/utils.d.ts +0 -2
  282. package/dist/types/stories/utils.d.ts.map +1 -1
  283. package/dist/types/version.d.ts +1 -1
  284. package/dist/types/x402/common.d.ts.map +1 -1
  285. package/dist/types/x402/facilitator.d.ts +4 -5
  286. package/dist/types/x402/facilitator.d.ts.map +1 -1
  287. package/dist/types/x402/schemas.d.ts +21 -0
  288. package/dist/types/x402/schemas.d.ts.map +1 -1
  289. package/dist/types/x402/settle-payment.d.ts.map +1 -1
  290. package/dist/types/x402/types.d.ts +5 -4
  291. package/dist/types/x402/types.d.ts.map +1 -1
  292. package/dist/types/x402/verify-payment.d.ts.map +1 -1
  293. package/package.json +3 -3
  294. package/src/react/core/hooks/transaction/useSendTransaction.ts +6 -0
  295. package/src/react/core/hooks/usePaymentMethods.ts +1 -4
  296. package/src/react/web/hooks/transaction/useSendTransaction.tsx +1 -0
  297. package/src/react/web/ui/Bridge/BuyWidget.tsx +355 -160
  298. package/src/react/web/ui/Bridge/CheckoutWidget.tsx +384 -107
  299. package/src/react/web/ui/Bridge/DirectPayment.tsx +34 -26
  300. package/src/react/web/ui/Bridge/FundWallet.tsx +610 -266
  301. package/src/react/web/ui/Bridge/QuoteLoader.tsx +10 -20
  302. package/src/react/web/ui/Bridge/StepRunner.tsx +7 -7
  303. package/src/react/web/ui/Bridge/TransactionPayment.tsx +35 -25
  304. package/src/react/web/ui/Bridge/TransactionWidget.tsx +395 -71
  305. package/src/react/web/ui/Bridge/UnsupportedTokenScreen.tsx +3 -3
  306. package/src/react/web/ui/Bridge/bridge-widget/bridge-widget.tsx +16 -14
  307. package/src/react/web/ui/Bridge/common/WithHeader.tsx +13 -19
  308. package/src/react/web/ui/Bridge/common/active-wallet-details.tsx +103 -0
  309. package/src/react/web/ui/Bridge/common/decimal-input.tsx +61 -0
  310. package/src/react/web/ui/Bridge/common/selected-token-button.tsx +168 -0
  311. package/src/react/web/ui/Bridge/common/token-balance.tsx +23 -0
  312. package/src/react/web/ui/Bridge/common/token-query.ts +49 -0
  313. package/src/react/web/ui/Bridge/payment-details/PaymentDetails.tsx +23 -14
  314. package/src/react/web/ui/Bridge/payment-details/PaymentOverview.tsx +36 -22
  315. package/src/react/web/ui/Bridge/payment-selection/PaymentSelection.tsx +11 -22
  316. package/src/react/web/ui/Bridge/payment-selection/TokenSelection.tsx +1 -1
  317. package/src/react/web/ui/Bridge/payment-success/SuccessScreen.tsx +7 -8
  318. package/src/react/web/ui/Bridge/swap-widget/SwapWidget.tsx +14 -12
  319. package/src/react/web/ui/Bridge/swap-widget/swap-ui.tsx +19 -332
  320. package/src/react/web/ui/Bridge/types.ts +47 -0
  321. package/src/react/web/ui/ConnectWallet/Details.tsx +3 -1
  322. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +1 -5
  323. package/src/react/web/ui/ConnectWallet/screens/formatTokenBalance.ts +5 -1
  324. package/src/react/web/ui/TransactionButton/DepositScreen.tsx +1 -2
  325. package/src/react/web/ui/TransactionButton/TransactionModal.tsx +44 -27
  326. package/src/react/web/ui/components/CopyIcon.tsx +11 -2
  327. package/src/script-exports/bridge-widget-script.tsx +3 -3
  328. package/src/script-exports/readme.md +1 -8
  329. package/src/stories/Bridge/CheckoutWidget.stories.tsx +147 -0
  330. package/src/stories/Bridge/ErrorBanner.stories.tsx +13 -138
  331. package/src/stories/Bridge/PaymentDetails.stories.tsx +34 -349
  332. package/src/stories/Bridge/PaymentSelection.stories.tsx +28 -156
  333. package/src/stories/Bridge/StepRunner.stories.tsx +18 -65
  334. package/src/stories/Bridge/SuccessScreen.stories.tsx +21 -130
  335. package/src/stories/Bridge/Transaction/TransactionWidget.stories.tsx +63 -0
  336. package/src/stories/Bridge/Transaction/useSendTransactionModal.stories.tsx +68 -0
  337. package/src/stories/Bridge/UnsupportedTokenScreen.stories.tsx +19 -108
  338. package/src/stories/Bridge/fixtures.ts +36 -63
  339. package/src/stories/BuyWidget.stories.tsx +103 -8
  340. package/src/stories/utils.tsx +16 -9
  341. package/src/version.ts +1 -1
  342. package/src/x402/common.ts +2 -5
  343. package/src/x402/facilitator.ts +8 -8
  344. package/src/x402/schemas.ts +10 -0
  345. package/src/x402/settle-payment.ts +7 -6
  346. package/src/x402/sign.ts +3 -8
  347. package/src/x402/types.ts +5 -4
  348. package/src/x402/verify-payment.ts +7 -6
  349. package/dist/cjs/react/core/machines/paymentMachine.js +0 -191
  350. package/dist/cjs/react/core/machines/paymentMachine.js.map +0 -1
  351. package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js +0 -129
  352. package/dist/cjs/react/web/ui/Bridge/BridgeOrchestrator.js.map +0 -1
  353. package/dist/cjs/stories/Bridge/BridgeOrchestrator.stories.js +0 -258
  354. package/dist/cjs/stories/Bridge/BridgeOrchestrator.stories.js.map +0 -1
  355. package/dist/cjs/stories/Bridge/DirectPayment.stories.js +0 -222
  356. package/dist/cjs/stories/Bridge/DirectPayment.stories.js.map +0 -1
  357. package/dist/cjs/stories/Bridge/FundWallet.stories.js +0 -201
  358. package/dist/cjs/stories/Bridge/FundWallet.stories.js.map +0 -1
  359. package/dist/cjs/stories/Bridge/TransactionPayment.stories.js +0 -168
  360. package/dist/cjs/stories/Bridge/TransactionPayment.stories.js.map +0 -1
  361. package/dist/esm/react/core/machines/paymentMachine.js +0 -188
  362. package/dist/esm/react/core/machines/paymentMachine.js.map +0 -1
  363. package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js +0 -126
  364. package/dist/esm/react/web/ui/Bridge/BridgeOrchestrator.js.map +0 -1
  365. package/dist/esm/stories/Bridge/BridgeOrchestrator.stories.js +0 -255
  366. package/dist/esm/stories/Bridge/BridgeOrchestrator.stories.js.map +0 -1
  367. package/dist/esm/stories/Bridge/DirectPayment.stories.js +0 -219
  368. package/dist/esm/stories/Bridge/DirectPayment.stories.js.map +0 -1
  369. package/dist/esm/stories/Bridge/FundWallet.stories.js +0 -198
  370. package/dist/esm/stories/Bridge/FundWallet.stories.js.map +0 -1
  371. package/dist/esm/stories/Bridge/TransactionPayment.stories.js +0 -165
  372. package/dist/esm/stories/Bridge/TransactionPayment.stories.js.map +0 -1
  373. package/dist/types/react/core/machines/paymentMachine.d.ts +0 -89
  374. package/dist/types/react/core/machines/paymentMachine.d.ts.map +0 -1
  375. package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts +0 -99
  376. package/dist/types/react/web/ui/Bridge/BridgeOrchestrator.d.ts.map +0 -1
  377. package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts +0 -97
  378. package/dist/types/stories/Bridge/BridgeOrchestrator.stories.d.ts.map +0 -1
  379. package/dist/types/stories/Bridge/DirectPayment.stories.d.ts +0 -69
  380. package/dist/types/stories/Bridge/DirectPayment.stories.d.ts.map +0 -1
  381. package/dist/types/stories/Bridge/FundWallet.stories.d.ts +0 -67
  382. package/dist/types/stories/Bridge/FundWallet.stories.d.ts.map +0 -1
  383. package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts +0 -60
  384. package/dist/types/stories/Bridge/TransactionPayment.stories.d.ts.map +0 -1
  385. package/src/react/core/machines/paymentMachine.test.ts +0 -519
  386. package/src/react/core/machines/paymentMachine.ts +0 -295
  387. package/src/react/web/ui/Bridge/BridgeOrchestrator.tsx +0 -425
  388. package/src/stories/Bridge/BridgeOrchestrator.stories.tsx +0 -298
  389. package/src/stories/Bridge/DirectPayment.stories.tsx +0 -256
  390. package/src/stories/Bridge/FundWallet.stories.tsx +0 -227
  391. package/src/stories/Bridge/TransactionPayment.stories.tsx +0 -202
@@ -5,31 +5,25 @@ import { radius } from "../../../../core/design-system/index.js";
5
5
  import { Container } from "../../components/basic.js";
6
6
  import { Spacer } from "../../components/Spacer.js";
7
7
  import { Text } from "../../components/text.js";
8
- import type { UIOptions } from "../BridgeOrchestrator.js";
9
8
 
10
- export function WithHeader({
11
- children,
12
- uiOptions,
13
- defaultTitle,
14
- client,
15
- }: {
9
+ export function WithHeader(props: {
16
10
  children: React.ReactNode;
17
- uiOptions: UIOptions;
18
- defaultTitle: string;
11
+ title: string | undefined;
12
+ description: string | undefined;
13
+ image: string | undefined;
19
14
  client: ThirdwebClient;
20
15
  }) {
21
16
  const theme = useCustomTheme();
22
- const showTitle = uiOptions.metadata?.title !== "";
23
17
 
24
18
  return (
25
19
  <Container flex="column">
26
20
  {/* image */}
27
- {uiOptions.metadata?.image && (
21
+ {props.image && (
28
22
  <div
29
23
  style={{
30
24
  aspectRatio: "16/9",
31
25
  backgroundColor: theme.colors.tertiaryBg,
32
- backgroundImage: `url(${getUrl(client, uiOptions.metadata.image)})`,
26
+ backgroundImage: `url(${getUrl(props.client, props.image)})`,
33
27
  backgroundPosition: "center",
34
28
  backgroundSize: "cover",
35
29
  borderRadius: `${radius.md} ${radius.md} 0 0`,
@@ -40,23 +34,23 @@ export function WithHeader({
40
34
  )}
41
35
 
42
36
  <Container flex="column" px="md">
43
- <Spacer y="md+" />
37
+ <Spacer y="md" />
44
38
 
45
- {(showTitle || uiOptions.metadata?.description) && (
39
+ {(props.title || props.description) && (
46
40
  <>
47
41
  {/* title */}
48
- {showTitle && (
42
+ {props.title && (
49
43
  <Text color="primaryText" size="lg" weight={600}>
50
- {uiOptions.metadata?.title || defaultTitle}
44
+ {props.title}
51
45
  </Text>
52
46
  )}
53
47
 
54
48
  {/* Description */}
55
- {uiOptions.metadata?.description && (
49
+ {props.description && (
56
50
  <>
57
51
  <Spacer y="xxs" />
58
52
  <Text color="secondaryText" size="sm" multiline>
59
- {uiOptions.metadata?.description}
53
+ {props.description}
60
54
  </Text>
61
55
  </>
62
56
  )}
@@ -65,7 +59,7 @@ export function WithHeader({
65
59
  </>
66
60
  )}
67
61
 
68
- {children}
62
+ {props.children}
69
63
  </Container>
70
64
  </Container>
71
65
  );
@@ -0,0 +1,103 @@
1
+ import styled from "@emotion/styled";
2
+ import type { ThirdwebClient } from "../../../../../client/client.js";
3
+ import { shortenAddress } from "../../../../../utils/address.js";
4
+ import { AccountProvider } from "../../../../core/account/provider.js";
5
+ import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js";
6
+ import {
7
+ fontSize,
8
+ iconSize,
9
+ radius,
10
+ spacing,
11
+ } from "../../../../core/design-system/index.js";
12
+ import { WalletProvider } from "../../../../core/wallet/provider.js";
13
+ import { Container } from "../../components/basic.js";
14
+ import { Button } from "../../components/buttons.js";
15
+ import { AccountAvatar } from "../../prebuilt/Account/avatar.js";
16
+ import { AccountBlobbie } from "../../prebuilt/Account/blobbie.js";
17
+ import { AccountName } from "../../prebuilt/Account/name.js";
18
+ import { WalletIcon } from "../../prebuilt/Wallet/icon.js";
19
+ import type { ActiveWalletInfo } from "../swap-widget/types.js";
20
+
21
+ export function ActiveWalletDetails(props: {
22
+ activeWalletInfo: ActiveWalletInfo;
23
+ client: ThirdwebClient;
24
+ onClick: () => void;
25
+ }) {
26
+ const wallet = props.activeWalletInfo.activeWallet;
27
+ const account = props.activeWalletInfo.activeAccount;
28
+
29
+ const accountBlobbie = (
30
+ <AccountBlobbie
31
+ style={{
32
+ width: `${iconSize.xs}px`,
33
+ height: `${iconSize.xs}px`,
34
+ borderRadius: radius.full,
35
+ }}
36
+ />
37
+ );
38
+ const accountAvatarFallback = (
39
+ <WalletIcon
40
+ style={{
41
+ width: `${iconSize.xs}px`,
42
+ height: `${iconSize.xs}px`,
43
+ }}
44
+ fallbackComponent={accountBlobbie}
45
+ loadingComponent={accountBlobbie}
46
+ />
47
+ );
48
+
49
+ return (
50
+ <WalletButton
51
+ variant="ghost-solid"
52
+ style={{
53
+ paddingInline: spacing.xxs,
54
+ paddingBlock: "2px",
55
+ }}
56
+ onClick={props.onClick}
57
+ >
58
+ <AccountProvider address={account.address} client={props.client}>
59
+ <WalletProvider id={wallet.id}>
60
+ <Container flex="row" gap="xxs" center="y">
61
+ <AccountAvatar
62
+ style={{
63
+ width: `${iconSize.xs}px`,
64
+ height: `${iconSize.xs}px`,
65
+ borderRadius: radius.full,
66
+ objectFit: "cover",
67
+ }}
68
+ fallbackComponent={accountAvatarFallback}
69
+ loadingComponent={accountAvatarFallback}
70
+ />
71
+
72
+ <span
73
+ style={{
74
+ fontSize: fontSize.xs,
75
+ letterSpacing: "0.025em",
76
+ }}
77
+ >
78
+ <AccountName
79
+ fallbackComponent={
80
+ <span>{shortenAddress(account.address)}</span>
81
+ }
82
+ loadingComponent={
83
+ <span>{shortenAddress(account.address)}</span>
84
+ }
85
+ />
86
+ </span>
87
+ </Container>
88
+ </WalletProvider>
89
+ </AccountProvider>
90
+ </WalletButton>
91
+ );
92
+ }
93
+
94
+ const WalletButton = /* @__PURE__ */ styled(Button)(() => {
95
+ const theme = useCustomTheme();
96
+ return {
97
+ color: theme.colors.secondaryText,
98
+ transition: "color 200ms ease",
99
+ "&:hover": {
100
+ color: theme.colors.primaryText,
101
+ },
102
+ };
103
+ });
@@ -0,0 +1,61 @@
1
+ import { Input } from "../../components/formElements.js";
2
+
3
+ type InputProps = React.JSX.IntrinsicElements["input"];
4
+
5
+ export function DecimalInput(
6
+ props: Exclude<
7
+ InputProps,
8
+ "onChange" | "onClick" | "inputMode" | "pattern" | "type" | "value"
9
+ > & {
10
+ setValue: (value: string) => void;
11
+ },
12
+ ) {
13
+ const handleAmountChange = (inputValue: string) => {
14
+ let processedValue = inputValue;
15
+
16
+ // Replace comma with period if it exists
17
+ processedValue = processedValue.replace(",", ".");
18
+
19
+ if (processedValue.startsWith(".")) {
20
+ processedValue = `0${processedValue}`;
21
+ }
22
+
23
+ const numValue = Number(processedValue);
24
+ if (Number.isNaN(numValue)) {
25
+ return;
26
+ }
27
+
28
+ if (
29
+ processedValue.length > 1 &&
30
+ processedValue.startsWith("0") &&
31
+ !processedValue.startsWith("0.")
32
+ ) {
33
+ props.setValue(processedValue.slice(1));
34
+ } else {
35
+ props.setValue(processedValue);
36
+ }
37
+ };
38
+
39
+ return (
40
+ <Input
41
+ {...props}
42
+ inputMode="decimal"
43
+ onChange={(e) => {
44
+ handleAmountChange(e.target.value);
45
+ }}
46
+ onClick={(e) => {
47
+ // put cursor at the end of the input
48
+ if (props.value === "") {
49
+ e.currentTarget.setSelectionRange(
50
+ e.currentTarget.value.length,
51
+ e.currentTarget.value.length,
52
+ );
53
+ }
54
+ }}
55
+ pattern="^[0-9]*[.,]?[0-9]*$"
56
+ placeholder="0.0"
57
+ type="text"
58
+ variant="transparent"
59
+ />
60
+ );
61
+ }
@@ -0,0 +1,168 @@
1
+ import { ChevronDownIcon } from "@radix-ui/react-icons";
2
+ import type { TokenWithPrices } from "../../../../../bridge/index.js";
3
+ import type { BridgeChain } from "../../../../../bridge/types/Chain.js";
4
+ import type { ThirdwebClient } from "../../../../../client/client.js";
5
+ import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js";
6
+ import {
7
+ fontSize,
8
+ iconSize,
9
+ radius,
10
+ spacing,
11
+ } from "../../../../core/design-system/index.js";
12
+ import { Container } from "../../components/basic.js";
13
+ import { Button } from "../../components/buttons.js";
14
+ import { Img } from "../../components/Img.js";
15
+ import { Skeleton } from "../../components/Skeleton.js";
16
+ import { Text } from "../../components/text.js";
17
+ import { cleanedChainName } from "../swap-widget/utils.js";
18
+
19
+ export function SelectedTokenButton(props: {
20
+ selectedToken:
21
+ | {
22
+ data: TokenWithPrices | undefined;
23
+ isFetching: boolean;
24
+ }
25
+ | undefined;
26
+ client: ThirdwebClient;
27
+ onSelectToken: () => void;
28
+ chain: BridgeChain | undefined;
29
+ }) {
30
+ const theme = useCustomTheme();
31
+ return (
32
+ <Button
33
+ variant="ghost-solid"
34
+ hoverBg="secondaryButtonBg"
35
+ fullWidth
36
+ onClick={props.onSelectToken}
37
+ gap="sm"
38
+ style={{
39
+ borderBottom: `1px dashed ${theme.colors.borderColor}`,
40
+ justifyContent: "space-between",
41
+ paddingInline: spacing.md,
42
+ paddingBlock: spacing.md,
43
+ borderRadius: 0,
44
+ }}
45
+ >
46
+ <Container gap="sm" flex="row" center="y">
47
+ {/* icons */}
48
+ <Container relative color="secondaryText">
49
+ {/* token icon */}
50
+ {props.selectedToken ? (
51
+ <Img
52
+ key={props.selectedToken?.data?.iconUri}
53
+ src={
54
+ props.selectedToken?.data === undefined
55
+ ? undefined
56
+ : props.selectedToken.data.iconUri || ""
57
+ }
58
+ client={props.client}
59
+ width="40"
60
+ height="40"
61
+ fallback={
62
+ <Container
63
+ style={{
64
+ background: `linear-gradient(45deg, white, ${theme.colors.accentText})`,
65
+ borderRadius: radius.full,
66
+ width: "40px",
67
+ height: "40px",
68
+ }}
69
+ />
70
+ }
71
+ style={{
72
+ objectFit: "cover",
73
+ borderRadius: radius.full,
74
+ }}
75
+ />
76
+ ) : (
77
+ <Container
78
+ style={{
79
+ border: `1px solid ${theme.colors.borderColor}`,
80
+ background: `linear-gradient(45deg, white, ${theme.colors.accentText})`,
81
+ borderRadius: radius.full,
82
+ width: "40px",
83
+ height: "40px",
84
+ }}
85
+ />
86
+ )}
87
+
88
+ {/* chain icon */}
89
+ {props.chain && (
90
+ <Container
91
+ bg="modalBg"
92
+ style={{
93
+ padding: "2px",
94
+ position: "absolute",
95
+ bottom: -2,
96
+ right: -2,
97
+ display: "flex",
98
+ borderRadius: radius.full,
99
+ }}
100
+ >
101
+ <Img
102
+ src={props.chain?.icon}
103
+ client={props.client}
104
+ width={iconSize.sm}
105
+ height={iconSize.sm}
106
+ style={{
107
+ borderRadius: radius.full,
108
+ }}
109
+ />
110
+ </Container>
111
+ )}
112
+ </Container>
113
+
114
+ {/* token symbol and chain name */}
115
+ {props.selectedToken ? (
116
+ <Container flex="column" style={{ gap: "3px" }}>
117
+ {props.selectedToken?.isFetching ? (
118
+ <Skeleton width="60px" height={fontSize.md} />
119
+ ) : (
120
+ <Text size="md" color="primaryText" weight={500}>
121
+ {props.selectedToken?.data?.symbol}
122
+ </Text>
123
+ )}
124
+
125
+ {props.chain ? (
126
+ <Text
127
+ size="xs"
128
+ color="secondaryText"
129
+ style={{
130
+ overflow: "hidden",
131
+ textOverflow: "ellipsis",
132
+ whiteSpace: "nowrap",
133
+ }}
134
+ >
135
+ {cleanedChainName(props.chain.name)}
136
+ </Text>
137
+ ) : (
138
+ <Skeleton width="140px" height={fontSize.sm} />
139
+ )}
140
+ </Container>
141
+ ) : (
142
+ <Container flex="column" style={{ gap: "3px" }}>
143
+ <Text size="md" color="primaryText" weight={500}>
144
+ Select Token
145
+ </Text>
146
+ <Text size="xs" color="secondaryText">
147
+ Required
148
+ </Text>
149
+ </Container>
150
+ )}
151
+ </Container>
152
+ <Container
153
+ color="secondaryText"
154
+ flex="row"
155
+ center="both"
156
+ borderColor="borderColor"
157
+ style={{
158
+ borderRadius: radius.full,
159
+ borderWidth: 1,
160
+ borderStyle: "solid",
161
+ padding: spacing.xs,
162
+ }}
163
+ >
164
+ <ChevronDownIcon width={iconSize.sm} height={iconSize.sm} />
165
+ </Container>
166
+ </Button>
167
+ );
168
+ }
@@ -0,0 +1,23 @@
1
+ import { defineChain } from "../../../../../chains/utils.js";
2
+ import type { ThirdwebClient } from "../../../../../client/client.js";
3
+ import { NATIVE_TOKEN_ADDRESS } from "../../../../../constants/addresses.js";
4
+ import { getAddress } from "../../../../../utils/address.js";
5
+ import { useWalletBalance } from "../../../../core/hooks/others/useWalletBalance.js";
6
+
7
+ export function useTokenBalance(props: {
8
+ chainId: number | undefined;
9
+ tokenAddress: string | undefined;
10
+ client: ThirdwebClient;
11
+ walletAddress: string | undefined;
12
+ }) {
13
+ return useWalletBalance({
14
+ address: props.walletAddress,
15
+ chain: props.chainId ? defineChain(props.chainId) : undefined,
16
+ client: props.client,
17
+ tokenAddress: props.tokenAddress
18
+ ? getAddress(props.tokenAddress) === getAddress(NATIVE_TOKEN_ADDRESS)
19
+ ? undefined
20
+ : getAddress(props.tokenAddress)
21
+ : undefined,
22
+ });
23
+ }
@@ -0,0 +1,49 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import type { TokenWithPrices } from "../../../../../bridge/index.js";
3
+ import type { ThirdwebClient } from "../../../../../client/client.js";
4
+ import { NATIVE_TOKEN_ADDRESS } from "../../../../../constants/addresses.js";
5
+ import { getToken } from "../../../../../pay/convert/get-token.js";
6
+
7
+ type TokenQueryResult =
8
+ | { type: "success"; token: TokenWithPrices }
9
+ | {
10
+ type: "unsupported_token";
11
+ };
12
+
13
+ export function useTokenQuery(params: {
14
+ tokenAddress: string | undefined;
15
+ chainId: number | undefined;
16
+ client: ThirdwebClient;
17
+ }) {
18
+ return useQuery({
19
+ enabled: !!params.chainId,
20
+ queryFn: async (): Promise<TokenQueryResult> => {
21
+ if (!params.chainId) {
22
+ throw new Error("Chain ID is required");
23
+ }
24
+ const tokenAddress = params.tokenAddress || NATIVE_TOKEN_ADDRESS;
25
+ const token = await getToken(
26
+ params.client,
27
+ tokenAddress,
28
+ params.chainId,
29
+ ).catch((err) => {
30
+ err.message.includes("not supported") ? undefined : Promise.reject(err);
31
+ });
32
+
33
+ if (!token) {
34
+ return {
35
+ type: "unsupported_token",
36
+ };
37
+ }
38
+
39
+ return {
40
+ token: token,
41
+ type: "success",
42
+ };
43
+ },
44
+ queryKey: ["bridge.getToken", params],
45
+ refetchOnWindowFocus: false,
46
+ refetchOnMount: false,
47
+ refetchOnReconnect: false,
48
+ });
49
+ }
@@ -4,11 +4,11 @@ import { useMemo } from "react";
4
4
  import { trackPayEvent } from "../../../../../analytics/track/pay.js";
5
5
  import { defineChain } from "../../../../../chains/utils.js";
6
6
  import type { ThirdwebClient } from "../../../../../client/client.js";
7
+ import type { SupportedFiatCurrency } from "../../../../../pay/convert/type.js";
7
8
  import { useCustomTheme } from "../../../../core/design-system/CustomThemeProvider.js";
8
9
  import { radius, spacing } from "../../../../core/design-system/index.js";
9
10
  import { useChainsQuery } from "../../../../core/hooks/others/useChainQuery.js";
10
11
  import type { BridgePrepareResult } from "../../../../core/hooks/useBridgePrepare.js";
11
- import type { PaymentMethod } from "../../../../core/machines/paymentMachine.js";
12
12
  import {
13
13
  formatCurrencyAmount,
14
14
  formatTokenAmount,
@@ -17,17 +17,20 @@ import { Container, ModalHeader } from "../../components/basic.js";
17
17
  import { Button } from "../../components/buttons.js";
18
18
  import { Spacer } from "../../components/Spacer.js";
19
19
  import { Text } from "../../components/text.js";
20
- import type { UIOptions } from "../BridgeOrchestrator.js";
20
+ import type { ModeInfo, PaymentMethod } from "../types.js";
21
+
21
22
  import { PaymentOverview } from "./PaymentOverview.js";
22
23
 
23
- export interface PaymentDetailsProps {
24
- title?: string;
25
- confirmButtonLabel?: string;
24
+ type PaymentDetailsProps = {
25
+ metadata: {
26
+ title: string | undefined;
27
+ description: string | undefined;
28
+ };
26
29
 
27
- /**
28
- * The UI mode to use
29
- */
30
- uiOptions: UIOptions;
30
+ currency: SupportedFiatCurrency;
31
+ modeInfo: ModeInfo;
32
+
33
+ confirmButtonLabel: string | undefined;
31
34
  /**
32
35
  * The client to use
33
36
  */
@@ -55,18 +58,19 @@ export interface PaymentDetailsProps {
55
58
  * Called when an error occurs
56
59
  */
57
60
  onError: (error: Error) => void;
58
- }
61
+ };
59
62
 
60
63
  export function PaymentDetails({
61
- title,
64
+ metadata,
62
65
  confirmButtonLabel,
63
- uiOptions,
64
66
  client,
65
67
  paymentMethod,
66
68
  preparedQuote,
67
69
  onConfirm,
68
70
  onBack,
69
71
  onError,
72
+ currency,
73
+ modeInfo,
70
74
  }: PaymentDetailsProps) {
71
75
  const theme = useCustomTheme();
72
76
 
@@ -267,7 +271,10 @@ export function PaymentDetails({
267
271
 
268
272
  return (
269
273
  <Container flex="column" fullHeight px="md" pb="md" pt="md+">
270
- <ModalHeader onBack={onBack} title={title || "Payment Details"} />
274
+ <ModalHeader
275
+ onBack={onBack}
276
+ title={metadata.title || "Payment Details"}
277
+ />
271
278
 
272
279
  <Spacer y="lg" />
273
280
 
@@ -276,6 +283,9 @@ export function PaymentDetails({
276
283
  <Container flex="column">
277
284
  {displayData.destinationToken && (
278
285
  <PaymentOverview
286
+ currency={currency}
287
+ metadata={metadata}
288
+ modeInfo={modeInfo}
279
289
  client={client}
280
290
  fromAmount={displayData.originAmount}
281
291
  paymentMethod={paymentMethod}
@@ -286,7 +296,6 @@ export function PaymentDetails({
286
296
  }
287
297
  toAmount={displayData.destinationAmount}
288
298
  toToken={displayData.destinationToken}
289
- uiOptions={uiOptions}
290
299
  />
291
300
  )}
292
301