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