@rango-dev/widget-embedded 0.0.0-experimental-1624fbb4-20260708 → 0.0.0-experimental-99f1781b-20260920
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 +47 -0
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/CustomDestination/CustomDestination.styles.d.ts +4 -4
- package/dist/components/CustomDestination/CustomDestination.styles.d.ts.map +1 -1
- package/dist/components/CustomTokenModal/CustomTokenModal.styles.d.ts +169 -169
- package/dist/components/CustomTokenModal/CustomTokenModal.styles.d.ts.map +1 -1
- package/dist/components/FilterSelector/FilterSelector.style.d.ts +1 -1
- package/dist/components/FilterSelector/FilterSelector.style.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/NamespaceItem/NamespaceItem.d.ts.map +1 -1
- package/dist/components/NamespaceItem/NamespaceItem.styles.d.ts +1 -1
- package/dist/components/NamespaceItem/NamespaceItem.styles.d.ts.map +1 -1
- package/dist/components/NamespaceItem/NamespaceItem.types.d.ts +3 -3
- package/dist/components/NamespaceItem/NamespaceItem.types.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +171 -171
- package/dist/components/Quote/Quote.styles.d.ts.map +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/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +169 -169
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts +168 -168
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts.map +1 -1
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts +2 -1
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +3 -3
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts +1 -1
- package/dist/components/SwapMetrics/SwapMetrics.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +2 -2
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +7 -3
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.test.d.ts +2 -0
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.test.d.ts.map +1 -0
- package/dist/components/WalletStatefulConnect/DerivationPath.styles.d.ts +169 -169
- package/dist/components/WalletStatefulConnect/DerivationPath.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Detached.types.d.ts +2 -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.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts +168 -168
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +1 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +3 -3
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +1 -0
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.constants.d.ts +3 -0
- package/dist/containers/Wallets/Wallets.constants.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.helpers.d.ts +2 -2
- package/dist/containers/Wallets/Wallets.helpers.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.helpers.test.d.ts +2 -0
- package/dist/containers/Wallets/Wallets.helpers.test.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.types.d.ts +6 -4
- package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.helpers.d.ts +5 -0
- package/dist/containers/WidgetProvider/WidgetProvider.helpers.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -1
- package/dist/hooks/useConnectWithLogging/index.d.ts +2 -0
- package/dist/hooks/useConnectWithLogging/index.d.ts.map +1 -0
- package/dist/hooks/useConnectWithLogging/useConnectWithLogging.d.ts +11 -0
- package/dist/hooks/useConnectWithLogging/useConnectWithLogging.d.ts.map +1 -0
- package/dist/hooks/useConnectWithLogging/useConnectWithLogging.test.d.ts +2 -0
- package/dist/hooks/useConnectWithLogging/useConnectWithLogging.test.d.ts.map +1 -0
- 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 +5 -4
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts +2 -2
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts +2 -3
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts.map +1 -1
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +4 -4
- package/dist/libs/connectLogging/connectLogging.constants.d.ts +9 -0
- package/dist/libs/connectLogging/connectLogging.constants.d.ts.map +1 -0
- package/dist/libs/connectLogging/connectLogging.d.ts +12 -0
- package/dist/libs/connectLogging/connectLogging.d.ts.map +1 -0
- package/dist/libs/connectLogging/connectLogging.test.d.ts +2 -0
- package/dist/libs/connectLogging/connectLogging.test.d.ts.map +1 -0
- package/dist/libs/connectLogging/connectLogging.types.d.ts +57 -0
- package/dist/libs/connectLogging/connectLogging.types.d.ts.map +1 -0
- package/dist/libs/connectLogging/index.d.ts +3 -0
- package/dist/libs/connectLogging/index.d.ts.map +1 -0
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +2 -2
- package/dist/store/AppStore.d.ts.map +1 -1
- package/dist/store/app.d.ts +2 -2
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +5 -5
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/test-utils/fixtures.d.ts +2 -2
- package/dist/test-utils/fixtures.d.ts.map +1 -1
- package/dist/types/config.d.ts +25 -4
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +1 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +14 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.test.d.ts +2 -0
- package/dist/utils/errors.test.d.ts.map +1 -0
- package/dist/utils/providers.d.ts +3 -6
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/QueueManager.tsx +17 -16
- package/src/components/ConfirmWalletsModal/WalletList.tsx +2 -2
- package/src/components/NamespaceItem/NamespaceItem.styles.ts +1 -0
- package/src/components/NamespaceItem/NamespaceItem.tsx +5 -1
- package/src/components/NamespaceItem/NamespaceItem.types.ts +3 -3
- package/src/components/Quote/Quote.tsx +0 -2
- package/src/components/Quote/Quote.types.ts +0 -2
- package/src/components/Quote/QuoteCostDetails.tsx +15 -4
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +4 -2
- package/src/components/SwapDetails/SwapDetails.tsx +17 -8
- package/src/components/SwapDetailsModal/SwapDetailsModal.ConnectWallet.tsx +12 -13
- package/src/components/SwapDetailsModal/SwapDetailsModal.InstallWallet.tsx +8 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +3 -3
- package/src/components/TokenList/LoadingTokenList.tsx +2 -2
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.test.ts +98 -0
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +14 -10
- package/src/components/WalletStatefulConnect/DerivationPath.tsx +14 -7
- package/src/components/WalletStatefulConnect/Detached.tsx +17 -10
- package/src/components/WalletStatefulConnect/Detached.types.ts +2 -1
- package/src/components/WalletStatefulConnect/NamespaceDetachedItem.tsx +2 -1
- package/src/components/WalletStatefulConnect/Namespaces.tsx +6 -12
- package/src/components/WalletStatefulConnect/Namespaces.types.tsx +3 -3
- package/src/constants/errors.ts +3 -0
- package/src/containers/Wallets/Wallets.constants.ts +14 -0
- package/src/containers/Wallets/Wallets.helpers.test.ts +67 -0
- package/src/containers/Wallets/Wallets.helpers.ts +9 -9
- package/src/containers/Wallets/Wallets.tsx +20 -3
- package/src/containers/Wallets/Wallets.types.ts +7 -7
- package/src/containers/Wallets/useUpdates.ts +7 -117
- package/src/containers/WidgetProvider/WidgetProvider.helpers.ts +10 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +12 -1
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +1 -1
- package/src/hooks/useConnectWithLogging/index.ts +1 -0
- package/src/hooks/useConnectWithLogging/useConnectWithLogging.test.ts +138 -0
- package/src/hooks/useConnectWithLogging/useConnectWithLogging.ts +36 -0
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +36 -29
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +6 -3
- package/src/hooks/useWalletList.ts +10 -7
- package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +3 -10
- package/src/hooks/useWalletProviders/useWalletProviders.ts +2 -2
- package/src/index.ts +10 -11
- package/src/libs/connectLogging/connectLogging.constants.ts +17 -0
- package/src/libs/connectLogging/connectLogging.test.ts +918 -0
- package/src/libs/connectLogging/connectLogging.ts +359 -0
- package/src/libs/connectLogging/connectLogging.types.ts +70 -0
- package/src/libs/connectLogging/index.ts +5 -0
- package/src/pages/WalletsPage.tsx +1 -0
- package/src/store/AppStore.tsx +4 -2
- package/src/store/app.ts +7 -2
- package/src/store/slices/config.ts +36 -25
- package/src/store/slices/data.test.ts +2 -2
- package/src/test-utils/fixtures.ts +6 -2
- package/src/types/config.ts +31 -4
- package/src/types/wallets.ts +1 -1
- package/src/utils/common.ts +6 -0
- package/src/utils/errors.test.ts +78 -0
- package/src/utils/errors.ts +69 -0
- package/src/utils/providers.ts +16 -50
- package/src/utils/swap.ts +8 -1
- package/src/utils/wallets.ts +12 -15
- package/dist/widget-embedded.build.json +0 -1
|
@@ -128,6 +128,7 @@ export function WalletList(props: PropTypes) {
|
|
|
128
128
|
<StatefulConnectModal
|
|
129
129
|
id="widget-wallets-list-stateful-connect-modal"
|
|
130
130
|
wallet={selectedWalletToConnect}
|
|
131
|
+
trigger="confirm-wallets-modal"
|
|
131
132
|
options={{ defaultSelectedChains: quoteChains || [chain] }}
|
|
132
133
|
onClose={() => {
|
|
133
134
|
setSelectedWalletToConnect(undefined);
|
|
@@ -150,8 +151,7 @@ export function WalletList(props: PropTypes) {
|
|
|
150
151
|
<ShowMoreWallets
|
|
151
152
|
selected={false}
|
|
152
153
|
onClick={onShowMore}
|
|
153
|
-
id="widget-wallets-list-show-more-wallets-btn"
|
|
154
|
-
>
|
|
154
|
+
id="widget-wallets-list-show-more-wallets-btn">
|
|
155
155
|
<Typography variant="label" size="medium">
|
|
156
156
|
{i18n.t('Show more wallets')}
|
|
157
157
|
<Typography variant="label" size="medium" color="$primary">
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PropTypes } from './NamespaceItem.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
+
import { getSupportedChainsFromNamespace } from '@rango-dev/internal-blockchains';
|
|
4
5
|
import {
|
|
5
6
|
ChevronDownIcon,
|
|
6
7
|
ChevronUpIcon,
|
|
@@ -32,7 +33,10 @@ export function NamespaceItem(props: PropTypes) {
|
|
|
32
33
|
|
|
33
34
|
useEffect(() => setErrorIsExpanded(false), [error]);
|
|
34
35
|
|
|
35
|
-
const supportedChains =
|
|
36
|
+
const supportedChains = getSupportedChainsFromNamespace(
|
|
37
|
+
namespace,
|
|
38
|
+
blockchains
|
|
39
|
+
);
|
|
36
40
|
const isSupportedChainsDisplayed =
|
|
37
41
|
!error && !connected && supportedChains.length > 1;
|
|
38
42
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NamespaceMeta } from '@rango-dev/wallets-react';
|
|
2
2
|
|
|
3
3
|
export type PropTypes = {
|
|
4
|
-
namespace:
|
|
4
|
+
namespace: NamespaceMeta;
|
|
5
5
|
error?: string;
|
|
6
6
|
suffix?: React.ReactNode;
|
|
7
7
|
connected?: boolean;
|
|
@@ -10,5 +10,5 @@ export type PropTypes = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export type NamespaceUnsupportedItemPropTypes = {
|
|
13
|
-
namespace:
|
|
13
|
+
namespace: NamespaceMeta;
|
|
14
14
|
};
|
|
@@ -362,7 +362,6 @@ export function Quote(props: QuoteProps) {
|
|
|
362
362
|
quote={quote}
|
|
363
363
|
fullExpandedMode
|
|
364
364
|
time={totalTime}
|
|
365
|
-
fee={totalFee}
|
|
366
365
|
feeWarning={feeWarning}
|
|
367
366
|
timeWarning={timeWarning}
|
|
368
367
|
showModalFee={showModalFee}
|
|
@@ -415,7 +414,6 @@ export function Quote(props: QuoteProps) {
|
|
|
415
414
|
<QuoteCostDetails
|
|
416
415
|
quote={quote}
|
|
417
416
|
time={totalTime}
|
|
418
|
-
fee={totalFee}
|
|
419
417
|
feeWarning={feeWarning}
|
|
420
418
|
timeWarning={timeWarning}
|
|
421
419
|
showModalFee={showModalFee}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { QuoteError, QuoteWarning, SelectedQuote } from '../../types';
|
|
2
2
|
import type { Step } from '@rango-dev/ui';
|
|
3
|
-
import type BigNumber from 'bignumber.js';
|
|
4
3
|
import type { ReactNode } from 'react';
|
|
5
4
|
|
|
6
5
|
export type QuoteProps = {
|
|
@@ -46,7 +45,6 @@ export type QuoteTriggerImagesProps = {
|
|
|
46
45
|
export type QuoteCostDetailsProps = {
|
|
47
46
|
quote: SelectedQuote | null;
|
|
48
47
|
steps: number;
|
|
49
|
-
fee: BigNumber;
|
|
50
48
|
time: string;
|
|
51
49
|
feeWarning?: boolean;
|
|
52
50
|
timeWarning?: boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { QuoteCostDetailsProps } from './Quote.types';
|
|
2
2
|
import type { NameOfFees } from '../../constants/quote';
|
|
3
|
-
import type BigNumber from 'bignumber.js';
|
|
4
3
|
|
|
5
4
|
import { i18n } from '@lingui/core';
|
|
6
5
|
import {
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
QuoteCost,
|
|
13
12
|
Typography,
|
|
14
13
|
} from '@rango-dev/ui';
|
|
14
|
+
import BigNumber from 'bignumber.js';
|
|
15
15
|
import React, { useState } from 'react';
|
|
16
16
|
|
|
17
17
|
import { getFeeLabel } from '../../constants/quote';
|
|
@@ -62,7 +62,6 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
62
62
|
const {
|
|
63
63
|
steps,
|
|
64
64
|
quote,
|
|
65
|
-
fee,
|
|
66
65
|
time,
|
|
67
66
|
feeWarning,
|
|
68
67
|
timeWarning,
|
|
@@ -73,8 +72,20 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
73
72
|
const container = fullExpandedMode ? getExpanded() : getContainer();
|
|
74
73
|
|
|
75
74
|
const feesGroup = getFeesGroup(swaps);
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* The "Total Payable Fee" must reflect only the fees the user actually pays
|
|
78
|
+
* (feesGroup.payable). We sum the USD value of every payable fee group and use
|
|
79
|
+
* it for both the collapsed summary and the itemized rows in the modal, so the
|
|
80
|
+
* two never disagree.
|
|
81
|
+
*/
|
|
82
|
+
const totalPayableFee = Object.values(feesGroup.payable).reduce(
|
|
83
|
+
(acc: BigNumber, fees) => acc.plus(getTotalFeesInUsd(fees)),
|
|
84
|
+
new BigNumber(0)
|
|
85
|
+
);
|
|
86
|
+
|
|
76
87
|
const roundedFee = numberToString(
|
|
77
|
-
|
|
88
|
+
totalPayableFee,
|
|
78
89
|
GAS_FEE_MIN_DECIMALS,
|
|
79
90
|
GAS_FEE_MAX_DECIMALS
|
|
80
91
|
);
|
|
@@ -181,7 +192,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
181
192
|
<Typography variant="label" size="medium">
|
|
182
193
|
$
|
|
183
194
|
{numberToString(
|
|
184
|
-
|
|
195
|
+
totalPayableFee,
|
|
185
196
|
USD_VALUE_MIN_DECIMALS,
|
|
186
197
|
USD_VALUE_MAX_DECIMALS
|
|
187
198
|
)}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Result } from '../../hooks/useStatefulConnect';
|
|
2
|
+
import type { WithConnectTrigger } from '../../libs/connectLogging';
|
|
2
3
|
import type { WalletInfoWithExtra } from '../../types';
|
|
3
4
|
import type { Namespace } from '@hub3js/namespaces';
|
|
4
5
|
|
|
@@ -29,7 +30,7 @@ import {
|
|
|
29
30
|
const KEEP_SUCCESS_MODAL_FOR = 3_000;
|
|
30
31
|
const DELAY_SHOWING_MODAL_FOR = 300;
|
|
31
32
|
|
|
32
|
-
interface PropTypes {
|
|
33
|
+
interface PropTypes extends WithConnectTrigger {
|
|
33
34
|
wallet: WalletInfoWithExtra | undefined;
|
|
34
35
|
id: string;
|
|
35
36
|
onClose: () => void;
|
|
@@ -56,7 +57,7 @@ export function StatefulConnectModal(props: PropTypes) {
|
|
|
56
57
|
getState,
|
|
57
58
|
resetState,
|
|
58
59
|
handleDisconnect,
|
|
59
|
-
} = useStatefulConnect();
|
|
60
|
+
} = useStatefulConnect(props);
|
|
60
61
|
|
|
61
62
|
const handleConfirmNamespaces = (selectedNamespaces: Namespace[]) => {
|
|
62
63
|
handleNamespace(props.wallet!, selectedNamespaces)
|
|
@@ -208,6 +209,7 @@ export function StatefulConnectModal(props: PropTypes) {
|
|
|
208
209
|
value={getState().namespace}
|
|
209
210
|
selectedNamespaces={getState().selectedNamespaces}
|
|
210
211
|
navigateToDerivationPath={handleNavigateToDerivationPath}
|
|
212
|
+
trigger={props.trigger}
|
|
211
213
|
/>
|
|
212
214
|
)}
|
|
213
215
|
</WatermarkedModal>
|
|
@@ -31,11 +31,13 @@ import {
|
|
|
31
31
|
USD_VALUE_MAX_DECIMALS,
|
|
32
32
|
USD_VALUE_MIN_DECIMALS,
|
|
33
33
|
} from '../../constants/routing';
|
|
34
|
+
import { useConnectWithLogging } from '../../hooks/useConnectWithLogging';
|
|
34
35
|
import { useAppStore } from '../../store/AppStore';
|
|
35
36
|
import { useNotificationStore } from '../../store/notification';
|
|
36
37
|
import { useQuoteStore } from '../../store/quote';
|
|
37
38
|
import { UiEventTypes } from '../../types';
|
|
38
39
|
import { getContainer } from '../../utils/common';
|
|
40
|
+
import { tryRefineError } from '../../utils/errors';
|
|
39
41
|
import { emitUiEvent } from '../../utils/events';
|
|
40
42
|
import {
|
|
41
43
|
numberToString,
|
|
@@ -78,7 +80,8 @@ const SUCCESS_SWITCH_NETWORK_MODAL_CLOSE_DELAY = 3000;
|
|
|
78
80
|
|
|
79
81
|
export function SwapDetails(props: SwapDetailsProps) {
|
|
80
82
|
const { swap, requestId, onDelete, onCancel } = props;
|
|
81
|
-
const { canSwitchNetworkTo,
|
|
83
|
+
const { canSwitchNetworkTo, getWalletInfo } = useWallets();
|
|
84
|
+
const connect = useConnectWithLogging();
|
|
82
85
|
const blockchains = useAppStore().blockchains();
|
|
83
86
|
const swappers = useAppStore().swappers();
|
|
84
87
|
const { findToken } = useAppStore();
|
|
@@ -175,17 +178,23 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
175
178
|
const handleSwitchNetwork = () => {
|
|
176
179
|
if (switchNetworkIsAvailable) {
|
|
177
180
|
handleShowSwitchNetworkLoading();
|
|
178
|
-
connect(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
connect(
|
|
182
|
+
currentStepWallet.walletType,
|
|
183
|
+
[
|
|
184
|
+
{
|
|
185
|
+
namespace: currentStepNamespace.namespace,
|
|
186
|
+
network: currentStepNamespace.network,
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
{ trigger: 'swap-details-switch-network' }
|
|
190
|
+
)
|
|
184
191
|
.then(() => {
|
|
185
192
|
handleShowSwitchNetworkSucceeded();
|
|
186
193
|
})
|
|
187
194
|
.catch((error: unknown) => {
|
|
188
|
-
handleShowSwitchNetworkFailed(
|
|
195
|
+
handleShowSwitchNetworkFailed(
|
|
196
|
+
tryRefineError(error) ?? (error as Error)
|
|
197
|
+
);
|
|
189
198
|
});
|
|
190
199
|
}
|
|
191
200
|
};
|
|
@@ -14,8 +14,10 @@ import {
|
|
|
14
14
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
15
15
|
import React, { useState } from 'react';
|
|
16
16
|
|
|
17
|
+
import { useConnectWithLogging } from '../../hooks/useConnectWithLogging';
|
|
17
18
|
import { useWalletList } from '../../hooks/useWalletList';
|
|
18
19
|
import { useUiStore } from '../../store/ui';
|
|
20
|
+
import { tryRefineError } from '../../utils/errors';
|
|
19
21
|
import { getConciseAddress } from '../../utils/wallets';
|
|
20
22
|
import { NamespaceItem } from '../NamespaceItem';
|
|
21
23
|
|
|
@@ -30,7 +32,8 @@ export const ConnectWalletContent = (props: ConnectWalletContentProps) => {
|
|
|
30
32
|
const [error, setError] = useState<Error | null>(null);
|
|
31
33
|
const { list } = useWalletList();
|
|
32
34
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
33
|
-
const { state
|
|
35
|
+
const { state } = useWallets();
|
|
36
|
+
const connect = useConnectWithLogging();
|
|
34
37
|
|
|
35
38
|
const wallet = list.find(
|
|
36
39
|
(wallet) => wallet.type === currentStepWallet.walletType
|
|
@@ -44,15 +47,12 @@ export const ConnectWalletContent = (props: ConnectWalletContentProps) => {
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
const walletState = state(currentStepWallet.walletType);
|
|
47
|
-
const namespaceState =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
: null;
|
|
50
|
+
const namespaceState = namespace?.namespace
|
|
51
|
+
? walletState.namespaces?.get(namespace.namespace)
|
|
52
|
+
: null;
|
|
51
53
|
|
|
52
54
|
const connecting = walletState.connecting || namespaceState?.connecting;
|
|
53
|
-
const connected =
|
|
54
|
-
? namespaceState?.connected
|
|
55
|
-
: walletState.connected;
|
|
55
|
+
const connected = namespaceState?.connected;
|
|
56
56
|
|
|
57
57
|
const getButtonTitle = () => {
|
|
58
58
|
if (connected) {
|
|
@@ -86,10 +86,11 @@ export const ConnectWalletContent = (props: ConnectWalletContentProps) => {
|
|
|
86
86
|
derivationPath: currentStepWallet.derivationPath,
|
|
87
87
|
},
|
|
88
88
|
]
|
|
89
|
-
: undefined
|
|
89
|
+
: undefined,
|
|
90
|
+
{ trigger: 'swap-details-reconnect' }
|
|
90
91
|
);
|
|
91
92
|
} catch (error) {
|
|
92
|
-
setError(error as Error);
|
|
93
|
+
setError(tryRefineError(error) ?? (error as Error));
|
|
93
94
|
}
|
|
94
95
|
};
|
|
95
96
|
|
|
@@ -106,9 +107,7 @@ export const ConnectWalletContent = (props: ConnectWalletContentProps) => {
|
|
|
106
107
|
if (!connected) {
|
|
107
108
|
return null;
|
|
108
109
|
}
|
|
109
|
-
const firstAccountArray =
|
|
110
|
-
? namespaceState?.accounts?.[0]?.split(':')
|
|
111
|
-
: walletState?.accounts?.[0]?.split(':');
|
|
110
|
+
const firstAccountArray = namespaceState?.accounts?.[0]?.split(':');
|
|
112
111
|
const address = firstAccountArray?.[firstAccountArray?.length - 1];
|
|
113
112
|
|
|
114
113
|
if (!address) {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { InstallWalletContentProps } from './SwapDetailsModal.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
detectInstallLink,
|
|
7
|
+
Divider,
|
|
8
|
+
Image,
|
|
9
|
+
MessageBox,
|
|
10
|
+
WarningIcon,
|
|
11
|
+
} from '@rango-dev/ui';
|
|
5
12
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
6
|
-
import { detectInstallLink } from '@rango-dev/wallets-shared';
|
|
7
13
|
import React from 'react';
|
|
8
14
|
|
|
9
15
|
import {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { WalletType } from '@hub3js/core';
|
|
1
2
|
import type { TargetNamespace } from '@rango-dev/queue-manager-rango-preset';
|
|
2
|
-
import type { LegacyWalletType } from '@rango-dev/wallets-core/legacy';
|
|
3
3
|
import type { PendingSwap } from 'rango-types';
|
|
4
4
|
|
|
5
5
|
export type ModalState =
|
|
@@ -60,12 +60,12 @@ export interface NetworkStateContentProps {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
export interface InstallWalletContentProps {
|
|
63
|
-
walletType:
|
|
63
|
+
walletType: WalletType;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export interface ConnectWalletContentProps {
|
|
67
67
|
wallet: {
|
|
68
|
-
walletType:
|
|
68
|
+
walletType: WalletType;
|
|
69
69
|
address: string;
|
|
70
70
|
derivationPath?: string;
|
|
71
71
|
};
|
|
@@ -8,9 +8,9 @@ import { End, List } from './TokenList.styles';
|
|
|
8
8
|
export function LoadingTokenList(props: LoadingTokenListProps) {
|
|
9
9
|
return (
|
|
10
10
|
<List>
|
|
11
|
-
{Array.from(Array(props.size), (
|
|
11
|
+
{Array.from(Array(props.size), (_, index) => (
|
|
12
12
|
<ListItem
|
|
13
|
-
key={
|
|
13
|
+
key={index}
|
|
14
14
|
hasDivider
|
|
15
15
|
start={<Skeleton variant="circular" width={35} height={35} />}
|
|
16
16
|
end={
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { DerivationPathTemplate } from './DerivationPath.helpers';
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
CUSTOM_DERIVATION_PATH,
|
|
7
|
+
getDerivationPaths,
|
|
8
|
+
} from './DerivationPath.helpers';
|
|
9
|
+
|
|
10
|
+
const LEDGER: DerivationPathTemplate[] = [
|
|
11
|
+
{
|
|
12
|
+
id: 'metamask',
|
|
13
|
+
label: `Metamask (m/44'/60'/0'/0/index)`,
|
|
14
|
+
namespace: 'EVM',
|
|
15
|
+
generateDerivationPath: (index) => `44'/60'/0'/0/${index}`,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'ledgerLive',
|
|
19
|
+
label: `LedgerLive (m/44'/60'/index'/0/0)`,
|
|
20
|
+
namespace: 'EVM',
|
|
21
|
+
generateDerivationPath: (index) => `44'/60'/${index}'/0/0`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'legacy',
|
|
25
|
+
label: `Legacy (m/44'/60'/0'/index)`,
|
|
26
|
+
namespace: 'EVM',
|
|
27
|
+
generateDerivationPath: (index) => `44'/60'/0'/${index}`,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: `(m/44'/501'/index')`,
|
|
31
|
+
label: `(m/44'/501'/index')`,
|
|
32
|
+
namespace: 'Solana',
|
|
33
|
+
generateDerivationPath: (index) => `44'/501'/${index}'`,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: `(m/44'/501'/0'/index)`,
|
|
37
|
+
label: `(m/44'/501'/0'/index)`,
|
|
38
|
+
namespace: 'Solana',
|
|
39
|
+
generateDerivationPath: (index) => `44'/501'/0'/${index}`,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const TREZOR_UTXO: DerivationPathTemplate[] = [
|
|
44
|
+
{
|
|
45
|
+
id: 'bitcoin-native-segwit',
|
|
46
|
+
label: `Native SegWit (m/84'/0'/index')`,
|
|
47
|
+
namespace: 'UTXO',
|
|
48
|
+
generateDerivationPath: (index) => `84'/0'/${index}'/0/0`,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'bitcoin-taproot',
|
|
52
|
+
label: `Taproot (m/86'/0'/index')`,
|
|
53
|
+
namespace: 'UTXO',
|
|
54
|
+
generateDerivationPath: (index) => `86'/0'/${index}'/0/0`,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
describe('getDerivationPaths', () => {
|
|
59
|
+
it('returns only the templates of the selected namespace', () => {
|
|
60
|
+
expect(getDerivationPaths(LEDGER, 'EVM').map((path) => path.id)).toEqual([
|
|
61
|
+
'metamask',
|
|
62
|
+
'ledgerLive',
|
|
63
|
+
'legacy',
|
|
64
|
+
CUSTOM_DERIVATION_PATH.id,
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
expect(getDerivationPaths(LEDGER, 'Solana').map((path) => path.id)).toEqual(
|
|
68
|
+
[
|
|
69
|
+
`(m/44'/501'/index')`,
|
|
70
|
+
`(m/44'/501'/0'/index)`,
|
|
71
|
+
CUSTOM_DERIVATION_PATH.id,
|
|
72
|
+
]
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('appends the custom template so a user can enter a full path', () => {
|
|
77
|
+
const paths = getDerivationPaths(TREZOR_UTXO, 'UTXO');
|
|
78
|
+
|
|
79
|
+
expect(paths.at(-1)).toBe(CUSTOM_DERIVATION_PATH);
|
|
80
|
+
expect(CUSTOM_DERIVATION_PATH.generateDerivationPath(`84'/0'/3'/0/0`)).toBe(
|
|
81
|
+
`84'/0'/3'/0/0`
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('generates the path the wallet expects for the picked index', () => {
|
|
86
|
+
const evm = getDerivationPaths(LEDGER, 'EVM');
|
|
87
|
+
const utxo = getDerivationPaths(TREZOR_UTXO, 'UTXO');
|
|
88
|
+
|
|
89
|
+
expect(evm[0]?.generateDerivationPath('2')).toBe(`44'/60'/0'/0/2`);
|
|
90
|
+
expect(evm[1]?.generateDerivationPath('2')).toBe(`44'/60'/2'/0/0`);
|
|
91
|
+
expect(utxo[0]?.generateDerivationPath('2')).toBe(`84'/0'/2'/0/0`);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('returns nothing when the provider declares no template for the namespace', () => {
|
|
95
|
+
expect(getDerivationPaths(LEDGER, 'UTXO')).toEqual([]);
|
|
96
|
+
expect(getDerivationPaths([], 'EVM')).toEqual([]);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
+
import type { ProviderProperty } from '@hub3js/core/store';
|
|
1
2
|
import type { Namespace } from '@hub3js/namespaces';
|
|
2
|
-
import type { DerivationPath } from '@rango-dev/wallets-shared';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export type DerivationPathTemplate = Extract<
|
|
5
|
+
ProviderProperty,
|
|
6
|
+
{ name: 'derivationPath' }
|
|
7
|
+
>['value']['data'][number];
|
|
5
8
|
|
|
6
|
-
export
|
|
9
|
+
export type DerivationPathOption = Omit<DerivationPathTemplate, 'namespace'>;
|
|
10
|
+
|
|
11
|
+
export const CUSTOM_DERIVATION_PATH: DerivationPathOption = {
|
|
7
12
|
id: 'custom',
|
|
8
13
|
label: 'Custom',
|
|
9
14
|
generateDerivationPath: (index: string) => index,
|
|
10
15
|
};
|
|
11
16
|
|
|
12
17
|
export function getDerivationPaths(
|
|
18
|
+
derivationPaths: DerivationPathTemplate[],
|
|
13
19
|
selectedNamespace?: Namespace
|
|
14
|
-
):
|
|
15
|
-
const selectedNamespaceDerivationPaths =
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
): DerivationPathOption[] {
|
|
21
|
+
const selectedNamespaceDerivationPaths = derivationPaths.filter(
|
|
22
|
+
(derivationPath) => derivationPath.namespace === selectedNamespace
|
|
23
|
+
);
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
return selectedNamespaceDerivationPaths.length
|
|
20
26
|
? [...selectedNamespaceDerivationPaths, CUSTOM_DERIVATION_PATH]
|
|
21
27
|
: [];
|
|
22
|
-
|
|
23
|
-
return derivationPaths;
|
|
24
28
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PropTypes } from './DerivationPath.types';
|
|
2
|
-
import type { DerivationPath } from '@rango-dev/wallets-shared';
|
|
3
2
|
|
|
4
3
|
import { i18n } from '@lingui/core';
|
|
5
4
|
import { Divider, Image, MessageBox, Select, TextField } from '@rango-dev/ui';
|
|
6
|
-
import
|
|
5
|
+
import { useWallets } from '@rango-dev/wallets-react';
|
|
6
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
CUSTOM_DERIVATION_PATH,
|
|
@@ -26,6 +26,8 @@ export function DerivationPath(props: PropTypes) {
|
|
|
26
26
|
providerType: type,
|
|
27
27
|
} = props.value;
|
|
28
28
|
|
|
29
|
+
const { getWalletInfo } = useWallets();
|
|
30
|
+
|
|
29
31
|
const [selectedDerivationPathId, setSelectedDerivationPathId] = useState<
|
|
30
32
|
string | null
|
|
31
33
|
>(null);
|
|
@@ -36,7 +38,14 @@ export function DerivationPath(props: PropTypes) {
|
|
|
36
38
|
const isCustomOptionSelected =
|
|
37
39
|
selectedDerivationPathId === CUSTOM_DERIVATION_PATH.id;
|
|
38
40
|
|
|
39
|
-
const derivationPaths =
|
|
41
|
+
const derivationPaths = useMemo(
|
|
42
|
+
() =>
|
|
43
|
+
getDerivationPaths(
|
|
44
|
+
getWalletInfo(type).needsDerivationPath?.data ?? [],
|
|
45
|
+
selectedNamespace
|
|
46
|
+
),
|
|
47
|
+
[type, selectedNamespace]
|
|
48
|
+
);
|
|
40
49
|
|
|
41
50
|
const handleDerivationPathItemClick = ({ value }: { value: string }) => {
|
|
42
51
|
const selectedDerivationPath = derivationPaths?.find(
|
|
@@ -75,10 +84,8 @@ export function DerivationPath(props: PropTypes) {
|
|
|
75
84
|
};
|
|
76
85
|
|
|
77
86
|
useEffect(() => {
|
|
78
|
-
setSelectedDerivationPathId(
|
|
79
|
-
|
|
80
|
-
);
|
|
81
|
-
}, [selectedNamespace]);
|
|
87
|
+
setSelectedDerivationPathId(derivationPaths[0]?.id || null);
|
|
88
|
+
}, [derivationPaths]);
|
|
82
89
|
|
|
83
90
|
return (
|
|
84
91
|
<>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropTypes } from './Detached.types';
|
|
2
2
|
import type { Namespace } from '@hub3js/namespaces';
|
|
3
|
-
import type {
|
|
3
|
+
import type { NamespaceMeta } from '@rango-dev/wallets-react';
|
|
4
4
|
|
|
5
5
|
import { i18n } from '@lingui/core';
|
|
6
6
|
import {
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { useWallets } from '@rango-dev/wallets-react';
|
|
15
15
|
import React from 'react';
|
|
16
16
|
|
|
17
|
+
import { useConnectWithLogging } from '../../hooks/useConnectWithLogging';
|
|
17
18
|
import { NamespaceUnsupportedItem } from '../NamespaceItem/NamespaceUnsupportedItem';
|
|
18
19
|
|
|
19
20
|
import { NamespacesHeader } from './Detached.styles';
|
|
@@ -28,10 +29,12 @@ export function Detached(props: PropTypes) {
|
|
|
28
29
|
confirmText = i18n.t('Done'),
|
|
29
30
|
onDisconnectWallet,
|
|
30
31
|
navigateToDerivationPath,
|
|
32
|
+
trigger,
|
|
31
33
|
} = props;
|
|
32
34
|
const { targetWallet } = value;
|
|
33
35
|
|
|
34
|
-
const {
|
|
36
|
+
const { disconnect, state } = useWallets();
|
|
37
|
+
const connect = useConnectWithLogging();
|
|
35
38
|
const walletType = targetWallet.type;
|
|
36
39
|
const walletState = state(walletType);
|
|
37
40
|
const namespacesProperty = targetWallet.properties?.find(
|
|
@@ -57,13 +60,17 @@ export function Detached(props: PropTypes) {
|
|
|
57
60
|
if (derivationPathProperty && options?.shouldAskForDerivationPath) {
|
|
58
61
|
navigateToDerivationPath(namespace);
|
|
59
62
|
} else {
|
|
60
|
-
await connect(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
await connect(
|
|
64
|
+
walletType,
|
|
65
|
+
[
|
|
66
|
+
{
|
|
67
|
+
namespace: namespace,
|
|
68
|
+
network: '',
|
|
69
|
+
derivationPath: options?.derivationPath ?? undefined,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
{ trigger }
|
|
73
|
+
);
|
|
67
74
|
}
|
|
68
75
|
};
|
|
69
76
|
|
|
@@ -119,7 +126,7 @@ export function Detached(props: PropTypes) {
|
|
|
119
126
|
);
|
|
120
127
|
};
|
|
121
128
|
|
|
122
|
-
const renderNamespaceItem = (namespace:
|
|
129
|
+
const renderNamespaceItem = (namespace: NamespaceMeta) => {
|
|
123
130
|
if (namespace.unsupported) {
|
|
124
131
|
return <NamespaceUnsupportedItem namespace={namespace} />;
|
|
125
132
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
|
|
2
|
+
import type { WithConnectTrigger } from '../../libs/connectLogging';
|
|
2
3
|
import type { Namespace } from '@hub3js/namespaces';
|
|
3
4
|
|
|
4
|
-
export interface PropTypes {
|
|
5
|
+
export interface PropTypes extends WithConnectTrigger {
|
|
5
6
|
value: NeedsNamespacesState;
|
|
6
7
|
onConfirm: () => void;
|
|
7
8
|
confirmText?: string;
|
|
@@ -4,6 +4,7 @@ import { i18n } from '@lingui/core';
|
|
|
4
4
|
import { Button, Spinner } from '@rango-dev/ui';
|
|
5
5
|
import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { tryRefineError } from '../../utils/errors';
|
|
7
8
|
import { getConciseAddress } from '../../utils/wallets';
|
|
8
9
|
import { NamespaceItem } from '../NamespaceItem';
|
|
9
10
|
|
|
@@ -39,7 +40,7 @@ export function NamespaceDetachedItem(props: NamespaceDetachedItemPropTypes) {
|
|
|
39
40
|
processingConnectAttempt.current = true;
|
|
40
41
|
await handleConnect(options);
|
|
41
42
|
} catch (error) {
|
|
42
|
-
setError(error as Error);
|
|
43
|
+
setError(tryRefineError(error) ?? (error as Error));
|
|
43
44
|
} finally {
|
|
44
45
|
processingConnectAttempt.current = false;
|
|
45
46
|
}
|