@rango-dev/ui 0.1.10-next.92 → 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 (112) 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/Icon/types.d.ts +1 -0
  14. package/dist/components/LiquiditySourceList/LiquiditySourceList.d.ts +3 -1
  15. package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +2 -1
  16. package/dist/components/Modal/Modal.d.ts +0 -1
  17. package/dist/components/SelectableWalletList/mock.d.ts +1 -1
  18. package/dist/components/Settings/Settings.d.ts +2 -1
  19. package/dist/components/StepDetail/StepDetail.d.ts +3 -1
  20. package/dist/components/SwapContainer/SwapContainer.d.ts +1 -0
  21. package/dist/components/SwapDetail/Token.d.ts +17 -0
  22. package/dist/components/TextField/TextField.d.ts +1 -1
  23. package/dist/components/TokenList/TokenList.d.ts +2 -2
  24. package/dist/components/TokenSelector/TokenSelector.d.ts +4 -3
  25. package/dist/components/Typography/Typography.d.ts +1 -1
  26. package/dist/components/common/Image.d.ts +6 -0
  27. package/dist/components/common/index.d.ts +1 -0
  28. package/dist/components/index.d.ts +2 -0
  29. package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +14 -19
  30. package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +1 -0
  31. package/dist/containers/ConfirmSwap/mock.d.ts +3 -0
  32. package/dist/containers/History/History.d.ts +5 -7
  33. package/dist/containers/History/SwapsGroup.d.ts +13 -0
  34. package/dist/containers/History/index.d.ts +1 -0
  35. package/dist/containers/History/types.d.ts +3 -24
  36. package/dist/containers/SwapHistory/SwapHistory.d.ts +16 -3
  37. package/dist/containers/SwapHistory/SwapMessages.d.ts +17 -0
  38. package/dist/containers/index.d.ts +0 -1
  39. package/dist/helper/index.d.ts +3 -1
  40. package/dist/types/meta.d.ts +1 -0
  41. package/dist/ui.cjs.development.js +1137 -837
  42. package/dist/ui.cjs.development.js.map +1 -1
  43. package/dist/ui.cjs.production.min.js +1 -1
  44. package/dist/ui.cjs.production.min.js.map +1 -1
  45. package/dist/ui.esm.js +1134 -839
  46. package/dist/ui.esm.js.map +1 -1
  47. package/package.json +3 -2
  48. package/src/components/Alert/Alert.tsx +33 -12
  49. package/src/components/Alert/LoadingFailedAlert.tsx +11 -0
  50. package/src/components/Alert/NotFoundAlert.tsx +19 -0
  51. package/src/components/Alert/index.ts +1 -0
  52. package/src/components/BestRoute/BestRoute.tsx +2 -5
  53. package/src/components/BestRoute/mock.ts +10 -0
  54. package/src/components/BlockchainSelector/BlockchainSelector.tsx +31 -34
  55. package/src/components/BlockchainsList/BlockchainsList.tsx +8 -6
  56. package/src/components/Button/Button.tsx +2 -1
  57. package/src/components/ConnectWalletsModal/mockData.ts +16 -0
  58. package/src/components/Divider/Divider.tsx +41 -0
  59. package/src/components/Divider/index.ts +1 -0
  60. package/src/components/Drawer/Drawer.tsx +1 -1
  61. package/src/components/Header/Header.tsx +39 -0
  62. package/src/components/Header/index.ts +1 -0
  63. package/src/components/Icon/ArrowRightIcon.tsx +31 -0
  64. package/src/components/Icon/common.ts +10 -0
  65. package/src/components/Icon/index.ts +1 -0
  66. package/src/components/Icon/types.tsx +1 -0
  67. package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +81 -27
  68. package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +15 -10
  69. package/src/components/Modal/Modal.tsx +1 -6
  70. package/src/components/SecondaryPage/SecondaryPage.tsx +26 -52
  71. package/src/components/SelectableWalletList/SelectableWalletList.tsx +7 -1
  72. package/src/components/SelectableWalletList/mock.ts +4 -3
  73. package/src/components/Settings/Settings.tsx +34 -14
  74. package/src/components/StatusDrawer/StatusDrawer.tsx +1 -0
  75. package/src/components/StepDetail/StepDetail.tsx +46 -12
  76. package/src/components/SwapContainer/SwapContainer.tsx +21 -17
  77. package/src/components/SwapDetail/SwapDetail.tsx +71 -117
  78. package/src/components/SwapDetail/Token.tsx +73 -0
  79. package/src/components/SwapDetail/mock.ts +1 -0
  80. package/src/components/TextField/TextField.tsx +9 -0
  81. package/src/components/TokenList/TokenItem.tsx +12 -6
  82. package/src/components/TokenList/TokenList.tsx +18 -21
  83. package/src/components/TokenSelector/TokenSelector.tsx +38 -25
  84. package/src/components/Typography/Typography.tsx +8 -0
  85. package/src/components/Wallet/Wallet.tsx +9 -6
  86. package/src/components/common/Image.tsx +27 -0
  87. package/src/components/common/index.ts +1 -0
  88. package/src/components/index.ts +2 -0
  89. package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +11 -2
  90. package/src/containers/ConfirmSwap/ConfirmSwap.tsx +111 -125
  91. package/src/containers/ConfirmSwap/mock.ts +79 -2
  92. package/src/containers/History/History.tsx +33 -57
  93. package/src/containers/History/SwapsGroup.tsx +59 -0
  94. package/src/containers/History/index.ts +1 -0
  95. package/src/containers/History/mock.ts +1 -0
  96. package/src/containers/History/types.tsx +2 -30
  97. package/src/containers/SwapHistory/SwapHistory.tsx +306 -177
  98. package/src/containers/SwapHistory/SwapMessages.tsx +116 -0
  99. package/src/containers/SwapHistory/mock.ts +1 -0
  100. package/src/containers/index.ts +0 -1
  101. package/src/helper/index.ts +31 -2
  102. package/src/types/meta.ts +2 -0
  103. package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +0 -16
  104. package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +0 -6
  105. package/dist/containers/ConfirmWallets/index.d.ts +0 -1
  106. package/dist/containers/ConfirmWallets/mock.d.ts +0 -5
  107. package/dist/helper/swaps.d.ts +0 -5
  108. package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +0 -26
  109. package/src/containers/ConfirmWallets/ConfirmWallets.tsx +0 -143
  110. package/src/containers/ConfirmWallets/index.ts +0 -1
  111. package/src/containers/ConfirmWallets/mock.ts +0 -222
  112. package/src/helper/swaps.ts +0 -23
@@ -6,38 +6,108 @@ 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
+ Image,
15
16
  } from '../../components';
16
17
  import { styled } from '../../theme';
17
- import {
18
- RelativeContainer,
19
- Dot,
20
- SwapperContainer,
21
- SwapperLogo,
22
- ArrowDown,
23
- Fee,
24
- } from '../ConfirmSwap/ConfirmSwap';
25
18
  import { PendingSwap } from '../History/types';
26
19
  import { pulse } from '../../components/BestRoute/BestRoute';
20
+ import {
21
+ SwapMessages,
22
+ PropTypes as SwapMessagesPropTypes,
23
+ } from './SwapMessages';
24
+
25
+ export const SwapperContainer = styled('div', {
26
+ display: 'flex',
27
+ alignItems: 'center',
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
+ },
41
+ });
42
+
43
+ export const BodyError = styled('div', {
44
+ height: '100%',
45
+ display: 'flex',
46
+ justifyContent: 'center',
47
+ alignItems: 'center',
48
+ });
49
+
50
+ export const ErrorMsg = styled(Typography, {
51
+ color: '$error',
52
+ });
53
+
54
+ export const FeeContainer = styled('div', {
55
+ paddingLeft: '$16',
56
+ });
57
+
58
+ export const Fee = styled('div', {
59
+ display: 'flex',
60
+ alignItems: 'center',
61
+ });
62
+
63
+ export const RelativeContainer = styled('div', {
64
+ position: 'relative',
65
+ });
66
+
67
+ export const Footer = styled('div', {
68
+ display: 'flex',
69
+ alignItems: 'center',
70
+ });
71
+
72
+ export const Dot = styled('div', {
73
+ width: '$8',
74
+ height: '$8',
75
+ backgroundColor: '$foreground',
76
+ borderRadius: '4px',
77
+ marginLeft: '11px',
78
+ });
79
+
80
+ export const ArrowDown = styled('div', {
81
+ width: '0px',
82
+ height: '0px',
83
+ borderLeft: '5px solid transparent',
84
+ borderRight: '5px solid transparent',
85
+ borderTop: '5px solid $foreground',
86
+ marginLeft: '$10',
87
+ });
27
88
 
28
89
  const StyledAnchor = styled('a', {
29
90
  color: '$primary',
30
91
  fontWeight: '$600',
31
- marginLeft: '$12',
92
+ });
93
+
94
+ const SwapInfoContainer = styled('div', {
95
+ display: 'flex',
96
+ flexDirection: 'column',
97
+ paddingBottom: '$16',
98
+ borderBottom: '1px solid $neutrals300',
32
99
  });
33
100
 
34
101
  const InternalDetailsContainer = styled('div', {
35
102
  display: 'flex',
103
+ '.details': {
104
+ padding: '$8 0',
105
+ },
36
106
  });
37
107
 
38
108
  const InternalDetail = styled('div', {
39
109
  display: 'flex',
40
- padding: '$10',
110
+ margin: '$12 0 $12 $20',
41
111
  });
42
112
 
43
113
  const DescriptionContainer = styled('div', {
@@ -47,196 +117,266 @@ const DescriptionContainer = styled('div', {
47
117
 
48
118
  const Description = styled(Typography, {
49
119
  color: '$success',
50
- marginLeft: '$8',
51
- });
52
-
53
- const Error = styled(Description, {
54
- color: '$error',
120
+ paddingLeft: '$4',
55
121
  });
56
122
 
57
123
  export const Line = styled('div', {
58
124
  width: '0',
59
125
  minHeight: '$16',
60
- marginLeft: '$12',
126
+ marginLeft: '14px',
61
127
  border: '1px dashed $foreground',
62
128
  borderRadius: 'inherit',
63
129
  });
64
130
 
65
- const RequestIdContainer = styled('div', {
66
- cursor: 'pointer',
67
- backgroundColor: '$neutrals200',
68
- padding: '$4',
131
+ const Row = styled('div', {
69
132
  display: 'flex',
70
- justifyContent: 'center',
133
+ justifyContent: 'space-between',
71
134
  alignItems: 'center',
72
- borderRadius: '$5',
73
- marginBottom: '$16',
135
+ fontSize: '$14',
136
+ padding: '$8 0',
137
+
138
+ '.name': {
139
+ color: '$neutrals600',
140
+ },
141
+ '.value': {
142
+ display: 'flex',
143
+ alignItems: 'center',
144
+ color: '$neutrals800',
145
+ justifyContent: 'flex-end',
146
+ },
147
+ '.status': {
148
+ fontWeight: 'bold',
149
+ textTransform: 'uppercase',
150
+ },
151
+ '.status.failed': {
152
+ color: '$error',
153
+ },
154
+ '.status.success': {
155
+ color: '$success',
156
+ },
74
157
  });
75
158
 
76
- const RequestId = styled(Typography, {
77
- color: '$warning500',
159
+ const RequestId = styled('div', {
160
+ width: '150px',
161
+ whiteSpace: 'nowrap',
162
+ overflow: 'hidden',
163
+ textOverflow: 'ellipsis',
164
+ '@md': {
165
+ width: 'auto',
166
+ },
78
167
  });
79
168
 
80
- const CancelButtonContainer = styled('div', {
81
- display: 'flex',
82
- justifyContent: 'center',
83
- alignItems: 'center',
169
+ const ExtraDetails = styled('div', {
170
+ padding: '0',
171
+ color: '$neutrals600',
172
+ fontSize: '$10',
84
173
  });
85
174
 
86
- const StepContainer = styled('div', {
87
- variants: {
88
- hasNotStarted: {
89
- true: {
90
- filter: 'grayscale(100%)',
91
- },
92
- },
93
- isRunning: {
94
- true: {
95
- animation: `${pulse} 2s ease-in-out infinite`,
96
- },
97
- },
98
- },
175
+ const SwapFlowContainer = styled('div', {
176
+ overflowY: 'auto',
177
+ padding: '$8 $4 $2 $4',
99
178
  });
100
179
 
101
- export interface PropTypes {
180
+ export type PropTypes = {
102
181
  pendingSwap: PendingSwap;
103
182
  onCopy: (requestId: string) => void;
104
183
  onBack: () => void;
105
184
  isCopied: boolean;
106
185
  onCancel: (requestId: string) => void;
107
- }
186
+ onRetry?: () => void;
187
+ date: string;
188
+ previewInputs?: React.ReactNode;
189
+ } & SwapMessagesPropTypes;
108
190
 
109
191
  export function SwapHistory(props: PropTypes) {
110
- const { pendingSwap, onBack, onCopy, isCopied, onCancel } = props;
192
+ const {
193
+ pendingSwap,
194
+ onBack,
195
+ onCopy,
196
+ isCopied,
197
+ onCancel,
198
+ date,
199
+ onRetry,
200
+ previewInputs,
201
+ ...extraMessageProps
202
+ } = props;
111
203
  const [showDrawer, setShowDrawer] = useState(false);
112
204
 
113
205
  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} />
206
+ <SecondaryPage
207
+ title="Swap Details"
208
+ textField={false}
209
+ onBack={onBack}
210
+ Footer={
211
+ <>
212
+ {pendingSwap?.status === 'running' && (
213
+ <Button
214
+ variant="outlined"
215
+ fullWidth
216
+ type="error"
217
+ onClick={setShowDrawer.bind(null, true)}
218
+ >
219
+ Cancel
220
+ </Button>
221
+ )}
222
+ {!!onRetry && (
223
+ <Button
224
+ variant="contained"
225
+ fullWidth
226
+ type="primary"
227
+ onClick={onRetry}
228
+ >
229
+ Try again
230
+ </Button>
231
+ )}
232
+ </>
233
+ }
234
+ >
235
+ <div>
236
+ <SwapInfoContainer>
237
+ <Row>
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>
250
+ </div>
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>
259
+ </div>
260
+ </Row>
261
+ </SwapInfoContainer>
262
+ {/* TODO: It was temporarily removed to find a better solution.
263
+
264
+ <Divider size={16} />*/}
265
+ </div>
266
+ <SwapFlowContainer>
267
+ {/*{previewInputs} */}
268
+
269
+ {extraMessageProps.shortMessage && (
270
+ <SwapMessages {...extraMessageProps} />
271
+ )}
272
+
273
+ <Divider size={16} />
274
+
275
+ {pendingSwap?.steps.map((step, index) => (
276
+ <div key={index}>
277
+ {index === 0 && (
278
+ <RelativeContainer>
279
+ <StepDetail
280
+ logo={step.fromLogo}
281
+ symbol={step.fromSymbol}
282
+ chainLogo={step.fromBlockchainLogo || ''}
283
+ blockchain={step.fromBlockchain}
284
+ amount={pendingSwap.inputAmount}
285
+ />
286
+ <Dot />
287
+ </RelativeContainer>
127
288
  )}
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
- }
289
+ <Line />
290
+ <SwapperContainer
291
+ created={step.status === 'created'}
292
+ running={!['created', 'success', 'failed'].includes(step.status)}
140
293
  >
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>
152
- )}
153
- <Line />
154
- <SwapperContainer>
155
- <SwapperLogo src={step.swapperLogo} alt={step.swapperId} />
156
- <div>
157
- <Typography ml={4} variant="caption">
158
- {step.swapperType} from {step.fromSymbol} to {step.toSymbol}
159
- via {step.swapperId}
294
+ <Image
295
+ src={step.swapperLogo || ''}
296
+ alt={step.swapperId}
297
+ size={20}
298
+ />
299
+
300
+ <FeeContainer>
301
+ <Typography variant="caption">
302
+ {step.swapperType === 'DEX' ? 'Swap' : 'Bridge'} via{' '}
303
+ {step.swapperId}
304
+ </Typography>
305
+ <Fee>
306
+ <GasIcon />
307
+ <Typography variant="caption">
308
+ &nbsp; ${step.feeInUsd} estimated gas fee
160
309
  </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 />
310
+ </Fee>
311
+ </FeeContainer>
312
+ </SwapperContainer>
313
+ <div
314
+ style={{
315
+ display: 'flex',
316
+ }}
317
+ >
318
+ <InternalDetailsContainer>
319
+ <Line />
320
+ <div className="details">
176
321
  {!!step.explorerUrl && (
177
322
  <div>
178
323
  {step.explorerUrl.map((item, index) => (
179
324
  <InternalDetail key={index}>
180
325
  <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
- )}
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>
193
346
  </Description>
194
347
  </DescriptionContainer>
195
- <StyledAnchor
196
- href={item.url}
197
- target="_blank"
198
- rel="noreferrer"
199
- key={index}
200
- >
201
- TX-Link
202
- </StyledAnchor>
203
348
  </InternalDetail>
204
349
  ))}
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
350
  </div>
214
351
  )}
215
- </InternalDetailsContainer>
216
- </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>
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>
363
+ </InternalDetailsContainer>
364
+ </div>
365
+ {index + 1 === pendingSwap.steps.length && <ArrowDown />}
366
+ <StepDetail
367
+ logo={step.toLogo}
368
+ symbol={step.toSymbol}
369
+ chainLogo={step.toBlockchainLogo || ''}
370
+ blockchain={step.toBlockchain}
371
+ amount={step.outputAmount || ''}
372
+ estimatedAmount={step.expectedOutputAmountHumanReadable || ''}
373
+ success={step.status === 'success'}
374
+ />
375
+ </div>
376
+ ))}
377
+
378
+ <Divider size={32} />
379
+ </SwapFlowContainer>
240
380
  <Drawer
241
381
  onClose={setShowDrawer.bind(null, false)}
242
382
  open={showDrawer}
@@ -244,24 +384,13 @@ export function SwapHistory(props: PropTypes) {
244
384
  anchor="bottom"
245
385
  title="Cancel Progress"
246
386
  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
- </>
387
+ <Alert type="warning">
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>
393
+ </Alert>
265
394
  }
266
395
  footer={
267
396
  <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="body3">
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="body3">
90
+ Don't worry, your fund is&nbsp;
91
+ </Typography>
92
+ <SuccessText variant="body3">
93
+ <b>Safe</b>
94
+ </SuccessText>
95
+ </p>
96
+
97
+ <p>
98
+ <Typography variant="body3">
99
+ It is converted to &nbsp;
100
+ <u>{lastConvertedTokenInFailedSwap.outputAmount}</u>
101
+ &nbsp;
102
+ </Typography>
103
+ <SuccessText variant="body3">
104
+ <b>{lastConvertedTokenInFailedSwap.symbol}&nbsp;</b>
105
+ </SuccessText>
106
+ <Typography variant="body3">on your&nbsp;</Typography>
107
+ <SuccessText variant="body3">
108
+ <b>{lastConvertedTokenInFailedSwap.blockchain}&nbsp;</b>
109
+ </SuccessText>
110
+ <Typography variant="body3">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