@rango-dev/widget-embedded 0.47.0 → 0.47.1-next.1
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 +15 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/HistoryGroupedList/HistoryGroupedList.d.ts.map +1 -1
- package/dist/components/HistoryGroupedList/HistoryGroupedList.helpers.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +6 -6
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +3 -3
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/slices/wallets.d.ts.map +1 -1
- package/dist/store/utils/data.d.ts.map +1 -1
- package/dist/store/utils/wallets.d.ts +1 -1
- package/dist/store/utils/wallets.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +8 -8
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +7 -6
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +1 -1
- package/src/components/HistoryGroupedList/HistoryGroupedList.helpers.ts +4 -2
- package/src/components/HistoryGroupedList/HistoryGroupedList.tsx +3 -0
- package/src/components/Quote/Quote.tsx +14 -9
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +2 -2
- package/src/components/SwapDetails/SwapDetails.tsx +21 -19
- package/src/components/SwapMetrics/SwapMetrics.tsx +2 -2
- package/src/components/TokenList/TokenList.tsx +10 -8
- package/src/components/TokenList/TokenList.types.ts +9 -6
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +1 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +4 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +1 -1
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +1 -1
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.helpers.ts +4 -2
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +12 -15
- package/src/pages/SelectSwapItemPage/SelectSwapItemPage.helpers.ts +1 -1
- package/src/store/notification.ts +3 -1
- package/src/store/slices/data.test.ts +9 -9
- package/src/store/slices/data.ts +1 -1
- package/src/store/slices/wallets.ts +22 -9
- package/src/store/utils/data.test.ts +27 -14
- package/src/store/utils/data.ts +11 -3
- package/src/store/utils/wallets.ts +23 -11
- package/src/test-utils/fixtures.ts +1 -1
- package/src/utils/colors.ts +4 -1
- package/src/utils/configs.ts +10 -6
- package/src/utils/quote.ts +16 -5
- package/src/utils/swap.ts +11 -4
- package/src/utils/wallets.ts +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rango-dev/widget-embedded",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.1-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"@lingui/core": "4.2.1",
|
|
26
26
|
"@lingui/react": "4.2.1",
|
|
27
27
|
"@rango-dev/logging-core": "^0.11.0",
|
|
28
|
-
"@rango-dev/provider-all": "^0.50.0",
|
|
28
|
+
"@rango-dev/provider-all": "^0.50.1-next.0",
|
|
29
29
|
"@rango-dev/queue-manager-core": "^0.32.0",
|
|
30
|
-
"@rango-dev/queue-manager-rango-preset": "^0.49.0",
|
|
30
|
+
"@rango-dev/queue-manager-rango-preset": "^0.49.1-next.0",
|
|
31
31
|
"@rango-dev/queue-manager-react": "^0.32.0",
|
|
32
32
|
"@rango-dev/signer-solana": "^0.43.0",
|
|
33
|
-
"@rango-dev/ui": "^0.50.0",
|
|
34
|
-
"@rango-dev/wallets-core": "^0.47.0",
|
|
35
|
-
"@rango-dev/wallets-react": "^0.34.0",
|
|
36
|
-
"@rango-dev/wallets-shared": "^0.48.0",
|
|
33
|
+
"@rango-dev/ui": "^0.50.1-next.0",
|
|
34
|
+
"@rango-dev/wallets-core": "^0.47.1-next.0",
|
|
35
|
+
"@rango-dev/wallets-react": "^0.34.1-next.0",
|
|
36
|
+
"@rango-dev/wallets-shared": "^0.48.1-next.0",
|
|
37
37
|
"bignumber.js": "^9.1.1",
|
|
38
38
|
"copy-to-clipboard": "^3.3.3",
|
|
39
39
|
"dayjs": "^1.11.7",
|
|
@@ -54,4 +54,4 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
}
|
|
57
|
-
}
|
|
57
|
+
}
|
|
@@ -43,7 +43,9 @@ export function BlockchainsSection(props: PropTypes) {
|
|
|
43
43
|
/**
|
|
44
44
|
* When only one item is left on list, we will not show the `More` button and will show the item itself instead.
|
|
45
45
|
*/
|
|
46
|
-
const
|
|
46
|
+
const firstItemOfList = blockchainsList.more[0];
|
|
47
|
+
const onlyOneItemInList =
|
|
48
|
+
blockchainsList.more.length === 1 && firstItemOfList;
|
|
47
49
|
const showMoreButton = !onlyOneItemInList && hasMoreItemsInList;
|
|
48
50
|
|
|
49
51
|
return (
|
|
@@ -103,13 +105,12 @@ export function BlockchainsSection(props: PropTypes) {
|
|
|
103
105
|
{onlyOneItemInList ? (
|
|
104
106
|
<BlockchainsChip
|
|
105
107
|
className="widget-blockchains-section-only-item-btn"
|
|
106
|
-
key={
|
|
108
|
+
key={firstItemOfList.name}
|
|
107
109
|
selected={
|
|
108
|
-
!!blockchain &&
|
|
109
|
-
blockchain.name === blockchainsList.more[0].name
|
|
110
|
+
!!blockchain && blockchain.name === firstItemOfList.name
|
|
110
111
|
}
|
|
111
|
-
onClick={() => onChange(
|
|
112
|
-
<Image src={
|
|
112
|
+
onClick={() => onChange(firstItemOfList)}>
|
|
113
|
+
<Image src={firstItemOfList.logo} size={30} />
|
|
113
114
|
</BlockchainsChip>
|
|
114
115
|
) : null}
|
|
115
116
|
|
|
@@ -79,7 +79,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
79
79
|
const lastStepToBlockchain = blockchains.find(
|
|
80
80
|
(blockchain) =>
|
|
81
81
|
blockchain.name ===
|
|
82
|
-
selectedQuote?.swaps[selectedQuote?.swaps.length - 1]
|
|
82
|
+
selectedQuote?.swaps[selectedQuote?.swaps.length - 1]?.to.blockchain
|
|
83
83
|
);
|
|
84
84
|
const isWalletRequiredFor = (blockchain: string) =>
|
|
85
85
|
requiredChains.includes(blockchain);
|
|
@@ -9,8 +9,10 @@ export function calculateGroupsSoFar(totalGroups: number[], count: number) {
|
|
|
9
9
|
let index = 0;
|
|
10
10
|
do {
|
|
11
11
|
const group = totalGroups[index];
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (group) {
|
|
13
|
+
groups.push(Math.min(group, count));
|
|
14
|
+
count -= group;
|
|
15
|
+
}
|
|
14
16
|
index++;
|
|
15
17
|
} while (count > 0 && index <= totalGroups.length);
|
|
16
18
|
return groups;
|
|
@@ -109,6 +109,9 @@ export function HistoryGroupedList(props: PropTypes) {
|
|
|
109
109
|
const currentStep = getCurrentStep(swap);
|
|
110
110
|
const firstStep = swap.steps[0];
|
|
111
111
|
const lastStep = swap.steps[swap.steps.length - 1];
|
|
112
|
+
if (!firstStep || !lastStep) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
112
115
|
return (
|
|
113
116
|
<SwapItemContainer key={swap.requestId}>
|
|
114
117
|
<SwapListItem
|
|
@@ -329,6 +329,13 @@ export function Quote(props: QuoteProps) {
|
|
|
329
329
|
const timeWarning =
|
|
330
330
|
totalDurationSeconds / SECONDS_IN_MINUTE >= ROUTE_TIME_MAX;
|
|
331
331
|
|
|
332
|
+
const lastStep = steps[numberOfSteps - 1];
|
|
333
|
+
const firstStep = steps[0];
|
|
334
|
+
|
|
335
|
+
if (!firstStep || !lastStep) {
|
|
336
|
+
return null;
|
|
337
|
+
}
|
|
338
|
+
|
|
332
339
|
return fullExpandedMode ? (
|
|
333
340
|
<FullExpandedQuote
|
|
334
341
|
selected={selected}
|
|
@@ -427,7 +434,7 @@ export function Quote(props: QuoteProps) {
|
|
|
427
434
|
</FrameIcon>
|
|
428
435
|
<ContainerInfoOutput>
|
|
429
436
|
<BasicInfoOutput size="small" variant="body">
|
|
430
|
-
{`${roundedInput} ${
|
|
437
|
+
{`${roundedInput} ${firstStep.from.token.displayName} = `}
|
|
431
438
|
</BasicInfoOutput>
|
|
432
439
|
<NumericTooltip
|
|
433
440
|
content={output.value}
|
|
@@ -435,9 +442,7 @@ export function Quote(props: QuoteProps) {
|
|
|
435
442
|
open={!output.value ? false : undefined}>
|
|
436
443
|
<BasicInfoOutput size="small" variant="body">
|
|
437
444
|
|
|
438
|
-
{`${roundedOutput} ${
|
|
439
|
-
steps[steps.length - 1].to.token.displayName
|
|
440
|
-
}`}
|
|
445
|
+
{`${roundedOutput} ${lastStep.to.token.displayName}`}
|
|
441
446
|
</BasicInfoOutput>
|
|
442
447
|
</NumericTooltip>
|
|
443
448
|
</ContainerInfoOutput>
|
|
@@ -462,10 +467,10 @@ export function Quote(props: QuoteProps) {
|
|
|
462
467
|
realUsdValue: output.usdValue,
|
|
463
468
|
}}
|
|
464
469
|
token={{
|
|
465
|
-
displayName:
|
|
466
|
-
image:
|
|
470
|
+
displayName: lastStep.to.token.displayName,
|
|
471
|
+
image: lastStep.to.token.image,
|
|
467
472
|
}}
|
|
468
|
-
chain={{ image:
|
|
473
|
+
chain={{ image: lastStep.to.chain.image }}
|
|
469
474
|
percentageChange={percentageChange}
|
|
470
475
|
warningLevel={priceImpactWarningLevel}
|
|
471
476
|
/>
|
|
@@ -473,8 +478,8 @@ export function Quote(props: QuoteProps) {
|
|
|
473
478
|
{type === 'swap-preview' && (
|
|
474
479
|
<>
|
|
475
480
|
<QuoteSummary
|
|
476
|
-
from={
|
|
477
|
-
to={
|
|
481
|
+
from={firstStep.from}
|
|
482
|
+
to={lastStep.to}
|
|
478
483
|
percentageChange={percentageChange}
|
|
479
484
|
warningLevel={priceImpactWarningLevel}
|
|
480
485
|
/>
|
|
@@ -30,8 +30,8 @@ export const getSteps = ({
|
|
|
30
30
|
const amountToConvert =
|
|
31
31
|
index === 0
|
|
32
32
|
? swap.inputAmount
|
|
33
|
-
: swap.steps[index - 1]
|
|
34
|
-
swap.steps[index - 1]
|
|
33
|
+
: swap.steps[index - 1]?.outputAmount ||
|
|
34
|
+
swap.steps[index - 1]?.expectedOutputAmountHumanReadable;
|
|
35
35
|
return {
|
|
36
36
|
from: {
|
|
37
37
|
token: { displayName: step.fromSymbol, image: step.fromLogo ?? '' },
|
|
@@ -207,7 +207,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
207
207
|
const numberOfSteps = steps.length;
|
|
208
208
|
const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
|
|
209
209
|
const outputAmount =
|
|
210
|
-
lastStep
|
|
210
|
+
lastStep?.outputAmount || lastStep?.expectedOutputAmountHumanReadable;
|
|
211
211
|
|
|
212
212
|
const totalFee = swap.steps.reduce(
|
|
213
213
|
(totalFee, steps) => totalFee + parseFloat(steps.feeInUsd || ''),
|
|
@@ -219,13 +219,13 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
219
219
|
)?.diagnosisUrl;
|
|
220
220
|
|
|
221
221
|
const outputUsdValue = numberToString(
|
|
222
|
-
parseFloat(outputAmount || '0') * (lastStep
|
|
222
|
+
parseFloat(outputAmount || '0') * (lastStep?.toUsdPrice || 0),
|
|
223
223
|
USD_VALUE_MIN_DECIMALS,
|
|
224
224
|
USD_VALUE_MAX_DECIMALS
|
|
225
225
|
);
|
|
226
226
|
|
|
227
227
|
const inputUsdValue = numberToString(
|
|
228
|
-
parseFloat(swap.inputAmount) * (firstStep
|
|
228
|
+
parseFloat(swap.inputAmount) * (firstStep?.fromUsdPrice || 0),
|
|
229
229
|
USD_VALUE_MIN_DECIMALS,
|
|
230
230
|
USD_VALUE_MAX_DECIMALS
|
|
231
231
|
);
|
|
@@ -237,7 +237,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
237
237
|
: '';
|
|
238
238
|
|
|
239
239
|
const realInputUsdValue = new BigNumber(swap.inputAmount)
|
|
240
|
-
.multipliedBy(firstStep
|
|
240
|
+
.multipliedBy(firstStep?.fromUsdPrice || 0)
|
|
241
241
|
.toString();
|
|
242
242
|
|
|
243
243
|
const percentageChange = getPriceImpact(inputUsdValue, outputUsdValue);
|
|
@@ -255,12 +255,12 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
255
255
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
256
256
|
TOKEN_AMOUNT_MAX_DECIMALS
|
|
257
257
|
),
|
|
258
|
-
token: steps[numberOfSteps - 1]
|
|
258
|
+
token: steps[numberOfSteps - 1]?.to.token.displayName,
|
|
259
259
|
conciseAddress: getConciseAddress(
|
|
260
|
-
swap.wallets[steps[numberOfSteps - 1]
|
|
260
|
+
swap.wallets[steps[numberOfSteps - 1]?.to.chain.displayName || '']
|
|
261
261
|
?.address || ''
|
|
262
262
|
),
|
|
263
|
-
chain: steps[numberOfSteps - 1]
|
|
263
|
+
chain: steps[numberOfSteps - 1]?.to.chain.displayName,
|
|
264
264
|
},
|
|
265
265
|
})
|
|
266
266
|
) : (
|
|
@@ -442,12 +442,12 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
442
442
|
realValue: swap.inputAmount,
|
|
443
443
|
},
|
|
444
444
|
token: {
|
|
445
|
-
displayName: steps[0]
|
|
446
|
-
image: steps[0]
|
|
445
|
+
displayName: steps[0]?.from.token.displayName || '',
|
|
446
|
+
image: steps[0]?.from.token.image,
|
|
447
447
|
},
|
|
448
448
|
chain: {
|
|
449
|
-
image: steps[0]
|
|
450
|
-
displayName: steps[0]
|
|
449
|
+
image: steps[0]?.from.chain.image,
|
|
450
|
+
displayName: steps[0]?.from.chain.displayName || '',
|
|
451
451
|
},
|
|
452
452
|
}}
|
|
453
453
|
to={{
|
|
@@ -462,12 +462,14 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
462
462
|
realValue: outputAmount || '',
|
|
463
463
|
},
|
|
464
464
|
token: {
|
|
465
|
-
displayName:
|
|
466
|
-
|
|
465
|
+
displayName:
|
|
466
|
+
steps[numberOfSteps - 1]?.to.token.displayName || '',
|
|
467
|
+
image: steps[numberOfSteps - 1]?.to.token.image,
|
|
467
468
|
},
|
|
468
469
|
chain: {
|
|
469
|
-
image: steps[numberOfSteps - 1]
|
|
470
|
-
displayName:
|
|
470
|
+
image: steps[numberOfSteps - 1]?.to.chain.image,
|
|
471
|
+
displayName:
|
|
472
|
+
steps[numberOfSteps - 1]?.to.chain.displayName || '',
|
|
471
473
|
},
|
|
472
474
|
}}
|
|
473
475
|
percentageChange={numberToString(
|
|
@@ -487,7 +489,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
487
489
|
<StepsList>
|
|
488
490
|
{steps.map((step, index) => {
|
|
489
491
|
const key = index;
|
|
490
|
-
const state = getStepState(swap.steps[index]);
|
|
492
|
+
const state = swap.steps[index] && getStepState(swap.steps[index]);
|
|
491
493
|
const isFocused =
|
|
492
494
|
state === 'error' ||
|
|
493
495
|
state === 'in-progress' ||
|
|
@@ -541,10 +543,10 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
541
543
|
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
542
544
|
)}
|
|
543
545
|
token={{
|
|
544
|
-
displayName: steps[numberOfSteps - 1]
|
|
545
|
-
image: steps[numberOfSteps - 1]
|
|
546
|
+
displayName: steps[numberOfSteps - 1]?.to.token.displayName || '',
|
|
547
|
+
image: steps[numberOfSteps - 1]?.to.token.image,
|
|
546
548
|
}}
|
|
547
|
-
chain={{ image: steps[numberOfSteps - 1]
|
|
549
|
+
chain={{ image: steps[numberOfSteps - 1]?.to.chain.image }}
|
|
548
550
|
description={completeModalDesc}
|
|
549
551
|
/>
|
|
550
552
|
</Layout>
|
|
@@ -52,9 +52,9 @@ export function SwapMetrics(props: PropTypes) {
|
|
|
52
52
|
: null,
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const sourceToken = quote?.swaps[0]
|
|
55
|
+
const sourceToken = quote?.swaps[0]?.from || initialFromToken;
|
|
56
56
|
const destinationToken =
|
|
57
|
-
quote?.swaps[quote?.swaps.length - 1]
|
|
57
|
+
quote?.swaps[quote?.swaps.length - 1]?.to || initialToToken;
|
|
58
58
|
|
|
59
59
|
const fromToken = isDefaultRate ? sourceToken : destinationToken;
|
|
60
60
|
const toToken = isDefaultRate ? destinationToken : sourceToken;
|
|
@@ -219,9 +219,8 @@ export function TokenList(props: PropTypes) {
|
|
|
219
219
|
/>
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
|
-
const address = token.address || '';
|
|
223
222
|
const blockchain = blockchains.find(
|
|
224
|
-
(blockchain) => blockchain.name === token
|
|
223
|
+
(blockchain) => blockchain.name === token?.blockchain
|
|
225
224
|
);
|
|
226
225
|
|
|
227
226
|
/**
|
|
@@ -229,10 +228,12 @@ export function TokenList(props: PropTypes) {
|
|
|
229
228
|
* Be cautious, as Virtuoso warns us if we return empty elements.
|
|
230
229
|
* If you need to exclude any items, do so before passing them to the virtual list.
|
|
231
230
|
*/
|
|
232
|
-
if (!blockchain) {
|
|
231
|
+
if (!blockchain || !token) {
|
|
233
232
|
return null;
|
|
234
233
|
}
|
|
235
234
|
|
|
235
|
+
const address = token.address;
|
|
236
|
+
|
|
236
237
|
const colors = createTintsAndShades(blockchain.color, 'main');
|
|
237
238
|
const customCssForTag = {
|
|
238
239
|
$$color: colors.main150,
|
|
@@ -260,11 +261,11 @@ export function TokenList(props: PropTypes) {
|
|
|
260
261
|
<ListItemContainer>
|
|
261
262
|
<StyledListItemButton
|
|
262
263
|
tab-index={index}
|
|
263
|
-
key={`${token.symbol}${
|
|
264
|
-
id={`${token.symbol}${
|
|
264
|
+
key={`${token.symbol}${address}`}
|
|
265
|
+
id={`${token.symbol}${address}`}
|
|
265
266
|
className="widget-token-list-item-btn"
|
|
266
267
|
hasDivider
|
|
267
|
-
customToken={token
|
|
268
|
+
customToken={token?.customToken}
|
|
268
269
|
onClick={handleClick}
|
|
269
270
|
start={
|
|
270
271
|
<ImageSection>
|
|
@@ -277,6 +278,7 @@ export function TokenList(props: PropTypes) {
|
|
|
277
278
|
size={30}
|
|
278
279
|
/>
|
|
279
280
|
{props.type !== 'custom-token' &&
|
|
281
|
+
token &&
|
|
280
282
|
isTokenPinned(token, props.type) && (
|
|
281
283
|
<Pin>
|
|
282
284
|
<PinIcon size={12} color="gray" />
|
|
@@ -285,7 +287,7 @@ export function TokenList(props: PropTypes) {
|
|
|
285
287
|
</ImageSection>
|
|
286
288
|
}
|
|
287
289
|
title={
|
|
288
|
-
blockchain
|
|
290
|
+
blockchain.type === 'COSMOS' ||
|
|
289
291
|
!!token.name ||
|
|
290
292
|
(!token.name && !address) ? (
|
|
291
293
|
<Title>
|
|
@@ -312,7 +314,7 @@ export function TokenList(props: PropTypes) {
|
|
|
312
314
|
}
|
|
313
315
|
description={
|
|
314
316
|
typeof token !== 'string' &&
|
|
315
|
-
!!blockchain
|
|
317
|
+
!!blockchain.info &&
|
|
316
318
|
!!address &&
|
|
317
319
|
blockchain.type !== 'COSMOS'
|
|
318
320
|
? renderDesc({
|
|
@@ -32,17 +32,20 @@ type TagCSS = {
|
|
|
32
32
|
[x: string]:
|
|
33
33
|
| string
|
|
34
34
|
| {
|
|
35
|
-
$$color
|
|
36
|
-
}
|
|
37
|
-
|
|
35
|
+
$$color?: string;
|
|
36
|
+
}
|
|
37
|
+
| undefined;
|
|
38
|
+
$$color?: string;
|
|
38
39
|
backgroundColor: string;
|
|
39
40
|
};
|
|
41
|
+
|
|
40
42
|
type TitleCSS = {
|
|
41
43
|
[x: string]:
|
|
42
44
|
| string
|
|
43
45
|
| {
|
|
44
|
-
$$color
|
|
45
|
-
}
|
|
46
|
-
|
|
46
|
+
$$color?: string;
|
|
47
|
+
}
|
|
48
|
+
| undefined;
|
|
49
|
+
$$color?: string;
|
|
47
50
|
color: string;
|
|
48
51
|
};
|
|
@@ -13,7 +13,7 @@ export function getDerivationPaths(
|
|
|
13
13
|
selectedNamespace?: Namespace
|
|
14
14
|
): DerivationPath[] {
|
|
15
15
|
const selectedNamespaceDerivationPaths = selectedNamespace
|
|
16
|
-
? namespaces[selectedNamespace]
|
|
16
|
+
? namespaces[selectedNamespace]?.derivationPaths
|
|
17
17
|
: null;
|
|
18
18
|
|
|
19
19
|
const derivationPaths: DerivationPath[] = !!selectedNamespaceDerivationPaths
|
|
@@ -44,8 +44,11 @@ export function throwErrorIfResponseIsNotValid(response: QuoteResponse) {
|
|
|
44
44
|
export function getQuoteError(swaps: SwapResult[]): QuoteErrorResponse | null {
|
|
45
45
|
const limitError = hasLimitError(swaps);
|
|
46
46
|
if (limitError) {
|
|
47
|
-
const { swap,
|
|
47
|
+
const { swap, fromAmountRangeError, recommendation } =
|
|
48
48
|
getLimitErrorMessage(swaps);
|
|
49
|
+
if (!swap) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
49
52
|
return {
|
|
50
53
|
message: 'bridge limit error',
|
|
51
54
|
options: {
|
|
@@ -54,7 +54,7 @@ export function prepare(
|
|
|
54
54
|
|
|
55
55
|
preferredBlockchainsWithoutMainList =
|
|
56
56
|
preferredBlockchainsWithoutMainList.filter((preferredBlockchain) => {
|
|
57
|
-
return blockchain
|
|
57
|
+
return blockchain?.name !== preferredBlockchain;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -122,7 +122,7 @@ export function useStatefulConnect(): UseStatefulConnect {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// 3. Target wallet contains only one namespace
|
|
125
|
-
if (needsNamespace?.data.length === 1) {
|
|
125
|
+
if (needsNamespace?.data.length === 1 && needsNamespace.data[0]) {
|
|
126
126
|
if (needsDerivationPath) {
|
|
127
127
|
const namespace = needsNamespace.data[0];
|
|
128
128
|
|
|
@@ -3,9 +3,11 @@ import type { Asset, BlockchainMeta, Token } from 'rango-sdk';
|
|
|
3
3
|
export function convertTokenSearchParamToAsset(
|
|
4
4
|
searchParam: string,
|
|
5
5
|
chain: BlockchainMeta
|
|
6
|
-
): Asset {
|
|
6
|
+
): Asset | null {
|
|
7
7
|
const symbolAndAddress = searchParam.split('--');
|
|
8
|
-
|
|
8
|
+
if (!symbolAndAddress[0]) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
9
11
|
return {
|
|
10
12
|
blockchain: chain.name,
|
|
11
13
|
address: symbolAndAddress?.[1] || null,
|
|
@@ -131,25 +131,22 @@ export function useSyncUrlAndStore() {
|
|
|
131
131
|
(blockchain) => blockchain.name === searchParams.fromBlockchain
|
|
132
132
|
);
|
|
133
133
|
|
|
134
|
-
const
|
|
135
|
-
searchParams.fromToken &&
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
)
|
|
142
|
-
: undefined;
|
|
134
|
+
const convertFromToken =
|
|
135
|
+
searchParams.fromToken &&
|
|
136
|
+
fromBlockchain &&
|
|
137
|
+
convertTokenSearchParamToAsset(searchParams.fromToken, fromBlockchain);
|
|
138
|
+
const fromToken = convertFromToken
|
|
139
|
+
? findToken(convertFromToken)
|
|
140
|
+
: undefined;
|
|
143
141
|
const toBlockchain = blockchains.find(
|
|
144
142
|
(blockchain) => blockchain.name === searchParams.toBlockchain
|
|
145
143
|
);
|
|
144
|
+
const convertToToken =
|
|
145
|
+
searchParams.toToken &&
|
|
146
|
+
toBlockchain &&
|
|
147
|
+
convertTokenSearchParamToAsset(searchParams.toToken, toBlockchain);
|
|
146
148
|
|
|
147
|
-
const toToken =
|
|
148
|
-
searchParams.toToken && toBlockchain
|
|
149
|
-
? findToken(
|
|
150
|
-
convertTokenSearchParamToAsset(searchParams.toToken, toBlockchain)
|
|
151
|
-
)
|
|
152
|
-
: undefined;
|
|
149
|
+
const toToken = convertToToken ? findToken(convertToToken) : undefined;
|
|
153
150
|
|
|
154
151
|
if (!!fromBlockchain) {
|
|
155
152
|
setFromBlockchain(fromBlockchain);
|
|
@@ -30,7 +30,9 @@ export const useNotificationStore = createSelectors(
|
|
|
30
30
|
setNotification: (event, route) => {
|
|
31
31
|
const fromStep = route.steps[0];
|
|
32
32
|
const toStep = route.steps[route.steps.length - 1];
|
|
33
|
-
|
|
33
|
+
if (!fromStep || !toStep) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
34
36
|
const notification: Notification = {
|
|
35
37
|
event,
|
|
36
38
|
creationTime: Date.now(),
|
|
@@ -76,7 +76,7 @@ beforeEach(() => {
|
|
|
76
76
|
if (!initData._tokensMapByBlockchainName[token.blockchain]) {
|
|
77
77
|
initData._tokensMapByBlockchainName[token.blockchain] = [];
|
|
78
78
|
}
|
|
79
|
-
initData._tokensMapByBlockchainName[token.blockchain]
|
|
79
|
+
initData._tokensMapByBlockchainName[token.blockchain]?.push(tokenHash);
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const appStore = createAppStore(DEFAULT_CONFIG);
|
|
@@ -104,7 +104,7 @@ describe('check sorting tokens is working correctly in app store', () => {
|
|
|
104
104
|
type: 'source',
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
const firstResult = tokens[0]
|
|
107
|
+
const firstResult = tokens[0]?.symbol;
|
|
108
108
|
expect(firstResult).toBe(rangoToken.symbol);
|
|
109
109
|
});
|
|
110
110
|
|
|
@@ -125,7 +125,7 @@ describe('check sorting tokens is working correctly in app store', () => {
|
|
|
125
125
|
},
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
const firstResult = tokens[0]
|
|
128
|
+
const firstResult = tokens[0]?.symbol;
|
|
129
129
|
expect(firstResult).toBe(rangoToken.symbol);
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -146,7 +146,7 @@ describe('check sorting tokens is working correctly in app store', () => {
|
|
|
146
146
|
type: 'source',
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
const firstResult = tokens[0]
|
|
149
|
+
const firstResult = tokens[0]?.symbol;
|
|
150
150
|
expect(firstResult).toBe(rangoToken.symbol);
|
|
151
151
|
});
|
|
152
152
|
|
|
@@ -191,7 +191,7 @@ describe('check sorting tokens is working correctly in app store', () => {
|
|
|
191
191
|
type: 'source',
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
-
const firstResult = tokens[0]
|
|
194
|
+
const firstResult = tokens[0]?.symbol;
|
|
195
195
|
expect(firstResult).toBe(rangoToken.symbol);
|
|
196
196
|
});
|
|
197
197
|
|
|
@@ -225,8 +225,8 @@ describe('check sorting tokens is working correctly in app store', () => {
|
|
|
225
225
|
},
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
-
const firstResult = tokens[0]
|
|
229
|
-
const secondResult = tokens[1]
|
|
228
|
+
const firstResult = tokens[0]?.symbol;
|
|
229
|
+
const secondResult = tokens[1]?.symbol;
|
|
230
230
|
expect(firstResult).toBe(rangoToken.symbol);
|
|
231
231
|
expect(secondResult).toBe(djangoToken.symbol);
|
|
232
232
|
});
|
|
@@ -261,8 +261,8 @@ describe('check sorting tokens is working correctly in app store', () => {
|
|
|
261
261
|
},
|
|
262
262
|
});
|
|
263
263
|
|
|
264
|
-
const firstResult = tokens[0]
|
|
265
|
-
const secondResult = tokens[1]
|
|
264
|
+
const firstResult = tokens[0]?.symbol;
|
|
265
|
+
const secondResult = tokens[1]?.symbol;
|
|
266
266
|
|
|
267
267
|
const popularTokensCount = tokens.reduce((previousValue, current) => {
|
|
268
268
|
if (current.isPopular) {
|
package/src/store/slices/data.ts
CHANGED
|
@@ -378,7 +378,7 @@ export const createDataSlice: StateCreator<
|
|
|
378
378
|
tokensMapByBlockchainName[token.blockchain] = [];
|
|
379
379
|
}
|
|
380
380
|
tokensMapByTokenHash.set(tokenHash, token);
|
|
381
|
-
tokensMapByBlockchainName[token.blockchain]
|
|
381
|
+
tokensMapByBlockchainName[token.blockchain]?.push(tokenHash);
|
|
382
382
|
});
|
|
383
383
|
|
|
384
384
|
set({
|