@aurora-is-near/intents-swap-widget 3.14.0-redesign.2 → 3.14.0-redesign.3
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/{config-Bmc4hOIl.js → config-1EcDCy24.js} +603 -584
- package/dist/config-1EcDCy24.js.map +1 -0
- package/dist/config.js +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 +1 -1
- package/dist/features/DepositMethodSwitcher.js +1 -1
- package/dist/features/ErrorBoundary.js +1 -1
- package/dist/features/ExternalDeposit.js +18 -18
- package/dist/features/ExternalDeposit.js.map +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/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/useTokenInputPair.js +1 -1
- package/dist/hooks/useTokens.js +1 -1
- package/dist/hooks/useTokensFiltered.js +1 -1
- package/dist/hooks/useTokensIntentsUnique.js +1 -1
- package/dist/index.js +1 -1
- package/dist/machine/computed/getIsDirectNearTokenWithdrawal.js +1 -1
- package/dist/machine/computed/getIsDirectNearTokenWithdrawal.js.map +1 -1
- package/dist/machine/computed/getIsDirectTokenOnNearDeposit.js +1 -1
- package/dist/machine/computed/getIsDirectTokenOnNearDeposit.js.map +1 -1
- package/dist/machine/computed/getIsDirectTokenOnNearTransfer.js +1 -1
- package/dist/machine/computed/getIsDirectTokenOnNearTransfer.js.map +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.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.js +1 -1
- package/dist/machine/subscriptions/checkers/isSendAddressAsConnected.js +1 -1
- package/dist/machine/subscriptions/index.js +1 -1
- package/dist/types/localisation.d.ts +1 -1
- package/dist/utils/intents/signers/near.js +1 -1
- package/dist/utils/intents/signers/privy.js +1 -1
- package/dist/utils/localstorage.js +41 -28
- package/dist/utils/localstorage.js.map +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 +2 -2
- package/src/features/ExternalDeposit.tsx +2 -1
- package/src/features/SubmitButton/index.tsx +40 -0
- package/src/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.ts +2 -1
- package/src/machine/computed/getIsDirectNearTokenWithdrawal.ts +2 -1
- package/src/machine/computed/getIsDirectTokenOnNearDeposit.ts +2 -1
- package/src/machine/computed/getIsDirectTokenOnNearTransfer.ts +2 -1
- package/src/types/localisation.ts +3 -0
- package/src/utils/localstorage.ts +35 -10
- package/dist/config-Bmc4hOIl.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { p as
|
|
1
|
+
import { p as Je } from "./index-xuotMAFm.js";
|
|
2
2
|
import { jsx as c, jsxs as k, Fragment as Rt } from "react/jsx-runtime";
|
|
3
3
|
import Dt from "i18next";
|
|
4
4
|
import { deepClone as me } from "valtio/utils";
|
|
5
5
|
import { snapshot as Se, useSnapshot as oe, proxy as et } from "valtio";
|
|
6
6
|
import { HelmetProvider as Ct, Helmet as vt } from "react-helmet-async";
|
|
7
|
-
import { memo as Ot, useEffect as R, useMemo as x, useRef as
|
|
7
|
+
import { memo as Ot, useEffect as R, useMemo as x, useRef as z, useCallback as fe, useState as se, useId as xt, Fragment as Ft, useContext as Lt, createContext as Bt } from "react";
|
|
8
8
|
import { useQuery as Ae, useInfiniteQuery as qt, useQueryClient as Ut, QueryClient as Pt, QueryClientProvider as Wt } from "@tanstack/react-query";
|
|
9
|
-
import { Trans as
|
|
10
|
-
import { useTypedTranslation as
|
|
9
|
+
import { Trans as Mt, I18nextProvider as Vt } from "react-i18next";
|
|
10
|
+
import { useTypedTranslation as H, initLocalisation as Qt } from "./localisation.js";
|
|
11
11
|
import { logger as b } from "./logger.js";
|
|
12
12
|
import { getTonTokenBalance as $t } from "./utils/ton/getTonTokenBalance.js";
|
|
13
13
|
import { getSolanaTokenBalance as Kt } from "./utils/solana/getSolanaTokenBalance.js";
|
|
@@ -15,37 +15,37 @@ import { useWalletAddressForToken as tt } from "./hooks/useWalletAddressForToken
|
|
|
15
15
|
import "@headlessui/react";
|
|
16
16
|
import "framer-motion";
|
|
17
17
|
import "lucide-react";
|
|
18
|
-
import { cn as
|
|
19
|
-
import { OneClickService as Ht, QuoteRequest as U, GetExecutionStatusResponse as
|
|
20
|
-
import { CHAINS_LIST as _e, DEFAULT_CHAIN_ICON as Gt, DEFAULT_CHAINS_ORDER as nt, CHAIN_POA_MAP as
|
|
18
|
+
import { cn as j } from "./utils/cn.js";
|
|
19
|
+
import { OneClickService as Ht, QuoteRequest as U, GetExecutionStatusResponse as ee } from "@defuse-protocol/one-click-sdk-typescript";
|
|
20
|
+
import { CHAINS_LIST as _e, DEFAULT_CHAIN_ICON as Gt, DEFAULT_CHAINS_ORDER as nt, CHAIN_POA_MAP as rt, POA_EVM_CHAIN_ID as st, CHAIN_BASE_TOKENS as jt, EVM_CHAIN_IDS_MAP as pe, CHAIN_IDS_MAP as Yt, EVM_CHAINS as zt } from "./constants/chains.js";
|
|
21
21
|
import "use-debounce";
|
|
22
22
|
import { derive as Zt } from "derive-valtio";
|
|
23
|
-
import { getIsNativeNearDeposit as
|
|
24
|
-
import { getIsDirectTokenOnNearDeposit as
|
|
23
|
+
import { getIsNativeNearDeposit as Xt } from "./machine/computed/getIsNativeNearDeposit.js";
|
|
24
|
+
import { getIsDirectTokenOnNearDeposit as Jt } from "./machine/computed/getIsDirectTokenOnNearDeposit.js";
|
|
25
25
|
import "ethers";
|
|
26
|
-
import { moveTo as O, machine as
|
|
26
|
+
import { moveTo as O, machine as Z } from "./machine/machine.js";
|
|
27
27
|
import en from "lodash.once";
|
|
28
28
|
import { guardStates as C } from "./machine/guards/index.js";
|
|
29
29
|
import { parse as tn } from "./ext/alchemy/parse.js";
|
|
30
30
|
import { createLoader as nn } from "./ext/alchemy/load.js";
|
|
31
|
-
import { isAlchemySupportedChain as
|
|
31
|
+
import { isAlchemySupportedChain as rn } from "./ext/alchemy/types.js";
|
|
32
32
|
import { fireEvent as p } from "./machine/events/utils/fireEvent.js";
|
|
33
33
|
import { NATIVE_NEAR_DUMB_ASSET_ID as Q, TOKENS_DATA as Ne, WNEAR_ASSET_ID as Te } from "./constants/tokens.js";
|
|
34
|
-
import { isValidChain as
|
|
34
|
+
import { isValidChain as sn } from "./utils/checkers/isValidChain.js";
|
|
35
35
|
import { useWalletBalance as Ee } from "./hooks/useWalletBalance.js";
|
|
36
|
-
import { getIntentsAccountId as
|
|
36
|
+
import { getIntentsAccountId as te } from "./utils/intents/getIntentsAccountId.js";
|
|
37
37
|
import { getIntentsBalances as an } from "./utils/intents/getIntentsBalance.js";
|
|
38
38
|
import { notReachable as be } from "./utils/notReachable.js";
|
|
39
|
-
import { getTokenBalanceKey as
|
|
39
|
+
import { getTokenBalanceKey as K } from "./utils/intents/getTokenBalanceKey.js";
|
|
40
40
|
import { isDryQuote as ye } from "./machine/guards/checks/isDryQuote.js";
|
|
41
41
|
import { snakeCase as at } from "change-case";
|
|
42
42
|
import on, { CanceledError as ot, AxiosError as it } from "axios";
|
|
43
43
|
import { oneClickApi as he, bridgeApi as ct } from "./network.js";
|
|
44
|
-
import { formatBigToHuman as
|
|
44
|
+
import { formatBigToHuman as Y } from "./utils/formatters/formatBigToHuman.js";
|
|
45
45
|
import { getDryQuoteAddress as qe } from "./utils/getDryQuoteAddress.js";
|
|
46
|
-
import { isEvmChain as
|
|
46
|
+
import { isEvmChain as V } from "./utils/evm/isEvmChain.js";
|
|
47
47
|
import { checkNearAccountExists as cn } from "./utils/near/checkNearAccountExists.js";
|
|
48
|
-
import { isNotEmptyAmount as
|
|
48
|
+
import { isNotEmptyAmount as ne } from "./utils/checkers/isNotEmptyAmount.js";
|
|
49
49
|
import { isValidBigint as lt } from "./utils/checkers/isValidBigint.js";
|
|
50
50
|
import { isNearAddress as dt } from "./utils/near/isNearAddress.js";
|
|
51
51
|
import { isBalanceSufficient as Re } from "./machine/guards/checks/isBalanceSufficient.js";
|
|
@@ -82,18 +82,18 @@ import { getIsDirectTokenOnNearTransfer as Ln } from "./machine/computed/getIsDi
|
|
|
82
82
|
import { getIsDirectNearTokenWithdrawal as Bn } from "./machine/computed/getIsDirectNearTokenWithdrawal.js";
|
|
83
83
|
import { getIsSameAssetDiffChainWithdrawal as qn } from "./machine/computed/getIsSameAssetDiffChainWithdrawal.js";
|
|
84
84
|
import "viem";
|
|
85
|
-
import { Button as
|
|
85
|
+
import { Button as A } from "./components/Button.js";
|
|
86
86
|
import { TinyNumber as ve } from "./components/TinyNumber.js";
|
|
87
|
-
import { ErrorMessage as
|
|
87
|
+
import { ErrorMessage as $ } from "./components/ErrorMessage.js";
|
|
88
88
|
import { FT_DEPOSIT_GAS as Ue, FT_TRANSFER_GAS as Pe } from "./utils/near/config.js";
|
|
89
89
|
import { a as Oe } from "./index-DEq3oXQF.js";
|
|
90
|
-
import { z as
|
|
90
|
+
import { z as re } from "zod";
|
|
91
91
|
import { decodeQueryResult as Un } from "./utils/near/decodeQueryResult.js";
|
|
92
92
|
import { nearRpcClient as Pn } from "./utils/near/rpc.js";
|
|
93
93
|
import { getNearNep141MinStorageBalance as Wn } from "./utils/near/getNearNep141MinStorageBalance.js";
|
|
94
94
|
import { INTENTS_CONTRACT as Ie } from "./constants/intents.js";
|
|
95
|
-
import { isEth as
|
|
96
|
-
import { useMakeEvmTransfer as
|
|
95
|
+
import { isEth as Mn } from "./utils/evm/isEth.js";
|
|
96
|
+
import { useMakeEvmTransfer as Vn } from "./hooks/useMakeEvmTransfer.js";
|
|
97
97
|
import { useMakeSolanaTransfer as Qn } from "./hooks/useMakeSolanaTransfer.js";
|
|
98
98
|
import { isUserDeniedSigning as we } from "./utils/checkers/isUserDeniedSigning.js";
|
|
99
99
|
import { createIntentSignerNEP413 as $n, BridgeSDK as Kn, createNearWithdrawalRoute as Hn, createInternalTransferRoute as Gn } from "@defuse-protocol/bridge-sdk";
|
|
@@ -101,106 +101,106 @@ import { generateRandomBytes as jn } from "./utils/near/getRandomBytes.js";
|
|
|
101
101
|
import { IntentSignerSolana as Yn } from "./utils/intents/signers/solana.js";
|
|
102
102
|
import { localStorageTyped as We } from "./utils/localstorage.js";
|
|
103
103
|
import { queryContract as zn } from "./utils/near/queryContract.js";
|
|
104
|
-
import { utils as
|
|
104
|
+
import { utils as Me } from "@defuse-protocol/internal-utils";
|
|
105
105
|
import { getTransactionLink as Zn } from "./utils/formatters/getTransactionLink.js";
|
|
106
|
-
import { switchEthereumChain as
|
|
106
|
+
import { switchEthereumChain as Xn } from "./utils/evm/switchEthereumChain.js";
|
|
107
107
|
import "copy-text-to-clipboard";
|
|
108
108
|
import { SwapQuoteSkeleton as ft } from "./features/SwapQuote/SwapQuoteSkeleton.js";
|
|
109
109
|
import { Notes as le } from "./components/Notes.js";
|
|
110
|
-
import { Accordion as
|
|
111
|
-
import { formatUsdAmount as
|
|
112
|
-
import { formatTinyNumber as
|
|
113
|
-
import
|
|
114
|
-
import { Skeleton as
|
|
115
|
-
import { getBalancePortion as
|
|
116
|
-
import { getUsdDisplayAmount as
|
|
110
|
+
import { Accordion as Jn } from "./components/Accordion.js";
|
|
111
|
+
import { formatUsdAmount as Ve } from "./utils/formatters/formatUsdAmount.js";
|
|
112
|
+
import { formatTinyNumber as er } from "./utils/formatters/formatTinyNumber.js";
|
|
113
|
+
import tr from "clsx";
|
|
114
|
+
import { Skeleton as nr } from "./components/Skeleton.js";
|
|
115
|
+
import { getBalancePortion as rr } from "./features/TokenInput/utils/getBalancePortion.js";
|
|
116
|
+
import { getUsdDisplayAmount as sr } from "./features/TokenInput/utils/getUsdDisplayAmount.js";
|
|
117
117
|
import { TokenInputHeading as pt } from "./features/TokenInput/TokenInputHeading.js";
|
|
118
|
-
import { noop as
|
|
118
|
+
import { noop as ar } from "./utils/noop.js";
|
|
119
119
|
import { Card as Tt } from "./components/Card.js";
|
|
120
120
|
import { Badge as Qe } from "./components/Badge.js";
|
|
121
121
|
import { TokenIcon as ht } from "./components/TokenIcon.js";
|
|
122
|
-
import { InputAmount as
|
|
123
|
-
import { TokenInputSkeleton as
|
|
124
|
-
import { getUsdDisplayBalance as
|
|
125
|
-
import { VList as
|
|
122
|
+
import { InputAmount as or } from "./components/InputAmount.js";
|
|
123
|
+
import { TokenInputSkeleton as ir } from "./features/TokenInput/TokenInputSkeleton.js";
|
|
124
|
+
import { getUsdDisplayBalance as cr } from "./utils/formatters/getUsdDisplayBalance.js";
|
|
125
|
+
import { VList as lr } from "virtua";
|
|
126
126
|
import { TokensListPlaceholder as ke } from "./features/TokensList/TokensListPlaceholder.js";
|
|
127
|
-
import { Hr as
|
|
128
|
-
import { createTokenSorter as
|
|
127
|
+
import { Hr as dr } from "./components/Hr.js";
|
|
128
|
+
import { createTokenSorter as ur } from "./utils/tokens/sort.js";
|
|
129
129
|
import { createFilterByIntents as $e } from "./utils/tokens/filterByIntents.js";
|
|
130
|
-
import { createFilterBySearch as
|
|
131
|
-
import { createFilterBySelectedChain as
|
|
130
|
+
import { createFilterBySearch as mr } from "./utils/tokens/filterBySearchString.js";
|
|
131
|
+
import { createFilterBySelectedChain as fr } from "./utils/tokens/filterBySelectedChain.js";
|
|
132
132
|
import "bs58";
|
|
133
133
|
import "viem/chains";
|
|
134
134
|
import "browser-or-node";
|
|
135
135
|
import "qrcode.react";
|
|
136
|
-
import { ThemeProvider as
|
|
136
|
+
import { ThemeProvider as pr } from "./theme/ThemeProvider.js";
|
|
137
137
|
import "./features/WalletCompatibilityCheck/WalletCompatibilityModal.js";
|
|
138
|
-
import { DEFAULT_RPCS as
|
|
139
|
-
import { useAddClassToPortal as
|
|
140
|
-
import { ErrorBoundary as
|
|
141
|
-
import { isEvmToken as
|
|
142
|
-
import { isEvmBaseToken as
|
|
143
|
-
import { getEvmMainTokenBalance as
|
|
144
|
-
import { getNativeNearBalance as
|
|
145
|
-
import { getNearTokenBalance as
|
|
146
|
-
import { getEvmTokenBalance as
|
|
147
|
-
function
|
|
148
|
-
const { walletSupportedChains:
|
|
138
|
+
import { DEFAULT_RPCS as Tr } from "./rpcs.js";
|
|
139
|
+
import { useAddClassToPortal as hr } from "./hooks/useAddClassToPortal.js";
|
|
140
|
+
import { ErrorBoundary as gr } from "react-error-boundary";
|
|
141
|
+
import { isEvmToken as Ir } from "./utils/evm/isEvmToken.js";
|
|
142
|
+
import { isEvmBaseToken as wr } from "./utils/evm/isEvmBaseToken.js";
|
|
143
|
+
import { getEvmMainTokenBalance as kr } from "./utils/evm/getEvmMainTokenBalance.js";
|
|
144
|
+
import { getNativeNearBalance as Sr } from "./utils/near/getNativeNearBalance.js";
|
|
145
|
+
import { getNearTokenBalance as Ar } from "./utils/near/getNearTokenBalance.js";
|
|
146
|
+
import { getEvmTokenBalance as _r } from "./utils/evm/getEvmTokenBalance.js";
|
|
147
|
+
function Nr({ rpcs: e, token: t, connectedWallets: s }) {
|
|
148
|
+
const { walletSupportedChains: r, tonCenterApiKey: n, alchemyApiKey: a } = E(), { walletAddress: l } = tt(s, t);
|
|
149
149
|
return Ae({
|
|
150
150
|
retry: 2,
|
|
151
151
|
enabled: !!l && Object.keys(e).includes(t.blockchain),
|
|
152
|
-
queryKey: ["tokenBalance", t.assetId,
|
|
152
|
+
queryKey: ["tokenBalance", t.assetId, s],
|
|
153
153
|
queryFn: async () => {
|
|
154
154
|
if (!l)
|
|
155
155
|
return null;
|
|
156
|
-
if (t.blockchain === "near" &&
|
|
157
|
-
return !e.near || e.near.length === 0 ? null : t.assetId === Q ?
|
|
158
|
-
if (!
|
|
156
|
+
if (t.blockchain === "near" && r.includes(t.blockchain))
|
|
157
|
+
return !e.near || e.near.length === 0 ? null : t.assetId === Q ? Sr(l, e.near) : Ar(t, l, e.near);
|
|
158
|
+
if (!r.includes("eth") && V(t.blockchain))
|
|
159
159
|
return null;
|
|
160
|
-
if (
|
|
160
|
+
if (V(t.blockchain) && wr(t)) {
|
|
161
161
|
const i = e[t.blockchain] ?? [];
|
|
162
|
-
return i.length > 0 ?
|
|
162
|
+
return i.length > 0 ? kr(l, i[0]) : null;
|
|
163
163
|
}
|
|
164
|
-
if (
|
|
164
|
+
if (Ir(t) || V(t.blockchain)) {
|
|
165
165
|
const i = e[t.blockchain] ?? [];
|
|
166
|
-
return i.length > 0 ?
|
|
166
|
+
return i.length > 0 ? _r(t, l, i[0]) : null;
|
|
167
167
|
}
|
|
168
|
-
return t.blockchain === "ton" ? $t(t, l, n) : t.blockchain === "sol" &&
|
|
168
|
+
return t.blockchain === "ton" ? $t(t, l, n) : t.blockchain === "sol" && r.includes(t.blockchain) ? Kt(t, l, a) : (b.warn(
|
|
169
169
|
`Failed to fetch token balance for ${t.symbol} on ${t.blockchain}`
|
|
170
170
|
), null);
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
const
|
|
174
|
+
const Er = ({
|
|
175
175
|
rpcs: e,
|
|
176
176
|
token: t,
|
|
177
|
-
onBalancesLoaded:
|
|
177
|
+
onBalancesLoaded: s
|
|
178
178
|
}) => (R(() => {
|
|
179
|
-
t.isIntent || !Object.keys(e).includes(t.blockchain) ||
|
|
179
|
+
t.isIntent || !Object.keys(e).includes(t.blockchain) || s({ [t.assetId]: "0" });
|
|
180
180
|
}, [t.assetId]), null), gt = Ot(
|
|
181
|
-
({ rpcs: e, token: t, connectedWallets:
|
|
182
|
-
const { data: n } =
|
|
181
|
+
({ rpcs: e, token: t, connectedWallets: s, onBalancesLoaded: r }) => {
|
|
182
|
+
const { data: n } = Nr({
|
|
183
183
|
rpcs: e,
|
|
184
184
|
token: t,
|
|
185
|
-
connectedWallets:
|
|
185
|
+
connectedWallets: s
|
|
186
186
|
});
|
|
187
187
|
return R(() => {
|
|
188
|
-
!t.isIntent && n != null &&
|
|
189
|
-
}, [t, n,
|
|
188
|
+
!t.isIntent && n != null && r({ [t.assetId]: n });
|
|
189
|
+
}, [t, n, r]), null;
|
|
190
190
|
},
|
|
191
191
|
(e, t) => e.token.assetId === t.token.assetId && e.connectedWallets === t.connectedWallets
|
|
192
192
|
);
|
|
193
193
|
gt.displayName = "TokenBalanceLoader";
|
|
194
194
|
const Ke = Object.assign(gt, {
|
|
195
|
-
Zero:
|
|
196
|
-
}),
|
|
195
|
+
Zero: Er
|
|
196
|
+
}), br = (e) => {
|
|
197
197
|
const t = e.toLowerCase();
|
|
198
198
|
return Ne[t]?.icon ?? "";
|
|
199
|
-
}, He = (e) => _e[e].icon ?? Gt,
|
|
199
|
+
}, He = (e) => _e[e].icon ?? Gt, yr = (e) => `${e?.charAt(0).toUpperCase()}${e?.slice(1)}`, Rr = (e) => Ne[e]?.name ?? e, P = (e) => {
|
|
200
200
|
const {
|
|
201
201
|
showIntentTokens: t,
|
|
202
|
-
allowedTokensList:
|
|
203
|
-
allowedSourceTokensList:
|
|
202
|
+
allowedTokensList: s,
|
|
203
|
+
allowedSourceTokensList: r,
|
|
204
204
|
allowedTargetTokensList: n,
|
|
205
205
|
filterTokens: a,
|
|
206
206
|
fetchSourceTokens: l,
|
|
@@ -213,17 +213,17 @@ const Ke = Object.assign(gt, {
|
|
|
213
213
|
return [];
|
|
214
214
|
const m = d.map((f) => {
|
|
215
215
|
const I = f.blockchain.toLowerCase();
|
|
216
|
-
return !
|
|
216
|
+
return !sn(I) || s && !s.includes(f.assetId) || e === "source" && r && !r.includes(f.assetId) || e === "target" && n && !n.includes(f.assetId) ? null : {
|
|
217
217
|
assetId: f.assetId,
|
|
218
218
|
symbol: f.symbol,
|
|
219
219
|
decimals: f.decimals,
|
|
220
220
|
price: f.price,
|
|
221
221
|
blockchain: I,
|
|
222
222
|
isIntent: !1,
|
|
223
|
-
icon: f.icon ??
|
|
224
|
-
name:
|
|
223
|
+
icon: f.icon ?? br(f.symbol),
|
|
224
|
+
name: Rr(f.symbol),
|
|
225
225
|
chainIcon: He(I),
|
|
226
|
-
chainName: _e[f.blockchain]?.label ??
|
|
226
|
+
chainName: _e[f.blockchain]?.label ?? yr(f.blockchain),
|
|
227
227
|
contractAddress: f.contractAddress
|
|
228
228
|
};
|
|
229
229
|
}).filter((f) => !!f).filter(a ?? (() => !0)), T = m.filter(
|
|
@@ -253,37 +253,37 @@ const Ke = Object.assign(gt, {
|
|
|
253
253
|
...u,
|
|
254
254
|
tokens: o
|
|
255
255
|
};
|
|
256
|
-
},
|
|
257
|
-
const { tokens: e } = P(), { tokens: t } = P("source"), { tokens:
|
|
256
|
+
}, Dr = () => {
|
|
257
|
+
const { tokens: e } = P(), { tokens: t } = P("source"), { tokens: s } = P("target");
|
|
258
258
|
return { tokens: x(() => {
|
|
259
259
|
const n = {};
|
|
260
260
|
return [
|
|
261
261
|
...e,
|
|
262
262
|
...t || [],
|
|
263
|
-
...
|
|
263
|
+
...s || []
|
|
264
264
|
].forEach((a) => {
|
|
265
265
|
const l = `${a.assetId}-${a.isIntent}`;
|
|
266
266
|
n[l] = a;
|
|
267
267
|
}), Object.values(n);
|
|
268
|
-
}, [e, t,
|
|
268
|
+
}, [e, t, s]) };
|
|
269
269
|
}, de = [
|
|
270
270
|
{ eth: ["ETH", "USDT", "USDC", "AURORA"] },
|
|
271
271
|
{ near: ["USDT", "USDC", "AURORA"] },
|
|
272
272
|
{ arb: ["ARB", "ETH", "USDT", "USDC"] },
|
|
273
273
|
{ btc: ["BTC"] }
|
|
274
|
-
],
|
|
275
|
-
const
|
|
274
|
+
], Cr = (e) => [...e].sort((t, s) => {
|
|
275
|
+
const r = de.findIndex(
|
|
276
276
|
(d) => Object.keys(d)[0] === t.blockchain
|
|
277
277
|
), n = de.findIndex(
|
|
278
|
-
(d) => Object.keys(d)[0] ===
|
|
278
|
+
(d) => Object.keys(d)[0] === s.blockchain
|
|
279
279
|
);
|
|
280
|
-
if (
|
|
281
|
-
return
|
|
282
|
-
const a = de[
|
|
280
|
+
if (r !== n)
|
|
281
|
+
return r === -1 ? 1 : n === -1 ? -1 : r - n;
|
|
282
|
+
const a = de[r]?.[t.blockchain] ?? [], l = a.indexOf(t.symbol), i = a.indexOf(s.symbol);
|
|
283
283
|
return l === -1 && i === -1 ? 0 : l === -1 ? 1 : i === -1 ? -1 : l - i;
|
|
284
|
-
}),
|
|
285
|
-
const { tokens:
|
|
286
|
-
return x(() =>
|
|
284
|
+
}), vr = ({ rpcs: e, connectedWallets: t }) => {
|
|
285
|
+
const { tokens: s } = Dr(), { walletSupportedChains: r } = E(), { setWalletBalance: n } = Ee(t);
|
|
286
|
+
return x(() => Cr(s), [s]).map((l) => r.includes(l.blockchain) ? /* @__PURE__ */ c(
|
|
287
287
|
Ke,
|
|
288
288
|
{
|
|
289
289
|
rpcs: e,
|
|
@@ -291,7 +291,7 @@ const Ke = Object.assign(gt, {
|
|
|
291
291
|
connectedWallets: t,
|
|
292
292
|
onBalancesLoaded: (i) => n(t, i)
|
|
293
293
|
},
|
|
294
|
-
|
|
294
|
+
K(l)
|
|
295
295
|
) : /* @__PURE__ */ c(
|
|
296
296
|
Ke.Zero,
|
|
297
297
|
{
|
|
@@ -299,37 +299,37 @@ const Ke = Object.assign(gt, {
|
|
|
299
299
|
token: l,
|
|
300
300
|
onBalancesLoaded: (i) => n(t, i)
|
|
301
301
|
},
|
|
302
|
-
|
|
302
|
+
K(l)
|
|
303
303
|
));
|
|
304
304
|
};
|
|
305
|
-
function
|
|
306
|
-
const
|
|
305
|
+
function Or(e, t) {
|
|
306
|
+
const s = Array.from(
|
|
307
307
|
/* @__PURE__ */ new Set([...t ?? [], ...nt])
|
|
308
|
-
),
|
|
308
|
+
), r = new Map(s.map((n, a) => [n, a]));
|
|
309
309
|
return [...e].sort((n, a) => {
|
|
310
|
-
const l =
|
|
310
|
+
const l = r.has(n.id) ? r.get(n.id) : 1 / 0, i = r.has(a.id) ? r.get(a.id) : 1 / 0;
|
|
311
311
|
return l !== i ? l - i : n.id.localeCompare(a.id, void 0, { sensitivity: "base" });
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
|
-
const
|
|
314
|
+
const xr = (e) => {
|
|
315
315
|
const {
|
|
316
316
|
chainsOrder: t,
|
|
317
|
-
allowedChainsList:
|
|
318
|
-
allowedSourceChainsList:
|
|
317
|
+
allowedChainsList: s,
|
|
318
|
+
allowedSourceChainsList: r,
|
|
319
319
|
allowedTargetChainsList: n
|
|
320
320
|
} = E(), { tokens: a } = P();
|
|
321
321
|
return x(() => {
|
|
322
322
|
const l = Array.from(
|
|
323
323
|
new Set(a.map((i) => _e[i.blockchain]))
|
|
324
|
-
).filter((i) => !(
|
|
325
|
-
return
|
|
326
|
-
}, [a, t,
|
|
324
|
+
).filter((i) => !(s && !s.includes(i.id) || e === "source" && r && !r.includes(i.id) || e === "target" && n && !n.includes(i.id)));
|
|
325
|
+
return Or(l, t);
|
|
326
|
+
}, [a, t, s]);
|
|
327
327
|
}, Ge = 3, It = ({
|
|
328
328
|
connectedWallets: e,
|
|
329
329
|
alchemyApiKey: t,
|
|
330
|
-
...
|
|
330
|
+
...s
|
|
331
331
|
}) => {
|
|
332
|
-
const { ctx:
|
|
332
|
+
const { ctx: r } = N(), { tokens: n } = P(), { walletSupportedChains: a } = E(), { setWalletBalance: l } = Ee(e), i = s.isEnabled && !!Object.values(e).length && a.length > 0, d = qt({
|
|
333
333
|
initialPageParam: null,
|
|
334
334
|
enabled: !!i && !!t,
|
|
335
335
|
queryKey: ["walletTokensBalance", e],
|
|
@@ -354,11 +354,11 @@ const xs = (e) => {
|
|
|
354
354
|
d.data.pages.flatMap((m) => m.data)
|
|
355
355
|
);
|
|
356
356
|
return n.forEach((m) => {
|
|
357
|
-
|
|
357
|
+
rn(m.blockchain) && !(m.assetId in o) && (o[m.assetId] = "0");
|
|
358
358
|
}), o;
|
|
359
359
|
}, [d.data, n]);
|
|
360
360
|
return R(() => {
|
|
361
|
-
C(
|
|
361
|
+
C(r, ["initial_wallet"]) && (l(e, u), r.sourceToken && Object.keys(u).includes(r.sourceToken.assetId) && p("tokenSetBalance", u[r.sourceToken.assetId]));
|
|
362
362
|
}, [u]), {
|
|
363
363
|
status: d.status,
|
|
364
364
|
refetch: d.refetch,
|
|
@@ -367,13 +367,13 @@ const xs = (e) => {
|
|
|
367
367
|
}, ie = () => {
|
|
368
368
|
const { intentsAccountType: e } = E(), {
|
|
369
369
|
ctx: { walletAddress: t }
|
|
370
|
-
} =
|
|
370
|
+
} = N(), { tokens: s } = P(), r = s.filter((i) => i.isIntent).map((i) => i.assetId), n = te({
|
|
371
371
|
walletAddress: t,
|
|
372
372
|
addressType: e
|
|
373
373
|
}), a = Ae({
|
|
374
|
-
enabled: !!t && !!n &&
|
|
374
|
+
enabled: !!t && !!n && s.length > 0,
|
|
375
375
|
queryKey: ["intentsBalances", n],
|
|
376
|
-
queryFn: async () => n ? await an(n,
|
|
376
|
+
queryFn: async () => n ? await an(n, r) : {}
|
|
377
377
|
}), l = x(() => {
|
|
378
378
|
switch (a.status) {
|
|
379
379
|
case "error":
|
|
@@ -395,29 +395,29 @@ const xs = (e) => {
|
|
|
395
395
|
...a,
|
|
396
396
|
intentBalances: l
|
|
397
397
|
};
|
|
398
|
-
},
|
|
398
|
+
}, Fr = ({
|
|
399
399
|
isEnabled: e,
|
|
400
400
|
alchemyApiKey: t
|
|
401
401
|
}) => {
|
|
402
|
-
const { connectedWallets:
|
|
402
|
+
const { connectedWallets: s } = E(), { ctx: r } = N(), n = Ut(), { refetch: a } = ie(), { refetch: l } = It({
|
|
403
403
|
isEnabled: e,
|
|
404
|
-
connectedWallets:
|
|
404
|
+
connectedWallets: s,
|
|
405
405
|
alchemyApiKey: t ?? ""
|
|
406
406
|
});
|
|
407
407
|
R(() => {
|
|
408
|
-
const i = C(
|
|
408
|
+
const i = C(r, ["transfer_success"]);
|
|
409
409
|
!e || !i || (async () => (await a(), t && (await new Promise((d) => {
|
|
410
410
|
setTimeout(d, 1e4);
|
|
411
411
|
}), await l()), await n.invalidateQueries({ queryKey: ["tokenBalance"] })))();
|
|
412
|
-
}, [
|
|
412
|
+
}, [r.state, e, t]);
|
|
413
413
|
}, ce = () => {
|
|
414
|
-
const { connectedWallets: e } = E(), { intentBalances: t } = ie(), { walletBalance:
|
|
414
|
+
const { connectedWallets: e } = E(), { intentBalances: t } = ie(), { walletBalance: s } = Ee(e);
|
|
415
415
|
return { mergedBalance: x(
|
|
416
|
-
() => ({ ...
|
|
417
|
-
[
|
|
416
|
+
() => ({ ...s, ...t }),
|
|
417
|
+
[s, t]
|
|
418
418
|
) };
|
|
419
|
-
},
|
|
420
|
-
const { ctx: t } =
|
|
419
|
+
}, Lr = ({ isEnabled: e }) => {
|
|
420
|
+
const { ctx: t } = N(), { mergedBalance: s } = ce();
|
|
421
421
|
R(() => {
|
|
422
422
|
if (!e)
|
|
423
423
|
return;
|
|
@@ -425,9 +425,9 @@ const xs = (e) => {
|
|
|
425
425
|
p("tokenSetBalance", void 0);
|
|
426
426
|
return;
|
|
427
427
|
}
|
|
428
|
-
const
|
|
429
|
-
p("tokenSetBalance", r
|
|
430
|
-
}, [
|
|
428
|
+
const r = K(t.sourceToken);
|
|
429
|
+
p("tokenSetBalance", s[r]);
|
|
430
|
+
}, [s, t.sourceToken]);
|
|
431
431
|
}, je = {
|
|
432
432
|
// cbBTC (eth)
|
|
433
433
|
"nep141:eth-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near": "nep141:nbtc.bridge.near",
|
|
@@ -443,10 +443,10 @@ const xs = (e) => {
|
|
|
443
443
|
"nep245:v2_1.omni.hot.tg:56_SZzgw3HSudhZcTwPWUTi2RJB19t": "nep141:wrap.near",
|
|
444
444
|
// BTC (near)
|
|
445
445
|
"nep141:btc.omft.near": "nep141:nbtc.bridge.near"
|
|
446
|
-
},
|
|
446
|
+
}, Br = ({
|
|
447
447
|
isEnabled: e
|
|
448
448
|
}) => {
|
|
449
|
-
const { ctx: t } =
|
|
449
|
+
const { ctx: t } = N(), { tokens: s } = P();
|
|
450
450
|
R(() => {
|
|
451
451
|
if (!e)
|
|
452
452
|
return;
|
|
@@ -454,10 +454,10 @@ const xs = (e) => {
|
|
|
454
454
|
p("tokenSelect", { variant: "target", token: void 0 });
|
|
455
455
|
return;
|
|
456
456
|
}
|
|
457
|
-
const { sourceToken:
|
|
457
|
+
const { sourceToken: r } = t;
|
|
458
458
|
if (t.sourceToken.assetId in je) {
|
|
459
|
-
const i =
|
|
460
|
-
(d) => d.isIntent && d.assetId === je[
|
|
459
|
+
const i = s.find(
|
|
460
|
+
(d) => d.isIntent && d.assetId === je[r.assetId]
|
|
461
461
|
);
|
|
462
462
|
p("tokenSelect", {
|
|
463
463
|
variant: "target",
|
|
@@ -465,45 +465,45 @@ const xs = (e) => {
|
|
|
465
465
|
});
|
|
466
466
|
return;
|
|
467
467
|
}
|
|
468
|
-
const n =
|
|
469
|
-
(i) => i.isIntent && i.symbol ===
|
|
468
|
+
const n = s.find(
|
|
469
|
+
(i) => i.isIntent && i.symbol === r.symbol && i.blockchain === "near"
|
|
470
470
|
);
|
|
471
471
|
if (n) {
|
|
472
472
|
p("tokenSelect", { variant: "target", token: n });
|
|
473
473
|
return;
|
|
474
474
|
}
|
|
475
|
-
const a =
|
|
476
|
-
(i) => i.isIntent && i.assetId ===
|
|
477
|
-
), l =
|
|
475
|
+
const a = s.find(
|
|
476
|
+
(i) => i.isIntent && i.assetId === r.assetId
|
|
477
|
+
), l = s.find(
|
|
478
478
|
(i) => i.isIntent && i.symbol === "USDC" && i.blockchain === "near"
|
|
479
479
|
);
|
|
480
480
|
p("tokenSelect", {
|
|
481
481
|
variant: "target",
|
|
482
482
|
token: a ?? l
|
|
483
483
|
});
|
|
484
|
-
}, [
|
|
485
|
-
},
|
|
486
|
-
const { connectedWallets: t } = E(), { ctx:
|
|
484
|
+
}, [s, t.sourceToken]);
|
|
485
|
+
}, qr = ({ isEnabled: e }) => {
|
|
486
|
+
const { connectedWallets: t } = E(), { ctx: s, state: r } = N(), { walletAddress: n } = tt(
|
|
487
487
|
t,
|
|
488
|
-
|
|
488
|
+
s.sourceToken
|
|
489
489
|
);
|
|
490
490
|
R(() => {
|
|
491
491
|
if (!e)
|
|
492
492
|
return;
|
|
493
|
-
p("walletAddressSet", n), C(
|
|
494
|
-
}, [e, n,
|
|
495
|
-
},
|
|
493
|
+
p("walletAddressSet", n), C(s, ["initial_dry", "initial_wallet"]) && (r === "initial_wallet" && !n ? O("initial_dry") : r === "initial_dry" && n && O("initial_wallet"));
|
|
494
|
+
}, [e, n, s, r]);
|
|
495
|
+
}, Ur = (e) => (["depositAddress"].forEach((t) => {
|
|
496
496
|
if (!(t in e))
|
|
497
497
|
return b.error(`Missing ${t} in quote response`), !1;
|
|
498
|
-
}), !0),
|
|
499
|
-
const { ctx: e } =
|
|
498
|
+
}), !0), Pr = () => {
|
|
499
|
+
const { ctx: e } = N(), {
|
|
500
500
|
walletSupportedChains: t,
|
|
501
|
-
intentsAccountType:
|
|
502
|
-
appName:
|
|
501
|
+
intentsAccountType: s,
|
|
502
|
+
appName: r,
|
|
503
503
|
appFees: n,
|
|
504
504
|
fetchQuote: a,
|
|
505
505
|
slippageTolerance: l
|
|
506
|
-
} = E(), i = ye(e), d =
|
|
506
|
+
} = E(), i = ye(e), d = z(null), u = z(new AbortController()), o = x(() => async (T, h) => {
|
|
507
507
|
const { signal: f } = u.current;
|
|
508
508
|
return a ? a(T, {
|
|
509
509
|
...h,
|
|
@@ -533,8 +533,8 @@ const xs = (e) => {
|
|
|
533
533
|
meta: { isDry: i, message: w }
|
|
534
534
|
});
|
|
535
535
|
}
|
|
536
|
-
const S =
|
|
537
|
-
addressType:
|
|
536
|
+
const S = te({
|
|
537
|
+
addressType: s,
|
|
538
538
|
walletAddress: i ? (
|
|
539
539
|
// address on the target chain should be a dry quote recipient
|
|
540
540
|
qe(e.targetToken.blockchain)
|
|
@@ -567,7 +567,7 @@ const xs = (e) => {
|
|
|
567
567
|
// Experimental
|
|
568
568
|
quoteWaitingTimeMs: 0
|
|
569
569
|
};
|
|
570
|
-
T && (L.customRecipientMsg = T),
|
|
570
|
+
T && (L.customRecipientMsg = T), r && (L.referral = at(r)), n && (L.appFees = [...n]);
|
|
571
571
|
try {
|
|
572
572
|
e.sourceToken.isIntent && e.targetToken.isIntent && (d.current = o(
|
|
573
573
|
{
|
|
@@ -599,11 +599,11 @@ const xs = (e) => {
|
|
|
599
599
|
let v = w instanceof Error ? w.message : "";
|
|
600
600
|
if (w instanceof it) {
|
|
601
601
|
if (v = w.response?.data.message || v, v.includes("Amount is too low")) {
|
|
602
|
-
const
|
|
602
|
+
const X = v.match(/\d+/), J = X ? X[0] : void 0;
|
|
603
603
|
throw new q({
|
|
604
604
|
code: "QUOTE_AMOUNT_IS_TOO_LOW",
|
|
605
605
|
meta: {
|
|
606
|
-
minAmount: (J &&
|
|
606
|
+
minAmount: (J && Y(J, e.sourceToken.decimals)) ?? "0"
|
|
607
607
|
}
|
|
608
608
|
});
|
|
609
609
|
}
|
|
@@ -625,7 +625,7 @@ const xs = (e) => {
|
|
|
625
625
|
...F,
|
|
626
626
|
deadline: void 0,
|
|
627
627
|
depositAddress: void 0
|
|
628
|
-
} : (
|
|
628
|
+
} : (Ur(F), {
|
|
629
629
|
dry: !1,
|
|
630
630
|
...F,
|
|
631
631
|
deadline: F.deadline,
|
|
@@ -636,11 +636,11 @@ const xs = (e) => {
|
|
|
636
636
|
u.current.abort("Abort quote manually"), u.current = new AbortController();
|
|
637
637
|
}
|
|
638
638
|
};
|
|
639
|
-
},
|
|
640
|
-
const { ctx: e } =
|
|
639
|
+
}, Wr = () => {
|
|
640
|
+
const { ctx: e } = N(), { intentsAccountType: t } = E(), { isNativeNearDeposit: s } = G(), r = te({
|
|
641
641
|
addressType: t,
|
|
642
642
|
walletAddress: e.walletAddress ?? ""
|
|
643
|
-
}), n =
|
|
643
|
+
}), n = z(null), a = z(new AbortController()), l = x(() => async (d) => ct.post(
|
|
644
644
|
"",
|
|
645
645
|
{
|
|
646
646
|
id: 1,
|
|
@@ -672,7 +672,7 @@ const xs = (e) => {
|
|
|
672
672
|
meta: { isDry: !1, message: o }
|
|
673
673
|
});
|
|
674
674
|
}
|
|
675
|
-
if (
|
|
675
|
+
if (s && !e.isDepositFromExternalWallet || !s && e.sourceToken.assetId !== e.targetToken.assetId)
|
|
676
676
|
throw new q({
|
|
677
677
|
code: "QUOTE_INVALID_INITIAL",
|
|
678
678
|
meta: {
|
|
@@ -696,7 +696,7 @@ const xs = (e) => {
|
|
|
696
696
|
message: "Use transfer call. POA for tokens on Near only used for external deposits"
|
|
697
697
|
}
|
|
698
698
|
});
|
|
699
|
-
if (!
|
|
699
|
+
if (!r) {
|
|
700
700
|
const o = "No corresponding intents account to run a quote";
|
|
701
701
|
throw b.error(`[WIDGET] ${o}`), new q({
|
|
702
702
|
code: "QUOTE_INVALID_INITIAL",
|
|
@@ -704,10 +704,10 @@ const xs = (e) => {
|
|
|
704
704
|
});
|
|
705
705
|
}
|
|
706
706
|
n.current && (a.current.abort("Abort previous quote (auto)"), a.current = new AbortController());
|
|
707
|
-
let u =
|
|
707
|
+
let u = rt[e.targetToken.blockchain];
|
|
708
708
|
if (!u)
|
|
709
|
-
if (
|
|
710
|
-
u =
|
|
709
|
+
if (V(e.targetToken.blockchain))
|
|
710
|
+
u = st;
|
|
711
711
|
else
|
|
712
712
|
throw new q({
|
|
713
713
|
code: "QUOTE_INVALID_INITIAL",
|
|
@@ -716,18 +716,18 @@ const xs = (e) => {
|
|
|
716
716
|
try {
|
|
717
717
|
return n.current = l({
|
|
718
718
|
chain: u,
|
|
719
|
-
accountId:
|
|
719
|
+
accountId: r
|
|
720
720
|
}), {
|
|
721
721
|
depositAddress: (await n.current).data.result.address,
|
|
722
722
|
amountIn: e.sourceTokenAmount,
|
|
723
723
|
amountOut: e.targetTokenAmount,
|
|
724
724
|
amountInUsd: `${parseFloat(
|
|
725
|
-
|
|
725
|
+
Y(e.sourceTokenAmount, e.sourceToken.decimals)
|
|
726
726
|
) * e.sourceToken.price}`,
|
|
727
727
|
amountOutUsd: `${parseFloat(
|
|
728
|
-
|
|
728
|
+
Y(e.targetTokenAmount, e.targetToken.decimals)
|
|
729
729
|
) * e.targetToken.price}`,
|
|
730
|
-
amountOutFormatted:
|
|
730
|
+
amountOutFormatted: Y(
|
|
731
731
|
e.targetTokenAmount,
|
|
732
732
|
e.targetToken.decimals
|
|
733
733
|
),
|
|
@@ -778,49 +778,49 @@ const xs = (e) => {
|
|
|
778
778
|
}
|
|
779
779
|
e.error ? ln(e.error) && (p("errorSet", null), O("input_valid_external")) : O("input_valid_external");
|
|
780
780
|
}, wt = (e) => {
|
|
781
|
-
const t = C(e, ["initial_dry"]),
|
|
782
|
-
if (!t && !
|
|
781
|
+
const t = C(e, ["initial_dry"]), s = C(e, ["input_valid_dry"]);
|
|
782
|
+
if (!t && !s)
|
|
783
783
|
return;
|
|
784
|
-
let
|
|
785
|
-
return t && (e.sourceToken ? e.targetToken ?
|
|
784
|
+
let r;
|
|
785
|
+
return t && (e.sourceToken ? e.targetToken ? ne(e.sourceTokenAmount) ? e.walletAddress && !Re(e) && (r = { code: "SOURCE_BALANCE_INSUFFICIENT" }) : r = { code: "SOURCE_TOKEN_AMOUNT_IS_EMPTY" } : r = { code: "TARGET_TOKEN_IS_EMPTY" } : r = { code: "SOURCE_TOKEN_IS_EMPTY" }), !s && r ? p("errorSet", r) : e.error && !De(e.error) && !Ce(e.error) && p("errorSet", null), s && r?.code === "SOURCE_BALANCE_INSUFFICIENT" && p("errorSet", r), s;
|
|
786
786
|
}, kt = (e) => {
|
|
787
|
-
const t = C(e, ["initial_wallet"]),
|
|
788
|
-
if (!t && !
|
|
787
|
+
const t = C(e, ["initial_wallet"]), s = C(e, ["input_valid_external"]);
|
|
788
|
+
if (!t && !s)
|
|
789
789
|
return;
|
|
790
|
-
const
|
|
790
|
+
const r = e.sourceTokenBalance;
|
|
791
791
|
let n;
|
|
792
|
-
return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? n = { code: "SOURCE_TOKEN_IS_INTENT" } :
|
|
792
|
+
return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? n = { code: "SOURCE_TOKEN_IS_INTENT" } : ne(e.sourceTokenAmount) ? e.sendAddress ? e.targetToken.blockchain === "near" ? dt(e.sendAddress) ? ze(e) : n = {
|
|
793
793
|
code: "SEND_ADDRESS_IS_INVALID",
|
|
794
794
|
meta: { address: e.sendAddress, chain: "near" }
|
|
795
|
-
} : e.isDepositFromExternalWallet || (!
|
|
795
|
+
} : e.isDepositFromExternalWallet || (!r || !lt(r) ? n = { code: "INVALID_SOURCE_BALANCE" } : Re(e) || (n = { code: "SOURCE_BALANCE_INSUFFICIENT" })) : n = { code: "SEND_ADDRESS_IS_EMPTY" } : n = { code: "SOURCE_TOKEN_AMOUNT_IS_EMPTY" } : n = { code: "TARGET_TOKEN_IS_EMPTY" } : n = { code: "SOURCE_TOKEN_IS_EMPTY" }), s && e.targetToken.blockchain === "near" && ze(e), !s && n ? p("errorSet", n) : e.error && !De(e.error) && !Ce(e.error) && p("errorSet", null), s;
|
|
796
796
|
}, St = (e) => {
|
|
797
|
-
const t = C(e, ["initial_wallet"]),
|
|
798
|
-
if (!t && !
|
|
797
|
+
const t = C(e, ["initial_wallet"]), s = C(e, ["input_valid_internal"]);
|
|
798
|
+
if (!t && !s)
|
|
799
799
|
return;
|
|
800
|
-
const
|
|
800
|
+
const r = e.sourceTokenBalance;
|
|
801
801
|
let n;
|
|
802
|
-
return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ?
|
|
802
|
+
return t && (e.sourceToken ? e.targetToken ? e.targetToken.isIntent ? ne(e.sourceTokenAmount) ? e.isDepositFromExternalWallet || (!r || !lt(r) ? n = { code: "INVALID_SOURCE_BALANCE" } : Re(e) || (n = { code: "SOURCE_BALANCE_INSUFFICIENT" })) : n = { code: "SOURCE_TOKEN_AMOUNT_IS_EMPTY" } : n = { code: "SOURCE_TOKEN_NOT_INTENT" } : n = { code: "TARGET_TOKEN_IS_EMPTY" } : n = { code: "SOURCE_TOKEN_IS_EMPTY" }), !s && n ? p("errorSet", n) : e.error && !De(e.error) && !Ce(e.error) && p("errorSet", null), s;
|
|
803
803
|
}, At = (e) => {
|
|
804
|
-
const t = ye(e),
|
|
804
|
+
const t = ye(e), s = !t && e.targetToken?.isIntent === !0, r = !t && e.targetToken?.isIntent === !1;
|
|
805
805
|
if (t) {
|
|
806
806
|
const n = wt(e);
|
|
807
807
|
return O(n ? "input_valid_dry" : "initial_dry");
|
|
808
808
|
}
|
|
809
|
-
|
|
810
|
-
},
|
|
809
|
+
r && kt(e) ? O("input_valid_external") : s && St(e) ? O("input_valid_internal") : O("initial_wallet");
|
|
810
|
+
}, Mr = ({
|
|
811
811
|
isEnabled: e,
|
|
812
812
|
message: t,
|
|
813
|
-
type:
|
|
814
|
-
refetchQuoteInterval:
|
|
813
|
+
type: s = "exact_in",
|
|
814
|
+
refetchQuoteInterval: r
|
|
815
815
|
}) => {
|
|
816
|
-
const { ctx: n } =
|
|
816
|
+
const { ctx: n } = N(), {
|
|
817
817
|
isNativeNearDeposit: a,
|
|
818
818
|
isDirectNonNearWithdrawal: l,
|
|
819
819
|
isDirectTokenOnNearDeposit: i,
|
|
820
820
|
isDirectNearTokenWithdrawal: d,
|
|
821
821
|
isDirectTokenOnNearTransfer: u,
|
|
822
822
|
isSameAssetDiffChainWithdrawal: o
|
|
823
|
-
} =
|
|
823
|
+
} = G(), m = ye(n), T = e && !n.areInputsValidating && (o || (i || a) && n.isDepositFromExternalWallet || !d && !l && !i && !u), { make: h, cancel: f } = Pr(), { make: I, cancel: S } = Wr(), y = z(null), B = () => {
|
|
824
824
|
f(), S();
|
|
825
825
|
};
|
|
826
826
|
R(() => {
|
|
@@ -836,7 +836,7 @@ const xs = (e) => {
|
|
|
836
836
|
return;
|
|
837
837
|
p("quoteSetStatus", "pending"), w = await I();
|
|
838
838
|
} else
|
|
839
|
-
p("quoteSetStatus", "pending"), w = await h({ message: t, quoteType:
|
|
839
|
+
p("quoteSetStatus", "pending"), w = await h({ message: t, quoteType: s, options: L });
|
|
840
840
|
if (!w)
|
|
841
841
|
return;
|
|
842
842
|
if (p("quoteSetStatus", "success"), p("quoteSet", w), !m && n.error?.code !== "SOURCE_BALANCE_INSUFFICIENT" && p("errorSet", null), p("tokenSetAmount", {
|
|
@@ -862,7 +862,7 @@ const xs = (e) => {
|
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
864
|
},
|
|
865
|
-
[n, m, I, h, t,
|
|
865
|
+
[n, m, I, h, t, s, T]
|
|
866
866
|
);
|
|
867
867
|
R(() => {
|
|
868
868
|
!T || !(m ? n.state === "input_valid_dry" : n.state === "input_valid_external" && !n.targetToken?.isIntent || n.state === "input_valid_internal" && n.targetToken?.isIntent) || n.quoteStatus !== "error" && (a && !n.isDepositFromExternalWallet || F({ isRefetch: !1 }));
|
|
@@ -870,26 +870,26 @@ const xs = (e) => {
|
|
|
870
870
|
const L = () => {
|
|
871
871
|
y.current && (clearInterval(y.current), y.current = null);
|
|
872
872
|
};
|
|
873
|
-
return n.state !== "quote_success_internal" && n.state !== "quote_success_external" || !
|
|
873
|
+
return n.state !== "quote_success_internal" && n.state !== "quote_success_external" || !r || (y.current = setInterval(async () => {
|
|
874
874
|
await F({ isRefetch: !0 });
|
|
875
|
-
},
|
|
875
|
+
}, r)), L;
|
|
876
876
|
}, [T, F, B, n.state]);
|
|
877
877
|
}, ue = {
|
|
878
878
|
sol: "sol",
|
|
879
879
|
evm: "eth",
|
|
880
880
|
near: "near"
|
|
881
|
-
},
|
|
881
|
+
}, Vr = ({
|
|
882
882
|
isEnabled: e,
|
|
883
883
|
skipIntents: t = !1,
|
|
884
|
-
target:
|
|
884
|
+
target: s = "none"
|
|
885
885
|
}) => {
|
|
886
|
-
const { tokens:
|
|
887
|
-
tokens:
|
|
886
|
+
const { tokens: r } = P(), { ctx: n, state: a } = N(), { intentBalances: l } = ie(), { walletSupportedChains: i, chainsFilter: d, intentsAccountType: u } = E(), o = mn({
|
|
887
|
+
tokens: r,
|
|
888
888
|
walletSupportedChains: i,
|
|
889
889
|
balances: l,
|
|
890
890
|
across: "intents"
|
|
891
891
|
}), [m, T] = x(() => !n.walletAddress && !t ? [
|
|
892
|
-
{ token: un({ tokens:
|
|
892
|
+
{ token: un({ tokens: r }), status: "loaded" },
|
|
893
893
|
{ token: void 0, status: "loaded" }
|
|
894
894
|
] : d.source.intents !== "none" && !t ? o ? [
|
|
895
895
|
{ token: o, status: "loaded" },
|
|
@@ -899,12 +899,12 @@ const xs = (e) => {
|
|
|
899
899
|
{ token: void 0, status: "loading" }
|
|
900
900
|
] : [
|
|
901
901
|
{ token: dn({
|
|
902
|
-
tokens:
|
|
902
|
+
tokens: r,
|
|
903
903
|
walletSupportedChains: i
|
|
904
904
|
}), status: "loaded" },
|
|
905
905
|
{ token: void 0, status: "loaded" }
|
|
906
906
|
], [
|
|
907
|
-
|
|
907
|
+
r,
|
|
908
908
|
t,
|
|
909
909
|
d,
|
|
910
910
|
n.walletAddress,
|
|
@@ -920,17 +920,17 @@ const xs = (e) => {
|
|
|
920
920
|
token: m.token
|
|
921
921
|
}), T.status === "loaded" && m.status === "loaded" && !n.targetToken)) {
|
|
922
922
|
let I = T.token;
|
|
923
|
-
if (
|
|
923
|
+
if (s === "same-asset")
|
|
924
924
|
if (m.token?.isIntent) {
|
|
925
925
|
if (!u)
|
|
926
926
|
throw new Error(
|
|
927
927
|
"Intents account type is required to select same-asset target token"
|
|
928
928
|
);
|
|
929
|
-
I =
|
|
929
|
+
I = r.find(
|
|
930
930
|
(S) => !S.isIntent && S.symbol === n.sourceToken?.symbol && S.blockchain === ue[u]
|
|
931
931
|
);
|
|
932
932
|
} else
|
|
933
|
-
I =
|
|
933
|
+
I = r.find(
|
|
934
934
|
(S) => S.isIntent && S.symbol === n.sourceToken?.symbol
|
|
935
935
|
);
|
|
936
936
|
p("tokenSelect", {
|
|
@@ -940,7 +940,7 @@ const xs = (e) => {
|
|
|
940
940
|
}
|
|
941
941
|
}, [n, m, T, e]);
|
|
942
942
|
const h = (f, I) => {
|
|
943
|
-
const S =
|
|
943
|
+
const S = r.find(
|
|
944
944
|
(y) => !y.isIntent && y.blockchain === ue[f] && y.symbol.toLowerCase() === jt[ue[f]]?.toLowerCase()
|
|
945
945
|
) ?? I;
|
|
946
946
|
p("tokenSelect", {
|
|
@@ -952,7 +952,7 @@ const xs = (e) => {
|
|
|
952
952
|
const f = C(n, ["initial_dry", "initial_wallet"]);
|
|
953
953
|
if (!e || !f)
|
|
954
954
|
return;
|
|
955
|
-
const I =
|
|
955
|
+
const I = r.find(
|
|
956
956
|
(y) => y.isIntent && y.symbol === "AURORA" && y.blockchain === "near"
|
|
957
957
|
), S = setTimeout(() => {
|
|
958
958
|
m.token || (!t && o ? p("tokenSelect", {
|
|
@@ -964,30 +964,30 @@ const xs = (e) => {
|
|
|
964
964
|
}));
|
|
965
965
|
}, 3e3);
|
|
966
966
|
return () => clearTimeout(S);
|
|
967
|
-
}, [
|
|
968
|
-
},
|
|
967
|
+
}, [r, m, t]), { source: n.sourceToken, target: n.targetToken };
|
|
968
|
+
}, Qr = ({
|
|
969
969
|
isEnabled: e,
|
|
970
970
|
alchemyApiKey: t
|
|
971
971
|
}) => {
|
|
972
|
-
const { connectedWallets:
|
|
972
|
+
const { connectedWallets: s } = E();
|
|
973
973
|
It({
|
|
974
974
|
isEnabled: e,
|
|
975
|
-
connectedWallets:
|
|
975
|
+
connectedWallets: s,
|
|
976
976
|
alchemyApiKey: t ?? ""
|
|
977
977
|
});
|
|
978
|
-
}, $
|
|
979
|
-
const { config:
|
|
980
|
-
return e.targetToken && !e.sendAddress && !!e.walletAddress && !e.targetToken.isIntent && !t.find((
|
|
981
|
-
},
|
|
982
|
-
|
|
983
|
-
const
|
|
984
|
-
if (e && b.debug("[WIDGET] Context changed",
|
|
978
|
+
}, $r = (e, t) => {
|
|
979
|
+
const { config: s } = Se(Be);
|
|
980
|
+
return e.targetToken && !e.sendAddress && !!e.walletAddress && !e.targetToken.isIntent && !t.find((r) => r?.key === "sendAddress") && s.walletSupportedChains.includes(e.targetToken.blockchain);
|
|
981
|
+
}, Kr = ({ debug: e }) => {
|
|
982
|
+
Z.onContextChange((t, s) => {
|
|
983
|
+
const r = s;
|
|
984
|
+
if (e && b.debug("[WIDGET] Context changed", r), e && t.error && Tn(r) && b.debug(`[WIDGET] Error set to ${t.error.code}`), hn(r) || kn(t, r, e))
|
|
985
985
|
return;
|
|
986
|
-
if (In(t,
|
|
986
|
+
if (In(t, r)) {
|
|
987
987
|
p("reset", { clearWalletAddress: !0 }), O("initial_dry");
|
|
988
988
|
return;
|
|
989
989
|
}
|
|
990
|
-
const { isChanged: n, isDry: a } = pn(t,
|
|
990
|
+
const { isChanged: n, isDry: a } = pn(t, r);
|
|
991
991
|
if (n) {
|
|
992
992
|
if (gn(t)) {
|
|
993
993
|
const l = a ? "initial_dry" : "initial_wallet";
|
|
@@ -999,87 +999,87 @@ const xs = (e) => {
|
|
|
999
999
|
}
|
|
1000
1000
|
});
|
|
1001
1001
|
}
|
|
1002
|
-
fn(t) || (t.quote = void 0, t.quoteStatus = "idle", t.transferStatus = { status: "idle" }), wn(t) && (t.sendAddress = void 0), $
|
|
1002
|
+
fn(t) || (t.quote = void 0, t.quoteStatus = "idle", t.transferStatus = { status: "idle" }), wn(t) && (t.sendAddress = void 0), $r(t, r) && (t.sendAddress = t.walletAddress), At(t);
|
|
1003
1003
|
}
|
|
1004
1004
|
});
|
|
1005
|
-
},
|
|
1006
|
-
|
|
1007
|
-
e && b.debug(`===> [WIDGET] State moved from ${t} to ${
|
|
1005
|
+
}, Hr = ({ debug: e }) => {
|
|
1006
|
+
Z.onTransition((t, s) => {
|
|
1007
|
+
e && b.debug(`===> [WIDGET] State moved from ${t} to ${s}`);
|
|
1008
1008
|
});
|
|
1009
|
-
},
|
|
1010
|
-
const { variant:
|
|
1011
|
-
switch (
|
|
1009
|
+
}, Gr = (e, t) => {
|
|
1010
|
+
const { variant: s, token: r } = t, { config: n } = Se(Be);
|
|
1011
|
+
switch (s) {
|
|
1012
1012
|
case "source":
|
|
1013
|
-
if (
|
|
1013
|
+
if (r && r.assetId === e.targetToken?.assetId && r.isIntent === e.targetToken.isIntent && n.enableAutoTokensSwitching) {
|
|
1014
1014
|
if (!e.sourceToken)
|
|
1015
1015
|
return;
|
|
1016
1016
|
ge(e);
|
|
1017
1017
|
return;
|
|
1018
1018
|
}
|
|
1019
|
-
if (
|
|
1019
|
+
if (r && !e.sourceToken && r.assetId === e.targetToken?.assetId && r.isIntent === e.targetToken.isIntent && n.enableAutoTokensSwitching)
|
|
1020
1020
|
return;
|
|
1021
|
-
e.sourceToken =
|
|
1021
|
+
e.sourceToken = r;
|
|
1022
1022
|
break;
|
|
1023
1023
|
case "target":
|
|
1024
|
-
if (
|
|
1024
|
+
if (r && r.assetId === e.sourceToken?.assetId && r.isIntent === e.sourceToken.isIntent && n.enableAutoTokensSwitching) {
|
|
1025
1025
|
if (!e.targetToken)
|
|
1026
1026
|
return;
|
|
1027
1027
|
ge(e);
|
|
1028
1028
|
return;
|
|
1029
1029
|
}
|
|
1030
|
-
e.targetToken =
|
|
1030
|
+
e.targetToken = r;
|
|
1031
1031
|
break;
|
|
1032
1032
|
default:
|
|
1033
|
-
be(
|
|
1033
|
+
be(s, { throwError: !1 });
|
|
1034
1034
|
}
|
|
1035
|
-
}, D = (e, t) =>
|
|
1035
|
+
}, D = (e, t) => Z.on(
|
|
1036
1036
|
e,
|
|
1037
|
-
(
|
|
1038
|
-
),
|
|
1039
|
-
D("quoteSetStatus", bn), D("walletAddressSet", Cn), D("transferSetStatus", On), D("tokenSelectRotate", ge), D("tokenSetBalance", vn), D("tokenSetAmount", En), D("depositTypeSet", yn), D("setInputsValidating", Dn), D("externalDepositTxSet", Rn), D("tokenSelect",
|
|
1040
|
-
},
|
|
1037
|
+
(s, r) => t(s, r, Z)
|
|
1038
|
+
), jr = () => {
|
|
1039
|
+
D("quoteSetStatus", bn), D("walletAddressSet", Cn), D("transferSetStatus", On), D("tokenSelectRotate", ge), D("tokenSetBalance", vn), D("tokenSetAmount", En), D("depositTypeSet", yn), D("setInputsValidating", Dn), D("externalDepositTxSet", Rn), D("tokenSelect", Gr), D("addressSet", Nn), D("errorSet", An), D("quoteSet", _n), D("reset", Sn), D("validateDryInputs", wt), D("validateExternalInputs", kt), D("validateInternalInputs", St);
|
|
1040
|
+
}, Yr = en(({ debug: e }) => {
|
|
1041
1041
|
e && b.debug(
|
|
1042
|
-
"[WIDGET] Debug mode is enabled (package version: 3.14.0-redesign.
|
|
1043
|
-
),
|
|
1042
|
+
"[WIDGET] Debug mode is enabled (package version: 3.14.0-redesign.3)"
|
|
1043
|
+
), jr(), Hr({ debug: e }), Kr({ debug: e });
|
|
1044
1044
|
}), hi = ({ listenTo: e, debug: t = !1 }) => {
|
|
1045
1045
|
R(() => {
|
|
1046
|
-
|
|
1046
|
+
Yr({ debug: t });
|
|
1047
1047
|
}, [t]);
|
|
1048
|
-
const
|
|
1048
|
+
const s = e.find(
|
|
1049
1049
|
(a) => Array.isArray(a) && a[0] === "setBalancesUsingAlchemyExt"
|
|
1050
|
-
),
|
|
1050
|
+
), r = e.find(
|
|
1051
1051
|
(a) => Array.isArray(a) && a[0] === "setDefaultSelectedTokens"
|
|
1052
1052
|
), n = e.find(
|
|
1053
1053
|
(a) => Array.isArray(a) && a[0] === "makeQuote"
|
|
1054
1054
|
);
|
|
1055
|
-
|
|
1056
|
-
isEnabled: !!r,
|
|
1057
|
-
alchemyApiKey: r?.[1].alchemyApiKey
|
|
1058
|
-
}), Ms({
|
|
1055
|
+
Qr({
|
|
1059
1056
|
isEnabled: !!s,
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1057
|
+
alchemyApiKey: s?.[1].alchemyApiKey
|
|
1058
|
+
}), Vr({
|
|
1059
|
+
isEnabled: !!r,
|
|
1060
|
+
skipIntents: r?.[1].skipIntents,
|
|
1061
|
+
target: r?.[1].target
|
|
1062
|
+
}), Mr({
|
|
1063
1063
|
isEnabled: !!n,
|
|
1064
1064
|
message: n?.[1].message,
|
|
1065
1065
|
type: n?.[1].type,
|
|
1066
1066
|
refetchQuoteInterval: n?.[1].refetchQuoteInterval
|
|
1067
|
-
}),
|
|
1067
|
+
}), qr({
|
|
1068
1068
|
isEnabled: e.includes("checkWalletConnection")
|
|
1069
|
-
}),
|
|
1069
|
+
}), Lr({
|
|
1070
1070
|
isEnabled: e.includes("setSourceTokenBalance")
|
|
1071
|
-
}),
|
|
1071
|
+
}), Br({
|
|
1072
1072
|
isEnabled: e.includes("setSourceTokenIntentsTarget")
|
|
1073
|
-
}),
|
|
1073
|
+
}), Fr({
|
|
1074
1074
|
isEnabled: e.includes("updateBalances"),
|
|
1075
|
-
alchemyApiKey:
|
|
1075
|
+
alchemyApiKey: s?.[1].alchemyApiKey
|
|
1076
1076
|
});
|
|
1077
|
-
},
|
|
1077
|
+
}, zr = Z.getStore();
|
|
1078
1078
|
class W extends Error {
|
|
1079
1079
|
context;
|
|
1080
1080
|
_is_widget_error = !0;
|
|
1081
|
-
constructor(t,
|
|
1082
|
-
super(t), this.name = "WidgetError", this.cause =
|
|
1081
|
+
constructor(t, s) {
|
|
1082
|
+
super(t), this.name = "WidgetError", this.cause = s?.cause, this.context = Se(zr).context;
|
|
1083
1083
|
}
|
|
1084
1084
|
}
|
|
1085
1085
|
class _t extends W {
|
|
@@ -1098,49 +1098,49 @@ class g extends _t {
|
|
|
1098
1098
|
super(t), this.name = "TransferError";
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
1101
|
-
const gi = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e && !!e._is_widget_error,
|
|
1102
|
-
usdTradeDelta: (e) => xn(e(
|
|
1103
|
-
isDirectNearTokenWithdrawal: (e) => Bn(e(
|
|
1104
|
-
isDirectNonNearWithdrawal: (e) => Fn(e(
|
|
1105
|
-
isDirectTokenOnNearDeposit: (e) =>
|
|
1106
|
-
isNativeNearDeposit: (e) =>
|
|
1107
|
-
isSameAssetDiffChainWithdrawal: (e) => qn(e(
|
|
1108
|
-
isDirectTokenOnNearTransfer: (e) => Ln(e(
|
|
1109
|
-
}),
|
|
1110
|
-
const e = oe(
|
|
1101
|
+
const gi = (e) => typeof e == "object" && e !== null && "_is_widget_error" in e && !!e._is_widget_error, M = Z.getStore(), Zr = Zt({
|
|
1102
|
+
usdTradeDelta: (e) => xn(e(M.context)),
|
|
1103
|
+
isDirectNearTokenWithdrawal: (e) => Bn(e(M.context)),
|
|
1104
|
+
isDirectNonNearWithdrawal: (e) => Fn(e(M.context)),
|
|
1105
|
+
isDirectTokenOnNearDeposit: (e) => Jt(e(M.context)),
|
|
1106
|
+
isNativeNearDeposit: (e) => Xt(e(M.context)),
|
|
1107
|
+
isSameAssetDiffChainWithdrawal: (e) => qn(e(M.context)),
|
|
1108
|
+
isDirectTokenOnNearTransfer: (e) => Ln(e(M.context))
|
|
1109
|
+
}), G = () => oe(Zr), N = () => {
|
|
1110
|
+
const e = oe(M);
|
|
1111
1111
|
return {
|
|
1112
1112
|
state: e.state,
|
|
1113
1113
|
ctx: e.context
|
|
1114
1114
|
};
|
|
1115
1115
|
}, Ii = (e) => {
|
|
1116
|
-
const t = oe(
|
|
1116
|
+
const t = oe(M);
|
|
1117
1117
|
if (!C(t.context, [e]))
|
|
1118
1118
|
throw new W(
|
|
1119
1119
|
`[WIDGET] Attempt to access snapshot for ${e} state while context does not match`
|
|
1120
1120
|
);
|
|
1121
1121
|
return t.context;
|
|
1122
|
-
},
|
|
1122
|
+
}, Xr = async ({
|
|
1123
1123
|
contractId: e,
|
|
1124
1124
|
accountId: t
|
|
1125
1125
|
}) => {
|
|
1126
1126
|
try {
|
|
1127
|
-
const
|
|
1127
|
+
const s = { account_id: t }, r = Oe.from(JSON.stringify(s)).toString("base64"), n = await Pn.query({
|
|
1128
1128
|
request_type: "call_function",
|
|
1129
1129
|
method_name: "storage_balance_of",
|
|
1130
1130
|
account_id: e,
|
|
1131
|
-
args_base64:
|
|
1131
|
+
args_base64: r,
|
|
1132
1132
|
finality: "optimistic"
|
|
1133
1133
|
}), a = Un(
|
|
1134
1134
|
n,
|
|
1135
|
-
|
|
1135
|
+
re.union([re.null(), re.object({ total: re.string() })])
|
|
1136
1136
|
);
|
|
1137
1137
|
return BigInt(a?.total ?? "0");
|
|
1138
|
-
} catch (
|
|
1139
|
-
throw new W("Error fetching balance", { cause:
|
|
1138
|
+
} catch (s) {
|
|
1139
|
+
throw new W("Error fetching balance", { cause: s });
|
|
1140
1140
|
}
|
|
1141
1141
|
};
|
|
1142
|
-
function
|
|
1143
|
-
const { ctx: t } =
|
|
1142
|
+
function Jr(e) {
|
|
1143
|
+
const { ctx: t } = N(), { isNativeNearDeposit: s } = G(), r = t.sourceToken?.contractAddress, n = t.quote?.amountIn ?? t.sourceTokenAmount;
|
|
1144
1144
|
return {
|
|
1145
1145
|
make: async (l, i) => {
|
|
1146
1146
|
if (!e)
|
|
@@ -1148,7 +1148,7 @@ function Xs(e) {
|
|
|
1148
1148
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1149
1149
|
meta: { message: "No connected wallet to sign a transfer." }
|
|
1150
1150
|
});
|
|
1151
|
-
if (!
|
|
1151
|
+
if (!r && t.sourceToken?.assetId !== Q)
|
|
1152
1152
|
throw new g({
|
|
1153
1153
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1154
1154
|
meta: { message: "No token selected to transfer." }
|
|
@@ -1193,7 +1193,7 @@ function Xs(e) {
|
|
|
1193
1193
|
};
|
|
1194
1194
|
}
|
|
1195
1195
|
const u = [];
|
|
1196
|
-
if (t.targetToken &&
|
|
1196
|
+
if (t.targetToken && s)
|
|
1197
1197
|
try {
|
|
1198
1198
|
u.push({
|
|
1199
1199
|
type: "FunctionCall",
|
|
@@ -1239,7 +1239,7 @@ function Xs(e) {
|
|
|
1239
1239
|
code: "DIRECT_TRANSFER_ERROR"
|
|
1240
1240
|
});
|
|
1241
1241
|
}
|
|
1242
|
-
if (!
|
|
1242
|
+
if (!r)
|
|
1243
1243
|
throw new g({
|
|
1244
1244
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1245
1245
|
meta: { message: "No token selected to transfer." }
|
|
@@ -1247,10 +1247,10 @@ function Xs(e) {
|
|
|
1247
1247
|
try {
|
|
1248
1248
|
const [o, m] = await Promise.all([
|
|
1249
1249
|
Wn({
|
|
1250
|
-
contractId:
|
|
1250
|
+
contractId: r
|
|
1251
1251
|
}),
|
|
1252
|
-
|
|
1253
|
-
contractId:
|
|
1252
|
+
Xr({
|
|
1253
|
+
contractId: r,
|
|
1254
1254
|
accountId: l
|
|
1255
1255
|
})
|
|
1256
1256
|
]), T = o - m;
|
|
@@ -1278,7 +1278,7 @@ function Xs(e) {
|
|
|
1278
1278
|
const h = await d.signAndSendTransactions({
|
|
1279
1279
|
transactions: [
|
|
1280
1280
|
{
|
|
1281
|
-
receiverId:
|
|
1281
|
+
receiverId: r,
|
|
1282
1282
|
actions: u
|
|
1283
1283
|
}
|
|
1284
1284
|
]
|
|
@@ -1300,15 +1300,15 @@ function Xs(e) {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
};
|
|
1302
1302
|
}
|
|
1303
|
-
const
|
|
1303
|
+
const es = ({
|
|
1304
1304
|
makeTransfer: e,
|
|
1305
1305
|
providers: t
|
|
1306
1306
|
}) => {
|
|
1307
|
-
const { ctx:
|
|
1307
|
+
const { ctx: s } = N(), { alchemyApiKey: r } = E(), { make: n } = Vn({
|
|
1308
1308
|
provider: t?.evm
|
|
1309
1309
|
}), { make: a } = Qn({
|
|
1310
1310
|
provider: t?.sol,
|
|
1311
|
-
alchemyApiKey:
|
|
1311
|
+
alchemyApiKey: r
|
|
1312
1312
|
}), l = (d) => {
|
|
1313
1313
|
if (e)
|
|
1314
1314
|
return e;
|
|
@@ -1322,21 +1322,21 @@ const er = ({
|
|
|
1322
1322
|
});
|
|
1323
1323
|
};
|
|
1324
1324
|
return { make: async () => {
|
|
1325
|
-
if (!
|
|
1325
|
+
if (!s.sourceToken) {
|
|
1326
1326
|
const o = "No token selected to transfer.";
|
|
1327
1327
|
throw new g({
|
|
1328
1328
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1329
1329
|
meta: { message: o }
|
|
1330
1330
|
});
|
|
1331
1331
|
}
|
|
1332
|
-
if (!
|
|
1332
|
+
if (!s.quote) {
|
|
1333
1333
|
const o = "Quote is required for a transfer.";
|
|
1334
1334
|
throw new g({
|
|
1335
1335
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1336
1336
|
meta: { message: o }
|
|
1337
1337
|
});
|
|
1338
1338
|
}
|
|
1339
|
-
if (!
|
|
1339
|
+
if (!s.quote.depositAddress) {
|
|
1340
1340
|
const o = "Quote has no deposit address. Make sure not dry.";
|
|
1341
1341
|
throw new g({
|
|
1342
1342
|
code: "TRANSFER_INVALID_INITIAL",
|
|
@@ -1344,15 +1344,15 @@ const er = ({
|
|
|
1344
1344
|
});
|
|
1345
1345
|
}
|
|
1346
1346
|
const d = {
|
|
1347
|
-
amount:
|
|
1348
|
-
decimals:
|
|
1349
|
-
address:
|
|
1350
|
-
chain:
|
|
1351
|
-
evmChainId:
|
|
1352
|
-
isNativeEthTransfer: !!
|
|
1353
|
-
tokenAddress:
|
|
1354
|
-
sourceAssetId:
|
|
1355
|
-
targetAssetId:
|
|
1347
|
+
amount: s.quote.amountIn,
|
|
1348
|
+
decimals: s.sourceToken.decimals,
|
|
1349
|
+
address: s.quote.depositAddress,
|
|
1350
|
+
chain: s.sourceToken.blockchain,
|
|
1351
|
+
evmChainId: V(s.sourceToken.blockchain) ? pe[s.sourceToken.blockchain] : null,
|
|
1352
|
+
isNativeEthTransfer: !!s.sourceToken && Mn(s.sourceToken),
|
|
1353
|
+
tokenAddress: s.sourceToken.assetId === Q ? Q : s.sourceToken.contractAddress,
|
|
1354
|
+
sourceAssetId: s.sourceToken.assetId,
|
|
1355
|
+
targetAssetId: s.targetToken.assetId
|
|
1356
1356
|
}, u = l(d.address);
|
|
1357
1357
|
try {
|
|
1358
1358
|
const o = await u(d);
|
|
@@ -1389,49 +1389,49 @@ const er = ({
|
|
|
1389
1389
|
}
|
|
1390
1390
|
} };
|
|
1391
1391
|
};
|
|
1392
|
-
class
|
|
1393
|
-
constructor(t,
|
|
1394
|
-
this.account = t, this.provider =
|
|
1392
|
+
class ts {
|
|
1393
|
+
constructor(t, s) {
|
|
1394
|
+
this.account = t, this.provider = s;
|
|
1395
1395
|
}
|
|
1396
1396
|
async signIntent(t) {
|
|
1397
|
-
const
|
|
1397
|
+
const s = JSON.stringify({
|
|
1398
1398
|
verifying_contract: t.verifying_contract,
|
|
1399
1399
|
deadline: t.deadline,
|
|
1400
1400
|
nonce: t.nonce,
|
|
1401
1401
|
intents: t.intents,
|
|
1402
|
-
signer_id: t.signer_id ??
|
|
1402
|
+
signer_id: t.signer_id ?? Me.authHandleToIntentsUserId({
|
|
1403
1403
|
identifier: this.account.walletAddress,
|
|
1404
1404
|
method: "evm"
|
|
1405
1405
|
})
|
|
1406
|
-
}),
|
|
1406
|
+
}), r = typeof this.provider == "function" ? await this.provider() : this.provider, n = await r.request({
|
|
1407
1407
|
method: "eth_requestAccounts"
|
|
1408
|
-
}), a = await
|
|
1408
|
+
}), a = await r.request({
|
|
1409
1409
|
method: "personal_sign",
|
|
1410
|
-
params: [
|
|
1410
|
+
params: [s, n[0]]
|
|
1411
1411
|
});
|
|
1412
1412
|
if (a == null)
|
|
1413
1413
|
throw new W("No signature is returned");
|
|
1414
1414
|
return {
|
|
1415
|
-
payload:
|
|
1415
|
+
payload: s,
|
|
1416
1416
|
standard: "erc191",
|
|
1417
|
-
signature:
|
|
1417
|
+
signature: Me.transformERC191Signature(a)
|
|
1418
1418
|
};
|
|
1419
1419
|
}
|
|
1420
1420
|
}
|
|
1421
|
-
const
|
|
1421
|
+
const ns = ({
|
|
1422
1422
|
walletAddress: e,
|
|
1423
1423
|
getProvider: t
|
|
1424
1424
|
}) => $n({
|
|
1425
1425
|
accountId: e,
|
|
1426
|
-
signMessage: async (
|
|
1427
|
-
const
|
|
1428
|
-
if (!
|
|
1426
|
+
signMessage: async (s) => {
|
|
1427
|
+
const r = t();
|
|
1428
|
+
if (!r.signMessage)
|
|
1429
1429
|
throw new W("Near wallet has no signMessage method exposed");
|
|
1430
1430
|
let n;
|
|
1431
1431
|
try {
|
|
1432
|
-
n = await
|
|
1433
|
-
...
|
|
1434
|
-
nonce: Oe.from(
|
|
1432
|
+
n = await r.signMessage({
|
|
1433
|
+
...s,
|
|
1434
|
+
nonce: Oe.from(s.nonce)
|
|
1435
1435
|
});
|
|
1436
1436
|
} catch (a) {
|
|
1437
1437
|
throw new W("Near wallet failed to sign a message", {
|
|
@@ -1445,7 +1445,7 @@ const nr = ({
|
|
|
1445
1445
|
signature: n.signature
|
|
1446
1446
|
};
|
|
1447
1447
|
}
|
|
1448
|
-
}),
|
|
1448
|
+
}), rs = (e, t) => {
|
|
1449
1449
|
if (t) {
|
|
1450
1450
|
if (e.sendAddress)
|
|
1451
1451
|
return e.sendAddress;
|
|
@@ -1460,14 +1460,14 @@ const nr = ({
|
|
|
1460
1460
|
meta: { message: "Quote is required for intents non-direct transfer" }
|
|
1461
1461
|
});
|
|
1462
1462
|
return e.quote.depositAddress;
|
|
1463
|
-
},
|
|
1464
|
-
let
|
|
1463
|
+
}, ss = async (e, t) => {
|
|
1464
|
+
let s = We.getItem("nearWalletsPk")[t];
|
|
1465
1465
|
if (!e.signMessage)
|
|
1466
1466
|
throw new g({
|
|
1467
1467
|
code: "DIRECT_TRANSFER_ERROR",
|
|
1468
1468
|
meta: { message: "Your wallet doesn't support signing messages" }
|
|
1469
1469
|
});
|
|
1470
|
-
if (!
|
|
1470
|
+
if (!s)
|
|
1471
1471
|
try {
|
|
1472
1472
|
const a = await e.signMessage({
|
|
1473
1473
|
message: "Authenticate",
|
|
@@ -1479,7 +1479,7 @@ const nr = ({
|
|
|
1479
1479
|
code: "DIRECT_TRANSFER_ERROR",
|
|
1480
1480
|
meta: { message: "Signing message failed" }
|
|
1481
1481
|
});
|
|
1482
|
-
|
|
1482
|
+
s = a.publicKey, We.setItem("nearWalletsPk", {
|
|
1483
1483
|
[t]: a.publicKey
|
|
1484
1484
|
});
|
|
1485
1485
|
} catch {
|
|
@@ -1488,7 +1488,7 @@ const nr = ({
|
|
|
1488
1488
|
meta: { message: "Your wallet doesn't support signing messages" }
|
|
1489
1489
|
});
|
|
1490
1490
|
}
|
|
1491
|
-
const
|
|
1491
|
+
const r = te({
|
|
1492
1492
|
walletAddress: t,
|
|
1493
1493
|
addressType: "near"
|
|
1494
1494
|
});
|
|
@@ -1496,8 +1496,8 @@ const nr = ({
|
|
|
1496
1496
|
contractId: Ie,
|
|
1497
1497
|
methodName: "has_public_key",
|
|
1498
1498
|
args: {
|
|
1499
|
-
account_id:
|
|
1500
|
-
public_key:
|
|
1499
|
+
account_id: r,
|
|
1500
|
+
public_key: s
|
|
1501
1501
|
}
|
|
1502
1502
|
}))
|
|
1503
1503
|
try {
|
|
@@ -1511,7 +1511,7 @@ const nr = ({
|
|
|
1511
1511
|
type: "FunctionCall",
|
|
1512
1512
|
params: {
|
|
1513
1513
|
methodName: "add_public_key",
|
|
1514
|
-
args: { public_key:
|
|
1514
|
+
args: { public_key: s },
|
|
1515
1515
|
gas: "100000000000000",
|
|
1516
1516
|
deposit: "1"
|
|
1517
1517
|
}
|
|
@@ -1526,12 +1526,12 @@ const nr = ({
|
|
|
1526
1526
|
meta: { message: "Unable to add public key to intents account" }
|
|
1527
1527
|
});
|
|
1528
1528
|
}
|
|
1529
|
-
},
|
|
1530
|
-
const { ctx: t } =
|
|
1529
|
+
}, as = ({ providers: e }) => {
|
|
1530
|
+
const { ctx: t } = N(), { appName: s, intentsAccountType: r } = E(), {
|
|
1531
1531
|
isNativeNearDeposit: n,
|
|
1532
1532
|
isDirectNearTokenWithdrawal: a,
|
|
1533
1533
|
isDirectNonNearWithdrawal: l
|
|
1534
|
-
} =
|
|
1534
|
+
} = G();
|
|
1535
1535
|
return { make: async ({
|
|
1536
1536
|
message: d,
|
|
1537
1537
|
onPending: u
|
|
@@ -1554,19 +1554,19 @@ const nr = ({
|
|
|
1554
1554
|
}
|
|
1555
1555
|
});
|
|
1556
1556
|
let o;
|
|
1557
|
-
if (!
|
|
1557
|
+
if (!r)
|
|
1558
1558
|
throw new g({
|
|
1559
1559
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1560
1560
|
meta: { message: "Intents account type is not defined" }
|
|
1561
1561
|
});
|
|
1562
|
-
switch (
|
|
1562
|
+
switch (r) {
|
|
1563
1563
|
case "evm":
|
|
1564
1564
|
if (!e?.evm)
|
|
1565
1565
|
throw new g({
|
|
1566
1566
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1567
1567
|
meta: { message: "No EVM provider configured" }
|
|
1568
1568
|
});
|
|
1569
|
-
o = new
|
|
1569
|
+
o = new ts(
|
|
1570
1570
|
{ walletAddress: t.walletAddress },
|
|
1571
1571
|
e.evm
|
|
1572
1572
|
);
|
|
@@ -1588,16 +1588,16 @@ const nr = ({
|
|
|
1588
1588
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1589
1589
|
meta: { message: "No NEAR provider configured" }
|
|
1590
1590
|
});
|
|
1591
|
-
await
|
|
1591
|
+
await ss(e.near(), t.walletAddress), o = ns({
|
|
1592
1592
|
walletAddress: t.walletAddress,
|
|
1593
1593
|
getProvider: e.near
|
|
1594
1594
|
});
|
|
1595
1595
|
break;
|
|
1596
1596
|
}
|
|
1597
1597
|
default:
|
|
1598
|
-
be(
|
|
1598
|
+
be(r);
|
|
1599
1599
|
}
|
|
1600
|
-
const m = new Kn({ referral: at(
|
|
1600
|
+
const m = new Kn({ referral: at(s) });
|
|
1601
1601
|
m.setIntentSigner(o);
|
|
1602
1602
|
let T;
|
|
1603
1603
|
n ? T = void 0 : a ? T = Hn(d ?? void 0) : l ? T = void 0 : T = Gn();
|
|
@@ -1605,7 +1605,7 @@ const nr = ({
|
|
|
1605
1605
|
withdrawalParams: {
|
|
1606
1606
|
assetId: t.sourceToken.assetId,
|
|
1607
1607
|
amount: BigInt(t.sourceTokenAmount),
|
|
1608
|
-
destinationAddress:
|
|
1608
|
+
destinationAddress: rs(
|
|
1609
1609
|
t,
|
|
1610
1610
|
a || l
|
|
1611
1611
|
),
|
|
@@ -1638,30 +1638,30 @@ const nr = ({
|
|
|
1638
1638
|
});
|
|
1639
1639
|
}
|
|
1640
1640
|
} };
|
|
1641
|
-
},
|
|
1641
|
+
}, os = ({
|
|
1642
1642
|
message: e,
|
|
1643
1643
|
providers: t,
|
|
1644
|
-
makeTransfer:
|
|
1644
|
+
makeTransfer: s
|
|
1645
1645
|
}) => {
|
|
1646
|
-
const { ctx:
|
|
1646
|
+
const { ctx: r } = N(), {
|
|
1647
1647
|
isDirectTokenOnNearDeposit: n,
|
|
1648
1648
|
isDirectTokenOnNearTransfer: a,
|
|
1649
1649
|
isNativeNearDeposit: l
|
|
1650
|
-
} =
|
|
1651
|
-
makeTransfer:
|
|
1650
|
+
} = G(), { make: i } = as({ providers: t }), { make: d } = es({
|
|
1651
|
+
makeTransfer: s,
|
|
1652
1652
|
providers: t
|
|
1653
|
-
}), { make: u } =
|
|
1653
|
+
}), { make: u } = Jr(
|
|
1654
1654
|
t?.near
|
|
1655
1655
|
);
|
|
1656
1656
|
return { make: async () => {
|
|
1657
|
-
if (!
|
|
1657
|
+
if (!r.targetToken)
|
|
1658
1658
|
return;
|
|
1659
1659
|
let m;
|
|
1660
1660
|
try {
|
|
1661
1661
|
if (p("transferSetStatus", {
|
|
1662
1662
|
status: "pending",
|
|
1663
1663
|
reason: "WAITING_CONFIRMATION"
|
|
1664
|
-
}),
|
|
1664
|
+
}), r.sourceToken?.isIntent)
|
|
1665
1665
|
m = await i({
|
|
1666
1666
|
message: e,
|
|
1667
1667
|
onPending: (T) => {
|
|
@@ -1671,19 +1671,19 @@ const nr = ({
|
|
|
1671
1671
|
});
|
|
1672
1672
|
}
|
|
1673
1673
|
});
|
|
1674
|
-
else if ((l || n) && !
|
|
1674
|
+
else if ((l || n) && !r.isDepositFromExternalWallet)
|
|
1675
1675
|
m = await u(
|
|
1676
|
-
|
|
1676
|
+
r.sendAddress ?? Ie,
|
|
1677
1677
|
e
|
|
1678
1678
|
);
|
|
1679
1679
|
else if (a) {
|
|
1680
|
-
if (!
|
|
1680
|
+
if (!r.sendAddress)
|
|
1681
1681
|
throw new g({
|
|
1682
1682
|
code: "TRANSFER_INVALID_INITIAL",
|
|
1683
1683
|
meta: { message: "No recipient address to transfer" }
|
|
1684
1684
|
});
|
|
1685
1685
|
m = await u(
|
|
1686
|
-
|
|
1686
|
+
r.sendAddress,
|
|
1687
1687
|
e
|
|
1688
1688
|
);
|
|
1689
1689
|
} else
|
|
@@ -1697,36 +1697,36 @@ const nr = ({
|
|
|
1697
1697
|
}
|
|
1698
1698
|
return p("transferSetStatus", { status: "success" }), O("transfer_success"), m;
|
|
1699
1699
|
} };
|
|
1700
|
-
},
|
|
1700
|
+
}, is = async (e) => {
|
|
1701
1701
|
if (!e)
|
|
1702
1702
|
return;
|
|
1703
1703
|
const t = await e.request({
|
|
1704
1704
|
method: "eth_chainId"
|
|
1705
1705
|
});
|
|
1706
1706
|
return parseInt(t, 16);
|
|
1707
|
-
},
|
|
1708
|
-
const { ctx: t } =
|
|
1707
|
+
}, cs = ({ providers: e }) => {
|
|
1708
|
+
const { ctx: t } = N(), [s, r] = se(!1), [n, a] = se(!1), l = fe(async () => {
|
|
1709
1709
|
const d = typeof e?.evm == "function" ? await e.evm() : e?.evm;
|
|
1710
1710
|
if (!t.sourceToken || !d)
|
|
1711
1711
|
return !1;
|
|
1712
|
-
const u = await
|
|
1713
|
-
if (!
|
|
1712
|
+
const u = await is(d);
|
|
1713
|
+
if (!V(t.sourceToken.blockchain))
|
|
1714
1714
|
return !1;
|
|
1715
1715
|
const o = pe[t.sourceToken.blockchain];
|
|
1716
1716
|
return !o || !u ? !1 : u !== o;
|
|
1717
1717
|
}, [t.sourceToken, e]), i = fe(async () => {
|
|
1718
1718
|
const d = typeof e?.evm == "function" ? await e.evm() : e?.evm;
|
|
1719
|
-
if (!t.sourceToken || !d || !
|
|
1719
|
+
if (!t.sourceToken || !d || !V(t.sourceToken.blockchain))
|
|
1720
1720
|
return !1;
|
|
1721
1721
|
const u = pe[t.sourceToken.blockchain];
|
|
1722
1722
|
if (!u)
|
|
1723
1723
|
return !1;
|
|
1724
1724
|
try {
|
|
1725
|
-
return
|
|
1725
|
+
return r(!0), await Xn(u, d), !0;
|
|
1726
1726
|
} catch (o) {
|
|
1727
1727
|
return b.error("Failed to switch chain:", o), !1;
|
|
1728
1728
|
} finally {
|
|
1729
|
-
|
|
1729
|
+
r(!1);
|
|
1730
1730
|
}
|
|
1731
1731
|
}, [t.sourceToken, e]);
|
|
1732
1732
|
return R(() => {
|
|
@@ -1734,31 +1734,31 @@ const nr = ({
|
|
|
1734
1734
|
}, [l]), {
|
|
1735
1735
|
isSwitchingChainRequired: n,
|
|
1736
1736
|
switchChain: i,
|
|
1737
|
-
isSwitchingChain:
|
|
1737
|
+
isSwitchingChain: s
|
|
1738
1738
|
};
|
|
1739
|
-
},
|
|
1739
|
+
}, _ = {
|
|
1740
1740
|
size: "lg",
|
|
1741
1741
|
variant: "primary"
|
|
1742
1742
|
}, xe = (e) => {
|
|
1743
|
-
const { t } =
|
|
1743
|
+
const { t } = H();
|
|
1744
1744
|
if (e.error?.code === "TOKEN_IS_NOT_SUPPORTED")
|
|
1745
|
-
return /* @__PURE__ */ c(
|
|
1745
|
+
return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.invalidAddress", "Invalid address") });
|
|
1746
1746
|
if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_EMPTY")
|
|
1747
|
-
return /* @__PURE__ */ c(
|
|
1747
|
+
return /* @__PURE__ */ c(A, { state: "disabled", ..._, children: t("submit.disabled.enterRecipientAddress", "Enter recipient address") });
|
|
1748
1748
|
if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_NOT_FOUND")
|
|
1749
|
-
return /* @__PURE__ */ c(
|
|
1749
|
+
return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.sendAddressNotFound", {
|
|
1750
1750
|
defaultValue: "Address not found on {{chain}}",
|
|
1751
1751
|
chain: e.error.meta.chain.toUpperCase()
|
|
1752
1752
|
}) });
|
|
1753
1753
|
if (e.state === "initial_wallet" && e.error?.code === "SEND_ADDRESS_IS_INVALID")
|
|
1754
|
-
return /* @__PURE__ */ c(
|
|
1754
|
+
return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.sendAddressInvalid", {
|
|
1755
1755
|
defaultValue: "Invalid {{chain}} address",
|
|
1756
1756
|
chain: e.error.meta.chain.toUpperCase()
|
|
1757
1757
|
}) });
|
|
1758
1758
|
if (e.error?.code === "QUOTE_AMOUNT_IS_TOO_LOW")
|
|
1759
1759
|
return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1760
|
-
/* @__PURE__ */ c(
|
|
1761
|
-
/* @__PURE__ */ c(
|
|
1760
|
+
/* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.amountTooLow.label", "Amount is too low") }),
|
|
1761
|
+
/* @__PURE__ */ c($, { children: /* @__PURE__ */ k(Mt, { i18nKey: "submit.error.amountTooLow.message", children: [
|
|
1762
1762
|
"Amount you entered is very low. Please try increasing it",
|
|
1763
1763
|
" ",
|
|
1764
1764
|
/* @__PURE__ */ k("span", { className: "text-nowrap", children: [
|
|
@@ -1772,63 +1772,81 @@ const nr = ({
|
|
|
1772
1772
|
] });
|
|
1773
1773
|
if (e.quoteStatus === "error")
|
|
1774
1774
|
return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1775
|
-
/* @__PURE__ */ c(
|
|
1776
|
-
/* @__PURE__ */ c(
|
|
1775
|
+
/* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.quoteFailed.label", "Quote failed") }),
|
|
1776
|
+
/* @__PURE__ */ c($, { children: t(
|
|
1777
1777
|
"submit.error.quoteFailed.message",
|
|
1778
1778
|
"We couldn’t finalize your quote. Please try again or adjust your values."
|
|
1779
1779
|
) })
|
|
1780
1780
|
] });
|
|
1781
1781
|
if (e.error?.code === "TRANSFER_INVALID_INITIAL")
|
|
1782
1782
|
return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1783
|
-
/* @__PURE__ */ c(
|
|
1784
|
-
e.error.meta?.message ? /* @__PURE__ */ c(
|
|
1783
|
+
/* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.invalidTransferData.label", "Invalid transfer data") }),
|
|
1784
|
+
e.error.meta?.message ? /* @__PURE__ */ c($, { children: e.error.meta.message }) : null
|
|
1785
|
+
] });
|
|
1786
|
+
if (e.error?.code === "EXTERNAL_TRANSFER_FAILED")
|
|
1787
|
+
return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.externalTransferFailed.label", "Transfer failed") });
|
|
1788
|
+
if (e.error?.code === "EXTERNAL_TRANSFER_INCOMPLETE")
|
|
1789
|
+
return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1790
|
+
/* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.externalTransferFailed.label", "Transfer failed") }),
|
|
1791
|
+
/* @__PURE__ */ c($, { children: t(
|
|
1792
|
+
"submit.error.externalTransferFailed.incompleteMessage",
|
|
1793
|
+
"Incomplete transfer. Deposited amount will be refunded."
|
|
1794
|
+
) })
|
|
1795
|
+
] });
|
|
1796
|
+
if (e.error?.code === "EXTERNAL_TRANSFER_REFUNDED")
|
|
1797
|
+
return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1798
|
+
/* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.externalTransferFailed.label", "Transfer failed") }),
|
|
1799
|
+
/* @__PURE__ */ c($, { children: t(
|
|
1800
|
+
"submit.error.externalTransferFailed.refundedMessage",
|
|
1801
|
+
"Deposited amount will be refunded."
|
|
1802
|
+
) })
|
|
1785
1803
|
] });
|
|
1786
1804
|
if (e.error?.code === "DIRECT_TRANSFER_ERROR")
|
|
1787
1805
|
return /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1788
|
-
/* @__PURE__ */ c(
|
|
1789
|
-
e.error.meta?.message ? /* @__PURE__ */ c(
|
|
1806
|
+
/* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.transferFailed.label", "Transfer failed") }),
|
|
1807
|
+
e.error.meta?.message ? /* @__PURE__ */ c($, { children: e.error.meta.message }) : null
|
|
1790
1808
|
] });
|
|
1791
1809
|
if (e.error?.code === "SOURCE_BALANCE_INSUFFICIENT")
|
|
1792
|
-
return /* @__PURE__ */ c(
|
|
1793
|
-
},
|
|
1794
|
-
const { t } =
|
|
1795
|
-
return /* @__PURE__ */ c(
|
|
1796
|
-
},
|
|
1797
|
-
const { ctx: e } =
|
|
1810
|
+
return /* @__PURE__ */ c(A, { state: "error", ..._, children: t("submit.error.insufficientBalance", "Insufficient balance") });
|
|
1811
|
+
}, ls = ({ onClick: e }) => {
|
|
1812
|
+
const { t } = H();
|
|
1813
|
+
return /* @__PURE__ */ c(A, { state: "disabled", ..._, onClick: e, children: t("submit.error.connectWallet", "Connect wallet") });
|
|
1814
|
+
}, ds = () => {
|
|
1815
|
+
const { ctx: e } = N();
|
|
1798
1816
|
return xe(e) ?? null;
|
|
1799
|
-
},
|
|
1800
|
-
const { providers: t, makeTransfer:
|
|
1817
|
+
}, us = (e) => {
|
|
1818
|
+
const { providers: t, makeTransfer: s, onSuccess: r } = e, { ctx: n } = N(), { t: a } = H(), {
|
|
1801
1819
|
isNativeNearDeposit: l,
|
|
1802
1820
|
isDirectNonNearWithdrawal: i,
|
|
1803
1821
|
isDirectTokenOnNearDeposit: d,
|
|
1804
1822
|
isDirectNearTokenWithdrawal: u
|
|
1805
|
-
} =
|
|
1823
|
+
} = G(), { make: o } = os({ providers: t, makeTransfer: s }), { isSwitchingChainRequired: m, switchChain: T, isSwitchingChain: h } = cs({ providers: t }), f = xe(n), I = async () => {
|
|
1806
1824
|
if (m && !await T())
|
|
1807
1825
|
return;
|
|
1808
1826
|
const S = await o();
|
|
1809
|
-
S &&
|
|
1827
|
+
S && r(S);
|
|
1810
1828
|
};
|
|
1811
1829
|
if (!n.targetToken)
|
|
1812
|
-
return /* @__PURE__ */ c(
|
|
1813
|
-
if (!
|
|
1814
|
-
return /* @__PURE__ */ c(
|
|
1830
|
+
return /* @__PURE__ */ c(A, { ..._, state: "disabled", children: a("submit.disabled.selectTokenToReceive", "Select token to receive") });
|
|
1831
|
+
if (!ne(n.sourceTokenAmount))
|
|
1832
|
+
return /* @__PURE__ */ c(A, { ..._, state: "disabled", children: a("submit.disabled.enterAmount", "Enter amount") });
|
|
1815
1833
|
if (n.areInputsValidating)
|
|
1816
|
-
return /* @__PURE__ */ c(
|
|
1834
|
+
return /* @__PURE__ */ c(A, { state: "loading", ..._, children: a("submit.pending.validating", "Validating...") });
|
|
1817
1835
|
if (h)
|
|
1818
|
-
return /* @__PURE__ */ c(
|
|
1836
|
+
return /* @__PURE__ */ c(A, { state: "loading", ..._, children: a("submit.pending.switchingChain", "Switching network...") });
|
|
1819
1837
|
if (!m && f)
|
|
1820
1838
|
return f;
|
|
1821
1839
|
if (n.transferStatus.status === "pending")
|
|
1822
1840
|
switch (n.transferStatus.reason) {
|
|
1823
1841
|
case "WAITING_CONFIRMATION":
|
|
1824
|
-
return /* @__PURE__ */ c(
|
|
1842
|
+
return /* @__PURE__ */ c(A, { state: "loading", ..._, children: a("submit.pending.transfer.confirmInWallet", "Confirm in wallet") });
|
|
1825
1843
|
case "PROCESSING":
|
|
1826
1844
|
default:
|
|
1827
|
-
return /* @__PURE__ */ c(
|
|
1845
|
+
return /* @__PURE__ */ c(A, { state: "loading", ..._, children: a("submit.pending.transfer.finalizing", "Finalizing transfer") });
|
|
1828
1846
|
}
|
|
1829
1847
|
return n.transferStatus.status === "error" ? /* @__PURE__ */ k("div", { className: "gap-sw-md flex flex-col", children: [
|
|
1830
|
-
/* @__PURE__ */ c(
|
|
1831
|
-
/* @__PURE__ */ c(
|
|
1848
|
+
/* @__PURE__ */ c(A, { ..._, children: e.label }),
|
|
1849
|
+
/* @__PURE__ */ c($, { children: (() => {
|
|
1832
1850
|
switch (n.error?.code) {
|
|
1833
1851
|
case "FEES_NOT_ESTIMATED":
|
|
1834
1852
|
return a(
|
|
@@ -1842,36 +1860,36 @@ const nr = ({
|
|
|
1842
1860
|
);
|
|
1843
1861
|
}
|
|
1844
1862
|
})() })
|
|
1845
|
-
] }) : n.quoteStatus === "pending" ? /* @__PURE__ */ c(
|
|
1846
|
-
},
|
|
1847
|
-
const { t } =
|
|
1848
|
-
return
|
|
1849
|
-
},
|
|
1850
|
-
const { ctx: t } =
|
|
1851
|
-
return t.walletAddress ? /* @__PURE__ */ c(
|
|
1863
|
+
] }) : n.quoteStatus === "pending" ? /* @__PURE__ */ c(A, { state: "loading", ..._, children: n.quote ? a("submit.pending.quote.refreshing", "Refreshing quote") : a("submit.pending.quote.finalizing", "Finalizing quote") }) : n.error ? /* @__PURE__ */ c(A, { state: "disabled", ..._, children: e.label }) : !n.quote && !i && !d && !u && !l ? /* @__PURE__ */ c(A, { state: "disabled", ..._, children: e.label }) : /* @__PURE__ */ c(A, { ..._, onClick: I, children: e.label });
|
|
1864
|
+
}, ms = (e) => {
|
|
1865
|
+
const { t } = H(), { ctx: s } = N(), r = xe(s);
|
|
1866
|
+
return s.isDepositFromExternalWallet ? ne(s.sourceTokenAmount) ? s.externalDepositTxReceived ? /* @__PURE__ */ c(A, { state: "loading", ..._, children: t("submit.pending.externalDeposit.processing", "Processing") }) : /* @__PURE__ */ c(A, { state: "loading", ..._, children: t("submit.pending.externalDeposit.waiting", "Waiting for transaction") }) : /* @__PURE__ */ c(A, { ..._, state: "disabled", children: t("submit.disabled.enterAmount", "Enter amount") }) : r || /* @__PURE__ */ c(us, { ...e });
|
|
1867
|
+
}, fs = (e) => {
|
|
1868
|
+
const { ctx: t } = N(), s = E();
|
|
1869
|
+
return t.walletAddress ? /* @__PURE__ */ c(ms, { ...e }) : /* @__PURE__ */ c(ls, { onClick: s.onWalletSignin });
|
|
1852
1870
|
};
|
|
1853
|
-
|
|
1854
|
-
const
|
|
1855
|
-
const { t } =
|
|
1856
|
-
return
|
|
1857
|
-
|
|
1871
|
+
fs.Error = ds;
|
|
1872
|
+
const ps = ({ className: e }) => {
|
|
1873
|
+
const { t } = H(), { slippageTolerance: s } = E(), { ctx: r } = N(), n = r.sourceToken && r.targetToken && r.sourceToken.price / r.targetToken.price;
|
|
1874
|
+
return r.sourceToken ? /* @__PURE__ */ c(
|
|
1875
|
+
Jn,
|
|
1858
1876
|
{
|
|
1859
1877
|
expandedByDefault: !1,
|
|
1860
|
-
expandedHeightPx:
|
|
1861
|
-
isBadgeLoading:
|
|
1862
|
-
badge:
|
|
1878
|
+
expandedHeightPx: r.walletAddress ? 80 : 50,
|
|
1879
|
+
isBadgeLoading: r.quoteStatus === "pending",
|
|
1880
|
+
badge: r.quote ? `~ ${r.quote.timeEstimate} sec` : void 0,
|
|
1863
1881
|
className: e,
|
|
1864
|
-
title:
|
|
1865
|
-
`1 ${
|
|
1882
|
+
title: r.sourceToken && r.targetToken ? /* @__PURE__ */ k("span", { style: { borderBottomWidth: "2px", borderStyle: "dotted" }, children: [
|
|
1883
|
+
`1 ${r.sourceToken.symbol} ≈ `,
|
|
1866
1884
|
" ",
|
|
1867
|
-
|
|
1885
|
+
er(n ?? 0),
|
|
1868
1886
|
" ",
|
|
1869
|
-
`${
|
|
1870
|
-
/* @__PURE__ */ c("span", { className: "text-sw-gray-50", children: `(${
|
|
1887
|
+
`${r.targetToken.symbol}`,
|
|
1888
|
+
/* @__PURE__ */ c("span", { className: "text-sw-gray-50", children: `(${Ve(r.sourceToken.price)})` })
|
|
1871
1889
|
] }) : /* @__PURE__ */ k("span", { style: { borderBottomWidth: "2px", borderStyle: "dotted" }, children: [
|
|
1872
|
-
`1 ${
|
|
1890
|
+
`1 ${r.sourceToken.symbol} ≈ `,
|
|
1873
1891
|
" ",
|
|
1874
|
-
|
|
1892
|
+
Ve(r.sourceToken.price),
|
|
1875
1893
|
" USD"
|
|
1876
1894
|
] }),
|
|
1877
1895
|
children: /* @__PURE__ */ k(le, { children: [
|
|
@@ -1879,38 +1897,38 @@ const pr = ({ className: e }) => {
|
|
|
1879
1897
|
le.Item,
|
|
1880
1898
|
{
|
|
1881
1899
|
label: t("quote.result.maxSlippage.label", "Max slippage"),
|
|
1882
|
-
value: `${(
|
|
1900
|
+
value: `${(s / 100).toFixed(2)}%`
|
|
1883
1901
|
}
|
|
1884
1902
|
),
|
|
1885
|
-
!!
|
|
1903
|
+
!!r.walletAddress && /* @__PURE__ */ c(
|
|
1886
1904
|
le.Item,
|
|
1887
1905
|
{
|
|
1888
|
-
isLoading:
|
|
1906
|
+
isLoading: r.quoteStatus === "pending",
|
|
1889
1907
|
label: t("quote.result.processingTime.label", "Processing time"),
|
|
1890
|
-
value:
|
|
1908
|
+
value: r.quote ? `${r.quote.timeEstimate} sec.` : "—"
|
|
1891
1909
|
}
|
|
1892
1910
|
)
|
|
1893
1911
|
] })
|
|
1894
1912
|
}
|
|
1895
1913
|
) : /* @__PURE__ */ c(ft, {});
|
|
1896
|
-
}, wi = Object.assign(
|
|
1914
|
+
}, wi = Object.assign(ps, {
|
|
1897
1915
|
Skeleton: ft
|
|
1898
|
-
}),
|
|
1916
|
+
}), Ts = ({
|
|
1899
1917
|
token: e,
|
|
1900
1918
|
balance: t,
|
|
1901
|
-
isNotSufficient:
|
|
1902
|
-
onClick:
|
|
1919
|
+
isNotSufficient: s = !1,
|
|
1920
|
+
onClick: r
|
|
1903
1921
|
}) => {
|
|
1904
1922
|
const n = E();
|
|
1905
|
-
return !e.isIntent && !n.walletSupportedChains.includes(e.blockchain) ? /* @__PURE__ */ c("span", {}) : t === void 0 ? /* @__PURE__ */ c(
|
|
1923
|
+
return !e.isIntent && !n.walletSupportedChains.includes(e.blockchain) ? /* @__PURE__ */ c("span", {}) : t === void 0 ? /* @__PURE__ */ c(nr, { width: 100 }) : /* @__PURE__ */ c(
|
|
1906
1924
|
"span",
|
|
1907
1925
|
{
|
|
1908
|
-
onClick: t ?
|
|
1926
|
+
onClick: t ? r : void 0,
|
|
1909
1927
|
style: t ? { borderBottomWidth: "2px", borderStyle: "dotted" } : void 0,
|
|
1910
|
-
className:
|
|
1911
|
-
"text-sw-status-error":
|
|
1912
|
-
"text-sw-gray-100": !
|
|
1913
|
-
"cursor-pointer": !!t && !!
|
|
1928
|
+
className: tr("text-sw-label-sm", {
|
|
1929
|
+
"text-sw-status-error": s,
|
|
1930
|
+
"text-sw-gray-100": !s,
|
|
1931
|
+
"cursor-pointer": !!t && !!r
|
|
1914
1932
|
}),
|
|
1915
1933
|
children: /* @__PURE__ */ c(
|
|
1916
1934
|
ve,
|
|
@@ -1924,8 +1942,8 @@ const pr = ({ className: e }) => {
|
|
|
1924
1942
|
}, Fe = ({
|
|
1925
1943
|
token: e,
|
|
1926
1944
|
balance: t,
|
|
1927
|
-
value:
|
|
1928
|
-
quoteUsdDelta:
|
|
1945
|
+
value: s = "",
|
|
1946
|
+
quoteUsdDelta: r,
|
|
1929
1947
|
quoteUsdValue: n,
|
|
1930
1948
|
state: a = "default",
|
|
1931
1949
|
showBalance: l = !0,
|
|
@@ -1933,10 +1951,10 @@ const pr = ({ className: e }) => {
|
|
|
1933
1951
|
heading: d,
|
|
1934
1952
|
onMsg: u
|
|
1935
1953
|
}) => {
|
|
1936
|
-
const o = xt(), { ctx: m } =
|
|
1954
|
+
const o = xt(), { ctx: m } = N(), { t: T } = H(), { hideTokenInputHeadings: h } = E(), f = sr(e, s, n), I = (S) => {
|
|
1937
1955
|
u({
|
|
1938
1956
|
type: "on_change_amount",
|
|
1939
|
-
amount:
|
|
1957
|
+
amount: rr(t, e.decimals, S)
|
|
1940
1958
|
});
|
|
1941
1959
|
};
|
|
1942
1960
|
return /* @__PURE__ */ k(Tt, { className: "flex flex-col", "aria-label": d, children: [
|
|
@@ -1944,17 +1962,17 @@ const pr = ({ className: e }) => {
|
|
|
1944
1962
|
/* @__PURE__ */ k(
|
|
1945
1963
|
"div",
|
|
1946
1964
|
{
|
|
1947
|
-
className:
|
|
1965
|
+
className: j(
|
|
1948
1966
|
"flex items-center justify-between",
|
|
1949
1967
|
!h && "mt-sw-2xl"
|
|
1950
1968
|
),
|
|
1951
1969
|
children: [
|
|
1952
1970
|
/* @__PURE__ */ c(
|
|
1953
|
-
|
|
1971
|
+
or,
|
|
1954
1972
|
{
|
|
1955
|
-
value:
|
|
1973
|
+
value: s,
|
|
1956
1974
|
name: o,
|
|
1957
|
-
setValue:
|
|
1975
|
+
setValue: ar,
|
|
1958
1976
|
placeholder: "0",
|
|
1959
1977
|
state: a === "default" || a === "disabled" ? a : "error",
|
|
1960
1978
|
onChange: (S) => {
|
|
@@ -1967,7 +1985,7 @@ const pr = ({ className: e }) => {
|
|
|
1967
1985
|
{
|
|
1968
1986
|
type: "button",
|
|
1969
1987
|
onClick: a === "disabled" ? void 0 : () => u({ type: "on_click_select_token" }),
|
|
1970
|
-
className:
|
|
1988
|
+
className: j(
|
|
1971
1989
|
"gap-sw-md pl-sw-sm pr-sw-md flex h-[36px] min-w-[80px] shrink-0 items-center rounded-sw-md transition-colors bg-sw-gray-800 hover:bg-sw-gray-700 group",
|
|
1972
1990
|
{
|
|
1973
1991
|
"cursor-pointer": a !== "disabled",
|
|
@@ -1993,22 +2011,22 @@ const pr = ({ className: e }) => {
|
|
|
1993
2011
|
/* @__PURE__ */ k("div", { className: "gap-sw-sm min-h-sw-2xl flex items-center justify-between mt-sw-lg", children: [
|
|
1994
2012
|
/* @__PURE__ */ k("div", { className: "gap-sw-md flex items-center", children: [
|
|
1995
2013
|
/* @__PURE__ */ c("span", { className: "text-sw-label-sm text-sw-gray-100", children: f }),
|
|
1996
|
-
|
|
2014
|
+
r ? /* @__PURE__ */ c(
|
|
1997
2015
|
"span",
|
|
1998
2016
|
{
|
|
1999
|
-
className:
|
|
2000
|
-
"text-sw-gray-400":
|
|
2001
|
-
"text-sw-status-success":
|
|
2002
|
-
"text-sw-status-error":
|
|
2003
|
-
"text-sw-status-warning":
|
|
2017
|
+
className: j("text-sw-label-sm text-nowrap", {
|
|
2018
|
+
"text-sw-gray-400": r >= -2 && r <= 2,
|
|
2019
|
+
"text-sw-status-success": r > 2,
|
|
2020
|
+
"text-sw-status-error": r <= -5,
|
|
2021
|
+
"text-sw-status-warning": r < -2 && r > -5
|
|
2004
2022
|
}),
|
|
2005
|
-
children: `${
|
|
2023
|
+
children: `${r > 0 ? "+" : ""}${r.toFixed(2)}%`
|
|
2006
2024
|
}
|
|
2007
2025
|
) : null
|
|
2008
2026
|
] }),
|
|
2009
2027
|
/* @__PURE__ */ k("div", { className: "gap-sw-sm flex items-center", children: [
|
|
2010
2028
|
e && !!m.walletAddress && l && /* @__PURE__ */ c(
|
|
2011
|
-
|
|
2029
|
+
Ts,
|
|
2012
2030
|
{
|
|
2013
2031
|
token: e,
|
|
2014
2032
|
balance: t,
|
|
@@ -2039,7 +2057,7 @@ const pr = ({ className: e }) => {
|
|
|
2039
2057
|
] })
|
|
2040
2058
|
] });
|
|
2041
2059
|
}, Le = ({ onMsg: e, heading: t }) => {
|
|
2042
|
-
const { hideTokenInputHeadings:
|
|
2060
|
+
const { hideTokenInputHeadings: s } = E();
|
|
2043
2061
|
return /* @__PURE__ */ k(
|
|
2044
2062
|
Tt,
|
|
2045
2063
|
{
|
|
@@ -2047,13 +2065,13 @@ const pr = ({ className: e }) => {
|
|
|
2047
2065
|
className: "flex flex-col",
|
|
2048
2066
|
onClick: () => e({ type: "on_click_select_token" }),
|
|
2049
2067
|
children: [
|
|
2050
|
-
!
|
|
2068
|
+
!s && /* @__PURE__ */ c(pt, { children: t }),
|
|
2051
2069
|
/* @__PURE__ */ k(
|
|
2052
2070
|
"div",
|
|
2053
2071
|
{
|
|
2054
|
-
className:
|
|
2072
|
+
className: j(
|
|
2055
2073
|
"flex items-center justify-between",
|
|
2056
|
-
!
|
|
2074
|
+
!s && "mt-sw-2xl"
|
|
2057
2075
|
),
|
|
2058
2076
|
children: [
|
|
2059
2077
|
/* @__PURE__ */ c(
|
|
@@ -2081,40 +2099,40 @@ const pr = ({ className: e }) => {
|
|
|
2081
2099
|
}
|
|
2082
2100
|
);
|
|
2083
2101
|
}, Nt = (e) => {
|
|
2084
|
-
const { mergedBalance: t } = ce(), [
|
|
2085
|
-
e ? t[
|
|
2102
|
+
const { mergedBalance: t } = ce(), [s, r] = se(
|
|
2103
|
+
e ? t[K(e)] : void 0
|
|
2086
2104
|
);
|
|
2087
2105
|
return R(() => {
|
|
2088
2106
|
let n;
|
|
2089
2107
|
if (e) {
|
|
2090
|
-
const a = t[
|
|
2108
|
+
const a = t[K(e)];
|
|
2091
2109
|
a ? n = setTimeout(() => {
|
|
2092
|
-
|
|
2110
|
+
r(a);
|
|
2093
2111
|
}, 0) : n = setTimeout(() => {
|
|
2094
|
-
|
|
2095
|
-
e ? t[
|
|
2112
|
+
r(
|
|
2113
|
+
e ? t[K(e)] ?? 0 : 0
|
|
2096
2114
|
);
|
|
2097
2115
|
}, 2e3);
|
|
2098
2116
|
}
|
|
2099
2117
|
return () => {
|
|
2100
2118
|
n && clearTimeout(n);
|
|
2101
2119
|
};
|
|
2102
|
-
}, [e, t]),
|
|
2120
|
+
}, [e, t]), s;
|
|
2103
2121
|
}, Et = (e, t) => {
|
|
2104
|
-
const { tokens:
|
|
2105
|
-
new Set(
|
|
2122
|
+
const { tokens: s } = P(e), r = Array.from(
|
|
2123
|
+
new Set(s.map((n) => n.assetId))
|
|
2106
2124
|
);
|
|
2107
2125
|
R(() => {
|
|
2108
|
-
const n =
|
|
2126
|
+
const n = r.length === 1 ? s[0] : null;
|
|
2109
2127
|
n && t({ type: "on_select_token", token: n });
|
|
2110
|
-
}, [
|
|
2111
|
-
},
|
|
2128
|
+
}, [s]);
|
|
2129
|
+
}, hs = ({
|
|
2112
2130
|
onMsg: e,
|
|
2113
2131
|
isChanging: t = !0,
|
|
2114
|
-
showBalance:
|
|
2115
|
-
heading:
|
|
2132
|
+
showBalance: s = !0,
|
|
2133
|
+
heading: r
|
|
2116
2134
|
}) => {
|
|
2117
|
-
const { ctx: n } =
|
|
2135
|
+
const { ctx: n } = N(), a = Nt(n.sourceToken);
|
|
2118
2136
|
Et("source", e);
|
|
2119
2137
|
const l = x(() => {
|
|
2120
2138
|
if (!t && n.quoteStatus === "pending")
|
|
@@ -2129,64 +2147,64 @@ const pr = ({ className: e }) => {
|
|
|
2129
2147
|
return n.sourceToken ? /* @__PURE__ */ c(
|
|
2130
2148
|
Fe,
|
|
2131
2149
|
{
|
|
2132
|
-
heading:
|
|
2150
|
+
heading: r,
|
|
2133
2151
|
token: n.sourceToken,
|
|
2134
2152
|
state: l,
|
|
2135
2153
|
balance: a,
|
|
2136
|
-
showBalance:
|
|
2154
|
+
showBalance: s,
|
|
2137
2155
|
showQuickBalanceActions: !0,
|
|
2138
|
-
value:
|
|
2156
|
+
value: Y(n.sourceTokenAmount, n.sourceToken?.decimals),
|
|
2139
2157
|
onMsg: e
|
|
2140
2158
|
}
|
|
2141
|
-
) : /* @__PURE__ */ c(Le, { heading:
|
|
2142
|
-
},
|
|
2159
|
+
) : /* @__PURE__ */ c(Le, { heading: r, onMsg: e });
|
|
2160
|
+
}, gs = ({
|
|
2143
2161
|
isChanging: e = !1,
|
|
2144
2162
|
onMsg: t,
|
|
2145
|
-
heading:
|
|
2163
|
+
heading: s
|
|
2146
2164
|
}) => {
|
|
2147
|
-
const { ctx:
|
|
2165
|
+
const { ctx: r } = N(), { usdTradeDelta: n } = G(), a = Nt(r.targetToken);
|
|
2148
2166
|
Et("target", t);
|
|
2149
|
-
const l = x(() => !e &&
|
|
2150
|
-
return
|
|
2167
|
+
const l = x(() => !e && r.quoteStatus === "pending" ? "disabled" : "default", [e, r.quoteStatus]);
|
|
2168
|
+
return r.targetToken ? /* @__PURE__ */ c(
|
|
2151
2169
|
Fe,
|
|
2152
2170
|
{
|
|
2153
|
-
heading:
|
|
2154
|
-
token:
|
|
2171
|
+
heading: s,
|
|
2172
|
+
token: r.targetToken,
|
|
2155
2173
|
balance: a,
|
|
2156
2174
|
quoteUsdDelta: n?.percentage,
|
|
2157
|
-
quoteUsdValue:
|
|
2158
|
-
value:
|
|
2175
|
+
quoteUsdValue: r.quote && parseFloat(r.quote.amountOutUsd),
|
|
2176
|
+
value: Y(r.targetTokenAmount, r.targetToken?.decimals),
|
|
2159
2177
|
state: l,
|
|
2160
2178
|
showQuickBalanceActions: !1,
|
|
2161
2179
|
showBalance: !0,
|
|
2162
2180
|
onMsg: t
|
|
2163
2181
|
}
|
|
2164
|
-
) : /* @__PURE__ */ c(Le, { heading:
|
|
2165
|
-
},
|
|
2166
|
-
Skeleton:
|
|
2167
|
-
Source:
|
|
2168
|
-
Target:
|
|
2182
|
+
) : /* @__PURE__ */ c(Le, { heading: s, onMsg: t });
|
|
2183
|
+
}, Is = ({ token: e, heading: t, ...s }) => e ? /* @__PURE__ */ c(Fe, { ...s, token: e, heading: t }) : /* @__PURE__ */ c(Le, { onMsg: s.onMsg, heading: t }), ki = Object.assign(Is, {
|
|
2184
|
+
Skeleton: ir,
|
|
2185
|
+
Source: hs,
|
|
2186
|
+
Target: gs
|
|
2169
2187
|
}), Ze = 58, bt = ({
|
|
2170
2188
|
token: e,
|
|
2171
2189
|
balance: t,
|
|
2172
|
-
showBalance:
|
|
2173
|
-
isNotSelectable:
|
|
2190
|
+
showBalance: s = !0,
|
|
2191
|
+
isNotSelectable: r,
|
|
2174
2192
|
className: n,
|
|
2175
2193
|
onMsg: a
|
|
2176
2194
|
}) => {
|
|
2177
|
-
const { ctx: l } =
|
|
2195
|
+
const { ctx: l } = N(), { walletSupportedChains: i, appName: d } = E(), u = cr(t, e), o = i.includes(e.blockchain) || e.isIntent, m = t !== "0" && t !== 0 && t !== void 0;
|
|
2178
2196
|
return /* @__PURE__ */ c("li", { className: "list-none group", children: /* @__PURE__ */ k(
|
|
2179
2197
|
"div",
|
|
2180
2198
|
{
|
|
2181
|
-
className:
|
|
2199
|
+
className: j(
|
|
2182
2200
|
"gap-sw-lg p-sw-lg flex justify-between rounded-sw-md transition-colors",
|
|
2183
2201
|
{
|
|
2184
|
-
"cursor-not-allowed":
|
|
2185
|
-
"cursor-pointer hover:bg-sw-gray-800": !
|
|
2202
|
+
"cursor-not-allowed": r,
|
|
2203
|
+
"cursor-pointer hover:bg-sw-gray-800": !r
|
|
2186
2204
|
},
|
|
2187
2205
|
n
|
|
2188
2206
|
),
|
|
2189
|
-
onClick: () => !
|
|
2207
|
+
onClick: () => !r && a({ type: "on_select_token", token: e }),
|
|
2190
2208
|
children: [
|
|
2191
2209
|
/* @__PURE__ */ c(
|
|
2192
2210
|
ht,
|
|
@@ -2208,7 +2226,7 @@ const pr = ({ className: e }) => {
|
|
|
2208
2226
|
/* @__PURE__ */ c("span", { className: "text-sw-label-sm text-sw-gray-300", children: `on ${e.chainName}` })
|
|
2209
2227
|
] })
|
|
2210
2228
|
] }),
|
|
2211
|
-
o && !!l.walletAddress &&
|
|
2229
|
+
o && !!l.walletAddress && s && /* @__PURE__ */ k("div", { className: "gap-sw-xs flex flex-col items-end", children: [
|
|
2212
2230
|
t === void 0 && !e.isIntent ? /* @__PURE__ */ c("span", { className: "h-[16px] w-[60px] animate-pulse rounded-full bg-sw-gray-700" }) : /* @__PURE__ */ c("span", { className: "h-[16px] text-sw-label-md text-sw-gray-50", children: m && /* @__PURE__ */ c(
|
|
2213
2231
|
ve,
|
|
2214
2232
|
{
|
|
@@ -2221,7 +2239,7 @@ const pr = ({ className: e }) => {
|
|
|
2221
2239
|
]
|
|
2222
2240
|
}
|
|
2223
2241
|
) });
|
|
2224
|
-
},
|
|
2242
|
+
}, Xe = [
|
|
2225
2243
|
"nep141:eth-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near",
|
|
2226
2244
|
// cbBTC (eth)
|
|
2227
2245
|
"nep141:base-0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf.omft.near",
|
|
@@ -2234,32 +2252,32 @@ const pr = ({ className: e }) => {
|
|
|
2234
2252
|
// NEAR (bsc)
|
|
2235
2253
|
"nep141:eth-0xe0f63a424a4439cbe457d80e4f4b51ad25b2c56c.omft.near"
|
|
2236
2254
|
// SPX (eth)
|
|
2237
|
-
],
|
|
2255
|
+
], ws = () => {
|
|
2238
2256
|
const { tokens: e } = P();
|
|
2239
2257
|
return {
|
|
2240
2258
|
uniqueIntentsTokens: x(() => {
|
|
2241
2259
|
const t = e.filter(
|
|
2242
|
-
(n) => n.isIntent && n.blockchain === "near" && !
|
|
2243
|
-
),
|
|
2244
|
-
return [...t, ...
|
|
2260
|
+
(n) => n.isIntent && n.blockchain === "near" && !Xe.includes(n.assetId)
|
|
2261
|
+
), s = t.map((n) => n.isIntent && n.symbol), r = e.filter((n) => n.isIntent && n.blockchain !== "near" && !s.includes(n.symbol) && !Xe.includes(n.assetId));
|
|
2262
|
+
return [...t, ...r];
|
|
2245
2263
|
}, [e])
|
|
2246
2264
|
};
|
|
2247
|
-
},
|
|
2265
|
+
}, ks = ({
|
|
2248
2266
|
variant: e,
|
|
2249
2267
|
search: t,
|
|
2250
|
-
selectedChain:
|
|
2251
|
-
chainsFilter:
|
|
2268
|
+
selectedChain: s,
|
|
2269
|
+
chainsFilter: r,
|
|
2252
2270
|
walletSupportedChains: n
|
|
2253
2271
|
}) => {
|
|
2254
|
-
|
|
2255
|
-
const { tokens: a } = P(e), { mergedBalance: l } = ce(), { intentBalances: i } = ie(), { uniqueIntentsTokens: d } =
|
|
2272
|
+
xr(e);
|
|
2273
|
+
const { tokens: a } = P(e), { mergedBalance: l } = ce(), { intentBalances: i } = ie(), { uniqueIntentsTokens: d } = ws(), u = ur(
|
|
2256
2274
|
l,
|
|
2257
2275
|
n,
|
|
2258
2276
|
t
|
|
2259
|
-
), o = a.filter(
|
|
2260
|
-
|
|
2261
|
-
selectedChain:
|
|
2262
|
-
chainsFilter:
|
|
2277
|
+
), o = a.filter(mr({ search: t })).filter(
|
|
2278
|
+
fr({
|
|
2279
|
+
selectedChain: s,
|
|
2280
|
+
chainsFilter: r,
|
|
2263
2281
|
walletSupportedChains: n,
|
|
2264
2282
|
intentBalances: i,
|
|
2265
2283
|
uniqueIntentTokenIds: d.map((m) => m.assetId)
|
|
@@ -2270,24 +2288,24 @@ const pr = ({ className: e }) => {
|
|
|
2270
2288
|
intents: o.filter($e({ isIntent: !0 })).sort(u),
|
|
2271
2289
|
wallet: o.filter($e({ isIntent: !1 })).sort(u)
|
|
2272
2290
|
};
|
|
2273
|
-
},
|
|
2291
|
+
}, Ss = (e, t) => e.length === 0 && t ? "EMPTY_SEARCH" : e.length === 0 && !t ? "NO_TOKENS" : "HAS_TOKENS", As = ({
|
|
2274
2292
|
variant: e,
|
|
2275
2293
|
search: t,
|
|
2276
|
-
className:
|
|
2277
|
-
groupTokens:
|
|
2294
|
+
className: s,
|
|
2295
|
+
groupTokens: r,
|
|
2278
2296
|
showBalances: n,
|
|
2279
2297
|
chainsFilter: a,
|
|
2280
2298
|
selectedChain: l,
|
|
2281
2299
|
chainIsNotSupported: i,
|
|
2282
2300
|
onMsg: d
|
|
2283
2301
|
}) => {
|
|
2284
|
-
const { t: u } =
|
|
2302
|
+
const { t: u } = H(), { ctx: o } = N(), { walletSupportedChains: m, appName: T } = E(), { mergedBalance: h } = ce(), f = ks({
|
|
2285
2303
|
variant: e,
|
|
2286
2304
|
search: t,
|
|
2287
2305
|
chainsFilter: a,
|
|
2288
2306
|
selectedChain: l,
|
|
2289
2307
|
walletSupportedChains: m
|
|
2290
|
-
}), I = o.walletAddress ?
|
|
2308
|
+
}), I = o.walletAddress ? r : !1, S = Ss(f.all, t), y = x(
|
|
2291
2309
|
() => [{ label: null, tokens: f.all }],
|
|
2292
2310
|
[f.all]
|
|
2293
2311
|
), B = x(
|
|
@@ -2321,8 +2339,8 @@ const pr = ({ className: e }) => {
|
|
|
2321
2339
|
}
|
|
2322
2340
|
);
|
|
2323
2341
|
case "HAS_TOKENS":
|
|
2324
|
-
return /* @__PURE__ */ c("div", { className:
|
|
2325
|
-
|
|
2342
|
+
return /* @__PURE__ */ c("div", { className: j("gap-sw-lg flex flex-col", s), children: /* @__PURE__ */ c(
|
|
2343
|
+
lr,
|
|
2326
2344
|
{
|
|
2327
2345
|
className: "hide-scrollbar",
|
|
2328
2346
|
style: {
|
|
@@ -2333,15 +2351,15 @@ const pr = ({ className: e }) => {
|
|
|
2333
2351
|
children: (I ? B : y).map(
|
|
2334
2352
|
({ label: w, tokens: v }) => /* @__PURE__ */ k(Ft, { children: [
|
|
2335
2353
|
v.length && w ? /* @__PURE__ */ k("header", { className: "pb-sw-lg flex flex-col", children: [
|
|
2336
|
-
/* @__PURE__ */ c(
|
|
2354
|
+
/* @__PURE__ */ c(dr, {}),
|
|
2337
2355
|
/* @__PURE__ */ c("span", { className: "text-sw-label-sm pt-sw-xl text-sw-gray-100", children: `${w} — ${v.length}` })
|
|
2338
2356
|
] }) : null,
|
|
2339
|
-
v.map((
|
|
2340
|
-
const J =
|
|
2357
|
+
v.map((X) => {
|
|
2358
|
+
const J = K(X);
|
|
2341
2359
|
return /* @__PURE__ */ c(
|
|
2342
2360
|
bt,
|
|
2343
2361
|
{
|
|
2344
|
-
token:
|
|
2362
|
+
token: X,
|
|
2345
2363
|
showBalance: n,
|
|
2346
2364
|
balance: h[J],
|
|
2347
2365
|
isNotSelectable: i && !!o.walletAddress,
|
|
@@ -2372,11 +2390,11 @@ const pr = ({ className: e }) => {
|
|
|
2372
2390
|
}
|
|
2373
2391
|
);
|
|
2374
2392
|
}
|
|
2375
|
-
}, Si = Object.assign(
|
|
2393
|
+
}, Si = Object.assign(As, {
|
|
2376
2394
|
Placeholder: ke,
|
|
2377
2395
|
Item: bt
|
|
2378
|
-
}),
|
|
2379
|
-
const
|
|
2396
|
+
}), _s = (e, t) => {
|
|
2397
|
+
const s = t.assetId.substring(t.assetId.indexOf(":") + 1), r = (a) => {
|
|
2380
2398
|
const l = (u) => u.replace(/(\.\d*?[1-9])0+$/, "$1").replace(/\.0+$/, ""), i = l(t.amount), d = l(
|
|
2381
2399
|
a.amount.toLocaleString("en-US", {
|
|
2382
2400
|
useGrouping: !1,
|
|
@@ -2386,15 +2404,16 @@ const pr = ({ className: e }) => {
|
|
|
2386
2404
|
return i.startsWith(d) || d.startsWith(i);
|
|
2387
2405
|
}, n = (a) => new Date(a.created_at) >= new Date(t.initiatedAtDate);
|
|
2388
2406
|
return (e.result.deposits || []).find(
|
|
2389
|
-
(a) => a.chain === t.chainId && a.account_id === t.intentsAccountId && a.address === t.depositAddress && a.near_token_id ===
|
|
2407
|
+
(a) => a.chain === t.chainId && a.account_id === t.intentsAccountId && a.address === t.depositAddress && a.near_token_id === s && n(a) && r(a)
|
|
2390
2408
|
);
|
|
2391
|
-
},
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2409
|
+
}, Ns = {
|
|
2410
|
+
CREDITED: ee.status.PROCESSING,
|
|
2411
|
+
PENDING: ee.status.PROCESSING,
|
|
2412
|
+
COMPLETED: ee.status.SUCCESS,
|
|
2413
|
+
FAILED: ee.status.FAILED
|
|
2395
2414
|
}, Ai = ({ depositAddress: e }) => {
|
|
2396
|
-
const { ctx: t } =
|
|
2397
|
-
addressType:
|
|
2415
|
+
const { ctx: t } = N(), { intentsAccountType: s } = E(), [r, n] = se(null), a = te({
|
|
2416
|
+
addressType: s,
|
|
2398
2417
|
walletAddress: t.walletAddress
|
|
2399
2418
|
});
|
|
2400
2419
|
return { pollDepositStatus: async ({
|
|
@@ -2404,16 +2423,16 @@ const pr = ({ className: e }) => {
|
|
|
2404
2423
|
}) => {
|
|
2405
2424
|
if (!a)
|
|
2406
2425
|
throw new W("Unknown intents account for POA deposit check");
|
|
2407
|
-
let o =
|
|
2426
|
+
let o = rt[i];
|
|
2408
2427
|
if (!o)
|
|
2409
|
-
if (
|
|
2410
|
-
o =
|
|
2428
|
+
if (V(i))
|
|
2429
|
+
o = st;
|
|
2411
2430
|
else
|
|
2412
2431
|
throw new W(
|
|
2413
2432
|
`Unknown chain for POA deposit check ${i}`
|
|
2414
2433
|
);
|
|
2415
|
-
const m =
|
|
2416
|
-
|
|
2434
|
+
const m = r ?? (/* @__PURE__ */ new Date()).toUTCString();
|
|
2435
|
+
r || n(m);
|
|
2417
2436
|
const T = await ct.post("", {
|
|
2418
2437
|
id: 1,
|
|
2419
2438
|
jsonrpc: "2.0",
|
|
@@ -2424,7 +2443,7 @@ const pr = ({ className: e }) => {
|
|
|
2424
2443
|
chain: o
|
|
2425
2444
|
}
|
|
2426
2445
|
]
|
|
2427
|
-
}), h =
|
|
2446
|
+
}), h = _s(T.data, {
|
|
2428
2447
|
intentsAccountId: a,
|
|
2429
2448
|
initiatedAtDate: m,
|
|
2430
2449
|
depositAddress: e,
|
|
@@ -2433,45 +2452,45 @@ const pr = ({ className: e }) => {
|
|
|
2433
2452
|
amount: d
|
|
2434
2453
|
});
|
|
2435
2454
|
return h ? {
|
|
2436
|
-
status:
|
|
2455
|
+
status: Ns[h.status],
|
|
2437
2456
|
swapDetails: {
|
|
2438
2457
|
intentHashes: [""],
|
|
2439
2458
|
destinationChainTxHashes: [{ hash: h.tx_hash ?? "" }]
|
|
2440
2459
|
}
|
|
2441
2460
|
} : {
|
|
2442
|
-
status:
|
|
2461
|
+
status: ee.status.PENDING_DEPOSIT,
|
|
2443
2462
|
swapDetails: {
|
|
2444
2463
|
destinationChainTxHashes: [{ hash: "" }],
|
|
2445
2464
|
intentHashes: [""]
|
|
2446
2465
|
}
|
|
2447
2466
|
};
|
|
2448
2467
|
} };
|
|
2449
|
-
},
|
|
2468
|
+
}, Es = (e) => null, bs = (e) => (t) => {
|
|
2450
2469
|
if (t instanceof W)
|
|
2451
2470
|
throw t;
|
|
2452
|
-
const
|
|
2471
|
+
const s = new W(
|
|
2453
2472
|
t instanceof Error ? t.message : "Unknown error",
|
|
2454
2473
|
{ cause: t }
|
|
2455
2474
|
);
|
|
2456
|
-
throw
|
|
2457
|
-
},
|
|
2458
|
-
const { ctx: t } =
|
|
2475
|
+
throw s.context = e, s;
|
|
2476
|
+
}, ys = ({ children: e }) => {
|
|
2477
|
+
const { ctx: t } = N();
|
|
2459
2478
|
return /* @__PURE__ */ c(
|
|
2460
|
-
|
|
2479
|
+
gr,
|
|
2461
2480
|
{
|
|
2462
|
-
FallbackComponent:
|
|
2463
|
-
onError:
|
|
2481
|
+
FallbackComponent: Es,
|
|
2482
|
+
onError: bs(t),
|
|
2464
2483
|
children: e
|
|
2465
2484
|
}
|
|
2466
2485
|
);
|
|
2467
|
-
},
|
|
2486
|
+
}, Rs = new Pt({
|
|
2468
2487
|
defaultOptions: {
|
|
2469
2488
|
queries: {
|
|
2470
2489
|
staleTime: 2e3 * 60,
|
|
2471
|
-
retry:
|
|
2490
|
+
retry: Je.env.NODE_ENV === "test" ? !1 : 3
|
|
2472
2491
|
}
|
|
2473
2492
|
}
|
|
2474
|
-
}),
|
|
2493
|
+
}), Ds = ["fms", "abg", "stjack", "noear", "testnebula"], ae = {
|
|
2475
2494
|
appName: "Unknown",
|
|
2476
2495
|
appIcon: "https://wtmcxrwapthiogjpxwfr.supabase.co/storage/v1/object/public/swap-widget/unknown.svg",
|
|
2477
2496
|
slippageTolerance: 100,
|
|
@@ -2482,7 +2501,7 @@ const pr = ({ className: e }) => {
|
|
|
2482
2501
|
enableAutoTokensSwitching: !0,
|
|
2483
2502
|
showIntentTokens: !0,
|
|
2484
2503
|
chainsOrder: nt,
|
|
2485
|
-
filterTokens: (e) => !
|
|
2504
|
+
filterTokens: (e) => !Ds.includes(e.symbol.toLocaleLowerCase()),
|
|
2486
2505
|
chainsFilter: {
|
|
2487
2506
|
source: { external: "wallet-supported", intents: "none" },
|
|
2488
2507
|
target: { external: "all", intents: "none" }
|
|
@@ -2494,18 +2513,18 @@ const pr = ({ className: e }) => {
|
|
|
2494
2513
|
}), E = () => {
|
|
2495
2514
|
const e = Lt(yt);
|
|
2496
2515
|
return oe(e).config;
|
|
2497
|
-
},
|
|
2516
|
+
}, Cs = (e) => {
|
|
2498
2517
|
Be.config = me(e);
|
|
2499
2518
|
}, _i = ({
|
|
2500
2519
|
children: e,
|
|
2501
2520
|
config: t,
|
|
2502
|
-
balanceViaRpc:
|
|
2521
|
+
balanceViaRpc: s = !0,
|
|
2503
2522
|
// you don't usually want to disable it
|
|
2504
|
-
localisation:
|
|
2523
|
+
localisation: r,
|
|
2505
2524
|
rpcs: n,
|
|
2506
2525
|
theme: a
|
|
2507
2526
|
}) => {
|
|
2508
|
-
const l =
|
|
2527
|
+
const l = z(
|
|
2509
2528
|
et({
|
|
2510
2529
|
config: me({
|
|
2511
2530
|
...ae,
|
|
@@ -2518,92 +2537,92 @@ const pr = ({ className: e }) => {
|
|
|
2518
2537
|
...ae,
|
|
2519
2538
|
...t
|
|
2520
2539
|
});
|
|
2521
|
-
Object.assign(l.current.config, i),
|
|
2522
|
-
}, [t]), Qt(
|
|
2540
|
+
Object.assign(l.current.config, i), Cs(i);
|
|
2541
|
+
}, [t]), Qt(r ?? {}), hr("headlessui-portal-root", "sw"), /* @__PURE__ */ c(Wt, { client: Rs, children: /* @__PURE__ */ c(Vt, { i18n: Dt, children: /* @__PURE__ */ k(yt.Provider, { value: l.current, children: [
|
|
2523
2542
|
/* @__PURE__ */ k(Ct, { children: [
|
|
2524
2543
|
/* @__PURE__ */ k(vt, { children: [
|
|
2525
2544
|
/* @__PURE__ */ c("link", { rel: "preconnect", href: "https://rsms.me/" }),
|
|
2526
2545
|
/* @__PURE__ */ c("link", { rel: "stylesheet", href: "https://rsms.me/inter/inter.css" })
|
|
2527
2546
|
] }),
|
|
2528
|
-
/* @__PURE__ */ c(
|
|
2547
|
+
/* @__PURE__ */ c(pr, { theme: a, children: Je.env.NODE_ENV === "test" ? e : /* @__PURE__ */ c(ys, { children: e }) })
|
|
2529
2548
|
] }),
|
|
2530
|
-
|
|
2531
|
-
|
|
2549
|
+
s && /* @__PURE__ */ c(
|
|
2550
|
+
vr,
|
|
2532
2551
|
{
|
|
2533
|
-
rpcs: n ??
|
|
2552
|
+
rpcs: n ?? Tr,
|
|
2534
2553
|
connectedWallets: t.connectedWallets ?? {}
|
|
2535
2554
|
}
|
|
2536
2555
|
)
|
|
2537
2556
|
] }) }) });
|
|
2538
2557
|
};
|
|
2539
2558
|
export {
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2559
|
+
ts as $,
|
|
2560
|
+
Nr as A,
|
|
2561
|
+
vr as B,
|
|
2543
2562
|
Ke as C,
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2563
|
+
Fr as D,
|
|
2564
|
+
Lr as E,
|
|
2565
|
+
Br as F,
|
|
2566
|
+
qr as G,
|
|
2567
|
+
Wr as H,
|
|
2549
2568
|
wt as I,
|
|
2550
2569
|
kt as J,
|
|
2551
2570
|
St as K,
|
|
2552
2571
|
At as L,
|
|
2553
2572
|
_t as M,
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2573
|
+
Mr as N,
|
|
2574
|
+
Vr as O,
|
|
2575
|
+
Qr as P,
|
|
2557
2576
|
q as Q,
|
|
2558
|
-
$
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2577
|
+
$r as R,
|
|
2578
|
+
fs as S,
|
|
2579
|
+
Is as T,
|
|
2580
|
+
Kr as U,
|
|
2581
|
+
Hr as V,
|
|
2563
2582
|
_i as W,
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2583
|
+
Gr as X,
|
|
2584
|
+
jr as Y,
|
|
2585
|
+
Xr as Z,
|
|
2586
|
+
Jr as _,
|
|
2568
2587
|
Ii as a,
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2588
|
+
ns as a0,
|
|
2589
|
+
ps as a1,
|
|
2590
|
+
Ts as a2,
|
|
2572
2591
|
Fe as a3,
|
|
2573
2592
|
Le as a4,
|
|
2574
2593
|
Et as a5,
|
|
2575
|
-
|
|
2576
|
-
|
|
2594
|
+
hs as a6,
|
|
2595
|
+
gs as a7,
|
|
2577
2596
|
Ze as a8,
|
|
2578
2597
|
bt as a9,
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2598
|
+
ws as aa,
|
|
2599
|
+
As as ab,
|
|
2600
|
+
ys as ac,
|
|
2582
2601
|
Be as ad,
|
|
2583
|
-
|
|
2602
|
+
N as b,
|
|
2584
2603
|
hi as c,
|
|
2585
|
-
|
|
2586
|
-
|
|
2604
|
+
xr as d,
|
|
2605
|
+
Dr as e,
|
|
2587
2606
|
ie as f,
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2607
|
+
as as g,
|
|
2608
|
+
Pr as h,
|
|
2609
|
+
os as i,
|
|
2610
|
+
es as j,
|
|
2592
2611
|
ce as k,
|
|
2593
|
-
|
|
2594
|
-
|
|
2612
|
+
cs as l,
|
|
2613
|
+
ks as m,
|
|
2595
2614
|
P as n,
|
|
2596
2615
|
wi as o,
|
|
2597
2616
|
ki as p,
|
|
2598
2617
|
Si as q,
|
|
2599
|
-
|
|
2618
|
+
Yr as r,
|
|
2600
2619
|
Nt as s,
|
|
2601
2620
|
It as t,
|
|
2602
|
-
|
|
2621
|
+
G as u,
|
|
2603
2622
|
W as v,
|
|
2604
2623
|
g as w,
|
|
2605
2624
|
gi as x,
|
|
2606
2625
|
E as y,
|
|
2607
2626
|
Ai as z
|
|
2608
2627
|
};
|
|
2609
|
-
//# sourceMappingURL=config-
|
|
2628
|
+
//# sourceMappingURL=config-1EcDCy24.js.map
|