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,5 +1,6 @@
1
1
  import { useQuery } from "@tanstack/react-query";
2
2
  import type { AsyncStorage } from "../../../../utils/storage/AsyncStorage.js";
3
+ import { getUrlToken } from "../../../../wallets/in-app/web/lib/get-url-token.js";
3
4
  import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
4
5
  import {
5
6
  type ConnectionManager,
@@ -7,6 +8,7 @@ import {
7
8
  getStoredActiveWalletId,
8
9
  getStoredConnectedWalletIds,
9
10
  } from "../../../../wallets/manager/index.js";
11
+ import { setLastAuthProvider } from "../../utils/storage.js";
10
12
  import { timeoutPromise } from "../../utils/timeoutPromise.js";
11
13
  import type { AutoConnectProps } from "../connection/types.js";
12
14
  import { useConnectCore } from "./useConnect.js";
@@ -32,12 +34,23 @@ export function useAutoConnectCore(
32
34
  const autoConnect = async (): Promise<boolean> => {
33
35
  let autoConnected = false;
34
36
  isAutoConnecting.setValue(true);
35
- const [lastConnectedWalletIds, lastActiveWalletId] = await Promise.all([
37
+ let [lastConnectedWalletIds, lastActiveWalletId] = await Promise.all([
36
38
  getStoredConnectedWalletIds(storage),
37
39
  getStoredActiveWalletId(storage),
38
40
  ]);
39
41
 
40
- // if no wallets were last connected
42
+ const { authResult, walletId, authProvider } = getUrlToken();
43
+ if (authResult && walletId) {
44
+ lastActiveWalletId = walletId;
45
+ lastConnectedWalletIds = lastConnectedWalletIds?.includes(walletId)
46
+ ? lastConnectedWalletIds
47
+ : [walletId, ...(lastConnectedWalletIds || [])];
48
+ }
49
+ if (authProvider) {
50
+ await setLastAuthProvider(authProvider, storage);
51
+ }
52
+
53
+ // if no wallets were last connected or we didn't receive an auth token
41
54
  if (!lastConnectedWalletIds) {
42
55
  return autoConnected;
43
56
  }
@@ -48,6 +61,7 @@ export function useAutoConnectCore(
48
61
  return wallet.autoConnect({
49
62
  client: props.client,
50
63
  chain: lastConnectedChain ?? undefined,
64
+ authResult,
51
65
  });
52
66
  }
53
67
 
@@ -61,7 +75,7 @@ export function useAutoConnectCore(
61
75
  setConnectionStatus("connecting"); // only set connecting status if we are connecting the last active EOA
62
76
  await timeoutPromise(handleWalletConnection(activeWallet), {
63
77
  ms: timeout,
64
- message: `AutoConnect timeout : ${timeout}ms limit exceeded.`,
78
+ message: `AutoConnect timeout: ${timeout}ms limit exceeded.`,
65
79
  });
66
80
 
67
81
  // connected wallet could be activeWallet or smart wallet
@@ -1,3 +1,4 @@
1
+ import type { Chain } from "../../../chains/types.js";
1
2
  import type { Address } from "../../../utils/address.js";
2
3
 
3
4
  export type TokenInfo = {
@@ -34,31 +35,8 @@ const fantomIcon =
34
35
  export type SupportedTokens = Record<number, TokenInfo[]>;
35
36
  export type SupportedNFTs = Record<number, Address[]>;
36
37
 
37
- /**
38
- * Default tokens shown in [`ConnectButton`](https://portal.thirdweb.com/react/v4/components/ConnectButton)'s SendFunds screen for each network.
39
- *
40
- * You can use the default tokens as a starting point for your own list of tokens and override tokens for specific networks.
41
- * @example
42
- * Below example shows adding a custom token for the Ethereum mainnet at start of the list of default tokens for the Ethereum mainnet. Here the `1` represents the chainId of Ethereum mainnet.
43
- *
44
- * ```tsx
45
- * const ethereumChainId = 1;
46
- *
47
- * <ConnectButton supportedTokens={{
48
- * ...defaultTokens,
49
- * [ethereumChainId]: [
50
- * {
51
- * address: 'YOUR_TOKEN_ADDRESS',
52
- * name: 'YOUR_TOKEN_NAME',
53
- * symbol: 'YOUR_TOKEN_SYMBOL',
54
- * icon: 'YOUR_TOKEN_ICON_URL'
55
- * },
56
- * ...defaultTokens[ethereumChainId],
57
- * ]
58
- * }} />
59
- * ```
60
- */
61
- export const defaultTokens: SupportedTokens = {
38
+ // TODO these should be moved to chain definitions
39
+ const DEFAULT_TOKENS = {
62
40
  "1": [
63
41
  {
64
42
  address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
@@ -333,4 +311,38 @@ export const defaultTokens: SupportedTokens = {
333
311
  icon: usdcIcon,
334
312
  },
335
313
  ],
336
- };
314
+ } as const;
315
+
316
+ /**
317
+ * Default tokens shown in [`ConnectButton`](https://portal.thirdweb.com/react/v4/components/ConnectButton)'s SendFunds screen for each network.
318
+ *
319
+ * You can use the default tokens as a starting point for your own list of tokens and override tokens for specific networks.
320
+ * @example
321
+ * Below example shows adding a custom token for the Ethereum mainnet at start of the list of default tokens for the Ethereum mainnet. Here the `1` represents the chainId of Ethereum mainnet.
322
+ *
323
+ * ```tsx
324
+ * const ethereumChainId = 1;
325
+ *
326
+ * <ConnectButton supportedTokens={{
327
+ * ...defaultTokens,
328
+ * [ethereumChainId]: [
329
+ * {
330
+ * address: 'YOUR_TOKEN_ADDRESS',
331
+ * name: 'YOUR_TOKEN_NAME',
332
+ * symbol: 'YOUR_TOKEN_SYMBOL',
333
+ * icon: 'YOUR_TOKEN_ICON_URL'
334
+ * },
335
+ * ...defaultTokens[ethereumChainId],
336
+ * ]
337
+ * }} />
338
+ * ```
339
+ */
340
+ export const defaultTokens = DEFAULT_TOKENS as unknown as SupportedTokens;
341
+
342
+ type SupportedSymbol =
343
+ (typeof DEFAULT_TOKENS)[keyof typeof DEFAULT_TOKENS][number]["symbol"];
344
+
345
+ export function getDefaultToken(chain: Chain, symbol: SupportedSymbol) {
346
+ const tokens = defaultTokens[chain.id];
347
+ return tokens?.find((t) => t.symbol === symbol);
348
+ }
@@ -5,12 +5,75 @@ import type { ThirdwebClient } from "../../../client/client.js";
5
5
  import { resolveAvatar } from "../../../extensions/ens/resolve-avatar.js";
6
6
  import { resolveName } from "../../../extensions/ens/resolve-name.js";
7
7
  import { getWalletInfo } from "../../../wallets/__generated__/getWalletInfo.js";
8
- import type { Account } from "../../../wallets/interfaces/wallet.js";
8
+ import type { Account, Wallet } from "../../../wallets/interfaces/wallet.js";
9
9
  import type { WalletInfo } from "../../../wallets/wallet-info.js";
10
10
  import type { WalletId } from "../../../wallets/wallet-types.js";
11
11
  import { useWalletBalance } from "../hooks/others/useWalletBalance.js";
12
12
  import { shortenString } from "./addresses.js";
13
13
 
14
+ /**
15
+ * Get the ENS name and avatar for an address
16
+ * @param options - the client and address to get the ENS name and avatar for
17
+ * @returns - a query object that resolves to the ENS name
18
+ * @example
19
+ * ```tsx
20
+ * import { useEnsName } from "thirdweb/react";
21
+ *
22
+ * const { data: ensName } = useEnsName({
23
+ * client,
24
+ * address: "0x1234...",
25
+ * });
26
+ * ```
27
+ * @extension ENS
28
+ */
29
+ export function useEnsName(options: {
30
+ client: ThirdwebClient;
31
+ address: string | undefined;
32
+ }) {
33
+ const { client, address } = options;
34
+ return useQuery({
35
+ queryKey: ["ens-name", address],
36
+ enabled: !!address,
37
+ queryFn: () =>
38
+ resolveName({
39
+ client,
40
+ address: address || "",
41
+ resolverChain: ethereum,
42
+ }),
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Get the ENS avatar for an ENS name
48
+ * @param options - the client and ENS name to get the avatar for
49
+ * @returns - a query object that resolves to the avatar
50
+ * @example
51
+ * ```tsx
52
+ * import { useEnsAvatar } from "thirdweb/react";
53
+ *
54
+ * const { data: ensAvatar } = useEnsAvatar({
55
+ * client,
56
+ * ensName: "my-ens-name.eth",
57
+ * });
58
+ * ```
59
+ * @extension ENS
60
+ */
61
+ export function useEnsAvatar(options: {
62
+ client: ThirdwebClient;
63
+ ensName: string | null | undefined;
64
+ }) {
65
+ const { client, ensName } = options;
66
+ return useQuery({
67
+ queryKey: ["ens-avatar", ensName],
68
+ enabled: !!ensName,
69
+ queryFn: async () =>
70
+ resolveAvatar({
71
+ client,
72
+ name: ensName || "",
73
+ }),
74
+ });
75
+ }
76
+
14
77
  /**
15
78
  * @internal
16
79
  */
@@ -25,25 +88,14 @@ export function useConnectedWalletDetails(
25
88
  ? displayBalanceToken[Number(walletChain.id)]
26
89
  : undefined;
27
90
 
28
- const ensNameQuery = useQuery({
29
- queryKey: ["ens-name", activeAccount?.address],
30
- enabled: !!activeAccount?.address,
31
- queryFn: () =>
32
- resolveName({
33
- client,
34
- address: activeAccount?.address || "",
35
- resolverChain: ethereum,
36
- }),
91
+ const ensNameQuery = useEnsName({
92
+ client,
93
+ address: activeAccount?.address,
37
94
  });
38
95
 
39
- const ensAvatarQuery = useQuery({
40
- queryKey: ["ens-avatar", ensNameQuery.data],
41
- enabled: !!ensNameQuery.data,
42
- queryFn: async () =>
43
- resolveAvatar({
44
- client,
45
- name: ensNameQuery.data || "",
46
- }),
96
+ const ensAvatarQuery = useEnsAvatar({
97
+ client,
98
+ ensName: ensNameQuery.data,
47
99
  });
48
100
 
49
101
  const shortAddress = activeAccount?.address
@@ -107,3 +159,35 @@ export function useWalletImage(id: WalletId | undefined) {
107
159
  enabled: !!id,
108
160
  });
109
161
  }
162
+
163
+ /**
164
+ * @internal
165
+ */
166
+ export function hasSponsoredTransactionsEnabled(wallet: Wallet | undefined) {
167
+ if (!wallet) {
168
+ return false;
169
+ }
170
+ let sponsoredTransactionsEnabled = false;
171
+ if (wallet && wallet.id === "smart") {
172
+ const options = (wallet as Wallet<"smart">).getConfig();
173
+ if ("sponsorGas" in options) {
174
+ sponsoredTransactionsEnabled = options.sponsorGas;
175
+ }
176
+ if ("gasless" in options) {
177
+ sponsoredTransactionsEnabled = options.gasless;
178
+ }
179
+ }
180
+ if (wallet && wallet.id === "inApp") {
181
+ const options = (wallet as Wallet<"inApp">).getConfig();
182
+ if (options && "smartAccount" in options && options.smartAccount) {
183
+ const smartOptions = options.smartAccount;
184
+ if ("sponsorGas" in smartOptions) {
185
+ sponsoredTransactionsEnabled = smartOptions.sponsorGas;
186
+ }
187
+ if ("gasless" in smartOptions) {
188
+ sponsoredTransactionsEnabled = smartOptions.gasless;
189
+ }
190
+ }
191
+ }
192
+ return sponsoredTransactionsEnabled;
193
+ }
@@ -1,33 +1,11 @@
1
- import { CheckCircledIcon } from "@radix-ui/react-icons";
2
- import { useCallback, useContext, useEffect, useRef, useState } from "react";
3
- import type { ThirdwebClient } from "../../../../client/client.js";
4
- import { isNativeTokenAddress } from "../../../../constants/addresses.js";
5
- import type { WaitForReceiptOptions } from "../../../../transaction/actions/wait-for-tx-receipt.js";
6
- import type { PreparedTransaction } from "../../../../transaction/prepare-transaction.js";
7
- import { toTokens } from "../../../../utils/units.js";
8
- import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
9
- import type { GetWalletBalanceResult } from "../../../../wallets/utils/getWalletBalance.js";
10
- import { CustomThemeProvider } from "../../../core/design-system/CustomThemeProvider.js";
11
- import { type Theme, iconSize } from "../../../core/design-system/index.js";
12
- import type { PayUIOptions } from "../../../core/hooks/connection/ConnectButtonProps.js";
1
+ import { useContext } from "react";
13
2
  import {
14
3
  type SendTransactionConfig,
4
+ type ShowModalData,
15
5
  useSendTransactionCore,
16
6
  } from "../../../core/hooks/transaction/useSendTransaction.js";
17
7
  import { SetRootElementContext } from "../../../core/providers/RootElementContext.js";
18
- import type { SupportedTokens } from "../../../core/utils/defaultTokens.js";
19
- import { AccentFailIcon } from "../../ui/ConnectWallet/icons/AccentFailIcon.js";
20
- import { useConnectLocale } from "../../ui/ConnectWallet/locale/getConnectLocale.js";
21
- import { LazyBuyScreen } from "../../ui/ConnectWallet/screens/Buy/LazyBuyScreen.js";
22
- import { PayTxHistoryScreen } from "../../ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js";
23
- import { Modal } from "../../ui/components/Modal.js";
24
- import { Spacer } from "../../ui/components/Spacer.js";
25
- import { Spinner } from "../../ui/components/Spinner.js";
26
- import { Container, ModalHeader } from "../../ui/components/basic.js";
27
- import { Button } from "../../ui/components/buttons.js";
28
- import { Text } from "../../ui/components/text.js";
29
- import type { LocaleId } from "../../ui/types.js";
30
- import { LoadingScreen } from "../../wallets/shared/LoadingScreen.js";
8
+ import { TransactionModal } from "../../ui/TransactionButton/TransactionModal.js";
31
9
  import { useActiveWallet } from "../wallets/useActiveWallet.js";
32
10
  import { useSwitchActiveWalletChain } from "../wallets/useSwitchActiveWalletChain.js";
33
11
 
@@ -48,9 +26,9 @@ import { useSwitchActiveWalletChain } from "../wallets/useSwitchActiveWalletChai
48
26
  * @transaction
49
27
  */
50
28
  export function useSendTransaction(config: SendTransactionConfig = {}) {
51
- const activeWallet = useActiveWallet();
52
29
  const switchChain = useSwitchActiveWalletChain();
53
30
  const wallet = useActiveWallet();
31
+ const setRootEl = useContext(SetRootElementContext);
54
32
  const payModal = config.payModal;
55
33
 
56
34
  let payModalEnabled = true;
@@ -59,263 +37,41 @@ export function useSendTransaction(config: SendTransactionConfig = {}) {
59
37
  payModalEnabled = false;
60
38
  }
61
39
 
62
- // TODO handle erc20 pay modal
63
- // if active wallet is smart wallet with gasless enabled, don't show the pay modal
64
- if (activeWallet && activeWallet.id === "smart") {
65
- const options = (activeWallet as Wallet<"smart">).getConfig();
66
-
67
- if ("sponsorGas" in options && options.sponsorGas === true) {
68
- payModalEnabled = false;
69
- }
70
-
71
- if ("gasless" in options && options.gasless === true) {
72
- payModalEnabled = false;
73
- }
74
- }
75
-
76
- if (activeWallet && activeWallet.id === "inApp") {
77
- const options = (activeWallet as Wallet<"inApp">).getConfig();
78
-
79
- if (options && "smartAccount" in options && options.smartAccount) {
80
- const smartOptions = options.smartAccount;
81
- if ("sponsorGas" in smartOptions && smartOptions.sponsorGas === true) {
82
- payModalEnabled = false;
83
- }
84
-
85
- if ("gasless" in smartOptions && smartOptions.gasless === true) {
86
- payModalEnabled = false;
87
- }
88
- }
89
- }
40
+ const showPayModal = (data: ShowModalData) => {
41
+ if (payModal === false) return;
42
+ setRootEl(
43
+ <TransactionModal
44
+ title={payModal?.metadata?.name || "Transaction"}
45
+ tx={data.tx}
46
+ onComplete={data.sendTx}
47
+ onClose={() => {
48
+ setRootEl(null);
49
+ data.rejectTx(
50
+ new Error("User rejected transaction by closing modal"),
51
+ );
52
+ }}
53
+ onTxSent={data.resolveTx}
54
+ client={data.tx.client}
55
+ localeId={payModal?.locale || "en_US"}
56
+ supportedTokens={payModal?.supportedTokens}
57
+ theme={payModal?.theme || "dark"}
58
+ payOptions={{
59
+ buyWithCrypto: payModal?.buyWithCrypto,
60
+ buyWithFiat: payModal?.buyWithFiat,
61
+ purchaseData: payModal?.purchaseData,
62
+ mode: "transaction",
63
+ transaction: data.tx,
64
+ metadata: payModal?.metadata,
65
+ }}
66
+ />,
67
+ );
68
+ };
90
69
 
91
- const setRootEl = useContext(SetRootElementContext);
92
70
  return useSendTransactionCore({
93
71
  showPayModal:
94
- !payModalEnabled || payModal === false
95
- ? undefined
96
- : (data) => {
97
- const prefillBuy: PayUIOptions["prefillBuy"] =
98
- data.currency && !isNativeTokenAddress(data.currency.address)
99
- ? {
100
- chain: data.tx.chain,
101
- amount: toTokens(data.totalCostWei, data.currency.decimals),
102
- token: data.currency,
103
- }
104
- : undefined;
105
- setRootEl(
106
- <TxModal
107
- title={payModal?.metadata?.title || "Buy"}
108
- tx={data.tx}
109
- onComplete={data.sendTx}
110
- onClose={() => {
111
- setRootEl(null);
112
- data.rejectTx(
113
- new Error("User rejected transaction by closing modal"),
114
- );
115
- }}
116
- onTxSent={data.resolveTx}
117
- client={data.tx.client}
118
- localeId={payModal?.locale || "en_US"}
119
- supportedTokens={payModal?.supportedTokens}
120
- theme={payModal?.theme || "dark"}
121
- txCostWei={data.totalCostWei}
122
- walletBalance={data.walletBalance}
123
- payOptions={{
124
- buyWithCrypto: payModal?.buyWithCrypto,
125
- buyWithFiat: payModal?.buyWithFiat,
126
- purchaseData: payModal?.purchaseData,
127
- prefillBuy,
128
- }}
129
- />,
130
- );
131
- },
72
+ !payModalEnabled || payModal === false ? undefined : showPayModal,
132
73
  gasless: config.gasless,
133
74
  switchChain,
134
75
  wallet,
135
76
  });
136
77
  }
137
-
138
- type ModalProps = {
139
- title: string;
140
- onComplete: () => void;
141
- onClose: () => void;
142
- client: ThirdwebClient;
143
- localeId: LocaleId;
144
- supportedTokens?: SupportedTokens;
145
- theme: Theme | "light" | "dark";
146
- txCostWei: bigint;
147
- walletBalance: GetWalletBalanceResult;
148
- tx: PreparedTransaction;
149
- payOptions: PayUIOptions;
150
- onTxSent: (data: WaitForReceiptOptions) => void;
151
- };
152
-
153
- function TxModal(props: ModalProps) {
154
- return (
155
- <CustomThemeProvider theme={props.theme}>
156
- <Modal
157
- open={true}
158
- size="compact"
159
- setOpen={(_open) => {
160
- if (!_open) {
161
- props.onClose();
162
- }
163
- }}
164
- >
165
- <ModalContent {...props} />
166
- </Modal>
167
- </CustomThemeProvider>
168
- );
169
- }
170
-
171
- function ModalContent(props: ModalProps) {
172
- const localeQuery = useConnectLocale(props.localeId);
173
- const [screen, setScreen] = useState<"buy" | "tx-history" | "execute-tx">(
174
- "buy",
175
- );
176
-
177
- if (!localeQuery.data) {
178
- return <LoadingScreen />;
179
- }
180
-
181
- if (screen === "execute-tx") {
182
- return (
183
- <ExecutingTxScreen
184
- tx={props.tx}
185
- closeModal={props.onClose}
186
- onTxSent={props.onTxSent}
187
- />
188
- );
189
- }
190
-
191
- if (screen === "tx-history") {
192
- return (
193
- <PayTxHistoryScreen
194
- title={props.title}
195
- client={props.client}
196
- onBack={() => {
197
- setScreen("buy");
198
- }}
199
- onDone={() => {
200
- setScreen("execute-tx");
201
- }}
202
- isBuyForTx={true}
203
- isEmbed={false}
204
- />
205
- );
206
- }
207
-
208
- return (
209
- <LazyBuyScreen
210
- title={props.title}
211
- isEmbed={false}
212
- client={props.client}
213
- onViewPendingTx={() => {
214
- setScreen("tx-history");
215
- }}
216
- supportedTokens={props.supportedTokens}
217
- connectLocale={localeQuery.data}
218
- buyForTx={{
219
- balance: props.walletBalance.value,
220
- cost: props.txCostWei,
221
- tx: props.tx,
222
- tokenSymbol: props.walletBalance.symbol,
223
- tokenDecimals: props.walletBalance.decimals,
224
- }}
225
- theme={typeof props.theme === "string" ? props.theme : props.theme.type}
226
- payOptions={props.payOptions}
227
- onDone={() => {
228
- setScreen("execute-tx");
229
- }}
230
- connectOptions={undefined}
231
- onBack={undefined}
232
- />
233
- );
234
- }
235
-
236
- function ExecutingTxScreen(props: {
237
- tx: PreparedTransaction;
238
- closeModal: () => void;
239
- onTxSent: (data: WaitForReceiptOptions) => void;
240
- }) {
241
- const sendTxCore = useSendTransaction({
242
- payModal: false,
243
- });
244
- const [status, setStatus] = useState<"loading" | "failed" | "sent">(
245
- "loading",
246
- );
247
-
248
- const sendTx = useCallback(async () => {
249
- setStatus("loading");
250
- try {
251
- const txData = await sendTxCore.mutateAsync(props.tx);
252
- props.onTxSent(txData);
253
- setStatus("sent");
254
- } catch (e) {
255
- // Do not reject the transaction here, because the user may want to try again
256
- // we only reject on modal close
257
- console.error(e);
258
- setStatus("failed");
259
- }
260
- }, [sendTxCore, props.tx, props.onTxSent]);
261
-
262
- const done = useRef(false);
263
- useEffect(() => {
264
- if (done.current) {
265
- return;
266
- }
267
-
268
- done.current = true;
269
- sendTx();
270
- }, [sendTx]);
271
-
272
- return (
273
- <Container p="lg">
274
- <ModalHeader title="Transaction" />
275
-
276
- <Spacer y="xxl" />
277
- <Spacer y="xxl" />
278
-
279
- <Container flex="row" center="x">
280
- {status === "loading" && <Spinner size="3xl" color="accentText" />}
281
- {status === "failed" && <AccentFailIcon size={iconSize["3xl"]} />}
282
- {status === "sent" && (
283
- <Container color="success" flex="row" center="both">
284
- <CheckCircledIcon
285
- width={iconSize["3xl"]}
286
- height={iconSize["3xl"]}
287
- />
288
- </Container>
289
- )}
290
- </Container>
291
- <Spacer y="lg" />
292
-
293
- <Text color="primaryText" center size="lg">
294
- {status === "loading" && "Sending transaction"}
295
- {status === "failed" && "Transaction failed"}
296
- {status === "sent" && "Transaction sent"}
297
- </Text>
298
- <Spacer y="sm" />
299
- <Text color="danger" center size="sm">
300
- {status === "failed" && sendTxCore.error
301
- ? sendTxCore.error.message
302
- : ""}
303
- </Text>
304
-
305
- <Spacer y="xxl" />
306
- <Spacer y="xxl" />
307
-
308
- {status === "failed" && (
309
- <Button variant="accent" fullWidth onClick={sendTx}>
310
- Try Again
311
- </Button>
312
- )}
313
-
314
- {status === "sent" && (
315
- <Button variant="accent" fullWidth onClick={props.closeModal}>
316
- Done
317
- </Button>
318
- )}
319
- </Container>
320
- );
321
- }
@@ -816,13 +816,15 @@ function DetailsModal(props: {
816
816
  client={client}
817
817
  onBack={() => setScreen("main")}
818
818
  supportedTokens={props.supportedTokens}
819
- onViewPendingTx={() => setScreen("transactions")}
820
819
  connectLocale={locale}
821
- payOptions={props.detailsModal?.payOptions || {}}
820
+ payOptions={
821
+ props.detailsModal?.payOptions || {
822
+ mode: "fund_wallet",
823
+ }
824
+ }
822
825
  theme={typeof props.theme === "string" ? props.theme : props.theme.type}
823
826
  onDone={closeModal}
824
827
  connectOptions={undefined}
825
- buyForTx={undefined}
826
828
  />
827
829
  );
828
830
  }
@@ -1246,7 +1248,7 @@ export type UseWalletDetailsModalOptions = {
1246
1248
  *
1247
1249
  * thirdweb Pay allows users to buy tokens using crypto or fiat currency.
1248
1250
  */
1249
- payOptions?: PayUIOptions;
1251
+ payOptions?: Extract<PayUIOptions, { mode?: "fund_wallet" }>;
1250
1252
 
1251
1253
  /**
1252
1254
  * Display the balance of a token instead of the native token
@@ -210,7 +210,7 @@ const ConnectEmbedContent = (props: {
210
210
  welcomeScreen: undefined,
211
211
  wallets: props.wallets,
212
212
  });
213
- const { setScreen, initialScreen } = screenSetup;
213
+ const { setScreen, initialScreen, screen } = screenSetup;
214
214
  const activeWallet = useActiveWallet();
215
215
  const siweAuth = useSiweAuth(activeWallet, props.auth);
216
216
  const activeAccount = useActiveAccount();
@@ -219,11 +219,17 @@ const ConnectEmbedContent = (props: {
219
219
 
220
220
  let content = null;
221
221
 
222
+ // if sign in is required but connect embed is showing the initial screen - change to sign in screen
222
223
  useEffect(() => {
223
- if (siweAuth.requiresAuth && !siweAuth.isLoggedIn && activeAccount) {
224
+ if (
225
+ siweAuth.requiresAuth &&
226
+ !siweAuth.isLoggedIn &&
227
+ activeAccount &&
228
+ screen === initialScreen
229
+ ) {
224
230
  setScreen(reservedScreens.signIn);
225
231
  }
226
- }, [siweAuth, setScreen, activeAccount]);
232
+ }, [siweAuth, setScreen, activeAccount, screen, initialScreen]);
227
233
 
228
234
  const modalSize = !canFitWideModal()
229
235
  ? "compact"
@@ -61,7 +61,7 @@ export function TransactionsScreen(props: {
61
61
  onBack={() => setSelectedTx(null)}
62
62
  onDone={() => setSelectedTx(null)}
63
63
  payer={payer}
64
- isBuyForTx={false}
64
+ transactionMode={false}
65
65
  isEmbed={false}
66
66
  />
67
67
  );