@rango-dev/ui 0.1.10-next.92 → 0.1.11-next.2

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 (96) hide show
  1. package/README.md +1 -181
  2. package/dist/components/Alert/LoadingFailedAlert.d.ts +2 -0
  3. package/dist/components/Alert/NotFoundAlert.d.ts +7 -0
  4. package/dist/components/Alert/index.d.ts +1 -0
  5. package/dist/components/BlockchainSelector/BlockchainSelector.d.ts +1 -1
  6. package/dist/components/Button/Button.d.ts +1 -1
  7. package/dist/components/Divider/Divider.d.ts +6 -0
  8. package/dist/components/Divider/index.d.ts +1 -0
  9. package/dist/components/Header/Header.d.ts +9 -0
  10. package/dist/components/Header/index.d.ts +1 -0
  11. package/dist/components/Icon/ArrowRightIcon.d.ts +3 -0
  12. package/dist/components/Icon/index.d.ts +1 -0
  13. package/dist/components/LiquiditySourceList/LiquiditySourceList.d.ts +3 -1
  14. package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +2 -1
  15. package/dist/components/Modal/Modal.d.ts +0 -1
  16. package/dist/components/SelectableWalletList/mock.d.ts +1 -1
  17. package/dist/components/Settings/Settings.d.ts +2 -1
  18. package/dist/components/SwapContainer/SwapContainer.d.ts +1 -0
  19. package/dist/components/SwapDetail/Token.d.ts +16 -0
  20. package/dist/components/TokenList/TokenList.d.ts +2 -2
  21. package/dist/components/TokenSelector/TokenSelector.d.ts +4 -3
  22. package/dist/components/index.d.ts +2 -0
  23. package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +10 -17
  24. package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +1 -0
  25. package/dist/containers/ConfirmSwap/mock.d.ts +3 -0
  26. package/dist/containers/History/History.d.ts +6 -1
  27. package/dist/containers/History/index.d.ts +1 -1
  28. package/dist/containers/History/types.d.ts +3 -24
  29. package/dist/containers/SwapHistory/SwapHistory.d.ts +16 -3
  30. package/dist/containers/SwapHistory/SwapMessages.d.ts +17 -0
  31. package/dist/containers/index.d.ts +0 -1
  32. package/dist/helper/index.d.ts +1 -0
  33. package/dist/types/meta.d.ts +1 -0
  34. package/dist/ui.cjs.development.js +1069 -857
  35. package/dist/ui.cjs.development.js.map +1 -1
  36. package/dist/ui.cjs.production.min.js +1 -1
  37. package/dist/ui.cjs.production.min.js.map +1 -1
  38. package/dist/ui.esm.js +1068 -859
  39. package/dist/ui.esm.js.map +1 -1
  40. package/package.json +3 -2
  41. package/src/components/Alert/Alert.tsx +33 -12
  42. package/src/components/Alert/LoadingFailedAlert.tsx +11 -0
  43. package/src/components/Alert/NotFoundAlert.tsx +19 -0
  44. package/src/components/Alert/index.ts +1 -0
  45. package/src/components/BestRoute/mock.ts +10 -0
  46. package/src/components/BlockchainSelector/BlockchainSelector.tsx +13 -19
  47. package/src/components/Button/Button.tsx +2 -1
  48. package/src/components/ConnectWalletsModal/mockData.ts +16 -0
  49. package/src/components/Divider/Divider.tsx +41 -0
  50. package/src/components/Divider/index.ts +1 -0
  51. package/src/components/Header/Header.tsx +39 -0
  52. package/src/components/Header/index.ts +1 -0
  53. package/src/components/Icon/ArrowRightIcon.tsx +31 -0
  54. package/src/components/Icon/index.ts +1 -0
  55. package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +72 -22
  56. package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +15 -10
  57. package/src/components/Modal/Modal.tsx +1 -6
  58. package/src/components/SecondaryPage/SecondaryPage.tsx +26 -52
  59. package/src/components/SelectableWalletList/SelectableWalletList.tsx +5 -0
  60. package/src/components/SelectableWalletList/mock.ts +4 -3
  61. package/src/components/Settings/Settings.tsx +30 -11
  62. package/src/components/StatusDrawer/StatusDrawer.tsx +1 -0
  63. package/src/components/StepDetail/StepDetail.tsx +1 -0
  64. package/src/components/SwapContainer/SwapContainer.tsx +21 -16
  65. package/src/components/SwapDetail/SwapDetail.tsx +77 -115
  66. package/src/components/SwapDetail/Token.tsx +68 -0
  67. package/src/components/SwapDetail/mock.ts +1 -0
  68. package/src/components/TextField/TextField.tsx +1 -0
  69. package/src/components/TokenList/TokenItem.tsx +4 -1
  70. package/src/components/TokenList/TokenList.tsx +18 -21
  71. package/src/components/TokenSelector/TokenSelector.tsx +38 -25
  72. package/src/components/Wallet/Wallet.tsx +1 -1
  73. package/src/components/index.ts +2 -0
  74. package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +11 -2
  75. package/src/containers/ConfirmSwap/ConfirmSwap.tsx +103 -117
  76. package/src/containers/ConfirmSwap/mock.ts +79 -2
  77. package/src/containers/History/History.tsx +57 -38
  78. package/src/containers/History/index.ts +1 -1
  79. package/src/containers/History/mock.ts +1 -0
  80. package/src/containers/History/types.tsx +2 -30
  81. package/src/containers/SwapHistory/SwapHistory.tsx +313 -165
  82. package/src/containers/SwapHistory/SwapMessages.tsx +116 -0
  83. package/src/containers/SwapHistory/mock.ts +1 -0
  84. package/src/containers/index.ts +0 -1
  85. package/src/helper/index.ts +14 -0
  86. package/src/types/meta.ts +2 -0
  87. package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +0 -16
  88. package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +0 -6
  89. package/dist/containers/ConfirmWallets/index.d.ts +0 -1
  90. package/dist/containers/ConfirmWallets/mock.d.ts +0 -5
  91. package/dist/helper/swaps.d.ts +0 -5
  92. package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +0 -26
  93. package/src/containers/ConfirmWallets/ConfirmWallets.tsx +0 -143
  94. package/src/containers/ConfirmWallets/index.ts +0 -1
  95. package/src/containers/ConfirmWallets/mock.ts +0 -222
  96. package/src/helper/swaps.ts +0 -23
@@ -6,24 +6,73 @@ import {
6
6
  Typography,
7
7
  CheckCircleIcon,
8
8
  InfoCircleIcon,
9
- CopyIcon,
10
9
  Spacer,
11
- CheckSquareIcon,
12
10
  Button,
13
11
  Alert,
14
12
  Drawer,
13
+ Spinner,
14
+ Divider,
15
15
  } from '../../components';
16
16
  import { styled } from '../../theme';
17
- import {
18
- RelativeContainer,
19
- Dot,
20
- SwapperContainer,
21
- SwapperLogo,
22
- ArrowDown,
23
- Fee,
24
- } from '../ConfirmSwap/ConfirmSwap';
25
17
  import { PendingSwap } from '../History/types';
26
18
  import { pulse } from '../../components/BestRoute/BestRoute';
19
+ import {
20
+ SwapMessages,
21
+ PropTypes as SwapMessagesPropTypes,
22
+ } from './SwapMessages';
23
+
24
+ export const SwapperContainer = styled('div', {
25
+ display: 'flex',
26
+ alignItems: 'center',
27
+ marginLeft: '6px',
28
+ });
29
+
30
+ export const BodyError = styled('div', {
31
+ height: '100%',
32
+ display: 'flex',
33
+ justifyContent: 'center',
34
+ alignItems: 'center',
35
+ });
36
+
37
+ export const ErrorMsg = styled(Typography, {
38
+ color: '$error',
39
+ });
40
+
41
+ export const Fee = styled('div', {
42
+ display: 'flex',
43
+ alignItems: 'center',
44
+ });
45
+
46
+ export const SwapperLogo = styled('img', {
47
+ width: '$16',
48
+ height: '$16',
49
+ });
50
+
51
+ export const RelativeContainer = styled('div', {
52
+ position: 'relative',
53
+ });
54
+
55
+ export const Footer = styled('div', {
56
+ display: 'flex',
57
+ alignItems: 'center',
58
+ });
59
+
60
+ export const Dot = styled('div', {
61
+ width: '$8',
62
+ height: '$8',
63
+ backgroundColor: '$foreground',
64
+ borderRadius: '4px',
65
+ marginLeft: '$8',
66
+ });
67
+
68
+ export const ArrowDown = styled('div', {
69
+ width: '0px',
70
+ height: '0px',
71
+ borderLeft: '5px solid transparent',
72
+ borderRight: '5px solid transparent',
73
+ borderTop: '5px solid $foreground',
74
+ marginLeft: '$8',
75
+ });
27
76
 
28
77
  const StyledAnchor = styled('a', {
29
78
  color: '$primary',
@@ -31,6 +80,13 @@ const StyledAnchor = styled('a', {
31
80
  marginLeft: '$12',
32
81
  });
33
82
 
83
+ const SwapInfoContainer = styled('div', {
84
+ display: 'flex',
85
+ flexDirection: 'column',
86
+ paddingBottom: '$16',
87
+ borderBottom: '1px solid $neutrals300',
88
+ });
89
+
34
90
  const InternalDetailsContainer = styled('div', {
35
91
  display: 'flex',
36
92
  });
@@ -62,25 +118,47 @@ export const Line = styled('div', {
62
118
  borderRadius: 'inherit',
63
119
  });
64
120
 
65
- const RequestIdContainer = styled('div', {
66
- cursor: 'pointer',
67
- backgroundColor: '$neutrals200',
68
- padding: '$4',
121
+ const Row = styled('div', {
69
122
  display: 'flex',
70
- justifyContent: 'center',
123
+ justifyContent: 'space-between',
71
124
  alignItems: 'center',
72
- borderRadius: '$5',
73
- marginBottom: '$16',
125
+ fontSize: '$14',
126
+ padding: '$8 0',
127
+
128
+ '.name': {
129
+ color: '$neutrals600',
130
+ },
131
+ '.value': {
132
+ display: 'flex',
133
+ alignItems: 'center',
134
+ color: '$neutrals800',
135
+ },
136
+ '.status': {
137
+ fontWeight: 'bold',
138
+ textTransform: 'uppercase',
139
+ },
140
+ '.status.failed': {
141
+ color: '$error',
142
+ },
143
+ '.status.success': {
144
+ color: '$success',
145
+ },
74
146
  });
75
147
 
76
- const RequestId = styled(Typography, {
77
- color: '$warning500',
148
+ const RequestId = styled('div', {
149
+ width: '150px',
150
+ whiteSpace: 'nowrap',
151
+ overflow: 'hidden',
152
+ textOverflow: 'ellipsis',
153
+ '@md': {
154
+ width: 'auto',
155
+ },
78
156
  });
79
157
 
80
- const CancelButtonContainer = styled('div', {
81
- display: 'flex',
82
- justifyContent: 'center',
83
- alignItems: 'center',
158
+ const ExtraDetails = styled('div', {
159
+ padding: '$8 0',
160
+ color: '$neutrals600',
161
+ fontSize: '$12',
84
162
  });
85
163
 
86
164
  const StepContainer = styled('div', {
@@ -98,145 +176,220 @@ const StepContainer = styled('div', {
98
176
  },
99
177
  });
100
178
 
101
- export interface PropTypes {
179
+ const SwapFlowContainer = styled('div', {
180
+ overflowY: 'auto',
181
+ });
182
+
183
+ export type PropTypes = {
102
184
  pendingSwap: PendingSwap;
103
185
  onCopy: (requestId: string) => void;
104
186
  onBack: () => void;
105
187
  isCopied: boolean;
106
188
  onCancel: (requestId: string) => void;
107
- }
189
+ onRetry?: () => void;
190
+ date: string;
191
+ previewInputs?: React.ReactNode;
192
+ } & SwapMessagesPropTypes;
108
193
 
109
194
  export function SwapHistory(props: PropTypes) {
110
- const { pendingSwap, onBack, onCopy, isCopied, onCancel } = props;
195
+ const {
196
+ pendingSwap,
197
+ onBack,
198
+ onCopy,
199
+ isCopied,
200
+ onCancel,
201
+ date,
202
+ onRetry,
203
+ previewInputs,
204
+ ...extraMessageProps
205
+ } = props;
111
206
  const [showDrawer, setShowDrawer] = useState(false);
112
207
 
113
208
  return (
114
- <SecondaryPage title="Swap Details" textField={false} onBack={onBack}>
115
- <div style={{ overflow: 'hidden' }}>
116
- <div>
117
- <Typography variant="body1"> request ID :</Typography>
118
- <RequestIdContainer
119
- onClick={onCopy.bind(null, pendingSwap?.requestId)}
120
- >
121
- <RequestId variant="body1">{pendingSwap?.requestId}</RequestId>
122
- <Spacer size={12} />
123
- {isCopied ? (
124
- <CheckSquareIcon color="success" size={18} />
125
- ) : (
126
- <CopyIcon color="warning" size={18} />
127
- )}
128
- </RequestIdContainer>
129
- </div>
130
- <div style={{ overflow: 'auto', position: 'relative' }}>
131
- {pendingSwap?.steps.map((step, index) => (
132
- <StepContainer
133
- key={index}
134
- hasNotStarted={step.status === 'created'}
135
- isRunning={
136
- step.status != 'failed' &&
137
- step.status != 'success' &&
138
- step.status != 'created'
139
- }
209
+ <SecondaryPage
210
+ title="Swap Details"
211
+ textField={false}
212
+ onBack={onBack}
213
+ Footer={
214
+ <>
215
+ {pendingSwap?.status === 'running' && (
216
+ <Button
217
+ variant="outlined"
218
+ fullWidth
219
+ type="error"
220
+ onClick={setShowDrawer.bind(null, true)}
221
+ >
222
+ Cancel
223
+ </Button>
224
+ )}
225
+ {!!onRetry && (
226
+ <Button
227
+ variant="contained"
228
+ fullWidth
229
+ type="primary"
230
+ onClick={onRetry}
231
+ >
232
+ Try again
233
+ </Button>
234
+ )}
235
+ </>
236
+ }
237
+ >
238
+ <div>
239
+ <SwapInfoContainer>
240
+ <Row>
241
+ <div className="name">Request ID:</div>
242
+ <div
243
+ className="value requestId"
244
+ onClick={onCopy.bind(null, pendingSwap?.requestId)}
140
245
  >
141
- {index === 0 && (
142
- <RelativeContainer>
143
- <StepDetail
144
- logo={step.fromLogo}
145
- symbol={step.fromSymbol}
146
- chainLogo={step.fromBlockchainLogo}
147
- blockchain={step.fromBlockchain}
148
- amount={pendingSwap.inputAmount}
149
- />
150
- <Dot />
151
- </RelativeContainer>
246
+ <RequestId>{pendingSwap?.requestId}</RequestId>
247
+ <Spacer size={4} />
248
+ <Button type="primary" variant="ghost" size="compact">
249
+ {isCopied ? 'Copied!' : 'Copy'}
250
+ </Button>
251
+ </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" />
152
259
  )}
153
- <Line />
154
- <SwapperContainer>
155
- <SwapperLogo src={step.swapperLogo} alt={step.swapperId} />
156
- <div>
260
+ </div>
261
+ </Row>
262
+ <ExtraDetails>{date}</ExtraDetails>
263
+ </SwapInfoContainer>
264
+ {/* TODO: It was temporarily removed to find a better solution.
265
+
266
+ <Divider size={16} />*/}
267
+ </div>
268
+ <SwapFlowContainer>
269
+ {/*{previewInputs} */}
270
+
271
+ {extraMessageProps.shortMessage && (
272
+ <SwapMessages {...extraMessageProps} />
273
+ )}
274
+
275
+ <Divider size={32} />
276
+
277
+ {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
+ >
287
+ {index === 0 && (
288
+ <RelativeContainer>
289
+ <StepDetail
290
+ logo={step.fromLogo}
291
+ symbol={step.fromSymbol}
292
+ // @ts-ignore
293
+ chainLogo={step.fromBlockchainLogo || ''}
294
+ blockchain={step.fromBlockchain}
295
+ amount={pendingSwap.inputAmount}
296
+ />
297
+ <Dot />
298
+ </RelativeContainer>
299
+ )}
300
+ <Line />
301
+ <SwapperContainer>
302
+ <SwapperLogo
303
+ src={
304
+ // @ts-ignore
305
+ step.swapperLogo || ''
306
+ }
307
+ alt={step.swapperId}
308
+ />
309
+ <div>
310
+ <Typography ml={4} variant="caption">
311
+ {
312
+ // @ts-ignore
313
+ step.swapperType
314
+ }{' '}
315
+ from {step.fromSymbol} to {step.toSymbol}
316
+ via {step.swapperId}
317
+ </Typography>
318
+ <Fee>
319
+ <GasIcon />
157
320
  <Typography ml={4} variant="caption">
158
- {step.swapperType} from {step.fromSymbol} to {step.toSymbol}
159
- via {step.swapperId}
321
+ $
322
+ {
323
+ // @ts-ignore
324
+
325
+ step.feeInUsd
326
+ }{' '}
327
+ estimated gas fee
160
328
  </Typography>
161
- <Fee>
162
- <GasIcon />
163
- <Typography ml={4} variant="caption">
164
- ${step.feeInUsd} estimated gas fee
165
- </Typography>
166
- </Fee>
167
- </div>
168
- </SwapperContainer>
169
- <div
170
- style={{
171
- display: 'flex',
172
- }}
173
- >
174
- <InternalDetailsContainer>
175
- <Line />
176
- {!!step.explorerUrl && (
177
- <div>
178
- {step.explorerUrl.map((item, index) => (
179
- <InternalDetail key={index}>
180
- <DescriptionContainer>
181
- <CheckCircleIcon color="success" />
182
- <Description variant="body2">
183
- {!item.description ? (
184
- <b>View transaction</b>
185
- ) : (
186
- <b>
187
- {item.description
188
- .substring(0, 1)
189
- .toUpperCase()}
190
- {item.description.substring(1)}
191
- </b>
192
- )}
193
- </Description>
194
- </DescriptionContainer>
195
- <StyledAnchor
196
- href={item.url}
197
- target="_blank"
198
- rel="noreferrer"
199
- key={index}
200
- >
201
- TX-Link
202
- </StyledAnchor>
203
- </InternalDetail>
204
- ))}
205
- {step.status === 'failed' && (
206
- <InternalDetail>
207
- <DescriptionContainer>
208
- <InfoCircleIcon color="error" />
209
- <Error variant="body2">Step failed</Error>
210
- </DescriptionContainer>
211
- </InternalDetail>
212
- )}
213
- </div>
214
- )}
215
- </InternalDetailsContainer>
329
+ </Fee>
216
330
  </div>
217
- {index + 1 === pendingSwap.steps.length && <ArrowDown />}
218
- <StepDetail
219
- logo={step.toLogo}
220
- symbol={step.toSymbol}
221
- chainLogo={step.toBlockchainLogo}
222
- blockchain={step.toBlockchain}
223
- amount={step.outputAmount}
224
- />
225
- </StepContainer>
226
- ))}
227
- {pendingSwap?.status === 'running' && (
228
- <CancelButtonContainer>
229
- <Button
230
- variant="contained"
231
- type="error"
232
- onClick={setShowDrawer.bind(null, true)}
233
- >
234
- Cancel
235
- </Button>
236
- </CancelButtonContainer>
237
- )}
238
- </div>
239
- </div>
331
+ </SwapperContainer>
332
+ <div
333
+ style={{
334
+ display: 'flex',
335
+ }}
336
+ >
337
+ <InternalDetailsContainer>
338
+ <Line />
339
+ {!!step.explorerUrl && (
340
+ <div>
341
+ {step.explorerUrl.map((item, index) => (
342
+ <InternalDetail key={index}>
343
+ <DescriptionContainer>
344
+ <CheckCircleIcon color="success" />
345
+ <Description variant="body2">
346
+ {!item.description ? (
347
+ <b>View transaction</b>
348
+ ) : (
349
+ <b>
350
+ {item.description.substring(0, 1).toUpperCase()}
351
+ {item.description.substring(1)}
352
+ </b>
353
+ )}
354
+ </Description>
355
+ </DescriptionContainer>
356
+ <StyledAnchor
357
+ href={item.url}
358
+ target="_blank"
359
+ rel="noreferrer"
360
+ key={index}
361
+ >
362
+ TX-Link
363
+ </StyledAnchor>
364
+ </InternalDetail>
365
+ ))}
366
+ {step.status === 'failed' && (
367
+ <InternalDetail>
368
+ <DescriptionContainer>
369
+ <InfoCircleIcon color="error" />
370
+ <Error variant="body2">Step failed</Error>
371
+ </DescriptionContainer>
372
+ </InternalDetail>
373
+ )}
374
+ </div>
375
+ )}
376
+ </InternalDetailsContainer>
377
+ </div>
378
+ {index + 1 === pendingSwap.steps.length && <ArrowDown />}
379
+ <StepDetail
380
+ logo={step.toLogo}
381
+ symbol={step.toSymbol}
382
+ // @ts-ignore
383
+
384
+ chainLogo={step.toBlockchainLogo || ''}
385
+ blockchain={step.toBlockchain}
386
+ amount={step.outputAmount || ''}
387
+ />
388
+ </StepContainer>
389
+ ))}
390
+
391
+ <Divider size={32} />
392
+ </SwapFlowContainer>
240
393
  <Drawer
241
394
  onClose={setShowDrawer.bind(null, false)}
242
395
  open={showDrawer}
@@ -244,24 +397,19 @@ export function SwapHistory(props: PropTypes) {
244
397
  anchor="bottom"
245
398
  title="Cancel Progress"
246
399
  content={
247
- <>
248
- <Alert type="warning">
249
- <Typography variant="body2">
250
- <p>
251
- Warning: Rango <u>neither reverts</u> your transaction
252
- <u>nor refunds</u> you if you've already signed and sent a
253
- transaction to the blockchain since it's out of Rango's
254
- control. Beware that "Cancel" only stops next steps from being
255
- executed.
256
- </p>
257
- <Spacer size={12} direction="vertical" />
258
- <p>
259
- If you have already signed your transaction to blockchain, you
260
- should wait for that to complete or rollback
261
- </p>
262
- </Typography>
263
- </Alert>
264
- </>
400
+ <Alert type="warning">
401
+ <p>
402
+ Warning: Rango <u>neither reverts</u> your transaction&nbsp;
403
+ <u>nor refunds</u> you if you've already signed and sent a
404
+ transaction to the blockchain since it's out of Rango's control.
405
+ Beware that "Cancel" only stops next steps from being executed.
406
+ </p>
407
+ <Spacer size={12} direction="vertical" />
408
+ <p>
409
+ If you have already signed your transaction to blockchain, you
410
+ should wait for that to complete or rollback
411
+ </p>
412
+ </Alert>
265
413
  }
266
414
  footer={
267
415
  <div
@@ -0,0 +1,116 @@
1
+ import React, { useState } from 'react';
2
+ import { Alert, Button, Typography } from '../../components';
3
+ import { styled } from '../../theme';
4
+
5
+ const getAlertType = (messageType: PropTypes['type']) => {
6
+ if (!messageType || messageType === 'info') return 'secondary';
7
+ else return messageType;
8
+ };
9
+
10
+ const DetailedMessage = styled('div', {
11
+ width: '90%',
12
+ overflowWrap: 'break-word',
13
+ color: '$error500 !important',
14
+ });
15
+
16
+ export type PropTypes = {
17
+ currentStepBlockchain: string;
18
+ switchNetwork?: () => Promise<any>;
19
+ shortMessage: string;
20
+ detailedMessage: { content: string; long: boolean };
21
+ type?: 'success' | 'error' | 'warning' | 'info';
22
+ lastConvertedTokenInFailedSwap?: {
23
+ symbol: string;
24
+ blockchain: string;
25
+ outputAmount: string;
26
+ };
27
+ };
28
+
29
+ const SuccessText = styled(Typography, {
30
+ color: '$success500 !important',
31
+ });
32
+
33
+ export const SwapMessages: React.FC<PropTypes> = (props) => {
34
+ const {
35
+ shortMessage,
36
+ detailedMessage,
37
+ currentStepBlockchain,
38
+ type,
39
+ lastConvertedTokenInFailedSwap,
40
+ } = props;
41
+
42
+ const [expandedMessage, setExpandedMessage] = useState(false);
43
+
44
+ const allowedNumberOfChars = detailedMessage.long ? 0 : 150;
45
+
46
+ const shouldShowMoreDetailsButton =
47
+ !expandedMessage && detailedMessage.content.length > allowedNumberOfChars;
48
+
49
+ return (
50
+ <Alert
51
+ type={getAlertType(type)}
52
+ title={shortMessage}
53
+ {...(shouldShowMoreDetailsButton && {
54
+ footer: (
55
+ <Button
56
+ variant="outlined"
57
+ type="primary"
58
+ onClick={setExpandedMessage.bind(null, (prevState) => !prevState)}
59
+ >
60
+ Show more details
61
+ </Button>
62
+ ),
63
+ })}
64
+ {...(!!props.switchNetwork && {
65
+ footer: (
66
+ <Button
67
+ variant={'outlined'}
68
+ type="primary"
69
+ onClick={props.switchNetwork}
70
+ >
71
+ Change network to {currentStepBlockchain}
72
+ </Button>
73
+ ),
74
+ })}
75
+ >
76
+ {!!detailedMessage.content ? (
77
+ <DetailedMessage>
78
+ <Typography variant="body2">
79
+ {shouldShowMoreDetailsButton && !expandedMessage
80
+ ? detailedMessage.content.substring(0, allowedNumberOfChars) +
81
+ (allowedNumberOfChars > 0 ? '...' : '')
82
+ : detailedMessage.content}
83
+ </Typography>
84
+ </DetailedMessage>
85
+ ) : null}
86
+ {!!lastConvertedTokenInFailedSwap && (
87
+ <>
88
+ <p>
89
+ <Typography variant="body2">
90
+ Don't worry, your fund is&nbsp;
91
+ </Typography>
92
+ <SuccessText variant="body2">
93
+ <b>Safe</b>
94
+ </SuccessText>
95
+ </p>
96
+
97
+ <p>
98
+ <Typography variant="body2">
99
+ It is converted to &nbsp;
100
+ <u>{lastConvertedTokenInFailedSwap.outputAmount}</u>
101
+ &nbsp;
102
+ </Typography>
103
+ <SuccessText variant="body2">
104
+ <b>{lastConvertedTokenInFailedSwap.symbol}&nbsp;</b>
105
+ </SuccessText>
106
+ <Typography variant="body2">on your&nbsp;</Typography>
107
+ <SuccessText variant="body2">
108
+ <b>{lastConvertedTokenInFailedSwap.blockchain}&nbsp;</b>
109
+ </SuccessText>
110
+ <Typography variant="body2">wallet</Typography>
111
+ </p>
112
+ </>
113
+ )}
114
+ </Alert>
115
+ );
116
+ };
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  import { RoutingResultType, TransactionType } from 'rango-sdk';
2
3
  import { PendingSwap } from '../History/types';
3
4
 
@@ -1,4 +1,3 @@
1
1
  export * from './ConfirmSwap';
2
- export * from './ConfirmWallets';
3
2
  export * from './History';
4
3
  export * from './SwapHistory';
@@ -1,2 +1,16 @@
1
1
  export const containsText = (text: string, searchText: string) =>
2
2
  text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
3
+
4
+ export const getConciseAddress = (
5
+ address: string | null,
6
+ maxChars = 8,
7
+ ellipsisLength = 3
8
+ ): string | null => {
9
+ if (!address) return null;
10
+ if (address.length < 2 * maxChars + ellipsisLength) return address;
11
+ const start = Math.ceil((address.length - maxChars) / 2);
12
+ const end = address.length - maxChars;
13
+ return `${address.substr(start, maxChars)}${'.'.repeat(
14
+ ellipsisLength
15
+ )}${address.substr(end)}`;
16
+ };