@rango-dev/widget-embedded 0.45.1-next.1 → 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.
- package/dist/components/CustomDestination/CustomDestination.styles.d.ts +1 -0
- package/dist/components/CustomDestination/CustomDestination.styles.d.ts.map +1 -1
- package/dist/components/NamespaceItem/NamespaceItem.d.ts +4 -0
- package/dist/components/NamespaceItem/NamespaceItem.d.ts.map +1 -0
- package/dist/components/{WalletStatefulConnect/Namespaces.helpers.d.ts → NamespaceItem/NamespaceItem.helpers.d.ts} +1 -1
- package/dist/components/NamespaceItem/NamespaceItem.helpers.d.ts.map +1 -0
- package/dist/components/NamespaceItem/NamespaceItem.styles.d.ts +1450 -0
- package/dist/components/NamespaceItem/NamespaceItem.styles.d.ts.map +1 -0
- package/dist/components/NamespaceItem/NamespaceItem.types.d.ts +13 -0
- package/dist/components/NamespaceItem/NamespaceItem.types.d.ts.map +1 -0
- package/dist/components/{WalletStatefulConnect → NamespaceItem}/NamespaceUnsupportedItem.d.ts +1 -1
- package/dist/components/NamespaceItem/NamespaceUnsupportedItem.d.ts.map +1 -0
- package/dist/components/NamespaceItem/SupportedChainsList.d.ts.map +1 -0
- package/dist/components/NamespaceItem/SupportedChainsList.styles.d.ts.map +1 -0
- package/dist/components/NamespaceItem/SupportedChainsList.types.d.ts.map +1 -0
- package/dist/components/NamespaceItem/index.d.ts +2 -0
- package/dist/components/NamespaceItem/index.d.ts.map +1 -0
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +0 -162
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
- package/dist/components/SwapDetails/RequestIdRow.d.ts +4 -0
- package/dist/components/SwapDetails/RequestIdRow.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDateRow.d.ts +4 -0
- package/dist/components/SwapDetails/SwapDateRow.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.types.d.ts +7 -0
- package/dist/components/SwapDetails/SwapDetails.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.NetworkState.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.NetworkState.d.ts.map +1 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +320 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +29 -10
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.styles.d.ts +161 -0
- package/dist/components/WalletStatefulConnect/Detached.styles.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts +1 -0
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/NamespaceListItem.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +281 -1730
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +0 -3
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -2
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/store/slices/wallets.d.ts +2 -2
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/types/quote.d.ts +1 -1
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +1 -0
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -0
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/components/{WalletStatefulConnect/Namespaces.helpers.ts → NamespaceItem/NamespaceItem.helpers.ts} +1 -1
- package/src/components/NamespaceItem/NamespaceItem.styles.ts +93 -0
- package/src/components/NamespaceItem/NamespaceItem.tsx +117 -0
- package/src/components/NamespaceItem/NamespaceItem.types.ts +14 -0
- package/src/components/{WalletStatefulConnect → NamespaceItem}/NamespaceUnsupportedItem.tsx +3 -3
- package/src/components/NamespaceItem/index.ts +1 -0
- package/src/components/Quote/Quote.tsx +4 -4
- package/src/components/Slippage/Slippage.styles.ts +0 -23
- package/src/components/Slippage/Slippage.tsx +24 -26
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +4 -0
- package/src/components/SwapDetails/RequestIdRow.tsx +73 -0
- package/src/components/SwapDetails/SwapDateRow.tsx +21 -0
- package/src/components/SwapDetails/SwapDetails.tsx +39 -83
- package/src/components/SwapDetails/SwapDetails.types.ts +7 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.tsx +177 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.tsx +52 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.NetworkState.tsx +17 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +22 -62
- package/src/components/SwapDetailsModal/SwapDetailsModal.styles.ts +20 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +24 -35
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +31 -10
- package/src/components/WalletStatefulConnect/Detached.styles.ts +6 -0
- package/src/components/WalletStatefulConnect/Detached.tsx +21 -4
- package/src/components/WalletStatefulConnect/Detached.types.ts +1 -0
- package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +20 -106
- package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +9 -34
- package/src/components/WalletStatefulConnect/Namespaces.styles.ts +2 -94
- package/src/components/WalletStatefulConnect/Namespaces.tsx +1 -1
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +0 -4
- package/src/containers/Wallets/useUpdates.ts +1 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +10 -23
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +19 -4
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +23 -7
- package/src/hooks/useSwapInput.ts +13 -4
- package/src/hooks/useWalletList.ts +1 -1
- package/src/store/slices/wallets.ts +11 -5
- package/src/types/quote.ts +1 -1
- package/src/types/wallets.ts +1 -0
- package/src/utils/swap.ts +10 -5
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +0 -4
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/NamespaceUnsupportedItem.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/Namespaces.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/SupportedChainsList.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/SupportedChainsList.styles.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/SupportedChainsList.types.d.ts.map +0 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +0 -26
- /package/dist/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.d.ts +0 -0
- /package/dist/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.styles.d.ts +0 -0
- /package/dist/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.types.d.ts +0 -0
- /package/src/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.styles.ts +0 -0
- /package/src/components/{WalletStatefulConnect → NamespaceItem}/SupportedChainsList.tsx +0 -0
- /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 {
|
|
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 {
|
|
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
|
-
|
|
33
|
-
open={!!state}
|
|
18
|
+
open={isOpen}
|
|
34
19
|
onClose={onClose}
|
|
35
|
-
container={
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
28
|
+
<DeleteContent
|
|
29
|
+
onClose={onClose}
|
|
30
|
+
onDelete={() => {
|
|
31
|
+
onClose();
|
|
32
|
+
onDelete();
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
52
35
|
)}
|
|
53
36
|
{state === 'cancel' && (
|
|
54
|
-
<CancelContent
|
|
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
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
export interface WalletStateContentProps {
|
|
42
|
+
swap: PendingSwap;
|
|
43
|
+
message: string;
|
|
44
|
+
onClose: () => void;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
export interface
|
|
45
|
-
swap: PendingSwap;
|
|
47
|
+
export interface NetworkStateContentProps {
|
|
46
48
|
message: string;
|
|
47
|
-
|
|
48
|
-
|
|
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
|
|
66
|
+
export interface CancelContentProps {
|
|
67
|
+
onCancel: () => void;
|
|
68
|
+
onClose: () => void;
|
|
69
|
+
}
|
|
52
70
|
|
|
53
|
-
export
|
|
71
|
+
export interface DeleteContentProps {
|
|
72
|
+
onDelete: () => void;
|
|
73
|
+
onClose: () => void;
|
|
74
|
+
}
|
|
@@ -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={
|
|
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}>
|
|
@@ -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, {
|
|
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
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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="
|
|
96
|
+
size="xsmall"
|
|
173
97
|
onClick={async () => handleButtonClick(namespaceState)}>
|
|
174
98
|
{getButtonText()}
|
|
175
99
|
</Button>
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
|
|
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
|
|
3
|
+
import { Checkbox, Radio } from '@rango-dev/ui';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
|
-
import {
|
|
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
|
-
<
|
|
12
|
+
<NamespaceItem
|
|
13
|
+
namespace={namespace}
|
|
25
14
|
onClick={onClick}
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
47
|
-
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
/>
|
|
48
23
|
);
|
|
49
24
|
}
|
|
@@ -1,104 +1,12 @@
|
|
|
1
|
-
import { Button,
|
|
1
|
+
import { Button, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const NamespaceList = styled('ul', {
|
|
4
4
|
padding: 0,
|
|
5
|
-
paddingTop: '$
|
|
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;
|
|
@@ -124,42 +124,29 @@ export function generateWarnings(params: {
|
|
|
124
124
|
return output;
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
export function handleQuoteErrors(
|
|
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
|
-
|
|
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
|
-
|
|
149
|
-
|
|
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
|
-
|
|
159
|
-
|
|
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:
|
|
129
|
-
const
|
|
130
|
-
|
|
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
|
|