@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.
Files changed (42) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/components/BlockchainList/BlockchainList.helpers.d.ts +1 -2
  3. package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
  4. package/dist/constants/fonts.d.ts +5 -0
  5. package/dist/constants/fonts.d.ts.map +1 -1
  6. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
  7. package/dist/globalStyles.d.ts.map +1 -1
  8. package/dist/hooks/useFontLoader.d.ts +5 -0
  9. package/dist/hooks/useFontLoader.d.ts.map +1 -0
  10. package/dist/hooks/useTheme.d.ts.map +1 -1
  11. package/dist/index.d.ts +2 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -2
  14. package/dist/index.js.map +4 -4
  15. package/dist/pages/WalletsPage.d.ts.map +1 -1
  16. package/dist/types/config.d.ts +5 -1
  17. package/dist/types/config.d.ts.map +1 -1
  18. package/dist/utils/common.d.ts +3 -0
  19. package/dist/utils/common.d.ts.map +1 -1
  20. package/dist/utils/configs.d.ts +0 -1
  21. package/dist/utils/configs.d.ts.map +1 -1
  22. package/dist/utils/wallets.d.ts +2 -0
  23. package/dist/utils/wallets.d.ts.map +1 -1
  24. package/package.json +8 -7
  25. package/src/components/BlockchainList/BlockchainList.helpers.ts +6 -25
  26. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +4 -4
  27. package/src/components/HeaderButtons/HeaderButtons.styles.ts +1 -1
  28. package/src/components/Quote/Quote.styles.ts +1 -1
  29. package/src/components/Slippage/Slippage.tsx +1 -1
  30. package/src/constants/fonts.ts +84 -0
  31. package/src/containers/WidgetProvider/WidgetProvider.tsx +20 -2
  32. package/src/globalStyles.ts +1 -3
  33. package/src/hooks/useBootstrap/useBootstrap.ts +1 -1
  34. package/src/hooks/useFontLoader.ts +40 -0
  35. package/src/hooks/useTheme.ts +1 -1
  36. package/src/index.ts +2 -0
  37. package/src/pages/SelectBlockchainPage.tsx +3 -3
  38. package/src/pages/WalletsPage.tsx +34 -2
  39. package/src/types/config.ts +6 -1
  40. package/src/utils/common.ts +29 -0
  41. package/src/utils/configs.ts +0 -1
  42. package/src/utils/wallets.ts +53 -2
@@ -16,9 +16,17 @@ import type {
16
16
  WalletType,
17
17
  WalletTypes,
18
18
  } from '@rango-dev/wallets-shared';
19
- import type { BlockchainMeta, Token, WalletDetail } from 'rango-sdk';
19
+ import type {
20
+ BlockchainMeta,
21
+ Token,
22
+ TransactionType,
23
+ WalletDetail,
24
+ } from 'rango-sdk';
20
25
 
21
- import { WalletState as WalletStatus } from '@rango-dev/ui';
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
+ }