@rango-dev/widget-embedded 0.36.1-next.9 → 0.37.1-next.0
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/QueueManager.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
- package/dist/components/Quotes/Quotes.d.ts.map +1 -1
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/constants/quote.d.ts +8 -0
- package/dist/constants/quote.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +6 -4
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useFetchApiConfig.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +2 -4
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +4 -0
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/wallets.d.ts +3 -1
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/store/ui.d.ts +4 -0
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/types/quote.d.ts +8 -17
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +1 -6
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +6 -2
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +5 -6
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +4 -4
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/QueueManager.tsx +11 -10
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +2 -19
- package/src/components/ConfirmWalletsModal/WalletList.tsx +1 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +42 -22
- package/src/components/Quotes/Quotes.tsx +2 -3
- package/src/components/SwapDetails/SwapDetails.tsx +10 -7
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +26 -13
- package/src/components/WalletStatefulConnect/Namespaces.tsx +30 -37
- package/src/constants/quote.ts +23 -0
- package/src/containers/QuoteInfo/QuoteInfo.tsx +3 -9
- package/src/containers/Wallets/Wallets.tsx +63 -3
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +2 -2
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +29 -66
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +10 -15
- package/src/hooks/useFetchApiConfig.ts +5 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +20 -22
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +2 -4
- package/src/hooks/useSwapInput.ts +2 -9
- package/src/hooks/useWalletList.ts +6 -6
- package/src/hooks/useWalletProviders/useWalletProviders.ts +7 -7
- package/src/pages/ConfirmSwapPage.tsx +7 -15
- package/src/store/quote.ts +3 -13
- package/src/store/slices/config.ts +73 -0
- package/src/store/slices/data.test.ts +23 -1
- package/src/store/slices/wallets.ts +13 -2
- package/src/store/ui.ts +6 -0
- package/src/types/quote.ts +10 -24
- package/src/types/wallets.ts +1 -6
- package/src/utils/providers.ts +66 -70
- package/src/utils/quote.ts +57 -45
- package/src/utils/swap.ts +55 -36
- package/src/utils/wallets.ts +2 -4
- package/dist/constants/warnings.d.ts +0 -3
- package/dist/constants/warnings.d.ts.map +0 -1
- package/dist/utils/hub.d.ts +0 -4
- package/dist/utils/hub.d.ts.map +0 -1
- package/src/constants/warnings.ts +0 -26
- package/src/utils/hub.ts +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.1-next.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"@lingui/core": "4.2.1",
|
|
26
26
|
"@lingui/react": "4.2.1",
|
|
27
27
|
"@rango-dev/logging-core": "^0.6.0",
|
|
28
|
-
"@rango-dev/provider-all": "^0.
|
|
28
|
+
"@rango-dev/provider-all": "^0.41.1-next.0",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.27.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.41.1-next.0",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.27.0",
|
|
32
32
|
"@rango-dev/signer-solana": "^0.35.1-next.0",
|
|
33
|
-
"@rango-dev/ui": "^0.
|
|
34
|
-
"@rango-dev/wallets-core": "^0.40.1-next.
|
|
35
|
-
"@rango-dev/wallets-react": "^0.
|
|
36
|
-
"@rango-dev/wallets-shared": "^0.
|
|
33
|
+
"@rango-dev/ui": "^0.43.1-next.0",
|
|
34
|
+
"@rango-dev/wallets-core": "^0.40.1-next.8",
|
|
35
|
+
"@rango-dev/wallets-react": "^0.27.1-next.0",
|
|
36
|
+
"@rango-dev/wallets-shared": "^0.41.1-next.0",
|
|
37
37
|
"bignumber.js": "^9.1.1",
|
|
38
38
|
"copy-to-clipboard": "^3.3.3",
|
|
39
39
|
"dayjs": "^1.11.7",
|
package/src/QueueManager.tsx
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
SwapQueueContext,
|
|
3
|
+
TargetNamespace,
|
|
4
|
+
} from '@rango-dev/queue-manager-rango-preset';
|
|
5
|
+
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
3
6
|
import type { PropsWithChildren } from 'react';
|
|
4
7
|
|
|
5
8
|
import {
|
|
@@ -48,16 +51,14 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
48
51
|
})),
|
|
49
52
|
};
|
|
50
53
|
|
|
51
|
-
const switchNetwork = async (
|
|
52
|
-
|
|
54
|
+
const switchNetwork = async (
|
|
55
|
+
wallet: WalletType,
|
|
56
|
+
namespace: TargetNamespace
|
|
57
|
+
) => {
|
|
58
|
+
if (!canSwitchNetworkTo(wallet, namespace.network)) {
|
|
53
59
|
return undefined;
|
|
54
60
|
}
|
|
55
|
-
const result = await connect(wallet, [
|
|
56
|
-
{
|
|
57
|
-
namespace: 'DISCOVER_MODE',
|
|
58
|
-
network,
|
|
59
|
-
},
|
|
60
|
-
]);
|
|
61
|
+
const result = await connect(wallet, [namespace]);
|
|
61
62
|
|
|
62
63
|
return result;
|
|
63
64
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropTypes } from './ConfirmWalletsModal.types';
|
|
2
2
|
import type { ConnectedWallet } from '../../store/slices/wallets';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Wallet } from '../../types';
|
|
4
4
|
|
|
5
5
|
import { i18n } from '@lingui/core';
|
|
6
6
|
import {
|
|
@@ -17,7 +17,6 @@ import { useNavigate } from 'react-router-dom';
|
|
|
17
17
|
|
|
18
18
|
import { WIDGET_UI_ID } from '../../constants';
|
|
19
19
|
import { getQuoteErrorMessage } from '../../constants/errors';
|
|
20
|
-
import { getQuoteUpdateWarningMessage } from '../../constants/warnings';
|
|
21
20
|
import { useAppStore } from '../../store/AppStore';
|
|
22
21
|
import { useQuoteStore } from '../../store/quote';
|
|
23
22
|
import { getBlockchainShortNameFor } from '../../utils/meta';
|
|
@@ -58,9 +57,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
58
57
|
const [showMoreWalletFor, setShowMoreWalletFor] = useState('');
|
|
59
58
|
const [balanceWarnings, setBalanceWarnings] = useState<string[]>([]);
|
|
60
59
|
const [error, setError] = useState('');
|
|
61
|
-
const [quoteWarning, setQuoteWarning] = useState<
|
|
62
|
-
ConfirmSwapWarnings['quoteUpdate'] | null
|
|
63
|
-
>(null);
|
|
64
60
|
|
|
65
61
|
const [isCustomDestinationOpen, setCustomDestinationOpen] = useState(
|
|
66
62
|
!!customDestination
|
|
@@ -224,7 +220,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
224
220
|
const onConfirmWallets = async () => {
|
|
225
221
|
setBalanceWarnings([]);
|
|
226
222
|
setError('');
|
|
227
|
-
setQuoteWarning(null);
|
|
228
223
|
|
|
229
224
|
const result = await onCheckBalance?.({
|
|
230
225
|
selectedWallets: selectableWallets.filter((wallet) => wallet.selected),
|
|
@@ -234,9 +229,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
234
229
|
if (warnings?.balance?.messages) {
|
|
235
230
|
setBalanceWarnings(warnings.balance.messages);
|
|
236
231
|
}
|
|
237
|
-
|
|
238
|
-
setQuoteWarning(warnings.quoteUpdate);
|
|
239
|
-
}
|
|
232
|
+
|
|
240
233
|
if (result.error) {
|
|
241
234
|
setError(getQuoteErrorMessage(result.error));
|
|
242
235
|
}
|
|
@@ -416,16 +409,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
416
409
|
<Divider size={12} />
|
|
417
410
|
</>
|
|
418
411
|
)}
|
|
419
|
-
{quoteWarning && (
|
|
420
|
-
<>
|
|
421
|
-
<Alert
|
|
422
|
-
variant="alarm"
|
|
423
|
-
type="warning"
|
|
424
|
-
title={getQuoteUpdateWarningMessage(quoteWarning)}
|
|
425
|
-
/>
|
|
426
|
-
<Divider size={12} />
|
|
427
|
-
</>
|
|
428
|
-
)}
|
|
429
412
|
<Wallets>
|
|
430
413
|
{quoteWallets.map((requiredWallet, index) => {
|
|
431
414
|
const blockchain = blockchains.find(
|
|
@@ -149,7 +149,7 @@ export function WalletList(props: PropTypes) {
|
|
|
149
149
|
const isDisconnected = wallet.state === WalletState.DISCONNECTED;
|
|
150
150
|
const isConnectedButDifferentThanTargetNamespace = wallet.isHub
|
|
151
151
|
? !conciseAddress
|
|
152
|
-
: !!wallet.
|
|
152
|
+
: !!wallet.needsNamespace && !conciseAddress;
|
|
153
153
|
|
|
154
154
|
if (isDisconnected) {
|
|
155
155
|
setSelectedWalletToConnect(wallet);
|
|
@@ -44,30 +44,50 @@ export function makeAlerts(
|
|
|
44
44
|
return alertInfo;
|
|
45
45
|
}
|
|
46
46
|
if (warning) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
switch (warning.type) {
|
|
48
|
+
case QuoteWarningType.HIGH_VALUE_LOSS: {
|
|
49
|
+
const warningLevel = getPriceImpactLevel(warning.priceImpact);
|
|
50
|
+
if (warningLevel === 'high') {
|
|
51
|
+
alertInfo.alertType = 'error';
|
|
52
|
+
}
|
|
53
|
+
alertInfo.action = 'show-info';
|
|
54
|
+
alertInfo.title = errorMessages().highValueLossError.title;
|
|
55
|
+
break;
|
|
51
56
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
case QuoteWarningType.EXCESSIVE_OUTPUT_AMOUNT_CHANGE: {
|
|
58
|
+
alertInfo.title = i18n.t({
|
|
59
|
+
id: 'Output amount changed by {percentageChange}% (${usdValueChange}).',
|
|
60
|
+
values: {
|
|
61
|
+
percentageChange: warning.percentageChange,
|
|
62
|
+
usdValueChange: warning.usdValueChange,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case QuoteWarningType.UNKNOWN_PRICE: {
|
|
68
|
+
alertInfo.title = errorMessages().unknownPriceError.title;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case QuoteWarningType.INSUFFICIENT_SLIPPAGE: {
|
|
72
|
+
alertInfo.title = i18n.t({
|
|
73
|
+
id: 'We recommend you to increase slippage to at least {minRequiredSlippage} for this route.',
|
|
74
|
+
values: {
|
|
75
|
+
minRequiredSlippage: warning.minRequiredSlippage,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
alertInfo.action = 'change-settings';
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case QuoteWarningType.HIGH_SLIPPAGE: {
|
|
82
|
+
alertInfo.title = i18n.t('Caution, your slippage is high.');
|
|
83
|
+
alertInfo.action = 'change-settings';
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
default:
|
|
88
|
+
break;
|
|
70
89
|
}
|
|
90
|
+
|
|
71
91
|
return alertInfo;
|
|
72
92
|
}
|
|
73
93
|
return null;
|
|
@@ -3,7 +3,7 @@ import type { ModalState } from '../SwapDetailsModal';
|
|
|
3
3
|
|
|
4
4
|
import { i18n } from '@lingui/core';
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
getCurrentNamespaceOfOrNull,
|
|
7
7
|
getCurrentStep,
|
|
8
8
|
getRelatedWalletOrNull,
|
|
9
9
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
@@ -138,8 +138,8 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
138
138
|
const lastConvertedTokenInFailedSwap =
|
|
139
139
|
getLastConvertedTokenInFailedSwap(swap);
|
|
140
140
|
|
|
141
|
-
const
|
|
142
|
-
?
|
|
141
|
+
const currentStepNamespace = currentStep
|
|
142
|
+
? getCurrentNamespaceOfOrNull(swap, currentStep)
|
|
143
143
|
: null;
|
|
144
144
|
const currentStepWallet = currentStep
|
|
145
145
|
? getRelatedWalletOrNull(swap, currentStep)
|
|
@@ -154,16 +154,19 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
154
154
|
const showSwitchNetwork =
|
|
155
155
|
currentStepNetworkStatus ===
|
|
156
156
|
PendingSwapNetworkStatus.WaitingForNetworkChange &&
|
|
157
|
-
!!
|
|
157
|
+
!!currentStepNamespace &&
|
|
158
158
|
!!currentStepWallet?.walletType &&
|
|
159
159
|
(isMobileWallet(currentStepWallet.walletType) ||
|
|
160
|
-
canSwitchNetworkTo(
|
|
160
|
+
canSwitchNetworkTo(
|
|
161
|
+
currentStepWallet.walletType,
|
|
162
|
+
currentStepNamespace.network
|
|
163
|
+
));
|
|
161
164
|
|
|
162
165
|
const switchNetwork = showSwitchNetwork
|
|
163
166
|
? connect.bind(null, currentStepWallet.walletType, [
|
|
164
167
|
{
|
|
165
|
-
namespace:
|
|
166
|
-
network:
|
|
168
|
+
namespace: currentStepNamespace.namespace,
|
|
169
|
+
network: currentStepNamespace.network,
|
|
167
170
|
},
|
|
168
171
|
])
|
|
169
172
|
: undefined;
|
|
@@ -12,6 +12,7 @@ import React from 'react';
|
|
|
12
12
|
import { useNavigate } from 'react-router-dom';
|
|
13
13
|
|
|
14
14
|
import { WIDGET_UI_ID } from '../../constants';
|
|
15
|
+
import { useUiStore } from '../../store/ui';
|
|
15
16
|
import { getContainer } from '../../utils/common';
|
|
16
17
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
17
18
|
|
|
@@ -31,6 +32,7 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
|
|
|
31
32
|
diagnosisUrl,
|
|
32
33
|
} = props;
|
|
33
34
|
const navigate = useNavigate();
|
|
35
|
+
const { showProfileBanner } = useUiStore();
|
|
34
36
|
|
|
35
37
|
return (
|
|
36
38
|
<WatermarkedModal
|
|
@@ -72,21 +74,32 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
|
|
|
72
74
|
description={description}
|
|
73
75
|
/>
|
|
74
76
|
)}
|
|
75
|
-
<Divider size={
|
|
77
|
+
<Divider size={30} />
|
|
76
78
|
{status === 'success' && (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
<>
|
|
80
|
+
{showProfileBanner && (
|
|
81
|
+
<>
|
|
82
|
+
<img
|
|
83
|
+
src={
|
|
84
|
+
'https://raw.githubusercontent.com/rango-exchange/assets/main/banners/widget/profile.png'
|
|
85
|
+
}
|
|
86
|
+
alt="Profile Banner"
|
|
87
|
+
/>
|
|
88
|
+
<Divider size={30} />
|
|
89
|
+
</>
|
|
90
|
+
)}
|
|
91
|
+
<Button
|
|
92
|
+
id="widget-swap-details-modal-done-btn"
|
|
93
|
+
variant="contained"
|
|
94
|
+
type="primary"
|
|
95
|
+
size="large"
|
|
96
|
+
onClick={() => {
|
|
97
|
+
const home = '../../';
|
|
98
|
+
navigate(home);
|
|
99
|
+
}}>
|
|
87
100
|
{i18n.t('Done')}
|
|
88
|
-
</
|
|
89
|
-
|
|
101
|
+
</Button>
|
|
102
|
+
</>
|
|
90
103
|
)}
|
|
91
104
|
<Divider size={12} />
|
|
92
105
|
{diagnosisUrl && (
|
|
@@ -12,8 +12,7 @@ import {
|
|
|
12
12
|
Radio,
|
|
13
13
|
RadioRoot,
|
|
14
14
|
} from '@rango-dev/ui';
|
|
15
|
-
import {
|
|
16
|
-
import React, { useMemo, useState } from 'react';
|
|
15
|
+
import React, { useState } from 'react';
|
|
17
16
|
|
|
18
17
|
import { useAppStore } from '../../store/AppStore';
|
|
19
18
|
import { WalletImageContainer } from '../HeaderButtons/HeaderButtons.styles';
|
|
@@ -23,25 +22,14 @@ import { getBlockchainLogo } from './Namespaces.helpers';
|
|
|
23
22
|
import { NamespaceList } from './Namespaces.styles';
|
|
24
23
|
|
|
25
24
|
export function Namespaces(props: PropTypes) {
|
|
26
|
-
const {
|
|
25
|
+
const { targetWallet } = props.value;
|
|
26
|
+
const singleNamespace = targetWallet.needsNamespace?.selection === 'single';
|
|
27
|
+
const providerImage = targetWallet.image;
|
|
27
28
|
|
|
28
29
|
const [selectedNamespaces, setSelectedNamespaces] = useState<Namespace[]>([]);
|
|
29
30
|
|
|
30
31
|
const blockchains = useAppStore().blockchains();
|
|
31
32
|
|
|
32
|
-
const namespacesInfo = useMemo(
|
|
33
|
-
() =>
|
|
34
|
-
availableNamespaces?.map((namespace) => ({
|
|
35
|
-
name: namespace,
|
|
36
|
-
logo: getBlockchainLogo(
|
|
37
|
-
blockchains,
|
|
38
|
-
namespaces[namespace].mainBlockchain
|
|
39
|
-
),
|
|
40
|
-
title: namespaces[namespace].title,
|
|
41
|
-
})),
|
|
42
|
-
[availableNamespaces]
|
|
43
|
-
);
|
|
44
|
-
|
|
45
33
|
const onSelect = (namespace: Namespace) => {
|
|
46
34
|
if (singleNamespace) {
|
|
47
35
|
setSelectedNamespaces([namespace]);
|
|
@@ -83,28 +71,33 @@ export function Namespaces(props: PropTypes) {
|
|
|
83
71
|
<NamespaceList>
|
|
84
72
|
{wrapRadioRoot(
|
|
85
73
|
<>
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
<Checkbox
|
|
100
|
-
checked={selectedNamespaces.includes(
|
|
101
|
-
namespaceInfoItem.name
|
|
102
|
-
)}
|
|
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}
|
|
103
87
|
/>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
+
})}
|
|
108
101
|
</>
|
|
109
102
|
)}
|
|
110
103
|
</NamespaceList>
|
package/src/constants/quote.ts
CHANGED
|
@@ -32,6 +32,29 @@ export const HIGH_PRIORITY_TAGS: TagValue[] = [
|
|
|
32
32
|
'HIGH_IMPACT',
|
|
33
33
|
];
|
|
34
34
|
|
|
35
|
+
export type Criteria = {
|
|
36
|
+
threshold: number;
|
|
37
|
+
minInput: number;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const PERCENT_MULTIPLIER = 100;
|
|
35
41
|
export const GAS_FEE_MAX = 30;
|
|
36
42
|
export const ROUTE_TIME_MAX = 15;
|
|
37
43
|
export const SECONDS_IN_MINUTE = 60;
|
|
44
|
+
export const HIGH_FEE_THRESHOLD_USD = 30;
|
|
45
|
+
|
|
46
|
+
export const HIGH_VALUE_LOSS_CRITERIA: Criteria[] = [
|
|
47
|
+
{ threshold: -10, minInput: 400 },
|
|
48
|
+
{ threshold: -5, minInput: 1000 },
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
export const OUTPUT_CHANGE_WARNING_CRITERIA: Criteria[] = [
|
|
52
|
+
{
|
|
53
|
+
threshold: -1,
|
|
54
|
+
minInput: 1000,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
threshold: -2,
|
|
58
|
+
minInput: 500,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
@@ -7,8 +7,7 @@ import { Quote } from '../../components/Quote';
|
|
|
7
7
|
import { QuoteSkeleton } from '../../components/QuoteSkeleton';
|
|
8
8
|
import { useQuoteStore } from '../../store/quote';
|
|
9
9
|
import { QuoteErrorType } from '../../types';
|
|
10
|
-
import {
|
|
11
|
-
import { calcOutputUsdValue } from '../../utils/swap';
|
|
10
|
+
import { getUsdOutputFrom } from '../../utils/swap';
|
|
12
11
|
|
|
13
12
|
import { QuoteContainer } from './QuoteInfo.styles';
|
|
14
13
|
|
|
@@ -28,17 +27,12 @@ export function QuoteInfo(props: PropTypes) {
|
|
|
28
27
|
fullExpandedMode = false,
|
|
29
28
|
container,
|
|
30
29
|
} = props;
|
|
31
|
-
const { inputAmount, inputUsdValue
|
|
30
|
+
const { inputAmount, inputUsdValue } = useQuoteStore();
|
|
32
31
|
|
|
33
32
|
const outputAmount = !!quote?.outputAmount
|
|
34
33
|
? new BigNumber(quote?.outputAmount)
|
|
35
34
|
: null;
|
|
36
|
-
const outputUsdValue =
|
|
37
|
-
? calcOutputUsdValue(
|
|
38
|
-
quote?.outputAmount,
|
|
39
|
-
getQuoteToTokenUsdPrice(quote) || toToken?.usdPrice
|
|
40
|
-
)
|
|
41
|
-
: null;
|
|
35
|
+
const outputUsdValue = quote ? getUsdOutputFrom(quote) : null;
|
|
42
36
|
|
|
43
37
|
const noResult =
|
|
44
38
|
error &&
|
|
@@ -7,6 +7,10 @@ import type { ProvidersOptions } from '../../utils/providers';
|
|
|
7
7
|
import type { LegacyEventHandler as EventHandler } from '@rango-dev/wallets-core/legacy';
|
|
8
8
|
import type { PropsWithChildren } from 'react';
|
|
9
9
|
|
|
10
|
+
import {
|
|
11
|
+
legacyFormatAddressWithNetwork as formatAddressWithNetwork,
|
|
12
|
+
legacyReadAccountAddress as readAccountAddress,
|
|
13
|
+
} from '@rango-dev/wallets-core/legacy';
|
|
10
14
|
import { Events, Provider } from '@rango-dev/wallets-react';
|
|
11
15
|
import { type Network } from '@rango-dev/wallets-shared';
|
|
12
16
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
@@ -36,9 +40,11 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
36
40
|
updateSettings,
|
|
37
41
|
fetch: fetchMeta,
|
|
38
42
|
fetchStatus,
|
|
43
|
+
removeBalancesForWallet,
|
|
39
44
|
} = useAppStore();
|
|
40
45
|
const blockchains = useAppStore().blockchains();
|
|
41
|
-
const { newWalletConnected, disconnectWallet } =
|
|
46
|
+
const { newWalletConnected, disconnectWallet, connectedWallets } =
|
|
47
|
+
useAppStore();
|
|
42
48
|
const config = useAppStore().config;
|
|
43
49
|
|
|
44
50
|
const walletOptions: ProvidersOptions = {
|
|
@@ -75,9 +81,62 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
75
81
|
|
|
76
82
|
const onUpdateState: EventHandler = (type, event, value, state, meta) => {
|
|
77
83
|
if (event === Events.ACCOUNTS) {
|
|
84
|
+
const supportedChainNames: Network[] | null =
|
|
85
|
+
walletAndSupportedChainsNames(meta.supportedBlockchains);
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
* When a wallet is connecting to an evm account, we will consider it as the account exists on other evm-compatible blockchains
|
|
89
|
+
* To get their balances.
|
|
90
|
+
*
|
|
91
|
+
* The logic here is for handling switching account functionality in wallets. when a wallet is switching to another account
|
|
92
|
+
* we need to clean the balances for old accounts.
|
|
93
|
+
*/
|
|
94
|
+
const evmAccounts: string[] = [];
|
|
95
|
+
const nonEvmAccounts: string[] = [];
|
|
96
|
+
|
|
97
|
+
value?.forEach((account: string) => {
|
|
98
|
+
const { network } = readAccountAddress(account);
|
|
99
|
+
if (evmBasedChainNames.includes(network)) {
|
|
100
|
+
evmAccounts.push(account);
|
|
101
|
+
} else {
|
|
102
|
+
nonEvmAccounts.push(account);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const previousAccounts = connectedWallets
|
|
107
|
+
.filter((wallet) => wallet.walletType === type)
|
|
108
|
+
.map((wallet) =>
|
|
109
|
+
formatAddressWithNetwork(wallet.address, wallet.chain)
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
if (previousAccounts.length > 0) {
|
|
113
|
+
if (evmAccounts.length > 0) {
|
|
114
|
+
// We use same logic for removing as we use for adding.
|
|
115
|
+
const data = prepareAccountsForWalletStore(
|
|
116
|
+
type,
|
|
117
|
+
evmAccounts,
|
|
118
|
+
evmBasedChainNames,
|
|
119
|
+
supportedChainNames,
|
|
120
|
+
meta.isContractWallet
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
removeBalancesForWallet(type, {
|
|
124
|
+
chains: data.map((account) => account.chain),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (nonEvmAccounts.length > 0) {
|
|
129
|
+
removeBalancesForWallet(type, {
|
|
130
|
+
chains: nonEvmAccounts.map((account) => {
|
|
131
|
+
const { network } = readAccountAddress(account);
|
|
132
|
+
return network;
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// After cleaning up balances, it's time to add new accounts.
|
|
78
139
|
if (value) {
|
|
79
|
-
const supportedChainNames: Network[] | null =
|
|
80
|
-
walletAndSupportedChainsNames(meta.supportedBlockchains);
|
|
81
140
|
const data = prepareAccountsForWalletStore(
|
|
82
141
|
type,
|
|
83
142
|
value,
|
|
@@ -149,6 +208,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
149
208
|
onUpdateState={onUpdateState}
|
|
150
209
|
autoConnect={!!isActiveTab}
|
|
151
210
|
configs={{
|
|
211
|
+
wallets: config.wallets,
|
|
152
212
|
isExperimentalEnabled: isFeatureEnabled(
|
|
153
213
|
'experimentalWallet',
|
|
154
214
|
config.features
|
|
@@ -5,7 +5,7 @@ import type { PendingSwap } from 'rango-types/lib';
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
cancelSwap,
|
|
8
|
-
|
|
8
|
+
getCurrentNamespaceOfOrNull,
|
|
9
9
|
getCurrentStep,
|
|
10
10
|
getRelatedWalletOrNull,
|
|
11
11
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
@@ -66,7 +66,7 @@ export class WidgetHistory {
|
|
|
66
66
|
step: currentStep,
|
|
67
67
|
wallet: currentStep ? getRelatedWalletOrNull(swap, currentStep) : null,
|
|
68
68
|
network: currentStep
|
|
69
|
-
?
|
|
69
|
+
? getCurrentNamespaceOfOrNull(swap, currentStep)?.network
|
|
70
70
|
: null,
|
|
71
71
|
};
|
|
72
72
|
}
|