@rango-dev/ui 0.1.10-next.91 → 0.1.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 (116) hide show
  1. package/README.md +1 -181
  2. package/dist/components/Alert/Alert.d.ts +3 -2
  3. package/dist/components/Alert/LoadingFailedAlert.d.ts +2 -0
  4. package/dist/components/Alert/NotFoundAlert.d.ts +7 -0
  5. package/dist/components/Alert/index.d.ts +1 -0
  6. package/dist/components/BlockchainSelector/BlockchainSelector.d.ts +1 -1
  7. package/dist/components/Button/Button.d.ts +3 -3
  8. package/dist/components/Divider/Divider.d.ts +6 -0
  9. package/dist/components/Divider/index.d.ts +1 -0
  10. package/dist/components/Header/Header.d.ts +9 -0
  11. package/dist/components/Header/index.d.ts +1 -0
  12. package/dist/components/Icon/ArrowRightIcon.d.ts +3 -0
  13. package/dist/components/Icon/ChevronRightIcon.d.ts +3 -0
  14. package/dist/components/Icon/DisconnectIcon.d.ts +3 -0
  15. package/dist/components/Icon/index.d.ts +3 -0
  16. package/dist/components/Icon/types.d.ts +1 -1
  17. package/dist/components/LiquiditySourceList/LiquiditySourceList.d.ts +3 -1
  18. package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +2 -1
  19. package/dist/components/SelectableWalletList/mock.d.ts +1 -1
  20. package/dist/components/Settings/Settings.d.ts +2 -1
  21. package/dist/components/Spacer/Spacer.d.ts +1 -1
  22. package/dist/components/SwapContainer/SwapContainer.d.ts +1 -0
  23. package/dist/components/SwapDetail/Token.d.ts +16 -0
  24. package/dist/components/TextField/TextField.stories.d.ts +1 -1
  25. package/dist/components/TokenSelector/TokenSelector.d.ts +3 -0
  26. package/dist/components/Typography/Typography.d.ts +3 -2
  27. package/dist/components/index.d.ts +2 -0
  28. package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +10 -17
  29. package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +1 -0
  30. package/dist/containers/ConfirmSwap/mock.d.ts +3 -0
  31. package/dist/containers/History/History.d.ts +6 -1
  32. package/dist/containers/History/index.d.ts +1 -1
  33. package/dist/containers/History/types.d.ts +3 -24
  34. package/dist/containers/SwapHistory/SwapHistory.d.ts +16 -3
  35. package/dist/containers/SwapHistory/SwapMessages.d.ts +17 -0
  36. package/dist/containers/index.d.ts +0 -1
  37. package/dist/helper/index.d.ts +1 -0
  38. package/dist/types/meta.d.ts +1 -0
  39. package/dist/ui.cjs.development.js +1455 -1033
  40. package/dist/ui.cjs.development.js.map +1 -1
  41. package/dist/ui.cjs.production.min.js +1 -1
  42. package/dist/ui.cjs.production.min.js.map +1 -1
  43. package/dist/ui.esm.js +1463 -1046
  44. package/dist/ui.esm.js.map +1 -1
  45. package/package.json +3 -2
  46. package/src/components/Alert/Alert.tsx +63 -39
  47. package/src/components/Alert/LoadingFailedAlert.tsx +11 -0
  48. package/src/components/Alert/NotFoundAlert.tsx +19 -0
  49. package/src/components/Alert/index.ts +1 -0
  50. package/src/components/BestRoute/BestRoute.tsx +28 -19
  51. package/src/components/BestRoute/mock.ts +10 -0
  52. package/src/components/BlockchainSelector/BlockchainSelector.tsx +13 -21
  53. package/src/components/Button/Button.stories.tsx +1 -1
  54. package/src/components/Button/Button.tsx +36 -23
  55. package/src/components/Chip/Chip.tsx +7 -4
  56. package/src/components/ConnectWalletsModal/mockData.ts +16 -0
  57. package/src/components/Divider/Divider.tsx +41 -0
  58. package/src/components/Divider/index.ts +1 -0
  59. package/src/components/Header/Header.tsx +39 -0
  60. package/src/components/Header/index.ts +1 -0
  61. package/src/components/Icon/ArrowRightIcon.tsx +31 -0
  62. package/src/components/Icon/ChevronRightIcon.tsx +29 -0
  63. package/src/components/Icon/DisconnectIcon.tsx +31 -0
  64. package/src/components/Icon/HistoryIcon.tsx +12 -18
  65. package/src/components/Icon/RetryIcon.tsx +13 -13
  66. package/src/components/Icon/SettingIcon.tsx +6 -14
  67. package/src/components/Icon/index.ts +3 -0
  68. package/src/components/Icon/types.tsx +1 -1
  69. package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +104 -30
  70. package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +16 -11
  71. package/src/components/Radio/Radio.tsx +5 -4
  72. package/src/components/SecondaryPage/SecondaryPage.tsx +26 -52
  73. package/src/components/SelectableWalletList/SelectableWalletList.tsx +5 -1
  74. package/src/components/SelectableWalletList/mock.ts +4 -3
  75. package/src/components/Settings/Settings.tsx +47 -12
  76. package/src/components/Spacer/Spacer.tsx +31 -1
  77. package/src/components/StatusDrawer/StatusDrawer.tsx +1 -0
  78. package/src/components/StepDetail/StepDetail.tsx +19 -7
  79. package/src/components/SwapContainer/SwapContainer.tsx +22 -17
  80. package/src/components/SwapDetail/SwapDetail.tsx +77 -115
  81. package/src/components/SwapDetail/Token.tsx +68 -0
  82. package/src/components/SwapDetail/mock.ts +1 -0
  83. package/src/components/Switch/Switch.tsx +7 -5
  84. package/src/components/TextField/TextField.tsx +3 -1
  85. package/src/components/TokenList/TokenItem.tsx +4 -1
  86. package/src/components/TokenList/TokenList.tsx +16 -18
  87. package/src/components/TokenSelector/TokenSelector.tsx +47 -10
  88. package/src/components/Typography/Typography.stories.tsx +4 -0
  89. package/src/components/Typography/Typography.tsx +20 -9
  90. package/src/components/Wallet/State.tsx +2 -3
  91. package/src/components/Wallet/Wallet.tsx +33 -6
  92. package/src/components/index.ts +2 -0
  93. package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +11 -2
  94. package/src/containers/ConfirmSwap/ConfirmSwap.tsx +103 -119
  95. package/src/containers/ConfirmSwap/mock.ts +79 -2
  96. package/src/containers/History/History.tsx +57 -38
  97. package/src/containers/History/index.ts +1 -1
  98. package/src/containers/History/mock.ts +1 -0
  99. package/src/containers/History/types.tsx +2 -30
  100. package/src/containers/SwapHistory/SwapHistory.tsx +309 -165
  101. package/src/containers/SwapHistory/SwapMessages.tsx +116 -0
  102. package/src/containers/SwapHistory/mock.ts +1 -0
  103. package/src/containers/index.ts +0 -1
  104. package/src/helper/index.ts +14 -0
  105. package/src/theme.ts +4 -2
  106. package/src/types/meta.ts +2 -0
  107. package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +0 -18
  108. package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +0 -6
  109. package/dist/containers/ConfirmWallets/index.d.ts +0 -1
  110. package/dist/containers/ConfirmWallets/mock.d.ts +0 -5
  111. package/dist/helper/swaps.d.ts +0 -5
  112. package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +0 -26
  113. package/src/containers/ConfirmWallets/ConfirmWallets.tsx +0 -118
  114. package/src/containers/ConfirmWallets/index.ts +0 -1
  115. package/src/containers/ConfirmWallets/mock.ts +0 -222
  116. 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,216 @@ 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}
140
231
  >
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>
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)}
245
+ >
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
+ // @ts-ignore
304
+ src={step.swapperLogo}
305
+ alt={step.swapperId}
306
+ />
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}
315
+ </Typography>
316
+ <Fee>
317
+ <GasIcon />
157
318
  <Typography ml={4} variant="caption">
158
- {step.swapperType} from {step.fromSymbol} to {step.toSymbol}
159
- via {step.swapperId}
319
+ $
320
+ {
321
+ // @ts-ignore
322
+ step.feeInUsd
323
+ }{' '}
324
+ estimated gas fee
160
325
  </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>
326
+ </Fee>
216
327
  </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>
328
+ </SwapperContainer>
329
+ <div
330
+ style={{
331
+ display: 'flex',
332
+ }}
333
+ >
334
+ <InternalDetailsContainer>
335
+ <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
+ )}
373
+ </InternalDetailsContainer>
374
+ </div>
375
+ {index + 1 === pendingSwap.steps.length && <ArrowDown />}
376
+ <StepDetail
377
+ logo={step.toLogo}
378
+ symbol={step.toSymbol}
379
+ // @ts-ignore
380
+ chainLogo={step.toBlockchainLogo}
381
+ blockchain={step.toBlockchain}
382
+ amount={step.outputAmount || ''}
383
+ />
384
+ </StepContainer>
385
+ ))}
386
+
387
+ <Divider size={32} />
388
+ </SwapFlowContainer>
240
389
  <Drawer
241
390
  onClose={setShowDrawer.bind(null, false)}
242
391
  open={showDrawer}
@@ -244,24 +393,19 @@ export function SwapHistory(props: PropTypes) {
244
393
  anchor="bottom"
245
394
  title="Cancel Progress"
246
395
  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
- </>
396
+ <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>
408
+ </Alert>
265
409
  }
266
410
  footer={
267
411
  <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
+ };