@rango-dev/widget-embedded 0.28.2-next.0 → 0.28.2
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/BlockchainList/BlockchainList.helpers.d.ts +2 -1
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
- package/dist/constants/fonts.d.ts +0 -5
- 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/useTheme.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- 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 +1 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +0 -3
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +1 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +0 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +7 -8
- package/src/components/BlockchainList/BlockchainList.helpers.ts +25 -6
- 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 +0 -84
- package/src/containers/WidgetProvider/WidgetProvider.tsx +2 -20
- package/src/globalStyles.ts +3 -1
- package/src/hooks/useBootstrap/useBootstrap.ts +1 -1
- package/src/hooks/useTheme.ts +1 -1
- package/src/index.ts +0 -2
- package/src/pages/SelectBlockchainPage.tsx +3 -3
- package/src/pages/WalletsPage.tsx +2 -34
- package/src/types/config.ts +1 -6
- package/src/utils/common.ts +0 -29
- package/src/utils/configs.ts +1 -0
- package/src/utils/wallets.ts +2 -53
- package/dist/hooks/useFontLoader.d.ts +0 -5
- package/dist/hooks/useFontLoader.d.ts.map +0 -1
- package/src/hooks/useFontLoader.ts +0 -40
package/src/utils/wallets.ts
CHANGED
|
@@ -16,17 +16,9 @@ import type {
|
|
|
16
16
|
WalletType,
|
|
17
17
|
WalletTypes,
|
|
18
18
|
} from '@rango-dev/wallets-shared';
|
|
19
|
-
import type {
|
|
20
|
-
BlockchainMeta,
|
|
21
|
-
Token,
|
|
22
|
-
TransactionType,
|
|
23
|
-
WalletDetail,
|
|
24
|
-
} from 'rango-sdk';
|
|
19
|
+
import type { BlockchainMeta, Token, WalletDetail } from 'rango-sdk';
|
|
25
20
|
|
|
26
|
-
import {
|
|
27
|
-
BlockchainCategories,
|
|
28
|
-
WalletState as WalletStatus,
|
|
29
|
-
} from '@rango-dev/ui';
|
|
21
|
+
import { WalletState as WalletStatus } from '@rango-dev/ui';
|
|
30
22
|
import { readAccountAddress } from '@rango-dev/wallets-react';
|
|
31
23
|
import {
|
|
32
24
|
detectInstallLink,
|
|
@@ -47,7 +39,6 @@ import {
|
|
|
47
39
|
} from '../constants/routing';
|
|
48
40
|
import { EXCLUDED_WALLETS } from '../constants/wallets';
|
|
49
41
|
|
|
50
|
-
import { isBlockchainTypeInCategory, removeDuplicateFrom } from './common';
|
|
51
42
|
import { numberToString } from './numbers';
|
|
52
43
|
|
|
53
44
|
export function mapStatusToWalletState(state: WalletState): WalletStatus {
|
|
@@ -73,7 +64,6 @@ export function mapWalletTypesToWalletInfo(
|
|
|
73
64
|
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet as WalletTypes))
|
|
74
65
|
.filter((wallet) => {
|
|
75
66
|
const { supportedChains, isContractWallet } = getWalletInfo(wallet);
|
|
76
|
-
|
|
77
67
|
const { installed, network } = getState(wallet);
|
|
78
68
|
const filterContractWallets =
|
|
79
69
|
isContractWallet && (!installed || (!!chain && network !== chain));
|
|
@@ -95,12 +85,7 @@ export function mapWalletTypesToWalletInfo(
|
|
|
95
85
|
showOnMobile,
|
|
96
86
|
namespaces,
|
|
97
87
|
singleNamespace,
|
|
98
|
-
supportedChains,
|
|
99
88
|
} = getWalletInfo(type);
|
|
100
|
-
const blockchainTypes = removeDuplicateFrom(
|
|
101
|
-
supportedChains.map((item) => item.type)
|
|
102
|
-
);
|
|
103
|
-
|
|
104
89
|
const state = mapStatusToWalletState(getState(type));
|
|
105
90
|
return {
|
|
106
91
|
title: name,
|
|
@@ -111,7 +96,6 @@ export function mapWalletTypesToWalletInfo(
|
|
|
111
96
|
showOnMobile,
|
|
112
97
|
namespaces,
|
|
113
98
|
singleNamespace,
|
|
114
|
-
blockchainTypes,
|
|
115
99
|
};
|
|
116
100
|
});
|
|
117
101
|
}
|
|
@@ -554,38 +538,3 @@ export const isFetchingBalance = (
|
|
|
554
538
|
export function hashWalletsState(walletsInfo: ModalWalletInfo[]) {
|
|
555
539
|
return walletsInfo.map((w) => w.state).join('-');
|
|
556
540
|
}
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useFontLoader.d.ts","sourceRoot":"","sources":["../../src/hooks/useFontLoader.ts"],"names":[],"mappings":"AASA,QAAA,MAAM,aAAa;qCAkBuB,MAAM;CAU/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { getFontUrlByName } from '../utils/common';
|
|
4
|
-
/*
|
|
5
|
-
*TODO:
|
|
6
|
-
* Loading fonts from JS has a downside and it is the bundle needs to be downloaded and executed first which means after sometime font will be added to <head /> and it causes a layoutshift each time.
|
|
7
|
-
* We've added Roboto into <head /> since it's the default font. the downside here is it will load roboto anyway even dApp has set fontFamily other than Roboto which causes an unneccerary downloand (Roboto).
|
|
8
|
-
* We decided to go with the second one and it can be solved in future by split these types of configs into a separate js file and let it to be loaded with a more priority than the main bundle. it should be also cached which imrpove user experience after first load.
|
|
9
|
-
*/
|
|
10
|
-
const useFontLoader = () => {
|
|
11
|
-
const [fontLink, setFontLink] = useState<HTMLLinkElement | null>(null);
|
|
12
|
-
|
|
13
|
-
const loadFont = (fontUrl: string) => {
|
|
14
|
-
const link = document.createElement('link');
|
|
15
|
-
link.href = fontUrl;
|
|
16
|
-
link.rel = 'stylesheet';
|
|
17
|
-
document.head.appendChild(link);
|
|
18
|
-
return link;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const unloadFont = () => {
|
|
22
|
-
if (fontLink) {
|
|
23
|
-
document.head.removeChild(fontLink);
|
|
24
|
-
setFontLink(null);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const handleLoadCustomFont = (fontName: string) => {
|
|
29
|
-
unloadFont(); // Remove previous font
|
|
30
|
-
const fontUrl = getFontUrlByName(fontName);
|
|
31
|
-
if (fontUrl) {
|
|
32
|
-
const newFontLink = loadFont(fontUrl);
|
|
33
|
-
setFontLink(newFontLink);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return { handleLoadCustomFont };
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default useFontLoader;
|