@rango-dev/ui 0.1.10 → 0.1.11-next.11
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/README.md +1 -1
- package/dist/components/Icon/types.d.ts +1 -0
- package/dist/components/Modal/Modal.d.ts +0 -1
- package/dist/components/StepDetail/StepDetail.d.ts +3 -1
- package/dist/components/SwapDetail/Token.d.ts +1 -0
- package/dist/components/TextField/TextField.d.ts +1 -1
- package/dist/components/TokenList/TokenList.d.ts +2 -2
- package/dist/components/TokenSelector/TokenSelector.d.ts +1 -3
- package/dist/components/Typography/Typography.d.ts +1 -1
- package/dist/components/common/Image.d.ts +6 -0
- package/dist/components/common/index.d.ts +1 -0
- package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +4 -2
- package/dist/containers/History/History.d.ts +5 -12
- package/dist/containers/History/SwapsGroup.d.ts +13 -0
- package/dist/containers/History/index.d.ts +2 -1
- package/dist/containers/SwapHistory/SwapHistory.d.ts +1 -1
- package/dist/helper/index.d.ts +3 -2
- package/dist/ui.cjs.development.js +329 -255
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +328 -256
- package/dist/ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Alert/Alert.tsx +3 -3
- package/src/components/BestRoute/BestRoute.tsx +2 -5
- package/src/components/BlockchainSelector/BlockchainSelector.tsx +24 -21
- package/src/components/BlockchainsList/BlockchainsList.tsx +8 -6
- package/src/components/Drawer/Drawer.tsx +1 -1
- package/src/components/Icon/common.ts +10 -0
- package/src/components/Icon/types.tsx +1 -0
- package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +9 -5
- package/src/components/Modal/Modal.tsx +1 -6
- package/src/components/SelectableWalletList/SelectableWalletList.tsx +2 -1
- package/src/components/Settings/Settings.tsx +4 -3
- package/src/components/StepDetail/StepDetail.tsx +45 -12
- package/src/components/SwapContainer/SwapContainer.tsx +1 -2
- package/src/components/SwapDetail/SwapDetail.tsx +8 -16
- package/src/components/SwapDetail/Token.tsx +19 -14
- package/src/components/TextField/TextField.tsx +8 -0
- package/src/components/TokenList/TokenItem.tsx +8 -5
- package/src/components/TokenList/TokenList.tsx +2 -3
- package/src/components/TokenSelector/TokenSelector.tsx +23 -47
- package/src/components/Typography/Typography.tsx +11 -3
- package/src/components/Wallet/Wallet.tsx +8 -5
- package/src/components/common/Image.tsx +27 -0
- package/src/components/common/index.ts +1 -0
- package/src/containers/ConfirmSwap/ConfirmSwap.tsx +9 -9
- package/src/containers/History/History.tsx +28 -71
- package/src/containers/History/SwapsGroup.tsx +59 -0
- package/src/containers/History/index.ts +2 -1
- package/src/containers/SwapHistory/SwapHistory.tsx +121 -135
- package/src/helper/index.ts +20 -5
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
Drawer,
|
|
13
13
|
Spinner,
|
|
14
14
|
Divider,
|
|
15
|
+
Image,
|
|
15
16
|
} from '../../components';
|
|
16
17
|
import { styled } from '../../theme';
|
|
17
18
|
import { PendingSwap } from '../History/types';
|
|
@@ -24,7 +25,19 @@ import {
|
|
|
24
25
|
export const SwapperContainer = styled('div', {
|
|
25
26
|
display: 'flex',
|
|
26
27
|
alignItems: 'center',
|
|
27
|
-
|
|
28
|
+
paddingLeft: '$4',
|
|
29
|
+
variants: {
|
|
30
|
+
created: {
|
|
31
|
+
true: {
|
|
32
|
+
filter: 'grayscale(100%)',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
running: {
|
|
36
|
+
true: {
|
|
37
|
+
animation: `${pulse} 2s ease-in-out infinite`,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
28
41
|
});
|
|
29
42
|
|
|
30
43
|
export const BodyError = styled('div', {
|
|
@@ -38,16 +51,16 @@ export const ErrorMsg = styled(Typography, {
|
|
|
38
51
|
color: '$error',
|
|
39
52
|
});
|
|
40
53
|
|
|
54
|
+
export const FeeContainer = styled('div', {
|
|
55
|
+
paddingLeft: '$16',
|
|
56
|
+
color: '$neutrals800'
|
|
57
|
+
});
|
|
58
|
+
|
|
41
59
|
export const Fee = styled('div', {
|
|
42
60
|
display: 'flex',
|
|
43
61
|
alignItems: 'center',
|
|
44
62
|
});
|
|
45
63
|
|
|
46
|
-
export const SwapperLogo = styled('img', {
|
|
47
|
-
width: '$16',
|
|
48
|
-
height: '$16',
|
|
49
|
-
});
|
|
50
|
-
|
|
51
64
|
export const RelativeContainer = styled('div', {
|
|
52
65
|
position: 'relative',
|
|
53
66
|
});
|
|
@@ -62,7 +75,7 @@ export const Dot = styled('div', {
|
|
|
62
75
|
height: '$8',
|
|
63
76
|
backgroundColor: '$foreground',
|
|
64
77
|
borderRadius: '4px',
|
|
65
|
-
marginLeft: '
|
|
78
|
+
marginLeft: '11px',
|
|
66
79
|
});
|
|
67
80
|
|
|
68
81
|
export const ArrowDown = styled('div', {
|
|
@@ -71,13 +84,12 @@ export const ArrowDown = styled('div', {
|
|
|
71
84
|
borderLeft: '5px solid transparent',
|
|
72
85
|
borderRight: '5px solid transparent',
|
|
73
86
|
borderTop: '5px solid $foreground',
|
|
74
|
-
marginLeft: '$
|
|
87
|
+
marginLeft: '$10',
|
|
75
88
|
});
|
|
76
89
|
|
|
77
90
|
const StyledAnchor = styled('a', {
|
|
78
91
|
color: '$primary',
|
|
79
92
|
fontWeight: '$600',
|
|
80
|
-
marginLeft: '$12',
|
|
81
93
|
});
|
|
82
94
|
|
|
83
95
|
const SwapInfoContainer = styled('div', {
|
|
@@ -89,11 +101,14 @@ const SwapInfoContainer = styled('div', {
|
|
|
89
101
|
|
|
90
102
|
const InternalDetailsContainer = styled('div', {
|
|
91
103
|
display: 'flex',
|
|
104
|
+
'.details': {
|
|
105
|
+
padding: '$8 0',
|
|
106
|
+
},
|
|
92
107
|
});
|
|
93
108
|
|
|
94
109
|
const InternalDetail = styled('div', {
|
|
95
110
|
display: 'flex',
|
|
96
|
-
|
|
111
|
+
margin: '$12 0 $12 $20',
|
|
97
112
|
});
|
|
98
113
|
|
|
99
114
|
const DescriptionContainer = styled('div', {
|
|
@@ -103,17 +118,13 @@ const DescriptionContainer = styled('div', {
|
|
|
103
118
|
|
|
104
119
|
const Description = styled(Typography, {
|
|
105
120
|
color: '$success',
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
const Error = styled(Description, {
|
|
110
|
-
color: '$error',
|
|
121
|
+
paddingLeft: '$4',
|
|
111
122
|
});
|
|
112
123
|
|
|
113
124
|
export const Line = styled('div', {
|
|
114
125
|
width: '0',
|
|
115
126
|
minHeight: '$16',
|
|
116
|
-
marginLeft: '
|
|
127
|
+
marginLeft: '14px',
|
|
117
128
|
border: '1px dashed $foreground',
|
|
118
129
|
borderRadius: 'inherit',
|
|
119
130
|
});
|
|
@@ -132,6 +143,7 @@ const Row = styled('div', {
|
|
|
132
143
|
display: 'flex',
|
|
133
144
|
alignItems: 'center',
|
|
134
145
|
color: '$neutrals800',
|
|
146
|
+
justifyContent: 'flex-end',
|
|
135
147
|
},
|
|
136
148
|
'.status': {
|
|
137
149
|
fontWeight: 'bold',
|
|
@@ -156,28 +168,14 @@ const RequestId = styled('div', {
|
|
|
156
168
|
});
|
|
157
169
|
|
|
158
170
|
const ExtraDetails = styled('div', {
|
|
159
|
-
padding: '
|
|
171
|
+
padding: '0',
|
|
160
172
|
color: '$neutrals600',
|
|
161
|
-
fontSize: '$
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
const StepContainer = styled('div', {
|
|
165
|
-
variants: {
|
|
166
|
-
hasNotStarted: {
|
|
167
|
-
true: {
|
|
168
|
-
filter: 'grayscale(100%)',
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
isRunning: {
|
|
172
|
-
true: {
|
|
173
|
-
animation: `${pulse} 2s ease-in-out infinite`,
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
173
|
+
fontSize: '$10',
|
|
177
174
|
});
|
|
178
175
|
|
|
179
176
|
const SwapFlowContainer = styled('div', {
|
|
180
177
|
overflowY: 'auto',
|
|
178
|
+
padding: '$8 $4 $2 $4',
|
|
181
179
|
});
|
|
182
180
|
|
|
183
181
|
export type PropTypes = {
|
|
@@ -238,28 +236,29 @@ export function SwapHistory(props: PropTypes) {
|
|
|
238
236
|
<div>
|
|
239
237
|
<SwapInfoContainer>
|
|
240
238
|
<Row>
|
|
241
|
-
<div className="name">
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
239
|
+
<div className="name">
|
|
240
|
+
Request Id:
|
|
241
|
+
<span
|
|
242
|
+
className="value requestId"
|
|
243
|
+
onClick={onCopy.bind(null, pendingSwap?.requestId)}
|
|
244
|
+
>
|
|
245
|
+
<RequestId>{pendingSwap?.requestId}</RequestId>
|
|
246
|
+
<Spacer size={4} />
|
|
247
|
+
<Button type="primary" variant="ghost" size="compact">
|
|
248
|
+
{isCopied ? 'Copied!' : 'Copy'}
|
|
249
|
+
</Button>
|
|
250
|
+
</span>
|
|
251
251
|
</div>
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
252
|
+
<div className="name">
|
|
253
|
+
<span className={`value status ${pendingSwap?.status || ''}`}>
|
|
254
|
+
{pendingSwap?.status}
|
|
255
|
+
{pendingSwap?.status === 'running' && (
|
|
256
|
+
<Spinner size={16} color="primary" />
|
|
257
|
+
)}
|
|
258
|
+
</span>
|
|
259
|
+
<ExtraDetails>{date}</ExtraDetails>
|
|
260
260
|
</div>
|
|
261
261
|
</Row>
|
|
262
|
-
<ExtraDetails>{date}</ExtraDetails>
|
|
263
262
|
</SwapInfoContainer>
|
|
264
263
|
{/* TODO: It was temporarily removed to find a better solution.
|
|
265
264
|
|
|
@@ -272,25 +271,16 @@ export function SwapHistory(props: PropTypes) {
|
|
|
272
271
|
<SwapMessages {...extraMessageProps} />
|
|
273
272
|
)}
|
|
274
273
|
|
|
275
|
-
<Divider size={
|
|
274
|
+
<Divider size={16} />
|
|
276
275
|
|
|
277
276
|
{pendingSwap?.steps.map((step, index) => (
|
|
278
|
-
<
|
|
279
|
-
key={index}
|
|
280
|
-
hasNotStarted={step.status === 'created'}
|
|
281
|
-
isRunning={
|
|
282
|
-
step.status != 'failed' &&
|
|
283
|
-
step.status != 'success' &&
|
|
284
|
-
step.status != 'created'
|
|
285
|
-
}
|
|
286
|
-
>
|
|
277
|
+
<div key={index}>
|
|
287
278
|
{index === 0 && (
|
|
288
279
|
<RelativeContainer>
|
|
289
280
|
<StepDetail
|
|
290
281
|
logo={step.fromLogo}
|
|
291
282
|
symbol={step.fromSymbol}
|
|
292
|
-
|
|
293
|
-
chainLogo={step.fromBlockchainLogo}
|
|
283
|
+
chainLogo={step.fromBlockchainLogo || ''}
|
|
294
284
|
blockchain={step.fromBlockchain}
|
|
295
285
|
amount={pendingSwap.inputAmount}
|
|
296
286
|
/>
|
|
@@ -298,33 +288,28 @@ export function SwapHistory(props: PropTypes) {
|
|
|
298
288
|
</RelativeContainer>
|
|
299
289
|
)}
|
|
300
290
|
<Line />
|
|
301
|
-
<SwapperContainer
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
291
|
+
<SwapperContainer
|
|
292
|
+
created={step.status === 'created'}
|
|
293
|
+
running={!['created', 'success', 'failed'].includes(step.status)}
|
|
294
|
+
>
|
|
295
|
+
<Image
|
|
296
|
+
src={step.swapperLogo || ''}
|
|
305
297
|
alt={step.swapperId}
|
|
298
|
+
size={20}
|
|
306
299
|
/>
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
}{' '}
|
|
313
|
-
from {step.fromSymbol} to {step.toSymbol}
|
|
314
|
-
via {step.swapperId}
|
|
300
|
+
|
|
301
|
+
<FeeContainer>
|
|
302
|
+
<Typography variant="body2">
|
|
303
|
+
{step.swapperType === 'DEX' ? 'Swap' : 'Bridge'} via{' '}
|
|
304
|
+
{step.swapperId}
|
|
315
305
|
</Typography>
|
|
316
306
|
<Fee>
|
|
317
307
|
<GasIcon />
|
|
318
|
-
<Typography
|
|
319
|
-
$
|
|
320
|
-
{
|
|
321
|
-
// @ts-ignore
|
|
322
|
-
step.feeInUsd
|
|
323
|
-
}{' '}
|
|
324
|
-
estimated gas fee
|
|
308
|
+
<Typography variant="body2">
|
|
309
|
+
${step.feeInUsd} estimated gas fee
|
|
325
310
|
</Typography>
|
|
326
311
|
</Fee>
|
|
327
|
-
</
|
|
312
|
+
</FeeContainer>
|
|
328
313
|
</SwapperContainer>
|
|
329
314
|
<div
|
|
330
315
|
style={{
|
|
@@ -333,55 +318,62 @@ export function SwapHistory(props: PropTypes) {
|
|
|
333
318
|
>
|
|
334
319
|
<InternalDetailsContainer>
|
|
335
320
|
<Line />
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
<
|
|
341
|
-
<
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
321
|
+
<div className="details">
|
|
322
|
+
{!!step.explorerUrl && (
|
|
323
|
+
<div>
|
|
324
|
+
{step.explorerUrl.map((item, index) => (
|
|
325
|
+
<InternalDetail key={index}>
|
|
326
|
+
<DescriptionContainer>
|
|
327
|
+
<Divider size={4} />
|
|
328
|
+
<CheckCircleIcon color="primary" />
|
|
329
|
+
<Description variant="body2">
|
|
330
|
+
<StyledAnchor
|
|
331
|
+
href={item.url}
|
|
332
|
+
target="_blank"
|
|
333
|
+
rel="noreferrer"
|
|
334
|
+
key={index}
|
|
335
|
+
>
|
|
336
|
+
{!item.description ? (
|
|
337
|
+
<b>View transaction</b>
|
|
338
|
+
) : (
|
|
339
|
+
<b>
|
|
340
|
+
{item.description
|
|
341
|
+
.substring(0, 1)
|
|
342
|
+
.toUpperCase()}
|
|
343
|
+
{item.description.substring(1)} Tx
|
|
344
|
+
</b>
|
|
345
|
+
)}
|
|
346
|
+
</StyledAnchor>
|
|
347
|
+
</Description>
|
|
348
|
+
</DescriptionContainer>
|
|
349
|
+
</InternalDetail>
|
|
350
|
+
))}
|
|
351
|
+
</div>
|
|
352
|
+
)}
|
|
353
|
+
{step.status === 'failed' && (
|
|
354
|
+
<InternalDetail>
|
|
355
|
+
<DescriptionContainer>
|
|
356
|
+
<InfoCircleIcon color="error" />
|
|
357
|
+
<Description variant="body2" color="$error500">
|
|
358
|
+
Step failed
|
|
359
|
+
</Description>
|
|
360
|
+
</DescriptionContainer>
|
|
361
|
+
</InternalDetail>
|
|
362
|
+
)}
|
|
363
|
+
</div>
|
|
373
364
|
</InternalDetailsContainer>
|
|
374
365
|
</div>
|
|
375
366
|
{index + 1 === pendingSwap.steps.length && <ArrowDown />}
|
|
376
367
|
<StepDetail
|
|
377
368
|
logo={step.toLogo}
|
|
378
369
|
symbol={step.toSymbol}
|
|
379
|
-
|
|
380
|
-
chainLogo={step.toBlockchainLogo}
|
|
370
|
+
chainLogo={step.toBlockchainLogo || ''}
|
|
381
371
|
blockchain={step.toBlockchain}
|
|
382
372
|
amount={step.outputAmount || ''}
|
|
373
|
+
estimatedAmount={step.expectedOutputAmountHumanReadable || ''}
|
|
374
|
+
success={step.status === 'success'}
|
|
383
375
|
/>
|
|
384
|
-
</
|
|
376
|
+
</div>
|
|
385
377
|
))}
|
|
386
378
|
|
|
387
379
|
<Divider size={32} />
|
|
@@ -394,17 +386,11 @@ export function SwapHistory(props: PropTypes) {
|
|
|
394
386
|
title="Cancel Progress"
|
|
395
387
|
content={
|
|
396
388
|
<Alert type="warning">
|
|
397
|
-
<
|
|
398
|
-
Warning:
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
</p>
|
|
403
|
-
<Spacer size={12} direction="vertical" />
|
|
404
|
-
<p>
|
|
405
|
-
If you have already signed your transaction to blockchain, you
|
|
406
|
-
should wait for that to complete or rollback
|
|
407
|
-
</p>
|
|
389
|
+
<Typography variant="body2">
|
|
390
|
+
Warning: Cancel <u>doesn't revert</u> your transaction if you've
|
|
391
|
+
already signed and sent a transaction to the blockchain. It only
|
|
392
|
+
stops next steps from being executed.
|
|
393
|
+
</Typography>
|
|
408
394
|
</Alert>
|
|
409
395
|
}
|
|
410
396
|
footer={
|
package/src/helper/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
|
|
1
|
+
export function containsText(text: string, searchText: string): boolean {
|
|
2
|
+
return text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
|
|
3
|
+
}
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
+
export function getConciseAddress(
|
|
5
6
|
address: string | null,
|
|
6
7
|
maxChars = 8,
|
|
7
8
|
ellipsisLength = 3
|
|
8
|
-
): string | null
|
|
9
|
+
): string | null {
|
|
9
10
|
if (!address) return null;
|
|
10
11
|
if (address.length < 2 * maxChars + ellipsisLength) return address;
|
|
11
12
|
const start = Math.ceil((address.length - maxChars) / 2);
|
|
@@ -13,4 +14,18 @@ export const getConciseAddress = (
|
|
|
13
14
|
return `${address.substr(start, maxChars)}${'.'.repeat(
|
|
14
15
|
ellipsisLength
|
|
15
16
|
)}${address.substr(end)}`;
|
|
16
|
-
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function limitDecimalPlaces(
|
|
20
|
+
numberString: string,
|
|
21
|
+
maxDecimalPlaces = 4
|
|
22
|
+
): string {
|
|
23
|
+
const number = parseFloat(numberString);
|
|
24
|
+
if (isNaN(number))
|
|
25
|
+
return numberString; // Return the original string if it's not a valid number
|
|
26
|
+
else {
|
|
27
|
+
const multiplier = Math.pow(10, maxDecimalPlaces);
|
|
28
|
+
const roundedNumber = Math.round(number * multiplier) / multiplier;
|
|
29
|
+
return roundedNumber.toString();
|
|
30
|
+
}
|
|
31
|
+
}
|