thirdweb 5.40.0-nightly-3848327373e49aa83c5902e6a16d5b8e96cf1eeb-20240726000343 → 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 (250) 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/utils/defaultTokens.js +32 -25
  8. package/dist/cjs/react/core/utils/defaultTokens.js.map +1 -1
  9. package/dist/cjs/react/core/utils/wallet.js +91 -13
  10. package/dist/cjs/react/core/utils/wallet.js.map +1 -1
  11. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js +18 -127
  12. package/dist/cjs/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  13. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +3 -1
  14. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  15. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -1
  16. package/dist/cjs/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  17. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +184 -118
  18. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  19. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js +104 -0
  20. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js.map +1 -0
  21. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +69 -0
  22. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -0
  23. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +23 -5
  24. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
  25. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js +4 -4
  26. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js.map +1 -1
  27. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +2 -2
  28. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +2 -2
  30. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +1 -1
  32. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +132 -45
  34. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +2 -5
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +13 -8
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  39. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +1 -1
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +1 -1
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +1 -1
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +1 -1
  43. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +1 -1
  44. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  45. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js +1 -1
  46. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js.map +1 -1
  47. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +1 -1
  48. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +1 -1
  49. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +9 -5
  50. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  51. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js +1 -1
  52. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js.map +1 -1
  53. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +8 -3
  54. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
  55. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js +1 -1
  56. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js.map +1 -1
  57. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js +1 -1
  58. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js.map +1 -1
  59. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js +84 -0
  60. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -0
  61. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +13 -7
  62. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +1 -1
  63. package/dist/cjs/react/web/ui/ConnectWallet/screens/nativeToken.js +3 -1
  64. package/dist/cjs/react/web/ui/ConnectWallet/screens/nativeToken.js.map +1 -1
  65. package/dist/cjs/react/web/ui/PayEmbed.js +16 -9
  66. package/dist/cjs/react/web/ui/PayEmbed.js.map +1 -1
  67. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js +53 -0
  68. package/dist/cjs/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -0
  69. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js +33 -0
  70. package/dist/cjs/react/web/ui/TransactionButton/TransactionModal.js.map +1 -0
  71. package/dist/cjs/version.js +1 -1
  72. package/dist/cjs/version.js.map +1 -1
  73. package/dist/esm/exports/react.js +3 -1
  74. package/dist/esm/exports/react.js.map +1 -1
  75. package/dist/esm/react/core/design-system/index.js +2 -0
  76. package/dist/esm/react/core/design-system/index.js.map +1 -1
  77. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js +13 -93
  78. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  79. package/dist/esm/react/core/utils/defaultTokens.js +31 -25
  80. package/dist/esm/react/core/utils/defaultTokens.js.map +1 -1
  81. package/dist/esm/react/core/utils/wallet.js +88 -13
  82. package/dist/esm/react/core/utils/wallet.js.map +1 -1
  83. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js +20 -129
  84. package/dist/esm/react/web/hooks/transaction/useSendTransaction.js.map +1 -1
  85. package/dist/esm/react/web/ui/ConnectWallet/Details.js +3 -1
  86. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  87. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js +1 -1
  88. package/dist/esm/react/web/ui/ConnectWallet/TransactionsScreen.js.map +1 -1
  89. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +188 -122
  90. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  91. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js +101 -0
  92. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.js.map +1 -0
  93. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js +66 -0
  94. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.js.map +1 -0
  95. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js +22 -5
  96. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.js.map +1 -1
  97. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js +4 -4
  98. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js.map +1 -1
  99. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +2 -2
  100. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +1 -1
  101. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js +2 -2
  102. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.js.map +1 -1
  103. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js +1 -1
  104. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.js.map +1 -1
  105. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js +130 -44
  106. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.js.map +1 -1
  107. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js +2 -5
  108. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.js.map +1 -1
  109. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +13 -8
  110. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  111. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js +1 -1
  112. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.js.map +1 -1
  113. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js +1 -1
  114. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.js.map +1 -1
  115. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +1 -1
  116. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  117. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js +1 -1
  118. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.js.map +1 -1
  119. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js +1 -1
  120. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.js.map +1 -1
  121. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js +7 -4
  122. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.js.map +1 -1
  123. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js +1 -1
  124. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.js.map +1 -1
  125. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js +9 -4
  126. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.js.map +1 -1
  127. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js +1 -1
  128. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.js.map +1 -1
  129. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js +1 -1
  130. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js.map +1 -1
  131. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js +81 -0
  132. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -0
  133. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js +14 -8
  134. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.js.map +1 -1
  135. package/dist/esm/react/web/ui/ConnectWallet/screens/nativeToken.js +3 -1
  136. package/dist/esm/react/web/ui/ConnectWallet/screens/nativeToken.js.map +1 -1
  137. package/dist/esm/react/web/ui/PayEmbed.js +16 -9
  138. package/dist/esm/react/web/ui/PayEmbed.js.map +1 -1
  139. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js +50 -0
  140. package/dist/esm/react/web/ui/TransactionButton/ExecutingScreen.js.map +1 -0
  141. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js +29 -0
  142. package/dist/esm/react/web/ui/TransactionButton/TransactionModal.js.map +1 -0
  143. package/dist/esm/version.js +1 -1
  144. package/dist/esm/version.js.map +1 -1
  145. package/dist/types/exports/react.d.ts +3 -2
  146. package/dist/types/exports/react.d.ts.map +1 -1
  147. package/dist/types/react/core/design-system/index.d.ts +2 -0
  148. package/dist/types/react/core/design-system/index.d.ts.map +1 -1
  149. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +80 -34
  150. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
  151. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +3 -15
  152. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  153. package/dist/types/react/core/utils/defaultTokens.d.ts +222 -0
  154. package/dist/types/react/core/utils/defaultTokens.d.ts.map +1 -1
  155. package/dist/types/react/core/utils/wallet.d.ts +43 -1
  156. package/dist/types/react/core/utils/wallet.d.ts.map +1 -1
  157. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts +2 -4
  158. package/dist/types/react/web/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  159. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts +3 -1
  160. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  161. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts +0 -3
  162. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.d.ts.map +1 -1
  163. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.d.ts +18 -0
  164. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.d.ts.map +1 -0
  165. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts +18 -0
  166. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.d.ts.map +1 -0
  167. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts +5 -0
  168. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.d.ts.map +1 -1
  169. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.d.ts +1 -2
  170. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.d.ts.map +1 -1
  171. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.d.ts +1 -2
  172. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.d.ts.map +1 -1
  173. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts +1 -2
  174. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.d.ts.map +1 -1
  175. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts +1 -2
  176. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.d.ts.map +1 -1
  177. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +14 -8
  178. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
  179. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts +19 -9
  180. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.d.ts.map +1 -1
  181. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts +6 -5
  182. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.d.ts.map +1 -1
  183. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts +0 -2
  184. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts.map +1 -1
  185. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts +1 -1
  186. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.d.ts.map +1 -1
  187. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts +1 -1
  188. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.d.ts.map +1 -1
  189. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts +1 -1
  190. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.d.ts.map +1 -1
  191. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts +4 -0
  192. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.d.ts.map +1 -1
  193. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.d.ts.map +1 -1
  194. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts +1 -0
  195. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.d.ts.map +1 -1
  196. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.d.ts +1 -2
  197. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.d.ts.map +1 -1
  198. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.d.ts +1 -2
  199. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.d.ts.map +1 -1
  200. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts +19 -0
  201. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts.map +1 -0
  202. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.d.ts.map +1 -1
  203. package/dist/types/react/web/ui/ConnectWallet/screens/nativeToken.d.ts.map +1 -1
  204. package/dist/types/react/web/ui/PayEmbed.d.ts +0 -6
  205. package/dist/types/react/web/ui/PayEmbed.d.ts.map +1 -1
  206. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts +9 -0
  207. package/dist/types/react/web/ui/TransactionButton/ExecutingScreen.d.ts.map +1 -0
  208. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts +24 -0
  209. package/dist/types/react/web/ui/TransactionButton/TransactionModal.d.ts.map +1 -0
  210. package/dist/types/version.d.ts +1 -1
  211. package/dist/types/version.d.ts.map +1 -1
  212. package/package.json +1 -1
  213. package/src/exports/react.ts +14 -2
  214. package/src/react/core/design-system/index.ts +2 -0
  215. package/src/react/core/hooks/connection/ConnectButtonProps.ts +103 -51
  216. package/src/react/core/hooks/transaction/useSendTransaction.ts +17 -127
  217. package/src/react/core/utils/defaultTokens.ts +38 -26
  218. package/src/react/core/utils/wallet.ts +102 -18
  219. package/src/react/web/hooks/transaction/useSendTransaction.tsx +34 -278
  220. package/src/react/web/ui/ConnectWallet/Details.tsx +6 -4
  221. package/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx +1 -1
  222. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +347 -383
  223. package/src/react/web/ui/ConnectWallet/screens/Buy/DirectPaymentModeScreen.tsx +266 -0
  224. package/src/react/web/ui/ConnectWallet/screens/Buy/TransactionModeScreen.tsx +253 -0
  225. package/src/react/web/ui/ConnectWallet/screens/Buy/WalletSelectorButton.tsx +52 -21
  226. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.tsx +3 -6
  227. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.tsx +5 -6
  228. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwap.tsx +2 -4
  229. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/PostOnRampSwapFlow.tsx +2 -4
  230. package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +16 -12
  231. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useBuyTxStates.ts +155 -60
  232. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useEnabledPaymentMethods.ts +8 -3
  233. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.ts +17 -12
  234. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx +2 -2
  235. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/FiatDetailsScreen.tsx +2 -3
  236. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +1 -1
  237. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TokenInfoRow.tsx +1 -1
  238. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/TxDetailsScreen.tsx +2 -2
  239. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx +27 -19
  240. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.tsx +8 -4
  241. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/PayWithCrypto.tsx +12 -5
  242. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapFlow.tsx +2 -4
  243. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.tsx +3 -4
  244. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx +243 -0
  245. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletSwitcherDrawerContent.tsx +30 -17
  246. package/src/react/web/ui/ConnectWallet/screens/nativeToken.ts +5 -1
  247. package/src/react/web/ui/PayEmbed.tsx +31 -32
  248. package/src/react/web/ui/TransactionButton/ExecutingScreen.tsx +127 -0
  249. package/src/react/web/ui/TransactionButton/TransactionModal.tsx +83 -0
  250. package/src/version.ts +1 -1
@@ -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
@@ -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
  );