@rango-dev/widget-embedded 0.30.1-next.9 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/FilterSelector/FilterSelector.d.ts +4 -0
- package/dist/components/FilterSelector/FilterSelector.d.ts.map +1 -0
- package/dist/components/FilterSelector/FilterSelector.style.d.ts +962 -0
- package/dist/components/FilterSelector/FilterSelector.style.d.ts.map +1 -0
- package/dist/components/FilterSelector/FilterSelector.type.d.ts +14 -0
- package/dist/components/FilterSelector/FilterSelector.type.d.ts.map +1 -0
- package/dist/components/FilterSelector/FilterSelectorContent.d.ts +4 -0
- package/dist/components/FilterSelector/FilterSelectorContent.d.ts.map +1 -0
- package/dist/components/FilterSelector/index.d.ts +2 -0
- package/dist/components/FilterSelector/index.d.ts.map +1 -0
- package/dist/components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/containers/Inputs/Inputs.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +5 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/hooks/useObserveBalanceChanges/index.d.ts +2 -0
- package/dist/hooks/useObserveBalanceChanges/index.d.ts.map +1 -0
- package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts +4 -0
- package/dist/hooks/useObserveBalanceChanges/useObserveBalanceChanges.d.ts.map +1 -0
- package/dist/hooks/useUpdateQuoteInputs/index.d.ts +2 -0
- package/dist/hooks/useUpdateQuoteInputs/index.d.ts.map +1 -0
- package/dist/hooks/useUpdateQuoteInputs/useUpdateQuoteInputs.d.ts +3 -0
- package/dist/hooks/useUpdateQuoteInputs/useUpdateQuoteInputs.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/HistoryPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/types/quote.d.ts +9 -1
- package/dist/types/quote.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +10 -10
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +2 -1
- package/src/components/FilterSelector/FilterSelector.style.ts +95 -0
- package/src/components/FilterSelector/FilterSelector.tsx +42 -0
- package/src/components/FilterSelector/FilterSelector.type.ts +15 -0
- package/src/components/FilterSelector/FilterSelectorContent.tsx +60 -0
- package/src/components/FilterSelector/index.ts +1 -0
- package/src/components/SearchInput/SearchInput.tsx +2 -0
- package/src/components/SwapDetails/SwapDetails.tsx +1 -7
- package/src/components/TokenList/TokenList.tsx +8 -2
- package/src/containers/Inputs/Inputs.tsx +1 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +26 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +5 -1
- package/src/hooks/useObserveBalanceChanges/index.ts +1 -0
- package/src/hooks/useObserveBalanceChanges/useObserveBalanceChanges.ts +68 -0
- package/src/hooks/useUpdateQuoteInputs/index.ts +1 -0
- package/src/hooks/useUpdateQuoteInputs/useUpdateQuoteInputs.ts +50 -0
- package/src/pages/HistoryPage.tsx +180 -26
- package/src/pages/WalletsPage.tsx +4 -2
- package/src/store/quote.ts +1 -1
- package/src/store/slices/data.ts +1 -1
- package/src/types/quote.ts +11 -0
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
import type { PendingSwap, PendingSwapStep } from 'rango-types';
|
|
2
|
-
|
|
3
1
|
import { i18n } from '@lingui/core';
|
|
4
2
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
5
|
-
import {
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
Button,
|
|
5
|
+
darkTheme,
|
|
6
|
+
Divider,
|
|
7
|
+
MessageBox,
|
|
8
|
+
NotFound,
|
|
9
|
+
styled,
|
|
10
|
+
Typography,
|
|
11
|
+
} from '@rango-dev/ui';
|
|
12
|
+
import {
|
|
13
|
+
type PendingSwap,
|
|
14
|
+
type PendingSwapStep,
|
|
15
|
+
TransactionStatus,
|
|
16
|
+
} from 'rango-types';
|
|
17
|
+
import React, { useMemo, useState } from 'react';
|
|
7
18
|
import { useNavigate } from 'react-router-dom';
|
|
8
19
|
|
|
20
|
+
import { WatermarkedModal } from '../components/common/WatermarkedModal';
|
|
21
|
+
import { FilterSelector } from '../components/FilterSelector';
|
|
22
|
+
import { SuffixContainer } from '../components/HeaderButtons/HeaderButtons.styles';
|
|
9
23
|
import { HistoryGroupedList } from '../components/HistoryGroupedList';
|
|
10
24
|
import { NotFoundContainer } from '../components/HistoryGroupedList/HistoryGroupedList.styles';
|
|
11
25
|
import { Layout, PageContainer } from '../components/Layout';
|
|
12
26
|
import { SearchInput } from '../components/SearchInput';
|
|
27
|
+
import { getContainer } from '../utils/common';
|
|
13
28
|
import { groupSwapsByDate } from '../utils/date';
|
|
14
29
|
import { containsText } from '../utils/numbers';
|
|
15
30
|
import { getPendingSwaps } from '../utils/queue';
|
|
@@ -23,6 +38,33 @@ const HistoryGroupedListContainer = styled('div', {
|
|
|
23
38
|
height: '100%',
|
|
24
39
|
});
|
|
25
40
|
|
|
41
|
+
const SearchAndFilterBar = styled('div', {
|
|
42
|
+
display: 'flex',
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const Description = styled('div', {
|
|
48
|
+
'._typography': {
|
|
49
|
+
color: '$neutral700',
|
|
50
|
+
[`.${darkTheme}&`]: {
|
|
51
|
+
color: '$neutral900',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const transactionStatusFilters = [
|
|
57
|
+
{
|
|
58
|
+
id: TransactionStatus.SUCCESS,
|
|
59
|
+
title: i18n.t('Complete'),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: TransactionStatus.RUNNING,
|
|
63
|
+
title: i18n.t('Running'),
|
|
64
|
+
},
|
|
65
|
+
{ id: TransactionStatus.FAILED, title: i18n.t('Failed') },
|
|
66
|
+
];
|
|
67
|
+
|
|
26
68
|
const isStepContainsText = (steps: PendingSwapStep[], value: string) => {
|
|
27
69
|
if (!steps?.length) {
|
|
28
70
|
return false;
|
|
@@ -41,50 +83,116 @@ export function HistoryPage() {
|
|
|
41
83
|
const { manager, state } = useManager();
|
|
42
84
|
const list: PendingSwap[] = getPendingSwaps(manager).map(({ swap }) => swap);
|
|
43
85
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
86
|
+
const [openFilterSelector, setOpenFilterSelector] = useState(false);
|
|
44
87
|
const loading = !state.loadedFromPersistor;
|
|
45
|
-
|
|
88
|
+
const [filterBy, setFilterBy] = useState('');
|
|
89
|
+
const [openClearModal, setOpenClearModal] = useState(false);
|
|
46
90
|
const searchHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
47
91
|
const value = event.target.value;
|
|
48
92
|
setSearchedFor(value);
|
|
49
93
|
};
|
|
50
94
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
95
|
+
const filteredList = useMemo(() => {
|
|
96
|
+
if (!searchedFor && !filterBy) {
|
|
97
|
+
return list;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return list.filter((swap) => {
|
|
101
|
+
const { inputAmount, status, steps, requestId } = swap;
|
|
102
|
+
|
|
103
|
+
const matchesSearch =
|
|
104
|
+
!searchedFor ||
|
|
105
|
+
containsText(inputAmount, searchedFor) ||
|
|
106
|
+
containsText(status, searchedFor) ||
|
|
107
|
+
isStepContainsText(steps, searchedFor) ||
|
|
108
|
+
containsText(requestId, searchedFor);
|
|
109
|
+
|
|
110
|
+
const matchesFilter = !filterBy || filterBy === status;
|
|
111
|
+
|
|
112
|
+
return matchesSearch && matchesFilter;
|
|
113
|
+
});
|
|
114
|
+
}, [list, searchedFor, filterBy]);
|
|
61
115
|
|
|
62
116
|
const isEmpty = !filteredList?.length && !loading;
|
|
63
117
|
|
|
118
|
+
const onCloseModal = () => setOpenClearModal(false);
|
|
119
|
+
const onClear = async () => {
|
|
120
|
+
try {
|
|
121
|
+
await manager?.clearQueue();
|
|
122
|
+
|
|
123
|
+
setOpenClearModal(false);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
console.log(e);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const isClearButtonDisabled = useMemo(() => {
|
|
129
|
+
return !list.some(
|
|
130
|
+
(swap) =>
|
|
131
|
+
swap.status === TransactionStatus.SUCCESS ||
|
|
132
|
+
swap.status === TransactionStatus.FAILED
|
|
133
|
+
);
|
|
134
|
+
}, [list]);
|
|
135
|
+
|
|
64
136
|
return (
|
|
65
137
|
<Layout
|
|
66
138
|
header={{
|
|
67
139
|
title: i18n.t('History'),
|
|
140
|
+
suffix: (
|
|
141
|
+
<SuffixContainer>
|
|
142
|
+
<Button
|
|
143
|
+
disabled={isClearButtonDisabled}
|
|
144
|
+
variant="ghost"
|
|
145
|
+
size="xsmall"
|
|
146
|
+
onClick={() => setOpenClearModal(true)}>
|
|
147
|
+
<Typography size="medium" variant="label" color="error">
|
|
148
|
+
{i18n.t('Clear all Txs')}
|
|
149
|
+
</Typography>
|
|
150
|
+
</Button>
|
|
151
|
+
</SuffixContainer>
|
|
152
|
+
),
|
|
68
153
|
}}>
|
|
69
154
|
<PageContainer>
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
155
|
+
<SearchAndFilterBar>
|
|
156
|
+
<SearchInput
|
|
157
|
+
setValue={setSearchedFor}
|
|
158
|
+
fullWidth
|
|
159
|
+
variant="contained"
|
|
160
|
+
placeholder={i18n.t('Search Transaction')}
|
|
161
|
+
autoFocus
|
|
162
|
+
onChange={searchHandler}
|
|
163
|
+
style={{ height: 36 }}
|
|
164
|
+
value={searchedFor}
|
|
165
|
+
/>
|
|
166
|
+
<Divider size={10} direction="horizontal" />
|
|
167
|
+
|
|
168
|
+
<FilterSelector
|
|
169
|
+
filterBy={filterBy}
|
|
170
|
+
open={openFilterSelector}
|
|
171
|
+
onOpenChange={(open) => setOpenFilterSelector(open)}
|
|
172
|
+
onClickItem={(id) => setFilterBy(id)}
|
|
173
|
+
list={transactionStatusFilters}
|
|
174
|
+
/>
|
|
175
|
+
</SearchAndFilterBar>
|
|
176
|
+
|
|
79
177
|
<Divider size="16" />
|
|
80
178
|
<HistoryGroupedListContainer>
|
|
81
179
|
{isEmpty && (
|
|
82
180
|
<NotFoundContainer>
|
|
83
181
|
<Divider size={32} />
|
|
84
182
|
<NotFound
|
|
85
|
-
title={
|
|
183
|
+
title={
|
|
184
|
+
searchedFor
|
|
185
|
+
? i18n.t('No results found')
|
|
186
|
+
: i18n.t('No transactions')
|
|
187
|
+
}
|
|
188
|
+
titleColor={!searchedFor ? '$info' : undefined}
|
|
189
|
+
hasIcon={!!searchedFor}
|
|
86
190
|
description={
|
|
87
|
-
searchedFor
|
|
191
|
+
searchedFor
|
|
192
|
+
? i18n.t('Try using different keywords')
|
|
193
|
+
: i18n.t(
|
|
194
|
+
'Your transaction history is stored locally and will appear here after you start a swap'
|
|
195
|
+
)
|
|
88
196
|
}
|
|
89
197
|
/>
|
|
90
198
|
</NotFoundContainer>
|
|
@@ -99,6 +207,52 @@ export function HistoryPage() {
|
|
|
99
207
|
)}
|
|
100
208
|
</HistoryGroupedListContainer>
|
|
101
209
|
</PageContainer>
|
|
210
|
+
<WatermarkedModal
|
|
211
|
+
open={openClearModal}
|
|
212
|
+
onClose={onCloseModal}
|
|
213
|
+
container={getContainer()}>
|
|
214
|
+
<Divider size={20} />
|
|
215
|
+
<MessageBox
|
|
216
|
+
type="warning"
|
|
217
|
+
title={i18n.t('Clear History')}
|
|
218
|
+
description={
|
|
219
|
+
<Description>
|
|
220
|
+
<Typography variant="body" size="medium">
|
|
221
|
+
{i18n.t(
|
|
222
|
+
'This would clear all succeeded/failed transactions from widget. Do you wish to proceed?'
|
|
223
|
+
)}
|
|
224
|
+
</Typography>
|
|
225
|
+
<Divider size={'24'} />
|
|
226
|
+
|
|
227
|
+
<Typography variant="body" size="small">
|
|
228
|
+
{i18n.t(
|
|
229
|
+
'Hint: This does not clear your transaction history on blockchain. Only hides them in this page.'
|
|
230
|
+
)}
|
|
231
|
+
</Typography>
|
|
232
|
+
</Description>
|
|
233
|
+
}
|
|
234
|
+
/>
|
|
235
|
+
<Divider size={40} />
|
|
236
|
+
|
|
237
|
+
<Divider size={10} />
|
|
238
|
+
<Button
|
|
239
|
+
variant="contained"
|
|
240
|
+
type="primary"
|
|
241
|
+
size="large"
|
|
242
|
+
onClick={onClear}>
|
|
243
|
+
{i18n.t('Yes, Clear history')}
|
|
244
|
+
</Button>
|
|
245
|
+
<Divider size={10} />
|
|
246
|
+
<Button
|
|
247
|
+
variant="outlined"
|
|
248
|
+
type="primary"
|
|
249
|
+
size="large"
|
|
250
|
+
onClick={onCloseModal}>
|
|
251
|
+
<Typography variant="title" size="medium" color="primary">
|
|
252
|
+
{i18n.t('No, Cancel')}
|
|
253
|
+
</Typography>
|
|
254
|
+
</Button>
|
|
255
|
+
</WatermarkedModal>
|
|
102
256
|
</Layout>
|
|
103
257
|
);
|
|
104
258
|
}
|
|
@@ -80,12 +80,14 @@ export function WalletsPage() {
|
|
|
80
80
|
setSelectedWalletType(type);
|
|
81
81
|
}, TIME_TO_IGNORE_MODAL);
|
|
82
82
|
},
|
|
83
|
-
onConnect: () => {
|
|
83
|
+
onConnect: (type) => {
|
|
84
84
|
if (modalTimerId) {
|
|
85
85
|
clearTimeout(modalTimerId);
|
|
86
86
|
}
|
|
87
87
|
setTimeout(() => {
|
|
88
|
-
|
|
88
|
+
if (selectedWalletType === type) {
|
|
89
|
+
setOpenModal(false);
|
|
90
|
+
}
|
|
89
91
|
}, TIME_TO_CLOSE_MODAL);
|
|
90
92
|
},
|
|
91
93
|
});
|
package/src/store/quote.ts
CHANGED
package/src/store/slices/data.ts
CHANGED
|
@@ -102,7 +102,7 @@ export const createDataSlice: StateCreator<
|
|
|
102
102
|
: 'supportedDestinationTokens';
|
|
103
103
|
|
|
104
104
|
let supportedTokens = cacheService.get(cacheKey);
|
|
105
|
-
if (!supportedTokens) {
|
|
105
|
+
if (!supportedTokens?.length) {
|
|
106
106
|
supportedTokens = matchTokensFromConfigWithMeta({
|
|
107
107
|
type: options.type,
|
|
108
108
|
config: {
|
package/src/types/quote.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import type { PriceImpactWarningLevel } from '@rango-dev/ui';
|
|
4
4
|
import type BigNumber from 'bignumber.js';
|
|
5
5
|
import type {
|
|
6
|
+
Asset,
|
|
6
7
|
BlockchainValidationStatus,
|
|
7
8
|
RouteTag,
|
|
8
9
|
RoutingResultType,
|
|
@@ -131,3 +132,13 @@ export type QuoteErrorResponse = {
|
|
|
131
132
|
message: string;
|
|
132
133
|
options: QuoteError;
|
|
133
134
|
};
|
|
135
|
+
|
|
136
|
+
export type QuoteInputs = {
|
|
137
|
+
fromBlockchain: string | null;
|
|
138
|
+
toBlockchain: string | null;
|
|
139
|
+
fromToken: Asset | null;
|
|
140
|
+
toToken: Asset | null;
|
|
141
|
+
requestAmount: string;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type UpdateQuoteInputs = (params: Partial<QuoteInputs>) => void;
|