@rango-dev/widget-embedded 0.37.0 → 0.37.1-next.1

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 (157) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/QueueManager.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  4. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  5. package/dist/components/Layout/Layout.d.ts.map +1 -1
  6. package/dist/components/Quote/Quote.d.ts.map +1 -1
  7. package/dist/components/Quote/Quote.styles.d.ts +1 -1
  8. package/dist/components/Quote/Quote.types.d.ts +2 -0
  9. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  10. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
  11. package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
  12. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
  13. package/dist/components/Quotes/Quotes.d.ts.map +1 -1
  14. package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
  15. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  16. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +1 -1
  17. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
  18. package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
  19. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  20. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +2 -1
  21. package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
  22. package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
  23. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +1 -1
  24. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  25. package/dist/constants/quote.d.ts +10 -0
  26. package/dist/constants/quote.d.ts.map +1 -1
  27. package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
  28. package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
  29. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  30. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  31. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
  32. package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +1 -1
  33. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +3 -3
  34. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
  35. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
  36. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +6 -4
  37. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
  38. package/dist/hooks/useFetchApiConfig.d.ts.map +1 -1
  39. package/dist/hooks/useFetchCustomToken.d.ts.map +1 -1
  40. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +2 -1
  41. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  42. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +3 -5
  43. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  44. package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
  45. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  46. package/dist/hooks/useWalletList.d.ts.map +1 -1
  47. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +2 -3
  48. package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +2 -2
  52. package/dist/index.js.map +4 -4
  53. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  54. package/dist/pages/Home.d.ts.map +1 -1
  55. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  56. package/dist/store/app.d.ts +2 -4
  57. package/dist/store/app.d.ts.map +1 -1
  58. package/dist/store/quote.d.ts.map +1 -1
  59. package/dist/store/slices/config.d.ts +4 -0
  60. package/dist/store/slices/config.d.ts.map +1 -1
  61. package/dist/store/slices/data.d.ts.map +1 -1
  62. package/dist/store/slices/types.d.ts +6 -0
  63. package/dist/store/slices/types.d.ts.map +1 -0
  64. package/dist/store/slices/wallets.d.ts +80 -0
  65. package/dist/store/slices/wallets.d.ts.map +1 -0
  66. package/dist/store/ui.d.ts +4 -0
  67. package/dist/store/ui.d.ts.map +1 -1
  68. package/dist/store/utils/wallets.d.ts +17 -0
  69. package/dist/store/utils/wallets.d.ts.map +1 -0
  70. package/dist/types/config.d.ts +6 -3
  71. package/dist/types/config.d.ts.map +1 -1
  72. package/dist/types/quote.d.ts +8 -17
  73. package/dist/types/quote.d.ts.map +1 -1
  74. package/dist/types/wallets.d.ts +3 -7
  75. package/dist/types/wallets.d.ts.map +1 -1
  76. package/dist/utils/providers.d.ts +8 -9
  77. package/dist/utils/providers.d.ts.map +1 -1
  78. package/dist/utils/quote.d.ts +5 -6
  79. package/dist/utils/quote.d.ts.map +1 -1
  80. package/dist/utils/settings.d.ts +1 -0
  81. package/dist/utils/settings.d.ts.map +1 -1
  82. package/dist/utils/swap.d.ts +5 -5
  83. package/dist/utils/swap.d.ts.map +1 -1
  84. package/dist/utils/wallets.d.ts +12 -14
  85. package/dist/utils/wallets.d.ts.map +1 -1
  86. package/dist/widget-embedded.build.json +1 -1
  87. package/package.json +9 -9
  88. package/src/QueueManager.tsx +17 -11
  89. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -24
  90. package/src/components/ConfirmWalletsModal/WalletList.tsx +10 -7
  91. package/src/components/Layout/Layout.tsx +1 -3
  92. package/src/components/Quote/Quote.tsx +22 -3
  93. package/src/components/Quote/Quote.types.ts +2 -0
  94. package/src/components/Quote/QuoteCostDetails.styles.ts +0 -1
  95. package/src/components/Quote/QuoteCostDetails.tsx +23 -4
  96. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +42 -22
  97. package/src/components/Quotes/Quotes.tsx +2 -3
  98. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
  99. package/src/components/SwapDetails/SwapDetails.tsx +14 -6
  100. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
  101. package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +26 -13
  102. package/src/components/TokenList/TokenList.tsx +4 -27
  103. package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +2 -1
  104. package/src/components/WalletStatefulConnect/Namespaces.tsx +31 -38
  105. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +1 -1
  106. package/src/constants/quote.ts +25 -0
  107. package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +1 -0
  108. package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +1 -1
  109. package/src/containers/Inputs/Inputs.tsx +20 -7
  110. package/src/containers/QuoteInfo/QuoteInfo.tsx +3 -9
  111. package/src/containers/Wallets/Wallets.tsx +82 -16
  112. package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +2 -2
  113. package/src/containers/WidgetInfo/WidgetInfo.tsx +10 -8
  114. package/src/containers/WidgetInfo/WidgetInfo.types.ts +3 -3
  115. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +29 -66
  116. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +10 -15
  117. package/src/hooks/useFetchApiConfig.ts +5 -1
  118. package/src/hooks/useFetchCustomToken.ts +5 -0
  119. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +50 -17
  120. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +3 -5
  121. package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +7 -6
  122. package/src/hooks/useSwapInput.ts +3 -11
  123. package/src/hooks/useWalletList.ts +6 -8
  124. package/src/hooks/useWalletProviders/useWalletProviders.ts +8 -12
  125. package/src/index.ts +1 -1
  126. package/src/pages/ConfirmSwapPage.tsx +7 -15
  127. package/src/pages/Home.tsx +5 -3
  128. package/src/pages/SelectSwapItemsPage.tsx +1 -2
  129. package/src/store/app.ts +4 -4
  130. package/src/store/quote.ts +3 -13
  131. package/src/store/slices/config.ts +76 -0
  132. package/src/store/slices/data.test.ts +23 -1
  133. package/src/store/slices/data.ts +3 -2
  134. package/src/store/slices/types.ts +9 -0
  135. package/src/store/slices/wallets.ts +577 -0
  136. package/src/store/ui.ts +6 -0
  137. package/src/store/utils/wallets.ts +111 -0
  138. package/src/types/config.ts +7 -3
  139. package/src/types/quote.ts +10 -24
  140. package/src/types/wallets.ts +3 -7
  141. package/src/utils/providers.ts +88 -36
  142. package/src/utils/quote.ts +57 -45
  143. package/src/utils/settings.ts +4 -0
  144. package/src/utils/swap.ts +56 -37
  145. package/src/utils/wallets.ts +76 -141
  146. package/dist/constants/warnings.d.ts +0 -3
  147. package/dist/constants/warnings.d.ts.map +0 -1
  148. package/dist/hooks/useObserveBalanceChanges/index.d.ts +0 -2
  149. package/dist/hooks/useObserveBalanceChanges/index.d.ts.map +0 -1
  150. package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts +0 -4
  151. package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts.map +0 -1
  152. package/dist/store/wallets.d.ts +0 -66
  153. package/dist/store/wallets.d.ts.map +0 -1
  154. package/src/constants/warnings.ts +0 -26
  155. package/src/hooks/useObserveBalanceChanges/index.ts +0 -1
  156. package/src/hooks/useObserveBalanceChanges/useObserveBalanceChanges.ts +0 -68
  157. package/src/store/wallets.ts +0 -268
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/widget-embedded",
3
- "version": "0.37.0",
3
+ "version": "0.37.1-next.1",
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.0",
28
+ "@rango-dev/provider-all": "^0.41.1-next.0",
29
29
  "@rango-dev/queue-manager-core": "^0.27.0",
30
- "@rango-dev/queue-manager-rango-preset": "^0.41.0",
30
+ "@rango-dev/queue-manager-rango-preset": "^0.41.1-next.0",
31
31
  "@rango-dev/queue-manager-react": "^0.27.0",
32
- "@rango-dev/signer-solana": "^0.35.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",
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",
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,5 +1,8 @@
1
- import type { SwapQueueContext } from '@rango-dev/queue-manager-rango-preset';
2
- import type { Network, WalletType } from '@rango-dev/wallets-shared';
1
+ import type {
2
+ SwapQueueContext,
3
+ TargetNamespace,
4
+ } from '@rango-dev/queue-manager-rango-preset';
5
+ import type { WalletType } from '@rango-dev/wallets-shared';
3
6
  import type { PropsWithChildren } from 'react';
4
7
 
5
8
  import {
@@ -15,7 +18,6 @@ import React, { useMemo } from 'react';
15
18
  import { eventEmitter } from './services/eventEmitter';
16
19
  import { useAppStore } from './store/AppStore';
17
20
  import { useUiStore } from './store/ui';
18
- import { useWalletsStore } from './store/wallets';
19
21
  import { getConfig } from './utils/configs';
20
22
  import { walletAndSupportedChainsNames } from './utils/wallets';
21
23
 
@@ -39,8 +41,8 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
39
41
  });
40
42
  }, [props.apiKey]);
41
43
 
42
- const blockchains = useAppStore().blockchains();
43
- const connectedWallets = useWalletsStore.use.connectedWallets();
44
+ const { blockchains, connectedWallets } = useAppStore();
45
+ const blockchainsList = blockchains();
44
46
 
45
47
  const wallets = {
46
48
  blockchains: connectedWallets.map((wallet) => ({
@@ -49,18 +51,23 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
49
51
  })),
50
52
  };
51
53
 
52
- const switchNetwork = async (wallet: WalletType, network: Network) => {
53
- if (!canSwitchNetworkTo(wallet, network)) {
54
+ const switchNetwork = async (
55
+ wallet: WalletType,
56
+ namespace: TargetNamespace
57
+ ) => {
58
+ if (!canSwitchNetworkTo(wallet, namespace.network)) {
54
59
  return undefined;
55
60
  }
56
- return connect(wallet, network);
61
+ const result = await connect(wallet, [namespace]);
62
+
63
+ return result;
57
64
  };
58
65
 
59
66
  const isMobileWallet = (walletType: WalletType): boolean =>
60
67
  !!getWalletInfo(walletType).mobileWallet;
61
68
 
62
69
  // TODO: this code copy & pasted from rango, should be refactored.
63
- const allBlockchains = blockchains
70
+ const allBlockchains = blockchainsList
64
71
  .filter((blockchain) => blockchain.enabled)
65
72
  .reduce(
66
73
  (blockchainsObj: any, blockchain) => (
@@ -68,7 +75,7 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
68
75
  ),
69
76
  {}
70
77
  );
71
- const evmBasedChains = blockchains.filter(isEvmBlockchain);
78
+ const evmBasedChains = blockchainsList.filter(isEvmBlockchain);
72
79
  const getSupportedChainNames = (type: WalletType) => {
73
80
  const { supportedChains } = getWalletInfo(type);
74
81
  return walletAndSupportedChainsNames(supportedChains);
@@ -88,7 +95,6 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
88
95
  providers: allProviders,
89
96
  switchNetwork,
90
97
  canSwitchNetworkTo,
91
- connect,
92
98
  state,
93
99
  isMobileWallet,
94
100
  };
@@ -1,6 +1,6 @@
1
1
  import type { PropTypes } from './ConfirmWalletsModal.types';
2
- import type { ConnectedWallet } from '../../store/wallets';
3
- import type { ConfirmSwapWarnings, Wallet } from '../../types';
2
+ import type { ConnectedWallet } from '../../store/slices/wallets';
3
+ import type { Wallet } from '../../types';
4
4
 
5
5
  import { i18n } from '@lingui/core';
6
6
  import {
@@ -17,10 +17,8 @@ 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';
21
20
  import { useAppStore } from '../../store/AppStore';
22
21
  import { useQuoteStore } from '../../store/quote';
23
- import { useWalletsStore } from '../../store/wallets';
24
22
  import { getBlockchainShortNameFor } from '../../utils/meta';
25
23
  import { isConfirmSwapDisabled } from '../../utils/swap';
26
24
  import { getQuoteWallets } from '../../utils/wallets';
@@ -54,15 +52,11 @@ export function ConfirmWalletsModal(props: PropTypes) {
54
52
  customDestination,
55
53
  setCustomDestination,
56
54
  } = useQuoteStore();
57
- const { connectedWallets, selectWallets } = useWalletsStore();
58
- const { config } = useAppStore();
55
+ const { config, connectedWallets, setWalletsAsSelected } = useAppStore();
59
56
 
60
57
  const [showMoreWalletFor, setShowMoreWalletFor] = useState('');
61
58
  const [balanceWarnings, setBalanceWarnings] = useState<string[]>([]);
62
59
  const [error, setError] = useState('');
63
- const [quoteWarning, setQuoteWarning] = useState<
64
- ConfirmSwapWarnings['quoteUpdate'] | null
65
- >(null);
66
60
 
67
61
  const [isCustomDestinationOpen, setCustomDestinationOpen] = useState(
68
62
  !!customDestination
@@ -217,7 +211,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
217
211
  const lastSelectedWallets = selectableWallets.filter(
218
212
  (wallet) => wallet.selected
219
213
  );
220
- selectWallets(lastSelectedWallets);
214
+ setWalletsAsSelected(lastSelectedWallets);
221
215
  selectQuoteWallets(lastSelectedWallets);
222
216
  setQuoteWalletConfirmed(true);
223
217
  onClose();
@@ -226,7 +220,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
226
220
  const onConfirmWallets = async () => {
227
221
  setBalanceWarnings([]);
228
222
  setError('');
229
- setQuoteWarning(null);
230
223
 
231
224
  const result = await onCheckBalance?.({
232
225
  selectedWallets: selectableWallets.filter((wallet) => wallet.selected),
@@ -236,9 +229,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
236
229
  if (warnings?.balance?.messages) {
237
230
  setBalanceWarnings(warnings.balance.messages);
238
231
  }
239
- if (warnings?.quoteUpdate) {
240
- setQuoteWarning(warnings.quoteUpdate);
241
- }
232
+
242
233
  if (result.error) {
243
234
  setError(getQuoteErrorMessage(result.error));
244
235
  }
@@ -418,16 +409,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
418
409
  <Divider size={12} />
419
410
  </>
420
411
  )}
421
- {quoteWarning && (
422
- <>
423
- <Alert
424
- variant="alarm"
425
- type="warning"
426
- title={getQuoteUpdateWarningMessage(quoteWarning)}
427
- />
428
- <Divider size={12} />
429
- </>
430
- )}
431
412
  <Wallets>
432
413
  {quoteWallets.map((requiredWallet, index) => {
433
414
  const blockchain = blockchains.find(
@@ -1,5 +1,6 @@
1
1
  import type { PropTypes } from './WalletList.type';
2
- import type { Wallet, WalletInfoWithExtra } from '../../types';
2
+ import type { Wallet } from '../../types';
3
+ import type { ExtendedModalWalletInfo } from '../../utils/wallets';
3
4
 
4
5
  import { i18n } from '@lingui/core';
5
6
  import { warn } from '@rango-dev/logging-core';
@@ -20,7 +21,6 @@ import {
20
21
  import { useWalletList } from '../../hooks/useWalletList';
21
22
  import { useAppStore } from '../../store/AppStore';
22
23
  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,10 +41,9 @@ 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 connectedWallets = useWalletsStore.use.connectedWallets();
45
- const { blockchains } = useAppStore();
44
+ const { blockchains, connectedWallets } = useAppStore();
46
45
  const [selectedWalletToConnect, setSelectedWalletToConnect] =
47
- useState<WalletInfoWithExtra>();
46
+ useState<ExtendedModalWalletInfo>();
48
47
  const [experimentalChainWallet, setExperimentalChainWallet] =
49
48
  useState<Wallet | null>(null);
50
49
  const [showExperimentalChainModal, setShowExperimentalChainModal] =
@@ -57,7 +56,7 @@ export function WalletList(props: PropTypes) {
57
56
  chain,
58
57
  });
59
58
 
60
- const [sortedList, setSortedList] = useState<WalletInfoWithExtra[]>(list);
59
+ const [sortedList, setSortedList] = useState<ExtendedModalWalletInfo[]>(list);
61
60
  const numberOfSupportedWallets = list.length;
62
61
  const shouldShowMoreWallets = limit && numberOfSupportedWallets - limit > 0;
63
62
 
@@ -148,9 +147,13 @@ export function WalletList(props: PropTypes) {
148
147
 
149
148
  const onSelectableWalletClick = async () => {
150
149
  const isDisconnected = wallet.state === WalletState.DISCONNECTED;
150
+ const isConnectedButDifferentThanTargetNamespace = wallet.isHub
151
+ ? !conciseAddress
152
+ : !!wallet.needsNamespace && !conciseAddress;
153
+
151
154
  if (isDisconnected) {
152
155
  setSelectedWalletToConnect(wallet);
153
- } else if (!!wallet.namespaces && !conciseAddress) {
156
+ } else if (isConnectedButDifferentThanTargetNamespace) {
154
157
  // wallet is connected on a different namespace
155
158
  await handleDisconnect(wallet.type);
156
159
 
@@ -13,7 +13,6 @@ 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';
17
16
  import { getContainer } from '../../utils/common';
18
17
  import { getPendingSwaps } from '../../utils/queue';
19
18
  import { isFeatureHidden } from '../../utils/settings';
@@ -28,9 +27,8 @@ import { Container, Content, Footer, LayoutContainer } from './Layout.styles';
28
27
  function Layout(props: PropsWithChildren<PropTypes>) {
29
28
  const { connectHeightObserver, disconnectHeightObserver } = useIframe();
30
29
  const { children, header, footer, height = 'fixed' } = props;
31
- const { fetchStatus } = useAppStore();
30
+ const { fetchStatus, connectedWallets } = useAppStore();
32
31
  const [openRefreshModal, setOpenRefreshModal] = useState(false);
33
- const connectedWallets = useWalletsStore.use.connectedWallets();
34
32
  const {
35
33
  config: { features, theme },
36
34
  } = useAppStore();
@@ -17,7 +17,11 @@ import {
17
17
  import BigNumber from 'bignumber.js';
18
18
  import React, { useRef, useState } from 'react';
19
19
 
20
- import { GAS_FEE_MAX } from '../../constants/quote';
20
+ import {
21
+ GAS_FEE_MAX,
22
+ ROUTE_TIME_MAX,
23
+ SECONDS_IN_MINUTE,
24
+ } from '../../constants/quote';
21
25
  import {
22
26
  GAS_FEE_MAX_DECIMALS,
23
27
  GAS_FEE_MIN_DECIMALS,
@@ -311,7 +315,8 @@ export function Quote(props: QuoteProps) {
311
315
  const container = propContainer || getContainer();
312
316
  const sortedQuoteTags = sortTags(props.quote.tags || []);
313
317
  const showAllRoutesButton = !!onClickAllRoutes;
314
- const totalTime = roundedSecondsToString(totalArrivalTime(quote?.swaps));
318
+ const totalDurationSeconds = totalArrivalTime(quote?.swaps);
319
+ const totalTime = roundedSecondsToString(totalDurationSeconds);
315
320
  const totalFee = getTotalFeeInUsd(quote?.swaps ?? [], findToken);
316
321
  const fee = numberToString(
317
322
  totalFee,
@@ -320,6 +325,8 @@ export function Quote(props: QuoteProps) {
320
325
  );
321
326
 
322
327
  const feeWarning = totalFee.gte(new BigNumber(GAS_FEE_MAX));
328
+ const timeWarning =
329
+ totalDurationSeconds / SECONDS_IN_MINUTE >= ROUTE_TIME_MAX;
323
330
 
324
331
  return fullExpandedMode ? (
325
332
  <FullExpandedQuote
@@ -329,7 +336,18 @@ export function Quote(props: QuoteProps) {
329
336
  tooltipContainer={getExpanded()}
330
337
  steps={steps}
331
338
  tags={sortedQuoteTags}
332
- feeWarning={feeWarning}
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
+ }
333
351
  percentageChange={percentageChange}
334
352
  warningLevel={priceImpactWarningLevel}
335
353
  outputPrice={{
@@ -368,6 +386,7 @@ export function Quote(props: QuoteProps) {
368
386
  time={totalTime}
369
387
  fee={fee}
370
388
  feeWarning={feeWarning}
389
+ timeWarning={timeWarning}
371
390
  showModalFee={showModalFee}
372
391
  steps={numberOfSteps}
373
392
  />
@@ -48,5 +48,7 @@ export type QuoteCostDetailsProps = {
48
48
  fee: string;
49
49
  time: string;
50
50
  feeWarning?: boolean;
51
+ timeWarning?: boolean;
51
52
  showModalFee: boolean;
53
+ fullExpandedMode?: boolean;
52
54
  };
@@ -28,7 +28,6 @@ export const ModalContainer = styled('div', {
28
28
 
29
29
  export const ModalHeader = styled('div', {
30
30
  padding: '$20 $20 $10',
31
- textAlign: 'center',
32
31
  position: 'relative',
33
32
  '._icon-button': {
34
33
  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 } from '../../utils/common';
24
+ import { getContainer, getExpanded } 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,9 +57,18 @@ 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 { steps, quote, fee, time, feeWarning, showModalFee } = props;
60
+ const {
61
+ steps,
62
+ quote,
63
+ fee,
64
+ time,
65
+ feeWarning,
66
+ timeWarning,
67
+ showModalFee,
68
+ fullExpandedMode = false,
69
+ } = props;
61
70
  const swaps = quote?.swaps ?? [];
62
- const container = getContainer();
71
+ const container = fullExpandedMode ? getExpanded() : getContainer();
63
72
 
64
73
  const feesGroup = getFeesGroup(swaps);
65
74
 
@@ -76,6 +85,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
76
85
  }
77
86
  fee={fee}
78
87
  feeWarning={feeWarning}
88
+ timeWarning={timeWarning}
79
89
  time={time}
80
90
  steps={steps}
81
91
  tooltipGas={showModalFee ? i18n.t('View more info') : undefined}
@@ -85,8 +95,17 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
85
95
  <WatermarkedModal
86
96
  container={container}
87
97
  open={open}
98
+ anchor={fullExpandedMode ? 'center' : 'bottom'}
99
+ styles={{
100
+ container: {
101
+ maxWidth: fullExpandedMode ? '484px' : 'unset',
102
+ },
103
+ }}
88
104
  header={
89
- <ModalHeader>
105
+ <ModalHeader
106
+ style={{
107
+ textAlign: fullExpandedMode ? 'left' : 'center',
108
+ }}>
90
109
  <Typography variant="title" size="medium">
91
110
  {i18n.t('Gas & Fee Explanation')}
92
111
  </Typography>
@@ -44,30 +44,50 @@ export function makeAlerts(
44
44
  return alertInfo;
45
45
  }
46
46
  if (warning) {
47
- if (warning.type === QuoteWarningType.HIGH_VALUE_LOSS) {
48
- const warningLevel = getPriceImpactLevel(warning.priceImpact);
49
- if (warningLevel === 'high') {
50
- alertInfo.alertType = 'error';
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;
51
56
  }
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';
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;
70
89
  }
90
+
71
91
  return alertInfo;
72
92
  }
73
93
  return null;
@@ -53,9 +53,8 @@ export function Quotes(props: PropTypes) {
53
53
  ...quote,
54
54
  };
55
55
 
56
- return generateQuoteWarnings(mergedQuote, {
57
- fromToken,
58
- toToken,
56
+ return generateQuoteWarnings({
57
+ currentQuote: mergedQuote,
59
58
  userSlippage,
60
59
  findToken,
61
60
  });
@@ -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-shared';
3
+ import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
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
- getCurrentBlockchainOfOrNull,
6
+ getCurrentNamespaceOfOrNull,
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 currentStepBlockchain = currentStep
142
- ? getCurrentBlockchainOfOrNull(swap, currentStep)
141
+ const currentStepNamespace = currentStep
142
+ ? getCurrentNamespaceOfOrNull(swap, currentStep)
143
143
  : null;
144
144
  const currentStepWallet = currentStep
145
145
  ? getRelatedWalletOrNull(swap, currentStep)
@@ -154,13 +154,21 @@ export function SwapDetails(props: SwapDetailsProps) {
154
154
  const showSwitchNetwork =
155
155
  currentStepNetworkStatus ===
156
156
  PendingSwapNetworkStatus.WaitingForNetworkChange &&
157
- !!currentStepBlockchain &&
157
+ !!currentStepNamespace &&
158
158
  !!currentStepWallet?.walletType &&
159
159
  (isMobileWallet(currentStepWallet.walletType) ||
160
- canSwitchNetworkTo(currentStepWallet.walletType, currentStepBlockchain));
160
+ canSwitchNetworkTo(
161
+ currentStepWallet.walletType,
162
+ currentStepNamespace.network
163
+ ));
161
164
 
162
165
  const switchNetwork = showSwitchNetwork
163
- ? connect.bind(null, currentStepWallet.walletType, currentStepBlockchain)
166
+ ? connect.bind(null, currentStepWallet.walletType, [
167
+ {
168
+ namespace: currentStepNamespace.namespace,
169
+ network: currentStepNamespace.network,
170
+ },
171
+ ])
164
172
  : undefined;
165
173
 
166
174
  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,6 +12,7 @@ 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';
15
16
  import { getContainer } from '../../utils/common';
16
17
  import { WatermarkedModal } from '../common/WatermarkedModal';
17
18
 
@@ -31,6 +32,7 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
31
32
  diagnosisUrl,
32
33
  } = props;
33
34
  const navigate = useNavigate();
35
+ const { showProfileBanner } = useUiStore();
34
36
 
35
37
  return (
36
38
  <WatermarkedModal
@@ -72,21 +74,32 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
72
74
  description={description}
73
75
  />
74
76
  )}
75
- <Divider size={32} />
77
+ <Divider size={30} />
76
78
  {status === 'success' && (
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">
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
+ }}>
87
100
  {i18n.t('Done')}
88
- </Typography>
89
- </Button>
101
+ </Button>
102
+ </>
90
103
  )}
91
104
  <Divider size={12} />
92
105
  {diagnosisUrl && (