@rango-dev/widget-embedded 0.22.4-next.9 → 0.23.1-next.0
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/CHANGELOG.md +19 -0
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +0 -162
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.types.d.ts +3 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +2 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.Cancel.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.Delete.d.ts.map +1 -1
- package/dist/constants/quote.d.ts +1 -0
- package/dist/constants/quote.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +2 -4
- package/dist/utils/quote.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/QueueManager.tsx +0 -3
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +8 -3
- package/src/components/Quote/Quote.styles.ts +0 -7
- package/src/components/Quote/Quote.tsx +27 -9
- package/src/components/Quote/Quote.types.ts +3 -0
- package/src/components/Quote/QuoteCostDetails.tsx +8 -29
- package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +3 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +1 -3
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +3 -7
- package/src/components/SwapDetailsModal/SwapDetailsModal.Delete.tsx +1 -3
- package/src/constants/quote.ts +2 -0
- package/src/containers/Wallets/Wallets.tsx +5 -11
- package/src/pages/Home.tsx +2 -4
- package/src/utils/quote.ts +3 -19
package/dist/pages/Home.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAuCnD,wBAAgB,IAAI,
|
|
1
|
+
{"version":3,"file":"Home.d.ts","sourceRoot":"","sources":["../../src/pages/Home.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAuCnD,wBAAgB,IAAI,sBAgQnB"}
|
package/dist/utils/quote.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { QuoteWarning, SelectedQuote, Wallet } from '../types';
|
|
2
|
-
import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
|
|
3
|
-
import type {
|
|
4
|
-
import type { Asset, BlockchainMeta, MultiRouteResponse, MultiRouteSimulationResult, PreferenceType, RouteTag, TagValue, Token } from 'rango-sdk';
|
|
2
|
+
import type { PriceImpactWarningLevel, SimulationAssetAndAmount, SimulationValidationStatus, Step } from '@rango-dev/ui';
|
|
3
|
+
import type { Asset, BlockchainMeta, MultiRouteResponse, MultiRouteSimulationResult, PreferenceType, RouteTag, Token } from 'rango-sdk';
|
|
5
4
|
import type { PendingSwap } from 'rango-types';
|
|
6
5
|
import BigNumber from 'bignumber.js';
|
|
7
6
|
export declare function getQuoteToTokenUsdPrice(quote: SelectedQuote | null): number | null | undefined;
|
|
@@ -34,5 +33,4 @@ export declare const getUniqueBlockchains: (steps: Step[]) => {
|
|
|
34
33
|
export declare const sortQuotesBy: (strategy: PreferenceType, quotes: MultiRouteResponse['results']) => MultiRouteResponse['results'];
|
|
35
34
|
export declare const getDefaultQuote: (currentQuote: SelectedQuote | null, quotes: MultiRouteSimulationResult[], requestAmount: string) => SelectedQuote | null;
|
|
36
35
|
export declare const sortTags: (tags: RouteTag[]) => RouteTag[];
|
|
37
|
-
export declare const getRouteTagColor: (tag: TagValue) => string;
|
|
38
36
|
//# sourceMappingURL=quote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACpE,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC1B,IAAI,EACL,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,cAAc,EACd,QAAQ,EACR,KAAK,EACN,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,SAAS,MAAM,cAAc,CAAC;AAmBrC,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,aAAa,GAAG,IAAI,GAC1B,MAAM,GAAG,IAAI,GAAG,SAAS,CAG3B;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,WAKtB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,WAKtB;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,WAKtB;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,GACpB,OAAO,CAMT;AAED,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,SAAS,GAAG,IAAI,EAC9B,YAAY,EAAE,SAAS,GAAG,CAAC,WAQ5B;AAED,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,0BAA0B,EAAE,GAAG,IAAI,GACvC,wBAAwB,EAAE,GAAG,IAAI,CAcnC;AAED,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,GAClB,uBAAuB,CASzB;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,KAAK,EAAE,EAAE,CAAC,SAAS,KAAK,EAAE,EACnE,KAAK,EAAE,CAAC,EACR,KAAK,EAAE,CAAC,KAUT;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,cAAc,EAAE,EAC7B,MAAM,EAAE,KAAK,EAAE,GACd;IACD,cAAc,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,OAAO,EAAE,KAAK,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CA4CA;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE;IACN,SAAS,EAAE,KAAK,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,GACA,YAAY,GAAG,IAAI,CAiDrB;AAED,wBAAgB,cAAc,CAC5B,aAAa,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,EACxC,cAAc,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,GACxC,MAAM,GAAG,IAAI,CAcf;AAED,eAAO,MAAM,oBAAoB,UAAW,IAAI,EAAE;iBAEnB,MAAM;WAAS,MAAM;GAanD,CAAC;AAEF,eAAO,MAAM,YAAY,aACb,cAAc,UAChB,kBAAkB,CAAC,SAAS,CAAC,KACpC,kBAAkB,CAAC,SAAS,CAkB9B,CAAC;AAEF,eAAO,MAAM,eAAe,iBACZ,aAAa,GAAG,IAAI,UAC1B,0BAA0B,EAAE,iBACrB,MAAM,KACpB,aAAa,GAAG,IAgClB,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,QAAQ,EAAE,KAAG,QAAQ,EAmBnD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.1-next.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@lingui/core": "4.2.1",
|
|
23
23
|
"@lingui/react": "4.2.1",
|
|
24
|
-
"@rango-dev/provider-all": "^0.
|
|
25
|
-
"@rango-dev/queue-manager-core": "^0.
|
|
26
|
-
"@rango-dev/queue-manager-rango-preset": "^0.
|
|
27
|
-
"@rango-dev/queue-manager-react": "^0.
|
|
28
|
-
"@rango-dev/ui": "^0.
|
|
29
|
-
"@rango-dev/wallets-react": "^0.
|
|
30
|
-
"@rango-dev/wallets-shared": "^0.
|
|
24
|
+
"@rango-dev/provider-all": "^0.28.0",
|
|
25
|
+
"@rango-dev/queue-manager-core": "^0.26.0",
|
|
26
|
+
"@rango-dev/queue-manager-rango-preset": "^0.28.0",
|
|
27
|
+
"@rango-dev/queue-manager-react": "^0.26.0",
|
|
28
|
+
"@rango-dev/ui": "^0.29.1-next.0",
|
|
29
|
+
"@rango-dev/wallets-react": "^0.14.0",
|
|
30
|
+
"@rango-dev/wallets-shared": "^0.28.0",
|
|
31
31
|
"bignumber.js": "^9.1.1",
|
|
32
32
|
"copy-to-clipboard": "^3.3.3",
|
|
33
33
|
"dayjs": "^1.11.7",
|
package/src/QueueManager.tsx
CHANGED
|
@@ -80,9 +80,6 @@ function QueueManager(props: PropsWithChildren<{ apiKey?: string }>) {
|
|
|
80
80
|
getSupportedChainNames,
|
|
81
81
|
},
|
|
82
82
|
getSigners,
|
|
83
|
-
//todo: remove Network type
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
85
|
-
//@ts-ignore
|
|
86
83
|
wallets,
|
|
87
84
|
providers: allProviders,
|
|
88
85
|
switchNetwork,
|
|
@@ -84,18 +84,23 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
84
84
|
const isWalletRequiredFor = (blockchain: string) =>
|
|
85
85
|
!!selectedQuote?.swaps.find((swap) => swap.from.blockchain === blockchain);
|
|
86
86
|
|
|
87
|
-
const
|
|
87
|
+
const getInitialSelectableWallets = () =>
|
|
88
88
|
connectedWallets.filter((connectedWallet) => {
|
|
89
89
|
return (
|
|
90
90
|
connectedWallet.selected &&
|
|
91
91
|
requiredWallets.includes(connectedWallet.chain)
|
|
92
92
|
);
|
|
93
|
-
})
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
|
|
96
|
+
getInitialSelectableWallets()
|
|
94
97
|
);
|
|
95
98
|
const lastStepToBlockchainMeta = blockchains.find(
|
|
96
99
|
(chain) => chain.name === lastStepToBlockchain?.name
|
|
97
100
|
);
|
|
98
101
|
|
|
102
|
+
const isInsufficientBalanceModalOpen = balanceWarnings.length > 0;
|
|
103
|
+
|
|
99
104
|
const isSelected = (walletType: string, chain: string) =>
|
|
100
105
|
!!selectableWallets.find(
|
|
101
106
|
(selectableWallet) =>
|
|
@@ -291,7 +296,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
291
296
|
})}
|
|
292
297
|
anchor="center">
|
|
293
298
|
<WatermarkedModal
|
|
294
|
-
open={
|
|
299
|
+
open={isInsufficientBalanceModalOpen}
|
|
295
300
|
onClose={setBalanceWarnings.bind(null, [])}
|
|
296
301
|
container={modalContainer}>
|
|
297
302
|
<MessageBox
|
|
@@ -365,13 +365,6 @@ export const MoreStep = styled('div', {
|
|
|
365
365
|
},
|
|
366
366
|
});
|
|
367
367
|
|
|
368
|
-
export const Tag = styled('div', {
|
|
369
|
-
backgroundColor: '$neutral400',
|
|
370
|
-
borderRadius: '$xs',
|
|
371
|
-
padding: '$2 $5',
|
|
372
|
-
fontSize: '$10',
|
|
373
|
-
fontWeight: 400,
|
|
374
|
-
});
|
|
375
368
|
export const TagContainer = styled('div', {
|
|
376
369
|
display: 'flex',
|
|
377
370
|
});
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
Alert,
|
|
8
8
|
Divider,
|
|
9
9
|
InfoIcon,
|
|
10
|
+
QuoteTag,
|
|
10
11
|
StepDetails,
|
|
11
12
|
TokenAmount,
|
|
12
13
|
Tooltip,
|
|
@@ -15,7 +16,10 @@ import {
|
|
|
15
16
|
import BigNumber from 'bignumber.js';
|
|
16
17
|
import React, { useRef, useState } from 'react';
|
|
17
18
|
|
|
19
|
+
import { GAS_FEE_MAX } from '../../constants/quote';
|
|
18
20
|
import {
|
|
21
|
+
GAS_FEE_MAX_DECIMALS,
|
|
22
|
+
GAS_FEE_MIN_DECIMALS,
|
|
19
23
|
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
20
24
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
21
25
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
@@ -34,13 +38,18 @@ import {
|
|
|
34
38
|
getBlockchainShortNameFor,
|
|
35
39
|
getSwapperDisplayName,
|
|
36
40
|
} from '../../utils/meta';
|
|
37
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
formatTooltipNumbers,
|
|
43
|
+
numberToString,
|
|
44
|
+
secondsToString,
|
|
45
|
+
totalArrivalTime,
|
|
46
|
+
} from '../../utils/numbers';
|
|
38
47
|
import {
|
|
39
48
|
getPriceImpact,
|
|
40
49
|
getPriceImpactLevel,
|
|
41
|
-
getRouteTagColor,
|
|
42
50
|
sortTags,
|
|
43
51
|
} from '../../utils/quote';
|
|
52
|
+
import { getTotalFeeInUsd } from '../../utils/swap';
|
|
44
53
|
|
|
45
54
|
import {
|
|
46
55
|
AllRoutesButton,
|
|
@@ -56,7 +65,6 @@ import {
|
|
|
56
65
|
SummaryContainer,
|
|
57
66
|
summaryHeaderStyles,
|
|
58
67
|
summaryStyles,
|
|
59
|
-
Tag,
|
|
60
68
|
TagContainer,
|
|
61
69
|
} from './Quote.styles';
|
|
62
70
|
import { QuoteCostDetails } from './QuoteCostDetails';
|
|
@@ -76,6 +84,7 @@ export function Quote(props: QuoteProps) {
|
|
|
76
84
|
onClickAllRoutes,
|
|
77
85
|
} = props;
|
|
78
86
|
const blockchains = useAppStore().blockchains();
|
|
87
|
+
const tokens = useAppStore().tokens();
|
|
79
88
|
const swappers = useAppStore().swappers();
|
|
80
89
|
const [expanded, setExpanded] = useState(props.expanded);
|
|
81
90
|
const quoteRef = useRef<HTMLButtonElement | null>(null);
|
|
@@ -280,6 +289,13 @@ export function Quote(props: QuoteProps) {
|
|
|
280
289
|
const container = getContainer();
|
|
281
290
|
const sortedQuoteTags = sortTags(props.quote.tags || []);
|
|
282
291
|
const showAllRoutesButton = !!onClickAllRoutes;
|
|
292
|
+
const totalTime = secondsToString(totalArrivalTime(quote?.swaps));
|
|
293
|
+
const totalFee = getTotalFeeInUsd(quote?.swaps ?? [], tokens);
|
|
294
|
+
const fee = numberToString(
|
|
295
|
+
totalFee,
|
|
296
|
+
GAS_FEE_MIN_DECIMALS,
|
|
297
|
+
GAS_FEE_MAX_DECIMALS
|
|
298
|
+
);
|
|
283
299
|
|
|
284
300
|
return (
|
|
285
301
|
<>
|
|
@@ -295,11 +311,7 @@ export function Quote(props: QuoteProps) {
|
|
|
295
311
|
const key = `${tag.value}_${index}`;
|
|
296
312
|
return (
|
|
297
313
|
<>
|
|
298
|
-
<
|
|
299
|
-
style={{ color: getRouteTagColor(tag.value) }}
|
|
300
|
-
key={key}>
|
|
301
|
-
{tag.label}
|
|
302
|
-
</Tag>
|
|
314
|
+
<QuoteTag label={tag.label} key={key} value={tag.value} />
|
|
303
315
|
<Divider size={4} direction="horizontal" />
|
|
304
316
|
</>
|
|
305
317
|
);
|
|
@@ -310,7 +322,13 @@ export function Quote(props: QuoteProps) {
|
|
|
310
322
|
</>
|
|
311
323
|
) : null}
|
|
312
324
|
<div id="portal-root" className={summaryHeaderStyles()}>
|
|
313
|
-
<QuoteCostDetails
|
|
325
|
+
<QuoteCostDetails
|
|
326
|
+
steps={numberOfSteps}
|
|
327
|
+
quote={quote}
|
|
328
|
+
time={totalTime}
|
|
329
|
+
fee={fee}
|
|
330
|
+
feeWarning={totalFee.gte(new BigNumber(GAS_FEE_MAX))}
|
|
331
|
+
/>
|
|
314
332
|
|
|
315
333
|
{showAllRoutesButton && (
|
|
316
334
|
<AllRoutesButton
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { QuoteCostDetailsProps } from './Quote.types';
|
|
2
2
|
import type { NameOfFees } from '../../constants/quote';
|
|
3
|
+
import type BigNumber from 'bignumber.js';
|
|
3
4
|
|
|
4
5
|
import { i18n } from '@lingui/core';
|
|
5
6
|
import {
|
|
@@ -11,7 +12,6 @@ import {
|
|
|
11
12
|
Tooltip,
|
|
12
13
|
Typography,
|
|
13
14
|
} from '@rango-dev/ui';
|
|
14
|
-
import BigNumber from 'bignumber.js';
|
|
15
15
|
import React, { useState } from 'react';
|
|
16
16
|
|
|
17
17
|
import { NAME_OF_FEES } from '../../constants/quote';
|
|
@@ -21,20 +21,9 @@ import {
|
|
|
21
21
|
USD_VALUE_MAX_DECIMALS,
|
|
22
22
|
USD_VALUE_MIN_DECIMALS,
|
|
23
23
|
} from '../../constants/routing';
|
|
24
|
-
import { useAppStore } from '../../store/AppStore';
|
|
25
24
|
import { getContainer } from '../../utils/common';
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
numberToString,
|
|
29
|
-
secondsToString,
|
|
30
|
-
totalArrivalTime,
|
|
31
|
-
} from '../../utils/numbers';
|
|
32
|
-
import {
|
|
33
|
-
getFeesGroup,
|
|
34
|
-
getTotalFeeInUsd,
|
|
35
|
-
getTotalFeesInUsd,
|
|
36
|
-
getUsdFee,
|
|
37
|
-
} from '../../utils/swap';
|
|
25
|
+
import { formatTooltipNumbers, numberToString } from '../../utils/numbers';
|
|
26
|
+
import { getFeesGroup, getTotalFeesInUsd, getUsdFee } from '../../utils/swap';
|
|
38
27
|
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
39
28
|
import { CustomCollapsible } from '../CustomCollapsible/CustomCollapsible';
|
|
40
29
|
import { ExpandedIcon } from '../CustomCollapsible/CustomCollapsible.styles';
|
|
@@ -47,8 +36,6 @@ import {
|
|
|
47
36
|
trigger,
|
|
48
37
|
} from './QuoteCostDetails.styles';
|
|
49
38
|
|
|
50
|
-
const GAS_FEE_MAX = 30;
|
|
51
|
-
|
|
52
39
|
const NonPayableFee = (props: { fee: BigNumber; label: string }) => {
|
|
53
40
|
return !props.fee.isZero() ? (
|
|
54
41
|
<FeeSection>
|
|
@@ -70,14 +57,10 @@ const NonPayableFee = (props: { fee: BigNumber; label: string }) => {
|
|
|
70
57
|
export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
71
58
|
const [open, setOpen] = useState<boolean>(false);
|
|
72
59
|
const [openCollapse, setOpenCollapse] = useState<boolean>(false);
|
|
73
|
-
const { steps, quote } = props;
|
|
74
|
-
const tokens = useAppStore().tokens();
|
|
75
|
-
const totalTime = secondsToString(totalArrivalTime(quote?.swaps));
|
|
60
|
+
const { steps, quote, fee, time, feeWarning } = props;
|
|
76
61
|
const swaps = quote?.swaps ?? [];
|
|
77
62
|
const container = getContainer();
|
|
78
63
|
|
|
79
|
-
const totalFee = getTotalFeeInUsd(swaps, tokens);
|
|
80
|
-
|
|
81
64
|
const feesGroup = getFeesGroup(swaps);
|
|
82
65
|
|
|
83
66
|
return (
|
|
@@ -87,13 +70,9 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
87
70
|
e.stopPropagation();
|
|
88
71
|
setOpen(!open);
|
|
89
72
|
}}
|
|
90
|
-
fee={
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
GAS_FEE_MAX_DECIMALS
|
|
94
|
-
)}
|
|
95
|
-
feeWarning={totalFee.gte(new BigNumber(GAS_FEE_MAX))}
|
|
96
|
-
time={totalTime}
|
|
73
|
+
fee={fee}
|
|
74
|
+
feeWarning={feeWarning}
|
|
75
|
+
time={time}
|
|
97
76
|
steps={steps}
|
|
98
77
|
tooltipGas={i18n.t('View more info')}
|
|
99
78
|
tooltipContainer={container}
|
|
@@ -164,7 +143,7 @@ export function QuoteCostDetails(props: QuoteCostDetailsProps) {
|
|
|
164
143
|
<Typography variant="label" size="medium">
|
|
165
144
|
$
|
|
166
145
|
{numberToString(
|
|
167
|
-
|
|
146
|
+
fee,
|
|
168
147
|
USD_VALUE_MIN_DECIMALS,
|
|
169
148
|
USD_VALUE_MAX_DECIMALS
|
|
170
149
|
)}
|
|
@@ -95,9 +95,7 @@ export function SwapDetailsCompleteModal(props: CompleteModalPropTypes) {
|
|
|
95
95
|
type="primary"
|
|
96
96
|
size="large"
|
|
97
97
|
onClick={() => window.open(diagnosisUrl, '_blank')}>
|
|
98
|
-
|
|
99
|
-
{i18n.t('Diagnosis')}
|
|
100
|
-
</Typography>
|
|
98
|
+
{i18n.t('Diagnosis')}
|
|
101
99
|
</Button>
|
|
102
100
|
<Divider size={12} />
|
|
103
101
|
</>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CancelContentProps } from './SwapDetailsModal.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
|
-
import { Button, Divider, MessageBox
|
|
4
|
+
import { Button, Divider, MessageBox } from '@rango-dev/ui';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
export const CancelContent = ({ onCancel, onClose }: CancelContentProps) => {
|
|
@@ -19,15 +19,11 @@ export const CancelContent = ({ onCancel, onClose }: CancelContentProps) => {
|
|
|
19
19
|
type="primary"
|
|
20
20
|
size="large"
|
|
21
21
|
onClick={onCancel}>
|
|
22
|
-
|
|
23
|
-
{i18n.t('Yes, Cancel it')}
|
|
24
|
-
</Typography>
|
|
22
|
+
{i18n.t('Yes, Cancel it')}
|
|
25
23
|
</Button>
|
|
26
24
|
<Divider size={12} />
|
|
27
25
|
<Button variant="outlined" type="primary" size="large" onClick={onClose}>
|
|
28
|
-
|
|
29
|
-
{i18n.t('No, Continue')}
|
|
30
|
-
</Typography>
|
|
26
|
+
{i18n.t('No, Continue')}
|
|
31
27
|
</Button>
|
|
32
28
|
</>
|
|
33
29
|
);
|
|
@@ -19,9 +19,7 @@ export const DeleteContent = ({ onDelete, onClose }: DeleteContentProps) => {
|
|
|
19
19
|
type="primary"
|
|
20
20
|
size="large"
|
|
21
21
|
onClick={onDelete}>
|
|
22
|
-
|
|
23
|
-
{i18n.t('Yes, Delete it')}
|
|
24
|
-
</Typography>
|
|
22
|
+
{i18n.t('Yes, Delete it')}
|
|
25
23
|
</Button>
|
|
26
24
|
<Divider size={12} />
|
|
27
25
|
<Button variant="outlined" type="primary" size="large" onClick={onClose}>
|
package/src/constants/quote.ts
CHANGED
|
@@ -3,15 +3,14 @@ import type {
|
|
|
3
3
|
PropTypes,
|
|
4
4
|
WidgetContextInterface,
|
|
5
5
|
} from './Wallets.types';
|
|
6
|
-
import type { Wallet } from '../../types/wallets';
|
|
7
6
|
import type { ProvidersOptions } from '../../utils/providers';
|
|
8
7
|
import type { EventHandler } from '@rango-dev/wallets-react';
|
|
9
|
-
import type { Network } from '@rango-dev/wallets-shared';
|
|
10
8
|
import type { PropsWithChildren } from 'react';
|
|
11
9
|
|
|
12
10
|
import { Events, Provider } from '@rango-dev/wallets-react';
|
|
11
|
+
import { type Network } from '@rango-dev/wallets-shared';
|
|
13
12
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
14
|
-
import React, { createContext, useEffect, useRef
|
|
13
|
+
import React, { createContext, useEffect, useRef } from 'react';
|
|
15
14
|
|
|
16
15
|
import { useWalletProviders } from '../../hooks/useWalletProviders';
|
|
17
16
|
import { AppStoreProvider, useAppStore } from '../../store/AppStore';
|
|
@@ -35,7 +34,6 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
35
34
|
const walletOptions: ProvidersOptions = {
|
|
36
35
|
walletConnectProjectId: props.config?.walletConnectProjectId,
|
|
37
36
|
};
|
|
38
|
-
const [accounts, setAccounts] = useState<Wallet[]>([]);
|
|
39
37
|
const { providers } = useWalletProviders(props.config.wallets, walletOptions);
|
|
40
38
|
const { connectWallet, disconnectWallet } = useWalletsStore();
|
|
41
39
|
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
@@ -67,7 +65,9 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
67
65
|
supportedChainNames,
|
|
68
66
|
meta.isContractWallet
|
|
69
67
|
);
|
|
70
|
-
|
|
68
|
+
if (data.length) {
|
|
69
|
+
connectWallet(data, tokens);
|
|
70
|
+
}
|
|
71
71
|
} else {
|
|
72
72
|
disconnectWallet(type);
|
|
73
73
|
}
|
|
@@ -102,12 +102,6 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
102
102
|
};
|
|
103
103
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
104
104
|
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
if (accounts.length) {
|
|
107
|
-
connectWallet(accounts, tokens);
|
|
108
|
-
}
|
|
109
|
-
}, [accounts, tokens]);
|
|
110
|
-
|
|
111
105
|
return (
|
|
112
106
|
<WidgetContext.Provider
|
|
113
107
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
package/src/pages/Home.tsx
CHANGED
|
@@ -102,7 +102,7 @@ export function Home() {
|
|
|
102
102
|
formatBalance(fromTokenBalance)?.amount ?? '0';
|
|
103
103
|
|
|
104
104
|
const tokenBalanceReal =
|
|
105
|
-
!!fromBlockchain && !!fromToken
|
|
105
|
+
!!fromBlockchain && !!fromToken && fromTokenBalance?.amount
|
|
106
106
|
? numberToString(fromTokenBalance?.amount, fromTokenBalance?.decimals)
|
|
107
107
|
: '0';
|
|
108
108
|
|
|
@@ -203,9 +203,7 @@ export function Home() {
|
|
|
203
203
|
loadingBalance={fetchingBalance}
|
|
204
204
|
tooltipContainer={getContainer()}
|
|
205
205
|
onSelectMaxBalance={() => {
|
|
206
|
-
|
|
207
|
-
setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
208
|
-
}
|
|
206
|
+
setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
209
207
|
}}
|
|
210
208
|
/>
|
|
211
209
|
<SwitchFromAndToButton />
|
package/src/utils/quote.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
2
|
import type { QuoteWarning, SelectedQuote, Wallet } from '../types';
|
|
3
|
-
import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
|
|
4
3
|
import type {
|
|
4
|
+
PriceImpactWarningLevel,
|
|
5
5
|
SimulationAssetAndAmount,
|
|
6
6
|
SimulationValidationStatus,
|
|
7
|
-
|
|
7
|
+
Step,
|
|
8
|
+
} from '@rango-dev/ui';
|
|
8
9
|
import type {
|
|
9
10
|
Asset,
|
|
10
11
|
BlockchainMeta,
|
|
@@ -12,7 +13,6 @@ import type {
|
|
|
12
13
|
MultiRouteSimulationResult,
|
|
13
14
|
PreferenceType,
|
|
14
15
|
RouteTag,
|
|
15
|
-
TagValue,
|
|
16
16
|
Token,
|
|
17
17
|
} from 'rango-sdk';
|
|
18
18
|
import type { PendingSwap } from 'rango-types';
|
|
@@ -372,19 +372,3 @@ export const sortTags = (tags: RouteTag[]): RouteTag[] => {
|
|
|
372
372
|
|
|
373
373
|
return tags.sort(customSort);
|
|
374
374
|
};
|
|
375
|
-
|
|
376
|
-
export const getRouteTagColor = (tag: TagValue): string => {
|
|
377
|
-
switch (tag) {
|
|
378
|
-
case 'FASTEST':
|
|
379
|
-
return '#06C270';
|
|
380
|
-
case 'RECOMMENDED':
|
|
381
|
-
return '#469BF5';
|
|
382
|
-
case 'LOWEST_FEE':
|
|
383
|
-
return '#FF4DAD';
|
|
384
|
-
case 'HIGH_IMPACT':
|
|
385
|
-
return '#FF3B3B';
|
|
386
|
-
case 'CENTRALIZED':
|
|
387
|
-
default:
|
|
388
|
-
return '#FFF1D4';
|
|
389
|
-
}
|
|
390
|
-
};
|