@rango-dev/ui 0.1.10-next.92 → 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.
- package/README.md +1 -181
- package/dist/components/Alert/LoadingFailedAlert.d.ts +2 -0
- package/dist/components/Alert/NotFoundAlert.d.ts +7 -0
- package/dist/components/Alert/index.d.ts +1 -0
- package/dist/components/BlockchainSelector/BlockchainSelector.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Divider/Divider.d.ts +6 -0
- package/dist/components/Divider/index.d.ts +1 -0
- package/dist/components/Header/Header.d.ts +9 -0
- package/dist/components/Header/index.d.ts +1 -0
- package/dist/components/Icon/ArrowRightIcon.d.ts +3 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/LiquiditySourceList/LiquiditySourceList.d.ts +3 -1
- package/dist/components/LiquiditySourcesSelector/LiquiditySourcesSelector.d.ts +2 -1
- package/dist/components/SelectableWalletList/mock.d.ts +1 -1
- package/dist/components/Settings/Settings.d.ts +2 -1
- package/dist/components/SwapContainer/SwapContainer.d.ts +1 -0
- package/dist/components/SwapDetail/Token.d.ts +16 -0
- package/dist/components/TokenSelector/TokenSelector.d.ts +3 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/containers/ConfirmSwap/ConfirmSwap.d.ts +10 -17
- package/dist/containers/ConfirmSwap/ConfirmSwap.stories.d.ts +1 -0
- package/dist/containers/ConfirmSwap/mock.d.ts +3 -0
- package/dist/containers/History/History.d.ts +6 -1
- package/dist/containers/History/index.d.ts +1 -1
- package/dist/containers/History/types.d.ts +3 -24
- package/dist/containers/SwapHistory/SwapHistory.d.ts +16 -3
- package/dist/containers/SwapHistory/SwapMessages.d.ts +17 -0
- package/dist/containers/index.d.ts +0 -1
- package/dist/helper/index.d.ts +1 -0
- package/dist/types/meta.d.ts +1 -0
- package/dist/ui.cjs.development.js +1062 -838
- 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 +1061 -840
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/components/Alert/Alert.tsx +33 -12
- package/src/components/Alert/LoadingFailedAlert.tsx +11 -0
- package/src/components/Alert/NotFoundAlert.tsx +19 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/BestRoute/mock.ts +10 -0
- package/src/components/BlockchainSelector/BlockchainSelector.tsx +13 -19
- package/src/components/Button/Button.tsx +2 -1
- package/src/components/ConnectWalletsModal/mockData.ts +16 -0
- package/src/components/Divider/Divider.tsx +41 -0
- package/src/components/Divider/index.ts +1 -0
- package/src/components/Header/Header.tsx +39 -0
- package/src/components/Header/index.ts +1 -0
- package/src/components/Icon/ArrowRightIcon.tsx +31 -0
- package/src/components/Icon/index.ts +1 -0
- package/src/components/LiquiditySourceList/LiquiditySourceList.tsx +72 -22
- package/src/components/LiquiditySourcesSelector/LiquiditySourcesSelector.tsx +15 -10
- package/src/components/SecondaryPage/SecondaryPage.tsx +26 -52
- package/src/components/SelectableWalletList/SelectableWalletList.tsx +5 -0
- package/src/components/SelectableWalletList/mock.ts +4 -3
- package/src/components/Settings/Settings.tsx +30 -11
- package/src/components/StatusDrawer/StatusDrawer.tsx +1 -0
- package/src/components/StepDetail/StepDetail.tsx +1 -0
- package/src/components/SwapContainer/SwapContainer.tsx +21 -16
- package/src/components/SwapDetail/SwapDetail.tsx +77 -115
- package/src/components/SwapDetail/Token.tsx +68 -0
- package/src/components/SwapDetail/mock.ts +1 -0
- package/src/components/TextField/TextField.tsx +1 -0
- package/src/components/TokenList/TokenItem.tsx +4 -1
- package/src/components/TokenList/TokenList.tsx +16 -18
- package/src/components/TokenSelector/TokenSelector.tsx +47 -10
- package/src/components/Wallet/Wallet.tsx +1 -1
- package/src/components/index.ts +2 -0
- package/src/containers/ConfirmSwap/ConfirmSwap.stories.tsx +11 -2
- package/src/containers/ConfirmSwap/ConfirmSwap.tsx +103 -117
- package/src/containers/ConfirmSwap/mock.ts +79 -2
- package/src/containers/History/History.tsx +57 -38
- package/src/containers/History/index.ts +1 -1
- package/src/containers/History/mock.ts +1 -0
- package/src/containers/History/types.tsx +2 -30
- package/src/containers/SwapHistory/SwapHistory.tsx +309 -165
- package/src/containers/SwapHistory/SwapMessages.tsx +116 -0
- package/src/containers/SwapHistory/mock.ts +1 -0
- package/src/containers/index.ts +0 -1
- package/src/helper/index.ts +14 -0
- package/src/types/meta.ts +2 -0
- package/dist/containers/ConfirmWallets/ConfirmWallets.d.ts +0 -16
- package/dist/containers/ConfirmWallets/ConfirmWallets.stories.d.ts +0 -6
- package/dist/containers/ConfirmWallets/index.d.ts +0 -1
- package/dist/containers/ConfirmWallets/mock.d.ts +0 -5
- package/dist/helper/swaps.d.ts +0 -5
- package/src/containers/ConfirmWallets/ConfirmWallets.stories.tsx +0 -26
- package/src/containers/ConfirmWallets/ConfirmWallets.tsx +0 -143
- package/src/containers/ConfirmWallets/index.ts +0 -1
- package/src/containers/ConfirmWallets/mock.ts +0 -222
- 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
|
|
66
|
-
cursor: 'pointer',
|
|
67
|
-
backgroundColor: '$neutrals200',
|
|
68
|
-
padding: '$4',
|
|
121
|
+
const Row = styled('div', {
|
|
69
122
|
display: 'flex',
|
|
70
|
-
justifyContent: '
|
|
123
|
+
justifyContent: 'space-between',
|
|
71
124
|
alignItems: 'center',
|
|
72
|
-
|
|
73
|
-
|
|
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(
|
|
77
|
-
|
|
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
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
159
|
-
|
|
319
|
+
$
|
|
320
|
+
{
|
|
321
|
+
// @ts-ignore
|
|
322
|
+
step.feeInUsd
|
|
323
|
+
}{' '}
|
|
324
|
+
estimated gas fee
|
|
160
325
|
</Typography>
|
|
161
|
-
|
|
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
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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
|
-
<
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
|
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
|
|
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
|
|
100
|
+
<u>{lastConvertedTokenInFailedSwap.outputAmount}</u>
|
|
101
|
+
|
|
102
|
+
</Typography>
|
|
103
|
+
<SuccessText variant="body2">
|
|
104
|
+
<b>{lastConvertedTokenInFailedSwap.symbol} </b>
|
|
105
|
+
</SuccessText>
|
|
106
|
+
<Typography variant="body2">on your </Typography>
|
|
107
|
+
<SuccessText variant="body2">
|
|
108
|
+
<b>{lastConvertedTokenInFailedSwap.blockchain} </b>
|
|
109
|
+
</SuccessText>
|
|
110
|
+
<Typography variant="body2">wallet</Typography>
|
|
111
|
+
</p>
|
|
112
|
+
</>
|
|
113
|
+
)}
|
|
114
|
+
</Alert>
|
|
115
|
+
);
|
|
116
|
+
};
|
package/src/containers/index.ts
CHANGED
package/src/helper/index.ts
CHANGED
|
@@ -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
|
+
};
|