@rango-dev/widget-embedded 0.41.2-next.1 → 0.41.2-next.11

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 (56) hide show
  1. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  2. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  3. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -0
  4. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
  5. package/dist/components/HistoryGroupedList/HistoryGroupedList.d.ts.map +1 -1
  6. package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts +3 -0
  7. package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
  8. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
  9. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +3 -9
  10. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
  11. package/dist/components/WalletStatefulConnect/DerivationPath.d.ts.map +1 -1
  12. package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts +4 -0
  13. package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -0
  14. package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
  15. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +647 -0
  16. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
  17. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +21 -1
  18. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  19. package/dist/components/WalletStatefulConnect/SupportedChainsList.d.ts +4 -0
  20. package/dist/components/WalletStatefulConnect/SupportedChainsList.d.ts.map +1 -0
  21. package/dist/components/WalletStatefulConnect/SupportedChainsList.styles.d.ts +323 -0
  22. package/dist/components/WalletStatefulConnect/SupportedChainsList.styles.d.ts.map +1 -0
  23. package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts +5 -0
  24. package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts.map +1 -0
  25. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  26. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +2 -0
  27. package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
  28. package/dist/index.js +2 -2
  29. package/dist/index.js.map +4 -4
  30. package/dist/utils/swap.d.ts +2 -1
  31. package/dist/utils/swap.d.ts.map +1 -1
  32. package/dist/utils/wallets.d.ts +1 -1
  33. package/dist/utils/wallets.d.ts.map +1 -1
  34. package/dist/widget-embedded.build.json +1 -1
  35. package/package.json +11 -11
  36. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +13 -11
  37. package/src/components/ConfirmWalletsModal/WalletList.tsx +3 -1
  38. package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -0
  39. package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +3 -0
  40. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +4 -0
  41. package/src/components/SwapDetails/SwapDetails.tsx +2 -2
  42. package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +17 -8
  43. package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +2 -2
  44. package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +3 -8
  45. package/src/components/WalletStatefulConnect/DerivationPath.tsx +1 -13
  46. package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +64 -0
  47. package/src/components/WalletStatefulConnect/Namespaces.styles.ts +58 -3
  48. package/src/components/WalletStatefulConnect/Namespaces.tsx +97 -50
  49. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +29 -1
  50. package/src/components/WalletStatefulConnect/SupportedChainsList.styles.ts +25 -0
  51. package/src/components/WalletStatefulConnect/SupportedChainsList.tsx +58 -0
  52. package/src/components/WalletStatefulConnect/SupportedChainsList.types.ts +5 -0
  53. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +49 -51
  54. package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +2 -0
  55. package/src/utils/swap.ts +23 -12
  56. package/src/utils/wallets.ts +8 -12
@@ -3,22 +3,16 @@ import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
3
3
 
4
4
  import { i18n } from '@lingui/core';
5
5
  import {
6
+ Alert,
6
7
  Button,
7
- Checkbox,
8
8
  Divider,
9
9
  Image,
10
- ListItemButton,
11
10
  MessageBox,
12
- Radio,
13
11
  RadioRoot,
14
12
  } from '@rango-dev/ui';
15
- import React, { useState } from 'react';
13
+ import React, { useEffect, useMemo, useState } from 'react';
16
14
 
17
- import { useAppStore } from '../../store/AppStore';
18
- import { WalletImageContainer } from '../HeaderButtons/HeaderButtons.styles';
19
-
20
- import { LogoContainer, Spinner } from './ConnectStatus.styles';
21
- import { getBlockchainLogo } from './Namespaces.helpers';
15
+ import { NamespaceListItem } from './NamespaceListItem';
22
16
  import { NamespaceList } from './Namespaces.styles';
23
17
 
24
18
  export function Namespaces(props: PropTypes) {
@@ -27,8 +21,13 @@ export function Namespaces(props: PropTypes) {
27
21
  const providerImage = targetWallet.image;
28
22
 
29
23
  const [selectedNamespaces, setSelectedNamespaces] = useState<Namespace[]>([]);
30
-
31
- const blockchains = useAppStore().blockchains();
24
+ const supportedNamespaces = useMemo(
25
+ () =>
26
+ targetWallet.needsNamespace?.data.filter(
27
+ (namespace) => !namespace.unsupported
28
+ ),
29
+ [targetWallet?.type]
30
+ );
32
31
 
33
32
  const onSelect = (namespace: Namespace) => {
34
33
  if (singleNamespace) {
@@ -42,6 +41,23 @@ export function Namespaces(props: PropTypes) {
42
41
  }
43
42
  };
44
43
 
44
+ const allSupportedNamespacesSelected =
45
+ supportedNamespaces?.length === selectedNamespaces.length;
46
+
47
+ const onSelectAll = () => {
48
+ if (singleNamespace) {
49
+ throw new Error(
50
+ 'onSelectAll should not be called on single selection mode.'
51
+ );
52
+ } else if (allSupportedNamespacesSelected) {
53
+ setSelectedNamespaces([]);
54
+ } else if (supportedNamespaces) {
55
+ setSelectedNamespaces(
56
+ supportedNamespaces.map((namespace) => namespace.value)
57
+ );
58
+ }
59
+ };
60
+
45
61
  const wrapRadioRoot = (children: React.ReactNode) => {
46
62
  if (singleNamespace) {
47
63
  return <RadioRoot value={selectedNamespaces?.[0]}>{children}</RadioRoot>;
@@ -50,63 +66,94 @@ export function Namespaces(props: PropTypes) {
50
66
  return <>{children}</>;
51
67
  };
52
68
 
69
+ useEffect(() => {
70
+ // Initially select supported and required namespaces
71
+ if (!singleNamespace && supportedNamespaces) {
72
+ if (!!props.value.defaultSelectedChains?.length) {
73
+ const namespacesContainingDefaultSelectedChains =
74
+ supportedNamespaces.filter((namespace) =>
75
+ namespace.chains.some((chain) =>
76
+ props.value.defaultSelectedChains?.includes(chain.name)
77
+ )
78
+ );
79
+ setSelectedNamespaces(
80
+ namespacesContainingDefaultSelectedChains.map(
81
+ (namespace) => namespace.value
82
+ )
83
+ );
84
+ } else {
85
+ setSelectedNamespaces(
86
+ supportedNamespaces.map((namespace) => namespace.value)
87
+ );
88
+ }
89
+ }
90
+ }, []);
91
+
53
92
  return (
54
93
  <>
55
- <Divider size={20} />
56
94
  <MessageBox
57
95
  type="info"
58
- title={i18n.t('Select chain types')}
96
+ title={i18n.t(`Connect {wallet}`, {
97
+ wallet: targetWallet.title,
98
+ })}
59
99
  description={i18n.t(
60
- `This wallet supports multiple chains. Select which chain you'd like to connect to.`
100
+ "This wallet supports multiple chains. Choose which chains you'd like to connect to."
61
101
  )}
62
- icon={
63
- <LogoContainer>
64
- <WalletImageContainer>
65
- <Image src={providerImage} size={45} />
66
- </WalletImageContainer>
67
- <Spinner />
68
- </LogoContainer>
69
- }
102
+ icon={<Image src={providerImage} size={45} />}
70
103
  />
104
+ {singleNamespace ? (
105
+ <>
106
+ <Divider size={20} />
107
+ <Alert
108
+ variant="alarm"
109
+ type="info"
110
+ title={i18n.t(
111
+ 'This wallet can only connect to one chain at a time. '
112
+ )}
113
+ />
114
+ </>
115
+ ) : (
116
+ <>
117
+ <Divider size={30} />
118
+ <Button
119
+ style={{ marginLeft: 'auto' }}
120
+ id="widget-name-space-select-all-btn"
121
+ size="xsmall"
122
+ variant="ghost"
123
+ type="primary"
124
+ onClick={onSelectAll}>
125
+ {allSupportedNamespacesSelected
126
+ ? i18n.t('Deselect all')
127
+ : i18n.t('Select all')}
128
+ </Button>
129
+ </>
130
+ )}
71
131
  <NamespaceList>
72
132
  {wrapRadioRoot(
73
133
  <>
74
- {targetWallet.needsNamespace?.data.map((ns) => {
75
- return (
76
- <ListItemButton
77
- key={ns.id}
78
- id={ns.id}
79
- title={ns.label}
80
- hasDivider
81
- style={{ height: 60 }}
82
- onClick={() => onSelect(ns.value)}
83
- start={
84
- <Image
85
- src={getBlockchainLogo(blockchains, ns.id)}
86
- size={22}
87
- />
88
- }
89
- end={
90
- singleNamespace ? (
91
- <Radio value={ns.value} />
92
- ) : (
93
- <Checkbox
94
- checked={selectedNamespaces.includes(ns.value)}
95
- />
96
- )
97
- }
98
- />
99
- );
100
- })}
134
+ {targetWallet.needsNamespace?.data.map(
135
+ (namespace, index, array) => (
136
+ <React.Fragment key={namespace.id}>
137
+ <NamespaceListItem
138
+ value={selectedNamespaces.includes(namespace.value)}
139
+ namespace={namespace}
140
+ type={singleNamespace ? 'radio' : 'checkbox'}
141
+ onClick={() => onSelect(namespace.value)}
142
+ />
143
+ {index !== array.length - 1 && <Divider size={10} />}
144
+ </React.Fragment>
145
+ )
146
+ )}
101
147
  </>
102
148
  )}
103
149
  </NamespaceList>
150
+ <Divider size={20} />
104
151
  <Button
105
152
  id="widget-name-space-confirm-btn"
106
153
  type="primary"
107
154
  disabled={!selectedNamespaces.length}
108
155
  onClick={() => props.onConfirm(selectedNamespaces)}>
109
- {i18n.t('Confirm')}
156
+ {i18n.t('Connect')}
110
157
  </Button>
111
158
  </>
112
159
  );
@@ -1,7 +1,35 @@
1
1
  import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
2
- import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
2
+ import type {
3
+ Chain,
4
+ Namespace,
5
+ } from '@rango-dev/wallets-core/namespaces/common';
3
6
 
4
7
  export interface PropTypes {
5
8
  onConfirm: (namespaces: Namespace[]) => void;
6
9
  value: NeedsNamespacesState;
7
10
  }
11
+
12
+ interface NamespaceItemSharedPropTypes {
13
+ onClick: () => void;
14
+ type: 'radio' | 'checkbox';
15
+ namespace: {
16
+ label: string;
17
+ id: string;
18
+ value: Namespace;
19
+ chains: Chain[];
20
+ unsupported?: boolean;
21
+ };
22
+ }
23
+
24
+ interface RadioNamespaceItemPropTypes extends NamespaceItemSharedPropTypes {
25
+ type: 'radio';
26
+ }
27
+
28
+ interface CheckboxNamespaceItemPropTypes extends NamespaceItemSharedPropTypes {
29
+ type: 'checkbox';
30
+ value: boolean;
31
+ }
32
+
33
+ export type NamespaceItemPropTypes =
34
+ | RadioNamespaceItemPropTypes
35
+ | CheckboxNamespaceItemPropTypes;
@@ -0,0 +1,25 @@
1
+ import { styled } from '@rango-dev/ui';
2
+
3
+ export const SupportedChainsContainer = styled('div', {
4
+ display: 'flex',
5
+ alignItems: 'center',
6
+ padding: 0,
7
+ margin: 0,
8
+ });
9
+
10
+ export const SupportedChainItem = styled('div', {
11
+ marginLeft: '-5px',
12
+ listStyleType: 'none',
13
+ backgroundColor: '$background',
14
+ borderRadius: '$lg',
15
+ minWidth: '15px',
16
+ height: '15px',
17
+ variants: {
18
+ firstItem: {
19
+ true: { marginLeft: 0 },
20
+ },
21
+ },
22
+ display: 'flex',
23
+ alignItems: 'center',
24
+ justifyContent: 'center',
25
+ });
@@ -0,0 +1,58 @@
1
+ import type { PropTypes } from './SupportedChainsList.types';
2
+
3
+ import { Image, Tooltip, Typography } from '@rango-dev/ui';
4
+ import React from 'react';
5
+
6
+ import { getContainer } from '../../utils/common';
7
+
8
+ import {
9
+ SupportedChainItem,
10
+ SupportedChainsContainer,
11
+ } from './SupportedChainsList.styles';
12
+
13
+ const SUPPORTED_CHAINS_MAX_DISPLAYED_NUMBER = 3;
14
+
15
+ export function SupportedChainsList(props: PropTypes) {
16
+ const { chains } = props;
17
+ return (
18
+ <SupportedChainsContainer>
19
+ {chains
20
+ .slice(0, SUPPORTED_CHAINS_MAX_DISPLAYED_NUMBER)
21
+ .map((chain, index) => (
22
+ <Tooltip
23
+ key={chain.name}
24
+ container={getContainer()}
25
+ side="bottom"
26
+ align="start"
27
+ content={chain.name}
28
+ sideOffset={4}>
29
+ <SupportedChainItem firstItem={index === 0}>
30
+ <Image src={chain.logo} size={15} />
31
+ </SupportedChainItem>
32
+ </Tooltip>
33
+ ))}
34
+ {chains.length > SUPPORTED_CHAINS_MAX_DISPLAYED_NUMBER && (
35
+ <Tooltip
36
+ container={getContainer()}
37
+ side="bottom"
38
+ align="start"
39
+ sideOffset={4}
40
+ content={
41
+ <SupportedChainsContainer>
42
+ {chains.map((chain, index) => (
43
+ <SupportedChainItem key={chain.name} firstItem={index === 0}>
44
+ <Image src={chain.logo} size={15} />
45
+ </SupportedChainItem>
46
+ ))}
47
+ </SupportedChainsContainer>
48
+ }>
49
+ <SupportedChainItem>
50
+ <Typography variant="body" size="xsmall">
51
+ +{chains.length - SUPPORTED_CHAINS_MAX_DISPLAYED_NUMBER}
52
+ </Typography>
53
+ </SupportedChainItem>
54
+ </Tooltip>
55
+ )}
56
+ </SupportedChainsContainer>
57
+ );
58
+ }
@@ -0,0 +1,5 @@
1
+ import type { Chain } from '@rango-dev/wallets-core/dist/namespaces/common/types';
2
+
3
+ export type PropTypes = {
4
+ chains: Chain[];
5
+ };
@@ -85,72 +85,70 @@ export function useStatefulConnect(): UseStatefulConnect {
85
85
  const isDisconnected = wallet.state === WalletState.DISCONNECTED;
86
86
 
87
87
  if (isDisconnected) {
88
- // Legacy and hub have different structure to check wether we need to show namespace or not.
89
-
90
- // Hub
91
- const isHub = !!wallet.isHub;
92
- if (isHub) {
93
- const detachedInstances = wallet.properties?.find(
94
- (item) => item.name === 'detached'
95
- );
96
- const needsNamespace =
97
- detachedInstances && wallet.state !== 'connected';
98
-
99
- if (needsNamespace) {
100
- dispatch({
101
- type: 'needsNamespace',
102
- payload: {
103
- targetWallet: wallet,
104
- },
105
- });
106
- return { status: ResultStatus.Namespace };
107
- }
108
- }
109
-
110
88
  /*
111
- * Legacy
112
- *
113
- * For legacy there are 3 states:
114
- * 1. a wallet doesn't have any namespace defined, we call the connect.
115
- * 2. a wallet has more than two namespaces, we should show namepsace modal, and in that place user will be checked to needs derivation path or not.
116
- * 3. a wallet has exactly one namespacesape, in this case we check if that needs derivation or not, if it needs we will do it here by dispatching the action accordingly.
89
+ * Currently, handling connect should be covered for 3 different types of target wallet:
90
+ * 1. Target wallet does not contain any namespaces, in this situation we should just try to connect to the related provider.
91
+ * 2. Target wallet contains more than one namespace, in this situation we should display namespaces modal to allow the user to choose from available namespaces.
92
+ * 3. Target wallet contains only one namespace, in this situation we should check if that namespace needs derivation path and based on that, try to connect to the related provider or display derivation path modal.
117
93
  */
118
- if (!wallet.needsNamespace) {
94
+
95
+ // Legacy and hub have different structure to handle each situation.
96
+ const isHub = !!wallet.isHub;
97
+ const detachedInstances = wallet.properties?.find(
98
+ (item) => item.name === 'detached'
99
+ )?.value;
100
+
101
+ // 1. Target wallet does not contain any namespaces
102
+ if (
103
+ (isHub && !detachedInstances?.length) ||
104
+ (!isHub && !wallet.needsNamespace)
105
+ ) {
119
106
  return await runConnect(wallet.type, undefined, options);
120
107
  }
121
108
 
122
- const needsNamespace = wallet.needsNamespace.data.length > 1;
123
- const needsDerivationPath = wallet.needsDerivationPath;
124
-
125
- if (needsNamespace) {
109
+ // 2. Target wallet contains more than one namespace
110
+ if (
111
+ (isHub && detachedInstances?.length && detachedInstances.length > 1) ||
112
+ (!isHub &&
113
+ wallet.needsNamespace?.data.length &&
114
+ wallet.needsNamespace.data.length > 1)
115
+ ) {
126
116
  dispatch({
127
117
  type: 'needsNamespace',
128
118
  payload: {
129
119
  targetWallet: wallet,
120
+ defaultSelectedChains: options?.defaultSelectedChains,
130
121
  },
131
122
  });
132
123
  return { status: ResultStatus.Namespace };
133
- } else if (needsDerivationPath) {
134
- const namespace = wallet.needsNamespace.data[0];
124
+ }
135
125
 
136
- dispatch({
137
- type: 'needsDerivationPath',
138
- payload: {
139
- providerType: wallet.type,
140
- providerImage: wallet.image,
126
+ // 3. Target wallet contains only one namespace
127
+ if (
128
+ (isHub && detachedInstances?.length === 1) ||
129
+ (!isHub && wallet.needsNamespace?.data.length === 1)
130
+ ) {
131
+ if (wallet.needsNamespace && wallet.needsDerivationPath) {
132
+ const namespace = wallet.needsNamespace.data[0];
133
+
134
+ dispatch({
135
+ type: 'needsDerivationPath',
136
+ payload: {
137
+ providerType: wallet.type,
138
+ providerImage: wallet.image,
139
+ namespace: namespace.value,
140
+ },
141
+ });
142
+ return { status: ResultStatus.DerivationPath };
143
+ }
144
+ return await runConnect(
145
+ wallet.type,
146
+ wallet.needsNamespace?.data.map((namespace) => ({
141
147
  namespace: namespace.value,
142
- },
143
- });
144
- return { status: ResultStatus.DerivationPath };
148
+ })),
149
+ options
150
+ );
145
151
  }
146
-
147
- return await runConnect(
148
- wallet.type,
149
- wallet.needsNamespace?.data.map((namespace) => ({
150
- namespace: namespace.value,
151
- })),
152
- options
153
- );
154
152
  }
155
153
 
156
154
  if (options?.disconnectIfConnected) {
@@ -4,10 +4,12 @@ import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
4
4
  export interface HandleConnectOptions {
5
5
  // To have a switch between connect and disconnect when user is clicking on a button, this option can be helpful.
6
6
  disconnectIfConnected?: boolean;
7
+ defaultSelectedChains?: string[];
7
8
  }
8
9
 
9
10
  export interface NeedsNamespacesState {
10
11
  targetWallet: ExtendedModalWalletInfo;
12
+ defaultSelectedChains?: string[];
11
13
  }
12
14
 
13
15
  export interface NeedsDerivationPathState {
package/src/utils/swap.ts CHANGED
@@ -9,6 +9,7 @@ import type {
9
9
  SwapButtonState,
10
10
  Wallet,
11
11
  } from '../types';
12
+ import type { ExtendedWalletInfo } from '@rango-dev/wallets-react';
12
13
  import type { WalletType } from '@rango-dev/wallets-shared';
13
14
  import type {
14
15
  BestRouteRequest,
@@ -22,6 +23,7 @@ import type { PendingSwap, PendingSwapStep } from 'rango-types';
22
23
 
23
24
  import { i18n } from '@lingui/core';
24
25
  import {
26
+ getRelatedWalletOrNull,
25
27
  type RouteEvent,
26
28
  RouteEventType,
27
29
  type StepEvent,
@@ -50,7 +52,7 @@ import {
50
52
  import { getBlockchainShortNameFor, isValidTokenAddress } from './meta';
51
53
  import { numberToString } from './numbers';
52
54
  import { getRequiredBalanceOfWallet } from './quote';
53
- import { getQuoteWallets } from './wallets';
55
+ import { getQuoteChains } from './wallets';
54
56
 
55
57
  export function getOutputRatio(
56
58
  inputUsdValue: BigNumber | null,
@@ -601,7 +603,7 @@ export function generateBalanceWarnings(
601
603
  blockchains: BlockchainMeta[]
602
604
  ) {
603
605
  const fee = quote.validationStatus;
604
- const requiredWallets = getQuoteWallets({ filter: 'required', quote });
606
+ const requiredWallets = getQuoteChains({ filter: 'required', quote });
605
607
  const walletsSortedByRequiredWallets = selectedWallets.sort(
606
608
  (selectedWallet1, selectedWallet2) =>
607
609
  requiredWallets.indexOf(selectedWallet1.chain) -
@@ -666,7 +668,8 @@ export function isNetworkStatusInWarningState(
666
668
 
667
669
  export function getSwapMessages(
668
670
  pendingSwap: PendingSwap,
669
- currentStep: PendingSwapStep | null
671
+ currentStep: PendingSwapStep | null,
672
+ getWalletInfo?: (type: WalletType) => ExtendedWalletInfo
670
673
  ): {
671
674
  shortMessage: string;
672
675
  detailedMessage: { content: string; long: boolean };
@@ -685,10 +688,20 @@ export function getSwapMessages(
685
688
  if (networkWarningState) {
686
689
  message = pendingSwap.networkStatusExtraMessage || '';
687
690
  detailedMessage = pendingSwap.networkStatusExtraMessageDetail || '';
691
+
692
+ const currentStepWallet = currentStep
693
+ ? getRelatedWalletOrNull(pendingSwap, currentStep)
694
+ : null;
695
+ const walletType = currentStepWallet?.walletType;
696
+ const walletName = walletType ? getWalletInfo?.(walletType)?.name : null;
688
697
  // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
689
698
  switch (currentStep?.networkStatus) {
690
699
  case PendingSwapNetworkStatus.WaitingForConnectingWallet:
691
- message = message || i18n.t('Waiting for connecting wallet');
700
+ message = walletName
701
+ ? i18n.t('Connect {wallet}', {
702
+ wallet: walletName,
703
+ })
704
+ : message;
692
705
  break;
693
706
  case PendingSwapNetworkStatus.WaitingForQueue:
694
707
  message =
@@ -751,18 +764,16 @@ export function isConfirmSwapDisabled(
751
764
  return true;
752
765
  }
753
766
 
754
- const allWallets = getQuoteWallets({ filter: 'all', quote });
767
+ const allChains = getQuoteChains({ filter: 'all', quote });
755
768
 
756
- const requiredWallets = getQuoteWallets({ filter: 'required', quote });
769
+ const requiredChains = getQuoteChains({ filter: 'required', quote });
757
770
 
758
- const everyWalletSelected = allWallets.every((blockchain) =>
759
- selectedWallets.some(
760
- (selectedWallet) => selectedWallet.chain === blockchain
761
- )
771
+ const everyWalletSelected = allChains.every((chain) =>
772
+ selectedWallets.some((selectedWallet) => selectedWallet.chain === chain)
762
773
  );
763
774
 
764
- const everyRequiredWalletSelected = requiredWallets.every((wallet) =>
765
- selectedWallets.some((selectedWallet) => selectedWallet.chain === wallet)
775
+ const everyRequiredWalletSelected = requiredChains.every((chain) =>
776
+ selectedWallets.some((selectedWallet) => selectedWallet.chain === chain)
766
777
  );
767
778
 
768
779
  const customDestinationIsValid =
@@ -45,18 +45,14 @@ export type ExtendedModalWalletInfo = WalletInfoWithExtra &
45
45
  Pick<ExtendedWalletInfo, 'properties' | 'isHub'>;
46
46
 
47
47
  export function mapStatusToWalletState(state: WalletState): WalletStatus {
48
- // TODO: refactor
49
- // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
50
- switch (true) {
51
- case state.connected:
52
- return WalletStatus.CONNECTED;
53
- case state.connecting:
54
- return WalletStatus.CONNECTING;
55
- case !state.installed:
56
- return WalletStatus.NOT_INSTALLED;
57
- default:
58
- return WalletStatus.DISCONNECTED;
48
+ if (state.connected) {
49
+ return WalletStatus.CONNECTED;
50
+ } else if (state.connecting) {
51
+ return WalletStatus.CONNECTING;
52
+ } else if (!state.installed) {
53
+ return WalletStatus.NOT_INSTALLED;
59
54
  }
55
+ return WalletStatus.DISCONNECTED;
60
56
  }
61
57
 
62
58
  export function mapWalletTypesToWalletInfo(
@@ -225,7 +221,7 @@ export function prepareAccountsForWalletStore(
225
221
  return result;
226
222
  }
227
223
 
228
- export function getQuoteWallets(params: {
224
+ export function getQuoteChains(params: {
229
225
  filter: 'all' | 'required';
230
226
  quote: SelectedQuote | null;
231
227
  }): string[] {