@aurora-is-near/intents-swap-widget 3.15.3 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/TokenIcon.d.ts +5 -12
- package/dist/components/TokenIcon.js +34 -32
- package/dist/components/TokenIcon.js.map +1 -1
- package/dist/{config-DKdwFIJc.js → config-DQMHUj5z.js} +745 -748
- package/dist/config-DQMHUj5z.js.map +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/constants/chains.d.ts +0 -1
- package/dist/constants/chains.js +44 -65
- package/dist/constants/chains.js.map +1 -1
- package/dist/constants/tokens.d.ts +1 -1
- package/dist/constants/tokens.js +3 -50
- package/dist/constants/tokens.js.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/ext/alchemy/index.js +1 -1
- package/dist/ext/index.js +1 -1
- package/dist/features/BalanceRpcLoader/TokenBalanceLoader.js +1 -1
- package/dist/features/BalanceRpcLoader/index.js +1 -1
- package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
- package/dist/features/ChainsDropdown/index.js +32 -32
- package/dist/features/ChainsDropdown/index.js.map +1 -1
- package/dist/features/DepositMethodSwitcher.js +1 -1
- package/dist/features/ErrorBoundary.js +1 -1
- package/dist/features/ExternalDeposit.js +1 -1
- package/dist/features/SendAddress/index.js +1 -1
- package/dist/features/SendAddress/useNotification.js +1 -1
- package/dist/features/SubmitButton/index.js +1 -1
- package/dist/features/SuccessScreen/index.js +1 -1
- package/dist/features/SwapDirectionSwitcher.js +1 -1
- package/dist/features/SwapQuote/SwapQuote.js +1 -1
- package/dist/features/SwapQuote/index.js +1 -1
- package/dist/features/TokenInput/TokenInput.js +1 -1
- package/dist/features/TokenInput/TokenInputEmpty.js +1 -1
- package/dist/features/TokenInput/TokenInputSource.js +1 -1
- package/dist/features/TokenInput/TokenInputTarget.js +1 -1
- package/dist/features/TokenInput/WalletBalance.js +1 -1
- package/dist/features/TokenInput/hooks/index.js +1 -1
- package/dist/features/TokenInput/hooks/useTokenInputBalance.js +1 -1
- package/dist/features/TokenInput/index.js +1 -1
- package/dist/features/TokensList/TokenItem.js +1 -1
- package/dist/features/TokensList/TokensList.js +1 -1
- package/dist/features/TokensList/index.js +1 -1
- package/dist/features/TokensModal.js +1 -1
- package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +1 -1
- package/dist/features/WalletCompatibilityCheck/index.js +1 -1
- package/dist/features/index.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useAllTokens.js +1 -1
- package/dist/hooks/useChains.js +1 -1
- package/dist/hooks/useCompatibilityCheck.js +1 -1
- package/dist/hooks/useDefaultToken.js +1 -1
- package/dist/hooks/useExternalDepositStatus/index.js +1 -1
- package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
- package/dist/hooks/useIntentsBalance.js +1 -1
- package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
- package/dist/hooks/useMakeDepositAddress.js +1 -1
- package/dist/hooks/useMakeIntentsTransfer.js +1 -1
- package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
- package/dist/hooks/useMakeQuote.js +1 -1
- package/dist/hooks/useMakeQuoteTransfer.js +1 -1
- package/dist/hooks/useMakeTransfer.js +1 -1
- package/dist/hooks/useMergedBalance.js +1 -1
- package/dist/hooks/useSwitchChain.js +1 -1
- package/dist/hooks/useTheme.js +1 -1
- package/dist/hooks/useTokenInputPair.js +1 -1
- package/dist/hooks/useTokens.js +2 -2
- package/dist/hooks/useTokensFiltered.js +1 -1
- package/dist/hooks/useTokensIntentsUnique.js +1 -1
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +392 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/machine/effects/index.js +1 -1
- package/dist/machine/effects/useAlchemyBalanceEffect.js +1 -1
- package/dist/machine/effects/useBalancesUpdateEffect.js +1 -1
- package/dist/machine/effects/useMakeQuoteEffect.js +1 -1
- package/dist/machine/effects/useSelectedTokensEffect.d.ts +0 -2
- package/dist/machine/effects/useSelectedTokensEffect.js +1 -1
- package/dist/machine/effects/useSetTokenBalanceEffect.js +1 -1
- package/dist/machine/effects/useSetTokenIntentsTargetEffect.js +1 -1
- package/dist/machine/effects/useWalletConnEffect.js +1 -1
- package/dist/machine/events/index.js +1 -1
- package/dist/machine/events/tokenSelect.js +1 -1
- package/dist/machine/events/validateInputAndMoveTo.js +1 -1
- package/dist/machine/events/validateInputs.js +1 -1
- package/dist/machine/index.js +1 -1
- package/dist/machine/snap.d.ts +0 -18
- package/dist/machine/snap.js +1 -1
- package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
- package/dist/machine/subscriptions/index.js +1 -1
- package/dist/theme/ThemeProvider.js +1 -1
- package/dist/types/chain.d.ts +0 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/token.d.ts +0 -1
- package/dist/utils/intents/signers/near.js +1 -1
- package/dist/utils/intents/signers/privy.js +1 -1
- package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
- package/package.json +1 -1
- package/src/components/TokenIcon.tsx +35 -38
- package/src/config.tsx +0 -2
- package/src/constants/chains.ts +0 -23
- package/src/constants/tokens.ts +1 -48
- package/src/features/ChainsDropdown/index.tsx +5 -5
- package/src/features/TokenInput/TokenInput.tsx +1 -1
- package/src/features/TokensList/TokenItem.tsx +1 -1
- package/src/hooks/useTokens.ts +1 -8
- package/src/icons/abg.svg +11 -0
- package/src/icons/arb.svg +22 -0
- package/src/icons/aster.svg +1 -0
- package/src/icons/aurora.svg +14 -0
- package/src/icons/avax.svg +12 -0
- package/src/icons/base.svg +11 -0
- package/src/icons/bera.svg +20 -0
- package/src/icons/bsc.svg +14 -0
- package/src/icons/btc.svg +11 -0
- package/src/icons/cardano.svg +40 -0
- package/src/icons/doge.svg +15 -0
- package/src/icons/eth.svg +16 -0
- package/src/icons/frax.svg +26 -0
- package/src/icons/gnear.svg +1 -0
- package/src/icons/gnosis.svg +16 -0
- package/src/icons/index.tsx +111 -0
- package/src/icons/itlx.svg +12 -0
- package/src/icons/jambo.svg +10 -0
- package/src/icons/knc.svg +1 -0
- package/src/icons/loud.svg +7 -0
- package/src/icons/ltc.svg +1 -0
- package/src/icons/mon.svg +1 -0
- package/src/icons/mpdao.svg +1 -0
- package/src/icons/near.svg +16 -0
- package/src/icons/noear.svg +10 -0
- package/src/icons/op.svg +12 -0
- package/src/icons/pol.svg +11 -0
- package/src/icons/public.svg +1 -0
- package/src/icons/purge.svg +10 -0
- package/src/icons/rhea.svg +10 -0
- package/src/icons/sol.svg +21 -0
- package/src/icons/sui.svg +16 -0
- package/src/icons/ton.svg +11 -0
- package/src/icons/tron.svg +11 -0
- package/src/icons/unknown.svg +4 -0
- package/src/icons/usd1.svg +10 -0
- package/src/icons/usdf.svg +10 -0
- package/src/icons/wif.svg +10 -0
- package/src/icons/xdai.svg +22 -0
- package/src/icons/xrp.svg +17 -0
- package/src/icons/zec.svg +16 -0
- package/src/types/chain.ts +0 -1
- package/src/types/config.ts +1 -1
- package/src/types/token.ts +0 -1
- package/dist/config-DKdwFIJc.js.map +0 -1
|
@@ -1,262 +1,260 @@
|
|
|
1
|
-
import { p as
|
|
2
|
-
import { jsx as o, jsxs as
|
|
3
|
-
import
|
|
1
|
+
import { p as tt } from "./index-xuotMAFm.js";
|
|
2
|
+
import { jsx as o, jsxs as h, Fragment as Lt } from "react/jsx-runtime";
|
|
3
|
+
import Bt from "i18next";
|
|
4
4
|
import { deepClone as pe } from "valtio/utils";
|
|
5
|
-
import { snapshot as
|
|
6
|
-
import { HelmetProvider as
|
|
7
|
-
import { memo as
|
|
8
|
-
import { useQuery as _e, useInfiniteQuery as
|
|
9
|
-
import { Trans as
|
|
10
|
-
import { useTypedTranslation as V, initLocalisation as
|
|
5
|
+
import { snapshot as Ne, useSnapshot as oe, proxy as nt } from "valtio";
|
|
6
|
+
import { HelmetProvider as qt, Helmet as Ut } from "react-helmet-async";
|
|
7
|
+
import { memo as Pt, useEffect as R, useMemo as v, useRef as Y, useCallback as Te, useState as re, useId as Wt, Fragment as Mt, createContext as st, useContext as Vt } from "react";
|
|
8
|
+
import { useQuery as _e, useInfiniteQuery as Qt, useQueryClient as $t, QueryClient as Kt, QueryClientProvider as Ht } from "@tanstack/react-query";
|
|
9
|
+
import { Trans as Gt, I18nextProvider as jt } from "react-i18next";
|
|
10
|
+
import { useTypedTranslation as V, initLocalisation as zt } from "./localisation.js";
|
|
11
11
|
import { logger as b } from "./logger.js";
|
|
12
|
-
import { getTonTokenBalance as
|
|
13
|
-
import { getSolanaTokenBalance as
|
|
14
|
-
import { useWalletAddressForToken as
|
|
12
|
+
import { getTonTokenBalance as Yt } from "./utils/ton/getTonTokenBalance.js";
|
|
13
|
+
import { getSolanaTokenBalance as Zt } from "./utils/solana/getSolanaTokenBalance.js";
|
|
14
|
+
import { useWalletAddressForToken as rt } from "./hooks/useWalletAddressForToken.js";
|
|
15
15
|
import "@headlessui/react";
|
|
16
16
|
import "framer-motion";
|
|
17
17
|
import "lucide-react";
|
|
18
18
|
import "./features/ChainsDropdown/ChainItem.js";
|
|
19
19
|
import { cn as H } from "./utils/cn.js";
|
|
20
|
-
import { OneClickService as
|
|
21
|
-
import { CHAINS_LIST as
|
|
20
|
+
import { OneClickService as Xt, QuoteRequest as U, GetExecutionStatusResponse as ee } from "@defuse-protocol/one-click-sdk-typescript";
|
|
21
|
+
import { CHAINS_LIST as at, DEFAULT_CHAINS_ORDER as ot, CHAIN_POA_MAP as it, POA_EVM_CHAIN_ID as lt, CHAIN_BASE_TOKENS as Jt, EVM_CHAIN_IDS_MAP as he, CHAIN_IDS_MAP as en, EVM_CHAINS as tn } from "./constants/chains.js";
|
|
22
22
|
import "use-debounce";
|
|
23
|
-
import { derive as
|
|
24
|
-
import { getIsNativeNearDeposit as
|
|
25
|
-
import { getIsDirectTokenOnNearDeposit as
|
|
23
|
+
import { derive as nn } from "derive-valtio";
|
|
24
|
+
import { getIsNativeNearDeposit as sn } from "./machine/computed/getIsNativeNearDeposit.js";
|
|
25
|
+
import { getIsDirectTokenOnNearDeposit as rn } from "./machine/computed/getIsDirectTokenOnNearDeposit.js";
|
|
26
26
|
import "ethers";
|
|
27
27
|
import { moveTo as O, machine as Z } from "./machine/machine.js";
|
|
28
|
-
import
|
|
28
|
+
import an from "lodash.once";
|
|
29
29
|
import { guardStates as D } from "./machine/guards/index.js";
|
|
30
|
-
import { parse as
|
|
31
|
-
import { createLoader as
|
|
32
|
-
import { isAlchemySupportedChain as
|
|
30
|
+
import { parse as on } from "./ext/alchemy/parse.js";
|
|
31
|
+
import { createLoader as ln } from "./ext/alchemy/load.js";
|
|
32
|
+
import { isAlchemySupportedChain as cn } from "./ext/alchemy/types.js";
|
|
33
33
|
import { fireEvent as p } from "./machine/events/utils/fireEvent.js";
|
|
34
|
-
import { NATIVE_NEAR_DUMB_ASSET_ID as $, TOKENS_DATA as
|
|
35
|
-
import { isValidChain as
|
|
36
|
-
import { useWalletBalance as
|
|
34
|
+
import { NATIVE_NEAR_DUMB_ASSET_ID as $, TOKENS_DATA as ye, WNEAR_ASSET_ID as ge } from "./constants/tokens.js";
|
|
35
|
+
import { isValidChain as dn } from "./utils/checkers/isValidChain.js";
|
|
36
|
+
import { useWalletBalance as be } from "./hooks/useWalletBalance.js";
|
|
37
37
|
import { getIntentsAccountId as te } from "./utils/intents/getIntentsAccountId.js";
|
|
38
|
-
import { getIntentsBalances as
|
|
39
|
-
import { notReachable as
|
|
38
|
+
import { getIntentsBalances as un } from "./utils/intents/getIntentsBalance.js";
|
|
39
|
+
import { notReachable as Ee } from "./utils/notReachable.js";
|
|
40
40
|
import { getTokenBalanceKey as G } from "./utils/intents/getTokenBalanceKey.js";
|
|
41
41
|
import { isDryQuote as Re } from "./machine/guards/checks/isDryQuote.js";
|
|
42
|
-
import { snakeCase as
|
|
43
|
-
import
|
|
44
|
-
import { oneClickApi as Ie, bridgeApi as
|
|
42
|
+
import { snakeCase as ct } from "change-case";
|
|
43
|
+
import mn, { CanceledError as dt, AxiosError as ut } from "axios";
|
|
44
|
+
import { oneClickApi as Ie, bridgeApi as mt } from "./network.js";
|
|
45
45
|
import { formatBigToHuman as j } from "./utils/formatters/formatBigToHuman.js";
|
|
46
|
-
import { getDryQuoteAddress as
|
|
46
|
+
import { getDryQuoteAddress as Ue } from "./utils/getDryQuoteAddress.js";
|
|
47
47
|
import { isEvmChain as Q } from "./utils/evm/isEvmChain.js";
|
|
48
|
-
import { checkNearAccountExists as
|
|
48
|
+
import { checkNearAccountExists as fn } from "./utils/near/checkNearAccountExists.js";
|
|
49
49
|
import { isNotEmptyAmount as ne } from "./utils/checkers/isNotEmptyAmount.js";
|
|
50
|
-
import { isValidBigint as
|
|
51
|
-
import { isNearAddress as
|
|
52
|
-
import { isBalanceSufficient as
|
|
53
|
-
import { isQuoteError as
|
|
50
|
+
import { isValidBigint as ft } from "./utils/checkers/isValidBigint.js";
|
|
51
|
+
import { isNearAddress as pt } from "./utils/near/isNearAddress.js";
|
|
52
|
+
import { isBalanceSufficient as Ce } from "./machine/guards/checks/isBalanceSufficient.js";
|
|
53
|
+
import { isQuoteError as ve, isTransferError as De, isAsyncSendAddressValidationError as pn } from "./machine/errors.js";
|
|
54
54
|
import { isSolanaAddress as Tt } from "./utils/solana/isSolanaAddress.js";
|
|
55
|
-
import { isEvmAddress as
|
|
56
|
-
import { getMainTokenByChain as
|
|
57
|
-
import { getDefaultIntentsToken as
|
|
58
|
-
import { getTokenWithHighBalance as
|
|
59
|
-
import { isQuoteIdle as
|
|
60
|
-
import { isInputChanged as
|
|
61
|
-
import { isErrorChanged as
|
|
62
|
-
import { isOnlyErrorChanged as
|
|
63
|
-
import { isValidInitialState as
|
|
64
|
-
import { isWalletDisconnected as
|
|
65
|
-
import { isSendAddressForbidden as
|
|
66
|
-
import { isAmountChangedFromQuote as
|
|
67
|
-
import { reset as
|
|
55
|
+
import { isEvmAddress as ht } from "./utils/evm/isEvmAddress.js";
|
|
56
|
+
import { getMainTokenByChain as Tn } from "./utils/tokens/getMainTokenByChain.js";
|
|
57
|
+
import { getDefaultIntentsToken as hn } from "./utils/tokens/getDefaultIntentsToken.js";
|
|
58
|
+
import { getTokenWithHighBalance as gn } from "./utils/tokens/getTokenWithHighBalance.js";
|
|
59
|
+
import { isQuoteIdle as In } from "./machine/subscriptions/checkers/isQuoteIdle.js";
|
|
60
|
+
import { isInputChanged as wn } from "./machine/subscriptions/checkers/isInputChanged.js";
|
|
61
|
+
import { isErrorChanged as kn } from "./machine/subscriptions/checkers/isErrorChanged.js";
|
|
62
|
+
import { isOnlyErrorChanged as An } from "./machine/subscriptions/checkers/isOnlyErrorChanged.js";
|
|
63
|
+
import { isValidInitialState as Sn } from "./machine/subscriptions/checkers/isValidInitialState.js";
|
|
64
|
+
import { isWalletDisconnected as Nn } from "./machine/subscriptions/checkers/isWalletDisconnected.js";
|
|
65
|
+
import { isSendAddressForbidden as _n } from "./machine/subscriptions/checkers/isSendAddressForbidden.js";
|
|
66
|
+
import { isAmountChangedFromQuote as yn } from "./machine/subscriptions/checkers/isAmountChangedFromQuote.js";
|
|
67
|
+
import { reset as bn } from "./machine/events/reset.js";
|
|
68
68
|
import { tokenSelectRotate as we } from "./machine/events/tokenSelectRotate.js";
|
|
69
|
-
import { errorSet as
|
|
70
|
-
import { quoteSet as
|
|
71
|
-
import { addressSet as
|
|
72
|
-
import { tokenSetAmount as
|
|
73
|
-
import { quoteSetStatus as
|
|
74
|
-
import { depositTypeSet as
|
|
75
|
-
import { externalDepositTxSet as
|
|
76
|
-
import { setInputsValidating as
|
|
77
|
-
import { walletAddressSet as
|
|
78
|
-
import { tokenSetBalance as
|
|
79
|
-
import { transferSetStatus as
|
|
80
|
-
import { getUsdTradeDelta as
|
|
81
|
-
import { getIsDirectNonNearWithdrawal as
|
|
82
|
-
import { getIsDirectTokenOnNearTransfer as
|
|
83
|
-
import { getIsDirectNearTokenWithdrawal as
|
|
84
|
-
import { getIsSameAssetDiffChainWithdrawal as
|
|
69
|
+
import { errorSet as En } from "./machine/events/errorSet.js";
|
|
70
|
+
import { quoteSet as Rn } from "./machine/events/quoteSet.js";
|
|
71
|
+
import { addressSet as Cn } from "./machine/events/addressSet.js";
|
|
72
|
+
import { tokenSetAmount as vn } from "./machine/events/tokenSetAmount.js";
|
|
73
|
+
import { quoteSetStatus as Dn } from "./machine/events/quoteSetStatus.js";
|
|
74
|
+
import { depositTypeSet as xn } from "./machine/events/depositTypeSet.js";
|
|
75
|
+
import { externalDepositTxSet as On } from "./machine/events/externalDepositTxSet.js";
|
|
76
|
+
import { setInputsValidating as Fn } from "./machine/events/setInputsValidating.js";
|
|
77
|
+
import { walletAddressSet as Ln } from "./machine/events/walletAddressSet.js";
|
|
78
|
+
import { tokenSetBalance as Bn } from "./machine/events/tokenSetBalance.js";
|
|
79
|
+
import { transferSetStatus as qn } from "./machine/events/transferSetStatus.js";
|
|
80
|
+
import { getUsdTradeDelta as Un } from "./machine/computed/getUsdTradeDelta.js";
|
|
81
|
+
import { getIsDirectNonNearWithdrawal as Pn } from "./machine/computed/getIsDirectNonNearWithdrawal.js";
|
|
82
|
+
import { getIsDirectTokenOnNearTransfer as Wn } from "./machine/computed/getIsDirectTokenOnNearTransfer.js";
|
|
83
|
+
import { getIsDirectNearTokenWithdrawal as Mn } from "./machine/computed/getIsDirectNearTokenWithdrawal.js";
|
|
84
|
+
import { getIsSameAssetDiffChainWithdrawal as Vn } from "./machine/computed/getIsSameAssetDiffChainWithdrawal.js";
|
|
85
85
|
import "viem";
|
|
86
86
|
import { Button as A } from "./components/Button.js";
|
|
87
|
-
import { TinyNumber as
|
|
87
|
+
import { TinyNumber as xe } from "./components/TinyNumber.js";
|
|
88
88
|
import { ErrorMessage as K } from "./components/ErrorMessage.js";
|
|
89
|
-
import { FT_DEPOSIT_GAS as
|
|
90
|
-
import { a as
|
|
89
|
+
import { FT_DEPOSIT_GAS as Pe, FT_TRANSFER_GAS as We } from "./utils/near/config.js";
|
|
90
|
+
import { a as Oe } from "./index-DEq3oXQF.js";
|
|
91
91
|
import { z as se } from "zod";
|
|
92
|
-
import { decodeQueryResult as
|
|
93
|
-
import { nearRpcClient as
|
|
94
|
-
import { getNearNep141MinStorageBalance as
|
|
92
|
+
import { decodeQueryResult as Qn } from "./utils/near/decodeQueryResult.js";
|
|
93
|
+
import { nearRpcClient as $n } from "./utils/near/rpc.js";
|
|
94
|
+
import { getNearNep141MinStorageBalance as Kn } from "./utils/near/getNearNep141MinStorageBalance.js";
|
|
95
95
|
import { INTENTS_CONTRACT as ke } from "./constants/intents.js";
|
|
96
|
-
import { isEvmBaseToken as
|
|
97
|
-
import { useMakeEvmTransfer as
|
|
98
|
-
import { useMakeSolanaTransfer as
|
|
96
|
+
import { isEvmBaseToken as gt } from "./utils/evm/isEvmBaseToken.js";
|
|
97
|
+
import { useMakeEvmTransfer as Hn } from "./hooks/useMakeEvmTransfer.js";
|
|
98
|
+
import { useMakeSolanaTransfer as Gn } from "./hooks/useMakeSolanaTransfer.js";
|
|
99
99
|
import { isUserDeniedSigning as Ae } from "./utils/checkers/isUserDeniedSigning.js";
|
|
100
|
-
import { createIntentSignerNEP413 as
|
|
101
|
-
import { generateRandomBytes as
|
|
102
|
-
import { IntentSignerSolana as
|
|
103
|
-
import { localStorageTyped as
|
|
104
|
-
import { queryContract as
|
|
105
|
-
import { utils as
|
|
106
|
-
import { getTransactionLink as
|
|
107
|
-
import { switchEthereumChain as
|
|
100
|
+
import { createIntentSignerNEP413 as jn, BridgeSDK as zn, createNearWithdrawalRoute as Yn, createInternalTransferRoute as Zn, MinWithdrawalAmountError as Xn, FeeExceedsAmountError as Jn } from "@defuse-protocol/bridge-sdk";
|
|
101
|
+
import { generateRandomBytes as es } from "./utils/near/getRandomBytes.js";
|
|
102
|
+
import { IntentSignerSolana as ts } from "./utils/intents/signers/solana.js";
|
|
103
|
+
import { localStorageTyped as Me } from "./utils/localstorage.js";
|
|
104
|
+
import { queryContract as ns } from "./utils/near/queryContract.js";
|
|
105
|
+
import { utils as Ve } from "@defuse-protocol/internal-utils";
|
|
106
|
+
import { getTransactionLink as ss } from "./utils/formatters/getTransactionLink.js";
|
|
107
|
+
import { switchEthereumChain as rs } from "./utils/evm/switchEthereumChain.js";
|
|
108
108
|
import "copy-text-to-clipboard";
|
|
109
|
-
import { SwapQuoteSkeleton as
|
|
109
|
+
import { SwapQuoteSkeleton as It } from "./features/SwapQuote/SwapQuoteSkeleton.js";
|
|
110
110
|
import { Notes as de } from "./components/Notes.js";
|
|
111
|
-
import { Accordion as
|
|
112
|
-
import { formatUsdAmount as
|
|
113
|
-
import { formatTinyNumber as
|
|
114
|
-
import
|
|
115
|
-
import { Skeleton as
|
|
116
|
-
import { getBalancePortion as
|
|
117
|
-
import { getUsdDisplayAmount as
|
|
118
|
-
import { TokenInputHeading as
|
|
119
|
-
import { noop as
|
|
111
|
+
import { Accordion as as } from "./components/Accordion.js";
|
|
112
|
+
import { formatUsdAmount as Qe } from "./utils/formatters/formatUsdAmount.js";
|
|
113
|
+
import { formatTinyNumber as os } from "./utils/formatters/formatTinyNumber.js";
|
|
114
|
+
import is from "clsx";
|
|
115
|
+
import { Skeleton as ls } from "./components/Skeleton.js";
|
|
116
|
+
import { getBalancePortion as cs } from "./features/TokenInput/utils/getBalancePortion.js";
|
|
117
|
+
import { getUsdDisplayAmount as ds } from "./features/TokenInput/utils/getUsdDisplayAmount.js";
|
|
118
|
+
import { TokenInputHeading as wt } from "./features/TokenInput/TokenInputHeading.js";
|
|
119
|
+
import { noop as us } from "./utils/noop.js";
|
|
120
120
|
import { Card as ie } from "./components/Card.js";
|
|
121
|
-
import { Badge as
|
|
122
|
-
import { TokenIcon as
|
|
123
|
-
import { InputAmount as
|
|
124
|
-
import { TokenInputSkeleton as
|
|
125
|
-
import { getUsdDisplayBalance as
|
|
126
|
-
import { VList as
|
|
127
|
-
import { TokensListPlaceholder as
|
|
128
|
-
import { Hr as
|
|
129
|
-
import { createTokenSorter as
|
|
130
|
-
import { createFilterByIntents as
|
|
131
|
-
import { createFilterBySearch as
|
|
132
|
-
import { createFilterBySelectedChain as
|
|
121
|
+
import { Badge as $e } from "./components/Badge.js";
|
|
122
|
+
import { TokenIcon as kt } from "./components/TokenIcon.js";
|
|
123
|
+
import { InputAmount as ms } from "./components/InputAmount.js";
|
|
124
|
+
import { TokenInputSkeleton as fs } from "./features/TokenInput/TokenInputSkeleton.js";
|
|
125
|
+
import { getUsdDisplayBalance as ps } from "./utils/formatters/getUsdDisplayBalance.js";
|
|
126
|
+
import { VList as Ts } from "virtua";
|
|
127
|
+
import { TokensListPlaceholder as Se } from "./features/TokensList/TokensListPlaceholder.js";
|
|
128
|
+
import { Hr as hs } from "./components/Hr.js";
|
|
129
|
+
import { createTokenSorter as gs } from "./utils/tokens/sort.js";
|
|
130
|
+
import { createFilterByIntents as Ke } from "./utils/tokens/filterByIntents.js";
|
|
131
|
+
import { createFilterBySearch as Is } from "./utils/tokens/filterBySearchString.js";
|
|
132
|
+
import { createFilterBySelectedChain as ws } from "./utils/tokens/filterBySelectedChain.js";
|
|
133
133
|
import "bs58";
|
|
134
134
|
import "viem/chains";
|
|
135
|
-
import { isBrowser as
|
|
135
|
+
import { isBrowser as At } from "browser-or-node";
|
|
136
136
|
import "qrcode.react";
|
|
137
|
-
import { createColorPalette as
|
|
138
|
-
import { ArmingCountdownFill as
|
|
139
|
-
import { useTimer as
|
|
137
|
+
import { createColorPalette as ks } from "./theme/createColorPalette.js";
|
|
138
|
+
import { ArmingCountdownFill as As, BeenhereFill as Ss, EncryptedFill as Ns, AccountBalanceWalletFill as _s, CheckCircleFill as ys, GppBadFill as bs } from "@material-symbols-svg/react-rounded";
|
|
139
|
+
import { useTimer as Es } from "use-timer";
|
|
140
140
|
import { useHandleKeyDown as St } from "./hooks/useHandleKeyDown.js";
|
|
141
|
-
import { CloseButton as
|
|
142
|
-
import { DEFAULT_RPCS as
|
|
143
|
-
import { useAddClassToPortal as
|
|
144
|
-
import { ErrorBoundary as
|
|
145
|
-
import { isEvmToken as
|
|
146
|
-
import { getEvmMainTokenBalance as
|
|
147
|
-
import { getNativeNearBalance as
|
|
148
|
-
import { getNearTokenBalance as
|
|
149
|
-
import { getEvmTokenBalance as
|
|
150
|
-
function
|
|
151
|
-
const { walletSupportedChains: s, tonCenterApiKey: n, alchemyApiKey: a } = y(), { walletAddress:
|
|
141
|
+
import { CloseButton as Nt } from "./components/CloseButton.js";
|
|
142
|
+
import { DEFAULT_RPCS as Rs } from "./rpcs.js";
|
|
143
|
+
import { useAddClassToPortal as Cs } from "./hooks/useAddClassToPortal.js";
|
|
144
|
+
import { ErrorBoundary as vs } from "react-error-boundary";
|
|
145
|
+
import { isEvmToken as Ds } from "./utils/evm/isEvmToken.js";
|
|
146
|
+
import { getEvmMainTokenBalance as xs } from "./utils/evm/getEvmMainTokenBalance.js";
|
|
147
|
+
import { getNativeNearBalance as Os } from "./utils/near/getNativeNearBalance.js";
|
|
148
|
+
import { getNearTokenBalance as Fs } from "./utils/near/getNearTokenBalance.js";
|
|
149
|
+
import { getEvmTokenBalance as Ls } from "./utils/evm/getEvmTokenBalance.js";
|
|
150
|
+
function Bs({ rpcs: e, token: t, connectedWallets: r }) {
|
|
151
|
+
const { walletSupportedChains: s, tonCenterApiKey: n, alchemyApiKey: a } = y(), { walletAddress: c } = rt(r, t);
|
|
152
152
|
return _e({
|
|
153
153
|
retry: 2,
|
|
154
|
-
enabled: !!
|
|
154
|
+
enabled: !!c && Object.keys(e).includes(t.blockchain),
|
|
155
155
|
queryKey: ["tokenBalance", t.assetId, r],
|
|
156
156
|
queryFn: async () => {
|
|
157
|
-
if (!
|
|
157
|
+
if (!c)
|
|
158
158
|
return null;
|
|
159
159
|
if (t.blockchain === "near" && s.includes(t.blockchain))
|
|
160
|
-
return !e.near || e.near.length === 0 ? null : t.assetId === $ ?
|
|
160
|
+
return !e.near || e.near.length === 0 ? null : t.assetId === $ ? Os(c, e.near) : Fs(t, c, e.near);
|
|
161
161
|
if (!s.includes("eth") && Q(t.blockchain))
|
|
162
162
|
return null;
|
|
163
|
-
if (Q(t.blockchain) &&
|
|
164
|
-
const
|
|
165
|
-
return
|
|
163
|
+
if (Q(t.blockchain) && gt(t)) {
|
|
164
|
+
const l = e[t.blockchain] ?? [];
|
|
165
|
+
return l.length > 0 ? xs(c, l[0]) : null;
|
|
166
166
|
}
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
return
|
|
167
|
+
if (Ds(t) || Q(t.blockchain)) {
|
|
168
|
+
const l = e[t.blockchain] ?? [];
|
|
169
|
+
return l.length > 0 ? Ls(t, c, l[0]) : null;
|
|
170
170
|
}
|
|
171
|
-
return t.blockchain === "ton" ?
|
|
171
|
+
return t.blockchain === "ton" ? Yt(t, c, n) : t.blockchain === "sol" && s.includes(t.blockchain) ? Zt(t, c, a) : (b.warn(
|
|
172
172
|
`Failed to fetch token balance for ${t.symbol} on ${t.blockchain}`
|
|
173
173
|
), null);
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
-
const
|
|
177
|
+
const qs = ({
|
|
178
178
|
rpcs: e,
|
|
179
179
|
token: t,
|
|
180
180
|
onBalancesLoaded: r
|
|
181
|
-
}) => (
|
|
181
|
+
}) => (R(() => {
|
|
182
182
|
t.isIntent || !Object.keys(e).includes(t.blockchain) || r({ [t.assetId]: "0" });
|
|
183
|
-
}, [t.assetId]), null),
|
|
183
|
+
}, [t.assetId]), null), _t = Pt(
|
|
184
184
|
({ rpcs: e, token: t, connectedWallets: r, onBalancesLoaded: s }) => {
|
|
185
|
-
const { data: n } =
|
|
185
|
+
const { data: n } = Bs({
|
|
186
186
|
rpcs: e,
|
|
187
187
|
token: t,
|
|
188
188
|
connectedWallets: r
|
|
189
189
|
});
|
|
190
|
-
return
|
|
190
|
+
return R(() => {
|
|
191
191
|
!t.isIntent && n != null && s({ [t.assetId]: n });
|
|
192
192
|
}, [t, n, s]), null;
|
|
193
193
|
},
|
|
194
194
|
(e, t) => e.token.assetId === t.token.assetId && e.connectedWallets === t.connectedWallets
|
|
195
195
|
);
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
Zero:
|
|
199
|
-
}),
|
|
196
|
+
_t.displayName = "TokenBalanceLoader";
|
|
197
|
+
const He = Object.assign(_t, {
|
|
198
|
+
Zero: qs
|
|
199
|
+
}), Us = (e) => {
|
|
200
200
|
const t = e.toLowerCase();
|
|
201
|
-
return
|
|
202
|
-
},
|
|
201
|
+
return ye[t]?.icon ?? "";
|
|
202
|
+
}, Ps = (e) => `${e?.charAt(0).toUpperCase()}${e?.slice(1)}`, Ws = (e) => ye[e]?.name ?? e, P = (e) => {
|
|
203
203
|
const {
|
|
204
204
|
showIntentTokens: t,
|
|
205
205
|
allowedTokensList: r,
|
|
206
206
|
allowedSourceTokensList: s,
|
|
207
207
|
allowedTargetTokensList: n,
|
|
208
208
|
filterTokens: a,
|
|
209
|
-
fetchSourceTokens:
|
|
210
|
-
fetchTargetTokens:
|
|
209
|
+
fetchSourceTokens: c,
|
|
210
|
+
fetchTargetTokens: l
|
|
211
211
|
} = y(), { data: d, ...u } = _e({
|
|
212
212
|
queryKey: ["tokens", e].filter(Boolean),
|
|
213
|
-
queryFn: async () => e === "source" &&
|
|
213
|
+
queryFn: async () => e === "source" && c ? c() : e === "target" && l ? l() : Xt.getTokens()
|
|
214
214
|
}), i = v(() => {
|
|
215
215
|
if (!d)
|
|
216
216
|
return [];
|
|
217
217
|
const f = d.map((m) => {
|
|
218
218
|
const w = m.blockchain.toLowerCase();
|
|
219
|
-
return !
|
|
219
|
+
return !dn(w) || r && !r.includes(m.assetId) || e === "source" && s && !s.includes(m.assetId) || e === "target" && n && !n.includes(m.assetId) ? null : {
|
|
220
220
|
assetId: m.assetId,
|
|
221
221
|
symbol: m.symbol,
|
|
222
222
|
decimals: m.decimals,
|
|
223
223
|
price: m.price,
|
|
224
224
|
blockchain: w,
|
|
225
225
|
isIntent: !1,
|
|
226
|
-
icon: m.icon ??
|
|
227
|
-
name:
|
|
228
|
-
|
|
229
|
-
chainName: ye[m.blockchain]?.label ?? Ms(m.blockchain),
|
|
226
|
+
icon: m.icon ?? Us(m.symbol),
|
|
227
|
+
name: Ws(m.symbol),
|
|
228
|
+
chainName: at[m.blockchain]?.label ?? Ps(m.blockchain),
|
|
230
229
|
contractAddress: m.contractAddress
|
|
231
230
|
};
|
|
232
|
-
}).filter((m) => !!m).filter(a ?? (() => !0)),
|
|
231
|
+
}).filter((m) => !!m).filter(a ?? (() => !0)), T = f.filter(
|
|
233
232
|
(m) => m.symbol.toLowerCase() !== "wnear"
|
|
234
233
|
), I = f.find((m) => m.symbol.toLowerCase() === "wnear");
|
|
235
|
-
return I &&
|
|
234
|
+
return I && T.push({
|
|
236
235
|
name: "NEAR",
|
|
237
236
|
symbol: "NEAR",
|
|
238
237
|
chainName: "Near",
|
|
239
238
|
blockchain: "near",
|
|
240
239
|
assetId: $,
|
|
241
|
-
|
|
242
|
-
icon: be.near?.icon ?? "",
|
|
240
|
+
icon: ye.near?.icon ?? "",
|
|
243
241
|
price: I?.price ?? 0,
|
|
244
242
|
contractAddress: I?.contractAddress,
|
|
245
243
|
isIntent: !1,
|
|
246
244
|
decimals: 24
|
|
247
245
|
}), t ? [
|
|
248
|
-
...
|
|
246
|
+
...T,
|
|
249
247
|
// add intents tokens to the full list
|
|
250
248
|
...f.map(
|
|
251
249
|
(m) => m.symbol.toLowerCase() === "wnear" ? { ...m, symbol: "NEAR", name: "NEAR", isIntent: !0 } : { ...m, isIntent: !0 }
|
|
252
250
|
)
|
|
253
|
-
] :
|
|
251
|
+
] : T;
|
|
254
252
|
}, [d, t, a]);
|
|
255
253
|
return {
|
|
256
254
|
...u,
|
|
257
255
|
tokens: i
|
|
258
256
|
};
|
|
259
|
-
},
|
|
257
|
+
}, Ms = () => {
|
|
260
258
|
const { tokens: e } = P(), { tokens: t } = P("source"), { tokens: r } = P("target");
|
|
261
259
|
return { tokens: v(() => {
|
|
262
260
|
const n = {};
|
|
@@ -265,8 +263,8 @@ const Ge = Object.assign(yt, {
|
|
|
265
263
|
...t || [],
|
|
266
264
|
...r || []
|
|
267
265
|
].forEach((a) => {
|
|
268
|
-
const
|
|
269
|
-
n[
|
|
266
|
+
const c = `${a.assetId}-${a.isIntent}`;
|
|
267
|
+
n[c] = a;
|
|
270
268
|
}), Object.values(n);
|
|
271
269
|
}, [e, t, r]) };
|
|
272
270
|
}, ue = [
|
|
@@ -274,7 +272,7 @@ const Ge = Object.assign(yt, {
|
|
|
274
272
|
{ near: ["USDT", "USDC", "AURORA"] },
|
|
275
273
|
{ arb: ["ARB", "ETH", "USDT", "USDC"] },
|
|
276
274
|
{ btc: ["BTC"] }
|
|
277
|
-
],
|
|
275
|
+
], Vs = (e) => [...e].sort((t, r) => {
|
|
278
276
|
const s = ue.findIndex(
|
|
279
277
|
(d) => Object.keys(d)[0] === t.blockchain
|
|
280
278
|
), n = ue.findIndex(
|
|
@@ -282,39 +280,39 @@ const Ge = Object.assign(yt, {
|
|
|
282
280
|
);
|
|
283
281
|
if (s !== n)
|
|
284
282
|
return s === -1 ? 1 : n === -1 ? -1 : s - n;
|
|
285
|
-
const a = ue[s]?.[t.blockchain] ?? [],
|
|
286
|
-
return
|
|
287
|
-
}),
|
|
288
|
-
const { tokens: r } =
|
|
289
|
-
return v(() =>
|
|
290
|
-
|
|
283
|
+
const a = ue[s]?.[t.blockchain] ?? [], c = a.indexOf(t.symbol), l = a.indexOf(r.symbol);
|
|
284
|
+
return c === -1 && l === -1 ? 0 : c === -1 ? 1 : l === -1 ? -1 : c - l;
|
|
285
|
+
}), Qs = ({ rpcs: e, connectedWallets: t }) => {
|
|
286
|
+
const { tokens: r } = Ms(), { walletSupportedChains: s } = y(), { setWalletBalance: n } = be(t);
|
|
287
|
+
return v(() => Vs(r), [r]).map((c) => s.includes(c.blockchain) ? /* @__PURE__ */ o(
|
|
288
|
+
He,
|
|
291
289
|
{
|
|
292
290
|
rpcs: e,
|
|
293
|
-
token:
|
|
291
|
+
token: c,
|
|
294
292
|
connectedWallets: t,
|
|
295
|
-
onBalancesLoaded: (
|
|
293
|
+
onBalancesLoaded: (l) => n(t, l)
|
|
296
294
|
},
|
|
297
|
-
G(
|
|
295
|
+
G(c)
|
|
298
296
|
) : /* @__PURE__ */ o(
|
|
299
|
-
|
|
297
|
+
He.Zero,
|
|
300
298
|
{
|
|
301
299
|
rpcs: e,
|
|
302
|
-
token:
|
|
303
|
-
onBalancesLoaded: (
|
|
300
|
+
token: c,
|
|
301
|
+
onBalancesLoaded: (l) => n(t, l)
|
|
304
302
|
},
|
|
305
|
-
G(
|
|
303
|
+
G(c)
|
|
306
304
|
));
|
|
307
305
|
};
|
|
308
|
-
function
|
|
306
|
+
function $s(e, t) {
|
|
309
307
|
const r = Array.from(
|
|
310
|
-
/* @__PURE__ */ new Set([...t ?? [], ...
|
|
308
|
+
/* @__PURE__ */ new Set([...t ?? [], ...ot])
|
|
311
309
|
), s = new Map(r.map((n, a) => [n, a]));
|
|
312
310
|
return [...e].sort((n, a) => {
|
|
313
|
-
const
|
|
314
|
-
return
|
|
311
|
+
const c = s.has(n.id) ? s.get(n.id) : 1 / 0, l = s.has(a.id) ? s.get(a.id) : 1 / 0;
|
|
312
|
+
return c !== l ? c - l : n.id.localeCompare(a.id, void 0, { sensitivity: "base" });
|
|
315
313
|
});
|
|
316
314
|
}
|
|
317
|
-
const
|
|
315
|
+
const Ks = (e) => {
|
|
318
316
|
const {
|
|
319
317
|
chainsOrder: t,
|
|
320
318
|
allowedChainsList: r,
|
|
@@ -322,106 +320,106 @@ const Gs = (e) => {
|
|
|
322
320
|
allowedTargetChainsList: n
|
|
323
321
|
} = y(), { tokens: a } = P();
|
|
324
322
|
return v(() => {
|
|
325
|
-
const
|
|
326
|
-
new Set(a.map((
|
|
327
|
-
).filter((
|
|
328
|
-
return
|
|
323
|
+
const c = Array.from(
|
|
324
|
+
new Set(a.map((l) => at[l.blockchain]))
|
|
325
|
+
).filter((l) => !(r && !r.includes(l.id) || e === "source" && s && !s.includes(l.id) || e === "target" && n && !n.includes(l.id)));
|
|
326
|
+
return $s(c, t);
|
|
329
327
|
}, [a, t, r]);
|
|
330
|
-
},
|
|
328
|
+
}, Ge = 3, yt = ({
|
|
331
329
|
connectedWallets: e,
|
|
332
330
|
alchemyApiKey: t,
|
|
333
331
|
...r
|
|
334
332
|
}) => {
|
|
335
|
-
const { ctx: s } = _(), { tokens: n } = P(), { walletSupportedChains: a } = y(), { setWalletBalance:
|
|
333
|
+
const { ctx: s } = _(), { tokens: n } = P(), { walletSupportedChains: a } = y(), { setWalletBalance: c } = be(e), l = r.isEnabled && !!Object.values(e).length && a.length > 0, d = Qt({
|
|
336
334
|
initialPageParam: null,
|
|
337
|
-
enabled: !!
|
|
335
|
+
enabled: !!l && !!t,
|
|
338
336
|
queryKey: ["walletTokensBalance", e],
|
|
339
|
-
queryFn: async ({ pageParam: i }) =>
|
|
337
|
+
queryFn: async ({ pageParam: i }) => ln({ alchemyApiKey: t })({
|
|
340
338
|
pageParam: i ? `${i}` : null,
|
|
341
339
|
connectedWallets: e,
|
|
342
340
|
walletSupportedChains: a
|
|
343
341
|
}),
|
|
344
342
|
getNextPageParam: (i, f) => {
|
|
345
|
-
if (i.pageKey && !(f.length >=
|
|
343
|
+
if (i.pageKey && !(f.length >= Ge))
|
|
346
344
|
return i.pageKey;
|
|
347
345
|
}
|
|
348
346
|
});
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}, [
|
|
347
|
+
R(() => {
|
|
348
|
+
l && d.data && d.hasNextPage && d.data.pages.length < Ge && !d.isFetchingNextPage && d.fetchNextPage();
|
|
349
|
+
}, [l, d]);
|
|
352
350
|
const u = v(() => {
|
|
353
351
|
if (!d.data?.pages)
|
|
354
352
|
return {};
|
|
355
|
-
const i =
|
|
353
|
+
const i = on(
|
|
356
354
|
n,
|
|
357
355
|
d.data.pages.flatMap((f) => f.data)
|
|
358
356
|
);
|
|
359
357
|
return n.forEach((f) => {
|
|
360
|
-
|
|
358
|
+
cn(f.blockchain) && !(f.assetId in i) && (i[f.assetId] = "0");
|
|
361
359
|
}), i;
|
|
362
360
|
}, [d.data, n]);
|
|
363
|
-
return
|
|
364
|
-
D(s, ["initial_wallet"]) && (
|
|
361
|
+
return R(() => {
|
|
362
|
+
D(s, ["initial_wallet"]) && (c(e, u), s.sourceToken && Object.keys(u).includes(s.sourceToken.assetId) && p("tokenSetBalance", u[s.sourceToken.assetId]));
|
|
365
363
|
}, [u]), {
|
|
366
364
|
status: d.status,
|
|
367
365
|
refetch: d.refetch,
|
|
368
366
|
balances: u
|
|
369
367
|
};
|
|
370
|
-
},
|
|
368
|
+
}, le = () => {
|
|
371
369
|
const { intentsAccountType: e } = y(), {
|
|
372
370
|
ctx: { walletAddress: t }
|
|
373
|
-
} = _(), { tokens: r } = P(), s = r.filter((
|
|
371
|
+
} = _(), { tokens: r } = P(), s = r.filter((l) => l.isIntent).map((l) => l.assetId), n = te({
|
|
374
372
|
walletAddress: t,
|
|
375
373
|
addressType: e
|
|
376
374
|
}), a = _e({
|
|
377
375
|
enabled: !!t && !!n && r.length > 0,
|
|
378
376
|
queryKey: ["intentsBalances", n],
|
|
379
|
-
queryFn: async () => n ? await
|
|
380
|
-
}),
|
|
377
|
+
queryFn: async () => n ? await un(n, s) : {}
|
|
378
|
+
}), c = v(() => {
|
|
381
379
|
switch (a.status) {
|
|
382
380
|
case "error":
|
|
383
381
|
return b.error("Unable to load intents balances:", a.error), {};
|
|
384
382
|
case "success":
|
|
385
383
|
return Object.fromEntries(
|
|
386
|
-
Object.entries(a.data).map(([
|
|
387
|
-
`intent-${
|
|
384
|
+
Object.entries(a.data).map(([l, d]) => [
|
|
385
|
+
`intent-${l}`,
|
|
388
386
|
d
|
|
389
387
|
])
|
|
390
388
|
);
|
|
391
389
|
case "pending":
|
|
392
390
|
return {};
|
|
393
391
|
default:
|
|
394
|
-
return
|
|
392
|
+
return Ee(a, { throwError: !1 }), {};
|
|
395
393
|
}
|
|
396
394
|
}, [a]) ?? {};
|
|
397
395
|
return {
|
|
398
396
|
...a,
|
|
399
|
-
intentBalances:
|
|
397
|
+
intentBalances: c
|
|
400
398
|
};
|
|
401
|
-
},
|
|
399
|
+
}, Hs = ({
|
|
402
400
|
isEnabled: e,
|
|
403
401
|
alchemyApiKey: t
|
|
404
402
|
}) => {
|
|
405
|
-
const { connectedWallets: r } = y(), { ctx: s } = _(), n =
|
|
403
|
+
const { connectedWallets: r } = y(), { ctx: s } = _(), n = $t(), { refetch: a } = le(), { refetch: c } = yt({
|
|
406
404
|
isEnabled: e,
|
|
407
405
|
connectedWallets: r,
|
|
408
406
|
alchemyApiKey: t ?? ""
|
|
409
407
|
});
|
|
410
|
-
|
|
411
|
-
const
|
|
412
|
-
!e || !
|
|
408
|
+
R(() => {
|
|
409
|
+
const l = D(s, ["transfer_success"]);
|
|
410
|
+
!e || !l || (async () => (await a(), t && (await new Promise((d) => {
|
|
413
411
|
setTimeout(d, 1e4);
|
|
414
|
-
}), await
|
|
412
|
+
}), await c()), await n.invalidateQueries({ queryKey: ["tokenBalance"] })))();
|
|
415
413
|
}, [s.state, e, t]);
|
|
416
|
-
},
|
|
417
|
-
const { connectedWallets: e } = y(), { intentBalances: t } =
|
|
414
|
+
}, ce = () => {
|
|
415
|
+
const { connectedWallets: e } = y(), { intentBalances: t } = le(), { walletBalance: r } = be(e);
|
|
418
416
|
return { mergedBalance: v(
|
|
419
417
|
() => ({ ...r, ...t }),
|
|
420
418
|
[r, t]
|
|
421
419
|
) };
|
|
422
|
-
},
|
|
423
|
-
const { ctx: t } = _(), { mergedBalance: r } =
|
|
424
|
-
|
|
420
|
+
}, Gs = ({ isEnabled: e }) => {
|
|
421
|
+
const { ctx: t } = _(), { mergedBalance: r } = ce();
|
|
422
|
+
R(() => {
|
|
425
423
|
if (!e)
|
|
426
424
|
return;
|
|
427
425
|
if (!t.sourceToken || !t.walletAddress) {
|
|
@@ -431,7 +429,7 @@ const Gs = (e) => {
|
|
|
431
429
|
const s = G(t.sourceToken);
|
|
432
430
|
p("tokenSetBalance", r[s]);
|
|
433
431
|
}, [r, t.sourceToken]);
|
|
434
|
-
},
|
|
432
|
+
}, je = {
|
|
435
433
|
// cbBTC (eth)
|
|
436
434
|
"nep141:eth-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near": "nep141:nbtc.bridge.near",
|
|
437
435
|
// cbBTC (base)
|
|
@@ -446,11 +444,11 @@ const Gs = (e) => {
|
|
|
446
444
|
"nep245:v2_1.omni.hot.tg:56_SZzgw3HSudhZcTwPWUTi2RJB19t": "nep141:wrap.near",
|
|
447
445
|
// BTC (near)
|
|
448
446
|
"nep141:btc.omft.near": "nep141:nbtc.bridge.near"
|
|
449
|
-
},
|
|
447
|
+
}, js = ({
|
|
450
448
|
isEnabled: e
|
|
451
449
|
}) => {
|
|
452
450
|
const { ctx: t } = _(), { tokens: r } = P();
|
|
453
|
-
|
|
451
|
+
R(() => {
|
|
454
452
|
if (!e)
|
|
455
453
|
return;
|
|
456
454
|
if (!t.sourceToken) {
|
|
@@ -458,68 +456,68 @@ const Gs = (e) => {
|
|
|
458
456
|
return;
|
|
459
457
|
}
|
|
460
458
|
const { sourceToken: s } = t;
|
|
461
|
-
if (t.sourceToken.assetId in
|
|
462
|
-
const
|
|
463
|
-
(d) => d.isIntent && d.assetId ===
|
|
459
|
+
if (t.sourceToken.assetId in je) {
|
|
460
|
+
const l = r.find(
|
|
461
|
+
(d) => d.isIntent && d.assetId === je[s.assetId]
|
|
464
462
|
);
|
|
465
463
|
p("tokenSelect", {
|
|
466
464
|
variant: "target",
|
|
467
|
-
token:
|
|
465
|
+
token: l
|
|
468
466
|
});
|
|
469
467
|
return;
|
|
470
468
|
}
|
|
471
469
|
const n = r.find(
|
|
472
|
-
(
|
|
470
|
+
(l) => l.isIntent && l.symbol === s.symbol && l.blockchain === "near"
|
|
473
471
|
);
|
|
474
472
|
if (n) {
|
|
475
473
|
p("tokenSelect", { variant: "target", token: n });
|
|
476
474
|
return;
|
|
477
475
|
}
|
|
478
476
|
const a = r.find(
|
|
479
|
-
(
|
|
480
|
-
),
|
|
481
|
-
(
|
|
477
|
+
(l) => l.isIntent && l.assetId === s.assetId
|
|
478
|
+
), c = r.find(
|
|
479
|
+
(l) => l.isIntent && l.symbol === "USDC" && l.blockchain === "near"
|
|
482
480
|
);
|
|
483
481
|
p("tokenSelect", {
|
|
484
482
|
variant: "target",
|
|
485
|
-
token: a ??
|
|
483
|
+
token: a ?? c
|
|
486
484
|
});
|
|
487
485
|
}, [r, t.sourceToken]);
|
|
488
|
-
},
|
|
489
|
-
const { connectedWallets: t } = y(), { ctx: r, state: s } = _(), { walletAddress: n } =
|
|
486
|
+
}, zs = ({ isEnabled: e }) => {
|
|
487
|
+
const { connectedWallets: t } = y(), { ctx: r, state: s } = _(), { walletAddress: n } = rt(
|
|
490
488
|
t,
|
|
491
489
|
r.sourceToken
|
|
492
490
|
);
|
|
493
|
-
|
|
491
|
+
R(() => {
|
|
494
492
|
if (!e)
|
|
495
493
|
return;
|
|
496
494
|
p("walletAddressSet", n), D(r, ["initial_dry", "initial_wallet"]) && (s === "initial_wallet" && !n ? O("initial_dry") : s === "initial_dry" && n && O("initial_wallet"));
|
|
497
495
|
}, [e, n, r, s]);
|
|
498
|
-
},
|
|
496
|
+
}, Ys = (e) => (["depositAddress"].forEach((t) => {
|
|
499
497
|
if (!(t in e))
|
|
500
498
|
return b.error(`Missing ${t} in quote response`), !1;
|
|
501
|
-
}), !0),
|
|
499
|
+
}), !0), Zs = () => {
|
|
502
500
|
const { ctx: e } = _(), {
|
|
503
501
|
walletSupportedChains: t,
|
|
504
502
|
intentsAccountType: r,
|
|
505
503
|
appName: s,
|
|
506
504
|
appFees: n,
|
|
507
505
|
fetchQuote: a,
|
|
508
|
-
slippageTolerance:
|
|
509
|
-
} = y(),
|
|
506
|
+
slippageTolerance: c
|
|
507
|
+
} = y(), l = Re(e), d = Y(null), u = Y(new AbortController()), i = v(() => async (T, I) => {
|
|
510
508
|
const { signal: m } = u.current;
|
|
511
|
-
return a ? a(
|
|
509
|
+
return a ? a(T, {
|
|
512
510
|
...I,
|
|
513
511
|
signal: m
|
|
514
512
|
}) : (await Ie.post(
|
|
515
513
|
"https://1click.chaindefuser.com/v0/quote",
|
|
516
|
-
|
|
514
|
+
T,
|
|
517
515
|
{ signal: m }
|
|
518
516
|
)).data.quote;
|
|
519
517
|
}, [Ie]);
|
|
520
518
|
return {
|
|
521
519
|
make: async ({
|
|
522
|
-
message:
|
|
520
|
+
message: T,
|
|
523
521
|
quoteType: I = "exact_in",
|
|
524
522
|
options: m = {}
|
|
525
523
|
} = {}) => {
|
|
@@ -533,32 +531,32 @@ const Gs = (e) => {
|
|
|
533
531
|
const k = `Unable to run quote in current state ${e.state}`;
|
|
534
532
|
throw b.error(`[WIDGET] ${k}`), new q({
|
|
535
533
|
code: "QUOTE_INVALID_INITIAL",
|
|
536
|
-
meta: { isDry:
|
|
534
|
+
meta: { isDry: l, message: k }
|
|
537
535
|
});
|
|
538
536
|
}
|
|
539
|
-
const
|
|
537
|
+
const S = te({
|
|
540
538
|
addressType: r,
|
|
541
|
-
walletAddress:
|
|
539
|
+
walletAddress: l ? (
|
|
542
540
|
// address on the target chain should be a dry quote recipient
|
|
543
|
-
|
|
541
|
+
Ue(e.targetToken.blockchain)
|
|
544
542
|
) : e.walletAddress ?? ""
|
|
545
|
-
}), E =
|
|
543
|
+
}), E = S && (e.sourceToken.isIntent || !t.includes(e.sourceToken.blockchain)), B = () => l ? Ue(
|
|
546
544
|
e.sourceToken.blockchain,
|
|
547
545
|
e.sourceToken.isIntent
|
|
548
|
-
) : E ?
|
|
549
|
-
if (!
|
|
546
|
+
) : E ? S : e.walletAddress ?? "";
|
|
547
|
+
if (!S) {
|
|
550
548
|
const k = "No corresponding intents account to run a quote";
|
|
551
549
|
throw b.error(`[WIDGET] ${k}`), new q({
|
|
552
550
|
code: "QUOTE_INVALID_INITIAL",
|
|
553
|
-
meta: { isDry:
|
|
551
|
+
meta: { isDry: l, message: k }
|
|
554
552
|
});
|
|
555
553
|
}
|
|
556
554
|
d.current && (u.current.abort("Abort previous quote (auto)"), u.current = new AbortController());
|
|
557
555
|
let F;
|
|
558
556
|
const L = {
|
|
559
557
|
// Settings
|
|
560
|
-
dry:
|
|
561
|
-
slippageTolerance:
|
|
558
|
+
dry: l,
|
|
559
|
+
slippageTolerance: c,
|
|
562
560
|
deadline: new Date(Date.now() + 3600 * 1e3).toISOString(),
|
|
563
561
|
// 1 hour
|
|
564
562
|
swapType: I === "exact_out" ? U.swapType.EXACT_OUTPUT : U.swapType.EXACT_INPUT,
|
|
@@ -570,23 +568,23 @@ const Gs = (e) => {
|
|
|
570
568
|
// Experimental
|
|
571
569
|
quoteWaitingTimeMs: 0
|
|
572
570
|
};
|
|
573
|
-
|
|
571
|
+
T && (L.customRecipientMsg = T), s && (L.referral = ct(s)), n && (L.appFees = [...n]);
|
|
574
572
|
try {
|
|
575
573
|
e.sourceToken.isIntent && e.targetToken.isIntent && (d.current = i(
|
|
576
574
|
{
|
|
577
575
|
...L,
|
|
578
|
-
recipient:
|
|
576
|
+
recipient: S,
|
|
579
577
|
recipientType: U.recipientType.INTENTS,
|
|
580
578
|
depositType: U.depositType.INTENTS,
|
|
581
579
|
// Refund
|
|
582
|
-
refundTo:
|
|
580
|
+
refundTo: S,
|
|
583
581
|
refundType: U.refundType.INTENTS
|
|
584
582
|
},
|
|
585
583
|
m
|
|
586
584
|
), F = await d.current), d.current = i(
|
|
587
585
|
{
|
|
588
586
|
...L,
|
|
589
|
-
recipient: !e.targetToken.isIntent && e.sendAddress ? e.sendAddress :
|
|
587
|
+
recipient: !e.targetToken.isIntent && e.sendAddress ? e.sendAddress : S,
|
|
590
588
|
recipientType: e.targetToken.isIntent ? U.recipientType.INTENTS : U.recipientType.DESTINATION_CHAIN,
|
|
591
589
|
depositType: e.sourceToken.isIntent ? U.depositType.INTENTS : U.depositType.ORIGIN_CHAIN,
|
|
592
590
|
// Refund
|
|
@@ -596,11 +594,11 @@ const Gs = (e) => {
|
|
|
596
594
|
m
|
|
597
595
|
), F = await d.current;
|
|
598
596
|
} catch (k) {
|
|
599
|
-
if (k instanceof
|
|
597
|
+
if (k instanceof dt)
|
|
600
598
|
return;
|
|
601
599
|
b.error("Quote error: ", k);
|
|
602
600
|
let x = k instanceof Error ? k.message : "";
|
|
603
|
-
if (k instanceof
|
|
601
|
+
if (k instanceof ut) {
|
|
604
602
|
if (x = k.response?.data.message || x, x.includes("Amount is too low")) {
|
|
605
603
|
const X = x.match(/\d+/), J = X ? X[0] : void 0;
|
|
606
604
|
throw new q({
|
|
@@ -623,12 +621,12 @@ const Gs = (e) => {
|
|
|
623
621
|
}
|
|
624
622
|
});
|
|
625
623
|
}
|
|
626
|
-
return
|
|
624
|
+
return l ? {
|
|
627
625
|
dry: !0,
|
|
628
626
|
...F,
|
|
629
627
|
deadline: void 0,
|
|
630
628
|
depositAddress: void 0
|
|
631
|
-
} : (
|
|
629
|
+
} : (Ys(F), {
|
|
632
630
|
dry: !1,
|
|
633
631
|
...F,
|
|
634
632
|
deadline: F.deadline,
|
|
@@ -639,11 +637,11 @@ const Gs = (e) => {
|
|
|
639
637
|
u.current.abort("Abort quote manually"), u.current = new AbortController();
|
|
640
638
|
}
|
|
641
639
|
};
|
|
642
|
-
},
|
|
640
|
+
}, Xs = () => {
|
|
643
641
|
const { ctx: e } = _(), { intentsAccountType: t } = y(), { isNativeNearDeposit: r } = z(), s = te({
|
|
644
642
|
addressType: t,
|
|
645
643
|
walletAddress: e.walletAddress ?? ""
|
|
646
|
-
}), n = Y(null), a = Y(new AbortController()),
|
|
644
|
+
}), n = Y(null), a = Y(new AbortController()), c = v(() => async (d) => mt.post(
|
|
647
645
|
"",
|
|
648
646
|
{
|
|
649
647
|
id: 1,
|
|
@@ -707,7 +705,7 @@ const Gs = (e) => {
|
|
|
707
705
|
});
|
|
708
706
|
}
|
|
709
707
|
n.current && (a.current.abort("Abort previous quote (auto)"), a.current = new AbortController());
|
|
710
|
-
let u =
|
|
708
|
+
let u = it[e.targetToken.blockchain];
|
|
711
709
|
if (!u)
|
|
712
710
|
if (Q(e.targetToken.blockchain))
|
|
713
711
|
u = lt;
|
|
@@ -717,7 +715,7 @@ const Gs = (e) => {
|
|
|
717
715
|
meta: { isDry: !1, message: "Chain is not supported by POA" }
|
|
718
716
|
});
|
|
719
717
|
try {
|
|
720
|
-
return n.current =
|
|
718
|
+
return n.current = c({
|
|
721
719
|
chain: u,
|
|
722
720
|
accountId: s
|
|
723
721
|
}), {
|
|
@@ -740,9 +738,9 @@ const Gs = (e) => {
|
|
|
740
738
|
dry: !1
|
|
741
739
|
};
|
|
742
740
|
} catch (i) {
|
|
743
|
-
if (i instanceof
|
|
741
|
+
if (i instanceof dt)
|
|
744
742
|
return;
|
|
745
|
-
if (b.error(i), i instanceof
|
|
743
|
+
if (b.error(i), i instanceof ut) {
|
|
746
744
|
const f = i.response?.data.message || i.message;
|
|
747
745
|
throw new q({
|
|
748
746
|
code: "QUOTE_FAILED",
|
|
@@ -757,60 +755,60 @@ const Gs = (e) => {
|
|
|
757
755
|
a.current.abort("Abort quote manually"), a.current = new AbortController();
|
|
758
756
|
}
|
|
759
757
|
};
|
|
760
|
-
},
|
|
758
|
+
}, ze = (e) => {
|
|
761
759
|
p("errorSet", e), p("quoteSet", void 0), p("quoteSetStatus", "idle"), p("transferSetStatus", { status: "idle" });
|
|
762
|
-
},
|
|
760
|
+
}, Ye = async (e) => {
|
|
763
761
|
if (!e.sendAddress)
|
|
764
762
|
return;
|
|
765
763
|
let t = !1;
|
|
766
764
|
try {
|
|
767
|
-
p("setInputsValidating", !0), t = await
|
|
765
|
+
p("setInputsValidating", !0), t = await fn(e.sendAddress);
|
|
768
766
|
} catch {
|
|
769
|
-
|
|
767
|
+
ze({
|
|
770
768
|
code: "SEND_ADDRESS_IS_NOT_VERIFIED",
|
|
771
769
|
meta: { address: e.sendAddress, chain: "near" }
|
|
772
770
|
}), p("setInputsValidating", !1), O("initial_wallet");
|
|
773
771
|
return;
|
|
774
772
|
}
|
|
775
773
|
if (p("setInputsValidating", !1), !t) {
|
|
776
|
-
|
|
774
|
+
ze({
|
|
777
775
|
code: "SEND_ADDRESS_IS_NOT_FOUND",
|
|
778
776
|
meta: { address: e.sendAddress, chain: "near" }
|
|
779
777
|
}), O("initial_wallet");
|
|
780
778
|
return;
|
|
781
779
|
}
|
|
782
|
-
e.error ?
|
|
783
|
-
},
|
|
780
|
+
e.error ? pn(e.error) && (p("errorSet", null), O("input_valid_external")) : O("input_valid_external");
|
|
781
|
+
}, bt = (e) => {
|
|
784
782
|
const t = D(e, ["initial_dry"]), r = D(e, ["input_valid_dry"]);
|
|
785
783
|
if (!t && !r)
|
|
786
784
|
return;
|
|
787
785
|
let s;
|
|
788
|
-
return t && (e.sourceToken ? e.targetToken ? ne(e.sourceTokenAmount) ? e.walletAddress && !
|
|
789
|
-
},
|
|
786
|
+
return t && (e.sourceToken ? e.targetToken ? ne(e.sourceTokenAmount) ? e.walletAddress && !Ce(e) && (s = { code: "SOURCE_BALANCE_INSUFFICIENT" }) : s = { code: "SOURCE_TOKEN_AMOUNT_IS_EMPTY" } : s = { code: "TARGET_TOKEN_IS_EMPTY" } : s = { code: "SOURCE_TOKEN_IS_EMPTY" }), !r && s ? p("errorSet", s) : e.error && !ve(e.error) && !De(e.error) && p("errorSet", null), r && s?.code === "SOURCE_BALANCE_INSUFFICIENT" && p("errorSet", s), r;
|
|
787
|
+
}, Et = (e) => {
|
|
790
788
|
const t = D(e, ["initial_wallet"]), r = D(e, ["input_valid_external"]);
|
|
791
789
|
if (!t && !r)
|
|
792
790
|
return;
|
|
793
791
|
const s = e.sourceTokenBalance;
|
|
794
792
|
let n;
|
|
795
|
-
return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? n = { code: "SOURCE_TOKEN_IS_INTENT" } : ne(e.sourceTokenAmount) ? e.sendAddress ? e.targetToken.blockchain === "near" ?
|
|
793
|
+
return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? n = { code: "SOURCE_TOKEN_IS_INTENT" } : ne(e.sourceTokenAmount) ? e.sendAddress ? e.targetToken.blockchain === "near" ? pt(e.sendAddress) ? Ye(e) : n = {
|
|
796
794
|
code: "SEND_ADDRESS_IS_INVALID",
|
|
797
795
|
meta: { address: e.sendAddress, chain: "near" }
|
|
798
|
-
} : e.isDepositFromExternalWallet || (!s || !
|
|
796
|
+
} : e.isDepositFromExternalWallet || (!s || !ft(s) ? n = { code: "INVALID_SOURCE_BALANCE" } : Ce(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" }), r && e.targetToken.blockchain === "near" && Ye(e), !r && n ? p("errorSet", n) : e.error && !ve(e.error) && !De(e.error) && p("errorSet", null), r;
|
|
799
797
|
}, Rt = (e) => {
|
|
800
798
|
const t = D(e, ["initial_wallet"]), r = D(e, ["input_valid_internal"]);
|
|
801
799
|
if (!t && !r)
|
|
802
800
|
return;
|
|
803
801
|
const s = e.sourceTokenBalance;
|
|
804
802
|
let n;
|
|
805
|
-
return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? ne(e.sourceTokenAmount) ? e.isDepositFromExternalWallet || (!s || !
|
|
806
|
-
},
|
|
803
|
+
return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? ne(e.sourceTokenAmount) ? e.isDepositFromExternalWallet || (!s || !ft(s) ? n = { code: "INVALID_SOURCE_BALANCE" } : Ce(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" }), !r && n ? p("errorSet", n) : e.error && !ve(e.error) && !De(e.error) && p("errorSet", null), r;
|
|
804
|
+
}, Ct = (e) => {
|
|
807
805
|
const t = Re(e), r = !t && e.targetToken?.isIntent === !0, s = !t && e.targetToken?.isIntent === !1;
|
|
808
806
|
if (t) {
|
|
809
|
-
const n =
|
|
807
|
+
const n = bt(e);
|
|
810
808
|
return O(n ? "input_valid_dry" : "initial_dry");
|
|
811
809
|
}
|
|
812
|
-
s &&
|
|
813
|
-
},
|
|
810
|
+
s && Et(e) ? O("input_valid_external") : r && Rt(e) ? O("input_valid_internal") : O("initial_wallet");
|
|
811
|
+
}, Js = ({
|
|
814
812
|
isEnabled: e,
|
|
815
813
|
message: t,
|
|
816
814
|
type: r = "exact_in",
|
|
@@ -818,19 +816,19 @@ const Gs = (e) => {
|
|
|
818
816
|
}) => {
|
|
819
817
|
const { ctx: n } = _(), {
|
|
820
818
|
isNativeNearDeposit: a,
|
|
821
|
-
isDirectNonNearWithdrawal:
|
|
822
|
-
isDirectTokenOnNearDeposit:
|
|
819
|
+
isDirectNonNearWithdrawal: c,
|
|
820
|
+
isDirectTokenOnNearDeposit: l,
|
|
823
821
|
isDirectNearTokenWithdrawal: d,
|
|
824
822
|
isDirectTokenOnNearTransfer: u,
|
|
825
823
|
isSameAssetDiffChainWithdrawal: i
|
|
826
|
-
} = z(), f = Re(n),
|
|
827
|
-
m(),
|
|
824
|
+
} = z(), f = Re(n), T = e && !n.areInputsValidating && (i || (l || a) && n.isDepositFromExternalWallet || !d && !c && !l && !u), { make: I, cancel: m } = Zs(), { make: w, cancel: S } = Xs(), E = Y(null), B = () => {
|
|
825
|
+
m(), S();
|
|
828
826
|
};
|
|
829
|
-
|
|
827
|
+
R(() => {
|
|
830
828
|
const L = D(n, ["input_valid_dry"]), k = D(n, ["input_valid_external"]), x = D(n, ["input_valid_internal"]);
|
|
831
829
|
(f && !L || !f && n.targetToken?.isIntent && !x || !f && !n.targetToken?.isIntent && !k || n.areInputsValidating) && B();
|
|
832
830
|
}, [B, f, n]);
|
|
833
|
-
const F =
|
|
831
|
+
const F = Te(
|
|
834
832
|
async (L) => {
|
|
835
833
|
try {
|
|
836
834
|
let k;
|
|
@@ -856,7 +854,7 @@ const Gs = (e) => {
|
|
|
856
854
|
p("quoteSetStatus", "idle"), p("quoteSet", void 0), p("errorSet", null);
|
|
857
855
|
return;
|
|
858
856
|
}
|
|
859
|
-
p("quoteSetStatus", "error"), p("quoteSet", void 0), p("errorSet", k.data),
|
|
857
|
+
p("quoteSetStatus", "error"), p("quoteSet", void 0), p("errorSet", k.data), Ct(n);
|
|
860
858
|
return;
|
|
861
859
|
}
|
|
862
860
|
b.error("Unhandled error in useMakeQuoteEffect:", k), p("quoteSetStatus", "error"), p("quoteSet", void 0), p("errorSet", {
|
|
@@ -865,34 +863,34 @@ const Gs = (e) => {
|
|
|
865
863
|
});
|
|
866
864
|
}
|
|
867
865
|
},
|
|
868
|
-
[n, f, w, I, t, r,
|
|
866
|
+
[n, f, w, I, t, r, T]
|
|
869
867
|
);
|
|
870
|
-
|
|
871
|
-
!
|
|
872
|
-
}, [
|
|
868
|
+
R(() => {
|
|
869
|
+
!T || !(f ? 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 }));
|
|
870
|
+
}, [T, F, B, n.sourceToken, n.targetToken]), R(() => {
|
|
873
871
|
const L = () => {
|
|
874
872
|
E.current && (clearInterval(E.current), E.current = null);
|
|
875
873
|
};
|
|
876
874
|
return n.state !== "quote_success_internal" && n.state !== "quote_success_external" || !s || (E.current = setInterval(async () => {
|
|
877
875
|
await F({ isRefetch: !0 });
|
|
878
876
|
}, s)), L;
|
|
879
|
-
}, [
|
|
877
|
+
}, [T, F, B, n.state]);
|
|
880
878
|
}, me = {
|
|
881
879
|
sol: "sol",
|
|
882
880
|
evm: "eth",
|
|
883
881
|
near: "near"
|
|
884
|
-
},
|
|
882
|
+
}, er = ({
|
|
885
883
|
isEnabled: e,
|
|
886
884
|
skipIntents: t = !1,
|
|
887
885
|
target: r = "none"
|
|
888
886
|
}) => {
|
|
889
|
-
const { tokens: s } = P(), { ctx: n, state: a } = _(), { intentBalances:
|
|
887
|
+
const { tokens: s } = P(), { ctx: n, state: a } = _(), { intentBalances: c } = le(), { walletSupportedChains: l, chainsFilter: d, intentsAccountType: u } = y(), i = gn({
|
|
890
888
|
tokens: s,
|
|
891
|
-
walletSupportedChains:
|
|
892
|
-
balances:
|
|
889
|
+
walletSupportedChains: l,
|
|
890
|
+
balances: c,
|
|
893
891
|
across: "intents"
|
|
894
|
-
}), [f,
|
|
895
|
-
{ token:
|
|
892
|
+
}), [f, T] = v(() => !n.walletAddress && !t ? [
|
|
893
|
+
{ token: hn({ tokens: s }), status: "loaded" },
|
|
896
894
|
{ token: void 0, status: "loaded" }
|
|
897
895
|
] : d.source.intents !== "none" && !t ? i ? [
|
|
898
896
|
{ token: i, status: "loaded" },
|
|
@@ -901,9 +899,9 @@ const Gs = (e) => {
|
|
|
901
899
|
{ token: void 0, status: "loading" },
|
|
902
900
|
{ token: void 0, status: "loading" }
|
|
903
901
|
] : [
|
|
904
|
-
{ token:
|
|
902
|
+
{ token: Tn({
|
|
905
903
|
tokens: s,
|
|
906
|
-
walletSupportedChains:
|
|
904
|
+
walletSupportedChains: l
|
|
907
905
|
}), status: "loaded" },
|
|
908
906
|
{ token: void 0, status: "loaded" }
|
|
909
907
|
], [
|
|
@@ -912,17 +910,17 @@ const Gs = (e) => {
|
|
|
912
910
|
d,
|
|
913
911
|
n.walletAddress,
|
|
914
912
|
i,
|
|
915
|
-
|
|
913
|
+
l,
|
|
916
914
|
a
|
|
917
915
|
]);
|
|
918
|
-
|
|
916
|
+
R(() => {
|
|
919
917
|
if (!e)
|
|
920
918
|
return;
|
|
921
919
|
if (D(n, ["initial_dry", "initial_wallet"]) && (f.status === "loaded" && !n.sourceToken && p("tokenSelect", {
|
|
922
920
|
variant: "source",
|
|
923
921
|
token: f.token
|
|
924
|
-
}),
|
|
925
|
-
let w =
|
|
922
|
+
}), T.status === "loaded" && f.status === "loaded" && !n.targetToken)) {
|
|
923
|
+
let w = T.token;
|
|
926
924
|
if (r === "same-asset")
|
|
927
925
|
if (f.token?.isIntent) {
|
|
928
926
|
if (!u)
|
|
@@ -930,87 +928,87 @@ const Gs = (e) => {
|
|
|
930
928
|
"Intents account type is required to select same-asset target token"
|
|
931
929
|
);
|
|
932
930
|
w = s.find(
|
|
933
|
-
(
|
|
931
|
+
(S) => !S.isIntent && S.symbol === n.sourceToken?.symbol && S.blockchain === me[u]
|
|
934
932
|
);
|
|
935
933
|
} else
|
|
936
934
|
w = s.find(
|
|
937
|
-
(
|
|
935
|
+
(S) => S.isIntent && S.symbol === n.sourceToken?.symbol
|
|
938
936
|
);
|
|
939
937
|
p("tokenSelect", {
|
|
940
938
|
variant: "target",
|
|
941
939
|
token: w
|
|
942
940
|
});
|
|
943
941
|
}
|
|
944
|
-
}, [n, f,
|
|
942
|
+
}, [n, f, T, e]);
|
|
945
943
|
const I = (m, w) => {
|
|
946
|
-
const
|
|
947
|
-
(E) => !E.isIntent && E.blockchain === me[m] && E.symbol.toLowerCase() ===
|
|
944
|
+
const S = s.find(
|
|
945
|
+
(E) => !E.isIntent && E.blockchain === me[m] && E.symbol.toLowerCase() === Jt[me[m]]?.toLowerCase()
|
|
948
946
|
) ?? w;
|
|
949
947
|
p("tokenSelect", {
|
|
950
948
|
variant: "source",
|
|
951
|
-
token:
|
|
949
|
+
token: S
|
|
952
950
|
});
|
|
953
951
|
};
|
|
954
|
-
return
|
|
952
|
+
return R(() => {
|
|
955
953
|
const m = D(n, ["initial_dry", "initial_wallet"]);
|
|
956
954
|
if (!e || !m)
|
|
957
955
|
return;
|
|
958
956
|
const w = s.find(
|
|
959
957
|
(E) => E.isIntent && E.symbol === "AURORA" && E.blockchain === "near"
|
|
960
|
-
),
|
|
958
|
+
), S = setTimeout(() => {
|
|
961
959
|
f.token || (!t && i ? p("tokenSelect", {
|
|
962
960
|
variant: "source",
|
|
963
961
|
token: i
|
|
964
|
-
}) :
|
|
962
|
+
}) : l.length && u ? I(u, w) : n.walletAddress && Tt(n.walletAddress) ? I("sol", w) : n.walletAddress && ht(n.walletAddress) ? I("evm", w) : n.walletAddress && pt(n.walletAddress) ? I("near", w) : p("tokenSelect", {
|
|
965
963
|
variant: "source",
|
|
966
964
|
token: w
|
|
967
965
|
}));
|
|
968
966
|
}, 3e3);
|
|
969
|
-
return () => clearTimeout(
|
|
967
|
+
return () => clearTimeout(S);
|
|
970
968
|
}, [s, f, t]), { source: n.sourceToken, target: n.targetToken };
|
|
971
|
-
},
|
|
969
|
+
}, tr = ({
|
|
972
970
|
isEnabled: e,
|
|
973
971
|
alchemyApiKey: t
|
|
974
972
|
}) => {
|
|
975
973
|
const { connectedWallets: r } = y();
|
|
976
|
-
|
|
974
|
+
yt({
|
|
977
975
|
isEnabled: e,
|
|
978
976
|
connectedWallets: r,
|
|
979
977
|
alchemyApiKey: t ?? ""
|
|
980
978
|
});
|
|
981
|
-
},
|
|
982
|
-
const { config: r } =
|
|
979
|
+
}, nr = (e, t) => {
|
|
980
|
+
const { config: r } = Ne(qe);
|
|
983
981
|
return e.targetToken && !e.sendAddress && !!e.walletAddress && !e.targetToken.isIntent && !t.find((s) => s?.key === "sendAddress") && r.walletSupportedChains.includes(e.targetToken.blockchain);
|
|
984
|
-
},
|
|
982
|
+
}, sr = ({ debug: e }) => {
|
|
985
983
|
Z.onContextChange((t, r) => {
|
|
986
984
|
const s = r;
|
|
987
|
-
if (e && b.debug("[WIDGET] Context changed", s), e && t.error &&
|
|
985
|
+
if (e && b.debug("[WIDGET] Context changed", s), e && t.error && kn(s) && b.debug(`[WIDGET] Error set to ${t.error.code}`), An(s) || yn(t, s, e))
|
|
988
986
|
return;
|
|
989
|
-
if (
|
|
987
|
+
if (Nn(t, s)) {
|
|
990
988
|
p("reset", { clearWalletAddress: !0 }), O("initial_dry");
|
|
991
989
|
return;
|
|
992
990
|
}
|
|
993
|
-
const { isChanged: n, isDry: a } =
|
|
991
|
+
const { isChanged: n, isDry: a } = wn(t, s);
|
|
994
992
|
if (n) {
|
|
995
|
-
if (
|
|
996
|
-
const
|
|
997
|
-
O(
|
|
993
|
+
if (Sn(t)) {
|
|
994
|
+
const c = a ? "initial_dry" : "initial_wallet";
|
|
995
|
+
O(c, {
|
|
998
996
|
onMoved: () => {
|
|
999
997
|
e && b.debug(
|
|
1000
|
-
`[WIDGET] Inputs changed. State moved to ${
|
|
998
|
+
`[WIDGET] Inputs changed. State moved to ${c}`
|
|
1001
999
|
);
|
|
1002
1000
|
}
|
|
1003
1001
|
});
|
|
1004
1002
|
}
|
|
1005
|
-
|
|
1003
|
+
In(t) || (t.quote = void 0, t.quoteStatus = "idle", t.transferStatus = { status: "idle" }), _n(t) && (t.sendAddress = void 0), nr(t, s) && (t.sendAddress = t.walletAddress), Ct(t);
|
|
1006
1004
|
}
|
|
1007
1005
|
});
|
|
1008
|
-
},
|
|
1006
|
+
}, rr = ({ debug: e }) => {
|
|
1009
1007
|
Z.onTransition((t, r) => {
|
|
1010
1008
|
e && b.debug(`===> [WIDGET] State moved from ${t} to ${r}`);
|
|
1011
1009
|
});
|
|
1012
|
-
},
|
|
1013
|
-
const { variant: r, token: s } = t, { config: n } =
|
|
1010
|
+
}, ar = (e, t) => {
|
|
1011
|
+
const { variant: r, token: s } = t, { config: n } = Ne(qe);
|
|
1014
1012
|
switch (r) {
|
|
1015
1013
|
case "source":
|
|
1016
1014
|
if (s && s.assetId === e.targetToken?.assetId && s.isIntent === e.targetToken.isIntent && n.enableAutoTokensSwitching) {
|
|
@@ -1033,20 +1031,20 @@ const Gs = (e) => {
|
|
|
1033
1031
|
e.targetToken = s;
|
|
1034
1032
|
break;
|
|
1035
1033
|
default:
|
|
1036
|
-
|
|
1034
|
+
Ee(r, { throwError: !1 });
|
|
1037
1035
|
}
|
|
1038
|
-
},
|
|
1036
|
+
}, C = (e, t) => Z.on(
|
|
1039
1037
|
e,
|
|
1040
1038
|
(r, s) => t(r, s, Z)
|
|
1041
|
-
),
|
|
1042
|
-
|
|
1043
|
-
},
|
|
1039
|
+
), or = () => {
|
|
1040
|
+
C("quoteSetStatus", Dn), C("walletAddressSet", Ln), C("transferSetStatus", qn), C("tokenSelectRotate", we), C("tokenSetBalance", Bn), C("tokenSetAmount", vn), C("depositTypeSet", xn), C("setInputsValidating", Fn), C("externalDepositTxSet", On), C("tokenSelect", ar), C("addressSet", Cn), C("errorSet", En), C("quoteSet", Rn), C("reset", bn), C("validateDryInputs", bt), C("validateExternalInputs", Et), C("validateInternalInputs", Rt);
|
|
1041
|
+
}, ir = an(({ debug: e }) => {
|
|
1044
1042
|
e && b.debug(
|
|
1045
|
-
"[WIDGET] Debug mode is enabled (package version: 3.
|
|
1046
|
-
),
|
|
1047
|
-
}),
|
|
1048
|
-
|
|
1049
|
-
|
|
1043
|
+
"[WIDGET] Debug mode is enabled (package version: 3.16.0)"
|
|
1044
|
+
), or(), rr({ debug: e }), sr({ debug: e });
|
|
1045
|
+
}), qi = ({ listenTo: e, debug: t = !1 }) => {
|
|
1046
|
+
R(() => {
|
|
1047
|
+
ir({ debug: t });
|
|
1050
1048
|
}, [t]);
|
|
1051
1049
|
const r = e.find(
|
|
1052
1050
|
(a) => Array.isArray(a) && a[0] === "setBalancesUsingAlchemyExt"
|
|
@@ -1055,85 +1053,85 @@ const Gs = (e) => {
|
|
|
1055
1053
|
), n = e.find(
|
|
1056
1054
|
(a) => Array.isArray(a) && a[0] === "makeQuote"
|
|
1057
1055
|
);
|
|
1058
|
-
|
|
1056
|
+
tr({
|
|
1059
1057
|
isEnabled: !!r,
|
|
1060
1058
|
alchemyApiKey: r?.[1].alchemyApiKey
|
|
1061
|
-
}),
|
|
1059
|
+
}), er({
|
|
1062
1060
|
isEnabled: !!s,
|
|
1063
1061
|
skipIntents: s?.[1].skipIntents,
|
|
1064
1062
|
target: s?.[1].target
|
|
1065
|
-
}),
|
|
1063
|
+
}), Js({
|
|
1066
1064
|
isEnabled: !!n,
|
|
1067
1065
|
message: n?.[1].message,
|
|
1068
1066
|
type: n?.[1].type,
|
|
1069
1067
|
refetchQuoteInterval: n?.[1].refetchQuoteInterval
|
|
1070
|
-
}), Zs({
|
|
1071
|
-
isEnabled: e.includes("checkWalletConnection")
|
|
1072
1068
|
}), zs({
|
|
1069
|
+
isEnabled: e.includes("checkWalletConnection")
|
|
1070
|
+
}), Gs({
|
|
1073
1071
|
isEnabled: e.includes("setSourceTokenBalance")
|
|
1074
|
-
}), Ys({
|
|
1075
|
-
isEnabled: e.includes("setSourceTokenIntentsTarget")
|
|
1076
1072
|
}), js({
|
|
1073
|
+
isEnabled: e.includes("setSourceTokenIntentsTarget")
|
|
1074
|
+
}), Hs({
|
|
1077
1075
|
isEnabled: e.includes("updateBalances"),
|
|
1078
1076
|
alchemyApiKey: r?.[1].alchemyApiKey
|
|
1079
1077
|
});
|
|
1080
|
-
},
|
|
1078
|
+
}, lr = Z.getStore();
|
|
1081
1079
|
class W extends Error {
|
|
1082
1080
|
context;
|
|
1083
1081
|
_is_widget_error = !0;
|
|
1084
1082
|
constructor(t, r) {
|
|
1085
|
-
super(t), this.name = "WidgetError", this.cause = r?.cause, this.context =
|
|
1083
|
+
super(t), this.name = "WidgetError", this.cause = r?.cause, this.context = Ne(lr).context;
|
|
1086
1084
|
}
|
|
1087
1085
|
}
|
|
1088
|
-
class
|
|
1086
|
+
class vt extends W {
|
|
1089
1087
|
data;
|
|
1090
1088
|
constructor(t) {
|
|
1091
1089
|
super(t.code), this.data = t, this.name = "MachineError";
|
|
1092
1090
|
}
|
|
1093
1091
|
}
|
|
1094
|
-
class q extends
|
|
1092
|
+
class q extends vt {
|
|
1095
1093
|
constructor(t) {
|
|
1096
1094
|
super(t), this.name = "QuoteError";
|
|
1097
1095
|
}
|
|
1098
1096
|
}
|
|
1099
|
-
class g extends
|
|
1097
|
+
class g extends vt {
|
|
1100
1098
|
constructor(t) {
|
|
1101
1099
|
super(t), this.name = "TransferError";
|
|
1102
1100
|
}
|
|
1103
1101
|
}
|
|
1104
|
-
const
|
|
1105
|
-
usdTradeDelta: (e) =>
|
|
1106
|
-
isDirectNearTokenWithdrawal: (e) =>
|
|
1107
|
-
isDirectNonNearWithdrawal: (e) =>
|
|
1108
|
-
isDirectTokenOnNearDeposit: (e) =>
|
|
1109
|
-
isNativeNearDeposit: (e) =>
|
|
1110
|
-
isSameAssetDiffChainWithdrawal: (e) =>
|
|
1111
|
-
isDirectTokenOnNearTransfer: (e) =>
|
|
1112
|
-
}), z = () => oe(
|
|
1102
|
+
const Ui = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e && !!e._is_widget_error, M = Z.getStore(), cr = nn({
|
|
1103
|
+
usdTradeDelta: (e) => Un(e(M.context)),
|
|
1104
|
+
isDirectNearTokenWithdrawal: (e) => Mn(e(M.context)),
|
|
1105
|
+
isDirectNonNearWithdrawal: (e) => Pn(e(M.context)),
|
|
1106
|
+
isDirectTokenOnNearDeposit: (e) => rn(e(M.context)),
|
|
1107
|
+
isNativeNearDeposit: (e) => sn(e(M.context)),
|
|
1108
|
+
isSameAssetDiffChainWithdrawal: (e) => Vn(e(M.context)),
|
|
1109
|
+
isDirectTokenOnNearTransfer: (e) => Wn(e(M.context))
|
|
1110
|
+
}), z = () => oe(cr), _ = () => {
|
|
1113
1111
|
const e = oe(M);
|
|
1114
1112
|
return {
|
|
1115
1113
|
state: e.state,
|
|
1116
1114
|
ctx: e.context
|
|
1117
1115
|
};
|
|
1118
|
-
},
|
|
1116
|
+
}, Pi = (e) => {
|
|
1119
1117
|
const t = oe(M);
|
|
1120
1118
|
if (!D(t.context, [e]))
|
|
1121
1119
|
throw new W(
|
|
1122
1120
|
`[WIDGET] Attempt to access snapshot for ${e} state while context does not match`
|
|
1123
1121
|
);
|
|
1124
1122
|
return t.context;
|
|
1125
|
-
},
|
|
1123
|
+
}, dr = async ({
|
|
1126
1124
|
contractId: e,
|
|
1127
1125
|
accountId: t
|
|
1128
1126
|
}) => {
|
|
1129
1127
|
try {
|
|
1130
|
-
const r = { account_id: t }, s =
|
|
1128
|
+
const r = { account_id: t }, s = Oe.from(JSON.stringify(r)).toString("base64"), n = await $n.query({
|
|
1131
1129
|
request_type: "call_function",
|
|
1132
1130
|
method_name: "storage_balance_of",
|
|
1133
1131
|
account_id: e,
|
|
1134
1132
|
args_base64: s,
|
|
1135
1133
|
finality: "optimistic"
|
|
1136
|
-
}), a =
|
|
1134
|
+
}), a = Qn(
|
|
1137
1135
|
n,
|
|
1138
1136
|
se.union([se.null(), se.object({ total: se.string() })])
|
|
1139
1137
|
);
|
|
@@ -1142,10 +1140,10 @@ const Wi = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e
|
|
|
1142
1140
|
throw new W("Error fetching balance", { cause: r });
|
|
1143
1141
|
}
|
|
1144
1142
|
};
|
|
1145
|
-
function
|
|
1143
|
+
function ur(e) {
|
|
1146
1144
|
const { ctx: t } = _(), { isNativeNearDeposit: r } = z(), s = t.sourceToken?.contractAddress, n = t.quote?.amountIn ?? t.sourceTokenAmount;
|
|
1147
1145
|
return {
|
|
1148
|
-
make: async (
|
|
1146
|
+
make: async (c, l) => {
|
|
1149
1147
|
if (!e)
|
|
1150
1148
|
throw new g({
|
|
1151
1149
|
code: "TRANSFER_INVALID_INITIAL",
|
|
@@ -1156,7 +1154,7 @@ function fr(e) {
|
|
|
1156
1154
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1157
1155
|
meta: { message: "No token selected to transfer." }
|
|
1158
1156
|
});
|
|
1159
|
-
if (!
|
|
1157
|
+
if (!c)
|
|
1160
1158
|
throw new g({
|
|
1161
1159
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1162
1160
|
meta: { message: "No recipient address to transfer." }
|
|
@@ -1172,7 +1170,7 @@ function fr(e) {
|
|
|
1172
1170
|
transactions: [
|
|
1173
1171
|
{
|
|
1174
1172
|
signerId: t.walletAddress,
|
|
1175
|
-
receiverId:
|
|
1173
|
+
receiverId: c,
|
|
1176
1174
|
actions: [
|
|
1177
1175
|
{
|
|
1178
1176
|
type: "Transfer",
|
|
@@ -1202,7 +1200,7 @@ function fr(e) {
|
|
|
1202
1200
|
type: "FunctionCall",
|
|
1203
1201
|
params: {
|
|
1204
1202
|
methodName: "near_deposit",
|
|
1205
|
-
gas:
|
|
1203
|
+
gas: Pe,
|
|
1206
1204
|
deposit: n,
|
|
1207
1205
|
args: {}
|
|
1208
1206
|
}
|
|
@@ -1212,11 +1210,11 @@ function fr(e) {
|
|
|
1212
1210
|
methodName: "ft_transfer_call",
|
|
1213
1211
|
deposit: "1",
|
|
1214
1212
|
// 1 yocto required by NEP-141
|
|
1215
|
-
gas:
|
|
1213
|
+
gas: We,
|
|
1216
1214
|
args: {
|
|
1217
1215
|
amount: n,
|
|
1218
|
-
receiver_id:
|
|
1219
|
-
msg:
|
|
1216
|
+
receiver_id: c,
|
|
1217
|
+
msg: l ?? ""
|
|
1220
1218
|
}
|
|
1221
1219
|
}
|
|
1222
1220
|
});
|
|
@@ -1249,32 +1247,32 @@ function fr(e) {
|
|
|
1249
1247
|
});
|
|
1250
1248
|
try {
|
|
1251
1249
|
const [i, f] = await Promise.all([
|
|
1252
|
-
|
|
1250
|
+
Kn({
|
|
1253
1251
|
contractId: s
|
|
1254
1252
|
}),
|
|
1255
|
-
|
|
1253
|
+
dr({
|
|
1256
1254
|
contractId: s,
|
|
1257
|
-
accountId:
|
|
1255
|
+
accountId: c
|
|
1258
1256
|
})
|
|
1259
|
-
]),
|
|
1260
|
-
|
|
1257
|
+
]), T = i - f;
|
|
1258
|
+
T > 0n && u.push({
|
|
1261
1259
|
type: "FunctionCall",
|
|
1262
1260
|
params: {
|
|
1263
1261
|
methodName: "storage_deposit",
|
|
1264
|
-
args: { account_id:
|
|
1265
|
-
gas:
|
|
1266
|
-
deposit:
|
|
1262
|
+
args: { account_id: c },
|
|
1263
|
+
gas: Pe,
|
|
1264
|
+
deposit: T.toString()
|
|
1267
1265
|
}
|
|
1268
1266
|
}), u.push({
|
|
1269
1267
|
type: "FunctionCall",
|
|
1270
1268
|
params: {
|
|
1271
1269
|
methodName: "ft_transfer_call",
|
|
1272
1270
|
args: {
|
|
1273
|
-
receiver_id:
|
|
1271
|
+
receiver_id: c,
|
|
1274
1272
|
amount: n,
|
|
1275
|
-
msg:
|
|
1273
|
+
msg: l ?? ""
|
|
1276
1274
|
},
|
|
1277
|
-
gas:
|
|
1275
|
+
gas: We,
|
|
1278
1276
|
deposit: "1"
|
|
1279
1277
|
}
|
|
1280
1278
|
});
|
|
@@ -1303,19 +1301,19 @@ function fr(e) {
|
|
|
1303
1301
|
}
|
|
1304
1302
|
};
|
|
1305
1303
|
}
|
|
1306
|
-
const
|
|
1304
|
+
const mr = ({
|
|
1307
1305
|
makeTransfer: e,
|
|
1308
1306
|
providers: t
|
|
1309
1307
|
}) => {
|
|
1310
|
-
const { ctx: r } = _(), { alchemyApiKey: s } = y(), { make: n } =
|
|
1308
|
+
const { ctx: r } = _(), { alchemyApiKey: s } = y(), { make: n } = Hn({
|
|
1311
1309
|
provider: t?.evm
|
|
1312
|
-
}), { make: a } =
|
|
1310
|
+
}), { make: a } = Gn({
|
|
1313
1311
|
provider: t?.sol,
|
|
1314
1312
|
alchemyApiKey: s
|
|
1315
|
-
}),
|
|
1313
|
+
}), c = (d) => {
|
|
1316
1314
|
if (e)
|
|
1317
1315
|
return e;
|
|
1318
|
-
if (
|
|
1316
|
+
if (ht(d))
|
|
1319
1317
|
return n;
|
|
1320
1318
|
if (Tt(d))
|
|
1321
1319
|
return a;
|
|
@@ -1351,12 +1349,12 @@ const pr = ({
|
|
|
1351
1349
|
decimals: r.sourceToken.decimals,
|
|
1352
1350
|
address: r.quote.depositAddress,
|
|
1353
1351
|
chain: r.sourceToken.blockchain,
|
|
1354
|
-
evmChainId: Q(r.sourceToken.blockchain) ?
|
|
1355
|
-
isNativeEvmTokenTransfer: !!r.sourceToken &&
|
|
1352
|
+
evmChainId: Q(r.sourceToken.blockchain) ? he[r.sourceToken.blockchain] : null,
|
|
1353
|
+
isNativeEvmTokenTransfer: !!r.sourceToken && gt(r.sourceToken),
|
|
1356
1354
|
tokenAddress: r.sourceToken.assetId === $ ? $ : r.sourceToken.contractAddress,
|
|
1357
1355
|
sourceAssetId: r.sourceToken.assetId,
|
|
1358
1356
|
targetAssetId: r.targetToken.assetId
|
|
1359
|
-
}, u =
|
|
1357
|
+
}, u = c(d.address);
|
|
1360
1358
|
try {
|
|
1361
1359
|
const i = await u(d);
|
|
1362
1360
|
if (!i) {
|
|
@@ -1374,15 +1372,15 @@ const pr = ({
|
|
|
1374
1372
|
} catch (i) {
|
|
1375
1373
|
b.error("[TRANSFER ERROR]", i, { error: i });
|
|
1376
1374
|
let f = "Failed to make a transfer. Please try again.";
|
|
1377
|
-
const
|
|
1378
|
-
if (
|
|
1375
|
+
const T = i instanceof Error && Ae(i.message);
|
|
1376
|
+
if (T)
|
|
1379
1377
|
return;
|
|
1380
|
-
throw
|
|
1378
|
+
throw mn.isAxiosError(i) ? (f = i.response?.data?.detail ?? i.message ?? "Failed to make deposit. Please try again.", new g({
|
|
1381
1379
|
code: "QUOTE_ERROR",
|
|
1382
1380
|
meta: { message: f }
|
|
1383
1381
|
})) : f === "No quotes found" ? new g({
|
|
1384
1382
|
code: "NO_QUOTE_FOUND"
|
|
1385
|
-
}) : i instanceof Error && !
|
|
1383
|
+
}) : i instanceof Error && !T ? new g({
|
|
1386
1384
|
code: "QUOTE_ERROR",
|
|
1387
1385
|
meta: { message: i.message }
|
|
1388
1386
|
}) : new g({
|
|
@@ -1392,7 +1390,7 @@ const pr = ({
|
|
|
1392
1390
|
}
|
|
1393
1391
|
} };
|
|
1394
1392
|
};
|
|
1395
|
-
class
|
|
1393
|
+
class fr {
|
|
1396
1394
|
constructor(t, r) {
|
|
1397
1395
|
this.account = t, this.provider = r;
|
|
1398
1396
|
}
|
|
@@ -1402,7 +1400,7 @@ class hr {
|
|
|
1402
1400
|
deadline: t.deadline,
|
|
1403
1401
|
nonce: t.nonce,
|
|
1404
1402
|
intents: t.intents,
|
|
1405
|
-
signer_id: t.signer_id ??
|
|
1403
|
+
signer_id: t.signer_id ?? Ve.authHandleToIntentsUserId({
|
|
1406
1404
|
identifier: this.account.walletAddress,
|
|
1407
1405
|
method: "evm"
|
|
1408
1406
|
})
|
|
@@ -1417,14 +1415,14 @@ class hr {
|
|
|
1417
1415
|
return {
|
|
1418
1416
|
payload: r,
|
|
1419
1417
|
standard: "erc191",
|
|
1420
|
-
signature:
|
|
1418
|
+
signature: Ve.transformERC191Signature(a)
|
|
1421
1419
|
};
|
|
1422
1420
|
}
|
|
1423
1421
|
}
|
|
1424
|
-
const
|
|
1422
|
+
const pr = ({
|
|
1425
1423
|
walletAddress: e,
|
|
1426
1424
|
getProvider: t
|
|
1427
|
-
}) =>
|
|
1425
|
+
}) => jn({
|
|
1428
1426
|
accountId: e,
|
|
1429
1427
|
signMessage: async (r) => {
|
|
1430
1428
|
const s = t();
|
|
@@ -1434,7 +1432,7 @@ const Tr = ({
|
|
|
1434
1432
|
try {
|
|
1435
1433
|
n = await s.signMessage({
|
|
1436
1434
|
...r,
|
|
1437
|
-
nonce:
|
|
1435
|
+
nonce: Oe.from(r.nonce)
|
|
1438
1436
|
});
|
|
1439
1437
|
} catch (a) {
|
|
1440
1438
|
throw new W("Near wallet failed to sign a message", {
|
|
@@ -1448,7 +1446,7 @@ const Tr = ({
|
|
|
1448
1446
|
signature: n.signature
|
|
1449
1447
|
};
|
|
1450
1448
|
}
|
|
1451
|
-
}),
|
|
1449
|
+
}), Tr = (e, t) => {
|
|
1452
1450
|
if (t) {
|
|
1453
1451
|
if (e.sendAddress)
|
|
1454
1452
|
return e.sendAddress;
|
|
@@ -1463,8 +1461,8 @@ const Tr = ({
|
|
|
1463
1461
|
meta: { message: "Quote is required for intents non-direct transfer" }
|
|
1464
1462
|
});
|
|
1465
1463
|
return e.quote.depositAddress;
|
|
1466
|
-
},
|
|
1467
|
-
let r =
|
|
1464
|
+
}, hr = async (e, t) => {
|
|
1465
|
+
let r = Me.getItem("nearWalletsPk")[t];
|
|
1468
1466
|
if (!e.signMessage)
|
|
1469
1467
|
throw new g({
|
|
1470
1468
|
code: "DIRECT_TRANSFER_ERROR",
|
|
@@ -1475,14 +1473,14 @@ const Tr = ({
|
|
|
1475
1473
|
const a = await e.signMessage({
|
|
1476
1474
|
message: "Authenticate",
|
|
1477
1475
|
recipient: "intents.near",
|
|
1478
|
-
nonce:
|
|
1476
|
+
nonce: Oe.from(es(32))
|
|
1479
1477
|
});
|
|
1480
1478
|
if (!a)
|
|
1481
1479
|
throw new g({
|
|
1482
1480
|
code: "DIRECT_TRANSFER_ERROR",
|
|
1483
1481
|
meta: { message: "Signing message failed" }
|
|
1484
1482
|
});
|
|
1485
|
-
r = a.publicKey,
|
|
1483
|
+
r = a.publicKey, Me.setItem("nearWalletsPk", {
|
|
1486
1484
|
[t]: a.publicKey
|
|
1487
1485
|
});
|
|
1488
1486
|
} catch {
|
|
@@ -1495,7 +1493,7 @@ const Tr = ({
|
|
|
1495
1493
|
walletAddress: t,
|
|
1496
1494
|
addressType: "near"
|
|
1497
1495
|
});
|
|
1498
|
-
if (!await
|
|
1496
|
+
if (!await ns({
|
|
1499
1497
|
contractId: ke,
|
|
1500
1498
|
methodName: "has_public_key",
|
|
1501
1499
|
args: {
|
|
@@ -1529,11 +1527,11 @@ const Tr = ({
|
|
|
1529
1527
|
meta: { message: "Unable to add public key to intents account" }
|
|
1530
1528
|
});
|
|
1531
1529
|
}
|
|
1532
|
-
},
|
|
1530
|
+
}, gr = ({ providers: e }) => {
|
|
1533
1531
|
const { ctx: t } = _(), { appName: r, intentsAccountType: s } = y(), {
|
|
1534
1532
|
isNativeNearDeposit: n,
|
|
1535
1533
|
isDirectNearTokenWithdrawal: a,
|
|
1536
|
-
isDirectNonNearWithdrawal:
|
|
1534
|
+
isDirectNonNearWithdrawal: c
|
|
1537
1535
|
} = z();
|
|
1538
1536
|
return { make: async ({
|
|
1539
1537
|
message: d,
|
|
@@ -1569,7 +1567,7 @@ const Tr = ({
|
|
|
1569
1567
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1570
1568
|
meta: { message: "No EVM provider configured" }
|
|
1571
1569
|
});
|
|
1572
|
-
i = new
|
|
1570
|
+
i = new fr(
|
|
1573
1571
|
{ walletAddress: t.walletAddress },
|
|
1574
1572
|
e.evm
|
|
1575
1573
|
);
|
|
@@ -1580,7 +1578,7 @@ const Tr = ({
|
|
|
1580
1578
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1581
1579
|
meta: { message: "No SOL provider configured" }
|
|
1582
1580
|
});
|
|
1583
|
-
i = new
|
|
1581
|
+
i = new ts(
|
|
1584
1582
|
{ walletAddress: t.walletAddress },
|
|
1585
1583
|
e.sol
|
|
1586
1584
|
);
|
|
@@ -1591,30 +1589,30 @@ const Tr = ({
|
|
|
1591
1589
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1592
1590
|
meta: { message: "No NEAR provider configured" }
|
|
1593
1591
|
});
|
|
1594
|
-
await
|
|
1592
|
+
await hr(e.near(), t.walletAddress), i = pr({
|
|
1595
1593
|
walletAddress: t.walletAddress,
|
|
1596
1594
|
getProvider: e.near
|
|
1597
1595
|
});
|
|
1598
1596
|
break;
|
|
1599
1597
|
}
|
|
1600
1598
|
default:
|
|
1601
|
-
|
|
1599
|
+
Ee(s);
|
|
1602
1600
|
}
|
|
1603
|
-
const f = new
|
|
1601
|
+
const f = new zn({ referral: ct(r) });
|
|
1604
1602
|
f.setIntentSigner(i);
|
|
1605
|
-
let
|
|
1606
|
-
n ?
|
|
1603
|
+
let T;
|
|
1604
|
+
n ? T = void 0 : a ? T = Yn(d ?? void 0) : c ? T = void 0 : T = Zn();
|
|
1607
1605
|
const I = f.createWithdrawal({
|
|
1608
1606
|
withdrawalParams: {
|
|
1609
1607
|
assetId: t.sourceToken.assetId,
|
|
1610
1608
|
amount: BigInt(t.sourceTokenAmount),
|
|
1611
|
-
destinationAddress:
|
|
1609
|
+
destinationAddress: Tr(
|
|
1612
1610
|
t,
|
|
1613
|
-
a ||
|
|
1611
|
+
a || c
|
|
1614
1612
|
),
|
|
1615
1613
|
destinationMemo: void 0,
|
|
1616
1614
|
feeInclusive: !1,
|
|
1617
|
-
routeConfig:
|
|
1615
|
+
routeConfig: T
|
|
1618
1616
|
}
|
|
1619
1617
|
});
|
|
1620
1618
|
try {
|
|
@@ -1624,11 +1622,11 @@ const Tr = ({
|
|
|
1624
1622
|
const w = await I.waitForIntentSettlement();
|
|
1625
1623
|
return await I.waitForWithdrawalCompletion(), {
|
|
1626
1624
|
hash: w.hash,
|
|
1627
|
-
transactionLink:
|
|
1625
|
+
transactionLink: ss(en.near, w.hash),
|
|
1628
1626
|
intent: m
|
|
1629
1627
|
};
|
|
1630
1628
|
} catch (m) {
|
|
1631
|
-
if (b.error("[TRANSFER ERROR]", m), m instanceof
|
|
1629
|
+
if (b.error("[TRANSFER ERROR]", m), m instanceof Xn)
|
|
1632
1630
|
throw new g({
|
|
1633
1631
|
code: "MIN_WITHDRAWAL_AMOUNT_ERROR",
|
|
1634
1632
|
meta: {
|
|
@@ -1638,7 +1636,7 @@ const Tr = ({
|
|
|
1638
1636
|
)
|
|
1639
1637
|
}
|
|
1640
1638
|
});
|
|
1641
|
-
if (m instanceof
|
|
1639
|
+
if (m instanceof Jn)
|
|
1642
1640
|
throw new g({
|
|
1643
1641
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1644
1642
|
meta: { message: "Fee is above the maximum allowed" }
|
|
@@ -1656,7 +1654,7 @@ const Tr = ({
|
|
|
1656
1654
|
});
|
|
1657
1655
|
}
|
|
1658
1656
|
} };
|
|
1659
|
-
},
|
|
1657
|
+
}, Ir = ({
|
|
1660
1658
|
message: e,
|
|
1661
1659
|
providers: t,
|
|
1662
1660
|
makeTransfer: r
|
|
@@ -1664,11 +1662,11 @@ const Tr = ({
|
|
|
1664
1662
|
const { ctx: s } = _(), {
|
|
1665
1663
|
isDirectTokenOnNearDeposit: n,
|
|
1666
1664
|
isDirectTokenOnNearTransfer: a,
|
|
1667
|
-
isNativeNearDeposit:
|
|
1668
|
-
} = z(), { make:
|
|
1665
|
+
isNativeNearDeposit: c
|
|
1666
|
+
} = z(), { make: l } = gr({ providers: t }), { make: d } = mr({
|
|
1669
1667
|
makeTransfer: r,
|
|
1670
1668
|
providers: t
|
|
1671
|
-
}), { make: u } =
|
|
1669
|
+
}), { make: u } = ur(
|
|
1672
1670
|
t?.near
|
|
1673
1671
|
);
|
|
1674
1672
|
return { make: async () => {
|
|
@@ -1680,16 +1678,16 @@ const Tr = ({
|
|
|
1680
1678
|
status: "pending",
|
|
1681
1679
|
reason: "WAITING_CONFIRMATION"
|
|
1682
1680
|
}), s.sourceToken?.isIntent)
|
|
1683
|
-
f = await
|
|
1681
|
+
f = await l({
|
|
1684
1682
|
message: e,
|
|
1685
|
-
onPending: (
|
|
1683
|
+
onPending: (T) => {
|
|
1686
1684
|
p("transferSetStatus", {
|
|
1687
1685
|
status: "pending",
|
|
1688
|
-
reason:
|
|
1686
|
+
reason: T
|
|
1689
1687
|
});
|
|
1690
1688
|
}
|
|
1691
1689
|
});
|
|
1692
|
-
else if ((
|
|
1690
|
+
else if ((c || n) && !s.isDepositFromExternalWallet)
|
|
1693
1691
|
f = await u(
|
|
1694
1692
|
s.sendAddress ?? ke,
|
|
1695
1693
|
e
|
|
@@ -1706,8 +1704,8 @@ const Tr = ({
|
|
|
1706
1704
|
);
|
|
1707
1705
|
} else
|
|
1708
1706
|
f = await d();
|
|
1709
|
-
} catch (
|
|
1710
|
-
|
|
1707
|
+
} catch (T) {
|
|
1708
|
+
T instanceof g && (b.error(T.data), p("transferSetStatus", { status: "error" }), p("errorSet", T.data));
|
|
1711
1709
|
}
|
|
1712
1710
|
if (!f) {
|
|
1713
1711
|
p("transferSetStatus", { status: "idle" });
|
|
@@ -1715,73 +1713,73 @@ const Tr = ({
|
|
|
1715
1713
|
}
|
|
1716
1714
|
return p("transferSetStatus", { status: "success" }), O("transfer_success"), f;
|
|
1717
1715
|
} };
|
|
1718
|
-
},
|
|
1716
|
+
}, wr = async (e) => {
|
|
1719
1717
|
if (!e)
|
|
1720
1718
|
return;
|
|
1721
1719
|
const t = await e.request({
|
|
1722
1720
|
method: "eth_chainId"
|
|
1723
1721
|
});
|
|
1724
1722
|
return parseInt(t, 16);
|
|
1725
|
-
},
|
|
1726
|
-
const { ctx: t } = _(), [r, s] = re(!1), [n, a] = re(!1),
|
|
1723
|
+
}, kr = ({ providers: e }) => {
|
|
1724
|
+
const { ctx: t } = _(), [r, s] = re(!1), [n, a] = re(!1), c = Te(async () => {
|
|
1727
1725
|
const d = typeof e?.evm == "function" ? await e.evm() : e?.evm;
|
|
1728
1726
|
if (!t.sourceToken || !d)
|
|
1729
1727
|
return !1;
|
|
1730
|
-
const u = await
|
|
1728
|
+
const u = await wr(d);
|
|
1731
1729
|
if (!Q(t.sourceToken.blockchain))
|
|
1732
1730
|
return !1;
|
|
1733
|
-
const i =
|
|
1731
|
+
const i = he[t.sourceToken.blockchain];
|
|
1734
1732
|
return !i || !u ? !1 : u !== i;
|
|
1735
|
-
}, [t.sourceToken, e]),
|
|
1733
|
+
}, [t.sourceToken, e]), l = Te(async () => {
|
|
1736
1734
|
const d = typeof e?.evm == "function" ? await e.evm() : e?.evm;
|
|
1737
1735
|
if (!t.sourceToken || !d || !Q(t.sourceToken.blockchain))
|
|
1738
1736
|
return !1;
|
|
1739
|
-
const u =
|
|
1737
|
+
const u = he[t.sourceToken.blockchain];
|
|
1740
1738
|
if (!u)
|
|
1741
1739
|
return !1;
|
|
1742
1740
|
try {
|
|
1743
|
-
return s(!0), await
|
|
1741
|
+
return s(!0), await rs(u, d), !0;
|
|
1744
1742
|
} catch (i) {
|
|
1745
1743
|
return b.error("Failed to switch chain:", i), !1;
|
|
1746
1744
|
} finally {
|
|
1747
1745
|
s(!1);
|
|
1748
1746
|
}
|
|
1749
1747
|
}, [t.sourceToken, e]);
|
|
1750
|
-
return
|
|
1751
|
-
|
|
1752
|
-
}, [
|
|
1748
|
+
return R(() => {
|
|
1749
|
+
c().then(a);
|
|
1750
|
+
}, [c]), {
|
|
1753
1751
|
isSwitchingChainRequired: n,
|
|
1754
|
-
switchChain:
|
|
1752
|
+
switchChain: l,
|
|
1755
1753
|
isSwitchingChain: r
|
|
1756
1754
|
};
|
|
1757
|
-
},
|
|
1755
|
+
}, N = {
|
|
1758
1756
|
size: "lg",
|
|
1759
1757
|
variant: "primary"
|
|
1760
|
-
},
|
|
1758
|
+
}, Fe = (e) => {
|
|
1761
1759
|
const { t } = V();
|
|
1762
1760
|
if (e.error?.code === "TOKEN_IS_NOT_SUPPORTED")
|
|
1763
|
-
return /* @__PURE__ */ o(A, { state: "error", ...
|
|
1761
|
+
return /* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.invalidAddress", "Invalid address") });
|
|
1764
1762
|
if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_EMPTY")
|
|
1765
|
-
return /* @__PURE__ */ o(A, { state: "disabled", ...
|
|
1763
|
+
return /* @__PURE__ */ o(A, { state: "disabled", ...N, children: t("submit.disabled.enterRecipientAddress", "Enter recipient address") });
|
|
1766
1764
|
if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_NOT_FOUND")
|
|
1767
|
-
return /* @__PURE__ */ o(A, { state: "error", ...
|
|
1765
|
+
return /* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.sendAddressNotFound", {
|
|
1768
1766
|
defaultValue: "Address not found on {{chain}}",
|
|
1769
1767
|
chain: e.error.meta.chain.toUpperCase()
|
|
1770
1768
|
}) });
|
|
1771
1769
|
if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_INVALID")
|
|
1772
|
-
return /* @__PURE__ */ o(A, { state: "error", ...
|
|
1770
|
+
return /* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.sendAddressInvalid", {
|
|
1773
1771
|
defaultValue: "Invalid {{chain}} address",
|
|
1774
1772
|
chain: e.error.meta.chain.toUpperCase()
|
|
1775
1773
|
}) });
|
|
1776
1774
|
if (e.error?.code === "QUOTE_AMOUNT_IS_TOO_LOW" || e.error?.code === "MIN_WITHDRAWAL_AMOUNT_ERROR")
|
|
1777
|
-
return /* @__PURE__ */
|
|
1778
|
-
/* @__PURE__ */ o(A, { state: "error", ...
|
|
1779
|
-
/* @__PURE__ */ o(K, { children: /* @__PURE__ */
|
|
1775
|
+
return /* @__PURE__ */ h("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1776
|
+
/* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.amountTooLow.label", "Amount is too low") }),
|
|
1777
|
+
/* @__PURE__ */ o(K, { children: /* @__PURE__ */ h(Gt, { i18nKey: "submit.error.amountTooLow.message", children: [
|
|
1780
1778
|
"Amount you entered is very low. Please try increasing it",
|
|
1781
1779
|
" ",
|
|
1782
|
-
/* @__PURE__ */
|
|
1780
|
+
/* @__PURE__ */ h("span", { className: "text-nowrap", children: [
|
|
1783
1781
|
"above ",
|
|
1784
|
-
/* @__PURE__ */ o(
|
|
1782
|
+
/* @__PURE__ */ o(xe, { value: e.error.meta.minAmount ?? "0" }),
|
|
1785
1783
|
" ",
|
|
1786
1784
|
e.sourceToken?.symbol ?? "",
|
|
1787
1785
|
"."
|
|
@@ -1789,81 +1787,81 @@ const Tr = ({
|
|
|
1789
1787
|
] }) })
|
|
1790
1788
|
] });
|
|
1791
1789
|
if (e.quoteStatus === "error")
|
|
1792
|
-
return /* @__PURE__ */
|
|
1793
|
-
/* @__PURE__ */ o(A, { state: "error", ...
|
|
1790
|
+
return /* @__PURE__ */ h("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1791
|
+
/* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.quoteFailed.label", "Quote failed") }),
|
|
1794
1792
|
/* @__PURE__ */ o(K, { children: t(
|
|
1795
1793
|
"submit.error.quoteFailed.message",
|
|
1796
1794
|
"We couldn’t finalize your quote. Please try again or adjust your values."
|
|
1797
1795
|
) })
|
|
1798
1796
|
] });
|
|
1799
1797
|
if (e.error?.code === "TRANSFER_INVALID_INITIAL")
|
|
1800
|
-
return /* @__PURE__ */
|
|
1801
|
-
/* @__PURE__ */ o(A, { state: "error", ...
|
|
1798
|
+
return /* @__PURE__ */ h("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1799
|
+
/* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.invalidTransferData.label", "Invalid transfer data") }),
|
|
1802
1800
|
e.error.meta?.message ? /* @__PURE__ */ o(K, { children: e.error.meta.message }) : null
|
|
1803
1801
|
] });
|
|
1804
1802
|
if (e.error?.code === "EXTERNAL_TRANSFER_FAILED")
|
|
1805
|
-
return /* @__PURE__ */ o(A, { state: "error", ...
|
|
1803
|
+
return /* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.externalTransferFailed.label", "Transfer failed") });
|
|
1806
1804
|
if (e.error?.code === "EXTERNAL_TRANSFER_INCOMPLETE")
|
|
1807
|
-
return /* @__PURE__ */
|
|
1808
|
-
/* @__PURE__ */ o(A, { state: "error", ...
|
|
1805
|
+
return /* @__PURE__ */ h("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1806
|
+
/* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.externalTransferFailed.label", "Transfer failed") }),
|
|
1809
1807
|
/* @__PURE__ */ o(K, { children: t(
|
|
1810
1808
|
"submit.error.externalTransferFailed.incompleteMessage",
|
|
1811
1809
|
"Incomplete transfer. Deposited amount will be refunded."
|
|
1812
1810
|
) })
|
|
1813
1811
|
] });
|
|
1814
1812
|
if (e.error?.code === "EXTERNAL_TRANSFER_REFUNDED")
|
|
1815
|
-
return /* @__PURE__ */
|
|
1816
|
-
/* @__PURE__ */ o(A, { state: "error", ...
|
|
1813
|
+
return /* @__PURE__ */ h("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1814
|
+
/* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.externalTransferFailed.label", "Transfer failed") }),
|
|
1817
1815
|
/* @__PURE__ */ o(K, { children: t(
|
|
1818
1816
|
"submit.error.externalTransferFailed.refundedMessage",
|
|
1819
1817
|
"Deposited amount will be refunded."
|
|
1820
1818
|
) })
|
|
1821
1819
|
] });
|
|
1822
1820
|
if (e.error?.code === "DIRECT_TRANSFER_ERROR")
|
|
1823
|
-
return /* @__PURE__ */
|
|
1824
|
-
/* @__PURE__ */ o(A, { state: "error", ...
|
|
1821
|
+
return /* @__PURE__ */ h("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1822
|
+
/* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.transferFailed.label", "Transfer failed") }),
|
|
1825
1823
|
e.error.meta?.message ? /* @__PURE__ */ o(K, { children: e.error.meta.message }) : null
|
|
1826
1824
|
] });
|
|
1827
1825
|
if (e.error?.code === "SOURCE_BALANCE_INSUFFICIENT")
|
|
1828
|
-
return /* @__PURE__ */ o(A, { state: "error", ...
|
|
1829
|
-
},
|
|
1826
|
+
return /* @__PURE__ */ o(A, { state: "error", ...N, children: t("submit.error.insufficientBalance", "Insufficient balance") });
|
|
1827
|
+
}, Ar = ({ onClick: e }) => {
|
|
1830
1828
|
const { t } = V();
|
|
1831
|
-
return /* @__PURE__ */ o(A, { state: "disabled", ...
|
|
1832
|
-
},
|
|
1829
|
+
return /* @__PURE__ */ o(A, { state: "disabled", ...N, onClick: e, children: t("submit.error.connectWallet", "Connect wallet") });
|
|
1830
|
+
}, Sr = () => {
|
|
1833
1831
|
const { ctx: e } = _();
|
|
1834
|
-
return
|
|
1835
|
-
},
|
|
1832
|
+
return Fe(e) ?? null;
|
|
1833
|
+
}, Nr = (e) => {
|
|
1836
1834
|
const { providers: t, makeTransfer: r, onSuccess: s } = e, { ctx: n } = _(), { t: a } = V(), {
|
|
1837
|
-
isNativeNearDeposit:
|
|
1838
|
-
isDirectNonNearWithdrawal:
|
|
1835
|
+
isNativeNearDeposit: c,
|
|
1836
|
+
isDirectNonNearWithdrawal: l,
|
|
1839
1837
|
isDirectTokenOnNearDeposit: d,
|
|
1840
1838
|
isDirectNearTokenWithdrawal: u
|
|
1841
|
-
} = z(), { make: i } =
|
|
1842
|
-
if (f && !await
|
|
1839
|
+
} = z(), { make: i } = Ir({ providers: t, makeTransfer: r }), { isSwitchingChainRequired: f, switchChain: T, isSwitchingChain: I } = kr({ providers: t }), m = Fe(n), w = async () => {
|
|
1840
|
+
if (f && !await T())
|
|
1843
1841
|
return;
|
|
1844
|
-
const
|
|
1845
|
-
|
|
1842
|
+
const S = await i();
|
|
1843
|
+
S && s(S);
|
|
1846
1844
|
};
|
|
1847
1845
|
if (!n.targetToken)
|
|
1848
|
-
return /* @__PURE__ */ o(A, { ...
|
|
1846
|
+
return /* @__PURE__ */ o(A, { ...N, state: "disabled", children: a("submit.disabled.selectTokenToReceive", "Select token to receive") });
|
|
1849
1847
|
if (!ne(n.sourceTokenAmount))
|
|
1850
|
-
return /* @__PURE__ */ o(A, { ...
|
|
1848
|
+
return /* @__PURE__ */ o(A, { ...N, state: "disabled", children: a("submit.disabled.enterAmount", "Enter amount") });
|
|
1851
1849
|
if (n.areInputsValidating)
|
|
1852
|
-
return /* @__PURE__ */ o(A, { state: "loading", ...
|
|
1850
|
+
return /* @__PURE__ */ o(A, { state: "loading", ...N, children: a("submit.pending.validating", "Validating...") });
|
|
1853
1851
|
if (I)
|
|
1854
|
-
return /* @__PURE__ */ o(A, { state: "loading", ...
|
|
1852
|
+
return /* @__PURE__ */ o(A, { state: "loading", ...N, children: a("submit.pending.switchingChain", "Switching network...") });
|
|
1855
1853
|
if (!f && m)
|
|
1856
1854
|
return m;
|
|
1857
1855
|
if (n.transferStatus.status === "pending")
|
|
1858
1856
|
switch (n.transferStatus.reason) {
|
|
1859
1857
|
case "WAITING_CONFIRMATION":
|
|
1860
|
-
return /* @__PURE__ */ o(A, { state: "loading", ...
|
|
1858
|
+
return /* @__PURE__ */ o(A, { state: "loading", ...N, children: a("submit.pending.transfer.confirmInWallet", "Confirm in wallet") });
|
|
1861
1859
|
case "PROCESSING":
|
|
1862
1860
|
default:
|
|
1863
|
-
return /* @__PURE__ */ o(A, { state: "loading", ...
|
|
1861
|
+
return /* @__PURE__ */ o(A, { state: "loading", ...N, children: a("submit.pending.transfer.finalizing", "Finalizing transfer") });
|
|
1864
1862
|
}
|
|
1865
|
-
return n.transferStatus.status === "error" ? /* @__PURE__ */
|
|
1866
|
-
/* @__PURE__ */ o(A, { ...
|
|
1863
|
+
return n.transferStatus.status === "error" ? /* @__PURE__ */ h("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1864
|
+
/* @__PURE__ */ o(A, { ...N, children: e.label }),
|
|
1867
1865
|
/* @__PURE__ */ o(K, { children: (() => {
|
|
1868
1866
|
switch (n.error?.code) {
|
|
1869
1867
|
case "FEES_NOT_ESTIMATED":
|
|
@@ -1878,39 +1876,39 @@ const Tr = ({
|
|
|
1878
1876
|
);
|
|
1879
1877
|
}
|
|
1880
1878
|
})() })
|
|
1881
|
-
] }) : n.quoteStatus === "pending" ? /* @__PURE__ */ o(A, { state: "loading", ...
|
|
1882
|
-
},
|
|
1883
|
-
const { t } = V(), { ctx: r } = _(), s =
|
|
1884
|
-
return r.isDepositFromExternalWallet ? ne(r.sourceTokenAmount) ? r.externalDepositTxReceived ? /* @__PURE__ */ o(A, { state: "loading", ...
|
|
1885
|
-
},
|
|
1879
|
+
] }) : n.quoteStatus === "pending" ? /* @__PURE__ */ o(A, { state: "loading", ...N, children: n.quote ? a("submit.pending.quote.refreshing", "Refreshing quote") : a("submit.pending.quote.finalizing", "Finalizing quote") }) : n.error ? /* @__PURE__ */ o(A, { state: "disabled", ...N, children: e.label }) : !n.quote && !l && !d && !u && !c ? /* @__PURE__ */ o(A, { state: "disabled", ...N, children: e.label }) : /* @__PURE__ */ o(A, { ...N, onClick: w, children: e.label });
|
|
1880
|
+
}, _r = (e) => {
|
|
1881
|
+
const { t } = V(), { ctx: r } = _(), s = Fe(r);
|
|
1882
|
+
return r.isDepositFromExternalWallet ? ne(r.sourceTokenAmount) ? r.externalDepositTxReceived ? /* @__PURE__ */ o(A, { state: "loading", ...N, children: t("submit.pending.externalDeposit.processing", "Processing") }) : /* @__PURE__ */ o(A, { state: "loading", ...N, children: t("submit.pending.externalDeposit.waiting", "Waiting for transaction") }) : /* @__PURE__ */ o(A, { ...N, state: "disabled", children: t("submit.disabled.enterAmount", "Enter amount") }) : s || /* @__PURE__ */ o(Nr, { ...e });
|
|
1883
|
+
}, yr = (e) => {
|
|
1886
1884
|
const { ctx: t } = _(), r = y();
|
|
1887
|
-
return t.walletAddress ? /* @__PURE__ */ o(
|
|
1885
|
+
return t.walletAddress ? /* @__PURE__ */ o(_r, { ...e }) : /* @__PURE__ */ o(Ar, { onClick: r.onWalletSignin });
|
|
1888
1886
|
};
|
|
1889
|
-
|
|
1890
|
-
const
|
|
1887
|
+
yr.Error = Sr;
|
|
1888
|
+
const br = ({ className: e }) => {
|
|
1891
1889
|
const { t } = V(), { slippageTolerance: r } = y(), { ctx: s } = _(), n = s.sourceToken && s.targetToken && s.sourceToken.price / s.targetToken.price;
|
|
1892
1890
|
return s.sourceToken ? /* @__PURE__ */ o(
|
|
1893
|
-
|
|
1891
|
+
as,
|
|
1894
1892
|
{
|
|
1895
1893
|
expandedByDefault: !1,
|
|
1896
1894
|
expandedHeightPx: s.walletAddress ? 80 : 50,
|
|
1897
1895
|
isBadgeLoading: s.quoteStatus === "pending",
|
|
1898
1896
|
badge: s.quote ? `~ ${s.quote.timeEstimate} sec` : void 0,
|
|
1899
1897
|
className: e,
|
|
1900
|
-
title: s.sourceToken && s.targetToken ? /* @__PURE__ */
|
|
1898
|
+
title: s.sourceToken && s.targetToken ? /* @__PURE__ */ h("span", { style: { borderBottomWidth: "2px", borderStyle: "dotted" }, children: [
|
|
1901
1899
|
`1 ${s.sourceToken.symbol} ≈ `,
|
|
1902
1900
|
" ",
|
|
1903
|
-
|
|
1901
|
+
os(n ?? 0),
|
|
1904
1902
|
" ",
|
|
1905
1903
|
`${s.targetToken.symbol}`,
|
|
1906
|
-
/* @__PURE__ */ o("span", { className: "text-sw-gray-50", children: ` (${
|
|
1907
|
-
] }) : /* @__PURE__ */
|
|
1904
|
+
/* @__PURE__ */ o("span", { className: "text-sw-gray-50", children: ` (${Qe(s.sourceToken.price)})` })
|
|
1905
|
+
] }) : /* @__PURE__ */ h("span", { style: { borderBottomWidth: "2px", borderStyle: "dotted" }, children: [
|
|
1908
1906
|
`1 ${s.sourceToken.symbol} ≈ `,
|
|
1909
1907
|
" ",
|
|
1910
|
-
|
|
1908
|
+
Qe(s.sourceToken.price),
|
|
1911
1909
|
" USD"
|
|
1912
1910
|
] }),
|
|
1913
|
-
children: /* @__PURE__ */
|
|
1911
|
+
children: /* @__PURE__ */ h(de, { children: [
|
|
1914
1912
|
/* @__PURE__ */ o(
|
|
1915
1913
|
de.Item,
|
|
1916
1914
|
{
|
|
@@ -1928,28 +1926,28 @@ const Cr = ({ className: e }) => {
|
|
|
1928
1926
|
)
|
|
1929
1927
|
] })
|
|
1930
1928
|
}
|
|
1931
|
-
) : /* @__PURE__ */ o(
|
|
1932
|
-
},
|
|
1933
|
-
Skeleton:
|
|
1934
|
-
}),
|
|
1929
|
+
) : /* @__PURE__ */ o(It, {});
|
|
1930
|
+
}, Wi = Object.assign(br, {
|
|
1931
|
+
Skeleton: It
|
|
1932
|
+
}), Er = ({
|
|
1935
1933
|
token: e,
|
|
1936
1934
|
balance: t,
|
|
1937
1935
|
isNotSufficient: r = !1,
|
|
1938
1936
|
onClick: s
|
|
1939
1937
|
}) => {
|
|
1940
1938
|
const n = y();
|
|
1941
|
-
return !e.isIntent && !n.walletSupportedChains.includes(e.blockchain) ? /* @__PURE__ */ o("span", {}) : t === void 0 ? /* @__PURE__ */ o(
|
|
1939
|
+
return !e.isIntent && !n.walletSupportedChains.includes(e.blockchain) ? /* @__PURE__ */ o("span", {}) : t === void 0 ? /* @__PURE__ */ o(ls, { width: 100 }) : /* @__PURE__ */ o(
|
|
1942
1940
|
"span",
|
|
1943
1941
|
{
|
|
1944
1942
|
onClick: t ? s : void 0,
|
|
1945
1943
|
style: t ? { borderBottomWidth: "2px", borderStyle: "dotted" } : void 0,
|
|
1946
|
-
className:
|
|
1944
|
+
className: is("text-sw-label-sm", {
|
|
1947
1945
|
"text-sw-status-error": r,
|
|
1948
1946
|
"text-sw-gray-100": !r,
|
|
1949
1947
|
"cursor-pointer": !!t && !!s
|
|
1950
1948
|
}),
|
|
1951
1949
|
children: /* @__PURE__ */ o(
|
|
1952
|
-
|
|
1950
|
+
xe,
|
|
1953
1951
|
{
|
|
1954
1952
|
decimals: e.decimals,
|
|
1955
1953
|
value: t === void 0 ? "0" : `${t}`
|
|
@@ -1957,27 +1955,27 @@ const Cr = ({ className: e }) => {
|
|
|
1957
1955
|
)
|
|
1958
1956
|
}
|
|
1959
1957
|
);
|
|
1960
|
-
},
|
|
1958
|
+
}, Le = ({
|
|
1961
1959
|
token: e,
|
|
1962
1960
|
balance: t,
|
|
1963
1961
|
value: r = "",
|
|
1964
1962
|
quoteUsdDelta: s,
|
|
1965
1963
|
quoteUsdValue: n,
|
|
1966
1964
|
state: a = "default",
|
|
1967
|
-
showBalance:
|
|
1968
|
-
showQuickBalanceActions:
|
|
1965
|
+
showBalance: c = !0,
|
|
1966
|
+
showQuickBalanceActions: l = !0,
|
|
1969
1967
|
heading: d,
|
|
1970
1968
|
onMsg: u
|
|
1971
1969
|
}) => {
|
|
1972
|
-
const i =
|
|
1970
|
+
const i = Wt(), { ctx: f } = _(), { t: T } = V(), { hideTokenInputHeadings: I } = y(), m = ds(e, r, n), w = (S) => {
|
|
1973
1971
|
u({
|
|
1974
1972
|
type: "on_change_amount",
|
|
1975
|
-
amount:
|
|
1973
|
+
amount: cs(t, e.decimals, S)
|
|
1976
1974
|
});
|
|
1977
1975
|
};
|
|
1978
|
-
return /* @__PURE__ */
|
|
1979
|
-
!I && /* @__PURE__ */ o(
|
|
1980
|
-
/* @__PURE__ */
|
|
1976
|
+
return /* @__PURE__ */ h(ie, { className: "flex flex-col", "aria-label": d, children: [
|
|
1977
|
+
!I && /* @__PURE__ */ o(wt, { children: d }),
|
|
1978
|
+
/* @__PURE__ */ h(
|
|
1981
1979
|
"div",
|
|
1982
1980
|
{
|
|
1983
1981
|
className: H(
|
|
@@ -1986,19 +1984,19 @@ const Cr = ({ className: e }) => {
|
|
|
1986
1984
|
),
|
|
1987
1985
|
children: [
|
|
1988
1986
|
/* @__PURE__ */ o(
|
|
1989
|
-
|
|
1987
|
+
ms,
|
|
1990
1988
|
{
|
|
1991
1989
|
value: r,
|
|
1992
1990
|
name: i,
|
|
1993
|
-
setValue:
|
|
1991
|
+
setValue: us,
|
|
1994
1992
|
placeholder: "0",
|
|
1995
1993
|
state: a === "default" || a === "disabled" ? a : "error",
|
|
1996
|
-
onChange: (
|
|
1997
|
-
u({ type: "on_change_amount", amount:
|
|
1994
|
+
onChange: (S) => {
|
|
1995
|
+
u({ type: "on_change_amount", amount: S.target.value });
|
|
1998
1996
|
}
|
|
1999
1997
|
}
|
|
2000
1998
|
),
|
|
2001
|
-
/* @__PURE__ */
|
|
1999
|
+
/* @__PURE__ */ h(
|
|
2002
2000
|
"button",
|
|
2003
2001
|
{
|
|
2004
2002
|
type: "button",
|
|
@@ -2012,11 +2010,11 @@ const Cr = ({ className: e }) => {
|
|
|
2012
2010
|
),
|
|
2013
2011
|
children: [
|
|
2014
2012
|
/* @__PURE__ */ o(
|
|
2015
|
-
|
|
2013
|
+
kt,
|
|
2016
2014
|
{
|
|
2015
|
+
token: e,
|
|
2017
2016
|
chainShowIcon: !e.isIntent,
|
|
2018
|
-
className: "border-sw-gray-800 group-hover:border-sw-gray-700 transition-colors top-[14px]"
|
|
2019
|
-
...e
|
|
2017
|
+
className: "border-sw-gray-800 group-hover:border-sw-gray-700 transition-colors top-[14px]"
|
|
2020
2018
|
}
|
|
2021
2019
|
),
|
|
2022
2020
|
/* @__PURE__ */ o("span", { className: "text-sw-label-md text-sw-gray-50", children: e.symbol })
|
|
@@ -2026,8 +2024,8 @@ const Cr = ({ className: e }) => {
|
|
|
2026
2024
|
]
|
|
2027
2025
|
}
|
|
2028
2026
|
),
|
|
2029
|
-
/* @__PURE__ */
|
|
2030
|
-
/* @__PURE__ */
|
|
2027
|
+
/* @__PURE__ */ h("div", { className: "gap-sw-sm min-h-sw-2xl flex items-center justify-between mt-sw-lg", children: [
|
|
2028
|
+
/* @__PURE__ */ h("div", { className: "gap-sw-md flex items-center", children: [
|
|
2031
2029
|
/* @__PURE__ */ o("span", { className: "text-sw-label-sm text-sw-gray-100", children: m }),
|
|
2032
2030
|
s ? /* @__PURE__ */ o(
|
|
2033
2031
|
"span",
|
|
@@ -2042,9 +2040,9 @@ const Cr = ({ className: e }) => {
|
|
|
2042
2040
|
}
|
|
2043
2041
|
) : null
|
|
2044
2042
|
] }),
|
|
2045
|
-
/* @__PURE__ */
|
|
2046
|
-
e && !!f.walletAddress &&
|
|
2047
|
-
|
|
2043
|
+
/* @__PURE__ */ h("div", { className: "gap-sw-sm flex items-center", children: [
|
|
2044
|
+
e && !!f.walletAddress && c && /* @__PURE__ */ o(
|
|
2045
|
+
Er,
|
|
2048
2046
|
{
|
|
2049
2047
|
token: e,
|
|
2050
2048
|
balance: t,
|
|
@@ -2052,39 +2050,39 @@ const Cr = ({ className: e }) => {
|
|
|
2052
2050
|
onClick: () => w(1)
|
|
2053
2051
|
}
|
|
2054
2052
|
),
|
|
2055
|
-
!!t &&
|
|
2053
|
+
!!t && c && l && /* @__PURE__ */ h(Lt, { children: [
|
|
2056
2054
|
/* @__PURE__ */ o(
|
|
2057
|
-
|
|
2055
|
+
$e,
|
|
2058
2056
|
{
|
|
2059
2057
|
isClickable: a !== "disabled",
|
|
2060
2058
|
onClick: () => w(2),
|
|
2061
|
-
children:
|
|
2059
|
+
children: T("tokens.input.half.label", "50%")
|
|
2062
2060
|
}
|
|
2063
2061
|
),
|
|
2064
2062
|
/* @__PURE__ */ o(
|
|
2065
|
-
|
|
2063
|
+
$e,
|
|
2066
2064
|
{
|
|
2067
2065
|
isClickable: a !== "disabled",
|
|
2068
2066
|
onClick: () => w(1),
|
|
2069
|
-
children:
|
|
2067
|
+
children: T("tokens.input.max.label", "Max")
|
|
2070
2068
|
}
|
|
2071
2069
|
)
|
|
2072
2070
|
] }),
|
|
2073
|
-
!
|
|
2071
|
+
!c && /* @__PURE__ */ o("div", { className: "rounded-full bg-sw-gray-700 py-sw-xs px-sw-sm flex items-center justify-center", children: /* @__PURE__ */ o("span", { className: "text-sw-gray-100 text-sw-label-sm", children: T("tokens.input.externalBalance.label", "External balance") }) })
|
|
2074
2072
|
] })
|
|
2075
2073
|
] })
|
|
2076
2074
|
] });
|
|
2077
|
-
},
|
|
2075
|
+
}, Be = ({ onMsg: e, heading: t }) => {
|
|
2078
2076
|
const { hideTokenInputHeadings: r } = y();
|
|
2079
|
-
return /* @__PURE__ */
|
|
2077
|
+
return /* @__PURE__ */ h(
|
|
2080
2078
|
ie,
|
|
2081
2079
|
{
|
|
2082
2080
|
isClickable: !0,
|
|
2083
2081
|
className: "flex flex-col",
|
|
2084
2082
|
onClick: () => e({ type: "on_click_select_token" }),
|
|
2085
2083
|
children: [
|
|
2086
|
-
!r && /* @__PURE__ */ o(
|
|
2087
|
-
/* @__PURE__ */
|
|
2084
|
+
!r && /* @__PURE__ */ o(wt, { children: t }),
|
|
2085
|
+
/* @__PURE__ */ h(
|
|
2088
2086
|
"div",
|
|
2089
2087
|
{
|
|
2090
2088
|
className: H(
|
|
@@ -2116,11 +2114,11 @@ const Cr = ({ className: e }) => {
|
|
|
2116
2114
|
]
|
|
2117
2115
|
}
|
|
2118
2116
|
);
|
|
2119
|
-
},
|
|
2120
|
-
const { mergedBalance: t } =
|
|
2117
|
+
}, Dt = (e) => {
|
|
2118
|
+
const { mergedBalance: t } = ce(), [r, s] = re(
|
|
2121
2119
|
e ? t[G(e)] : void 0
|
|
2122
2120
|
);
|
|
2123
|
-
return
|
|
2121
|
+
return R(() => {
|
|
2124
2122
|
let n;
|
|
2125
2123
|
if (e) {
|
|
2126
2124
|
const a = t[G(e)];
|
|
@@ -2136,23 +2134,23 @@ const Cr = ({ className: e }) => {
|
|
|
2136
2134
|
n && clearTimeout(n);
|
|
2137
2135
|
};
|
|
2138
2136
|
}, [e, t]), r;
|
|
2139
|
-
},
|
|
2137
|
+
}, xt = (e, t) => {
|
|
2140
2138
|
const { tokens: r } = P(e), s = Array.from(
|
|
2141
2139
|
new Set(r.map((n) => n.assetId))
|
|
2142
2140
|
);
|
|
2143
|
-
|
|
2141
|
+
R(() => {
|
|
2144
2142
|
const n = s.length === 1 ? r[0] : null;
|
|
2145
2143
|
n && t({ type: "on_select_token", token: n });
|
|
2146
2144
|
}, [r]);
|
|
2147
|
-
},
|
|
2145
|
+
}, Rr = ({
|
|
2148
2146
|
onMsg: e,
|
|
2149
2147
|
isChanging: t = !0,
|
|
2150
2148
|
showBalance: r = !0,
|
|
2151
2149
|
heading: s
|
|
2152
2150
|
}) => {
|
|
2153
|
-
const { ctx: n } = _(), a =
|
|
2154
|
-
|
|
2155
|
-
const
|
|
2151
|
+
const { ctx: n } = _(), a = Dt(n.sourceToken);
|
|
2152
|
+
xt("source", e);
|
|
2153
|
+
const c = v(() => {
|
|
2156
2154
|
if (!t && n.quoteStatus === "pending")
|
|
2157
2155
|
return "disabled";
|
|
2158
2156
|
if (!n.error)
|
|
@@ -2163,28 +2161,28 @@ const Cr = ({ className: e }) => {
|
|
|
2163
2161
|
return "error-balance";
|
|
2164
2162
|
}, [t, n.error, n.quoteStatus]);
|
|
2165
2163
|
return n.sourceToken ? /* @__PURE__ */ o(
|
|
2166
|
-
|
|
2164
|
+
Le,
|
|
2167
2165
|
{
|
|
2168
2166
|
heading: s,
|
|
2169
2167
|
token: n.sourceToken,
|
|
2170
|
-
state:
|
|
2168
|
+
state: c,
|
|
2171
2169
|
balance: a,
|
|
2172
2170
|
showBalance: r,
|
|
2173
2171
|
showQuickBalanceActions: !0,
|
|
2174
2172
|
value: j(n.sourceTokenAmount, n.sourceToken?.decimals),
|
|
2175
2173
|
onMsg: e
|
|
2176
2174
|
}
|
|
2177
|
-
) : /* @__PURE__ */ o(
|
|
2178
|
-
},
|
|
2175
|
+
) : /* @__PURE__ */ o(Be, { heading: s, onMsg: e });
|
|
2176
|
+
}, Cr = ({
|
|
2179
2177
|
isChanging: e = !1,
|
|
2180
2178
|
onMsg: t,
|
|
2181
2179
|
heading: r
|
|
2182
2180
|
}) => {
|
|
2183
|
-
const { ctx: s } = _(), { usdTradeDelta: n } = z(), a =
|
|
2184
|
-
|
|
2185
|
-
const
|
|
2181
|
+
const { ctx: s } = _(), { usdTradeDelta: n } = z(), a = Dt(s.targetToken);
|
|
2182
|
+
xt("target", t);
|
|
2183
|
+
const c = v(() => !e && s.quoteStatus === "pending" ? "disabled" : "default", [e, s.quoteStatus]);
|
|
2186
2184
|
return s.targetToken ? /* @__PURE__ */ o(
|
|
2187
|
-
|
|
2185
|
+
Le,
|
|
2188
2186
|
{
|
|
2189
2187
|
heading: r,
|
|
2190
2188
|
token: s.targetToken,
|
|
@@ -2192,17 +2190,17 @@ const Cr = ({ className: e }) => {
|
|
|
2192
2190
|
quoteUsdDelta: n?.percentage,
|
|
2193
2191
|
quoteUsdValue: s.quote && parseFloat(s.quote.amountOutUsd),
|
|
2194
2192
|
value: j(s.targetTokenAmount, s.targetToken?.decimals),
|
|
2195
|
-
state:
|
|
2193
|
+
state: c,
|
|
2196
2194
|
showQuickBalanceActions: !1,
|
|
2197
2195
|
showBalance: !0,
|
|
2198
2196
|
onMsg: t
|
|
2199
2197
|
}
|
|
2200
|
-
) : /* @__PURE__ */ o(
|
|
2201
|
-
},
|
|
2202
|
-
Skeleton:
|
|
2203
|
-
Source:
|
|
2204
|
-
Target:
|
|
2205
|
-
}),
|
|
2198
|
+
) : /* @__PURE__ */ o(Be, { heading: r, onMsg: t });
|
|
2199
|
+
}, vr = ({ token: e, heading: t, ...r }) => e ? /* @__PURE__ */ o(Le, { ...r, token: e, heading: t }) : /* @__PURE__ */ o(Be, { onMsg: r.onMsg, heading: t }), Mi = Object.assign(vr, {
|
|
2200
|
+
Skeleton: fs,
|
|
2201
|
+
Source: Rr,
|
|
2202
|
+
Target: Cr
|
|
2203
|
+
}), Ze = 58, Ot = ({
|
|
2206
2204
|
token: e,
|
|
2207
2205
|
balance: t,
|
|
2208
2206
|
showBalance: r = !0,
|
|
@@ -2210,8 +2208,8 @@ const Cr = ({ className: e }) => {
|
|
|
2210
2208
|
className: n,
|
|
2211
2209
|
onMsg: a
|
|
2212
2210
|
}) => {
|
|
2213
|
-
const { ctx:
|
|
2214
|
-
return /* @__PURE__ */ o("li", { className: "list-none group", children: /* @__PURE__ */
|
|
2211
|
+
const { ctx: c } = _(), { walletSupportedChains: l, appName: d } = y(), u = ps(t, e), i = l.includes(e.blockchain) || e.isIntent, f = t !== "0" && t !== 0 && t !== void 0;
|
|
2212
|
+
return /* @__PURE__ */ o("li", { className: "list-none group", children: /* @__PURE__ */ h(
|
|
2215
2213
|
"div",
|
|
2216
2214
|
{
|
|
2217
2215
|
className: H(
|
|
@@ -2225,28 +2223,28 @@ const Cr = ({ className: e }) => {
|
|
|
2225
2223
|
onClick: () => !s && a({ type: "on_select_token", token: e }),
|
|
2226
2224
|
children: [
|
|
2227
2225
|
/* @__PURE__ */ o(
|
|
2228
|
-
|
|
2226
|
+
kt,
|
|
2229
2227
|
{
|
|
2228
|
+
token: e,
|
|
2230
2229
|
chainShowIcon: !e.isIntent,
|
|
2231
|
-
className: "border-sw-gray-900 group-hover:border-sw-gray-800 transition-colors"
|
|
2232
|
-
...e
|
|
2230
|
+
className: "border-sw-gray-900 group-hover:border-sw-gray-800 transition-colors"
|
|
2233
2231
|
}
|
|
2234
2232
|
),
|
|
2235
|
-
/* @__PURE__ */
|
|
2233
|
+
/* @__PURE__ */ h("div", { className: "gap-sw-xs mr-auto flex flex-col", children: [
|
|
2236
2234
|
/* @__PURE__ */ o("span", { className: "text-sw-label-md text-sw-gray-50", children: e.name }),
|
|
2237
|
-
e.isIntent ? /* @__PURE__ */
|
|
2235
|
+
e.isIntent ? /* @__PURE__ */ h("div", { className: "flex items-center gap-sw-xs", children: [
|
|
2238
2236
|
/* @__PURE__ */ o("span", { className: "text-sw-label-md text-sw-gray-300", children: e.symbol }),
|
|
2239
2237
|
" ",
|
|
2240
2238
|
/* @__PURE__ */ o("span", { className: "text-sw-label-sm text-sw-gray-300", children: `on ${d} ${e.chainName.toLowerCase() !== "near" && f ? `(${e.chainName})` : ""}` })
|
|
2241
|
-
] }) : /* @__PURE__ */
|
|
2239
|
+
] }) : /* @__PURE__ */ h("div", { className: "flex items-center gap-sw-xs", children: [
|
|
2242
2240
|
/* @__PURE__ */ o("span", { className: "text-sw-label-md text-sw-gray-300", children: e.symbol }),
|
|
2243
2241
|
" ",
|
|
2244
2242
|
/* @__PURE__ */ o("span", { className: "text-sw-label-sm text-sw-gray-300", children: `on ${e.chainName}` })
|
|
2245
2243
|
] })
|
|
2246
2244
|
] }),
|
|
2247
|
-
i && !!
|
|
2245
|
+
i && !!c.walletAddress && r && /* @__PURE__ */ h("div", { className: "gap-sw-xs flex flex-col items-end", children: [
|
|
2248
2246
|
t === void 0 && !e.isIntent ? /* @__PURE__ */ o("span", { className: "h-[16px] w-[60px] animate-pulse rounded-full bg-sw-gray-700" }) : /* @__PURE__ */ o("span", { className: "h-[16px] text-sw-label-md text-sw-gray-50", children: f && /* @__PURE__ */ o(
|
|
2249
|
-
|
|
2247
|
+
xe,
|
|
2250
2248
|
{
|
|
2251
2249
|
decimals: e.decimals,
|
|
2252
2250
|
value: t === void 0 ? "0" : `${t}`
|
|
@@ -2257,7 +2255,7 @@ const Cr = ({ className: e }) => {
|
|
|
2257
2255
|
]
|
|
2258
2256
|
}
|
|
2259
2257
|
) });
|
|
2260
|
-
},
|
|
2258
|
+
}, Xe = [
|
|
2261
2259
|
"nep141:eth-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near",
|
|
2262
2260
|
// cbBTC (eth)
|
|
2263
2261
|
"nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near",
|
|
@@ -2270,79 +2268,79 @@ const Cr = ({ className: e }) => {
|
|
|
2270
2268
|
// NEAR (bsc)
|
|
2271
2269
|
"nep141:eth-0xe0f63a424a4439cbe457d80e4f4b51ad25b2c56c.omft.near"
|
|
2272
2270
|
// SPX (eth)
|
|
2273
|
-
],
|
|
2271
|
+
], Dr = () => {
|
|
2274
2272
|
const { tokens: e } = P();
|
|
2275
2273
|
return {
|
|
2276
2274
|
uniqueIntentsTokens: v(() => {
|
|
2277
2275
|
const t = e.filter(
|
|
2278
|
-
(n) => n.isIntent && n.blockchain === "near" && !
|
|
2279
|
-
), r = t.map((n) => n.isIntent && n.symbol), s = e.filter((n) => n.isIntent && n.blockchain !== "near" && !r.includes(n.symbol) && !
|
|
2276
|
+
(n) => n.isIntent && n.blockchain === "near" && !Xe.includes(n.assetId)
|
|
2277
|
+
), r = t.map((n) => n.isIntent && n.symbol), s = e.filter((n) => n.isIntent && n.blockchain !== "near" && !r.includes(n.symbol) && !Xe.includes(n.assetId));
|
|
2280
2278
|
return [...t, ...s];
|
|
2281
2279
|
}, [e])
|
|
2282
2280
|
};
|
|
2283
|
-
},
|
|
2281
|
+
}, xr = ({
|
|
2284
2282
|
variant: e,
|
|
2285
2283
|
search: t,
|
|
2286
2284
|
selectedChain: r,
|
|
2287
2285
|
chainsFilter: s,
|
|
2288
2286
|
walletSupportedChains: n
|
|
2289
2287
|
}) => {
|
|
2290
|
-
|
|
2291
|
-
const { tokens: a } = P(e), { mergedBalance:
|
|
2292
|
-
|
|
2288
|
+
Ks(e);
|
|
2289
|
+
const { tokens: a } = P(e), { mergedBalance: c } = ce(), { intentBalances: l } = le(), { uniqueIntentsTokens: d } = Dr(), u = gs(
|
|
2290
|
+
c,
|
|
2293
2291
|
n,
|
|
2294
2292
|
t
|
|
2295
|
-
), i = a.filter(
|
|
2296
|
-
|
|
2293
|
+
), i = a.filter(Is({ search: t })).filter(
|
|
2294
|
+
ws({
|
|
2297
2295
|
selectedChain: r,
|
|
2298
2296
|
chainsFilter: s,
|
|
2299
2297
|
walletSupportedChains: n,
|
|
2300
|
-
intentBalances:
|
|
2298
|
+
intentBalances: l,
|
|
2301
2299
|
uniqueIntentTokenIds: d.map((f) => f.assetId)
|
|
2302
2300
|
})
|
|
2303
2301
|
);
|
|
2304
2302
|
return {
|
|
2305
2303
|
all: i.sort(u),
|
|
2306
|
-
intents: i.filter(
|
|
2307
|
-
wallet: i.filter(
|
|
2304
|
+
intents: i.filter(Ke({ isIntent: !0 })).sort(u),
|
|
2305
|
+
wallet: i.filter(Ke({ isIntent: !1 })).sort(u)
|
|
2308
2306
|
};
|
|
2309
|
-
},
|
|
2307
|
+
}, Or = (e, t) => e.length === 0 && t ? "EMPTY_SEARCH" : e.length === 0 && !t ? "NO_TOKENS" : "HAS_TOKENS", Fr = ({
|
|
2310
2308
|
variant: e,
|
|
2311
2309
|
search: t,
|
|
2312
2310
|
className: r,
|
|
2313
2311
|
groupTokens: s,
|
|
2314
2312
|
showBalances: n,
|
|
2315
2313
|
chainsFilter: a,
|
|
2316
|
-
selectedChain:
|
|
2317
|
-
chainIsNotSupported:
|
|
2314
|
+
selectedChain: c,
|
|
2315
|
+
chainIsNotSupported: l,
|
|
2318
2316
|
onMsg: d
|
|
2319
2317
|
}) => {
|
|
2320
|
-
const { t: u } = V(), { ctx: i } = _(), { walletSupportedChains: f, appName:
|
|
2318
|
+
const { t: u } = V(), { ctx: i } = _(), { walletSupportedChains: f, appName: T } = y(), { mergedBalance: I } = ce(), m = xr({
|
|
2321
2319
|
variant: e,
|
|
2322
2320
|
search: t,
|
|
2323
2321
|
chainsFilter: a,
|
|
2324
|
-
selectedChain:
|
|
2322
|
+
selectedChain: c,
|
|
2325
2323
|
walletSupportedChains: f
|
|
2326
|
-
}), w = i.walletAddress ? s : !1,
|
|
2324
|
+
}), w = i.walletAddress ? s : !1, S = Or(m.all, t), E = v(
|
|
2327
2325
|
() => [{ label: null, tokens: m.all }],
|
|
2328
2326
|
[m.all]
|
|
2329
2327
|
), B = v(
|
|
2330
2328
|
() => [
|
|
2331
|
-
{ label:
|
|
2329
|
+
{ label: T, tokens: m.intents },
|
|
2332
2330
|
{
|
|
2333
|
-
label:
|
|
2331
|
+
label: l ? null : "Connected wallet",
|
|
2334
2332
|
tokens: m.wallet
|
|
2335
2333
|
}
|
|
2336
2334
|
],
|
|
2337
|
-
[m.wallet, m.intents,
|
|
2335
|
+
[m.wallet, m.intents, l]
|
|
2338
2336
|
), F = v(() => (w ? B : E).reduce(
|
|
2339
2337
|
(k, x) => k + x.tokens.length,
|
|
2340
2338
|
0
|
|
2341
2339
|
), [B, E, w]), L = "450px";
|
|
2342
|
-
switch (
|
|
2340
|
+
switch (S) {
|
|
2343
2341
|
case "EMPTY_SEARCH":
|
|
2344
2342
|
return /* @__PURE__ */ o(
|
|
2345
|
-
|
|
2343
|
+
Se,
|
|
2346
2344
|
{
|
|
2347
2345
|
hasAction: !0,
|
|
2348
2346
|
actionType: "outlined",
|
|
@@ -2358,29 +2356,29 @@ const Cr = ({ className: e }) => {
|
|
|
2358
2356
|
);
|
|
2359
2357
|
case "HAS_TOKENS":
|
|
2360
2358
|
return /* @__PURE__ */ o("div", { className: H("gap-sw-lg flex flex-col", r), children: /* @__PURE__ */ o(
|
|
2361
|
-
|
|
2359
|
+
Ts,
|
|
2362
2360
|
{
|
|
2363
2361
|
className: "hide-scrollbar",
|
|
2364
2362
|
style: {
|
|
2365
2363
|
maxHeight: L,
|
|
2366
2364
|
minHeight: 200,
|
|
2367
|
-
height: F ? F *
|
|
2365
|
+
height: F ? F * Ze + (w ? B.length * 62 : 0) : Ze * 2
|
|
2368
2366
|
},
|
|
2369
2367
|
children: (w ? B : E).map(
|
|
2370
|
-
({ label: k, tokens: x }) => /* @__PURE__ */
|
|
2371
|
-
x.length && k ? /* @__PURE__ */
|
|
2372
|
-
/* @__PURE__ */ o(
|
|
2368
|
+
({ label: k, tokens: x }) => /* @__PURE__ */ h(Mt, { children: [
|
|
2369
|
+
x.length && k ? /* @__PURE__ */ h("header", { className: "pb-sw-lg flex flex-col", children: [
|
|
2370
|
+
/* @__PURE__ */ o(hs, {}),
|
|
2373
2371
|
/* @__PURE__ */ o("span", { className: "text-sw-label-sm pt-sw-xl text-sw-gray-100", children: `${k} — ${x.length}` })
|
|
2374
2372
|
] }) : null,
|
|
2375
2373
|
x.map((X) => {
|
|
2376
2374
|
const J = G(X);
|
|
2377
2375
|
return /* @__PURE__ */ o(
|
|
2378
|
-
|
|
2376
|
+
Ot,
|
|
2379
2377
|
{
|
|
2380
2378
|
token: X,
|
|
2381
2379
|
showBalance: n,
|
|
2382
2380
|
balance: I[J],
|
|
2383
|
-
isNotSelectable:
|
|
2381
|
+
isNotSelectable: l && !!i.walletAddress,
|
|
2384
2382
|
onMsg: d
|
|
2385
2383
|
},
|
|
2386
2384
|
J
|
|
@@ -2394,7 +2392,7 @@ const Cr = ({ className: e }) => {
|
|
|
2394
2392
|
case "NO_TOKENS":
|
|
2395
2393
|
default:
|
|
2396
2394
|
return /* @__PURE__ */ o(
|
|
2397
|
-
|
|
2395
|
+
Se,
|
|
2398
2396
|
{
|
|
2399
2397
|
className: "pt-sw-5xl pb-sw-5xl",
|
|
2400
2398
|
subHeading: u(
|
|
@@ -2403,55 +2401,55 @@ const Cr = ({ className: e }) => {
|
|
|
2403
2401
|
),
|
|
2404
2402
|
heading: u("tokens.list.noBalanceOnApp.label", {
|
|
2405
2403
|
defaultValue: "You have no balances on {{appName}}",
|
|
2406
|
-
appName:
|
|
2404
|
+
appName: T
|
|
2407
2405
|
})
|
|
2408
2406
|
}
|
|
2409
2407
|
);
|
|
2410
2408
|
}
|
|
2411
|
-
},
|
|
2412
|
-
Placeholder:
|
|
2413
|
-
Item:
|
|
2414
|
-
}),
|
|
2409
|
+
}, Vi = Object.assign(Fr, {
|
|
2410
|
+
Placeholder: Se,
|
|
2411
|
+
Item: Ot
|
|
2412
|
+
}), Lr = (e, t) => {
|
|
2415
2413
|
const r = t.assetId.substring(t.assetId.indexOf(":") + 1), s = (a) => {
|
|
2416
|
-
const
|
|
2414
|
+
const c = (u) => u.replace(/(\.\d*?[1-9])0+$/, "$1").replace(/\.0+$/, ""), l = c(t.amount), d = c(
|
|
2417
2415
|
a.amount.toLocaleString("en-US", {
|
|
2418
2416
|
useGrouping: !1,
|
|
2419
2417
|
maximumFractionDigits: 20
|
|
2420
2418
|
})
|
|
2421
2419
|
);
|
|
2422
|
-
return
|
|
2420
|
+
return l.startsWith(d) || d.startsWith(l);
|
|
2423
2421
|
}, n = (a) => new Date(a.created_at) >= new Date(t.initiatedAtDate);
|
|
2424
2422
|
return (e.result.deposits || []).find(
|
|
2425
2423
|
(a) => a.chain === t.chainId && a.account_id === t.intentsAccountId && a.address === t.depositAddress && a.near_token_id === r && n(a) && s(a)
|
|
2426
2424
|
);
|
|
2427
|
-
},
|
|
2425
|
+
}, Br = {
|
|
2428
2426
|
CREDITED: ee.status.PROCESSING,
|
|
2429
2427
|
PENDING: ee.status.PROCESSING,
|
|
2430
2428
|
COMPLETED: ee.status.SUCCESS,
|
|
2431
2429
|
FAILED: ee.status.FAILED
|
|
2432
|
-
},
|
|
2430
|
+
}, Qi = ({ depositAddress: e }) => {
|
|
2433
2431
|
const { ctx: t } = _(), { intentsAccountType: r } = y(), [s, n] = re(null), a = te({
|
|
2434
2432
|
addressType: r,
|
|
2435
2433
|
walletAddress: t.walletAddress
|
|
2436
2434
|
});
|
|
2437
2435
|
return { pollDepositStatus: async ({
|
|
2438
|
-
blockchain:
|
|
2436
|
+
blockchain: l,
|
|
2439
2437
|
amount: d,
|
|
2440
2438
|
assetId: u
|
|
2441
2439
|
}) => {
|
|
2442
2440
|
if (!a)
|
|
2443
2441
|
throw new W("Unknown intents account for POA deposit check");
|
|
2444
|
-
let i =
|
|
2442
|
+
let i = it[l];
|
|
2445
2443
|
if (!i)
|
|
2446
|
-
if (Q(
|
|
2444
|
+
if (Q(l))
|
|
2447
2445
|
i = lt;
|
|
2448
2446
|
else
|
|
2449
2447
|
throw new W(
|
|
2450
|
-
`Unknown chain for POA deposit check ${
|
|
2448
|
+
`Unknown chain for POA deposit check ${l}`
|
|
2451
2449
|
);
|
|
2452
2450
|
const f = s ?? (/* @__PURE__ */ new Date()).toUTCString();
|
|
2453
2451
|
s || n(f);
|
|
2454
|
-
const
|
|
2452
|
+
const T = await mt.post("", {
|
|
2455
2453
|
id: 1,
|
|
2456
2454
|
jsonrpc: "2.0",
|
|
2457
2455
|
method: "recent_deposits",
|
|
@@ -2461,7 +2459,7 @@ const Cr = ({ className: e }) => {
|
|
|
2461
2459
|
chain: i
|
|
2462
2460
|
}
|
|
2463
2461
|
]
|
|
2464
|
-
}), I =
|
|
2462
|
+
}), I = Lr(T.data, {
|
|
2465
2463
|
intentsAccountId: a,
|
|
2466
2464
|
initiatedAtDate: f,
|
|
2467
2465
|
depositAddress: e,
|
|
@@ -2470,7 +2468,7 @@ const Cr = ({ className: e }) => {
|
|
|
2470
2468
|
amount: d
|
|
2471
2469
|
});
|
|
2472
2470
|
return I ? {
|
|
2473
|
-
status:
|
|
2471
|
+
status: Br[I.status],
|
|
2474
2472
|
swapDetails: {
|
|
2475
2473
|
intentHashes: [""],
|
|
2476
2474
|
destinationChainTxHashes: [{ hash: I.tx_hash ?? "" }]
|
|
@@ -2483,38 +2481,38 @@ const Cr = ({ className: e }) => {
|
|
|
2483
2481
|
}
|
|
2484
2482
|
};
|
|
2485
2483
|
} };
|
|
2486
|
-
},
|
|
2487
|
-
if (
|
|
2484
|
+
}, qr = (e, t, r) => {
|
|
2485
|
+
if (At) {
|
|
2488
2486
|
let s = document.body;
|
|
2489
2487
|
r instanceof HTMLElement && (s = r), Object.entries(e).forEach(([n, a]) => {
|
|
2490
2488
|
s.style.setProperty(`--c-sw-${t}-${n}`, a);
|
|
2491
2489
|
});
|
|
2492
2490
|
}
|
|
2493
|
-
},
|
|
2494
|
-
const a =
|
|
2495
|
-
a &&
|
|
2496
|
-
},
|
|
2491
|
+
}, Je = (e, t, r, s, n) => {
|
|
2492
|
+
const a = ks(s, n, t);
|
|
2493
|
+
a && qr(a, e, r);
|
|
2494
|
+
}, Ur = (e, t) => {
|
|
2497
2495
|
const { primaryColor: r, surfaceColor: s, colorScheme: n = "dark" } = t;
|
|
2498
|
-
r &&
|
|
2499
|
-
},
|
|
2496
|
+
r && Je("accent", 500, e, r, n), s && Je("gray", 950, e, s, n);
|
|
2497
|
+
}, Pr = st(void 0), Wr = ({ children: e, theme: t }) => {
|
|
2500
2498
|
const { themeParentElementSelector: r } = y(), s = v(() => t, [t]);
|
|
2501
|
-
return
|
|
2502
|
-
if (t &&
|
|
2499
|
+
return R(() => {
|
|
2500
|
+
if (t && At) {
|
|
2503
2501
|
const n = r ? document.querySelector(r) : null;
|
|
2504
|
-
|
|
2502
|
+
Ur(n, t);
|
|
2505
2503
|
}
|
|
2506
|
-
}, [t]), /* @__PURE__ */ o(
|
|
2504
|
+
}, [t]), /* @__PURE__ */ o(Pr.Provider, { value: s, children: /* @__PURE__ */ o("div", { className: "sw", children: e }) });
|
|
2507
2505
|
}, fe = ({
|
|
2508
2506
|
text: e,
|
|
2509
2507
|
icon: t
|
|
2510
|
-
}) => /* @__PURE__ */
|
|
2508
|
+
}) => /* @__PURE__ */ h("li", { className: "flex items-center gap-sw-md", children: [
|
|
2511
2509
|
t && /* @__PURE__ */ o(t, { size: 20, className: "text-sw-gray-300" }),
|
|
2512
2510
|
/* @__PURE__ */ o("span", { className: "text-sw-label-md text-sw-gray-50", children: e })
|
|
2513
|
-
] }),
|
|
2511
|
+
] }), et = ({
|
|
2514
2512
|
label: e,
|
|
2515
2513
|
icon: t,
|
|
2516
2514
|
className: r
|
|
2517
|
-
}) => /* @__PURE__ */
|
|
2515
|
+
}) => /* @__PURE__ */ h(
|
|
2518
2516
|
"div",
|
|
2519
2517
|
{
|
|
2520
2518
|
className: H(
|
|
@@ -2526,28 +2524,28 @@ const Cr = ({ className: e }) => {
|
|
|
2526
2524
|
/* @__PURE__ */ o("span", { className: "text-sw-label-md", children: e })
|
|
2527
2525
|
]
|
|
2528
2526
|
}
|
|
2529
|
-
),
|
|
2527
|
+
), Mr = ({ isSigned: e, isSigning: t, onMsg: r }) => {
|
|
2530
2528
|
const { t: s } = V(), n = () => r({ type: "on_close" });
|
|
2531
2529
|
St("Escape", n);
|
|
2532
|
-
const a =
|
|
2530
|
+
const a = Es({
|
|
2533
2531
|
endTime: 0,
|
|
2534
2532
|
autostart: !1,
|
|
2535
2533
|
timerType: "DECREMENTAL",
|
|
2536
2534
|
initialTime: 7,
|
|
2537
2535
|
onTimeOver: n
|
|
2538
2536
|
});
|
|
2539
|
-
return
|
|
2537
|
+
return R(() => {
|
|
2540
2538
|
e ? a.start() : a.reset();
|
|
2541
|
-
}, [e]), /* @__PURE__ */
|
|
2539
|
+
}, [e]), /* @__PURE__ */ h(ie, { className: "relative w-full gap-sw-2xl flex flex-col", children: [
|
|
2542
2540
|
/* @__PURE__ */ o(
|
|
2543
|
-
|
|
2541
|
+
Nt,
|
|
2544
2542
|
{
|
|
2545
2543
|
onClick: n,
|
|
2546
2544
|
className: "absolute top-sw-2xl right-sw-2xl"
|
|
2547
2545
|
}
|
|
2548
2546
|
),
|
|
2549
|
-
/* @__PURE__ */ o(
|
|
2550
|
-
/* @__PURE__ */
|
|
2547
|
+
/* @__PURE__ */ o(As, { size: 48, className: "text-sw-status-warning" }),
|
|
2548
|
+
/* @__PURE__ */ h("header", { className: "flex flex-col gap-sw-lg", children: [
|
|
2551
2549
|
/* @__PURE__ */ o("h1", { className: "text-sw-label-lg text-sw-gray-50", children: s(
|
|
2552
2550
|
"walletCompatibility.modal.title.initial",
|
|
2553
2551
|
"Verify your wallet to continue"
|
|
@@ -2557,7 +2555,7 @@ const Cr = ({ className: e }) => {
|
|
|
2557
2555
|
"Please sign a message to verify your wallet. This confirms your wallet is compatible and lets us securely read your public key."
|
|
2558
2556
|
) })
|
|
2559
2557
|
] }),
|
|
2560
|
-
/* @__PURE__ */
|
|
2558
|
+
/* @__PURE__ */ h("ul", { className: "flex flex-col gap-sw-xl", children: [
|
|
2561
2559
|
/* @__PURE__ */ o(
|
|
2562
2560
|
fe,
|
|
2563
2561
|
{
|
|
@@ -2565,7 +2563,7 @@ const Cr = ({ className: e }) => {
|
|
|
2565
2563
|
"walletCompatibility.modal.feature.secureTransactions",
|
|
2566
2564
|
"Read-only signature – no gas required."
|
|
2567
2565
|
),
|
|
2568
|
-
icon:
|
|
2566
|
+
icon: Ss
|
|
2569
2567
|
}
|
|
2570
2568
|
),
|
|
2571
2569
|
/* @__PURE__ */ o(
|
|
@@ -2575,7 +2573,7 @@ const Cr = ({ className: e }) => {
|
|
|
2575
2573
|
"walletCompatibility.modal.feature.fullAccess",
|
|
2576
2574
|
"No access to your funds, no hidden permissions."
|
|
2577
2575
|
),
|
|
2578
|
-
icon:
|
|
2576
|
+
icon: Ns
|
|
2579
2577
|
}
|
|
2580
2578
|
),
|
|
2581
2579
|
/* @__PURE__ */ o(
|
|
@@ -2585,24 +2583,24 @@ const Cr = ({ className: e }) => {
|
|
|
2585
2583
|
"walletCompatibility.modal.feature.fundProtection",
|
|
2586
2584
|
"Only checks whether your wallet is supported."
|
|
2587
2585
|
),
|
|
2588
|
-
icon:
|
|
2586
|
+
icon: _s
|
|
2589
2587
|
}
|
|
2590
2588
|
)
|
|
2591
2589
|
] }),
|
|
2592
|
-
e ? /* @__PURE__ */
|
|
2590
|
+
e ? /* @__PURE__ */ h("div", { className: "flex flex-col gap-sw-xl mt-sw-lg w-full", children: [
|
|
2593
2591
|
/* @__PURE__ */ o(
|
|
2594
|
-
|
|
2592
|
+
et,
|
|
2595
2593
|
{
|
|
2596
2594
|
label: s(
|
|
2597
2595
|
"walletCompatibility.modal.button.verified",
|
|
2598
2596
|
"Wallet verified"
|
|
2599
2597
|
),
|
|
2600
2598
|
className: "bg-sw-status-success text-sw-gray-950",
|
|
2601
|
-
icon:
|
|
2599
|
+
icon: ys
|
|
2602
2600
|
}
|
|
2603
2601
|
),
|
|
2604
2602
|
a.status === "RUNNING" && /* @__PURE__ */ o(
|
|
2605
|
-
|
|
2603
|
+
et,
|
|
2606
2604
|
{
|
|
2607
2605
|
className: "text-sw-gray-400",
|
|
2608
2606
|
label: s("walletCompatibility.modal.button.closeTimer", {
|
|
@@ -2611,7 +2609,7 @@ const Cr = ({ className: e }) => {
|
|
|
2611
2609
|
})
|
|
2612
2610
|
}
|
|
2613
2611
|
)
|
|
2614
|
-
] }) : /* @__PURE__ */
|
|
2612
|
+
] }) : /* @__PURE__ */ h("div", { className: "flex flex-col gap-sw-xl mt-sw-lg", children: [
|
|
2615
2613
|
/* @__PURE__ */ o(
|
|
2616
2614
|
A,
|
|
2617
2615
|
{
|
|
@@ -2636,18 +2634,18 @@ const Cr = ({ className: e }) => {
|
|
|
2636
2634
|
)
|
|
2637
2635
|
] })
|
|
2638
2636
|
] });
|
|
2639
|
-
},
|
|
2637
|
+
}, Vr = ({ onMsg: e }) => {
|
|
2640
2638
|
const { t } = V(), r = () => e({ type: "on_close" });
|
|
2641
|
-
return St("Escape", r), /* @__PURE__ */
|
|
2639
|
+
return St("Escape", r), /* @__PURE__ */ h(ie, { className: "relative w-full gap-sw-2xl flex flex-col", children: [
|
|
2642
2640
|
/* @__PURE__ */ o(
|
|
2643
|
-
|
|
2641
|
+
Nt,
|
|
2644
2642
|
{
|
|
2645
2643
|
onClick: r,
|
|
2646
2644
|
className: "absolute top-sw-2xl right-sw-2xl"
|
|
2647
2645
|
}
|
|
2648
2646
|
),
|
|
2649
|
-
/* @__PURE__ */ o(
|
|
2650
|
-
/* @__PURE__ */
|
|
2647
|
+
/* @__PURE__ */ o(bs, { size: 48, className: "text-sw-status-error" }),
|
|
2648
|
+
/* @__PURE__ */ h("header", { className: "flex flex-col gap-sw-lg", children: [
|
|
2651
2649
|
/* @__PURE__ */ o("h1", { className: "text-sw-label-lg text-sw-gray-50", children: t(
|
|
2652
2650
|
"walletCompatibility.modal.title.error",
|
|
2653
2651
|
"Unable to verify wallet"
|
|
@@ -2661,7 +2659,7 @@ const Cr = ({ className: e }) => {
|
|
|
2661
2659
|
"If the issue continues, please try another wallet."
|
|
2662
2660
|
) })
|
|
2663
2661
|
] }),
|
|
2664
|
-
/* @__PURE__ */
|
|
2662
|
+
/* @__PURE__ */ h("div", { className: "flex flex-col gap-sw-xl mt-sw-lg", children: [
|
|
2665
2663
|
/* @__PURE__ */ o(
|
|
2666
2664
|
A,
|
|
2667
2665
|
{
|
|
@@ -2682,9 +2680,9 @@ const Cr = ({ className: e }) => {
|
|
|
2682
2680
|
)
|
|
2683
2681
|
] })
|
|
2684
2682
|
] });
|
|
2685
|
-
},
|
|
2686
|
-
Error:
|
|
2687
|
-
}),
|
|
2683
|
+
}, $i = Object.assign(Mr, {
|
|
2684
|
+
Error: Vr
|
|
2685
|
+
}), Qr = (e) => null, $r = (e) => (t) => {
|
|
2688
2686
|
if (t instanceof W)
|
|
2689
2687
|
throw t;
|
|
2690
2688
|
const r = new W(
|
|
@@ -2692,49 +2690,48 @@ const Cr = ({ className: e }) => {
|
|
|
2692
2690
|
{ cause: t }
|
|
2693
2691
|
);
|
|
2694
2692
|
throw r.context = e, r;
|
|
2695
|
-
},
|
|
2693
|
+
}, Kr = ({ children: e }) => {
|
|
2696
2694
|
const { ctx: t } = _();
|
|
2697
2695
|
return /* @__PURE__ */ o(
|
|
2698
|
-
|
|
2696
|
+
vs,
|
|
2699
2697
|
{
|
|
2700
|
-
FallbackComponent:
|
|
2701
|
-
onError:
|
|
2698
|
+
FallbackComponent: Qr,
|
|
2699
|
+
onError: $r(t),
|
|
2702
2700
|
children: e
|
|
2703
2701
|
}
|
|
2704
2702
|
);
|
|
2705
|
-
},
|
|
2703
|
+
}, Hr = new Kt({
|
|
2706
2704
|
defaultOptions: {
|
|
2707
2705
|
queries: {
|
|
2708
2706
|
staleTime: 2e3 * 60,
|
|
2709
|
-
retry:
|
|
2707
|
+
retry: tt.env.NODE_ENV === "test" ? !1 : 3
|
|
2710
2708
|
}
|
|
2711
2709
|
}
|
|
2712
|
-
}),
|
|
2710
|
+
}), Gr = ["fms", "abg", "stjack", "noear", "testnebula"], ae = {
|
|
2713
2711
|
appName: "Unknown",
|
|
2714
|
-
appIcon: "https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg",
|
|
2715
2712
|
slippageTolerance: 100,
|
|
2716
2713
|
// 1%
|
|
2717
2714
|
intentsAccountType: "evm",
|
|
2718
|
-
walletSupportedChains:
|
|
2715
|
+
walletSupportedChains: tn,
|
|
2719
2716
|
connectedWallets: {},
|
|
2720
2717
|
enableAutoTokensSwitching: !0,
|
|
2721
2718
|
showIntentTokens: !0,
|
|
2722
|
-
chainsOrder:
|
|
2723
|
-
filterTokens: (e) => !
|
|
2719
|
+
chainsOrder: ot,
|
|
2720
|
+
filterTokens: (e) => !Gr.includes(e.symbol.toLocaleLowerCase()),
|
|
2724
2721
|
chainsFilter: {
|
|
2725
2722
|
source: { external: "wallet-supported", intents: "none" },
|
|
2726
2723
|
target: { external: "all", intents: "none" }
|
|
2727
2724
|
}
|
|
2728
|
-
},
|
|
2725
|
+
}, Ft = st({
|
|
2729
2726
|
config: ae
|
|
2730
|
-
}),
|
|
2727
|
+
}), qe = nt({
|
|
2731
2728
|
config: ae
|
|
2732
2729
|
}), y = () => {
|
|
2733
|
-
const e =
|
|
2730
|
+
const e = Vt(Ft);
|
|
2734
2731
|
return oe(e).config;
|
|
2735
|
-
},
|
|
2736
|
-
|
|
2737
|
-
},
|
|
2732
|
+
}, jr = (e) => {
|
|
2733
|
+
qe.config = pe(e);
|
|
2734
|
+
}, Ki = ({
|
|
2738
2735
|
children: e,
|
|
2739
2736
|
config: t,
|
|
2740
2737
|
balanceViaRpc: r = !0,
|
|
@@ -2743,110 +2740,110 @@ const Cr = ({ className: e }) => {
|
|
|
2743
2740
|
rpcs: n,
|
|
2744
2741
|
theme: a
|
|
2745
2742
|
}) => {
|
|
2746
|
-
const
|
|
2747
|
-
|
|
2743
|
+
const c = Y(
|
|
2744
|
+
nt({
|
|
2748
2745
|
config: pe({
|
|
2749
2746
|
...ae,
|
|
2750
2747
|
...t
|
|
2751
2748
|
})
|
|
2752
2749
|
})
|
|
2753
2750
|
);
|
|
2754
|
-
return
|
|
2755
|
-
const
|
|
2751
|
+
return R(() => {
|
|
2752
|
+
const l = pe({
|
|
2756
2753
|
...ae,
|
|
2757
2754
|
...t
|
|
2758
2755
|
});
|
|
2759
|
-
Object.assign(
|
|
2760
|
-
}, [t]),
|
|
2761
|
-
/* @__PURE__ */
|
|
2762
|
-
/* @__PURE__ */
|
|
2756
|
+
Object.assign(c.current.config, l), jr(l);
|
|
2757
|
+
}, [t]), zt(s ?? {}), Cs("headlessui-portal-root", "sw"), /* @__PURE__ */ o(Ht, { client: Hr, children: /* @__PURE__ */ o(jt, { i18n: Bt, children: /* @__PURE__ */ h(Ft.Provider, { value: c.current, children: [
|
|
2758
|
+
/* @__PURE__ */ h(qt, { children: [
|
|
2759
|
+
/* @__PURE__ */ h(Ut, { children: [
|
|
2763
2760
|
/* @__PURE__ */ o("link", { rel: "preconnect", href: "https://rsms.me/" }),
|
|
2764
2761
|
/* @__PURE__ */ o("link", { rel: "stylesheet", href: "https://rsms.me/inter/inter.css" })
|
|
2765
2762
|
] }),
|
|
2766
|
-
/* @__PURE__ */ o(
|
|
2763
|
+
/* @__PURE__ */ o(Wr, { theme: a, children: tt.env.NODE_ENV === "test" ? e : /* @__PURE__ */ o(Kr, { children: e }) })
|
|
2767
2764
|
] }),
|
|
2768
2765
|
r && /* @__PURE__ */ o(
|
|
2769
|
-
|
|
2766
|
+
Qs,
|
|
2770
2767
|
{
|
|
2771
|
-
rpcs: n ??
|
|
2768
|
+
rpcs: n ?? Rs,
|
|
2772
2769
|
connectedWallets: t.connectedWallets ?? {}
|
|
2773
2770
|
}
|
|
2774
2771
|
)
|
|
2775
2772
|
] }) }) });
|
|
2776
2773
|
};
|
|
2777
2774
|
export {
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2775
|
+
dr as $,
|
|
2776
|
+
Qi as A,
|
|
2777
|
+
Qs as B,
|
|
2778
|
+
Pr as C,
|
|
2779
|
+
Bs as D,
|
|
2780
|
+
He as E,
|
|
2781
|
+
Hs as F,
|
|
2782
|
+
Gs as G,
|
|
2783
|
+
js as H,
|
|
2784
|
+
zs as I,
|
|
2785
|
+
Xs as J,
|
|
2786
|
+
bt as K,
|
|
2787
|
+
Et as L,
|
|
2788
|
+
vt as M,
|
|
2792
2789
|
Rt as N,
|
|
2793
|
-
|
|
2794
|
-
|
|
2790
|
+
Ct as O,
|
|
2791
|
+
Js as P,
|
|
2795
2792
|
q as Q,
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2793
|
+
er as R,
|
|
2794
|
+
yr as S,
|
|
2795
|
+
vr as T,
|
|
2796
|
+
tr as U,
|
|
2797
|
+
nr as V,
|
|
2798
|
+
Ki as W,
|
|
2799
|
+
sr as X,
|
|
2800
|
+
rr as Y,
|
|
2801
|
+
ar as Z,
|
|
2802
|
+
or as _,
|
|
2803
|
+
Pi as a,
|
|
2804
|
+
ur as a0,
|
|
2805
|
+
fr as a1,
|
|
2806
|
+
pr as a2,
|
|
2807
|
+
br as a3,
|
|
2808
|
+
Er as a4,
|
|
2809
|
+
Le as a5,
|
|
2810
|
+
Be as a6,
|
|
2811
|
+
xt as a7,
|
|
2812
|
+
Rr as a8,
|
|
2813
|
+
Cr as a9,
|
|
2814
|
+
Ze as aa,
|
|
2815
|
+
Ot as ab,
|
|
2816
|
+
Dr as ac,
|
|
2817
|
+
Fr as ad,
|
|
2818
|
+
Wr as ae,
|
|
2819
|
+
Mr as af,
|
|
2820
|
+
Vr as ag,
|
|
2821
|
+
Kr as ah,
|
|
2822
|
+
qe as ai,
|
|
2826
2823
|
_ as b,
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2824
|
+
qi as c,
|
|
2825
|
+
Ks as d,
|
|
2826
|
+
Ms as e,
|
|
2827
|
+
le as f,
|
|
2828
|
+
gr as g,
|
|
2829
|
+
Zs as h,
|
|
2830
|
+
Ir as i,
|
|
2831
|
+
mr as j,
|
|
2832
|
+
ce as k,
|
|
2833
|
+
kr as l,
|
|
2834
|
+
xr as m,
|
|
2838
2835
|
P as n,
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2836
|
+
Wi as o,
|
|
2837
|
+
Mi as p,
|
|
2838
|
+
Vi as q,
|
|
2839
|
+
ir as r,
|
|
2840
|
+
Dt as s,
|
|
2841
|
+
yt as t,
|
|
2845
2842
|
z as u,
|
|
2846
2843
|
W as v,
|
|
2847
2844
|
g as w,
|
|
2848
|
-
|
|
2845
|
+
Ui as x,
|
|
2849
2846
|
y,
|
|
2850
|
-
|
|
2847
|
+
$i as z
|
|
2851
2848
|
};
|
|
2852
|
-
//# sourceMappingURL=config-
|
|
2849
|
+
//# sourceMappingURL=config-DQMHUj5z.js.map
|