@rango-dev/widget-embedded 0.0.0-experimental-e5c14f42-20260614 → 0.0.0-experimental-e17e4765-20260615
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/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/CustomDestination/CustomDestination.d.ts.map +1 -1
- package/dist/components/CustomTokenModal/CustomTokenModal.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts +1 -1
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/NamespaceDetachedItem.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +2 -2
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/index.d.ts +0 -1
- package/dist/components/WalletStatefulConnect/index.d.ts.map +1 -1
- package/dist/constants/wallets.d.ts +1 -2
- package/dist/constants/wallets.d.ts.map +1 -1
- package/dist/containers/Settings/Lists.d.ts.map +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts.map +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +1 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncNotifications/useSyncNotifications.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.helpers.d.ts +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.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/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.d.ts +0 -1
- package/dist/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemPage/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +1 -1
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/wallets.d.ts +2 -4
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/store/utils/wallets.d.ts +2 -2
- package/dist/store/utils/wallets.d.ts.map +1 -1
- package/dist/test-utils/fixtures.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/event.d.ts +6 -141
- package/dist/types/event.d.ts.map +1 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/events.d.ts +5 -16
- package/dist/utils/events.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +4 -0
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +2 -1
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +0 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +11 -8
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +2 -53
- package/src/components/ConfirmWalletsModal/WalletList.tsx +16 -166
- package/src/components/CustomDestination/CustomDestination.tsx +0 -18
- package/src/components/CustomTokenModal/CustomTokenModal.tsx +7 -2
- package/src/components/Quote/QuoteCostDetails.tsx +0 -8
- package/src/components/Slippage/Slippage.tsx +0 -21
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +0 -6
- package/src/components/TokenList/TokenList.tsx +11 -8
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +1 -1
- package/src/components/WalletStatefulConnect/Detached.tsx +1 -1
- package/src/components/WalletStatefulConnect/Detached.types.ts +1 -1
- package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +7 -1
- package/src/components/WalletStatefulConnect/Namespaces.tsx +1 -1
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +2 -2
- package/src/components/WalletStatefulConnect/index.ts +0 -1
- package/src/constants/wallets.ts +1 -3
- package/src/containers/Settings/Lists.tsx +1 -13
- package/src/containers/Wallets/useUpdates.ts +1 -9
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +45 -3316
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +26 -228
- package/src/hooks/useStatefulConnect/useStatefulConnect.state.ts +1 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +1 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +1 -1
- package/src/hooks/useSwapInput.ts +1 -46
- package/src/hooks/useSyncNotifications/useSyncNotifications.ts +1 -26
- package/src/hooks/useWalletList.ts +6 -63
- package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +1 -1
- package/src/pages/ConfirmSwapPage.tsx +1 -12
- package/src/pages/Home.tsx +4 -33
- package/src/pages/LiquiditySourcePage.tsx +0 -24
- package/src/pages/SelectBlockchainPage.tsx +0 -10
- package/src/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.ts +0 -13
- package/src/pages/SelectSwapItemPage/SelectSwapItemsPage.tsx +0 -27
- package/src/pages/SwapDetailsPage.tsx +0 -6
- package/src/store/slices/config.ts +1 -1
- package/src/store/slices/wallets.ts +4 -12
- package/src/store/utils/wallets.ts +2 -2
- package/src/test-utils/fixtures.ts +0 -39
- package/src/types/config.ts +1 -1
- package/src/types/event.ts +10 -182
- package/src/utils/common.ts +0 -1
- package/src/utils/events.ts +6 -51
- package/src/utils/meta.ts +13 -0
- package/src/utils/providers.ts +2 -2
- package/src/utils/wallets.ts +0 -32
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts +0 -3
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts +0 -9
- package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts +0 -8
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts +0 -6
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts.map +0 -1
- package/dist/services/walletConnectionSource.d.ts +0 -10
- package/dist/services/walletConnectionSource.d.ts.map +0 -1
- package/dist/utils/eventPayloads.d.ts +0 -8
- package/dist/utils/eventPayloads.d.ts.map +0 -1
- package/src/components/CustomTokenModal/CustomTokenModal.helpers.ts +0 -19
- package/src/components/WalletStatefulConnect/ExperimentalChain.tsx +0 -39
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.ts +0 -53
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.tsx +0 -36
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.types.ts +0 -5
- package/src/services/walletConnectionSource.ts +0 -41
- package/src/utils/eventPayloads.ts +0 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-e17e4765-20260615",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -22,18 +22,21 @@
|
|
|
22
22
|
"test:coverage": "vitest run --coverage"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@hub3js/core": "^0.60.1",
|
|
26
|
+
"@hub3js/namespaces": "^0.1.1",
|
|
27
|
+
"@hub3js/std": "^0.1.1",
|
|
25
28
|
"@lingui/core": "4.2.1",
|
|
26
29
|
"@lingui/react": "4.2.1",
|
|
27
30
|
"@rango-dev/logging-core": "^0.12.1",
|
|
28
|
-
"@rango-dev/provider-all": "^0.
|
|
31
|
+
"@rango-dev/provider-all": "^0.0.0-experimental-e17e4765-20260615",
|
|
29
32
|
"@rango-dev/queue-manager-core": "^0.33.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.
|
|
33
|
+
"@rango-dev/queue-manager-rango-preset": "^0.0.0-experimental-e17e4765-20260615",
|
|
31
34
|
"@rango-dev/queue-manager-react": "^0.33.0",
|
|
32
35
|
"@rango-dev/signer-solana": "^0.48.0",
|
|
33
|
-
"@rango-dev/ui": "^0.
|
|
34
|
-
"@rango-dev/wallets-core": "^0.
|
|
35
|
-
"@rango-dev/wallets-react": "^0.
|
|
36
|
-
"@rango-dev/wallets-shared": "^0.
|
|
36
|
+
"@rango-dev/ui": "^0.0.0-experimental-e17e4765-20260615",
|
|
37
|
+
"@rango-dev/wallets-core": "^0.0.0-experimental-e17e4765-20260615",
|
|
38
|
+
"@rango-dev/wallets-react": "^0.0.0-experimental-e17e4765-20260615",
|
|
39
|
+
"@rango-dev/wallets-shared": "^0.0.0-experimental-e17e4765-20260615",
|
|
37
40
|
"bignumber.js": "^9.1.1",
|
|
38
41
|
"copy-to-clipboard": "^3.3.3",
|
|
39
42
|
"crypto-browserify": "^3.12.1",
|
|
@@ -63,4 +66,4 @@
|
|
|
63
66
|
"publishConfig": {
|
|
64
67
|
"access": "public"
|
|
65
68
|
}
|
|
66
|
-
}
|
|
69
|
+
}
|
|
@@ -12,21 +12,13 @@ import {
|
|
|
12
12
|
MessageBox,
|
|
13
13
|
Typography,
|
|
14
14
|
} from '@rango-dev/ui';
|
|
15
|
-
import React, {
|
|
16
|
-
useCallback,
|
|
17
|
-
useEffect,
|
|
18
|
-
useMemo,
|
|
19
|
-
useRef,
|
|
20
|
-
useState,
|
|
21
|
-
} from 'react';
|
|
15
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
22
16
|
import { useNavigate } from 'react-router-dom';
|
|
23
17
|
|
|
24
18
|
import { WIDGET_UI_ID } from '../../constants';
|
|
25
19
|
import { getQuoteErrorMessage } from '../../constants/errors';
|
|
26
20
|
import { useAppStore } from '../../store/AppStore';
|
|
27
21
|
import { useQuoteStore } from '../../store/quote';
|
|
28
|
-
import { UiEventTypes } from '../../types';
|
|
29
|
-
import { emitUiEvent } from '../../utils/events';
|
|
30
22
|
import { getBlockchainShortNameFor } from '../../utils/meta';
|
|
31
23
|
import { isConfirmSwapDisabled } from '../../utils/swap';
|
|
32
24
|
import { getQuoteChains } from '../../utils/wallets';
|
|
@@ -219,10 +211,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
219
211
|
const lastSelectedWallets = selectableWallets.filter(
|
|
220
212
|
(wallet) => wallet.selected
|
|
221
213
|
);
|
|
222
|
-
emitUiEvent({
|
|
223
|
-
type: UiEventTypes.SWAP_WALLETS_CONFIRMED,
|
|
224
|
-
payload: { routeId: selectedQuote?.requestId ?? '' },
|
|
225
|
-
});
|
|
226
214
|
setWalletsAsSelected(lastSelectedWallets);
|
|
227
215
|
selectQuoteWallets(lastSelectedWallets);
|
|
228
216
|
setQuoteWalletConfirmed(true);
|
|
@@ -313,39 +301,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
313
301
|
}
|
|
314
302
|
}, [connectedWallets, nextSelectedWallets]);
|
|
315
303
|
|
|
316
|
-
const routeId = selectedQuote?.requestId ?? '';
|
|
317
|
-
const hasReportedModalShown = useRef(false);
|
|
318
|
-
|
|
319
|
-
useEffect(() => {
|
|
320
|
-
if (open && !hasReportedModalShown.current) {
|
|
321
|
-
hasReportedModalShown.current = true;
|
|
322
|
-
const pendingChains = requiredChains.filter(
|
|
323
|
-
(chain) =>
|
|
324
|
-
!connectedWallets.some(
|
|
325
|
-
(connectedWallet) => connectedWallet.chain === chain
|
|
326
|
-
)
|
|
327
|
-
);
|
|
328
|
-
emitUiEvent({
|
|
329
|
-
type: UiEventTypes.SWAP_WALLETS_MODAL_SHOWN,
|
|
330
|
-
payload: {
|
|
331
|
-
chainsRequired: requiredChains.length,
|
|
332
|
-
chainsPending: pendingChains.length,
|
|
333
|
-
},
|
|
334
|
-
});
|
|
335
|
-
} else if (!open) {
|
|
336
|
-
hasReportedModalShown.current = false;
|
|
337
|
-
}
|
|
338
|
-
}, [open, requiredChains, connectedWallets]);
|
|
339
|
-
|
|
340
|
-
useEffect(() => {
|
|
341
|
-
if (isInsufficientBalanceModalOpen) {
|
|
342
|
-
emitUiEvent({
|
|
343
|
-
type: UiEventTypes.GAS_WARNING_SHOWN,
|
|
344
|
-
payload: { routeId },
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}, [isInsufficientBalanceModalOpen, routeId]);
|
|
348
|
-
|
|
349
304
|
const modalContainer = document.getElementById(
|
|
350
305
|
WIDGET_UI_ID.SWAP_BOX_ID
|
|
351
306
|
) as HTMLDivElement;
|
|
@@ -428,13 +383,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
428
383
|
size="large"
|
|
429
384
|
type="primary"
|
|
430
385
|
fullWidth
|
|
431
|
-
onClick={
|
|
432
|
-
emitUiEvent({
|
|
433
|
-
type: UiEventTypes.GAS_WARNING_BYPASSED,
|
|
434
|
-
payload: { routeId },
|
|
435
|
-
});
|
|
436
|
-
onConfirmBalance();
|
|
437
|
-
}}>
|
|
386
|
+
onClick={onConfirmBalance}>
|
|
438
387
|
{i18n.t('Proceed anyway')}
|
|
439
388
|
</Button>
|
|
440
389
|
</MessageBox>
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { PropTypes } from './WalletList.type';
|
|
2
|
-
import type { Wallet } from '../../types';
|
|
3
2
|
import type { ExtendedModalWalletInfo } from '../../utils/wallets';
|
|
4
3
|
|
|
5
4
|
import { i18n } from '@lingui/core';
|
|
6
5
|
import { warn } from '@rango-dev/logging-core';
|
|
7
6
|
import {
|
|
8
|
-
Divider,
|
|
9
7
|
makeInfo,
|
|
10
8
|
SelectableWallet,
|
|
11
9
|
Typography,
|
|
@@ -13,42 +11,24 @@ import {
|
|
|
13
11
|
} from '@rango-dev/ui';
|
|
14
12
|
import React, { useEffect, useState } from 'react';
|
|
15
13
|
|
|
16
|
-
import { useWallets } from '../..';
|
|
17
|
-
import { WIDGET_UI_ID } from '../../constants';
|
|
18
14
|
import { useWalletList } from '../../hooks/useWalletList';
|
|
19
15
|
import { useAppStore } from '../../store/AppStore';
|
|
20
16
|
import { useUiStore } from '../../store/ui';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
getAddress,
|
|
24
|
-
getConciseAddress,
|
|
25
|
-
isExperimentalChain,
|
|
26
|
-
} from '../../utils/wallets';
|
|
27
|
-
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
17
|
+
import { getAddress, getConciseAddress } from '../../utils/wallets';
|
|
28
18
|
import { StatefulConnectModal } from '../StatefulConnectModal';
|
|
29
|
-
import { ExperimentalChain } from '../WalletStatefulConnect';
|
|
30
|
-
import { ExperimentalChainStatus } from '../WalletStatefulConnect/ExperimentalChainStatus';
|
|
31
19
|
|
|
32
20
|
import { ShowMoreWallets } from './ConfirmWallets.styles';
|
|
33
21
|
|
|
34
22
|
const ACCOUNT_ADDRESS_MAX_CHARACTERS = 7;
|
|
35
|
-
const TIME_TO_CLOSE_MODAL = 3_000;
|
|
36
23
|
|
|
37
24
|
export function WalletList(props: PropTypes) {
|
|
38
25
|
const { chain, quoteChains, isSelected, selectWallet, limit, onShowMore } =
|
|
39
26
|
props;
|
|
40
27
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
41
28
|
|
|
42
|
-
const {
|
|
29
|
+
const { connectedWallets } = useAppStore();
|
|
43
30
|
const [selectedWalletToConnect, setSelectedWalletToConnect] =
|
|
44
31
|
useState<ExtendedModalWalletInfo>();
|
|
45
|
-
const [experimentalChainWallet, setExperimentalChainWallet] =
|
|
46
|
-
useState<Wallet | null>(null);
|
|
47
|
-
const [showExperimentalChainModal, setShowExperimentalChainModal] =
|
|
48
|
-
useState(false);
|
|
49
|
-
const [addingExperimentalChainStatus, setAddingExperimentalChainStatus] =
|
|
50
|
-
useState<'in-progress' | 'completed' | 'rejected' | null>(null);
|
|
51
|
-
const { suggestAndConnect } = useWallets();
|
|
52
32
|
const { list } = useWalletList({
|
|
53
33
|
chain,
|
|
54
34
|
});
|
|
@@ -57,45 +37,6 @@ export function WalletList(props: PropTypes) {
|
|
|
57
37
|
const numberOfSupportedWallets = list.length;
|
|
58
38
|
const shouldShowMoreWallets = limit && numberOfSupportedWallets - limit > 0;
|
|
59
39
|
|
|
60
|
-
const addExperimentalChain = async (wallet: Wallet) => {
|
|
61
|
-
setShowExperimentalChainModal(false);
|
|
62
|
-
setAddingExperimentalChainStatus('in-progress');
|
|
63
|
-
try {
|
|
64
|
-
// 1. Finding wallet with namespaces info.
|
|
65
|
-
const walletWithNamespace = list.find(
|
|
66
|
-
(wallet) => wallet.type === wallet.type
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
/*
|
|
70
|
-
* 2. Getting namespaces info.
|
|
71
|
-
* Legacy and hub have different structure to handle each situation.
|
|
72
|
-
*/
|
|
73
|
-
const needsNamespace = walletWithNamespace?.isHub
|
|
74
|
-
? walletWithNamespace.properties?.find(
|
|
75
|
-
(item) => item.name === 'namespaces'
|
|
76
|
-
)?.value
|
|
77
|
-
: walletWithNamespace?.needsNamespace;
|
|
78
|
-
|
|
79
|
-
// 3. Finding target namespace.
|
|
80
|
-
const allBlockChains = blockchains();
|
|
81
|
-
const namespace = needsNamespace?.data.find((ns) =>
|
|
82
|
-
ns
|
|
83
|
-
.getSupportedChains(allBlockChains)
|
|
84
|
-
.some((chain) => chain.name === wallet.chain)
|
|
85
|
-
);
|
|
86
|
-
if (!namespace) {
|
|
87
|
-
throw new Error('Requested chain is not supported');
|
|
88
|
-
}
|
|
89
|
-
await suggestAndConnect(wallet.walletType, {
|
|
90
|
-
namespace: namespace.value,
|
|
91
|
-
network: wallet.chain,
|
|
92
|
-
});
|
|
93
|
-
setAddingExperimentalChainStatus('completed');
|
|
94
|
-
} catch {
|
|
95
|
-
setAddingExperimentalChainStatus('rejected');
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
40
|
useEffect(() => {
|
|
100
41
|
setSortedList((sortedList) => {
|
|
101
42
|
const selectedWalletIndex = list.findIndex((wallet) =>
|
|
@@ -115,29 +56,6 @@ export function WalletList(props: PropTypes) {
|
|
|
115
56
|
});
|
|
116
57
|
}, [JSON.stringify(list)]);
|
|
117
58
|
|
|
118
|
-
const modalContainer = document.getElementById(
|
|
119
|
-
WIDGET_UI_ID.SWAP_BOX_ID
|
|
120
|
-
) as HTMLDivElement;
|
|
121
|
-
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
let timeout: ReturnType<typeof setTimeout> | null = null;
|
|
124
|
-
if (
|
|
125
|
-
addingExperimentalChainStatus === 'completed' ||
|
|
126
|
-
addingExperimentalChainStatus === 'rejected'
|
|
127
|
-
) {
|
|
128
|
-
timeout = setTimeout(
|
|
129
|
-
() => setAddingExperimentalChainStatus(null),
|
|
130
|
-
TIME_TO_CLOSE_MODAL
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return () => {
|
|
135
|
-
if (timeout) {
|
|
136
|
-
clearTimeout(timeout);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}, [addingExperimentalChainStatus]);
|
|
140
|
-
|
|
141
59
|
return (
|
|
142
60
|
<>
|
|
143
61
|
{sortedList.slice(0, limit).map((wallet) => {
|
|
@@ -155,35 +73,11 @@ export function WalletList(props: PropTypes) {
|
|
|
155
73
|
const isConnectedButDifferentThanTargetNamespace =
|
|
156
74
|
isConnected && !!wallet.needsNamespace && !conciseAddress;
|
|
157
75
|
|
|
158
|
-
const experimentalChain = isExperimentalChain(blockchains(), chain);
|
|
159
|
-
|
|
160
|
-
const experimentalChainNotAdded = !connectedWallets.find(
|
|
161
|
-
(connectedWallet) =>
|
|
162
|
-
connectedWallet.walletType === wallet.type &&
|
|
163
|
-
connectedWallet.chain === chain
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const couldAddExperimentalChain =
|
|
167
|
-
experimentalChain &&
|
|
168
|
-
experimentalChainNotAdded &&
|
|
169
|
-
wallet.state === WalletState.CONNECTED;
|
|
170
|
-
|
|
171
76
|
const onSelectableWalletClick = async () => {
|
|
172
77
|
const isDisconnected = wallet.state === WalletState.DISCONNECTED;
|
|
173
78
|
|
|
174
|
-
if (
|
|
175
|
-
isDisconnected ||
|
|
176
|
-
(isConnectedButDifferentThanTargetNamespace &&
|
|
177
|
-
!couldAddExperimentalChain)
|
|
178
|
-
) {
|
|
79
|
+
if (isDisconnected || isConnectedButDifferentThanTargetNamespace) {
|
|
179
80
|
setSelectedWalletToConnect(wallet);
|
|
180
|
-
} else if (couldAddExperimentalChain) {
|
|
181
|
-
setExperimentalChainWallet({
|
|
182
|
-
walletType: wallet.type,
|
|
183
|
-
chain,
|
|
184
|
-
address: address ?? '',
|
|
185
|
-
});
|
|
186
|
-
setShowExperimentalChainModal(true);
|
|
187
81
|
} else {
|
|
188
82
|
selectWallet({
|
|
189
83
|
walletType: wallet.type,
|
|
@@ -196,12 +90,7 @@ export function WalletList(props: PropTypes) {
|
|
|
196
90
|
const info = makeInfo(wallet.state);
|
|
197
91
|
|
|
198
92
|
const getWalletDescription = () => {
|
|
199
|
-
if (
|
|
200
|
-
return i18n.t({
|
|
201
|
-
id: 'Add {chain} chain',
|
|
202
|
-
values: { chain },
|
|
203
|
-
});
|
|
204
|
-
} else if (isConnectedButDifferentThanTargetNamespace) {
|
|
93
|
+
if (isConnectedButDifferentThanTargetNamespace) {
|
|
205
94
|
return i18n.t('Chain not connected');
|
|
206
95
|
} else if (conciseAddress) {
|
|
207
96
|
return conciseAddress;
|
|
@@ -223,57 +112,17 @@ export function WalletList(props: PropTypes) {
|
|
|
223
112
|
return info.color;
|
|
224
113
|
};
|
|
225
114
|
|
|
226
|
-
const blockchainDisplayName: string | undefined =
|
|
227
|
-
experimentalChainWallet?.chain
|
|
228
|
-
? getBlockchainDisplayNameFor(
|
|
229
|
-
experimentalChainWallet.chain,
|
|
230
|
-
blockchains()
|
|
231
|
-
)
|
|
232
|
-
: undefined;
|
|
233
115
|
return (
|
|
234
|
-
<
|
|
235
|
-
{
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
id="widget-wallets-list-experimental-chain-container"
|
|
245
|
-
displayName={blockchainDisplayName}
|
|
246
|
-
onConfirm={() => {
|
|
247
|
-
void addExperimentalChain(experimentalChainWallet);
|
|
248
|
-
}}
|
|
249
|
-
/>
|
|
250
|
-
</WatermarkedModal>
|
|
251
|
-
)}
|
|
252
|
-
{addingExperimentalChainStatus && (
|
|
253
|
-
<WatermarkedModal
|
|
254
|
-
id="widget-wallets-list-experimental-chain-watermarked-modal"
|
|
255
|
-
open={!!addingExperimentalChainStatus}
|
|
256
|
-
onClose={setAddingExperimentalChainStatus.bind(null, null)}
|
|
257
|
-
container={modalContainer}>
|
|
258
|
-
<ExperimentalChainStatus
|
|
259
|
-
status={addingExperimentalChainStatus}
|
|
260
|
-
displayName={blockchainDisplayName}
|
|
261
|
-
image={wallet.image}
|
|
262
|
-
/>
|
|
263
|
-
<Divider direction="vertical" size={32} />
|
|
264
|
-
</WatermarkedModal>
|
|
265
|
-
)}
|
|
266
|
-
<SelectableWallet
|
|
267
|
-
key={wallet.type}
|
|
268
|
-
id="widget-wallets-list-selectable-wallet-btn"
|
|
269
|
-
description={getWalletDescription()}
|
|
270
|
-
descriptionColor={getWalletDescriptionColor()}
|
|
271
|
-
onClick={onSelectableWalletClick}
|
|
272
|
-
selected={isSelected(wallet.type, chain)}
|
|
273
|
-
disabled={!isActiveTab}
|
|
274
|
-
{...wallet}
|
|
275
|
-
/>
|
|
276
|
-
</React.Fragment>
|
|
116
|
+
<SelectableWallet
|
|
117
|
+
key={wallet.type}
|
|
118
|
+
id="widget-wallets-list-selectable-wallet-btn"
|
|
119
|
+
description={getWalletDescription()}
|
|
120
|
+
descriptionColor={getWalletDescriptionColor()}
|
|
121
|
+
onClick={onSelectableWalletClick}
|
|
122
|
+
selected={isSelected(wallet.type, chain)}
|
|
123
|
+
disabled={!isActiveTab}
|
|
124
|
+
{...wallet}
|
|
125
|
+
/>
|
|
277
126
|
);
|
|
278
127
|
})}
|
|
279
128
|
<StatefulConnectModal
|
|
@@ -301,7 +150,8 @@ export function WalletList(props: PropTypes) {
|
|
|
301
150
|
<ShowMoreWallets
|
|
302
151
|
selected={false}
|
|
303
152
|
onClick={onShowMore}
|
|
304
|
-
id="widget-wallets-list-show-more-wallets-btn"
|
|
153
|
+
id="widget-wallets-list-show-more-wallets-btn"
|
|
154
|
+
>
|
|
305
155
|
<Typography variant="label" size="medium">
|
|
306
156
|
{i18n.t('Show more wallets')}
|
|
307
157
|
<Typography variant="label" size="medium" color="$primary">
|
|
@@ -16,8 +16,6 @@ import React, { useEffect, useRef } from 'react';
|
|
|
16
16
|
|
|
17
17
|
import { useAppStore } from '../../store/AppStore';
|
|
18
18
|
import { useQuoteStore } from '../../store/quote';
|
|
19
|
-
import { UiEventTypes } from '../../types';
|
|
20
|
-
import { emitUiEvent } from '../../utils/events';
|
|
21
19
|
import {
|
|
22
20
|
getBlockchainDisplayNameFor,
|
|
23
21
|
isValidTokenAddress,
|
|
@@ -96,22 +94,6 @@ export function CustomDestination(props: PropTypes) {
|
|
|
96
94
|
}
|
|
97
95
|
}, [configDestination]);
|
|
98
96
|
|
|
99
|
-
const lastReportedDestination = useRef<string | null>(null);
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (!customDestination) {
|
|
102
|
-
lastReportedDestination.current = null;
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const isValid = open && isValidTokenAddress(blockchain, customDestination);
|
|
106
|
-
if (isValid && lastReportedDestination.current !== customDestination) {
|
|
107
|
-
lastReportedDestination.current = customDestination;
|
|
108
|
-
emitUiEvent({
|
|
109
|
-
type: UiEventTypes.DESTINATION_ADDRESS_SET,
|
|
110
|
-
payload: { destinationChain: blockchain.name },
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}, [customDestination, open, blockchain]);
|
|
114
|
-
|
|
115
97
|
return (
|
|
116
98
|
<Container>
|
|
117
99
|
<CustomCollapsible
|
|
@@ -13,10 +13,10 @@ import React from 'react';
|
|
|
13
13
|
|
|
14
14
|
import { DEFAULT_TOKEN_IMAGE_SRC } from '../../constants/customTokens';
|
|
15
15
|
import { getContainer } from '../../utils/common';
|
|
16
|
+
import { createTokenExplorerUrl } from '../../utils/meta';
|
|
16
17
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
17
18
|
|
|
18
19
|
import { CUSTOM_TOKEN_LEARN_MORE_LINK } from './CustomTokenModal.constants';
|
|
19
|
-
import { generateExplorerLink } from './CustomTokenModal.helpers';
|
|
20
20
|
import {
|
|
21
21
|
Container,
|
|
22
22
|
FlexCenteredContainer,
|
|
@@ -29,7 +29,12 @@ const MAX_SYMBOL_LENGTH_THRESHOLD = 9;
|
|
|
29
29
|
export function CustomTokenModal(props: PropTypes) {
|
|
30
30
|
const { open, onClose, token, onExit, onSubmitClick, blockchain } = props;
|
|
31
31
|
|
|
32
|
-
const explorerLink =
|
|
32
|
+
const explorerLink = token.address
|
|
33
|
+
? createTokenExplorerUrl({
|
|
34
|
+
contractAddress: token.address,
|
|
35
|
+
blockchainMeta: blockchain,
|
|
36
|
+
})
|
|
37
|
+
: undefined;
|
|
33
38
|
|
|
34
39
|
const onClickLearnMore = () =>
|
|
35
40
|
window.open(CUSTOM_TOKEN_LEARN_MORE_LINK, '_blank');
|
|
@@ -21,9 +21,7 @@ import {
|
|
|
21
21
|
USD_VALUE_MAX_DECIMALS,
|
|
22
22
|
USD_VALUE_MIN_DECIMALS,
|
|
23
23
|
} from '../../constants/routing';
|
|
24
|
-
import { UiEventTypes } from '../../types';
|
|
25
24
|
import { getContainer, getExpanded } from '../../utils/common';
|
|
26
|
-
import { emitUiEvent } from '../../utils/events';
|
|
27
25
|
import { numberToString } from '../../utils/numbers';
|
|
28
26
|
import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
|
|
29
27
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
@@ -86,12 +84,6 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
86
84
|
showModalFee
|
|
87
85
|
? (e) => {
|
|
88
86
|
e.stopPropagation();
|
|
89
|
-
if (!open && quote) {
|
|
90
|
-
emitUiEvent({
|
|
91
|
-
type: UiEventTypes.ROUTE_FEE_VIEWED,
|
|
92
|
-
payload: { routeId: quote.requestId },
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
87
|
setOpen(!open);
|
|
96
88
|
}
|
|
97
89
|
: undefined
|
|
@@ -12,9 +12,7 @@ import React from 'react';
|
|
|
12
12
|
|
|
13
13
|
import { MAX_SLIPPAGE, SLIPPAGES } from '../../constants/swapSettings';
|
|
14
14
|
import { useAppStore } from '../../store/AppStore';
|
|
15
|
-
import { UiEventTypes } from '../../types';
|
|
16
15
|
import { getContainer } from '../../utils/common';
|
|
17
|
-
import { emitUiEvent } from '../../utils/events';
|
|
18
16
|
import { getSlippageValidation } from '../../utils/settings';
|
|
19
17
|
import { isValidCurrencyFormat } from '../../utils/validation';
|
|
20
18
|
|
|
@@ -33,23 +31,6 @@ export function Slippage() {
|
|
|
33
31
|
const slippageValidation =
|
|
34
32
|
customSlippage !== null ? getSlippageValidation(customSlippage) : null;
|
|
35
33
|
|
|
36
|
-
/** Effective slippage before a change, used as the previous value in events. */
|
|
37
|
-
const effectiveSlippage = customSlippage ?? slippage;
|
|
38
|
-
|
|
39
|
-
const emitSlippageChanged = (previousValue: number, newValue: number) => {
|
|
40
|
-
if (previousValue === newValue) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
emitUiEvent({
|
|
44
|
-
type: UiEventTypes.SETTINGS_CHANGED,
|
|
45
|
-
payload: {
|
|
46
|
-
settingName: 'slippage',
|
|
47
|
-
previousValue: String(previousValue),
|
|
48
|
-
newValue: String(newValue),
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
34
|
const onSlippageValueChange = (
|
|
54
35
|
event: React.ChangeEvent<HTMLInputElement>
|
|
55
36
|
) => {
|
|
@@ -62,12 +43,10 @@ export function Slippage() {
|
|
|
62
43
|
if (parsedValue > MAX_SLIPPAGE) {
|
|
63
44
|
slippage = MAX_SLIPPAGE;
|
|
64
45
|
}
|
|
65
|
-
emitSlippageChanged(effectiveSlippage, slippage);
|
|
66
46
|
setCustomSlippage(slippage);
|
|
67
47
|
};
|
|
68
48
|
|
|
69
49
|
const onClickSlippageChip = (slippageItem: number) => {
|
|
70
|
-
emitSlippageChanged(effectiveSlippage, slippageItem);
|
|
71
50
|
if (customSlippage !== null) {
|
|
72
51
|
setCustomSlippage(null);
|
|
73
52
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Result } from '../../hooks/useStatefulConnect';
|
|
2
2
|
import type { WalletInfoWithExtra } from '../../types';
|
|
3
|
-
import type { Namespace } from '@
|
|
3
|
+
import type { Namespace } from '@hub3js/namespaces';
|
|
4
4
|
|
|
5
5
|
import { Divider } from '@rango-dev/ui';
|
|
6
6
|
import React, { useEffect, useRef, useState } from 'react';
|
|
@@ -34,9 +34,7 @@ import {
|
|
|
34
34
|
import { useAppStore } from '../../store/AppStore';
|
|
35
35
|
import { useNotificationStore } from '../../store/notification';
|
|
36
36
|
import { useQuoteStore } from '../../store/quote';
|
|
37
|
-
import { UiEventTypes } from '../../types';
|
|
38
37
|
import { getContainer } from '../../utils/common';
|
|
39
|
-
import { emitUiEvent } from '../../utils/events';
|
|
40
38
|
import {
|
|
41
39
|
numberToString,
|
|
42
40
|
roundedSecondsToString,
|
|
@@ -406,10 +404,6 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
406
404
|
type="primary"
|
|
407
405
|
size="large"
|
|
408
406
|
onClick={() => {
|
|
409
|
-
emitUiEvent({
|
|
410
|
-
type: UiEventTypes.SWAP_RETRIED,
|
|
411
|
-
payload: { routeId: swap.requestId },
|
|
412
|
-
});
|
|
413
407
|
const swapInput = createRetryQuote(swap, blockchains, findToken);
|
|
414
408
|
retry(swapInput);
|
|
415
409
|
setTimeout(() => {
|
|
@@ -25,7 +25,7 @@ import { useAppStore } from '../../store/AppStore';
|
|
|
25
25
|
import { useQuoteStore } from '../../store/quote';
|
|
26
26
|
import { createTintsAndShades } from '../../utils/colors';
|
|
27
27
|
import { getContainer } from '../../utils/common';
|
|
28
|
-
import { findBlockchain } from '../../utils/meta';
|
|
28
|
+
import { createTokenExplorerUrl, findBlockchain } from '../../utils/meta';
|
|
29
29
|
import { formatBalance } from '../../utils/wallets';
|
|
30
30
|
import { ImportCustomToken } from '../ImportCustomToken';
|
|
31
31
|
|
|
@@ -262,6 +262,13 @@ export function TokenList(props: PropTypes) {
|
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
+
const url = address
|
|
266
|
+
? createTokenExplorerUrl({
|
|
267
|
+
contractAddress: address,
|
|
268
|
+
blockchainMeta: blockchain,
|
|
269
|
+
})
|
|
270
|
+
: undefined;
|
|
271
|
+
|
|
265
272
|
return (
|
|
266
273
|
<ListItemContainer>
|
|
267
274
|
<StyledListItemButton
|
|
@@ -292,9 +299,7 @@ export function TokenList(props: PropTypes) {
|
|
|
292
299
|
</ImageSection>
|
|
293
300
|
}
|
|
294
301
|
title={
|
|
295
|
-
|
|
296
|
-
!!token.name ||
|
|
297
|
-
(!token.name && !address) ? (
|
|
302
|
+
!!token.name || (!token.name && !address) ? (
|
|
298
303
|
<Title>
|
|
299
304
|
<Typography variant="title" size="xmedium">
|
|
300
305
|
{token.symbol}
|
|
@@ -321,16 +326,14 @@ export function TokenList(props: PropTypes) {
|
|
|
321
326
|
typeof token !== 'string' &&
|
|
322
327
|
!!blockchain.info &&
|
|
323
328
|
!!address &&
|
|
324
|
-
|
|
329
|
+
!!url
|
|
325
330
|
? renderDesc({
|
|
326
331
|
address,
|
|
327
332
|
token,
|
|
328
333
|
customCssForTag,
|
|
329
334
|
customCssForTagTitle,
|
|
330
335
|
name: token.name,
|
|
331
|
-
url
|
|
332
|
-
.split('{wallet}')
|
|
333
|
-
.join(address),
|
|
336
|
+
url,
|
|
334
337
|
})
|
|
335
338
|
: token.name || undefined
|
|
336
339
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropTypes } from './Detached.types';
|
|
2
|
+
import type { Namespace } from '@hub3js/namespaces';
|
|
2
3
|
import type { LegacyNamespaceMeta } from '@rango-dev/wallets-core/legacy';
|
|
3
|
-
import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
|
|
4
4
|
|
|
5
5
|
import { i18n } from '@lingui/core';
|
|
6
6
|
import {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
|
|
2
|
-
import type { Namespace } from '@
|
|
2
|
+
import type { Namespace } from '@hub3js/namespaces';
|
|
3
3
|
|
|
4
4
|
export interface PropTypes {
|
|
5
5
|
value: NeedsNamespacesState;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { NamespaceDetachedItemPropTypes } from './Namespaces.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
+
import { debug } from '@rango-dev/logging-core';
|
|
4
5
|
import { Button, Spinner } from '@rango-dev/ui';
|
|
5
6
|
import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
6
7
|
|
|
@@ -39,7 +40,12 @@ export function NamespaceDetachedItem(props: NamespaceDetachedItemPropTypes) {
|
|
|
39
40
|
processingConnectAttempt.current = true;
|
|
40
41
|
await handleConnect(options);
|
|
41
42
|
} catch (error) {
|
|
42
|
-
|
|
43
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
44
|
+
debug(err, {
|
|
45
|
+
context: { namespace, state, connectOptions: options },
|
|
46
|
+
tags: { type: 'wallet-error' },
|
|
47
|
+
});
|
|
48
|
+
setError(err);
|
|
43
49
|
} finally {
|
|
44
50
|
processingConnectAttempt.current = false;
|
|
45
51
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
|
|
2
|
+
import type { NamespaceData } from '@hub3js/core/store';
|
|
3
|
+
import type { Namespace } from '@hub3js/namespaces';
|
|
2
4
|
import type { LegacyNamespaceMeta } from '@rango-dev/wallets-core/legacy';
|
|
3
|
-
import type { Namespace } from '@rango-dev/wallets-core/namespaces/common';
|
|
4
|
-
import type { NamespaceData } from '@rango-dev/wallets-core/store';
|
|
5
5
|
|
|
6
6
|
export interface PropTypes {
|
|
7
7
|
onConfirm: (namespaces: Namespace[]) => void;
|