@rango-dev/widget-embedded 0.45.1-next.2 → 0.45.1-next.4
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/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/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/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/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/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/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.tsx +2 -1
- package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +19 -105
- package/src/components/WalletStatefulConnect/NamespaceListItem.tsx +9 -34
- package/src/components/WalletStatefulConnect/Namespaces.styles.ts +1 -93
- 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/store/slices/wallets.ts +11 -5
- package/src/types/wallets.ts +1 -0
- package/src/utils/swap.ts +6 -1
- 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
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { ConnectWalletContentProps } from './SwapDetailsModal.types';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
import {
|
|
5
|
+
Alert,
|
|
6
|
+
Button,
|
|
7
|
+
Checkbox,
|
|
8
|
+
Divider,
|
|
9
|
+
Image,
|
|
10
|
+
MessageBox,
|
|
11
|
+
Spinner,
|
|
12
|
+
WarningIcon,
|
|
13
|
+
} from '@rango-dev/ui';
|
|
14
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
15
|
+
import React, { useState } from 'react';
|
|
16
|
+
|
|
17
|
+
import { useWalletList } from '../../hooks/useWalletList';
|
|
18
|
+
import { useUiStore } from '../../store/ui';
|
|
19
|
+
import { getConciseAddress } from '../../utils/wallets';
|
|
20
|
+
import { NamespaceItem } from '../NamespaceItem';
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
WalletIcon,
|
|
24
|
+
WalletIconBadgeContainer,
|
|
25
|
+
} from './SwapDetailsModal.styles';
|
|
26
|
+
|
|
27
|
+
export const ConnectWalletContent = (props: ConnectWalletContentProps) => {
|
|
28
|
+
const { wallet: currentStepWallet, namespace, onClose } = props;
|
|
29
|
+
|
|
30
|
+
const [error, setError] = useState<Error | null>(null);
|
|
31
|
+
const { list } = useWalletList();
|
|
32
|
+
const isActiveTab = useUiStore.use.isActiveTab();
|
|
33
|
+
const { state, connect } = useWallets();
|
|
34
|
+
|
|
35
|
+
const wallet = list.find(
|
|
36
|
+
(wallet) => wallet.type === currentStepWallet.walletType
|
|
37
|
+
);
|
|
38
|
+
const namespaceData = wallet?.needsNamespace?.data.find(
|
|
39
|
+
(namespaceData) => namespaceData.value === namespace?.namespace
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (!wallet) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const walletState = state(currentStepWallet.walletType);
|
|
47
|
+
const namespaceState =
|
|
48
|
+
wallet.isHub && namespace?.namespace
|
|
49
|
+
? walletState.namespaces?.get(namespace.namespace)
|
|
50
|
+
: null;
|
|
51
|
+
|
|
52
|
+
const connecting = walletState.connecting || namespaceState?.connecting;
|
|
53
|
+
const connected = wallet.isHub
|
|
54
|
+
? namespaceState?.connected
|
|
55
|
+
: walletState.connected;
|
|
56
|
+
|
|
57
|
+
const getButtonTitle = () => {
|
|
58
|
+
if (connected) {
|
|
59
|
+
return i18n.t('Done');
|
|
60
|
+
}
|
|
61
|
+
if (error) {
|
|
62
|
+
return i18n.t('Try again');
|
|
63
|
+
}
|
|
64
|
+
return i18n.t('Connect');
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const getNamespaceSuffix = () => {
|
|
68
|
+
if (connecting) {
|
|
69
|
+
return <Spinner color="info" />;
|
|
70
|
+
} else if (error || connected) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return <Checkbox checked disabled />;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const handleConnect = async () => {
|
|
77
|
+
try {
|
|
78
|
+
setError(null);
|
|
79
|
+
await connect(
|
|
80
|
+
wallet.type,
|
|
81
|
+
namespace?.namespace
|
|
82
|
+
? [
|
|
83
|
+
{
|
|
84
|
+
namespace: namespace?.namespace,
|
|
85
|
+
network: undefined,
|
|
86
|
+
derivationPath: currentStepWallet.derivationPath,
|
|
87
|
+
},
|
|
88
|
+
]
|
|
89
|
+
: undefined
|
|
90
|
+
);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
setError(error as Error);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const handleClickButton = async () => {
|
|
97
|
+
if (connected) {
|
|
98
|
+
onClose();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
void handleConnect();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const getAddress = () => {
|
|
106
|
+
if (!connected) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const firstAccountArray = wallet?.isHub
|
|
110
|
+
? namespaceState?.accounts?.[0]?.split(':')
|
|
111
|
+
: walletState?.accounts?.[0]?.split(':');
|
|
112
|
+
const address = firstAccountArray?.[firstAccountArray?.length - 1];
|
|
113
|
+
|
|
114
|
+
if (!address) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return getConciseAddress(address);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<>
|
|
123
|
+
<MessageBox
|
|
124
|
+
type="warning"
|
|
125
|
+
title={i18n.t('Connect {wallet}', { wallet: wallet.title })}
|
|
126
|
+
description={i18n.t(
|
|
127
|
+
'The connection of your wallet or some networks has been disconnected. Connect to continue the swap'
|
|
128
|
+
)}
|
|
129
|
+
icon={
|
|
130
|
+
<WalletIcon>
|
|
131
|
+
<Image src={wallet.image} size={45} />
|
|
132
|
+
<WalletIconBadgeContainer>
|
|
133
|
+
<WarningIcon color="warning" size={10} />
|
|
134
|
+
</WalletIconBadgeContainer>
|
|
135
|
+
</WalletIcon>
|
|
136
|
+
}
|
|
137
|
+
/>
|
|
138
|
+
{connected && !namespaceData && (
|
|
139
|
+
<>
|
|
140
|
+
<Divider size={10} />
|
|
141
|
+
<Alert
|
|
142
|
+
type="success"
|
|
143
|
+
variant="alarm"
|
|
144
|
+
title={i18n.t('Wallet connected successfully.')}
|
|
145
|
+
/>
|
|
146
|
+
</>
|
|
147
|
+
)}
|
|
148
|
+
{error && !namespaceData && (
|
|
149
|
+
<>
|
|
150
|
+
<Divider size={10} />
|
|
151
|
+
<Alert type="error" title={error?.message} variant="alarm" />
|
|
152
|
+
</>
|
|
153
|
+
)}
|
|
154
|
+
{namespaceData && (
|
|
155
|
+
<>
|
|
156
|
+
<Divider size={30} />
|
|
157
|
+
<NamespaceItem
|
|
158
|
+
namespace={namespaceData}
|
|
159
|
+
suffix={getNamespaceSuffix()}
|
|
160
|
+
error={error?.message}
|
|
161
|
+
connected={connected}
|
|
162
|
+
address={getAddress()}
|
|
163
|
+
/>
|
|
164
|
+
</>
|
|
165
|
+
)}
|
|
166
|
+
<Divider size="40" />
|
|
167
|
+
<Button
|
|
168
|
+
loading={connecting}
|
|
169
|
+
type="primary"
|
|
170
|
+
id="widget-connect-wallet-btn"
|
|
171
|
+
onClick={handleClickButton}
|
|
172
|
+
disabled={!isActiveTab}>
|
|
173
|
+
{getButtonTitle()}
|
|
174
|
+
</Button>
|
|
175
|
+
</>
|
|
176
|
+
);
|
|
177
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { InstallWalletContentProps } from './SwapDetailsModal.types';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
import { Button, Divider, Image, MessageBox, WarningIcon } from '@rango-dev/ui';
|
|
5
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
6
|
+
import { detectInstallLink } from '@rango-dev/wallets-shared';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
WalletIcon,
|
|
11
|
+
WalletIconBadgeContainer,
|
|
12
|
+
} from './SwapDetailsModal.styles';
|
|
13
|
+
|
|
14
|
+
export const InstallWalletContent = (props: InstallWalletContentProps) => {
|
|
15
|
+
const { walletType } = props;
|
|
16
|
+
|
|
17
|
+
const { getWalletInfo } = useWallets();
|
|
18
|
+
|
|
19
|
+
const walletInfo = walletType ? getWalletInfo(walletType) : null;
|
|
20
|
+
|
|
21
|
+
if (!walletInfo) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const handleButtonClick = () =>
|
|
26
|
+
window.open(detectInstallLink(walletInfo.installLink), '_blank');
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
<MessageBox
|
|
31
|
+
type="warning"
|
|
32
|
+
title={i18n.t('Install {wallet}', { wallet: walletInfo.name })}
|
|
33
|
+
description="Your wallet is not installed. Please install it to continue the swap. "
|
|
34
|
+
icon={
|
|
35
|
+
<WalletIcon>
|
|
36
|
+
<Image src={walletInfo.img} size={45} />
|
|
37
|
+
<WalletIconBadgeContainer>
|
|
38
|
+
<WarningIcon color="warning" size={10} />
|
|
39
|
+
</WalletIconBadgeContainer>
|
|
40
|
+
</WalletIcon>
|
|
41
|
+
}
|
|
42
|
+
/>
|
|
43
|
+
<Divider size="40" />
|
|
44
|
+
<Button
|
|
45
|
+
type="primary"
|
|
46
|
+
id="widget-install-wallet-btn"
|
|
47
|
+
onClick={handleButtonClick}>
|
|
48
|
+
{i18n.t('Install')}
|
|
49
|
+
</Button>
|
|
50
|
+
</>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { NetworkStateContentProps } from './SwapDetailsModal.types';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
import { MessageBox } from '@rango-dev/ui';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
export const NetworkStateContent = (props: NetworkStateContentProps) => {
|
|
8
|
+
const { status, message } = props;
|
|
9
|
+
|
|
10
|
+
const type = status === 'waitingForNetworkChange' ? 'loading' : 'success';
|
|
11
|
+
const title =
|
|
12
|
+
status === 'waitingForNetworkChange'
|
|
13
|
+
? i18n.t('Change Network')
|
|
14
|
+
: i18n.t('Network Changed');
|
|
15
|
+
|
|
16
|
+
return <MessageBox type={type} title={title} description={message} />;
|
|
17
|
+
};
|
|
@@ -1,89 +1,49 @@
|
|
|
1
1
|
import type { WalletStateContentProps } from './SwapDetailsModal.types';
|
|
2
|
-
import type { WalletInfoWithExtra } from '../../types';
|
|
3
2
|
|
|
4
|
-
import { warn } from '@rango-dev/logging-core';
|
|
5
3
|
import {
|
|
4
|
+
getCurrentNamespaceOfOrNull,
|
|
6
5
|
getCurrentStep,
|
|
7
6
|
getRelatedWalletOrNull,
|
|
8
7
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
|
-
import {
|
|
8
|
+
import { WalletState } from '@rango-dev/ui';
|
|
10
9
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
11
|
-
import React
|
|
10
|
+
import React from 'react';
|
|
12
11
|
|
|
13
|
-
import { useWalletList } from '../../hooks/useWalletList';
|
|
14
|
-
import { getContainer } from '../../utils/common';
|
|
15
12
|
import { mapStatusToWalletState } from '../../utils/wallets';
|
|
16
|
-
import { StatefulConnectModal } from '../StatefulConnectModal';
|
|
17
13
|
|
|
18
|
-
import {
|
|
14
|
+
import { ConnectWalletContent } from './SwapDetailsModal.ConnectWallet';
|
|
15
|
+
import { InstallWalletContent } from './SwapDetailsModal.InstallWallet';
|
|
19
16
|
|
|
20
17
|
export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
const [selectedWalletToConnect, setSelectedWalletToConnect] =
|
|
24
|
-
useState<WalletInfoWithExtra>();
|
|
25
|
-
const { getWalletInfo, state } = useWallets();
|
|
18
|
+
const { swap, onClose } = props;
|
|
19
|
+
const { state } = useWallets();
|
|
26
20
|
|
|
27
21
|
const currentStep = getCurrentStep(swap);
|
|
28
22
|
const currentStepWallet = currentStep
|
|
29
23
|
? getRelatedWalletOrNull(swap, currentStep)
|
|
30
24
|
: null;
|
|
31
|
-
|
|
25
|
+
|
|
32
26
|
const walletType = currentStepWallet?.walletType;
|
|
33
27
|
const walletState = walletType
|
|
34
28
|
? mapStatusToWalletState(state(walletType))
|
|
35
29
|
: null;
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const { list } = useWalletList();
|
|
30
|
+
const currentNamespace = currentStep
|
|
31
|
+
? getCurrentNamespaceOfOrNull(swap, currentStep)
|
|
32
|
+
: null;
|
|
40
33
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
if (!walletType) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
warn(
|
|
49
|
-
new Error(
|
|
50
|
-
`It seems requested wallet to be connected is not available in the list. requested wallet: ${wallet}`
|
|
51
|
-
)
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
38
|
+
if (walletState === WalletState.NOT_INSTALLED) {
|
|
39
|
+
return <InstallWalletContent walletType={walletType} />;
|
|
40
|
+
}
|
|
56
41
|
|
|
57
42
|
return (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
container={getContainer()}
|
|
64
|
-
title={walletInfo.name}
|
|
65
|
-
image={walletInfo.img}
|
|
66
|
-
type={walletType}
|
|
67
|
-
state={walletState}
|
|
68
|
-
link={walletInfo.installLink}
|
|
69
|
-
disabled={walletButtonDisabled}
|
|
70
|
-
// TODO we need to show an error modal when user reject the connection
|
|
71
|
-
onClick={handleWalletItemClick}
|
|
72
|
-
/>
|
|
73
|
-
</WalletContainer>
|
|
74
|
-
)}
|
|
75
|
-
<StatefulConnectModal
|
|
76
|
-
id="widget-swap-details-modal"
|
|
77
|
-
wallet={selectedWalletToConnect}
|
|
78
|
-
onClose={() => {
|
|
79
|
-
setSelectedWalletToConnect(undefined);
|
|
80
|
-
}}
|
|
81
|
-
options={{
|
|
82
|
-
defaultSelectedChains: currentStepFromBlockchain
|
|
83
|
-
? [currentStepFromBlockchain]
|
|
84
|
-
: undefined,
|
|
85
|
-
}}
|
|
86
|
-
/>
|
|
87
|
-
</>
|
|
43
|
+
<ConnectWalletContent
|
|
44
|
+
wallet={currentStepWallet}
|
|
45
|
+
namespace={currentNamespace}
|
|
46
|
+
onClose={onClose}
|
|
47
|
+
/>
|
|
88
48
|
);
|
|
89
49
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { styled } from '@rango-dev/ui';
|
|
1
|
+
import { darkTheme, styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
3
|
export const WalletContainer = styled('div', {
|
|
4
4
|
display: 'flex',
|
|
@@ -16,3 +16,22 @@ export const TooltipErrorContent = styled('div', {
|
|
|
16
16
|
export const ProfileBanner = styled('img', {
|
|
17
17
|
width: '100%',
|
|
18
18
|
});
|
|
19
|
+
|
|
20
|
+
export const WalletIcon = styled('div', {
|
|
21
|
+
position: 'relative',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const WalletIconBadgeContainer = styled('span', {
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
top: 0,
|
|
27
|
+
right: 0,
|
|
28
|
+
borderRadius: '50%',
|
|
29
|
+
width: '14px',
|
|
30
|
+
height: '14px',
|
|
31
|
+
display: 'flex',
|
|
32
|
+
padding: '$2',
|
|
33
|
+
backgroundColor: '$warning300',
|
|
34
|
+
[`.${darkTheme} &`]: {
|
|
35
|
+
$$color: '$warning600',
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -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
|
+
}
|
|
@@ -4,9 +4,10 @@ import { i18n } from '@lingui/core';
|
|
|
4
4
|
import { Divider, Image, MessageBox } from '@rango-dev/ui';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
+
import { NamespaceUnsupportedItem } from '../NamespaceItem/NamespaceUnsupportedItem';
|
|
8
|
+
|
|
7
9
|
import { NamespaceDetachedItem } from './NamespaceDetachedItem';
|
|
8
10
|
import { NamespaceList, StyledButton } from './Namespaces.styles';
|
|
9
|
-
import { NamespaceUnsupportedItem } from './NamespaceUnsupportedItem';
|
|
10
11
|
|
|
11
12
|
export function Detached(props: PropTypes) {
|
|
12
13
|
const { selectedNamespaces, value } = props;
|