@rango-dev/widget-embedded 0.17.1-next.3 → 0.17.1-next.5

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 (104) hide show
  1. package/dist/QueueManager.d.ts +2 -1
  2. package/dist/QueueManager.d.ts.map +1 -1
  3. package/dist/Wallets.d.ts +1 -0
  4. package/dist/Wallets.d.ts.map +1 -1
  5. package/dist/Widget.d.ts +1 -1
  6. package/dist/Widget.d.ts.map +1 -1
  7. package/dist/components/AppRouter.d.ts +0 -2
  8. package/dist/components/AppRouter.d.ts.map +1 -1
  9. package/dist/components/AppRoutes.d.ts +1 -6
  10. package/dist/components/AppRoutes.d.ts.map +1 -1
  11. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  12. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  13. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +0 -2
  14. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  15. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  16. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -4
  17. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
  18. package/dist/components/NoResult/NoResult.d.ts.map +1 -1
  19. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  20. package/dist/components/Quote/Quote.d.ts.map +1 -1
  21. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  22. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  23. package/dist/components/UpdateUrl.d.ts +1 -6
  24. package/dist/components/UpdateUrl.d.ts.map +1 -1
  25. package/dist/components/WidgetEvents.d.ts.map +1 -1
  26. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  27. package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
  28. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  29. package/dist/hooks/useWalletList.d.ts.map +1 -1
  30. package/dist/index.js +1 -1
  31. package/dist/index.js.map +4 -4
  32. package/dist/pages/ConfirmSwapPage.d.ts +1 -6
  33. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  34. package/dist/pages/LiquiditySourcePage.d.ts +1 -2
  35. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  36. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  37. package/dist/pages/SettingsPage.d.ts +1 -6
  38. package/dist/pages/SettingsPage.d.ts.map +1 -1
  39. package/dist/pages/WalletsPage.d.ts +1 -8
  40. package/dist/pages/WalletsPage.d.ts.map +1 -1
  41. package/dist/store/AppStore.d.ts +59 -0
  42. package/dist/store/AppStore.d.ts.map +1 -0
  43. package/dist/store/app.d.ts +12 -6
  44. package/dist/store/app.d.ts.map +1 -1
  45. package/dist/store/quote.d.ts +14 -7
  46. package/dist/store/quote.d.ts.map +1 -1
  47. package/dist/store/settings.d.ts +3 -2
  48. package/dist/store/settings.d.ts.map +1 -1
  49. package/dist/store/slices/config.d.ts +3 -2
  50. package/dist/store/slices/config.d.ts.map +1 -1
  51. package/dist/store/slices/data.d.ts +3 -0
  52. package/dist/store/slices/data.d.ts.map +1 -1
  53. package/dist/store/wallets.d.ts +5 -4
  54. package/dist/store/wallets.d.ts.map +1 -1
  55. package/dist/types/config.d.ts +5 -5
  56. package/dist/types/config.d.ts.map +1 -1
  57. package/dist/utils/settings.d.ts +3 -2
  58. package/dist/utils/settings.d.ts.map +1 -1
  59. package/dist/utils/swap.d.ts +4 -3
  60. package/dist/utils/swap.d.ts.map +1 -1
  61. package/package.json +3 -3
  62. package/src/QueueManager.tsx +14 -14
  63. package/src/Wallets.tsx +30 -5
  64. package/src/Widget.tsx +11 -25
  65. package/src/components/AppRouter.tsx +3 -5
  66. package/src/components/AppRoutes.tsx +6 -39
  67. package/src/components/BlockchainList/BlockchainList.tsx +4 -4
  68. package/src/components/BlockchainsSection/BlockchainsSection.tsx +4 -4
  69. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -14
  70. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +0 -2
  71. package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
  72. package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
  73. package/src/components/NoResult/NoResult.tsx +4 -1
  74. package/src/components/NotificationContent/NotificationContent.tsx +3 -2
  75. package/src/components/Quote/Quote.tsx +2 -4
  76. package/src/components/SwapDetails/SwapDetails.tsx +5 -6
  77. package/src/components/TokenList/TokenList.tsx +6 -7
  78. package/src/components/UpdateUrl.tsx +20 -14
  79. package/src/components/WidgetEvents.tsx +4 -2
  80. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +5 -5
  81. package/src/hooks/useSwapInput.ts +6 -4
  82. package/src/hooks/useSyncStoresWithConfig.ts +20 -17
  83. package/src/hooks/useWalletList.ts +3 -5
  84. package/src/pages/ConfirmSwapPage.tsx +1 -9
  85. package/src/pages/Home.tsx +7 -7
  86. package/src/pages/LiquiditySourcePage.tsx +22 -31
  87. package/src/pages/SelectBlockchainPage.tsx +4 -5
  88. package/src/pages/SelectSwapItemsPage.tsx +5 -5
  89. package/src/pages/SettingsPage.tsx +8 -12
  90. package/src/pages/SwapDetailsPage.tsx +3 -3
  91. package/src/pages/WalletsPage.tsx +4 -11
  92. package/src/store/AppStore.tsx +35 -0
  93. package/src/store/app.ts +20 -5
  94. package/src/store/quote.ts +26 -22
  95. package/src/store/settings.ts +7 -4
  96. package/src/store/slices/config.ts +25 -15
  97. package/src/store/slices/data.ts +64 -29
  98. package/src/store/wallets.ts +11 -8
  99. package/src/types/config.ts +5 -5
  100. package/src/utils/settings.ts +8 -7
  101. package/src/utils/swap.ts +14 -16
  102. package/dist/store/meta.d.ts +0 -23
  103. package/dist/store/meta.d.ts.map +0 -1
  104. package/src/store/meta.ts +0 -39
package/src/Wallets.tsx CHANGED
@@ -6,10 +6,10 @@ import type { PropsWithChildren } from 'react';
6
6
 
7
7
  import { Events, Provider } from '@rango-dev/wallets-react';
8
8
  import { isEvmBlockchain } from 'rango-sdk';
9
- import React, { createContext, useRef } from 'react';
9
+ import React, { createContext, useEffect, useRef } from 'react';
10
10
 
11
11
  import { useWalletProviders } from './hooks/useWalletProviders';
12
- import { useMetaStore } from './store/meta';
12
+ import { AppStoreProvider, useAppStore } from './store/AppStore';
13
13
  import { useWalletsStore } from './store/wallets';
14
14
  import {
15
15
  prepareAccountsForWalletStore,
@@ -27,19 +27,28 @@ export const WidgetContext = createContext<WidgetContextInterface>({
27
27
  },
28
28
  });
29
29
 
30
- export function WidgetWallets(
30
+ function Main(
31
31
  props: PropsWithChildren<{
32
32
  providers: WidgetConfig['wallets'];
33
33
  options?: ProvidersOptions;
34
34
  onUpdateState?: EventHandler;
35
+ config: WidgetConfig;
35
36
  }>
36
37
  ) {
37
- const { blockchains } = useMetaStore.use.meta();
38
+ const updateConfig = useAppStore().use.updateConfig();
39
+ const blockchains = useAppStore().use.blockchains()();
40
+ const tokens = useAppStore().use.tokens()();
38
41
  const { providers } = useWalletProviders(props.providers, props?.options);
39
42
  const disconnectWallet = useWalletsStore.use.disconnectWallet();
40
43
  const connectWallet = useWalletsStore.use.connectWallet();
41
44
  const onConnectWalletHandler = useRef<OnConnectHandler>();
42
45
 
46
+ useEffect(() => {
47
+ if (props.config) {
48
+ updateConfig(props.config);
49
+ }
50
+ }, [props.config]);
51
+
43
52
  const evmBasedChainNames = blockchains
44
53
  .filter(isEvmBlockchain)
45
54
  .map((chain) => chain.name);
@@ -61,7 +70,7 @@ export function WidgetWallets(
61
70
  evmBasedChainNames,
62
71
  supportedChainNames
63
72
  );
64
- connectWallet(data);
73
+ connectWallet(data, tokens);
65
74
  } else {
66
75
  disconnectWallet(type);
67
76
  }
@@ -112,3 +121,19 @@ export function WidgetWallets(
112
121
  </WidgetContext.Provider>
113
122
  );
114
123
  }
124
+
125
+ export function WidgetWallets(
126
+ props: PropsWithChildren<{
127
+ providers: WidgetConfig['wallets'];
128
+ options?: ProvidersOptions;
129
+ onUpdateState?: EventHandler;
130
+ config: WidgetConfig;
131
+ }>
132
+ ) {
133
+ const { config, ...otherProps } = props;
134
+ return (
135
+ <AppStoreProvider config={config}>
136
+ <Main {...otherProps} config={config} />
137
+ </AppStoreProvider>
138
+ );
139
+ }
package/src/Widget.tsx CHANGED
@@ -12,10 +12,10 @@ import { globalFont } from './globalStyles';
12
12
  import { useLanguage } from './hooks/useLanguage';
13
13
  import { useTheme } from './hooks/useTheme';
14
14
  import QueueManager from './QueueManager';
15
- import { useAppStore } from './store/app';
16
- import { useMetaStore } from './store/meta';
15
+ import { useAppStore } from './store/AppStore';
17
16
  import { useNotificationStore } from './store/notification';
18
17
  import { useSettingsStore } from './store/settings';
18
+ import { DEFAULT_CONFIG } from './store/slices/config';
19
19
  import { initConfig } from './utils/configs';
20
20
  import { WidgetContext, WidgetWallets } from './Wallets';
21
21
 
@@ -40,18 +40,16 @@ export type WidgetProps = {
40
40
  config?: WidgetConfig;
41
41
  };
42
42
 
43
- export function Main(props: PropsWithChildren<WidgetProps>) {
44
- const { config } = props;
43
+ export function Main() {
45
44
  globalFont();
46
45
 
46
+ const { fetch: fetchMeta, config } = useAppStore()();
47
47
  const { activeTheme } = useTheme(config?.theme || {});
48
48
  const { activeLanguage, changeLanguage } = useLanguage();
49
-
50
49
  const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
51
50
  useState<string>('');
52
51
  const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
53
52
  const widgetContext = useContext(WidgetContext);
54
- const fetchMeta = useMetaStore.use.fetchMeta();
55
53
 
56
54
  useMemo(() => {
57
55
  if (config?.apiKey) {
@@ -60,33 +58,29 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
60
58
  });
61
59
  }
62
60
  }, [config]);
63
-
64
61
  useEffect(() => {
65
- void fetchMeta();
62
+ void fetchMeta().catch();
66
63
  void useSettingsStore.persist.rehydrate();
67
64
  void useNotificationStore.persist.rehydrate();
68
65
  widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
69
66
  }, []);
70
-
71
67
  useEffect(() => {
72
68
  if (config?.language) {
73
69
  changeLanguage(config.language);
74
70
  }
75
71
  }, [config?.language]);
76
-
77
72
  return (
78
73
  <I18nManager language={activeLanguage}>
79
74
  <MainContainer id="swap-container" className={activeTheme()}>
80
75
  <QueueManager>
81
76
  <WidgetEvents />
82
77
  <AppRouter
83
- config={config}
84
78
  lastConnectedWallet={lastConnectedWalletWithNetwork}
85
79
  disconnectedWallet={disconnectedWallet}
86
80
  clearDisconnectedWallet={() => {
87
81
  setDisconnectedWallet(undefined);
88
82
  }}>
89
- <AppRoutes config={config} />
83
+ <AppRoutes />
90
84
  </AppRouter>
91
85
  </QueueManager>
92
86
  </MainContainer>
@@ -95,25 +89,17 @@ export function Main(props: PropsWithChildren<WidgetProps>) {
95
89
  }
96
90
 
97
91
  export function Widget(props: PropsWithChildren<WidgetProps>) {
98
- const { updateConfig, config } = useAppStore();
99
- useEffect(() => {
100
- if (props.config) {
101
- updateConfig(props.config);
102
- }
103
- }, [props.config]);
104
-
105
92
  if (!props.config?.externalWallets) {
106
93
  return (
107
94
  <WidgetWallets
108
- providers={config?.wallets}
95
+ config={props.config ?? DEFAULT_CONFIG}
96
+ providers={props.config?.wallets}
109
97
  options={{
110
- walletConnectProjectId:
111
- config?.walletConnectProjectId ||
112
- props.config?.walletConnectProjectId,
98
+ walletConnectProjectId: props.config?.walletConnectProjectId,
113
99
  }}>
114
- <Main {...props} />
100
+ <Main />
115
101
  </WidgetWallets>
116
102
  );
117
103
  }
118
- return <Main {...props} />;
104
+ return <Main />;
119
105
  }
@@ -1,4 +1,3 @@
1
- import type { WidgetConfig } from '../types';
2
1
  import type { WalletType } from '@rango-dev/wallets-shared';
3
2
  import type { PropsWithChildren } from 'react';
4
3
 
@@ -11,7 +10,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
11
10
 
12
11
  import { navigationRoutes } from '../constants/navigationRoutes';
13
12
  import { Home } from '../pages/Home';
14
- import { useMetaStore } from '../store/meta';
13
+ import { useAppStore } from '../store/AppStore';
15
14
 
16
15
  import { UpdateUrl } from './UpdateUrl';
17
16
 
@@ -44,11 +43,10 @@ export function AppRouter({
44
43
  lastConnectedWallet: string;
45
44
  disconnectedWallet: WalletType | undefined;
46
45
  clearDisconnectedWallet: () => void;
47
- config: WidgetConfig | undefined;
48
46
  }) {
49
47
  const isRouterInContext = useInRouterContext();
50
48
  const Router = isRouterInContext ? Route : MemoryRouter;
51
- const { blockchains } = useMetaStore.use.meta();
49
+ const blockchains = useAppStore().use.blockchains()();
52
50
  const { canSwitchNetworkTo } = useWallets();
53
51
 
54
52
  const evmChains = blockchains.filter(isEvmBlockchain);
@@ -64,7 +62,7 @@ export function AppRouter({
64
62
  return (
65
63
  <>
66
64
  <Router>{children}</Router>
67
- {isRouterInContext && <UpdateUrl config={props.config} />}
65
+ {isRouterInContext && <UpdateUrl />}
68
66
  </>
69
67
  );
70
68
  }
@@ -1,5 +1,3 @@
1
- import type { WidgetConfig } from '../types';
2
-
3
1
  import React from 'react';
4
2
  import { useRoutes } from 'react-router-dom';
5
3
 
@@ -18,13 +16,7 @@ import { WalletsPage } from '../pages/WalletsPage';
18
16
 
19
17
  const getAbsolutePath = (path: string) => path.replace('/', '');
20
18
 
21
- interface PropTypes {
22
- config?: WidgetConfig;
23
- }
24
-
25
- export function AppRoutes(props: PropTypes) {
26
- const { config } = props;
27
-
19
+ export function AppRoutes() {
28
20
  return useRoutes([
29
21
  {
30
22
  path: navigationRoutes.home,
@@ -48,12 +40,7 @@ export function AppRoutes(props: PropTypes) {
48
40
  },
49
41
  {
50
42
  path: navigationRoutes.settings,
51
- element: (
52
- <SettingsPage
53
- singleTheme={config?.theme?.singleTheme}
54
- supportedSwappers={config?.liquiditySources}
55
- />
56
- ),
43
+ element: <SettingsPage />,
57
44
  },
58
45
  {
59
46
  path: navigationRoutes.themes,
@@ -65,21 +52,11 @@ export function AppRoutes(props: PropTypes) {
65
52
  },
66
53
  {
67
54
  path: navigationRoutes.exchanges,
68
- element: (
69
- <LiquiditySourcePage
70
- sourceType="Exchanges"
71
- supportedSwappers={config?.liquiditySources}
72
- />
73
- ),
55
+ element: <LiquiditySourcePage sourceType="Exchanges" />,
74
56
  },
75
57
  {
76
58
  path: navigationRoutes.bridges,
77
- element: (
78
- <LiquiditySourcePage
79
- sourceType="Bridges"
80
- supportedSwappers={config?.liquiditySources}
81
- />
82
- ),
59
+ element: <LiquiditySourcePage sourceType="Bridges" />,
83
60
  },
84
61
  { path: navigationRoutes.swaps, element: <HistoryPage /> },
85
62
  {
@@ -88,21 +65,11 @@ export function AppRoutes(props: PropTypes) {
88
65
  },
89
66
  {
90
67
  path: navigationRoutes.wallets,
91
- element: (
92
- <WalletsPage
93
- supportedWallets={config?.wallets}
94
- multiWallets={
95
- typeof config?.multiWallets === 'undefined'
96
- ? true
97
- : config.multiWallets
98
- }
99
- config={config}
100
- />
101
- ),
68
+ element: <WalletsPage />,
102
69
  },
103
70
  {
104
71
  path: getAbsolutePath(navigationRoutes.confirmSwap),
105
- element: <ConfirmSwapPage config={config} />,
72
+ element: <ConfirmSwapPage />,
106
73
  },
107
74
  ]);
108
75
  }
@@ -11,7 +11,7 @@ import {
11
11
  } from '@rango-dev/ui';
12
12
  import React, { useEffect, useState } from 'react';
13
13
 
14
- import { useMetaStore } from '../../store/meta';
14
+ import { useAppStore } from '../../store/AppStore';
15
15
 
16
16
  import { filterBlockchains } from './BlockchainList.helpers';
17
17
  import { Container, List } from './BlockchainList.styles';
@@ -20,7 +20,7 @@ import { LoadingBlockchainList } from './LoadingBlockchainList';
20
20
  export function BlockchainList(props: PropTypes) {
21
21
  const { list, searchedFor, onChange, blockchainCategory } = props;
22
22
  const [blockchains, setBlockchains] = useState<BlockchainMeta[]>(list);
23
- const loadingStatus = useMetaStore.use.loadingStatus();
23
+ const { fetchStatus } = useAppStore()();
24
24
 
25
25
  useEffect(() => {
26
26
  setBlockchains([
@@ -66,8 +66,8 @@ export function BlockchainList(props: PropTypes) {
66
66
  {i18n.t('Select Blockchain')}
67
67
  </Typography>
68
68
  <Divider size={4} />
69
- {loadingStatus === 'loading' && <LoadingBlockchainList />}
70
- {loadingStatus === 'success' && renderList()}
69
+ {fetchStatus === 'loading' && <LoadingBlockchainList />}
70
+ {fetchStatus === 'success' && renderList()}
71
71
  </Container>
72
72
  );
73
73
  }
@@ -13,7 +13,7 @@ import React from 'react';
13
13
 
14
14
  import { BLOCKCHAIN_LIST_SIZE } from '../../constants/configs';
15
15
  import { usePrepareBlockchainList } from '../../hooks/usePrepareBlockchainList';
16
- import { useMetaStore } from '../../store/meta';
16
+ import { useAppStore } from '../../store/AppStore';
17
17
  import { useQuoteStore } from '../../store/quote';
18
18
 
19
19
  import { Container } from './BlockchainsSection.styles';
@@ -27,7 +27,7 @@ export function BlockchainsSection(props: PropTypes) {
27
27
  selected: blockchain?.name,
28
28
  });
29
29
 
30
- const loadingStatus = useMetaStore.use.loadingStatus();
30
+ const { fetchStatus } = useAppStore()();
31
31
  const resetToBlockchain = useQuoteStore.use.resetToBlockchain();
32
32
  const resetFromBlockchain = useQuoteStore.use.resetFromBlockchain();
33
33
  const hasMoreItemsInList = blockchainsList.more.length > 0;
@@ -45,11 +45,11 @@ export function BlockchainsSection(props: PropTypes) {
45
45
  </Typography>
46
46
  <Divider size={12} />
47
47
  <Container>
48
- {loadingStatus === 'loading' &&
48
+ {fetchStatus === 'loading' &&
49
49
  Array.from(Array(NUMBER_OF_LOADING), (e) => (
50
50
  <Skeleton key={e} variant="rounded" height={50} />
51
51
  ))}
52
- {loadingStatus === 'success' && (
52
+ {fetchStatus === 'success' && (
53
53
  <>
54
54
  <BlockchainsChip
55
55
  selected={!blockchain}
@@ -21,7 +21,7 @@ import { useNavigate } from 'react-router-dom';
21
21
  import { getQuoteErrorMessage } from '../../constants/errors';
22
22
  import { navigationRoutes } from '../../constants/navigationRoutes';
23
23
  import { getQuoteUpdateWarningMessage } from '../../constants/warnings';
24
- import { useMetaStore } from '../../store/meta';
24
+ import { useAppStore } from '../../store/AppStore';
25
25
  import { useQuoteStore } from '../../store/quote';
26
26
  import { useWalletsStore } from '../../store/wallets';
27
27
  import { confirmSwapDisabled } from '../../utils/swap';
@@ -50,8 +50,9 @@ const NUMBER_OF_WALLETS_TO_DISPLAY = 2;
50
50
 
51
51
  export function ConfirmWalletsModal(props: PropTypes) {
52
52
  //TODO: move component's logics to a custom hook
53
- const { open, onClose, onCancel, onCheckBalance, config, loading } = props;
54
- const { blockchains } = useMetaStore.use.meta();
53
+ const { open, onClose, onCancel, onCheckBalance, loading } = props;
54
+ const config = useAppStore().use.config();
55
+ const blockchains = useAppStore().use.blockchains()();
55
56
  const {
56
57
  quote,
57
58
  setSelectedWallets: selectQuoteWallets,
@@ -75,10 +76,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
75
76
  const customDestinationRef = useRef<HTMLDivElement | null>(null);
76
77
 
77
78
  const requiredWallets = getRequiredWallets(quote);
78
- const customDestinationEnabled =
79
- typeof config?.customDestination === 'undefined'
80
- ? true
81
- : config.customDestination;
82
79
 
83
80
  const lastStepToBlockchain = blockchains.find(
84
81
  (blockchain) =>
@@ -320,9 +317,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
320
317
  chain={showMoreWalletFor}
321
318
  isSelected={isSelected}
322
319
  selectWallet={onChange}
323
- multiWallets={config?.multiWallets ?? true}
324
- supportedWallets={config?.wallets ?? []}
325
- config={config}
326
320
  onShowMore={setShowMoreWalletFor.bind(null, showMoreWalletFor)}
327
321
  />
328
322
  </div>
@@ -380,9 +374,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
380
374
  chain={requiredWallet}
381
375
  isSelected={isSelected}
382
376
  selectWallet={onChange}
383
- multiWallets={config?.multiWallets ?? true}
384
- supportedWallets={config?.wallets ?? []}
385
- config={config}
386
377
  limit={NUMBER_OF_WALLETS_TO_DISPLAY}
387
378
  onShowMore={() =>
388
379
  setShowMoreWalletFor(blockchain?.name ?? '')
@@ -390,7 +381,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
390
381
  />
391
382
  </ListContainer>
392
383
  {!isLastWallet && <Divider size={32} />}
393
- {isLastWallet && customDestinationEnabled && (
384
+ {isLastWallet && config?.customDestination && (
394
385
  <CustomDestination>
395
386
  <CollapsibleRoot
396
387
  ref={customDestinationRef}
@@ -1,4 +1,3 @@
1
- import type { WidgetConfig } from '../..';
2
1
  import type { ConfirmSwap } from '../../hooks/useConfirmSwap/useConfirmSwap.types';
3
2
 
4
3
  export type PropTypes = {
@@ -6,6 +5,5 @@ export type PropTypes = {
6
5
  onClose: () => void;
7
6
  onCancel: () => void;
8
7
  onCheckBalance: ConfirmSwap['fetch'];
9
- config?: WidgetConfig;
10
8
  loading: boolean;
11
9
  };
@@ -23,7 +23,7 @@ import {
23
23
  TIME_TO_CLOSE_MODAL,
24
24
  TIME_TO_IGNORE_MODAL,
25
25
  } from '../../pages/WalletsPage';
26
- import { useMetaStore } from '../../store/meta';
26
+ import { useAppStore } from '../../store/AppStore';
27
27
  import { useWalletsStore } from '../../store/wallets';
28
28
  import { getBlockchainDisplayNameFor } from '../../utils/meta';
29
29
  import {
@@ -41,10 +41,11 @@ import {
41
41
  } from './WalletList.styles';
42
42
 
43
43
  export function WalletList(props: PropTypes) {
44
- const { config, chain, isSelected, selectWallet, limit, onShowMore } = props;
44
+ const { chain, isSelected, selectWallet, limit, onShowMore } = props;
45
+ const { config } = useAppStore()();
45
46
 
46
47
  const connectedWallets = useWalletsStore.use.connectedWallets();
47
- const { blockchains } = useMetaStore.use.meta();
48
+ const { blockchains } = useAppStore()();
48
49
  const [openWalletStateModal, setOpenWalletStateModal] =
49
50
  useState<WalletType>('');
50
51
  const [experimentalChainWallet, setExperimentalChainWallet] =
@@ -137,7 +138,7 @@ export function WalletList(props: PropTypes) {
137
138
  });
138
139
  const conciseAddress = address ? getConciseAddress(address) : '';
139
140
 
140
- const experimentalChain = isExperimentalChain(blockchains, chain);
141
+ const experimentalChain = isExperimentalChain(blockchains(), chain);
141
142
 
142
143
  const experimentalChainNotAdded = !connectedWallets.find(
143
144
  (connectedWallet) =>
@@ -180,7 +181,7 @@ export function WalletList(props: PropTypes) {
180
181
  experimentalChainWallet?.chain
181
182
  ? getBlockchainDisplayNameFor(
182
183
  experimentalChainWallet.chain,
183
- blockchains
184
+ blockchains()
184
185
  )
185
186
  : undefined;
186
187
  return (
@@ -1,12 +1,9 @@
1
- import type { Wallet, WidgetConfig } from '../../types';
1
+ import type { Wallet } from '../../types';
2
2
 
3
3
  export type PropTypes = {
4
4
  chain: string;
5
- supportedWallets: WidgetConfig['wallets'];
6
5
  isSelected: (walletType: string, chain: string) => boolean;
7
6
  selectWallet: (wallet: Wallet) => void;
8
- multiWallets: boolean;
9
- config?: WidgetConfig;
10
7
  limit?: number;
11
8
  onShowMore: () => void;
12
9
  };
@@ -11,6 +11,7 @@ import {
11
11
  import React from 'react';
12
12
 
13
13
  import { errorMessages } from '../../constants/errors';
14
+ import { useAppStore } from '../../store/AppStore';
14
15
  import { useSettingsStore } from '../../store/settings';
15
16
 
16
17
  import { makeInfo } from './NoResult.helpers';
@@ -23,10 +24,12 @@ export function NoResult(props: PropTypes) {
23
24
  const toggleAllLiquiditySources =
24
25
  useSettingsStore.use.toggleAllLiquiditySources();
25
26
 
27
+ const swappers = useAppStore().use.swappers()();
28
+
26
29
  const info = makeInfo(
27
30
  error,
28
31
  disabledLiquiditySources,
29
- toggleAllLiquiditySources,
32
+ () => toggleAllLiquiditySources(swappers, true),
30
33
  fetch
31
34
  );
32
35
 
@@ -10,7 +10,7 @@ import {
10
10
  import React from 'react';
11
11
  import { useNavigate } from 'react-router-dom';
12
12
 
13
- import { useMetaStore } from '../../store/meta';
13
+ import { useAppStore } from '../../store/AppStore';
14
14
  import { useNotificationStore } from '../../store/notification';
15
15
  import { useUiStore } from '../../store/ui';
16
16
 
@@ -26,7 +26,8 @@ export function NotificationContent() {
26
26
  const { getUnreadNotifications } = useNotificationStore();
27
27
 
28
28
  const notifications: Notification[] = getUnreadNotifications();
29
- const { tokens, blockchains } = useMetaStore.use.meta();
29
+ const blockchains = useAppStore().use.blockchains()();
30
+ const tokens = useAppStore().use.tokens()();
30
31
  const sortedNotification = notifications
31
32
  .sort((a, b) => b.creationTime - a.creationTime)
32
33
  .slice(0, MAX_NOTIFICATIONS_DISPLAYED);
@@ -30,7 +30,7 @@ import {
30
30
  FooterAlert,
31
31
  FooterStepAlarm,
32
32
  } from '../../containers/QuoteInfo/QuoteInfo.styles';
33
- import { useMetaStore } from '../../store/meta';
33
+ import { useAppStore } from '../../store/AppStore';
34
34
  import { QuoteErrorType, QuoteWarningType } from '../../types';
35
35
  import {
36
36
  numberToString,
@@ -53,9 +53,6 @@ import {
53
53
  import { QuoteSummary } from './QuoteSummary';
54
54
 
55
55
  export function Quote(props: QuoteProps) {
56
- const {
57
- meta: { tokens },
58
- } = useMetaStore();
59
56
  const {
60
57
  quote,
61
58
  input,
@@ -65,6 +62,7 @@ export function Quote(props: QuoteProps) {
65
62
  type,
66
63
  recommended = true,
67
64
  } = props;
65
+ const tokens = useAppStore().use.tokens()();
68
66
 
69
67
  const [expanded, setExpanded] = useState(props.expanded);
70
68
  const quoteRef = useRef<HTMLButtonElement | null>(null);
@@ -34,7 +34,7 @@ import {
34
34
  USD_VALUE_MIN_DECIMALS,
35
35
  } from '../../constants/routing';
36
36
  import { useNavigateBack } from '../../hooks/useNavigateBack';
37
- import { useMetaStore } from '../../store/meta';
37
+ import { useAppStore } from '../../store/AppStore';
38
38
  import { useNotificationStore } from '../../store/notification';
39
39
  import { useQuoteStore } from '../../store/quote';
40
40
  import {
@@ -64,6 +64,8 @@ import { Container, HeaderDetails, StepsList } from './SwapDetails.styles';
64
64
  export function SwapDetails(props: SwapDetailsProps) {
65
65
  const { swap, requestId, onDelete, onCancel: onCancelProps } = props;
66
66
  const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
67
+ const blockchains = useAppStore().use.blockchains()();
68
+ const tokens = useAppStore().use.tokens()();
67
69
  const retry = useQuoteStore.use.retry();
68
70
  const navigate = useNavigate();
69
71
  const { navigateBackFrom } = useNavigateBack();
@@ -73,9 +75,6 @@ export function SwapDetails(props: SwapDetailsProps) {
73
75
  const [showCompletedModal, setShowCompletedModal] = useState<
74
76
  'success' | 'failed' | null
75
77
  >(null);
76
- const {
77
- meta: { tokens, blockchains },
78
- } = useMetaStore();
79
78
 
80
79
  const onCancel = () => {
81
80
  onCancelProps();
@@ -150,7 +149,7 @@ export function SwapDetails(props: SwapDetailsProps) {
150
149
  showNetworkModal: currentStepNetworkStatus,
151
150
  setNetworkModal: setModalState,
152
151
  message: stepMessage,
153
- blockchains,
152
+ blockchains: blockchains,
154
153
  });
155
154
  const numberOfSteps = steps.length;
156
155
  const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
@@ -264,7 +263,7 @@ export function SwapDetails(props: SwapDetailsProps) {
264
263
  type="primary"
265
264
  size="large"
266
265
  onClick={() => {
267
- retry(swap);
266
+ retry(swap, { blockchains: blockchains, tokens: tokens });
268
267
  setTimeout(() => {
269
268
  navigate(navigationRoutes.home);
270
269
  }, 0);
@@ -21,8 +21,7 @@ import {
21
21
  } from '@rango-dev/ui';
22
22
  import React, { forwardRef, useEffect, useState } from 'react';
23
23
 
24
- import { useAppStore } from '../../store/app';
25
- import { useMetaStore } from '../../store/meta';
24
+ import { useAppStore } from '../../store/AppStore';
26
25
  import { useWalletsStore } from '../../store/wallets';
27
26
  import { generateRangeColors } from '../../utils/colors';
28
27
 
@@ -87,11 +86,11 @@ export function TokenList(props: PropTypes) {
87
86
  const { list, searchedFor = '', onChange, selectedBlockchain } = props;
88
87
 
89
88
  const [tokens, setTokens] = useState<TokenWithBalance[]>(list);
90
- const loadingStatus = useMetaStore.use.loadingStatus();
89
+ const fetchStatus = useAppStore().use.fetchStatus();
90
+ const blockchains = useAppStore().use.blockchains()();
91
91
  const [hasNextPage, setHasNextPage] = useState<boolean>(true);
92
92
  const loadingWallet = useWalletsStore.use.loading();
93
- const { blockchains } = useMetaStore.use.meta();
94
- const { isTokenPinned } = useAppStore();
93
+ const { isTokenPinned } = useAppStore()();
95
94
 
96
95
  // eslint-disable-next-line react/display-name
97
96
  const innerElementType: React.FC<CommonProps> = forwardRef((render, ref) => {
@@ -268,8 +267,8 @@ export function TokenList(props: PropTypes) {
268
267
  {i18n.t('Select Token')}
269
268
  </Typography>
270
269
  <Divider size={4} />
271
- {loadingStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
272
- {loadingStatus === 'success' && <List>{renderList()}</List>}
270
+ {fetchStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
271
+ {fetchStatus === 'success' && <List>{renderList()}</List>}
273
272
  </Container>
274
273
  );
275
274
  }