@rango-dev/widget-embedded 0.37.1-next.1 → 0.38.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 (156) 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/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
  12. package/dist/components/Quotes/Quotes.d.ts.map +1 -1
  13. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
  14. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  15. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +1 -1
  16. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
  17. package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
  18. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  19. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +1 -2
  20. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
  21. package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
  22. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +1 -1
  23. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  24. package/dist/constants/quote.d.ts +0 -10
  25. package/dist/constants/quote.d.ts.map +1 -1
  26. package/dist/constants/warnings.d.ts +3 -0
  27. package/dist/constants/warnings.d.ts.map +1 -0
  28. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
  29. package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
  30. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  31. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  32. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
  33. package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +1 -1
  34. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +3 -3
  35. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
  36. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
  37. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +4 -6
  38. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
  39. package/dist/hooks/useFetchApiConfig.d.ts.map +1 -1
  40. package/dist/hooks/useFetchCustomToken.d.ts.map +1 -1
  41. package/dist/hooks/useObserveBalanceChanges/index.d.ts +2 -0
  42. package/dist/hooks/useObserveBalanceChanges/index.d.ts.map +1 -0
  43. package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts +4 -0
  44. package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts.map +1 -0
  45. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -2
  46. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  47. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +5 -3
  48. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  49. package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
  50. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  51. package/dist/hooks/useWalletList.d.ts.map +1 -1
  52. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +3 -2
  53. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
  54. package/dist/index.d.ts +1 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +2 -2
  57. package/dist/index.js.map +4 -4
  58. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  59. package/dist/pages/Home.d.ts.map +1 -1
  60. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  61. package/dist/store/app.d.ts +4 -2
  62. package/dist/store/app.d.ts.map +1 -1
  63. package/dist/store/quote.d.ts.map +1 -1
  64. package/dist/store/slices/config.d.ts +0 -4
  65. package/dist/store/slices/config.d.ts.map +1 -1
  66. package/dist/store/slices/data.d.ts.map +1 -1
  67. package/dist/store/ui.d.ts +0 -4
  68. package/dist/store/ui.d.ts.map +1 -1
  69. package/dist/store/wallets.d.ts +66 -0
  70. package/dist/store/wallets.d.ts.map +1 -0
  71. package/dist/types/config.d.ts +9 -7
  72. package/dist/types/config.d.ts.map +1 -1
  73. package/dist/types/quote.d.ts +17 -8
  74. package/dist/types/quote.d.ts.map +1 -1
  75. package/dist/types/wallets.d.ts +7 -3
  76. package/dist/types/wallets.d.ts.map +1 -1
  77. package/dist/utils/providers.d.ts +9 -8
  78. package/dist/utils/providers.d.ts.map +1 -1
  79. package/dist/utils/quote.d.ts +6 -5
  80. package/dist/utils/quote.d.ts.map +1 -1
  81. package/dist/utils/settings.d.ts +0 -1
  82. package/dist/utils/settings.d.ts.map +1 -1
  83. package/dist/utils/swap.d.ts +5 -5
  84. package/dist/utils/swap.d.ts.map +1 -1
  85. package/dist/utils/wallets.d.ts +14 -12
  86. package/dist/utils/wallets.d.ts.map +1 -1
  87. package/dist/widget-embedded.build.json +1 -1
  88. package/package.json +9 -9
  89. package/src/QueueManager.tsx +11 -17
  90. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +24 -5
  91. package/src/components/ConfirmWalletsModal/WalletList.tsx +7 -10
  92. package/src/components/Layout/Layout.tsx +3 -1
  93. package/src/components/Quote/Quote.tsx +3 -22
  94. package/src/components/Quote/Quote.types.ts +0 -2
  95. package/src/components/Quote/QuoteCostDetails.styles.ts +1 -0
  96. package/src/components/Quote/QuoteCostDetails.tsx +4 -23
  97. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +22 -42
  98. package/src/components/Quotes/Quotes.tsx +3 -2
  99. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
  100. package/src/components/SwapDetails/SwapDetails.tsx +6 -14
  101. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
  102. package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +13 -26
  103. package/src/components/TokenList/TokenList.tsx +27 -4
  104. package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +1 -2
  105. package/src/components/WalletStatefulConnect/Namespaces.tsx +38 -31
  106. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +1 -1
  107. package/src/constants/quote.ts +0 -25
  108. package/src/constants/warnings.ts +26 -0
  109. package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +0 -1
  110. package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +1 -1
  111. package/src/containers/Inputs/Inputs.tsx +7 -20
  112. package/src/containers/QuoteInfo/QuoteInfo.tsx +9 -3
  113. package/src/containers/Wallets/Wallets.tsx +16 -82
  114. package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +2 -2
  115. package/src/containers/WidgetInfo/WidgetInfo.tsx +8 -10
  116. package/src/containers/WidgetInfo/WidgetInfo.types.ts +3 -3
  117. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +66 -29
  118. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +15 -10
  119. package/src/hooks/useFetchApiConfig.ts +1 -5
  120. package/src/hooks/useFetchCustomToken.ts +0 -5
  121. package/src/hooks/useObserveBalanceChanges/index.ts +1 -0
  122. package/src/hooks/useObserveBalanceChanges/useObserveBalanceChanges.ts +68 -0
  123. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +17 -50
  124. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +5 -3
  125. package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +6 -7
  126. package/src/hooks/useSwapInput.ts +11 -3
  127. package/src/hooks/useWalletList.ts +8 -6
  128. package/src/hooks/useWalletProviders/useWalletProviders.ts +12 -8
  129. package/src/index.ts +1 -1
  130. package/src/pages/ConfirmSwapPage.tsx +15 -7
  131. package/src/pages/Home.tsx +3 -5
  132. package/src/pages/SelectSwapItemsPage.tsx +2 -1
  133. package/src/store/app.ts +4 -4
  134. package/src/store/quote.ts +13 -3
  135. package/src/store/slices/config.ts +0 -76
  136. package/src/store/slices/data.test.ts +1 -23
  137. package/src/store/slices/data.ts +2 -3
  138. package/src/store/ui.ts +0 -6
  139. package/src/store/wallets.ts +268 -0
  140. package/src/types/config.ts +9 -8
  141. package/src/types/quote.ts +24 -10
  142. package/src/types/wallets.ts +7 -3
  143. package/src/utils/providers.ts +36 -88
  144. package/src/utils/quote.ts +45 -57
  145. package/src/utils/settings.ts +0 -4
  146. package/src/utils/swap.ts +37 -56
  147. package/src/utils/wallets.ts +141 -76
  148. package/dist/store/slices/types.d.ts +0 -6
  149. package/dist/store/slices/types.d.ts.map +0 -1
  150. package/dist/store/slices/wallets.d.ts +0 -80
  151. package/dist/store/slices/wallets.d.ts.map +0 -1
  152. package/dist/store/utils/wallets.d.ts +0 -17
  153. package/dist/store/utils/wallets.d.ts.map +0 -1
  154. package/src/store/slices/types.ts +0 -9
  155. package/src/store/slices/wallets.ts +0 -577
  156. package/src/store/utils/wallets.ts +0 -111
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.37.1-next.1",
3
+ "version": "0.38.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.41.1-next.0",
28
+ "@rango-dev/provider-all": "^0.42.0",
29
29
  "@rango-dev/queue-manager-core": "^0.27.0",
30
- "@rango-dev/queue-manager-rango-preset": "^0.41.1-next.0",
30
+ "@rango-dev/queue-manager-rango-preset": "^0.41.0",
31
31
  "@rango-dev/queue-manager-react": "^0.27.0",
32
- "@rango-dev/signer-solana": "^0.35.1-next.0",
33
- "@rango-dev/ui": "^0.43.1-next.0",
34
- "@rango-dev/wallets-core": "^0.40.1-next.8",
35
- "@rango-dev/wallets-react": "^0.27.1-next.0",
36
- "@rango-dev/wallets-shared": "^0.41.1-next.0",
32
+ "@rango-dev/signer-solana": "^0.36.0",
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",
@@ -54,4 +54,4 @@
54
54
  "publishConfig": {
55
55
  "access": "public"
56
56
  }
57
- }
57
+ }
@@ -1,8 +1,5 @@
1
- import type {
2
- SwapQueueContext,
3
- TargetNamespace,
4
- } from '@rango-dev/queue-manager-rango-preset';
5
- import type { WalletType } from '@rango-dev/wallets-shared';
1
+ import type { SwapQueueContext } from '@rango-dev/queue-manager-rango-preset';
2
+ import type { Network, WalletType } from '@rango-dev/wallets-shared';
6
3
  import type { PropsWithChildren } from 'react';
7
4
 
8
5
  import {
@@ -18,6 +15,7 @@ import React, { useMemo } from 'react';
18
15
  import { eventEmitter } from './services/eventEmitter';
19
16
  import { useAppStore } from './store/AppStore';
20
17
  import { useUiStore } from './store/ui';
18
+ import { useWalletsStore } from './store/wallets';
21
19
  import { getConfig } from './utils/configs';
22
20
  import { walletAndSupportedChainsNames } from './utils/wallets';
23
21
 
@@ -41,8 +39,8 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
41
39
  });
42
40
  }, [props.apiKey]);
43
41
 
44
- const { blockchains, connectedWallets } = useAppStore();
45
- const blockchainsList = blockchains();
42
+ const blockchains = useAppStore().blockchains();
43
+ const connectedWallets = useWalletsStore.use.connectedWallets();
46
44
 
47
45
  const wallets = {
48
46
  blockchains: connectedWallets.map((wallet) => ({
@@ -51,23 +49,18 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
51
49
  })),
52
50
  };
53
51
 
54
- const switchNetwork = async (
55
- wallet: WalletType,
56
- namespace: TargetNamespace
57
- ) => {
58
- if (!canSwitchNetworkTo(wallet, namespace.network)) {
52
+ const switchNetwork = async (wallet: WalletType, network: Network) => {
53
+ if (!canSwitchNetworkTo(wallet, network)) {
59
54
  return undefined;
60
55
  }
61
- const result = await connect(wallet, [namespace]);
62
-
63
- return result;
56
+ return connect(wallet, network);
64
57
  };
65
58
 
66
59
  const isMobileWallet = (walletType: WalletType): boolean =>
67
60
  !!getWalletInfo(walletType).mobileWallet;
68
61
 
69
62
  // TODO: this code copy & pasted from rango, should be refactored.
70
- const allBlockchains = blockchainsList
63
+ const allBlockchains = blockchains
71
64
  .filter((blockchain) => blockchain.enabled)
72
65
  .reduce(
73
66
  (blockchainsObj: any, blockchain) => (
@@ -75,7 +68,7 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
75
68
  ),
76
69
  {}
77
70
  );
78
- const evmBasedChains = blockchainsList.filter(isEvmBlockchain);
71
+ const evmBasedChains = blockchains.filter(isEvmBlockchain);
79
72
  const getSupportedChainNames = (type: WalletType) => {
80
73
  const { supportedChains } = getWalletInfo(type);
81
74
  return walletAndSupportedChainsNames(supportedChains);
@@ -95,6 +88,7 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
95
88
  providers: allProviders,
96
89
  switchNetwork,
97
90
  canSwitchNetworkTo,
91
+ connect,
98
92
  state,
99
93
  isMobileWallet,
100
94
  };
@@ -1,6 +1,6 @@
1
1
  import type { PropTypes } from './ConfirmWalletsModal.types';
2
- import type { ConnectedWallet } from '../../store/slices/wallets';
3
- import type { Wallet } from '../../types';
2
+ import type { ConnectedWallet } from '../../store/wallets';
3
+ import type { ConfirmSwapWarnings, Wallet } from '../../types';
4
4
 
5
5
  import { i18n } from '@lingui/core';
6
6
  import {
@@ -17,8 +17,10 @@ import { useNavigate } from 'react-router-dom';
17
17
 
18
18
  import { WIDGET_UI_ID } from '../../constants';
19
19
  import { getQuoteErrorMessage } from '../../constants/errors';
20
+ import { getQuoteUpdateWarningMessage } from '../../constants/warnings';
20
21
  import { useAppStore } from '../../store/AppStore';
21
22
  import { useQuoteStore } from '../../store/quote';
23
+ import { useWalletsStore } from '../../store/wallets';
22
24
  import { getBlockchainShortNameFor } from '../../utils/meta';
23
25
  import { isConfirmSwapDisabled } from '../../utils/swap';
24
26
  import { getQuoteWallets } from '../../utils/wallets';
@@ -52,11 +54,15 @@ export function ConfirmWalletsModal(props: PropTypes) {
52
54
  customDestination,
53
55
  setCustomDestination,
54
56
  } = useQuoteStore();
55
- const { config, connectedWallets, setWalletsAsSelected } = useAppStore();
57
+ const { connectedWallets, selectWallets } = useWalletsStore();
58
+ const { config } = useAppStore();
56
59
 
57
60
  const [showMoreWalletFor, setShowMoreWalletFor] = useState('');
58
61
  const [balanceWarnings, setBalanceWarnings] = useState<string[]>([]);
59
62
  const [error, setError] = useState('');
63
+ const [quoteWarning, setQuoteWarning] = useState<
64
+ ConfirmSwapWarnings['quoteUpdate'] | null
65
+ >(null);
60
66
 
61
67
  const [isCustomDestinationOpen, setCustomDestinationOpen] = useState(
62
68
  !!customDestination
@@ -211,7 +217,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
211
217
  const lastSelectedWallets = selectableWallets.filter(
212
218
  (wallet) => wallet.selected
213
219
  );
214
- setWalletsAsSelected(lastSelectedWallets);
220
+ selectWallets(lastSelectedWallets);
215
221
  selectQuoteWallets(lastSelectedWallets);
216
222
  setQuoteWalletConfirmed(true);
217
223
  onClose();
@@ -220,6 +226,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
220
226
  const onConfirmWallets = async () => {
221
227
  setBalanceWarnings([]);
222
228
  setError('');
229
+ setQuoteWarning(null);
223
230
 
224
231
  const result = await onCheckBalance?.({
225
232
  selectedWallets: selectableWallets.filter((wallet) => wallet.selected),
@@ -229,7 +236,9 @@ export function ConfirmWalletsModal(props: PropTypes) {
229
236
  if (warnings?.balance?.messages) {
230
237
  setBalanceWarnings(warnings.balance.messages);
231
238
  }
232
-
239
+ if (warnings?.quoteUpdate) {
240
+ setQuoteWarning(warnings.quoteUpdate);
241
+ }
233
242
  if (result.error) {
234
243
  setError(getQuoteErrorMessage(result.error));
235
244
  }
@@ -409,6 +418,16 @@ export function ConfirmWalletsModal(props: PropTypes) {
409
418
  <Divider size={12} />
410
419
  </>
411
420
  )}
421
+ {quoteWarning && (
422
+ <>
423
+ <Alert
424
+ variant="alarm"
425
+ type="warning"
426
+ title={getQuoteUpdateWarningMessage(quoteWarning)}
427
+ />
428
+ <Divider size={12} />
429
+ </>
430
+ )}
412
431
  <Wallets>
413
432
  {quoteWallets.map((requiredWallet, index) => {
414
433
  const blockchain = blockchains.find(
@@ -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.needsNamespace && !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>
@@ -44,50 +44,30 @@ export function makeAlerts(
44
44
  return alertInfo;
45
45
  }
46
46
  if (warning) {
47
- switch (warning.type) {
48
- case QuoteWarningType.HIGH_VALUE_LOSS: {
49
- const warningLevel = getPriceImpactLevel(warning.priceImpact);
50
- if (warningLevel === 'high') {
51
- alertInfo.alertType = 'error';
52
- }
53
- alertInfo.action = 'show-info';
54
- alertInfo.title = errorMessages().highValueLossError.title;
55
- break;
47
+ if (warning.type === QuoteWarningType.HIGH_VALUE_LOSS) {
48
+ const warningLevel = getPriceImpactLevel(warning.priceImpact);
49
+ if (warningLevel === 'high') {
50
+ alertInfo.alertType = 'error';
56
51
  }
57
- case QuoteWarningType.EXCESSIVE_OUTPUT_AMOUNT_CHANGE: {
58
- alertInfo.title = i18n.t({
59
- id: 'Output amount changed by {percentageChange}% (${usdValueChange}).',
60
- values: {
61
- percentageChange: warning.percentageChange,
62
- usdValueChange: warning.usdValueChange,
63
- },
64
- });
65
- break;
66
- }
67
- case QuoteWarningType.UNKNOWN_PRICE: {
68
- alertInfo.title = errorMessages().unknownPriceError.title;
69
- break;
70
- }
71
- case QuoteWarningType.INSUFFICIENT_SLIPPAGE: {
72
- alertInfo.title = i18n.t({
73
- id: 'We recommend you to increase slippage to at least {minRequiredSlippage} for this route.',
74
- values: {
75
- minRequiredSlippage: warning.minRequiredSlippage,
76
- },
77
- });
78
- alertInfo.action = 'change-settings';
79
- break;
80
- }
81
- case QuoteWarningType.HIGH_SLIPPAGE: {
82
- alertInfo.title = i18n.t('Caution, your slippage is high.');
83
- alertInfo.action = 'change-settings';
84
- break;
85
- }
86
-
87
- default:
88
- break;
52
+ alertInfo.action = 'show-info';
53
+ alertInfo.title = errorMessages().highValueLossError.title;
54
+ }
55
+ if (warning.type === QuoteWarningType.UNKNOWN_PRICE) {
56
+ alertInfo.title = errorMessages().unknownPriceError.title;
57
+ }
58
+ if (warning.type === QuoteWarningType.INSUFFICIENT_SLIPPAGE) {
59
+ alertInfo.title = i18n.t({
60
+ id: 'We recommend you to increase slippage to at least {minRequiredSlippage} for this route.',
61
+ values: {
62
+ minRequiredSlippage: warning.minRequiredSlippage,
63
+ },
64
+ });
65
+ alertInfo.action = 'change-settings';
66
+ }
67
+ if (warning.type === QuoteWarningType.HIGH_SLIPPAGE) {
68
+ alertInfo.title = i18n.t('Caution, your slippage is high.');
69
+ alertInfo.action = 'change-settings';
89
70
  }
90
-
91
71
  return alertInfo;
92
72
  }
93
73
  return null;
@@ -53,8 +53,9 @@ export function Quotes(props: PropTypes) {
53
53
  ...quote,
54
54
  };
55
55
 
56
- return generateQuoteWarnings({
57
- currentQuote: mergedQuote,
56
+ return generateQuoteWarnings(mergedQuote, {
57
+ fromToken,
58
+ toToken,
58
59
  userSlippage,
59
60
  findToken,
60
61
  });
@@ -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';
@@ -3,7 +3,7 @@ import type { ModalState } from '../SwapDetailsModal';
3
3
 
4
4
  import { i18n } from '@lingui/core';
5
5
  import {
6
- getCurrentNamespaceOfOrNull,
6
+ getCurrentBlockchainOfOrNull,
7
7
  getCurrentStep,
8
8
  getRelatedWalletOrNull,
9
9
  } from '@rango-dev/queue-manager-rango-preset';
@@ -138,8 +138,8 @@ export function SwapDetails(props: SwapDetailsProps) {
138
138
  const lastConvertedTokenInFailedSwap =
139
139
  getLastConvertedTokenInFailedSwap(swap);
140
140
 
141
- const currentStepNamespace = currentStep
142
- ? getCurrentNamespaceOfOrNull(swap, currentStep)
141
+ const currentStepBlockchain = currentStep
142
+ ? getCurrentBlockchainOfOrNull(swap, currentStep)
143
143
  : null;
144
144
  const currentStepWallet = currentStep
145
145
  ? getRelatedWalletOrNull(swap, currentStep)
@@ -154,21 +154,13 @@ export function SwapDetails(props: SwapDetailsProps) {
154
154
  const showSwitchNetwork =
155
155
  currentStepNetworkStatus ===
156
156
  PendingSwapNetworkStatus.WaitingForNetworkChange &&
157
- !!currentStepNamespace &&
157
+ !!currentStepBlockchain &&
158
158
  !!currentStepWallet?.walletType &&
159
159
  (isMobileWallet(currentStepWallet.walletType) ||
160
- canSwitchNetworkTo(
161
- currentStepWallet.walletType,
162
- currentStepNamespace.network
163
- ));
160
+ canSwitchNetworkTo(currentStepWallet.walletType, currentStepBlockchain));
164
161
 
165
162
  const switchNetwork = showSwitchNetwork
166
- ? connect.bind(null, currentStepWallet.walletType, [
167
- {
168
- namespace: currentStepNamespace.namespace,
169
- network: currentStepNamespace.network,
170
- },
171
- ])
163
+ ? connect.bind(null, currentStepWallet.walletType, currentStepBlockchain)
172
164
  : undefined;
173
165
 
174
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
  }
@@ -12,7 +12,6 @@ import React from 'react';
12
12
  import { useNavigate } from 'react-router-dom';
13
13
 
14
14
  import { WIDGET_UI_ID } from '../../constants';
15
- import { useUiStore } from '../../store/ui';
16
15
  import { getContainer } from '../../utils/common';
17
16
  import { WatermarkedModal } from '../common/WatermarkedModal';
18
17
 
@@ -32,7 +31,6 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
32
31
  diagnosisUrl,
33
32
  } = props;
34
33
  const navigate = useNavigate();
35
- const { showProfileBanner } = useUiStore();
36
34
 
37
35
  return (
38
36
  <WatermarkedModal
@@ -74,32 +72,21 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
74
72
  description={description}
75
73
  />
76
74
  )}
77
- <Divider size={30} />
75
+ <Divider size={32} />
78
76
  {status === 'success' && (
79
- <>
80
- {showProfileBanner && (
81
- <>
82
- <img
83
- src={
84
- 'https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.png'
85
- }
86
- alt="Profile Banner"
87
- />
88
- <Divider size={30} />
89
- </>
90
- )}
91
- <Button
92
- id="widget-swap-details-modal-done-btn"
93
- variant="contained"
94
- type="primary"
95
- size="large"
96
- onClick={() => {
97
- const home = '../../';
98
- navigate(home);
99
- }}>
77
+ <Button
78
+ id="widget-swap-details-modal-done-btn"
79
+ variant="contained"
80
+ type="primary"
81
+ size="large"
82
+ onClick={() => {
83
+ const home = '../../';
84
+ navigate(home);
85
+ }}>
86
+ <Typography variant="title" size="medium" color="neutral100">
100
87
  {i18n.t('Done')}
101
- </Button>
102
- </>
88
+ </Typography>
89
+ </Button>
103
90
  )}
104
91
  <Divider size={12} />
105
92
  {diagnosisUrl && (