@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.
Files changed (41) hide show
  1. package/dist/components/BlockchainList/BlockchainList.helpers.d.ts +2 -1
  2. package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
  3. package/dist/constants/fonts.d.ts +0 -5
  4. package/dist/constants/fonts.d.ts.map +1 -1
  5. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
  6. package/dist/globalStyles.d.ts.map +1 -1
  7. package/dist/hooks/useTheme.d.ts.map +1 -1
  8. package/dist/index.d.ts +1 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +2 -2
  11. package/dist/index.js.map +4 -4
  12. package/dist/pages/WalletsPage.d.ts.map +1 -1
  13. package/dist/types/config.d.ts +1 -5
  14. package/dist/types/config.d.ts.map +1 -1
  15. package/dist/utils/common.d.ts +0 -3
  16. package/dist/utils/common.d.ts.map +1 -1
  17. package/dist/utils/configs.d.ts +1 -0
  18. package/dist/utils/configs.d.ts.map +1 -1
  19. package/dist/utils/wallets.d.ts +0 -2
  20. package/dist/utils/wallets.d.ts.map +1 -1
  21. package/package.json +7 -8
  22. package/src/components/BlockchainList/BlockchainList.helpers.ts +25 -6
  23. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +4 -4
  24. package/src/components/HeaderButtons/HeaderButtons.styles.ts +1 -1
  25. package/src/components/Quote/Quote.styles.ts +1 -1
  26. package/src/components/Slippage/Slippage.tsx +1 -1
  27. package/src/constants/fonts.ts +0 -84
  28. package/src/containers/WidgetProvider/WidgetProvider.tsx +2 -20
  29. package/src/globalStyles.ts +3 -1
  30. package/src/hooks/useBootstrap/useBootstrap.ts +1 -1
  31. package/src/hooks/useTheme.ts +1 -1
  32. package/src/index.ts +0 -2
  33. package/src/pages/SelectBlockchainPage.tsx +3 -3
  34. package/src/pages/WalletsPage.tsx +2 -34
  35. package/src/types/config.ts +1 -6
  36. package/src/utils/common.ts +0 -29
  37. package/src/utils/configs.ts +1 -0
  38. package/src/utils/wallets.ts +2 -53
  39. package/dist/hooks/useFontLoader.d.ts +0 -5
  40. package/dist/hooks/useFontLoader.d.ts.map +0 -1
  41. package/src/hooks/useFontLoader.ts +0 -40
@@ -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,5 +0,0 @@
1
- declare const useFontLoader: () => {
2
- handleLoadCustomFont: (fontName: string) => void;
3
- };
4
- export default useFontLoader;
5
- //# sourceMappingURL=useFontLoader.d.ts.map
@@ -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;