@rango-dev/widget-embedded 0.29.1-next.0 → 0.29.1-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +3 -3
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +15 -15
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +3 -3
- package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts +4 -4
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +8 -8
- package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts +6 -6
- package/dist/components/Layout/Layout.styles.d.ts +4 -4
- package/dist/components/Layout/PageContainer.d.ts +1 -1
- package/dist/components/Layout/ScrollableArea.d.ts +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +14 -14
- package/dist/components/NoResult/NoResult.styles.d.ts +4 -4
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +21 -21
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts +5 -5
- package/dist/components/Quote/QuoteSummary.styles.d.ts +2 -2
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +4 -4
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +10 -10
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +5 -5
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +4 -4
- package/dist/components/Quotes/Quotes.styles.d.ts +3 -3
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +3 -3
- package/dist/components/Slippage/Slippage.styles.d.ts +5 -5
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +15 -15
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +3 -3
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +2 -2
- package/dist/components/SwitchFromAndTo/SwitchFromAndTo.styles.d.ts +2 -2
- package/dist/components/TokenList/TokenList.styles.d.ts +18 -18
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts +4 -4
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts +0 -2
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts.map +1 -1
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.styles.d.ts +1 -1
- package/dist/containers/App/App.styles.d.ts +1 -1
- package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts +2 -2
- package/dist/containers/Inputs/Inputs.styles.d.ts +2 -2
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +3 -3
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +4 -2
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.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/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +2 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts +2 -2
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletList.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/store/notification.d.ts.map +1 -1
- package/dist/store/quote.d.ts +9 -3
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/selectors.d.ts +1 -1
- package/dist/store/selectors.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +5 -3
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +5 -4
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/test-utils/fixtures.d.ts +1 -1
- package/dist/test-utils/fixtures.d.ts.map +1 -1
- package/dist/types/config.d.ts +5 -1
- package/dist/types/config.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 +3 -1
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +4 -8
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +3 -4
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +4 -5
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +7 -7
- package/src/components/Layout/Layout.styles.ts +1 -1
- package/src/components/NotificationContent/NotificationContent.tsx +13 -119
- package/src/components/Quote/Quote.tsx +3 -3
- package/src/components/Quotes/Quotes.tsx +2 -2
- package/src/components/SwapDetails/SwapDetails.tsx +8 -3
- package/src/components/WalletNamespacesModal/WalletNamespacesModal.tsx +2 -10
- package/src/containers/Wallets/Wallets.tsx +3 -3
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +12 -3
- package/src/containers/WidgetInfo/WidgetInfo.tsx +7 -2
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +3 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +4 -2
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +3 -1
- package/src/hooks/useSubscribeToWidgetEvents/useSubscribeToWidgetEvents.ts +3 -3
- package/src/hooks/useSwapInput.ts +2 -2
- package/src/hooks/useSyncStoresWithConfig.ts +6 -7
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.ts +12 -26
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +19 -12
- package/src/hooks/useTheme.ts +1 -0
- package/src/hooks/useWalletList.ts +2 -4
- package/src/pages/WalletsPage.tsx +23 -16
- package/src/store/notification.ts +3 -1
- package/src/store/quote.ts +12 -7
- package/src/store/selectors.ts +6 -4
- package/src/store/slices/data.test.ts +9 -5
- package/src/store/slices/data.ts +26 -7
- package/src/store/slices/settings.ts +3 -0
- package/src/store/wallets.ts +9 -8
- package/src/test-utils/fixtures.ts +9 -2
- package/src/types/config.ts +7 -1
- package/src/utils/common.ts +12 -1
- package/src/utils/meta.ts +13 -6
- package/src/utils/quote.ts +12 -20
- package/src/utils/swap.ts +5 -25
- package/src/utils/wallets.ts +4 -28
- 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/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.10",
|
|
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.5",
|
|
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.5",
|
|
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.6",
|
|
34
|
+
"@rango-dev/wallets-react": "^0.20.1-next.4",
|
|
35
|
+
"@rango-dev/wallets-shared": "^0.34.1-next.4",
|
|
36
36
|
"bignumber.js": "^9.1.1",
|
|
37
37
|
"copy-to-clipboard": "^3.3.3",
|
|
38
38
|
"dayjs": "^1.11.7",
|
|
@@ -1,33 +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
|
-
import {
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
ClearAllButton,
|
|
21
|
-
Container,
|
|
22
|
-
Header,
|
|
23
|
-
IconContainer,
|
|
24
|
-
Images,
|
|
25
|
-
List,
|
|
26
|
-
ListItem,
|
|
27
|
-
} from './NotificationContent.styles';
|
|
28
|
-
import { NotificationNotFound } from './NotificationNotFound';
|
|
29
|
-
|
|
30
|
-
const MAX_NOTIFICATIONS_DISPLAYED = 4;
|
|
10
|
+
import { getBlockchainImage } from '../../utils/meta';
|
|
31
11
|
|
|
32
12
|
export function NotificationContent() {
|
|
33
13
|
const navigate = useNavigate();
|
|
@@ -36,107 +16,21 @@ export function NotificationContent() {
|
|
|
36
16
|
|
|
37
17
|
const notifications: Notification[] = getNotifications();
|
|
38
18
|
const blockchains = useAppStore().blockchains();
|
|
39
|
-
const
|
|
40
|
-
const sortedNotification = notifications
|
|
41
|
-
.sort((a, b) => b.creationTime - a.creationTime)
|
|
42
|
-
.slice(0, MAX_NOTIFICATIONS_DISPLAYED);
|
|
19
|
+
const { findToken } = useAppStore();
|
|
43
20
|
|
|
44
|
-
const
|
|
21
|
+
const onClickItem = (requestId: Notification['requestId']) => {
|
|
45
22
|
navigate(`${navigationRoutes.swaps}/${requestId}`);
|
|
46
23
|
};
|
|
47
24
|
|
|
48
25
|
return (
|
|
49
|
-
<
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
size="xsmall"
|
|
59
|
-
onClick={clearNotifications}>
|
|
60
|
-
<Typography variant="body" size="xsmall">
|
|
61
|
-
{i18n.t('Clear all')}
|
|
62
|
-
</Typography>
|
|
63
|
-
</ClearAllButton>
|
|
64
|
-
</Header>
|
|
65
|
-
<Divider direction="vertical" size={4} />
|
|
66
|
-
</>
|
|
67
|
-
)}
|
|
68
|
-
{sortedNotification.length ? (
|
|
69
|
-
<List>
|
|
70
|
-
{sortedNotification.map((notificationItem, index) => {
|
|
71
|
-
const { route, requestId, event } = notificationItem;
|
|
72
|
-
const fromToken = tokens.find((tokenItem) =>
|
|
73
|
-
areTokensEqual(tokenItem, route.from)
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const fromBlockchain = blockchains.find(
|
|
77
|
-
(blockchainItem) => blockchainItem.name === route.from.blockchain
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const toToken = tokens.find((tokenItem) =>
|
|
81
|
-
areTokensEqual(tokenItem, route.to)
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const toBlockchain = blockchains.find(
|
|
85
|
-
(blockchainItem) => blockchainItem.name === route.to.blockchain
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<React.Fragment key={requestId}>
|
|
90
|
-
{index > 0 && <Divider size={4} />}
|
|
91
|
-
<ListItem
|
|
92
|
-
onClick={() => handleOnClick(requestId)}
|
|
93
|
-
actionRequired={
|
|
94
|
-
event.messageSeverity === EventSeverity.WARNING
|
|
95
|
-
}
|
|
96
|
-
title={
|
|
97
|
-
<Typography
|
|
98
|
-
variant="body"
|
|
99
|
-
size="small"
|
|
100
|
-
color={
|
|
101
|
-
event.messageSeverity === EventSeverity.WARNING
|
|
102
|
-
? '$foreground'
|
|
103
|
-
: '$neutral700'
|
|
104
|
-
}>
|
|
105
|
-
{i18n.t(event.message)}
|
|
106
|
-
</Typography>
|
|
107
|
-
}
|
|
108
|
-
id={requestId}
|
|
109
|
-
start={
|
|
110
|
-
<Images>
|
|
111
|
-
<div className="from-chain-token">
|
|
112
|
-
<ChainToken
|
|
113
|
-
tokenImage={fromToken ? fromToken.image : ''}
|
|
114
|
-
chainImage={fromBlockchain ? fromBlockchain.logo : ''}
|
|
115
|
-
size="small"
|
|
116
|
-
/>
|
|
117
|
-
</div>
|
|
118
|
-
<div className="to-chain-token">
|
|
119
|
-
<ChainToken
|
|
120
|
-
tokenImage={toToken ? toToken.image : ''}
|
|
121
|
-
chainImage={toBlockchain ? toBlockchain.logo : ''}
|
|
122
|
-
size="small"
|
|
123
|
-
/>
|
|
124
|
-
</div>
|
|
125
|
-
</Images>
|
|
126
|
-
}
|
|
127
|
-
end={
|
|
128
|
-
<IconContainer>
|
|
129
|
-
<ChevronRightIcon size={12} color="gray" />
|
|
130
|
-
</IconContainer>
|
|
131
|
-
}
|
|
132
|
-
/>
|
|
133
|
-
</React.Fragment>
|
|
134
|
-
);
|
|
135
|
-
})}
|
|
136
|
-
</List>
|
|
137
|
-
) : (
|
|
138
|
-
<NotificationNotFound />
|
|
139
|
-
)}
|
|
140
|
-
</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
|
+
/>
|
|
141
35
|
);
|
|
142
36
|
}
|
|
@@ -88,7 +88,7 @@ export function Quote(props: QuoteProps) {
|
|
|
88
88
|
container: propContainer,
|
|
89
89
|
} = props;
|
|
90
90
|
const blockchains = useAppStore().blockchains();
|
|
91
|
-
const
|
|
91
|
+
const { findToken } = useAppStore();
|
|
92
92
|
const swappers = useAppStore().swappers();
|
|
93
93
|
const { customSlippage, slippage } = useAppStore();
|
|
94
94
|
const userSlippage = customSlippage || slippage;
|
|
@@ -303,7 +303,7 @@ export function Quote(props: QuoteProps) {
|
|
|
303
303
|
) : undefined,
|
|
304
304
|
time: roundedSecondsToString(swap.estimatedTimeInSeconds),
|
|
305
305
|
fee: numberToString(
|
|
306
|
-
getUsdFeeOfStep(swap,
|
|
306
|
+
getUsdFeeOfStep(swap, findToken),
|
|
307
307
|
GAS_FEE_MIN_DECIMALS,
|
|
308
308
|
GAS_FEE_MAX_DECIMALS
|
|
309
309
|
),
|
|
@@ -320,7 +320,7 @@ export function Quote(props: QuoteProps) {
|
|
|
320
320
|
const sortedQuoteTags = sortTags(props.quote.tags || []);
|
|
321
321
|
const showAllRoutesButton = !!onClickAllRoutes;
|
|
322
322
|
const totalTime = roundedSecondsToString(totalArrivalTime(quote?.swaps));
|
|
323
|
-
const totalFee = getTotalFeeInUsd(quote?.swaps ?? [],
|
|
323
|
+
const totalFee = getTotalFeeInUsd(quote?.swaps ?? [], findToken);
|
|
324
324
|
const fee = numberToString(
|
|
325
325
|
totalFee,
|
|
326
326
|
GAS_FEE_MIN_DECIMALS,
|
|
@@ -39,7 +39,7 @@ export function Quotes(props: PropTypes) {
|
|
|
39
39
|
error,
|
|
40
40
|
} = useQuoteStore();
|
|
41
41
|
const { slippage, customSlippage } = useAppStore();
|
|
42
|
-
const
|
|
42
|
+
const { findToken } = useAppStore();
|
|
43
43
|
const container = propContainer || getContainer();
|
|
44
44
|
const hasQuotes = !!quotes && quotes.results.length;
|
|
45
45
|
const userSlippage = customSlippage ?? slippage;
|
|
@@ -56,7 +56,7 @@ export function Quotes(props: PropTypes) {
|
|
|
56
56
|
fromToken,
|
|
57
57
|
toToken,
|
|
58
58
|
userSlippage,
|
|
59
|
-
|
|
59
|
+
findToken,
|
|
60
60
|
});
|
|
61
61
|
};
|
|
62
62
|
const showNoResultMessage =
|
|
@@ -47,7 +47,11 @@ import {
|
|
|
47
47
|
roundedSecondsToString,
|
|
48
48
|
totalArrivalTime,
|
|
49
49
|
} from '../../utils/numbers';
|
|
50
|
-
import {
|
|
50
|
+
import {
|
|
51
|
+
createRetryQuote,
|
|
52
|
+
getPriceImpact,
|
|
53
|
+
getPriceImpactLevel,
|
|
54
|
+
} from '../../utils/quote';
|
|
51
55
|
import {
|
|
52
56
|
getLastConvertedTokenInFailedSwap,
|
|
53
57
|
getSwapMessages,
|
|
@@ -81,7 +85,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
81
85
|
const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
|
|
82
86
|
const blockchains = useAppStore().blockchains();
|
|
83
87
|
const swappers = useAppStore().swappers();
|
|
84
|
-
const
|
|
88
|
+
const { findToken } = useAppStore();
|
|
85
89
|
const retry = useQuoteStore.use.retry();
|
|
86
90
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
87
91
|
const navigate = useNavigate();
|
|
@@ -294,7 +298,8 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
294
298
|
type="primary"
|
|
295
299
|
size="large"
|
|
296
300
|
onClick={() => {
|
|
297
|
-
|
|
301
|
+
const swapInput = createRetryQuote(swap, blockchains, findToken);
|
|
302
|
+
retry(swapInput);
|
|
298
303
|
setTimeout(() => {
|
|
299
304
|
const home = '../../';
|
|
300
305
|
navigate(home);
|
|
@@ -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
|
|
@@ -33,11 +33,11 @@ export const WidgetContext = createContext<WidgetContextInterface>({
|
|
|
33
33
|
function Main(props: PropsWithChildren<PropTypes>) {
|
|
34
34
|
const { updateConfig, updateSettings, fetch: fetchMeta } = useAppStore();
|
|
35
35
|
const blockchains = useAppStore().blockchains();
|
|
36
|
-
const
|
|
36
|
+
const { findToken } = useAppStore();
|
|
37
37
|
const config = useAppStore().config;
|
|
38
38
|
|
|
39
39
|
const walletOptions: ProvidersOptions = {
|
|
40
|
-
walletConnectProjectId:
|
|
40
|
+
walletConnectProjectId: config?.walletConnectProjectId,
|
|
41
41
|
walletConnectListedDesktopWalletLink:
|
|
42
42
|
props.config.__UNSTABLE_OR_INTERNAL__
|
|
43
43
|
?.walletConnectListedDesktopWalletLink,
|
|
@@ -79,7 +79,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
79
79
|
meta.isContractWallet
|
|
80
80
|
);
|
|
81
81
|
if (data.length) {
|
|
82
|
-
connectWallet(data,
|
|
82
|
+
connectWallet(data, findToken);
|
|
83
83
|
}
|
|
84
84
|
} else {
|
|
85
85
|
disconnectWallet(type);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Meta } from '../../store/quote';
|
|
1
|
+
import type { Meta, RetryQuote } from '../../store/quote';
|
|
2
|
+
import type { FindToken } from '../../store/slices/data';
|
|
2
3
|
import type { Manager } from '@rango-dev/queue-manager-core';
|
|
3
4
|
import type { PendingSwap } from 'rango-types/lib';
|
|
4
5
|
|
|
@@ -10,9 +11,11 @@ import {
|
|
|
10
11
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
11
12
|
|
|
12
13
|
import { getPendingSwaps } from '../../utils/queue';
|
|
14
|
+
import { createRetryQuote } from '../../utils/quote';
|
|
13
15
|
|
|
14
16
|
interface WidgetHistoryActions {
|
|
15
|
-
retrySwap: (
|
|
17
|
+
retrySwap: (retryQuote: RetryQuote) => void;
|
|
18
|
+
findToken: FindToken;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
export class WidgetHistory {
|
|
@@ -41,7 +44,13 @@ export class WidgetHistory {
|
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
public retry(swap: PendingSwap, meta: Meta) {
|
|
44
|
-
|
|
47
|
+
const retryQuote = createRetryQuote(
|
|
48
|
+
swap,
|
|
49
|
+
meta.blockchains,
|
|
50
|
+
this.actions.findToken
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return this.actions.retrySwap(retryQuote);
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
public cancel(id: string) {
|
|
@@ -21,7 +21,9 @@ export function WidgetInfo(props: React.PropsWithChildren) {
|
|
|
21
21
|
const { manager } = useManager();
|
|
22
22
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
23
23
|
const retrySwap = useQuoteStore.use.retry();
|
|
24
|
-
const
|
|
24
|
+
const { findToken } = useAppStore();
|
|
25
|
+
|
|
26
|
+
const history = new WidgetHistory(manager, { retrySwap, findToken });
|
|
25
27
|
const details = useWalletsStore.use.connectedWallets();
|
|
26
28
|
const isLoading = useWalletsStore.use.loading();
|
|
27
29
|
const totalBalance = calculateWalletUsdValue(details);
|
|
@@ -32,6 +34,7 @@ export function WidgetInfo(props: React.PropsWithChildren) {
|
|
|
32
34
|
const loadingStatus = useAppStore().fetchStatus;
|
|
33
35
|
const resetLanguage = useLanguage().resetLanguage;
|
|
34
36
|
const notifications = useNotificationStore().getNotifications();
|
|
37
|
+
const clearNotifications = useNotificationStore().clearNotifications;
|
|
35
38
|
|
|
36
39
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
37
40
|
const value: WidgetInfoContextInterface = {
|
|
@@ -42,17 +45,19 @@ export function WidgetInfo(props: React.PropsWithChildren) {
|
|
|
42
45
|
isLoading,
|
|
43
46
|
details,
|
|
44
47
|
totalBalance,
|
|
45
|
-
refetch,
|
|
48
|
+
refetch: (accounts) => refetch(accounts, findToken),
|
|
46
49
|
},
|
|
47
50
|
meta: {
|
|
48
51
|
blockchains,
|
|
49
52
|
tokens,
|
|
50
53
|
swappers,
|
|
51
54
|
loadingStatus,
|
|
55
|
+
findToken,
|
|
52
56
|
},
|
|
53
57
|
resetLanguage,
|
|
54
58
|
notifications: {
|
|
55
59
|
list: notifications,
|
|
60
|
+
clearAll: clearNotifications,
|
|
56
61
|
},
|
|
57
62
|
};
|
|
58
63
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WidgetHistory } from './WidgetInfo.helpers';
|
|
2
|
-
import type { FetchStatus } from '../../store/slices/data';
|
|
2
|
+
import type { FetchStatus, FindToken } from '../../store/slices/data';
|
|
3
3
|
import type { ConnectedWallet } from '../../store/wallets';
|
|
4
4
|
import type { Wallet } from '../../types';
|
|
5
5
|
import type { Notification } from '../../types/notification';
|
|
@@ -20,9 +20,11 @@ export interface WidgetInfoContextInterface {
|
|
|
20
20
|
tokens: Token[];
|
|
21
21
|
swappers: SwapperMeta[];
|
|
22
22
|
loadingStatus: FetchStatus;
|
|
23
|
+
findToken: FindToken;
|
|
23
24
|
};
|
|
24
25
|
resetLanguage: () => void;
|
|
25
26
|
notifications: {
|
|
26
27
|
list: Notification[];
|
|
28
|
+
clearAll: () => void;
|
|
27
29
|
};
|
|
28
30
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ConfirmSwapFetchResult } from './useConfirmSwap.types';
|
|
2
|
+
import type { FindToken } from '../../store/slices/data';
|
|
2
3
|
import type {
|
|
3
4
|
ConfirmSwapWarnings,
|
|
4
5
|
QuoteErrorResponse,
|
|
@@ -87,9 +88,10 @@ export function generateWarnings(
|
|
|
87
88
|
params: {
|
|
88
89
|
fromToken: Token;
|
|
89
90
|
toToken: Token;
|
|
90
|
-
meta: { blockchains: BlockchainMeta[]
|
|
91
|
+
meta: { blockchains: BlockchainMeta[] };
|
|
91
92
|
selectedWallets: Wallet[];
|
|
92
93
|
userSlippage: number;
|
|
94
|
+
findToken: FindToken;
|
|
93
95
|
}
|
|
94
96
|
): ConfirmSwapWarnings {
|
|
95
97
|
let quoteChanged = false;
|
|
@@ -105,7 +107,7 @@ export function generateWarnings(
|
|
|
105
107
|
const quoteWarning = generateQuoteWarnings(currentQuote, {
|
|
106
108
|
fromToken: params.fromToken,
|
|
107
109
|
toToken: params.toToken,
|
|
108
|
-
|
|
110
|
+
findToken: params.findToken,
|
|
109
111
|
userSlippage: params.userSlippage,
|
|
110
112
|
});
|
|
111
113
|
|
|
@@ -32,6 +32,7 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
32
32
|
const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
|
|
33
33
|
const blockchains = useAppStore().blockchains();
|
|
34
34
|
const tokens = useAppStore().tokens();
|
|
35
|
+
const { findToken } = useAppStore();
|
|
35
36
|
|
|
36
37
|
const userSlippage = customSlippage || slippage;
|
|
37
38
|
|
|
@@ -96,7 +97,8 @@ export function useConfirmSwap(): ConfirmSwap {
|
|
|
96
97
|
{
|
|
97
98
|
fromToken,
|
|
98
99
|
toToken,
|
|
99
|
-
meta: { blockchains
|
|
100
|
+
meta: { blockchains },
|
|
101
|
+
findToken,
|
|
100
102
|
selectedWallets,
|
|
101
103
|
userSlippage,
|
|
102
104
|
}
|
|
@@ -15,10 +15,10 @@ import { useNotificationStore } from '../../store/notification';
|
|
|
15
15
|
import { useWalletsStore } from '../../store/wallets';
|
|
16
16
|
|
|
17
17
|
export function useSubscribeToWidgetEvents() {
|
|
18
|
-
const tokens = useAppStore().tokens();
|
|
19
18
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
20
19
|
const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
|
|
21
20
|
const setNotification = useNotificationStore.use.setNotification();
|
|
21
|
+
const { findToken } = useAppStore();
|
|
22
22
|
const widgetEvents = useEvents();
|
|
23
23
|
|
|
24
24
|
useEffect(() => {
|
|
@@ -40,8 +40,8 @@ export function useSubscribeToWidgetEvents() {
|
|
|
40
40
|
(wallet) => wallet.chain === step?.toBlockchain
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
-
fromAccount && getWalletsDetails([fromAccount],
|
|
44
|
-
toAccount && getWalletsDetails([toAccount],
|
|
43
|
+
fromAccount && getWalletsDetails([fromAccount], findToken);
|
|
44
|
+
toAccount && getWalletsDetails([toAccount], findToken);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
setNotification(event, route);
|
|
@@ -53,7 +53,6 @@ export function useSwapInput({
|
|
|
53
53
|
} = useAppStore().config;
|
|
54
54
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
55
55
|
|
|
56
|
-
const tokens = useAppStore().tokens();
|
|
57
56
|
const {
|
|
58
57
|
fromToken,
|
|
59
58
|
toToken,
|
|
@@ -78,6 +77,7 @@ export function useSwapInput({
|
|
|
78
77
|
const liquiditySources = useAppStore().getLiquiditySources();
|
|
79
78
|
const disabledLiquiditySources = useAppStore().getDisabledLiquiditySources();
|
|
80
79
|
const excludeLiquiditySources = useAppStore().excludeLiquiditySources();
|
|
80
|
+
const { findToken } = useAppStore();
|
|
81
81
|
|
|
82
82
|
const [loading, setLoading] = useState(true);
|
|
83
83
|
const prevInputAmount = useRef(inputAmount);
|
|
@@ -153,7 +153,7 @@ export function useSwapInput({
|
|
|
153
153
|
fromToken,
|
|
154
154
|
toToken,
|
|
155
155
|
userSlippage,
|
|
156
|
-
|
|
156
|
+
findToken,
|
|
157
157
|
});
|
|
158
158
|
updateQuotePartialState('warning', quoteWarning);
|
|
159
159
|
})
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
isBlockchainExcludedInConfig,
|
|
9
9
|
isTokenExcludedInConfig,
|
|
10
10
|
} from '../utils/configs';
|
|
11
|
-
import { areTokensEqual } from '../utils/wallets';
|
|
12
11
|
|
|
13
12
|
export function useSyncStoresWithConfig() {
|
|
14
13
|
const {
|
|
@@ -28,6 +27,7 @@ export function useSyncStoresWithConfig() {
|
|
|
28
27
|
const fetchMetaStatus = useAppStore().fetchStatus;
|
|
29
28
|
const blockchains = useAppStore().blockchains();
|
|
30
29
|
const tokens = useAppStore().tokens();
|
|
30
|
+
const { findToken } = useAppStore();
|
|
31
31
|
|
|
32
32
|
const { setAffiliateRef, setAffiliatePercent, setAffiliateWallets } =
|
|
33
33
|
useAppStore();
|
|
@@ -51,9 +51,8 @@ export function useSyncStoresWithConfig() {
|
|
|
51
51
|
const chain = blockchains.find(
|
|
52
52
|
(chain) => chain.name === config?.from?.blockchain
|
|
53
53
|
);
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
);
|
|
54
|
+
const fromToken = config?.from?.token;
|
|
55
|
+
const token = fromToken && findToken(fromToken);
|
|
57
56
|
|
|
58
57
|
if (chain || (!chain && prevConfigFromBlockchain.current)) {
|
|
59
58
|
setFromBlockchain(chain ?? null);
|
|
@@ -101,9 +100,9 @@ export function useSyncStoresWithConfig() {
|
|
|
101
100
|
const chain = blockchains.find(
|
|
102
101
|
(chain) => chain.name === config?.to?.blockchain
|
|
103
102
|
);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
);
|
|
103
|
+
|
|
104
|
+
const toToken = config?.to?.token;
|
|
105
|
+
const token = toToken && findToken(toToken);
|
|
107
106
|
|
|
108
107
|
if (chain || (!chain && prevConfigToBlockchain.current)) {
|
|
109
108
|
setToBlockchain(chain ?? null);
|
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
import type { BlockchainMeta, Token } from 'rango-sdk';
|
|
1
|
+
import type { Asset, BlockchainMeta, Token } from 'rango-sdk';
|
|
2
2
|
|
|
3
|
-
export function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (symbolAndAddress?.length === 1) {
|
|
15
|
-
return (
|
|
16
|
-
token.symbol === symbolAndAddress[0] &&
|
|
17
|
-
token.address === null &&
|
|
18
|
-
token.blockchain === chain.name
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
return (
|
|
22
|
-
token.symbol === symbolAndAddress?.[0] &&
|
|
23
|
-
token.address === symbolAndAddress?.[1] &&
|
|
24
|
-
token.blockchain === chain.name
|
|
25
|
-
);
|
|
26
|
-
}) || null
|
|
27
|
-
);
|
|
3
|
+
export function convertTokenSearchParamToAsset(
|
|
4
|
+
searchParam: string,
|
|
5
|
+
chain: BlockchainMeta
|
|
6
|
+
): Asset {
|
|
7
|
+
const symbolAndAddress = searchParam.split('--');
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
blockchain: chain.name,
|
|
11
|
+
address: symbolAndAddress?.[1] || null,
|
|
12
|
+
symbol: symbolAndAddress[0],
|
|
13
|
+
};
|
|
28
14
|
}
|
|
29
15
|
|
|
30
16
|
export function tokenToSearchParam(token: Token | null): string | undefined {
|
|
@@ -10,7 +10,7 @@ import { useAppStore } from '../../store/AppStore';
|
|
|
10
10
|
import { useQuoteStore } from '../../store/quote';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
|
-
|
|
13
|
+
convertTokenSearchParamToAsset,
|
|
14
14
|
tokenToSearchParam,
|
|
15
15
|
} from './useSyncUrlAndStore.helpers';
|
|
16
16
|
|
|
@@ -36,7 +36,7 @@ export function useSyncUrlAndStore() {
|
|
|
36
36
|
const { updateIframe, updateCampaignMode } = useAppStore();
|
|
37
37
|
const campaignMode = useAppStore().isInCampaignMode();
|
|
38
38
|
const liquiditySourcesParamsRef = useRef<string>();
|
|
39
|
-
|
|
39
|
+
const { findToken } = useAppStore();
|
|
40
40
|
const getUrlSearchParams = () => {
|
|
41
41
|
const utmQueryParams: Record<string, string> = {};
|
|
42
42
|
|
|
@@ -124,19 +124,26 @@ export function useSyncUrlAndStore() {
|
|
|
124
124
|
const fromBlockchain = blockchains.find(
|
|
125
125
|
(blockchain) => blockchain.name === searchParams.fromBlockchain
|
|
126
126
|
);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
searchParams.fromToken
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
|
|
128
|
+
const fromToken =
|
|
129
|
+
searchParams.fromToken && fromBlockchain
|
|
130
|
+
? findToken(
|
|
131
|
+
convertTokenSearchParamToAsset(
|
|
132
|
+
searchParams.fromToken,
|
|
133
|
+
fromBlockchain
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
: undefined;
|
|
132
137
|
const toBlockchain = blockchains.find(
|
|
133
138
|
(blockchain) => blockchain.name === searchParams.toBlockchain
|
|
134
139
|
);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
searchParams.toToken
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
|
|
141
|
+
const toToken =
|
|
142
|
+
searchParams.toToken && toBlockchain
|
|
143
|
+
? findToken(
|
|
144
|
+
convertTokenSearchParamToAsset(searchParams.toToken, toBlockchain)
|
|
145
|
+
)
|
|
146
|
+
: undefined;
|
|
140
147
|
|
|
141
148
|
if (!!fromBlockchain) {
|
|
142
149
|
setFromBlockchain(fromBlockchain);
|
package/src/hooks/useTheme.ts
CHANGED
|
@@ -30,6 +30,7 @@ export function useTheme(props: WidgetTheme) {
|
|
|
30
30
|
const { dark, light } = customizedThemeTokens(colors);
|
|
31
31
|
|
|
32
32
|
const baseTheme = createTheme({
|
|
33
|
+
shadows: props.shadows || {},
|
|
33
34
|
radii: {
|
|
34
35
|
primary: `${borderRadius}px`,
|
|
35
36
|
secondary: `${secondaryBorderRadius}px`,
|