thirdweb 5.39.0 → 5.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/dist/cjs/exports/react.js +7 -2
  2. package/dist/cjs/exports/react.js.map +1 -1
  3. package/dist/cjs/react/core/design-system/index.js +2 -0
  4. package/dist/cjs/react/core/design-system/index.js.map +1 -1
  5. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js +13 -94
  6. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  7. package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js +16 -3
  8. package/dist/cjs/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
  9. package/dist/cjs/react/core/utils/defaultTokens.js +32 -25
  10. package/dist/cjs/react/core/utils/defaultTokens.js.map +1 -1
  11. package/dist/cjs/react/core/utils/wallet.js +91 -13
  12. package/dist/cjs/react/core/utils/wallet.js.map +1 -1
  13. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +18 -127
  14. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  15. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +3 -1
  16. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  17. package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +7 -3
  18. package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
  19. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -1
  20. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  21. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +184 -118
  22. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  23. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js +104 -0
  24. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js.map +1 -0
  25. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +69 -0
  26. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -0
  27. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +23 -5
  28. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js +4 -4
  30. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +2 -2
  32. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +2 -2
  34. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +1 -1
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +1 -1
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +132 -45
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +2 -5
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +13 -8
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  43. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +1 -1
  44. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +1 -1
  45. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +1 -1
  46. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +1 -1
  47. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +1 -1
  48. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  49. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js +1 -1
  50. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js.map +1 -1
  51. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +1 -1
  52. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +1 -1
  53. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +9 -5
  54. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  55. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js +1 -1
  56. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js.map +1 -1
  57. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +8 -3
  58. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
  59. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js +1 -1
  60. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js.map +1 -1
  61. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js +1 -1
  62. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js.map +1 -1
  63. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js +84 -0
  64. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -0
  65. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +13 -7
  66. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +1 -1
  67. package/dist/cjs/react/web/ui/ConnectWallet/screens/nativeToken.js +3 -1
  68. package/dist/cjs/react/web/ui/ConnectWallet/screens/nativeToken.js.map +1 -1
  69. package/dist/cjs/react/web/ui/PayEmbed.js +16 -9
  70. package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
  71. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +53 -0
  72. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -0
  73. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +33 -0
  74. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -0
  75. package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +16 -5
  76. package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
  77. package/dist/cjs/react/web/wallets/shared/SocialLogin.js +18 -2
  78. package/dist/cjs/react/web/wallets/shared/SocialLogin.js.map +1 -1
  79. package/dist/cjs/react/web/wallets/shared/{openOauthSignInWindow.js → oauthSignIn.js} +2 -3
  80. package/dist/cjs/react/web/wallets/shared/oauthSignIn.js.map +1 -0
  81. package/dist/cjs/version.js +1 -1
  82. package/dist/cjs/wallets/in-app/core/wallet/index.js +15 -0
  83. package/dist/cjs/wallets/in-app/core/wallet/index.js.map +1 -1
  84. package/dist/cjs/wallets/in-app/web/in-app.js +10 -0
  85. package/dist/cjs/wallets/in-app/web/in-app.js.map +1 -1
  86. package/dist/cjs/wallets/in-app/web/lib/auth/index.js +2 -0
  87. package/dist/cjs/wallets/in-app/web/lib/auth/index.js.map +1 -1
  88. package/dist/cjs/wallets/in-app/web/lib/auth/oauth.js +9 -1
  89. package/dist/cjs/wallets/in-app/web/lib/auth/oauth.js.map +1 -1
  90. package/dist/cjs/wallets/in-app/web/lib/get-url-token.js +26 -0
  91. package/dist/cjs/wallets/in-app/web/lib/get-url-token.js.map +1 -0
  92. package/dist/cjs/wallets/in-app/web/lib/web-connector.js +13 -3
  93. package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
  94. package/dist/esm/exports/react.js +3 -1
  95. package/dist/esm/exports/react.js.map +1 -1
  96. package/dist/esm/react/core/design-system/index.js +2 -0
  97. package/dist/esm/react/core/design-system/index.js.map +1 -1
  98. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +13 -93
  99. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  100. package/dist/esm/react/core/hooks/wallets/useAutoConnect.js +16 -3
  101. package/dist/esm/react/core/hooks/wallets/useAutoConnect.js.map +1 -1
  102. package/dist/esm/react/core/utils/defaultTokens.js +31 -25
  103. package/dist/esm/react/core/utils/defaultTokens.js.map +1 -1
  104. package/dist/esm/react/core/utils/wallet.js +88 -13
  105. package/dist/esm/react/core/utils/wallet.js.map +1 -1
  106. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +20 -129
  107. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  108. package/dist/esm/react/web/ui/ConnectWallet/Details.js +3 -1
  109. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  110. package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +7 -3
  111. package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
  112. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -1
  113. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  114. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +188 -122
  115. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  116. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js +101 -0
  117. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js.map +1 -0
  118. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +66 -0
  119. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -0
  120. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +22 -5
  121. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
  122. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js +4 -4
  123. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js.map +1 -1
  124. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +2 -2
  125. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +1 -1
  126. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +2 -2
  127. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +1 -1
  128. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +1 -1
  129. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +1 -1
  130. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +130 -44
  131. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  132. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +2 -5
  133. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
  134. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +13 -8
  135. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  136. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +1 -1
  137. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +1 -1
  138. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +1 -1
  139. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +1 -1
  140. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +1 -1
  141. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  142. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js +1 -1
  143. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js.map +1 -1
  144. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +1 -1
  145. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +1 -1
  146. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +7 -4
  147. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  148. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js +1 -1
  149. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js.map +1 -1
  150. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +9 -4
  151. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
  152. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js +1 -1
  153. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js.map +1 -1
  154. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js +1 -1
  155. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js.map +1 -1
  156. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js +81 -0
  157. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -0
  158. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +14 -8
  159. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +1 -1
  160. package/dist/esm/react/web/ui/ConnectWallet/screens/nativeToken.js +3 -1
  161. package/dist/esm/react/web/ui/ConnectWallet/screens/nativeToken.js.map +1 -1
  162. package/dist/esm/react/web/ui/PayEmbed.js +16 -9
  163. package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
  164. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +50 -0
  165. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -0
  166. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +29 -0
  167. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -0
  168. package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +15 -4
  169. package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
  170. package/dist/esm/react/web/wallets/shared/SocialLogin.js +17 -1
  171. package/dist/esm/react/web/wallets/shared/SocialLogin.js.map +1 -1
  172. package/dist/esm/react/web/wallets/shared/{openOauthSignInWindow.js → oauthSignIn.js} +2 -3
  173. package/dist/esm/react/web/wallets/shared/oauthSignIn.js.map +1 -0
  174. package/dist/esm/version.js +1 -1
  175. package/dist/esm/wallets/in-app/core/wallet/index.js +15 -0
  176. package/dist/esm/wallets/in-app/core/wallet/index.js.map +1 -1
  177. package/dist/esm/wallets/in-app/web/in-app.js +10 -0
  178. package/dist/esm/wallets/in-app/web/in-app.js.map +1 -1
  179. package/dist/esm/wallets/in-app/web/lib/auth/index.js +2 -0
  180. package/dist/esm/wallets/in-app/web/lib/auth/index.js.map +1 -1
  181. package/dist/esm/wallets/in-app/web/lib/auth/oauth.js +7 -0
  182. package/dist/esm/wallets/in-app/web/lib/auth/oauth.js.map +1 -1
  183. package/dist/esm/wallets/in-app/web/lib/get-url-token.js +23 -0
  184. package/dist/esm/wallets/in-app/web/lib/get-url-token.js.map +1 -0
  185. package/dist/esm/wallets/in-app/web/lib/web-connector.js +14 -4
  186. package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
  187. package/dist/types/exports/react.d.ts +3 -2
  188. package/dist/types/exports/react.d.ts.map +1 -1
  189. package/dist/types/exports/utils.d.ts +1 -0
  190. package/dist/types/exports/utils.d.ts.map +1 -1
  191. package/dist/types/react/core/design-system/index.d.ts +2 -0
  192. package/dist/types/react/core/design-system/index.d.ts.map +1 -1
  193. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +80 -34
  194. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
  195. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +3 -15
  196. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  197. package/dist/types/react/core/hooks/wallets/useAutoConnect.d.ts.map +1 -1
  198. package/dist/types/react/core/utils/defaultTokens.d.ts +222 -0
  199. package/dist/types/react/core/utils/defaultTokens.d.ts.map +1 -1
  200. package/dist/types/react/core/utils/wallet.d.ts +43 -1
  201. package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
  202. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts +2 -4
  203. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  204. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts +3 -1
  205. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  206. package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
  207. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts +0 -3
  208. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
  209. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.d.ts +18 -0
  210. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.d.ts.map +1 -0
  211. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts +18 -0
  212. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -0
  213. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts +5 -0
  214. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts.map +1 -1
  215. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.d.ts +1 -2
  216. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.d.ts.map +1 -1
  217. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.d.ts +1 -2
  218. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.d.ts.map +1 -1
  219. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts +1 -2
  220. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts.map +1 -1
  221. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts +1 -2
  222. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts.map +1 -1
  223. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +14 -8
  224. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
  225. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts +19 -9
  226. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts.map +1 -1
  227. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts +6 -5
  228. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts.map +1 -1
  229. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts +0 -2
  230. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts.map +1 -1
  231. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts +1 -1
  232. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +1 -1
  233. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts +1 -1
  234. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts.map +1 -1
  235. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts +1 -1
  236. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts.map +1 -1
  237. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts +4 -0
  238. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts.map +1 -1
  239. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.d.ts.map +1 -1
  240. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts +1 -0
  241. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts.map +1 -1
  242. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.d.ts +1 -2
  243. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.d.ts.map +1 -1
  244. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.d.ts +1 -2
  245. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.d.ts.map +1 -1
  246. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts +19 -0
  247. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts.map +1 -0
  248. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts.map +1 -1
  249. package/dist/types/react/web/ui/ConnectWallet/screens/nativeToken.d.ts.map +1 -1
  250. package/dist/types/react/web/ui/PayEmbed.d.ts +0 -6
  251. package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
  252. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts +9 -0
  253. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -0
  254. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +24 -0
  255. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -0
  256. package/dist/types/react/web/wallets/shared/ConnectWalletSocialOptions.d.ts.map +1 -1
  257. package/dist/types/react/web/wallets/shared/SocialLogin.d.ts.map +1 -1
  258. package/dist/types/react/web/wallets/shared/{openOauthSignInWindow.d.ts → oauthSignIn.d.ts} +1 -2
  259. package/dist/types/react/web/wallets/shared/oauthSignIn.d.ts.map +1 -0
  260. package/dist/types/version.d.ts +1 -1
  261. package/dist/types/wallets/ecosystem/types.d.ts +3 -0
  262. package/dist/types/wallets/ecosystem/types.d.ts.map +1 -1
  263. package/dist/types/wallets/in-app/core/interfaces/connector.d.ts +4 -1
  264. package/dist/types/wallets/in-app/core/interfaces/connector.d.ts.map +1 -1
  265. package/dist/types/wallets/in-app/core/wallet/index.d.ts.map +1 -1
  266. package/dist/types/wallets/in-app/core/wallet/types.d.ts +4 -1
  267. package/dist/types/wallets/in-app/core/wallet/types.d.ts.map +1 -1
  268. package/dist/types/wallets/in-app/web/in-app.d.ts +10 -0
  269. package/dist/types/wallets/in-app/web/in-app.d.ts.map +1 -1
  270. package/dist/types/wallets/in-app/web/lib/auth/index.d.ts +11 -2
  271. package/dist/types/wallets/in-app/web/lib/auth/index.d.ts.map +1 -1
  272. package/dist/types/wallets/in-app/web/lib/auth/oauth.d.ts +5 -0
  273. package/dist/types/wallets/in-app/web/lib/auth/oauth.d.ts.map +1 -1
  274. package/dist/types/wallets/in-app/web/lib/get-url-token.d.ts +12 -0
  275. package/dist/types/wallets/in-app/web/lib/get-url-token.d.ts.map +1 -0
  276. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts +4 -1
  277. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
  278. package/package.json +1 -1
  279. package/src/exports/react.ts +14 -2
  280. package/src/exports/utils.ts +2 -0
  281. package/src/react/core/design-system/index.ts +2 -0
  282. package/src/react/core/hooks/connection/ConnectButtonProps.ts +103 -51
  283. package/src/react/core/hooks/transaction/useSendTransaction.ts +17 -127
  284. package/src/react/core/hooks/wallets/useAutoConnect.ts +17 -3
  285. package/src/react/core/utils/defaultTokens.ts +38 -26
  286. package/src/react/core/utils/wallet.ts +102 -18
  287. package/src/react/web/hooks/transaction/useSendTransaction.tsx +34 -278
  288. package/src/react/web/ui/ConnectWallet/Details.tsx +6 -4
  289. package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +9 -3
  290. package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +1 -1
  291. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +347 -383
  292. package/src/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.tsx +266 -0
  293. package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +253 -0
  294. package/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx +52 -21
  295. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.tsx +3 -6
  296. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.tsx +5 -6
  297. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx +2 -4
  298. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx +2 -4
  299. package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +16 -12
  300. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts +155 -60
  301. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.ts +8 -3
  302. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.ts +17 -12
  303. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +2 -2
  304. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx +2 -3
  305. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +1 -1
  306. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx +1 -1
  307. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx +2 -2
  308. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +27 -19
  309. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.tsx +8 -4
  310. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.tsx +12 -5
  311. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.tsx +2 -4
  312. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.tsx +3 -4
  313. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx +243 -0
  314. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.tsx +30 -17
  315. package/src/react/web/ui/ConnectWallet/screens/nativeToken.ts +5 -1
  316. package/src/react/web/ui/PayEmbed.tsx +31 -32
  317. package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +127 -0
  318. package/src/react/web/ui/TransactionButton/TransactionModal.tsx +83 -0
  319. package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +18 -4
  320. package/src/react/web/wallets/shared/SocialLogin.tsx +20 -1
  321. package/src/react/web/wallets/shared/{openOauthSignInWindow.ts → oauthSignIn.ts} +1 -2
  322. package/src/version.ts +1 -1
  323. package/src/wallets/ecosystem/types.ts +3 -0
  324. package/src/wallets/in-app/core/interfaces/connector.ts +6 -0
  325. package/src/wallets/in-app/core/wallet/index.ts +22 -0
  326. package/src/wallets/in-app/core/wallet/types.ts +4 -0
  327. package/src/wallets/in-app/web/in-app.ts +10 -0
  328. package/src/wallets/in-app/web/lib/auth/index.ts +14 -3
  329. package/src/wallets/in-app/web/lib/auth/oauth.ts +12 -0
  330. package/src/wallets/in-app/web/lib/get-url-token.ts +36 -0
  331. package/src/wallets/in-app/web/lib/web-connector.ts +18 -4
  332. package/dist/cjs/react/web/wallets/shared/openOauthSignInWindow.js.map +0 -1
  333. package/dist/esm/react/web/wallets/shared/openOauthSignInWindow.js.map +0 -1
  334. package/dist/types/react/web/wallets/shared/openOauthSignInWindow.d.ts.map +0 -1
@@ -1,21 +1,21 @@
1
1
  import { IdCardIcon } from "@radix-ui/react-icons";
2
- import { useMemo, useState } from "react";
2
+ import { useCallback, useMemo, useState } from "react";
3
3
  import type { Chain } from "../../../../../../chains/types.js";
4
4
  import type { ThirdwebClient } from "../../../../../../client/client.js";
5
5
  import { NATIVE_TOKEN_ADDRESS } from "../../../../../../constants/addresses.js";
6
6
  import type { GetBuyWithCryptoQuoteParams } from "../../../../../../pay/buyWithCrypto/getQuote.js";
7
7
  import { isSwapRequiredPostOnramp } from "../../../../../../pay/buyWithFiat/isSwapRequiredPostOnramp.js";
8
8
  import { formatNumber } from "../../../../../../utils/formatNumber.js";
9
- import { toEther, toTokens } from "../../../../../../utils/units.js";
10
9
  import type { Account } from "../../../../../../wallets/interfaces/wallet.js";
11
10
  import {
12
11
  type Theme,
13
- fontSize,
14
12
  iconSize,
15
13
  spacing,
16
14
  } from "../../../../../core/design-system/index.js";
17
- import type { PayUIOptions } from "../../../../../core/hooks/connection/ConnectButtonProps.js";
18
- import { useChainName } from "../../../../../core/hooks/others/useChainQuery.js";
15
+ import type {
16
+ FundWalletOptions,
17
+ PayUIOptions,
18
+ } from "../../../../../core/hooks/connection/ConnectButtonProps.js";
19
19
  import { useWalletBalance } from "../../../../../core/hooks/others/useWalletBalance.js";
20
20
  import { useBuyWithCryptoQuote } from "../../../../../core/hooks/pay/useBuyWithCryptoQuote.js";
21
21
  import { useBuyWithFiatQuote } from "../../../../../core/hooks/pay/useBuyWithFiatQuote.js";
@@ -29,11 +29,9 @@ import {
29
29
  DrawerOverlay,
30
30
  useDrawer,
31
31
  } from "../../../components/Drawer.js";
32
- import { Skeleton } from "../../../components/Skeleton.js";
33
32
  import { Spacer } from "../../../components/Spacer.js";
34
33
  import { Spinner } from "../../../components/Spinner.js";
35
34
  import { SwitchNetworkButton } from "../../../components/SwitchNetwork.js";
36
- import { TokenIcon } from "../../../components/TokenIcon.js";
37
35
  import { Container, Line, ModalHeader } from "../../../components/basic.js";
38
36
  import { Button } from "../../../components/buttons.js";
39
37
  import { Text } from "../../../components/text.js";
@@ -44,28 +42,28 @@ import { CoinsIcon } from "../../icons/CoinsIcon.js";
44
42
  import type { ConnectLocale } from "../../locale/types.js";
45
43
  import { TokenSelector } from "../TokenSelector.js";
46
44
  import { WalletSwitcherConnectionScreen } from "../WalletSwitcherConnectionScreen.js";
47
- import {
48
- type ERC20OrNativeToken,
49
- NATIVE_TOKEN,
50
- isNativeToken,
51
- } from "../nativeToken.js";
45
+ import { type ERC20OrNativeToken, isNativeToken } from "../nativeToken.js";
46
+ import { DirectPaymentModeScreen } from "./DirectPaymentModeScreen.js";
52
47
  import { EstimatedTimeAndFees } from "./EstimatedTimeAndFees.js";
53
48
  import { PayTokenIcon } from "./PayTokenIcon.js";
54
49
  import { PayWithCreditCard } from "./PayWIthCreditCard.js";
55
- import { ReceiverWalletDrawerScreen } from "./ReceiverWalletSelectionScreen.js";
50
+ import { TransactionModeScreen } from "./TransactionModeScreen.js";
56
51
  import { WalletSelectorButton } from "./WalletSelectorButton.js";
57
52
  import { CurrencySelection } from "./fiat/CurrencySelection.js";
58
53
  import { FiatFlow } from "./fiat/FiatFlow.js";
59
54
  import type { CurrencyMeta } from "./fiat/currencies.js";
60
- import type { BuyForTx, SelectedScreen } from "./main/types.js";
61
- import { useBuyTxStates } from "./main/useBuyTxStates.js";
62
- import { useEnabledPaymentMethods } from "./main/useEnabledPaymentMethods.js";
55
+ import type { SelectedScreen } from "./main/types.js";
56
+ import {
57
+ type PaymentMethods,
58
+ useEnabledPaymentMethods,
59
+ } from "./main/useEnabledPaymentMethods.js";
63
60
  import { useUISelectionStates } from "./main/useUISelectionStates.js";
64
61
  import { openOnrampPopup } from "./openOnRamppopup.js";
65
62
  import { BuyTokenInput } from "./swap/BuyTokenInput.js";
66
63
  import { FiatFees, SwapFees } from "./swap/Fees.js";
67
64
  import { PayWithCrypto } from "./swap/PayWithCrypto.js";
68
65
  import { SwapFlow } from "./swap/SwapFlow.js";
66
+ import { TransferFlow } from "./swap/TransferFlow.js";
69
67
  import { WalletSwitcherDrawerContent } from "./swap/WalletSwitcherDrawerContent.js";
70
68
  import { addPendingTx } from "./swap/pendingSwapTx.js";
71
69
  import {
@@ -80,10 +78,8 @@ export type BuyScreenProps = {
80
78
  title: string;
81
79
  onBack: (() => void) | undefined;
82
80
  supportedTokens: SupportedTokens | undefined;
83
- onViewPendingTx: () => void;
84
81
  client: ThirdwebClient;
85
82
  connectLocale: ConnectLocale;
86
- buyForTx: BuyForTx | undefined;
87
83
  payOptions: PayUIOptions;
88
84
  theme: "light" | "dark" | Theme;
89
85
  onDone: () => void;
@@ -104,9 +100,7 @@ export default function BuyScreen(props: BuyScreenProps) {
104
100
  return (
105
101
  <BuyScreenContent
106
102
  {...props}
107
- onViewPendingTx={props.onViewPendingTx}
108
103
  supportedDestinations={supportedDestinationsQuery.data}
109
- buyForTx={props.buyForTx}
110
104
  />
111
105
  );
112
106
  }
@@ -116,10 +110,8 @@ type BuyScreenContentProps = {
116
110
  client: ThirdwebClient;
117
111
  onBack?: () => void;
118
112
  supportedTokens?: SupportedTokens;
119
- onViewPendingTx: () => void;
120
113
  supportedDestinations: SupportedChainAndTokens;
121
114
  connectLocale: ConnectLocale;
122
- buyForTx?: BuyForTx;
123
115
  theme: "light" | "dark" | Theme;
124
116
  payOptions: PayUIOptions;
125
117
  onDone: () => void;
@@ -131,8 +123,7 @@ type BuyScreenContentProps = {
131
123
  * @internal
132
124
  */
133
125
  function BuyScreenContent(props: BuyScreenContentProps) {
134
- const { client, supportedDestinations, connectLocale, payOptions, buyForTx } =
135
- props;
126
+ const { client, supportedDestinations, connectLocale, payOptions } = props;
136
127
 
137
128
  const activeAccount = useActiveAccount();
138
129
  const { payer, setPayer } = usePayerSetup();
@@ -143,6 +134,11 @@ function BuyScreenContent(props: BuyScreenContentProps) {
143
134
 
144
135
  const [hasEditedAmount, setHasEditedAmount] = useState(false);
145
136
 
137
+ const onDone = useCallback(() => {
138
+ setScreen({ id: "main" });
139
+ props.onDone();
140
+ }, [props.onDone]);
141
+
146
142
  // UI selection
147
143
  const {
148
144
  tokenAmount,
@@ -160,7 +156,6 @@ function BuyScreenContent(props: BuyScreenContentProps) {
160
156
  setSelectedCurrency,
161
157
  } = useUISelectionStates({
162
158
  payOptions,
163
- buyForTx,
164
159
  supportedDestinations,
165
160
  });
166
161
 
@@ -195,6 +190,18 @@ function BuyScreenContent(props: BuyScreenContentProps) {
195
190
  );
196
191
  }, [props.supportedTokens, supportedSourcesQuery.data, payOptions]);
197
192
 
193
+ const enabledPaymentMethods = useEnabledPaymentMethods({
194
+ payOptions: props.payOptions,
195
+ supportedDestinations: props.supportedDestinations,
196
+ toChain: toChain,
197
+ toToken: toToken,
198
+ });
199
+
200
+ const payDisabled =
201
+ enabledPaymentMethods.showPaymentSelection === false &&
202
+ enabledPaymentMethods.buyWithCryptoEnabled === false &&
203
+ enabledPaymentMethods.buyWithFiatEnabled === false;
204
+
198
205
  // screens ----------------------------
199
206
 
200
207
  if (screen.id === "connect-payer-wallet") {
@@ -231,7 +238,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
231
238
  return (
232
239
  <SwapFlow
233
240
  title={props.title}
234
- isBuyForTx={!!props.buyForTx}
241
+ transactionMode={payOptions.mode === "transaction"}
235
242
  isEmbed={props.isEmbed}
236
243
  client={client}
237
244
  onBack={() => {
@@ -241,9 +248,8 @@ function BuyScreenContent(props: BuyScreenContentProps) {
241
248
  }}
242
249
  buyWithCryptoQuote={screen.quote}
243
250
  payer={payer}
244
- onViewPendingTx={props.onViewPendingTx}
245
251
  isFiatFlow={false}
246
- onDone={props.onDone}
252
+ onDone={onDone}
247
253
  onTryAgain={() => {
248
254
  setScreen({
249
255
  id: "buy-with-crypto",
@@ -257,7 +263,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
257
263
  return (
258
264
  <FiatFlow
259
265
  title={props.title}
260
- isBuyForTx={!!props.buyForTx}
266
+ transactionMode={payOptions.mode === "transaction"}
261
267
  quote={screen.quote}
262
268
  onBack={() => {
263
269
  setScreen({
@@ -270,15 +276,37 @@ function BuyScreenContent(props: BuyScreenContentProps) {
270
276
  props.payOptions.buyWithFiat?.testMode === true
271
277
  }
272
278
  theme={typeof props.theme === "string" ? props.theme : props.theme.type}
273
- onViewPendingTx={props.onViewPendingTx}
274
279
  openedWindow={screen.openedWindow}
275
- onDone={props.onDone}
280
+ onDone={onDone}
276
281
  isEmbed={props.isEmbed}
277
282
  payer={payer}
278
283
  />
279
284
  );
280
285
  }
281
286
 
287
+ if (screen.id === "transfer-flow" && payer && activeAccount) {
288
+ const goBack = () => setScreen({ id: "buy-with-crypto" });
289
+ // TODO (pay) pass it via screen props
290
+ const defaultRecipientAddress = (
291
+ props.payOptions as Extract<PayUIOptions, { mode: "direct_payment" }>
292
+ )?.paymentInfo?.sellerAddress;
293
+ const receiverAddress = defaultRecipientAddress || activeAccount.address;
294
+ return (
295
+ <TransferFlow
296
+ title={props.title}
297
+ onBack={goBack}
298
+ payer={payer}
299
+ client={props.client}
300
+ onDone={onDone}
301
+ chain={toChain}
302
+ token={toToken}
303
+ tokenAmount={tokenAmount}
304
+ receiverAddress={receiverAddress}
305
+ transactionMode={props.payOptions.mode === "transaction"}
306
+ />
307
+ );
308
+ }
309
+
282
310
  if (screen.id === "select-currency") {
283
311
  const goBack = () => setScreen(screen.backScreen);
284
312
  return (
@@ -295,8 +323,10 @@ function BuyScreenContent(props: BuyScreenContentProps) {
295
323
  if (screen.id === "select-to-token") {
296
324
  const chains = supportedDestinations.map((x) => x.chain);
297
325
  const goBack = () => setScreen(screen.backScreen);
326
+ const allowEdits = (payOptions as FundWalletOptions)?.prefillBuy
327
+ ?.allowEdits;
298
328
  // if token selection is disabled - only show network selector screen
299
- if (payOptions.prefillBuy?.allowEdits?.token === false) {
329
+ if (allowEdits?.token === false) {
300
330
  return (
301
331
  <ChainSelectionScreen
302
332
  chains={chains}
@@ -322,7 +352,7 @@ function BuyScreenContent(props: BuyScreenContentProps) {
322
352
  chain={toChain}
323
353
  chainSelection={
324
354
  // hide chain selection if it's disabled
325
- payOptions.prefillBuy?.allowEdits?.chain !== false
355
+ allowEdits?.chain !== false
326
356
  ? {
327
357
  chains: chains,
328
358
  select: (c) => {
@@ -397,28 +427,32 @@ function BuyScreenContent(props: BuyScreenContentProps) {
397
427
  <MainScreen
398
428
  title={props.title}
399
429
  payerAccount={payer?.account}
400
- buyForTx={buyForTx}
401
430
  client={client}
402
431
  onSelectBuyToken={() =>
403
432
  setScreen({ id: "select-to-token", backScreen: screen })
404
433
  }
405
434
  payOptions={payOptions}
406
435
  setTokenAmount={setTokenAmount}
436
+ setToChain={setToChain}
437
+ setToToken={setToToken}
438
+ setFromChain={setFromChain}
439
+ setFromToken={setFromToken}
407
440
  toChain={toChain}
408
441
  toToken={toToken}
409
442
  tokenAmount={tokenAmount}
410
443
  connectOptions={props.connectOptions}
411
- onViewPendingTx={props.onViewPendingTx}
412
444
  setScreen={setScreen}
413
445
  supportedDestinations={supportedDestinations}
414
446
  onBack={props.onBack}
415
447
  theme={props.theme}
416
448
  hasEditedAmount={hasEditedAmount}
417
449
  setHasEditedAmount={setHasEditedAmount}
450
+ enabledPaymentMethods={enabledPaymentMethods}
418
451
  />
419
452
  )}
420
453
 
421
454
  {(screen.id === "select-payment-method" ||
455
+ screen.id === "select-wallet" ||
422
456
  screen.id === "buy-with-crypto" ||
423
457
  screen.id === "buy-with-fiat") &&
424
458
  payer && (
@@ -430,11 +464,14 @@ function BuyScreenContent(props: BuyScreenContentProps) {
430
464
  client={client}
431
465
  onBack={() => {
432
466
  if (
433
- screen.id === "buy-with-crypto" ||
434
- screen.id === "buy-with-fiat"
467
+ enabledPaymentMethods.showPaymentSelection &&
468
+ (screen.id === "select-wallet" ||
469
+ screen.id === "buy-with-fiat")
435
470
  ) {
436
471
  setScreen({ id: "select-payment-method" });
437
- } else if (screen.id === "select-payment-method") {
472
+ } else if (screen.id === "buy-with-crypto") {
473
+ setScreen({ id: "select-wallet" });
474
+ } else {
438
475
  setScreen({ id: "main" });
439
476
  }
440
477
  }}
@@ -443,6 +480,38 @@ function BuyScreenContent(props: BuyScreenContentProps) {
443
480
  <PaymentMethodSelection setScreen={(id) => setScreen({ id })} />
444
481
  )}
445
482
 
483
+ {screen.id === "select-wallet" && (
484
+ <WalletSwitcherDrawerContent
485
+ client={client}
486
+ onSelect={(w) => {
487
+ const chain = w.getChain();
488
+ const account = w.getAccount();
489
+ if (chain && account) {
490
+ setPayer({
491
+ account,
492
+ chain,
493
+ wallet: w,
494
+ });
495
+ setScreen({ id: "buy-with-crypto" });
496
+ }
497
+ }}
498
+ showAllWallets={!!props.connectOptions?.showAllWallets}
499
+ wallets={props.connectOptions?.wallets}
500
+ onBack={() => {
501
+ // no-op
502
+ }}
503
+ onConnect={() => {
504
+ setScreen({
505
+ id: "connect-payer-wallet",
506
+ backScreen: {
507
+ id: "select-wallet",
508
+ },
509
+ });
510
+ }}
511
+ selectedAddress={payer.account.address}
512
+ />
513
+ )}
514
+
446
515
  {screen.id === "buy-with-crypto" && activeAccount && (
447
516
  <SwapScreenContent
448
517
  setScreen={setScreen}
@@ -458,11 +527,9 @@ function BuyScreenContent(props: BuyScreenContentProps) {
458
527
  });
459
528
  }}
460
529
  payer={payer}
461
- buyForTx={buyForTx || null}
462
530
  client={client}
463
531
  isEmbed={props.isEmbed}
464
- onDone={props.onDone}
465
- onViewPendingTx={props.onViewPendingTx}
532
+ onDone={onDone}
466
533
  payOptions={payOptions}
467
534
  connectLocale={connectLocale}
468
535
  connectOptions={props.connectOptions}
@@ -471,6 +538,14 @@ function BuyScreenContent(props: BuyScreenContentProps) {
471
538
  activeAccount={activeAccount}
472
539
  setTokenAmount={setTokenAmount}
473
540
  setHasEditedAmount={setHasEditedAmount}
541
+ disableTokenSelection={
542
+ payDisabled === true ||
543
+ (payOptions.buyWithCrypto !== false &&
544
+ payOptions.buyWithCrypto?.prefillSource?.allowEdits
545
+ ?.chain === false &&
546
+ payOptions.buyWithCrypto?.prefillSource?.allowEdits
547
+ ?.token === false)
548
+ }
474
549
  />
475
550
  )}
476
551
 
@@ -481,11 +556,9 @@ function BuyScreenContent(props: BuyScreenContentProps) {
481
556
  toChain={toChain}
482
557
  toToken={toToken}
483
558
  selectedCurrency={selectedCurrency}
484
- buyForTx={buyForTx || null}
485
559
  client={client}
486
560
  isEmbed={props.isEmbed}
487
- onDone={props.onDone}
488
- onViewPendingTx={props.onViewPendingTx}
561
+ onDone={onDone}
489
562
  payOptions={payOptions}
490
563
  theme={props.theme}
491
564
  showCurrencySelector={() => {
@@ -556,9 +629,12 @@ function SelectedTokenInfo(props: {
556
629
 
557
630
  function MainScreen(props: {
558
631
  title: string;
559
- buyForTx: BuyForTx | undefined;
560
632
  client: ThirdwebClient;
561
633
  setTokenAmount: (amount: string) => void;
634
+ setFromChain: (chain: Chain) => void;
635
+ setFromToken: (token: ERC20OrNativeToken) => void;
636
+ setToChain: (chain: Chain) => void;
637
+ setToToken: (token: ERC20OrNativeToken) => void;
562
638
  payerAccount: Account | undefined;
563
639
  tokenAmount: string;
564
640
  payOptions: PayUIOptions;
@@ -566,148 +642,159 @@ function MainScreen(props: {
566
642
  toChain: Chain;
567
643
  onSelectBuyToken: () => void;
568
644
  connectOptions: PayEmbedConnectOptions | undefined;
569
- onViewPendingTx: () => void;
570
645
  setScreen: (screen: SelectedScreen) => void;
571
646
  supportedDestinations: SupportedChainAndTokens;
572
647
  onBack: (() => void) | undefined;
573
648
  theme: "light" | "dark" | Theme;
574
649
  hasEditedAmount: boolean;
575
650
  setHasEditedAmount: (hasEdited: boolean) => void;
651
+ enabledPaymentMethods: PaymentMethods;
576
652
  }) {
577
- const { showPaymentSelection, buyWithCryptoEnabled, buyWithFiatEnabled } =
578
- useEnabledPaymentMethods({
579
- payOptions: props.payOptions,
580
- supportedDestinations: props.supportedDestinations,
581
- toChain: props.toChain,
582
- toToken: props.toToken,
583
- });
584
-
585
653
  const {
586
- buyForTx,
587
654
  setTokenAmount,
655
+ setToChain,
656
+ setToToken,
657
+ setFromChain,
658
+ setFromToken,
588
659
  payerAccount,
589
660
  client,
590
661
  tokenAmount,
591
662
  payOptions,
592
663
  toToken,
593
664
  toChain,
665
+ supportedDestinations,
666
+ enabledPaymentMethods,
594
667
  } = props;
595
668
 
596
- // Buy Transaction flow states
597
- const { amountNeeded } = useBuyTxStates({
598
- setTokenAmount,
599
- buyForTx: buyForTx || null,
600
- hasEditedAmount: props.hasEditedAmount,
601
- account: payerAccount || null,
602
- });
603
-
669
+ const { showPaymentSelection, buyWithCryptoEnabled, buyWithFiatEnabled } =
670
+ enabledPaymentMethods;
604
671
  const disableContinue = !tokenAmount;
605
672
 
606
- return (
607
- <Container p="lg">
608
- <ModalHeader
609
- title={
610
- props.buyForTx
611
- ? `Not enough ${props.buyForTx.tokenSymbol}`
612
- : props.title
613
- }
614
- onBack={props.onBack}
615
- />
616
-
617
- {/* Amount needed for Send Tx */}
618
- {amountNeeded && props.buyForTx ? (
619
- <>
620
- <Spacer y="lg" />
621
- <BuyForTxUI
622
- amountNeeded={String(
623
- formatNumber(
624
- Number(toTokens(amountNeeded, props.buyForTx.tokenDecimals)),
625
- 6,
626
- ),
627
- )}
628
- buyForTx={props.buyForTx}
629
- client={client}
630
- />
631
- </>
632
- ) : (
633
- <Spacer y="xl" />
634
- )}
635
-
636
- {/* To */}
637
- <BuyTokenInput
638
- value={tokenAmount}
639
- onChange={async (value) => {
640
- props.setHasEditedAmount(true);
641
- setTokenAmount(value);
642
- }}
643
- freezeAmount={payOptions.prefillBuy?.allowEdits?.amount === false}
644
- freezeChainAndToken={
645
- payOptions.prefillBuy?.allowEdits?.chain === false &&
646
- payOptions.prefillBuy?.allowEdits?.token === false
647
- }
648
- token={toToken}
649
- chain={toChain}
650
- onSelectToken={props.onSelectBuyToken}
651
- client={props.client}
652
- hideTokenSelector={!!props.buyForTx}
653
- />
673
+ switch (payOptions.mode) {
674
+ case "transaction": {
675
+ return (
676
+ <TransactionModeScreen
677
+ supportedDestinations={supportedDestinations}
678
+ payUiOptions={payOptions}
679
+ payerAccount={payerAccount}
680
+ connectOptions={props.connectOptions}
681
+ client={client}
682
+ onContinue={(tokenAmount, toChain, toToken) => {
683
+ setTokenAmount(tokenAmount);
684
+ setToChain(toChain);
685
+ setFromChain(toChain);
686
+ setFromToken(toToken);
687
+ setToToken(toToken);
688
+ if (showPaymentSelection) {
689
+ props.setScreen({ id: "select-payment-method" });
690
+ } else if (buyWithCryptoEnabled) {
691
+ props.setScreen({ id: "select-wallet" });
692
+ } else if (buyWithFiatEnabled) {
693
+ props.setScreen({ id: "buy-with-fiat" });
694
+ } else {
695
+ // default to buy with crypto with connected wallet if chain not supported by pay
696
+ props.setScreen({ id: "select-wallet" });
697
+ }
698
+ }}
699
+ />
700
+ );
701
+ }
702
+ case "direct_payment": {
703
+ return (
704
+ <DirectPaymentModeScreen
705
+ client={client}
706
+ payUiOptions={payOptions}
707
+ payerAccount={payerAccount}
708
+ connectOptions={props.connectOptions}
709
+ supportedDestinations={supportedDestinations}
710
+ onContinue={(tokenAmount, toChain, toToken) => {
711
+ setTokenAmount(tokenAmount);
712
+ setToChain(toChain);
713
+ setFromChain(toChain);
714
+ setFromToken(toToken);
715
+ setToToken(toToken);
716
+ if (showPaymentSelection) {
717
+ props.setScreen({ id: "select-payment-method" });
718
+ } else if (buyWithCryptoEnabled) {
719
+ props.setScreen({ id: "buy-with-crypto" });
720
+ } else if (buyWithFiatEnabled) {
721
+ props.setScreen({ id: "buy-with-fiat" });
722
+ } else {
723
+ // default to buy with crypto with connected wallet if chain not supported by pay
724
+ props.setScreen({ id: "select-wallet" });
725
+ }
726
+ }}
727
+ />
728
+ );
729
+ }
730
+ default: {
731
+ return (
732
+ <Container p="lg">
733
+ <ModalHeader title={props.title} onBack={props.onBack} />
654
734
 
655
- <Spacer y="xl" />
735
+ <Spacer y="xl" />
656
736
 
657
- {/* Continue */}
658
- <Container flex="column" gap="sm">
659
- {!payerAccount ? (
660
- <div>
661
- <ConnectButton
662
- {...props.connectOptions}
663
- client={props.client}
664
- theme={props.theme}
665
- connectButton={{
666
- style: {
667
- width: "100%",
668
- },
669
- }}
670
- />
671
- </div>
672
- ) : (
673
- <Button
674
- variant="accent"
675
- fullWidth
676
- disabled={disableContinue}
677
- data-disabled={disableContinue}
678
- onClick={() => {
679
- if (showPaymentSelection) {
680
- props.setScreen({ id: "select-payment-method" });
681
- } else if (buyWithCryptoEnabled) {
682
- props.setScreen({ id: "buy-with-crypto" });
683
- } else if (buyWithFiatEnabled) {
684
- props.setScreen({ id: "buy-with-fiat" });
685
- } else {
686
- console.error("No payment method enabled");
687
- }
737
+ {/* To */}
738
+ <BuyTokenInput
739
+ value={tokenAmount}
740
+ onChange={async (value) => {
741
+ props.setHasEditedAmount(true);
742
+ setTokenAmount(value);
688
743
  }}
689
- >
690
- Continue
691
- </Button>
692
- )}
744
+ freezeAmount={payOptions.prefillBuy?.allowEdits?.amount === false}
745
+ freezeChainAndToken={
746
+ payOptions.prefillBuy?.allowEdits?.chain === false &&
747
+ payOptions.prefillBuy?.allowEdits?.token === false
748
+ }
749
+ token={toToken}
750
+ chain={toChain}
751
+ onSelectToken={props.onSelectBuyToken}
752
+ client={props.client}
753
+ />
693
754
 
694
- {/* Do we want to remove this? */}
695
- {payerAccount && (
696
- <Button
697
- variant="outline"
698
- fullWidth
699
- style={{
700
- padding: spacing.xs,
701
- fontSize: fontSize.sm,
702
- }}
703
- onClick={props.onViewPendingTx}
704
- >
705
- View all transactions
706
- </Button>
707
- )}
708
- </Container>
709
- </Container>
710
- );
755
+ <Spacer y="xl" />
756
+
757
+ {/* Continue */}
758
+ <Container flex="column" gap="sm">
759
+ {!payerAccount ? (
760
+ <div>
761
+ <ConnectButton
762
+ {...props.connectOptions}
763
+ client={props.client}
764
+ theme={props.theme}
765
+ connectButton={{
766
+ style: {
767
+ width: "100%",
768
+ },
769
+ }}
770
+ />
771
+ </div>
772
+ ) : (
773
+ <Button
774
+ variant="accent"
775
+ fullWidth
776
+ disabled={disableContinue}
777
+ data-disabled={disableContinue}
778
+ onClick={() => {
779
+ if (showPaymentSelection) {
780
+ props.setScreen({ id: "select-payment-method" });
781
+ } else if (buyWithCryptoEnabled) {
782
+ props.setScreen({ id: "buy-with-crypto" });
783
+ } else if (buyWithFiatEnabled) {
784
+ props.setScreen({ id: "buy-with-fiat" });
785
+ } else {
786
+ console.error("No payment method enabled");
787
+ }
788
+ }}
789
+ >
790
+ Continue
791
+ </Button>
792
+ )}
793
+ </Container>
794
+ </Container>
795
+ );
796
+ }
797
+ }
711
798
  }
712
799
 
713
800
  function TokenSelectedLayout(props: {
@@ -753,7 +840,7 @@ function TokenSelectedLayout(props: {
753
840
  }
754
841
 
755
842
  function PaymentMethodSelection(props: {
756
- setScreen: (screenId: "buy-with-crypto" | "buy-with-fiat") => void;
843
+ setScreen: (screenId: "select-wallet" | "buy-with-fiat") => void;
757
844
  }) {
758
845
  return (
759
846
  <Container animate="fadein">
@@ -782,7 +869,7 @@ function PaymentMethodSelection(props: {
782
869
  <Text size="md" color="primaryText">
783
870
  Credit Card
784
871
  </Text>
785
- <Text size="xs">Easily and securely make payments</Text>
872
+ <Text size="xs">Securely pay with credit card</Text>
786
873
  </Container>
787
874
  </Button>
788
875
 
@@ -790,7 +877,7 @@ function PaymentMethodSelection(props: {
790
877
  <Button
791
878
  variant="outline"
792
879
  bg="tertiaryBg"
793
- onClick={() => props.setScreen("buy-with-crypto")}
880
+ onClick={() => props.setScreen("select-wallet")}
794
881
  style={{
795
882
  justifyContent: "flex-start",
796
883
  }}
@@ -804,7 +891,7 @@ function PaymentMethodSelection(props: {
804
891
  <Text size="md" color="primaryText">
805
892
  Crypto
806
893
  </Text>
807
- <Text size="xs">Pay with confidence using crypto</Text>
894
+ <Text size="xs">Pay with your connected wallet</Text>
808
895
  </Container>
809
896
  </Button>
810
897
  </Container>
@@ -823,9 +910,7 @@ function SwapScreenContent(props: {
823
910
  payer: PayerInfo;
824
911
  client: ThirdwebClient;
825
912
  payOptions: PayUIOptions;
826
- buyForTx: BuyForTx | null;
827
913
  isEmbed: boolean;
828
- onViewPendingTx: () => void;
829
914
  onDone: () => void;
830
915
  connectOptions: PayEmbedConnectOptions | undefined;
831
916
  connectLocale: ConnectLocale;
@@ -833,6 +918,7 @@ function SwapScreenContent(props: {
833
918
  activeAccount: Account;
834
919
  setTokenAmount: (amount: string) => void;
835
920
  setHasEditedAmount: (hasEdited: boolean) => void;
921
+ disableTokenSelection: boolean;
836
922
  }) {
837
923
  const {
838
924
  setScreen,
@@ -845,11 +931,14 @@ function SwapScreenContent(props: {
845
931
  fromToken,
846
932
  showFromTokenSelector,
847
933
  payOptions,
934
+ disableTokenSelection,
848
935
  } = props;
849
936
 
850
- const [receiverAddress, setReceiverAddress] = useState(
851
- props.payOptions.recipientAddress || props.activeAccount.address,
852
- );
937
+ const defaultRecipientAddress = (
938
+ props.payOptions as Extract<PayUIOptions, { mode: "direct_payment" }>
939
+ )?.paymentInfo?.sellerAddress;
940
+ const receiverAddress =
941
+ defaultRecipientAddress || props.activeAccount.address;
853
942
  const { drawerRef, drawerOverlayRef, isOpen, setIsOpen } = useDrawer();
854
943
  const [drawerScreen, setDrawerScreen] = useState<
855
944
  "fees" | "receiver" | "payer"
@@ -862,27 +951,35 @@ function SwapScreenContent(props: {
862
951
  client,
863
952
  });
864
953
 
865
- const quoteParams: GetBuyWithCryptoQuoteParams | undefined =
866
- tokenAmount && !(fromChain.id === toChain.id && fromToken === toToken)
867
- ? {
868
- // wallets
869
- fromAddress: payer.account.address,
870
- toAddress: receiverAddress,
871
- // from
872
- fromChainId: fromChain.id,
873
- fromTokenAddress: isNativeToken(fromToken)
874
- ? NATIVE_TOKEN_ADDRESS
875
- : fromToken.address,
876
- // to
877
- toChainId: toChain.id,
878
- toTokenAddress: isNativeToken(toToken)
879
- ? NATIVE_TOKEN_ADDRESS
880
- : toToken.address,
881
- toAmount: tokenAmount,
882
- client,
883
- purchaseData: payOptions.purchaseData,
884
- }
885
- : undefined;
954
+ const fromTokenId = isNativeToken(fromToken)
955
+ ? NATIVE_TOKEN_ADDRESS
956
+ : fromToken.address.toLowerCase();
957
+ const toTokenId = isNativeToken(toToken)
958
+ ? NATIVE_TOKEN_ADDRESS
959
+ : toToken.address.toLowerCase();
960
+ const swapRequired =
961
+ !!tokenAmount &&
962
+ !(fromChain.id === toChain.id && fromTokenId === toTokenId);
963
+ const quoteParams: GetBuyWithCryptoQuoteParams | undefined = swapRequired
964
+ ? {
965
+ // wallets
966
+ fromAddress: payer.account.address,
967
+ toAddress: receiverAddress,
968
+ // from
969
+ fromChainId: fromChain.id,
970
+ fromTokenAddress: isNativeToken(fromToken)
971
+ ? NATIVE_TOKEN_ADDRESS
972
+ : fromToken.address,
973
+ // to
974
+ toChainId: toChain.id,
975
+ toTokenAddress: isNativeToken(toToken)
976
+ ? NATIVE_TOKEN_ADDRESS
977
+ : toToken.address,
978
+ toAmount: tokenAmount,
979
+ client,
980
+ purchaseData: payOptions.purchaseData,
981
+ }
982
+ : undefined;
886
983
 
887
984
  const quoteQuery = useBuyWithCryptoQuote(quoteParams, {
888
985
  // refetch every 30 seconds
@@ -891,14 +988,17 @@ function SwapScreenContent(props: {
891
988
  gcTime: 30 * 1000,
892
989
  });
893
990
 
894
- const sourceTokenAmount = quoteQuery.data?.swapDetails.fromAmount;
991
+ const sourceTokenAmount = swapRequired
992
+ ? quoteQuery.data?.swapDetails.fromAmount
993
+ : tokenAmount;
895
994
 
896
995
  const isNotEnoughBalance =
897
996
  !!sourceTokenAmount &&
898
997
  !!fromTokenBalanceQuery.data &&
899
998
  Number(fromTokenBalanceQuery.data.displayValue) < Number(sourceTokenAmount);
900
999
 
901
- const disableContinue = !quoteQuery.data || isNotEnoughBalance;
1000
+ const disableContinue =
1001
+ (swapRequired && !quoteQuery.data) || isNotEnoughBalance;
902
1002
  const switchChainRequired = props.payer.chain.id !== fromChain.id;
903
1003
 
904
1004
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
@@ -935,6 +1035,25 @@ function SwapScreenContent(props: {
935
1035
  : undefined;
936
1036
 
937
1037
  function showSwapFlow() {
1038
+ if (
1039
+ (props.payOptions.mode === "transaction" ||
1040
+ props.payOptions.mode === "direct_payment") &&
1041
+ !isNotEnoughBalance &&
1042
+ !swapRequired
1043
+ ) {
1044
+ if (payer.account.address !== receiverAddress) {
1045
+ // same currency, just transfer, but from another wallet
1046
+ setScreen({
1047
+ id: "transfer-flow",
1048
+ });
1049
+ } else {
1050
+ // has enough balance to just do the transaction directly
1051
+ props.onDone();
1052
+ }
1053
+
1054
+ return;
1055
+ }
1056
+
938
1057
  if (!quoteQuery.data) {
939
1058
  return;
940
1059
  }
@@ -954,13 +1073,6 @@ function SwapScreenContent(props: {
954
1073
  setDrawerScreen("fees");
955
1074
  }
956
1075
 
957
- const prefillSource =
958
- payOptions.buyWithCrypto !== false
959
- ? payOptions.buyWithCrypto?.prefillSource
960
- : undefined;
961
-
962
- const disableReceiverSelection = !!props.payOptions.recipientAddress;
963
-
964
1076
  return (
965
1077
  <Container flex="column" gap="md" animate="fadein">
966
1078
  {isOpen && (
@@ -976,46 +1088,6 @@ function SwapScreenContent(props: {
976
1088
  <SwapFees quote={quoteQuery.data} align="left" />
977
1089
  </div>
978
1090
  )}
979
-
980
- {drawerScreen === "receiver" && (
981
- <ReceiverWalletDrawerScreen
982
- client={props.client}
983
- onSelect={(x) => setReceiverAddress(x)}
984
- receiverAddress={receiverAddress}
985
- onBack={() => setIsOpen(false)}
986
- />
987
- )}
988
-
989
- {drawerScreen === "payer" && (
990
- <WalletSwitcherDrawerContent
991
- client={client}
992
- onSelect={(w) => {
993
- const chain = w.getChain();
994
- const account = w.getAccount();
995
- if (chain && account) {
996
- props.setPayer({
997
- account,
998
- chain,
999
- wallet: w,
1000
- });
1001
- }
1002
- }}
1003
- showAllWallets={!!props.connectOptions?.showAllWallets}
1004
- wallets={props.connectOptions?.wallets}
1005
- onBack={() => {
1006
- setIsOpen(false);
1007
- }}
1008
- onConnect={() => {
1009
- setScreen({
1010
- id: "connect-payer-wallet",
1011
- backScreen: {
1012
- id: "buy-with-crypto",
1013
- },
1014
- });
1015
- }}
1016
- selectedAddress={payer.account.address}
1017
- />
1018
- )}
1019
1091
  </Drawer>
1020
1092
  </>
1021
1093
  )}
@@ -1025,8 +1097,7 @@ function SwapScreenContent(props: {
1025
1097
  <WalletSelectorButton
1026
1098
  client={props.client}
1027
1099
  onClick={() => {
1028
- setIsOpen(true);
1029
- setDrawerScreen("payer");
1100
+ setScreen({ id: "select-wallet" });
1030
1101
  }}
1031
1102
  address={props.payer.account.address}
1032
1103
  walletId={props.payer.wallet.id}
@@ -1043,34 +1114,20 @@ function SwapScreenContent(props: {
1043
1114
  token={fromToken}
1044
1115
  isLoading={quoteQuery.isLoading && !sourceTokenAmount}
1045
1116
  client={client}
1046
- freezeChainAndTokenSelection={
1047
- prefillSource?.allowEdits?.chain === false &&
1048
- prefillSource?.allowEdits?.token === false
1049
- }
1117
+ freezeChainAndTokenSelection={disableTokenSelection}
1050
1118
  payerAccount={props.payer.account}
1119
+ swapRequired={swapRequired}
1051
1120
  />
1052
- <EstimatedTimeAndFees
1053
- quoteIsLoading={quoteQuery.isLoading}
1054
- estimatedSeconds={
1055
- quoteQuery.data?.swapDetails.estimated.durationSeconds
1056
- }
1057
- onViewFees={showFees}
1058
- />
1059
-
1121
+ {swapRequired && (
1122
+ <EstimatedTimeAndFees
1123
+ quoteIsLoading={quoteQuery.isLoading}
1124
+ estimatedSeconds={
1125
+ quoteQuery.data?.swapDetails.estimated.durationSeconds
1126
+ }
1127
+ onViewFees={showFees}
1128
+ />
1129
+ )}
1060
1130
  <Spacer y="md" />
1061
- <Text size="sm">Send to</Text>
1062
- <Spacer y="xs" />
1063
- <WalletSelectorButton
1064
- client={props.client}
1065
- disabled={disableReceiverSelection}
1066
- disableChevron={disableReceiverSelection}
1067
- onClick={() => {
1068
- setIsOpen(true);
1069
- setDrawerScreen("receiver");
1070
- }}
1071
- address={receiverAddress}
1072
- walletId={undefined}
1073
- />
1074
1131
  </div>
1075
1132
 
1076
1133
  {/* Error message */}
@@ -1097,6 +1154,17 @@ function SwapScreenContent(props: {
1097
1154
  </div>
1098
1155
  )}
1099
1156
 
1157
+ {!errorMsg && isNotEnoughBalance && (
1158
+ <div>
1159
+ <Text color="danger" size="sm" center multiline>
1160
+ Not enough funds.
1161
+ </Text>
1162
+ <Text color="danger" size="sm" center multiline>
1163
+ Try a different wallet or token.
1164
+ </Text>
1165
+ </div>
1166
+ )}
1167
+
1100
1168
  {/* Button */}
1101
1169
  {errorMsg?.minAmount ? (
1102
1170
  <Button
@@ -1133,9 +1201,7 @@ function SwapScreenContent(props: {
1133
1201
  }}
1134
1202
  gap="xs"
1135
1203
  >
1136
- {isNotEnoughBalance ? (
1137
- <Text color="danger">Not Enough Funds</Text>
1138
- ) : quoteQuery.isLoading ? (
1204
+ {quoteQuery.isLoading ? (
1139
1205
  <>
1140
1206
  Getting price quote
1141
1207
  <Spinner size="sm" color="accentText" />
@@ -1158,9 +1224,7 @@ function FiatScreenContent(props: {
1158
1224
  showCurrencySelector: () => void;
1159
1225
  payOptions: PayUIOptions;
1160
1226
  theme: "light" | "dark" | Theme;
1161
- buyForTx: BuyForTx | null;
1162
1227
  client: ThirdwebClient;
1163
- onViewPendingTx: () => void;
1164
1228
  onDone: () => void;
1165
1229
  isEmbed: boolean;
1166
1230
  payer: PayerInfo;
@@ -1177,11 +1241,13 @@ function FiatScreenContent(props: {
1177
1241
  showCurrencySelector,
1178
1242
  selectedCurrency,
1179
1243
  } = props;
1180
- const [receiverAddress, setReceiverAddress] = useState(
1181
- props.payOptions.recipientAddress || props.payer.account.address,
1182
- );
1244
+ const defaultRecipientAddress = (
1245
+ props.payOptions as Extract<PayUIOptions, { mode: "direct_payment" }>
1246
+ )?.paymentInfo?.sellerAddress;
1247
+ const receiverAddress =
1248
+ defaultRecipientAddress || props.payer.account.address;
1183
1249
  const { drawerRef, drawerOverlayRef, isOpen, setIsOpen } = useDrawer();
1184
- const [drawerScreen, setDrawerScreen] = useState<"fees" | "receiver">("fees");
1250
+ const [drawerScreen, setDrawerScreen] = useState<"fees">("fees");
1185
1251
 
1186
1252
  const buyWithFiatOptions = props.payOptions.buyWithFiat;
1187
1253
 
@@ -1269,8 +1335,6 @@ function FiatScreenContent(props: {
1269
1335
 
1270
1336
  const disableSubmit = !fiatQuoteQuery.data;
1271
1337
 
1272
- const disableReceiverSelection = !!props.payOptions.recipientAddress;
1273
-
1274
1338
  const errorMsg =
1275
1339
  !fiatQuoteQuery.isLoading && fiatQuoteQuery.error
1276
1340
  ? getErrorMessage(fiatQuoteQuery.error)
@@ -1292,15 +1356,6 @@ function FiatScreenContent(props: {
1292
1356
  <FiatFees quote={fiatQuoteQuery.data} />
1293
1357
  </div>
1294
1358
  )}
1295
-
1296
- {drawerScreen === "receiver" && (
1297
- <ReceiverWalletDrawerScreen
1298
- client={props.client}
1299
- onSelect={(x) => setReceiverAddress(x)}
1300
- receiverAddress={receiverAddress}
1301
- onBack={() => setIsOpen(false)}
1302
- />
1303
- )}
1304
1359
  </Drawer>
1305
1360
  </>
1306
1361
  )}
@@ -1320,19 +1375,6 @@ function FiatScreenContent(props: {
1320
1375
  onViewFees={showFees}
1321
1376
  />
1322
1377
  <Spacer y="md" />
1323
- <Text size="sm">Send to</Text>
1324
- <Spacer y="xs" />
1325
- <WalletSelectorButton
1326
- client={props.client}
1327
- onClick={() => {
1328
- setDrawerScreen("receiver");
1329
- setIsOpen(true);
1330
- }}
1331
- address={receiverAddress}
1332
- disabled={disableReceiverSelection}
1333
- disableChevron={disableReceiverSelection}
1334
- walletId={undefined}
1335
- />
1336
1378
  </div>
1337
1379
 
1338
1380
  {/* Error message */}
@@ -1393,86 +1435,6 @@ function FiatScreenContent(props: {
1393
1435
  );
1394
1436
  }
1395
1437
 
1396
- function BuyForTxUI(props: {
1397
- amountNeeded: string;
1398
- buyForTx: BuyForTx;
1399
- client: ThirdwebClient;
1400
- }) {
1401
- const chainNameQuery = useChainName(props.buyForTx.tx.chain);
1402
-
1403
- return (
1404
- <Container>
1405
- <Spacer y="xs" />
1406
- <Container
1407
- flex="row"
1408
- style={{
1409
- justifyContent: "space-between",
1410
- }}
1411
- >
1412
- <Text size="sm">Amount Needed</Text>
1413
- <Container
1414
- flex="column"
1415
- style={{
1416
- alignItems: "flex-end",
1417
- }}
1418
- >
1419
- <Container flex="row" gap="xs" center="y">
1420
- <Text color="primaryText" size="sm">
1421
- {props.amountNeeded} {props.buyForTx.tokenSymbol}
1422
- </Text>
1423
- <TokenIcon
1424
- chain={props.buyForTx.tx.chain}
1425
- client={props.client}
1426
- size="sm"
1427
- token={NATIVE_TOKEN}
1428
- />
1429
- </Container>
1430
- <Spacer y="xxs" />
1431
- {chainNameQuery.name ? (
1432
- <Text size="sm">{chainNameQuery.name}</Text>
1433
- ) : (
1434
- <Skeleton height={fontSize.sm} width="50px" />
1435
- )}
1436
- </Container>
1437
- </Container>
1438
-
1439
- <Spacer y="md" />
1440
- <Line />
1441
- <Spacer y="md" />
1442
-
1443
- <Container
1444
- flex="row"
1445
- style={{
1446
- justifyContent: "space-between",
1447
- }}
1448
- >
1449
- <Text size="sm">Your Balance</Text>
1450
- <Container flex="row" gap="xs">
1451
- <Text color="primaryText" size="sm">
1452
- {formatNumber(Number(toEther(props.buyForTx.balance)), 6)}{" "}
1453
- {props.buyForTx.tokenSymbol}
1454
- </Text>
1455
- <TokenIcon
1456
- chain={props.buyForTx.tx.chain}
1457
- client={props.client}
1458
- size="sm"
1459
- token={NATIVE_TOKEN}
1460
- />
1461
- </Container>
1462
- </Container>
1463
-
1464
- <Spacer y="md" />
1465
- <Line />
1466
- <Spacer y="xl" />
1467
-
1468
- <Text center size="sm">
1469
- Purchase
1470
- </Text>
1471
- <Spacer y="xxs" />
1472
- </Container>
1473
- );
1474
- }
1475
-
1476
1438
  function createSupportedTokens(
1477
1439
  data: SupportedChainAndTokens,
1478
1440
  payOptions: PayUIOptions,
@@ -1483,6 +1445,8 @@ function createSupportedTokens(
1483
1445
  const isBuyWithFiatDisabled = payOptions.buyWithFiat === false;
1484
1446
  const isBuyWithCryptoDisabled = payOptions.buyWithCrypto === false;
1485
1447
 
1448
+ // FIXME (pay) when buywithFiat is disabled, missing a bunch of tokens on base??
1449
+
1486
1450
  for (const x of data) {
1487
1451
  tokens[x.chain.id] = x.tokens.filter((t) => {
1488
1452
  // it token supports both - include it