thirdweb 5.88.6 → 5.88.8-nightly-1fa36c1d56758788a8f9053f8929497bacb2b115-20250224233959

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 (198) hide show
  1. package/dist/cjs/contract/deployment/utils/create-2-factory.js +4 -0
  2. package/dist/cjs/contract/deployment/utils/create-2-factory.js.map +1 -1
  3. package/dist/cjs/pay/buyWithFiat/getQuote.js +1 -0
  4. package/dist/cjs/pay/buyWithFiat/getQuote.js.map +1 -1
  5. package/dist/cjs/pay/buyWithFiat/isSwapRequiredPostOnramp.js +44 -0
  6. package/dist/cjs/pay/buyWithFiat/isSwapRequiredPostOnramp.js.map +1 -1
  7. package/dist/cjs/pay/convert/type.js +30 -1
  8. package/dist/cjs/pay/convert/type.js.map +1 -1
  9. package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -0
  10. package/dist/cjs/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
  11. package/dist/cjs/react/core/hooks/wallets/useSendToken.js +18 -2
  12. package/dist/cjs/react/core/hooks/wallets/useSendToken.js.map +1 -1
  13. package/dist/cjs/react/core/providers/invalidateWalletBalance.js +6 -1
  14. package/dist/cjs/react/core/providers/invalidateWalletBalance.js.map +1 -1
  15. package/dist/cjs/react/core/utils/account.js +2 -7
  16. package/dist/cjs/react/core/utils/account.js.map +1 -1
  17. package/dist/cjs/react/web/ui/ConnectWallet/NetworkSelector.js +1 -1
  18. package/dist/cjs/react/web/ui/ConnectWallet/NetworkSelector.js.map +1 -1
  19. package/dist/cjs/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.js +1 -1
  20. package/dist/cjs/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.js.map +1 -1
  21. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +6 -4
  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/PayWIthCreditCard.js +2 -1
  24. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.js.map +1 -1
  25. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/CurrencySelection.js +1 -1
  26. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/CurrencySelection.js.map +1 -1
  27. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +0 -13
  28. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
  29. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +6 -26
  30. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  31. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +1 -1
  32. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +1 -1
  33. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +541 -0
  34. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -0
  35. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js +23 -0
  36. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js.map +1 -1
  37. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +8 -0
  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/swap/StepConnector.js +21 -0
  40. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js.map +1 -0
  41. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js +4 -9
  42. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js.map +1 -1
  43. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +2 -2
  44. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
  45. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +2 -1
  46. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  47. package/dist/cjs/rpc/rpc.js +1 -1
  48. package/dist/cjs/storage/upload/mobile.js +1 -1
  49. package/dist/cjs/storage/upload/mobile.js.map +1 -1
  50. package/dist/cjs/storage/upload/web-node.js +1 -0
  51. package/dist/cjs/storage/upload/web-node.js.map +1 -1
  52. package/dist/cjs/version.js +1 -1
  53. package/dist/cjs/version.js.map +1 -1
  54. package/dist/cjs/wallets/in-app/web/ecosystem.js +1 -1
  55. package/dist/cjs/wallets/in-app/web/lib/iframe-wallet.js +1 -1
  56. package/dist/cjs/wallets/in-app/web/lib/iframe-wallet.js.map +1 -1
  57. package/dist/esm/contract/deployment/utils/create-2-factory.js +4 -0
  58. package/dist/esm/contract/deployment/utils/create-2-factory.js.map +1 -1
  59. package/dist/esm/pay/buyWithFiat/getQuote.js +1 -0
  60. package/dist/esm/pay/buyWithFiat/getQuote.js.map +1 -1
  61. package/dist/esm/pay/buyWithFiat/isSwapRequiredPostOnramp.js +43 -0
  62. package/dist/esm/pay/buyWithFiat/isSwapRequiredPostOnramp.js.map +1 -1
  63. package/dist/esm/pay/convert/type.js +29 -2
  64. package/dist/esm/pay/convert/type.js.map +1 -1
  65. package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js +1 -0
  66. package/dist/esm/react/core/hooks/pay/useBuyWithFiatStatus.js.map +1 -1
  67. package/dist/esm/react/core/hooks/wallets/useSendToken.js +19 -3
  68. package/dist/esm/react/core/hooks/wallets/useSendToken.js.map +1 -1
  69. package/dist/esm/react/core/providers/invalidateWalletBalance.js +6 -1
  70. package/dist/esm/react/core/providers/invalidateWalletBalance.js.map +1 -1
  71. package/dist/esm/react/core/utils/account.js +1 -6
  72. package/dist/esm/react/core/utils/account.js.map +1 -1
  73. package/dist/esm/react/web/ui/ConnectWallet/NetworkSelector.js +1 -1
  74. package/dist/esm/react/web/ui/ConnectWallet/NetworkSelector.js.map +1 -1
  75. package/dist/esm/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.js +1 -1
  76. package/dist/esm/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.js.map +1 -1
  77. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js +6 -4
  78. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.js.map +1 -1
  79. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.js +2 -1
  80. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.js.map +1 -1
  81. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/CurrencySelection.js +3 -3
  82. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/CurrencySelection.js.map +1 -1
  83. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js +0 -13
  84. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.js.map +1 -1
  85. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js +7 -27
  86. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.js.map +1 -1
  87. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js +2 -2
  88. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.js.map +1 -1
  89. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +538 -0
  90. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -0
  91. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js +22 -0
  92. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.js.map +1 -1
  93. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js +8 -0
  94. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.js.map +1 -1
  95. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js +18 -0
  96. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.js.map +1 -0
  97. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js +5 -10
  98. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.js.map +1 -1
  99. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js +2 -2
  100. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.js.map +1 -1
  101. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js +2 -1
  102. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.js.map +1 -1
  103. package/dist/esm/rpc/rpc.js +1 -1
  104. package/dist/esm/storage/upload/mobile.js +1 -1
  105. package/dist/esm/storage/upload/mobile.js.map +1 -1
  106. package/dist/esm/storage/upload/web-node.js +1 -0
  107. package/dist/esm/storage/upload/web-node.js.map +1 -1
  108. package/dist/esm/version.js +1 -1
  109. package/dist/esm/version.js.map +1 -1
  110. package/dist/esm/wallets/in-app/web/ecosystem.js +1 -1
  111. package/dist/esm/wallets/in-app/web/lib/iframe-wallet.js +1 -1
  112. package/dist/esm/wallets/in-app/web/lib/iframe-wallet.js.map +1 -1
  113. package/dist/types/pay/buyWithFiat/getQuote.d.ts +8 -32
  114. package/dist/types/pay/buyWithFiat/getQuote.d.ts.map +1 -1
  115. package/dist/types/pay/buyWithFiat/isSwapRequiredPostOnramp.d.ts +7 -0
  116. package/dist/types/pay/buyWithFiat/isSwapRequiredPostOnramp.d.ts.map +1 -1
  117. package/dist/types/pay/convert/type.d.ts +2 -1
  118. package/dist/types/pay/convert/type.d.ts.map +1 -1
  119. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts +2 -1
  120. package/dist/types/react/core/hooks/connection/ConnectButtonProps.d.ts.map +1 -1
  121. package/dist/types/react/core/hooks/pay/useBuyWithFiatStatus.d.ts +2 -1
  122. package/dist/types/react/core/hooks/pay/useBuyWithFiatStatus.d.ts.map +1 -1
  123. package/dist/types/react/core/hooks/wallets/useSendToken.d.ts +6 -1
  124. package/dist/types/react/core/hooks/wallets/useSendToken.d.ts.map +1 -1
  125. package/dist/types/react/core/providers/invalidateWalletBalance.d.ts +1 -1
  126. package/dist/types/react/core/providers/invalidateWalletBalance.d.ts.map +1 -1
  127. package/dist/types/react/core/utils/account.d.ts +1 -1
  128. package/dist/types/react/core/utils/account.d.ts.map +1 -1
  129. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.d.ts +1 -1
  130. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.d.ts.map +1 -1
  131. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/CurrencySelection.d.ts.map +1 -1
  132. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.d.ts.map +1 -1
  133. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts +7 -2
  134. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.d.ts.map +1 -1
  135. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/{FiatFlow.d.ts → OnRampScreen.d.ts} +4 -4
  136. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts.map +1 -0
  137. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.d.ts +6 -2
  138. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.d.ts.map +1 -1
  139. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts +0 -1
  140. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/main/types.d.ts.map +1 -1
  141. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.d.ts +4 -0
  142. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.d.ts.map +1 -0
  143. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.d.ts.map +1 -1
  144. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.d.ts +1 -0
  145. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.d.ts.map +1 -1
  146. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts +1 -0
  147. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.d.ts.map +1 -1
  148. package/dist/types/react/web/ui/MediaRenderer/MediaRenderer.d.ts +2 -2
  149. package/dist/types/react/web/ui/MediaRenderer/ModelViewer.d.ts +1 -1
  150. package/dist/types/storage/upload/web-node.d.ts.map +1 -1
  151. package/dist/types/version.d.ts +1 -1
  152. package/dist/types/version.d.ts.map +1 -1
  153. package/dist/types/wallets/in-app/web/ecosystem.d.ts +1 -1
  154. package/package.json +1 -1
  155. package/src/contract/deployment/utils/create-2-factory.ts +4 -0
  156. package/src/pay/buyWithFiat/getQuote.ts +9 -33
  157. package/src/pay/buyWithFiat/isSwapRequiredPostOnramp.ts +56 -0
  158. package/src/pay/convert/type.ts +30 -1
  159. package/src/react/core/hooks/connection/ConnectButtonProps.ts +2 -1
  160. package/src/react/core/hooks/pay/useBuyWithFiatStatus.ts +3 -1
  161. package/src/react/core/hooks/wallets/useSendToken.ts +19 -3
  162. package/src/react/core/providers/invalidateWalletBalance.ts +6 -1
  163. package/src/react/core/utils/account.ts +4 -8
  164. package/src/react/web/ui/ConnectWallet/NetworkSelector.tsx +1 -1
  165. package/src/react/web/ui/ConnectWallet/icons/currencies/JPYIcon.tsx +1 -1
  166. package/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +8 -3
  167. package/src/react/web/ui/ConnectWallet/screens/Buy/PayWIthCreditCard.tsx +2 -2
  168. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/CurrencySelection.tsx +3 -6
  169. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatScreenContent.tsx +0 -19
  170. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatSteps.tsx +9 -32
  171. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatTxDetailsTable.tsx +2 -2
  172. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +790 -0
  173. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/currencies.tsx +38 -2
  174. package/src/react/web/ui/ConnectWallet/screens/Buy/main/types.ts +0 -1
  175. package/src/react/web/ui/ConnectWallet/screens/Buy/main/useUISelectionStates.ts +10 -0
  176. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/StepConnector.tsx +55 -0
  177. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/SwapSummary.tsx +18 -41
  178. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx +25 -22
  179. package/src/react/web/ui/ConnectWallet/screens/Buy/swap/WalletRow.tsx +10 -1
  180. package/src/rpc/rpc.ts +1 -1
  181. package/src/storage/upload/mobile.ts +1 -1
  182. package/src/storage/upload/web-node.ts +1 -0
  183. package/src/version.ts +1 -1
  184. package/src/wallets/in-app/web/ecosystem.ts +1 -1
  185. package/src/wallets/in-app/web/lib/iframe-wallet.ts +1 -1
  186. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js +0 -63
  187. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js.map +0 -1
  188. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +0 -116
  189. package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +0 -1
  190. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js +0 -60
  191. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.js.map +0 -1
  192. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js +0 -113
  193. package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.js.map +0 -1
  194. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.d.ts.map +0 -1
  195. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.d.ts +0 -24
  196. package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.d.ts.map +0 -1
  197. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatFlow.tsx +0 -152
  198. package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/FiatStatusScreen.tsx +0 -258
@@ -0,0 +1,790 @@
1
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { trackPayEvent } from "../../../../../../../analytics/track/pay.js";
4
+ import { getCachedChain } from "../../../../../../../chains/utils.js";
5
+ import type { ThirdwebClient } from "../../../../../../../client/client.js";
6
+ import { getContract } from "../../../../../../../contract/contract.js";
7
+ import { allowance } from "../../../../../../../extensions/erc20/__generated__/IERC20/read/allowance.js";
8
+ import { approve } from "../../../../../../../extensions/erc20/write/approve.js";
9
+ import type { BuyWithCryptoQuote } from "../../../../../../../pay/buyWithCrypto/getQuote.js";
10
+ import type { BuyWithCryptoStatus } from "../../../../../../../pay/buyWithCrypto/getStatus.js";
11
+ import type { BuyWithFiatQuote } from "../../../../../../../pay/buyWithFiat/getQuote.js";
12
+ import {
13
+ type BuyWithFiatStatus,
14
+ getBuyWithFiatStatus,
15
+ } from "../../../../../../../pay/buyWithFiat/getStatus.js";
16
+ import {
17
+ type OnRampStep,
18
+ getOnRampSteps,
19
+ } from "../../../../../../../pay/buyWithFiat/isSwapRequiredPostOnramp.js";
20
+ import { sendBatchTransaction } from "../../../../../../../transaction/actions/send-batch-transaction.js";
21
+ import { sendTransaction } from "../../../../../../../transaction/actions/send-transaction.js";
22
+ import type { WaitForReceiptOptions } from "../../../../../../../transaction/actions/wait-for-tx-receipt.js";
23
+ import { waitForReceipt } from "../../../../../../../transaction/actions/wait-for-tx-receipt.js";
24
+ import { formatNumber } from "../../../../../../../utils/formatNumber.js";
25
+ import { isEcosystemWallet } from "../../../../../../../wallets/ecosystem/is-ecosystem-wallet.js";
26
+ import { isInAppWallet } from "../../../../../../../wallets/in-app/core/wallet/index.js";
27
+ import type { Wallet } from "../../../../../../../wallets/interfaces/wallet.js";
28
+ import { isSmartWallet } from "../../../../../../../wallets/smart/is-smart-wallet.js";
29
+ import { spacing } from "../../../../../../core/design-system/index.js";
30
+ import { useChainName } from "../../../../../../core/hooks/others/useChainQuery.js";
31
+ import { useBuyWithCryptoQuote } from "../../../../../../core/hooks/pay/useBuyWithCryptoQuote.js";
32
+ import { useBuyWithCryptoStatus } from "../../../../../../core/hooks/pay/useBuyWithCryptoStatus.js";
33
+ import { useBuyWithFiatStatus } from "../../../../../../core/hooks/pay/useBuyWithFiatStatus.js";
34
+ import { useConnectedWallets } from "../../../../../../core/hooks/wallets/useConnectedWallets.js";
35
+ import { invalidateWalletBalance } from "../../../../../../core/providers/invalidateWalletBalance.js";
36
+ import { Spacer } from "../../../../components/Spacer.js";
37
+ import { Spinner } from "../../../../components/Spinner.js";
38
+ import { SwitchNetworkButton } from "../../../../components/SwitchNetwork.js";
39
+ import { Container, ModalHeader } from "../../../../components/basic.js";
40
+ import { Button } from "../../../../components/buttons.js";
41
+ import { Text } from "../../../../components/text.js";
42
+ import { TokenSymbol } from "../../../../components/token/TokenSymbol.js";
43
+ import { PayTokenIcon } from "../PayTokenIcon.js";
44
+ import { openOnrampPopup } from "../openOnRamppopup.js";
45
+ import type { FiatStatusMeta } from "../pay-transactions/statusMeta.js";
46
+ import { StepConnectorArrow } from "../swap/StepConnector.js";
47
+ import { WalletRow } from "../swap/WalletRow.js";
48
+ import { addPendingTx } from "../swap/pendingSwapTx.js";
49
+ import type { PayerInfo } from "../types.js";
50
+ import { StepContainer } from "./FiatSteps.js";
51
+
52
+ type OnRampScreenState = {
53
+ steps: Array<{
54
+ index: number;
55
+ step: OnRampStep;
56
+ status: FiatStatusMeta["progressStatus"];
57
+ }>;
58
+ handleContinue: () => void;
59
+ isLoading: boolean;
60
+ isDone: boolean;
61
+ isFailed: boolean;
62
+ };
63
+
64
+ export function OnRampScreen(props: {
65
+ title: string;
66
+ quote: BuyWithFiatQuote;
67
+ onBack: () => void;
68
+ client: ThirdwebClient;
69
+ testMode: boolean;
70
+ theme: "light" | "dark";
71
+ onDone: () => void;
72
+ transactionMode: boolean;
73
+ isEmbed: boolean;
74
+ payer: PayerInfo;
75
+ onSuccess: (status: BuyWithFiatStatus) => void;
76
+ receiverAddress: string;
77
+ }) {
78
+ const connectedWallets = useConnectedWallets();
79
+ const isAutoMode = isInAppSigner({
80
+ wallet: props.payer.wallet,
81
+ connectedWallets,
82
+ });
83
+ const state = useOnRampScreenState({
84
+ quote: props.quote,
85
+ client: props.client,
86
+ onSuccess: props.onSuccess,
87
+ onDone: props.onDone,
88
+ payer: props.payer,
89
+ theme: props.theme,
90
+ isAutoMode,
91
+ });
92
+ const firstStepChainId = state.steps[0]?.step.token.chainId;
93
+ const currentStepIndex = state.steps.findIndex(
94
+ (step) => step.status === "pending" || step.status === "actionRequired",
95
+ );
96
+ return (
97
+ <Container p="lg">
98
+ <ModalHeader title={props.title} onBack={props.onBack} />
99
+ <Spacer y="xl" />
100
+ <Container
101
+ flex="column"
102
+ gap="xs"
103
+ center="y"
104
+ style={{
105
+ paddingLeft: spacing.md,
106
+ }}
107
+ >
108
+ <WalletRow
109
+ client={props.client}
110
+ address={props.receiverAddress}
111
+ iconSize="md"
112
+ textSize="sm"
113
+ label="Recipient wallet"
114
+ />
115
+ </Container>
116
+ <Spacer y="md" />
117
+ <Container flex="column">
118
+ {state.steps.map(({ step, status }, index) => (
119
+ <Container flex="column" key={step.action}>
120
+ <StepContainer
121
+ state={status}
122
+ index={index}
123
+ style={{
124
+ flex: "1",
125
+ }}
126
+ >
127
+ <StepUI
128
+ step={step}
129
+ client={props.client}
130
+ payer={props.payer}
131
+ index={index}
132
+ />
133
+ </StepContainer>
134
+ {index < state.steps.length - 1 && (
135
+ <StepConnectorArrow active={index === currentStepIndex} />
136
+ )}
137
+ </Container>
138
+ ))}
139
+ </Container>
140
+
141
+ <Spacer y="md" />
142
+
143
+ <Text
144
+ size="xs"
145
+ color="secondaryText"
146
+ center
147
+ style={{ padding: `0 ${spacing.xl}` }}
148
+ >
149
+ Keep this window open until all transactions are complete.
150
+ </Text>
151
+
152
+ <Spacer y="lg" />
153
+
154
+ <Container flex="column" gap="md">
155
+ {!state.isDone &&
156
+ firstStepChainId &&
157
+ firstStepChainId !== props.payer.chain.id ? (
158
+ <SwitchNetworkButton
159
+ fullWidth
160
+ variant="accent"
161
+ switchChain={async () => {
162
+ await props.payer.wallet.switchChain(
163
+ getCachedChain(firstStepChainId),
164
+ );
165
+ }}
166
+ />
167
+ ) : (
168
+ <Button
169
+ variant="accent"
170
+ gap="sm"
171
+ fullWidth
172
+ onClick={state.handleContinue}
173
+ disabled={state.isLoading}
174
+ >
175
+ {state.isLoading
176
+ ? "Processing"
177
+ : state.isDone
178
+ ? props.transactionMode
179
+ ? "Continue Transaction"
180
+ : "Done"
181
+ : state.isFailed
182
+ ? "Retry"
183
+ : "Continue"}
184
+ {state.isLoading && <Spinner size="sm" color="primaryText" />}
185
+ </Button>
186
+ )}
187
+ </Container>
188
+ </Container>
189
+ );
190
+ }
191
+
192
+ function StepUI(props: {
193
+ step: OnRampStep;
194
+ index: number;
195
+ client: ThirdwebClient;
196
+ payer: PayerInfo;
197
+ }) {
198
+ const { step, client } = props;
199
+ const chain = useChainName(getCachedChain(step.token.chainId));
200
+ return (
201
+ <Container flex="column" gap="xs" py="3xs">
202
+ <Container
203
+ flex="row"
204
+ center="y"
205
+ gap="sm"
206
+ style={{
207
+ display: "flex",
208
+ justifyContent: "space-between",
209
+ flexWrap: "nowrap",
210
+ }}
211
+ >
212
+ <PayTokenIcon
213
+ chain={getCachedChain(step.token.chainId)}
214
+ client={client}
215
+ size="md"
216
+ token={{
217
+ address: step.token.tokenAddress,
218
+ }}
219
+ />
220
+ <Container flex="column" gap="3xs" center="y" style={{ flex: "1" }}>
221
+ <Text size="sm" color="primaryText">
222
+ {step.action.charAt(0).toUpperCase() + step.action.slice(1)}
223
+ </Text>
224
+
225
+ <Container
226
+ flex="row"
227
+ gap="xs"
228
+ center="y"
229
+ style={{
230
+ display: "flex",
231
+ justifyContent: "space-between",
232
+ flexWrap: "nowrap",
233
+ }}
234
+ >
235
+ <Container
236
+ flex="row"
237
+ gap="xxs"
238
+ center="y"
239
+ style={{
240
+ flex: "1 1 60%",
241
+ minWidth: 0,
242
+ maxWidth: "60%",
243
+ overflow: "hidden",
244
+ flexWrap: "nowrap",
245
+ }}
246
+ >
247
+ <Text size="sm" color="primaryText">
248
+ {formatNumber(Number(step.amount), 5)}
249
+ </Text>
250
+ <TokenSymbol
251
+ token={{
252
+ address: step.token.tokenAddress,
253
+ name: step.token.name || "",
254
+ symbol: step.token.symbol || "",
255
+ }}
256
+ chain={getCachedChain(step.token.chainId)}
257
+ size="sm"
258
+ color="secondaryText"
259
+ />
260
+ </Container>
261
+ <Container
262
+ flex="row"
263
+ gap="xs"
264
+ center="y"
265
+ style={{
266
+ flex: "1 1 40%",
267
+ maxWidth: "40%",
268
+ minWidth: 0,
269
+ justifyContent: "flex-end",
270
+ flexWrap: "nowrap",
271
+ }}
272
+ >
273
+ <Text
274
+ size="xs"
275
+ style={{
276
+ overflow: "hidden",
277
+ textOverflow: "ellipsis",
278
+ whiteSpace: "nowrap",
279
+ }}
280
+ >
281
+ {chain.name}
282
+ </Text>
283
+ </Container>
284
+ </Container>
285
+ </Container>
286
+ </Container>
287
+ </Container>
288
+ );
289
+ }
290
+
291
+ function useOnRampScreenState(props: {
292
+ quote: BuyWithFiatQuote;
293
+ client: ThirdwebClient;
294
+ onSuccess: (status: BuyWithFiatStatus) => void;
295
+ onDone: () => void;
296
+ payer: PayerInfo;
297
+ theme: "light" | "dark";
298
+ isAutoMode?: boolean;
299
+ }): OnRampScreenState {
300
+ const onRampSteps = getOnRampSteps(props.quote);
301
+ const [currentStepIndex, setCurrentStepIndex] = useState(0);
302
+ const [swapTxHash, setSwapTxHash] = useState<{
303
+ hash: string;
304
+ chainId: number;
305
+ }>();
306
+ const [popupWindow, setPopupWindow] = useState<Window | null>(null);
307
+
308
+ // Track onramp status
309
+ const { uiStatus: fiatOnrampStatus } = useOnRampStatus({
310
+ intentId: props.quote.intentId,
311
+ client: props.client,
312
+ onSuccess: (status) => {
313
+ if (onRampSteps.length === 1) {
314
+ // If only one step, this is the final success
315
+ props.onSuccess(status);
316
+ } else {
317
+ // Move to next step (swap)
318
+ setCurrentStepIndex((prev) => prev + 1);
319
+ }
320
+ },
321
+ openedWindow: popupWindow,
322
+ });
323
+
324
+ // Get quote for current swap/bridge step if needed
325
+ const previousStep = onRampSteps[currentStepIndex - 1];
326
+ const currentStep = onRampSteps[currentStepIndex];
327
+ const swapQuoteQuery = useBuyWithCryptoQuote(
328
+ previousStep && currentStep
329
+ ? {
330
+ fromChainId: previousStep.token.chainId,
331
+ fromTokenAddress: previousStep.token.tokenAddress,
332
+ toAmount: currentStep.amount,
333
+ toChainId: currentStep.token.chainId,
334
+ toTokenAddress: currentStep.token.tokenAddress,
335
+ fromAddress: props.payer.account.address,
336
+ toAddress: props.payer.account.address,
337
+ client: props.client,
338
+ }
339
+ : undefined,
340
+ );
341
+
342
+ // Handle swap execution
343
+ const swapMutation = useSwapMutation({
344
+ client: props.client,
345
+ payer: props.payer,
346
+ isFiatFlow: true,
347
+ });
348
+
349
+ // Track swap status
350
+ const { uiStatus: swapStatus } = useSwapStatus({
351
+ client: props.client,
352
+ transactionHash: swapTxHash?.hash,
353
+ chainId: swapTxHash?.chainId,
354
+ onSuccess: () => {
355
+ if (currentStepIndex === onRampSteps.length - 1) {
356
+ // Last step completed - call final success
357
+ getBuyWithFiatStatus({
358
+ intentId: props.quote.intentId,
359
+ client: props.client,
360
+ }).then(props.onSuccess);
361
+ } else {
362
+ // Reset swap state before moving to next step
363
+ setSwapTxHash(undefined);
364
+ swapMutation.reset();
365
+ // Move to next step
366
+ setCurrentStepIndex((prev) => prev + 1);
367
+ }
368
+ },
369
+ });
370
+
371
+ // Map steps to their current status
372
+ const steps = onRampSteps.map((step, index) => {
373
+ let status: FiatStatusMeta["progressStatus"] = "unknown";
374
+
375
+ if (index === 0) {
376
+ // First step (onramp) status
377
+ status = fiatOnrampStatus;
378
+ } else if (index < currentStepIndex) {
379
+ // Previous steps are completed
380
+ status = "completed";
381
+ } else if (index === currentStepIndex) {
382
+ // Current step - could be swap or bridge
383
+ if (swapQuoteQuery.isLoading || swapMutation.isPending) {
384
+ status = "pending";
385
+ } else if (swapQuoteQuery.error || swapMutation.error) {
386
+ status = "failed";
387
+ } else if (swapTxHash) {
388
+ status = swapStatus;
389
+ } else {
390
+ status = "actionRequired";
391
+ }
392
+ }
393
+
394
+ return {
395
+ index,
396
+ step,
397
+ status,
398
+ };
399
+ });
400
+
401
+ const isLoading = steps.some((step) => step.status === "pending");
402
+ const isDone = steps.every((step) => step.status === "completed");
403
+ const isFailed = steps.some((step) => step.status === "failed");
404
+
405
+ // Update handleContinue to handle done state
406
+ const handleContinue = useCallback(async () => {
407
+ if (isDone) {
408
+ props.onDone();
409
+ return;
410
+ }
411
+
412
+ if (currentStepIndex === 0) {
413
+ // First step - open onramp popup
414
+ const popup = openOnrampPopup(props.quote.onRampLink, props.theme);
415
+ trackPayEvent({
416
+ event: "open_onramp_popup",
417
+ client: props.client,
418
+ walletAddress: props.payer.account.address,
419
+ walletType: props.payer.wallet.id,
420
+ });
421
+ setPopupWindow(popup);
422
+ addPendingTx({
423
+ type: "fiat",
424
+ intentId: props.quote.intentId,
425
+ });
426
+ } else if (swapQuoteQuery.data && !swapTxHash) {
427
+ // Execute swap/bridge
428
+ try {
429
+ const result = await swapMutation.mutateAsync({
430
+ quote: swapQuoteQuery.data,
431
+ });
432
+ setSwapTxHash({
433
+ hash: result.transactionHash,
434
+ chainId: result.chainId,
435
+ });
436
+ } catch (e) {
437
+ console.error("Failed to execute swap:", e);
438
+ }
439
+ } else if (isFailed) {
440
+ // retry the quote step
441
+ setSwapTxHash(undefined);
442
+ swapMutation.reset();
443
+ swapQuoteQuery.refetch();
444
+ }
445
+ }, [
446
+ isDone,
447
+ currentStepIndex,
448
+ swapQuoteQuery.data,
449
+ swapTxHash,
450
+ props.quote,
451
+ props.onDone,
452
+ swapMutation,
453
+ props.theme,
454
+ isFailed,
455
+ swapQuoteQuery.refetch,
456
+ swapMutation.reset,
457
+ props.client,
458
+ props.payer.account.address,
459
+ props.payer.wallet.id,
460
+ ]);
461
+
462
+ // Auto-progress effect
463
+ useEffect(() => {
464
+ if (!props.isAutoMode) {
465
+ return;
466
+ }
467
+
468
+ // Auto-start next swap step when previous step completes
469
+ if (
470
+ !isLoading &&
471
+ !isDone &&
472
+ !isFailed &&
473
+ currentStepIndex > 0 &&
474
+ currentStepIndex < onRampSteps.length &&
475
+ swapQuoteQuery.data &&
476
+ !swapTxHash
477
+ ) {
478
+ handleContinue();
479
+ }
480
+ }, [
481
+ props.isAutoMode,
482
+ currentStepIndex,
483
+ swapQuoteQuery.data,
484
+ swapTxHash,
485
+ onRampSteps.length,
486
+ handleContinue,
487
+ isDone,
488
+ isFailed,
489
+ isLoading,
490
+ ]);
491
+
492
+ return {
493
+ steps,
494
+ handleContinue,
495
+ isLoading,
496
+ isDone,
497
+ isFailed,
498
+ };
499
+ }
500
+
501
+ function useOnRampStatus(props: {
502
+ intentId: string;
503
+ client: ThirdwebClient;
504
+ onSuccess: (status: BuyWithFiatStatus) => void;
505
+ openedWindow: Window | null;
506
+ }) {
507
+ const queryClient = useQueryClient();
508
+ const statusQuery = useBuyWithFiatStatus({
509
+ intentId: props.intentId,
510
+ client: props.client,
511
+ queryOptions: {
512
+ enabled: !!props.openedWindow,
513
+ },
514
+ });
515
+ let uiStatus: FiatStatusMeta["progressStatus"] = "actionRequired";
516
+
517
+ switch (statusQuery.data?.status) {
518
+ case "ON_RAMP_TRANSFER_COMPLETED":
519
+ case "CRYPTO_SWAP_COMPLETED":
520
+ case "CRYPTO_SWAP_REQUIRED":
521
+ uiStatus = "completed";
522
+ break;
523
+ case "CRYPTO_SWAP_FALLBACK":
524
+ uiStatus = "partialSuccess";
525
+ break;
526
+ case "ON_RAMP_TRANSFER_FAILED":
527
+ case "PAYMENT_FAILED":
528
+ uiStatus = "failed";
529
+ break;
530
+ case "PENDING_PAYMENT":
531
+ case "ON_RAMP_TRANSFER_IN_PROGRESS":
532
+ uiStatus = "pending";
533
+ break;
534
+ default:
535
+ uiStatus = "actionRequired";
536
+ break;
537
+ }
538
+
539
+ const purchaseCbCalled = useRef(false);
540
+ useEffect(() => {
541
+ if (purchaseCbCalled.current || !props.onSuccess) {
542
+ return;
543
+ }
544
+
545
+ if (
546
+ statusQuery.data &&
547
+ (uiStatus === "completed" || uiStatus === "partialSuccess")
548
+ ) {
549
+ purchaseCbCalled.current = true;
550
+ props.onSuccess(statusQuery.data);
551
+ }
552
+ }, [props.onSuccess, statusQuery.data, uiStatus]);
553
+
554
+ // close the onramp popup if onramp is completed
555
+ useEffect(() => {
556
+ if (!props.openedWindow) {
557
+ return;
558
+ }
559
+
560
+ if (uiStatus === "completed" || uiStatus === "partialSuccess") {
561
+ try {
562
+ if (props.openedWindow && !props.openedWindow.closed) {
563
+ props.openedWindow.close();
564
+ }
565
+ } catch (e) {
566
+ console.warn("Failed to close payment window:", e);
567
+ }
568
+ }
569
+ }, [props.openedWindow, uiStatus]);
570
+
571
+ // invalidate wallet balance when onramp is completed
572
+ const invalidatedBalance = useRef(false);
573
+ useEffect(() => {
574
+ if (!invalidatedBalance.current && uiStatus === "completed") {
575
+ invalidatedBalance.current = true;
576
+ invalidateWalletBalance(queryClient);
577
+ }
578
+ }, [uiStatus, queryClient]);
579
+
580
+ return { uiStatus };
581
+ }
582
+
583
+ function useSwapStatus(props: {
584
+ client: ThirdwebClient;
585
+ transactionHash?: string;
586
+ chainId?: number;
587
+ onSuccess: (status: BuyWithCryptoStatus) => void;
588
+ }) {
589
+ const swapStatus = useBuyWithCryptoStatus(
590
+ props.transactionHash && props.chainId
591
+ ? {
592
+ client: props.client,
593
+ transactionHash: props.transactionHash,
594
+ chainId: props.chainId,
595
+ }
596
+ : undefined,
597
+ );
598
+
599
+ let uiStatus: FiatStatusMeta["progressStatus"] = "unknown";
600
+
601
+ switch (swapStatus.data?.status) {
602
+ case "COMPLETED":
603
+ uiStatus = "completed";
604
+ break;
605
+ case "FAILED":
606
+ case "NOT_FOUND":
607
+ uiStatus = "failed";
608
+ break;
609
+ case "PENDING":
610
+ uiStatus = "pending";
611
+ break;
612
+ case "NONE":
613
+ uiStatus = "unknown";
614
+ break;
615
+ default:
616
+ uiStatus = "unknown";
617
+ break;
618
+ }
619
+
620
+ const purchaseCbCalled = useRef(false);
621
+ useEffect(() => {
622
+ if (purchaseCbCalled.current || !props.onSuccess) {
623
+ return;
624
+ }
625
+
626
+ if (swapStatus.data?.status === "COMPLETED") {
627
+ purchaseCbCalled.current = true;
628
+ props.onSuccess(swapStatus.data);
629
+ }
630
+ }, [props.onSuccess, swapStatus]);
631
+
632
+ const queryClient = useQueryClient();
633
+ const balanceInvalidated = useRef(false);
634
+ useEffect(() => {
635
+ if (uiStatus === "completed" && !balanceInvalidated.current) {
636
+ balanceInvalidated.current = true;
637
+ invalidateWalletBalance(queryClient);
638
+ }
639
+ }, [queryClient, uiStatus]);
640
+
641
+ return { uiStatus };
642
+ }
643
+
644
+ function useSwapMutation(props: {
645
+ client: ThirdwebClient;
646
+ payer: PayerInfo;
647
+ isFiatFlow: boolean;
648
+ }) {
649
+ const queryClient = useQueryClient();
650
+ return useMutation({
651
+ mutationFn: async (input: { quote: BuyWithCryptoQuote }) => {
652
+ const { quote } = input;
653
+ const canBatch = props.payer.account.sendBatchTransaction;
654
+ const tokenContract = getContract({
655
+ client: props.client,
656
+ address: quote.swapDetails.fromToken.tokenAddress,
657
+ chain: getCachedChain(quote.swapDetails.fromToken.chainId),
658
+ });
659
+ const approveTxRequired =
660
+ quote.approvalData &&
661
+ (await allowance({
662
+ contract: tokenContract,
663
+ owner: props.payer.account.address,
664
+ spender: quote.approvalData.spenderAddress,
665
+ })) < BigInt(quote.approvalData.amountWei);
666
+ if (approveTxRequired && quote.approvalData && !canBatch) {
667
+ trackPayEvent({
668
+ event: "prompt_swap_approval",
669
+ client: props.client,
670
+ walletAddress: props.payer.account.address,
671
+ walletType: props.payer.wallet.id,
672
+ fromToken: quote.swapDetails.fromToken.tokenAddress,
673
+ fromAmount: quote.swapDetails.fromAmountWei,
674
+ toToken: quote.swapDetails.toToken.tokenAddress,
675
+ toAmount: quote.swapDetails.toAmountWei,
676
+ chainId: quote.swapDetails.fromToken.chainId,
677
+ dstChainId: quote.swapDetails.toToken.chainId,
678
+ });
679
+
680
+ const transaction = approve({
681
+ contract: tokenContract,
682
+ spender: quote.approvalData.spenderAddress,
683
+ amountWei: BigInt(quote.approvalData.amountWei),
684
+ });
685
+
686
+ const tx = await sendTransaction({
687
+ account: props.payer.account,
688
+ transaction,
689
+ });
690
+
691
+ await waitForReceipt({ ...tx, maxBlocksWaitTime: 50 });
692
+
693
+ trackPayEvent({
694
+ event: "swap_approval_success",
695
+ client: props.client,
696
+ walletAddress: props.payer.account.address,
697
+ walletType: props.payer.wallet.id,
698
+ fromToken: quote.swapDetails.fromToken.tokenAddress,
699
+ fromAmount: quote.swapDetails.fromAmountWei,
700
+ toToken: quote.swapDetails.toToken.tokenAddress,
701
+ toAmount: quote.swapDetails.toAmountWei,
702
+ chainId: quote.swapDetails.fromToken.chainId,
703
+ dstChainId: quote.swapDetails.toToken.chainId,
704
+ });
705
+ }
706
+
707
+ trackPayEvent({
708
+ event: "prompt_swap_execution",
709
+ client: props.client,
710
+ walletAddress: props.payer.account.address,
711
+ walletType: props.payer.wallet.id,
712
+ fromToken: quote.swapDetails.fromToken.tokenAddress,
713
+ fromAmount: quote.swapDetails.fromAmountWei,
714
+ toToken: quote.swapDetails.toToken.tokenAddress,
715
+ toAmount: quote.swapDetails.toAmountWei,
716
+ chainId: quote.swapDetails.fromToken.chainId,
717
+ dstChainId: quote.swapDetails.toToken.chainId,
718
+ });
719
+ const tx = quote.transactionRequest;
720
+ let _swapTx: WaitForReceiptOptions;
721
+ // check if we can batch approval and swap
722
+ if (canBatch && quote.approvalData && approveTxRequired) {
723
+ const approveTx = approve({
724
+ contract: tokenContract,
725
+ spender: quote.approvalData.spenderAddress,
726
+ amountWei: BigInt(quote.approvalData.amountWei),
727
+ });
728
+
729
+ _swapTx = await sendBatchTransaction({
730
+ account: props.payer.account,
731
+ transactions: [approveTx, tx],
732
+ });
733
+ } else {
734
+ _swapTx = await sendTransaction({
735
+ account: props.payer.account,
736
+ transaction: tx,
737
+ });
738
+ }
739
+
740
+ await waitForReceipt({ ..._swapTx, maxBlocksWaitTime: 50 });
741
+
742
+ trackPayEvent({
743
+ event: "swap_execution_success",
744
+ client: props.client,
745
+ walletAddress: props.payer.account.address,
746
+ walletType: props.payer.wallet.id,
747
+ fromToken: quote.swapDetails.fromToken.tokenAddress,
748
+ fromAmount: quote.swapDetails.fromAmountWei,
749
+ toToken: quote.swapDetails.toToken.tokenAddress,
750
+ toAmount: quote.swapDetails.toAmountWei,
751
+ chainId: quote.swapDetails.fromToken.chainId,
752
+ dstChainId: quote.swapDetails.toToken.chainId,
753
+ });
754
+
755
+ // do not add pending tx if the swap is part of fiat flow
756
+ if (!props.isFiatFlow) {
757
+ addPendingTx({
758
+ type: "swap",
759
+ txHash: _swapTx.transactionHash,
760
+ chainId: _swapTx.chain.id,
761
+ });
762
+ }
763
+
764
+ return {
765
+ transactionHash: _swapTx.transactionHash,
766
+ chainId: _swapTx.chain.id,
767
+ };
768
+ },
769
+ onSuccess: () => {
770
+ invalidateWalletBalance(queryClient);
771
+ },
772
+ });
773
+ }
774
+
775
+ function isInAppSigner(options: {
776
+ wallet: Wallet;
777
+ connectedWallets: Wallet[];
778
+ }) {
779
+ const isInAppOrEcosystem = (w: Wallet) =>
780
+ isInAppWallet(w) || isEcosystemWallet(w);
781
+ const isSmartWalletWithAdmin =
782
+ isSmartWallet(options.wallet) &&
783
+ options.connectedWallets.some(
784
+ (w) =>
785
+ isInAppOrEcosystem(w) &&
786
+ w.getAccount()?.address?.toLowerCase() ===
787
+ options.wallet.getAdminAccount?.()?.address?.toLowerCase(),
788
+ );
789
+ return isInAppOrEcosystem(options.wallet) || isSmartWalletWithAdmin;
790
+ }