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,12 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { IdCardIcon } from "@radix-ui/react-icons";
3
- import { useMemo, useState } from "react";
3
+ import { useCallback, useMemo, useState } from "react";
4
4
  import { NATIVE_TOKEN_ADDRESS } from "../../../../../../constants/addresses.js";
5
5
  import { isSwapRequiredPostOnramp } from "../../../../../../pay/buyWithFiat/isSwapRequiredPostOnramp.js";
6
6
  import { formatNumber } from "../../../../../../utils/formatNumber.js";
7
- import { toEther, toTokens } from "../../../../../../utils/units.js";
8
- import { fontSize, iconSize, spacing, } from "../../../../../core/design-system/index.js";
9
- import { useChainName } from "../../../../../core/hooks/others/useChainQuery.js";
7
+ import { iconSize, spacing, } from "../../../../../core/design-system/index.js";
10
8
  import { useWalletBalance } from "../../../../../core/hooks/others/useWalletBalance.js";
11
9
  import { useBuyWithCryptoQuote } from "../../../../../core/hooks/pay/useBuyWithCryptoQuote.js";
12
10
  import { useBuyWithFiatQuote } from "../../../../../core/hooks/pay/useBuyWithFiatQuote.js";
@@ -14,11 +12,9 @@ import { useActiveAccount } from "../../../../hooks/wallets/useActiveAccount.js"
14
12
  import { LoadingScreen } from "../../../../wallets/shared/LoadingScreen.js";
15
13
  import { ChainName } from "../../../components/ChainName.js";
16
14
  import { Drawer, DrawerOverlay, useDrawer, } from "../../../components/Drawer.js";
17
- import { Skeleton } from "../../../components/Skeleton.js";
18
15
  import { Spacer } from "../../../components/Spacer.js";
19
16
  import { Spinner } from "../../../components/Spinner.js";
20
17
  import { SwitchNetworkButton } from "../../../components/SwitchNetwork.js";
21
- import { TokenIcon } from "../../../components/TokenIcon.js";
22
18
  import { Container, Line, ModalHeader } from "../../../components/basic.js";
23
19
  import { Button } from "../../../components/buttons.js";
24
20
  import { Text } from "../../../components/text.js";
@@ -28,22 +24,23 @@ import { ChainButton, NetworkSelectorContent } from "../../NetworkSelector.js";
28
24
  import { CoinsIcon } from "../../icons/CoinsIcon.js";
29
25
  import { TokenSelector } from "../TokenSelector.js";
30
26
  import { WalletSwitcherConnectionScreen } from "../WalletSwitcherConnectionScreen.js";
31
- import { NATIVE_TOKEN, isNativeToken, } from "../nativeToken.js";
27
+ import { isNativeToken } from "../nativeToken.js";
28
+ import { DirectPaymentModeScreen } from "./DirectPaymentModeScreen.js";
32
29
  import { EstimatedTimeAndFees } from "./EstimatedTimeAndFees.js";
33
30
  import { PayTokenIcon } from "./PayTokenIcon.js";
34
31
  import { PayWithCreditCard } from "./PayWIthCreditCard.js";
35
- import { ReceiverWalletDrawerScreen } from "./ReceiverWalletSelectionScreen.js";
32
+ import { TransactionModeScreen } from "./TransactionModeScreen.js";
36
33
  import { WalletSelectorButton } from "./WalletSelectorButton.js";
37
34
  import { CurrencySelection } from "./fiat/CurrencySelection.js";
38
35
  import { FiatFlow } from "./fiat/FiatFlow.js";
39
- import { useBuyTxStates } from "./main/useBuyTxStates.js";
40
- import { useEnabledPaymentMethods } from "./main/useEnabledPaymentMethods.js";
36
+ import { useEnabledPaymentMethods, } from "./main/useEnabledPaymentMethods.js";
41
37
  import { useUISelectionStates } from "./main/useUISelectionStates.js";
42
38
  import { openOnrampPopup } from "./openOnRamppopup.js";
43
39
  import { BuyTokenInput } from "./swap/BuyTokenInput.js";
44
40
  import { FiatFees, SwapFees } from "./swap/Fees.js";
45
41
  import { PayWithCrypto } from "./swap/PayWithCrypto.js";
46
42
  import { SwapFlow } from "./swap/SwapFlow.js";
43
+ import { TransferFlow } from "./swap/TransferFlow.js";
47
44
  import { WalletSwitcherDrawerContent } from "./swap/WalletSwitcherDrawerContent.js";
48
45
  import { addPendingTx } from "./swap/pendingSwapTx.js";
49
46
  import { useBuySupportedDestinations, useBuySupportedSources, } from "./swap/useSwapSupportedChains.js";
@@ -56,23 +53,26 @@ export default function BuyScreen(props) {
56
53
  if (!supportedDestinationsQuery.data) {
57
54
  return _jsx(LoadingScreen, {});
58
55
  }
59
- return (_jsx(BuyScreenContent, { ...props, onViewPendingTx: props.onViewPendingTx, supportedDestinations: supportedDestinationsQuery.data, buyForTx: props.buyForTx }));
56
+ return (_jsx(BuyScreenContent, { ...props, supportedDestinations: supportedDestinationsQuery.data }));
60
57
  }
61
58
  /**
62
59
  * @internal
63
60
  */
64
61
  function BuyScreenContent(props) {
65
- const { client, supportedDestinations, connectLocale, payOptions, buyForTx } = props;
62
+ const { client, supportedDestinations, connectLocale, payOptions } = props;
66
63
  const activeAccount = useActiveAccount();
67
64
  const { payer, setPayer } = usePayerSetup();
68
65
  const [screen, setScreen] = useState({
69
66
  id: "main",
70
67
  });
71
68
  const [hasEditedAmount, setHasEditedAmount] = useState(false);
69
+ const onDone = useCallback(() => {
70
+ setScreen({ id: "main" });
71
+ props.onDone();
72
+ }, [props.onDone]);
72
73
  // UI selection
73
74
  const { tokenAmount, setTokenAmount, toChain, setToChain, deferredTokenAmount, fromChain, setFromChain, toToken, setToToken, fromToken, setFromToken, selectedCurrency, setSelectedCurrency, } = useUISelectionStates({
74
75
  payOptions,
75
- buyForTx,
76
76
  supportedDestinations,
77
77
  });
78
78
  // check if the screen is expanded or not
@@ -93,6 +93,15 @@ function BuyScreenContent(props) {
93
93
  }
94
94
  return createSupportedTokens(supportedSourcesQuery.data, payOptions, props.supportedTokens);
95
95
  }, [props.supportedTokens, supportedSourcesQuery.data, payOptions]);
96
+ const enabledPaymentMethods = useEnabledPaymentMethods({
97
+ payOptions: props.payOptions,
98
+ supportedDestinations: props.supportedDestinations,
99
+ toChain: toChain,
100
+ toToken: toToken,
101
+ });
102
+ const payDisabled = enabledPaymentMethods.showPaymentSelection === false &&
103
+ enabledPaymentMethods.buyWithCryptoEnabled === false &&
104
+ enabledPaymentMethods.buyWithFiatEnabled === false;
96
105
  // screens ----------------------------
97
106
  if (screen.id === "connect-payer-wallet") {
98
107
  return (_jsx(WalletSwitcherConnectionScreen, { accountAbstraction: props.connectOptions?.accountAbstraction, appMetadata: props.connectOptions?.appMetadata, chain: props.connectOptions?.chain, chains: props.connectOptions?.chains, client: props.client, connectLocale: props.connectLocale, isEmbed: props.isEmbed, onBack: () => setScreen(screen.backScreen), onSelect: (w) => {
@@ -108,23 +117,30 @@ function BuyScreenContent(props) {
108
117
  }, recommendedWallets: props.connectOptions?.recommendedWallets, showAllWallets: !!props.connectOptions?.showAllWallets, walletConnect: props.connectOptions?.walletConnect, wallets: props.connectOptions?.wallets }));
109
118
  }
110
119
  if (screen.id === "swap-flow" && payer) {
111
- return (_jsx(SwapFlow, { title: props.title, isBuyForTx: !!props.buyForTx, isEmbed: props.isEmbed, client: client, onBack: () => {
120
+ return (_jsx(SwapFlow, { title: props.title, transactionMode: payOptions.mode === "transaction", isEmbed: props.isEmbed, client: client, onBack: () => {
112
121
  setScreen({
113
122
  id: "buy-with-crypto",
114
123
  });
115
- }, buyWithCryptoQuote: screen.quote, payer: payer, onViewPendingTx: props.onViewPendingTx, isFiatFlow: false, onDone: props.onDone, onTryAgain: () => {
124
+ }, buyWithCryptoQuote: screen.quote, payer: payer, isFiatFlow: false, onDone: onDone, onTryAgain: () => {
116
125
  setScreen({
117
126
  id: "buy-with-crypto",
118
127
  });
119
128
  } }));
120
129
  }
121
130
  if (screen.id === "fiat-flow" && payer) {
122
- return (_jsx(FiatFlow, { title: props.title, isBuyForTx: !!props.buyForTx, quote: screen.quote, onBack: () => {
131
+ return (_jsx(FiatFlow, { title: props.title, transactionMode: payOptions.mode === "transaction", quote: screen.quote, onBack: () => {
123
132
  setScreen({
124
133
  id: "buy-with-fiat",
125
134
  });
126
135
  }, client: client, testMode: props.payOptions.buyWithFiat !== false &&
127
- props.payOptions.buyWithFiat?.testMode === true, theme: typeof props.theme === "string" ? props.theme : props.theme.type, onViewPendingTx: props.onViewPendingTx, openedWindow: screen.openedWindow, onDone: props.onDone, isEmbed: props.isEmbed, payer: payer }));
136
+ props.payOptions.buyWithFiat?.testMode === true, theme: typeof props.theme === "string" ? props.theme : props.theme.type, openedWindow: screen.openedWindow, onDone: onDone, isEmbed: props.isEmbed, payer: payer }));
137
+ }
138
+ if (screen.id === "transfer-flow" && payer && activeAccount) {
139
+ const goBack = () => setScreen({ id: "buy-with-crypto" });
140
+ // TODO (pay) pass it via screen props
141
+ const defaultRecipientAddress = props.payOptions?.paymentInfo?.sellerAddress;
142
+ const receiverAddress = defaultRecipientAddress || activeAccount.address;
143
+ return (_jsx(TransferFlow, { title: props.title, onBack: goBack, payer: payer, client: props.client, onDone: onDone, chain: toChain, token: toToken, tokenAmount: tokenAmount, receiverAddress: receiverAddress, transactionMode: props.payOptions.mode === "transaction" }));
128
144
  }
129
145
  if (screen.id === "select-currency") {
130
146
  const goBack = () => setScreen(screen.backScreen);
@@ -136,8 +152,10 @@ function BuyScreenContent(props) {
136
152
  if (screen.id === "select-to-token") {
137
153
  const chains = supportedDestinations.map((x) => x.chain);
138
154
  const goBack = () => setScreen(screen.backScreen);
155
+ const allowEdits = payOptions?.prefillBuy
156
+ ?.allowEdits;
139
157
  // if token selection is disabled - only show network selector screen
140
- if (payOptions.prefillBuy?.allowEdits?.token === false) {
158
+ if (allowEdits?.token === false) {
141
159
  return (_jsx(ChainSelectionScreen, { chains: chains, client: props.client, connectLocale: props.connectLocale, setChain: setToChain, goBack: goBack }));
142
160
  }
143
161
  return (_jsx(TokenSelector, { onBack: goBack, tokenList: ((toChain?.id ? destinationSupportedTokens[toChain.id] : undefined) ||
@@ -146,7 +164,7 @@ function BuyScreenContent(props) {
146
164
  goBack();
147
165
  }, chain: toChain, chainSelection:
148
166
  // hide chain selection if it's disabled
149
- payOptions.prefillBuy?.allowEdits?.chain !== false
167
+ allowEdits?.chain !== false
150
168
  ? {
151
169
  chains: chains,
152
170
  select: (c) => {
@@ -179,25 +197,55 @@ function BuyScreenContent(props) {
179
197
  }
180
198
  : undefined, connectLocale: connectLocale, client: client, modalTitle: "Pay with" }));
181
199
  }
182
- return (_jsx(Container, { animate: "fadein", children: _jsxs("div", { children: [screen.id === "main" && (_jsx(MainScreen, { title: props.title, payerAccount: payer?.account, buyForTx: buyForTx, client: client, onSelectBuyToken: () => setScreen({ id: "select-to-token", backScreen: screen }), payOptions: payOptions, setTokenAmount: setTokenAmount, toChain: toChain, toToken: toToken, tokenAmount: tokenAmount, connectOptions: props.connectOptions, onViewPendingTx: props.onViewPendingTx, setScreen: setScreen, supportedDestinations: supportedDestinations, onBack: props.onBack, theme: props.theme, hasEditedAmount: hasEditedAmount, setHasEditedAmount: setHasEditedAmount })), (screen.id === "select-payment-method" ||
200
+ return (_jsx(Container, { animate: "fadein", children: _jsxs("div", { children: [screen.id === "main" && (_jsx(MainScreen, { title: props.title, payerAccount: payer?.account, client: client, onSelectBuyToken: () => setScreen({ id: "select-to-token", backScreen: screen }), payOptions: payOptions, setTokenAmount: setTokenAmount, setToChain: setToChain, setToToken: setToToken, setFromChain: setFromChain, setFromToken: setFromToken, toChain: toChain, toToken: toToken, tokenAmount: tokenAmount, connectOptions: props.connectOptions, setScreen: setScreen, supportedDestinations: supportedDestinations, onBack: props.onBack, theme: props.theme, hasEditedAmount: hasEditedAmount, setHasEditedAmount: setHasEditedAmount, enabledPaymentMethods: enabledPaymentMethods })), (screen.id === "select-payment-method" ||
201
+ screen.id === "select-wallet" ||
183
202
  screen.id === "buy-with-crypto" ||
184
203
  screen.id === "buy-with-fiat") &&
185
204
  payer && (_jsxs(TokenSelectedLayout, { title: props.title, selectedChain: toChain, selectedToken: toToken, tokenAmount: tokenAmount, client: client, onBack: () => {
186
- if (screen.id === "buy-with-crypto" ||
187
- screen.id === "buy-with-fiat") {
205
+ if (enabledPaymentMethods.showPaymentSelection &&
206
+ (screen.id === "select-wallet" ||
207
+ screen.id === "buy-with-fiat")) {
188
208
  setScreen({ id: "select-payment-method" });
189
209
  }
190
- else if (screen.id === "select-payment-method") {
210
+ else if (screen.id === "buy-with-crypto") {
211
+ setScreen({ id: "select-wallet" });
212
+ }
213
+ else {
191
214
  setScreen({ id: "main" });
192
215
  }
193
- }, children: [screen.id === "select-payment-method" && (_jsx(PaymentMethodSelection, { setScreen: (id) => setScreen({ id }) })), screen.id === "buy-with-crypto" && activeAccount && (_jsx(SwapScreenContent, { setScreen: setScreen, tokenAmount: deferredTokenAmount, toChain: toChain, toToken: toToken, fromChain: fromChain, fromToken: fromToken, showFromTokenSelector: () => {
216
+ }, children: [screen.id === "select-payment-method" && (_jsx(PaymentMethodSelection, { setScreen: (id) => setScreen({ id }) })), screen.id === "select-wallet" && (_jsx(WalletSwitcherDrawerContent, { client: client, onSelect: (w) => {
217
+ const chain = w.getChain();
218
+ const account = w.getAccount();
219
+ if (chain && account) {
220
+ setPayer({
221
+ account,
222
+ chain,
223
+ wallet: w,
224
+ });
225
+ setScreen({ id: "buy-with-crypto" });
226
+ }
227
+ }, showAllWallets: !!props.connectOptions?.showAllWallets, wallets: props.connectOptions?.wallets, onBack: () => {
228
+ // no-op
229
+ }, onConnect: () => {
230
+ setScreen({
231
+ id: "connect-payer-wallet",
232
+ backScreen: {
233
+ id: "select-wallet",
234
+ },
235
+ });
236
+ }, selectedAddress: payer.account.address })), screen.id === "buy-with-crypto" && activeAccount && (_jsx(SwapScreenContent, { setScreen: setScreen, tokenAmount: deferredTokenAmount, toChain: toChain, toToken: toToken, fromChain: fromChain, fromToken: fromToken, showFromTokenSelector: () => {
194
237
  setScreen({
195
238
  id: "select-from-token",
196
239
  backScreen: screen,
197
240
  });
198
- }, payer: payer, buyForTx: buyForTx || null, client: client, isEmbed: props.isEmbed, onDone: props.onDone, onViewPendingTx: props.onViewPendingTx, payOptions: payOptions, connectLocale: connectLocale, connectOptions: props.connectOptions, setPayer: setPayer,
241
+ }, payer: payer, client: client, isEmbed: props.isEmbed, onDone: onDone, payOptions: payOptions, connectLocale: connectLocale, connectOptions: props.connectOptions, setPayer: setPayer,
199
242
  // pass it even though we are passing payer, because payer might be different
200
- activeAccount: activeAccount, setTokenAmount: setTokenAmount, setHasEditedAmount: setHasEditedAmount })), screen.id === "buy-with-fiat" && (_jsx(FiatScreenContent, { setScreen: setScreen, tokenAmount: deferredTokenAmount, toChain: toChain, toToken: toToken, selectedCurrency: selectedCurrency, buyForTx: buyForTx || null, client: client, isEmbed: props.isEmbed, onDone: props.onDone, onViewPendingTx: props.onViewPendingTx, payOptions: payOptions, theme: props.theme, showCurrencySelector: () => {
243
+ activeAccount: activeAccount, setTokenAmount: setTokenAmount, setHasEditedAmount: setHasEditedAmount, disableTokenSelection: payDisabled === true ||
244
+ (payOptions.buyWithCrypto !== false &&
245
+ payOptions.buyWithCrypto?.prefillSource?.allowEdits
246
+ ?.chain === false &&
247
+ payOptions.buyWithCrypto?.prefillSource?.allowEdits
248
+ ?.token === false) })), screen.id === "buy-with-fiat" && (_jsx(FiatScreenContent, { setScreen: setScreen, tokenAmount: deferredTokenAmount, toChain: toChain, toToken: toToken, selectedCurrency: selectedCurrency, client: client, isEmbed: props.isEmbed, onDone: onDone, payOptions: payOptions, theme: props.theme, showCurrencySelector: () => {
201
249
  setScreen({
202
250
  id: "select-currency",
203
251
  backScreen: screen,
@@ -210,48 +258,79 @@ function SelectedTokenInfo(props) {
210
258
  }, children: [_jsxs(Container, { flex: "row", gap: "xs", center: "y", children: [_jsx(Text, { color: "primaryText", "data-testid": "tokenAmount", size: "xl", children: formatNumber(Number(props.tokenAmount), 6) }), _jsxs(Container, { flex: "row", gap: "xxs", center: "y", children: [_jsx(TokenSymbol, { token: props.selectedToken, chain: props.selectedChain, size: "md", color: "secondaryText" }), _jsx(PayTokenIcon, { chain: props.selectedChain, client: props.client, size: "sm", token: props.selectedToken })] })] }), _jsx(ChainName, { chain: props.selectedChain, client: props.client, size: "sm", short: true })] }) }));
211
259
  }
212
260
  function MainScreen(props) {
213
- const { showPaymentSelection, buyWithCryptoEnabled, buyWithFiatEnabled } = useEnabledPaymentMethods({
214
- payOptions: props.payOptions,
215
- supportedDestinations: props.supportedDestinations,
216
- toChain: props.toChain,
217
- toToken: props.toToken,
218
- });
219
- const { buyForTx, setTokenAmount, payerAccount, client, tokenAmount, payOptions, toToken, toChain, } = props;
220
- // Buy Transaction flow states
221
- const { amountNeeded } = useBuyTxStates({
222
- setTokenAmount,
223
- buyForTx: buyForTx || null,
224
- hasEditedAmount: props.hasEditedAmount,
225
- account: payerAccount || null,
226
- });
261
+ const { setTokenAmount, setToChain, setToToken, setFromChain, setFromToken, payerAccount, client, tokenAmount, payOptions, toToken, toChain, supportedDestinations, enabledPaymentMethods, } = props;
262
+ const { showPaymentSelection, buyWithCryptoEnabled, buyWithFiatEnabled } = enabledPaymentMethods;
227
263
  const disableContinue = !tokenAmount;
228
- return (_jsxs(Container, { p: "lg", children: [_jsx(ModalHeader, { title: props.buyForTx
229
- ? `Not enough ${props.buyForTx.tokenSymbol}`
230
- : props.title, onBack: props.onBack }), amountNeeded && props.buyForTx ? (_jsxs(_Fragment, { children: [_jsx(Spacer, { y: "lg" }), _jsx(BuyForTxUI, { amountNeeded: String(formatNumber(Number(toTokens(amountNeeded, props.buyForTx.tokenDecimals)), 6)), buyForTx: props.buyForTx, client: client })] })) : (_jsx(Spacer, { y: "xl" })), _jsx(BuyTokenInput, { value: tokenAmount, onChange: async (value) => {
231
- props.setHasEditedAmount(true);
232
- setTokenAmount(value);
233
- }, freezeAmount: payOptions.prefillBuy?.allowEdits?.amount === false, freezeChainAndToken: payOptions.prefillBuy?.allowEdits?.chain === false &&
234
- payOptions.prefillBuy?.allowEdits?.token === false, token: toToken, chain: toChain, onSelectToken: props.onSelectBuyToken, client: props.client, hideTokenSelector: !!props.buyForTx }), _jsx(Spacer, { y: "xl" }), _jsxs(Container, { flex: "column", gap: "sm", children: [!payerAccount ? (_jsx("div", { children: _jsx(ConnectButton, { ...props.connectOptions, client: props.client, theme: props.theme, connectButton: {
235
- style: {
236
- width: "100%",
237
- },
238
- } }) })) : (_jsx(Button, { variant: "accent", fullWidth: true, disabled: disableContinue, "data-disabled": disableContinue, onClick: () => {
239
- if (showPaymentSelection) {
240
- props.setScreen({ id: "select-payment-method" });
241
- }
242
- else if (buyWithCryptoEnabled) {
243
- props.setScreen({ id: "buy-with-crypto" });
244
- }
245
- else if (buyWithFiatEnabled) {
246
- props.setScreen({ id: "buy-with-fiat" });
247
- }
248
- else {
249
- console.error("No payment method enabled");
250
- }
251
- }, children: "Continue" })), payerAccount && (_jsx(Button, { variant: "outline", fullWidth: true, style: {
252
- padding: spacing.xs,
253
- fontSize: fontSize.sm,
254
- }, onClick: props.onViewPendingTx, children: "View all transactions" }))] })] }));
264
+ switch (payOptions.mode) {
265
+ case "transaction": {
266
+ return (_jsx(TransactionModeScreen, { supportedDestinations: supportedDestinations, payUiOptions: payOptions, payerAccount: payerAccount, connectOptions: props.connectOptions, client: client, onContinue: (tokenAmount, toChain, toToken) => {
267
+ setTokenAmount(tokenAmount);
268
+ setToChain(toChain);
269
+ setFromChain(toChain);
270
+ setFromToken(toToken);
271
+ setToToken(toToken);
272
+ if (showPaymentSelection) {
273
+ props.setScreen({ id: "select-payment-method" });
274
+ }
275
+ else if (buyWithCryptoEnabled) {
276
+ props.setScreen({ id: "select-wallet" });
277
+ }
278
+ else if (buyWithFiatEnabled) {
279
+ props.setScreen({ id: "buy-with-fiat" });
280
+ }
281
+ else {
282
+ // default to buy with crypto with connected wallet if chain not supported by pay
283
+ props.setScreen({ id: "select-wallet" });
284
+ }
285
+ } }));
286
+ }
287
+ case "direct_payment": {
288
+ return (_jsx(DirectPaymentModeScreen, { client: client, payUiOptions: payOptions, payerAccount: payerAccount, connectOptions: props.connectOptions, supportedDestinations: supportedDestinations, onContinue: (tokenAmount, toChain, toToken) => {
289
+ setTokenAmount(tokenAmount);
290
+ setToChain(toChain);
291
+ setFromChain(toChain);
292
+ setFromToken(toToken);
293
+ setToToken(toToken);
294
+ if (showPaymentSelection) {
295
+ props.setScreen({ id: "select-payment-method" });
296
+ }
297
+ else if (buyWithCryptoEnabled) {
298
+ props.setScreen({ id: "buy-with-crypto" });
299
+ }
300
+ else if (buyWithFiatEnabled) {
301
+ props.setScreen({ id: "buy-with-fiat" });
302
+ }
303
+ else {
304
+ // default to buy with crypto with connected wallet if chain not supported by pay
305
+ props.setScreen({ id: "select-wallet" });
306
+ }
307
+ } }));
308
+ }
309
+ default: {
310
+ return (_jsxs(Container, { p: "lg", children: [_jsx(ModalHeader, { title: props.title, onBack: props.onBack }), _jsx(Spacer, { y: "xl" }), _jsx(BuyTokenInput, { value: tokenAmount, onChange: async (value) => {
311
+ props.setHasEditedAmount(true);
312
+ setTokenAmount(value);
313
+ }, freezeAmount: payOptions.prefillBuy?.allowEdits?.amount === false, freezeChainAndToken: payOptions.prefillBuy?.allowEdits?.chain === false &&
314
+ payOptions.prefillBuy?.allowEdits?.token === false, token: toToken, chain: toChain, onSelectToken: props.onSelectBuyToken, client: props.client }), _jsx(Spacer, { y: "xl" }), _jsx(Container, { flex: "column", gap: "sm", children: !payerAccount ? (_jsx("div", { children: _jsx(ConnectButton, { ...props.connectOptions, client: props.client, theme: props.theme, connectButton: {
315
+ style: {
316
+ width: "100%",
317
+ },
318
+ } }) })) : (_jsx(Button, { variant: "accent", fullWidth: true, disabled: disableContinue, "data-disabled": disableContinue, onClick: () => {
319
+ if (showPaymentSelection) {
320
+ props.setScreen({ id: "select-payment-method" });
321
+ }
322
+ else if (buyWithCryptoEnabled) {
323
+ props.setScreen({ id: "buy-with-crypto" });
324
+ }
325
+ else if (buyWithFiatEnabled) {
326
+ props.setScreen({ id: "buy-with-fiat" });
327
+ }
328
+ else {
329
+ console.error("No payment method enabled");
330
+ }
331
+ }, children: "Continue" })) })] }));
332
+ }
333
+ }
255
334
  }
256
335
  function TokenSelectedLayout(props) {
257
336
  return (_jsxs(Container, { children: [_jsx(Container, { p: "lg", children: _jsx(ModalHeader, { title: props.title, onBack: props.onBack }) }), _jsxs(Container, { px: "lg", style: {
@@ -265,13 +344,14 @@ function PaymentMethodSelection(props) {
265
344
  }, children: [_jsx(Container, { color: "secondaryText", flex: "row", center: "both", children: _jsx(IdCardIcon, { style: {
266
345
  width: iconSize.md,
267
346
  height: iconSize.md,
268
- } }) }), _jsxs(Container, { flex: "column", gap: "xxs", children: [_jsx(Text, { size: "md", color: "primaryText", children: "Credit Card" }), _jsx(Text, { size: "xs", children: "Easily and securely make payments" })] })] }), _jsxs(Button, { variant: "outline", bg: "tertiaryBg", onClick: () => props.setScreen("buy-with-crypto"), style: {
347
+ } }) }), _jsxs(Container, { flex: "column", gap: "xxs", children: [_jsx(Text, { size: "md", color: "primaryText", children: "Credit Card" }), _jsx(Text, { size: "xs", children: "Securely pay with credit card" })] })] }), _jsxs(Button, { variant: "outline", bg: "tertiaryBg", onClick: () => props.setScreen("select-wallet"), style: {
269
348
  justifyContent: "flex-start",
270
- }, gap: "sm", children: [_jsx(Container, { color: "secondaryText", flex: "row", center: "both", children: _jsx(CoinsIcon, { size: iconSize.md }) }), _jsxs(Container, { flex: "column", gap: "xxs", children: [_jsx(Text, { size: "md", color: "primaryText", children: "Crypto" }), _jsx(Text, { size: "xs", children: "Pay with confidence using crypto" })] })] })] }) }));
349
+ }, gap: "sm", children: [_jsx(Container, { color: "secondaryText", flex: "row", center: "both", children: _jsx(CoinsIcon, { size: iconSize.md }) }), _jsxs(Container, { flex: "column", gap: "xxs", children: [_jsx(Text, { size: "md", color: "primaryText", children: "Crypto" }), _jsx(Text, { size: "xs", children: "Pay with your connected wallet" })] })] })] }) }));
271
350
  }
272
351
  function SwapScreenContent(props) {
273
- const { setScreen, payer, client, toChain, tokenAmount, toToken, fromChain, fromToken, showFromTokenSelector, payOptions, } = props;
274
- const [receiverAddress, setReceiverAddress] = useState(props.payOptions.recipientAddress || props.activeAccount.address);
352
+ const { setScreen, payer, client, toChain, tokenAmount, toToken, fromChain, fromToken, showFromTokenSelector, payOptions, disableTokenSelection, } = props;
353
+ const defaultRecipientAddress = props.payOptions?.paymentInfo?.sellerAddress;
354
+ const receiverAddress = defaultRecipientAddress || props.activeAccount.address;
275
355
  const { drawerRef, drawerOverlayRef, isOpen, setIsOpen } = useDrawer();
276
356
  const [drawerScreen, setDrawerScreen] = useState("fees");
277
357
  const fromTokenBalanceQuery = useWalletBalance({
@@ -280,7 +360,15 @@ function SwapScreenContent(props) {
280
360
  tokenAddress: isNativeToken(fromToken) ? undefined : fromToken.address,
281
361
  client,
282
362
  });
283
- const quoteParams = tokenAmount && !(fromChain.id === toChain.id && fromToken === toToken)
363
+ const fromTokenId = isNativeToken(fromToken)
364
+ ? NATIVE_TOKEN_ADDRESS
365
+ : fromToken.address.toLowerCase();
366
+ const toTokenId = isNativeToken(toToken)
367
+ ? NATIVE_TOKEN_ADDRESS
368
+ : toToken.address.toLowerCase();
369
+ const swapRequired = !!tokenAmount &&
370
+ !(fromChain.id === toChain.id && fromTokenId === toTokenId);
371
+ const quoteParams = swapRequired
284
372
  ? {
285
373
  // wallets
286
374
  fromAddress: payer.account.address,
@@ -306,11 +394,13 @@ function SwapScreenContent(props) {
306
394
  refetchInterval: 30 * 1000,
307
395
  gcTime: 30 * 1000,
308
396
  });
309
- const sourceTokenAmount = quoteQuery.data?.swapDetails.fromAmount;
397
+ const sourceTokenAmount = swapRequired
398
+ ? quoteQuery.data?.swapDetails.fromAmount
399
+ : tokenAmount;
310
400
  const isNotEnoughBalance = !!sourceTokenAmount &&
311
401
  !!fromTokenBalanceQuery.data &&
312
402
  Number(fromTokenBalanceQuery.data.displayValue) < Number(sourceTokenAmount);
313
- const disableContinue = !quoteQuery.data || isNotEnoughBalance;
403
+ const disableContinue = (swapRequired && !quoteQuery.data) || isNotEnoughBalance;
314
404
  const switchChainRequired = props.payer.chain.id !== fromChain.id;
315
405
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
316
406
  function getErrorMessage(err) {
@@ -333,6 +423,22 @@ function SwapScreenContent(props) {
333
423
  ? getErrorMessage(quoteQuery.error)
334
424
  : undefined;
335
425
  function showSwapFlow() {
426
+ if ((props.payOptions.mode === "transaction" ||
427
+ props.payOptions.mode === "direct_payment") &&
428
+ !isNotEnoughBalance &&
429
+ !swapRequired) {
430
+ if (payer.account.address !== receiverAddress) {
431
+ // same currency, just transfer, but from another wallet
432
+ setScreen({
433
+ id: "transfer-flow",
434
+ });
435
+ }
436
+ else {
437
+ // has enough balance to just do the transaction directly
438
+ props.onDone();
439
+ }
440
+ return;
441
+ }
336
442
  if (!quoteQuery.data) {
337
443
  return;
338
444
  }
@@ -348,40 +454,12 @@ function SwapScreenContent(props) {
348
454
  setIsOpen(true);
349
455
  setDrawerScreen("fees");
350
456
  }
351
- const prefillSource = payOptions.buyWithCrypto !== false
352
- ? payOptions.buyWithCrypto?.prefillSource
353
- : undefined;
354
- const disableReceiverSelection = !!props.payOptions.recipientAddress;
355
- return (_jsxs(Container, { flex: "column", gap: "md", animate: "fadein", children: [isOpen && (_jsxs(_Fragment, { children: [_jsx(DrawerOverlay, { ref: drawerOverlayRef }), _jsxs(Drawer, { ref: drawerRef, close: () => setIsOpen(false), children: [drawerScreen === "fees" && quoteQuery.data && (_jsxs("div", { children: [_jsx(Text, { size: "lg", color: "primaryText", children: "Fees" }), _jsx(Spacer, { y: "lg" }), _jsx(SwapFees, { quote: quoteQuery.data, align: "left" })] })), drawerScreen === "receiver" && (_jsx(ReceiverWalletDrawerScreen, { client: props.client, onSelect: (x) => setReceiverAddress(x), receiverAddress: receiverAddress, onBack: () => setIsOpen(false) })), drawerScreen === "payer" && (_jsx(WalletSwitcherDrawerContent, { client: client, onSelect: (w) => {
356
- const chain = w.getChain();
357
- const account = w.getAccount();
358
- if (chain && account) {
359
- props.setPayer({
360
- account,
361
- chain,
362
- wallet: w,
363
- });
364
- }
365
- }, showAllWallets: !!props.connectOptions?.showAllWallets, wallets: props.connectOptions?.wallets, onBack: () => {
366
- setIsOpen(false);
367
- }, onConnect: () => {
368
- setScreen({
369
- id: "connect-payer-wallet",
370
- backScreen: {
371
- id: "buy-with-crypto",
372
- },
373
- });
374
- }, selectedAddress: payer.account.address }))] })] })), _jsxs("div", { children: [_jsx(WalletSelectorButton, { client: props.client, onClick: () => {
375
- setIsOpen(true);
376
- setDrawerScreen("payer");
457
+ return (_jsxs(Container, { flex: "column", gap: "md", animate: "fadein", children: [isOpen && (_jsxs(_Fragment, { children: [_jsx(DrawerOverlay, { ref: drawerOverlayRef }), _jsx(Drawer, { ref: drawerRef, close: () => setIsOpen(false), children: drawerScreen === "fees" && quoteQuery.data && (_jsxs("div", { children: [_jsx(Text, { size: "lg", color: "primaryText", children: "Fees" }), _jsx(Spacer, { y: "lg" }), _jsx(SwapFees, { quote: quoteQuery.data, align: "left" })] })) })] })), _jsxs("div", { children: [_jsx(WalletSelectorButton, { client: props.client, onClick: () => {
458
+ setScreen({ id: "select-wallet" });
377
459
  }, address: props.payer.account.address, walletId: props.payer.wallet.id, containerStyle: {
378
460
  borderBottomRightRadius: 0,
379
461
  borderBottomLeftRadius: 0,
380
- } }), _jsx(PayWithCrypto, { value: sourceTokenAmount || "", onSelectToken: showFromTokenSelector, chain: fromChain, token: fromToken, isLoading: quoteQuery.isLoading && !sourceTokenAmount, client: client, freezeChainAndTokenSelection: prefillSource?.allowEdits?.chain === false &&
381
- prefillSource?.allowEdits?.token === false, payerAccount: props.payer.account }), _jsx(EstimatedTimeAndFees, { quoteIsLoading: quoteQuery.isLoading, estimatedSeconds: quoteQuery.data?.swapDetails.estimated.durationSeconds, onViewFees: showFees }), _jsx(Spacer, { y: "md" }), _jsx(Text, { size: "sm", children: "Send to" }), _jsx(Spacer, { y: "xs" }), _jsx(WalletSelectorButton, { client: props.client, disabled: disableReceiverSelection, disableChevron: disableReceiverSelection, onClick: () => {
382
- setIsOpen(true);
383
- setDrawerScreen("receiver");
384
- }, address: receiverAddress, walletId: undefined })] }), errorMsg && (_jsxs("div", { children: [errorMsg.minAmount && (_jsxs(Text, { color: "danger", size: "sm", center: true, multiline: true, children: ["Minimum amount is ", errorMsg.minAmount, " ", _jsx(TokenSymbol, { token: toToken, chain: toChain, size: "sm", inline: true, color: "danger" })] })), errorMsg.msg?.map((msg) => (_jsx(Text, { color: "danger", size: "sm", center: true, multiline: true, children: msg }, msg)))] })), errorMsg?.minAmount ? (_jsx(Button, { variant: "accent", fullWidth: true, onClick: () => {
462
+ } }), _jsx(PayWithCrypto, { value: sourceTokenAmount || "", onSelectToken: showFromTokenSelector, chain: fromChain, token: fromToken, isLoading: quoteQuery.isLoading && !sourceTokenAmount, client: client, freezeChainAndTokenSelection: disableTokenSelection, payerAccount: props.payer.account, swapRequired: swapRequired }), swapRequired && (_jsx(EstimatedTimeAndFees, { quoteIsLoading: quoteQuery.isLoading, estimatedSeconds: quoteQuery.data?.swapDetails.estimated.durationSeconds, onViewFees: showFees })), _jsx(Spacer, { y: "md" })] }), errorMsg && (_jsxs("div", { children: [errorMsg.minAmount && (_jsxs(Text, { color: "danger", size: "sm", center: true, multiline: true, children: ["Minimum amount is ", errorMsg.minAmount, " ", _jsx(TokenSymbol, { token: toToken, chain: toChain, size: "sm", inline: true, color: "danger" })] })), errorMsg.msg?.map((msg) => (_jsx(Text, { color: "danger", size: "sm", center: true, multiline: true, children: msg }, msg)))] })), !errorMsg && isNotEnoughBalance && (_jsxs("div", { children: [_jsx(Text, { color: "danger", size: "sm", center: true, multiline: true, children: "Not enough funds." }), _jsx(Text, { color: "danger", size: "sm", center: true, multiline: true, children: "Try a different wallet or token." })] })), errorMsg?.minAmount ? (_jsx(Button, { variant: "accent", fullWidth: true, onClick: () => {
385
463
  props.setTokenAmount(String(errorMsg.minAmount));
386
464
  props.setHasEditedAmount(true);
387
465
  }, children: "Set Minimum" })) : switchChainRequired &&
@@ -393,11 +471,12 @@ function SwapScreenContent(props) {
393
471
  if (!disableContinue) {
394
472
  showSwapFlow();
395
473
  }
396
- }, gap: "xs", children: isNotEnoughBalance ? (_jsx(Text, { color: "danger", children: "Not Enough Funds" })) : quoteQuery.isLoading ? (_jsxs(_Fragment, { children: ["Getting price quote", _jsx(Spinner, { size: "sm", color: "accentText" })] })) : ("Continue") }))] }));
474
+ }, gap: "xs", children: quoteQuery.isLoading ? (_jsxs(_Fragment, { children: ["Getting price quote", _jsx(Spinner, { size: "sm", color: "accentText" })] })) : ("Continue") }))] }));
397
475
  }
398
476
  function FiatScreenContent(props) {
399
477
  const { toToken, tokenAmount, payer, client, setScreen, toChain, showCurrencySelector, selectedCurrency, } = props;
400
- const [receiverAddress, setReceiverAddress] = useState(props.payOptions.recipientAddress || props.payer.account.address);
478
+ const defaultRecipientAddress = props.payOptions?.paymentInfo?.sellerAddress;
479
+ const receiverAddress = defaultRecipientAddress || props.payer.account.address;
401
480
  const { drawerRef, drawerOverlayRef, isOpen, setIsOpen } = useDrawer();
402
481
  const [drawerScreen, setDrawerScreen] = useState("fees");
403
482
  const buyWithFiatOptions = props.payOptions.buyWithFiat;
@@ -460,32 +539,19 @@ function FiatScreenContent(props) {
460
539
  };
461
540
  }
462
541
  const disableSubmit = !fiatQuoteQuery.data;
463
- const disableReceiverSelection = !!props.payOptions.recipientAddress;
464
542
  const errorMsg = !fiatQuoteQuery.isLoading && fiatQuoteQuery.error
465
543
  ? getErrorMessage(fiatQuoteQuery.error)
466
544
  : undefined;
467
- return (_jsxs(Container, { flex: "column", gap: "md", animate: "fadein", children: [isOpen && (_jsxs(_Fragment, { children: [_jsx(DrawerOverlay, { ref: drawerOverlayRef }), _jsxs(Drawer, { ref: drawerRef, close: () => setIsOpen(false), children: [drawerScreen === "fees" && fiatQuoteQuery.data && (_jsxs("div", { children: [_jsx(Text, { size: "lg", color: "primaryText", children: "Fees" }), _jsx(Spacer, { y: "lg" }), _jsx(FiatFees, { quote: fiatQuoteQuery.data })] })), drawerScreen === "receiver" && (_jsx(ReceiverWalletDrawerScreen, { client: props.client, onSelect: (x) => setReceiverAddress(x), receiverAddress: receiverAddress, onBack: () => setIsOpen(false) }))] })] })), _jsxs("div", { children: [_jsx(PayWithCreditCard, { isLoading: fiatQuoteQuery.isLoading, value: fiatQuoteQuery.data?.fromCurrencyWithFees.amount, client: client, currency: selectedCurrency, onSelectCurrency: showCurrencySelector }), _jsx(EstimatedTimeAndFees, { quoteIsLoading: fiatQuoteQuery.isLoading, estimatedSeconds: fiatQuoteQuery.data?.estimatedDurationSeconds, onViewFees: showFees }), _jsx(Spacer, { y: "md" }), _jsx(Text, { size: "sm", children: "Send to" }), _jsx(Spacer, { y: "xs" }), _jsx(WalletSelectorButton, { client: props.client, onClick: () => {
468
- setDrawerScreen("receiver");
469
- setIsOpen(true);
470
- }, address: receiverAddress, disabled: disableReceiverSelection, disableChevron: disableReceiverSelection, walletId: undefined })] }), errorMsg && (_jsxs("div", { children: [errorMsg.minAmount && (_jsxs(Text, { color: "danger", size: "sm", center: true, multiline: true, children: ["Minimum amount is ", errorMsg.minAmount, " ", _jsx(TokenSymbol, { token: toToken, chain: toChain, size: "sm", inline: true, color: "danger" })] })), errorMsg.msg?.map((msg) => (_jsx(Text, { color: "danger", size: "sm", center: true, multiline: true, children: msg }, msg)))] })), errorMsg?.minAmount ? (_jsx(Button, { variant: "accent", fullWidth: true, onClick: () => {
545
+ return (_jsxs(Container, { flex: "column", gap: "md", animate: "fadein", children: [isOpen && (_jsxs(_Fragment, { children: [_jsx(DrawerOverlay, { ref: drawerOverlayRef }), _jsx(Drawer, { ref: drawerRef, close: () => setIsOpen(false), children: drawerScreen === "fees" && fiatQuoteQuery.data && (_jsxs("div", { children: [_jsx(Text, { size: "lg", color: "primaryText", children: "Fees" }), _jsx(Spacer, { y: "lg" }), _jsx(FiatFees, { quote: fiatQuoteQuery.data })] })) })] })), _jsxs("div", { children: [_jsx(PayWithCreditCard, { isLoading: fiatQuoteQuery.isLoading, value: fiatQuoteQuery.data?.fromCurrencyWithFees.amount, client: client, currency: selectedCurrency, onSelectCurrency: showCurrencySelector }), _jsx(EstimatedTimeAndFees, { quoteIsLoading: fiatQuoteQuery.isLoading, estimatedSeconds: fiatQuoteQuery.data?.estimatedDurationSeconds, onViewFees: showFees }), _jsx(Spacer, { y: "md" })] }), errorMsg && (_jsxs("div", { children: [errorMsg.minAmount && (_jsxs(Text, { color: "danger", size: "sm", center: true, multiline: true, children: ["Minimum amount is ", errorMsg.minAmount, " ", _jsx(TokenSymbol, { token: toToken, chain: toChain, size: "sm", inline: true, color: "danger" })] })), errorMsg.msg?.map((msg) => (_jsx(Text, { color: "danger", size: "sm", center: true, multiline: true, children: msg }, msg)))] })), errorMsg?.minAmount ? (_jsx(Button, { variant: "accent", fullWidth: true, onClick: () => {
471
546
  props.setTokenAmount(String(errorMsg.minAmount));
472
547
  props.setHasEditedAmount(true);
473
548
  }, children: "Set Minimum" })) : (_jsx(Button, { variant: disableSubmit ? "outline" : "accent", "data-disabled": disableSubmit, disabled: disableSubmit, fullWidth: true, onClick: handleSubmit, gap: "xs", children: fiatQuoteQuery.isLoading ? (_jsxs(_Fragment, { children: ["Getting price quote", _jsx(Spinner, { size: "sm", color: "accentText" })] })) : ("Continue") }))] }));
474
549
  }
475
- function BuyForTxUI(props) {
476
- const chainNameQuery = useChainName(props.buyForTx.tx.chain);
477
- return (_jsxs(Container, { children: [_jsx(Spacer, { y: "xs" }), _jsxs(Container, { flex: "row", style: {
478
- justifyContent: "space-between",
479
- }, children: [_jsx(Text, { size: "sm", children: "Amount Needed" }), _jsxs(Container, { flex: "column", style: {
480
- alignItems: "flex-end",
481
- }, children: [_jsxs(Container, { flex: "row", gap: "xs", center: "y", children: [_jsxs(Text, { color: "primaryText", size: "sm", children: [props.amountNeeded, " ", props.buyForTx.tokenSymbol] }), _jsx(TokenIcon, { chain: props.buyForTx.tx.chain, client: props.client, size: "sm", token: NATIVE_TOKEN })] }), _jsx(Spacer, { y: "xxs" }), chainNameQuery.name ? (_jsx(Text, { size: "sm", children: chainNameQuery.name })) : (_jsx(Skeleton, { height: fontSize.sm, width: "50px" }))] })] }), _jsx(Spacer, { y: "md" }), _jsx(Line, {}), _jsx(Spacer, { y: "md" }), _jsxs(Container, { flex: "row", style: {
482
- justifyContent: "space-between",
483
- }, children: [_jsx(Text, { size: "sm", children: "Your Balance" }), _jsxs(Container, { flex: "row", gap: "xs", children: [_jsxs(Text, { color: "primaryText", size: "sm", children: [formatNumber(Number(toEther(props.buyForTx.balance)), 6), " ", props.buyForTx.tokenSymbol] }), _jsx(TokenIcon, { chain: props.buyForTx.tx.chain, client: props.client, size: "sm", token: NATIVE_TOKEN })] })] }), _jsx(Spacer, { y: "md" }), _jsx(Line, {}), _jsx(Spacer, { y: "xl" }), _jsx(Text, { center: true, size: "sm", children: "Purchase" }), _jsx(Spacer, { y: "xxs" })] }));
484
- }
485
550
  function createSupportedTokens(data, payOptions, supportedTokensOverrides) {
486
551
  const tokens = {};
487
552
  const isBuyWithFiatDisabled = payOptions.buyWithFiat === false;
488
553
  const isBuyWithCryptoDisabled = payOptions.buyWithCrypto === false;
554
+ // FIXME (pay) when buywithFiat is disabled, missing a bunch of tokens on base??
489
555
  for (const x of data) {
490
556
  tokens[x.chain.id] = x.tokens.filter((t) => {
491
557
  // it token supports both - include it