@rango-dev/widget-embedded 0.28.3-next.3 → 0.28.3-next.5
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/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +2 -2
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +1 -8
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +92 -32
- package/src/components/SwapDetails/SwapDetails.tsx +8 -2
- package/src/containers/WidgetProvider/WidgetProvider.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.28.3-next.
|
|
3
|
+
"version": "0.28.3-next.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@rango-dev/queue-manager-rango-preset": "^0.33.3-next.0",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
32
32
|
"@rango-dev/signer-solana": "^0.28.1-next.2",
|
|
33
|
-
"@rango-dev/ui": "^0.34.1-next.
|
|
33
|
+
"@rango-dev/ui": "^0.34.1-next.4",
|
|
34
34
|
"@rango-dev/wallets-react": "^0.19.1-next.1",
|
|
35
35
|
"@rango-dev/wallets-shared": "^0.33.1-next.1",
|
|
36
36
|
"bignumber.js": "^9.1.1",
|
|
@@ -118,7 +118,7 @@ export const ConfirmButton = styled('div', {
|
|
|
118
118
|
|
|
119
119
|
export const StyledTextField = styled(TextField, {
|
|
120
120
|
backgroundColor: '$neutral100',
|
|
121
|
-
padding: '$
|
|
121
|
+
padding: '$15',
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
export const Wallets = styled('div', { overflow: 'visible', width: '100%' });
|
|
@@ -137,13 +137,6 @@ export const CustomDestinationButton = styled('div', {
|
|
|
137
137
|
backgroundColor: '$$color',
|
|
138
138
|
borderBottomRightRadius: '0',
|
|
139
139
|
borderBottomLeftRadius: '0',
|
|
140
|
-
'&:hover': {
|
|
141
|
-
$$color: '$colors$secondary100',
|
|
142
|
-
[`.${darkTheme} &`]: {
|
|
143
|
-
$$color: '$colors$neutral100',
|
|
144
|
-
},
|
|
145
|
-
backgroundColor: '$$color',
|
|
146
|
-
},
|
|
147
140
|
'&:focus-visible': {
|
|
148
141
|
$$background: '$colors$secondary100',
|
|
149
142
|
[`.${darkTheme} &`]: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PropTypes } from './ConfirmWalletsModal.types';
|
|
2
2
|
import type { ConnectedWallet } from '../../store/wallets';
|
|
3
3
|
import type { ConfirmSwapWarnings, Wallet } from '../../types';
|
|
4
|
+
import type { MouseEvent } from 'react';
|
|
4
5
|
|
|
5
6
|
import { i18n } from '@lingui/core';
|
|
6
7
|
import {
|
|
@@ -9,12 +10,15 @@ import {
|
|
|
9
10
|
Button,
|
|
10
11
|
ChevronDownIcon,
|
|
11
12
|
ChevronLeftIcon,
|
|
13
|
+
CloseIcon,
|
|
12
14
|
Divider,
|
|
15
|
+
IconButton,
|
|
13
16
|
MessageBox,
|
|
17
|
+
PasteIcon,
|
|
14
18
|
Typography,
|
|
15
19
|
WalletIcon,
|
|
16
20
|
} from '@rango-dev/ui';
|
|
17
|
-
import React, { useEffect, useState } from 'react';
|
|
21
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
18
22
|
import { useNavigate } from 'react-router-dom';
|
|
19
23
|
|
|
20
24
|
import { WIDGET_UI_ID } from '../../constants';
|
|
@@ -23,7 +27,10 @@ import { getQuoteUpdateWarningMessage } from '../../constants/warnings';
|
|
|
23
27
|
import { useAppStore } from '../../store/AppStore';
|
|
24
28
|
import { useQuoteStore } from '../../store/quote';
|
|
25
29
|
import { useWalletsStore } from '../../store/wallets';
|
|
26
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
getBlockchainDisplayNameFor,
|
|
32
|
+
getBlockchainShortNameFor,
|
|
33
|
+
} from '../../utils/meta';
|
|
27
34
|
import { isConfirmSwapDisabled } from '../../utils/swap';
|
|
28
35
|
import { getQuoteWallets } from '../../utils/wallets';
|
|
29
36
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
@@ -54,6 +61,8 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
54
61
|
const { open, onClose, onCancel, onCheckBalance, loading } = props;
|
|
55
62
|
const config = useAppStore().config;
|
|
56
63
|
|
|
64
|
+
const customDestinationInputRef = useRef<HTMLInputElement | null>(null);
|
|
65
|
+
|
|
57
66
|
const blockchains = useAppStore().blockchains();
|
|
58
67
|
const {
|
|
59
68
|
selectedQuote,
|
|
@@ -75,6 +84,8 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
75
84
|
!!customDestination
|
|
76
85
|
);
|
|
77
86
|
|
|
87
|
+
const isFirefox = navigator?.userAgent.includes('Firefox');
|
|
88
|
+
|
|
78
89
|
const quoteWallets = getQuoteWallets({
|
|
79
90
|
filter: 'all',
|
|
80
91
|
quote: selectedQuote,
|
|
@@ -143,6 +154,39 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
143
154
|
});
|
|
144
155
|
};
|
|
145
156
|
|
|
157
|
+
const handleClearCustomDestination = () => setCustomDestination('');
|
|
158
|
+
|
|
159
|
+
const handlePasteCustomDestination = async (
|
|
160
|
+
event: MouseEvent<HTMLButtonElement>
|
|
161
|
+
) => {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
if (navigator.clipboard !== undefined) {
|
|
164
|
+
const pastedText = await navigator.clipboard.readText();
|
|
165
|
+
setCustomDestination(pastedText);
|
|
166
|
+
customDestinationInputRef?.current?.focus();
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const handleCustomDestinationCollapsibleOpenChange = (checked: boolean) => {
|
|
171
|
+
if (!checked) {
|
|
172
|
+
resetCustomDestination();
|
|
173
|
+
} else {
|
|
174
|
+
if (!isWalletRequiredFor(lastStepToBlockchain?.name ?? '')) {
|
|
175
|
+
setSelectableWallets((selectableWallets) =>
|
|
176
|
+
selectableWallets.map((selectableWallet) => {
|
|
177
|
+
if (selectableWallet.chain === lastStepToBlockchain?.name) {
|
|
178
|
+
return {
|
|
179
|
+
...selectableWallet,
|
|
180
|
+
selected: false,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return selectableWallet;
|
|
184
|
+
})
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
146
190
|
const onChange = (wallet: Wallet) => {
|
|
147
191
|
if (showMoreWalletFor) {
|
|
148
192
|
setShowMoreWalletFor('');
|
|
@@ -210,6 +254,24 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
210
254
|
}
|
|
211
255
|
};
|
|
212
256
|
|
|
257
|
+
const renderCustomDestinationSuffix = () => {
|
|
258
|
+
if (customDestination) {
|
|
259
|
+
return (
|
|
260
|
+
<IconButton onClick={handleClearCustomDestination} variant="ghost">
|
|
261
|
+
<CloseIcon size={12} color="gray" />
|
|
262
|
+
</IconButton>
|
|
263
|
+
);
|
|
264
|
+
} else if (!isFirefox) {
|
|
265
|
+
return (
|
|
266
|
+
<IconButton onClick={handlePasteCustomDestination} variant="ghost">
|
|
267
|
+
<PasteIcon size={16} />
|
|
268
|
+
</IconButton>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return null;
|
|
273
|
+
};
|
|
274
|
+
|
|
213
275
|
useEffect(() => {
|
|
214
276
|
setSelectableWallets((selectableWallets) =>
|
|
215
277
|
selectableWallets.concat(
|
|
@@ -386,32 +448,9 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
386
448
|
{isLastWallet && config?.customDestination && (
|
|
387
449
|
<CustomDestination>
|
|
388
450
|
<CustomCollapsible
|
|
389
|
-
onOpenChange={
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
} else {
|
|
393
|
-
if (
|
|
394
|
-
!isWalletRequiredFor(
|
|
395
|
-
lastStepToBlockchain?.name ?? ''
|
|
396
|
-
)
|
|
397
|
-
) {
|
|
398
|
-
setSelectableWallets((selectableWallets) =>
|
|
399
|
-
selectableWallets.map((selectableWallet) => {
|
|
400
|
-
if (
|
|
401
|
-
selectableWallet.chain ===
|
|
402
|
-
lastStepToBlockchain?.name
|
|
403
|
-
) {
|
|
404
|
-
return {
|
|
405
|
-
...selectableWallet,
|
|
406
|
-
selected: false,
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
return selectableWallet;
|
|
410
|
-
})
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}}
|
|
451
|
+
onOpenChange={
|
|
452
|
+
handleCustomDestinationCollapsibleOpenChange
|
|
453
|
+
}
|
|
415
454
|
hasSelected
|
|
416
455
|
open={showCustomDestination}
|
|
417
456
|
triggerAnchor="top"
|
|
@@ -420,7 +459,14 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
420
459
|
<div className="button__content">
|
|
421
460
|
<WalletIcon size={18} color="info" />
|
|
422
461
|
<Divider size={4} direction="horizontal" />
|
|
423
|
-
<Typography
|
|
462
|
+
<Typography
|
|
463
|
+
variant="label"
|
|
464
|
+
size="medium"
|
|
465
|
+
color={
|
|
466
|
+
showCustomDestination
|
|
467
|
+
? '$neutral600'
|
|
468
|
+
: undefined
|
|
469
|
+
}>
|
|
424
470
|
{i18n.t('Send to a different address')}
|
|
425
471
|
</Typography>
|
|
426
472
|
</div>
|
|
@@ -428,17 +474,31 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
428
474
|
orientation={
|
|
429
475
|
showCustomDestination ? 'up' : 'down'
|
|
430
476
|
}>
|
|
431
|
-
<ChevronDownIcon size={10} color="
|
|
477
|
+
<ChevronDownIcon size={10} color="secondary" />
|
|
432
478
|
</ExpandedIcon>
|
|
433
479
|
</CustomDestinationButton>
|
|
434
480
|
}
|
|
435
481
|
onClickTrigger={() =>
|
|
436
482
|
setShowCustomDestination((prev) => !prev)
|
|
437
483
|
}>
|
|
438
|
-
<Divider size={4} />
|
|
439
484
|
<StyledTextField
|
|
440
|
-
|
|
485
|
+
ref={customDestinationInputRef}
|
|
486
|
+
style={{
|
|
487
|
+
padding: 0,
|
|
488
|
+
paddingRight: customDestination ? '8px' : '5px',
|
|
489
|
+
}}
|
|
490
|
+
autoFocus
|
|
491
|
+
placeholder={i18n.t(
|
|
492
|
+
'Enter {blockchainName} address',
|
|
493
|
+
{
|
|
494
|
+
blockchainName: getBlockchainDisplayNameFor(
|
|
495
|
+
requiredWallet,
|
|
496
|
+
blockchains
|
|
497
|
+
),
|
|
498
|
+
}
|
|
499
|
+
)}
|
|
441
500
|
value={customDestination || ''}
|
|
501
|
+
suffix={renderCustomDestinationSuffix()}
|
|
442
502
|
onChange={(e) => {
|
|
443
503
|
const value = e.target.value;
|
|
444
504
|
if (!value.length) {
|
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
CopyIcon,
|
|
13
13
|
Divider,
|
|
14
14
|
IconButton,
|
|
15
|
-
LinkIcon,
|
|
16
15
|
QuoteCost,
|
|
16
|
+
RangoExplorerIcon,
|
|
17
17
|
StepDetails,
|
|
18
|
+
Tooltip,
|
|
18
19
|
Typography,
|
|
19
20
|
useCopyToClipboard,
|
|
20
21
|
} from '@rango-dev/ui';
|
|
@@ -321,7 +322,12 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
321
322
|
<StyledLink
|
|
322
323
|
target="_blank"
|
|
323
324
|
href={`${SCANNER_BASE_URL}/swap/${requestId}`}>
|
|
324
|
-
<
|
|
325
|
+
<Tooltip
|
|
326
|
+
container={getContainer()}
|
|
327
|
+
content={i18n.t('View on Rango Explorer')}
|
|
328
|
+
side="bottom">
|
|
329
|
+
<RangoExplorerIcon size={20} />
|
|
330
|
+
</Tooltip>
|
|
325
331
|
</StyledLink>
|
|
326
332
|
</div>
|
|
327
333
|
</div>
|
|
@@ -2,7 +2,7 @@ import type { PropTypes } from './WidgetProvider.types';
|
|
|
2
2
|
import type { PropsWithChildren } from 'react';
|
|
3
3
|
|
|
4
4
|
import { setSolanaSignerConfig } from '@rango-dev/signer-solana';
|
|
5
|
-
import React, { useEffect } from 'react';
|
|
5
|
+
import React, { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { DEFAULT_BASE_URL, RANGO_PUBLIC_API_KEY } from '../../constants';
|
|
8
8
|
import useFontLoader from '../../hooks/useFontLoader';
|
|
@@ -24,7 +24,7 @@ export function WidgetProvider(props: PropsWithChildren<PropTypes>) {
|
|
|
24
24
|
}
|
|
25
25
|
}, [fontFamily]);
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
useMemo(() => {
|
|
28
28
|
initConfig({
|
|
29
29
|
API_KEY: config?.apiKey || RANGO_PUBLIC_API_KEY,
|
|
30
30
|
BASE_URL: config?.apiUrl || DEFAULT_BASE_URL,
|