@rango-dev/widget-embedded 0.20.1-next.12 → 0.20.1-next.13
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/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +318 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +12 -12
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +43 -3
- package/src/components/SwapDetails/SwapDetails.styles.ts +13 -0
- package/src/components/SwapDetails/SwapDetails.tsx +10 -0
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.tsx +13 -7
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +2 -0
- package/src/constants/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.20.1-next.
|
|
3
|
+
"version": "0.20.1-next.13",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@rango-dev/queue-manager-core": "^0.25.0",
|
|
26
26
|
"@rango-dev/queue-manager-rango-preset": "^0.25.1-next.1",
|
|
27
27
|
"@rango-dev/queue-manager-react": "^0.24.0",
|
|
28
|
-
"@rango-dev/ui": "^0.26.1-next.
|
|
28
|
+
"@rango-dev/ui": "^0.26.1-next.7",
|
|
29
29
|
"@rango-dev/wallets-react": "^0.11.1-next.1",
|
|
30
30
|
"@rango-dev/wallets-shared": "^0.25.1-next.1",
|
|
31
31
|
"bignumber.js": "^9.1.1",
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import type { SwapDetailsPlaceholderPropTypes } from './SwapDetails.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
-
import {
|
|
5
|
-
CopyIcon,
|
|
6
|
-
IconButton,
|
|
7
|
-
NotFound,
|
|
8
|
-
Skeleton,
|
|
9
|
-
Typography,
|
|
10
|
-
} from '@rango-dev/ui';
|
|
4
|
+
import { Divider, NotFound, Skeleton, Typography } from '@rango-dev/ui';
|
|
11
5
|
import React from 'react';
|
|
12
6
|
|
|
13
7
|
import { SuffixContainer } from '../HeaderButtons/HeaderButtons.styles';
|
|
@@ -16,6 +10,7 @@ import { LoadingSwapDetails } from '../LoadingSwapDetails';
|
|
|
16
10
|
|
|
17
11
|
import {
|
|
18
12
|
Container,
|
|
13
|
+
datePlaceholderStyles,
|
|
19
14
|
HeaderDetails,
|
|
20
15
|
PlaceholderContainer,
|
|
21
16
|
requestIdStyles,
|
|
@@ -42,14 +37,19 @@ export function SwapDetailsPlaceholder(props: SwapDetailsPlaceholderPropTypes) {
|
|
|
42
37
|
<Typography variant="label" size="small" color="neutral700">
|
|
43
38
|
<Skeleton width={60} height={10} variant="rounded" />
|
|
44
39
|
</Typography>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
<Divider direction="horizontal" size={4} />
|
|
41
|
+
<Skeleton width={16} height={16} variant="rectangular" />
|
|
42
|
+
<Divider direction="horizontal" size={4} />
|
|
43
|
+
<Skeleton width={16} height={16} variant="rectangular" />
|
|
48
44
|
</div>
|
|
49
45
|
</div>
|
|
50
46
|
<div className={rowStyles()}>
|
|
51
|
-
<Typography
|
|
52
|
-
{
|
|
47
|
+
<Typography
|
|
48
|
+
className={datePlaceholderStyles()}
|
|
49
|
+
variant="label"
|
|
50
|
+
size="large"
|
|
51
|
+
color="neutral700">
|
|
52
|
+
<Skeleton width={60} height={10} variant="rounded" />
|
|
53
53
|
</Typography>
|
|
54
54
|
<Typography variant="label" size="small" color="neutral700">
|
|
55
55
|
<Skeleton width={60} height={10} variant="rounded" />
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
9
9
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
10
10
|
} from '../../constants/routing';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getBlockchainShortNameFor,
|
|
13
|
+
getSwapperDisplayName,
|
|
14
|
+
} from '../../utils/meta';
|
|
12
15
|
import { numberToString } from '../../utils/numbers';
|
|
13
16
|
import { isNetworkStatusInWarningState } from '../../utils/swap';
|
|
14
17
|
import { SwapDetailsAlerts } from '../SwapDetailsAlerts';
|
|
@@ -16,7 +19,12 @@ import { SwapDetailsAlerts } from '../SwapDetailsAlerts';
|
|
|
16
19
|
export const RESET_INTERVAL = 2_000;
|
|
17
20
|
export const SECONDS = 60;
|
|
18
21
|
|
|
19
|
-
export const getSteps = ({
|
|
22
|
+
export const getSteps = ({
|
|
23
|
+
swap,
|
|
24
|
+
blockchains,
|
|
25
|
+
swappers,
|
|
26
|
+
...args
|
|
27
|
+
}: GetStep): Step[] => {
|
|
20
28
|
const hasAlreadyProceededToSign = swap.hasAlreadyProceededToSign !== false;
|
|
21
29
|
return swap.steps.map((step, index) => {
|
|
22
30
|
const amountToConvert =
|
|
@@ -58,7 +66,39 @@ export const getSteps = ({ swap, blockchains, ...args }: GetStep): Step[] => {
|
|
|
58
66
|
step.outputAmount || step.expectedOutputAmountHumanReadable,
|
|
59
67
|
},
|
|
60
68
|
},
|
|
61
|
-
swapper: {
|
|
69
|
+
swapper: {
|
|
70
|
+
displayName: getSwapperDisplayName(step.swapperId, swappers),
|
|
71
|
+
image: step.swapperLogo ?? '',
|
|
72
|
+
type: step.swapperType,
|
|
73
|
+
},
|
|
74
|
+
internalSwaps: step.internalSwaps
|
|
75
|
+
? step.internalSwaps.map((internalSwap) => {
|
|
76
|
+
return {
|
|
77
|
+
from: {
|
|
78
|
+
blockchain:
|
|
79
|
+
getBlockchainShortNameFor(
|
|
80
|
+
internalSwap.fromBlockchain,
|
|
81
|
+
blockchains
|
|
82
|
+
) ?? '',
|
|
83
|
+
},
|
|
84
|
+
to: {
|
|
85
|
+
blockchain:
|
|
86
|
+
getBlockchainShortNameFor(
|
|
87
|
+
internalSwap.toBlockchain,
|
|
88
|
+
blockchains
|
|
89
|
+
) ?? '',
|
|
90
|
+
},
|
|
91
|
+
swapper: {
|
|
92
|
+
displayName: getSwapperDisplayName(
|
|
93
|
+
internalSwap.swapperId,
|
|
94
|
+
swappers
|
|
95
|
+
),
|
|
96
|
+
image: internalSwap.swapperLogo ?? '',
|
|
97
|
+
type: internalSwap.swapperType,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
})
|
|
101
|
+
: [],
|
|
62
102
|
alerts: (
|
|
63
103
|
<SwapDetailsAlerts
|
|
64
104
|
step={step}
|
|
@@ -54,6 +54,10 @@ export const rowStyles = css({
|
|
|
54
54
|
color: '$neutral500',
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
+
export const datePlaceholderStyles = css({
|
|
58
|
+
padding: '$5 0',
|
|
59
|
+
});
|
|
60
|
+
|
|
57
61
|
export const requestIdStyles = css({
|
|
58
62
|
display: 'flex',
|
|
59
63
|
justifyContent: 'center',
|
|
@@ -73,3 +77,12 @@ export const titleStepsStyles = css({
|
|
|
73
77
|
width: '100%',
|
|
74
78
|
padding: '0 $20 $10',
|
|
75
79
|
});
|
|
80
|
+
|
|
81
|
+
export const StyledLink = styled('a', {
|
|
82
|
+
fontSize: '$16',
|
|
83
|
+
fontWeight: '$400',
|
|
84
|
+
color: '$neutral700',
|
|
85
|
+
display: 'flex',
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
justifyContent: 'center',
|
|
88
|
+
});
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
CopyIcon,
|
|
13
13
|
Divider,
|
|
14
14
|
IconButton,
|
|
15
|
+
LinkIcon,
|
|
15
16
|
QuoteCost,
|
|
16
17
|
StepDetails,
|
|
17
18
|
Typography,
|
|
@@ -23,6 +24,7 @@ import { PendingSwapNetworkStatus } from 'rango-types';
|
|
|
23
24
|
import React, { useEffect, useRef, useState } from 'react';
|
|
24
25
|
import { useNavigate } from 'react-router-dom';
|
|
25
26
|
|
|
27
|
+
import { SCANNER_BASE_URL } from '../../constants';
|
|
26
28
|
import {
|
|
27
29
|
GAS_FEE_MAX_DECIMALS,
|
|
28
30
|
GAS_FEE_MIN_DECIMALS,
|
|
@@ -67,6 +69,7 @@ import {
|
|
|
67
69
|
requestIdStyles,
|
|
68
70
|
rowStyles,
|
|
69
71
|
StepsList,
|
|
72
|
+
StyledLink,
|
|
70
73
|
titleStepsStyles,
|
|
71
74
|
} from './SwapDetails.styles';
|
|
72
75
|
|
|
@@ -74,6 +77,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
74
77
|
const { swap, requestId, onDelete, onCancel: onCancelProps } = props;
|
|
75
78
|
const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
|
|
76
79
|
const blockchains = useAppStore().blockchains();
|
|
80
|
+
const swappers = useAppStore().swappers();
|
|
77
81
|
const tokens = useAppStore().tokens();
|
|
78
82
|
const retry = useQuoteStore.use.retry();
|
|
79
83
|
const navigate = useNavigate();
|
|
@@ -158,6 +162,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
158
162
|
setNetworkModal: setModalState,
|
|
159
163
|
message: stepMessage,
|
|
160
164
|
blockchains: blockchains,
|
|
165
|
+
swappers: swappers,
|
|
161
166
|
});
|
|
162
167
|
const numberOfSteps = steps.length;
|
|
163
168
|
const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
|
|
@@ -289,6 +294,11 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
289
294
|
onClick={handleCopy.bind(null, requestId || '')}>
|
|
290
295
|
<CopyIcon size={16} color="gray" />
|
|
291
296
|
</IconButton>
|
|
297
|
+
<StyledLink
|
|
298
|
+
target="_blank"
|
|
299
|
+
href={`${SCANNER_BASE_URL}/swap/${requestId}`}>
|
|
300
|
+
<LinkIcon size={16} />
|
|
301
|
+
</StyledLink>
|
|
292
302
|
</div>
|
|
293
303
|
</div>
|
|
294
304
|
<div className={rowStyles()}>
|
|
@@ -24,18 +24,27 @@ export function SwapDetailsAlerts(props: SwapAlertsProps) {
|
|
|
24
24
|
const waitingForApproval =
|
|
25
25
|
step.status === 'waitingForApproval' && !hasWarning;
|
|
26
26
|
const inProgress = step.status === 'running' && !hasWarning;
|
|
27
|
+
const waitingProgress =
|
|
28
|
+
(inProgress && !hasAlreadyProceededToSign) ||
|
|
29
|
+
(waitingForApproval && !step.explorerUrl?.length);
|
|
30
|
+
|
|
27
31
|
return (
|
|
28
32
|
<Alerts>
|
|
29
33
|
{step.explorerUrl?.map((explorerUrl, index, urls) => {
|
|
30
34
|
const key = index + explorerUrl.url;
|
|
31
35
|
const lastUrl = index === urls.length - 1;
|
|
32
|
-
const loading =
|
|
36
|
+
const loading =
|
|
37
|
+
((lastUrl && inProgress) || waitingForApproval) && !waitingProgress;
|
|
33
38
|
const error = lastUrl && step.status === 'failed';
|
|
34
39
|
|
|
35
40
|
return (
|
|
36
41
|
<Fragment key={key}>
|
|
37
42
|
<Alert
|
|
38
|
-
type={
|
|
43
|
+
type={
|
|
44
|
+
lastUrl
|
|
45
|
+
? (loading && 'loading') || (error && 'error') || 'success'
|
|
46
|
+
: 'success'
|
|
47
|
+
}
|
|
39
48
|
title={
|
|
40
49
|
!explorerUrl.description
|
|
41
50
|
? i18n.t('View transaction')
|
|
@@ -47,7 +56,7 @@ export function SwapDetailsAlerts(props: SwapAlertsProps) {
|
|
|
47
56
|
variant="ghost"
|
|
48
57
|
size="xsmall"
|
|
49
58
|
onClick={() => window.open(explorerUrl.url, '_blank')}>
|
|
50
|
-
<LinkIcon size={
|
|
59
|
+
<LinkIcon size={12} />
|
|
51
60
|
</IconButton>
|
|
52
61
|
)
|
|
53
62
|
}
|
|
@@ -55,10 +64,7 @@ export function SwapDetailsAlerts(props: SwapAlertsProps) {
|
|
|
55
64
|
</Fragment>
|
|
56
65
|
);
|
|
57
66
|
})}
|
|
58
|
-
{
|
|
59
|
-
(waitingForApproval && !step.explorerUrl?.length)) && (
|
|
60
|
-
<Alert type="loading" title={message.shortMessage} />
|
|
61
|
-
)}
|
|
67
|
+
{waitingProgress && <Alert type="loading" title={message.shortMessage} />}
|
|
62
68
|
{step.status !== 'failed' && hasWarning && (
|
|
63
69
|
<WarningAlert
|
|
64
70
|
switchNetwork={switchNetwork}
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
PendingSwap,
|
|
7
7
|
PendingSwapNetworkStatus,
|
|
8
8
|
PendingSwapStep,
|
|
9
|
+
SwapperMeta,
|
|
9
10
|
} from 'rango-types';
|
|
10
11
|
|
|
11
12
|
export interface SwapAlertsProps extends WaningAlertsProps {
|
|
@@ -26,4 +27,5 @@ export interface FailedAlertsProps {
|
|
|
26
27
|
export type GetStep = {
|
|
27
28
|
swap: PendingSwap;
|
|
28
29
|
blockchains: BlockchainMeta[];
|
|
30
|
+
swappers: SwapperMeta[];
|
|
29
31
|
} & Omit<SwapAlertsProps, 'step' | 'hasAlreadyProceededToSign'>;
|
package/src/constants/index.ts
CHANGED