@aurora-is-near/intents-swap-widget 3.18.3 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AllNetworksIcon.js +11 -0
- package/dist/components/AllNetworksIcon.js.map +1 -0
- package/dist/components/ChainShortcut.d.ts +15 -0
- package/dist/components/ChainShortcut.js +57 -0
- package/dist/components/ChainShortcut.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +21 -17
- package/dist/components/index.js.map +1 -1
- package/dist/{config-BMvXuF1-.js → config-C47AYcMK.js} +913 -898
- package/dist/config-C47AYcMK.js.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +2 -2
- 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/ChainItem.d.ts +1 -0
- package/dist/features/ChainsDropdown/ChainItem.js +23 -14
- package/dist/features/ChainsDropdown/ChainItem.js.map +1 -1
- package/dist/features/ChainsDropdown/index.js +61 -94
- package/dist/features/ChainsDropdown/index.js.map +1 -1
- package/dist/features/ChainsSelector/index.d.ts +15 -0
- package/dist/features/ChainsSelector/index.js +108 -0
- package/dist/features/ChainsSelector/index.js.map +1 -0
- 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/SuccessScreen/useSummaryItemsCount.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 +62 -64
- package/dist/features/TokensModal.js.map +1 -1
- package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js +5 -4
- package/dist/features/WalletCompatibilityCheck/WalletCompatibilityModal.js.map +1 -1
- package/dist/features/WalletCompatibilityCheck/index.js +1 -1
- package/dist/features/index.js +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useAllTokens.js +1 -1
- package/dist/hooks/useChains.js +1 -1
- package/dist/hooks/useCompatibilityCheck.js +1 -1
- package/dist/hooks/useDefaultToken.js +1 -1
- package/dist/hooks/useExternalDepositStatus/index.js +1 -1
- package/dist/hooks/useExternalDepositStatus/usePoaExternalDepositStatus.js +1 -1
- package/dist/hooks/useIntentsBalance.js +1 -1
- package/dist/hooks/useIsCompatibilityCheckRequired.js +1 -1
- package/dist/hooks/useMakeDepositAddress.js +1 -1
- package/dist/hooks/useMakeIntentsTransfer.js +1 -1
- package/dist/hooks/useMakeNEARFtTransferCall.js +1 -1
- package/dist/hooks/useMakeQuote.js +1 -1
- package/dist/hooks/useMakeQuoteTransfer.js +1 -1
- package/dist/hooks/useMakeTransfer.js +1 -1
- package/dist/hooks/useMergedBalance.js +1 -1
- package/dist/hooks/useSwitchChain.js +1 -1
- package/dist/hooks/useTheme.js +1 -1
- package/dist/hooks/useTokenInputPair.js +1 -1
- package/dist/hooks/useTokens.js +1 -1
- package/dist/hooks/useTokensFiltered.d.ts +3 -1
- package/dist/hooks/useTokensFiltered.js +1 -1
- package/dist/hooks/useTokensIntentsUnique.js +1 -1
- package/dist/index.js +74 -70
- package/dist/index.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/styles.css +1 -1
- package/dist/theme/ThemeProvider.js +1 -1
- package/dist/types/config.d.ts +3 -0
- 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/near/getNearNep141StorageBalance.js +1 -1
- package/dist/utils/tokens/sort.d.ts +2 -1
- package/dist/utils/tokens/sort.js +55 -24
- package/dist/utils/tokens/sort.js.map +1 -1
- package/dist/widgets/WidgetDeposit/WidgetDepositContent.js +2 -2
- package/dist/widgets/WidgetDeposit/WidgetDepositSkeleton.js +1 -1
- package/dist/widgets/WidgetSwap/WidgetSwapContent.js +2 -2
- package/dist/widgets/WidgetSwap/WidgetSwapSkeleton.js +1 -1
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawContent.js +2 -2
- package/dist/widgets/WidgetWithdraw/WidgetWithdrawSkeleton.js +1 -1
- package/package.json +1 -1
- package/src/components/AllNetworksIcon.tsx +8 -0
- package/src/components/ChainShortcut.tsx +67 -0
- package/src/components/index.ts +2 -0
- package/src/config.tsx +13 -0
- package/src/features/ChainsDropdown/ChainItem.tsx +17 -4
- package/src/features/ChainsDropdown/index.tsx +10 -41
- package/src/features/ChainsSelector/index.tsx +113 -0
- package/src/features/TokensList/TokensList.tsx +2 -1
- package/src/features/TokensModal.tsx +29 -29
- package/src/hooks/useTokensFiltered.ts +4 -0
- package/src/types/config.ts +8 -0
- package/src/types/localisation.ts +1 -0
- package/src/utils/tokens/sort.ts +107 -20
- package/dist/config-BMvXuF1-.js.map +0 -1
- package/dist/features/ChainsDropdown/AllNetworksIcon.js +0 -7
- package/dist/features/ChainsDropdown/AllNetworksIcon.js.map +0 -1
- package/src/features/ChainsDropdown/AllNetworksIcon.tsx +0 -7
- /package/dist/{features/ChainsDropdown → components}/AllNetworksIcon.d.ts +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type LocalisationKeys = 'chain.all.label' | 'wallet.recipient.placeholder' | 'wallet.recipient.info.selectToken' | 'wallet.recipient.error.noAddress' | 'wallet.recipient.error.tokenNotSelected' | 'wallet.recipient.error.invalidAddress' | 'wallet.recipient.error.sendAddressNotFound' | 'wallet.recipient.error.sendAddressInvalid' | 'wallet.recipient.warn.compatibleNetwork' | 'wallet.recipient.message.networkVerified' | 'wallet.recipient.message.receiveFunds' | 'wallet.connected.error.notSupportedChain' | 'transfer.success.swap.title' | 'transfer.success.withdrawal.title' | 'transfer.success.deposit.title' | 'transfer.success.details.label' | 'transfer.success.details.hash' | 'transfer.success.details.rate' | 'transfer.success.details.intent' | 'transfer.success.details.recipient' | 'transfer.success.action.viewOnExplorer' | 'transfer.success.action.backToSwap' | 'quote.result.maxSlippage.label' | 'quote.result.processingTime.label' | 'tokens.input.max.label' | 'tokens.input.half.label' | 'tokens.input.externalBalance.label' | 'tokens.list.noBalanceOnApp.label' | 'tokens.list.noBalanceOnApp.subLabel' | 'tokens.list.searchEmpty.label' | 'tokens.list.searchEmpty.subLabel' | 'tokens.list.searchReset.label' | 'deposit.external.error.noStatus' | 'deposit.external.error.incomplete' | 'deposit.external.error.failed' | 'deposit.external.loading.waiting' | 'deposit.external.loading.fetching' | 'submit.error.connectWallet' | 'submit.error.invalidTransferData.label' | 'submit.error.transferFailed.label' | 'submit.error.insufficientBalance' | 'submit.error.invalidAddress' | 'submit.error.sendAddressNotFound' | 'submit.error.sendAddressInvalid' | 'submit.error.amountTooLow.label' | 'submit.error.amountTooLow.message' | 'submit.error.quoteFailed.label' | 'submit.error.quoteFailed.message' | 'submit.error.transfer.noFees' | 'submit.error.transfer.failed' | 'submit.error.externalTransferFailed.label' | 'submit.error.externalTransferFailed.incompleteMessage' | 'submit.error.externalTransferFailed.refundedMessage' | 'sendAddress.label' | 'sendAddress.button.magic.label' | 'submit.active.swap' | 'submit.active.intentsSwap' | 'submit.active.withdraw' | 'submit.active.deposit' | 'submit.disabled.temporary.label' | 'submit.disabled.temporary.message' | 'submit.disabled.selectTokenToReceive' | 'submit.disabled.enterRecipientAddress' | 'submit.disabled.enterAmount' | 'submit.pending.quote.finalizing' | 'submit.pending.quote.refreshing' | 'submit.pending.transfer.confirmInWallet' | 'submit.pending.transfer.finalizing' | 'submit.pending.externalDeposit.waiting' | 'submit.pending.externalDeposit.processing' | 'submit.pending.switchingChain' | 'submit.pending.validating' | 'walletCompatibility.modal.title.initial' | 'walletCompatibility.modal.title.error' | 'walletCompatibility.modal.description.initial' | 'walletCompatibility.modal.description.error' | 'walletCompatibility.modal.feature.secureTransactions' | 'walletCompatibility.modal.feature.fullAccess' | 'walletCompatibility.modal.feature.fundProtection' | 'walletCompatibility.modal.button.verified' | 'walletCompatibility.modal.button.signing' | 'walletCompatibility.modal.button.verify' | 'walletCompatibility.modal.button.closeTimer' | 'walletCompatibility.modal.button.tryAgain' | 'walletCompatibility.modal.button.tryAgainDesc' | 'walletCompatibility.modal.button.signOut' | 'tokenInput.heading.source.withdraw' | 'tokenInput.heading.target.withdraw' | 'tokenInput.heading.source.deposit' | 'tokenInput.heading.source.swap' | 'tokenInput.heading.target.swap';
|
|
1
|
+
export type LocalisationKeys = 'chain.all.label' | 'chain.more.label' | 'wallet.recipient.placeholder' | 'wallet.recipient.info.selectToken' | 'wallet.recipient.error.noAddress' | 'wallet.recipient.error.tokenNotSelected' | 'wallet.recipient.error.invalidAddress' | 'wallet.recipient.error.sendAddressNotFound' | 'wallet.recipient.error.sendAddressInvalid' | 'wallet.recipient.warn.compatibleNetwork' | 'wallet.recipient.message.networkVerified' | 'wallet.recipient.message.receiveFunds' | 'wallet.connected.error.notSupportedChain' | 'transfer.success.swap.title' | 'transfer.success.withdrawal.title' | 'transfer.success.deposit.title' | 'transfer.success.details.label' | 'transfer.success.details.hash' | 'transfer.success.details.rate' | 'transfer.success.details.intent' | 'transfer.success.details.recipient' | 'transfer.success.action.viewOnExplorer' | 'transfer.success.action.backToSwap' | 'quote.result.maxSlippage.label' | 'quote.result.processingTime.label' | 'tokens.input.max.label' | 'tokens.input.half.label' | 'tokens.input.externalBalance.label' | 'tokens.list.noBalanceOnApp.label' | 'tokens.list.noBalanceOnApp.subLabel' | 'tokens.list.searchEmpty.label' | 'tokens.list.searchEmpty.subLabel' | 'tokens.list.searchReset.label' | 'deposit.external.error.noStatus' | 'deposit.external.error.incomplete' | 'deposit.external.error.failed' | 'deposit.external.loading.waiting' | 'deposit.external.loading.fetching' | 'submit.error.connectWallet' | 'submit.error.invalidTransferData.label' | 'submit.error.transferFailed.label' | 'submit.error.insufficientBalance' | 'submit.error.invalidAddress' | 'submit.error.sendAddressNotFound' | 'submit.error.sendAddressInvalid' | 'submit.error.amountTooLow.label' | 'submit.error.amountTooLow.message' | 'submit.error.quoteFailed.label' | 'submit.error.quoteFailed.message' | 'submit.error.transfer.noFees' | 'submit.error.transfer.failed' | 'submit.error.externalTransferFailed.label' | 'submit.error.externalTransferFailed.incompleteMessage' | 'submit.error.externalTransferFailed.refundedMessage' | 'sendAddress.label' | 'sendAddress.button.magic.label' | 'submit.active.swap' | 'submit.active.intentsSwap' | 'submit.active.withdraw' | 'submit.active.deposit' | 'submit.disabled.temporary.label' | 'submit.disabled.temporary.message' | 'submit.disabled.selectTokenToReceive' | 'submit.disabled.enterRecipientAddress' | 'submit.disabled.enterAmount' | 'submit.pending.quote.finalizing' | 'submit.pending.quote.refreshing' | 'submit.pending.transfer.confirmInWallet' | 'submit.pending.transfer.finalizing' | 'submit.pending.externalDeposit.waiting' | 'submit.pending.externalDeposit.processing' | 'submit.pending.switchingChain' | 'submit.pending.validating' | 'walletCompatibility.modal.title.initial' | 'walletCompatibility.modal.title.error' | 'walletCompatibility.modal.description.initial' | 'walletCompatibility.modal.description.error' | 'walletCompatibility.modal.feature.secureTransactions' | 'walletCompatibility.modal.feature.fullAccess' | 'walletCompatibility.modal.feature.fundProtection' | 'walletCompatibility.modal.button.verified' | 'walletCompatibility.modal.button.signing' | 'walletCompatibility.modal.button.verify' | 'walletCompatibility.modal.button.closeTimer' | 'walletCompatibility.modal.button.tryAgain' | 'walletCompatibility.modal.button.tryAgainDesc' | 'walletCompatibility.modal.button.signOut' | 'tokenInput.heading.source.withdraw' | 'tokenInput.heading.target.withdraw' | 'tokenInput.heading.source.deposit' | 'tokenInput.heading.source.swap' | 'tokenInput.heading.target.swap';
|
|
2
2
|
export type LocalisationDict = Partial<Record<LocalisationKeys, string>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Token, TokenBalances } from '../../types/token';
|
|
2
|
+
import { PriorityAssets } from '../../types/config';
|
|
2
3
|
import { Chains } from '../../types/chain';
|
|
3
|
-
export declare const createTokenSorter: (tokensBalance: TokenBalances, walletSupportedChains: ReadonlyArray<Chains>, searchStr?: string | undefined) => (a: Token, b: Token) => number;
|
|
4
|
+
export declare const createTokenSorter: (tokensBalance: TokenBalances, walletSupportedChains: ReadonlyArray<Chains>, searchStr?: string | undefined, priorityAssets?: PriorityAssets) => (a: Token, b: Token) => number;
|
|
@@ -1,37 +1,68 @@
|
|
|
1
|
-
import { formatUnits as
|
|
2
|
-
import { getTokenBalanceKey as
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
1
|
+
import { formatUnits as I } from "ethers";
|
|
2
|
+
import { getTokenBalanceKey as p } from "../intents/getTokenBalanceKey.js";
|
|
3
|
+
const v = (t, i, o) => {
|
|
4
|
+
if (t.isIntent || i.isIntent || o.length === 0)
|
|
5
|
+
return null;
|
|
6
|
+
const c = (n) => typeof o[0] == "string" ? o.includes(n.assetId) : o.some(
|
|
7
|
+
([u, a]) => n.blockchain === u && n.symbol.toLowerCase() === a.toLowerCase()
|
|
8
|
+
), s = (n) => typeof o[0] == "string" ? o.indexOf(n.assetId) : o.findIndex(
|
|
9
|
+
([u, a]) => n.blockchain === u && n.symbol.toLowerCase() === a.toLowerCase()
|
|
10
|
+
), e = c(t), r = c(i);
|
|
11
|
+
if (e && !r)
|
|
5
12
|
return -1;
|
|
6
|
-
if (!
|
|
13
|
+
if (!e && r)
|
|
7
14
|
return 1;
|
|
8
|
-
if (
|
|
9
|
-
const
|
|
10
|
-
|
|
15
|
+
if (e && r) {
|
|
16
|
+
const n = s(t), u = s(i);
|
|
17
|
+
if (n !== u)
|
|
18
|
+
return n - u;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}, C = (t, i, o) => {
|
|
22
|
+
if (t.isIntent && !i.isIntent)
|
|
23
|
+
return -1;
|
|
24
|
+
if (!t.isIntent && i.isIntent)
|
|
25
|
+
return 1;
|
|
26
|
+
if (!o) {
|
|
27
|
+
const n = (t.symbol ?? "").localeCompare(
|
|
28
|
+
i.symbol ?? "",
|
|
11
29
|
void 0,
|
|
12
30
|
{
|
|
13
31
|
sensitivity: "base"
|
|
14
32
|
}
|
|
15
33
|
);
|
|
16
|
-
return
|
|
34
|
+
return n !== 0 ? n : t.chainName.localeCompare(i.chainName, void 0, {
|
|
17
35
|
sensitivity: "base"
|
|
18
36
|
});
|
|
19
37
|
}
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
},
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
const c = (n) => n === o ? 0 : n.startsWith(o) ? 1 : n.includes(o) ? 2 : 3, s = c(t.symbol.toLowerCase()), e = c(i.symbol.toLowerCase());
|
|
39
|
+
if (s !== e)
|
|
40
|
+
return s - e;
|
|
41
|
+
const r = t.symbol.toLowerCase().localeCompare(i.symbol.toLowerCase());
|
|
42
|
+
return r !== 0 ? r : t.chainName.toLowerCase().localeCompare(i.chainName.toLowerCase());
|
|
43
|
+
}, h = (t, i, o, c, s, e, r) => {
|
|
44
|
+
const n = e.isIntent || r.isIntent, u = o !== void 0 && o > 0, a = c !== void 0 && c > 0;
|
|
45
|
+
if (u && !a)
|
|
46
|
+
return -1;
|
|
47
|
+
if (!u && a)
|
|
48
|
+
return 1;
|
|
49
|
+
if (u && a) {
|
|
50
|
+
const d = t.includes(e.blockchain), y = t.includes(r.blockchain);
|
|
51
|
+
return !n && d && !y ? -1 : !n && !d && y ? 1 : o !== c ? (c ?? 0) - (o ?? 0) : C(e, r, s);
|
|
52
|
+
}
|
|
53
|
+
const l = v(e, r, i);
|
|
54
|
+
if (l !== null)
|
|
55
|
+
return l;
|
|
56
|
+
const m = t.includes(e.blockchain), f = t.includes(r.blockchain);
|
|
57
|
+
return !n && m && !f ? -1 : !n && !m && f ? 1 : C(e, r, s);
|
|
58
|
+
}, k = (t, i, o, c = []) => (s, e) => {
|
|
59
|
+
const r = t[p(s)], n = t[p(e)], u = r ? I(r, s.decimals) : "0", a = n ? I(n, e.decimals) : "0", l = r !== void 0 ? parseFloat(`${u ?? 0}`) * s.price : void 0, m = n !== void 0 ? parseFloat(`${a ?? 0}`) * e.price : void 0, f = o?.trim().toLowerCase() ?? void 0;
|
|
60
|
+
return h(
|
|
61
|
+
i,
|
|
62
|
+
c,
|
|
63
|
+
l,
|
|
64
|
+
m,
|
|
65
|
+
f,
|
|
35
66
|
s,
|
|
36
67
|
e
|
|
37
68
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.js","sources":["../../../src/utils/tokens/sort.ts"],"sourcesContent":["import { formatUnits } from 'ethers';\n\nimport { getTokenBalanceKey } from '../intents/getTokenBalanceKey';\nimport type { Token, TokenBalances } from '@/types/token';\nimport type { Chains } from '@/types/chain';\n\nconst compareWithSearch = (\n a: Token,\n b: Token,\n searchLower: string | undefined,\n): number => {\n if (a.isIntent && !b.isIntent) {\n return -1;\n }\n\n if (!a.isIntent && b.isIntent) {\n return 1;\n }\n\n // sort alphabetically if no search\n if (!searchLower) {\n const symbolCompare = (a.symbol ?? '').localeCompare(\n b.symbol ?? '',\n undefined,\n {\n sensitivity: 'base',\n },\n );\n\n if (symbolCompare !== 0) {\n return symbolCompare;\n }\n\n return a.chainName.localeCompare(b.chainName, undefined, {\n sensitivity: 'base',\n });\n }\n\n const getSymbolRank = (symbol: string) => {\n if (symbol === searchLower) {\n return 0;\n }\n\n if (symbol.startsWith(searchLower)) {\n return 1;\n }\n\n if (symbol.includes(searchLower)) {\n return 2;\n }\n\n return 3;\n };\n\n const symbolRankA = getSymbolRank(a.symbol.toLowerCase());\n const symbolRankB = getSymbolRank(b.symbol.toLowerCase());\n\n // First compare by symbol match rank\n if (symbolRankA !== symbolRankB) {\n return symbolRankA - symbolRankB;\n }\n\n // Then compare alphabetically by symbol\n const symbolCompare = a.symbol\n .toLowerCase()\n .localeCompare(b.symbol.toLowerCase());\n\n if (symbolCompare !== 0) {\n return symbolCompare;\n }\n\n // Finally compare by blockchain\n return a.chainName.toLowerCase().localeCompare(b.chainName.toLowerCase());\n};\n\nconst
|
|
1
|
+
{"version":3,"file":"sort.js","sources":["../../../src/utils/tokens/sort.ts"],"sourcesContent":["import { formatUnits } from 'ethers';\n\nimport { getTokenBalanceKey } from '../intents/getTokenBalanceKey';\nimport type { Token, TokenBalances } from '@/types/token';\nimport type { PriorityAssets } from '@/types/config';\nimport type { Chains } from '@/types/chain';\n\nconst compareByPriority = (\n a: Token,\n b: Token,\n priorityAssets: PriorityAssets,\n): number | null => {\n if (a.isIntent || b.isIntent || priorityAssets.length === 0) {\n return null;\n }\n\n const isPriorityToken = (token: Token): boolean => {\n // by assetId\n if (typeof priorityAssets[0] === 'string') {\n return (priorityAssets as ReadonlyArray<string>).includes(token.assetId);\n }\n\n // by blockchain and symbol\n return (priorityAssets as ReadonlyArray<readonly [Chains, string]>).some(\n ([blockchain, symbol]) =>\n token.blockchain === blockchain &&\n token.symbol.toLowerCase() === symbol.toLowerCase(),\n );\n };\n\n const getPriorityIndex = (token: Token): number => {\n // by assetId\n if (typeof priorityAssets[0] === 'string') {\n return (priorityAssets as ReadonlyArray<string>).indexOf(token.assetId);\n }\n\n // by blockchain and symbol\n return (\n priorityAssets as ReadonlyArray<readonly [Chains, string]>\n ).findIndex(\n ([blockchain, symbol]) =>\n token.blockchain === blockchain &&\n token.symbol.toLowerCase() === symbol.toLowerCase(),\n );\n };\n\n const aIsPriority = isPriorityToken(a);\n const bIsPriority = isPriorityToken(b);\n\n if (aIsPriority && !bIsPriority) {\n return -1;\n }\n\n if (!aIsPriority && bIsPriority) {\n return 1;\n }\n\n // If both are priority tokens, maintain their relative order based on the priority list\n if (aIsPriority && bIsPriority) {\n const aIndex = getPriorityIndex(a);\n const bIndex = getPriorityIndex(b);\n\n if (aIndex !== bIndex) {\n return aIndex - bIndex;\n }\n }\n\n // Return null to indicate no priority difference, continue with other sorting criteria\n return null;\n};\n\nconst compareWithSearch = (\n a: Token,\n b: Token,\n searchLower: string | undefined,\n): number => {\n if (a.isIntent && !b.isIntent) {\n return -1;\n }\n\n if (!a.isIntent && b.isIntent) {\n return 1;\n }\n\n // sort alphabetically if no search\n if (!searchLower) {\n const symbolCompare = (a.symbol ?? '').localeCompare(\n b.symbol ?? '',\n undefined,\n {\n sensitivity: 'base',\n },\n );\n\n if (symbolCompare !== 0) {\n return symbolCompare;\n }\n\n return a.chainName.localeCompare(b.chainName, undefined, {\n sensitivity: 'base',\n });\n }\n\n const getSymbolRank = (symbol: string) => {\n if (symbol === searchLower) {\n return 0;\n }\n\n if (symbol.startsWith(searchLower)) {\n return 1;\n }\n\n if (symbol.includes(searchLower)) {\n return 2;\n }\n\n return 3;\n };\n\n const symbolRankA = getSymbolRank(a.symbol.toLowerCase());\n const symbolRankB = getSymbolRank(b.symbol.toLowerCase());\n\n // First compare by symbol match rank\n if (symbolRankA !== symbolRankB) {\n return symbolRankA - symbolRankB;\n }\n\n // Then compare alphabetically by symbol\n const symbolCompare = a.symbol\n .toLowerCase()\n .localeCompare(b.symbol.toLowerCase());\n\n if (symbolCompare !== 0) {\n return symbolCompare;\n }\n\n // Finally compare by blockchain\n return a.chainName.toLowerCase().localeCompare(b.chainName.toLowerCase());\n};\n\nconst sortTokens = (\n walletSupportedChains: ReadonlyArray<Chains>,\n priorityAssets: PriorityAssets,\n usdBalanceA: number | undefined,\n usdBalanceB: number | undefined,\n searchStr: string | undefined,\n a: Token,\n b: Token,\n): number => {\n const isIntent = a.isIntent || b.isIntent;\n const hasBalanceA = usdBalanceA !== undefined && usdBalanceA > 0;\n const hasBalanceB = usdBalanceB !== undefined && usdBalanceB > 0;\n\n // 1. Tokens with balance always come first\n if (hasBalanceA && !hasBalanceB) {\n return -1;\n }\n\n if (!hasBalanceA && hasBalanceB) {\n return 1;\n }\n\n // 2. If both have balance, sort by balance amount and other criteria\n if (hasBalanceA && hasBalanceB) {\n // Sort supported chains first\n const aSupported = walletSupportedChains.includes(a.blockchain);\n const bSupported = walletSupportedChains.includes(b.blockchain);\n\n if (!isIntent && aSupported && !bSupported) {\n return -1;\n }\n\n if (!isIntent && !aSupported && bSupported) {\n return 1;\n }\n\n // Compare non-zero balances\n if (usdBalanceA !== usdBalanceB) {\n return (usdBalanceB ?? 0) - (usdBalanceA ?? 0);\n }\n\n // If balances equal, sort by search/name\n return compareWithSearch(a, b, searchStr);\n }\n\n // 3. Both have no balance - prioritize by asset IDs or blockchain-symbol pairs (only for non-intent tokens)\n const priorityComparison = compareByPriority(a, b, priorityAssets);\n\n if (priorityComparison !== null) {\n return priorityComparison;\n }\n\n // 4. For tokens without balance and not in priority list, sort by supported chains\n const aSupported = walletSupportedChains.includes(a.blockchain);\n const bSupported = walletSupportedChains.includes(b.blockchain);\n\n if (!isIntent && aSupported && !bSupported) {\n return -1;\n }\n\n if (!isIntent && !aSupported && bSupported) {\n return 1;\n }\n\n // 5. Finally, sort alphabetically by search/name\n return compareWithSearch(a, b, searchStr);\n};\n\nexport const createTokenSorter = (\n tokensBalance: TokenBalances,\n walletSupportedChains: ReadonlyArray<Chains>,\n searchStr?: string | undefined,\n priorityAssets: PriorityAssets = [],\n) => {\n return (a: Token, b: Token) => {\n const recordA = tokensBalance[getTokenBalanceKey(a)];\n const recordB = tokensBalance[getTokenBalanceKey(b)];\n\n const balanceA = recordA ? formatUnits(recordA, a.decimals) : '0';\n const balanceB = recordB ? formatUnits(recordB, b.decimals) : '0';\n\n const usdBalanceA =\n recordA !== undefined\n ? parseFloat(`${balanceA ?? 0}`) * a.price\n : undefined;\n\n const usdBalanceB =\n recordB !== undefined\n ? parseFloat(`${balanceB ?? 0}`) * b.price\n : undefined;\n\n const searchLower = searchStr?.trim().toLowerCase() ?? undefined;\n\n return sortTokens(\n walletSupportedChains,\n priorityAssets,\n usdBalanceA,\n usdBalanceB,\n searchLower,\n a,\n b,\n );\n };\n};\n"],"names":["compareByPriority","a","b","priorityAssets","isPriorityToken","token","blockchain","symbol","getPriorityIndex","aIsPriority","bIsPriority","aIndex","bIndex","compareWithSearch","searchLower","symbolCompare","getSymbolRank","symbolRankA","symbolRankB","sortTokens","walletSupportedChains","usdBalanceA","usdBalanceB","searchStr","isIntent","hasBalanceA","hasBalanceB","aSupported","bSupported","priorityComparison","createTokenSorter","tokensBalance","recordA","getTokenBalanceKey","recordB","balanceA","formatUnits","balanceB"],"mappings":"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"}
|
|
@@ -3,13 +3,12 @@ import { useState as b, useEffect as p, useCallback as R } from "react";
|
|
|
3
3
|
import { useTokenModal as A } from "../../hooks/useTokenModal.js";
|
|
4
4
|
import { useTypedTranslation as F } from "../../localisation.js";
|
|
5
5
|
import { WidgetDepositSkeleton as S } from "./WidgetDepositSkeleton.js";
|
|
6
|
-
import { b as q, u as j, y as N, n as O, c as Q, p as U, o as K, S as P } from "../../config-
|
|
6
|
+
import { b as q, u as j, y as N, n as O, c as Q, p as U, o as K, S as P } from "../../config-C47AYcMK.js";
|
|
7
7
|
import "@tanstack/react-query";
|
|
8
8
|
import "@headlessui/react";
|
|
9
9
|
import "@material-symbols-svg/react-rounded/icons/chevron-left";
|
|
10
10
|
import "framer-motion";
|
|
11
11
|
import "../../features/ChainsDropdown/ChainItem.js";
|
|
12
|
-
import "@material-symbols-svg/react-rounded/icons/target";
|
|
13
12
|
import "../../utils/cn.js";
|
|
14
13
|
import "../../constants/chains.js";
|
|
15
14
|
import { notReachable as r } from "../../utils/notReachable.js";
|
|
@@ -36,6 +35,7 @@ import "../../components/InputAmount.js";
|
|
|
36
35
|
import "../../components/Notes.js";
|
|
37
36
|
import "@material-symbols-svg/react-rounded/icons/close";
|
|
38
37
|
import "@material-symbols-svg/react-rounded/icons/check-circle";
|
|
38
|
+
import "../../components/ChainShortcut.js";
|
|
39
39
|
import "zod";
|
|
40
40
|
import "../../utils/near/rpc.js";
|
|
41
41
|
import "../../index-DEq3oXQF.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import a from "clsx";
|
|
3
3
|
import { SkeletonBox as s } from "../../components/SkeletonBox.js";
|
|
4
|
-
import { y as i } from "../../config-
|
|
4
|
+
import { y as i } from "../../config-C47AYcMK.js";
|
|
5
5
|
const p = () => {
|
|
6
6
|
const { hideTokenInputHeadings: l } = i();
|
|
7
7
|
return /* @__PURE__ */ o("div", { className: "w-full gap-sw-xl relative flex flex-col", children: [
|
|
@@ -3,13 +3,12 @@ import { useState as S, useEffect as w } from "react";
|
|
|
3
3
|
import { useTokenModal as N } from "../../hooks/useTokenModal.js";
|
|
4
4
|
import { WidgetSwapSkeleton as T } from "./WidgetSwapSkeleton.js";
|
|
5
5
|
import { useTypedTranslation as O } from "../../localisation.js";
|
|
6
|
-
import { b as Q, u as j, y as q, n as F, c as U, p as b, o as K, S as P } from "../../config-
|
|
6
|
+
import { b as Q, u as j, y as q, n as F, c as U, p as b, o as K, S as P } from "../../config-C47AYcMK.js";
|
|
7
7
|
import "@tanstack/react-query";
|
|
8
8
|
import "@headlessui/react";
|
|
9
9
|
import "@material-symbols-svg/react-rounded/icons/chevron-left";
|
|
10
10
|
import "framer-motion";
|
|
11
11
|
import "../../features/ChainsDropdown/ChainItem.js";
|
|
12
|
-
import "@material-symbols-svg/react-rounded/icons/target";
|
|
13
12
|
import "../../utils/cn.js";
|
|
14
13
|
import "../../constants/chains.js";
|
|
15
14
|
import { notReachable as s } from "../../utils/notReachable.js";
|
|
@@ -51,6 +50,7 @@ import "../../components/Input.js";
|
|
|
51
50
|
import "../../components/InputAmount.js";
|
|
52
51
|
import "../../components/Notes.js";
|
|
53
52
|
import "@material-symbols-svg/react-rounded/icons/check-circle";
|
|
53
|
+
import "../../components/ChainShortcut.js";
|
|
54
54
|
import "@material-symbols-svg/react-rounded/icons/qr-code";
|
|
55
55
|
import "@material-symbols-svg/react-rounded/icons/wallet";
|
|
56
56
|
import { WalletCompatibilityCheck as Z } from "../../features/WalletCompatibilityCheck/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as a, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import o from "clsx";
|
|
3
3
|
import { SkeletonBox as s } from "../../components/SkeletonBox.js";
|
|
4
|
-
import { y as i } from "../../config-
|
|
4
|
+
import { y as i } from "../../config-C47AYcMK.js";
|
|
5
5
|
const m = () => {
|
|
6
6
|
const { hideTokenInputHeadings: e } = i();
|
|
7
7
|
return /* @__PURE__ */ a("div", { className: "w-full gap-sw-lg relative flex flex-col", children: [
|
|
@@ -3,13 +3,12 @@ import { useState as _, useEffect as b } from "react";
|
|
|
3
3
|
import { useTokenModal as N } from "../../hooks/useTokenModal.js";
|
|
4
4
|
import { WidgetWithdrawSkeleton as y } from "./WidgetWithdrawSkeleton.js";
|
|
5
5
|
import { useTypedTranslation as O } from "../../localisation.js";
|
|
6
|
-
import { b as Q, u as j, y as q, n as F, c as U, p as T, o as K, S as P } from "../../config-
|
|
6
|
+
import { b as Q, u as j, y as q, n as F, c as U, p as T, o as K, S as P } from "../../config-C47AYcMK.js";
|
|
7
7
|
import "@tanstack/react-query";
|
|
8
8
|
import "@headlessui/react";
|
|
9
9
|
import "@material-symbols-svg/react-rounded/icons/chevron-left";
|
|
10
10
|
import "framer-motion";
|
|
11
11
|
import "../../features/ChainsDropdown/ChainItem.js";
|
|
12
|
-
import "@material-symbols-svg/react-rounded/icons/target";
|
|
13
12
|
import "../../utils/cn.js";
|
|
14
13
|
import "../../constants/chains.js";
|
|
15
14
|
import { notReachable as r } from "../../utils/notReachable.js";
|
|
@@ -51,6 +50,7 @@ import "../../components/Input.js";
|
|
|
51
50
|
import "../../components/InputAmount.js";
|
|
52
51
|
import "../../components/Notes.js";
|
|
53
52
|
import "@material-symbols-svg/react-rounded/icons/check-circle";
|
|
53
|
+
import "../../components/ChainShortcut.js";
|
|
54
54
|
import "@material-symbols-svg/react-rounded/icons/qr-code";
|
|
55
55
|
import "@material-symbols-svg/react-rounded/icons/wallet";
|
|
56
56
|
import { WalletCompatibilityCheck as Z } from "../../features/WalletCompatibilityCheck/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import o from "clsx";
|
|
3
3
|
import { SkeletonBox as l } from "../../components/SkeletonBox.js";
|
|
4
|
-
import { y as x } from "../../config-
|
|
4
|
+
import { y as x } from "../../config-C47AYcMK.js";
|
|
5
5
|
const p = () => {
|
|
6
6
|
const { hideTokenInputHeadings: s } = x();
|
|
7
7
|
return /* @__PURE__ */ a("div", { className: "w-full gap-sw-xl relative flex flex-col", children: [
|
package/package.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const AllNetworksIcon = () => (
|
|
2
|
+
<div className="flex flex-wrap gap-y-0 gap-x-[2px] h-[17px] w-[16px]">
|
|
3
|
+
<div className="w-[7px] h-[7px] rounded-[2px] shrink-0 bg-sw-gray-900" />
|
|
4
|
+
<div className="w-[7px] h-[7px] rounded-[2px] shrink-0 bg-sw-gray-600" />
|
|
5
|
+
<div className="w-[7px] h-[7px] rounded-[2px] shrink-0 bg-sw-gray-600" />
|
|
6
|
+
<div className="w-[7px] h-[7px] rounded-[2px] shrink-0 bg-sw-gray-900" />
|
|
7
|
+
</div>
|
|
8
|
+
);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
|
|
3
|
+
import { AllNetworksIcon } from './AllNetworksIcon';
|
|
4
|
+
|
|
5
|
+
import { cn } from '@/utils/cn';
|
|
6
|
+
import { UNKNOWN_ICON } from '@/icons';
|
|
7
|
+
import { Icon } from '@/components/Icon';
|
|
8
|
+
import { useTypedTranslation } from '@/localisation';
|
|
9
|
+
|
|
10
|
+
type Props = {
|
|
11
|
+
label: string;
|
|
12
|
+
isSelected: boolean;
|
|
13
|
+
icon: ComponentProps<typeof Icon>['icon'];
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const Shortcut = ({ icon, label, isSelected, onClick }: Props) => {
|
|
18
|
+
return (
|
|
19
|
+
<li
|
|
20
|
+
onClick={onClick}
|
|
21
|
+
className={cn(
|
|
22
|
+
'w-[36px] h-[36px] p-sw-md rounded-sw-md cursor-pointer items-center justify-center flex transition-colors',
|
|
23
|
+
{
|
|
24
|
+
'bg-sw-gray-50': isSelected,
|
|
25
|
+
'bg-sw-gray-800 hover:bg-sw-gray-700': !isSelected,
|
|
26
|
+
},
|
|
27
|
+
)}>
|
|
28
|
+
<Icon
|
|
29
|
+
size={20}
|
|
30
|
+
radius={6}
|
|
31
|
+
label={label}
|
|
32
|
+
icon={icon ?? UNKNOWN_ICON}
|
|
33
|
+
className="bg-transparent"
|
|
34
|
+
/>
|
|
35
|
+
</li>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const AllChainsShortcut = ({
|
|
40
|
+
isSelected,
|
|
41
|
+
onClick,
|
|
42
|
+
}: {
|
|
43
|
+
isSelected: boolean;
|
|
44
|
+
onClick: () => void;
|
|
45
|
+
}) => {
|
|
46
|
+
const { t } = useTypedTranslation();
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
onClick={onClick}
|
|
51
|
+
className={cn(
|
|
52
|
+
'px-sw-lg gap-sw-sm flex h-[36px] cursor-pointer items-center rounded-sw-md text-sw-label-md transition-colors',
|
|
53
|
+
{
|
|
54
|
+
'bg-sw-gray-50 text-sw-gray-950': isSelected,
|
|
55
|
+
'bg-sw-gray-800 text-sw-gray-50 bg-sw-gray-800 hover:bg-sw-gray-700':
|
|
56
|
+
!isSelected,
|
|
57
|
+
},
|
|
58
|
+
)}>
|
|
59
|
+
<AllNetworksIcon />
|
|
60
|
+
{t('chain.all.label', 'All')}
|
|
61
|
+
</div>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const ChainShortcut = Object.assign(Shortcut, {
|
|
66
|
+
All: AllChainsShortcut,
|
|
67
|
+
});
|
package/src/components/index.ts
CHANGED
package/src/config.tsx
CHANGED
|
@@ -50,6 +50,19 @@ const DEFAULT_CONFIG: WidgetConfig = {
|
|
|
50
50
|
source: { external: 'wallet-supported', intents: 'none' },
|
|
51
51
|
target: { external: 'all', intents: 'none' },
|
|
52
52
|
},
|
|
53
|
+
|
|
54
|
+
topChainShortcuts: (intentsAccountType) => {
|
|
55
|
+
switch (intentsAccountType) {
|
|
56
|
+
case 'evm':
|
|
57
|
+
return ['eth', 'arb', 'avax', 'base'] as const;
|
|
58
|
+
case 'sol':
|
|
59
|
+
return ['sol', 'eth', 'btc', 'near'] as const;
|
|
60
|
+
case 'near':
|
|
61
|
+
return ['near', 'sol', 'eth', 'btc'] as const;
|
|
62
|
+
default:
|
|
63
|
+
return ['eth', 'btc', 'sol', 'near'] as const;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
53
66
|
};
|
|
54
67
|
|
|
55
68
|
type WidgetConfigContextType = { config: WidgetConfig };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { CheckFillW700 as Check } from '@material-symbols-svg/react-rounded/icons/check';
|
|
3
3
|
|
|
4
4
|
import { cn } from '@/utils/cn';
|
|
5
5
|
import { Icon } from '@/components/Icon';
|
|
@@ -13,12 +13,25 @@ type Props = {
|
|
|
13
13
|
isSelected: boolean;
|
|
14
14
|
chain: 'intents' | 'all' | Chains;
|
|
15
15
|
icon: string | React.ReactElement;
|
|
16
|
+
iconClassName?: string;
|
|
16
17
|
className?: string;
|
|
17
18
|
onMsg: (msg: Msg) => void;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export const ChainItem = React.forwardRef<HTMLButtonElement, Props>(
|
|
21
|
-
(
|
|
22
|
+
(
|
|
23
|
+
{
|
|
24
|
+
chain,
|
|
25
|
+
label,
|
|
26
|
+
icon,
|
|
27
|
+
iconClassName,
|
|
28
|
+
isFocused,
|
|
29
|
+
isSelected,
|
|
30
|
+
className,
|
|
31
|
+
onMsg,
|
|
32
|
+
},
|
|
33
|
+
ref,
|
|
34
|
+
) => (
|
|
22
35
|
<button
|
|
23
36
|
ref={ref}
|
|
24
37
|
type="button"
|
|
@@ -32,9 +45,9 @@ export const ChainItem = React.forwardRef<HTMLButtonElement, Props>(
|
|
|
32
45
|
},
|
|
33
46
|
className,
|
|
34
47
|
)}>
|
|
35
|
-
<Icon radius={10} label={label} icon={icon} />
|
|
48
|
+
<Icon radius={10} label={label} icon={icon} className={iconClassName} />
|
|
36
49
|
<span className="text-sw-label-md mr-auto">{label}</span>
|
|
37
|
-
{isSelected && <Check size={16} />}
|
|
50
|
+
{isSelected && <Check size={16} className="text-sw-status-success" />}
|
|
38
51
|
</button>
|
|
39
52
|
),
|
|
40
53
|
);
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { Fragment
|
|
1
|
+
import { Fragment } from 'react';
|
|
2
2
|
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/react';
|
|
3
3
|
import { ChevronLeftW700 as ChevronLeft } from '@material-symbols-svg/react-rounded/icons/chevron-left';
|
|
4
4
|
import { AnimatePresence, motion } from 'framer-motion';
|
|
5
5
|
|
|
6
6
|
import { ChainItem } from './ChainItem';
|
|
7
|
-
import { AllNetworksIcon } from './AllNetworksIcon';
|
|
8
7
|
import { useConfig } from '@/config';
|
|
9
8
|
import { Hr } from '@/components/Hr';
|
|
10
|
-
import {
|
|
9
|
+
import { AllNetworksIcon } from '@/components/AllNetworksIcon';
|
|
11
10
|
import { useChains } from '@/hooks/useChains';
|
|
12
11
|
import { notReachable } from '@/utils/notReachable';
|
|
13
12
|
import { useTypedTranslation } from '@/localisation';
|
|
14
|
-
import {
|
|
13
|
+
import { CHAIN_ICONS, UNKNOWN_ICON } from '@/icons';
|
|
15
14
|
import type { Chains, ChainsFilter } from '@/types/chain';
|
|
16
15
|
|
|
17
16
|
type Msg = { type: 'on_click_chain'; chain: 'all' | 'intents' | Chains };
|
|
@@ -32,11 +31,7 @@ export const ChainsDropdown = ({
|
|
|
32
31
|
const { t } = useTypedTranslation();
|
|
33
32
|
|
|
34
33
|
const chains = useChains(variant);
|
|
35
|
-
const { appIcon, appName
|
|
36
|
-
const selectedChain = useMemo(
|
|
37
|
-
() => chains.find((item) => item.id === selected),
|
|
38
|
-
[chains, selected],
|
|
39
|
-
);
|
|
34
|
+
const { appIcon, appName } = useConfig();
|
|
40
35
|
|
|
41
36
|
const hasIntentsAccountMenuItem = chainsFilter.intents !== 'none';
|
|
42
37
|
|
|
@@ -46,37 +41,10 @@ export const ChainsDropdown = ({
|
|
|
46
41
|
<div>
|
|
47
42
|
<MenuButton as={Fragment}>
|
|
48
43
|
{({ open: isOpen }) => (
|
|
49
|
-
<div className="py-sw-sm
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<Icon
|
|
55
|
-
radius={10}
|
|
56
|
-
icon={<AllNetworksIcon />}
|
|
57
|
-
label="All networks"
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
60
|
-
case 'intents':
|
|
61
|
-
return showIntentTokens ? (
|
|
62
|
-
<Icon radius={10} icon={appIcon} label={appName} />
|
|
63
|
-
) : null;
|
|
64
|
-
default:
|
|
65
|
-
return !selectedChain ? (
|
|
66
|
-
<Icon
|
|
67
|
-
radius={10}
|
|
68
|
-
icon={<AllNetworksIcon />}
|
|
69
|
-
label={t('chain.all.label', 'All networks')}
|
|
70
|
-
/>
|
|
71
|
-
) : (
|
|
72
|
-
<Icon
|
|
73
|
-
radius={10}
|
|
74
|
-
label={selectedChain.label}
|
|
75
|
-
icon={ASSET_ICONS[selected] ?? UNKNOWN_ICON}
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
})()}
|
|
44
|
+
<div className="py-sw-sm pr-sw-md pl-sw-lg gap-sw-xs flex h-[36px] cursor-pointer items-center rounded-sw-md bg-sw-gray-800 hover:bg-sw-gray-700">
|
|
45
|
+
<span className="text-sw-label-md text-sw-gray-50">
|
|
46
|
+
{t('chain.more.label', 'More')}
|
|
47
|
+
</span>
|
|
80
48
|
|
|
81
49
|
{isOpen ? (
|
|
82
50
|
<ChevronLeft
|
|
@@ -111,6 +79,7 @@ export const ChainsDropdown = ({
|
|
|
111
79
|
isSelected={selected === 'all'}
|
|
112
80
|
isFocused={focus}
|
|
113
81
|
icon={<AllNetworksIcon />}
|
|
82
|
+
iconClassName="bg-sw-gray-50"
|
|
114
83
|
onMsg={(msg) => {
|
|
115
84
|
switch (msg.type) {
|
|
116
85
|
case 'on_click_chain':
|
|
@@ -162,7 +131,7 @@ export const ChainsDropdown = ({
|
|
|
162
131
|
<ChainItem
|
|
163
132
|
chain={chain.id}
|
|
164
133
|
label={chain.label}
|
|
165
|
-
icon={
|
|
134
|
+
icon={CHAIN_ICONS[chain.id] ?? UNKNOWN_ICON}
|
|
166
135
|
isSelected={selected === chain.id}
|
|
167
136
|
isFocused={focus}
|
|
168
137
|
onMsg={(msg) => {
|