@rango-dev/widget-embedded 0.20.1-next.16 → 0.20.1-next.17
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/BlockchainList/BlockchainList.styles.d.ts +4 -0
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +2 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +38 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +6 -0
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +10 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts +6 -0
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +2 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +28 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.styles.d.ts +6 -0
- package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +8 -0
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +356 -2
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.types.d.ts +15 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +4 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
- package/dist/components/Quote/QuoteTrigger .d.ts +4 -0
- package/dist/components/Quote/QuoteTrigger .d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +8 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +20 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +10 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +8 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +2 -0
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +8 -0
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +10 -0
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +24 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +2 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +2 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +10 -0
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +34 -0
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts +8 -0
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
- package/dist/containers/App/App.styles.d.ts +2 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +10 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/utils/quote.d.ts +5 -1
- package/dist/utils/quote.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/Quote/Quote.styles.ts +43 -4
- package/src/components/Quote/Quote.tsx +7 -58
- package/src/components/Quote/Quote.types.ts +17 -0
- package/src/components/Quote/QuoteTrigger .tsx +215 -0
- package/src/utils/quote.ts +18 -1
package/dist/utils/quote.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QuoteError, QuoteWarning, Wallet } from '../types';
|
|
2
|
-
import type { PriceImpactWarningLevel } from '@rango-dev/ui';
|
|
2
|
+
import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
|
|
3
3
|
import type { SimulationAssetAndAmount, SimulationValidationStatus } from '@rango-dev/ui/dist/widget/ui/src/types/swaps';
|
|
4
4
|
import type { Asset, BestRouteResponse, BlockchainMeta, Token } from 'rango-sdk';
|
|
5
5
|
import type { PendingSwap } from 'rango-types';
|
|
@@ -29,4 +29,8 @@ export declare function generateQuoteWarnings(quote: BestRouteResponse, params:
|
|
|
29
29
|
}): QuoteWarning | null;
|
|
30
30
|
export declare function generateQuoteErrors(quote: BestRouteResponse): QuoteError | null;
|
|
31
31
|
export declare function getPriceImpact(inputUsdValue: BigNumber | string | null, outputUsdValue: BigNumber | string | null): number | null;
|
|
32
|
+
export declare const getUniqueBlockchains: (steps: Step[]) => {
|
|
33
|
+
displayName: string;
|
|
34
|
+
image: string;
|
|
35
|
+
}[];
|
|
32
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,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/utils/quote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,8CAA8C,CAAC;AACtD,OAAO,KAAK,EACV,KAAK,EACL,iBAAiB,EACjB,cAAc,EACd,KAAK,EACN,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,SAAS,MAAM,cAAc,CAAC;AAqBrC,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,KAAK,EAAE,EACf,YAAY,EAAE,MAAM,GAAG,IAAI,EAC3B,KAAK,EAAE,cAAc,GAAG,IAAI,GAC3B,KAAK,GAAG,IAAI,CAqBd;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,iBAAiB,GAAG,IAAI,GAC9B,MAAM,GAAG,IAAI,GAAG,SAAS,CAE3B;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,iBAAiB,WAK1B;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,iBAAiB,WAO1B;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,iBAAiB,WAO1B;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,iBAAiB,GACxB,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,iBAAiB,EACxB,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,mBAAmB,CACjC,KAAK,EAAE,iBAAiB,GACvB,UAAU,GAAG,IAAI,CA+BnB;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"}
|
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.17",
|
|
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.9",
|
|
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",
|
|
@@ -114,6 +114,15 @@ export const summaryStyles = css({
|
|
|
114
114
|
cursor: 'default',
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
+
export const rowStyles = css({
|
|
118
|
+
display: 'flex',
|
|
119
|
+
flexDirection: 'row',
|
|
120
|
+
justifyContent: 'center',
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
'.blockchainImage': {
|
|
123
|
+
marginLeft: '-$8',
|
|
124
|
+
},
|
|
125
|
+
});
|
|
117
126
|
export const basicInfoStyles = css({
|
|
118
127
|
paddingTop: '$10',
|
|
119
128
|
display: 'flex',
|
|
@@ -127,7 +136,7 @@ export const basicInfoStyles = css({
|
|
|
127
136
|
},
|
|
128
137
|
});
|
|
129
138
|
|
|
130
|
-
export const
|
|
139
|
+
export const Trigger = styled(Collapsible.Trigger, {
|
|
131
140
|
display: 'flex',
|
|
132
141
|
width: '100%',
|
|
133
142
|
justifyContent: 'space-between',
|
|
@@ -171,17 +180,27 @@ export const Chains = styled(Collapsible.Trigger, {
|
|
|
171
180
|
},
|
|
172
181
|
},
|
|
173
182
|
},
|
|
174
|
-
'
|
|
183
|
+
'.blockchains_section': {
|
|
184
|
+
display: 'none',
|
|
185
|
+
},
|
|
186
|
+
'@xs': {
|
|
187
|
+
'.blockchains_section': {
|
|
188
|
+
display: 'block',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
175
191
|
});
|
|
176
192
|
|
|
177
|
-
export const
|
|
193
|
+
export const ImageContainer = styled('div', {
|
|
178
194
|
width: '18px',
|
|
179
195
|
height: '18px',
|
|
180
196
|
borderRadius: '100%',
|
|
181
|
-
border: '1.5px transparent solid',
|
|
182
197
|
display: 'flex',
|
|
183
198
|
justifyContent: 'center',
|
|
184
199
|
alignItems: 'center',
|
|
200
|
+
border: '1.5px transparent solid',
|
|
201
|
+
img: {
|
|
202
|
+
borderRadius: '100%',
|
|
203
|
+
},
|
|
185
204
|
variants: {
|
|
186
205
|
state: {
|
|
187
206
|
error: {
|
|
@@ -252,3 +271,23 @@ export const ContainerInfoOutput = styled('div', {
|
|
|
252
271
|
display: 'flex',
|
|
253
272
|
flexWrap: 'wrap',
|
|
254
273
|
});
|
|
274
|
+
|
|
275
|
+
export const MoreStep = styled('div', {
|
|
276
|
+
width: '18px',
|
|
277
|
+
height: '18px',
|
|
278
|
+
borderRadius: '100%',
|
|
279
|
+
backgroundColor: '$background',
|
|
280
|
+
cursor: 'default',
|
|
281
|
+
display: 'flex',
|
|
282
|
+
justifyContent: 'center',
|
|
283
|
+
alignItems: 'center',
|
|
284
|
+
border: '1.5px transparent solid',
|
|
285
|
+
variants: {
|
|
286
|
+
state: {
|
|
287
|
+
error: {
|
|
288
|
+
borderColor: '$error500',
|
|
289
|
+
},
|
|
290
|
+
warning: { borderColor: '$warning500' },
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
});
|
|
@@ -5,10 +5,7 @@ import type { SwapResult } from 'rango-sdk';
|
|
|
5
5
|
import { i18n } from '@lingui/core';
|
|
6
6
|
import {
|
|
7
7
|
Alert,
|
|
8
|
-
ChevronDownIcon,
|
|
9
|
-
ChevronRightIcon,
|
|
10
8
|
Divider,
|
|
11
|
-
Image,
|
|
12
9
|
InfoIcon,
|
|
13
10
|
QuoteCost,
|
|
14
11
|
StepDetails,
|
|
@@ -52,20 +49,18 @@ import { getTotalFeeInUsd } from '../../utils/swap';
|
|
|
52
49
|
import {
|
|
53
50
|
BasicInfoOutput,
|
|
54
51
|
basicInfoStyles,
|
|
55
|
-
ChainImageContainer,
|
|
56
|
-
Chains,
|
|
57
52
|
ContainerInfoOutput,
|
|
58
53
|
Content,
|
|
59
54
|
EXPANDABLE_QUOTE_TRANSITION_DURATION,
|
|
60
55
|
FrameIcon,
|
|
61
56
|
HorizontalSeparator,
|
|
62
|
-
IconContainer,
|
|
63
57
|
QuoteContainer,
|
|
64
58
|
stepsDetailsStyles,
|
|
65
59
|
SummaryContainer,
|
|
66
60
|
summaryStyles,
|
|
67
61
|
} from './Quote.styles';
|
|
68
62
|
import { QuoteSummary } from './QuoteSummary';
|
|
63
|
+
import { QuoteTrigger } from './QuoteTrigger ';
|
|
69
64
|
|
|
70
65
|
export function Quote(props: QuoteProps) {
|
|
71
66
|
const {
|
|
@@ -374,59 +369,13 @@ export function Quote(props: QuoteProps) {
|
|
|
374
369
|
recommended={recommended}
|
|
375
370
|
open={expanded}
|
|
376
371
|
onOpenChange={setExpanded}>
|
|
377
|
-
<
|
|
378
|
-
|
|
372
|
+
<QuoteTrigger
|
|
373
|
+
quoteRef={quoteRef}
|
|
379
374
|
recommended={recommended}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
const arrow = (
|
|
385
|
-
<IconContainer>
|
|
386
|
-
<ChevronRightIcon
|
|
387
|
-
size={12}
|
|
388
|
-
color="black"
|
|
389
|
-
{...(step.state && {
|
|
390
|
-
color: step.state === 'error' ? 'error' : 'warning',
|
|
391
|
-
})}
|
|
392
|
-
/>
|
|
393
|
-
</IconContainer>
|
|
394
|
-
);
|
|
395
|
-
return (
|
|
396
|
-
<React.Fragment key={key}>
|
|
397
|
-
<Tooltip
|
|
398
|
-
container={tooltipContainer}
|
|
399
|
-
side="bottom"
|
|
400
|
-
sideOffset={4}
|
|
401
|
-
content={step.from.chain.displayName}>
|
|
402
|
-
<ChainImageContainer
|
|
403
|
-
state={step.state || steps[index - 1]?.state}>
|
|
404
|
-
<Image src={step.from.chain.image} size={16} />
|
|
405
|
-
</ChainImageContainer>
|
|
406
|
-
</Tooltip>
|
|
407
|
-
{index === numberOfSteps - 1 && (
|
|
408
|
-
<>
|
|
409
|
-
{arrow}
|
|
410
|
-
<Tooltip
|
|
411
|
-
container={tooltipContainer}
|
|
412
|
-
side="bottom"
|
|
413
|
-
sideOffset={4}
|
|
414
|
-
content={step.to.chain.displayName}>
|
|
415
|
-
<ChainImageContainer state={step.state}>
|
|
416
|
-
<Image src={step.to.chain.image} size={16} />
|
|
417
|
-
</ChainImageContainer>
|
|
418
|
-
</Tooltip>
|
|
419
|
-
</>
|
|
420
|
-
)}
|
|
421
|
-
{index !== numberOfSteps - 1 && <>{arrow}</>}
|
|
422
|
-
</React.Fragment>
|
|
423
|
-
);
|
|
424
|
-
})}
|
|
425
|
-
</div>
|
|
426
|
-
<IconContainer orientation={expanded ? 'up' : 'down'}>
|
|
427
|
-
<ChevronDownIcon size={12} color="black" />
|
|
428
|
-
</IconContainer>
|
|
429
|
-
</Chains>
|
|
375
|
+
setExpanded={setExpanded}
|
|
376
|
+
expanded={expanded}
|
|
377
|
+
steps={steps}
|
|
378
|
+
/>
|
|
430
379
|
<Content open={expanded}>
|
|
431
380
|
<HorizontalSeparator />
|
|
432
381
|
<div className={stepsDetailsStyles()}>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { QuoteError, QuoteWarning } from '../../types';
|
|
2
|
+
import type { Step } from '@rango-dev/ui';
|
|
2
3
|
import type { BestRouteResponse } from 'rango-sdk';
|
|
3
4
|
import type { ReactNode } from 'react';
|
|
4
5
|
|
|
@@ -13,3 +14,19 @@ export type QuoteProps = {
|
|
|
13
14
|
output: { value: string; usdValue?: string };
|
|
14
15
|
expanded?: boolean;
|
|
15
16
|
};
|
|
17
|
+
|
|
18
|
+
export type QuoteTriggerProps = {
|
|
19
|
+
quoteRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
20
|
+
recommended: boolean;
|
|
21
|
+
setExpanded: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
|
22
|
+
steps: Step[];
|
|
23
|
+
expanded?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type QuoteTriggerImagesProps = {
|
|
27
|
+
content: ReactNode;
|
|
28
|
+
state?: 'error' | 'warning' | undefined;
|
|
29
|
+
src: string;
|
|
30
|
+
open?: boolean;
|
|
31
|
+
className?: string;
|
|
32
|
+
};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import type { QuoteTriggerImagesProps, QuoteTriggerProps } from './Quote.types';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
import {
|
|
5
|
+
ChevronDownIcon,
|
|
6
|
+
ChevronRightIcon,
|
|
7
|
+
Divider,
|
|
8
|
+
Image,
|
|
9
|
+
Tooltip,
|
|
10
|
+
Typography,
|
|
11
|
+
} from '@rango-dev/ui';
|
|
12
|
+
import React, { useEffect, useState } from 'react';
|
|
13
|
+
|
|
14
|
+
import { getContainer } from '../../utils/common';
|
|
15
|
+
import { getUniqueBlockchains } from '../../utils/quote';
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
IconContainer,
|
|
19
|
+
ImageContainer,
|
|
20
|
+
MoreStep,
|
|
21
|
+
rowStyles,
|
|
22
|
+
Trigger,
|
|
23
|
+
} from './Quote.styles';
|
|
24
|
+
|
|
25
|
+
const MAX_STEPS = 4;
|
|
26
|
+
const MAX_BLOCKCHAINS = 6;
|
|
27
|
+
const MIN_WIDTH_WINDOW = 375;
|
|
28
|
+
|
|
29
|
+
const ImageComponent = (props: QuoteTriggerImagesProps) => {
|
|
30
|
+
const tooltipContainer = getContainer();
|
|
31
|
+
const { content, src, className, open, state } = props;
|
|
32
|
+
return (
|
|
33
|
+
<Tooltip
|
|
34
|
+
container={tooltipContainer}
|
|
35
|
+
side="bottom"
|
|
36
|
+
sideOffset={4}
|
|
37
|
+
open={open}
|
|
38
|
+
content={content}>
|
|
39
|
+
<ImageContainer className={className} state={state}>
|
|
40
|
+
<Image src={src} size={16} />
|
|
41
|
+
</ImageContainer>
|
|
42
|
+
</Tooltip>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export function QuoteTrigger(props: QuoteTriggerProps) {
|
|
47
|
+
const { quoteRef, recommended, setExpanded, steps, expanded } = props;
|
|
48
|
+
const tooltipContainer = getContainer();
|
|
49
|
+
const numberOfSteps = steps.length;
|
|
50
|
+
const blockchains = getUniqueBlockchains(steps);
|
|
51
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
52
|
+
|
|
53
|
+
//choose the screen size
|
|
54
|
+
const handleResize = () => {
|
|
55
|
+
if (window.innerWidth < MIN_WIDTH_WINDOW) {
|
|
56
|
+
setIsMobile(true);
|
|
57
|
+
} else {
|
|
58
|
+
setIsMobile(false);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
window.addEventListener('resize', handleResize);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Trigger
|
|
68
|
+
ref={(ref) => (quoteRef.current = ref)}
|
|
69
|
+
recommended={recommended}
|
|
70
|
+
onClick={() => setExpanded((prevState) => !prevState)}>
|
|
71
|
+
<div className={rowStyles()}>
|
|
72
|
+
<Typography variant="body" size="xsmall">
|
|
73
|
+
{i18n.t('Via:')}
|
|
74
|
+
</Typography>
|
|
75
|
+
<Divider direction="horizontal" size={4} />
|
|
76
|
+
{steps.map((step, index) => {
|
|
77
|
+
const key = `item-${index}`;
|
|
78
|
+
const arrow = (
|
|
79
|
+
<IconContainer>
|
|
80
|
+
<ChevronRightIcon size={12} color="black" />
|
|
81
|
+
</IconContainer>
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
return isMobile ? (
|
|
85
|
+
<>
|
|
86
|
+
<ImageComponent
|
|
87
|
+
content={step.swapper.displayName}
|
|
88
|
+
src={step.swapper.image}
|
|
89
|
+
state={step.state}
|
|
90
|
+
/>
|
|
91
|
+
{index !== numberOfSteps - 1 && <>{arrow}</>}
|
|
92
|
+
</>
|
|
93
|
+
) : (
|
|
94
|
+
<React.Fragment key={key}>
|
|
95
|
+
{numberOfSteps <= MAX_STEPS ||
|
|
96
|
+
(numberOfSteps > MAX_STEPS && index < MAX_STEPS - 1) ? (
|
|
97
|
+
<>
|
|
98
|
+
<ImageComponent
|
|
99
|
+
content={step.swapper.displayName}
|
|
100
|
+
src={step.swapper.image}
|
|
101
|
+
state={step.state}
|
|
102
|
+
/>
|
|
103
|
+
{index !== numberOfSteps - 1 && <>{arrow}</>}
|
|
104
|
+
</>
|
|
105
|
+
) : (
|
|
106
|
+
index === MAX_STEPS - 1 && (
|
|
107
|
+
<Tooltip
|
|
108
|
+
container={tooltipContainer}
|
|
109
|
+
side="bottom"
|
|
110
|
+
align="right"
|
|
111
|
+
sideOffset={4}
|
|
112
|
+
content={
|
|
113
|
+
<div className={rowStyles()}>
|
|
114
|
+
{arrow}
|
|
115
|
+
{steps.map((step, i) => {
|
|
116
|
+
const key = `image-${i}`;
|
|
117
|
+
return (
|
|
118
|
+
i >= index && (
|
|
119
|
+
<React.Fragment key={key}>
|
|
120
|
+
<ImageComponent
|
|
121
|
+
content={step.swapper.displayName}
|
|
122
|
+
src={step.swapper.image}
|
|
123
|
+
state={step.state}
|
|
124
|
+
open={false}
|
|
125
|
+
/>
|
|
126
|
+
{i !== numberOfSteps - 1 && <>{arrow}</>}
|
|
127
|
+
</React.Fragment>
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
})}
|
|
131
|
+
</div>
|
|
132
|
+
}>
|
|
133
|
+
<MoreStep
|
|
134
|
+
state={
|
|
135
|
+
steps.find(
|
|
136
|
+
(step, i) =>
|
|
137
|
+
i >= index &&
|
|
138
|
+
(step.state === 'error' || step.state === 'warning')
|
|
139
|
+
)?.state
|
|
140
|
+
}>
|
|
141
|
+
<Typography size="xsmall" variant="body">
|
|
142
|
+
+{numberOfSteps - index}
|
|
143
|
+
</Typography>
|
|
144
|
+
</MoreStep>
|
|
145
|
+
</Tooltip>
|
|
146
|
+
)
|
|
147
|
+
)}
|
|
148
|
+
</React.Fragment>
|
|
149
|
+
);
|
|
150
|
+
})}
|
|
151
|
+
</div>
|
|
152
|
+
<div className={rowStyles()}>
|
|
153
|
+
<div className="blockchains_section">
|
|
154
|
+
<div className={rowStyles()}>
|
|
155
|
+
<Typography variant="body" size="xsmall">
|
|
156
|
+
{i18n.t('Chains:')}
|
|
157
|
+
</Typography>
|
|
158
|
+
<Divider direction="horizontal" size={4} />
|
|
159
|
+
{blockchains.map((blockchain, index) => (
|
|
160
|
+
<>
|
|
161
|
+
{blockchains.length <= MAX_BLOCKCHAINS ||
|
|
162
|
+
(blockchains.length > MAX_BLOCKCHAINS &&
|
|
163
|
+
index < MAX_BLOCKCHAINS - 1) ? (
|
|
164
|
+
<ImageComponent
|
|
165
|
+
key={blockchain.displayName}
|
|
166
|
+
content={''}
|
|
167
|
+
src={blockchain.image}
|
|
168
|
+
open={false}
|
|
169
|
+
className={index !== 0 ? 'blockchainImage' : ''}
|
|
170
|
+
/>
|
|
171
|
+
) : (
|
|
172
|
+
index === MAX_BLOCKCHAINS - 1 && (
|
|
173
|
+
<Tooltip
|
|
174
|
+
container={tooltipContainer}
|
|
175
|
+
side="bottom"
|
|
176
|
+
align="right"
|
|
177
|
+
sideOffset={4}
|
|
178
|
+
content={
|
|
179
|
+
<div className={rowStyles()}>
|
|
180
|
+
{blockchains.map(
|
|
181
|
+
(chain, i) =>
|
|
182
|
+
i >= index && (
|
|
183
|
+
<ImageComponent
|
|
184
|
+
key={chain.displayName}
|
|
185
|
+
content={''}
|
|
186
|
+
src={chain.image}
|
|
187
|
+
open={false}
|
|
188
|
+
className={i > index ? 'blockchainImage' : ''}
|
|
189
|
+
/>
|
|
190
|
+
)
|
|
191
|
+
)}
|
|
192
|
+
</div>
|
|
193
|
+
}>
|
|
194
|
+
<MoreStep className={'blockchainImage'}>
|
|
195
|
+
<Typography size="xsmall" variant="body">
|
|
196
|
+
+{blockchains.length - index}
|
|
197
|
+
</Typography>
|
|
198
|
+
</MoreStep>
|
|
199
|
+
</Tooltip>
|
|
200
|
+
)
|
|
201
|
+
)}
|
|
202
|
+
</>
|
|
203
|
+
))}
|
|
204
|
+
|
|
205
|
+
<Divider direction="horizontal" size={32} />
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<IconContainer orientation={expanded ? 'up' : 'down'}>
|
|
210
|
+
<ChevronDownIcon size={12} color="black" />
|
|
211
|
+
</IconContainer>
|
|
212
|
+
</div>
|
|
213
|
+
</Trigger>
|
|
214
|
+
);
|
|
215
|
+
}
|
package/src/utils/quote.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
2
|
import type { QuoteError, QuoteWarning, Wallet } from '../types';
|
|
3
|
-
import type { PriceImpactWarningLevel } from '@rango-dev/ui';
|
|
3
|
+
import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
|
|
4
4
|
import type {
|
|
5
5
|
SimulationAssetAndAmount,
|
|
6
6
|
SimulationValidationStatus,
|
|
@@ -336,3 +336,20 @@ export function getPriceImpact(
|
|
|
336
336
|
|
|
337
337
|
return percentageChange && percentageChange < 0 ? percentageChange : null;
|
|
338
338
|
}
|
|
339
|
+
|
|
340
|
+
export const getUniqueBlockchains = (steps: Step[]) => {
|
|
341
|
+
const set = new Set();
|
|
342
|
+
const result: { displayName: string; image: string }[] = [];
|
|
343
|
+
steps.forEach((step) => {
|
|
344
|
+
if (!set.has(step.from.chain.displayName)) {
|
|
345
|
+
set.add(step.from.chain.displayName);
|
|
346
|
+
result.push(step.from.chain);
|
|
347
|
+
}
|
|
348
|
+
if (!set.has(step.to.chain.displayName)) {
|
|
349
|
+
set.add(step.to.chain.displayName);
|
|
350
|
+
result.push(step.to.chain);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
return result;
|
|
355
|
+
};
|