@rango-dev/widget-embedded 0.29.1-next.9 → 0.30.1-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +6 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.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/NotificationContent/NotificationContent.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/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.types.d.ts +2 -0
- package/dist/components/SearchInput/SearchInput.types.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.d.ts +4 -0
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.d.ts.map +1 -0
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.d.ts +325 -0
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.d.ts.map +1 -0
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.types.d.ts +10 -0
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.types.d.ts.map +1 -0
- package/dist/components/WalletDerivationPathModal/index.d.ts +2 -0
- package/dist/components/WalletDerivationPathModal/index.d.ts.map +1 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts.map +1 -1
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.types.d.ts +1 -1
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.types.d.ts.map +1 -1
- package/dist/constants/namespaces.d.ts +8 -0
- package/dist/constants/namespaces.d.ts.map +1 -0
- package/dist/constants/quote.d.ts +2 -1
- package/dist/constants/quote.d.ts.map +1 -1
- package/dist/constants/routing.d.ts +0 -1
- package/dist/constants/routing.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.types.d.ts +3 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/hooks/useBootstrap/useBootstrap.d.ts.map +1 -1
- package/dist/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts +4 -3
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders/index.d.ts +2 -0
- package/dist/hooks/useWalletProviders/index.d.ts.map +1 -0
- package/dist/hooks/{useWalletProviders.d.ts → useWalletProviders/useWalletProviders.d.ts} +2 -2
- package/dist/hooks/useWalletProviders/useWalletProviders.d.ts.map +1 -0
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts +3 -0
- package/dist/hooks/useWalletProviders/useWalletProviders.helpers.d.ts.map +1 -0
- package/dist/hooks/useWidgetEvents/index.d.ts +2 -0
- package/dist/hooks/useWidgetEvents/index.d.ts.map +1 -0
- package/dist/hooks/useWidgetEvents/useWidgetEvents.d.ts +3 -0
- package/dist/hooks/useWidgetEvents/useWidgetEvents.d.ts.map +1 -0
- package/dist/index.d.ts +16 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/services/eventEmitter.d.ts +4 -0
- package/dist/services/eventEmitter.d.ts.map +1 -0
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/quote.d.ts +2 -1
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts.map +1 -1
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +7 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/event.d.ts +68 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +2 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/common.d.ts +2 -2
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -0
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +0 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +1 -0
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +4 -4
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +8 -8
- package/src/QueueManager.tsx +4 -0
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +19 -9
- package/src/components/ConfirmWalletsModal/WalletList.tsx +81 -14
- package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +5 -5
- package/src/components/NotificationContent/NotificationContent.tsx +12 -113
- package/src/components/Quote/Quote.tsx +24 -34
- package/src/components/Quote/QuoteCostDetails.tsx +10 -9
- package/src/components/SearchInput/SearchInput.types.ts +2 -0
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +8 -10
- package/src/components/SwapDetails/SwapDetails.styles.ts +10 -0
- package/src/components/SwapDetails/SwapDetails.tsx +34 -17
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +77 -11
- package/src/components/TokenList/TokenList.tsx +5 -5
- package/src/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.ts +17 -0
- package/src/components/WalletDerivationPathModal/WalletDerivationPathModal.tsx +154 -0
- package/src/components/WalletDerivationPathModal/WalletDerivationPathModal.types.tsx +10 -0
- package/src/components/WalletDerivationPathModal/index.ts +1 -0
- package/src/components/WalletNamespacesModal/WalletNamespacesModal.tsx +9 -6
- package/src/components/WalletNamespacesModal/WalletNamespacesModal.types.tsx +1 -1
- package/src/constants/namespaces.ts +62 -0
- package/src/constants/quote.ts +11 -9
- package/src/constants/routing.ts +0 -2
- package/src/containers/Inputs/Inputs.tsx +5 -5
- package/src/containers/Wallets/Wallets.tsx +1 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +3 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +3 -1
- package/src/hooks/useBootstrap/useBootstrap.ts +4 -0
- package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +8 -10
- package/src/hooks/useSyncStoresWithConfig.ts +3 -1
- package/src/hooks/useWalletList.ts +12 -5
- package/src/hooks/useWalletProviders/index.ts +1 -0
- package/src/hooks/useWalletProviders/useWalletProviders.helpers.ts +14 -0
- package/src/hooks/{useWalletProviders.ts → useWalletProviders/useWalletProviders.ts} +11 -5
- package/src/hooks/useWidgetEvents/index.ts +1 -0
- package/src/hooks/useWidgetEvents/useWidgetEvents.ts +9 -0
- package/src/index.ts +26 -2
- package/src/pages/WalletsPage.tsx +85 -19
- package/src/services/eventEmitter.ts +11 -0
- package/src/store/notification.ts +3 -1
- package/src/store/quote.ts +70 -5
- package/src/store/slices/config.ts +4 -0
- package/src/store/slices/settings.ts +4 -1
- package/src/store/wallets.ts +194 -173
- package/src/types/config.ts +8 -4
- package/src/types/event.ts +89 -0
- package/src/types/index.ts +1 -0
- package/src/types/wallets.ts +2 -1
- package/src/utils/common.ts +2 -2
- package/src/utils/meta.ts +8 -0
- package/src/utils/numbers.ts +0 -12
- package/src/utils/providers.ts +4 -0
- package/src/utils/wallets.ts +7 -5
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +0 -1559
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +0 -1
- package/dist/components/NotificationContent/NotificationNotFound.d.ts +0 -3
- package/dist/components/NotificationContent/NotificationNotFound.d.ts.map +0 -1
- package/dist/hooks/useWalletProviders.d.ts.map +0 -1
- package/src/components/NotificationContent/NotificationContent.styles.ts +0 -63
- package/src/components/NotificationContent/NotificationNotFound.tsx +0 -17
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GetStep } from '../SwapDetailsAlerts';
|
|
2
2
|
import type { Step, StepDetailsProps } from '@rango-dev/ui';
|
|
3
|
-
import type { PendingSwapStep } from 'rango-types';
|
|
3
|
+
import type { PendingSwapStep, SwapperType } from 'rango-types';
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
@@ -46,7 +46,7 @@ export const getSteps = ({
|
|
|
46
46
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
47
47
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
48
48
|
),
|
|
49
|
-
realValue: amountToConvert,
|
|
49
|
+
realValue: amountToConvert ?? '',
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
52
|
to: {
|
|
@@ -63,13 +63,13 @@ export const getSteps = ({
|
|
|
63
63
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
64
64
|
),
|
|
65
65
|
realValue:
|
|
66
|
-
step.outputAmount || step.expectedOutputAmountHumanReadable,
|
|
66
|
+
step.outputAmount || step.expectedOutputAmountHumanReadable || '',
|
|
67
67
|
},
|
|
68
68
|
},
|
|
69
69
|
swapper: {
|
|
70
|
-
displayName: getSwapperDisplayName(step.swapperId, swappers),
|
|
70
|
+
displayName: getSwapperDisplayName(step.swapperId, swappers) ?? '',
|
|
71
71
|
image: step.swapperLogo ?? '',
|
|
72
|
-
type: step.swapperType,
|
|
72
|
+
type: step.swapperType as SwapperType,
|
|
73
73
|
},
|
|
74
74
|
internalSwaps: step.internalSwaps
|
|
75
75
|
? step.internalSwaps.map((internalSwap) => {
|
|
@@ -95,12 +95,10 @@ export const getSteps = ({
|
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
97
|
swapper: {
|
|
98
|
-
displayName:
|
|
99
|
-
internalSwap.swapperId,
|
|
100
|
-
swappers
|
|
101
|
-
),
|
|
98
|
+
displayName:
|
|
99
|
+
getSwapperDisplayName(internalSwap.swapperId, swappers) ?? '',
|
|
102
100
|
image: internalSwap.swapperLogo ?? '',
|
|
103
|
-
type: internalSwap.swapperType,
|
|
101
|
+
type: internalSwap.swapperType as SwapperType,
|
|
104
102
|
},
|
|
105
103
|
};
|
|
106
104
|
})
|
|
@@ -11,6 +11,16 @@ export const Container = styled('div', {
|
|
|
11
11
|
|
|
12
12
|
export const HeaderDetails = styled('div', {
|
|
13
13
|
width: '100%',
|
|
14
|
+
'& ._icon-button': {
|
|
15
|
+
'&:hover': {
|
|
16
|
+
'& svg': {
|
|
17
|
+
color: '$secondary550',
|
|
18
|
+
[`.${darkTheme} &`]: {
|
|
19
|
+
color: '$secondary500',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
14
24
|
});
|
|
15
25
|
|
|
16
26
|
export const StepsList = styled(ScrollableArea, {
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
Button,
|
|
12
12
|
CopyIcon,
|
|
13
13
|
Divider,
|
|
14
|
+
DoneIcon,
|
|
14
15
|
IconButton,
|
|
15
16
|
QuoteCost,
|
|
16
17
|
RangoExplorerIcon,
|
|
@@ -42,7 +43,6 @@ import { useQuoteStore } from '../../store/quote';
|
|
|
42
43
|
import { useUiStore } from '../../store/ui';
|
|
43
44
|
import { getContainer } from '../../utils/common';
|
|
44
45
|
import {
|
|
45
|
-
formatTooltipNumbers,
|
|
46
46
|
numberToString,
|
|
47
47
|
roundedSecondsToString,
|
|
48
48
|
totalArrivalTime,
|
|
@@ -89,7 +89,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
89
89
|
const retry = useQuoteStore.use.retry();
|
|
90
90
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
91
91
|
const navigate = useNavigate();
|
|
92
|
-
const [
|
|
92
|
+
const [isCopied, handleCopy] = useCopyToClipboard(RESET_INTERVAL);
|
|
93
93
|
const listRef = useRef<HTMLDivElement | null>(null);
|
|
94
94
|
const [modalState, setModalState] = useState<ModalState>(null);
|
|
95
95
|
const [showCompletedModal, setShowCompletedModal] = useState<
|
|
@@ -206,14 +206,14 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
206
206
|
);
|
|
207
207
|
|
|
208
208
|
const realOutputUsdValue = outputAmount
|
|
209
|
-
?
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
? new BigNumber(outputAmount)
|
|
210
|
+
.multipliedBy(lastStep.toUsdPrice || 0)
|
|
211
|
+
.toString()
|
|
212
212
|
: '';
|
|
213
213
|
|
|
214
|
-
const realInputUsdValue =
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
const realInputUsdValue = new BigNumber(swap.inputAmount)
|
|
215
|
+
.multipliedBy(firstStep.fromUsdPrice || 0)
|
|
216
|
+
.toString();
|
|
217
217
|
|
|
218
218
|
const percentageChange = getPriceImpact(inputUsdValue, outputUsdValue);
|
|
219
219
|
|
|
@@ -272,7 +272,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
272
272
|
return (
|
|
273
273
|
<Layout
|
|
274
274
|
header={{
|
|
275
|
-
title: i18n.t('Swap
|
|
275
|
+
title: i18n.t('Swap Details'),
|
|
276
276
|
onCancel:
|
|
277
277
|
swap.status === 'running' ? () => setModalState('cancel') : undefined,
|
|
278
278
|
suffix: swap.status !== 'running' && (
|
|
@@ -319,11 +319,28 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
319
319
|
<Typography variant="label" size="small" color="neutral700">
|
|
320
320
|
{requestId}
|
|
321
321
|
</Typography>
|
|
322
|
-
<
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
322
|
+
<Tooltip
|
|
323
|
+
container={getContainer()}
|
|
324
|
+
content={
|
|
325
|
+
isCopied
|
|
326
|
+
? i18n.t('Copied To Clipboard')
|
|
327
|
+
: i18n.t('Copy Request ID')
|
|
328
|
+
}
|
|
329
|
+
open={isCopied || undefined}
|
|
330
|
+
side="bottom"
|
|
331
|
+
alignOffset={-16}
|
|
332
|
+
align="end">
|
|
333
|
+
<IconButton
|
|
334
|
+
variant="ghost"
|
|
335
|
+
onClick={handleCopy.bind(null, requestId || '')}>
|
|
336
|
+
{isCopied ? (
|
|
337
|
+
<DoneIcon size={16} color="secondary" />
|
|
338
|
+
) : (
|
|
339
|
+
<CopyIcon size={16} color="gray" />
|
|
340
|
+
)}
|
|
341
|
+
</IconButton>
|
|
342
|
+
</Tooltip>
|
|
343
|
+
|
|
327
344
|
<StyledLink
|
|
328
345
|
target="_blank"
|
|
329
346
|
href={`${SCANNER_BASE_URL}/swap/${requestId}`}>
|
|
@@ -338,7 +355,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
338
355
|
</div>
|
|
339
356
|
<div className={rowStyles()}>
|
|
340
357
|
<Typography variant="label" size="large" color="neutral700">
|
|
341
|
-
{
|
|
358
|
+
{swap.finishTime ? i18n.t('Finished at') : i18n.t('Created at')}
|
|
342
359
|
</Typography>
|
|
343
360
|
<Typography variant="label" size="small" color="neutral700">
|
|
344
361
|
{swapDate}
|
|
@@ -386,7 +403,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
386
403
|
),
|
|
387
404
|
usdValue: outputUsdValue,
|
|
388
405
|
realUsdValue: realOutputUsdValue,
|
|
389
|
-
realValue: outputAmount,
|
|
406
|
+
realValue: outputAmount || '',
|
|
390
407
|
},
|
|
391
408
|
token: {
|
|
392
409
|
displayName: steps[numberOfSteps - 1].to.token.displayName,
|
|
@@ -458,7 +475,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
458
475
|
)}
|
|
459
476
|
usdValue={outputUsdValue}
|
|
460
477
|
realUsdValue={realOutputUsdValue}
|
|
461
|
-
realValue={
|
|
478
|
+
realValue={outputAmount || ''}
|
|
462
479
|
percentageChange={numberToString(
|
|
463
480
|
percentageChange,
|
|
464
481
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
@@ -8,17 +8,26 @@ import React, { useState } from 'react';
|
|
|
8
8
|
|
|
9
9
|
import { getContainer } from '../../utils/common';
|
|
10
10
|
import { mapStatusToWalletState } from '../../utils/wallets';
|
|
11
|
+
import { WalletDerivationPathModal } from '../WalletDerivationPathModal';
|
|
11
12
|
import { WalletNamespacesModal } from '../WalletNamespacesModal';
|
|
12
13
|
|
|
13
14
|
import { WalletContainer } from './SwapDetailsModal.styles';
|
|
14
15
|
|
|
15
16
|
interface NamespacesModalState {
|
|
17
|
+
open: boolean;
|
|
16
18
|
providerType: string;
|
|
17
19
|
providerImage: string;
|
|
18
20
|
availableNamespaces?: Namespace[];
|
|
19
21
|
singleNamespace?: boolean;
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
interface DerivationPathModalState {
|
|
25
|
+
open: boolean;
|
|
26
|
+
providerType: string;
|
|
27
|
+
providerImage: string;
|
|
28
|
+
namespace: Namespace;
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
23
32
|
const {
|
|
24
33
|
type,
|
|
@@ -31,6 +40,8 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
|
31
40
|
const { connect, getWalletInfo, state } = useWallets();
|
|
32
41
|
const [namespacesModalState, setNamespacesModalState] =
|
|
33
42
|
useState<NamespacesModalState | null>(null);
|
|
43
|
+
const [derivationPathModalState, setDerivationPathModalState] =
|
|
44
|
+
useState<DerivationPathModalState | null>(null);
|
|
34
45
|
const walletType = currentStepWallet?.walletType;
|
|
35
46
|
const walletState = walletType
|
|
36
47
|
? mapStatusToWalletState(state(walletType))
|
|
@@ -39,6 +50,59 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
|
39
50
|
const shouldShowWallet =
|
|
40
51
|
showWalletButton && !!walletType && !!walletState && !!walletInfo;
|
|
41
52
|
|
|
53
|
+
const handleCloseNamespaceModal = () => {
|
|
54
|
+
if (namespacesModalState) {
|
|
55
|
+
setNamespacesModalState({
|
|
56
|
+
...namespacesModalState,
|
|
57
|
+
open: false,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const handleCloseDerivationPathModal = () => {
|
|
63
|
+
if (derivationPathModalState) {
|
|
64
|
+
setDerivationPathModalState({
|
|
65
|
+
...derivationPathModalState,
|
|
66
|
+
open: false,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const handleConfirmNamespaces = (selectedNamespaces: Namespace[]) => {
|
|
72
|
+
if (
|
|
73
|
+
!!walletInfo?.needsDerivationPath &&
|
|
74
|
+
walletInfo?.singleNamespace &&
|
|
75
|
+
selectedNamespaces[0] &&
|
|
76
|
+
walletType
|
|
77
|
+
) {
|
|
78
|
+
setDerivationPathModalState({
|
|
79
|
+
open: true,
|
|
80
|
+
providerType: walletType,
|
|
81
|
+
providerImage: walletInfo.img,
|
|
82
|
+
namespace: selectedNamespaces[0],
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
connect(
|
|
86
|
+
namespacesModalState?.providerType as string,
|
|
87
|
+
undefined,
|
|
88
|
+
selectedNamespaces.map((namespace) => ({
|
|
89
|
+
namespace,
|
|
90
|
+
}))
|
|
91
|
+
).catch((error) => debug(error));
|
|
92
|
+
}
|
|
93
|
+
handleCloseNamespaceModal();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const handleDerivationPathConfirm = (derivationPath: string) => {
|
|
97
|
+
if (derivationPath && derivationPathModalState?.namespace) {
|
|
98
|
+
connect(derivationPathModalState?.providerType, undefined, [
|
|
99
|
+
{ namespace: derivationPathModalState.namespace, derivationPath },
|
|
100
|
+
]).catch((error) => debug(error));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
handleCloseDerivationPathModal();
|
|
104
|
+
};
|
|
105
|
+
|
|
42
106
|
return (
|
|
43
107
|
<>
|
|
44
108
|
<MessageBox type={type} title={title} description={message} />
|
|
@@ -56,6 +120,7 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
|
56
120
|
onClick={async () => {
|
|
57
121
|
if (walletInfo.namespaces) {
|
|
58
122
|
setNamespacesModalState({
|
|
123
|
+
open: true,
|
|
59
124
|
providerType: walletType,
|
|
60
125
|
providerImage: walletInfo.img,
|
|
61
126
|
availableNamespaces: walletInfo.namespaces,
|
|
@@ -69,20 +134,21 @@ export const WalletStateContent = (props: WalletStateContentProps) => {
|
|
|
69
134
|
</WalletContainer>
|
|
70
135
|
)}
|
|
71
136
|
<WalletNamespacesModal
|
|
72
|
-
open={!!namespacesModalState}
|
|
73
|
-
onClose={
|
|
74
|
-
onConfirm={
|
|
75
|
-
connect(
|
|
76
|
-
namespacesModalState?.providerType as string,
|
|
77
|
-
undefined,
|
|
78
|
-
namespaces
|
|
79
|
-
).catch((error) => debug(error));
|
|
80
|
-
setNamespacesModalState(null);
|
|
81
|
-
}}
|
|
137
|
+
open={!!namespacesModalState?.open}
|
|
138
|
+
onClose={handleCloseNamespaceModal}
|
|
139
|
+
onConfirm={handleConfirmNamespaces}
|
|
82
140
|
image={namespacesModalState?.providerImage}
|
|
83
|
-
|
|
141
|
+
availableNamespaces={namespacesModalState?.availableNamespaces}
|
|
84
142
|
singleNamespace={namespacesModalState?.singleNamespace}
|
|
85
143
|
/>
|
|
144
|
+
<WalletDerivationPathModal
|
|
145
|
+
open={!!derivationPathModalState?.open}
|
|
146
|
+
selectedNamespace={derivationPathModalState?.namespace}
|
|
147
|
+
type={derivationPathModalState?.providerType}
|
|
148
|
+
image={derivationPathModalState?.providerImage}
|
|
149
|
+
onClose={handleCloseDerivationPathModal}
|
|
150
|
+
onConfirm={handleDerivationPathConfirm}
|
|
151
|
+
/>
|
|
86
152
|
</>
|
|
87
153
|
);
|
|
88
154
|
};
|
|
@@ -110,7 +110,7 @@ export function TokenList(props: PropTypes) {
|
|
|
110
110
|
|
|
111
111
|
useEffect(() => {
|
|
112
112
|
setTokens(list.slice(0, PAGE_SIZE));
|
|
113
|
-
}, [list.length]);
|
|
113
|
+
}, [list.length, selectedBlockchain]);
|
|
114
114
|
|
|
115
115
|
const renderList = () => {
|
|
116
116
|
if (!tokens.length && !!searchedFor) {
|
|
@@ -136,17 +136,17 @@ export function TokenList(props: PropTypes) {
|
|
|
136
136
|
) as BlockchainMeta;
|
|
137
137
|
const colors = createTintsAndShades(blockchain.color, 'main');
|
|
138
138
|
const customCssForTag = {
|
|
139
|
-
$$color: colors.
|
|
139
|
+
$$color: colors.main150,
|
|
140
140
|
[`.${darkTheme} &`]: {
|
|
141
|
-
$$color: colors.
|
|
141
|
+
$$color: colors.main750,
|
|
142
142
|
},
|
|
143
143
|
backgroundColor: '$$color',
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
const customCssForTagTitle = {
|
|
147
|
-
$$color: colors.
|
|
147
|
+
$$color: colors.main750,
|
|
148
148
|
[`.${darkTheme} &`]: {
|
|
149
|
-
$$color: colors.
|
|
149
|
+
$$color: colors.main150,
|
|
150
150
|
},
|
|
151
151
|
color: '$$color',
|
|
152
152
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { styled, Typography } from '@rango-dev/ui';
|
|
2
|
+
|
|
3
|
+
export const InputsContainer = styled('div', {
|
|
4
|
+
paddingTop: '$30',
|
|
5
|
+
paddingBottom: '$30',
|
|
6
|
+
zIndex: 10, // This property is added to solve inconsistency between Select child of this component and subsequent button
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export const InputLabel = styled(Typography, {
|
|
10
|
+
paddingLeft: '$10',
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const derivationPathInputStyles = {
|
|
14
|
+
height: '$40',
|
|
15
|
+
backgroundColor: '$neutral200',
|
|
16
|
+
borderRadius: '$sm',
|
|
17
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { PropTypes } from './WalletDerivationPathModal.types';
|
|
2
|
+
import type { DerivationPath, Namespace } from '@rango-dev/wallets-shared';
|
|
3
|
+
|
|
4
|
+
import { i18n } from '@lingui/core';
|
|
5
|
+
import {
|
|
6
|
+
Button,
|
|
7
|
+
Divider,
|
|
8
|
+
Image,
|
|
9
|
+
MessageBox,
|
|
10
|
+
Select,
|
|
11
|
+
TextField,
|
|
12
|
+
} from '@rango-dev/ui';
|
|
13
|
+
import React, { useEffect, useState } from 'react';
|
|
14
|
+
|
|
15
|
+
import { WIDGET_UI_ID } from '../../constants';
|
|
16
|
+
import { namespaces } from '../../constants/namespaces';
|
|
17
|
+
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
18
|
+
import {
|
|
19
|
+
LogoContainer,
|
|
20
|
+
Spinner,
|
|
21
|
+
WalletImageContainer,
|
|
22
|
+
} from '../WalletModal/WalletModalContent.styles';
|
|
23
|
+
|
|
24
|
+
import {
|
|
25
|
+
derivationPathInputStyles,
|
|
26
|
+
InputLabel,
|
|
27
|
+
InputsContainer,
|
|
28
|
+
} from './WalletDerivationPathModal.styles';
|
|
29
|
+
|
|
30
|
+
const customDerivationPath: DerivationPath = {
|
|
31
|
+
id: 'custom',
|
|
32
|
+
label: 'Custom',
|
|
33
|
+
generateDerivationPath: (index: string) => index,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function getDerivationPaths(selectedNamespace?: Namespace) {
|
|
37
|
+
const selectedNamespaceDerivationPaths = selectedNamespace
|
|
38
|
+
? namespaces[selectedNamespace].derivationPaths
|
|
39
|
+
: null;
|
|
40
|
+
|
|
41
|
+
const derivationPaths: DerivationPath[] = !!selectedNamespaceDerivationPaths
|
|
42
|
+
? [...selectedNamespaceDerivationPaths, customDerivationPath]
|
|
43
|
+
: [];
|
|
44
|
+
|
|
45
|
+
return derivationPaths;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function WalletDerivationPathModal(props: PropTypes) {
|
|
49
|
+
const { onClose, onConfirm, selectedNamespace, image, type, open } = props;
|
|
50
|
+
|
|
51
|
+
const [selectedDerivationPathId, setSelectedDerivationPathId] = useState<
|
|
52
|
+
string | null
|
|
53
|
+
>(null);
|
|
54
|
+
const [derivationPathIndex, setDerivationPathIndex] = useState('0');
|
|
55
|
+
|
|
56
|
+
const isCustomOptionSelected =
|
|
57
|
+
selectedDerivationPathId === customDerivationPath.id;
|
|
58
|
+
|
|
59
|
+
const derivationPaths = getDerivationPaths(selectedNamespace);
|
|
60
|
+
|
|
61
|
+
const handleDerivationPathItemClick = ({ value }: { value: string }) => {
|
|
62
|
+
const selectedDerivationPath = derivationPaths?.find(
|
|
63
|
+
(derivationPath) => derivationPath.id === value
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (selectedDerivationPath) {
|
|
67
|
+
setSelectedDerivationPathId(selectedDerivationPath.id);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const handleConfirm = () => {
|
|
72
|
+
const selectedDerivationPath = derivationPaths.find(
|
|
73
|
+
(derivationPath) => derivationPath.id === selectedDerivationPathId
|
|
74
|
+
);
|
|
75
|
+
if (selectedDerivationPath) {
|
|
76
|
+
onConfirm(
|
|
77
|
+
selectedDerivationPath.generateDerivationPath(derivationPathIndex)
|
|
78
|
+
);
|
|
79
|
+
} else {
|
|
80
|
+
// Unreachable code
|
|
81
|
+
throw new Error('selectedDerivationPath can not be undefined');
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
setSelectedDerivationPathId(
|
|
87
|
+
getDerivationPaths(selectedNamespace)[0]?.id || null
|
|
88
|
+
);
|
|
89
|
+
}, [selectedNamespace]);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<WatermarkedModal
|
|
93
|
+
open={open}
|
|
94
|
+
onClose={onClose}
|
|
95
|
+
container={
|
|
96
|
+
document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
|
|
97
|
+
}>
|
|
98
|
+
<Divider size={20} />
|
|
99
|
+
<MessageBox
|
|
100
|
+
type="info"
|
|
101
|
+
title={i18n.t('Select Derivation Path')}
|
|
102
|
+
description={i18n.t(
|
|
103
|
+
`In order to connect to ${type}, you must first select a Derivation Path`
|
|
104
|
+
)}
|
|
105
|
+
icon={
|
|
106
|
+
<LogoContainer>
|
|
107
|
+
<WalletImageContainer>
|
|
108
|
+
<Image src={image} size={45} />
|
|
109
|
+
</WalletImageContainer>
|
|
110
|
+
<Spinner />
|
|
111
|
+
</LogoContainer>
|
|
112
|
+
}
|
|
113
|
+
/>
|
|
114
|
+
|
|
115
|
+
<InputsContainer>
|
|
116
|
+
<InputLabel variant="body" size="xsmall" color="$neutral600">
|
|
117
|
+
{i18n.t('Choose Derivation Path Template')}
|
|
118
|
+
</InputLabel>
|
|
119
|
+
<Select
|
|
120
|
+
value={selectedDerivationPathId || ''}
|
|
121
|
+
options={derivationPaths.map((derivationPath) => ({
|
|
122
|
+
value: derivationPath.id,
|
|
123
|
+
label: derivationPath.label,
|
|
124
|
+
}))}
|
|
125
|
+
variant="filled"
|
|
126
|
+
handleItemClick={handleDerivationPathItemClick}
|
|
127
|
+
styles={{ trigger: derivationPathInputStyles }}
|
|
128
|
+
/>
|
|
129
|
+
<Divider size={20} />
|
|
130
|
+
<InputLabel variant="body" size="xsmall" color="$neutral600">
|
|
131
|
+
{isCustomOptionSelected
|
|
132
|
+
? i18n.t('Enter Path')
|
|
133
|
+
: i18n.t('Enter Index')}
|
|
134
|
+
</InputLabel>
|
|
135
|
+
<TextField
|
|
136
|
+
type={isCustomOptionSelected ? 'text' : 'number'}
|
|
137
|
+
variant="contained"
|
|
138
|
+
value={derivationPathIndex}
|
|
139
|
+
onChange={(event) => setDerivationPathIndex(event.target.value)}
|
|
140
|
+
style={derivationPathInputStyles}
|
|
141
|
+
/>
|
|
142
|
+
</InputsContainer>
|
|
143
|
+
|
|
144
|
+
<Button
|
|
145
|
+
type="primary"
|
|
146
|
+
onClick={handleConfirm}
|
|
147
|
+
disabled={
|
|
148
|
+
!derivationPaths || !selectedDerivationPathId || !derivationPathIndex
|
|
149
|
+
}>
|
|
150
|
+
{i18n.t('Confirm')}
|
|
151
|
+
</Button>
|
|
152
|
+
</WatermarkedModal>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WalletDerivationPathModal } from './WalletDerivationPathModal';
|
|
@@ -6,16 +6,17 @@ import { i18n } from '@lingui/core';
|
|
|
6
6
|
import {
|
|
7
7
|
Button,
|
|
8
8
|
Checkbox,
|
|
9
|
+
Divider,
|
|
9
10
|
Image,
|
|
10
11
|
ListItemButton,
|
|
11
12
|
MessageBox,
|
|
12
13
|
Radio,
|
|
13
14
|
RadioRoot,
|
|
14
15
|
} from '@rango-dev/ui';
|
|
15
|
-
import { namespaceMainBlockchain } from '@rango-dev/wallets-shared';
|
|
16
16
|
import React, { useMemo, useState } from 'react';
|
|
17
17
|
|
|
18
18
|
import { WIDGET_UI_ID } from '../../constants';
|
|
19
|
+
import { namespaces } from '../../constants/namespaces';
|
|
19
20
|
import { useAppStore } from '../../store/AppStore';
|
|
20
21
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
21
22
|
import { WalletImageContainer } from '../HeaderButtons/HeaderButtons.styles';
|
|
@@ -35,7 +36,7 @@ const getBlockchainLogo = (
|
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
export function WalletNamespacesModal(props: PropTypes) {
|
|
38
|
-
const { singleNamespace,
|
|
39
|
+
const { singleNamespace, availableNamespaces } = props;
|
|
39
40
|
|
|
40
41
|
const [selectedNamespaces, setSelectedNamespaces] = useState<Namespace[]>([]);
|
|
41
42
|
|
|
@@ -43,14 +44,15 @@ export function WalletNamespacesModal(props: PropTypes) {
|
|
|
43
44
|
|
|
44
45
|
const namespacesInfo = useMemo(
|
|
45
46
|
() =>
|
|
46
|
-
|
|
47
|
+
availableNamespaces?.map((namespace) => ({
|
|
47
48
|
name: namespace,
|
|
48
49
|
logo: getBlockchainLogo(
|
|
49
50
|
blockchains,
|
|
50
|
-
|
|
51
|
+
namespaces[namespace].mainBlockchain
|
|
51
52
|
),
|
|
53
|
+
title: namespaces[namespace].title,
|
|
52
54
|
})),
|
|
53
|
-
[
|
|
55
|
+
[availableNamespaces]
|
|
54
56
|
);
|
|
55
57
|
|
|
56
58
|
const onSelect = (namespace: Namespace) => {
|
|
@@ -80,6 +82,7 @@ export function WalletNamespacesModal(props: PropTypes) {
|
|
|
80
82
|
container={
|
|
81
83
|
document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
|
|
82
84
|
}>
|
|
85
|
+
<Divider size={20} />
|
|
83
86
|
<MessageBox
|
|
84
87
|
type="info"
|
|
85
88
|
title={i18n.t('Select chain types')}
|
|
@@ -102,7 +105,7 @@ export function WalletNamespacesModal(props: PropTypes) {
|
|
|
102
105
|
<ListItemButton
|
|
103
106
|
key={namespaceInfoItem.name}
|
|
104
107
|
id={namespaceInfoItem.name}
|
|
105
|
-
title={namespaceInfoItem.
|
|
108
|
+
title={namespaceInfoItem.title}
|
|
106
109
|
hasDivider
|
|
107
110
|
style={{ height: 60 }}
|
|
108
111
|
onClick={() => onSelect(namespaceInfoItem.name)}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { DerivationPath } from '@rango-dev/wallets-shared';
|
|
2
|
+
|
|
3
|
+
import { Namespace } from '@rango-dev/wallets-shared';
|
|
4
|
+
|
|
5
|
+
export const namespaces: Record<
|
|
6
|
+
Namespace,
|
|
7
|
+
{ mainBlockchain: string; title: string; derivationPaths?: DerivationPath[] }
|
|
8
|
+
> = {
|
|
9
|
+
[Namespace.Evm]: {
|
|
10
|
+
mainBlockchain: 'ETH',
|
|
11
|
+
title: 'Ethereum',
|
|
12
|
+
derivationPaths: [
|
|
13
|
+
{
|
|
14
|
+
id: 'metamask',
|
|
15
|
+
label: `Metamask (m/44'/60'/0'/0/index)`,
|
|
16
|
+
generateDerivationPath: (index: string) => `44'/60'/0'/0/${index}`,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'ledgerLive',
|
|
20
|
+
label: `LedgerLive (m/44'/60'/index'/0/0)`,
|
|
21
|
+
generateDerivationPath: (index: string) => `44'/60'/${index}'/0/0`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: 'legacy',
|
|
25
|
+
label: `Legacy (m/44'/60'/0'/index)`,
|
|
26
|
+
generateDerivationPath: (index: string) => `44'/60'/0'/${index}`,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
[Namespace.Solana]: {
|
|
31
|
+
mainBlockchain: 'SOLANA',
|
|
32
|
+
title: 'Solana',
|
|
33
|
+
derivationPaths: [
|
|
34
|
+
{
|
|
35
|
+
id: `(m/44'/501'/index')`,
|
|
36
|
+
label: `(m/44'/501'/index')`,
|
|
37
|
+
generateDerivationPath: (index: string) => `44'/501'/${index}'`,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: `(m/44'/501'/0'/index)`,
|
|
41
|
+
label: `(m/44'/501'/0'/index)`,
|
|
42
|
+
generateDerivationPath: (index: string) => `44'/501'/0'/${index}`,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
[Namespace.Cosmos]: {
|
|
47
|
+
mainBlockchain: 'COSMOS',
|
|
48
|
+
title: 'Cosmos',
|
|
49
|
+
},
|
|
50
|
+
[Namespace.Utxo]: {
|
|
51
|
+
mainBlockchain: 'BTC',
|
|
52
|
+
title: 'Utxo',
|
|
53
|
+
},
|
|
54
|
+
[Namespace.Starknet]: {
|
|
55
|
+
title: 'Starknet',
|
|
56
|
+
mainBlockchain: 'STARKNET',
|
|
57
|
+
},
|
|
58
|
+
[Namespace.Tron]: {
|
|
59
|
+
title: 'Tron',
|
|
60
|
+
mainBlockchain: 'TRON',
|
|
61
|
+
},
|
|
62
|
+
};
|