@rango-dev/widget-embedded 0.36.1-next.7 → 0.37.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 (123) hide show
  1. package/dist/QueueManager.d.ts.map +1 -1
  2. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  4. package/dist/components/Layout/Layout.d.ts.map +1 -1
  5. package/dist/components/Quote/Quote.d.ts.map +1 -1
  6. package/dist/components/Quote/Quote.styles.d.ts +1 -1
  7. package/dist/components/Quote/Quote.types.d.ts +0 -2
  8. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  9. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  10. package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
  11. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
  12. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  13. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +1 -1
  14. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
  15. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  16. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +1 -2
  17. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
  18. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +1 -1
  19. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  20. package/dist/constants/quote.d.ts +0 -2
  21. package/dist/constants/quote.d.ts.map +1 -1
  22. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
  23. package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
  24. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  25. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
  26. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +2 -2
  27. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
  28. package/dist/hooks/useFetchCustomToken.d.ts.map +1 -1
  29. package/dist/hooks/useObserveBalanceChanges/index.d.ts +2 -0
  30. package/dist/hooks/useObserveBalanceChanges/index.d.ts.map +1 -0
  31. package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts +4 -0
  32. package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts.map +1 -0
  33. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -2
  34. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  35. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +1 -1
  36. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  37. package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
  38. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  39. package/dist/hooks/useWalletList.d.ts.map +1 -1
  40. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +2 -1
  41. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
  42. package/dist/index.d.ts +1 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +2 -2
  45. package/dist/index.js.map +4 -4
  46. package/dist/pages/Home.d.ts.map +1 -1
  47. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  48. package/dist/store/app.d.ts +4 -2
  49. package/dist/store/app.d.ts.map +1 -1
  50. package/dist/store/slices/config.d.ts.map +1 -1
  51. package/dist/store/slices/data.d.ts.map +1 -1
  52. package/dist/store/wallets.d.ts +66 -0
  53. package/dist/store/wallets.d.ts.map +1 -0
  54. package/dist/types/config.d.ts +3 -6
  55. package/dist/types/config.d.ts.map +1 -1
  56. package/dist/types/wallets.d.ts +2 -3
  57. package/dist/types/wallets.d.ts.map +1 -1
  58. package/dist/utils/providers.d.ts +8 -3
  59. package/dist/utils/providers.d.ts.map +1 -1
  60. package/dist/utils/settings.d.ts +0 -1
  61. package/dist/utils/settings.d.ts.map +1 -1
  62. package/dist/utils/swap.d.ts +1 -1
  63. package/dist/utils/swap.d.ts.map +1 -1
  64. package/dist/utils/wallets.d.ts +14 -12
  65. package/dist/utils/wallets.d.ts.map +1 -1
  66. package/dist/widget-embedded.build.json +1 -1
  67. package/package.json +7 -7
  68. package/src/QueueManager.tsx +7 -12
  69. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -3
  70. package/src/components/ConfirmWalletsModal/WalletList.tsx +7 -10
  71. package/src/components/Layout/Layout.tsx +3 -1
  72. package/src/components/Quote/Quote.tsx +3 -22
  73. package/src/components/Quote/Quote.types.ts +0 -2
  74. package/src/components/Quote/QuoteCostDetails.styles.ts +1 -0
  75. package/src/components/Quote/QuoteCostDetails.tsx +4 -23
  76. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
  77. package/src/components/SwapDetails/SwapDetails.tsx +1 -6
  78. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
  79. package/src/components/TokenList/TokenList.tsx +27 -4
  80. package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +1 -2
  81. package/src/components/WalletStatefulConnect/Namespaces.tsx +1 -1
  82. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +1 -1
  83. package/src/constants/quote.ts +0 -2
  84. package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +0 -1
  85. package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +1 -1
  86. package/src/containers/Inputs/Inputs.tsx +7 -20
  87. package/src/containers/Wallets/Wallets.tsx +14 -20
  88. package/src/containers/WidgetInfo/WidgetInfo.tsx +8 -10
  89. package/src/containers/WidgetInfo/WidgetInfo.types.ts +2 -2
  90. package/src/hooks/useFetchCustomToken.ts +0 -5
  91. package/src/hooks/useObserveBalanceChanges/index.ts +1 -0
  92. package/src/hooks/useObserveBalanceChanges/useObserveBalanceChanges.ts +68 -0
  93. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +7 -42
  94. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +1 -1
  95. package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +6 -7
  96. package/src/hooks/useSwapInput.ts +2 -1
  97. package/src/hooks/useWalletList.ts +3 -1
  98. package/src/hooks/useWalletProviders/useWalletProviders.ts +7 -3
  99. package/src/index.ts +1 -1
  100. package/src/pages/Home.tsx +3 -5
  101. package/src/pages/SelectSwapItemsPage.tsx +2 -1
  102. package/src/store/app.ts +4 -4
  103. package/src/store/slices/config.ts +0 -3
  104. package/src/store/slices/data.ts +2 -3
  105. package/src/store/wallets.ts +268 -0
  106. package/src/types/config.ts +3 -7
  107. package/src/types/wallets.ts +2 -3
  108. package/src/utils/providers.ts +12 -68
  109. package/src/utils/settings.ts +0 -4
  110. package/src/utils/swap.ts +1 -1
  111. package/src/utils/wallets.ts +137 -74
  112. package/dist/store/slices/types.d.ts +0 -6
  113. package/dist/store/slices/types.d.ts.map +0 -1
  114. package/dist/store/slices/wallets.d.ts +0 -58
  115. package/dist/store/slices/wallets.d.ts.map +0 -1
  116. package/dist/store/utils/wallets.d.ts +0 -17
  117. package/dist/store/utils/wallets.d.ts.map +0 -1
  118. package/dist/utils/hub.d.ts +0 -4
  119. package/dist/utils/hub.d.ts.map +0 -1
  120. package/src/store/slices/types.ts +0 -9
  121. package/src/store/slices/wallets.ts +0 -477
  122. package/src/store/utils/wallets.ts +0 -108
  123. package/src/utils/hub.ts +0 -21
@@ -9,6 +9,7 @@ import { useAppStore } from '../../store/AppStore';
9
9
  import { useNotificationStore } from '../../store/notification';
10
10
  import { useQuoteStore } from '../../store/quote';
11
11
  import { tabManager, useUiStore } from '../../store/ui';
12
+ import { useWalletsStore } from '../../store/wallets';
12
13
  import { calculateWalletUsdValue } from '../../utils/wallets';
13
14
 
14
15
  import { WidgetHistory } from './WidgetInfo.helpers';
@@ -21,16 +22,13 @@ export function WidgetInfo(props: React.PropsWithChildren) {
21
22
  const { manager } = useManager();
22
23
  const isActiveTab = useUiStore.use.isActiveTab();
23
24
  const retrySwap = useQuoteStore.use.retry();
24
- const {
25
- findToken,
26
- connectedWallets,
27
- getBalances,
28
- fetchBalances: refetch,
29
- } = useAppStore();
25
+ const { findToken } = useAppStore();
30
26
 
31
27
  const history = new WidgetHistory(manager, { retrySwap, findToken });
32
- const { fetchingWallets: isLoading } = useAppStore();
33
- const totalBalance = calculateWalletUsdValue(getBalances());
28
+ const details = useWalletsStore.use.connectedWallets();
29
+ const isLoading = useWalletsStore.use.loading();
30
+ const totalBalance = calculateWalletUsdValue(details);
31
+ const refetch = useWalletsStore.use.getWalletsDetails();
34
32
  const blockchains = useAppStore().blockchains();
35
33
  const tokens = useAppStore().tokens();
36
34
  const swappers = useAppStore().swappers();
@@ -49,9 +47,9 @@ export function WidgetInfo(props: React.PropsWithChildren) {
49
47
  history,
50
48
  wallets: {
51
49
  isLoading,
52
- details: connectedWallets,
50
+ details,
53
51
  totalBalance,
54
- refetch: async (accounts) => refetch(accounts),
52
+ refetch: (accounts) => refetch(accounts, findToken),
55
53
  },
56
54
  meta: {
57
55
  blockchains,
@@ -1,6 +1,6 @@
1
1
  import type { WidgetHistory } from './WidgetInfo.helpers';
2
2
  import type { FetchStatus, FindToken } from '../../store/slices/data';
3
- import type { ConnectedWallet } from '../../store/slices/wallets';
3
+ import type { ConnectedWallet } from '../../store/wallets';
4
4
  import type { QuoteInputs, UpdateQuoteInputs, Wallet } from '../../types';
5
5
  import type { Notification } from '../../types/notification';
6
6
  import type { BlockchainMeta, SwapperMeta, Token } from 'rango-sdk';
@@ -13,7 +13,7 @@ export interface WidgetInfoContextInterface {
13
13
  details: ConnectedWallet[];
14
14
  totalBalance: string;
15
15
  isLoading: boolean;
16
- refetch: (accounts: Wallet[]) => void;
16
+ refetch: (accounts: Wallet[], tokens: Token[]) => void;
17
17
  };
18
18
  meta: {
19
19
  blockchains: BlockchainMeta[];
@@ -103,11 +103,6 @@ export function useFetchCustomToken(): UseFetchCustomToken {
103
103
 
104
104
  return token;
105
105
  } catch (error: any) {
106
- if (error?.code === 'ERR_BAD_REQUEST') {
107
- const errorMessage = produceErrorMessage('not-found', blockchain);
108
- setError(errorMessage);
109
- return undefined;
110
- }
111
106
  setError(undefined);
112
107
  throw new Error(error.message);
113
108
  } finally {
@@ -0,0 +1 @@
1
+ export { useObserveBalanceChanges } from './useObserveBalanceChanges';
@@ -0,0 +1,68 @@
1
+ import type { WalletEventData } from '../../types';
2
+
3
+ import { useWallets } from '@rango-dev/wallets-react';
4
+ import { useEffect, useRef, useState } from 'react';
5
+
6
+ import { widgetEventEmitter } from '../../services/eventEmitter';
7
+ import { useWalletsStore } from '../../store/wallets';
8
+ import { WalletEventTypes, WidgetEvents } from '../../types';
9
+
10
+ // A hook to listen for and detect changes in balances on a specific blockchain.
11
+ export function useObserveBalanceChanges(selectedBlockchain?: string) {
12
+ const { connectedWallets } = useWalletsStore();
13
+ const { getWalletInfo } = useWallets();
14
+ const prevFetchingBalanceWallets = useRef<string[]>([]);
15
+ // The "balanceKey" will be updated and incremented after each change in the balance for a blockchain.
16
+ const [balanceKey, setBalanceKey] = useState(0);
17
+
18
+ useEffect(() => {
19
+ const handleWalletEvent = (event: WalletEventData) => {
20
+ if (event.type === WalletEventTypes.DISCONNECT) {
21
+ const walletInfo = getWalletInfo(event.payload.walletType);
22
+ const blockchainSupported = walletInfo.supportedChains.some(
23
+ (chain) => chain.name === selectedBlockchain
24
+ );
25
+
26
+ if (blockchainSupported) {
27
+ setBalanceKey((prev) => prev + 1);
28
+ }
29
+ }
30
+ };
31
+
32
+ widgetEventEmitter.on(WidgetEvents.WalletEvent, handleWalletEvent);
33
+
34
+ if (!selectedBlockchain) {
35
+ return setBalanceKey((prev) => prev + 1);
36
+ }
37
+
38
+ const supportedWallets = connectedWallets.filter(
39
+ (wallet) => wallet.chain === selectedBlockchain
40
+ );
41
+
42
+ supportedWallets.forEach((wallet) => {
43
+ const { walletType } = wallet;
44
+ const walletIsAlreadyFetching =
45
+ prevFetchingBalanceWallets.current.includes(walletType);
46
+
47
+ /**
48
+ * Watching for changes in "wallet.balances.length" is not accurate.
49
+ * Additionally, checking the equality of previous and current balances for a specific blockchain is resource-intensive, so we avoid these methods.
50
+ */
51
+ if (wallet.loading && !walletIsAlreadyFetching) {
52
+ prevFetchingBalanceWallets.current =
53
+ prevFetchingBalanceWallets.current.concat(walletType);
54
+ } else if (!wallet.loading && walletIsAlreadyFetching) {
55
+ prevFetchingBalanceWallets.current =
56
+ prevFetchingBalanceWallets.current.filter(
57
+ (prevWallet) => prevWallet !== walletType
58
+ );
59
+ setBalanceKey((prev) => prev + 1);
60
+ }
61
+ });
62
+
63
+ return () =>
64
+ widgetEventEmitter.off(WidgetEvents.WalletEvent, handleWalletEvent);
65
+ }, [connectedWallets, selectedBlockchain, getWalletInfo]);
66
+
67
+ return { balanceKey };
68
+ }
@@ -1,15 +1,15 @@
1
1
  import type { HandleConnectOptions, Result } from './useStatefulConnect.types';
2
2
  import type { WalletInfoWithExtra } from '../../types';
3
- import type { ExtendedModalWalletInfo } from '../../utils/wallets';
4
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
5
- import type { NamespaceData, WalletType } from '@rango-dev/wallets-shared';
3
+ import type {
4
+ Namespace,
5
+ NamespaceData,
6
+ WalletType,
7
+ } from '@rango-dev/wallets-shared';
6
8
 
7
9
  import { WalletState } from '@rango-dev/ui';
8
10
  import { useWallets } from '@rango-dev/wallets-react';
9
11
  import { useReducer } from 'react';
10
12
 
11
- import { convertCommonNamespacesKeysToLegacyNamespace } from '../../utils/hub';
12
-
13
13
  import {
14
14
  isStateOnDerivationPathStep,
15
15
  isStateOnNamespace,
@@ -61,11 +61,7 @@ export function useStatefulConnect(): UseStatefulConnect {
61
61
  });
62
62
 
63
63
  try {
64
- const legacyNamespacesInput = namespaces?.map((namespaceInput) => ({
65
- ...namespaceInput,
66
- network: undefined,
67
- }));
68
- await connect(type, legacyNamespacesInput);
64
+ await connect(type, undefined, namespaces);
69
65
 
70
66
  return { status: ResultStatus.Connected };
71
67
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -79,7 +75,7 @@ export function useStatefulConnect(): UseStatefulConnect {
79
75
  };
80
76
 
81
77
  const handleConnect = async (
82
- wallet: ExtendedModalWalletInfo,
78
+ wallet: WalletInfoWithExtra,
83
79
  options?: HandleConnectOptions
84
80
  ): Promise<{
85
81
  status: ResultStatus;
@@ -87,37 +83,6 @@ export function useStatefulConnect(): UseStatefulConnect {
87
83
  const isDisconnected = wallet.state === WalletState.DISCONNECTED;
88
84
 
89
85
  if (isDisconnected) {
90
- // Legacy and hub have different structure to check wether we need to show namespace or not.
91
-
92
- // Hub
93
- const isHub = !!wallet.isHub;
94
- if (isHub) {
95
- const detachedInstances = wallet.properties?.find(
96
- (item) => item.name === 'detached'
97
- );
98
- const needsNamespace =
99
- detachedInstances && wallet.state !== 'connected';
100
-
101
- if (needsNamespace) {
102
- const availableNamespaces =
103
- convertCommonNamespacesKeysToLegacyNamespace(
104
- detachedInstances.value
105
- );
106
-
107
- dispatch({
108
- type: 'needsNamespace',
109
- payload: {
110
- providerType: wallet.type,
111
- providerImage: wallet.image,
112
- availableNamespaces,
113
- singleNamespace: false,
114
- },
115
- });
116
- return { status: ResultStatus.Namespace };
117
- }
118
- }
119
-
120
- // Legacy
121
86
  if (!wallet.namespaces) {
122
87
  return await runConnect(wallet.type, undefined, options);
123
88
  }
@@ -1,4 +1,4 @@
1
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
1
+ import type { Namespace } from '@rango-dev/wallets-shared';
2
2
 
3
3
  export interface HandleConnectOptions {
4
4
  // To have a switch between connect and disconnect when user is clicking on a button, this option can be helpful.
@@ -12,10 +12,13 @@ import { useEffect } from 'react';
12
12
  import { eventEmitter } from '../../services/eventEmitter';
13
13
  import { useAppStore } from '../../store/AppStore';
14
14
  import { useNotificationStore } from '../../store/notification';
15
+ import { useWalletsStore } from '../../store/wallets';
15
16
 
16
17
  export function useSubscribeToWidgetEvents() {
18
+ const connectedWallets = useWalletsStore.use.connectedWallets();
19
+ const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
17
20
  const setNotification = useNotificationStore.use.setNotification();
18
- const { connectedWallets, fetchBalances } = useAppStore();
21
+ const { findToken } = useAppStore();
19
22
 
20
23
  useEffect(() => {
21
24
  const handleStepEvent = (widgetEvent: StepEventData) => {
@@ -36,12 +39,8 @@ export function useSubscribeToWidgetEvents() {
36
39
  (wallet) => wallet.chain === step?.toBlockchain
37
40
  );
38
41
 
39
- if (fromAccount) {
40
- void fetchBalances([fromAccount]);
41
- }
42
- if (toAccount) {
43
- void fetchBalances([toAccount]);
44
- }
42
+ fromAccount && getWalletsDetails([fromAccount], findToken);
43
+ toAccount && getWalletsDetails([toAccount], findToken);
45
44
  }
46
45
 
47
46
  setNotification(event, route);
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
4
4
 
5
5
  import { useAppStore } from '../store/AppStore';
6
6
  import { useQuoteStore } from '../store/quote';
7
+ import { useWalletsStore } from '../store/wallets';
7
8
  import { QuoteErrorType } from '../types';
8
9
  import { debounce } from '../utils/common';
9
10
  import { isPositiveNumber } from '../utils/numbers';
@@ -49,7 +50,7 @@ export function useSwapInput({
49
50
  const { fetch: fetchQuote, cancelFetch } = useFetchAllQuotes();
50
51
  const { excludeLiquiditySources: configExcludeLiquiditySources, routing } =
51
52
  useAppStore().config;
52
- const { connectedWallets } = useAppStore();
53
+ const connectedWallets = useWalletsStore.use.connectedWallets();
53
54
 
54
55
  const {
55
56
  fromToken,
@@ -12,6 +12,7 @@ import {
12
12
  import { useCallback, useEffect } from 'react';
13
13
 
14
14
  import { useAppStore } from '../store/AppStore';
15
+ import { useWalletsStore } from '../store/wallets';
15
16
  import { configWalletsToWalletName } from '../utils/providers';
16
17
  import {
17
18
  hashWalletsState,
@@ -42,8 +43,9 @@ interface API {
42
43
  */
43
44
  export function useWalletList(params?: Params): API {
44
45
  const { chain } = params || {};
45
- const { config, connectedWallets } = useAppStore();
46
+ const { config } = useAppStore();
46
47
  const { state, getWalletInfo } = useWallets();
48
+ const { connectedWallets } = useWalletsStore();
47
49
  const blockchains = useAppStore().blockchains();
48
50
  const { handleDisconnect } = useStatefulConnect();
49
51
 
@@ -1,9 +1,10 @@
1
1
  import type { WidgetConfig } from '../../types';
2
2
  import type { ProvidersOptions } from '../../utils/providers';
3
+ import type { ProviderInterface } from '@rango-dev/wallets-react';
3
4
 
4
5
  import { useEffect } from 'react';
5
6
 
6
- import { useAppStore } from '../../store/AppStore';
7
+ import { useWalletsStore } from '../../store/wallets';
7
8
  import { matchAndGenerateProviders } from '../../utils/providers';
8
9
 
9
10
  import { hashProviders } from './useWalletProviders.helpers';
@@ -12,8 +13,11 @@ export function useWalletProviders(
12
13
  providers: WidgetConfig['wallets'],
13
14
  options?: ProvidersOptions
14
15
  ) {
15
- const { clearConnectedWallet } = useAppStore();
16
- let generateProviders = matchAndGenerateProviders(providers, options);
16
+ const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
17
+ let generateProviders: ProviderInterface[] = matchAndGenerateProviders(
18
+ providers,
19
+ options
20
+ );
17
21
 
18
22
  useEffect(() => {
19
23
  clearConnectedWallet();
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { WidgetProps } from './containers/Widget';
2
- import type { ConnectedWallet } from './store/slices/wallets';
2
+ import type { ConnectedWallet } from './store/wallets';
3
3
  import type {
4
4
  BlockchainAndTokenConfig,
5
5
  QuoteEventData,
@@ -19,6 +19,7 @@ import { useSwapInput } from '../hooks/useSwapInput';
19
19
  import { useAppStore } from '../store/AppStore';
20
20
  import { useQuoteStore } from '../store/quote';
21
21
  import { useUiStore } from '../store/ui';
22
+ import { useWalletsStore } from '../store/wallets';
22
23
  import { UiEventTypes } from '../types';
23
24
  import { isVariantExpandable } from '../utils/configs';
24
25
  import { emitPreventableEvent } from '../utils/events';
@@ -54,12 +55,9 @@ export function Home() {
54
55
  const { isLargeScreen, isExtraLargeScreen } = useScreenDetect();
55
56
 
56
57
  const { fetch: fetchQuote, loading } = useSwapInput({ refetchQuote });
57
- const {
58
- config,
59
- fetchStatus: fetchMetaStatus,
60
- connectedWallets,
61
- } = useAppStore();
58
+ const { config, fetchStatus: fetchMetaStatus } = useAppStore();
62
59
 
60
+ const { connectedWallets } = useWalletsStore();
63
61
  const { isActiveTab } = useUiStore();
64
62
  const [showQuoteWarningModal, setShowQuoteWarningModal] = useState(false);
65
63
 
@@ -13,6 +13,7 @@ import { navigationRoutes } from '../constants/navigationRoutes';
13
13
  import { useNavigateBack } from '../hooks/useNavigateBack';
14
14
  import { useAppStore } from '../store/AppStore';
15
15
  import { useQuoteStore } from '../store/quote';
16
+ import { useWalletsStore } from '../store/wallets';
16
17
 
17
18
  interface PropTypes {
18
19
  type: 'source' | 'destination';
@@ -30,7 +31,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
30
31
  setFromBlockchain,
31
32
  setToBlockchain,
32
33
  } = useQuoteStore();
33
- const { getBalanceFor } = useAppStore();
34
+ const getBalanceFor = useWalletsStore.use.getBalanceFor();
34
35
  const [searchedFor, setSearchedFor] = useState<string>('');
35
36
 
36
37
  const selectedBlockchain = type === 'source' ? fromBlockchain : toBlockchain;
package/src/store/app.ts CHANGED
@@ -1,4 +1,6 @@
1
- import type { AppStoreState } from './slices/types';
1
+ import type { ConfigSlice } from './slices/config';
2
+ import type { DataSlice } from './slices/data';
3
+ import type { SettingsSlice } from './slices/settings';
2
4
  import type { WidgetConfig } from '../types';
3
5
  import type { StateCreator } from 'zustand';
4
6
 
@@ -8,7 +10,6 @@ import { persist } from 'zustand/middleware';
8
10
  import { createConfigSlice } from './slices/config';
9
11
  import { createDataSlice } from './slices/data';
10
12
  import { createSettingsSlice } from './slices/settings';
11
- import { createWalletsSlice } from './slices/wallets';
12
13
 
13
14
  export type StateCreatorWithInitialData<
14
15
  T extends Partial<WidgetConfig>,
@@ -19,13 +20,12 @@ export type StateCreatorWithInitialData<
19
20
  ...rest: Parameters<StateCreator<R, [], [], V>>
20
21
  ) => ReturnType<StateCreator<R, [], [], V>>;
21
22
 
22
- export type { AppStoreState };
23
+ export type AppStoreState = DataSlice & ConfigSlice & SettingsSlice;
23
24
 
24
25
  export function createAppStore(initialData?: WidgetConfig) {
25
26
  return create<AppStoreState>()(
26
27
  persist(
27
28
  (...a) => ({
28
- ...createWalletsSlice(...a),
29
29
  ...createDataSlice(...a),
30
30
  ...createSettingsSlice(...a),
31
31
  ...createConfigSlice(initialData, ...a),
@@ -21,9 +21,6 @@ export const DEFAULT_CONFIG: WidgetConfig = {
21
21
  manifestUrl:
22
22
  'https://raw.githubusercontent.com/rango-exchange/rango-types/main/assets/manifests/tonconnect-manifest.json',
23
23
  },
24
- features: {
25
- experimentalWallet: 'enabled',
26
- },
27
24
  };
28
25
 
29
26
  interface IframeConfigs {
@@ -348,9 +348,8 @@ export const createDataSlice: StateCreator<
348
348
  {};
349
349
  const tokens: Token[] = [];
350
350
  const popularTokens: Token[] = response.popularTokens;
351
- const swappers: SwapperMeta[] = response.swappers.filter(
352
- (swapper) => swapper.enabled
353
- );
351
+ const swappers: SwapperMeta[] = response.swappers;
352
+
354
353
  const blockchainsWithAtLeastOneToken = new Set();
355
354
 
356
355
  response.tokens.forEach((token) => {