@aurora-is-near/intents-swap-widget 3.17.0 → 3.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Input.d.ts +8 -2
- package/dist/components/Input.js +88 -84
- package/dist/components/Input.js.map +1 -1
- package/dist/{config-BMe2x51b.js → config-CQ4V08as.js} +21 -20
- package/dist/{config-BMe2x51b.js.map → config-CQ4V08as.js.map} +1 -1
- package/dist/config.js +5 -4
- package/dist/config.js.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/ext/alchemy/index.js +1 -1
- package/dist/ext/index.js +1 -1
- package/dist/features/BalanceRpcLoader/TokenBalanceLoader.js +1 -1
- package/dist/features/BalanceRpcLoader/index.js +1 -1
- package/dist/features/BalanceRpcLoader/useTokenBalanceRpc.js +1 -1
- package/dist/features/ChainsDropdown/index.js +1 -1
- package/dist/features/DepositMethodSwitcher.js +1 -1
- package/dist/features/ErrorBoundary.js +1 -1
- package/dist/features/ExternalDeposit.js +4 -3
- 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 +63 -54
- package/dist/features/TokensModal.js.map +1 -1
- package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +2 -2
- 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/useHandleKeyDown.d.ts +1 -1
- package/dist/hooks/useHandleKeyDown.js +12 -8
- package/dist/hooks/useHandleKeyDown.js.map +1 -1
- package/dist/hooks/useIntentsBalance.js +1 -1
- package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
- package/dist/hooks/useMakeDepositAddress.js +1 -1
- package/dist/hooks/useMakeIntentsTransfer.js +1 -1
- package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
- package/dist/hooks/useMakeQuote.js +1 -1
- package/dist/hooks/useMakeQuoteTransfer.js +1 -1
- package/dist/hooks/useMakeTransfer.js +1 -1
- package/dist/hooks/useMergedBalance.js +1 -1
- package/dist/hooks/useSwitchChain.js +1 -1
- package/dist/hooks/useTheme.js +1 -1
- package/dist/hooks/useTokenInputPair.js +1 -1
- package/dist/hooks/useTokens.js +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/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/theme/ThemeProvider.js +1 -1
- package/dist/utils/intents/signers/near.js +1 -1
- package/dist/utils/intents/signers/privy.js +1 -1
- package/dist/utils/near/getNearNep141StorageBalance.js +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +4 -3
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js.map +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js +4 -3
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js.map +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +4 -3
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js.map +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
- package/package.json +1 -1
- package/src/components/Input.tsx +111 -96
- package/src/features/TokensModal.tsx +19 -2
- package/src/hooks/useHandleKeyDown.ts +25 -3
package/dist/config.js
CHANGED
|
@@ -8,7 +8,7 @@ import "react";
|
|
|
8
8
|
import "@tanstack/react-query";
|
|
9
9
|
import "react-i18next";
|
|
10
10
|
import "./localisation.js";
|
|
11
|
-
import { W as
|
|
11
|
+
import { W as M, ai as N, y as O } from "./config-CQ4V08as.js";
|
|
12
12
|
import "@headlessui/react";
|
|
13
13
|
import "framer-motion";
|
|
14
14
|
import "lucide-react";
|
|
@@ -17,6 +17,7 @@ import "./utils/cn.js";
|
|
|
17
17
|
import "@defuse-protocol/one-click-sdk-typescript";
|
|
18
18
|
import "./constants/chains.js";
|
|
19
19
|
import "use-debounce";
|
|
20
|
+
import "./components/Input.js";
|
|
20
21
|
import "viem";
|
|
21
22
|
import "ethers";
|
|
22
23
|
import "./machine/machine.js";
|
|
@@ -38,8 +39,8 @@ import "./components/Notes.js";
|
|
|
38
39
|
import "./rpcs.js";
|
|
39
40
|
import "./hooks/useAddClassToPortal.js";
|
|
40
41
|
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
M as WidgetConfigProvider,
|
|
43
|
+
N as configStore,
|
|
44
|
+
O as useConfig
|
|
44
45
|
};
|
|
45
46
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/errors.js
CHANGED
|
@@ -3,7 +3,7 @@ import "@tanstack/react-query";
|
|
|
3
3
|
import "./parse.js";
|
|
4
4
|
import "./load.js";
|
|
5
5
|
import "./types.js";
|
|
6
|
-
import { t as s } from "../../config-
|
|
6
|
+
import { t as s } from "../../config-CQ4V08as.js";
|
|
7
7
|
import "../../machine/guards/index.js";
|
|
8
8
|
import "../../machine/machine.js";
|
|
9
9
|
import "../../machine/events/utils/fireEvent.js";
|
package/dist/ext/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import "../../logger.js";
|
|
|
3
3
|
import "../../utils/ton/getTonTokenBalance.js";
|
|
4
4
|
import "../../utils/solana/getSolanaTokenBalance.js";
|
|
5
5
|
import "../../hooks/useWalletAddressForToken.js";
|
|
6
|
-
import { D as x } from "../../config-
|
|
6
|
+
import { D as x } from "../../config-CQ4V08as.js";
|
|
7
7
|
import "../../utils/evm/isEvmChain.js";
|
|
8
8
|
import "../../utils/evm/isEvmToken.js";
|
|
9
9
|
import "../../utils/evm/isEvmBaseToken.js";
|
|
@@ -5,7 +5,7 @@ import { AnimatePresence as F, motion as T } from "framer-motion";
|
|
|
5
5
|
import * as x from "lucide-react";
|
|
6
6
|
import { ChainItem as d } from "./ChainItem.js";
|
|
7
7
|
import { AllNetworksIcon as h } from "./AllNetworksIcon.js";
|
|
8
|
-
import { d as z, y as O } from "../../config-
|
|
8
|
+
import { d as z, y as O } from "../../config-CQ4V08as.js";
|
|
9
9
|
import { Hr as j } from "../../components/Hr.js";
|
|
10
10
|
import { Icon as i } from "../../components/Icon.js";
|
|
11
11
|
import { notReachable as u } from "../../utils/notReachable.js";
|
|
@@ -3,7 +3,7 @@ import * as l from "lucide-react";
|
|
|
3
3
|
import { cn as m } from "../utils/cn.js";
|
|
4
4
|
import { Card as p } from "../components/Card.js";
|
|
5
5
|
import { Button as i } from "../components/Button.js";
|
|
6
|
-
import { b as c } from "../config-
|
|
6
|
+
import { b as c } from "../config-CQ4V08as.js";
|
|
7
7
|
import "ethers";
|
|
8
8
|
import "../machine/machine.js";
|
|
9
9
|
import { fireEvent as d } from "../machine/events/utils/fireEvent.js";
|
|
@@ -12,7 +12,7 @@ import { formatAddressTruncate as _ } from "../utils/formatters/formatAddressTru
|
|
|
12
12
|
import "../utils/cn.js";
|
|
13
13
|
import { notReachable as l } from "../utils/notReachable.js";
|
|
14
14
|
import "@tanstack/react-query";
|
|
15
|
-
import { b as E, u as I } from "../config-
|
|
15
|
+
import { b as E, u as I } from "../config-CQ4V08as.js";
|
|
16
16
|
import { guardStates as k } from "../machine/guards/index.js";
|
|
17
17
|
import { moveTo as A } from "../machine/machine.js";
|
|
18
18
|
import { fireEvent as o } from "../machine/events/utils/fireEvent.js";
|
|
@@ -32,6 +32,7 @@ import "browser-or-node";
|
|
|
32
32
|
import { useTypedTranslation as S } from "../localisation.js";
|
|
33
33
|
import "@headlessui/react";
|
|
34
34
|
import { CopyButton as R } from "../components/CopyButton.js";
|
|
35
|
+
import "../components/Input.js";
|
|
35
36
|
import "../components/InputAmount.js";
|
|
36
37
|
import "../components/Notes.js";
|
|
37
38
|
import { StatusWidget as n } from "../components/StatusWidget.js";
|
|
@@ -50,7 +51,7 @@ const f = ({ address: r }) => /* @__PURE__ */ c("div", { className: "flex flex-c
|
|
|
50
51
|
/* @__PURE__ */ t("span", { className: "text-sw-gray-100 text-sw-label-sm", children: T(i.sourceTokenAmount) ? r("deposit.external.loading.fetching", "Fetching new address") : r("deposit.external.loading.waiting", "Waiting for token amount") })
|
|
51
52
|
] })
|
|
52
53
|
] });
|
|
53
|
-
},
|
|
54
|
+
}, ft = ({ onMsg: r }) => {
|
|
54
55
|
const { t: i } = S(), { ctx: s } = E(), { isNativeNearDeposit: m } = I(), p = k(s, [
|
|
55
56
|
"quote_success_external",
|
|
56
57
|
"quote_success_internal"
|
|
@@ -158,6 +159,6 @@ const f = ({ address: r }) => /* @__PURE__ */ c("div", { className: "flex flex-c
|
|
|
158
159
|
}
|
|
159
160
|
};
|
|
160
161
|
export {
|
|
161
|
-
|
|
162
|
+
ft as ExternalDeposit
|
|
162
163
|
};
|
|
163
164
|
//# sourceMappingURL=ExternalDeposit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalDeposit.js","sources":["../../src/features/ExternalDeposit.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { QRCodeSVG } from 'qrcode.react';\nimport { GetExecutionStatusResponse } from '@defuse-protocol/one-click-sdk-typescript';\nimport * as Icons from 'lucide-react';\n\nimport { notReachable } from '@/utils';\nimport { CHAIN_IDS_MAP } from '@/constants/chains';\nimport { useExternalDepositStatus } from '@/hooks';\nimport { useTypedTranslation } from '@/localisation';\nimport { CopyButton, StatusWidget } from '@/components';\nimport {\n fireEvent,\n guardStates,\n moveTo,\n useComputedSnapshot,\n useUnsafeSnapshot,\n} from '@/machine';\nimport { formatAddressTruncate } from '@/utils/formatters/formatAddressTruncate';\nimport { getTransactionLink } from '@/utils/formatters/getTransactionLink';\nimport { isNotEmptyAmount } from '@/utils/checkers/isNotEmptyAmount';\nimport type { TransferResult } from '@/types';\n\ntype Msg =\n | { type: 'on_transaction_received' }\n | { type: 'on_successful_transfer'; transferResult: TransferResult };\n\ntype Props = {\n onMsg: (msg: Msg) => void;\n};\n\nconst QrCode = ({ address }: { address: string }) => (\n <div className=\"flex flex-col gap-sw-2xl items-center\">\n <div className=\"p-sw-lg m-sw-lg mx-auto w-fit rounded-sw-md bg-[#fff]\">\n <QRCodeSVG size={156} value={address} fgColor=\"#161926\" />\n </div>\n <div className=\"py-sw-lg px-sw-lg w-full flex items-center justify-between rounded-sw-md bg-sw-gray-800\">\n <span className=\"text-sw-label-md text-sw-gray-100\">\n {formatAddressTruncate(address, 38)}\n </span>\n <CopyButton value={address} />\n </div>\n </div>\n);\n\nconst Skeleton = () => {\n const { t } = useTypedTranslation();\n const { ctx } = useUnsafeSnapshot();\n\n return (\n <div className=\"flex flex-col gap-sw-2xl items-center\">\n <div className=\"bg-sw-gray-800 h-[180px] w-[180px] animate-pulse rounded-sw-md\" />\n <div className=\"bg-sw-gray-800 h-[44px] w-full animate-pulse rounded-sw-md flex items-center justify-center gap-sw-sm\">\n <Icons.Loader className=\"animate-spin text-sw-gray-100 h-sw-lg w-sw-lg\" />\n <span className=\"text-sw-gray-100 text-sw-label-sm\">\n {!isNotEmptyAmount(ctx.sourceTokenAmount)\n ? t('deposit.external.loading.waiting', 'Waiting for token amount')\n : t('deposit.external.loading.fetching', 'Fetching new address')}\n </span>\n </div>\n </div>\n );\n};\n\nexport const ExternalDeposit = ({ onMsg }: Props) => {\n const { t } = useTypedTranslation();\n const { ctx } = useUnsafeSnapshot();\n const { isNativeNearDeposit } = useComputedSnapshot();\n\n const isValidState = guardStates(ctx, [\n 'quote_success_external',\n 'quote_success_internal',\n ]);\n\n const isBridgePoaDeposit =\n (isNativeNearDeposit && ctx.isDepositFromExternalWallet) ||\n (!isNativeNearDeposit &&\n ctx.sourceToken?.assetId === ctx.targetToken?.assetId);\n\n const depositStatusQuery = useExternalDepositStatus({\n depositAddress: isValidState ? ctx.quote.depositAddress : '',\n depositAddressType: isBridgePoaDeposit ? 'poa' : 'one_click',\n });\n\n useEffect(() => {\n const status = depositStatusQuery.data?.status;\n\n if (!depositStatusQuery.data) {\n return;\n }\n\n switch (status) {\n case GetExecutionStatusResponse.status.SUCCESS: {\n const txHash =\n depositStatusQuery.data.swapDetails.destinationChainTxHashes[0]?.hash;\n\n fireEvent('transferSetStatus', { status: 'success' });\n moveTo('transfer_success');\n\n onMsg({\n type: 'on_successful_transfer',\n transferResult: {\n hash: txHash ?? '',\n intent: depositStatusQuery.data.swapDetails.intentHashes[0],\n transactionLink:\n (ctx.sourceToken &&\n txHash &&\n getTransactionLink(\n CHAIN_IDS_MAP[ctx.sourceToken.blockchain],\n txHash,\n )) ??\n '',\n },\n });\n break;\n }\n\n case GetExecutionStatusResponse.status.FAILED:\n fireEvent('transferSetStatus', { status: 'error' });\n fireEvent('errorSet', { code: 'EXTERNAL_TRANSFER_FAILED' });\n break;\n case GetExecutionStatusResponse.status.INCOMPLETE_DEPOSIT:\n fireEvent('transferSetStatus', { status: 'error' });\n fireEvent('errorSet', { code: 'EXTERNAL_TRANSFER_INCOMPLETE' });\n break;\n case GetExecutionStatusResponse.status.REFUNDED:\n fireEvent('transferSetStatus', { status: 'error' });\n fireEvent('errorSet', { code: 'EXTERNAL_TRANSFER_REFUNDED' });\n break;\n case GetExecutionStatusResponse.status.PROCESSING:\n case GetExecutionStatusResponse.status.KNOWN_DEPOSIT_TX:\n // Transaction was received from external wallet\n fireEvent('externalDepositTxSet', true);\n onMsg({ type: 'on_transaction_received' });\n break;\n case GetExecutionStatusResponse.status.PENDING_DEPOSIT:\n case undefined:\n // No action needed - waiting for deposit\n break;\n default:\n notReachable(status);\n }\n // do not include onMsg to avoid infinite loop\n }, [depositStatusQuery.data, ctx.sourceToken]);\n\n if (!isValidState) {\n return <Skeleton />;\n }\n\n if (!depositStatusQuery.data) {\n return <QrCode address={ctx.quote.depositAddress} />;\n }\n\n switch (depositStatusQuery.status) {\n case 'error':\n return (\n <StatusWidget.Error\n message={t(\n 'deposit.external.error.noStatus',\n 'Unable to check transfer status',\n )}\n />\n );\n\n case 'success': {\n switch (depositStatusQuery.data.status) {\n case GetExecutionStatusResponse.status.FAILED:\n return (\n <StatusWidget.Error\n message={t(\n 'deposit.external.error.noStatus',\n 'Unable to check transfer status',\n )}\n />\n );\n case GetExecutionStatusResponse.status.INCOMPLETE_DEPOSIT:\n return (\n <StatusWidget.Error\n message={t(\n 'deposit.external.error.incomplete',\n 'Incomplete deposit',\n )}\n />\n );\n case GetExecutionStatusResponse.status.REFUNDED:\n return (\n <StatusWidget.Error\n message={t(\n 'deposit.external.error.failed',\n 'Deposit failed. You were refunded.',\n )}\n />\n );\n case GetExecutionStatusResponse.status.PROCESSING:\n case GetExecutionStatusResponse.status.KNOWN_DEPOSIT_TX:\n return <StatusWidget.Success />;\n case GetExecutionStatusResponse.status.PENDING_DEPOSIT:\n return <QrCode address={ctx.quote.depositAddress} />;\n case GetExecutionStatusResponse.status.SUCCESS:\n return <StatusWidget.Success />;\n default:\n return null;\n }\n }\n\n default:\n return notReachable(depositStatusQuery);\n }\n};\n"],"names":["QrCode","address","jsxs","jsx","QRCodeSVG","formatAddressTruncate","CopyButton","Skeleton","t","useTypedTranslation","ctx","useUnsafeSnapshot","Icons","isNotEmptyAmount","ExternalDeposit","onMsg","isNativeNearDeposit","useComputedSnapshot","isValidState","guardStates","isBridgePoaDeposit","depositStatusQuery","useExternalDepositStatus","useEffect","status","GetExecutionStatusResponse","txHash","fireEvent","moveTo","getTransactionLink","CHAIN_IDS_MAP","notReachable","StatusWidget"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMA,IAAS,CAAC,EAAE,SAAAC,QAChB,gBAAAC,EA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gB;AAAA,QACpD,KAAKe,EAA2B,OAAO;AACrC,iBAAO,gBAAAtB,EAAC6B,EAAa,SAAb,EAAqB;AAAA,QAC/B;AACE,iBAAO;AAAA,MAAA;AAAA,IAIb;AACE,aAAOD,EAAaV,CAAkB;AAAA,EAAA;AAE5C;"}
|
|
1
|
+
{"version":3,"file":"ExternalDeposit.js","sources":["../../src/features/ExternalDeposit.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { QRCodeSVG } from 'qrcode.react';\nimport { GetExecutionStatusResponse } from '@defuse-protocol/one-click-sdk-typescript';\nimport * as Icons from 'lucide-react';\n\nimport { notReachable } from '@/utils';\nimport { CHAIN_IDS_MAP } from '@/constants/chains';\nimport { useExternalDepositStatus } from '@/hooks';\nimport { useTypedTranslation } from '@/localisation';\nimport { CopyButton, StatusWidget } from '@/components';\nimport {\n fireEvent,\n guardStates,\n moveTo,\n useComputedSnapshot,\n useUnsafeSnapshot,\n} from '@/machine';\nimport { formatAddressTruncate } from '@/utils/formatters/formatAddressTruncate';\nimport { getTransactionLink } from '@/utils/formatters/getTransactionLink';\nimport { isNotEmptyAmount } from '@/utils/checkers/isNotEmptyAmount';\nimport type { TransferResult } from '@/types';\n\ntype Msg =\n | { type: 'on_transaction_received' }\n | { type: 'on_successful_transfer'; transferResult: TransferResult };\n\ntype Props = {\n onMsg: (msg: Msg) => void;\n};\n\nconst QrCode = ({ address }: { address: string }) => (\n <div className=\"flex flex-col gap-sw-2xl items-center\">\n <div className=\"p-sw-lg m-sw-lg mx-auto w-fit rounded-sw-md bg-[#fff]\">\n <QRCodeSVG size={156} value={address} fgColor=\"#161926\" />\n </div>\n <div className=\"py-sw-lg px-sw-lg w-full flex items-center justify-between rounded-sw-md bg-sw-gray-800\">\n <span className=\"text-sw-label-md text-sw-gray-100\">\n {formatAddressTruncate(address, 38)}\n </span>\n <CopyButton value={address} />\n </div>\n </div>\n);\n\nconst Skeleton = () => {\n const { t } = useTypedTranslation();\n const { ctx } = useUnsafeSnapshot();\n\n return (\n <div className=\"flex flex-col gap-sw-2xl items-center\">\n <div className=\"bg-sw-gray-800 h-[180px] w-[180px] animate-pulse rounded-sw-md\" />\n <div className=\"bg-sw-gray-800 h-[44px] w-full animate-pulse rounded-sw-md flex items-center justify-center gap-sw-sm\">\n <Icons.Loader className=\"animate-spin text-sw-gray-100 h-sw-lg w-sw-lg\" />\n <span className=\"text-sw-gray-100 text-sw-label-sm\">\n {!isNotEmptyAmount(ctx.sourceTokenAmount)\n ? t('deposit.external.loading.waiting', 'Waiting for token amount')\n : t('deposit.external.loading.fetching', 'Fetching new address')}\n </span>\n </div>\n </div>\n );\n};\n\nexport const ExternalDeposit = ({ onMsg }: Props) => {\n const { t } = useTypedTranslation();\n const { ctx } = useUnsafeSnapshot();\n const { isNativeNearDeposit } = useComputedSnapshot();\n\n const isValidState = guardStates(ctx, [\n 'quote_success_external',\n 'quote_success_internal',\n ]);\n\n const isBridgePoaDeposit =\n (isNativeNearDeposit && ctx.isDepositFromExternalWallet) ||\n (!isNativeNearDeposit &&\n ctx.sourceToken?.assetId === ctx.targetToken?.assetId);\n\n const depositStatusQuery = useExternalDepositStatus({\n depositAddress: isValidState ? ctx.quote.depositAddress : '',\n depositAddressType: isBridgePoaDeposit ? 'poa' : 'one_click',\n });\n\n useEffect(() => {\n const status = depositStatusQuery.data?.status;\n\n if (!depositStatusQuery.data) {\n return;\n }\n\n switch (status) {\n case GetExecutionStatusResponse.status.SUCCESS: {\n const txHash =\n depositStatusQuery.data.swapDetails.destinationChainTxHashes[0]?.hash;\n\n fireEvent('transferSetStatus', { status: 'success' });\n moveTo('transfer_success');\n\n onMsg({\n type: 'on_successful_transfer',\n transferResult: {\n hash: txHash ?? '',\n intent: depositStatusQuery.data.swapDetails.intentHashes[0],\n transactionLink:\n (ctx.sourceToken &&\n txHash &&\n getTransactionLink(\n CHAIN_IDS_MAP[ctx.sourceToken.blockchain],\n txHash,\n )) ??\n '',\n },\n });\n break;\n }\n\n case GetExecutionStatusResponse.status.FAILED:\n fireEvent('transferSetStatus', { status: 'error' });\n fireEvent('errorSet', { code: 'EXTERNAL_TRANSFER_FAILED' });\n break;\n case GetExecutionStatusResponse.status.INCOMPLETE_DEPOSIT:\n fireEvent('transferSetStatus', { status: 'error' });\n fireEvent('errorSet', { code: 'EXTERNAL_TRANSFER_INCOMPLETE' });\n break;\n case GetExecutionStatusResponse.status.REFUNDED:\n fireEvent('transferSetStatus', { status: 'error' });\n fireEvent('errorSet', { code: 'EXTERNAL_TRANSFER_REFUNDED' });\n break;\n case GetExecutionStatusResponse.status.PROCESSING:\n case GetExecutionStatusResponse.status.KNOWN_DEPOSIT_TX:\n // Transaction was received from external wallet\n fireEvent('externalDepositTxSet', true);\n onMsg({ type: 'on_transaction_received' });\n break;\n case GetExecutionStatusResponse.status.PENDING_DEPOSIT:\n case undefined:\n // No action needed - waiting for deposit\n break;\n default:\n notReachable(status);\n }\n // do not include onMsg to avoid infinite loop\n }, [depositStatusQuery.data, ctx.sourceToken]);\n\n if (!isValidState) {\n return <Skeleton />;\n }\n\n if (!depositStatusQuery.data) {\n return <QrCode address={ctx.quote.depositAddress} />;\n }\n\n switch (depositStatusQuery.status) {\n case 'error':\n return (\n <StatusWidget.Error\n message={t(\n 'deposit.external.error.noStatus',\n 'Unable to check transfer status',\n )}\n />\n );\n\n case 'success': {\n switch (depositStatusQuery.data.status) {\n case GetExecutionStatusResponse.status.FAILED:\n return (\n <StatusWidget.Error\n message={t(\n 'deposit.external.error.noStatus',\n 'Unable to check transfer status',\n )}\n />\n );\n case GetExecutionStatusResponse.status.INCOMPLETE_DEPOSIT:\n return (\n <StatusWidget.Error\n message={t(\n 'deposit.external.error.incomplete',\n 'Incomplete deposit',\n )}\n />\n );\n case GetExecutionStatusResponse.status.REFUNDED:\n return (\n <StatusWidget.Error\n message={t(\n 'deposit.external.error.failed',\n 'Deposit failed. You were refunded.',\n )}\n />\n );\n case GetExecutionStatusResponse.status.PROCESSING:\n case GetExecutionStatusResponse.status.KNOWN_DEPOSIT_TX:\n return <StatusWidget.Success />;\n case GetExecutionStatusResponse.status.PENDING_DEPOSIT:\n return <QrCode address={ctx.quote.depositAddress} />;\n case GetExecutionStatusResponse.status.SUCCESS:\n return <StatusWidget.Success />;\n default:\n return null;\n }\n }\n\n default:\n return notReachable(depositStatusQuery);\n }\n};\n"],"names":["QrCode","address","jsxs","jsx","QRCodeSVG","formatAddressTruncate","CopyButton","Skeleton","t","useTypedTranslation","ctx","useUnsafeSnapshot","Icons","isNotEmptyAmount","ExternalDeposit","onMsg","isNativeNearDeposit","useComputedSnapshot","isValidState","guardStates","isBridgePoaDeposit","depositStatusQuery","useExternalDepositStatus","useEffect","status","GetExecutionStatusResponse","txHash","fireEvent","moveTo","getTransactionLink","CHAIN_IDS_MAP","notReachable","StatusWidget"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMA,IAAS,CAAC,EAAE,SAAAC,QAChB,gBAAAC,EAAC,OAAA,EAAI,WAAU,yCACb,UAAA;AAAA,EAAA,gBAAAC,EAAC,OAAA,EAAI,WAAU,yDACb,UAAA,gBAAAA,EAACC,GAAA,EAAU,MAAM,KAAK,OAAOH,GAAS,SAAQ,UAAA,CAAU,GAC1D;AAAA,EACA,gBAAAC,EAAC,OAAA,EAAI,WAAU,2FACb,UAAA;AAAA,IAAA,gBAAAC,EAAC,UAAK,WAAU,qCACb,UAAAE,EAAsBJ,GAAS,EAAE,GACpC;AAAA,IACA,gBAAAE,EAACG,GAAA,EAAW,OAAOL,EAAA,CAAS;AAAA,EAAA,EAAA,CAC9B;AAAA,GACF,GAGIM,IAAW,MAAM;AACrB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACR,EAAE,KAAAC,EAAA,IAAQC,EAAA;AAEhB,SACE,gBAAAT,EAAC,OAAA,EAAI,WAAU,yCACb,UAAA;AAAA,IAAA,gBAAAC,EAAC,OAAA,EAAI,WAAU,iEAAA,CAAiE;AAAA,IAChF,g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xB;AAAA,gBACP;AAAA,gBACA;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QAGN,KAAKiB,EAA2B,OAAO;AACrC,iBACE,gBAAAtB;AAAA,YAAC6B,EAAa;AAAA,YAAb;AAAA,cACC,SAASxB;AAAA,gBACP;AAAA,gBACA;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QAGN,KAAKiB,EAA2B,OAAO;AACrC,iBACE,gBAAAtB;AAAA,YAAC6B,EAAa;AAAA,YAAb;AAAA,cACC,SAASxB;AAAA,gBACP;AAAA,gBACA;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,QAGN,KAAKiB,EAA2B,OAAO;AAAA,QACvC,KAAKA,EAA2B,OAAO;AACrC,iBAAO,gBAAAtB,EAAC6B,EAAa,SAAb,EAAqB;AAAA,QAC/B,KAAKP,EAA2B,OAAO;AACrC,iBAAO,gBAAAtB,EAACH,GAAA,EAAO,SAASU,EAAI,MAAM,gBAAgB;AAAA,QACpD,KAAKe,EAA2B,OAAO;AACrC,iBAAO,gBAAAtB,EAAC6B,EAAa,SAAb,EAAqB;AAAA,QAC/B;AACE,iBAAO;AAAA,MAAA;AAAA,IAIb;AACE,aAAOD,EAAaV,CAAkB;AAAA,EAAA;AAE5C;"}
|
|
@@ -11,7 +11,7 @@ import "../../constants/chains.js";
|
|
|
11
11
|
import "viem";
|
|
12
12
|
import "ethers";
|
|
13
13
|
import { cn as M } from "../../utils/cn.js";
|
|
14
|
-
import { b as V, y as _ } from "../../config-
|
|
14
|
+
import { b as V, y as _ } from "../../config-CQ4V08as.js";
|
|
15
15
|
import "../../machine/machine.js";
|
|
16
16
|
import { fireEvent as d } from "../../machine/events/utils/fireEvent.js";
|
|
17
17
|
import { useTypedTranslation as j } from "../../localisation.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo as o } from "react";
|
|
2
|
-
import { b as d, y as l } from "../../config-
|
|
2
|
+
import { b as d, y as l } from "../../config-CQ4V08as.js";
|
|
3
3
|
import { useTypedTranslation as c } from "../../localisation.js";
|
|
4
4
|
import { getIntentsAccountId as u } from "../../utils/intents/getIntentsAccountId.js";
|
|
5
5
|
import { CHAINS_LIST as f, EVM_CHAINS as m } from "../../constants/chains.js";
|
|
@@ -3,7 +3,7 @@ import "react-i18next";
|
|
|
3
3
|
import "../../components/Button.js";
|
|
4
4
|
import "../../components/TinyNumber.js";
|
|
5
5
|
import "../../components/ErrorMessage.js";
|
|
6
|
-
import { S as b } from "../../config-
|
|
6
|
+
import { S as b } from "../../config-CQ4V08as.js";
|
|
7
7
|
import "../../localisation.js";
|
|
8
8
|
import "../../utils/checkers/isNotEmptyAmount.js";
|
|
9
9
|
export {
|
|
@@ -5,7 +5,7 @@ import { SummaryItem as n } from "./SummaryItem.js";
|
|
|
5
5
|
import { Hr as w } from "../../components/Hr.js";
|
|
6
6
|
import { Card as y } from "../../components/Card.js";
|
|
7
7
|
import { CloseButton as b } from "../../components/CloseButton.js";
|
|
8
|
-
import { b as A } from "../../config-
|
|
8
|
+
import { b as A } from "../../config-CQ4V08as.js";
|
|
9
9
|
import "ethers";
|
|
10
10
|
import "../../machine/machine.js";
|
|
11
11
|
import { fireEvent as C } from "../../machine/events/utils/fireEvent.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { DirectionSwitcher as r } from "../components/DirectionSwitcher.js";
|
|
3
|
-
import { b as i } from "../config-
|
|
3
|
+
import { b as i } from "../config-CQ4V08as.js";
|
|
4
4
|
import "ethers";
|
|
5
5
|
import "../machine/machine.js";
|
|
6
6
|
import { fireEvent as n } from "../machine/events/utils/fireEvent.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "./SwapQuoteSkeleton.js";
|
|
3
|
-
import { a3 as s } from "../../config-
|
|
3
|
+
import { a3 as s } from "../../config-CQ4V08as.js";
|
|
4
4
|
import "../../components/Notes.js";
|
|
5
5
|
import "../../components/Accordion.js";
|
|
6
6
|
import "../../utils/formatters/formatUsdAmount.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import { a5 as I } from "../../config-
|
|
3
|
+
import { a5 as I } from "../../config-CQ4V08as.js";
|
|
4
4
|
import "./utils/getBalancePortion.js";
|
|
5
5
|
import "./utils/getUsdDisplayAmount.js";
|
|
6
6
|
import "./TokenInputHeading.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "../../utils/cn.js";
|
|
3
|
-
import { aa as T, ab as e } from "../../config-
|
|
3
|
+
import { aa as T, ab as e } from "../../config-CQ4V08as.js";
|
|
4
4
|
import "../../components/TokenIcon.js";
|
|
5
5
|
import "../../components/TinyNumber.js";
|
|
6
6
|
import "../../utils/formatters/getUsdDisplayBalance.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
2
|
import "virtua";
|
|
3
3
|
import "react";
|
|
4
|
-
import { ad as f } from "../../config-
|
|
4
|
+
import { ad as f } from "../../config-CQ4V08as.js";
|
|
5
5
|
import "./TokensListPlaceholder.js";
|
|
6
6
|
import "../../utils/cn.js";
|
|
7
7
|
import "../../components/Hr.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import * as
|
|
4
|
-
import { b as
|
|
5
|
-
import { ChainsDropdown as
|
|
1
|
+
import { jsxs as a, jsx as t, Fragment as T } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as I, useState as f } from "react";
|
|
3
|
+
import * as j from "lucide-react";
|
|
4
|
+
import { b as E, y as M, d as R, q as A } from "../config-CQ4V08as.js";
|
|
5
|
+
import { ChainsDropdown as B } from "./ChainsDropdown/index.js";
|
|
6
6
|
import "@tanstack/react-query";
|
|
7
7
|
import "@defuse-protocol/one-click-sdk-typescript";
|
|
8
8
|
import "../constants/chains.js";
|
|
@@ -20,63 +20,72 @@ import "../index-xuotMAFm.js";
|
|
|
20
20
|
import "axios";
|
|
21
21
|
import "../network.js";
|
|
22
22
|
import "viem";
|
|
23
|
-
import { cn as
|
|
23
|
+
import { cn as D } from "../utils/cn.js";
|
|
24
24
|
import "viem/chains";
|
|
25
25
|
import "browser-or-node";
|
|
26
|
-
import { useHandleKeyDown as
|
|
27
|
-
import { Hr as
|
|
28
|
-
import { Card as
|
|
29
|
-
import { Input as
|
|
30
|
-
import { Banner as
|
|
31
|
-
import { CloseButton as
|
|
32
|
-
import { useTypedTranslation as
|
|
33
|
-
const
|
|
34
|
-
variant:
|
|
35
|
-
showBalances:
|
|
36
|
-
showChainsSelector:
|
|
37
|
-
chainsFilter:
|
|
38
|
-
groupTokens:
|
|
39
|
-
className:
|
|
40
|
-
onMsg:
|
|
26
|
+
import { useHandleKeyDown as u } from "../hooks/useHandleKeyDown.js";
|
|
27
|
+
import { Hr as H } from "../components/Hr.js";
|
|
28
|
+
import { Card as q } from "../components/Card.js";
|
|
29
|
+
import { Input as v } from "../components/Input.js";
|
|
30
|
+
import { Banner as K } from "../components/Banner.js";
|
|
31
|
+
import { CloseButton as L } from "../components/CloseButton.js";
|
|
32
|
+
import { useTypedTranslation as O } from "../localisation.js";
|
|
33
|
+
const Ce = ({
|
|
34
|
+
variant: n,
|
|
35
|
+
showBalances: w,
|
|
36
|
+
showChainsSelector: x,
|
|
37
|
+
chainsFilter: l,
|
|
38
|
+
groupTokens: C,
|
|
39
|
+
className: k,
|
|
40
|
+
onMsg: c
|
|
41
41
|
}) => {
|
|
42
|
-
const { t:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const { t: y } = O(), { ctx: S } = E(), { walletSupportedChains: _ } = M(), p = I(null), [r, s] = f(""), i = R(n), m = () => c({ type: "on_dismiss_tokens_modal" });
|
|
43
|
+
u(
|
|
44
|
+
"Escape",
|
|
45
|
+
() => {
|
|
46
|
+
r ? s("") : m();
|
|
47
|
+
},
|
|
48
|
+
[r]
|
|
49
|
+
), u("Alphanumeric", (e) => {
|
|
50
|
+
s((N) => N + e), p.current?.focus();
|
|
51
|
+
});
|
|
52
|
+
const b = i.length === 1 && i[0]?.id ? i[0]?.id : "all", [o, g] = f(b), d = o !== "all" && o !== "intents" && l.external !== "all" && !_.includes(o);
|
|
53
|
+
return /* @__PURE__ */ a(
|
|
54
|
+
q,
|
|
47
55
|
{
|
|
48
56
|
padding: "none",
|
|
49
|
-
className:
|
|
57
|
+
className: D(
|
|
50
58
|
"w-full gap-sw-xl flex flex-col px-sw-2xl pt-sw-2xl",
|
|
51
|
-
|
|
59
|
+
k
|
|
52
60
|
),
|
|
53
61
|
children: [
|
|
54
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ a("header", { className: "flex items-center justify-between", children: [
|
|
55
63
|
/* @__PURE__ */ t("h2", { className: "text-sw-label-lg text-sw-gray-50", children: "Select token" }),
|
|
56
|
-
/* @__PURE__ */ t(
|
|
64
|
+
/* @__PURE__ */ t(L, { onClick: m })
|
|
57
65
|
] }),
|
|
58
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ a("div", { className: "gap-sw-xl flex items-center", children: [
|
|
59
67
|
/* @__PURE__ */ t(
|
|
60
|
-
|
|
68
|
+
v,
|
|
61
69
|
{
|
|
62
70
|
focusOnMount: !0,
|
|
63
|
-
icon:
|
|
64
|
-
|
|
71
|
+
icon: j.Search,
|
|
72
|
+
ref: p,
|
|
73
|
+
defaultValue: r,
|
|
65
74
|
className: "w-full",
|
|
66
75
|
placeholder: "Search or paste address",
|
|
67
|
-
onChange: (e) =>
|
|
76
|
+
onChange: (e) => s(e.target.value.trim())
|
|
68
77
|
}
|
|
69
78
|
),
|
|
70
|
-
|
|
71
|
-
|
|
79
|
+
x && /* @__PURE__ */ t(
|
|
80
|
+
B,
|
|
72
81
|
{
|
|
73
|
-
variant:
|
|
82
|
+
variant: n,
|
|
74
83
|
selected: o,
|
|
75
|
-
chainsFilter:
|
|
84
|
+
chainsFilter: l,
|
|
76
85
|
onMsg: (e) => {
|
|
77
86
|
switch (e.type) {
|
|
78
87
|
case "on_click_chain":
|
|
79
|
-
|
|
88
|
+
g(e.chain);
|
|
80
89
|
break;
|
|
81
90
|
default:
|
|
82
91
|
h(e.type, { throwError: !1 });
|
|
@@ -85,36 +94,36 @@ const ue = ({
|
|
|
85
94
|
}
|
|
86
95
|
)
|
|
87
96
|
] }),
|
|
88
|
-
|
|
97
|
+
d && !!S.walletAddress && /* @__PURE__ */ a(T, { children: [
|
|
89
98
|
/* @__PURE__ */ t(
|
|
90
|
-
|
|
99
|
+
K,
|
|
91
100
|
{
|
|
92
101
|
variant: "error",
|
|
93
|
-
message:
|
|
102
|
+
message: y(
|
|
94
103
|
"wallet.connected.error.notSupportedChain",
|
|
95
104
|
"This network isn’t supported by your wallet."
|
|
96
105
|
)
|
|
97
106
|
}
|
|
98
107
|
),
|
|
99
|
-
/* @__PURE__ */ t(
|
|
108
|
+
/* @__PURE__ */ t(H, {})
|
|
100
109
|
] }),
|
|
101
110
|
/* @__PURE__ */ t(
|
|
102
|
-
|
|
111
|
+
A,
|
|
103
112
|
{
|
|
104
|
-
variant:
|
|
105
|
-
search:
|
|
106
|
-
groupTokens:
|
|
107
|
-
showBalances:
|
|
108
|
-
chainsFilter:
|
|
113
|
+
variant: n,
|
|
114
|
+
search: r,
|
|
115
|
+
groupTokens: C,
|
|
116
|
+
showBalances: w,
|
|
117
|
+
chainsFilter: l,
|
|
109
118
|
selectedChain: o,
|
|
110
|
-
chainIsNotSupported:
|
|
119
|
+
chainIsNotSupported: d,
|
|
111
120
|
onMsg: (e) => {
|
|
112
121
|
switch (e.type) {
|
|
113
122
|
case "on_reset_search":
|
|
114
|
-
|
|
123
|
+
s("");
|
|
115
124
|
break;
|
|
116
125
|
case "on_select_token":
|
|
117
|
-
|
|
126
|
+
c(e);
|
|
118
127
|
break;
|
|
119
128
|
default:
|
|
120
129
|
h(e, { throwError: !1 });
|
|
@@ -127,6 +136,6 @@ const ue = ({
|
|
|
127
136
|
);
|
|
128
137
|
};
|
|
129
138
|
export {
|
|
130
|
-
|
|
139
|
+
Ce as TokensModal
|
|
131
140
|
};
|
|
132
141
|
//# sourceMappingURL=TokensModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokensModal.js","sources":["../../src/features/TokensModal.tsx"],"sourcesContent":["import { useState } from 'react';\nimport * as Icons from 'lucide-react';\n\nimport { TokensList } from './TokensList';\nimport { ChainsDropdown } from './ChainsDropdown';\nimport { useChains } from '../hooks';\nimport { Hr } from '@/components/Hr';\nimport { Card } from '@/components/Card';\nimport { Input } from '@/components/Input';\nimport { Banner } from '@/components/Banner';\nimport { CloseButton } from '@/components/CloseButton';\n\nimport { cn } from '@/utils/cn';\nimport { useConfig } from '@/config';\nimport { useHandleKeyDown } from '@/hooks';\nimport { useUnsafeSnapshot } from '@/machine/snap';\nimport { notReachable } from '@/utils/notReachable';\nimport { useTypedTranslation } from '@/localisation';\nimport type { Chains, ChainsFilter } from '@/types/chain';\nimport type { Token } from '@/types/token';\n\ntype Msg =\n | { type: 'on_select_token'; token: Token }\n | { type: 'on_dismiss_tokens_modal' };\n\ntype Props = {\n variant: 'source' | 'target';\n groupTokens: boolean;\n showBalances: boolean;\n showChainsSelector: boolean;\n chainsFilter: ChainsFilter;\n className?: string;\n onMsg: (msg: Msg) => void;\n};\n\nexport const TokensModal = ({\n variant,\n showBalances,\n showChainsSelector,\n chainsFilter,\n groupTokens,\n className,\n onMsg,\n}: Props) => {\n const { t } = useTypedTranslation();\n const { ctx } = useUnsafeSnapshot();\n const { walletSupportedChains } = useConfig();\n\n const [search, setSearch] = useState('');\n const chains = useChains(variant);\n\n const handleClose = () => onMsg({ type: 'on_dismiss_tokens_modal' });\n\n useHandleKeyDown('Escape'
|
|
1
|
+
{"version":3,"file":"TokensModal.js","sources":["../../src/features/TokensModal.tsx"],"sourcesContent":["import { useRef, useState } from 'react';\nimport * as Icons from 'lucide-react';\n\nimport { TokensList } from './TokensList';\nimport { ChainsDropdown } from './ChainsDropdown';\nimport { useChains } from '../hooks';\nimport { Hr } from '@/components/Hr';\nimport { Card } from '@/components/Card';\nimport { Input } from '@/components/Input';\nimport { Banner } from '@/components/Banner';\nimport { CloseButton } from '@/components/CloseButton';\n\nimport { cn } from '@/utils/cn';\nimport { useConfig } from '@/config';\nimport { useHandleKeyDown } from '@/hooks';\nimport { useUnsafeSnapshot } from '@/machine/snap';\nimport { notReachable } from '@/utils/notReachable';\nimport { useTypedTranslation } from '@/localisation';\nimport type { Chains, ChainsFilter } from '@/types/chain';\nimport type { Token } from '@/types/token';\n\ntype Msg =\n | { type: 'on_select_token'; token: Token }\n | { type: 'on_dismiss_tokens_modal' };\n\ntype Props = {\n variant: 'source' | 'target';\n groupTokens: boolean;\n showBalances: boolean;\n showChainsSelector: boolean;\n chainsFilter: ChainsFilter;\n className?: string;\n onMsg: (msg: Msg) => void;\n};\n\nexport const TokensModal = ({\n variant,\n showBalances,\n showChainsSelector,\n chainsFilter,\n groupTokens,\n className,\n onMsg,\n}: Props) => {\n const { t } = useTypedTranslation();\n const { ctx } = useUnsafeSnapshot();\n const { walletSupportedChains } = useConfig();\n\n const searchInputRef = useRef<HTMLInputElement>(null);\n const [search, setSearch] = useState('');\n const chains = useChains(variant);\n\n const handleClose = () => onMsg({ type: 'on_dismiss_tokens_modal' });\n\n useHandleKeyDown(\n 'Escape',\n () => {\n if (search) {\n setSearch('');\n } else {\n handleClose();\n }\n },\n [search],\n );\n\n useHandleKeyDown('Alphanumeric', (key) => {\n setSearch((s) => s + key);\n searchInputRef.current?.focus();\n });\n\n // If there is only one chain available, select it by default\n const defaultChain =\n chains.length === 1 && chains[0]?.id ? chains[0]?.id : 'all';\n\n const [selectedChain, setSelectedChain] = useState<\n 'all' | 'intents' | Chains\n >(defaultChain);\n\n // selected chain is not supported by connected wallet\n const chainIsNotSupported =\n selectedChain !== 'all' &&\n selectedChain !== 'intents' &&\n chainsFilter.external !== 'all' &&\n !walletSupportedChains.includes(selectedChain);\n\n return (\n <Card\n padding=\"none\"\n className={cn(\n 'w-full gap-sw-xl flex flex-col px-sw-2xl pt-sw-2xl',\n className,\n )}>\n <header className=\"flex items-center justify-between\">\n <h2 className=\"text-sw-label-lg text-sw-gray-50\">Select token</h2>\n <CloseButton onClick={handleClose} />\n </header>\n\n <div className=\"gap-sw-xl flex items-center\">\n <Input\n focusOnMount\n icon={Icons.Search}\n ref={searchInputRef}\n defaultValue={search}\n className=\"w-full\"\n placeholder=\"Search or paste address\"\n onChange={(e) => setSearch(e.target.value.trim())}\n />\n {showChainsSelector && (\n <ChainsDropdown\n variant={variant}\n selected={selectedChain}\n chainsFilter={chainsFilter}\n onMsg={(msg) => {\n switch (msg.type) {\n case 'on_click_chain':\n setSelectedChain(msg.chain);\n break;\n default:\n notReachable(msg.type, { throwError: false });\n }\n }}\n />\n )}\n </div>\n\n {chainIsNotSupported && !!ctx.walletAddress && (\n <>\n <Banner\n variant=\"error\"\n message={t(\n 'wallet.connected.error.notSupportedChain',\n 'This network isn’t supported by your wallet.',\n )}\n />\n <Hr />\n </>\n )}\n\n <TokensList\n variant={variant}\n search={search}\n groupTokens={groupTokens}\n showBalances={showBalances}\n chainsFilter={chainsFilter}\n selectedChain={selectedChain}\n chainIsNotSupported={chainIsNotSupported}\n onMsg={(msg) => {\n switch (msg.type) {\n case 'on_reset_search':\n setSearch('');\n break;\n case 'on_select_token':\n onMsg(msg);\n break;\n default:\n notReachable(msg, { throwError: false });\n }\n }}\n />\n </Card>\n );\n};\n"],"names":["TokensModal","variant","showBalances","showChainsSelector","chainsFilter","groupTokens","className","onMsg","t","useTypedTranslation","ctx","useUnsafeSnapshot","walletSupportedChains","useConfig","searchInputRef","useRef","search","setSearch","useState","chains","useChains","handleClose","useHandleKeyDown","key","s","defaultChain","selectedChain","setSelectedChain","chainIsNotSupported","jsxs","Card","cn","jsx","CloseButton","Input","Icons","ChainsDropdown","msg","notReachable","Fragment","Banner","Hr","TokensList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,KAAc,CAAC;AAAA,EAC1B,SAAAC;AAAA,EACA,cAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AACF,MAAa;AACX,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAA,GACR,EAAE,KAAAC,EAAA,IAAQC,EAAA,GACV,EAAE,uBAAAC,EAAA,IAA0BC,EAAA,GAE5BC,IAAiBC,EAAyB,IAAI,GAC9C,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAE,GACjCC,IAASC,EAAUnB,CAAO,GAE1BoB,IAAc,MAAMd,EAAM,EAAE,MAAM,2BAA2B;AAEnE,EAAAe;AAAA,IACE;AAAA,IACA,MAAM;AACJ,MAAIN,IACFC,EAAU,EAAE,IAEZI,EAAA;AAAA,IAEJ;AAAA,IACA,CAACL,CAAM;AAAA,EAAA,GAGTM,EAAiB,gBAAgB,CAACC,MAAQ;AACxC,IAAAN,EAAU,CAACO,MAAMA,IAAID,CAAG,GACxBT,EAAe,SAAS,MAAA;AAAA,EAC1B,CAAC;AAGD,QAAMW,IACJN,EAAO,WAAW,KAAKA,EAAO,CAAC,GAAG,KAAKA,EAAO,CAAC,GAAG,KAAK,OAEnD,CAACO,GAAeC,CAAgB,IAAIT,EAExCO,CAAY,GAGRG,IACJF,MAAkB,SAClBA,MAAkB,aAClBtB,EAAa,aAAa,SAC1B,CAACQ,EAAsB,SAASc,CAAa;AAE/C,SACE,gBAAAG;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAQ;AAAA,MACR,WAAWC;AAAA,QACT;AAAA,QACAzB;AAAA,MAAA;AAAA,MAEF,UAAA;AAAA,QAAA,gBAAAuB,EAAC,UAAA,EA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AAAA,YACA,eAAAsB;AAAA,YACA,qBAAAE;AAAA,YACA,OAAO,CAACS,MAAQ;AACd,sBAAQA,EAAI,MAAA;AAAA,gBACV,KAAK;AACH,kBAAApB,EAAU,EAAE;AACZ;AAAA,gBACF,KAAK;AACH,kBAAAV,EAAM8B,CAAG;AACT;AAAA,gBACF;AACE,kBAAAC,EAAaD,GAAK,EAAE,YAAY,GAAA,CAAO;AAAA,cAAA;AAAA,YAE7C;AAAA,UAAA;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -9,7 +9,7 @@ import "ethers";
|
|
|
9
9
|
import "../../utils/cn.js";
|
|
10
10
|
import "@tanstack/react-query";
|
|
11
11
|
import "@defuse-protocol/one-click-sdk-typescript";
|
|
12
|
-
import { ag as F, af as G, z as H } from "../../config-
|
|
12
|
+
import { ag as F, af as G, z as H } from "../../config-CQ4V08as.js";
|
|
13
13
|
import "../../machine/machine.js";
|
|
14
14
|
import "zod";
|
|
15
15
|
import "../../utils/near/rpc.js";
|
|
@@ -28,7 +28,7 @@ import "lucide-react";
|
|
|
28
28
|
import "../../components/Card.js";
|
|
29
29
|
import "../../components/Button.js";
|
|
30
30
|
import "copy-text-to-clipboard";
|
|
31
|
-
import "
|
|
31
|
+
import "../../components/Input.js";
|
|
32
32
|
import "../../components/InputAmount.js";
|
|
33
33
|
import "../../components/Notes.js";
|
|
34
34
|
import "../../components/CloseButton.js";
|