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
@@ -34,13 +34,12 @@ export function OnrampStatusScreen(props: {
34
34
  client: ThirdwebClient;
35
35
  onBack: () => void;
36
36
  intentId: string;
37
- onViewPendingTx: () => void;
38
37
  hasTwoSteps: boolean;
39
38
  openedWindow: Window | null;
40
39
  quote: BuyWithFiatQuote;
41
40
  onDone: () => void;
42
41
  onShowSwapFlow: (status: BuyWithFiatStatus) => void;
43
- isBuyForTx: boolean;
42
+ transactionMode: boolean;
44
43
  isEmbed: boolean;
45
44
  }) {
46
45
  const queryClient = useQueryClient();
@@ -117,7 +116,7 @@ export function OnrampStatusScreen(props: {
117
116
  onDone={props.onDone}
118
117
  fiatStatus={statusQuery.data}
119
118
  client={props.client}
120
- isBuyForTx={props.isBuyForTx}
119
+ transactionMode={props.transactionMode}
121
120
  quote={props.quote}
122
121
  isEmbed={props.isEmbed}
123
122
  />
@@ -130,7 +129,7 @@ function OnrampStatusScreenUI(props: {
130
129
  fiatStatus?: BuyWithFiatStatus;
131
130
  onDone: () => void;
132
131
  client: ThirdwebClient;
133
- isBuyForTx: boolean;
132
+ transactionMode: boolean;
134
133
  isEmbed: boolean;
135
134
  quote: BuyWithFiatQuote;
136
135
  }) {
@@ -189,7 +188,7 @@ function OnrampStatusScreenUI(props: {
189
188
  <>
190
189
  <Spacer y="md" />
191
190
  <Container flex="row" center="x">
192
- <Spinner size="3xl" color="accentText" />
191
+ <Spinner size="xxl" color="accentText" />
193
192
  </Container>
194
193
  <Spacer y="md" />
195
194
  <Text color="primaryText" size="lg" center>
@@ -240,7 +239,7 @@ function OnrampStatusScreenUI(props: {
240
239
 
241
240
  {!props.isEmbed && (
242
241
  <Button variant="accent" fullWidth onClick={props.onDone}>
243
- {props.isBuyForTx ? "Continue Transaction" : "Done"}
242
+ {props.transactionMode ? "Continue Transaction" : "Done"}
244
243
  </Button>
245
244
  )}
246
245
  </>
@@ -19,9 +19,8 @@ export function PostOnRampSwap(props: {
19
19
  client: ThirdwebClient;
20
20
  buyWithFiatStatus: BuyWithFiatStatus;
21
21
  onBack?: () => void;
22
- onViewPendingTx: () => void;
23
22
  onDone: () => void;
24
- isBuyForTx: boolean;
23
+ transactionMode: boolean;
25
24
  isEmbed: boolean;
26
25
  payer: PayerInfo;
27
26
  }) {
@@ -123,14 +122,13 @@ export function PostOnRampSwap(props: {
123
122
  buyWithCryptoQuote={lockedOnRampQuote}
124
123
  client={props.client}
125
124
  onBack={props.onBack}
126
- onViewPendingTx={props.onViewPendingTx}
127
125
  isFiatFlow={true}
128
126
  onDone={props.onDone}
129
127
  onTryAgain={() => {
130
128
  setLockedOnRampQuote(undefined);
131
129
  postOnRampQuoteQuery.refetch();
132
130
  }}
133
- isBuyForTx={props.isBuyForTx}
131
+ transactionMode={props.transactionMode}
134
132
  isEmbed={props.isEmbed}
135
133
  />
136
134
  );
@@ -17,10 +17,9 @@ export function PostOnRampSwapFlow(props: {
17
17
  quote: BuyWithFiatPartialQuote;
18
18
  client: ThirdwebClient;
19
19
  onBack: () => void;
20
- onViewPendingTx: () => void;
21
20
  onDone: () => void;
22
21
  onSwapFlowStarted: () => void;
23
- isBuyForTx: boolean;
22
+ transactionMode: boolean;
24
23
  isEmbed: boolean;
25
24
  payer: PayerInfo;
26
25
  }) {
@@ -35,9 +34,8 @@ export function PostOnRampSwapFlow(props: {
35
34
  title={props.title}
36
35
  buyWithFiatStatus={statusForSwap}
37
36
  client={props.client}
38
- onViewPendingTx={props.onViewPendingTx}
39
37
  onDone={props.onDone}
40
- isBuyForTx={props.isBuyForTx}
38
+ transactionMode={props.transactionMode}
41
39
  isEmbed={props.isEmbed}
42
40
  payer={props.payer}
43
41
  />
@@ -1,22 +1,23 @@
1
1
  import type { BuyWithCryptoQuote } from "../../../../../../../pay/buyWithCrypto/getQuote.js";
2
2
  import type { BuyWithFiatQuote } from "../../../../../../../pay/buyWithFiat/getQuote.js";
3
- import type { PreparedTransaction } from "../../../../../../../transaction/prepare-transaction.js";
3
+ import type { GetWalletBalanceResult } from "../../../../../../../wallets/utils/getWalletBalance.js";
4
+ import type { TokenInfo } from "../../../../../../core/utils/defaultTokens.js";
4
5
 
5
- export type BuyForTx = {
6
- cost: bigint;
7
- balance: bigint;
8
- tx: PreparedTransaction;
9
- tokenSymbol: string;
10
- tokenDecimals: number;
6
+ export type TransactionCostAndData = {
7
+ token: TokenInfo;
8
+ decimals: number;
9
+ walletBalance: GetWalletBalanceResult;
10
+ transactionValueWei: bigint;
11
+ gasCostWei: bigint;
11
12
  };
12
13
 
13
14
  export type SelectedScreen =
14
15
  | {
15
- id:
16
- | "main"
17
- | "select-payment-method"
18
- | "buy-with-fiat"
19
- | "buy-with-crypto";
16
+ id: "main" | "select-payment-method" | "buy-with-fiat" | "select-wallet";
17
+ }
18
+ | {
19
+ id: "buy-with-crypto";
20
+ payDisabled?: boolean;
20
21
  }
21
22
  | {
22
23
  id: "select-from-token";
@@ -39,6 +40,9 @@ export type SelectedScreen =
39
40
  quote: BuyWithFiatQuote;
40
41
  openedWindow: Window | null;
41
42
  }
43
+ | {
44
+ id: "transfer-flow";
45
+ }
42
46
  | {
43
47
  id: "connect-payer-wallet";
44
48
  backScreen: SelectedScreen;
@@ -1,76 +1,171 @@
1
+ import { useQuery } from "@tanstack/react-query";
1
2
  import { useEffect, useState } from "react";
2
- import { toEther } from "../../../../../../../utils/units.js";
3
+ import { getChainMetadata } from "../../../../../../../chains/utils.js";
4
+ import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js";
5
+ import { getContract } from "../../../../../../../contract/contract.js";
6
+ import { getCurrencyMetadata } from "../../../../../../../extensions/erc20/read/getCurrencyMetadata.js";
7
+ import { getGasPrice } from "../../../../../../../gas/get-gas-price.js";
8
+ import { encode } from "../../../../../../../transaction/actions/encode.js";
9
+ import { estimateGasCost } from "../../../../../../../transaction/actions/estimate-gas-cost.js";
10
+ import type { PreparedTransaction } from "../../../../../../../transaction/prepare-transaction.js";
11
+ import type { Hex } from "../../../../../../../utils/encoding/hex.js";
12
+ import { resolvePromisedValue } from "../../../../../../../utils/promise/resolve-promised-value.js";
3
13
  import type { Account } from "../../../../../../../wallets/interfaces/wallet.js";
4
- import { getTotalTxCostForBuy } from "../../../../../../core/hooks/transaction/useSendTransaction.js";
5
- import { wait } from "../../../../../../core/utils/wait.js";
6
- import type { BuyForTx } from "./types.js";
14
+ import { getWalletBalance } from "../../../../../../../wallets/utils/getWalletBalance.js";
15
+ import type { SupportedChainAndTokens } from "../swap/useSwapSupportedChains.js";
16
+ import type { TransactionCostAndData } from "./types.js";
7
17
 
8
- export function useBuyTxStates(options: {
9
- setTokenAmount: (value: string) => void;
10
- buyForTx: BuyForTx | null;
11
- hasEditedAmount: boolean;
12
- account: Account | null;
18
+ export function useTransactionCostAndData(args: {
19
+ transaction: PreparedTransaction;
20
+ account: Account | undefined;
21
+ supportedDestinations: SupportedChainAndTokens;
13
22
  }) {
14
- const { buyForTx, hasEditedAmount, setTokenAmount, account } = options;
15
- const shouldRefreshTokenAmount = !hasEditedAmount;
16
-
17
- const [amountNeeded, setAmountNeeded] = useState<bigint | undefined>(
18
- buyForTx?.cost,
19
- );
20
-
21
- // update amount needed every 30 seconds
22
- // also update the token amount if allowed
23
- // ( Can't use useQuery because tx can't be added to queryKey )
23
+ const { transaction, account, supportedDestinations } = args;
24
+ // Compute query key of the transaction first
25
+ const [txQueryKey, setTxQueryKey] = useState<
26
+ | {
27
+ value: string | undefined;
28
+ erc20Value: string | undefined;
29
+ erc20Currency: string | undefined;
30
+ to: string | undefined;
31
+ data: Hex | undefined;
32
+ }
33
+ | undefined
34
+ >();
24
35
  useEffect(() => {
25
- if (!buyForTx) {
26
- return;
27
- }
28
-
29
- let mounted = true;
30
-
31
- if (buyForTx.tx.erc20Value) {
32
- // if erc20 value is set, we don't need to poll
33
- return;
34
- }
36
+ Promise.all([
37
+ resolvePromisedValue(transaction.value),
38
+ resolvePromisedValue(transaction.erc20Value),
39
+ resolvePromisedValue(transaction.to),
40
+ encode(transaction),
41
+ ]).then(([value, erc20Value, to, data]) => {
42
+ setTxQueryKey({
43
+ value: value?.toString(),
44
+ erc20Value: erc20Value?.amountWei?.toString(),
45
+ erc20Currency: erc20Value?.tokenAddress,
46
+ to,
47
+ data,
48
+ });
49
+ });
50
+ }, [transaction]);
35
51
 
36
- async function pollTxCost() {
37
- if (!buyForTx || !mounted) {
38
- return;
52
+ return useQuery({
53
+ queryKey: [
54
+ "transaction-cost",
55
+ transaction.chain.id,
56
+ account?.address,
57
+ txQueryKey,
58
+ ],
59
+ queryFn: async () => {
60
+ if (!account) {
61
+ throw new Error("No account");
39
62
  }
40
63
 
41
- try {
42
- const totalCost = await getTotalTxCostForBuy(
43
- buyForTx.tx,
44
- account?.address,
45
- );
46
-
47
- if (!mounted) {
48
- return;
49
- }
64
+ const erc20Value = await resolvePromisedValue(transaction.erc20Value);
65
+ if (erc20Value) {
66
+ const [tokenBalance, tokenMeta, gasCostWei] = await Promise.all([
67
+ getWalletBalance({
68
+ address: account.address,
69
+ chain: transaction.chain,
70
+ client: transaction.client,
71
+ tokenAddress: erc20Value.tokenAddress,
72
+ }),
73
+ getCurrencyMetadata({
74
+ contract: getContract({
75
+ address: erc20Value.tokenAddress,
76
+ chain: transaction.chain,
77
+ client: transaction.client,
78
+ }),
79
+ }),
80
+ getTransactionGasCost(transaction, account?.address),
81
+ ]);
82
+ const transactionValueWei = erc20Value.amountWei;
83
+ const walletBalance = tokenBalance;
84
+ const currency = {
85
+ address: erc20Value.tokenAddress,
86
+ name: tokenMeta.name,
87
+ symbol: tokenMeta.symbol,
88
+ icon: supportedDestinations
89
+ .find((c) => c.chain.id === transaction.chain.id)
90
+ ?.tokens.find(
91
+ (t) =>
92
+ t.address.toLowerCase() ===
93
+ erc20Value.tokenAddress.toLowerCase(),
94
+ )?.icon,
95
+ };
96
+ return {
97
+ token: currency,
98
+ decimals: tokenMeta.decimals,
99
+ walletBalance,
100
+ gasCostWei,
101
+ transactionValueWei,
102
+ } satisfies TransactionCostAndData;
103
+ }
50
104
 
51
- setAmountNeeded(totalCost);
105
+ const [nativeWalletBalance, chainMetadata, gasCostWei] =
106
+ await Promise.all([
107
+ getWalletBalance({
108
+ address: account.address,
109
+ chain: transaction.chain,
110
+ client: transaction.client,
111
+ }),
112
+ getChainMetadata(transaction.chain),
113
+ getTransactionGasCost(transaction, account?.address),
114
+ ]);
52
115
 
53
- if (shouldRefreshTokenAmount) {
54
- if (totalCost > buyForTx.balance) {
55
- setTokenAmount(toEther(totalCost - buyForTx.balance));
56
- }
57
- }
58
- } catch (error) {
59
- // no op
116
+ const walletBalance = nativeWalletBalance;
117
+ const transactionValueWei =
118
+ (await resolvePromisedValue(transaction.value)) || 0n;
119
+ return {
120
+ token: {
121
+ address: NATIVE_TOKEN_ADDRESS,
122
+ name: chainMetadata.nativeCurrency.name,
123
+ symbol: chainMetadata.nativeCurrency.symbol,
124
+ icon: chainMetadata.icon?.url,
125
+ },
126
+ decimals: 18,
127
+ walletBalance,
128
+ gasCostWei,
129
+ transactionValueWei,
130
+ } satisfies TransactionCostAndData;
131
+ },
132
+ enabled: !!transaction && !!account && !!txQueryKey,
133
+ refetchInterval: () => {
134
+ if (transaction.erc20Value) {
135
+ // if erc20 value is set, we don't need to poll
136
+ return undefined;
60
137
  }
138
+ return 30_000;
139
+ },
140
+ });
141
+ }
61
142
 
62
- await wait(30000);
63
- pollTxCost();
64
- }
143
+ export async function getTransactionGasCost(
144
+ tx: PreparedTransaction,
145
+ from?: string,
146
+ ) {
147
+ try {
148
+ const gasCost = await estimateGasCost({
149
+ transaction: tx,
150
+ from,
151
+ });
65
152
 
66
- pollTxCost();
153
+ const bufferCost = gasCost.wei / 10n;
67
154
 
68
- return () => {
69
- mounted = false;
70
- };
71
- }, [buyForTx, shouldRefreshTokenAmount, setTokenAmount, account]);
155
+ // Note: get tx.value AFTER estimateGasCost
156
+ // add 10% extra gas cost to the estimate to ensure user buys enough to cover the tx cost
157
+ return gasCost.wei + bufferCost;
158
+ } catch (e) {
159
+ if (from) {
160
+ // try again without passing from
161
+ return await getTransactionGasCost(tx);
162
+ }
163
+ // fallback if both fail, use the tx value + 2M * gas price
164
+ const gasPrice = await getGasPrice({
165
+ client: tx.client,
166
+ chain: tx.chain,
167
+ });
72
168
 
73
- return {
74
- amountNeeded,
75
- };
169
+ return 2_000_000n * gasPrice;
170
+ }
76
171
  }
@@ -7,13 +7,18 @@ import type { SupportedChainAndTokens } from "../swap/useSwapSupportedChains.js"
7
7
  // Based on what toToken, toChain, and supportedDestinations are, determine which payment methods should be enabled
8
8
  // change the current method if it should be disabled
9
9
  // return whether the payment selection should be shown or not ( if only one payment method is enabled, don't show the selection )
10
+ export type PaymentMethods = {
11
+ showPaymentSelection: boolean;
12
+ buyWithFiatEnabled: boolean;
13
+ buyWithCryptoEnabled: boolean;
14
+ };
10
15
 
11
16
  export function useEnabledPaymentMethods(options: {
12
17
  payOptions: PayUIOptions;
13
18
  supportedDestinations: SupportedChainAndTokens;
14
19
  toChain: Chain;
15
20
  toToken: ERC20OrNativeToken;
16
- }) {
21
+ }): PaymentMethods {
17
22
  const { payOptions, supportedDestinations, toChain, toToken } = options;
18
23
 
19
24
  function getEnabledPayMethodsForSelectedToken(): {
@@ -23,8 +28,8 @@ export function useEnabledPaymentMethods(options: {
23
28
  const chain = supportedDestinations.find((c) => c.chain.id === toChain.id);
24
29
  if (!chain) {
25
30
  return {
26
- fiat: true,
27
- swap: true,
31
+ fiat: false,
32
+ swap: false,
28
33
  };
29
34
  }
30
35
 
@@ -1,29 +1,29 @@
1
1
  import { useState } from "react";
2
2
  import { polygon } from "../../../../../../../chains/chain-definitions/polygon.js";
3
3
  import type { Chain } from "../../../../../../../chains/types.js";
4
- import { toEther } from "../../../../../../../utils/units.js";
5
- import type { PayUIOptions } from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
4
+ import type {
5
+ FundWalletOptions,
6
+ PayUIOptions,
7
+ } from "../../../../../../core/hooks/connection/ConnectButtonProps.js";
6
8
  import { useActiveWalletChain } from "../../../../../hooks/wallets/useActiveWalletChain.js";
7
9
  import { useDebouncedValue } from "../../../../hooks/useDebouncedValue.js";
8
10
  import { type ERC20OrNativeToken, NATIVE_TOKEN } from "../../nativeToken.js";
9
11
  import { defaultSelectedCurrency } from "../fiat/currencies.js";
10
12
  import type { SupportedChainAndTokens } from "../swap/useSwapSupportedChains.js";
11
- import type { BuyForTx } from "./types.js";
12
13
 
13
14
  // handle states for token and chain selection
14
15
 
15
16
  export function useUISelectionStates(options: {
16
17
  payOptions: PayUIOptions;
17
- buyForTx?: BuyForTx;
18
18
  supportedDestinations: SupportedChainAndTokens;
19
19
  }) {
20
20
  const activeChain = useActiveWalletChain();
21
- const { payOptions, buyForTx, supportedDestinations } = options;
21
+ const { payOptions, supportedDestinations } = options;
22
22
 
23
23
  // buy token amount ---------------------------------------------------------
24
- const initialTokenAmount =
25
- payOptions.prefillBuy?.amount ||
26
- (buyForTx ? String(toEther(buyForTx.cost - buyForTx.balance)) : "");
24
+ // NOTE - for transaction / direct payment modes, the token amount is set when the user tap continue
25
+ const prefillBuy = (payOptions as FundWalletOptions)?.prefillBuy;
26
+ const initialTokenAmount = prefillBuy?.amount || "";
27
27
 
28
28
  const [tokenAmount, setTokenAmount] = useState<string>(initialTokenAmount);
29
29
  const deferredTokenAmount = useDebouncedValue(tokenAmount, 300);
@@ -33,9 +33,9 @@ export function useUISelectionStates(options: {
33
33
  // Destination chain and token selection -----------------------------------
34
34
  const [toChain, setToChain] = useState<Chain>(
35
35
  // use prefill chain if available
36
- payOptions.prefillBuy?.chain ||
37
- // use buyForTx chain if available
38
- buyForTx?.tx.chain ||
36
+ prefillBuy?.chain ||
37
+ (payOptions.mode === "transaction" && payOptions.transaction?.chain) ||
38
+ (payOptions.mode === "direct_payment" && payOptions.paymentInfo?.chain) ||
39
39
  // use active chain if its supported as destination
40
40
  supportedDestinations.find((x) => x.chain.id === activeChain?.id)
41
41
  ?.chain ||
@@ -44,7 +44,9 @@ export function useUISelectionStates(options: {
44
44
  );
45
45
 
46
46
  const [toToken, setToToken] = useState<ERC20OrNativeToken>(
47
- payOptions.prefillBuy?.token || NATIVE_TOKEN,
47
+ prefillBuy?.token ||
48
+ (payOptions.mode === "direct_payment" && payOptions.paymentInfo.token) ||
49
+ NATIVE_TOKEN,
48
50
  );
49
51
  // --------------------------------------------------------------------------
50
52
 
@@ -53,6 +55,8 @@ export function useUISelectionStates(options: {
53
55
  // use prefill chain if available
54
56
  (payOptions.buyWithCrypto !== false &&
55
57
  payOptions.buyWithCrypto?.prefillSource?.chain) ||
58
+ (payOptions.mode === "transaction" && payOptions.transaction?.chain) ||
59
+ (payOptions.mode === "direct_payment" && payOptions.paymentInfo?.chain) ||
56
60
  // default to polygon
57
61
  polygon,
58
62
  );
@@ -61,6 +65,7 @@ export function useUISelectionStates(options: {
61
65
  // use prefill token if available
62
66
  (payOptions.buyWithCrypto !== false &&
63
67
  payOptions.buyWithCrypto?.prefillSource?.token) ||
68
+ (payOptions.mode === "direct_payment" && payOptions.paymentInfo.token) ||
64
69
  // default to native token
65
70
  NATIVE_TOKEN,
66
71
  );
@@ -40,7 +40,7 @@ export function PayTxHistoryScreen(props: {
40
40
  onBack?: () => void;
41
41
  client: ThirdwebClient;
42
42
  onDone: () => void;
43
- isBuyForTx: boolean;
43
+ transactionMode: boolean;
44
44
  isEmbed: boolean;
45
45
  }) {
46
46
  const [selectedTx, setSelectedTx] = useState<TxStatusInfo | null>(null);
@@ -66,7 +66,7 @@ export function PayTxHistoryScreen(props: {
66
66
  statusInfo={selectedTx}
67
67
  onBack={() => setSelectedTx(null)}
68
68
  onDone={props.onDone}
69
- isBuyForTx={props.isBuyForTx}
69
+ transactionMode={props.transactionMode}
70
70
  isEmbed={props.isEmbed}
71
71
  payer={payer}
72
72
  />
@@ -17,7 +17,7 @@ export function FiatDetailsScreen(props: {
17
17
  onBack: () => void;
18
18
  client: ThirdwebClient;
19
19
  onDone: () => void;
20
- isBuyForTx: boolean;
20
+ transactionMode: boolean;
21
21
  isEmbed: boolean;
22
22
  payer: PayerInfo;
23
23
  }) {
@@ -48,8 +48,7 @@ export function FiatDetailsScreen(props: {
48
48
  client={props.client}
49
49
  status={status}
50
50
  onBack={props.onBack}
51
- onViewPendingTx={props.onBack}
52
- isBuyForTx={props.isBuyForTx}
51
+ transactionMode={props.transactionMode}
53
52
  isEmbed={props.isEmbed}
54
53
  quote={{
55
54
  fromCurrencyAmount: fiatQuote.fromCurrencyWithFees.amount,
@@ -289,7 +289,7 @@ export function SwapTxDetailsTable(
289
289
  >
290
290
  <Text>Send to</Text>
291
291
  <Container flex="row" gap="xs" center="y">
292
- <Text color="primaryText">
292
+ <Text color="primaryText" size="sm">
293
293
  {shortenAddress(uiData.toAddress)}
294
294
  </Text>
295
295
  </Container>
@@ -28,7 +28,7 @@ export function TokenInfoRow(props: {
28
28
  justifyContent: "space-between",
29
29
  }}
30
30
  >
31
- <Text>{props.label}</Text>
31
+ <Text size="sm">{props.label}</Text>
32
32
  <Container
33
33
  flex="column"
34
34
  gap="xxs"
@@ -10,7 +10,7 @@ export function TxDetailsScreen(props: {
10
10
  statusInfo: TxStatusInfo;
11
11
  onBack: () => void;
12
12
  onDone: () => void;
13
- isBuyForTx: boolean;
13
+ transactionMode: boolean;
14
14
  isEmbed: boolean;
15
15
  payer: PayerInfo;
16
16
  }) {
@@ -34,7 +34,7 @@ export function TxDetailsScreen(props: {
34
34
  status={statusInfo.status}
35
35
  onBack={props.onBack}
36
36
  onDone={props.onDone}
37
- isBuyForTx={props.isBuyForTx}
37
+ transactionMode={props.transactionMode}
38
38
  isEmbed={props.isEmbed}
39
39
  payer={props.payer}
40
40
  />