@rango-dev/widget-embedded 0.0.0-experimental-ce08124c-20260613 → 0.0.0-experimental-55d181be-20260613
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/CustomDestination/CustomDestination.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/containers/Settings/Lists.d.ts.map +1 -1
- package/dist/containers/Wallets/useUpdates.d.ts.map +1 -1
- package/dist/containers/Widget/Widget.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncNotifications/useSyncNotifications.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemPage/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/store/slices/wallets.d.ts +1 -3
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/types/event.d.ts +6 -135
- package/dist/types/event.d.ts.map +1 -1
- package/dist/utils/events.d.ts +5 -16
- package/dist/utils/events.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +1 -1
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +2 -53
- package/src/components/CustomDestination/CustomDestination.tsx +0 -18
- package/src/components/Quote/QuoteCostDetails.tsx +0 -8
- package/src/components/Slippage/Slippage.tsx +0 -21
- package/src/components/SwapDetails/SwapDetails.tsx +0 -6
- package/src/containers/Settings/Lists.tsx +1 -13
- package/src/containers/Wallets/useUpdates.ts +2 -5
- package/src/containers/Widget/Widget.tsx +2 -0
- package/src/hooks/useSwapInput.ts +1 -46
- package/src/hooks/useSyncNotifications/useSyncNotifications.ts +1 -26
- package/src/hooks/useWalletList.ts +0 -34
- package/src/pages/ConfirmSwapPage.tsx +1 -12
- package/src/pages/Home.tsx +4 -33
- package/src/pages/LiquiditySourcePage.tsx +0 -24
- package/src/pages/SelectBlockchainPage.tsx +0 -10
- package/src/pages/SelectSwapItemPage/SelectSwapItemsPage.tsx +0 -27
- package/src/pages/SwapDetailsPage.tsx +0 -6
- package/src/store/slices/wallets.ts +3 -11
- package/src/types/event.ts +6 -174
- package/src/utils/events.ts +6 -51
- package/dist/services/walletConnectionSource.d.ts +0 -4
- package/dist/services/walletConnectionSource.d.ts.map +0 -1
- package/dist/utils/eventPayloads.d.ts +0 -8
- package/dist/utils/eventPayloads.d.ts.map +0 -1
- package/src/services/walletConnectionSource.ts +0 -19
- package/src/utils/eventPayloads.ts +0 -37
package/package.json
CHANGED
|
@@ -12,21 +12,13 @@ import {
|
|
|
12
12
|
MessageBox,
|
|
13
13
|
Typography,
|
|
14
14
|
} from '@rango-dev/ui';
|
|
15
|
-
import React, {
|
|
16
|
-
useCallback,
|
|
17
|
-
useEffect,
|
|
18
|
-
useMemo,
|
|
19
|
-
useRef,
|
|
20
|
-
useState,
|
|
21
|
-
} from 'react';
|
|
15
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
22
16
|
import { useNavigate } from 'react-router-dom';
|
|
23
17
|
|
|
24
18
|
import { WIDGET_UI_ID } from '../../constants';
|
|
25
19
|
import { getQuoteErrorMessage } from '../../constants/errors';
|
|
26
20
|
import { useAppStore } from '../../store/AppStore';
|
|
27
21
|
import { useQuoteStore } from '../../store/quote';
|
|
28
|
-
import { UiEventTypes } from '../../types';
|
|
29
|
-
import { emitUiEvent } from '../../utils/events';
|
|
30
22
|
import { getBlockchainShortNameFor } from '../../utils/meta';
|
|
31
23
|
import { isConfirmSwapDisabled } from '../../utils/swap';
|
|
32
24
|
import { getQuoteChains } from '../../utils/wallets';
|
|
@@ -219,10 +211,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
219
211
|
const lastSelectedWallets = selectableWallets.filter(
|
|
220
212
|
(wallet) => wallet.selected
|
|
221
213
|
);
|
|
222
|
-
emitUiEvent({
|
|
223
|
-
type: UiEventTypes.SWAP_WALLETS_CONFIRMED,
|
|
224
|
-
payload: { routeId: selectedQuote?.requestId ?? '' },
|
|
225
|
-
});
|
|
226
214
|
setWalletsAsSelected(lastSelectedWallets);
|
|
227
215
|
selectQuoteWallets(lastSelectedWallets);
|
|
228
216
|
setQuoteWalletConfirmed(true);
|
|
@@ -313,39 +301,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
313
301
|
}
|
|
314
302
|
}, [connectedWallets, nextSelectedWallets]);
|
|
315
303
|
|
|
316
|
-
const routeId = selectedQuote?.requestId ?? '';
|
|
317
|
-
const hasReportedModalShown = useRef(false);
|
|
318
|
-
|
|
319
|
-
useEffect(() => {
|
|
320
|
-
if (open && !hasReportedModalShown.current) {
|
|
321
|
-
hasReportedModalShown.current = true;
|
|
322
|
-
const pendingChains = requiredChains.filter(
|
|
323
|
-
(chain) =>
|
|
324
|
-
!connectedWallets.some(
|
|
325
|
-
(connectedWallet) => connectedWallet.chain === chain
|
|
326
|
-
)
|
|
327
|
-
);
|
|
328
|
-
emitUiEvent({
|
|
329
|
-
type: UiEventTypes.SWAP_WALLETS_MODAL_SHOWN,
|
|
330
|
-
payload: {
|
|
331
|
-
chainsRequired: requiredChains.length,
|
|
332
|
-
chainsPending: pendingChains.length,
|
|
333
|
-
},
|
|
334
|
-
});
|
|
335
|
-
} else if (!open) {
|
|
336
|
-
hasReportedModalShown.current = false;
|
|
337
|
-
}
|
|
338
|
-
}, [open, requiredChains, connectedWallets]);
|
|
339
|
-
|
|
340
|
-
useEffect(() => {
|
|
341
|
-
if (isInsufficientBalanceModalOpen) {
|
|
342
|
-
emitUiEvent({
|
|
343
|
-
type: UiEventTypes.GAS_WARNING_SHOWN,
|
|
344
|
-
payload: { routeId },
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
}, [isInsufficientBalanceModalOpen, routeId]);
|
|
348
|
-
|
|
349
304
|
const modalContainer = document.getElementById(
|
|
350
305
|
WIDGET_UI_ID.SWAP_BOX_ID
|
|
351
306
|
) as HTMLDivElement;
|
|
@@ -428,13 +383,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
428
383
|
size="large"
|
|
429
384
|
type="primary"
|
|
430
385
|
fullWidth
|
|
431
|
-
onClick={
|
|
432
|
-
emitUiEvent({
|
|
433
|
-
type: UiEventTypes.GAS_WARNING_BYPASSED,
|
|
434
|
-
payload: { routeId },
|
|
435
|
-
});
|
|
436
|
-
onConfirmBalance();
|
|
437
|
-
}}>
|
|
386
|
+
onClick={onConfirmBalance}>
|
|
438
387
|
{i18n.t('Proceed anyway')}
|
|
439
388
|
</Button>
|
|
440
389
|
</MessageBox>
|
|
@@ -16,8 +16,6 @@ import React, { useEffect, useRef } from 'react';
|
|
|
16
16
|
|
|
17
17
|
import { useAppStore } from '../../store/AppStore';
|
|
18
18
|
import { useQuoteStore } from '../../store/quote';
|
|
19
|
-
import { UiEventTypes } from '../../types';
|
|
20
|
-
import { emitUiEvent } from '../../utils/events';
|
|
21
19
|
import {
|
|
22
20
|
getBlockchainDisplayNameFor,
|
|
23
21
|
isValidTokenAddress,
|
|
@@ -96,22 +94,6 @@ export function CustomDestination(props: PropTypes) {
|
|
|
96
94
|
}
|
|
97
95
|
}, [configDestination]);
|
|
98
96
|
|
|
99
|
-
const lastReportedDestination = useRef<string | null>(null);
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (!customDestination) {
|
|
102
|
-
lastReportedDestination.current = null;
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const isValid = open && isValidTokenAddress(blockchain, customDestination);
|
|
106
|
-
if (isValid && lastReportedDestination.current !== customDestination) {
|
|
107
|
-
lastReportedDestination.current = customDestination;
|
|
108
|
-
emitUiEvent({
|
|
109
|
-
type: UiEventTypes.DESTINATION_ADDRESS_SET,
|
|
110
|
-
payload: { destinationChain: blockchain.name },
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}, [customDestination, open, blockchain]);
|
|
114
|
-
|
|
115
97
|
return (
|
|
116
98
|
<Container>
|
|
117
99
|
<CustomCollapsible
|
|
@@ -21,9 +21,7 @@ import {
|
|
|
21
21
|
USD_VALUE_MAX_DECIMALS,
|
|
22
22
|
USD_VALUE_MIN_DECIMALS,
|
|
23
23
|
} from '../../constants/routing';
|
|
24
|
-
import { UiEventTypes } from '../../types';
|
|
25
24
|
import { getContainer, getExpanded } from '../../utils/common';
|
|
26
|
-
import { emitUiEvent } from '../../utils/events';
|
|
27
25
|
import { numberToString } from '../../utils/numbers';
|
|
28
26
|
import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
|
|
29
27
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
@@ -86,12 +84,6 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
86
84
|
showModalFee
|
|
87
85
|
? (e) => {
|
|
88
86
|
e.stopPropagation();
|
|
89
|
-
if (!open && quote) {
|
|
90
|
-
emitUiEvent({
|
|
91
|
-
type: UiEventTypes.ROUTE_FEE_VIEWED,
|
|
92
|
-
payload: { routeId: quote.requestId },
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
87
|
setOpen(!open);
|
|
96
88
|
}
|
|
97
89
|
: undefined
|
|
@@ -12,9 +12,7 @@ import React from 'react';
|
|
|
12
12
|
|
|
13
13
|
import { MAX_SLIPPAGE, SLIPPAGES } from '../../constants/swapSettings';
|
|
14
14
|
import { useAppStore } from '../../store/AppStore';
|
|
15
|
-
import { UiEventTypes } from '../../types';
|
|
16
15
|
import { getContainer } from '../../utils/common';
|
|
17
|
-
import { emitUiEvent } from '../../utils/events';
|
|
18
16
|
import { getSlippageValidation } from '../../utils/settings';
|
|
19
17
|
import { isValidCurrencyFormat } from '../../utils/validation';
|
|
20
18
|
|
|
@@ -33,23 +31,6 @@ export function Slippage() {
|
|
|
33
31
|
const slippageValidation =
|
|
34
32
|
customSlippage !== null ? getSlippageValidation(customSlippage) : null;
|
|
35
33
|
|
|
36
|
-
/** Effective slippage before a change, used as the previous value in events. */
|
|
37
|
-
const effectiveSlippage = customSlippage ?? slippage;
|
|
38
|
-
|
|
39
|
-
const emitSlippageChanged = (previousValue: number, newValue: number) => {
|
|
40
|
-
if (previousValue === newValue) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
emitUiEvent({
|
|
44
|
-
type: UiEventTypes.SETTINGS_CHANGED,
|
|
45
|
-
payload: {
|
|
46
|
-
settingName: 'slippage',
|
|
47
|
-
previousValue: String(previousValue),
|
|
48
|
-
newValue: String(newValue),
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
34
|
const onSlippageValueChange = (
|
|
54
35
|
event: React.ChangeEvent<HTMLInputElement>
|
|
55
36
|
) => {
|
|
@@ -62,12 +43,10 @@ export function Slippage() {
|
|
|
62
43
|
if (parsedValue > MAX_SLIPPAGE) {
|
|
63
44
|
slippage = MAX_SLIPPAGE;
|
|
64
45
|
}
|
|
65
|
-
emitSlippageChanged(effectiveSlippage, slippage);
|
|
66
46
|
setCustomSlippage(slippage);
|
|
67
47
|
};
|
|
68
48
|
|
|
69
49
|
const onClickSlippageChip = (slippageItem: number) => {
|
|
70
|
-
emitSlippageChanged(effectiveSlippage, slippageItem);
|
|
71
50
|
if (customSlippage !== null) {
|
|
72
51
|
setCustomSlippage(null);
|
|
73
52
|
}
|
|
@@ -34,9 +34,7 @@ import {
|
|
|
34
34
|
import { useAppStore } from '../../store/AppStore';
|
|
35
35
|
import { useNotificationStore } from '../../store/notification';
|
|
36
36
|
import { useQuoteStore } from '../../store/quote';
|
|
37
|
-
import { UiEventTypes } from '../../types';
|
|
38
37
|
import { getContainer } from '../../utils/common';
|
|
39
|
-
import { emitUiEvent } from '../../utils/events';
|
|
40
38
|
import {
|
|
41
39
|
numberToString,
|
|
42
40
|
roundedSecondsToString,
|
|
@@ -406,10 +404,6 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
406
404
|
type="primary"
|
|
407
405
|
size="large"
|
|
408
406
|
onClick={() => {
|
|
409
|
-
emitUiEvent({
|
|
410
|
-
type: UiEventTypes.SWAP_RETRIED,
|
|
411
|
-
payload: { routeId: swap.requestId },
|
|
412
|
-
});
|
|
413
407
|
const swapInput = createRetryQuote(swap, blockchains, findToken);
|
|
414
408
|
retry(swapInput);
|
|
415
409
|
setTimeout(() => {
|
|
@@ -32,9 +32,7 @@ import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
|
32
32
|
import { ThemeModeEnum } from '../../constants/settings';
|
|
33
33
|
import { useLanguage } from '../../hooks/useLanguage';
|
|
34
34
|
import { useAppStore } from '../../store/AppStore';
|
|
35
|
-
import { UiEventTypes } from '../../types';
|
|
36
35
|
import { getContainer } from '../../utils/common';
|
|
37
|
-
import { emitUiEvent } from '../../utils/events';
|
|
38
36
|
import { getUniqueSwappersGroups, isFeatureHidden } from '../../utils/settings';
|
|
39
37
|
|
|
40
38
|
const ThemeSection = styled('div', {
|
|
@@ -259,17 +257,7 @@ export function SettingsLists() {
|
|
|
259
257
|
),
|
|
260
258
|
start: <InfinityIcon color="gray" size={16} />,
|
|
261
259
|
end: <Switch checked={infiniteApprove} />,
|
|
262
|
-
onClick:
|
|
263
|
-
emitUiEvent({
|
|
264
|
-
type: UiEventTypes.SETTINGS_CHANGED,
|
|
265
|
-
payload: {
|
|
266
|
-
settingName: 'infinite_approval',
|
|
267
|
-
previousValue: String(infiniteApprove),
|
|
268
|
-
newValue: String(!infiniteApprove),
|
|
269
|
-
},
|
|
270
|
-
});
|
|
271
|
-
toggleInfiniteApprove();
|
|
272
|
-
},
|
|
260
|
+
onClick: toggleInfiniteApprove,
|
|
273
261
|
};
|
|
274
262
|
|
|
275
263
|
const themeItem = {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
legacyFormatAddressWithNetwork as formatAddressWithNetwork,
|
|
13
13
|
legacyReadAccountAddress as readAccountAddress,
|
|
14
14
|
} from '@rango-dev/wallets-core/legacy';
|
|
15
|
-
import { Events
|
|
15
|
+
import { Events } from '@rango-dev/wallets-react';
|
|
16
16
|
import { type Network } from '@rango-dev/wallets-shared';
|
|
17
17
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
18
18
|
|
|
@@ -44,7 +44,6 @@ export function useUpdates(params: UseUpdatesParams): UseUpdates {
|
|
|
44
44
|
blockchains,
|
|
45
45
|
} = useAppStore();
|
|
46
46
|
|
|
47
|
-
const { getWalletInfo } = useWallets();
|
|
48
47
|
const { onConnectWalletHandler, onDisconnectWalletHandler } = params;
|
|
49
48
|
const evmBasedChainNames = blockchains()
|
|
50
49
|
.filter(isEvmBlockchain)
|
|
@@ -78,9 +77,7 @@ export function useUpdates(params: UseUpdatesParams): UseUpdates {
|
|
|
78
77
|
);
|
|
79
78
|
|
|
80
79
|
if (data.length) {
|
|
81
|
-
void newWalletConnected(data, info.namespace, state.derivationPath
|
|
82
|
-
walletName: getWalletInfo(type)?.name,
|
|
83
|
-
});
|
|
80
|
+
void newWalletConnected(data, info.namespace, state.derivationPath);
|
|
84
81
|
}
|
|
85
82
|
};
|
|
86
83
|
|
|
@@ -11,6 +11,8 @@ import { WidgetProvider } from '../WidgetProvider';
|
|
|
11
11
|
export function Widget(props: PropsWithChildren<WidgetProps>) {
|
|
12
12
|
const isExternalWalletsEnabled = props.config?.externalWallets;
|
|
13
13
|
|
|
14
|
+
console.log('Widget props', props);
|
|
15
|
+
|
|
14
16
|
return (
|
|
15
17
|
<AppRouter>
|
|
16
18
|
{isExternalWalletsEnabled ? (
|
|
@@ -5,10 +5,8 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
|
|
5
5
|
|
|
6
6
|
import { useAppStore } from '../store/AppStore';
|
|
7
7
|
import { useQuoteStore } from '../store/quote';
|
|
8
|
-
import { QuoteErrorType
|
|
8
|
+
import { QuoteErrorType } from '../types';
|
|
9
9
|
import { debounce } from '../utils/common';
|
|
10
|
-
import { buildSwapEstimatePayload } from '../utils/eventPayloads';
|
|
11
|
-
import { emitQuoteEvent } from '../utils/events';
|
|
12
10
|
import { isPositiveNumber } from '../utils/numbers';
|
|
13
11
|
import {
|
|
14
12
|
generateQuoteWarnings,
|
|
@@ -162,27 +160,6 @@ export function useSwapInput({
|
|
|
162
160
|
updateQuotePartialState('quotes', res);
|
|
163
161
|
setSelectedQuote(quote);
|
|
164
162
|
|
|
165
|
-
if (!res.results?.length || !quote) {
|
|
166
|
-
emitQuoteEvent({
|
|
167
|
-
type: QuoteEventTypes.ROUTE_NOT_FOUND,
|
|
168
|
-
payload: {
|
|
169
|
-
sourceChain: fromToken.blockchain,
|
|
170
|
-
destinationChain: toToken.blockchain,
|
|
171
|
-
sourceToken: fromToken.symbol,
|
|
172
|
-
destinationToken: toToken.symbol,
|
|
173
|
-
inputAmountUsd: inputUsdValue ? inputUsdValue.toNumber() : null,
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
} else {
|
|
177
|
-
emitQuoteEvent({
|
|
178
|
-
type: QuoteEventTypes.ROUTE_REQUESTED,
|
|
179
|
-
payload: {
|
|
180
|
-
...buildSwapEstimatePayload(quote),
|
|
181
|
-
routeCount: res.results.length,
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
163
|
throwErrorIfResponseIsNotValid({
|
|
187
164
|
diagnosisMessages: res.diagnosisMessages,
|
|
188
165
|
requestId: quote?.requestId || '',
|
|
@@ -199,28 +176,6 @@ export function useSwapInput({
|
|
|
199
176
|
})
|
|
200
177
|
.catch((error) => {
|
|
201
178
|
const quoteError = handleQuoteErrors(error);
|
|
202
|
-
if (quoteError.type === QuoteErrorType.NO_RESULT) {
|
|
203
|
-
emitQuoteEvent({
|
|
204
|
-
type: QuoteEventTypes.ROUTE_NOT_FOUND,
|
|
205
|
-
payload: {
|
|
206
|
-
sourceChain: fromToken.blockchain,
|
|
207
|
-
destinationChain: toToken.blockchain,
|
|
208
|
-
sourceToken: fromToken.symbol,
|
|
209
|
-
destinationToken: toToken.symbol,
|
|
210
|
-
inputAmountUsd: inputUsdValue ? inputUsdValue.toNumber() : null,
|
|
211
|
-
},
|
|
212
|
-
});
|
|
213
|
-
} else if (quoteError.type === QuoteErrorType.REQUEST_FAILED) {
|
|
214
|
-
emitQuoteEvent({
|
|
215
|
-
type: QuoteEventTypes.ROUTE_FETCH_FAILED,
|
|
216
|
-
payload: {
|
|
217
|
-
sourceChain: fromToken.blockchain,
|
|
218
|
-
destinationChain: toToken.blockchain,
|
|
219
|
-
|
|
220
|
-
errorCode: String(error?.response?.status ?? ''),
|
|
221
|
-
},
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
179
|
if (
|
|
225
180
|
quoteError.type === QuoteErrorType.NO_RESULT ||
|
|
226
181
|
quoteError.type === QuoteErrorType.REQUEST_FAILED
|
|
@@ -2,8 +2,6 @@ import { useManager } from '@rango-dev/queue-manager-react';
|
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
|
|
4
4
|
import { useNotificationStore } from '../../store/notification';
|
|
5
|
-
import { UiEventTypes } from '../../types';
|
|
6
|
-
import { emitUiEvent } from '../../utils/events';
|
|
7
5
|
import { getPendingSwaps } from '../../utils/queue';
|
|
8
6
|
|
|
9
7
|
export function useSyncNotifications() {
|
|
@@ -17,30 +15,7 @@ export function useSyncNotifications() {
|
|
|
17
15
|
!isSynced;
|
|
18
16
|
|
|
19
17
|
if (shouldSyncNotifications) {
|
|
20
|
-
|
|
21
|
-
syncNotifications(pendingSwaps);
|
|
22
|
-
|
|
23
|
-
pendingSwaps.forEach(({ swap }) => {
|
|
24
|
-
const isInProgressMultiStep =
|
|
25
|
-
swap.status === 'running' && swap.steps.length > 1;
|
|
26
|
-
if (!isInProgressMultiStep) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const currentStepIndex = swap.steps.findIndex(
|
|
30
|
-
(step) => step.status !== 'success'
|
|
31
|
-
);
|
|
32
|
-
emitUiEvent({
|
|
33
|
-
type: UiEventTypes.SWAP_RESUMED,
|
|
34
|
-
payload: {
|
|
35
|
-
routeId: swap.requestId,
|
|
36
|
-
stepCount: swap.steps.length,
|
|
37
|
-
stepNumber:
|
|
38
|
-
currentStepIndex === -1
|
|
39
|
-
? swap.steps.length
|
|
40
|
-
: currentStepIndex + 1,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
});
|
|
18
|
+
syncNotifications(getPendingSwaps(manager));
|
|
44
19
|
}
|
|
45
20
|
}, [
|
|
46
21
|
useNotificationStore.persist.hasHydrated(),
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
import { useCallback, useEffect } from 'react';
|
|
13
13
|
|
|
14
14
|
import { useAppStore } from '../store/AppStore';
|
|
15
|
-
import { emitWalletDetected } from '../utils/events';
|
|
16
15
|
import { configWalletsToWalletName } from '../utils/providers';
|
|
17
16
|
import {
|
|
18
17
|
hashWalletsState,
|
|
@@ -23,13 +22,6 @@ import {
|
|
|
23
22
|
|
|
24
23
|
import { useStatefulConnect } from './useStatefulConnect/useStatefulConnect';
|
|
25
24
|
|
|
26
|
-
/**
|
|
27
|
-
* Wallet types we've already reported as detected this session. Module-scoped so
|
|
28
|
-
* the `walletDetected` event fires at most once per provider regardless of how
|
|
29
|
-
* often the wallet list re-renders or remounts.
|
|
30
|
-
*/
|
|
31
|
-
const detectedWalletsReported = new Set<string>();
|
|
32
|
-
|
|
33
25
|
interface Params {
|
|
34
26
|
chain?: string;
|
|
35
27
|
}
|
|
@@ -74,32 +66,6 @@ export function useWalletList(params?: Params): API {
|
|
|
74
66
|
|
|
75
67
|
const sortedWallets = sortWalletsBasedOnConnectionState(wallets);
|
|
76
68
|
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
wallets.forEach((wallet) => {
|
|
79
|
-
const isDetected = wallet.state !== WalletState.NOT_INSTALLED;
|
|
80
|
-
if (isDetected && !detectedWalletsReported.has(wallet.type)) {
|
|
81
|
-
detectedWalletsReported.add(wallet.type);
|
|
82
|
-
emitWalletDetected({
|
|
83
|
-
walletType: wallet.type,
|
|
84
|
-
walletName: wallet.title,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}, [hashWalletsState(wallets)]);
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
wallets.forEach((wallet) => {
|
|
92
|
-
const isDetected = wallet.state !== WalletState.NOT_INSTALLED;
|
|
93
|
-
if (isDetected && !detectedWalletsReported.has(wallet.type)) {
|
|
94
|
-
detectedWalletsReported.add(wallet.type);
|
|
95
|
-
emitWalletDetected({
|
|
96
|
-
walletType: wallet.type,
|
|
97
|
-
walletName: wallet.title,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}, [hashWalletsState(wallets)]);
|
|
102
|
-
|
|
103
69
|
const isExperimentalChainNotAdded = (walletType: string) =>
|
|
104
70
|
!connectedWallets.find(
|
|
105
71
|
(connectedWallet) =>
|
|
@@ -28,9 +28,7 @@ import { useConfirmSwap } from '../hooks/useConfirmSwap';
|
|
|
28
28
|
import { useAppStore } from '../store/AppStore';
|
|
29
29
|
import { useQuoteStore } from '../store/quote';
|
|
30
30
|
import { useUiStore } from '../store/ui';
|
|
31
|
-
import { QuoteErrorType, QuoteWarningType
|
|
32
|
-
import { buildSwapEstimatePayload } from '../utils/eventPayloads';
|
|
33
|
-
import { emitUiEvent } from '../utils/events';
|
|
31
|
+
import { QuoteErrorType, QuoteWarningType } from '../types';
|
|
34
32
|
import { isQuoteWarningConfirmationRequired } from '../utils/quote';
|
|
35
33
|
import { joinList } from '../utils/ui';
|
|
36
34
|
|
|
@@ -144,15 +142,6 @@ export function ConfirmSwapPage() {
|
|
|
144
142
|
if (shouldShowWarningModal) {
|
|
145
143
|
setShowQuoteWarningModal(true);
|
|
146
144
|
} else {
|
|
147
|
-
if (selectedQuote) {
|
|
148
|
-
emitUiEvent({
|
|
149
|
-
type: UiEventTypes.SWAP_STARTED,
|
|
150
|
-
payload: {
|
|
151
|
-
...buildSwapEstimatePayload(selectedQuote),
|
|
152
|
-
stepCount: selectedQuote.swaps.length,
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
145
|
await onConfirm();
|
|
157
146
|
}
|
|
158
147
|
};
|
package/src/pages/Home.tsx
CHANGED
|
@@ -23,15 +23,9 @@ import { useSwapMode } from '../hooks/useSwapMode';
|
|
|
23
23
|
import { useAppStore } from '../store/AppStore';
|
|
24
24
|
import { useQuoteStore } from '../store/quote';
|
|
25
25
|
import { useUiStore } from '../store/ui';
|
|
26
|
-
import {
|
|
26
|
+
import { UiEventTypes } from '../types';
|
|
27
27
|
import { isVariantExpandable } from '../utils/configs';
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
emitPreventableEvent,
|
|
31
|
-
emitQuoteEvent,
|
|
32
|
-
emitUiEvent,
|
|
33
|
-
emitWalletConnectInitiated,
|
|
34
|
-
} from '../utils/events';
|
|
28
|
+
import { emitPreventableEvent } from '../utils/events';
|
|
35
29
|
import { getSlippageValidation } from '../utils/settings';
|
|
36
30
|
import { getSwapButtonState, isTokensIdentical } from '../utils/swap';
|
|
37
31
|
|
|
@@ -139,18 +133,6 @@ export function Home() {
|
|
|
139
133
|
};
|
|
140
134
|
const onClickOnQuote = (quote: SelectedQuote) => {
|
|
141
135
|
if (selectedQuote?.requestId !== quote.requestId) {
|
|
142
|
-
if (selectedQuote) {
|
|
143
|
-
emitQuoteEvent({
|
|
144
|
-
type: QuoteEventTypes.ROUTE_CHANGED,
|
|
145
|
-
payload: {
|
|
146
|
-
sourceChain: quote.swaps[0]?.from.blockchain ?? '',
|
|
147
|
-
destinationChain:
|
|
148
|
-
quote.swaps[quote.swaps.length - 1]?.to.blockchain ?? '',
|
|
149
|
-
fromRouteId: selectedQuote.requestId,
|
|
150
|
-
toRouteId: quote.requestId,
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
136
|
setShowQuoteWarningModal(false);
|
|
155
137
|
setSelectedQuote(quote);
|
|
156
138
|
}
|
|
@@ -208,21 +190,11 @@ export function Home() {
|
|
|
208
190
|
if (swapButtonState.action === 'connect-wallet') {
|
|
209
191
|
emitPreventableEvent(
|
|
210
192
|
{ type: UiEventTypes.CLICK_CONNECT_WALLET },
|
|
211
|
-
() =>
|
|
212
|
-
emitWalletConnectInitiated('swap_button');
|
|
213
|
-
onHandleNavigation(navigationRoutes.wallets);
|
|
214
|
-
}
|
|
193
|
+
() => onHandleNavigation(navigationRoutes.wallets)
|
|
215
194
|
);
|
|
216
195
|
} else if (swapButtonState.action === 'confirm-warning') {
|
|
217
196
|
setShowQuoteWarningModal(true);
|
|
218
|
-
} else
|
|
219
|
-
emitUiEvent({
|
|
220
|
-
type: UiEventTypes.SWAP_INITIATED,
|
|
221
|
-
payload: {
|
|
222
|
-
...buildSwapEstimatePayload(selectedQuote),
|
|
223
|
-
walletConnected: connectedWallets.length > 0,
|
|
224
|
-
},
|
|
225
|
-
});
|
|
197
|
+
} else {
|
|
226
198
|
onHandleNavigation(navigationRoutes.confirmSwap);
|
|
227
199
|
}
|
|
228
200
|
}}>
|
|
@@ -231,7 +203,6 @@ export function Home() {
|
|
|
231
203
|
}
|
|
232
204
|
header={{
|
|
233
205
|
onWallet: () => {
|
|
234
|
-
emitWalletConnectInitiated('nav');
|
|
235
206
|
onHandleNavigation(navigationRoutes.wallets);
|
|
236
207
|
},
|
|
237
208
|
hasBackButton: false,
|
|
@@ -21,8 +21,6 @@ import {
|
|
|
21
21
|
NotFoundContainer,
|
|
22
22
|
} from '../components/SettingsContainer';
|
|
23
23
|
import { useAppStore } from '../store/AppStore';
|
|
24
|
-
import { UiEventTypes } from '../types';
|
|
25
|
-
import { emitUiEvent } from '../utils/events';
|
|
26
24
|
import { containsText } from '../utils/numbers';
|
|
27
25
|
import { replaceSpacesWithDash } from '../utils/sanitizers';
|
|
28
26
|
import { getUniqueSwappersGroups } from '../utils/settings';
|
|
@@ -59,18 +57,6 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
|
|
|
59
57
|
liquiditySources.filter((sourceItem) => sourceItem.selected).length;
|
|
60
58
|
|
|
61
59
|
const toggleAllSources = () => {
|
|
62
|
-
emitUiEvent({
|
|
63
|
-
type: UiEventTypes.SETTINGS_CHANGED,
|
|
64
|
-
payload: {
|
|
65
|
-
settingName: 'bridge_exclusion',
|
|
66
|
-
previousValue: `${sourceType}:${
|
|
67
|
-
hasSelectAll ? 'all_enabled' : 'some_disabled'
|
|
68
|
-
}`,
|
|
69
|
-
newValue: `${sourceType}:${
|
|
70
|
-
hasSelectAll ? 'all_disabled' : 'all_enabled'
|
|
71
|
-
}`,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
60
|
liquiditySources.forEach((sourceItem) => {
|
|
75
61
|
if (hasSelectAll) {
|
|
76
62
|
toggleLiquiditySource(sourceItem.groupTitle);
|
|
@@ -93,16 +79,6 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
|
|
|
93
79
|
start: <Image src={logo} size={22} type="circular" />,
|
|
94
80
|
onClick: () => {
|
|
95
81
|
if (!campaignMode) {
|
|
96
|
-
emitUiEvent({
|
|
97
|
-
type: UiEventTypes.SETTINGS_CHANGED,
|
|
98
|
-
payload: {
|
|
99
|
-
settingName: 'bridge_exclusion',
|
|
100
|
-
previousValue: `${groupTitle}:${
|
|
101
|
-
selected ? 'enabled' : 'disabled'
|
|
102
|
-
}`,
|
|
103
|
-
newValue: `${groupTitle}:${selected ? 'disabled' : 'enabled'}`,
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
82
|
toggleLiquiditySource(groupTitle);
|
|
107
83
|
}
|
|
108
84
|
},
|
|
@@ -16,9 +16,7 @@ import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
|
16
16
|
import { useSwapMode } from '../hooks/useSwapMode';
|
|
17
17
|
import { useAppStore } from '../store/AppStore';
|
|
18
18
|
import { useQuoteStore } from '../store/quote';
|
|
19
|
-
import { UiEventTypes } from '../types';
|
|
20
19
|
import { filterBlockchainsWithAtLeastOneToken } from '../utils/common';
|
|
21
|
-
import { emitUiEvent } from '../utils/events';
|
|
22
20
|
|
|
23
21
|
interface PropTypes {
|
|
24
22
|
type: 'source' | 'destination' | 'custom-token';
|
|
@@ -53,14 +51,6 @@ export function SelectBlockchainPage(props: PropTypes) {
|
|
|
53
51
|
if (type === 'custom-token') {
|
|
54
52
|
navigate(`..?blockchain=${blockchain.name}`, { replace: true });
|
|
55
53
|
} else {
|
|
56
|
-
emitUiEvent({
|
|
57
|
-
type: UiEventTypes.CHAIN_FILTER_APPLIED,
|
|
58
|
-
payload: {
|
|
59
|
-
side: type === 'source' ? 'from' : 'to',
|
|
60
|
-
chain: blockchain.name,
|
|
61
|
-
filterSource: 'expanded',
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
54
|
if (type === 'source') {
|
|
65
55
|
setFromBlockchain(blockchain);
|
|
66
56
|
} else {
|
|
@@ -14,8 +14,6 @@ import { useNavigateBack } from '../../hooks/useNavigateBack';
|
|
|
14
14
|
import { useSearchCustomTokens } from '../../hooks/useSearchCustomTokens';
|
|
15
15
|
import { useAppStore } from '../../store/AppStore';
|
|
16
16
|
import { useQuoteStore } from '../../store/quote';
|
|
17
|
-
import { UiEventTypes } from '../../types';
|
|
18
|
-
import { emitUiEvent } from '../../utils/events';
|
|
19
17
|
|
|
20
18
|
import {
|
|
21
19
|
prepareTokensList,
|
|
@@ -113,14 +111,6 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
113
111
|
blockchain={type === 'source' ? fromBlockchain : toBlockchain}
|
|
114
112
|
onMoreClick={() => navigate(navigationRoutes.blockchains)}
|
|
115
113
|
onChange={(blockchain) => {
|
|
116
|
-
emitUiEvent({
|
|
117
|
-
type: UiEventTypes.CHAIN_FILTER_APPLIED,
|
|
118
|
-
payload: {
|
|
119
|
-
side: type === 'source' ? 'from' : 'to',
|
|
120
|
-
chain: blockchain.name,
|
|
121
|
-
filterSource: 'featured',
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
114
|
updateBlockchain(blockchain);
|
|
125
115
|
}}
|
|
126
116
|
/>
|
|
@@ -152,23 +142,6 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
152
142
|
searchedFor={searchedFor}
|
|
153
143
|
type={type}
|
|
154
144
|
onChange={(token) => {
|
|
155
|
-
emitUiEvent({
|
|
156
|
-
type: UiEventTypes.TOKEN_SELECTED,
|
|
157
|
-
payload: {
|
|
158
|
-
side: type === 'source' ? 'from' : 'to',
|
|
159
|
-
tokenName: token.name,
|
|
160
|
-
tokenSymbol: token.symbol,
|
|
161
|
-
tokenAddress: token.address,
|
|
162
|
-
chain: token.blockchain,
|
|
163
|
-
selectionMethod: searchedFor.trim()
|
|
164
|
-
? 'search'
|
|
165
|
-
: token.isPopular
|
|
166
|
-
? 'popular'
|
|
167
|
-
: 'recent',
|
|
168
|
-
activeChainFilter: selectedBlockchainName || 'all',
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
145
|
updateToken(token);
|
|
173
146
|
|
|
174
147
|
const tokenBlockchain = blockchains.find(
|