thirdweb 5.108.6 → 5.108.7

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 +0 -1
  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 +0 -1
  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 +2 -3
  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 +1 -1
  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 +3 -3
  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
@@ -1,14 +1,16 @@
1
1
  "use client";
2
2
 
3
3
  import { useQuery } from "@tanstack/react-query";
4
+ import { useCallback, useMemo, useState } from "react";
4
5
  import { trackPayEvent } from "../../../../analytics/track/pay.js";
5
- import type { Token } from "../../../../bridge/index.js";
6
+ import type { TokenWithPrices } from "../../../../bridge/index.js";
6
7
  import type { Chain } from "../../../../chains/types.js";
7
8
  import type { ThirdwebClient } from "../../../../client/client.js";
8
9
  import { NATIVE_TOKEN_ADDRESS } from "../../../../constants/addresses.js";
9
10
  import { getToken } from "../../../../pay/convert/get-token.js";
10
11
  import type { SupportedFiatCurrency } from "../../../../pay/convert/type.js";
11
12
  import type { PurchaseData } from "../../../../pay/types.js";
13
+ import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
12
14
  import {
13
15
  type PreparedTransaction,
14
16
  prepareTransaction,
@@ -24,16 +26,31 @@ import { CustomThemeProvider } from "../../../core/design-system/CustomThemeProv
24
26
  import { iconSize, type Theme } from "../../../core/design-system/index.js";
25
27
  import type { SiweAuthOptions } from "../../../core/hooks/auth/useSiweAuth.js";
26
28
  import type { ConnectButton_connectModalOptions } from "../../../core/hooks/connection/ConnectButtonProps.js";
29
+ import type {
30
+ BridgePrepareRequest,
31
+ BridgePrepareResult,
32
+ } from "../../../core/hooks/useBridgePrepare.js";
33
+ import type { CompletedStatusResult } from "../../../core/hooks/useStepExecutor.js";
27
34
  import type { SupportedTokens } from "../../../core/utils/defaultTokens.js";
35
+ import { webWindowAdapter } from "../../adapters/WindowAdapter.js";
28
36
  import { AccentFailIcon } from "../ConnectWallet/icons/AccentFailIcon.js";
29
37
  import { useConnectLocale } from "../ConnectWallet/locale/getConnectLocale.js";
38
+ import type { ConnectLocale } from "../ConnectWallet/locale/types.js";
30
39
  import { EmbedContainer } from "../ConnectWallet/Modal/ConnectEmbed.js";
31
40
  import { DynamicHeight } from "../components/DynamicHeight.js";
32
41
  import { Spacer } from "../components/Spacer.js";
33
42
  import { Spinner } from "../components/Spinner.js";
34
43
  import { Text } from "../components/text.js";
44
+ import { ExecutingTxScreen } from "../TransactionButton/ExecutingScreen.js";
35
45
  import type { LocaleId } from "../types.js";
36
- import { BridgeOrchestrator, type UIOptions } from "./BridgeOrchestrator.js";
46
+ import { ErrorBanner } from "./ErrorBanner.js";
47
+ import { PaymentDetails } from "./payment-details/PaymentDetails.js";
48
+ import { PaymentSelection } from "./payment-selection/PaymentSelection.js";
49
+ import { SuccessScreen } from "./payment-success/SuccessScreen.js";
50
+ import { QuoteLoader } from "./QuoteLoader.js";
51
+ import { StepRunner } from "./StepRunner.js";
52
+ import { TransactionPayment } from "./TransactionPayment.js";
53
+ import type { PaymentMethod } from "./types.js";
37
54
  import { UnsupportedTokenScreen } from "./UnsupportedTokenScreen.js";
38
55
 
39
56
  export type TransactionWidgetProps = {
@@ -146,11 +163,6 @@ export type TransactionWidgetProps = {
146
163
  */
147
164
  feePayer?: "user" | "seller";
148
165
 
149
- /**
150
- * Preset fiat amounts to display in the UI. Defaults to [5, 10, 20].
151
- */
152
- presetOptions?: [number, number, number];
153
-
154
166
  /**
155
167
  * Arbitrary data to be included in the returned status and webhook events.
156
168
  */
@@ -159,7 +171,7 @@ export type TransactionWidgetProps = {
159
171
  /**
160
172
  * Callback triggered when the purchase is successful.
161
173
  */
162
- onSuccess?: () => void;
174
+ onSuccess?: (data: WaitForReceiptOptions) => void;
163
175
 
164
176
  /**
165
177
  * Callback triggered when the purchase encounters an error.
@@ -202,20 +214,6 @@ export type TransactionWidgetProps = {
202
214
  buttonLabel?: string;
203
215
  };
204
216
 
205
- // Enhanced UIOptions to handle unsupported token state
206
- type UIOptionsResult =
207
- | { type: "success"; data: UIOptions }
208
- | {
209
- type: "indexing_token";
210
- token: Token;
211
- chain: Chain;
212
- }
213
- | {
214
- type: "unsupported_token";
215
- tokenAddress: Address;
216
- chain: Chain;
217
- };
218
-
219
217
  /**
220
218
  * Widget a prebuilt UI for purchasing a specific token.
221
219
  *
@@ -328,10 +326,29 @@ type UIOptionsResult =
328
326
  *
329
327
  * @bridge
330
328
  */
329
+
331
330
  export function TransactionWidget(props: TransactionWidgetProps) {
332
- const localeQuery = useConnectLocale(props.locale || "en_US");
333
- const theme = props.theme || "dark";
331
+ return (
332
+ <TransactionWidgetContainer
333
+ theme={props.theme}
334
+ className={props.className}
335
+ style={props.style}
336
+ >
337
+ <TransactionWidgetContentWrapper {...props} />
338
+ </TransactionWidgetContainer>
339
+ );
340
+ }
334
341
 
342
+ type TransactionQueryResult =
343
+ | {
344
+ transaction: PreparedTransaction;
345
+ type: "success";
346
+ }
347
+ | {
348
+ type: "unsupported_token";
349
+ };
350
+
351
+ export function TransactionWidgetContentWrapper(props: TransactionWidgetProps) {
335
352
  useQuery({
336
353
  queryFn: () => {
337
354
  trackPayEvent({
@@ -345,8 +362,10 @@ export function TransactionWidget(props: TransactionWidgetProps) {
345
362
  queryKey: ["transaction_widget:render"],
346
363
  });
347
364
 
348
- const bridgeDataQuery = useQuery({
349
- queryFn: async (): Promise<UIOptionsResult> => {
365
+ const localQuery = useConnectLocale(props.locale || "en_US");
366
+
367
+ const txQuery = useQuery({
368
+ queryFn: async (): Promise<TransactionQueryResult> => {
350
369
  let erc20Value = props.transaction.erc20Value;
351
370
 
352
371
  if (props.amount) {
@@ -364,8 +383,6 @@ export function TransactionWidget(props: TransactionWidgetProps) {
364
383
  });
365
384
  if (!token) {
366
385
  return {
367
- chain: props.transaction.chain,
368
- tokenAddress: checksumAddress(tokenAddress),
369
386
  type: "unsupported_token",
370
387
  };
371
388
  }
@@ -382,27 +399,31 @@ export function TransactionWidget(props: TransactionWidgetProps) {
382
399
  });
383
400
 
384
401
  return {
385
- data: {
386
- currency: props.currency || "USD",
387
- buttonLabel: props.buttonLabel,
388
- metadata: {
389
- description: props.description,
390
- image: props.image,
391
- title: props.title,
392
- },
393
- mode: "transaction",
394
- transaction,
395
- },
402
+ transaction,
396
403
  type: "success",
397
404
  };
398
405
  },
399
- queryKey: ["bridgeData", stringify(props)],
406
+
407
+ queryKey: ["transaction-query", stringify(props)],
400
408
  retry: 1,
401
409
  });
402
410
 
403
- let content = null;
404
- if (!localeQuery.data || bridgeDataQuery.isLoading) {
405
- content = (
411
+ // if branding is disabled for widget, disable it for connect options too
412
+ const connectOptions = useMemo(() => {
413
+ if (props.showThirdwebBranding === false) {
414
+ return {
415
+ ...props.connectOptions,
416
+ connectModal: {
417
+ ...props.connectOptions?.connectModal,
418
+ showThirdwebBranding: props.showThirdwebBranding,
419
+ },
420
+ };
421
+ }
422
+ return props.connectOptions;
423
+ }, [props.connectOptions, props.showThirdwebBranding]);
424
+
425
+ if (txQuery.isPending || !localQuery.data) {
426
+ return (
406
427
  <div
407
428
  style={{
408
429
  alignItems: "center",
@@ -414,8 +435,8 @@ export function TransactionWidget(props: TransactionWidgetProps) {
414
435
  <Spinner color="secondaryText" size="xl" />
415
436
  </div>
416
437
  );
417
- } else if (bridgeDataQuery.error) {
418
- content = (
438
+ } else if (txQuery.error) {
439
+ return (
419
440
  <div
420
441
  style={{
421
442
  alignItems: "center",
@@ -428,56 +449,359 @@ export function TransactionWidget(props: TransactionWidgetProps) {
428
449
  <AccentFailIcon size={iconSize["3xl"]} />
429
450
  <Spacer y="lg" />
430
451
  <Text color="secondaryText" size="md">
431
- {bridgeDataQuery.error.message}
452
+ {txQuery.error.message}
432
453
  </Text>
433
454
  </div>
434
455
  );
435
- } else if (bridgeDataQuery.data?.type === "unsupported_token") {
436
- // Show unsupported token screen
437
- content = (
456
+ } else if (txQuery.data?.type === "unsupported_token") {
457
+ return (
438
458
  <UnsupportedTokenScreen
439
- chain={bridgeDataQuery.data.chain}
459
+ chain={props.transaction.chain}
440
460
  client={props.client}
441
- tokenAddress={props.tokenAddress}
461
+ tokenAddress={props.tokenAddress || NATIVE_TOKEN_ADDRESS}
442
462
  />
443
463
  );
444
- } else if (bridgeDataQuery.data?.type === "success") {
445
- // Show normal bridge orchestrator
446
- content = (
447
- <BridgeOrchestrator
448
- country={props.country}
449
- supportedTokens={props.supportedTokens}
464
+ } else if (txQuery.data?.type === "success") {
465
+ return (
466
+ <TransactionWidgetContent
467
+ {...props}
468
+ connectOptions={connectOptions}
469
+ connectLocale={localQuery.data}
470
+ transaction={txQuery.data.transaction}
471
+ currency={props.currency || "USD"}
472
+ paymentMethods={props.paymentMethods || ["crypto", "card"]}
473
+ showThirdwebBranding={
474
+ props.showThirdwebBranding === undefined
475
+ ? true
476
+ : props.showThirdwebBranding
477
+ }
478
+ />
479
+ );
480
+ }
481
+
482
+ return null;
483
+ }
484
+
485
+ type TransactionWidgetScreen =
486
+ | { id: "init-ui" }
487
+ | {
488
+ id: "buy:1.methodSelection";
489
+ destinationAmount: string;
490
+ destinationToken: TokenWithPrices;
491
+ receiverAddress: Address;
492
+ transaction: PreparedTransaction;
493
+ }
494
+ | {
495
+ id: "buy:2.load-quote";
496
+ destinationAmount: string;
497
+ destinationToken: TokenWithPrices;
498
+ receiverAddress: Address;
499
+ paymentMethod: PaymentMethod;
500
+ transaction: PreparedTransaction;
501
+ }
502
+ | {
503
+ id: "buy:3.preview";
504
+ preparedQuote: BridgePrepareResult;
505
+ request: BridgePrepareRequest;
506
+ destinationAmount: string;
507
+ destinationToken: TokenWithPrices;
508
+ paymentMethod: PaymentMethod;
509
+ receiverAddress: Address;
510
+ transaction: PreparedTransaction;
511
+ }
512
+ | {
513
+ id: "buy:4.execute-buy";
514
+ preparedQuote: BridgePrepareResult;
515
+ request: BridgePrepareRequest;
516
+ destinationAmount: string;
517
+ destinationToken: TokenWithPrices;
518
+ paymentMethod: PaymentMethod;
519
+ receiverAddress: Address;
520
+ transaction: PreparedTransaction;
521
+ }
522
+ | {
523
+ id: "buy:5.success";
524
+ completedStatuses: CompletedStatusResult[];
525
+ preparedQuote: BridgePrepareResult;
526
+ transaction: PreparedTransaction;
527
+ }
528
+ | {
529
+ id: "execute-tx";
530
+ transaction: PreparedTransaction;
531
+ }
532
+ | {
533
+ id: "error";
534
+ error: Error;
535
+ };
536
+
537
+ type RequiredParams<T extends object, keys extends keyof T> = T & {
538
+ [K in keys]-?: T[K];
539
+ };
540
+
541
+ function TransactionWidgetContent(
542
+ props: RequiredParams<
543
+ TransactionWidgetProps,
544
+ "currency" | "showThirdwebBranding" | "paymentMethods"
545
+ > & {
546
+ connectLocale: ConnectLocale;
547
+ },
548
+ ) {
549
+ const [screen, setScreen] = useState<TransactionWidgetScreen>({
550
+ id: "init-ui",
551
+ });
552
+
553
+ const handleError = useCallback(
554
+ (error: Error) => {
555
+ console.error(error);
556
+ props.onError?.(error);
557
+ setScreen({
558
+ id: "error",
559
+ error,
560
+ });
561
+ },
562
+ [props.onError],
563
+ );
564
+
565
+ if (screen.id === "init-ui") {
566
+ return (
567
+ <TransactionPayment
450
568
  client={props.client}
451
- connectLocale={localeQuery.data}
569
+ metadata={{
570
+ title: props.title,
571
+ description: props.description,
572
+ image: props.image,
573
+ }}
452
574
  connectOptions={props.connectOptions}
453
- onCancel={() => {
454
- props.onCancel?.();
575
+ onContinue={(destinationAmount, destinationToken, receiverAddress) => {
576
+ setScreen({
577
+ id: "buy:1.methodSelection",
578
+ destinationAmount,
579
+ destinationToken,
580
+ transaction: props.transaction,
581
+ receiverAddress,
582
+ });
455
583
  }}
456
- onComplete={() => {
457
- props.onSuccess?.();
584
+ onExecuteTransaction={() => {
585
+ setScreen({
586
+ id: "execute-tx",
587
+ transaction: props.transaction,
588
+ });
458
589
  }}
459
- onError={(err: Error) => {
460
- props.onError?.(err);
590
+ showThirdwebBranding={props.showThirdwebBranding}
591
+ currency={props.currency}
592
+ buttonLabel={props.buttonLabel}
593
+ transaction={props.transaction}
594
+ />
595
+ );
596
+ }
597
+
598
+ if (screen.id === "buy:1.methodSelection") {
599
+ return (
600
+ <PaymentSelection
601
+ // from props
602
+ client={props.client}
603
+ connectLocale={props.connectLocale}
604
+ connectOptions={props.connectOptions}
605
+ paymentMethods={props.paymentMethods}
606
+ currency={props.currency}
607
+ supportedTokens={props.supportedTokens}
608
+ country={props.country}
609
+ // others
610
+ feePayer={undefined}
611
+ destinationToken={screen.destinationToken}
612
+ destinationAmount={screen.destinationAmount}
613
+ receiverAddress={screen.receiverAddress}
614
+ onBack={() => {
615
+ setScreen({ id: "init-ui" });
616
+ }}
617
+ onError={(error) => {
618
+ handleError(error);
619
+ }}
620
+ onPaymentMethodSelected={(paymentMethod) => {
621
+ setScreen({
622
+ ...screen,
623
+ id: "buy:2.load-quote",
624
+ paymentMethod,
625
+ });
461
626
  }}
627
+ />
628
+ );
629
+ }
630
+
631
+ if (screen.id === "buy:2.load-quote") {
632
+ return (
633
+ <QuoteLoader
634
+ // from props
462
635
  paymentLinkId={props.paymentLinkId}
463
- paymentMethods={props.paymentMethods}
464
- presetOptions={props.presetOptions}
465
636
  purchaseData={props.purchaseData}
466
- receiverAddress={undefined}
467
- uiOptions={bridgeDataQuery.data.data}
468
- showThirdwebBranding={props.showThirdwebBranding}
637
+ client={props.client}
638
+ // others
639
+ feePayer={undefined}
640
+ sender={undefined}
641
+ mode="transaction"
642
+ amount={screen.destinationAmount}
643
+ destinationToken={screen.destinationToken}
644
+ onBack={() => {
645
+ setScreen({
646
+ ...screen,
647
+ id: "buy:1.methodSelection",
648
+ });
649
+ }}
650
+ onError={(error) => {
651
+ handleError(error);
652
+ }}
653
+ onQuoteReceived={(preparedQuote, request) => {
654
+ setScreen({
655
+ ...screen,
656
+ id: "buy:3.preview",
657
+ preparedQuote,
658
+ request,
659
+ });
660
+ }}
661
+ paymentMethod={screen.paymentMethod}
662
+ receiver={screen.receiverAddress}
663
+ />
664
+ );
665
+ }
666
+
667
+ if (screen.id === "buy:3.preview") {
668
+ return (
669
+ <PaymentDetails
670
+ // from props
671
+ client={props.client}
672
+ currency={props.currency}
673
+ metadata={{
674
+ title: props.title,
675
+ description: props.description,
676
+ }}
677
+ // others
678
+ confirmButtonLabel={undefined}
679
+ onBack={() => {
680
+ setScreen({
681
+ ...screen,
682
+ id: "buy:1.methodSelection",
683
+ });
684
+ }}
685
+ onConfirm={() => {
686
+ setScreen({
687
+ ...screen,
688
+ id: "buy:4.execute-buy",
689
+ });
690
+ }}
691
+ onError={(error) => {
692
+ handleError(error);
693
+ }}
694
+ paymentMethod={screen.paymentMethod}
695
+ preparedQuote={screen.preparedQuote}
696
+ modeInfo={{
697
+ mode: "transaction",
698
+ transaction: screen.transaction,
699
+ }}
469
700
  />
470
701
  );
471
702
  }
472
703
 
704
+ if (screen.id === "buy:4.execute-buy") {
705
+ return (
706
+ <StepRunner
707
+ // from props
708
+ client={props.client}
709
+ // others
710
+ title={undefined}
711
+ preparedQuote={screen.preparedQuote}
712
+ autoStart={true}
713
+ onBack={() => {
714
+ setScreen({
715
+ ...screen,
716
+ id: "buy:3.preview",
717
+ });
718
+ }}
719
+ onCancel={() => {
720
+ props.onCancel?.();
721
+ }}
722
+ onComplete={(completedStatuses) => {
723
+ setScreen({
724
+ ...screen,
725
+ id: "buy:5.success",
726
+ completedStatuses,
727
+ });
728
+ }}
729
+ request={screen.request}
730
+ wallet={screen.paymentMethod.payerWallet}
731
+ windowAdapter={webWindowAdapter}
732
+ />
733
+ );
734
+ }
735
+
736
+ if (screen.id === "buy:5.success") {
737
+ return (
738
+ <SuccessScreen
739
+ // from props
740
+ client={props.client}
741
+ hasPaymentId={!!props.paymentLinkId}
742
+ // others
743
+ completedStatuses={screen.completedStatuses}
744
+ onDone={() => {
745
+ setScreen({ id: "execute-tx", transaction: screen.transaction });
746
+ }}
747
+ preparedQuote={screen.preparedQuote}
748
+ showContinueWithTx={true}
749
+ windowAdapter={webWindowAdapter}
750
+ />
751
+ );
752
+ }
753
+
754
+ if (screen.id === "error") {
755
+ return (
756
+ <ErrorBanner
757
+ client={props.client}
758
+ error={screen.error}
759
+ onCancel={() => {
760
+ setScreen({ id: "init-ui" });
761
+ props.onCancel?.();
762
+ }}
763
+ onRetry={() => {
764
+ setScreen({ id: "init-ui" });
765
+ }}
766
+ />
767
+ );
768
+ }
769
+
770
+ if (screen.id === "execute-tx") {
771
+ return (
772
+ <ExecutingTxScreen
773
+ closeModal={() => {
774
+ setScreen({ id: "init-ui" });
775
+ }}
776
+ onTxSent={(data) => {
777
+ props.onSuccess?.(data);
778
+ }}
779
+ tx={screen.transaction}
780
+ windowAdapter={webWindowAdapter}
781
+ />
782
+ );
783
+ }
784
+
785
+ return null;
786
+ }
787
+
788
+ /**
789
+ * @internal
790
+ */
791
+ function TransactionWidgetContainer(props: {
792
+ theme: TransactionWidgetProps["theme"];
793
+ className: string | undefined;
794
+ style?: React.CSSProperties | undefined;
795
+ children: React.ReactNode;
796
+ }) {
473
797
  return (
474
- <CustomThemeProvider theme={theme}>
798
+ <CustomThemeProvider theme={props.theme || "dark"}>
475
799
  <EmbedContainer
476
800
  className={props.className}
477
801
  modalSize="compact"
478
802
  style={props.style}
479
803
  >
480
- <DynamicHeight>{content}</DynamicHeight>
804
+ <DynamicHeight>{props.children}</DynamicHeight>
481
805
  </EmbedContainer>
482
806
  </CustomThemeProvider>
483
807
  );
@@ -9,14 +9,14 @@ import { Container } from "../components/basic.js";
9
9
  import { Spacer } from "../components/Spacer.js";
10
10
  import { Text } from "../components/text.js";
11
11
 
12
- export interface UnsupportedTokenScreenProps {
12
+ type UnsupportedTokenScreenProps = {
13
13
  /**
14
14
  * The chain the token is on
15
15
  */
16
16
  chain: Chain;
17
17
  client: ThirdwebClient;
18
- tokenAddress?: string;
19
- }
18
+ tokenAddress: string;
19
+ };
20
20
 
21
21
  /**
22
22
  * Screen displayed when a specified token is not supported by the Bridge API
@@ -149,15 +149,15 @@ export type BridgeWidgetProps = {
149
149
  /**
150
150
  * Configuration for the Buy tab. This mirrors {@link BuyWidget} options where applicable.
151
151
  */
152
- buy: {
152
+ buy?: {
153
153
  /**
154
154
  * The amount to buy (as a decimal string), e.g. "1.5" for 1.5 tokens.
155
155
  */
156
- amount: string; // TODO - make it optional
156
+ amount?: string;
157
157
  /**
158
158
  * The chain the accepted token is on.
159
159
  */
160
- chainId: number; // TODO - make it optional
160
+ chainId?: number;
161
161
  /**
162
162
  * Address of the token to buy. Leave undefined for the native token, or use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE.
163
163
  */
@@ -291,21 +291,23 @@ export function BridgeWidget(props: BridgeWidgetProps) {
291
291
  {tab === "buy" && (
292
292
  <BuyWidget
293
293
  client={props.client}
294
- amount={props.buy.amount}
294
+ amount={props.buy?.amount}
295
295
  showThirdwebBranding={props.showThirdwebBranding}
296
- chain={defineChain(props.buy.chainId)}
296
+ chain={
297
+ props.buy?.chainId ? defineChain(props.buy.chainId) : undefined
298
+ }
297
299
  currency={props.currency}
298
300
  theme={props.theme}
299
301
  title="" // Keep it empty string to hide the title
300
- tokenAddress={props.buy.tokenAddress as `0x${string}` | undefined}
301
- buttonLabel={props.buy.buttonLabel}
302
- className={props.buy.className}
303
- country={props.buy.country}
304
- onCancel={props.buy.onCancel}
305
- onError={props.buy.onError}
306
- onSuccess={props.buy.onSuccess}
307
- presetOptions={props.buy.presetOptions}
308
- purchaseData={props.buy.purchaseData}
302
+ tokenAddress={props.buy?.tokenAddress as `0x${string}` | undefined}
303
+ buttonLabel={props.buy?.buttonLabel}
304
+ className={props.buy?.className}
305
+ country={props.buy?.country}
306
+ onCancel={props.buy?.onCancel}
307
+ onError={props.buy?.onError}
308
+ onSuccess={props.buy?.onSuccess}
309
+ presetOptions={props.buy?.presetOptions}
310
+ purchaseData={props.buy?.purchaseData}
309
311
  paymentMethods={["card"]}
310
312
  style={{
311
313
  border: "none",