thirdweb 5.48.1-nightly-7ef1c721ef693584d153554d46f2e70e8015b261-20240822000343 → 5.48.2-nightly-1405598e7e51e4d415fd57f8169012823db0cedf-20240824000351

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 (253) hide show
  1. package/dist/cjs/exports/pay.js +3 -1
  2. package/dist/cjs/exports/pay.js.map +1 -1
  3. package/dist/cjs/exports/thirdweb.js +3 -1
  4. package/dist/cjs/exports/thirdweb.js.map +1 -1
  5. package/dist/cjs/pay/buyWithCrypto/commonTypes.js +3 -0
  6. package/dist/cjs/pay/buyWithCrypto/commonTypes.js.map +1 -0
  7. package/dist/cjs/pay/buyWithCrypto/getQuote.js.map +1 -1
  8. package/dist/cjs/pay/buyWithCrypto/getTransfer.js +95 -0
  9. package/dist/cjs/pay/buyWithCrypto/getTransfer.js.map +1 -0
  10. package/dist/cjs/pay/utils/definitions.js +7 -1
  11. package/dist/cjs/pay/utils/definitions.js.map +1 -1
  12. package/dist/cjs/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  13. package/dist/cjs/react/native/ui/connect/ConnectedButton.js +5 -1
  14. package/dist/cjs/react/native/ui/connect/ConnectedButton.js.map +1 -1
  15. package/dist/cjs/react/native/ui/connect/ConnectedModal.js +2 -1
  16. package/dist/cjs/react/native/ui/connect/ConnectedModal.js.map +1 -1
  17. package/dist/cjs/react/native/ui/connect/TokenListScreen.js +5 -1
  18. package/dist/cjs/react/native/ui/connect/TokenListScreen.js.map +1 -1
  19. package/dist/cjs/react/web/ui/ConnectWallet/Details.js +28 -22
  20. package/dist/cjs/react/web/ui/ConnectWallet/Details.js.map +1 -1
  21. package/dist/cjs/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.js +9 -0
  22. package/dist/cjs/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.js.map +1 -0
  23. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +5 -1
  24. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  25. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js +9 -3
  26. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js.map +1 -1
  27. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +34 -2
  28. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +8 -0
  30. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js +1 -1
  32. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +118 -0
  34. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -0
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js +7 -76
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js +2 -1
  38. package/dist/cjs/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
  39. package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js +3 -2
  40. package/dist/cjs/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
  41. package/dist/cjs/react/web/wallets/shared/SocialLogin.js +5 -2
  42. package/dist/cjs/react/web/wallets/shared/SocialLogin.js.map +1 -1
  43. package/dist/cjs/stories/ConnectButton.stories.js +28 -0
  44. package/dist/cjs/stories/ConnectButton.stories.js.map +1 -0
  45. package/dist/cjs/stories/PayEmbed.stories.js +38 -0
  46. package/dist/cjs/stories/PayEmbed.stories.js.map +1 -0
  47. package/dist/cjs/stories/utils.js +27 -0
  48. package/dist/cjs/stories/utils.js.map +1 -0
  49. package/dist/cjs/transaction/actions/send-transaction.js.map +1 -1
  50. package/dist/cjs/utils/fetch.js +2 -1
  51. package/dist/cjs/utils/fetch.js.map +1 -1
  52. package/dist/cjs/utils/signatures/sign-message.js +13 -19
  53. package/dist/cjs/utils/signatures/sign-message.js.map +1 -1
  54. package/dist/cjs/version.js +1 -1
  55. package/dist/cjs/wallets/in-app/core/authentication/getLoginPath.js +8 -7
  56. package/dist/cjs/wallets/in-app/core/authentication/getLoginPath.js.map +1 -1
  57. package/dist/cjs/wallets/in-app/core/authentication/types.js.map +1 -1
  58. package/dist/cjs/wallets/in-app/core/wallet/index.js +2 -2
  59. package/dist/cjs/wallets/in-app/core/wallet/index.js.map +1 -1
  60. package/dist/cjs/wallets/in-app/native/auth/native-auth.js +1 -1
  61. package/dist/cjs/wallets/in-app/web/lib/auth/index.js +3 -2
  62. package/dist/cjs/wallets/in-app/web/lib/auth/index.js.map +1 -1
  63. package/dist/cjs/wallets/in-app/web/lib/auth/oauth.js +4 -4
  64. package/dist/cjs/wallets/in-app/web/lib/auth/oauth.js.map +1 -1
  65. package/dist/cjs/wallets/in-app/web/lib/web-connector.js +5 -3
  66. package/dist/cjs/wallets/in-app/web/lib/web-connector.js.map +1 -1
  67. package/dist/cjs/wallets/smart/lib/constants.js +6 -0
  68. package/dist/cjs/wallets/smart/lib/constants.js.map +1 -1
  69. package/dist/esm/exports/pay.js +2 -0
  70. package/dist/esm/exports/pay.js.map +1 -1
  71. package/dist/esm/exports/thirdweb.js +2 -0
  72. package/dist/esm/exports/thirdweb.js.map +1 -1
  73. package/dist/esm/pay/buyWithCrypto/commonTypes.js +2 -0
  74. package/dist/esm/pay/buyWithCrypto/commonTypes.js.map +1 -0
  75. package/dist/esm/pay/buyWithCrypto/getQuote.js +1 -1
  76. package/dist/esm/pay/buyWithCrypto/getQuote.js.map +1 -1
  77. package/dist/esm/pay/buyWithCrypto/getTransfer.js +92 -0
  78. package/dist/esm/pay/buyWithCrypto/getTransfer.js.map +1 -0
  79. package/dist/esm/pay/utils/definitions.js +5 -0
  80. package/dist/esm/pay/utils/definitions.js.map +1 -1
  81. package/dist/esm/react/core/hooks/transaction/useSendTransaction.js.map +1 -1
  82. package/dist/esm/react/native/ui/connect/ConnectedButton.js +5 -1
  83. package/dist/esm/react/native/ui/connect/ConnectedButton.js.map +1 -1
  84. package/dist/esm/react/native/ui/connect/ConnectedModal.js +2 -1
  85. package/dist/esm/react/native/ui/connect/ConnectedModal.js.map +1 -1
  86. package/dist/esm/react/native/ui/connect/TokenListScreen.js +5 -1
  87. package/dist/esm/react/native/ui/connect/TokenListScreen.js.map +1 -1
  88. package/dist/esm/react/web/ui/ConnectWallet/Details.js +28 -22
  89. package/dist/esm/react/web/ui/ConnectWallet/Details.js.map +1 -1
  90. package/dist/esm/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.js +5 -0
  91. package/dist/esm/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.js.map +1 -0
  92. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +5 -1
  93. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  94. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js +8 -2
  95. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js.map +1 -1
  96. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +35 -3
  97. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  98. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js +8 -0
  99. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.js.map +1 -1
  100. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js +1 -1
  101. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.js.map +1 -1
  102. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js +115 -0
  103. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.js.map +1 -0
  104. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js +8 -77
  105. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.js.map +1 -1
  106. package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js +2 -1
  107. package/dist/esm/react/web/ui/ConnectWallet/screens/formatTokenBalance.js.map +1 -1
  108. package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js +3 -2
  109. package/dist/esm/react/web/wallets/shared/ConnectWalletSocialOptions.js.map +1 -1
  110. package/dist/esm/react/web/wallets/shared/SocialLogin.js +5 -2
  111. package/dist/esm/react/web/wallets/shared/SocialLogin.js.map +1 -1
  112. package/dist/esm/stories/ConnectButton.stories.js +25 -0
  113. package/dist/esm/stories/ConnectButton.stories.js.map +1 -0
  114. package/dist/esm/stories/PayEmbed.stories.js +35 -0
  115. package/dist/esm/stories/PayEmbed.stories.js.map +1 -0
  116. package/dist/esm/stories/utils.js +24 -0
  117. package/dist/esm/stories/utils.js.map +1 -0
  118. package/dist/esm/transaction/actions/send-transaction.js.map +1 -1
  119. package/dist/esm/utils/fetch.js +2 -1
  120. package/dist/esm/utils/fetch.js.map +1 -1
  121. package/dist/esm/utils/signatures/sign-message.js +13 -19
  122. package/dist/esm/utils/signatures/sign-message.js.map +1 -1
  123. package/dist/esm/version.js +1 -1
  124. package/dist/esm/wallets/in-app/core/authentication/getLoginPath.js +8 -7
  125. package/dist/esm/wallets/in-app/core/authentication/getLoginPath.js.map +1 -1
  126. package/dist/esm/wallets/in-app/core/authentication/types.js.map +1 -1
  127. package/dist/esm/wallets/in-app/core/wallet/index.js +2 -2
  128. package/dist/esm/wallets/in-app/core/wallet/index.js.map +1 -1
  129. package/dist/esm/wallets/in-app/native/auth/native-auth.js +1 -1
  130. package/dist/esm/wallets/in-app/web/lib/auth/index.js +3 -2
  131. package/dist/esm/wallets/in-app/web/lib/auth/index.js.map +1 -1
  132. package/dist/esm/wallets/in-app/web/lib/auth/oauth.js +4 -4
  133. package/dist/esm/wallets/in-app/web/lib/auth/oauth.js.map +1 -1
  134. package/dist/esm/wallets/in-app/web/lib/web-connector.js +5 -3
  135. package/dist/esm/wallets/in-app/web/lib/web-connector.js.map +1 -1
  136. package/dist/esm/wallets/smart/lib/constants.js +6 -0
  137. package/dist/esm/wallets/smart/lib/constants.js.map +1 -1
  138. package/dist/types/exports/pay.d.ts +3 -1
  139. package/dist/types/exports/pay.d.ts.map +1 -1
  140. package/dist/types/exports/thirdweb.d.ts +3 -1
  141. package/dist/types/exports/thirdweb.d.ts.map +1 -1
  142. package/dist/types/pay/buyWithCrypto/commonTypes.d.ts +36 -0
  143. package/dist/types/pay/buyWithCrypto/commonTypes.d.ts.map +1 -0
  144. package/dist/types/pay/buyWithCrypto/getQuote.d.ts +1 -24
  145. package/dist/types/pay/buyWithCrypto/getQuote.d.ts.map +1 -1
  146. package/dist/types/pay/buyWithCrypto/getStatus.d.ts +1 -1
  147. package/dist/types/pay/buyWithCrypto/getStatus.d.ts.map +1 -1
  148. package/dist/types/pay/buyWithCrypto/getTransfer.d.ts +85 -0
  149. package/dist/types/pay/buyWithCrypto/getTransfer.d.ts.map +1 -0
  150. package/dist/types/pay/buyWithFiat/getQuote.d.ts +1 -1
  151. package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
  152. package/dist/types/pay/utils/definitions.d.ts +5 -0
  153. package/dist/types/pay/utils/definitions.d.ts.map +1 -1
  154. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +15 -0
  155. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
  156. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts +3 -0
  157. package/dist/types/react/core/hooks/transaction/useSendTransaction.d.ts.map +1 -1
  158. package/dist/types/react/native/ui/connect/ConnectedButton.d.ts.map +1 -1
  159. package/dist/types/react/native/ui/connect/ConnectedModal.d.ts.map +1 -1
  160. package/dist/types/react/native/ui/connect/TokenListScreen.d.ts.map +1 -1
  161. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts +6 -0
  162. package/dist/types/react/web/ui/ConnectWallet/Details.d.ts.map +1 -1
  163. package/dist/types/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.d.ts +3 -0
  164. package/dist/types/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.d.ts.map +1 -0
  165. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.d.ts +2 -2
  166. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.d.ts.map +1 -1
  167. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts +3 -2
  168. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.d.ts.map +1 -1
  169. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.d.ts.map +1 -1
  170. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.d.ts +1 -1
  171. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.d.ts.map +1 -1
  172. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts +20 -0
  173. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.d.ts.map +1 -0
  174. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts +5 -1
  175. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.d.ts.map +1 -1
  176. package/dist/types/react/web/ui/ConnectWallet/screens/formatTokenBalance.d.ts.map +1 -1
  177. package/dist/types/react/web/wallets/shared/ConnectWalletSocialOptions.d.ts.map +1 -1
  178. package/dist/types/react/web/wallets/shared/SocialLogin.d.ts.map +1 -1
  179. package/dist/types/stories/ConnectButton.stories.d.ts +18 -0
  180. package/dist/types/stories/ConnectButton.stories.d.ts.map +1 -0
  181. package/dist/types/stories/PayEmbed.stories.d.ts +19 -0
  182. package/dist/types/stories/PayEmbed.stories.d.ts.map +1 -0
  183. package/dist/types/stories/utils.d.ts +5 -0
  184. package/dist/types/stories/utils.d.ts.map +1 -0
  185. package/dist/types/transaction/actions/send-transaction.d.ts +12 -2
  186. package/dist/types/transaction/actions/send-transaction.d.ts.map +1 -1
  187. package/dist/types/utils/fetch.d.ts.map +1 -1
  188. package/dist/types/utils/signatures/sign-message.d.ts +26 -3
  189. package/dist/types/utils/signatures/sign-message.d.ts.map +1 -1
  190. package/dist/types/version.d.ts +1 -1
  191. package/dist/types/wallets/ecosystem/types.d.ts +1 -2
  192. package/dist/types/wallets/ecosystem/types.d.ts.map +1 -1
  193. package/dist/types/wallets/in-app/core/authentication/getLoginPath.d.ts +1 -1
  194. package/dist/types/wallets/in-app/core/authentication/getLoginPath.d.ts.map +1 -1
  195. package/dist/types/wallets/in-app/core/authentication/types.d.ts +1 -8
  196. package/dist/types/wallets/in-app/core/authentication/types.d.ts.map +1 -1
  197. package/dist/types/wallets/in-app/core/interfaces/connector.d.ts +1 -1
  198. package/dist/types/wallets/in-app/core/interfaces/connector.d.ts.map +1 -1
  199. package/dist/types/wallets/in-app/core/wallet/index.d.ts.map +1 -1
  200. package/dist/types/wallets/in-app/core/wallet/types.d.ts +1 -5
  201. package/dist/types/wallets/in-app/core/wallet/types.d.ts.map +1 -1
  202. package/dist/types/wallets/in-app/web/lib/auth/index.d.ts.map +1 -1
  203. package/dist/types/wallets/in-app/web/lib/auth/oauth.d.ts +1 -1
  204. package/dist/types/wallets/in-app/web/lib/auth/oauth.d.ts.map +1 -1
  205. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts +1 -1
  206. package/dist/types/wallets/in-app/web/lib/web-connector.d.ts.map +1 -1
  207. package/dist/types/wallets/smart/lib/constants.d.ts.map +1 -1
  208. package/package.json +15 -2
  209. package/src/exports/pay.ts +11 -2
  210. package/src/exports/thirdweb.ts +11 -2
  211. package/src/pay/buyWithCrypto/commonTypes.ts +40 -0
  212. package/src/pay/buyWithCrypto/getQuote.ts +8 -42
  213. package/src/pay/buyWithCrypto/getStatus.ts +1 -1
  214. package/src/pay/buyWithCrypto/getTransfer.ts +185 -0
  215. package/src/pay/buyWithFiat/getQuote.ts +1 -1
  216. package/src/pay/utils/definitions.ts +7 -0
  217. package/src/react/core/hooks/connection/ConnectButtonProps.ts +16 -0
  218. package/src/react/core/hooks/transaction/useSendTransaction.ts +3 -0
  219. package/src/react/native/ui/connect/ConnectedButton.tsx +6 -1
  220. package/src/react/native/ui/connect/ConnectedModal.tsx +2 -1
  221. package/src/react/native/ui/connect/TokenListScreen.tsx +6 -1
  222. package/src/react/web/ui/ConnectWallet/Details.tsx +93 -77
  223. package/src/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.tsx +21 -0
  224. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +8 -1
  225. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.tsx +9 -3
  226. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.ts +47 -3
  227. package/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/SwapDetailsScreen.tsx +26 -0
  228. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapStatusScreen.tsx +3 -3
  229. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx +284 -0
  230. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferFlow.tsx +29 -220
  231. package/src/react/web/ui/ConnectWallet/screens/formatTokenBalance.ts +3 -1
  232. package/src/react/web/wallets/shared/ConnectWalletSocialOptions.tsx +3 -2
  233. package/src/react/web/wallets/shared/SocialLogin.tsx +7 -2
  234. package/src/stories/ConnectButton.stories.ts +31 -0
  235. package/src/stories/PayEmbed.stories.ts +42 -0
  236. package/src/stories/utils.tsx +29 -0
  237. package/src/transaction/actions/send-transaction.ts +12 -3
  238. package/src/utils/fetch.ts +4 -1
  239. package/src/utils/signatures/sign-message.test.ts +78 -50
  240. package/src/utils/signatures/sign-message.ts +44 -9
  241. package/src/version.ts +1 -1
  242. package/src/wallets/ecosystem/types.ts +1 -2
  243. package/src/wallets/in-app/core/authentication/getLoginPath.ts +11 -9
  244. package/src/wallets/in-app/core/authentication/types.ts +1 -8
  245. package/src/wallets/in-app/core/interfaces/connector.ts +5 -1
  246. package/src/wallets/in-app/core/wallet/index.ts +6 -2
  247. package/src/wallets/in-app/core/wallet/types.ts +1 -5
  248. package/src/wallets/in-app/native/auth/native-auth.ts +1 -1
  249. package/src/wallets/in-app/web/lib/auth/index.ts +7 -2
  250. package/src/wallets/in-app/web/lib/auth/oauth.ts +5 -5
  251. package/src/wallets/in-app/web/lib/web-connector.ts +9 -3
  252. package/src/wallets/smart/lib/constants.ts +6 -0
  253. package/src/wallets/smart/smart-wallet-dev.test.ts +86 -0
@@ -0,0 +1,284 @@
1
+ import { CheckCircledIcon, CrossCircledIcon } from "@radix-ui/react-icons";
2
+ import { useState } from "react";
3
+ import type { Chain } from "../../../../../../../chains/types.js";
4
+ import type { ThirdwebClient } from "../../../../../../../client/client.js";
5
+ import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js";
6
+ import { getContract } from "../../../../../../../contract/contract.js";
7
+ import { transfer } from "../../../../../../../extensions/erc20/write/transfer.js";
8
+ import { getBuyWithCryptoTransfer } from "../../../../../../../pay/buyWithCrypto/getTransfer.js";
9
+ import { sendAndConfirmTransaction } from "../../../../../../../transaction/actions/send-and-confirm-transaction.js";
10
+ import { sendTransaction } from "../../../../../../../transaction/actions/send-transaction.js";
11
+ import { prepareTransaction } from "../../../../../../../transaction/prepare-transaction.js";
12
+ import { toWei } from "../../../../../../../utils/units.js";
13
+ import { iconSize } from "../../../../../../core/design-system/index.js";
14
+ import { useChainSymbol } from "../../../../../../core/hooks/others/useChainQuery.js";
15
+ import { Spacer } from "../../../../components/Spacer.js";
16
+ import { Spinner } from "../../../../components/Spinner.js";
17
+ import { StepBar } from "../../../../components/StepBar.js";
18
+ import { SwitchNetworkButton } from "../../../../components/SwitchNetwork.js";
19
+ import { Container, Line, ModalHeader } from "../../../../components/basic.js";
20
+ import { Button } from "../../../../components/buttons.js";
21
+ import { Text } from "../../../../components/text.js";
22
+ import { type ERC20OrNativeToken, isNativeToken } from "../../nativeToken.js";
23
+ import { Step } from "../Stepper.js";
24
+ import { WalletRow } from "../WalletSelectorButton.js";
25
+ import { TokenInfoRow } from "../pay-transactions/TokenInfoRow.js";
26
+ import type { PayerInfo } from "../types.js";
27
+ import { ConnectorLine } from "./ConfirmationScreen.js";
28
+
29
+ type TrasnferConfirmationScreenProps = {
30
+ title: string;
31
+ onBack?: () => void;
32
+ setTransactionHash: (txHash: string) => void;
33
+ payer: PayerInfo;
34
+ receiverAddress: string;
35
+ client: ThirdwebClient;
36
+ onDone: () => void;
37
+ chain: Chain;
38
+ token: ERC20OrNativeToken;
39
+ tokenAmount: string;
40
+ transactionMode?: boolean;
41
+ };
42
+
43
+ export function TransferConfirmationScreen(
44
+ props: TrasnferConfirmationScreenProps,
45
+ ) {
46
+ const {
47
+ title,
48
+ onBack,
49
+ receiverAddress,
50
+ client,
51
+ payer,
52
+ onDone,
53
+ chain,
54
+ token,
55
+ tokenAmount,
56
+ transactionMode,
57
+ setTransactionHash,
58
+ } = props;
59
+ const [step, setStep] = useState<"approve" | "transfer" | "execute">(
60
+ "transfer",
61
+ );
62
+ const [status, setStatus] = useState<"idle" | "pending" | "error" | "done">(
63
+ "idle",
64
+ );
65
+ const { symbol } = useChainSymbol(chain);
66
+
67
+ return (
68
+ <Container p="lg">
69
+ <ModalHeader title={title} onBack={onBack} />
70
+ <Spacer y="xl" />
71
+
72
+ {transactionMode && (
73
+ <>
74
+ <StepBar steps={2} currentStep={step === "transfer" ? 1 : 2} />
75
+ <Spacer y="sm" />
76
+ <Text size="sm">
77
+ {step === "transfer"
78
+ ? "Step 1 of 2 - Transfer funds"
79
+ : "Step 2 of 2 - Finalize transaction"}
80
+ </Text>
81
+ <Spacer y="xl" />
82
+ </>
83
+ )}
84
+
85
+ {/* Sender Address */}
86
+ <Container
87
+ flex="row"
88
+ center="y"
89
+ style={{
90
+ justifyContent: "space-between",
91
+ }}
92
+ >
93
+ <Text size="sm">From</Text>
94
+ <WalletRow address={payer.account.address} client={client} />
95
+ </Container>
96
+
97
+ <Spacer y="md" />
98
+ <Line />
99
+ <Spacer y="md" />
100
+
101
+ {/* Receiver Address */}
102
+ <Container
103
+ flex="row"
104
+ center="y"
105
+ style={{
106
+ justifyContent: "space-between",
107
+ }}
108
+ >
109
+ <Text size="sm">To</Text>
110
+ <WalletRow address={receiverAddress} client={client} />
111
+ </Container>
112
+
113
+ <Spacer y="md" />
114
+ <Line />
115
+ <Spacer y="md" />
116
+
117
+ {/* Token Info */}
118
+ <TokenInfoRow
119
+ chainId={chain.id}
120
+ client={client}
121
+ label={"Amount"}
122
+ tokenAmount={tokenAmount}
123
+ tokenSymbol={isNativeToken(token) ? symbol || "" : token.symbol}
124
+ tokenAddress={
125
+ isNativeToken(token) ? NATIVE_TOKEN_ADDRESS : token.address
126
+ }
127
+ />
128
+
129
+ <Spacer y="lg" />
130
+
131
+ {transactionMode && (
132
+ <>
133
+ <Spacer y="sm" />
134
+ <Container
135
+ gap="sm"
136
+ flex="row"
137
+ style={{
138
+ justifyContent: "space-between",
139
+ }}
140
+ center="y"
141
+ color="accentText"
142
+ >
143
+ <Step
144
+ isDone={step === "execute"}
145
+ isActive={step === "transfer"}
146
+ label={step === "transfer" ? "Transfer" : "Done"}
147
+ />
148
+ <ConnectorLine />
149
+ <Step
150
+ isDone={false}
151
+ label="Finalize"
152
+ isActive={step === "execute"}
153
+ />
154
+ </Container>
155
+ <Spacer y="lg" />
156
+ </>
157
+ )}
158
+
159
+ {status === "error" && (
160
+ <>
161
+ <Container flex="row" gap="xs" center="both" color="danger">
162
+ <CrossCircledIcon width={iconSize.sm} height={iconSize.sm} />
163
+ <Text color="danger" size="sm">
164
+ {step === "transfer" ? "Failed to Transfer" : "Failed to Execute"}
165
+ </Text>
166
+ </Container>
167
+ <Spacer y="md" />
168
+ </>
169
+ )}
170
+
171
+ {!transactionMode && step === "execute" && status === "done" && (
172
+ <>
173
+ <Container flex="row" gap="xs" center="both" color="success">
174
+ <CheckCircledIcon width={iconSize.sm} height={iconSize.sm} />
175
+ <Text color="success" size="sm">
176
+ {"Payment completed"}
177
+ </Text>
178
+ </Container>
179
+ <Spacer y="md" />
180
+ </>
181
+ )}
182
+
183
+ {/* Execute */}
184
+ {payer.chain.id !== chain.id ? (
185
+ <SwitchNetworkButton
186
+ fullWidth
187
+ variant="accent"
188
+ switchChain={async () => {
189
+ await props.payer.wallet.switchChain(chain);
190
+ }}
191
+ />
192
+ ) : (
193
+ <Button
194
+ variant="accent"
195
+ fullWidth
196
+ disabled={status === "pending"}
197
+ onClick={async () => {
198
+ if (step === "execute") {
199
+ onDone();
200
+ return;
201
+ }
202
+
203
+ try {
204
+ setStatus("pending");
205
+
206
+ // TRANSACTION MODE = transfer funds to another one of your wallets before executing the tx
207
+ if (transactionMode) {
208
+ const transaction = isNativeToken(token)
209
+ ? prepareTransaction({
210
+ client,
211
+ chain,
212
+ to: receiverAddress,
213
+ value: toWei(tokenAmount),
214
+ })
215
+ : transfer({
216
+ contract: getContract({
217
+ address: token.address,
218
+ chain: chain,
219
+ client: client,
220
+ }),
221
+ to: receiverAddress,
222
+ amount: tokenAmount,
223
+ });
224
+ await sendAndConfirmTransaction({
225
+ account: props.payer.account,
226
+ transaction,
227
+ });
228
+ // switch to execute step
229
+ setStep("execute");
230
+ setStatus("idle");
231
+ } else {
232
+ const transferResponse = await getBuyWithCryptoTransfer({
233
+ client,
234
+ fromAddress: payer.account.address,
235
+ toAddress: receiverAddress,
236
+ chainId: chain.id,
237
+ tokenAddress: isNativeToken(token)
238
+ ? NATIVE_TOKEN_ADDRESS
239
+ : token.address,
240
+ amount: tokenAmount,
241
+ purchaseData: undefined, // TODO (pay): add purchase data
242
+ });
243
+
244
+ console.log("transferResponse", transferResponse);
245
+ if (transferResponse.approval) {
246
+ setStep("approve");
247
+ // approve the transfer
248
+ await sendAndConfirmTransaction({
249
+ account: props.payer.account,
250
+ transaction: transferResponse.approval,
251
+ });
252
+ }
253
+
254
+ setStep("transfer");
255
+ // execute the transfer
256
+ const transaction = transferResponse.transactionRequest;
257
+ const tx = await sendTransaction({
258
+ account: props.payer.account,
259
+ transaction,
260
+ });
261
+ // switches to the status polling screen
262
+ setTransactionHash(tx.transactionHash);
263
+ setStatus("idle");
264
+ }
265
+ } catch (e) {
266
+ console.error(e);
267
+ setStatus("error");
268
+ }
269
+ }}
270
+ gap="xs"
271
+ >
272
+ {step === "execute" && (status === "done" ? "Done" : "Continue")}
273
+ {step === "transfer" &&
274
+ (status === "pending" ? "Confirming" : "Confirm")}
275
+ {step === "approve" &&
276
+ (status === "pending" ? "Approving" : "Approve")}
277
+ {status === "pending" && (
278
+ <Spinner size="sm" color="accentButtonText" />
279
+ )}
280
+ </Button>
281
+ )}
282
+ </Container>
283
+ );
284
+ }
@@ -1,28 +1,11 @@
1
- import { CheckCircledIcon, CrossCircledIcon } from "@radix-ui/react-icons";
2
1
  import { useState } from "react";
3
2
  import type { Chain } from "../../../../../../../chains/types.js";
4
3
  import type { ThirdwebClient } from "../../../../../../../client/client.js";
5
- import { NATIVE_TOKEN_ADDRESS } from "../../../../../../../constants/addresses.js";
6
- import { getContract } from "../../../../../../../contract/contract.js";
7
- import { transfer } from "../../../../../../../extensions/erc20/write/transfer.js";
8
- import { sendAndConfirmTransaction } from "../../../../../../../transaction/actions/send-and-confirm-transaction.js";
9
- import { prepareTransaction } from "../../../../../../../transaction/prepare-transaction.js";
10
- import { toWei } from "../../../../../../../utils/units.js";
11
- import { iconSize } from "../../../../../../core/design-system/index.js";
12
- import { useChainSymbol } from "../../../../../../core/hooks/others/useChainQuery.js";
13
- import { Spacer } from "../../../../components/Spacer.js";
14
- import { Spinner } from "../../../../components/Spinner.js";
15
- import { StepBar } from "../../../../components/StepBar.js";
16
- import { SwitchNetworkButton } from "../../../../components/SwitchNetwork.js";
17
- import { Container, Line, ModalHeader } from "../../../../components/basic.js";
18
- import { Button } from "../../../../components/buttons.js";
19
- import { Text } from "../../../../components/text.js";
20
- import { type ERC20OrNativeToken, isNativeToken } from "../../nativeToken.js";
21
- import { Step } from "../Stepper.js";
22
- import { WalletRow } from "../WalletSelectorButton.js";
23
- import { TokenInfoRow } from "../pay-transactions/TokenInfoRow.js";
4
+ import type { BuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
5
+ import type { ERC20OrNativeToken } from "../../nativeToken.js";
24
6
  import type { PayerInfo } from "../types.js";
25
- import { ConnectorLine } from "./ConfirmationScreen.js";
7
+ import { SwapStatusScreen } from "./SwapStatusScreen.js";
8
+ import { TransferConfirmationScreen } from "./TransferConfirmationScreen.js";
26
9
 
27
10
  type TrasnferFlowProps = {
28
11
  title: string;
@@ -31,6 +14,9 @@ type TrasnferFlowProps = {
31
14
  receiverAddress: string;
32
15
  client: ThirdwebClient;
33
16
  onDone: () => void;
17
+ onTryAgain: () => void;
18
+ isEmbed: boolean;
19
+ onSuccess: ((status: BuyWithCryptoStatus) => void) | undefined;
34
20
  chain: Chain;
35
21
  token: ERC20OrNativeToken;
36
22
  tokenAmount: string;
@@ -38,206 +24,29 @@ type TrasnferFlowProps = {
38
24
  };
39
25
 
40
26
  export function TransferFlow(props: TrasnferFlowProps) {
41
- const {
42
- title,
43
- onBack,
44
- receiverAddress,
45
- client,
46
- payer,
47
- onDone,
48
- chain,
49
- token,
50
- tokenAmount,
51
- transactionMode,
52
- } = props;
53
- const [step, setStep] = useState<"transfer" | "execute">("transfer");
54
- const [status, setStatus] = useState<"idle" | "pending" | "error" | "done">(
55
- "idle",
56
- );
57
- const { symbol } = useChainSymbol(chain);
58
-
59
- return (
60
- <Container p="lg">
61
- <ModalHeader title={title} onBack={onBack} />
62
- <Spacer y="xl" />
63
-
64
- {transactionMode && (
65
- <>
66
- <StepBar steps={2} currentStep={step === "transfer" ? 1 : 2} />
67
- <Spacer y="sm" />
68
- <Text size="sm">
69
- {step === "transfer"
70
- ? "Step 1 of 2 - Transfer funds"
71
- : "Step 2 of 2 - Finalize transaction"}
72
- </Text>
73
- <Spacer y="xl" />
74
- </>
75
- )}
76
-
77
- {/* Sender Address */}
78
- <Container
79
- flex="row"
80
- center="y"
81
- style={{
82
- justifyContent: "space-between",
83
- }}
84
- >
85
- <Text size="sm">From</Text>
86
- <WalletRow address={payer.account.address} client={client} />
87
- </Container>
88
-
89
- <Spacer y="md" />
90
- <Line />
91
- <Spacer y="md" />
92
-
93
- {/* Receiver Address */}
94
- <Container
95
- flex="row"
96
- center="y"
97
- style={{
98
- justifyContent: "space-between",
99
- }}
100
- >
101
- <Text size="sm">To</Text>
102
- <WalletRow address={receiverAddress} client={client} />
103
- </Container>
104
-
105
- <Spacer y="md" />
106
- <Line />
107
- <Spacer y="md" />
108
-
109
- {/* Token Info */}
110
- <TokenInfoRow
111
- chainId={chain.id}
112
- client={client}
113
- label={"Amount"}
114
- tokenAmount={tokenAmount}
115
- tokenSymbol={isNativeToken(token) ? symbol || "" : token.symbol}
116
- tokenAddress={
117
- isNativeToken(token) ? NATIVE_TOKEN_ADDRESS : token.address
118
- }
27
+ const [transferTxHash, setTransferTxHash] = useState<string | undefined>();
28
+
29
+ if (transferTxHash) {
30
+ return (
31
+ <SwapStatusScreen
32
+ title={props.title}
33
+ onBack={props.onBack}
34
+ onTryAgain={props.onTryAgain}
35
+ swapTxHash={transferTxHash}
36
+ client={props.client}
37
+ onDone={props.onDone}
38
+ transactionMode={false}
39
+ isEmbed={props.isEmbed}
40
+ quote={undefined}
41
+ onSuccess={props.onSuccess}
119
42
  />
43
+ );
44
+ }
120
45
 
121
- <Spacer y="lg" />
122
-
123
- {transactionMode && (
124
- <>
125
- <Spacer y="sm" />
126
- <Container
127
- gap="sm"
128
- flex="row"
129
- style={{
130
- justifyContent: "space-between",
131
- }}
132
- center="y"
133
- color="accentText"
134
- >
135
- <Step
136
- isDone={step === "execute"}
137
- isActive={step === "transfer"}
138
- label={step === "transfer" ? "Transfer" : "Done"}
139
- />
140
- <ConnectorLine />
141
- <Step
142
- isDone={false}
143
- label="Finalize"
144
- isActive={step === "execute"}
145
- />
146
- </Container>
147
- <Spacer y="lg" />
148
- </>
149
- )}
150
-
151
- {status === "error" && (
152
- <>
153
- <Container flex="row" gap="xs" center="both" color="danger">
154
- <CrossCircledIcon width={iconSize.sm} height={iconSize.sm} />
155
- <Text color="danger" size="sm">
156
- {step === "transfer" ? "Failed to Transfer" : "Failed to Execute"}
157
- </Text>
158
- </Container>
159
- <Spacer y="md" />
160
- </>
161
- )}
162
-
163
- {!transactionMode && step === "execute" && status === "done" && (
164
- <>
165
- <Container flex="row" gap="xs" center="both" color="success">
166
- <CheckCircledIcon width={iconSize.sm} height={iconSize.sm} />
167
- <Text color="success" size="sm">
168
- {"Payment completed"}
169
- </Text>
170
- </Container>
171
- <Spacer y="md" />
172
- </>
173
- )}
174
-
175
- {/* Execute */}
176
- {payer.chain.id !== chain.id ? (
177
- <SwitchNetworkButton
178
- fullWidth
179
- variant="accent"
180
- switchChain={async () => {
181
- await props.payer.wallet.switchChain(chain);
182
- }}
183
- />
184
- ) : (
185
- <Button
186
- variant="accent"
187
- fullWidth
188
- disabled={status === "pending"}
189
- onClick={async () => {
190
- if (step === "execute") {
191
- onDone();
192
- return;
193
- }
194
-
195
- try {
196
- setStatus("pending");
197
-
198
- const transaction = isNativeToken(token)
199
- ? prepareTransaction({
200
- client,
201
- chain,
202
- to: receiverAddress,
203
- value: toWei(tokenAmount),
204
- })
205
- : transfer({
206
- contract: getContract({
207
- address: token.address,
208
- chain: chain,
209
- client: client,
210
- }),
211
- to: receiverAddress,
212
- amount: tokenAmount,
213
- });
214
-
215
- await sendAndConfirmTransaction({
216
- account: props.payer.account,
217
- transaction,
218
- });
219
-
220
- setStep("execute");
221
- if (transactionMode) {
222
- setStatus("idle");
223
- } else {
224
- setStatus("done");
225
- }
226
- } catch (e) {
227
- console.error(e);
228
- setStatus("error");
229
- }
230
- }}
231
- gap="xs"
232
- >
233
- {step === "execute" && (status === "done" ? "Done" : "Continue")}
234
- {step === "transfer" &&
235
- (status === "pending" ? "Confirming" : "Confirm")}
236
- {status === "pending" && (
237
- <Spinner size="sm" color="accentButtonText" />
238
- )}
239
- </Button>
240
- )}
241
- </Container>
46
+ return (
47
+ <TransferConfirmationScreen
48
+ {...props}
49
+ setTransactionHash={setTransferTxHash}
50
+ />
242
51
  );
243
52
  }
@@ -1,3 +1,5 @@
1
+ import { formatNumber } from "../../../../../utils/formatNumber.js";
2
+
1
3
  /**
2
4
  * @internal
3
5
  * @param balanceData
@@ -13,7 +15,7 @@ export function formatTokenBalance(
13
15
  showSymbol = true,
14
16
  ) {
15
17
  return (
16
- Number(balanceData.displayValue).toFixed(3) +
18
+ formatNumber(Number(balanceData.displayValue), 5) +
17
19
  (showSymbol ? ` ${balanceData.symbol}` : "")
18
20
  );
19
21
  }
@@ -181,10 +181,11 @@ export const ConnectWalletSocialOptions = (
181
181
  // Need to trigger login on button click to avoid popup from being blocked
182
182
  const handleSocialLogin = async (strategy: SocialAuthOption) => {
183
183
  const walletConfig = wallet.getConfig();
184
+ const authMode = walletConfig?.auth?.mode ?? "popup";
184
185
  if (
185
186
  walletConfig &&
186
187
  "auth" in walletConfig &&
187
- walletConfig?.auth?.mode === "redirect" &&
188
+ authMode !== "popup" &&
188
189
  !props.isLinking // We do not support redirects for linking
189
190
  ) {
190
191
  return loginWithOauthRedirect({
@@ -192,7 +193,7 @@ export const ConnectWalletSocialOptions = (
192
193
  client: props.client,
193
194
  ecosystem: ecosystemInfo,
194
195
  redirectUrl: walletConfig?.auth?.redirectUrl,
195
- redirectExternally: walletConfig?.auth?.redirectExternally,
196
+ mode: authMode,
196
197
  });
197
198
  }
198
199
 
@@ -48,10 +48,15 @@ export function SocialLogin(props: {
48
48
 
49
49
  const handleSocialLogin = async () => {
50
50
  const walletConfig = wallet.getConfig();
51
+ const authMode =
52
+ walletConfig && "auth" in walletConfig
53
+ ? walletConfig?.auth?.mode ?? "popup"
54
+ : "popup";
55
+
51
56
  if (
52
57
  walletConfig &&
53
58
  "auth" in walletConfig &&
54
- walletConfig?.auth?.mode === "redirect" &&
59
+ authMode !== "popup" &&
55
60
  !props.isLinking // Redirect not supported for account linking (we need to maintain the aplication state)
56
61
  ) {
57
62
  return loginWithOauthRedirect({
@@ -64,7 +69,7 @@ export function SocialLogin(props: {
64
69
  }
65
70
  : undefined,
66
71
  redirectUrl: walletConfig?.auth?.redirectUrl,
67
- redirectExternally: walletConfig?.auth?.redirectExternally,
72
+ mode: walletConfig?.auth?.mode,
68
73
  });
69
74
  }
70
75
 
@@ -0,0 +1,31 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { ConnectButton } from "../react/web/ui/ConnectWallet/ConnectButton.js";
3
+ import { storyClient } from "./utils.js";
4
+
5
+ const meta = {
6
+ title: "Connect/ConnectButton",
7
+ component: ConnectButton,
8
+ parameters: {
9
+ layout: "centered",
10
+ },
11
+ tags: ["autodocs"],
12
+ args: {
13
+ client: storyClient,
14
+ },
15
+ } satisfies Meta<typeof ConnectButton>;
16
+
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ export const Dark: Story = {
20
+ args: {
21
+ theme: "dark",
22
+ },
23
+ };
24
+
25
+ export const Light: Story = {
26
+ args: {
27
+ theme: "light",
28
+ },
29
+ };
30
+
31
+ export default meta;
@@ -0,0 +1,42 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { PayEmbed } from "../react/web/ui/PayEmbed.js";
3
+ import { storyClient } from "./utils.js";
4
+
5
+ const meta = {
6
+ title: "Connect/PayEmbed",
7
+ component: PayEmbed,
8
+ parameters: {
9
+ layout: "centered",
10
+ },
11
+ tags: ["autodocs"],
12
+ args: {
13
+ client: storyClient,
14
+ },
15
+ } satisfies Meta<typeof PayEmbed>;
16
+
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ export const Dark: Story = {
20
+ args: {
21
+ theme: "dark",
22
+ },
23
+ };
24
+
25
+ export const FiatTestMode: Story = {
26
+ args: {
27
+ theme: "dark",
28
+ payOptions: {
29
+ buyWithFiat: {
30
+ testMode: true,
31
+ },
32
+ },
33
+ },
34
+ };
35
+
36
+ export const Light: Story = {
37
+ args: {
38
+ theme: "light",
39
+ },
40
+ };
41
+
42
+ export default meta;