@rango-dev/widget-embedded 0.28.1 → 0.28.2-next.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/CHANGELOG.md +4 -0
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts +1 -2
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
- package/dist/constants/fonts.d.ts +5 -0
- package/dist/constants/fonts.d.ts.map +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/useFontLoader.d.ts +5 -0
- package/dist/hooks/useFontLoader.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.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/types/config.d.ts +5 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +3 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +0 -1
- package/dist/utils/configs.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 +8 -7
- 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/components/Slippage/Slippage.tsx +1 -1
- package/src/constants/fonts.ts +84 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +20 -2
- package/src/globalStyles.ts +1 -3
- package/src/hooks/useBootstrap/useBootstrap.ts +1 -1
- package/src/hooks/useFontLoader.ts +40 -0
- package/src/hooks/useTheme.ts +1 -1
- package/src/index.ts +2 -0
- package/src/pages/SelectBlockchainPage.tsx +3 -3
- package/src/pages/WalletsPage.tsx +34 -2
- package/src/types/config.ts +6 -1
- package/src/utils/common.ts +29 -0
- package/src/utils/configs.ts +0 -1
- package/src/utils/wallets.ts +53 -2
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
|
+
}
|