@rango-dev/widget-embedded 0.45.1-next.0 → 0.45.1-next.10

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/components/CustomDestination/CustomDestination.styles.d.ts +1 -0
  2. package/dist/components/CustomDestination/CustomDestination.styles.d.ts.map +1 -1
  3. package/dist/components/NamespaceItem/NamespaceItem.d.ts +4 -0
  4. package/dist/components/NamespaceItem/NamespaceItem.d.ts.map +1 -0
  5. package/dist/components/{WalletStatefulConnect/Namespaces.helpers.d.ts → NamespaceItem/NamespaceItem.helpers.d.ts} +1 -1
  6. package/dist/components/NamespaceItem/NamespaceItem.helpers.d.ts.map +1 -0
  7. package/dist/components/NamespaceItem/NamespaceItem.styles.d.ts +1450 -0
  8. package/dist/components/NamespaceItem/NamespaceItem.styles.d.ts.map +1 -0
  9. package/dist/components/NamespaceItem/NamespaceItem.types.d.ts +13 -0
  10. package/dist/components/NamespaceItem/NamespaceItem.types.d.ts.map +1 -0
  11. package/dist/components/{WalletStatefulConnect → NamespaceItem}/NamespaceUnsupportedItem.d.ts +1 -1
  12. package/dist/components/NamespaceItem/NamespaceUnsupportedItem.d.ts.map +1 -0
  13. package/dist/components/NamespaceItem/SupportedChainsList.d.ts.map +1 -0
  14. package/dist/components/NamespaceItem/SupportedChainsList.styles.d.ts.map +1 -0
  15. package/dist/components/NamespaceItem/SupportedChainsList.types.d.ts.map +1 -0
  16. package/dist/components/NamespaceItem/index.d.ts +2 -0
  17. package/dist/components/NamespaceItem/index.d.ts.map +1 -0
  18. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  19. package/dist/components/Slippage/Slippage.styles.d.ts +0 -162
  20. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  21. package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
  22. package/dist/components/SwapDetails/RequestIdRow.d.ts +4 -0
  23. package/dist/components/SwapDetails/RequestIdRow.d.ts.map +1 -0
  24. package/dist/components/SwapDetails/SwapDateRow.d.ts +4 -0
  25. package/dist/components/SwapDetails/SwapDateRow.d.ts.map +1 -0
  26. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  27. package/dist/components/SwapDetails/SwapDetails.types.d.ts +7 -0
  28. package/dist/components/SwapDetails/SwapDetails.types.d.ts.map +1 -1
  29. package/dist/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.d.ts +4 -0
  30. package/dist/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.d.ts.map +1 -0
  31. package/dist/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.d.ts +4 -0
  32. package/dist/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.d.ts.map +1 -0
  33. package/dist/components/SwapDetailsModal/SwapDetailsModal.NetworkState.d.ts +4 -0
  34. package/dist/components/SwapDetailsModal/SwapDetailsModal.NetworkState.d.ts.map +1 -0
  35. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts +1 -1
  36. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
  37. package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts.map +1 -1
  38. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +320 -0
  39. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  40. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +29 -10
  41. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
  42. package/dist/components/WalletStatefulConnect/Detached.d.ts.map +1 -1
  43. package/dist/components/WalletStatefulConnect/Detached.styles.d.ts +161 -0
  44. package/dist/components/WalletStatefulConnect/Detached.styles.d.ts.map +1 -0
  45. package/dist/components/WalletStatefulConnect/Detached.types.d.ts +1 -0
  46. package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +1 -1
  47. package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +1 -1
  48. package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -1
  49. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +281 -1730
  50. package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
  51. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +0 -3
  52. package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
  53. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
  54. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +1 -1
  55. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
  56. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -2
  57. package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
  58. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  59. package/dist/index.js +2 -2
  60. package/dist/index.js.map +4 -4
  61. package/dist/store/slices/wallets.d.ts +2 -2
  62. package/dist/store/slices/wallets.d.ts.map +1 -1
  63. package/dist/types/quote.d.ts +1 -1
  64. package/dist/types/quote.d.ts.map +1 -1
  65. package/dist/types/wallets.d.ts +1 -0
  66. package/dist/types/wallets.d.ts.map +1 -1
  67. package/dist/utils/swap.d.ts +1 -0
  68. package/dist/utils/swap.d.ts.map +1 -1
  69. package/dist/widget-embedded.build.json +1 -1
  70. package/package.json +7 -7
  71. package/src/components/{WalletStatefulConnect/Namespaces.helpers.ts → NamespaceItem/NamespaceItem.helpers.ts} +1 -1
  72. package/src/components/NamespaceItem/NamespaceItem.styles.ts +93 -0
  73. package/src/components/NamespaceItem/NamespaceItem.tsx +117 -0
  74. package/src/components/NamespaceItem/NamespaceItem.types.ts +14 -0
  75. package/src/components/{WalletStatefulConnect → NamespaceItem}/NamespaceUnsupportedItem.tsx +3 -3
  76. package/src/components/NamespaceItem/index.ts +1 -0
  77. package/src/components/Quote/Quote.tsx +4 -4
  78. package/src/components/Slippage/Slippage.styles.ts +0 -23
  79. package/src/components/Slippage/Slippage.tsx +24 -26
  80. package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +4 -0
  81. package/src/components/SwapDetails/RequestIdRow.tsx +73 -0
  82. package/src/components/SwapDetails/SwapDateRow.tsx +21 -0
  83. package/src/components/SwapDetails/SwapDetails.tsx +39 -83
  84. package/src/components/SwapDetails/SwapDetails.types.ts +7 -0
  85. package/src/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.tsx +177 -0
  86. package/src/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.tsx +52 -0
  87. package/src/components/SwapDetailsModal/SwapDetailsModal.NetworkState.tsx +17 -0
  88. package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +22 -62
  89. package/src/components/SwapDetailsModal/SwapDetailsModal.styles.ts +20 -1
  90. package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +24 -35
  91. package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +31 -10
  92. package/src/components/WalletStatefulConnect/Detached.styles.ts +6 -0
  93. package/src/components/WalletStatefulConnect/Detached.tsx +21 -4
  94. package/src/components/WalletStatefulConnect/Detached.types.ts +1 -0
  95. package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +20 -106
  96. package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +9 -34
  97. package/src/components/WalletStatefulConnect/Namespaces.styles.ts +2 -94
  98. package/src/components/WalletStatefulConnect/Namespaces.tsx +1 -1
  99. package/src/components/WalletStatefulConnect/Namespaces.types.tsx +0 -4
  100. package/src/containers/Wallets/useUpdates.ts +1 -1
  101. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +10 -23
  102. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +19 -4
  103. package/src/hooks/useStatefulConnect/useStatefulConnect.ts +23 -7
  104. package/src/hooks/useSwapInput.ts +13 -4
  105. package/src/hooks/useWalletList.ts +1 -1
  106. package/src/store/slices/wallets.ts +11 -5
  107. package/src/types/quote.ts +1 -1
  108. package/src/types/wallets.ts +1 -0
  109. package/src/utils/swap.ts +10 -5
  110. package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +0 -4
  111. package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +0 -1
  112. package/dist/components/WalletStatefulConnect/NamespaceUnsupportedItem.d.ts.map +0 -1
  113. package/dist/components/WalletStatefulConnect/Namespaces.helpers.d.ts.map +0 -1
  114. package/dist/components/WalletStatefulConnect/SupportedChainsList.d.ts.map +0 -1
  115. package/dist/components/WalletStatefulConnect/SupportedChainsList.styles.d.ts.map +0 -1
  116. package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts.map +0 -1
  117. package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +0 -26
  118. /package/dist/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.d.ts +0 -0
  119. /package/dist/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.styles.d.ts +0 -0
  120. /package/dist/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.types.d.ts +0 -0
  121. /package/src/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.styles.ts +0 -0
  122. /package/src/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.tsx +0 -0
  123. /package/src/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.types.ts +0 -0
@@ -1,57 +1,46 @@
1
1
  import type { ModalPropTypes } from './SwapDetailsModal.types';
2
2
 
3
- import { PendingSwapNetworkStatus } from 'rango-types';
4
3
  import React from 'react';
5
4
 
6
- import { WIDGET_UI_ID } from '../../constants';
5
+ import { getContainer } from '../../utils/common';
7
6
  import { WatermarkedModal } from '../common/WatermarkedModal';
8
7
 
9
8
  import { CancelContent } from './SwapDetailsModal.Cancel';
10
9
  import { DeleteContent } from './SwapDetailsModal.Delete';
11
- import { modalNetworkValues } from './SwapDetailsModal.helpers';
10
+ import { NetworkStateContent } from './SwapDetailsModal.NetworkState';
12
11
  import { WalletStateContent } from './SwapDetailsModal.WalletState';
13
12
 
14
13
  export function SwapDetailsModal(props: ModalPropTypes) {
15
- const {
16
- state,
17
- onClose,
18
- onDelete,
19
- onCancel,
20
- swap,
21
- message,
22
- walletButtonDisabled,
23
- } = props;
24
-
25
- const showWalletStateContent =
26
- state === PendingSwapNetworkStatus.WaitingForNetworkChange ||
27
- state === PendingSwapNetworkStatus.WaitingForConnectingWallet ||
28
- state === PendingSwapNetworkStatus.NetworkChanged;
14
+ const { isOpen, state, onClose, onDelete, onCancel, swap, message } = props;
29
15
 
30
16
  return (
31
17
  <WatermarkedModal
32
- id="widget-swap-details-modal"
33
- open={!!state}
18
+ open={isOpen}
34
19
  onClose={onClose}
35
- container={
36
- document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
37
- }>
38
- {showWalletStateContent && (
39
- <WalletStateContent
40
- type={modalNetworkValues[state].type}
41
- title={modalNetworkValues[state].title}
42
- swap={swap}
43
- message={message}
44
- walletButtonDisabled={walletButtonDisabled}
45
- showWalletButton={
46
- state !== PendingSwapNetworkStatus.WaitingForNetworkChange
47
- }
48
- />
20
+ container={getContainer()}>
21
+ {state === 'waitingForConnectingWallet' && (
22
+ <WalletStateContent swap={swap} message={message} onClose={onClose} />
23
+ )}
24
+ {(state === 'waitingForNetworkChange' || state === 'networkChanged') && (
25
+ <NetworkStateContent message={message} status={state} />
49
26
  )}
50
27
  {state === 'delete' && (
51
- <DeleteContent onClose={onClose} onDelete={onDelete} />
28
+ <DeleteContent
29
+ onClose={onClose}
30
+ onDelete={() => {
31
+ onClose();
32
+ onDelete();
33
+ }}
34
+ />
52
35
  )}
53
36
  {state === 'cancel' && (
54
- <CancelContent onClose={onClose} onCancel={onCancel} />
37
+ <CancelContent
38
+ onClose={onClose}
39
+ onCancel={() => {
40
+ onClose();
41
+ onCancel();
42
+ }}
43
+ />
55
44
  )}
56
45
  </WatermarkedModal>
57
46
  );
@@ -1,3 +1,5 @@
1
+ import type { TargetNamespace } from '@rango-dev/queue-manager-rango-preset';
2
+ import type { LegacyWalletType } from '@rango-dev/wallets-core/legacy';
1
3
  import type { PendingSwap, PendingSwapNetworkStatus } from 'rango-types';
2
4
 
3
5
  export type ModalState =
@@ -6,13 +8,13 @@ export type ModalState =
6
8
  | 'cancel'
7
9
  | null;
8
10
  export interface ModalPropTypes {
11
+ isOpen: boolean;
9
12
  onClose: () => void;
10
13
  onCancel: () => void;
11
14
  onDelete: () => void;
12
15
  state: ModalState;
13
16
  swap: PendingSwap;
14
17
  message: string;
15
- walletButtonDisabled: boolean;
16
18
  }
17
19
 
18
20
  export interface CompleteModalPropTypes {
@@ -36,18 +38,37 @@ export interface CompleteModalPropTypes {
36
38
  diagnosisUrl?: string | null;
37
39
  }
38
40
 
39
- export interface ModalNetworkValueTypes {
40
- type: 'loading' | 'warning' | 'success';
41
- title: string;
41
+ export interface WalletStateContentProps {
42
+ swap: PendingSwap;
43
+ message: string;
44
+ onClose: () => void;
42
45
  }
43
46
 
44
- export interface WalletStateContentProps extends ModalNetworkValueTypes {
45
- swap: PendingSwap;
47
+ export interface NetworkStateContentProps {
46
48
  message: string;
47
- showWalletButton: boolean;
48
- walletButtonDisabled: boolean;
49
+ status: 'networkChanged' | 'waitingForNetworkChange';
50
+ }
51
+
52
+ export interface InstallWalletContentProps {
53
+ walletType: LegacyWalletType;
54
+ }
55
+
56
+ export interface ConnectWalletContentProps {
57
+ wallet: {
58
+ walletType: LegacyWalletType;
59
+ address: string;
60
+ derivationPath?: string;
61
+ };
62
+ namespace: TargetNamespace | null;
63
+ onClose: () => void;
49
64
  }
50
65
 
51
- export type CancelContentProps = Pick<ModalPropTypes, 'onClose' | 'onCancel'>;
66
+ export interface CancelContentProps {
67
+ onCancel: () => void;
68
+ onClose: () => void;
69
+ }
52
70
 
53
- export type DeleteContentProps = Pick<ModalPropTypes, 'onClose' | 'onDelete'>;
71
+ export interface DeleteContentProps {
72
+ onDelete: () => void;
73
+ onClose: () => void;
74
+ }
@@ -0,0 +1,6 @@
1
+ import { styled } from '@rango-dev/ui';
2
+
3
+ export const NamespacesHeader = styled('div', {
4
+ display: 'flex',
5
+ justifyContent: 'end',
6
+ });
@@ -1,17 +1,23 @@
1
1
  import type { PropTypes } from './Detached.types';
2
2
 
3
3
  import { i18n } from '@lingui/core';
4
- import { Divider, Image, MessageBox } from '@rango-dev/ui';
4
+ import { Button, Divider, Image, MessageBox } from '@rango-dev/ui';
5
+ import { useWallets } from '@rango-dev/wallets-react';
5
6
  import React from 'react';
6
7
 
8
+ import { NamespaceUnsupportedItem } from '../NamespaceItem/NamespaceUnsupportedItem';
9
+
10
+ import { NamespacesHeader } from './Detached.styles';
7
11
  import { NamespaceDetachedItem } from './NamespaceDetachedItem';
8
12
  import { NamespaceList, StyledButton } from './Namespaces.styles';
9
- import { NamespaceUnsupportedItem } from './NamespaceUnsupportedItem';
10
13
 
11
14
  export function Detached(props: PropTypes) {
12
- const { selectedNamespaces, value } = props;
15
+ const { selectedNamespaces, value, onDisconnectWallet } = props;
13
16
  const { targetWallet } = value;
14
17
 
18
+ const { state } = useWallets();
19
+ const walletState = state(targetWallet.type);
20
+
15
21
  return (
16
22
  <>
17
23
  <MessageBox
@@ -24,7 +30,18 @@ export function Detached(props: PropTypes) {
24
30
  )}
25
31
  icon={<Image src={targetWallet.image} size={45} />}
26
32
  />
27
- <Divider size={20} />
33
+ <Divider size={30} />
34
+ <NamespacesHeader>
35
+ <Button
36
+ id="widget-detached-disconnect-wallet-btn"
37
+ variant="ghost"
38
+ type="error"
39
+ size="xsmall"
40
+ disabled={walletState.connecting || !walletState.connected}
41
+ onClick={onDisconnectWallet}>
42
+ {i18n.t('Disconnect wallet')}
43
+ </Button>
44
+ </NamespacesHeader>
28
45
  <NamespaceList id="widget-detached-namespace-list" as={'ul'}>
29
46
  {targetWallet.needsNamespace?.data.map((namespace, index, array) => (
30
47
  <React.Fragment key={namespace.id}>
@@ -4,5 +4,6 @@ import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
4
4
  export interface PropTypes {
5
5
  value: NeedsNamespacesState;
6
6
  onConfirm: () => void;
7
+ onDisconnectWallet: () => void;
7
8
  selectedNamespaces: Namespace[] | null;
8
9
  }
@@ -3,49 +3,25 @@ import type { NamespaceData } from '@rango-dev/wallets-core/dist/hub/store/names
3
3
  import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
4
4
 
5
5
  import { i18n } from '@lingui/core';
6
- import {
7
- Button,
8
- ChevronDownIcon,
9
- ChevronUpIcon,
10
- Divider,
11
- Spinner,
12
- Typography,
13
- } from '@rango-dev/ui';
6
+ import { Button, Spinner } from '@rango-dev/ui';
14
7
  import { useWallets } from '@rango-dev/wallets-react';
15
- import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
8
+ import React, { useLayoutEffect, useRef, useState } from 'react';
16
9
 
17
- import { useAppStore } from '../../store/AppStore';
18
10
  import { getConciseAddress } from '../../utils/wallets';
19
-
20
- import { getBlockchainLogo } from './Namespaces.helpers';
21
- import {
22
- NamespaceAccountAddress,
23
- NamespaceDetachedItemInfo,
24
- NamespaceItemContainer,
25
- NamespaceItemContent,
26
- NamespaceItemError,
27
- NamespaceItemErrorDropdownToggle,
28
- NamespaceItemInnerContent,
29
- NamespaceLogo,
30
- } from './Namespaces.styles';
31
- import { SupportedChainsList } from './SupportedChainsList';
11
+ import { NamespaceItem } from '../NamespaceItem';
32
12
 
33
13
  export const NamespaceDetachedItem = function NamespaceDetachedItem(
34
14
  props: NamespaceDetachedItemPropTypes
35
15
  ) {
36
16
  const { walletType, namespace, initialConnect } = props;
37
- const blockchains = useAppStore().blockchains();
38
17
  const { connect, disconnect, state } = useWallets();
39
18
  const [error, setError] = useState<Error | null>(null);
40
- const [errorIsExpanded, setErrorIsExpanded] = useState(false);
41
19
 
42
20
  const walletState = state(walletType);
43
21
 
44
22
  const namespaceState = walletState.namespaces?.get(namespace.value);
45
23
  const firstAccountArray = namespaceState.accounts?.[0]?.split(':');
46
24
 
47
- const supportedChains = namespace.getSupportedChains(blockchains);
48
-
49
25
  /*
50
26
  * Ref to track ongoing connection attempts.
51
27
  * In React Strict Mode, effects run twice for safety checks.
@@ -53,8 +29,6 @@ export const NamespaceDetachedItem = function NamespaceDetachedItem(
53
29
  */
54
30
  const processingConnectAttempt = useRef(false);
55
31
 
56
- useEffect(() => setErrorIsExpanded(false), [error]);
57
-
58
32
  useLayoutEffect(() => {
59
33
  if (initialConnect && !processingConnectAttempt.current) {
60
34
  void handleConnectNamespace(walletType, namespace.value);
@@ -100,91 +74,31 @@ export const NamespaceDetachedItem = function NamespaceDetachedItem(
100
74
  };
101
75
 
102
76
  return (
103
- <NamespaceItemContainer hasError={!!error}>
104
- <NamespaceItemContent>
105
- <NamespaceLogo
106
- src={getBlockchainLogo(blockchains, namespace.id)}
107
- size={40}
108
- />
109
- <NamespaceItemInnerContent>
110
- <NamespaceDetachedItemInfo className="widget-namespace-detached-item-info-div">
111
- <Typography variant="label" size="large">
112
- {namespace.label}
113
- </Typography>
114
- {namespaceState.connected && (
115
- <Typography variant="body" size="small" color="success500">
116
- {i18n.t('Connected')}
117
- </Typography>
118
- )}
119
- {!namespaceState.connected && !!error && (
120
- <Typography variant="body" size="small" color="error500">
121
- {i18n.t('Connection failed')}
122
- </Typography>
123
- )}
124
- </NamespaceDetachedItemInfo>
125
- {namespaceState.connected && (
126
- <NamespaceAccountAddress
127
- variant="body"
128
- size="small"
129
- color="neutral700">
130
- {getConciseAddress(
131
- firstAccountArray?.[firstAccountArray?.length - 1]
132
- )}
133
- </NamespaceAccountAddress>
134
- )}
135
- {!namespaceState.connected && error && (
136
- <NamespaceItemErrorDropdownToggle
137
- className="widget-namespace-detached-item-error-toggle-btn"
138
- onClick={() =>
139
- setErrorIsExpanded((errorIsExpanded) => !errorIsExpanded)
140
- }>
141
- <Typography
142
- variant="body"
143
- size="small"
144
- color="neutral700"
145
- style={{
146
- textDecoration: 'underline',
147
- userSelect: 'none',
148
- textDecorationSkipInk: 'none',
149
- }}>
150
- {i18n.t('See why')}
151
- </Typography>
152
- {errorIsExpanded ? (
153
- <ChevronUpIcon size={12} color="gray" />
154
- ) : (
155
- <ChevronDownIcon size={12} color="gray" />
156
- )}
157
- </NamespaceItemErrorDropdownToggle>
158
- )}
159
- {!namespaceState.connected &&
160
- !error &&
161
- supportedChains.length > 1 && (
162
- <SupportedChainsList chains={supportedChains} />
163
- )}
164
- </NamespaceItemInnerContent>
165
- {namespaceState.connecting ? (
77
+ <NamespaceItem
78
+ namespace={namespace}
79
+ connected={namespaceState.connected}
80
+ error={error?.message}
81
+ address={
82
+ namespaceState.connected
83
+ ? getConciseAddress(
84
+ firstAccountArray?.[firstAccountArray?.length - 1]
85
+ )
86
+ : ''
87
+ }
88
+ suffix={
89
+ namespaceState.connecting ? (
166
90
  <Spinner color="info" />
167
91
  ) : (
168
92
  <Button
169
93
  id="widget-name-space-connect-btn"
170
94
  variant="ghost"
171
95
  type={namespaceState.connected ? 'error' : 'primary'}
172
- size="small"
96
+ size="xsmall"
173
97
  onClick={async () => handleButtonClick(namespaceState)}>
174
98
  {getButtonText()}
175
99
  </Button>
176
- )}
177
- </NamespaceItemContent>
178
- {!namespaceState.connected && !!error && errorIsExpanded && (
179
- <>
180
- <Divider size={4} />
181
- <NamespaceItemError id="widget-namespace-item-error-div">
182
- <Typography variant="body" size="small" color="neutral700">
183
- {(error.cause as Error)?.message || error.message}
184
- </Typography>
185
- </NamespaceItemError>
186
- </>
187
- )}
188
- </NamespaceItemContainer>
100
+ )
101
+ }
102
+ />
189
103
  );
190
104
  };
@@ -1,49 +1,24 @@
1
1
  import type { NamespaceItemPropTypes } from './Namespaces.types';
2
2
 
3
- import { Checkbox, Radio, Typography } from '@rango-dev/ui';
3
+ import { Checkbox, Radio } from '@rango-dev/ui';
4
4
  import React from 'react';
5
5
 
6
- import { useAppStore } from '../../store/AppStore';
7
-
8
- import { getBlockchainLogo } from './Namespaces.helpers';
9
- import {
10
- NamespaceItemContainer,
11
- NamespaceItemContent,
12
- NamespaceItemInnerContent,
13
- NamespaceLogo,
14
- } from './Namespaces.styles';
15
- import { SupportedChainsList } from './SupportedChainsList';
6
+ import { NamespaceItem } from '../NamespaceItem';
16
7
 
17
8
  export function NamespaceListItem(props: NamespaceItemPropTypes) {
18
9
  const { onClick, type, namespace } = props;
19
- const blockchains = useAppStore().blockchains();
20
10
 
21
- const supportedChains = namespace.getSupportedChains(blockchains);
22
- const showSupportedChains = supportedChains.length > 1;
23
11
  return (
24
- <NamespaceItemContainer
12
+ <NamespaceItem
13
+ namespace={namespace}
25
14
  onClick={onClick}
26
- clickable
27
- className="widget-namespace-list-item">
28
- <NamespaceItemContent>
29
- <NamespaceLogo
30
- src={getBlockchainLogo(blockchains, namespace.id)}
31
- size={40}
32
- />
33
- <NamespaceItemInnerContent showSupportedChains={showSupportedChains}>
34
- <Typography variant="label" size="large">
35
- {namespace.label}
36
- </Typography>
37
- {showSupportedChains && (
38
- <SupportedChainsList chains={supportedChains} />
39
- )}
40
- </NamespaceItemInnerContent>
41
- {type === 'radio' ? (
15
+ suffix={
16
+ type === 'radio' ? (
42
17
  <Radio value={namespace.value} />
43
18
  ) : (
44
19
  <Checkbox checked={props.value} />
45
- )}
46
- </NamespaceItemContent>
47
- </NamespaceItemContainer>
20
+ )
21
+ }
22
+ />
48
23
  );
49
24
  }
@@ -1,104 +1,12 @@
1
- import { Button, darkTheme, Image, styled, Typography } from '@rango-dev/ui';
1
+ import { Button, styled } from '@rango-dev/ui';
2
2
 
3
3
  export const NamespaceList = styled('ul', {
4
4
  padding: 0,
5
- paddingTop: '$10',
5
+ paddingTop: '$16',
6
6
  paddingBottom: '$20',
7
7
  margin: 0,
8
8
  });
9
9
 
10
- export const NamespaceItemContainer = styled('li', {
11
- backgroundColor: '$neutral200',
12
- padding: '$16',
13
- borderRadius: '$sm',
14
- variants: {
15
- clickable: {
16
- true: {
17
- cursor: 'pointer',
18
- },
19
- },
20
- hasError: {
21
- true: {
22
- background: '$error100 ',
23
- [`.${darkTheme} &`]: {
24
- backgroundColor: '$error700',
25
- },
26
- },
27
- },
28
- unsupported: {
29
- true: {
30
- cursor: 'not-allowed',
31
- paddingTop: '$8',
32
- paddingBottom: '$8',
33
- },
34
- },
35
- },
36
- });
37
-
38
- export const NamespaceItemContent = styled('div', {
39
- display: 'flex',
40
- gap: '$8',
41
- alignItems: 'center',
42
- });
43
-
44
- export const NamespaceItemInnerContent = styled('div', {
45
- flex: '1',
46
- display: 'flex',
47
- flexDirection: 'column',
48
- justifyContent: 'space-between',
49
- height: '$40',
50
- variants: {
51
- showSupportedChains: {
52
- true: {
53
- justifyContent: 'space-between',
54
- },
55
- false: {
56
- justifyContent: 'center',
57
- },
58
- },
59
- },
60
- });
61
-
62
- export const UnsupportedNamespaceItemInnerContent = styled('div', {
63
- flex: '1',
64
- display: 'flex',
65
- alignItems: 'center',
66
- gap: '$4',
67
- opacity: '0.5',
68
- });
69
-
70
- export const NamespaceLogo = styled(Image, {
71
- variants: {
72
- disabled: {
73
- true: {
74
- opacity: '0.5',
75
- },
76
- },
77
- },
78
- });
79
-
80
10
  export const StyledButton = styled(Button, {
81
11
  minHeight: '$40',
82
12
  });
83
-
84
- export const NamespaceAccountAddress = styled(Typography, {
85
- maxWidth: '100px',
86
- });
87
-
88
- export const NamespaceItemError = styled('div', {
89
- paddingLeft: '48px',
90
- });
91
-
92
- export const NamespaceItemErrorDropdownToggle = styled('div', {
93
- display: 'flex',
94
- gap: '2px',
95
- cursor: 'pointer',
96
- alignItems: 'center',
97
- width: 'fit-content',
98
- });
99
-
100
- export const NamespaceDetachedItemInfo = styled('div', {
101
- display: 'flex',
102
- gap: '6px',
103
- alignItems: 'center',
104
- });
@@ -13,10 +13,10 @@ import {
13
13
  import React, { useEffect, useMemo, useState } from 'react';
14
14
 
15
15
  import { useAppStore } from '../../store/AppStore';
16
+ import { NamespaceUnsupportedItem } from '../NamespaceItem/NamespaceUnsupportedItem';
16
17
 
17
18
  import { NamespaceListItem } from './NamespaceListItem';
18
19
  import { NamespaceList, StyledButton } from './Namespaces.styles';
19
- import { NamespaceUnsupportedItem } from './NamespaceUnsupportedItem';
20
20
 
21
21
  export function Namespaces(props: PropTypes) {
22
22
  const { targetWallet } = props.value;
@@ -31,7 +31,3 @@ export type NamespaceDetachedItemPropTypes = {
31
31
  initialConnect?: boolean;
32
32
  namespace: LegacyNamespaceMeta;
33
33
  };
34
-
35
- export type NamespaceUnsupportedItemPropTypes = {
36
- namespace: LegacyNamespaceMeta;
37
- };
@@ -77,7 +77,7 @@ export function useUpdates(params: UseUpdatesParams): UseUpdates {
77
77
  );
78
78
 
79
79
  if (data.length) {
80
- void newWalletConnected(data, info.namespace);
80
+ void newWalletConnected(data, info.namespace, state.derivationPath);
81
81
  }
82
82
  };
83
83
 
@@ -124,42 +124,29 @@ export function generateWarnings(params: {
124
124
  return output;
125
125
  }
126
126
 
127
- export function handleQuoteErrors(error: any): ConfirmSwapFetchResult {
127
+ export function handleQuoteErrors(
128
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
+ error: any
130
+ ): NonNullable<ConfirmSwapFetchResult['error']> {
128
131
  if (error?.code === 'ERR_CANCELED') {
129
132
  return {
130
- swap: null,
131
- error: {
132
- type: QuoteErrorType.REQUEST_CANCELED,
133
- },
134
- warnings: null,
133
+ type: QuoteErrorType.REQUEST_CANCELED,
135
134
  };
136
135
  }
137
136
 
138
137
  if (error.cause) {
139
- return {
140
- swap: null,
141
- error: error.cause,
142
- warnings: null,
143
- };
138
+ return error.cause;
144
139
  }
145
140
 
146
141
  if (error?.code === 'ERR_BAD_REQUEST') {
147
142
  return {
148
- swap: null,
149
- error: {
150
- type: QuoteErrorType.NO_RESULT,
151
- diagnosisMessage: error.response.data.error,
152
- },
153
- warnings: null,
143
+ type: QuoteErrorType.NO_RESULT,
144
+ diagnosisMessage: error.response.data.error,
154
145
  };
155
146
  }
156
147
 
157
148
  return {
158
- swap: null,
159
- error: {
160
- type: QuoteErrorType.REQUEST_FAILED,
161
- diagnosisMessage: error.message,
162
- },
163
- warnings: null,
149
+ type: QuoteErrorType.REQUEST_FAILED,
150
+ diagnosisMessage: error.message,
164
151
  };
165
152
  }
@@ -1,12 +1,17 @@
1
1
  import type { ConfirmSwap } from './useConfirmSwap.types';
2
- import type { PendingSwapSettings, SelectedQuote } from '../../types';
3
2
  import type { ConfirmRouteRequest } from 'rango-sdk';
4
3
 
4
+ import { warn } from '@rango-dev/logging-core';
5
5
  import { calculatePendingSwap } from '@rango-dev/queue-manager-rango-preset';
6
6
  import { useEffect } from 'react';
7
7
 
8
8
  import { useAppStore } from '../../store/AppStore';
9
9
  import { useQuoteStore } from '../../store/quote';
10
+ import {
11
+ type PendingSwapSettings,
12
+ QuoteErrorType,
13
+ type SelectedQuote,
14
+ } from '../../types';
10
15
  import { getWalletsForNewSwap } from '../../utils/swap';
11
16
  import { useFetchConfirmQuote } from '../useFetchConfirmQuote';
12
17
 
@@ -125,9 +130,19 @@ export function useConfirmSwap(): ConfirmSwap {
125
130
  warnings: confirmSwapWarnings,
126
131
  };
127
132
  });
128
- } catch (error: any) {
129
- const confirmSwapResult = handleQuoteErrors(error);
130
- return confirmSwapResult;
133
+ } catch (error: unknown) {
134
+ const quoteError = handleQuoteErrors(error);
135
+ if (quoteError.type !== QuoteErrorType.REQUEST_CANCELED) {
136
+ warn(new Error('confirm swap error'), {
137
+ tags: {
138
+ ...quoteError,
139
+ type: QuoteErrorType[quoteError.type],
140
+ initialQuote,
141
+ requestBody,
142
+ },
143
+ });
144
+ }
145
+ return { swap: null, error: quoteError, warnings: null };
131
146
  }
132
147
  };
133
148