@aurora-is-near/intents-swap-widget 3.14.0-redesign.3 → 3.14.0-redesign.8

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 (133) hide show
  1. package/dist/components/BlockingError.js +15 -9
  2. package/dist/components/BlockingError.js.map +1 -1
  3. package/dist/components/CloseButton.js +1 -1
  4. package/dist/components/CloseButton.js.map +1 -1
  5. package/dist/config-CrzQCoLQ.js +2836 -0
  6. package/dist/config-CrzQCoLQ.js.map +1 -0
  7. package/dist/config.d.ts +1 -0
  8. package/dist/config.js +4 -6
  9. package/dist/config.js.map +1 -1
  10. package/dist/errors.js +1 -1
  11. package/dist/ext/alchemy/index.js +1 -1
  12. package/dist/ext/index.js +1 -1
  13. package/dist/features/BalanceRpcLoader/TokenBalanceLoader.js +1 -1
  14. package/dist/features/BalanceRpcLoader/index.js +1 -1
  15. package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
  16. package/dist/features/ChainsDropdown/index.js +1 -1
  17. package/dist/features/DepositMethodSwitcher.js +26 -29
  18. package/dist/features/DepositMethodSwitcher.js.map +1 -1
  19. package/dist/features/ErrorBoundary.js +1 -1
  20. package/dist/features/ExternalDeposit.js +13 -14
  21. package/dist/features/ExternalDeposit.js.map +1 -1
  22. package/dist/features/SendAddress/index.js +1 -1
  23. package/dist/features/SendAddress/useNotification.js +1 -1
  24. package/dist/features/SubmitButton/index.js +1 -1
  25. package/dist/features/SuccessScreen/SummaryItem.js +2 -2
  26. package/dist/features/SuccessScreen/SummaryItem.js.map +1 -1
  27. package/dist/features/SuccessScreen/index.js +20 -20
  28. package/dist/features/SuccessScreen/index.js.map +1 -1
  29. package/dist/features/SwapDirectionSwitcher.js +1 -1
  30. package/dist/features/SwapQuote/SwapQuote.js +1 -1
  31. package/dist/features/SwapQuote/index.js +1 -1
  32. package/dist/features/TokenInput/TokenInput.js +1 -1
  33. package/dist/features/TokenInput/TokenInputEmpty.js +1 -1
  34. package/dist/features/TokenInput/TokenInputSource.js +1 -1
  35. package/dist/features/TokenInput/TokenInputTarget.js +1 -1
  36. package/dist/features/TokenInput/WalletBalance.js +1 -1
  37. package/dist/features/TokenInput/hooks/index.js +1 -1
  38. package/dist/features/TokenInput/hooks/useTokenInputBalance.js +1 -1
  39. package/dist/features/TokenInput/index.js +1 -1
  40. package/dist/features/TokensList/TokenItem.js +1 -1
  41. package/dist/features/TokensList/TokensList.js +1 -1
  42. package/dist/features/TokensList/index.js +1 -1
  43. package/dist/features/TokensModal.js +1 -1
  44. package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +13 -191
  45. package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js.map +1 -1
  46. package/dist/features/WalletCompatibilityCheck/index.js +21 -26
  47. package/dist/features/WalletCompatibilityCheck/index.js.map +1 -1
  48. package/dist/features/index.js +1 -1
  49. package/dist/hooks/index.js +1 -1
  50. package/dist/hooks/useAllTokens.js +1 -1
  51. package/dist/hooks/useChains.js +1 -1
  52. package/dist/hooks/useCompatibilityCheck.js +1 -1
  53. package/dist/hooks/useDefaultToken.js +1 -1
  54. package/dist/hooks/useExternalDepositStatus/index.js +1 -1
  55. package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
  56. package/dist/hooks/useIntentsBalance.js +1 -1
  57. package/dist/hooks/useIsCompatibilityCheckRequired.d.ts +1 -1
  58. package/dist/hooks/useIsCompatibilityCheckRequired.js +2 -2
  59. package/dist/hooks/useIsCompatibilityCheckRequired.js.map +1 -1
  60. package/dist/hooks/useMakeDepositAddress.js +1 -1
  61. package/dist/hooks/useMakeIntentsTransfer.js +1 -1
  62. package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
  63. package/dist/hooks/useMakeQuote.js +1 -1
  64. package/dist/hooks/useMakeQuoteTransfer.js +1 -1
  65. package/dist/hooks/useMakeTransfer.js +1 -1
  66. package/dist/hooks/useMergedBalance.js +1 -1
  67. package/dist/hooks/useSwitchChain.js +1 -1
  68. package/dist/hooks/useTheme.js +1 -1
  69. package/dist/hooks/useToggleTheme.d.ts +6 -1
  70. package/dist/hooks/useToggleTheme.js +22 -16
  71. package/dist/hooks/useToggleTheme.js.map +1 -1
  72. package/dist/hooks/useTokenInputPair.js +1 -1
  73. package/dist/hooks/useTokens.js +1 -1
  74. package/dist/hooks/useTokensFiltered.js +1 -1
  75. package/dist/hooks/useTokensIntentsUnique.js +1 -1
  76. package/dist/index.js +1 -1
  77. package/dist/machine/effects/index.js +1 -1
  78. package/dist/machine/effects/useAlchemyBalanceEffect.js +1 -1
  79. package/dist/machine/effects/useBalancesUpdateEffect.js +1 -1
  80. package/dist/machine/effects/useMakeQuoteEffect.js +1 -1
  81. package/dist/machine/effects/useSelectedTokensEffect.js +1 -1
  82. package/dist/machine/effects/useSetTokenBalanceEffect.js +1 -1
  83. package/dist/machine/effects/useSetTokenIntentsTargetEffect.js +1 -1
  84. package/dist/machine/effects/useWalletConnEffect.js +1 -1
  85. package/dist/machine/events/index.js +1 -1
  86. package/dist/machine/events/tokenSelect.js +1 -1
  87. package/dist/machine/events/validateInputAndMoveTo.js +1 -1
  88. package/dist/machine/events/validateInputs.js +1 -1
  89. package/dist/machine/index.js +1 -1
  90. package/dist/machine/snap.js +1 -1
  91. package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
  92. package/dist/machine/subscriptions/index.js +1 -1
  93. package/dist/styles.css +1 -1
  94. package/dist/theme/ThemeProvider.js +7 -24
  95. package/dist/theme/ThemeProvider.js.map +1 -1
  96. package/dist/types/config.d.ts +1 -0
  97. package/dist/types/localisation.d.ts +1 -1
  98. package/dist/utils/intents/signers/near.js +1 -1
  99. package/dist/utils/intents/signers/privy.js +1 -1
  100. package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
  101. package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +11 -12
  102. package/dist/widgets/WidgetDeposit/WidgetDepositContent.js.map +1 -1
  103. package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
  104. package/dist/widgets/WidgetSwap/WidgetSwapContent.js +27 -26
  105. package/dist/widgets/WidgetSwap/WidgetSwapContent.js.map +1 -1
  106. package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
  107. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +5 -6
  108. package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js.map +1 -1
  109. package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
  110. package/package.json +2 -1
  111. package/src/components/BlockingError.tsx +7 -4
  112. package/src/components/CloseButton.tsx +1 -1
  113. package/src/features/DepositMethodSwitcher.tsx +5 -17
  114. package/src/features/ExternalDeposit.tsx +6 -6
  115. package/src/features/SuccessScreen/SummaryItem.tsx +2 -2
  116. package/src/features/SuccessScreen/index.tsx +5 -3
  117. package/src/features/SwapQuote/SwapQuote.tsx +1 -1
  118. package/src/features/WalletCompatibilityCheck/WalletCompatibilityModal.tsx +3 -0
  119. package/src/features/WalletCompatibilityCheck/index.tsx +4 -8
  120. package/src/hooks/useIsCompatibilityCheckRequired.ts +1 -1
  121. package/src/hooks/useToggleTheme.ts +19 -8
  122. package/src/theme/ThemeProvider.tsx +33 -14
  123. package/src/types/config.ts +1 -0
  124. package/src/types/localisation.ts +1 -0
  125. package/src/widgets/WidgetDeposit/WidgetDepositContent.tsx +3 -3
  126. package/src/widgets/WidgetSwap/WidgetSwapContent.tsx +5 -3
  127. package/src/widgets/WidgetWithdraw/WidgetWithdrawContent.tsx +3 -3
  128. package/dist/config-1EcDCy24.js +0 -2628
  129. package/dist/config-1EcDCy24.js.map +0 -1
  130. package/dist/features/SuccessScreen/CloseButton.d.ts +0 -5
  131. package/dist/features/SuccessScreen/CloseButton.js +0 -15
  132. package/dist/features/SuccessScreen/CloseButton.js.map +0 -1
  133. package/src/features/SuccessScreen/CloseButton.tsx +0 -14
@@ -1,2628 +0,0 @@
1
- import { p as Je } from "./index-xuotMAFm.js";
2
- import { jsx as c, jsxs as k, Fragment as Rt } from "react/jsx-runtime";
3
- import Dt from "i18next";
4
- import { deepClone as me } from "valtio/utils";
5
- import { snapshot as Se, useSnapshot as oe, proxy as et } from "valtio";
6
- import { HelmetProvider as Ct, Helmet as vt } from "react-helmet-async";
7
- import { memo as Ot, useEffect as R, useMemo as x, useRef as z, useCallback as fe, useState as se, useId as xt, Fragment as Ft, useContext as Lt, createContext as Bt } from "react";
8
- import { useQuery as Ae, useInfiniteQuery as qt, useQueryClient as Ut, QueryClient as Pt, QueryClientProvider as Wt } from "@tanstack/react-query";
9
- import { Trans as Mt, I18nextProvider as Vt } from "react-i18next";
10
- import { useTypedTranslation as H, initLocalisation as Qt } from "./localisation.js";
11
- import { logger as b } from "./logger.js";
12
- import { getTonTokenBalance as $t } from "./utils/ton/getTonTokenBalance.js";
13
- import { getSolanaTokenBalance as Kt } from "./utils/solana/getSolanaTokenBalance.js";
14
- import { useWalletAddressForToken as tt } from "./hooks/useWalletAddressForToken.js";
15
- import "@headlessui/react";
16
- import "framer-motion";
17
- import "lucide-react";
18
- import { cn as j } from "./utils/cn.js";
19
- import { OneClickService as Ht, QuoteRequest as U, GetExecutionStatusResponse as ee } from "@defuse-protocol/one-click-sdk-typescript";
20
- import { CHAINS_LIST as _e, DEFAULT_CHAIN_ICON as Gt, DEFAULT_CHAINS_ORDER as nt, CHAIN_POA_MAP as rt, POA_EVM_CHAIN_ID as st, CHAIN_BASE_TOKENS as jt, EVM_CHAIN_IDS_MAP as pe, CHAIN_IDS_MAP as Yt, EVM_CHAINS as zt } from "./constants/chains.js";
21
- import "use-debounce";
22
- import { derive as Zt } from "derive-valtio";
23
- import { getIsNativeNearDeposit as Xt } from "./machine/computed/getIsNativeNearDeposit.js";
24
- import { getIsDirectTokenOnNearDeposit as Jt } from "./machine/computed/getIsDirectTokenOnNearDeposit.js";
25
- import "ethers";
26
- import { moveTo as O, machine as Z } from "./machine/machine.js";
27
- import en from "lodash.once";
28
- import { guardStates as C } from "./machine/guards/index.js";
29
- import { parse as tn } from "./ext/alchemy/parse.js";
30
- import { createLoader as nn } from "./ext/alchemy/load.js";
31
- import { isAlchemySupportedChain as rn } from "./ext/alchemy/types.js";
32
- import { fireEvent as p } from "./machine/events/utils/fireEvent.js";
33
- import { NATIVE_NEAR_DUMB_ASSET_ID as Q, TOKENS_DATA as Ne, WNEAR_ASSET_ID as Te } from "./constants/tokens.js";
34
- import { isValidChain as sn } from "./utils/checkers/isValidChain.js";
35
- import { useWalletBalance as Ee } from "./hooks/useWalletBalance.js";
36
- import { getIntentsAccountId as te } from "./utils/intents/getIntentsAccountId.js";
37
- import { getIntentsBalances as an } from "./utils/intents/getIntentsBalance.js";
38
- import { notReachable as be } from "./utils/notReachable.js";
39
- import { getTokenBalanceKey as K } from "./utils/intents/getTokenBalanceKey.js";
40
- import { isDryQuote as ye } from "./machine/guards/checks/isDryQuote.js";
41
- import { snakeCase as at } from "change-case";
42
- import on, { CanceledError as ot, AxiosError as it } from "axios";
43
- import { oneClickApi as he, bridgeApi as ct } from "./network.js";
44
- import { formatBigToHuman as Y } from "./utils/formatters/formatBigToHuman.js";
45
- import { getDryQuoteAddress as qe } from "./utils/getDryQuoteAddress.js";
46
- import { isEvmChain as V } from "./utils/evm/isEvmChain.js";
47
- import { checkNearAccountExists as cn } from "./utils/near/checkNearAccountExists.js";
48
- import { isNotEmptyAmount as ne } from "./utils/checkers/isNotEmptyAmount.js";
49
- import { isValidBigint as lt } from "./utils/checkers/isValidBigint.js";
50
- import { isNearAddress as dt } from "./utils/near/isNearAddress.js";
51
- import { isBalanceSufficient as Re } from "./machine/guards/checks/isBalanceSufficient.js";
52
- import { isQuoteError as De, isTransferError as Ce, isAsyncSendAddressValidationError as ln } from "./machine/errors.js";
53
- import { isSolanaAddress as ut } from "./utils/solana/isSolanaAddress.js";
54
- import { isEvmAddress as mt } from "./utils/evm/isEvmAddress.js";
55
- import { getMainTokenByChain as dn } from "./utils/tokens/getMainTokenByChain.js";
56
- import { getDefaultIntentsToken as un } from "./utils/tokens/getDefaultIntentsToken.js";
57
- import { getTokenWithHighBalance as mn } from "./utils/tokens/getTokenWithHighBalance.js";
58
- import { isQuoteIdle as fn } from "./machine/subscriptions/checkers/isQuoteIdle.js";
59
- import { isInputChanged as pn } from "./machine/subscriptions/checkers/isInputChanged.js";
60
- import { isErrorChanged as Tn } from "./machine/subscriptions/checkers/isErrorChanged.js";
61
- import { isOnlyErrorChanged as hn } from "./machine/subscriptions/checkers/isOnlyErrorChanged.js";
62
- import { isValidInitialState as gn } from "./machine/subscriptions/checkers/isValidInitialState.js";
63
- import { isWalletDisconnected as In } from "./machine/subscriptions/checkers/isWalletDisconnected.js";
64
- import { isSendAddressForbidden as wn } from "./machine/subscriptions/checkers/isSendAddressForbidden.js";
65
- import { isAmountChangedFromQuote as kn } from "./machine/subscriptions/checkers/isAmountChangedFromQuote.js";
66
- import { reset as Sn } from "./machine/events/reset.js";
67
- import { tokenSelectRotate as ge } from "./machine/events/tokenSelectRotate.js";
68
- import { errorSet as An } from "./machine/events/errorSet.js";
69
- import { quoteSet as _n } from "./machine/events/quoteSet.js";
70
- import { addressSet as Nn } from "./machine/events/addressSet.js";
71
- import { tokenSetAmount as En } from "./machine/events/tokenSetAmount.js";
72
- import { quoteSetStatus as bn } from "./machine/events/quoteSetStatus.js";
73
- import { depositTypeSet as yn } from "./machine/events/depositTypeSet.js";
74
- import { externalDepositTxSet as Rn } from "./machine/events/externalDepositTxSet.js";
75
- import { setInputsValidating as Dn } from "./machine/events/setInputsValidating.js";
76
- import { walletAddressSet as Cn } from "./machine/events/walletAddressSet.js";
77
- import { tokenSetBalance as vn } from "./machine/events/tokenSetBalance.js";
78
- import { transferSetStatus as On } from "./machine/events/transferSetStatus.js";
79
- import { getUsdTradeDelta as xn } from "./machine/computed/getUsdTradeDelta.js";
80
- import { getIsDirectNonNearWithdrawal as Fn } from "./machine/computed/getIsDirectNonNearWithdrawal.js";
81
- import { getIsDirectTokenOnNearTransfer as Ln } from "./machine/computed/getIsDirectTokenOnNearTransfer.js";
82
- import { getIsDirectNearTokenWithdrawal as Bn } from "./machine/computed/getIsDirectNearTokenWithdrawal.js";
83
- import { getIsSameAssetDiffChainWithdrawal as qn } from "./machine/computed/getIsSameAssetDiffChainWithdrawal.js";
84
- import "viem";
85
- import { Button as A } from "./components/Button.js";
86
- import { TinyNumber as ve } from "./components/TinyNumber.js";
87
- import { ErrorMessage as $ } from "./components/ErrorMessage.js";
88
- import { FT_DEPOSIT_GAS as Ue, FT_TRANSFER_GAS as Pe } from "./utils/near/config.js";
89
- import { a as Oe } from "./index-DEq3oXQF.js";
90
- import { z as re } from "zod";
91
- import { decodeQueryResult as Un } from "./utils/near/decodeQueryResult.js";
92
- import { nearRpcClient as Pn } from "./utils/near/rpc.js";
93
- import { getNearNep141MinStorageBalance as Wn } from "./utils/near/getNearNep141MinStorageBalance.js";
94
- import { INTENTS_CONTRACT as Ie } from "./constants/intents.js";
95
- import { isEth as Mn } from "./utils/evm/isEth.js";
96
- import { useMakeEvmTransfer as Vn } from "./hooks/useMakeEvmTransfer.js";
97
- import { useMakeSolanaTransfer as Qn } from "./hooks/useMakeSolanaTransfer.js";
98
- import { isUserDeniedSigning as we } from "./utils/checkers/isUserDeniedSigning.js";
99
- import { createIntentSignerNEP413 as $n, BridgeSDK as Kn, createNearWithdrawalRoute as Hn, createInternalTransferRoute as Gn } from "@defuse-protocol/bridge-sdk";
100
- import { generateRandomBytes as jn } from "./utils/near/getRandomBytes.js";
101
- import { IntentSignerSolana as Yn } from "./utils/intents/signers/solana.js";
102
- import { localStorageTyped as We } from "./utils/localstorage.js";
103
- import { queryContract as zn } from "./utils/near/queryContract.js";
104
- import { utils as Me } from "@defuse-protocol/internal-utils";
105
- import { getTransactionLink as Zn } from "./utils/formatters/getTransactionLink.js";
106
- import { switchEthereumChain as Xn } from "./utils/evm/switchEthereumChain.js";
107
- import "copy-text-to-clipboard";
108
- import { SwapQuoteSkeleton as ft } from "./features/SwapQuote/SwapQuoteSkeleton.js";
109
- import { Notes as le } from "./components/Notes.js";
110
- import { Accordion as Jn } from "./components/Accordion.js";
111
- import { formatUsdAmount as Ve } from "./utils/formatters/formatUsdAmount.js";
112
- import { formatTinyNumber as er } from "./utils/formatters/formatTinyNumber.js";
113
- import tr from "clsx";
114
- import { Skeleton as nr } from "./components/Skeleton.js";
115
- import { getBalancePortion as rr } from "./features/TokenInput/utils/getBalancePortion.js";
116
- import { getUsdDisplayAmount as sr } from "./features/TokenInput/utils/getUsdDisplayAmount.js";
117
- import { TokenInputHeading as pt } from "./features/TokenInput/TokenInputHeading.js";
118
- import { noop as ar } from "./utils/noop.js";
119
- import { Card as Tt } from "./components/Card.js";
120
- import { Badge as Qe } from "./components/Badge.js";
121
- import { TokenIcon as ht } from "./components/TokenIcon.js";
122
- import { InputAmount as or } from "./components/InputAmount.js";
123
- import { TokenInputSkeleton as ir } from "./features/TokenInput/TokenInputSkeleton.js";
124
- import { getUsdDisplayBalance as cr } from "./utils/formatters/getUsdDisplayBalance.js";
125
- import { VList as lr } from "virtua";
126
- import { TokensListPlaceholder as ke } from "./features/TokensList/TokensListPlaceholder.js";
127
- import { Hr as dr } from "./components/Hr.js";
128
- import { createTokenSorter as ur } from "./utils/tokens/sort.js";
129
- import { createFilterByIntents as $e } from "./utils/tokens/filterByIntents.js";
130
- import { createFilterBySearch as mr } from "./utils/tokens/filterBySearchString.js";
131
- import { createFilterBySelectedChain as fr } from "./utils/tokens/filterBySelectedChain.js";
132
- import "bs58";
133
- import "viem/chains";
134
- import "browser-or-node";
135
- import "qrcode.react";
136
- import { ThemeProvider as pr } from "./theme/ThemeProvider.js";
137
- import "./features/WalletCompatibilityCheck/WalletCompatibilityModal.js";
138
- import { DEFAULT_RPCS as Tr } from "./rpcs.js";
139
- import { useAddClassToPortal as hr } from "./hooks/useAddClassToPortal.js";
140
- import { ErrorBoundary as gr } from "react-error-boundary";
141
- import { isEvmToken as Ir } from "./utils/evm/isEvmToken.js";
142
- import { isEvmBaseToken as wr } from "./utils/evm/isEvmBaseToken.js";
143
- import { getEvmMainTokenBalance as kr } from "./utils/evm/getEvmMainTokenBalance.js";
144
- import { getNativeNearBalance as Sr } from "./utils/near/getNativeNearBalance.js";
145
- import { getNearTokenBalance as Ar } from "./utils/near/getNearTokenBalance.js";
146
- import { getEvmTokenBalance as _r } from "./utils/evm/getEvmTokenBalance.js";
147
- function Nr({ rpcs: e, token: t, connectedWallets: s }) {
148
- const { walletSupportedChains: r, tonCenterApiKey: n, alchemyApiKey: a } = E(), { walletAddress: l } = tt(s, t);
149
- return Ae({
150
- retry: 2,
151
- enabled: !!l && Object.keys(e).includes(t.blockchain),
152
- queryKey: ["tokenBalance", t.assetId, s],
153
- queryFn: async () => {
154
- if (!l)
155
- return null;
156
- if (t.blockchain === "near" && r.includes(t.blockchain))
157
- return !e.near || e.near.length === 0 ? null : t.assetId === Q ? Sr(l, e.near) : Ar(t, l, e.near);
158
- if (!r.includes("eth") && V(t.blockchain))
159
- return null;
160
- if (V(t.blockchain) && wr(t)) {
161
- const i = e[t.blockchain] ?? [];
162
- return i.length > 0 ? kr(l, i[0]) : null;
163
- }
164
- if (Ir(t) || V(t.blockchain)) {
165
- const i = e[t.blockchain] ?? [];
166
- return i.length > 0 ? _r(t, l, i[0]) : null;
167
- }
168
- return t.blockchain === "ton" ? $t(t, l, n) : t.blockchain === "sol" && r.includes(t.blockchain) ? Kt(t, l, a) : (b.warn(
169
- `Failed to fetch token balance for ${t.symbol} on ${t.blockchain}`
170
- ), null);
171
- }
172
- });
173
- }
174
- const Er = ({
175
- rpcs: e,
176
- token: t,
177
- onBalancesLoaded: s
178
- }) => (R(() => {
179
- t.isIntent || !Object.keys(e).includes(t.blockchain) || s({ [t.assetId]: "0" });
180
- }, [t.assetId]), null), gt = Ot(
181
- ({ rpcs: e, token: t, connectedWallets: s, onBalancesLoaded: r }) => {
182
- const { data: n } = Nr({
183
- rpcs: e,
184
- token: t,
185
- connectedWallets: s
186
- });
187
- return R(() => {
188
- !t.isIntent && n != null && r({ [t.assetId]: n });
189
- }, [t, n, r]), null;
190
- },
191
- (e, t) => e.token.assetId === t.token.assetId && e.connectedWallets === t.connectedWallets
192
- );
193
- gt.displayName = "TokenBalanceLoader";
194
- const Ke = Object.assign(gt, {
195
- Zero: Er
196
- }), br = (e) => {
197
- const t = e.toLowerCase();
198
- return Ne[t]?.icon ?? "";
199
- }, He = (e) => _e[e].icon ?? Gt, yr = (e) => `${e?.charAt(0).toUpperCase()}${e?.slice(1)}`, Rr = (e) => Ne[e]?.name ?? e, P = (e) => {
200
- const {
201
- showIntentTokens: t,
202
- allowedTokensList: s,
203
- allowedSourceTokensList: r,
204
- allowedTargetTokensList: n,
205
- filterTokens: a,
206
- fetchSourceTokens: l,
207
- fetchTargetTokens: i
208
- } = E(), { data: d, ...u } = Ae({
209
- queryKey: ["tokens", e].filter(Boolean),
210
- queryFn: async () => e === "source" && l ? l() : e === "target" && i ? i() : Ht.getTokens()
211
- }), o = x(() => {
212
- if (!d)
213
- return [];
214
- const m = d.map((f) => {
215
- const I = f.blockchain.toLowerCase();
216
- return !sn(I) || s && !s.includes(f.assetId) || e === "source" && r && !r.includes(f.assetId) || e === "target" && n && !n.includes(f.assetId) ? null : {
217
- assetId: f.assetId,
218
- symbol: f.symbol,
219
- decimals: f.decimals,
220
- price: f.price,
221
- blockchain: I,
222
- isIntent: !1,
223
- icon: f.icon ?? br(f.symbol),
224
- name: Rr(f.symbol),
225
- chainIcon: He(I),
226
- chainName: _e[f.blockchain]?.label ?? yr(f.blockchain),
227
- contractAddress: f.contractAddress
228
- };
229
- }).filter((f) => !!f).filter(a ?? (() => !0)), T = m.filter(
230
- (f) => f.symbol.toLowerCase() !== "wnear"
231
- ), h = m.find((f) => f.symbol.toLowerCase() === "wnear");
232
- return h && T.push({
233
- name: "NEAR",
234
- symbol: "NEAR",
235
- chainName: "Near",
236
- blockchain: "near",
237
- assetId: Q,
238
- chainIcon: He("near"),
239
- icon: Ne.near?.icon ?? "",
240
- price: h?.price ?? 0,
241
- contractAddress: h?.contractAddress,
242
- isIntent: !1,
243
- decimals: 24
244
- }), t ? [
245
- ...T,
246
- // add intents tokens to the full list
247
- ...m.map(
248
- (f) => f.symbol.toLowerCase() === "wnear" ? { ...f, symbol: "NEAR", name: "NEAR", isIntent: !0 } : { ...f, isIntent: !0 }
249
- )
250
- ] : T;
251
- }, [d, t, a]);
252
- return {
253
- ...u,
254
- tokens: o
255
- };
256
- }, Dr = () => {
257
- const { tokens: e } = P(), { tokens: t } = P("source"), { tokens: s } = P("target");
258
- return { tokens: x(() => {
259
- const n = {};
260
- return [
261
- ...e,
262
- ...t || [],
263
- ...s || []
264
- ].forEach((a) => {
265
- const l = `${a.assetId}-${a.isIntent}`;
266
- n[l] = a;
267
- }), Object.values(n);
268
- }, [e, t, s]) };
269
- }, de = [
270
- { eth: ["ETH", "USDT", "USDC", "AURORA"] },
271
- { near: ["USDT", "USDC", "AURORA"] },
272
- { arb: ["ARB", "ETH", "USDT", "USDC"] },
273
- { btc: ["BTC"] }
274
- ], Cr = (e) => [...e].sort((t, s) => {
275
- const r = de.findIndex(
276
- (d) => Object.keys(d)[0] === t.blockchain
277
- ), n = de.findIndex(
278
- (d) => Object.keys(d)[0] === s.blockchain
279
- );
280
- if (r !== n)
281
- return r === -1 ? 1 : n === -1 ? -1 : r - n;
282
- const a = de[r]?.[t.blockchain] ?? [], l = a.indexOf(t.symbol), i = a.indexOf(s.symbol);
283
- return l === -1 && i === -1 ? 0 : l === -1 ? 1 : i === -1 ? -1 : l - i;
284
- }), vr = ({ rpcs: e, connectedWallets: t }) => {
285
- const { tokens: s } = Dr(), { walletSupportedChains: r } = E(), { setWalletBalance: n } = Ee(t);
286
- return x(() => Cr(s), [s]).map((l) => r.includes(l.blockchain) ? /* @__PURE__ */ c(
287
- Ke,
288
- {
289
- rpcs: e,
290
- token: l,
291
- connectedWallets: t,
292
- onBalancesLoaded: (i) => n(t, i)
293
- },
294
- K(l)
295
- ) : /* @__PURE__ */ c(
296
- Ke.Zero,
297
- {
298
- rpcs: e,
299
- token: l,
300
- onBalancesLoaded: (i) => n(t, i)
301
- },
302
- K(l)
303
- ));
304
- };
305
- function Or(e, t) {
306
- const s = Array.from(
307
- /* @__PURE__ */ new Set([...t ?? [], ...nt])
308
- ), r = new Map(s.map((n, a) => [n, a]));
309
- return [...e].sort((n, a) => {
310
- const l = r.has(n.id) ? r.get(n.id) : 1 / 0, i = r.has(a.id) ? r.get(a.id) : 1 / 0;
311
- return l !== i ? l - i : n.id.localeCompare(a.id, void 0, { sensitivity: "base" });
312
- });
313
- }
314
- const xr = (e) => {
315
- const {
316
- chainsOrder: t,
317
- allowedChainsList: s,
318
- allowedSourceChainsList: r,
319
- allowedTargetChainsList: n
320
- } = E(), { tokens: a } = P();
321
- return x(() => {
322
- const l = Array.from(
323
- new Set(a.map((i) => _e[i.blockchain]))
324
- ).filter((i) => !(s && !s.includes(i.id) || e === "source" && r && !r.includes(i.id) || e === "target" && n && !n.includes(i.id)));
325
- return Or(l, t);
326
- }, [a, t, s]);
327
- }, Ge = 3, It = ({
328
- connectedWallets: e,
329
- alchemyApiKey: t,
330
- ...s
331
- }) => {
332
- const { ctx: r } = N(), { tokens: n } = P(), { walletSupportedChains: a } = E(), { setWalletBalance: l } = Ee(e), i = s.isEnabled && !!Object.values(e).length && a.length > 0, d = qt({
333
- initialPageParam: null,
334
- enabled: !!i && !!t,
335
- queryKey: ["walletTokensBalance", e],
336
- queryFn: async ({ pageParam: o }) => nn({ alchemyApiKey: t })({
337
- pageParam: o ? `${o}` : null,
338
- connectedWallets: e,
339
- walletSupportedChains: a
340
- }),
341
- getNextPageParam: (o, m) => {
342
- if (o.pageKey && !(m.length >= Ge))
343
- return o.pageKey;
344
- }
345
- });
346
- R(() => {
347
- i && d.data && d.hasNextPage && d.data.pages.length < Ge && !d.isFetchingNextPage && d.fetchNextPage();
348
- }, [i, d]);
349
- const u = x(() => {
350
- if (!d.data?.pages)
351
- return {};
352
- const o = tn(
353
- n,
354
- d.data.pages.flatMap((m) => m.data)
355
- );
356
- return n.forEach((m) => {
357
- rn(m.blockchain) && !(m.assetId in o) && (o[m.assetId] = "0");
358
- }), o;
359
- }, [d.data, n]);
360
- return R(() => {
361
- C(r, ["initial_wallet"]) && (l(e, u), r.sourceToken && Object.keys(u).includes(r.sourceToken.assetId) && p("tokenSetBalance", u[r.sourceToken.assetId]));
362
- }, [u]), {
363
- status: d.status,
364
- refetch: d.refetch,
365
- balances: u
366
- };
367
- }, ie = () => {
368
- const { intentsAccountType: e } = E(), {
369
- ctx: { walletAddress: t }
370
- } = N(), { tokens: s } = P(), r = s.filter((i) => i.isIntent).map((i) => i.assetId), n = te({
371
- walletAddress: t,
372
- addressType: e
373
- }), a = Ae({
374
- enabled: !!t && !!n && s.length > 0,
375
- queryKey: ["intentsBalances", n],
376
- queryFn: async () => n ? await an(n, r) : {}
377
- }), l = x(() => {
378
- switch (a.status) {
379
- case "error":
380
- return b.error("Unable to load intents balances:", a.error), {};
381
- case "success":
382
- return Object.fromEntries(
383
- Object.entries(a.data).map(([i, d]) => [
384
- `intent-${i}`,
385
- d
386
- ])
387
- );
388
- case "pending":
389
- return {};
390
- default:
391
- return be(a, { throwError: !1 }), {};
392
- }
393
- }, [a]) ?? {};
394
- return {
395
- ...a,
396
- intentBalances: l
397
- };
398
- }, Fr = ({
399
- isEnabled: e,
400
- alchemyApiKey: t
401
- }) => {
402
- const { connectedWallets: s } = E(), { ctx: r } = N(), n = Ut(), { refetch: a } = ie(), { refetch: l } = It({
403
- isEnabled: e,
404
- connectedWallets: s,
405
- alchemyApiKey: t ?? ""
406
- });
407
- R(() => {
408
- const i = C(r, ["transfer_success"]);
409
- !e || !i || (async () => (await a(), t && (await new Promise((d) => {
410
- setTimeout(d, 1e4);
411
- }), await l()), await n.invalidateQueries({ queryKey: ["tokenBalance"] })))();
412
- }, [r.state, e, t]);
413
- }, ce = () => {
414
- const { connectedWallets: e } = E(), { intentBalances: t } = ie(), { walletBalance: s } = Ee(e);
415
- return { mergedBalance: x(
416
- () => ({ ...s, ...t }),
417
- [s, t]
418
- ) };
419
- }, Lr = ({ isEnabled: e }) => {
420
- const { ctx: t } = N(), { mergedBalance: s } = ce();
421
- R(() => {
422
- if (!e)
423
- return;
424
- if (!t.sourceToken || !t.walletAddress) {
425
- p("tokenSetBalance", void 0);
426
- return;
427
- }
428
- const r = K(t.sourceToken);
429
- p("tokenSetBalance", s[r]);
430
- }, [s, t.sourceToken]);
431
- }, je = {
432
- // cbBTC (eth)
433
- "nep141:eth-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near": "nep141:nbtc.bridge.near",
434
- // cbBTC (base)
435
- "nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near": "nep141:nbtc.bridge.near",
436
- // wBTC (near)
437
- "nep141:2260fac5e5542a773aa44fbcfedf7c193bc2c599.factory.bridge.near": "nep141:nbtc.bridge.near",
438
- // xBTC (sol)
439
- "nep141:sol-91914f13d3b54f8126a2824d71632d4b078d7403.omft.near": "nep141:nbtc.bridge.near",
440
- // wETH (gnosis)
441
- "nep141:gnosis-0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1.omft.near": "nep141:eth.bridge.near",
442
- // NEAR (bsc)
443
- "nep245:v2_1.omni.hot.tg:56_SZzgw3HSudhZcTwPWUTi2RJB19t": "nep141:wrap.near",
444
- // BTC (near)
445
- "nep141:btc.omft.near": "nep141:nbtc.bridge.near"
446
- }, Br = ({
447
- isEnabled: e
448
- }) => {
449
- const { ctx: t } = N(), { tokens: s } = P();
450
- R(() => {
451
- if (!e)
452
- return;
453
- if (!t.sourceToken) {
454
- p("tokenSelect", { variant: "target", token: void 0 });
455
- return;
456
- }
457
- const { sourceToken: r } = t;
458
- if (t.sourceToken.assetId in je) {
459
- const i = s.find(
460
- (d) => d.isIntent && d.assetId === je[r.assetId]
461
- );
462
- p("tokenSelect", {
463
- variant: "target",
464
- token: i
465
- });
466
- return;
467
- }
468
- const n = s.find(
469
- (i) => i.isIntent && i.symbol === r.symbol && i.blockchain === "near"
470
- );
471
- if (n) {
472
- p("tokenSelect", { variant: "target", token: n });
473
- return;
474
- }
475
- const a = s.find(
476
- (i) => i.isIntent && i.assetId === r.assetId
477
- ), l = s.find(
478
- (i) => i.isIntent && i.symbol === "USDC" && i.blockchain === "near"
479
- );
480
- p("tokenSelect", {
481
- variant: "target",
482
- token: a ?? l
483
- });
484
- }, [s, t.sourceToken]);
485
- }, qr = ({ isEnabled: e }) => {
486
- const { connectedWallets: t } = E(), { ctx: s, state: r } = N(), { walletAddress: n } = tt(
487
- t,
488
- s.sourceToken
489
- );
490
- R(() => {
491
- if (!e)
492
- return;
493
- p("walletAddressSet", n), C(s, ["initial_dry", "initial_wallet"]) && (r === "initial_wallet" && !n ? O("initial_dry") : r === "initial_dry" && n && O("initial_wallet"));
494
- }, [e, n, s, r]);
495
- }, Ur = (e) => (["depositAddress"].forEach((t) => {
496
- if (!(t in e))
497
- return b.error(`Missing ${t} in quote response`), !1;
498
- }), !0), Pr = () => {
499
- const { ctx: e } = N(), {
500
- walletSupportedChains: t,
501
- intentsAccountType: s,
502
- appName: r,
503
- appFees: n,
504
- fetchQuote: a,
505
- slippageTolerance: l
506
- } = E(), i = ye(e), d = z(null), u = z(new AbortController()), o = x(() => async (T, h) => {
507
- const { signal: f } = u.current;
508
- return a ? a(T, {
509
- ...h,
510
- signal: f
511
- }) : (await he.post(
512
- "https://1click.chaindefuser.com/v0/quote",
513
- T,
514
- { signal: f }
515
- )).data.quote;
516
- }, [he]);
517
- return {
518
- make: async ({
519
- message: T,
520
- quoteType: h = "exact_in",
521
- options: f = {}
522
- } = {}) => {
523
- if (!C(e, [
524
- "input_valid_dry",
525
- "input_valid_external",
526
- "input_valid_internal",
527
- "quote_success_internal",
528
- "quote_success_external"
529
- ])) {
530
- const w = `Unable to run quote in current state ${e.state}`;
531
- throw b.error(`[WIDGET] ${w}`), new q({
532
- code: "QUOTE_INVALID_INITIAL",
533
- meta: { isDry: i, message: w }
534
- });
535
- }
536
- const S = te({
537
- addressType: s,
538
- walletAddress: i ? (
539
- // address on the target chain should be a dry quote recipient
540
- qe(e.targetToken.blockchain)
541
- ) : e.walletAddress ?? ""
542
- }), y = S && (e.sourceToken.isIntent || !t.includes(e.sourceToken.blockchain)), B = () => i ? qe(
543
- e.sourceToken.blockchain,
544
- e.sourceToken.isIntent
545
- ) : y ? S : e.walletAddress ?? "";
546
- if (!S) {
547
- const w = "No corresponding intents account to run a quote";
548
- throw b.error(`[WIDGET] ${w}`), new q({
549
- code: "QUOTE_INVALID_INITIAL",
550
- meta: { isDry: i, message: w }
551
- });
552
- }
553
- d.current && (u.current.abort("Abort previous quote (auto)"), u.current = new AbortController());
554
- let F;
555
- const L = {
556
- // Settings
557
- dry: i,
558
- slippageTolerance: l,
559
- deadline: new Date(Date.now() + 3600 * 1e3).toISOString(),
560
- // 1 hour
561
- swapType: h === "exact_out" ? U.swapType.EXACT_OUTPUT : U.swapType.EXACT_INPUT,
562
- // Target
563
- destinationAsset: e.targetToken.assetId === Q ? Te : e.targetToken.assetId,
564
- // Source
565
- originAsset: e.sourceToken.assetId === Q ? Te : e.sourceToken.assetId,
566
- amount: h === "exact_out" ? e.targetTokenAmount : e.sourceTokenAmount,
567
- // Experimental
568
- quoteWaitingTimeMs: 0
569
- };
570
- T && (L.customRecipientMsg = T), r && (L.referral = at(r)), n && (L.appFees = [...n]);
571
- try {
572
- e.sourceToken.isIntent && e.targetToken.isIntent && (d.current = o(
573
- {
574
- ...L,
575
- recipient: S,
576
- recipientType: U.recipientType.INTENTS,
577
- depositType: U.depositType.INTENTS,
578
- // Refund
579
- refundTo: S,
580
- refundType: U.refundType.INTENTS
581
- },
582
- f
583
- ), F = await d.current), d.current = o(
584
- {
585
- ...L,
586
- recipient: !e.targetToken.isIntent && e.sendAddress ? e.sendAddress : S,
587
- recipientType: e.targetToken.isIntent ? U.recipientType.INTENTS : U.recipientType.DESTINATION_CHAIN,
588
- depositType: e.sourceToken.isIntent ? U.depositType.INTENTS : U.depositType.ORIGIN_CHAIN,
589
- // Refund
590
- refundTo: B(),
591
- refundType: y ? U.refundType.INTENTS : U.refundType.ORIGIN_CHAIN
592
- },
593
- f
594
- ), F = await d.current;
595
- } catch (w) {
596
- if (w instanceof ot)
597
- return;
598
- b.error("Quote error: ", w);
599
- let v = w instanceof Error ? w.message : "";
600
- if (w instanceof it) {
601
- if (v = w.response?.data.message || v, v.includes("Amount is too low")) {
602
- const X = v.match(/\d+/), J = X ? X[0] : void 0;
603
- throw new q({
604
- code: "QUOTE_AMOUNT_IS_TOO_LOW",
605
- meta: {
606
- minAmount: (J && Y(J, e.sourceToken.decimals)) ?? "0"
607
- }
608
- });
609
- }
610
- throw v.includes("recipient is not valid") ? new q({
611
- code: "TOKEN_IS_NOT_SUPPORTED"
612
- }) : v.includes("Failed to get a deposit address") ? new q({
613
- code: "QUOTE_NO_ONE_TIME_ADDRESS"
614
- }) : w;
615
- }
616
- throw new q({
617
- code: "QUOTE_FAILED",
618
- meta: {
619
- message: v || "Failed to fetch quote. Please try again."
620
- }
621
- });
622
- }
623
- return i ? {
624
- dry: !0,
625
- ...F,
626
- deadline: void 0,
627
- depositAddress: void 0
628
- } : (Ur(F), {
629
- dry: !1,
630
- ...F,
631
- deadline: F.deadline,
632
- depositAddress: F.depositAddress
633
- });
634
- },
635
- cancel: () => {
636
- u.current.abort("Abort quote manually"), u.current = new AbortController();
637
- }
638
- };
639
- }, Wr = () => {
640
- const { ctx: e } = N(), { intentsAccountType: t } = E(), { isNativeNearDeposit: s } = G(), r = te({
641
- addressType: t,
642
- walletAddress: e.walletAddress ?? ""
643
- }), n = z(null), a = z(new AbortController()), l = x(() => async (d) => ct.post(
644
- "",
645
- {
646
- id: 1,
647
- jsonrpc: "2.0",
648
- method: "deposit_address",
649
- params: [
650
- {
651
- account_id: d.accountId,
652
- chain: d.chain
653
- }
654
- ]
655
- },
656
- {
657
- signal: a.current.signal
658
- }
659
- ), [he]);
660
- return {
661
- make: async () => {
662
- if (!C(e, [
663
- "input_valid_dry",
664
- "input_valid_external",
665
- "input_valid_internal",
666
- "quote_success_internal",
667
- "quote_success_external"
668
- ])) {
669
- const o = `Unable to run quote in current state ${e.state}`;
670
- throw b.error(`[WIDGET] ${o}`), new q({
671
- code: "QUOTE_INVALID_INITIAL",
672
- meta: { isDry: !1, message: o }
673
- });
674
- }
675
- if (s && !e.isDepositFromExternalWallet || !s && e.sourceToken.assetId !== e.targetToken.assetId)
676
- throw new q({
677
- code: "QUOTE_INVALID_INITIAL",
678
- meta: {
679
- isDry: !1,
680
- message: "Asset IDs are not the same use 1Click Quote instead of POA"
681
- }
682
- });
683
- if (e.sourceToken.isIntent)
684
- throw new q({
685
- code: "QUOTE_INVALID_INITIAL",
686
- meta: {
687
- isDry: !1,
688
- message: "For withdrawals use withdrawal SDK instead of POA"
689
- }
690
- });
691
- if (!e.isDepositFromExternalWallet && e.sourceToken.blockchain === "near")
692
- throw new q({
693
- code: "QUOTE_INVALID_INITIAL",
694
- meta: {
695
- isDry: !1,
696
- message: "Use transfer call. POA for tokens on Near only used for external deposits"
697
- }
698
- });
699
- if (!r) {
700
- const o = "No corresponding intents account to run a quote";
701
- throw b.error(`[WIDGET] ${o}`), new q({
702
- code: "QUOTE_INVALID_INITIAL",
703
- meta: { isDry: !1, message: o }
704
- });
705
- }
706
- n.current && (a.current.abort("Abort previous quote (auto)"), a.current = new AbortController());
707
- let u = rt[e.targetToken.blockchain];
708
- if (!u)
709
- if (V(e.targetToken.blockchain))
710
- u = st;
711
- else
712
- throw new q({
713
- code: "QUOTE_INVALID_INITIAL",
714
- meta: { isDry: !1, message: "Chain is not supported by POA" }
715
- });
716
- try {
717
- return n.current = l({
718
- chain: u,
719
- accountId: r
720
- }), {
721
- depositAddress: (await n.current).data.result.address,
722
- amountIn: e.sourceTokenAmount,
723
- amountOut: e.targetTokenAmount,
724
- amountInUsd: `${parseFloat(
725
- Y(e.sourceTokenAmount, e.sourceToken.decimals)
726
- ) * e.sourceToken.price}`,
727
- amountOutUsd: `${parseFloat(
728
- Y(e.targetTokenAmount, e.targetToken.decimals)
729
- ) * e.targetToken.price}`,
730
- amountOutFormatted: Y(
731
- e.targetTokenAmount,
732
- e.targetToken.decimals
733
- ),
734
- // dummy values to match quote type
735
- deadline: new Date(Date.now() + 3600 * 1e3).toISOString(),
736
- timeEstimate: 0,
737
- dry: !1
738
- };
739
- } catch (o) {
740
- if (o instanceof ot)
741
- return;
742
- if (b.error(o), o instanceof it) {
743
- const m = o.response?.data.message || o.message;
744
- throw new q({
745
- code: "QUOTE_FAILED",
746
- meta: {
747
- message: m ?? "Failed to fetch quote. Please try again."
748
- }
749
- });
750
- }
751
- }
752
- },
753
- cancel: () => {
754
- a.current.abort("Abort quote manually"), a.current = new AbortController();
755
- }
756
- };
757
- }, Ye = (e) => {
758
- p("errorSet", e), p("quoteSet", void 0), p("quoteSetStatus", "idle"), p("transferSetStatus", { status: "idle" });
759
- }, ze = async (e) => {
760
- if (!e.sendAddress)
761
- return;
762
- let t = !1;
763
- try {
764
- p("setInputsValidating", !0), t = await cn(e.sendAddress);
765
- } catch {
766
- Ye({
767
- code: "SEND_ADDRESS_IS_NOT_VERIFIED",
768
- meta: { address: e.sendAddress, chain: "near" }
769
- }), p("setInputsValidating", !1), O("initial_wallet");
770
- return;
771
- }
772
- if (p("setInputsValidating", !1), !t) {
773
- Ye({
774
- code: "SEND_ADDRESS_IS_NOT_FOUND",
775
- meta: { address: e.sendAddress, chain: "near" }
776
- }), O("initial_wallet");
777
- return;
778
- }
779
- e.error ? ln(e.error) && (p("errorSet", null), O("input_valid_external")) : O("input_valid_external");
780
- }, wt = (e) => {
781
- const t = C(e, ["initial_dry"]), s = C(e, ["input_valid_dry"]);
782
- if (!t && !s)
783
- return;
784
- let r;
785
- return t && (e.sourceToken ? e.targetToken ? ne(e.sourceTokenAmount) ? e.walletAddress && !Re(e) && (r = { code: "SOURCE_BALANCE_INSUFFICIENT" }) : r = { code: "SOURCE_TOKEN_AMOUNT_IS_EMPTY" } : r = { code: "TARGET_TOKEN_IS_EMPTY" } : r = { code: "SOURCE_TOKEN_IS_EMPTY" }), !s && r ? p("errorSet", r) : e.error && !De(e.error) && !Ce(e.error) && p("errorSet", null), s && r?.code === "SOURCE_BALANCE_INSUFFICIENT" && p("errorSet", r), s;
786
- }, kt = (e) => {
787
- const t = C(e, ["initial_wallet"]), s = C(e, ["input_valid_external"]);
788
- if (!t && !s)
789
- return;
790
- const r = e.sourceTokenBalance;
791
- let n;
792
- return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? n = { code: "SOURCE_TOKEN_IS_INTENT" } : ne(e.sourceTokenAmount) ? e.sendAddress ? e.targetToken.blockchain === "near" ? dt(e.sendAddress) ? ze(e) : n = {
793
- code: "SEND_ADDRESS_IS_INVALID",
794
- meta: { address: e.sendAddress, chain: "near" }
795
- } : e.isDepositFromExternalWallet || (!r || !lt(r) ? n = { code: "INVALID_SOURCE_BALANCE" } : Re(e) || (n = { code: "SOURCE_BALANCE_INSUFFICIENT" })) : n = { code: "SEND_ADDRESS_IS_EMPTY" } : n = { code: "SOURCE_TOKEN_AMOUNT_IS_EMPTY" } : n = { code: "TARGET_TOKEN_IS_EMPTY" } : n = { code: "SOURCE_TOKEN_IS_EMPTY" }), s && e.targetToken.blockchain === "near" && ze(e), !s && n ? p("errorSet", n) : e.error && !De(e.error) && !Ce(e.error) && p("errorSet", null), s;
796
- }, St = (e) => {
797
- const t = C(e, ["initial_wallet"]), s = C(e, ["input_valid_internal"]);
798
- if (!t && !s)
799
- return;
800
- const r = e.sourceTokenBalance;
801
- let n;
802
- return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? ne(e.sourceTokenAmount) ? e.isDepositFromExternalWallet || (!r || !lt(r) ? n = { code: "INVALID_SOURCE_BALANCE" } : Re(e) || (n = { code: "SOURCE_BALANCE_INSUFFICIENT" })) : n = { code: "SOURCE_TOKEN_AMOUNT_IS_EMPTY" } : n = { code: "SOURCE_TOKEN_NOT_INTENT" } : n = { code: "TARGET_TOKEN_IS_EMPTY" } : n = { code: "SOURCE_TOKEN_IS_EMPTY" }), !s && n ? p("errorSet", n) : e.error && !De(e.error) && !Ce(e.error) && p("errorSet", null), s;
803
- }, At = (e) => {
804
- const t = ye(e), s = !t && e.targetToken?.isIntent === !0, r = !t && e.targetToken?.isIntent === !1;
805
- if (t) {
806
- const n = wt(e);
807
- return O(n ? "input_valid_dry" : "initial_dry");
808
- }
809
- r && kt(e) ? O("input_valid_external") : s && St(e) ? O("input_valid_internal") : O("initial_wallet");
810
- }, Mr = ({
811
- isEnabled: e,
812
- message: t,
813
- type: s = "exact_in",
814
- refetchQuoteInterval: r
815
- }) => {
816
- const { ctx: n } = N(), {
817
- isNativeNearDeposit: a,
818
- isDirectNonNearWithdrawal: l,
819
- isDirectTokenOnNearDeposit: i,
820
- isDirectNearTokenWithdrawal: d,
821
- isDirectTokenOnNearTransfer: u,
822
- isSameAssetDiffChainWithdrawal: o
823
- } = G(), m = ye(n), T = e && !n.areInputsValidating && (o || (i || a) && n.isDepositFromExternalWallet || !d && !l && !i && !u), { make: h, cancel: f } = Pr(), { make: I, cancel: S } = Wr(), y = z(null), B = () => {
824
- f(), S();
825
- };
826
- R(() => {
827
- const L = C(n, ["input_valid_dry"]), w = C(n, ["input_valid_external"]), v = C(n, ["input_valid_internal"]);
828
- (m && !L || !m && n.targetToken?.isIntent && !v || !m && !n.targetToken?.isIntent && !w || n.areInputsValidating) && B();
829
- }, [B, m, n]);
830
- const F = fe(
831
- async (L) => {
832
- try {
833
- let w;
834
- if (n.sourceToken?.assetId === n.targetToken?.assetId || a && n.isDepositFromExternalWallet) {
835
- if (m)
836
- return;
837
- p("quoteSetStatus", "pending"), w = await I();
838
- } else
839
- p("quoteSetStatus", "pending"), w = await h({ message: t, quoteType: s, options: L });
840
- if (!w)
841
- return;
842
- if (p("quoteSetStatus", "success"), p("quoteSet", w), !m && n.error?.code !== "SOURCE_BALANCE_INSUFFICIENT" && p("errorSet", null), p("tokenSetAmount", {
843
- variant: "target",
844
- amount: w.amountOut
845
- }), n.state === "input_valid_dry") {
846
- O("quote_success_dry");
847
- return;
848
- }
849
- n.targetToken?.isIntent ? O("quote_success_internal") : O("quote_success_external");
850
- } catch (w) {
851
- if (w instanceof q) {
852
- if (w.data.code === "QUOTE_INVALID_INITIAL") {
853
- p("quoteSetStatus", "idle"), p("quoteSet", void 0), p("errorSet", null);
854
- return;
855
- }
856
- p("quoteSetStatus", "error"), p("quoteSet", void 0), p("errorSet", w.data), At(n);
857
- return;
858
- }
859
- b.error("Unhandled error in useMakeQuoteEffect:", w), p("quoteSetStatus", "error"), p("quoteSet", void 0), p("errorSet", {
860
- code: "QUOTE_FAILED",
861
- meta: { message: "Unknown error" }
862
- });
863
- }
864
- },
865
- [n, m, I, h, t, s, T]
866
- );
867
- R(() => {
868
- !T || !(m ? n.state === "input_valid_dry" : n.state === "input_valid_external" && !n.targetToken?.isIntent || n.state === "input_valid_internal" && n.targetToken?.isIntent) || n.quoteStatus !== "error" && (a && !n.isDepositFromExternalWallet || F({ isRefetch: !1 }));
869
- }, [T, F, B, n.sourceToken, n.targetToken]), R(() => {
870
- const L = () => {
871
- y.current && (clearInterval(y.current), y.current = null);
872
- };
873
- return n.state !== "quote_success_internal" && n.state !== "quote_success_external" || !r || (y.current = setInterval(async () => {
874
- await F({ isRefetch: !0 });
875
- }, r)), L;
876
- }, [T, F, B, n.state]);
877
- }, ue = {
878
- sol: "sol",
879
- evm: "eth",
880
- near: "near"
881
- }, Vr = ({
882
- isEnabled: e,
883
- skipIntents: t = !1,
884
- target: s = "none"
885
- }) => {
886
- const { tokens: r } = P(), { ctx: n, state: a } = N(), { intentBalances: l } = ie(), { walletSupportedChains: i, chainsFilter: d, intentsAccountType: u } = E(), o = mn({
887
- tokens: r,
888
- walletSupportedChains: i,
889
- balances: l,
890
- across: "intents"
891
- }), [m, T] = x(() => !n.walletAddress && !t ? [
892
- { token: un({ tokens: r }), status: "loaded" },
893
- { token: void 0, status: "loaded" }
894
- ] : d.source.intents !== "none" && !t ? o ? [
895
- { token: o, status: "loaded" },
896
- { token: void 0, status: "loaded" }
897
- ] : [
898
- { token: void 0, status: "loading" },
899
- { token: void 0, status: "loading" }
900
- ] : [
901
- { token: dn({
902
- tokens: r,
903
- walletSupportedChains: i
904
- }), status: "loaded" },
905
- { token: void 0, status: "loaded" }
906
- ], [
907
- r,
908
- t,
909
- d,
910
- n.walletAddress,
911
- o,
912
- i,
913
- a
914
- ]);
915
- R(() => {
916
- if (!e)
917
- return;
918
- if (C(n, ["initial_dry", "initial_wallet"]) && (m.status === "loaded" && !n.sourceToken && p("tokenSelect", {
919
- variant: "source",
920
- token: m.token
921
- }), T.status === "loaded" && m.status === "loaded" && !n.targetToken)) {
922
- let I = T.token;
923
- if (s === "same-asset")
924
- if (m.token?.isIntent) {
925
- if (!u)
926
- throw new Error(
927
- "Intents account type is required to select same-asset target token"
928
- );
929
- I = r.find(
930
- (S) => !S.isIntent && S.symbol === n.sourceToken?.symbol && S.blockchain === ue[u]
931
- );
932
- } else
933
- I = r.find(
934
- (S) => S.isIntent && S.symbol === n.sourceToken?.symbol
935
- );
936
- p("tokenSelect", {
937
- variant: "target",
938
- token: I
939
- });
940
- }
941
- }, [n, m, T, e]);
942
- const h = (f, I) => {
943
- const S = r.find(
944
- (y) => !y.isIntent && y.blockchain === ue[f] && y.symbol.toLowerCase() === jt[ue[f]]?.toLowerCase()
945
- ) ?? I;
946
- p("tokenSelect", {
947
- variant: "source",
948
- token: S
949
- });
950
- };
951
- return R(() => {
952
- const f = C(n, ["initial_dry", "initial_wallet"]);
953
- if (!e || !f)
954
- return;
955
- const I = r.find(
956
- (y) => y.isIntent && y.symbol === "AURORA" && y.blockchain === "near"
957
- ), S = setTimeout(() => {
958
- m.token || (!t && o ? p("tokenSelect", {
959
- variant: "source",
960
- token: o
961
- }) : i.length && u ? h(u, I) : n.walletAddress && ut(n.walletAddress) ? h("sol", I) : n.walletAddress && mt(n.walletAddress) ? h("evm", I) : n.walletAddress && dt(n.walletAddress) ? h("near", I) : p("tokenSelect", {
962
- variant: "source",
963
- token: I
964
- }));
965
- }, 3e3);
966
- return () => clearTimeout(S);
967
- }, [r, m, t]), { source: n.sourceToken, target: n.targetToken };
968
- }, Qr = ({
969
- isEnabled: e,
970
- alchemyApiKey: t
971
- }) => {
972
- const { connectedWallets: s } = E();
973
- It({
974
- isEnabled: e,
975
- connectedWallets: s,
976
- alchemyApiKey: t ?? ""
977
- });
978
- }, $r = (e, t) => {
979
- const { config: s } = Se(Be);
980
- return e.targetToken && !e.sendAddress && !!e.walletAddress && !e.targetToken.isIntent && !t.find((r) => r?.key === "sendAddress") && s.walletSupportedChains.includes(e.targetToken.blockchain);
981
- }, Kr = ({ debug: e }) => {
982
- Z.onContextChange((t, s) => {
983
- const r = s;
984
- if (e && b.debug("[WIDGET] Context changed", r), e && t.error && Tn(r) && b.debug(`[WIDGET] Error set to ${t.error.code}`), hn(r) || kn(t, r, e))
985
- return;
986
- if (In(t, r)) {
987
- p("reset", { clearWalletAddress: !0 }), O("initial_dry");
988
- return;
989
- }
990
- const { isChanged: n, isDry: a } = pn(t, r);
991
- if (n) {
992
- if (gn(t)) {
993
- const l = a ? "initial_dry" : "initial_wallet";
994
- O(l, {
995
- onMoved: () => {
996
- e && b.debug(
997
- `[WIDGET] Inputs changed. State moved to ${l}`
998
- );
999
- }
1000
- });
1001
- }
1002
- fn(t) || (t.quote = void 0, t.quoteStatus = "idle", t.transferStatus = { status: "idle" }), wn(t) && (t.sendAddress = void 0), $r(t, r) && (t.sendAddress = t.walletAddress), At(t);
1003
- }
1004
- });
1005
- }, Hr = ({ debug: e }) => {
1006
- Z.onTransition((t, s) => {
1007
- e && b.debug(`===> [WIDGET] State moved from ${t} to ${s}`);
1008
- });
1009
- }, Gr = (e, t) => {
1010
- const { variant: s, token: r } = t, { config: n } = Se(Be);
1011
- switch (s) {
1012
- case "source":
1013
- if (r && r.assetId === e.targetToken?.assetId && r.isIntent === e.targetToken.isIntent && n.enableAutoTokensSwitching) {
1014
- if (!e.sourceToken)
1015
- return;
1016
- ge(e);
1017
- return;
1018
- }
1019
- if (r && !e.sourceToken && r.assetId === e.targetToken?.assetId && r.isIntent === e.targetToken.isIntent && n.enableAutoTokensSwitching)
1020
- return;
1021
- e.sourceToken = r;
1022
- break;
1023
- case "target":
1024
- if (r && r.assetId === e.sourceToken?.assetId && r.isIntent === e.sourceToken.isIntent && n.enableAutoTokensSwitching) {
1025
- if (!e.targetToken)
1026
- return;
1027
- ge(e);
1028
- return;
1029
- }
1030
- e.targetToken = r;
1031
- break;
1032
- default:
1033
- be(s, { throwError: !1 });
1034
- }
1035
- }, D = (e, t) => Z.on(
1036
- e,
1037
- (s, r) => t(s, r, Z)
1038
- ), jr = () => {
1039
- D("quoteSetStatus", bn), D("walletAddressSet", Cn), D("transferSetStatus", On), D("tokenSelectRotate", ge), D("tokenSetBalance", vn), D("tokenSetAmount", En), D("depositTypeSet", yn), D("setInputsValidating", Dn), D("externalDepositTxSet", Rn), D("tokenSelect", Gr), D("addressSet", Nn), D("errorSet", An), D("quoteSet", _n), D("reset", Sn), D("validateDryInputs", wt), D("validateExternalInputs", kt), D("validateInternalInputs", St);
1040
- }, Yr = en(({ debug: e }) => {
1041
- e && b.debug(
1042
- "[WIDGET] Debug mode is enabled (package version: 3.14.0-redesign.3)"
1043
- ), jr(), Hr({ debug: e }), Kr({ debug: e });
1044
- }), hi = ({ listenTo: e, debug: t = !1 }) => {
1045
- R(() => {
1046
- Yr({ debug: t });
1047
- }, [t]);
1048
- const s = e.find(
1049
- (a) => Array.isArray(a) && a[0] === "setBalancesUsingAlchemyExt"
1050
- ), r = e.find(
1051
- (a) => Array.isArray(a) && a[0] === "setDefaultSelectedTokens"
1052
- ), n = e.find(
1053
- (a) => Array.isArray(a) && a[0] === "makeQuote"
1054
- );
1055
- Qr({
1056
- isEnabled: !!s,
1057
- alchemyApiKey: s?.[1].alchemyApiKey
1058
- }), Vr({
1059
- isEnabled: !!r,
1060
- skipIntents: r?.[1].skipIntents,
1061
- target: r?.[1].target
1062
- }), Mr({
1063
- isEnabled: !!n,
1064
- message: n?.[1].message,
1065
- type: n?.[1].type,
1066
- refetchQuoteInterval: n?.[1].refetchQuoteInterval
1067
- }), qr({
1068
- isEnabled: e.includes("checkWalletConnection")
1069
- }), Lr({
1070
- isEnabled: e.includes("setSourceTokenBalance")
1071
- }), Br({
1072
- isEnabled: e.includes("setSourceTokenIntentsTarget")
1073
- }), Fr({
1074
- isEnabled: e.includes("updateBalances"),
1075
- alchemyApiKey: s?.[1].alchemyApiKey
1076
- });
1077
- }, zr = Z.getStore();
1078
- class W extends Error {
1079
- context;
1080
- _is_widget_error = !0;
1081
- constructor(t, s) {
1082
- super(t), this.name = "WidgetError", this.cause = s?.cause, this.context = Se(zr).context;
1083
- }
1084
- }
1085
- class _t extends W {
1086
- data;
1087
- constructor(t) {
1088
- super(t.code), this.data = t, this.name = "MachineError";
1089
- }
1090
- }
1091
- class q extends _t {
1092
- constructor(t) {
1093
- super(t), this.name = "QuoteError";
1094
- }
1095
- }
1096
- class g extends _t {
1097
- constructor(t) {
1098
- super(t), this.name = "TransferError";
1099
- }
1100
- }
1101
- const gi = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e && !!e._is_widget_error, M = Z.getStore(), Zr = Zt({
1102
- usdTradeDelta: (e) => xn(e(M.context)),
1103
- isDirectNearTokenWithdrawal: (e) => Bn(e(M.context)),
1104
- isDirectNonNearWithdrawal: (e) => Fn(e(M.context)),
1105
- isDirectTokenOnNearDeposit: (e) => Jt(e(M.context)),
1106
- isNativeNearDeposit: (e) => Xt(e(M.context)),
1107
- isSameAssetDiffChainWithdrawal: (e) => qn(e(M.context)),
1108
- isDirectTokenOnNearTransfer: (e) => Ln(e(M.context))
1109
- }), G = () => oe(Zr), N = () => {
1110
- const e = oe(M);
1111
- return {
1112
- state: e.state,
1113
- ctx: e.context
1114
- };
1115
- }, Ii = (e) => {
1116
- const t = oe(M);
1117
- if (!C(t.context, [e]))
1118
- throw new W(
1119
- `[WIDGET] Attempt to access snapshot for ${e} state while context does not match`
1120
- );
1121
- return t.context;
1122
- }, Xr = async ({
1123
- contractId: e,
1124
- accountId: t
1125
- }) => {
1126
- try {
1127
- const s = { account_id: t }, r = Oe.from(JSON.stringify(s)).toString("base64"), n = await Pn.query({
1128
- request_type: "call_function",
1129
- method_name: "storage_balance_of",
1130
- account_id: e,
1131
- args_base64: r,
1132
- finality: "optimistic"
1133
- }), a = Un(
1134
- n,
1135
- re.union([re.null(), re.object({ total: re.string() })])
1136
- );
1137
- return BigInt(a?.total ?? "0");
1138
- } catch (s) {
1139
- throw new W("Error fetching balance", { cause: s });
1140
- }
1141
- };
1142
- function Jr(e) {
1143
- const { ctx: t } = N(), { isNativeNearDeposit: s } = G(), r = t.sourceToken?.contractAddress, n = t.quote?.amountIn ?? t.sourceTokenAmount;
1144
- return {
1145
- make: async (l, i) => {
1146
- if (!e)
1147
- throw new g({
1148
- code: "TRANSFER_INVALID_INITIAL",
1149
- meta: { message: "No connected wallet to sign a transfer." }
1150
- });
1151
- if (!r && t.sourceToken?.assetId !== Q)
1152
- throw new g({
1153
- code: "TRANSFER_INVALID_INITIAL",
1154
- meta: { message: "No token selected to transfer." }
1155
- });
1156
- if (!l)
1157
- throw new g({
1158
- code: "TRANSFER_INVALID_INITIAL",
1159
- meta: { message: "No recipient address to transfer." }
1160
- });
1161
- if (!n)
1162
- throw new g({
1163
- code: "TRANSFER_INVALID_INITIAL",
1164
- meta: { message: "No amount to transfer." }
1165
- });
1166
- const d = e();
1167
- if (t.sourceToken.assetId === Q && t.targetToken?.assetId !== Te) {
1168
- const o = await d.signAndSendTransactions({
1169
- transactions: [
1170
- {
1171
- signerId: t.walletAddress,
1172
- receiverId: l,
1173
- actions: [
1174
- {
1175
- type: "Transfer",
1176
- params: {
1177
- deposit: n
1178
- // Amount in yoctoNEAR
1179
- }
1180
- }
1181
- ]
1182
- }
1183
- ]
1184
- });
1185
- return o && o.length > 0 ? {
1186
- hash: o[0]?.transaction?.hash ?? "",
1187
- transactionLink: `https://nearblocks.io/txns/${o[0]?.transaction?.hash}`,
1188
- intent: void 0
1189
- } : {
1190
- hash: "",
1191
- transactionLink: "",
1192
- intent: void 0
1193
- };
1194
- }
1195
- const u = [];
1196
- if (t.targetToken && s)
1197
- try {
1198
- u.push({
1199
- type: "FunctionCall",
1200
- params: {
1201
- methodName: "near_deposit",
1202
- gas: Ue,
1203
- deposit: n,
1204
- args: {}
1205
- }
1206
- }), u.push({
1207
- type: "FunctionCall",
1208
- params: {
1209
- methodName: "ft_transfer_call",
1210
- deposit: "1",
1211
- // 1 yocto required by NEP-141
1212
- gas: Pe,
1213
- args: {
1214
- amount: n,
1215
- receiver_id: l,
1216
- msg: i ?? ""
1217
- }
1218
- }
1219
- });
1220
- const o = await d.signAndSendTransactions({
1221
- transactions: [
1222
- {
1223
- receiverId: "wrap.near",
1224
- actions: u
1225
- }
1226
- ]
1227
- });
1228
- if (o?.[0]?.transaction?.hash)
1229
- return {
1230
- hash: o[0].transaction?.hash ?? "",
1231
- transactionLink: `https://nearblocks.io/txns/${o[0].transaction?.hash}`,
1232
- intent: void 0
1233
- };
1234
- throw new g({
1235
- code: "NO_DEPOSIT_RESULT"
1236
- });
1237
- } catch (o) {
1238
- throw b.error("[TRANSFER ERROR]", o), new g({
1239
- code: "DIRECT_TRANSFER_ERROR"
1240
- });
1241
- }
1242
- if (!r)
1243
- throw new g({
1244
- code: "TRANSFER_INVALID_INITIAL",
1245
- meta: { message: "No token selected to transfer." }
1246
- });
1247
- try {
1248
- const [o, m] = await Promise.all([
1249
- Wn({
1250
- contractId: r
1251
- }),
1252
- Xr({
1253
- contractId: r,
1254
- accountId: l
1255
- })
1256
- ]), T = o - m;
1257
- T > 0n && u.push({
1258
- type: "FunctionCall",
1259
- params: {
1260
- methodName: "storage_deposit",
1261
- args: { account_id: l },
1262
- gas: Ue,
1263
- deposit: T.toString()
1264
- }
1265
- }), u.push({
1266
- type: "FunctionCall",
1267
- params: {
1268
- methodName: "ft_transfer_call",
1269
- args: {
1270
- receiver_id: l,
1271
- amount: n,
1272
- msg: i ?? ""
1273
- },
1274
- gas: Pe,
1275
- deposit: "1"
1276
- }
1277
- });
1278
- const h = await d.signAndSendTransactions({
1279
- transactions: [
1280
- {
1281
- receiverId: r,
1282
- actions: u
1283
- }
1284
- ]
1285
- });
1286
- if (h?.[0]?.transaction?.hash)
1287
- return {
1288
- hash: h[0].transaction?.hash ?? "",
1289
- transactionLink: `https://nearblocks.io/txns/${h[0].transaction?.hash}`,
1290
- intent: void 0
1291
- };
1292
- throw new g({
1293
- code: "NO_DEPOSIT_RESULT"
1294
- });
1295
- } catch (o) {
1296
- throw b.error("[TRANSFER ERROR]", o), new g({
1297
- code: "DIRECT_TRANSFER_ERROR"
1298
- });
1299
- }
1300
- }
1301
- };
1302
- }
1303
- const es = ({
1304
- makeTransfer: e,
1305
- providers: t
1306
- }) => {
1307
- const { ctx: s } = N(), { alchemyApiKey: r } = E(), { make: n } = Vn({
1308
- provider: t?.evm
1309
- }), { make: a } = Qn({
1310
- provider: t?.sol,
1311
- alchemyApiKey: r
1312
- }), l = (d) => {
1313
- if (e)
1314
- return e;
1315
- if (mt(d))
1316
- return n;
1317
- if (ut(d))
1318
- return a;
1319
- throw new g({
1320
- code: "TRANSFER_INVALID_INITIAL",
1321
- meta: { message: "No transfer function established." }
1322
- });
1323
- };
1324
- return { make: async () => {
1325
- if (!s.sourceToken) {
1326
- const o = "No token selected to transfer.";
1327
- throw new g({
1328
- code: "TRANSFER_INVALID_INITIAL",
1329
- meta: { message: o }
1330
- });
1331
- }
1332
- if (!s.quote) {
1333
- const o = "Quote is required for a transfer.";
1334
- throw new g({
1335
- code: "TRANSFER_INVALID_INITIAL",
1336
- meta: { message: o }
1337
- });
1338
- }
1339
- if (!s.quote.depositAddress) {
1340
- const o = "Quote has no deposit address. Make sure not dry.";
1341
- throw new g({
1342
- code: "TRANSFER_INVALID_INITIAL",
1343
- meta: { message: o }
1344
- });
1345
- }
1346
- const d = {
1347
- amount: s.quote.amountIn,
1348
- decimals: s.sourceToken.decimals,
1349
- address: s.quote.depositAddress,
1350
- chain: s.sourceToken.blockchain,
1351
- evmChainId: V(s.sourceToken.blockchain) ? pe[s.sourceToken.blockchain] : null,
1352
- isNativeEthTransfer: !!s.sourceToken && Mn(s.sourceToken),
1353
- tokenAddress: s.sourceToken.assetId === Q ? Q : s.sourceToken.contractAddress,
1354
- sourceAssetId: s.sourceToken.assetId,
1355
- targetAssetId: s.targetToken.assetId
1356
- }, u = l(d.address);
1357
- try {
1358
- const o = await u(d);
1359
- if (!o) {
1360
- if (e)
1361
- return;
1362
- throw b.error("[TRANSFER ERROR]", "No deposit result"), new g({
1363
- code: "NO_DEPOSIT_RESULT"
1364
- });
1365
- }
1366
- return {
1367
- hash: o.hash,
1368
- transactionLink: o.transactionLink,
1369
- intent: void 0
1370
- };
1371
- } catch (o) {
1372
- b.error("[TRANSFER ERROR]", o, { error: o });
1373
- let m = "Failed to make a transfer. Please try again.";
1374
- const T = o instanceof Error && we(o.message);
1375
- if (T)
1376
- return;
1377
- throw on.isAxiosError(o) ? (m = o.response?.data?.detail ?? o.message ?? "Failed to make deposit. Please try again.", new g({
1378
- code: "QUOTE_ERROR",
1379
- meta: { message: m }
1380
- })) : m === "No quotes found" ? new g({
1381
- code: "NO_QUOTE_FOUND"
1382
- }) : o instanceof Error && !T ? new g({
1383
- code: "QUOTE_ERROR",
1384
- meta: { message: o.message }
1385
- }) : new g({
1386
- code: "QUOTE_ERROR",
1387
- meta: { message: "Unknown quote transfer error" }
1388
- });
1389
- }
1390
- } };
1391
- };
1392
- class ts {
1393
- constructor(t, s) {
1394
- this.account = t, this.provider = s;
1395
- }
1396
- async signIntent(t) {
1397
- const s = JSON.stringify({
1398
- verifying_contract: t.verifying_contract,
1399
- deadline: t.deadline,
1400
- nonce: t.nonce,
1401
- intents: t.intents,
1402
- signer_id: t.signer_id ?? Me.authHandleToIntentsUserId({
1403
- identifier: this.account.walletAddress,
1404
- method: "evm"
1405
- })
1406
- }), r = typeof this.provider == "function" ? await this.provider() : this.provider, n = await r.request({
1407
- method: "eth_requestAccounts"
1408
- }), a = await r.request({
1409
- method: "personal_sign",
1410
- params: [s, n[0]]
1411
- });
1412
- if (a == null)
1413
- throw new W("No signature is returned");
1414
- return {
1415
- payload: s,
1416
- standard: "erc191",
1417
- signature: Me.transformERC191Signature(a)
1418
- };
1419
- }
1420
- }
1421
- const ns = ({
1422
- walletAddress: e,
1423
- getProvider: t
1424
- }) => $n({
1425
- accountId: e,
1426
- signMessage: async (s) => {
1427
- const r = t();
1428
- if (!r.signMessage)
1429
- throw new W("Near wallet has no signMessage method exposed");
1430
- let n;
1431
- try {
1432
- n = await r.signMessage({
1433
- ...s,
1434
- nonce: Oe.from(s.nonce)
1435
- });
1436
- } catch (a) {
1437
- throw new W("Near wallet failed to sign a message", {
1438
- cause: a
1439
- });
1440
- }
1441
- if (!n)
1442
- throw new W("Near wallet failed to sign a message");
1443
- return {
1444
- publicKey: n.publicKey,
1445
- signature: n.signature
1446
- };
1447
- }
1448
- }), rs = (e, t) => {
1449
- if (t) {
1450
- if (e.sendAddress)
1451
- return e.sendAddress;
1452
- throw new g({
1453
- code: "TRANSFER_INVALID_INITIAL",
1454
- meta: { message: "Send to address is required for a direct transfer" }
1455
- });
1456
- }
1457
- if (!e.quote || e.quote.dry)
1458
- throw new g({
1459
- code: "TRANSFER_INVALID_INITIAL",
1460
- meta: { message: "Quote is required for intents non-direct transfer" }
1461
- });
1462
- return e.quote.depositAddress;
1463
- }, ss = async (e, t) => {
1464
- let s = We.getItem("nearWalletsPk")[t];
1465
- if (!e.signMessage)
1466
- throw new g({
1467
- code: "DIRECT_TRANSFER_ERROR",
1468
- meta: { message: "Your wallet doesn't support signing messages" }
1469
- });
1470
- if (!s)
1471
- try {
1472
- const a = await e.signMessage({
1473
- message: "Authenticate",
1474
- recipient: "intents.near",
1475
- nonce: Oe.from(jn(32))
1476
- });
1477
- if (!a)
1478
- throw new g({
1479
- code: "DIRECT_TRANSFER_ERROR",
1480
- meta: { message: "Signing message failed" }
1481
- });
1482
- s = a.publicKey, We.setItem("nearWalletsPk", {
1483
- [t]: a.publicKey
1484
- });
1485
- } catch {
1486
- throw new g({
1487
- code: "DIRECT_TRANSFER_ERROR",
1488
- meta: { message: "Your wallet doesn't support signing messages" }
1489
- });
1490
- }
1491
- const r = te({
1492
- walletAddress: t,
1493
- addressType: "near"
1494
- });
1495
- if (!await zn({
1496
- contractId: Ie,
1497
- methodName: "has_public_key",
1498
- args: {
1499
- account_id: r,
1500
- public_key: s
1501
- }
1502
- }))
1503
- try {
1504
- await e.signAndSendTransactions({
1505
- transactions: [
1506
- {
1507
- receiverId: Ie,
1508
- signerId: t,
1509
- actions: [
1510
- {
1511
- type: "FunctionCall",
1512
- params: {
1513
- methodName: "add_public_key",
1514
- args: { public_key: s },
1515
- gas: "100000000000000",
1516
- deposit: "1"
1517
- }
1518
- }
1519
- ]
1520
- }
1521
- ]
1522
- });
1523
- } catch {
1524
- throw new g({
1525
- code: "DIRECT_TRANSFER_ERROR",
1526
- meta: { message: "Unable to add public key to intents account" }
1527
- });
1528
- }
1529
- }, as = ({ providers: e }) => {
1530
- const { ctx: t } = N(), { appName: s, intentsAccountType: r } = E(), {
1531
- isNativeNearDeposit: n,
1532
- isDirectNearTokenWithdrawal: a,
1533
- isDirectNonNearWithdrawal: l
1534
- } = G();
1535
- return { make: async ({
1536
- message: d,
1537
- onPending: u
1538
- }) => {
1539
- if (!t.walletAddress)
1540
- throw new g({
1541
- code: "TRANSFER_INVALID_INITIAL",
1542
- meta: { message: "No connected wallet to sign a transfer." }
1543
- });
1544
- if (!t.sourceToken || !t.targetToken)
1545
- throw new g({
1546
- code: "TRANSFER_INVALID_INITIAL",
1547
- meta: { message: "No token selected to transfer." }
1548
- });
1549
- if (!t.sourceToken.isIntent)
1550
- throw new g({
1551
- code: "TRANSFER_INVALID_INITIAL",
1552
- meta: {
1553
- message: "For not intents source token use useMakeQuoteTransfer instead"
1554
- }
1555
- });
1556
- let o;
1557
- if (!r)
1558
- throw new g({
1559
- code: "TRANSFER_INVALID_INITIAL",
1560
- meta: { message: "Intents account type is not defined" }
1561
- });
1562
- switch (r) {
1563
- case "evm":
1564
- if (!e?.evm)
1565
- throw new g({
1566
- code: "TRANSFER_INVALID_INITIAL",
1567
- meta: { message: "No EVM provider configured" }
1568
- });
1569
- o = new ts(
1570
- { walletAddress: t.walletAddress },
1571
- e.evm
1572
- );
1573
- break;
1574
- case "sol":
1575
- if (!e?.sol)
1576
- throw new g({
1577
- code: "TRANSFER_INVALID_INITIAL",
1578
- meta: { message: "No SOL provider configured" }
1579
- });
1580
- o = new Yn(
1581
- { walletAddress: t.walletAddress },
1582
- e.sol
1583
- );
1584
- break;
1585
- case "near": {
1586
- if (!e?.near)
1587
- throw new g({
1588
- code: "TRANSFER_INVALID_INITIAL",
1589
- meta: { message: "No NEAR provider configured" }
1590
- });
1591
- await ss(e.near(), t.walletAddress), o = ns({
1592
- walletAddress: t.walletAddress,
1593
- getProvider: e.near
1594
- });
1595
- break;
1596
- }
1597
- default:
1598
- be(r);
1599
- }
1600
- const m = new Kn({ referral: at(s) });
1601
- m.setIntentSigner(o);
1602
- let T;
1603
- n ? T = void 0 : a ? T = Hn(d ?? void 0) : l ? T = void 0 : T = Gn();
1604
- const h = m.createWithdrawal({
1605
- withdrawalParams: {
1606
- assetId: t.sourceToken.assetId,
1607
- amount: BigInt(t.sourceTokenAmount),
1608
- destinationAddress: rs(
1609
- t,
1610
- a || l
1611
- ),
1612
- destinationMemo: void 0,
1613
- feeInclusive: !1,
1614
- routeConfig: T
1615
- }
1616
- });
1617
- try {
1618
- await h.estimateFee(), u("WAITING_CONFIRMATION");
1619
- const f = await h.signAndSendIntent();
1620
- u("PROCESSING");
1621
- const I = await h.waitForIntentSettlement();
1622
- return await h.waitForWithdrawalCompletion(), {
1623
- hash: I.hash,
1624
- transactionLink: Zn(Yt.near, I.hash),
1625
- intent: f
1626
- };
1627
- } catch (f) {
1628
- if (b.error("[TRANSFER ERROR]", f), f instanceof Error) {
1629
- if (f.message.includes("Fee is not estimated"))
1630
- throw new g({
1631
- code: "FEES_NOT_ESTIMATED"
1632
- });
1633
- if (we(f.message) || we(`${f.cause}`))
1634
- return;
1635
- }
1636
- throw new g({
1637
- code: "DIRECT_TRANSFER_ERROR"
1638
- });
1639
- }
1640
- } };
1641
- }, os = ({
1642
- message: e,
1643
- providers: t,
1644
- makeTransfer: s
1645
- }) => {
1646
- const { ctx: r } = N(), {
1647
- isDirectTokenOnNearDeposit: n,
1648
- isDirectTokenOnNearTransfer: a,
1649
- isNativeNearDeposit: l
1650
- } = G(), { make: i } = as({ providers: t }), { make: d } = es({
1651
- makeTransfer: s,
1652
- providers: t
1653
- }), { make: u } = Jr(
1654
- t?.near
1655
- );
1656
- return { make: async () => {
1657
- if (!r.targetToken)
1658
- return;
1659
- let m;
1660
- try {
1661
- if (p("transferSetStatus", {
1662
- status: "pending",
1663
- reason: "WAITING_CONFIRMATION"
1664
- }), r.sourceToken?.isIntent)
1665
- m = await i({
1666
- message: e,
1667
- onPending: (T) => {
1668
- p("transferSetStatus", {
1669
- status: "pending",
1670
- reason: T
1671
- });
1672
- }
1673
- });
1674
- else if ((l || n) && !r.isDepositFromExternalWallet)
1675
- m = await u(
1676
- r.sendAddress ?? Ie,
1677
- e
1678
- );
1679
- else if (a) {
1680
- if (!r.sendAddress)
1681
- throw new g({
1682
- code: "TRANSFER_INVALID_INITIAL",
1683
- meta: { message: "No recipient address to transfer" }
1684
- });
1685
- m = await u(
1686
- r.sendAddress,
1687
- e
1688
- );
1689
- } else
1690
- m = await d();
1691
- } catch (T) {
1692
- T instanceof g && (b.error(T.data), p("transferSetStatus", { status: "error" }), p("errorSet", T.data));
1693
- }
1694
- if (!m) {
1695
- p("transferSetStatus", { status: "idle" });
1696
- return;
1697
- }
1698
- return p("transferSetStatus", { status: "success" }), O("transfer_success"), m;
1699
- } };
1700
- }, is = async (e) => {
1701
- if (!e)
1702
- return;
1703
- const t = await e.request({
1704
- method: "eth_chainId"
1705
- });
1706
- return parseInt(t, 16);
1707
- }, cs = ({ providers: e }) => {
1708
- const { ctx: t } = N(), [s, r] = se(!1), [n, a] = se(!1), l = fe(async () => {
1709
- const d = typeof e?.evm == "function" ? await e.evm() : e?.evm;
1710
- if (!t.sourceToken || !d)
1711
- return !1;
1712
- const u = await is(d);
1713
- if (!V(t.sourceToken.blockchain))
1714
- return !1;
1715
- const o = pe[t.sourceToken.blockchain];
1716
- return !o || !u ? !1 : u !== o;
1717
- }, [t.sourceToken, e]), i = fe(async () => {
1718
- const d = typeof e?.evm == "function" ? await e.evm() : e?.evm;
1719
- if (!t.sourceToken || !d || !V(t.sourceToken.blockchain))
1720
- return !1;
1721
- const u = pe[t.sourceToken.blockchain];
1722
- if (!u)
1723
- return !1;
1724
- try {
1725
- return r(!0), await Xn(u, d), !0;
1726
- } catch (o) {
1727
- return b.error("Failed to switch chain:", o), !1;
1728
- } finally {
1729
- r(!1);
1730
- }
1731
- }, [t.sourceToken, e]);
1732
- return R(() => {
1733
- l().then(a);
1734
- }, [l]), {
1735
- isSwitchingChainRequired: n,
1736
- switchChain: i,
1737
- isSwitchingChain: s
1738
- };
1739
- }, _ = {
1740
- size: "lg",
1741
- variant: "primary"
1742
- }, xe = (e) => {
1743
- const { t } = H();
1744
- if (e.error?.code === "TOKEN_IS_NOT_SUPPORTED")
1745
- return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.invalidAddress", "Invalid address") });
1746
- if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_EMPTY")
1747
- return /* @__PURE__ */ c(A, { state: "disabled", ..._, children: t("submit.disabled.enterRecipientAddress", "Enter recipient address") });
1748
- if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_NOT_FOUND")
1749
- return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.sendAddressNotFound", {
1750
- defaultValue: "Address not found on {{chain}}",
1751
- chain: e.error.meta.chain.toUpperCase()
1752
- }) });
1753
- if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_INVALID")
1754
- return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.sendAddressInvalid", {
1755
- defaultValue: "Invalid {{chain}} address",
1756
- chain: e.error.meta.chain.toUpperCase()
1757
- }) });
1758
- if (e.error?.code === "QUOTE_AMOUNT_IS_TOO_LOW")
1759
- return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
1760
- /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.amountTooLow.label", "Amount is too low") }),
1761
- /* @__PURE__ */ c($, { children: /* @__PURE__ */ k(Mt, { i18nKey: "submit.error.amountTooLow.message", children: [
1762
- "Amount you entered is very low. Please try increasing it",
1763
- " ",
1764
- /* @__PURE__ */ k("span", { className: "text-nowrap", children: [
1765
- "above ",
1766
- /* @__PURE__ */ c(ve, { value: e.error.meta.minAmount ?? "0" }),
1767
- " ",
1768
- e.sourceToken?.symbol ?? "",
1769
- "."
1770
- ] })
1771
- ] }) })
1772
- ] });
1773
- if (e.quoteStatus === "error")
1774
- return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
1775
- /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.quoteFailed.label", "Quote failed") }),
1776
- /* @__PURE__ */ c($, { children: t(
1777
- "submit.error.quoteFailed.message",
1778
- "We couldn’t finalize your quote. Please try again or adjust your values."
1779
- ) })
1780
- ] });
1781
- if (e.error?.code === "TRANSFER_INVALID_INITIAL")
1782
- return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
1783
- /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.invalidTransferData.label", "Invalid transfer data") }),
1784
- e.error.meta?.message ? /* @__PURE__ */ c($, { children: e.error.meta.message }) : null
1785
- ] });
1786
- if (e.error?.code === "EXTERNAL_TRANSFER_FAILED")
1787
- return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.externalTransferFailed.label", "Transfer failed") });
1788
- if (e.error?.code === "EXTERNAL_TRANSFER_INCOMPLETE")
1789
- return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
1790
- /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.externalTransferFailed.label", "Transfer failed") }),
1791
- /* @__PURE__ */ c($, { children: t(
1792
- "submit.error.externalTransferFailed.incompleteMessage",
1793
- "Incomplete transfer. Deposited amount will be refunded."
1794
- ) })
1795
- ] });
1796
- if (e.error?.code === "EXTERNAL_TRANSFER_REFUNDED")
1797
- return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
1798
- /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.externalTransferFailed.label", "Transfer failed") }),
1799
- /* @__PURE__ */ c($, { children: t(
1800
- "submit.error.externalTransferFailed.refundedMessage",
1801
- "Deposited amount will be refunded."
1802
- ) })
1803
- ] });
1804
- if (e.error?.code === "DIRECT_TRANSFER_ERROR")
1805
- return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
1806
- /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.transferFailed.label", "Transfer failed") }),
1807
- e.error.meta?.message ? /* @__PURE__ */ c($, { children: e.error.meta.message }) : null
1808
- ] });
1809
- if (e.error?.code === "SOURCE_BALANCE_INSUFFICIENT")
1810
- return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.insufficientBalance", "Insufficient balance") });
1811
- }, ls = ({ onClick: e }) => {
1812
- const { t } = H();
1813
- return /* @__PURE__ */ c(A, { state: "disabled", ..._, onClick: e, children: t("submit.error.connectWallet", "Connect wallet") });
1814
- }, ds = () => {
1815
- const { ctx: e } = N();
1816
- return xe(e) ?? null;
1817
- }, us = (e) => {
1818
- const { providers: t, makeTransfer: s, onSuccess: r } = e, { ctx: n } = N(), { t: a } = H(), {
1819
- isNativeNearDeposit: l,
1820
- isDirectNonNearWithdrawal: i,
1821
- isDirectTokenOnNearDeposit: d,
1822
- isDirectNearTokenWithdrawal: u
1823
- } = G(), { make: o } = os({ providers: t, makeTransfer: s }), { isSwitchingChainRequired: m, switchChain: T, isSwitchingChain: h } = cs({ providers: t }), f = xe(n), I = async () => {
1824
- if (m && !await T())
1825
- return;
1826
- const S = await o();
1827
- S && r(S);
1828
- };
1829
- if (!n.targetToken)
1830
- return /* @__PURE__ */ c(A, { ..._, state: "disabled", children: a("submit.disabled.selectTokenToReceive", "Select token to receive") });
1831
- if (!ne(n.sourceTokenAmount))
1832
- return /* @__PURE__ */ c(A, { ..._, state: "disabled", children: a("submit.disabled.enterAmount", "Enter amount") });
1833
- if (n.areInputsValidating)
1834
- return /* @__PURE__ */ c(A, { state: "loading", ..._, children: a("submit.pending.validating", "Validating...") });
1835
- if (h)
1836
- return /* @__PURE__ */ c(A, { state: "loading", ..._, children: a("submit.pending.switchingChain", "Switching network...") });
1837
- if (!m && f)
1838
- return f;
1839
- if (n.transferStatus.status === "pending")
1840
- switch (n.transferStatus.reason) {
1841
- case "WAITING_CONFIRMATION":
1842
- return /* @__PURE__ */ c(A, { state: "loading", ..._, children: a("submit.pending.transfer.confirmInWallet", "Confirm in wallet") });
1843
- case "PROCESSING":
1844
- default:
1845
- return /* @__PURE__ */ c(A, { state: "loading", ..._, children: a("submit.pending.transfer.finalizing", "Finalizing transfer") });
1846
- }
1847
- return n.transferStatus.status === "error" ? /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
1848
- /* @__PURE__ */ c(A, { ..._, children: e.label }),
1849
- /* @__PURE__ */ c($, { children: (() => {
1850
- switch (n.error?.code) {
1851
- case "FEES_NOT_ESTIMATED":
1852
- return a(
1853
- "submit.error.transfer.noFees",
1854
- "Transfer fees could not be estimated."
1855
- );
1856
- default:
1857
- return a(
1858
- "submit.error.transfer.failed",
1859
- "Transfer can not be completed."
1860
- );
1861
- }
1862
- })() })
1863
- ] }) : n.quoteStatus === "pending" ? /* @__PURE__ */ c(A, { state: "loading", ..._, children: n.quote ? a("submit.pending.quote.refreshing", "Refreshing quote") : a("submit.pending.quote.finalizing", "Finalizing quote") }) : n.error ? /* @__PURE__ */ c(A, { state: "disabled", ..._, children: e.label }) : !n.quote && !i && !d && !u && !l ? /* @__PURE__ */ c(A, { state: "disabled", ..._, children: e.label }) : /* @__PURE__ */ c(A, { ..._, onClick: I, children: e.label });
1864
- }, ms = (e) => {
1865
- const { t } = H(), { ctx: s } = N(), r = xe(s);
1866
- return s.isDepositFromExternalWallet ? ne(s.sourceTokenAmount) ? s.externalDepositTxReceived ? /* @__PURE__ */ c(A, { state: "loading", ..._, children: t("submit.pending.externalDeposit.processing", "Processing") }) : /* @__PURE__ */ c(A, { state: "loading", ..._, children: t("submit.pending.externalDeposit.waiting", "Waiting for transaction") }) : /* @__PURE__ */ c(A, { ..._, state: "disabled", children: t("submit.disabled.enterAmount", "Enter amount") }) : r || /* @__PURE__ */ c(us, { ...e });
1867
- }, fs = (e) => {
1868
- const { ctx: t } = N(), s = E();
1869
- return t.walletAddress ? /* @__PURE__ */ c(ms, { ...e }) : /* @__PURE__ */ c(ls, { onClick: s.onWalletSignin });
1870
- };
1871
- fs.Error = ds;
1872
- const ps = ({ className: e }) => {
1873
- const { t } = H(), { slippageTolerance: s } = E(), { ctx: r } = N(), n = r.sourceToken && r.targetToken && r.sourceToken.price / r.targetToken.price;
1874
- return r.sourceToken ? /* @__PURE__ */ c(
1875
- Jn,
1876
- {
1877
- expandedByDefault: !1,
1878
- expandedHeightPx: r.walletAddress ? 80 : 50,
1879
- isBadgeLoading: r.quoteStatus === "pending",
1880
- badge: r.quote ? `~ ${r.quote.timeEstimate} sec` : void 0,
1881
- className: e,
1882
- title: r.sourceToken && r.targetToken ? /* @__PURE__ */ k("span", { style: { borderBottomWidth: "2px", borderStyle: "dotted" }, children: [
1883
- `1 ${r.sourceToken.symbol} ≈ `,
1884
- " ",
1885
- er(n ?? 0),
1886
- " ",
1887
- `${r.targetToken.symbol}`,
1888
- /* @__PURE__ */ c("span", { className: "text-sw-gray-50", children: `(${Ve(r.sourceToken.price)})` })
1889
- ] }) : /* @__PURE__ */ k("span", { style: { borderBottomWidth: "2px", borderStyle: "dotted" }, children: [
1890
- `1 ${r.sourceToken.symbol} ≈ `,
1891
- " ",
1892
- Ve(r.sourceToken.price),
1893
- " USD"
1894
- ] }),
1895
- children: /* @__PURE__ */ k(le, { children: [
1896
- /* @__PURE__ */ c(
1897
- le.Item,
1898
- {
1899
- label: t("quote.result.maxSlippage.label", "Max slippage"),
1900
- value: `${(s / 100).toFixed(2)}%`
1901
- }
1902
- ),
1903
- !!r.walletAddress && /* @__PURE__ */ c(
1904
- le.Item,
1905
- {
1906
- isLoading: r.quoteStatus === "pending",
1907
- label: t("quote.result.processingTime.label", "Processing time"),
1908
- value: r.quote ? `${r.quote.timeEstimate} sec.` : "—"
1909
- }
1910
- )
1911
- ] })
1912
- }
1913
- ) : /* @__PURE__ */ c(ft, {});
1914
- }, wi = Object.assign(ps, {
1915
- Skeleton: ft
1916
- }), Ts = ({
1917
- token: e,
1918
- balance: t,
1919
- isNotSufficient: s = !1,
1920
- onClick: r
1921
- }) => {
1922
- const n = E();
1923
- return !e.isIntent && !n.walletSupportedChains.includes(e.blockchain) ? /* @__PURE__ */ c("span", {}) : t === void 0 ? /* @__PURE__ */ c(nr, { width: 100 }) : /* @__PURE__ */ c(
1924
- "span",
1925
- {
1926
- onClick: t ? r : void 0,
1927
- style: t ? { borderBottomWidth: "2px", borderStyle: "dotted" } : void 0,
1928
- className: tr("text-sw-label-sm", {
1929
- "text-sw-status-error": s,
1930
- "text-sw-gray-100": !s,
1931
- "cursor-pointer": !!t && !!r
1932
- }),
1933
- children: /* @__PURE__ */ c(
1934
- ve,
1935
- {
1936
- decimals: e.decimals,
1937
- value: t === void 0 ? "0" : `${t}`
1938
- }
1939
- )
1940
- }
1941
- );
1942
- }, Fe = ({
1943
- token: e,
1944
- balance: t,
1945
- value: s = "",
1946
- quoteUsdDelta: r,
1947
- quoteUsdValue: n,
1948
- state: a = "default",
1949
- showBalance: l = !0,
1950
- showQuickBalanceActions: i = !0,
1951
- heading: d,
1952
- onMsg: u
1953
- }) => {
1954
- const o = xt(), { ctx: m } = N(), { t: T } = H(), { hideTokenInputHeadings: h } = E(), f = sr(e, s, n), I = (S) => {
1955
- u({
1956
- type: "on_change_amount",
1957
- amount: rr(t, e.decimals, S)
1958
- });
1959
- };
1960
- return /* @__PURE__ */ k(Tt, { className: "flex flex-col", "aria-label": d, children: [
1961
- !h && /* @__PURE__ */ c(pt, { children: d }),
1962
- /* @__PURE__ */ k(
1963
- "div",
1964
- {
1965
- className: j(
1966
- "flex items-center justify-between",
1967
- !h && "mt-sw-2xl"
1968
- ),
1969
- children: [
1970
- /* @__PURE__ */ c(
1971
- or,
1972
- {
1973
- value: s,
1974
- name: o,
1975
- setValue: ar,
1976
- placeholder: "0",
1977
- state: a === "default" || a === "disabled" ? a : "error",
1978
- onChange: (S) => {
1979
- u({ type: "on_change_amount", amount: S.target.value });
1980
- }
1981
- }
1982
- ),
1983
- /* @__PURE__ */ k(
1984
- "button",
1985
- {
1986
- type: "button",
1987
- onClick: a === "disabled" ? void 0 : () => u({ type: "on_click_select_token" }),
1988
- className: j(
1989
- "gap-sw-md pl-sw-sm pr-sw-md flex h-[36px] min-w-[80px] shrink-0 items-center rounded-sw-md transition-colors bg-sw-gray-800 hover:bg-sw-gray-700 group",
1990
- {
1991
- "cursor-pointer": a !== "disabled",
1992
- "animate-pulse cursor-default": a === "disabled"
1993
- }
1994
- ),
1995
- children: [
1996
- /* @__PURE__ */ c(
1997
- ht,
1998
- {
1999
- chainShowIcon: !e.isIntent,
2000
- className: "border-sw-gray-800 group-hover:border-sw-gray-700 transition-colors top-[14px]",
2001
- ...e
2002
- }
2003
- ),
2004
- /* @__PURE__ */ c("span", { className: "text-sw-label-md text-sw-gray-50", children: e.symbol })
2005
- ]
2006
- }
2007
- )
2008
- ]
2009
- }
2010
- ),
2011
- /* @__PURE__ */ k("div", { className: "gap-sw-sm min-h-sw-2xl flex items-center justify-between mt-sw-lg", children: [
2012
- /* @__PURE__ */ k("div", { className: "gap-sw-md flex items-center", children: [
2013
- /* @__PURE__ */ c("span", { className: "text-sw-label-sm text-sw-gray-100", children: f }),
2014
- r ? /* @__PURE__ */ c(
2015
- "span",
2016
- {
2017
- className: j("text-sw-label-sm text-nowrap", {
2018
- "text-sw-gray-400": r >= -2 && r <= 2,
2019
- "text-sw-status-success": r > 2,
2020
- "text-sw-status-error": r <= -5,
2021
- "text-sw-status-warning": r < -2 && r > -5
2022
- }),
2023
- children: `${r > 0 ? "+" : ""}${r.toFixed(2)}%`
2024
- }
2025
- ) : null
2026
- ] }),
2027
- /* @__PURE__ */ k("div", { className: "gap-sw-sm flex items-center", children: [
2028
- e && !!m.walletAddress && l && /* @__PURE__ */ c(
2029
- Ts,
2030
- {
2031
- token: e,
2032
- balance: t,
2033
- isNotSufficient: a === "error-balance",
2034
- onClick: () => I(1)
2035
- }
2036
- ),
2037
- !!t && l && i && /* @__PURE__ */ k(Rt, { children: [
2038
- /* @__PURE__ */ c(
2039
- Qe,
2040
- {
2041
- isClickable: a !== "disabled",
2042
- onClick: () => I(2),
2043
- children: T("tokens.input.half.label", "50%")
2044
- }
2045
- ),
2046
- /* @__PURE__ */ c(
2047
- Qe,
2048
- {
2049
- isClickable: a !== "disabled",
2050
- onClick: () => I(1),
2051
- children: T("tokens.input.max.label", "Max")
2052
- }
2053
- )
2054
- ] }),
2055
- !l && /* @__PURE__ */ c("div", { className: "rounded-full bg-sw-gray-700 py-sw-xs px-sw-sm flex items-center justify-center", children: /* @__PURE__ */ c("span", { className: "text-sw-gray-100 text-sw-label-sm", children: T("tokens.input.externalBalance.label", "External balance") }) })
2056
- ] })
2057
- ] })
2058
- ] });
2059
- }, Le = ({ onMsg: e, heading: t }) => {
2060
- const { hideTokenInputHeadings: s } = E();
2061
- return /* @__PURE__ */ k(
2062
- Tt,
2063
- {
2064
- isClickable: !0,
2065
- className: "flex flex-col",
2066
- onClick: () => e({ type: "on_click_select_token" }),
2067
- children: [
2068
- !s && /* @__PURE__ */ c(pt, { children: t }),
2069
- /* @__PURE__ */ k(
2070
- "div",
2071
- {
2072
- className: j(
2073
- "flex items-center justify-between",
2074
- !s && "mt-sw-2xl"
2075
- ),
2076
- children: [
2077
- /* @__PURE__ */ c(
2078
- "span",
2079
- {
2080
- className: "h-[36px] font-medium text-sw-gray-200",
2081
- style: { fontSize: "32px" },
2082
- children: "0"
2083
- }
2084
- ),
2085
- /* @__PURE__ */ c(
2086
- "button",
2087
- {
2088
- type: "button",
2089
- onClick: () => e({ type: "on_click_select_token" }),
2090
- className: "gap-sw-md px-sw-md flex h-[36px] min-w-[100px] shrink-0 cursor-pointer items-center rounded-sw-md bg-sw-gray-800",
2091
- children: /* @__PURE__ */ c("span", { className: "text-sw-label-md text-sw-gray-50", children: "Select token" })
2092
- }
2093
- )
2094
- ]
2095
- }
2096
- ),
2097
- /* @__PURE__ */ c("div", { className: "h-sw-2xl w-full mt-sw-lg" })
2098
- ]
2099
- }
2100
- );
2101
- }, Nt = (e) => {
2102
- const { mergedBalance: t } = ce(), [s, r] = se(
2103
- e ? t[K(e)] : void 0
2104
- );
2105
- return R(() => {
2106
- let n;
2107
- if (e) {
2108
- const a = t[K(e)];
2109
- a ? n = setTimeout(() => {
2110
- r(a);
2111
- }, 0) : n = setTimeout(() => {
2112
- r(
2113
- e ? t[K(e)] ?? 0 : 0
2114
- );
2115
- }, 2e3);
2116
- }
2117
- return () => {
2118
- n && clearTimeout(n);
2119
- };
2120
- }, [e, t]), s;
2121
- }, Et = (e, t) => {
2122
- const { tokens: s } = P(e), r = Array.from(
2123
- new Set(s.map((n) => n.assetId))
2124
- );
2125
- R(() => {
2126
- const n = r.length === 1 ? s[0] : null;
2127
- n && t({ type: "on_select_token", token: n });
2128
- }, [s]);
2129
- }, hs = ({
2130
- onMsg: e,
2131
- isChanging: t = !0,
2132
- showBalance: s = !0,
2133
- heading: r
2134
- }) => {
2135
- const { ctx: n } = N(), a = Nt(n.sourceToken);
2136
- Et("source", e);
2137
- const l = x(() => {
2138
- if (!t && n.quoteStatus === "pending")
2139
- return "disabled";
2140
- if (!n.error)
2141
- return "default";
2142
- if (n.error.code === "QUOTE_AMOUNT_IS_TOO_LOW")
2143
- return "error";
2144
- if (n.error.code === "SOURCE_BALANCE_INSUFFICIENT")
2145
- return "error-balance";
2146
- }, [t, n.error, n.quoteStatus]);
2147
- return n.sourceToken ? /* @__PURE__ */ c(
2148
- Fe,
2149
- {
2150
- heading: r,
2151
- token: n.sourceToken,
2152
- state: l,
2153
- balance: a,
2154
- showBalance: s,
2155
- showQuickBalanceActions: !0,
2156
- value: Y(n.sourceTokenAmount, n.sourceToken?.decimals),
2157
- onMsg: e
2158
- }
2159
- ) : /* @__PURE__ */ c(Le, { heading: r, onMsg: e });
2160
- }, gs = ({
2161
- isChanging: e = !1,
2162
- onMsg: t,
2163
- heading: s
2164
- }) => {
2165
- const { ctx: r } = N(), { usdTradeDelta: n } = G(), a = Nt(r.targetToken);
2166
- Et("target", t);
2167
- const l = x(() => !e && r.quoteStatus === "pending" ? "disabled" : "default", [e, r.quoteStatus]);
2168
- return r.targetToken ? /* @__PURE__ */ c(
2169
- Fe,
2170
- {
2171
- heading: s,
2172
- token: r.targetToken,
2173
- balance: a,
2174
- quoteUsdDelta: n?.percentage,
2175
- quoteUsdValue: r.quote && parseFloat(r.quote.amountOutUsd),
2176
- value: Y(r.targetTokenAmount, r.targetToken?.decimals),
2177
- state: l,
2178
- showQuickBalanceActions: !1,
2179
- showBalance: !0,
2180
- onMsg: t
2181
- }
2182
- ) : /* @__PURE__ */ c(Le, { heading: s, onMsg: t });
2183
- }, Is = ({ token: e, heading: t, ...s }) => e ? /* @__PURE__ */ c(Fe, { ...s, token: e, heading: t }) : /* @__PURE__ */ c(Le, { onMsg: s.onMsg, heading: t }), ki = Object.assign(Is, {
2184
- Skeleton: ir,
2185
- Source: hs,
2186
- Target: gs
2187
- }), Ze = 58, bt = ({
2188
- token: e,
2189
- balance: t,
2190
- showBalance: s = !0,
2191
- isNotSelectable: r,
2192
- className: n,
2193
- onMsg: a
2194
- }) => {
2195
- const { ctx: l } = N(), { walletSupportedChains: i, appName: d } = E(), u = cr(t, e), o = i.includes(e.blockchain) || e.isIntent, m = t !== "0" && t !== 0 && t !== void 0;
2196
- return /* @__PURE__ */ c("li", { className: "list-none group", children: /* @__PURE__ */ k(
2197
- "div",
2198
- {
2199
- className: j(
2200
- "gap-sw-lg p-sw-lg flex justify-between rounded-sw-md transition-colors",
2201
- {
2202
- "cursor-not-allowed": r,
2203
- "cursor-pointer hover:bg-sw-gray-800": !r
2204
- },
2205
- n
2206
- ),
2207
- onClick: () => !r && a({ type: "on_select_token", token: e }),
2208
- children: [
2209
- /* @__PURE__ */ c(
2210
- ht,
2211
- {
2212
- chainShowIcon: !e.isIntent,
2213
- className: "border-sw-gray-900 group-hover:border-sw-gray-800 transition-colors",
2214
- ...e
2215
- }
2216
- ),
2217
- /* @__PURE__ */ k("div", { className: "gap-sw-xs mr-auto flex flex-col", children: [
2218
- /* @__PURE__ */ c("span", { className: "text-sw-label-md text-sw-gray-50", children: e.name }),
2219
- e.isIntent ? /* @__PURE__ */ k("div", { className: "flex items-center gap-sw-xs", children: [
2220
- /* @__PURE__ */ c("span", { className: "text-sw-label-md text-sw-gray-300", children: e.symbol }),
2221
- " ",
2222
- /* @__PURE__ */ c("span", { className: "text-sw-label-sm text-sw-gray-300", children: `on ${d} ${e.chainName.toLowerCase() !== "near" && m ? `(${e.chainName})` : ""}` })
2223
- ] }) : /* @__PURE__ */ k("div", { className: "flex items-center gap-sw-xs", children: [
2224
- /* @__PURE__ */ c("span", { className: "text-sw-label-md text-sw-gray-300", children: e.symbol }),
2225
- " ",
2226
- /* @__PURE__ */ c("span", { className: "text-sw-label-sm text-sw-gray-300", children: `on ${e.chainName}` })
2227
- ] })
2228
- ] }),
2229
- o && !!l.walletAddress && s && /* @__PURE__ */ k("div", { className: "gap-sw-xs flex flex-col items-end", children: [
2230
- t === void 0 && !e.isIntent ? /* @__PURE__ */ c("span", { className: "h-[16px] w-[60px] animate-pulse rounded-full bg-sw-gray-700" }) : /* @__PURE__ */ c("span", { className: "h-[16px] text-sw-label-md text-sw-gray-50", children: m && /* @__PURE__ */ c(
2231
- ve,
2232
- {
2233
- decimals: e.decimals,
2234
- value: t === void 0 ? "0" : `${t}`
2235
- }
2236
- ) }),
2237
- m && /* @__PURE__ */ c("span", { className: "text-sw-label-sm text-sw-gray-300", children: u })
2238
- ] })
2239
- ]
2240
- }
2241
- ) });
2242
- }, Xe = [
2243
- "nep141:eth-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near",
2244
- // cbBTC (eth)
2245
- "nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near",
2246
- // cbBTC (base)
2247
- "nep141:gnosis-0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1.omft.near",
2248
- // wETH (gnosis)
2249
- "nep141:2260fac5e5542a773aa44fbcfedf7c193bc2c599.factory.bridge.near",
2250
- // wBTC (near)
2251
- "nep245:v2_1.omni.hot.tg:56_SZzgw3HSudhZcTwPWUTi2RJB19t",
2252
- // NEAR (bsc)
2253
- "nep141:eth-0xe0f63a424a4439cbe457d80e4f4b51ad25b2c56c.omft.near"
2254
- // SPX (eth)
2255
- ], ws = () => {
2256
- const { tokens: e } = P();
2257
- return {
2258
- uniqueIntentsTokens: x(() => {
2259
- const t = e.filter(
2260
- (n) => n.isIntent && n.blockchain === "near" && !Xe.includes(n.assetId)
2261
- ), s = t.map((n) => n.isIntent && n.symbol), r = e.filter((n) => n.isIntent && n.blockchain !== "near" && !s.includes(n.symbol) && !Xe.includes(n.assetId));
2262
- return [...t, ...r];
2263
- }, [e])
2264
- };
2265
- }, ks = ({
2266
- variant: e,
2267
- search: t,
2268
- selectedChain: s,
2269
- chainsFilter: r,
2270
- walletSupportedChains: n
2271
- }) => {
2272
- xr(e);
2273
- const { tokens: a } = P(e), { mergedBalance: l } = ce(), { intentBalances: i } = ie(), { uniqueIntentsTokens: d } = ws(), u = ur(
2274
- l,
2275
- n,
2276
- t
2277
- ), o = a.filter(mr({ search: t })).filter(
2278
- fr({
2279
- selectedChain: s,
2280
- chainsFilter: r,
2281
- walletSupportedChains: n,
2282
- intentBalances: i,
2283
- uniqueIntentTokenIds: d.map((m) => m.assetId)
2284
- })
2285
- );
2286
- return {
2287
- all: o.sort(u),
2288
- intents: o.filter($e({ isIntent: !0 })).sort(u),
2289
- wallet: o.filter($e({ isIntent: !1 })).sort(u)
2290
- };
2291
- }, Ss = (e, t) => e.length === 0 && t ? "EMPTY_SEARCH" : e.length === 0 && !t ? "NO_TOKENS" : "HAS_TOKENS", As = ({
2292
- variant: e,
2293
- search: t,
2294
- className: s,
2295
- groupTokens: r,
2296
- showBalances: n,
2297
- chainsFilter: a,
2298
- selectedChain: l,
2299
- chainIsNotSupported: i,
2300
- onMsg: d
2301
- }) => {
2302
- const { t: u } = H(), { ctx: o } = N(), { walletSupportedChains: m, appName: T } = E(), { mergedBalance: h } = ce(), f = ks({
2303
- variant: e,
2304
- search: t,
2305
- chainsFilter: a,
2306
- selectedChain: l,
2307
- walletSupportedChains: m
2308
- }), I = o.walletAddress ? r : !1, S = Ss(f.all, t), y = x(
2309
- () => [{ label: null, tokens: f.all }],
2310
- [f.all]
2311
- ), B = x(
2312
- () => [
2313
- { label: `${T} account`, tokens: f.intents },
2314
- {
2315
- label: i ? null : "Connected wallet",
2316
- tokens: f.wallet
2317
- }
2318
- ],
2319
- [f.wallet, f.intents, i]
2320
- ), F = x(() => (I ? B : y).reduce(
2321
- (w, v) => w + v.tokens.length,
2322
- 0
2323
- ), [B, y, I]), L = "450px";
2324
- switch (S) {
2325
- case "EMPTY_SEARCH":
2326
- return /* @__PURE__ */ c(
2327
- ke,
2328
- {
2329
- hasAction: !0,
2330
- actionType: "outlined",
2331
- actionLabel: u("tokens.list.searchReset.label", "Clear search"),
2332
- heading: u("tokens.list.searchEmpty.label", "No results"),
2333
- subHeading: u(
2334
- "tokens.list.searchEmpty.subLabel",
2335
- "Try another search or check if a specific network is selected."
2336
- ),
2337
- className: "pt-sw-5xl pb-sw-5xl",
2338
- onClick: () => d({ type: "on_reset_search" })
2339
- }
2340
- );
2341
- case "HAS_TOKENS":
2342
- return /* @__PURE__ */ c("div", { className: j("gap-sw-lg flex flex-col", s), children: /* @__PURE__ */ c(
2343
- lr,
2344
- {
2345
- className: "hide-scrollbar",
2346
- style: {
2347
- maxHeight: L,
2348
- minHeight: 200,
2349
- height: F ? F * Ze + (I ? B.length * 62 : 0) : Ze * 2
2350
- },
2351
- children: (I ? B : y).map(
2352
- ({ label: w, tokens: v }) => /* @__PURE__ */ k(Ft, { children: [
2353
- v.length && w ? /* @__PURE__ */ k("header", { className: "pb-sw-lg flex flex-col", children: [
2354
- /* @__PURE__ */ c(dr, {}),
2355
- /* @__PURE__ */ c("span", { className: "text-sw-label-sm pt-sw-xl text-sw-gray-100", children: `${w} — ${v.length}` })
2356
- ] }) : null,
2357
- v.map((X) => {
2358
- const J = K(X);
2359
- return /* @__PURE__ */ c(
2360
- bt,
2361
- {
2362
- token: X,
2363
- showBalance: n,
2364
- balance: h[J],
2365
- isNotSelectable: i && !!o.walletAddress,
2366
- onMsg: d
2367
- },
2368
- J
2369
- );
2370
- }),
2371
- v.length ? /* @__PURE__ */ c("div", { className: "h-sw-2xl" }) : null
2372
- ] }, w ?? "ungrouped-tokens")
2373
- )
2374
- }
2375
- ) });
2376
- case "NO_TOKENS":
2377
- default:
2378
- return /* @__PURE__ */ c(
2379
- ke,
2380
- {
2381
- className: "pt-sw-5xl pb-sw-5xl",
2382
- subHeading: u(
2383
- "tokens.list.noBalanceOnApp.subLabel",
2384
- "Deposit funds to get started"
2385
- ),
2386
- heading: u("tokens.list.noBalanceOnApp.label", {
2387
- defaultValue: "You have no balances on {{appName}}",
2388
- appName: T
2389
- })
2390
- }
2391
- );
2392
- }
2393
- }, Si = Object.assign(As, {
2394
- Placeholder: ke,
2395
- Item: bt
2396
- }), _s = (e, t) => {
2397
- const s = t.assetId.substring(t.assetId.indexOf(":") + 1), r = (a) => {
2398
- const l = (u) => u.replace(/(\.\d*?[1-9])0+$/, "$1").replace(/\.0+$/, ""), i = l(t.amount), d = l(
2399
- a.amount.toLocaleString("en-US", {
2400
- useGrouping: !1,
2401
- maximumFractionDigits: 20
2402
- })
2403
- );
2404
- return i.startsWith(d) || d.startsWith(i);
2405
- }, n = (a) => new Date(a.created_at) >= new Date(t.initiatedAtDate);
2406
- return (e.result.deposits || []).find(
2407
- (a) => a.chain === t.chainId && a.account_id === t.intentsAccountId && a.address === t.depositAddress && a.near_token_id === s && n(a) && r(a)
2408
- );
2409
- }, Ns = {
2410
- CREDITED: ee.status.PROCESSING,
2411
- PENDING: ee.status.PROCESSING,
2412
- COMPLETED: ee.status.SUCCESS,
2413
- FAILED: ee.status.FAILED
2414
- }, Ai = ({ depositAddress: e }) => {
2415
- const { ctx: t } = N(), { intentsAccountType: s } = E(), [r, n] = se(null), a = te({
2416
- addressType: s,
2417
- walletAddress: t.walletAddress
2418
- });
2419
- return { pollDepositStatus: async ({
2420
- blockchain: i,
2421
- amount: d,
2422
- assetId: u
2423
- }) => {
2424
- if (!a)
2425
- throw new W("Unknown intents account for POA deposit check");
2426
- let o = rt[i];
2427
- if (!o)
2428
- if (V(i))
2429
- o = st;
2430
- else
2431
- throw new W(
2432
- `Unknown chain for POA deposit check ${i}`
2433
- );
2434
- const m = r ?? (/* @__PURE__ */ new Date()).toUTCString();
2435
- r || n(m);
2436
- const T = await ct.post("", {
2437
- id: 1,
2438
- jsonrpc: "2.0",
2439
- method: "recent_deposits",
2440
- params: [
2441
- {
2442
- account_id: a,
2443
- chain: o
2444
- }
2445
- ]
2446
- }), h = _s(T.data, {
2447
- intentsAccountId: a,
2448
- initiatedAtDate: m,
2449
- depositAddress: e,
2450
- chainId: o,
2451
- assetId: u,
2452
- amount: d
2453
- });
2454
- return h ? {
2455
- status: Ns[h.status],
2456
- swapDetails: {
2457
- intentHashes: [""],
2458
- destinationChainTxHashes: [{ hash: h.tx_hash ?? "" }]
2459
- }
2460
- } : {
2461
- status: ee.status.PENDING_DEPOSIT,
2462
- swapDetails: {
2463
- destinationChainTxHashes: [{ hash: "" }],
2464
- intentHashes: [""]
2465
- }
2466
- };
2467
- } };
2468
- }, Es = (e) => null, bs = (e) => (t) => {
2469
- if (t instanceof W)
2470
- throw t;
2471
- const s = new W(
2472
- t instanceof Error ? t.message : "Unknown error",
2473
- { cause: t }
2474
- );
2475
- throw s.context = e, s;
2476
- }, ys = ({ children: e }) => {
2477
- const { ctx: t } = N();
2478
- return /* @__PURE__ */ c(
2479
- gr,
2480
- {
2481
- FallbackComponent: Es,
2482
- onError: bs(t),
2483
- children: e
2484
- }
2485
- );
2486
- }, Rs = new Pt({
2487
- defaultOptions: {
2488
- queries: {
2489
- staleTime: 2e3 * 60,
2490
- retry: Je.env.NODE_ENV === "test" ? !1 : 3
2491
- }
2492
- }
2493
- }), Ds = ["fms", "abg", "stjack", "noear", "testnebula"], ae = {
2494
- appName: "Unknown",
2495
- appIcon: "https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg",
2496
- slippageTolerance: 100,
2497
- // 1%
2498
- intentsAccountType: "evm",
2499
- walletSupportedChains: zt,
2500
- connectedWallets: {},
2501
- enableAutoTokensSwitching: !0,
2502
- showIntentTokens: !0,
2503
- chainsOrder: nt,
2504
- filterTokens: (e) => !Ds.includes(e.symbol.toLocaleLowerCase()),
2505
- chainsFilter: {
2506
- source: { external: "wallet-supported", intents: "none" },
2507
- target: { external: "all", intents: "none" }
2508
- }
2509
- }, yt = Bt({
2510
- config: ae
2511
- }), Be = et({
2512
- config: ae
2513
- }), E = () => {
2514
- const e = Lt(yt);
2515
- return oe(e).config;
2516
- }, Cs = (e) => {
2517
- Be.config = me(e);
2518
- }, _i = ({
2519
- children: e,
2520
- config: t,
2521
- balanceViaRpc: s = !0,
2522
- // you don't usually want to disable it
2523
- localisation: r,
2524
- rpcs: n,
2525
- theme: a
2526
- }) => {
2527
- const l = z(
2528
- et({
2529
- config: me({
2530
- ...ae,
2531
- ...t
2532
- })
2533
- })
2534
- );
2535
- return R(() => {
2536
- const i = me({
2537
- ...ae,
2538
- ...t
2539
- });
2540
- Object.assign(l.current.config, i), Cs(i);
2541
- }, [t]), Qt(r ?? {}), hr("headlessui-portal-root", "sw"), /* @__PURE__ */ c(Wt, { client: Rs, children: /* @__PURE__ */ c(Vt, { i18n: Dt, children: /* @__PURE__ */ k(yt.Provider, { value: l.current, children: [
2542
- /* @__PURE__ */ k(Ct, { children: [
2543
- /* @__PURE__ */ k(vt, { children: [
2544
- /* @__PURE__ */ c("link", { rel: "preconnect", href: "https://rsms.me/" }),
2545
- /* @__PURE__ */ c("link", { rel: "stylesheet", href: "https://rsms.me/inter/inter.css" })
2546
- ] }),
2547
- /* @__PURE__ */ c(pr, { theme: a, children: Je.env.NODE_ENV === "test" ? e : /* @__PURE__ */ c(ys, { children: e }) })
2548
- ] }),
2549
- s && /* @__PURE__ */ c(
2550
- vr,
2551
- {
2552
- rpcs: n ?? Tr,
2553
- connectedWallets: t.connectedWallets ?? {}
2554
- }
2555
- )
2556
- ] }) }) });
2557
- };
2558
- export {
2559
- ts as $,
2560
- Nr as A,
2561
- vr as B,
2562
- Ke as C,
2563
- Fr as D,
2564
- Lr as E,
2565
- Br as F,
2566
- qr as G,
2567
- Wr as H,
2568
- wt as I,
2569
- kt as J,
2570
- St as K,
2571
- At as L,
2572
- _t as M,
2573
- Mr as N,
2574
- Vr as O,
2575
- Qr as P,
2576
- q as Q,
2577
- $r as R,
2578
- fs as S,
2579
- Is as T,
2580
- Kr as U,
2581
- Hr as V,
2582
- _i as W,
2583
- Gr as X,
2584
- jr as Y,
2585
- Xr as Z,
2586
- Jr as _,
2587
- Ii as a,
2588
- ns as a0,
2589
- ps as a1,
2590
- Ts as a2,
2591
- Fe as a3,
2592
- Le as a4,
2593
- Et as a5,
2594
- hs as a6,
2595
- gs as a7,
2596
- Ze as a8,
2597
- bt as a9,
2598
- ws as aa,
2599
- As as ab,
2600
- ys as ac,
2601
- Be as ad,
2602
- N as b,
2603
- hi as c,
2604
- xr as d,
2605
- Dr as e,
2606
- ie as f,
2607
- as as g,
2608
- Pr as h,
2609
- os as i,
2610
- es as j,
2611
- ce as k,
2612
- cs as l,
2613
- ks as m,
2614
- P as n,
2615
- wi as o,
2616
- ki as p,
2617
- Si as q,
2618
- Yr as r,
2619
- Nt as s,
2620
- It as t,
2621
- G as u,
2622
- W as v,
2623
- g as w,
2624
- gi as x,
2625
- E as y,
2626
- Ai as z
2627
- };
2628
- //# sourceMappingURL=config-1EcDCy24.js.map