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