@rango-dev/widget-embedded 0.28.0 → 0.28.1-next.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/CHANGELOG.md +22 -0
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts +1 -2
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/utils/common.d.ts +2 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -0
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/BlockchainList/BlockchainList.helpers.ts +6 -25
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +4 -4
- package/src/components/HeaderButtons/HeaderButtons.styles.ts +1 -1
- package/src/components/Quote/Quote.styles.ts +1 -1
- package/src/pages/SelectBlockchainPage.tsx +3 -3
- package/src/pages/WalletsPage.tsx +34 -2
- package/src/utils/common.ts +23 -0
- package/src/utils/wallets.ts +53 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"WalletsPage.d.ts","sourceRoot":"","sources":["../../src/pages/WalletsPage.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAkCxC,eAAO,MAAM,mBAAmB,OAAQ,CAAC;AACzC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,wBAAgB,WAAW,sBAyH1B"}
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Token } from 'rango-sdk';
|
|
2
|
+
import { TransactionType } from 'rango-sdk';
|
|
2
3
|
export declare function removeDuplicateFrom<T>(array: T[]): T[];
|
|
3
4
|
export declare function areEqual(array1: (number | string)[], array2: (number | string)[]): boolean;
|
|
4
5
|
export declare function debounce(fn: Function, time: number): (...args: any) => void;
|
|
@@ -8,4 +9,5 @@ export declare function startWithText(text: string, searchText: string): boolean
|
|
|
8
9
|
export declare const getContainer: () => HTMLElement;
|
|
9
10
|
export declare const getExpanded: () => HTMLElement;
|
|
10
11
|
export declare function compareWithSearchFor(tokenA: Token, tokenB: Token, searchFor?: string): number;
|
|
12
|
+
export declare const isBlockchainTypeInCategory: (blockchainType: TransactionType, category: string) => boolean;
|
|
11
13
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAW5C,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAEtD;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC3B,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAK5B;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,aAGvB,GAAG,UAS9B;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAGtE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED,eAAO,MAAM,YAAY,mBACyC,CAAC;AAEnE,eAAO,MAAM,WAAW,mBAC8C,CAAC;AAsDvE,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,KAAK,EACb,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CA0GR;AAED,eAAO,MAAM,0BAA0B,mBACrB,eAAe,YACrB,MAAM,KACf,OAeF,CAAC"}
|
package/dist/utils/wallets.d.ts
CHANGED
|
@@ -33,4 +33,6 @@ export declare function createTokenHash(token: Asset): TokenHash;
|
|
|
33
33
|
export declare function makeTokensBalance(connectedWallets: ConnectedWallet[]): TokensBalance;
|
|
34
34
|
export declare const isFetchingBalance: (connectedWallets: ConnectedWallet[], blockchain: string) => boolean;
|
|
35
35
|
export declare function hashWalletsState(walletsInfo: ModalWalletInfo[]): string;
|
|
36
|
+
export declare function filterBlockchainsByWalletTypes(wallets: ModalWalletInfo[], blockchains: BlockchainMeta[]): BlockchainMeta[];
|
|
37
|
+
export declare function filterWalletsByCategory(wallets: WalletInfoWithNamespaces[], category: string): WalletInfoWithNamespaces[];
|
|
36
38
|
//# sourceMappingURL=wallets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/utils/wallets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,SAAS,EACT,aAAa,EACb,MAAM,EACN,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,UAAU,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,UAAU,EAEX,MAAM,2BAA2B,CAAC;AACnC,OAAO,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GACjB,MAAM,CAOR;AAED,wBAAgB,UAAU,CAAC,EACzB,KAAK,EACL,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,MAAM,GAAG,SAAS,CAMrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAEvD;AAED,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,eAAe,EAAE,iBAmCpE;AAED,eAAO,MAAM,iBAAiB,qBACV,eAAe,EAAE,cACvB,MAAM,YAIjB,CAAC;AAEJ,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,eAAe,EAAE,UAE9D;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,eAAe,EAAE,EAC1B,WAAW,EAAE,cAAc,EAAE,oBAa9B;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,EAAE,EACnC,QAAQ,EAAE,MAAM,8BAcjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.1-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.26.0",
|
|
30
30
|
"@rango-dev/queue-manager-rango-preset": "^0.33.0",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
32
|
-
"@rango-dev/ui": "^0.34.
|
|
32
|
+
"@rango-dev/ui": "^0.34.1-next.1",
|
|
33
33
|
"@rango-dev/wallets-react": "^0.19.0",
|
|
34
34
|
"@rango-dev/wallets-shared": "^0.33.0",
|
|
35
35
|
"bignumber.js": "^9.1.1",
|
|
@@ -1,35 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type BlockchainMeta, TransactionType } from 'rango-sdk';
|
|
1
|
+
import { type BlockchainMeta } from 'rango-sdk';
|
|
3
2
|
|
|
4
|
-
import { containsText } from '../../utils/common';
|
|
5
|
-
|
|
6
|
-
export const filterByType = (
|
|
7
|
-
blockchain: BlockchainMeta,
|
|
8
|
-
type: string
|
|
9
|
-
): boolean => {
|
|
10
|
-
switch (type) {
|
|
11
|
-
case BlockchainCategories.ALL:
|
|
12
|
-
return true;
|
|
13
|
-
case BlockchainCategories.UTXO:
|
|
14
|
-
return blockchain.type === TransactionType.TRANSFER;
|
|
15
|
-
case BlockchainCategories.OTHER:
|
|
16
|
-
return (
|
|
17
|
-
blockchain.type !== TransactionType.TRANSFER &&
|
|
18
|
-
blockchain.type !== TransactionType.COSMOS &&
|
|
19
|
-
blockchain.type !== TransactionType.EVM
|
|
20
|
-
);
|
|
21
|
-
default:
|
|
22
|
-
return blockchain.type === type;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
3
|
+
import { containsText, isBlockchainTypeInCategory } from '../../utils/common';
|
|
25
4
|
|
|
26
5
|
export const filterBlockchains = (
|
|
27
6
|
list: BlockchainMeta[],
|
|
28
7
|
searchedFor: string,
|
|
29
|
-
|
|
8
|
+
blockchainCategory: string
|
|
30
9
|
) =>
|
|
31
10
|
list
|
|
32
|
-
.filter((blockchain) =>
|
|
11
|
+
.filter((blockchain) =>
|
|
12
|
+
isBlockchainTypeInCategory(blockchain.type, blockchainCategory)
|
|
13
|
+
)
|
|
33
14
|
.filter(
|
|
34
15
|
(blockchain) =>
|
|
35
16
|
containsText(blockchain.name, searchedFor) ||
|
|
@@ -34,7 +34,7 @@ export const WalletButton = styled('button', {
|
|
|
34
34
|
position: 'relative',
|
|
35
35
|
|
|
36
36
|
'&:hover': {
|
|
37
|
-
$$color: '$colors$
|
|
37
|
+
$$color: '$colors$secondary100',
|
|
38
38
|
[`.${darkTheme} &`]: {
|
|
39
39
|
$$color: '$colors$neutral100',
|
|
40
40
|
},
|
|
@@ -42,7 +42,7 @@ export const WalletButton = styled('button', {
|
|
|
42
42
|
},
|
|
43
43
|
|
|
44
44
|
'&:focus-visible': {
|
|
45
|
-
$$color: '$colors$
|
|
45
|
+
$$color: '$colors$secondary100',
|
|
46
46
|
[`.${darkTheme} &`]: {
|
|
47
47
|
$$color: '$colors$info700',
|
|
48
48
|
},
|
|
@@ -138,14 +138,14 @@ export const CustomDestinationButton = styled('div', {
|
|
|
138
138
|
borderBottomRightRadius: '0',
|
|
139
139
|
borderBottomLeftRadius: '0',
|
|
140
140
|
'&:hover': {
|
|
141
|
-
$$color: '$colors$
|
|
141
|
+
$$color: '$colors$secondary100',
|
|
142
142
|
[`.${darkTheme} &`]: {
|
|
143
143
|
$$color: '$colors$neutral100',
|
|
144
144
|
},
|
|
145
145
|
backgroundColor: '$$color',
|
|
146
146
|
},
|
|
147
147
|
'&:focus-visible': {
|
|
148
|
-
$$background: '$colors$
|
|
148
|
+
$$background: '$colors$secondary100',
|
|
149
149
|
[`.${darkTheme} &`]: {
|
|
150
150
|
$$background: '$colors$info700',
|
|
151
151
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i18n } from '@lingui/core';
|
|
2
2
|
import {
|
|
3
3
|
Divider,
|
|
4
|
-
|
|
4
|
+
getCategoriesCount,
|
|
5
5
|
SelectableCategoryList,
|
|
6
6
|
} from '@rango-dev/ui';
|
|
7
7
|
import React, { useState } from 'react';
|
|
@@ -30,9 +30,9 @@ export function SelectBlockchainPage(props: PropTypes) {
|
|
|
30
30
|
type,
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const activeCategoriesCount = getCategoriesCount(blockchains);
|
|
34
34
|
|
|
35
|
-
const showCategory =
|
|
35
|
+
const showCategory = activeCategoriesCount !== 1;
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
38
|
<Layout
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { Namespace, WalletType } from '@rango-dev/wallets-shared';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Divider,
|
|
6
|
+
getCategoriesCount,
|
|
7
|
+
SelectableCategoryList,
|
|
8
|
+
styled,
|
|
9
|
+
Typography,
|
|
10
|
+
Wallet,
|
|
11
|
+
WalletState,
|
|
12
|
+
} from '@rango-dev/ui';
|
|
5
13
|
import React, { useState } from 'react';
|
|
6
14
|
|
|
7
15
|
import { Layout, PageContainer } from '../components/Layout';
|
|
@@ -11,6 +19,10 @@ import { useWalletList } from '../hooks/useWalletList';
|
|
|
11
19
|
import { useAppStore } from '../store/AppStore';
|
|
12
20
|
import { useUiStore } from '../store/ui';
|
|
13
21
|
import { getContainer } from '../utils/common';
|
|
22
|
+
import {
|
|
23
|
+
filterBlockchainsByWalletTypes,
|
|
24
|
+
filterWalletsByCategory,
|
|
25
|
+
} from '../utils/wallets';
|
|
14
26
|
|
|
15
27
|
interface NamespacesModalState {
|
|
16
28
|
providerType: string;
|
|
@@ -37,6 +49,9 @@ export const TIME_TO_IGNORE_MODAL = 300;
|
|
|
37
49
|
|
|
38
50
|
export function WalletsPage() {
|
|
39
51
|
const { fetchStatus: fetchMetaStatus } = useAppStore();
|
|
52
|
+
const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
|
|
53
|
+
const blockchains = useAppStore().blockchains();
|
|
54
|
+
|
|
40
55
|
const [openModal, setOpenModal] = useState(false);
|
|
41
56
|
const [namespacesModalState, setNamespacesModalState] =
|
|
42
57
|
useState<NamespacesModalState | null>(null);
|
|
@@ -74,17 +89,34 @@ export function WalletsPage() {
|
|
|
74
89
|
const selectedWalletState =
|
|
75
90
|
selectedWallet?.state || WalletState.NOT_INSTALLED;
|
|
76
91
|
|
|
92
|
+
const filteredBlockchains = filterBlockchainsByWalletTypes(list, blockchains);
|
|
93
|
+
const activeCategoriesCount = getCategoriesCount(filteredBlockchains);
|
|
94
|
+
const showCategory = activeCategoriesCount !== 1;
|
|
95
|
+
|
|
96
|
+
const filteredWallets = filterWalletsByCategory(list, blockchainCategory);
|
|
97
|
+
|
|
77
98
|
return (
|
|
78
99
|
<Layout
|
|
79
100
|
header={{
|
|
80
101
|
title: i18n.t('Connect Wallets'),
|
|
81
102
|
}}>
|
|
82
103
|
<Container>
|
|
104
|
+
{showCategory && (
|
|
105
|
+
<>
|
|
106
|
+
<SelectableCategoryList
|
|
107
|
+
setCategory={setBlockchainCategory}
|
|
108
|
+
category={blockchainCategory}
|
|
109
|
+
blockchains={filteredBlockchains}
|
|
110
|
+
isLoading={fetchMetaStatus === 'loading'}
|
|
111
|
+
/>
|
|
112
|
+
<Divider size={24} />
|
|
113
|
+
</>
|
|
114
|
+
)}
|
|
83
115
|
<Typography variant="title" size="xmedium" align="center">
|
|
84
116
|
{i18n.t('Choose a wallet to connect.')}
|
|
85
117
|
</Typography>
|
|
86
118
|
<ListContainer>
|
|
87
|
-
{
|
|
119
|
+
{filteredWallets.map((wallet, index) => {
|
|
88
120
|
const key = `wallet-${index}-${wallet.type}`;
|
|
89
121
|
return (
|
|
90
122
|
<Wallet
|
package/src/utils/common.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Token } from 'rango-sdk';
|
|
2
2
|
|
|
3
|
+
import { BlockchainCategories } from '@rango-dev/ui';
|
|
4
|
+
import { TransactionType } from 'rango-sdk';
|
|
5
|
+
|
|
3
6
|
import { WIDGET_UI_ID } from '../constants';
|
|
4
7
|
import {
|
|
5
8
|
MIN_LENGTH_SYMBOL_CONTAINS,
|
|
@@ -218,3 +221,23 @@ export function compareWithSearchFor(
|
|
|
218
221
|
|
|
219
222
|
return 0;
|
|
220
223
|
}
|
|
224
|
+
|
|
225
|
+
export const isBlockchainTypeInCategory = (
|
|
226
|
+
blockchainType: TransactionType,
|
|
227
|
+
category: string
|
|
228
|
+
): boolean => {
|
|
229
|
+
switch (category) {
|
|
230
|
+
case BlockchainCategories.ALL:
|
|
231
|
+
return true;
|
|
232
|
+
case BlockchainCategories.UTXO:
|
|
233
|
+
return blockchainType === TransactionType.TRANSFER;
|
|
234
|
+
case BlockchainCategories.OTHER:
|
|
235
|
+
return (
|
|
236
|
+
blockchainType !== TransactionType.TRANSFER &&
|
|
237
|
+
blockchainType !== TransactionType.COSMOS &&
|
|
238
|
+
blockchainType !== TransactionType.EVM
|
|
239
|
+
);
|
|
240
|
+
default:
|
|
241
|
+
return blockchainType === category;
|
|
242
|
+
}
|
|
243
|
+
};
|
package/src/utils/wallets.ts
CHANGED
|
@@ -16,9 +16,17 @@ import type {
|
|
|
16
16
|
WalletType,
|
|
17
17
|
WalletTypes,
|
|
18
18
|
} from '@rango-dev/wallets-shared';
|
|
19
|
-
import type {
|
|
19
|
+
import type {
|
|
20
|
+
BlockchainMeta,
|
|
21
|
+
Token,
|
|
22
|
+
TransactionType,
|
|
23
|
+
WalletDetail,
|
|
24
|
+
} from 'rango-sdk';
|
|
20
25
|
|
|
21
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
BlockchainCategories,
|
|
28
|
+
WalletState as WalletStatus,
|
|
29
|
+
} from '@rango-dev/ui';
|
|
22
30
|
import { readAccountAddress } from '@rango-dev/wallets-react';
|
|
23
31
|
import {
|
|
24
32
|
detectInstallLink,
|
|
@@ -39,6 +47,7 @@ import {
|
|
|
39
47
|
} from '../constants/routing';
|
|
40
48
|
import { EXCLUDED_WALLETS } from '../constants/wallets';
|
|
41
49
|
|
|
50
|
+
import { isBlockchainTypeInCategory, removeDuplicateFrom } from './common';
|
|
42
51
|
import { numberToString } from './numbers';
|
|
43
52
|
|
|
44
53
|
export function mapStatusToWalletState(state: WalletState): WalletStatus {
|
|
@@ -64,6 +73,7 @@ export function mapWalletTypesToWalletInfo(
|
|
|
64
73
|
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet as WalletTypes))
|
|
65
74
|
.filter((wallet) => {
|
|
66
75
|
const { supportedChains, isContractWallet } = getWalletInfo(wallet);
|
|
76
|
+
|
|
67
77
|
const { installed, network } = getState(wallet);
|
|
68
78
|
const filterContractWallets =
|
|
69
79
|
isContractWallet && (!installed || (!!chain && network !== chain));
|
|
@@ -85,7 +95,12 @@ export function mapWalletTypesToWalletInfo(
|
|
|
85
95
|
showOnMobile,
|
|
86
96
|
namespaces,
|
|
87
97
|
singleNamespace,
|
|
98
|
+
supportedChains,
|
|
88
99
|
} = getWalletInfo(type);
|
|
100
|
+
const blockchainTypes = removeDuplicateFrom(
|
|
101
|
+
supportedChains.map((item) => item.type)
|
|
102
|
+
);
|
|
103
|
+
|
|
89
104
|
const state = mapStatusToWalletState(getState(type));
|
|
90
105
|
return {
|
|
91
106
|
title: name,
|
|
@@ -96,6 +111,7 @@ export function mapWalletTypesToWalletInfo(
|
|
|
96
111
|
showOnMobile,
|
|
97
112
|
namespaces,
|
|
98
113
|
singleNamespace,
|
|
114
|
+
blockchainTypes,
|
|
99
115
|
};
|
|
100
116
|
});
|
|
101
117
|
}
|
|
@@ -538,3 +554,38 @@ export const isFetchingBalance = (
|
|
|
538
554
|
export function hashWalletsState(walletsInfo: ModalWalletInfo[]) {
|
|
539
555
|
return walletsInfo.map((w) => w.state).join('-');
|
|
540
556
|
}
|
|
557
|
+
|
|
558
|
+
export function filterBlockchainsByWalletTypes(
|
|
559
|
+
wallets: ModalWalletInfo[],
|
|
560
|
+
blockchains: BlockchainMeta[]
|
|
561
|
+
) {
|
|
562
|
+
const uniqueBlockchainTypes = new Set<TransactionType>();
|
|
563
|
+
wallets.forEach((wallet) => {
|
|
564
|
+
wallet.blockchainTypes.forEach((type) => {
|
|
565
|
+
uniqueBlockchainTypes.add(type);
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
const filteredBlockchains = blockchains.filter((blockchain) =>
|
|
569
|
+
uniqueBlockchainTypes.has(blockchain.type)
|
|
570
|
+
);
|
|
571
|
+
|
|
572
|
+
return filteredBlockchains;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
export function filterWalletsByCategory(
|
|
576
|
+
wallets: WalletInfoWithNamespaces[],
|
|
577
|
+
category: string
|
|
578
|
+
) {
|
|
579
|
+
if (category === BlockchainCategories.ALL) {
|
|
580
|
+
return wallets;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
return wallets.filter((wallet) => {
|
|
584
|
+
for (const type of wallet.blockchainTypes) {
|
|
585
|
+
if (isBlockchainTypeInCategory(type, category)) {
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return false;
|
|
590
|
+
});
|
|
591
|
+
}
|