@rango-dev/widget-embedded 0.37.0 → 0.37.1-next.1
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/CHANGELOG.md +4 -0
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +1 -1
- package/dist/components/Quote/Quote.types.d.ts +2 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +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/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +2 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/constants/quote.d.ts +10 -0
- package/dist/constants/quote.d.ts.map +1 -1
- package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
- package/dist/containers/Inputs/Inputs.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.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +3 -3
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +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/useFetchCustomToken.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +2 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +3 -5
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.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 +2 -3
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.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/pages/Home.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/store/app.d.ts +2 -4
- package/dist/store/app.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/data.d.ts.map +1 -1
- package/dist/store/slices/types.d.ts +6 -0
- package/dist/store/slices/types.d.ts.map +1 -0
- package/dist/store/slices/wallets.d.ts +80 -0
- package/dist/store/slices/wallets.d.ts.map +1 -0
- package/dist/store/ui.d.ts +4 -0
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/utils/wallets.d.ts +17 -0
- package/dist/store/utils/wallets.d.ts.map +1 -0
- package/dist/types/config.d.ts +6 -3
- package/dist/types/config.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 +3 -7
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +8 -9
- 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/settings.d.ts +1 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +5 -5
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +12 -14
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +9 -9
- package/src/QueueManager.tsx +17 -11
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +5 -24
- package/src/components/ConfirmWalletsModal/WalletList.tsx +10 -7
- package/src/components/Layout/Layout.tsx +1 -3
- package/src/components/Quote/Quote.tsx +22 -3
- package/src/components/Quote/Quote.types.ts +2 -0
- package/src/components/Quote/QuoteCostDetails.styles.ts +0 -1
- package/src/components/Quote/QuoteCostDetails.tsx +23 -4
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +42 -22
- package/src/components/Quotes/Quotes.tsx +2 -3
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +14 -6
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +26 -13
- package/src/components/TokenList/TokenList.tsx +4 -27
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +2 -1
- package/src/components/WalletStatefulConnect/Namespaces.tsx +31 -38
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +1 -1
- package/src/constants/quote.ts +25 -0
- package/src/containers/ExpandedQuotes/ExpandedQuotes.styles.ts +1 -0
- package/src/containers/ExpandedQuotes/ExpandedQuotes.tsx +1 -1
- package/src/containers/Inputs/Inputs.tsx +20 -7
- package/src/containers/QuoteInfo/QuoteInfo.tsx +3 -9
- package/src/containers/Wallets/Wallets.tsx +82 -16
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +2 -2
- package/src/containers/WidgetInfo/WidgetInfo.tsx +10 -8
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +3 -3
- 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/useFetchCustomToken.ts +5 -0
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +50 -17
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +3 -5
- package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +7 -6
- package/src/hooks/useSwapInput.ts +3 -11
- package/src/hooks/useWalletList.ts +6 -8
- package/src/hooks/useWalletProviders/useWalletProviders.ts +8 -12
- package/src/index.ts +1 -1
- package/src/pages/ConfirmSwapPage.tsx +7 -15
- package/src/pages/Home.tsx +5 -3
- package/src/pages/SelectSwapItemsPage.tsx +1 -2
- package/src/store/app.ts +4 -4
- package/src/store/quote.ts +3 -13
- package/src/store/slices/config.ts +76 -0
- package/src/store/slices/data.test.ts +23 -1
- package/src/store/slices/data.ts +3 -2
- package/src/store/slices/types.ts +9 -0
- package/src/store/slices/wallets.ts +577 -0
- package/src/store/ui.ts +6 -0
- package/src/store/utils/wallets.ts +111 -0
- package/src/types/config.ts +7 -3
- package/src/types/quote.ts +10 -24
- package/src/types/wallets.ts +3 -7
- package/src/utils/providers.ts +88 -36
- package/src/utils/quote.ts +57 -45
- package/src/utils/settings.ts +4 -0
- package/src/utils/swap.ts +56 -37
- package/src/utils/wallets.ts +76 -141
- package/dist/constants/warnings.d.ts +0 -3
- package/dist/constants/warnings.d.ts.map +0 -1
- package/dist/hooks/useObserveBalanceChanges/index.d.ts +0 -2
- package/dist/hooks/useObserveBalanceChanges/index.d.ts.map +0 -1
- package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts +0 -4
- package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts.map +0 -1
- package/dist/store/wallets.d.ts +0 -66
- package/dist/store/wallets.d.ts.map +0 -1
- package/src/constants/warnings.ts +0 -26
- package/src/hooks/useObserveBalanceChanges/index.ts +0 -1
- package/src/hooks/useObserveBalanceChanges/useObserveBalanceChanges.ts +0 -68
- package/src/store/wallets.ts +0 -268
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.1-next.1",
|
|
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.41.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.41.0",
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.41.1-next.0",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.27.0",
|
|
32
|
-
"@rango-dev/signer-solana": "^0.35.0",
|
|
33
|
-
"@rango-dev/ui": "^0.43.0",
|
|
34
|
-
"@rango-dev/wallets-core": "^0.40.
|
|
35
|
-
"@rango-dev/wallets-react": "^0.27.0",
|
|
36
|
-
"@rango-dev/wallets-shared": "^0.41.0",
|
|
32
|
+
"@rango-dev/signer-solana": "^0.35.1-next.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",
|
|
@@ -54,4 +54,4 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|
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 {
|
|
@@ -15,7 +18,6 @@ import React, { useMemo } from 'react';
|
|
|
15
18
|
import { eventEmitter } from './services/eventEmitter';
|
|
16
19
|
import { useAppStore } from './store/AppStore';
|
|
17
20
|
import { useUiStore } from './store/ui';
|
|
18
|
-
import { useWalletsStore } from './store/wallets';
|
|
19
21
|
import { getConfig } from './utils/configs';
|
|
20
22
|
import { walletAndSupportedChainsNames } from './utils/wallets';
|
|
21
23
|
|
|
@@ -39,8 +41,8 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
39
41
|
});
|
|
40
42
|
}, [props.apiKey]);
|
|
41
43
|
|
|
42
|
-
const blockchains = useAppStore()
|
|
43
|
-
const
|
|
44
|
+
const { blockchains, connectedWallets } = useAppStore();
|
|
45
|
+
const blockchainsList = blockchains();
|
|
44
46
|
|
|
45
47
|
const wallets = {
|
|
46
48
|
blockchains: connectedWallets.map((wallet) => ({
|
|
@@ -49,18 +51,23 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
49
51
|
})),
|
|
50
52
|
};
|
|
51
53
|
|
|
52
|
-
const switchNetwork = async (
|
|
53
|
-
|
|
54
|
+
const switchNetwork = async (
|
|
55
|
+
wallet: WalletType,
|
|
56
|
+
namespace: TargetNamespace
|
|
57
|
+
) => {
|
|
58
|
+
if (!canSwitchNetworkTo(wallet, namespace.network)) {
|
|
54
59
|
return undefined;
|
|
55
60
|
}
|
|
56
|
-
|
|
61
|
+
const result = await connect(wallet, [namespace]);
|
|
62
|
+
|
|
63
|
+
return result;
|
|
57
64
|
};
|
|
58
65
|
|
|
59
66
|
const isMobileWallet = (walletType: WalletType): boolean =>
|
|
60
67
|
!!getWalletInfo(walletType).mobileWallet;
|
|
61
68
|
|
|
62
69
|
// TODO: this code copy & pasted from rango, should be refactored.
|
|
63
|
-
const allBlockchains =
|
|
70
|
+
const allBlockchains = blockchainsList
|
|
64
71
|
.filter((blockchain) => blockchain.enabled)
|
|
65
72
|
.reduce(
|
|
66
73
|
(blockchainsObj: any, blockchain) => (
|
|
@@ -68,7 +75,7 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
68
75
|
),
|
|
69
76
|
{}
|
|
70
77
|
);
|
|
71
|
-
const evmBasedChains =
|
|
78
|
+
const evmBasedChains = blockchainsList.filter(isEvmBlockchain);
|
|
72
79
|
const getSupportedChainNames = (type: WalletType) => {
|
|
73
80
|
const { supportedChains } = getWalletInfo(type);
|
|
74
81
|
return walletAndSupportedChainsNames(supportedChains);
|
|
@@ -88,7 +95,6 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
88
95
|
providers: allProviders,
|
|
89
96
|
switchNetwork,
|
|
90
97
|
canSwitchNetworkTo,
|
|
91
|
-
connect,
|
|
92
98
|
state,
|
|
93
99
|
isMobileWallet,
|
|
94
100
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropTypes } from './ConfirmWalletsModal.types';
|
|
2
|
-
import type { ConnectedWallet } from '../../store/wallets';
|
|
3
|
-
import type {
|
|
2
|
+
import type { ConnectedWallet } from '../../store/slices/wallets';
|
|
3
|
+
import type { Wallet } from '../../types';
|
|
4
4
|
|
|
5
5
|
import { i18n } from '@lingui/core';
|
|
6
6
|
import {
|
|
@@ -17,10 +17,8 @@ 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
|
-
import { useWalletsStore } from '../../store/wallets';
|
|
24
22
|
import { getBlockchainShortNameFor } from '../../utils/meta';
|
|
25
23
|
import { isConfirmSwapDisabled } from '../../utils/swap';
|
|
26
24
|
import { getQuoteWallets } from '../../utils/wallets';
|
|
@@ -54,15 +52,11 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
54
52
|
customDestination,
|
|
55
53
|
setCustomDestination,
|
|
56
54
|
} = useQuoteStore();
|
|
57
|
-
const { connectedWallets,
|
|
58
|
-
const { config } = useAppStore();
|
|
55
|
+
const { config, connectedWallets, setWalletsAsSelected } = useAppStore();
|
|
59
56
|
|
|
60
57
|
const [showMoreWalletFor, setShowMoreWalletFor] = useState('');
|
|
61
58
|
const [balanceWarnings, setBalanceWarnings] = useState<string[]>([]);
|
|
62
59
|
const [error, setError] = useState('');
|
|
63
|
-
const [quoteWarning, setQuoteWarning] = useState<
|
|
64
|
-
ConfirmSwapWarnings['quoteUpdate'] | null
|
|
65
|
-
>(null);
|
|
66
60
|
|
|
67
61
|
const [isCustomDestinationOpen, setCustomDestinationOpen] = useState(
|
|
68
62
|
!!customDestination
|
|
@@ -217,7 +211,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
217
211
|
const lastSelectedWallets = selectableWallets.filter(
|
|
218
212
|
(wallet) => wallet.selected
|
|
219
213
|
);
|
|
220
|
-
|
|
214
|
+
setWalletsAsSelected(lastSelectedWallets);
|
|
221
215
|
selectQuoteWallets(lastSelectedWallets);
|
|
222
216
|
setQuoteWalletConfirmed(true);
|
|
223
217
|
onClose();
|
|
@@ -226,7 +220,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
226
220
|
const onConfirmWallets = async () => {
|
|
227
221
|
setBalanceWarnings([]);
|
|
228
222
|
setError('');
|
|
229
|
-
setQuoteWarning(null);
|
|
230
223
|
|
|
231
224
|
const result = await onCheckBalance?.({
|
|
232
225
|
selectedWallets: selectableWallets.filter((wallet) => wallet.selected),
|
|
@@ -236,9 +229,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
236
229
|
if (warnings?.balance?.messages) {
|
|
237
230
|
setBalanceWarnings(warnings.balance.messages);
|
|
238
231
|
}
|
|
239
|
-
|
|
240
|
-
setQuoteWarning(warnings.quoteUpdate);
|
|
241
|
-
}
|
|
232
|
+
|
|
242
233
|
if (result.error) {
|
|
243
234
|
setError(getQuoteErrorMessage(result.error));
|
|
244
235
|
}
|
|
@@ -418,16 +409,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
418
409
|
<Divider size={12} />
|
|
419
410
|
</>
|
|
420
411
|
)}
|
|
421
|
-
{quoteWarning && (
|
|
422
|
-
<>
|
|
423
|
-
<Alert
|
|
424
|
-
variant="alarm"
|
|
425
|
-
type="warning"
|
|
426
|
-
title={getQuoteUpdateWarningMessage(quoteWarning)}
|
|
427
|
-
/>
|
|
428
|
-
<Divider size={12} />
|
|
429
|
-
</>
|
|
430
|
-
)}
|
|
431
412
|
<Wallets>
|
|
432
413
|
{quoteWallets.map((requiredWallet, index) => {
|
|
433
414
|
const blockchain = blockchains.find(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PropTypes } from './WalletList.type';
|
|
2
|
-
import type { Wallet
|
|
2
|
+
import type { Wallet } from '../../types';
|
|
3
|
+
import type { ExtendedModalWalletInfo } from '../../utils/wallets';
|
|
3
4
|
|
|
4
5
|
import { i18n } from '@lingui/core';
|
|
5
6
|
import { warn } from '@rango-dev/logging-core';
|
|
@@ -20,7 +21,6 @@ import {
|
|
|
20
21
|
import { useWalletList } from '../../hooks/useWalletList';
|
|
21
22
|
import { useAppStore } from '../../store/AppStore';
|
|
22
23
|
import { useUiStore } from '../../store/ui';
|
|
23
|
-
import { useWalletsStore } from '../../store/wallets';
|
|
24
24
|
import { getBlockchainDisplayNameFor } from '../../utils/meta';
|
|
25
25
|
import {
|
|
26
26
|
getAddress,
|
|
@@ -41,10 +41,9 @@ export function WalletList(props: PropTypes) {
|
|
|
41
41
|
const { chain, isSelected, selectWallet, limit, onShowMore } = props;
|
|
42
42
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
43
43
|
|
|
44
|
-
const connectedWallets =
|
|
45
|
-
const { blockchains } = useAppStore();
|
|
44
|
+
const { blockchains, connectedWallets } = useAppStore();
|
|
46
45
|
const [selectedWalletToConnect, setSelectedWalletToConnect] =
|
|
47
|
-
useState<
|
|
46
|
+
useState<ExtendedModalWalletInfo>();
|
|
48
47
|
const [experimentalChainWallet, setExperimentalChainWallet] =
|
|
49
48
|
useState<Wallet | null>(null);
|
|
50
49
|
const [showExperimentalChainModal, setShowExperimentalChainModal] =
|
|
@@ -57,7 +56,7 @@ export function WalletList(props: PropTypes) {
|
|
|
57
56
|
chain,
|
|
58
57
|
});
|
|
59
58
|
|
|
60
|
-
const [sortedList, setSortedList] = useState<
|
|
59
|
+
const [sortedList, setSortedList] = useState<ExtendedModalWalletInfo[]>(list);
|
|
61
60
|
const numberOfSupportedWallets = list.length;
|
|
62
61
|
const shouldShowMoreWallets = limit && numberOfSupportedWallets - limit > 0;
|
|
63
62
|
|
|
@@ -148,9 +147,13 @@ export function WalletList(props: PropTypes) {
|
|
|
148
147
|
|
|
149
148
|
const onSelectableWalletClick = async () => {
|
|
150
149
|
const isDisconnected = wallet.state === WalletState.DISCONNECTED;
|
|
150
|
+
const isConnectedButDifferentThanTargetNamespace = wallet.isHub
|
|
151
|
+
? !conciseAddress
|
|
152
|
+
: !!wallet.needsNamespace && !conciseAddress;
|
|
153
|
+
|
|
151
154
|
if (isDisconnected) {
|
|
152
155
|
setSelectedWalletToConnect(wallet);
|
|
153
|
-
} else if (
|
|
156
|
+
} else if (isConnectedButDifferentThanTargetNamespace) {
|
|
154
157
|
// wallet is connected on a different namespace
|
|
155
158
|
await handleDisconnect(wallet.type);
|
|
156
159
|
|
|
@@ -13,7 +13,6 @@ import { useNavigateBack } from '../../hooks/useNavigateBack';
|
|
|
13
13
|
import { useTheme } from '../../hooks/useTheme';
|
|
14
14
|
import { useAppStore } from '../../store/AppStore';
|
|
15
15
|
import { tabManager, useUiStore } from '../../store/ui';
|
|
16
|
-
import { useWalletsStore } from '../../store/wallets';
|
|
17
16
|
import { getContainer } from '../../utils/common';
|
|
18
17
|
import { getPendingSwaps } from '../../utils/queue';
|
|
19
18
|
import { isFeatureHidden } from '../../utils/settings';
|
|
@@ -28,9 +27,8 @@ import { Container, Content, Footer, LayoutContainer } from './Layout.styles';
|
|
|
28
27
|
function Layout(props: PropsWithChildren<PropTypes>) {
|
|
29
28
|
const { connectHeightObserver, disconnectHeightObserver } = useIframe();
|
|
30
29
|
const { children, header, footer, height = 'fixed' } = props;
|
|
31
|
-
const { fetchStatus } = useAppStore();
|
|
30
|
+
const { fetchStatus, connectedWallets } = useAppStore();
|
|
32
31
|
const [openRefreshModal, setOpenRefreshModal] = useState(false);
|
|
33
|
-
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
34
32
|
const {
|
|
35
33
|
config: { features, theme },
|
|
36
34
|
} = useAppStore();
|
|
@@ -17,7 +17,11 @@ import {
|
|
|
17
17
|
import BigNumber from 'bignumber.js';
|
|
18
18
|
import React, { useRef, useState } from 'react';
|
|
19
19
|
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
GAS_FEE_MAX,
|
|
22
|
+
ROUTE_TIME_MAX,
|
|
23
|
+
SECONDS_IN_MINUTE,
|
|
24
|
+
} from '../../constants/quote';
|
|
21
25
|
import {
|
|
22
26
|
GAS_FEE_MAX_DECIMALS,
|
|
23
27
|
GAS_FEE_MIN_DECIMALS,
|
|
@@ -311,7 +315,8 @@ export function Quote(props: QuoteProps) {
|
|
|
311
315
|
const container = propContainer || getContainer();
|
|
312
316
|
const sortedQuoteTags = sortTags(props.quote.tags || []);
|
|
313
317
|
const showAllRoutesButton = !!onClickAllRoutes;
|
|
314
|
-
const
|
|
318
|
+
const totalDurationSeconds = totalArrivalTime(quote?.swaps);
|
|
319
|
+
const totalTime = roundedSecondsToString(totalDurationSeconds);
|
|
315
320
|
const totalFee = getTotalFeeInUsd(quote?.swaps ?? [], findToken);
|
|
316
321
|
const fee = numberToString(
|
|
317
322
|
totalFee,
|
|
@@ -320,6 +325,8 @@ export function Quote(props: QuoteProps) {
|
|
|
320
325
|
);
|
|
321
326
|
|
|
322
327
|
const feeWarning = totalFee.gte(new BigNumber(GAS_FEE_MAX));
|
|
328
|
+
const timeWarning =
|
|
329
|
+
totalDurationSeconds / SECONDS_IN_MINUTE >= ROUTE_TIME_MAX;
|
|
323
330
|
|
|
324
331
|
return fullExpandedMode ? (
|
|
325
332
|
<FullExpandedQuote
|
|
@@ -329,7 +336,18 @@ export function Quote(props: QuoteProps) {
|
|
|
329
336
|
tooltipContainer={getExpanded()}
|
|
330
337
|
steps={steps}
|
|
331
338
|
tags={sortedQuoteTags}
|
|
332
|
-
|
|
339
|
+
quoteCost={
|
|
340
|
+
<QuoteCostDetails
|
|
341
|
+
quote={quote}
|
|
342
|
+
fullExpandedMode
|
|
343
|
+
time={totalTime}
|
|
344
|
+
fee={fee}
|
|
345
|
+
feeWarning={feeWarning}
|
|
346
|
+
timeWarning={timeWarning}
|
|
347
|
+
showModalFee={showModalFee}
|
|
348
|
+
steps={numberOfSteps}
|
|
349
|
+
/>
|
|
350
|
+
}
|
|
333
351
|
percentageChange={percentageChange}
|
|
334
352
|
warningLevel={priceImpactWarningLevel}
|
|
335
353
|
outputPrice={{
|
|
@@ -368,6 +386,7 @@ export function Quote(props: QuoteProps) {
|
|
|
368
386
|
time={totalTime}
|
|
369
387
|
fee={fee}
|
|
370
388
|
feeWarning={feeWarning}
|
|
389
|
+
timeWarning={timeWarning}
|
|
371
390
|
showModalFee={showModalFee}
|
|
372
391
|
steps={numberOfSteps}
|
|
373
392
|
/>
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
USD_VALUE_MAX_DECIMALS,
|
|
22
22
|
USD_VALUE_MIN_DECIMALS,
|
|
23
23
|
} from '../../constants/routing';
|
|
24
|
-
import { getContainer } from '../../utils/common';
|
|
24
|
+
import { getContainer, getExpanded } from '../../utils/common';
|
|
25
25
|
import { numberToString } from '../../utils/numbers';
|
|
26
26
|
import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
|
|
27
27
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
@@ -57,9 +57,18 @@ const NonPayableFee = (props: { fee: BigNumber; label: string }) => {
|
|
|
57
57
|
export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
58
58
|
const [open, setOpen] = useState<boolean>(false);
|
|
59
59
|
const [openCollapse, setOpenCollapse] = useState<boolean>(false);
|
|
60
|
-
const {
|
|
60
|
+
const {
|
|
61
|
+
steps,
|
|
62
|
+
quote,
|
|
63
|
+
fee,
|
|
64
|
+
time,
|
|
65
|
+
feeWarning,
|
|
66
|
+
timeWarning,
|
|
67
|
+
showModalFee,
|
|
68
|
+
fullExpandedMode = false,
|
|
69
|
+
} = props;
|
|
61
70
|
const swaps = quote?.swaps ?? [];
|
|
62
|
-
const container = getContainer();
|
|
71
|
+
const container = fullExpandedMode ? getExpanded() : getContainer();
|
|
63
72
|
|
|
64
73
|
const feesGroup = getFeesGroup(swaps);
|
|
65
74
|
|
|
@@ -76,6 +85,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
76
85
|
}
|
|
77
86
|
fee={fee}
|
|
78
87
|
feeWarning={feeWarning}
|
|
88
|
+
timeWarning={timeWarning}
|
|
79
89
|
time={time}
|
|
80
90
|
steps={steps}
|
|
81
91
|
tooltipGas={showModalFee ? i18n.t('View more info') : undefined}
|
|
@@ -85,8 +95,17 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
85
95
|
<WatermarkedModal
|
|
86
96
|
container={container}
|
|
87
97
|
open={open}
|
|
98
|
+
anchor={fullExpandedMode ? 'center' : 'bottom'}
|
|
99
|
+
styles={{
|
|
100
|
+
container: {
|
|
101
|
+
maxWidth: fullExpandedMode ? '484px' : 'unset',
|
|
102
|
+
},
|
|
103
|
+
}}
|
|
88
104
|
header={
|
|
89
|
-
<ModalHeader
|
|
105
|
+
<ModalHeader
|
|
106
|
+
style={{
|
|
107
|
+
textAlign: fullExpandedMode ? 'left' : 'center',
|
|
108
|
+
}}>
|
|
90
109
|
<Typography variant="title" size="medium">
|
|
91
110
|
{i18n.t('Gas & Fee Explanation')}
|
|
92
111
|
</Typography>
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Result } from '../../hooks/useStatefulConnect';
|
|
2
2
|
import type { WalletInfoWithExtra } from '../../types';
|
|
3
|
-
import type { Namespace } from '@rango-dev/wallets-
|
|
3
|
+
import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
|
|
4
4
|
|
|
5
5
|
import { Divider } from '@rango-dev/ui';
|
|
6
6
|
import React, { useEffect, useRef, useState } from 'react';
|
|
@@ -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,13 +154,21 @@ 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
|
-
? connect.bind(null, currentStepWallet.walletType,
|
|
166
|
+
? connect.bind(null, currentStepWallet.walletType, [
|
|
167
|
+
{
|
|
168
|
+
namespace: currentStepNamespace.namespace,
|
|
169
|
+
network: currentStepNamespace.network,
|
|
170
|
+
},
|
|
171
|
+
])
|
|
164
172
|
: undefined;
|
|
165
173
|
|
|
166
174
|
const stepMessage = getSwapMessages(swap, currentStep);
|
|
@@ -15,7 +15,7 @@ export interface SwapAlertsProps extends WaningAlertsProps {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface WaningAlertsProps extends FailedAlertsProps {
|
|
18
|
-
switchNetwork: (() => Promise<ConnectResult>) | undefined;
|
|
18
|
+
switchNetwork: (() => Promise<ConnectResult[]>) | undefined;
|
|
19
19
|
showNetworkModal: PendingSwapNetworkStatus | null | undefined;
|
|
20
20
|
setNetworkModal: (network: ModalState) => void;
|
|
21
21
|
}
|
|
@@ -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 && (
|