@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.36.1-next.7",
3
+ "version": "0.37.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -25,15 +25,15 @@
25
25
  "@lingui/core": "4.2.1",
26
26
  "@lingui/react": "4.2.1",
27
27
  "@rango-dev/logging-core": "^0.6.0",
28
- "@rango-dev/provider-all": "^0.40.1-next.2",
28
+ "@rango-dev/provider-all": "^0.41.0",
29
29
  "@rango-dev/queue-manager-core": "^0.27.0",
30
- "@rango-dev/queue-manager-rango-preset": "^0.40.1-next.2",
30
+ "@rango-dev/queue-manager-rango-preset": "^0.41.0",
31
31
  "@rango-dev/queue-manager-react": "^0.27.0",
32
32
  "@rango-dev/signer-solana": "^0.35.0",
33
- "@rango-dev/ui": "^0.42.1-next.5",
34
- "@rango-dev/wallets-core": "^0.40.1-next.2",
35
- "@rango-dev/wallets-react": "^0.26.1-next.2",
36
- "@rango-dev/wallets-shared": "^0.40.1-next.2",
33
+ "@rango-dev/ui": "^0.43.0",
34
+ "@rango-dev/wallets-core": "^0.40.0",
35
+ "@rango-dev/wallets-react": "^0.27.0",
36
+ "@rango-dev/wallets-shared": "^0.41.0",
37
37
  "bignumber.js": "^9.1.1",
38
38
  "copy-to-clipboard": "^3.3.3",
39
39
  "dayjs": "^1.11.7",
@@ -15,6 +15,7 @@ import React, { useMemo } from 'react';
15
15
  import { eventEmitter } from './services/eventEmitter';
16
16
  import { useAppStore } from './store/AppStore';
17
17
  import { useUiStore } from './store/ui';
18
+ import { useWalletsStore } from './store/wallets';
18
19
  import { getConfig } from './utils/configs';
19
20
  import { walletAndSupportedChainsNames } from './utils/wallets';
20
21
 
@@ -38,8 +39,8 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
38
39
  });
39
40
  }, [props.apiKey]);
40
41
 
41
- const { blockchains, connectedWallets } = useAppStore();
42
- const blockchainsList = blockchains();
42
+ const blockchains = useAppStore().blockchains();
43
+ const connectedWallets = useWalletsStore.use.connectedWallets();
43
44
 
44
45
  const wallets = {
45
46
  blockchains: connectedWallets.map((wallet) => ({
@@ -52,21 +53,14 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
52
53
  if (!canSwitchNetworkTo(wallet, network)) {
53
54
  return undefined;
54
55
  }
55
- const result = await connect(wallet, [
56
- {
57
- namespace: 'DISCOVER_MODE',
58
- network,
59
- },
60
- ]);
61
-
62
- return result;
56
+ return connect(wallet, network);
63
57
  };
64
58
 
65
59
  const isMobileWallet = (walletType: WalletType): boolean =>
66
60
  !!getWalletInfo(walletType).mobileWallet;
67
61
 
68
62
  // TODO: this code copy & pasted from rango, should be refactored.
69
- const allBlockchains = blockchainsList
63
+ const allBlockchains = blockchains
70
64
  .filter((blockchain) => blockchain.enabled)
71
65
  .reduce(
72
66
  (blockchainsObj: any, blockchain) => (
@@ -74,7 +68,7 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
74
68
  ),
75
69
  {}
76
70
  );
77
- const evmBasedChains = blockchainsList.filter(isEvmBlockchain);
71
+ const evmBasedChains = blockchains.filter(isEvmBlockchain);
78
72
  const getSupportedChainNames = (type: WalletType) => {
79
73
  const { supportedChains } = getWalletInfo(type);
80
74
  return walletAndSupportedChainsNames(supportedChains);
@@ -94,6 +88,7 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
94
88
  providers: allProviders,
95
89
  switchNetwork,
96
90
  canSwitchNetworkTo,
91
+ connect,
97
92
  state,
98
93
  isMobileWallet,
99
94
  };
@@ -1,5 +1,5 @@
1
1
  import type { PropTypes } from './ConfirmWalletsModal.types';
2
- import type { ConnectedWallet } from '../../store/slices/wallets';
2
+ import type { ConnectedWallet } from '../../store/wallets';
3
3
  import type { ConfirmSwapWarnings, Wallet } from '../../types';
4
4
 
5
5
  import { i18n } from '@lingui/core';
@@ -20,6 +20,7 @@ import { getQuoteErrorMessage } from '../../constants/errors';
20
20
  import { getQuoteUpdateWarningMessage } from '../../constants/warnings';
21
21
  import { useAppStore } from '../../store/AppStore';
22
22
  import { useQuoteStore } from '../../store/quote';
23
+ import { useWalletsStore } from '../../store/wallets';
23
24
  import { getBlockchainShortNameFor } from '../../utils/meta';
24
25
  import { isConfirmSwapDisabled } from '../../utils/swap';
25
26
  import { getQuoteWallets } from '../../utils/wallets';
@@ -53,7 +54,8 @@ export function ConfirmWalletsModal(props: PropTypes) {
53
54
  customDestination,
54
55
  setCustomDestination,
55
56
  } = useQuoteStore();
56
- const { config, connectedWallets, setWalletsAsSelected } = useAppStore();
57
+ const { connectedWallets, selectWallets } = useWalletsStore();
58
+ const { config } = useAppStore();
57
59
 
58
60
  const [showMoreWalletFor, setShowMoreWalletFor] = useState('');
59
61
  const [balanceWarnings, setBalanceWarnings] = useState<string[]>([]);
@@ -215,7 +217,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
215
217
  const lastSelectedWallets = selectableWallets.filter(
216
218
  (wallet) => wallet.selected
217
219
  );
218
- setWalletsAsSelected(lastSelectedWallets);
220
+ selectWallets(lastSelectedWallets);
219
221
  selectQuoteWallets(lastSelectedWallets);
220
222
  setQuoteWalletConfirmed(true);
221
223
  onClose();
@@ -1,6 +1,5 @@
1
1
  import type { PropTypes } from './WalletList.type';
2
- import type { Wallet } from '../../types';
3
- import type { ExtendedModalWalletInfo } from '../../utils/wallets';
2
+ import type { Wallet, WalletInfoWithExtra } from '../../types';
4
3
 
5
4
  import { i18n } from '@lingui/core';
6
5
  import { warn } from '@rango-dev/logging-core';
@@ -21,6 +20,7 @@ import {
21
20
  import { useWalletList } from '../../hooks/useWalletList';
22
21
  import { useAppStore } from '../../store/AppStore';
23
22
  import { useUiStore } from '../../store/ui';
23
+ import { useWalletsStore } from '../../store/wallets';
24
24
  import { getBlockchainDisplayNameFor } from '../../utils/meta';
25
25
  import {
26
26
  getAddress,
@@ -41,9 +41,10 @@ export function WalletList(props: PropTypes) {
41
41
  const { chain, isSelected, selectWallet, limit, onShowMore } = props;
42
42
  const isActiveTab = useUiStore.use.isActiveTab();
43
43
 
44
- const { blockchains, connectedWallets } = useAppStore();
44
+ const connectedWallets = useWalletsStore.use.connectedWallets();
45
+ const { blockchains } = useAppStore();
45
46
  const [selectedWalletToConnect, setSelectedWalletToConnect] =
46
- useState<ExtendedModalWalletInfo>();
47
+ useState<WalletInfoWithExtra>();
47
48
  const [experimentalChainWallet, setExperimentalChainWallet] =
48
49
  useState<Wallet | null>(null);
49
50
  const [showExperimentalChainModal, setShowExperimentalChainModal] =
@@ -56,7 +57,7 @@ export function WalletList(props: PropTypes) {
56
57
  chain,
57
58
  });
58
59
 
59
- const [sortedList, setSortedList] = useState<ExtendedModalWalletInfo[]>(list);
60
+ const [sortedList, setSortedList] = useState<WalletInfoWithExtra[]>(list);
60
61
  const numberOfSupportedWallets = list.length;
61
62
  const shouldShowMoreWallets = limit && numberOfSupportedWallets - limit > 0;
62
63
 
@@ -147,13 +148,9 @@ export function WalletList(props: PropTypes) {
147
148
 
148
149
  const onSelectableWalletClick = async () => {
149
150
  const isDisconnected = wallet.state === WalletState.DISCONNECTED;
150
- const isConnectedButDifferentThanTargetNamespace = wallet.isHub
151
- ? !conciseAddress
152
- : !!wallet.namespaces && !conciseAddress;
153
-
154
151
  if (isDisconnected) {
155
152
  setSelectedWalletToConnect(wallet);
156
- } else if (isConnectedButDifferentThanTargetNamespace) {
153
+ } else if (!!wallet.namespaces && !conciseAddress) {
157
154
  // wallet is connected on a different namespace
158
155
  await handleDisconnect(wallet.type);
159
156
 
@@ -13,6 +13,7 @@ import { useNavigateBack } from '../../hooks/useNavigateBack';
13
13
  import { useTheme } from '../../hooks/useTheme';
14
14
  import { useAppStore } from '../../store/AppStore';
15
15
  import { tabManager, useUiStore } from '../../store/ui';
16
+ import { useWalletsStore } from '../../store/wallets';
16
17
  import { getContainer } from '../../utils/common';
17
18
  import { getPendingSwaps } from '../../utils/queue';
18
19
  import { isFeatureHidden } from '../../utils/settings';
@@ -27,8 +28,9 @@ import { Container, Content, Footer, LayoutContainer } from './Layout.styles';
27
28
  function Layout(props: PropsWithChildren<PropTypes>) {
28
29
  const { connectHeightObserver, disconnectHeightObserver } = useIframe();
29
30
  const { children, header, footer, height = 'fixed' } = props;
30
- const { fetchStatus, connectedWallets } = useAppStore();
31
+ const { fetchStatus } = useAppStore();
31
32
  const [openRefreshModal, setOpenRefreshModal] = useState(false);
33
+ const connectedWallets = useWalletsStore.use.connectedWallets();
32
34
  const {
33
35
  config: { features, theme },
34
36
  } = useAppStore();
@@ -17,11 +17,7 @@ import {
17
17
  import BigNumber from 'bignumber.js';
18
18
  import React, { useRef, useState } from 'react';
19
19
 
20
- import {
21
- GAS_FEE_MAX,
22
- ROUTE_TIME_MAX,
23
- SECONDS_IN_MINUTE,
24
- } from '../../constants/quote';
20
+ import { GAS_FEE_MAX } from '../../constants/quote';
25
21
  import {
26
22
  GAS_FEE_MAX_DECIMALS,
27
23
  GAS_FEE_MIN_DECIMALS,
@@ -315,8 +311,7 @@ export function Quote(props: QuoteProps) {
315
311
  const container = propContainer || getContainer();
316
312
  const sortedQuoteTags = sortTags(props.quote.tags || []);
317
313
  const showAllRoutesButton = !!onClickAllRoutes;
318
- const totalDurationSeconds = totalArrivalTime(quote?.swaps);
319
- const totalTime = roundedSecondsToString(totalDurationSeconds);
314
+ const totalTime = roundedSecondsToString(totalArrivalTime(quote?.swaps));
320
315
  const totalFee = getTotalFeeInUsd(quote?.swaps ?? [], findToken);
321
316
  const fee = numberToString(
322
317
  totalFee,
@@ -325,8 +320,6 @@ export function Quote(props: QuoteProps) {
325
320
  );
326
321
 
327
322
  const feeWarning = totalFee.gte(new BigNumber(GAS_FEE_MAX));
328
- const timeWarning =
329
- totalDurationSeconds / SECONDS_IN_MINUTE >= ROUTE_TIME_MAX;
330
323
 
331
324
  return fullExpandedMode ? (
332
325
  <FullExpandedQuote
@@ -336,18 +329,7 @@ export function Quote(props: QuoteProps) {
336
329
  tooltipContainer={getExpanded()}
337
330
  steps={steps}
338
331
  tags={sortedQuoteTags}
339
- quoteCost={
340
- <QuoteCostDetails
341
- quote={quote}
342
- fullExpandedMode
343
- time={totalTime}
344
- fee={fee}
345
- feeWarning={feeWarning}
346
- timeWarning={timeWarning}
347
- showModalFee={showModalFee}
348
- steps={numberOfSteps}
349
- />
350
- }
332
+ feeWarning={feeWarning}
351
333
  percentageChange={percentageChange}
352
334
  warningLevel={priceImpactWarningLevel}
353
335
  outputPrice={{
@@ -386,7 +368,6 @@ export function Quote(props: QuoteProps) {
386
368
  time={totalTime}
387
369
  fee={fee}
388
370
  feeWarning={feeWarning}
389
- timeWarning={timeWarning}
390
371
  showModalFee={showModalFee}
391
372
  steps={numberOfSteps}
392
373
  />
@@ -48,7 +48,5 @@ export type QuoteCostDetailsProps = {
48
48
  fee: string;
49
49
  time: string;
50
50
  feeWarning?: boolean;
51
- timeWarning?: boolean;
52
51
  showModalFee: boolean;
53
- fullExpandedMode?: boolean;
54
52
  };
@@ -28,6 +28,7 @@ export const ModalContainer = styled('div', {
28
28
 
29
29
  export const ModalHeader = styled('div', {
30
30
  padding: '$20 $20 $10',
31
+ textAlign: 'center',
31
32
  position: 'relative',
32
33
  '._icon-button': {
33
34
  position: 'absolute',
@@ -21,7 +21,7 @@ import {
21
21
  USD_VALUE_MAX_DECIMALS,
22
22
  USD_VALUE_MIN_DECIMALS,
23
23
  } from '../../constants/routing';
24
- import { getContainer, getExpanded } from '../../utils/common';
24
+ import { getContainer } from '../../utils/common';
25
25
  import { numberToString } from '../../utils/numbers';
26
26
  import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
27
27
  import { WatermarkedModal } from '../common/WatermarkedModal';
@@ -57,18 +57,9 @@ const NonPayableFee = (props: { fee: BigNumber; label: string }) => {
57
57
  export function QuoteCostDetails(props: QuoteCostDetailsProps) {
58
58
  const [open, setOpen] = useState<boolean>(false);
59
59
  const [openCollapse, setOpenCollapse] = useState<boolean>(false);
60
- const {
61
- steps,
62
- quote,
63
- fee,
64
- time,
65
- feeWarning,
66
- timeWarning,
67
- showModalFee,
68
- fullExpandedMode = false,
69
- } = props;
60
+ const { steps, quote, fee, time, feeWarning, showModalFee } = props;
70
61
  const swaps = quote?.swaps ?? [];
71
- const container = fullExpandedMode ? getExpanded() : getContainer();
62
+ const container = getContainer();
72
63
 
73
64
  const feesGroup = getFeesGroup(swaps);
74
65
 
@@ -85,7 +76,6 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
85
76
  }
86
77
  fee={fee}
87
78
  feeWarning={feeWarning}
88
- timeWarning={timeWarning}
89
79
  time={time}
90
80
  steps={steps}
91
81
  tooltipGas={showModalFee ? i18n.t('View more info') : undefined}
@@ -95,17 +85,8 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
95
85
  <WatermarkedModal
96
86
  container={container}
97
87
  open={open}
98
- anchor={fullExpandedMode ? 'center' : 'bottom'}
99
- styles={{
100
- container: {
101
- maxWidth: fullExpandedMode ? '484px' : 'unset',
102
- },
103
- }}
104
88
  header={
105
- <ModalHeader
106
- style={{
107
- textAlign: fullExpandedMode ? 'left' : 'center',
108
- }}>
89
+ <ModalHeader>
109
90
  <Typography variant="title" size="medium">
110
91
  {i18n.t('Gas & Fee Explanation')}
111
92
  </Typography>
@@ -1,6 +1,6 @@
1
1
  import type { Result } from '../../hooks/useStatefulConnect';
2
2
  import type { WalletInfoWithExtra } from '../../types';
3
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
3
+ import type { Namespace } from '@rango-dev/wallets-shared';
4
4
 
5
5
  import { Divider } from '@rango-dev/ui';
6
6
  import React, { useEffect, useRef, useState } from 'react';
@@ -160,12 +160,7 @@ export function SwapDetails(props: SwapDetailsProps) {
160
160
  canSwitchNetworkTo(currentStepWallet.walletType, currentStepBlockchain));
161
161
 
162
162
  const switchNetwork = showSwitchNetwork
163
- ? connect.bind(null, currentStepWallet.walletType, [
164
- {
165
- namespace: 'DISCOVER_MODE',
166
- network: currentStepBlockchain,
167
- },
168
- ])
163
+ ? connect.bind(null, currentStepWallet.walletType, currentStepBlockchain)
169
164
  : undefined;
170
165
 
171
166
  const stepMessage = getSwapMessages(swap, currentStep);
@@ -15,7 +15,7 @@ export interface SwapAlertsProps extends WaningAlertsProps {
15
15
  }
16
16
 
17
17
  export interface WaningAlertsProps extends FailedAlertsProps {
18
- switchNetwork: (() => Promise<ConnectResult[]>) | undefined;
18
+ switchNetwork: (() => Promise<ConnectResult>) | undefined;
19
19
  showNetworkModal: PendingSwapNetworkStatus | null | undefined;
20
20
  setNetworkModal: (network: ModalState) => void;
21
21
  }
@@ -15,9 +15,11 @@ import {
15
15
  Typography,
16
16
  VirtualizedList,
17
17
  } from '@rango-dev/ui';
18
- import React from 'react';
18
+ import React, { useEffect, useState } from 'react';
19
19
 
20
+ import { useObserveBalanceChanges } from '../../hooks/useObserveBalanceChanges';
20
21
  import { useAppStore } from '../../store/AppStore';
22
+ import { useWalletsStore } from '../../store/wallets';
21
23
  import { createTintsAndShades } from '../../utils/colors';
22
24
  import { formatBalance } from '../../utils/wallets';
23
25
 
@@ -91,7 +93,7 @@ const renderDesc = (props: RenderDescProps) => {
91
93
 
92
94
  export function TokenList(props: PropTypes) {
93
95
  const {
94
- list: tokens,
96
+ list,
95
97
  searchedFor = '',
96
98
  onChange,
97
99
  selectedBlockchain,
@@ -99,10 +101,29 @@ export function TokenList(props: PropTypes) {
99
101
  action,
100
102
  } = props;
101
103
 
104
+ const [tokens, setTokens] = useState<Token[]>(list);
102
105
  const fetchStatus = useAppStore().fetchStatus;
103
106
  const blockchains = useAppStore().blockchains();
104
- const { getBalanceFor, fetchingWallets: loadingWallet } = useAppStore();
107
+ const [hasNextPage, setHasNextPage] = useState<boolean>(true);
108
+ const { getBalanceFor, loading: loadingWallet } = useWalletsStore();
105
109
  const { isTokenPinned } = useAppStore();
110
+ /**
111
+ * We can create the key by hashing the list of tokens,
112
+ * but if the list is large, the memory usage and cost of comparisons may be high.
113
+ */
114
+ const { balanceKey } = useObserveBalanceChanges(selectedBlockchain);
115
+
116
+ const loadNextPage = () => {
117
+ setTokens(list.slice(0, tokens.length + PAGE_SIZE));
118
+ };
119
+
120
+ useEffect(() => {
121
+ setHasNextPage(list.length > tokens.length);
122
+ }, [tokens.length]);
123
+
124
+ useEffect(() => {
125
+ setTokens(list.slice(0, PAGE_SIZE));
126
+ }, [list.length, selectedBlockchain, balanceKey]);
106
127
 
107
128
  const endRenderer = (token: Token) => {
108
129
  const tokenBalance = formatBalance(getBalanceFor(token));
@@ -139,9 +160,11 @@ export function TokenList(props: PropTypes) {
139
160
  )
140
161
  );
141
162
  };
163
+
142
164
  const renderList = () => {
143
165
  return (
144
166
  <VirtualizedList
167
+ endReached={hasNextPage ? loadNextPage : undefined}
145
168
  itemContent={(index) => {
146
169
  const token = tokens[index];
147
170
  const address = token.address || '';
@@ -235,7 +258,7 @@ export function TokenList(props: PropTypes) {
235
258
  );
236
259
  }}
237
260
  totalCount={tokens.length}
238
- key={`${selectedBlockchain}-${searchedFor}`}
261
+ key={`${selectedBlockchain}-${searchedFor}-${balanceKey}`}
239
262
  />
240
263
  );
241
264
  };
@@ -1,5 +1,4 @@
1
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
2
- import type { DerivationPath } from '@rango-dev/wallets-shared';
1
+ import type { DerivationPath, Namespace } from '@rango-dev/wallets-shared';
3
2
 
4
3
  import { namespaces } from '@rango-dev/wallets-shared';
5
4
 
@@ -1,5 +1,5 @@
1
1
  import type { PropTypes } from './Namespaces.types';
2
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
2
+ import type { Namespace } from '@rango-dev/wallets-shared';
3
3
 
4
4
  import { i18n } from '@lingui/core';
5
5
  import {
@@ -1,5 +1,5 @@
1
1
  import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
2
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
2
+ import type { Namespace } from '@rango-dev/wallets-shared';
3
3
 
4
4
  export interface PropTypes {
5
5
  onConfirm: (namespaces: Namespace[]) => void;
@@ -33,5 +33,3 @@ export const HIGH_PRIORITY_TAGS: TagValue[] = [
33
33
  ];
34
34
 
35
35
  export const GAS_FEE_MAX = 30;
36
- export const ROUTE_TIME_MAX = 15;
37
- export const SECONDS_IN_MINUTE = 60;
@@ -4,7 +4,6 @@ export const Container = styled('div', {
4
4
  transition: 'width 0.2s, opacity 0.2s, margin-left 0.2s',
5
5
  height: '700px',
6
6
  width: '390px',
7
- position: 'relative',
8
7
  opacity: 1,
9
8
  marginLeft: '$16',
10
9
  backgroundColor: '$neutral100',
@@ -64,7 +64,7 @@ export function ExpandedQuotes(props: PropTypes) {
64
64
  />
65
65
  <Content>
66
66
  <Quotes
67
- showModalFee={true}
67
+ showModalFee={false}
68
68
  fetch={fetch}
69
69
  hasSort={false}
70
70
  loading={loading}
@@ -2,12 +2,10 @@ import type { PropTypes } from './Inputs.types';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
4
  import { SwapInput } from '@rango-dev/ui';
5
- import BigNumber from 'bignumber.js';
6
5
  import React from 'react';
7
6
 
8
7
  import { SwitchFromAndToButton } from '../../components/SwitchFromAndTo';
9
8
  import { errorMessages } from '../../constants/errors';
10
- import { ZERO } from '../../constants/numbers';
11
9
  import {
12
10
  PERCENTAGE_CHANGE_MAX_DECIMALS,
13
11
  PERCENTAGE_CHANGE_MIN_DECIMALS,
@@ -16,8 +14,8 @@ import {
16
14
  USD_VALUE_MAX_DECIMALS,
17
15
  USD_VALUE_MIN_DECIMALS,
18
16
  } from '../../constants/routing';
19
- import { useAppStore } from '../../store/AppStore';
20
17
  import { useQuoteStore } from '../../store/quote';
18
+ import { useWalletsStore } from '../../store/wallets';
21
19
  import { getContainer } from '../../utils/common';
22
20
  import { numberToString } from '../../utils/numbers';
23
21
  import { getPriceImpact, getPriceImpactLevel } from '../../utils/quote';
@@ -40,16 +38,15 @@ export function Inputs(props: PropTypes) {
40
38
  outputUsdValue,
41
39
  selectedQuote,
42
40
  } = useQuoteStore();
43
- const { connectedWallets, getBalanceFor } = useAppStore();
41
+ const { connectedWallets, getBalanceFor } = useWalletsStore();
44
42
  const fromTokenBalance = fromToken ? getBalanceFor(fromToken) : null;
45
43
  const fromTokenFormattedBalance =
46
44
  formatBalance(fromTokenBalance)?.amount ?? '0';
47
45
 
48
- const fromBalanceAmount = fromTokenBalance
49
- ? new BigNumber(fromTokenBalance.amount).shiftedBy(
50
- -fromTokenBalance.decimals
51
- )
52
- : ZERO;
46
+ const tokenBalanceReal =
47
+ !!fromBlockchain && !!fromToken
48
+ ? numberToString(fromTokenBalance?.amount, fromTokenBalance?.decimals)
49
+ : '0';
53
50
 
54
51
  const fetchingBalance =
55
52
  !!fromBlockchain &&
@@ -110,17 +107,7 @@ export function Inputs(props: PropTypes) {
110
107
  loadingBalance={fetchingBalance}
111
108
  tooltipContainer={getContainer()}
112
109
  onSelectMaxBalance={() => {
113
- const tokenBalanceReal = numberToString(
114
- fromBalanceAmount,
115
- fromTokenBalance?.decimals
116
- );
117
-
118
- // if a token hasn't any value, we will reset the input by setting an empty string.
119
- const nextInputAmount = !!fromTokenBalance?.amount
120
- ? tokenBalanceReal
121
- : '';
122
-
123
- setInputAmount(nextInputAmount);
110
+ setInputAmount(tokenBalanceReal.split(',').join(''));
124
111
  }}
125
112
  anyWalletConnected={connectedWallets.length > 0}
126
113
  />
@@ -15,7 +15,7 @@ import React, { createContext, useEffect, useMemo, useRef } from 'react';
15
15
  import { useWalletProviders } from '../../hooks/useWalletProviders';
16
16
  import { AppStoreProvider, useAppStore } from '../../store/AppStore';
17
17
  import { useUiStore } from '../../store/ui';
18
- import { isFeatureEnabled } from '../../utils/settings';
18
+ import { useWalletsStore } from '../../store/wallets';
19
19
  import {
20
20
  prepareAccountsForWalletStore,
21
21
  walletAndSupportedChainsNames,
@@ -38,7 +38,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
38
38
  fetchStatus,
39
39
  } = useAppStore();
40
40
  const blockchains = useAppStore().blockchains();
41
- const { newWalletConnected, disconnectWallet } = useAppStore();
41
+ const { findToken } = useAppStore();
42
42
  const config = useAppStore().config;
43
43
 
44
44
  const walletOptions: ProvidersOptions = {
@@ -48,9 +48,9 @@ function Main(props: PropsWithChildren<PropTypes>) {
48
48
  walletConnectListedDesktopWalletLink:
49
49
  props.config.__UNSTABLE_OR_INTERNAL__
50
50
  ?.walletConnectListedDesktopWalletLink,
51
- experimentalWallet: props.config.features?.experimentalWallet,
52
51
  };
53
52
  const { providers } = useWalletProviders(config.wallets, walletOptions);
53
+ const { connectWallet, disconnectWallet } = useWalletsStore();
54
54
  const onConnectWalletHandler = useRef<OnWalletConnectionChange>();
55
55
  const onDisconnectWalletHandler = useRef<OnWalletConnectionChange>();
56
56
 
@@ -86,7 +86,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
86
86
  meta.isContractWallet
87
87
  );
88
88
  if (data.length) {
89
- void newWalletConnected(data);
89
+ connectWallet(data, findToken);
90
90
  }
91
91
  } else {
92
92
  disconnectWallet(type);
@@ -99,17 +99,17 @@ function Main(props: PropsWithChildren<PropTypes>) {
99
99
  }
100
100
  }
101
101
  }
102
- if (
103
- (event === Events.ACCOUNTS && state.connected) ||
104
- // Hub works differently, and this check should be enough.
105
- (event === Events.ACCOUNTS && meta.isHub)
106
- ) {
102
+ if (event === Events.ACCOUNTS && state.connected) {
107
103
  const key = `${type}-${state.network}-${value}`;
108
104
 
109
- if (!!onConnectWalletHandler.current) {
110
- onConnectWalletHandler.current(key);
111
- } else {
112
- console.warn(`onConnectWallet handler hasn't been set. Are you sure?`);
105
+ if (state.connected) {
106
+ if (!!onConnectWalletHandler.current) {
107
+ onConnectWalletHandler.current(key);
108
+ } else {
109
+ console.warn(
110
+ `onConnectWallet handler hasn't been set. Are you sure?`
111
+ );
112
+ }
113
113
  }
114
114
  }
115
115
 
@@ -147,13 +147,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
147
147
  allBlockChains={blockchains}
148
148
  providers={providers}
149
149
  onUpdateState={onUpdateState}
150
- autoConnect={!!isActiveTab}
151
- configs={{
152
- isExperimentalEnabled: isFeatureEnabled(
153
- 'experimentalWallet',
154
- config.features
155
- ),
156
- }}>
150
+ autoConnect={!!isActiveTab}>
157
151
  {props.children}
158
152
  </Provider>
159
153
  </WidgetContext.Provider>