@rango-dev/widget-embedded 0.29.1-next.2 → 0.29.1-next.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/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/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts +0 -2
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts.map +1 -1
- 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 +2 -1
- 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 +8 -0
- 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/utils/common.d.ts +2 -0
- 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/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/QueueManager.tsx +4 -0
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +19 -9
- package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +5 -5
- package/src/components/NotificationContent/NotificationContent.tsx +12 -113
- package/src/components/Quote/Quote.tsx +18 -25
- package/src/components/Quote/QuoteCostDetails.tsx +10 -9
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +9 -10
- package/src/components/TokenList/TokenList.tsx +5 -5
- package/src/components/WalletNamespacesModal/WalletNamespacesModal.tsx +2 -10
- package/src/constants/quote.ts +11 -9
- package/src/constants/routing.ts +0 -2
- package/src/containers/Inputs/Inputs.tsx +4 -4
- package/src/containers/Wallets/Wallets.tsx +2 -1
- 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 +9 -7
- 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 +23 -16
- package/src/services/eventEmitter.ts +11 -0
- package/src/store/notification.ts +3 -1
- package/src/store/quote.ts +63 -1
- package/src/store/slices/config.ts +4 -0
- package/src/store/slices/settings.ts +6 -0
- package/src/store/wallets.ts +194 -173
- package/src/types/config.ts +9 -0
- package/src/types/event.ts +89 -0
- package/src/types/index.ts +1 -0
- package/src/utils/common.ts +12 -1
- package/src/utils/meta.ts +8 -0
- package/src/utils/numbers.ts +0 -12
- package/src/utils/providers.ts +4 -0
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.29.1-next.
|
|
3
|
+
"version": "0.29.1-next.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"@lingui/core": "4.2.1",
|
|
26
26
|
"@lingui/react": "4.2.1",
|
|
27
27
|
"@rango-dev/logging-core": "^0.4.0",
|
|
28
|
-
"@rango-dev/provider-all": "^0.34.1-next.
|
|
28
|
+
"@rango-dev/provider-all": "^0.34.1-next.7",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.26.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.34.1-next.
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.34.1-next.7",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
32
|
-
"@rango-dev/signer-solana": "^0.29.1-next.
|
|
33
|
-
"@rango-dev/ui": "^0.35.1-next.
|
|
34
|
-
"@rango-dev/wallets-react": "^0.20.1-next.
|
|
35
|
-
"@rango-dev/wallets-shared": "^0.34.1-next.
|
|
32
|
+
"@rango-dev/signer-solana": "^0.29.1-next.1",
|
|
33
|
+
"@rango-dev/ui": "^0.35.1-next.10",
|
|
34
|
+
"@rango-dev/wallets-react": "^0.20.1-next.5",
|
|
35
|
+
"@rango-dev/wallets-shared": "^0.34.1-next.5",
|
|
36
36
|
"bignumber.js": "^9.1.1",
|
|
37
37
|
"copy-to-clipboard": "^3.3.3",
|
|
38
38
|
"dayjs": "^1.11.7",
|
package/src/QueueManager.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import { convertEvmBlockchainMetaToEvmChainInfo } from '@rango-dev/wallets-share
|
|
|
12
12
|
import { isEvmBlockchain } from 'rango-types';
|
|
13
13
|
import React, { useMemo } from 'react';
|
|
14
14
|
|
|
15
|
+
import { eventEmitter } from './services/eventEmitter';
|
|
15
16
|
import { useAppStore } from './store/AppStore';
|
|
16
17
|
import { useUiStore } from './store/ui';
|
|
17
18
|
import { useWalletsStore } from './store/wallets';
|
|
@@ -32,6 +33,9 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
32
33
|
return makeQueueDefinition({
|
|
33
34
|
API_KEY: props.apiKey || getConfig('API_KEY'),
|
|
34
35
|
BASE_URL: getConfig('BASE_URL'),
|
|
36
|
+
emitter: {
|
|
37
|
+
emit: eventEmitter.emit,
|
|
38
|
+
},
|
|
35
39
|
});
|
|
36
40
|
}, [props.apiKey]);
|
|
37
41
|
|
|
@@ -18,7 +18,13 @@ import {
|
|
|
18
18
|
Typography,
|
|
19
19
|
WalletIcon,
|
|
20
20
|
} from '@rango-dev/ui';
|
|
21
|
-
import React, {
|
|
21
|
+
import React, {
|
|
22
|
+
useCallback,
|
|
23
|
+
useEffect,
|
|
24
|
+
useMemo,
|
|
25
|
+
useRef,
|
|
26
|
+
useState,
|
|
27
|
+
} from 'react';
|
|
22
28
|
import { useNavigate } from 'react-router-dom';
|
|
23
29
|
|
|
24
30
|
import { WIDGET_UI_ID } from '../../constants';
|
|
@@ -87,10 +93,14 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
87
93
|
|
|
88
94
|
const isFirefox = navigator?.userAgent.includes('Firefox');
|
|
89
95
|
|
|
90
|
-
const quoteWallets =
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
96
|
+
const quoteWallets = useMemo(
|
|
97
|
+
() =>
|
|
98
|
+
getQuoteWallets({
|
|
99
|
+
filter: 'all',
|
|
100
|
+
quote: selectedQuote,
|
|
101
|
+
}),
|
|
102
|
+
[selectedQuote]
|
|
103
|
+
);
|
|
94
104
|
|
|
95
105
|
const requiredWallets = getQuoteWallets({
|
|
96
106
|
filter: 'required',
|
|
@@ -113,7 +123,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
113
123
|
quoteWallets.includes(connectedWallet.chain)
|
|
114
124
|
);
|
|
115
125
|
}),
|
|
116
|
-
[connectedWallets
|
|
126
|
+
[connectedWallets, quoteWallets]
|
|
117
127
|
);
|
|
118
128
|
|
|
119
129
|
const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
|
|
@@ -333,7 +343,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
333
343
|
);
|
|
334
344
|
return nextState;
|
|
335
345
|
});
|
|
336
|
-
}, [connectedWallets
|
|
346
|
+
}, [connectedWallets, quoteWallets]);
|
|
337
347
|
|
|
338
348
|
useEffect(() => {
|
|
339
349
|
const nextState: typeof nextSelectedWallets = [];
|
|
@@ -353,7 +363,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
353
363
|
});
|
|
354
364
|
setNextSelectedWallets(nextState);
|
|
355
365
|
}
|
|
356
|
-
}, [connectedWallets
|
|
366
|
+
}, [connectedWallets, nextSelectedWallets]);
|
|
357
367
|
|
|
358
368
|
const modalContainer = document.getElementById(
|
|
359
369
|
WIDGET_UI_ID.SWAP_BOX_ID
|
|
@@ -513,7 +523,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
513
523
|
/>
|
|
514
524
|
</ListContainer>
|
|
515
525
|
{!isLastWallet && <Divider size={32} />}
|
|
516
|
-
{isLastWallet && config?.customDestination && (
|
|
526
|
+
{isLastWallet && config?.customDestination !== false && (
|
|
517
527
|
<CustomDestination>
|
|
518
528
|
<CustomCollapsible
|
|
519
529
|
onOpenChange={
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
16
16
|
} from '../../constants/routing';
|
|
17
17
|
import { getContainer } from '../../utils/common';
|
|
18
|
-
import {
|
|
18
|
+
import { numberToString } from '../../utils/numbers';
|
|
19
19
|
|
|
20
20
|
import { calculateGroupsSoFar } from './HistoryGroupedList.helpers';
|
|
21
21
|
import {
|
|
@@ -130,7 +130,7 @@ export function HistoryGroupedList(props: PropTypes) {
|
|
|
130
130
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
131
131
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
132
132
|
),
|
|
133
|
-
realAmount:
|
|
133
|
+
realAmount: swap.inputAmount,
|
|
134
134
|
},
|
|
135
135
|
to: {
|
|
136
136
|
token: {
|
|
@@ -147,10 +147,10 @@ export function HistoryGroupedList(props: PropTypes) {
|
|
|
147
147
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
148
148
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
149
149
|
),
|
|
150
|
-
realAmount:
|
|
150
|
+
realAmount:
|
|
151
151
|
lastStep.outputAmount ||
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
lastStep.expectedOutputAmountHumanReadable ||
|
|
153
|
+
'',
|
|
154
154
|
},
|
|
155
155
|
}}
|
|
156
156
|
/>
|
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
import type { Notification } from '../../types/notification';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { EventSeverity } from '@rango-dev/queue-manager-rango-preset';
|
|
5
|
-
import {
|
|
6
|
-
ChainToken,
|
|
7
|
-
ChevronRightIcon,
|
|
8
|
-
Divider,
|
|
9
|
-
Typography,
|
|
10
|
-
} from '@rango-dev/ui';
|
|
3
|
+
import { Notifications } from '@rango-dev/ui';
|
|
11
4
|
import React from 'react';
|
|
12
5
|
import { useNavigate } from 'react-router-dom';
|
|
13
6
|
|
|
14
7
|
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
15
8
|
import { useAppStore } from '../../store/AppStore';
|
|
16
9
|
import { useNotificationStore } from '../../store/notification';
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
ClearAllButton,
|
|
20
|
-
Container,
|
|
21
|
-
Header,
|
|
22
|
-
IconContainer,
|
|
23
|
-
Images,
|
|
24
|
-
List,
|
|
25
|
-
ListItem,
|
|
26
|
-
} from './NotificationContent.styles';
|
|
27
|
-
import { NotificationNotFound } from './NotificationNotFound';
|
|
28
|
-
|
|
29
|
-
const MAX_NOTIFICATIONS_DISPLAYED = 4;
|
|
10
|
+
import { getBlockchainImage } from '../../utils/meta';
|
|
30
11
|
|
|
31
12
|
export function NotificationContent() {
|
|
32
13
|
const navigate = useNavigate();
|
|
@@ -36,102 +17,20 @@ export function NotificationContent() {
|
|
|
36
17
|
const notifications: Notification[] = getNotifications();
|
|
37
18
|
const blockchains = useAppStore().blockchains();
|
|
38
19
|
const { findToken } = useAppStore();
|
|
39
|
-
const sortedNotification = notifications
|
|
40
|
-
.sort((a, b) => b.creationTime - a.creationTime)
|
|
41
|
-
.slice(0, MAX_NOTIFICATIONS_DISPLAYED);
|
|
42
20
|
|
|
43
|
-
const
|
|
21
|
+
const onClickItem = (requestId: Notification['requestId']) => {
|
|
44
22
|
navigate(`${navigationRoutes.swaps}/${requestId}`);
|
|
45
23
|
};
|
|
46
24
|
|
|
47
25
|
return (
|
|
48
|
-
<
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
size="xsmall"
|
|
58
|
-
onClick={clearNotifications}>
|
|
59
|
-
<Typography variant="body" size="xsmall">
|
|
60
|
-
{i18n.t('Clear all')}
|
|
61
|
-
</Typography>
|
|
62
|
-
</ClearAllButton>
|
|
63
|
-
</Header>
|
|
64
|
-
<Divider direction="vertical" size={4} />
|
|
65
|
-
</>
|
|
66
|
-
)}
|
|
67
|
-
{sortedNotification.length ? (
|
|
68
|
-
<List>
|
|
69
|
-
{sortedNotification.map((notificationItem, index) => {
|
|
70
|
-
const { route, requestId, event } = notificationItem;
|
|
71
|
-
const fromToken = findToken(route.from);
|
|
72
|
-
|
|
73
|
-
const fromBlockchain = blockchains.find(
|
|
74
|
-
(blockchainItem) => blockchainItem.name === route.from.blockchain
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const toToken = findToken(route.to);
|
|
78
|
-
|
|
79
|
-
const toBlockchain = blockchains.find(
|
|
80
|
-
(blockchainItem) => blockchainItem.name === route.to.blockchain
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
return (
|
|
84
|
-
<React.Fragment key={requestId}>
|
|
85
|
-
{index > 0 && <Divider size={4} />}
|
|
86
|
-
<ListItem
|
|
87
|
-
onClick={() => handleOnClick(requestId)}
|
|
88
|
-
actionRequired={
|
|
89
|
-
event.messageSeverity === EventSeverity.WARNING
|
|
90
|
-
}
|
|
91
|
-
title={
|
|
92
|
-
<Typography
|
|
93
|
-
variant="body"
|
|
94
|
-
size="small"
|
|
95
|
-
color={
|
|
96
|
-
event.messageSeverity === EventSeverity.WARNING
|
|
97
|
-
? '$foreground'
|
|
98
|
-
: '$neutral700'
|
|
99
|
-
}>
|
|
100
|
-
{i18n.t(event.message)}
|
|
101
|
-
</Typography>
|
|
102
|
-
}
|
|
103
|
-
id={requestId}
|
|
104
|
-
start={
|
|
105
|
-
<Images>
|
|
106
|
-
<div className="from-chain-token">
|
|
107
|
-
<ChainToken
|
|
108
|
-
tokenImage={fromToken ? fromToken.image : ''}
|
|
109
|
-
chainImage={fromBlockchain ? fromBlockchain.logo : ''}
|
|
110
|
-
size="small"
|
|
111
|
-
/>
|
|
112
|
-
</div>
|
|
113
|
-
<div className="to-chain-token">
|
|
114
|
-
<ChainToken
|
|
115
|
-
tokenImage={toToken ? toToken.image : ''}
|
|
116
|
-
chainImage={toBlockchain ? toBlockchain.logo : ''}
|
|
117
|
-
size="small"
|
|
118
|
-
/>
|
|
119
|
-
</div>
|
|
120
|
-
</Images>
|
|
121
|
-
}
|
|
122
|
-
end={
|
|
123
|
-
<IconContainer>
|
|
124
|
-
<ChevronRightIcon size={12} color="gray" />
|
|
125
|
-
</IconContainer>
|
|
126
|
-
}
|
|
127
|
-
/>
|
|
128
|
-
</React.Fragment>
|
|
129
|
-
);
|
|
130
|
-
})}
|
|
131
|
-
</List>
|
|
132
|
-
) : (
|
|
133
|
-
<NotificationNotFound />
|
|
134
|
-
)}
|
|
135
|
-
</Container>
|
|
26
|
+
<Notifications
|
|
27
|
+
list={notifications}
|
|
28
|
+
getBlockchainImage={(blockchain) =>
|
|
29
|
+
getBlockchainImage(blockchain, blockchains) ?? ''
|
|
30
|
+
}
|
|
31
|
+
getTokenImage={(token) => findToken(token)?.image ?? ''}
|
|
32
|
+
onClickItem={onClickItem}
|
|
33
|
+
onClearAll={clearNotifications}
|
|
34
|
+
/>
|
|
136
35
|
);
|
|
137
36
|
}
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
Divider,
|
|
9
9
|
FullExpandedQuote,
|
|
10
10
|
InfoIcon,
|
|
11
|
+
NumericTooltip,
|
|
11
12
|
QuoteTag,
|
|
12
13
|
StepDetails,
|
|
13
14
|
TokenAmount,
|
|
14
|
-
Tooltip,
|
|
15
15
|
Typography,
|
|
16
16
|
} from '@rango-dev/ui';
|
|
17
17
|
import BigNumber from 'bignumber.js';
|
|
@@ -40,7 +40,6 @@ import {
|
|
|
40
40
|
getSwapperDisplayName,
|
|
41
41
|
} from '../../utils/meta';
|
|
42
42
|
import {
|
|
43
|
-
formatTooltipNumbers,
|
|
44
43
|
numberToString,
|
|
45
44
|
roundedSecondsToString,
|
|
46
45
|
totalArrivalTime,
|
|
@@ -186,14 +185,10 @@ export function Quote(props: QuoteProps) {
|
|
|
186
185
|
USD_VALUE_MIN_DECIMALS,
|
|
187
186
|
USD_VALUE_MAX_DECIMALS
|
|
188
187
|
),
|
|
189
|
-
realValue:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
new BigNumber(swap.from.usdPrice ?? 0).multipliedBy(
|
|
194
|
-
swap.fromAmount
|
|
195
|
-
)
|
|
196
|
-
),
|
|
188
|
+
realValue: index === 0 ? input.value : swap.fromAmount,
|
|
189
|
+
realUsdValue: new BigNumber(swap.from.usdPrice ?? 0)
|
|
190
|
+
.multipliedBy(swap.fromAmount)
|
|
191
|
+
.toString(),
|
|
197
192
|
},
|
|
198
193
|
},
|
|
199
194
|
to: {
|
|
@@ -216,10 +211,10 @@ export function Quote(props: QuoteProps) {
|
|
|
216
211
|
USD_VALUE_MIN_DECIMALS,
|
|
217
212
|
USD_VALUE_MAX_DECIMALS
|
|
218
213
|
),
|
|
219
|
-
realValue:
|
|
220
|
-
realUsdValue:
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
realValue: swap.toAmount,
|
|
215
|
+
realUsdValue: new BigNumber(swap.to.usdPrice ?? 0)
|
|
216
|
+
.multipliedBy(swap.toAmount)
|
|
217
|
+
.toString(),
|
|
223
218
|
},
|
|
224
219
|
},
|
|
225
220
|
state: stepState,
|
|
@@ -343,8 +338,8 @@ export function Quote(props: QuoteProps) {
|
|
|
343
338
|
outputPrice={{
|
|
344
339
|
value: roundedOutput,
|
|
345
340
|
usdValue: roundedOutputUsdValue,
|
|
346
|
-
realValue:
|
|
347
|
-
realUsdValue:
|
|
341
|
+
realValue: output.value,
|
|
342
|
+
realUsdValue: output.usdValue,
|
|
348
343
|
}}
|
|
349
344
|
/>
|
|
350
345
|
) : (
|
|
@@ -414,8 +409,8 @@ export function Quote(props: QuoteProps) {
|
|
|
414
409
|
<BasicInfoOutput size="small" variant="body">
|
|
415
410
|
{`${roundedInput} ${steps[0].from.token.displayName} = `}
|
|
416
411
|
</BasicInfoOutput>
|
|
417
|
-
<
|
|
418
|
-
content={
|
|
412
|
+
<NumericTooltip
|
|
413
|
+
content={output.value}
|
|
419
414
|
container={container}
|
|
420
415
|
open={!output.value ? false : undefined}>
|
|
421
416
|
<BasicInfoOutput size="small" variant="body">
|
|
@@ -424,16 +419,14 @@ export function Quote(props: QuoteProps) {
|
|
|
424
419
|
steps[steps.length - 1].to.token.displayName
|
|
425
420
|
}`}
|
|
426
421
|
</BasicInfoOutput>
|
|
427
|
-
</
|
|
422
|
+
</NumericTooltip>
|
|
428
423
|
</ContainerInfoOutput>
|
|
429
|
-
<
|
|
430
|
-
content={formatTooltipNumbers(output.usdValue)}
|
|
431
|
-
container={container}>
|
|
424
|
+
<NumericTooltip content={output.usdValue} container={container}>
|
|
432
425
|
<Divider size={2} direction="horizontal" />
|
|
433
426
|
<Typography color="$neutral600" size="xsmall" variant="body">
|
|
434
427
|
{`($${roundedOutputUsdValue})`}
|
|
435
428
|
</Typography>
|
|
436
|
-
</
|
|
429
|
+
</NumericTooltip>
|
|
437
430
|
</div>
|
|
438
431
|
)}
|
|
439
432
|
{type === 'list-item' && (
|
|
@@ -444,8 +437,8 @@ export function Quote(props: QuoteProps) {
|
|
|
444
437
|
price={{
|
|
445
438
|
value: roundedOutput,
|
|
446
439
|
usdValue: roundedOutputUsdValue,
|
|
447
|
-
realValue:
|
|
448
|
-
realUsdValue:
|
|
440
|
+
realValue: output.value,
|
|
441
|
+
realUsdValue: output.usdValue,
|
|
449
442
|
}}
|
|
450
443
|
token={{
|
|
451
444
|
displayName: steps[numberOfSteps - 1].to.token.displayName,
|
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
CloseIcon,
|
|
9
9
|
Divider,
|
|
10
10
|
IconButton,
|
|
11
|
+
NumericTooltip,
|
|
11
12
|
QuoteCost,
|
|
12
|
-
Tooltip,
|
|
13
13
|
Typography,
|
|
14
14
|
} from '@rango-dev/ui';
|
|
15
15
|
import React, { useState } from 'react';
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { getFeeLabel } from '../../constants/quote';
|
|
18
18
|
import {
|
|
19
19
|
GAS_FEE_MAX_DECIMALS,
|
|
20
20
|
GAS_FEE_MIN_DECIMALS,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
USD_VALUE_MIN_DECIMALS,
|
|
23
23
|
} from '../../constants/routing';
|
|
24
24
|
import { getContainer } from '../../utils/common';
|
|
25
|
-
import {
|
|
25
|
+
import { numberToString } from '../../utils/numbers';
|
|
26
26
|
import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
|
|
27
27
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
28
28
|
import { CustomCollapsible } from '../CustomCollapsible/CustomCollapsible';
|
|
@@ -115,11 +115,9 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
115
115
|
variant="label"
|
|
116
116
|
size="medium"
|
|
117
117
|
color="neutral600">
|
|
118
|
-
{
|
|
118
|
+
{getFeeLabel(payableFeesKey as NameOfFees, i18n.t)}
|
|
119
119
|
</Typography>
|
|
120
|
-
<
|
|
121
|
-
content={formatTooltipNumbers(fee.amount)}
|
|
122
|
-
container={container}>
|
|
120
|
+
<NumericTooltip content={fee.amount} container={container}>
|
|
123
121
|
<Typography variant="label" size="medium">
|
|
124
122
|
{numberToString(
|
|
125
123
|
fee.amount,
|
|
@@ -134,7 +132,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
134
132
|
)}
|
|
135
133
|
)
|
|
136
134
|
</Typography>
|
|
137
|
-
</
|
|
135
|
+
</NumericTooltip>
|
|
138
136
|
</FeeSection>
|
|
139
137
|
);
|
|
140
138
|
})
|
|
@@ -184,7 +182,10 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
184
182
|
{Object.entries(feesGroup.nonePayable).map(
|
|
185
183
|
([nonPayableFeesKey, fees], index) => {
|
|
186
184
|
const totalFeeInUsd = getTotalFeesInUsd(fees);
|
|
187
|
-
const label =
|
|
185
|
+
const label = getFeeLabel(
|
|
186
|
+
nonPayableFeesKey as NameOfFees,
|
|
187
|
+
i18n.t
|
|
188
|
+
);
|
|
188
189
|
const key = `non-payable-fee-${index}`;
|
|
189
190
|
return (
|
|
190
191
|
<NonPayableFee
|
|
@@ -42,7 +42,6 @@ import { useQuoteStore } from '../../store/quote';
|
|
|
42
42
|
import { useUiStore } from '../../store/ui';
|
|
43
43
|
import { getContainer } from '../../utils/common';
|
|
44
44
|
import {
|
|
45
|
-
formatTooltipNumbers,
|
|
46
45
|
numberToString,
|
|
47
46
|
roundedSecondsToString,
|
|
48
47
|
totalArrivalTime,
|
|
@@ -206,14 +205,14 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
206
205
|
);
|
|
207
206
|
|
|
208
207
|
const realOutputUsdValue = outputAmount
|
|
209
|
-
?
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
? new BigNumber(outputAmount)
|
|
209
|
+
.multipliedBy(lastStep.toUsdPrice || 0)
|
|
210
|
+
.toString()
|
|
212
211
|
: '';
|
|
213
212
|
|
|
214
|
-
const realInputUsdValue =
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
const realInputUsdValue = new BigNumber(swap.inputAmount)
|
|
214
|
+
.multipliedBy(firstStep.fromUsdPrice || 0)
|
|
215
|
+
.toString();
|
|
217
216
|
|
|
218
217
|
const percentageChange = getPriceImpact(inputUsdValue, outputUsdValue);
|
|
219
218
|
|
|
@@ -272,7 +271,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
272
271
|
return (
|
|
273
272
|
<Layout
|
|
274
273
|
header={{
|
|
275
|
-
title: i18n.t('Swap
|
|
274
|
+
title: i18n.t('Swap Details'),
|
|
276
275
|
onCancel:
|
|
277
276
|
swap.status === 'running' ? () => setModalState('cancel') : undefined,
|
|
278
277
|
suffix: swap.status !== 'running' && (
|
|
@@ -338,7 +337,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
338
337
|
</div>
|
|
339
338
|
<div className={rowStyles()}>
|
|
340
339
|
<Typography variant="label" size="large" color="neutral700">
|
|
341
|
-
{
|
|
340
|
+
{swap.finishTime ? i18n.t('Finished at') : i18n.t('Created at')}
|
|
342
341
|
</Typography>
|
|
343
342
|
<Typography variant="label" size="small" color="neutral700">
|
|
344
343
|
{swapDate}
|
|
@@ -458,7 +457,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
458
457
|
)}
|
|
459
458
|
usdValue={outputUsdValue}
|
|
460
459
|
realUsdValue={realOutputUsdValue}
|
|
461
|
-
realValue={
|
|
460
|
+
realValue={outputAmount || ''}
|
|
462
461
|
percentageChange={numberToString(
|
|
463
462
|
percentageChange,
|
|
464
463
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
@@ -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
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PropTypes } from './WalletNamespacesModal.types';
|
|
2
|
+
import type { Namespace } from '@rango-dev/wallets-shared';
|
|
2
3
|
import type { BlockchainMeta } from 'rango-sdk';
|
|
3
4
|
|
|
4
5
|
import { i18n } from '@lingui/core';
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
Radio,
|
|
12
13
|
RadioRoot,
|
|
13
14
|
} from '@rango-dev/ui';
|
|
14
|
-
import {
|
|
15
|
+
import { namespaceMainBlockchain } from '@rango-dev/wallets-shared';
|
|
15
16
|
import React, { useMemo, useState } from 'react';
|
|
16
17
|
|
|
17
18
|
import { WIDGET_UI_ID } from '../../constants';
|
|
@@ -25,15 +26,6 @@ import {
|
|
|
25
26
|
|
|
26
27
|
import { NamespaceList } from './WalletNamespacesModal.styles';
|
|
27
28
|
|
|
28
|
-
export const namespaceMainBlockchain: Record<Namespace, string> = {
|
|
29
|
-
[Namespace.Evm]: 'ETH',
|
|
30
|
-
[Namespace.Solana]: 'SOLANA',
|
|
31
|
-
[Namespace.Cosmos]: 'COSMOS',
|
|
32
|
-
[Namespace.Utxo]: 'BTC',
|
|
33
|
-
[Namespace.Starknet]: 'STARKNET',
|
|
34
|
-
[Namespace.Tron]: 'TRON',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
29
|
const getBlockchainLogo = (
|
|
38
30
|
blockchains: BlockchainMeta[],
|
|
39
31
|
blockchainName: string
|
package/src/constants/quote.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import type { I18n } from '@lingui/core';
|
|
1
2
|
import type { SwapFee, TagValue } from 'rango-sdk';
|
|
2
3
|
|
|
3
|
-
import { i18n } from '@lingui/core';
|
|
4
|
-
|
|
5
4
|
export type NameOfFees =
|
|
6
5
|
| 'Swapper Fee'
|
|
7
6
|
| 'Affiliate Fee'
|
|
@@ -9,13 +8,16 @@ export type NameOfFees =
|
|
|
9
8
|
| 'Rango Fee'
|
|
10
9
|
| 'Network Fee';
|
|
11
10
|
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export function getFeeLabel(fee: NameOfFees, t: I18n['t']): string {
|
|
12
|
+
const data: Record<NameOfFees, string> = {
|
|
13
|
+
'Network Fee': t('Network Fee'),
|
|
14
|
+
'Swapper Fee': t('Protocol Fee'),
|
|
15
|
+
'Affiliate Fee': t('Affiliate Fee'),
|
|
16
|
+
'Outbound network fee': t('Outbound Fee'),
|
|
17
|
+
'Rango Fee': t('Rango Fee'),
|
|
18
|
+
};
|
|
19
|
+
return data[fee];
|
|
20
|
+
}
|
|
19
21
|
|
|
20
22
|
export type FeesGroup = {
|
|
21
23
|
payable: { [key in NameOfFees]?: SwapFee[] };
|
package/src/constants/routing.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { useQuoteStore } from '../../store/quote';
|
|
18
18
|
import { useWalletsStore } from '../../store/wallets';
|
|
19
19
|
import { getContainer } from '../../utils/common';
|
|
20
|
-
import {
|
|
20
|
+
import { numberToString } from '../../utils/numbers';
|
|
21
21
|
import { getPriceImpact, getPriceImpactLevel } from '../../utils/quote';
|
|
22
22
|
import { canComputePriceImpact } from '../../utils/swap';
|
|
23
23
|
import { formatBalance, isFetchingBalance } from '../../utils/wallets';
|
|
@@ -97,7 +97,7 @@ export function Inputs(props: PropTypes) {
|
|
|
97
97
|
),
|
|
98
98
|
realUsdValue: priceImpactInputCanNotBeComputed
|
|
99
99
|
? undefined
|
|
100
|
-
:
|
|
100
|
+
: inputUsdValue?.toString(),
|
|
101
101
|
error: priceImpactInputCanNotBeComputed
|
|
102
102
|
? errorMessages().unknownPriceError.impactTitle
|
|
103
103
|
: undefined,
|
|
@@ -144,10 +144,10 @@ export function Inputs(props: PropTypes) {
|
|
|
144
144
|
USD_VALUE_MIN_DECIMALS,
|
|
145
145
|
USD_VALUE_MAX_DECIMALS
|
|
146
146
|
),
|
|
147
|
-
realValue:
|
|
147
|
+
realValue: outputAmount?.toString(),
|
|
148
148
|
realUsdValue: priceImpactOutputCanNotBeComputed
|
|
149
149
|
? undefined
|
|
150
|
-
:
|
|
150
|
+
: outputUsdValue?.toString(),
|
|
151
151
|
error: priceImpactOutputCanNotBeComputed
|
|
152
152
|
? errorMessages().unknownPriceError.impactTitle
|
|
153
153
|
: undefined,
|