@rango-dev/widget-embedded 0.1.10-next.96 → 0.1.10-next.99
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/ChangeSlippageButton.d.ts.map +1 -1
- package/dist/components/RoutesOverview.d.ts +10 -0
- package/dist/components/RoutesOverview.d.ts.map +1 -0
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/components/TokenPreview.d.ts +20 -0
- package/dist/components/TokenPreview.d.ts.map +1 -0
- package/dist/components/warnings/HighSlippageWarning.d.ts.map +1 -1
- package/dist/pages/ConfirmWalletsPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +2 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +344 -97
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +344 -97
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +343 -97
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ChangeSlippageButton.tsx +4 -8
- package/src/components/HeaderButtons.tsx +2 -2
- package/src/components/RoutesOverview.tsx +60 -0
- package/src/components/TokenInfo.tsx +125 -77
- package/src/components/TokenPreview.tsx +175 -0
- package/src/components/warnings/HighSlippageWarning.tsx +4 -7
- package/src/globalStyles.ts +1 -1
- package/src/hooks/useTheme.ts +9 -9
- package/src/languages/en.json +9 -8
- package/src/pages/ConfirmWalletsPage.tsx +53 -6
- package/src/pages/Home.tsx +33 -35
- package/src/pages/SwapDetailsPage.tsx +12 -7
- package/src/pages/WalletsPage.tsx +2 -5
- package/src/store/bestRoute.ts +4 -5
- package/src/utils/swap.ts +12 -1
|
@@ -22,11 +22,12 @@ var reactI18next = require('react-i18next');
|
|
|
22
22
|
var theme = require('@rango-dev/ui/src/theme');
|
|
23
23
|
var providerAll = require('@rango-dev/provider-all');
|
|
24
24
|
var queueManagerReact = require('@rango-dev/queue-manager-react');
|
|
25
|
+
var i18n = require('i18next');
|
|
26
|
+
var i18n__default = _interopDefault(i18n);
|
|
25
27
|
var copy = _interopDefault(require('copy-to-clipboard'));
|
|
26
|
-
var
|
|
28
|
+
var queueManagerRangoPreset = require('@rango-dev/queue-manager-rango-preset');
|
|
27
29
|
var Backend = _interopDefault(require('i18next-http-backend'));
|
|
28
30
|
var LanguageDetector = _interopDefault(require('i18next-browser-languagedetector'));
|
|
29
|
-
var queueManagerRangoPreset = require('@rango-dev/queue-manager-rango-preset');
|
|
30
31
|
|
|
31
32
|
const navigationRoutes = {
|
|
32
33
|
home: '/',
|
|
@@ -413,7 +414,7 @@ function LimitErrorMessage(bestRoute) {
|
|
|
413
414
|
recommendation
|
|
414
415
|
};
|
|
415
416
|
}
|
|
416
|
-
function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, hasLimitError, highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath) {
|
|
417
|
+
function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, hasLimitError, highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputIsZero) {
|
|
417
418
|
if (loadingMetaStatus !== 'success') return {
|
|
418
419
|
title: 'Connect Wallet',
|
|
419
420
|
disabled: true
|
|
@@ -425,6 +426,9 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
|
|
|
425
426
|
if (loading) return {
|
|
426
427
|
title: 'Finding Best Route...',
|
|
427
428
|
disabled: true
|
|
429
|
+
};else if (inputIsZero) return {
|
|
430
|
+
title: 'Enter an amount',
|
|
431
|
+
disabled: true
|
|
428
432
|
};else if (!bestRoute) return {
|
|
429
433
|
title: 'Swap',
|
|
430
434
|
disabled: true
|
|
@@ -634,6 +638,10 @@ function getBalanceWarnings(route, selectedWallets) {
|
|
|
634
638
|
return warningMessage;
|
|
635
639
|
});
|
|
636
640
|
}
|
|
641
|
+
function calcOutputUsdValue(outputAmount, tokenPrice) {
|
|
642
|
+
const amount = !!outputAmount ? new BigNumber__default(outputAmount) : ZERO;
|
|
643
|
+
return amount.multipliedBy(tokenPrice || 0);
|
|
644
|
+
}
|
|
637
645
|
|
|
638
646
|
function searchParamsToToken(tokens, searchParams, chain) {
|
|
639
647
|
if (!chain) return null;
|
|
@@ -890,7 +898,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
890
898
|
let outputUsdValue = ZERO;
|
|
891
899
|
if (!!bestRoute) {
|
|
892
900
|
outputAmount = !!bestRoute.result?.outputAmount ? new BigNumber__default(bestRoute.result?.outputAmount) : null;
|
|
893
|
-
outputUsdValue =
|
|
901
|
+
outputUsdValue = calcOutputUsdValue(bestRoute.result?.outputAmount, getBestRouteToTokenUsdPrice(bestRoute) || state.toToken?.usdPrice);
|
|
894
902
|
}
|
|
895
903
|
return {
|
|
896
904
|
bestRoute,
|
|
@@ -1187,12 +1195,12 @@ function HeaderButtons(props) {
|
|
|
1187
1195
|
} = props;
|
|
1188
1196
|
const navigate = reactRouterDom.useNavigate();
|
|
1189
1197
|
return React__default.createElement(ButtonsContainer, null, React__default.createElement(ui.Tooltip, {
|
|
1190
|
-
content: "
|
|
1198
|
+
content: "Refresh"
|
|
1191
1199
|
}, React__default.createElement(ui.Button, {
|
|
1192
1200
|
variant: "ghost",
|
|
1193
1201
|
onClick: onClickRefresh
|
|
1194
1202
|
}, React__default.createElement(ui.RetryIcon, {
|
|
1195
|
-
size:
|
|
1203
|
+
size: 24
|
|
1196
1204
|
}))), React__default.createElement(ui.Tooltip, {
|
|
1197
1205
|
content: "Transactions History"
|
|
1198
1206
|
}, React__default.createElement(ui.Button, {
|
|
@@ -1246,13 +1254,42 @@ const Box = /*#__PURE__*/ui.styled('div', {
|
|
|
1246
1254
|
});
|
|
1247
1255
|
const Container = /*#__PURE__*/ui.styled('div', {
|
|
1248
1256
|
boxSizing: 'border-box',
|
|
1249
|
-
backgroundColor: '$neutrals300',
|
|
1250
1257
|
borderRadius: '$5',
|
|
1251
|
-
padding: '$8
|
|
1258
|
+
padding: '$8 $16 $16 $16',
|
|
1259
|
+
variants: {
|
|
1260
|
+
type: {
|
|
1261
|
+
filled: {
|
|
1262
|
+
backgroundColor: '$neutrals300'
|
|
1263
|
+
},
|
|
1264
|
+
outlined: {
|
|
1265
|
+
border: '1px solid $neutrals300'
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1269
|
+
defaultVariants: {
|
|
1270
|
+
type: 'filled'
|
|
1271
|
+
},
|
|
1272
|
+
'.head': {
|
|
1273
|
+
display: 'flex',
|
|
1274
|
+
justifyContent: 'space-between',
|
|
1275
|
+
alignItems: 'center',
|
|
1276
|
+
minHeight: '32px'
|
|
1277
|
+
},
|
|
1252
1278
|
'.form': {
|
|
1253
1279
|
display: 'flex',
|
|
1254
1280
|
width: '100%',
|
|
1255
|
-
padding: '$
|
|
1281
|
+
padding: '$2 0',
|
|
1282
|
+
'.selectors': {
|
|
1283
|
+
width: '35%',
|
|
1284
|
+
'._text': {
|
|
1285
|
+
whiteSpace: 'nowrap',
|
|
1286
|
+
overflow: 'hidden',
|
|
1287
|
+
textOverflow: 'ellipsis'
|
|
1288
|
+
}
|
|
1289
|
+
},
|
|
1290
|
+
'.amount': {
|
|
1291
|
+
width: '30%'
|
|
1292
|
+
}
|
|
1256
1293
|
}
|
|
1257
1294
|
});
|
|
1258
1295
|
const StyledImage = /*#__PURE__*/ui.styled('img', {
|
|
@@ -1262,7 +1299,10 @@ const StyledImage = /*#__PURE__*/ui.styled('img', {
|
|
|
1262
1299
|
const Options = /*#__PURE__*/ui.styled('div', {
|
|
1263
1300
|
display: 'flex',
|
|
1264
1301
|
justifyContent: 'flex-end',
|
|
1265
|
-
|
|
1302
|
+
'.balance': {
|
|
1303
|
+
display: 'flex',
|
|
1304
|
+
alignItems: 'center'
|
|
1305
|
+
}
|
|
1266
1306
|
});
|
|
1267
1307
|
const ImagePlaceholder = /*#__PURE__*/ui.styled('span', {
|
|
1268
1308
|
width: '24px',
|
|
@@ -1271,10 +1311,9 @@ const ImagePlaceholder = /*#__PURE__*/ui.styled('span', {
|
|
|
1271
1311
|
borderRadius: '99999px'
|
|
1272
1312
|
});
|
|
1273
1313
|
const OutputContainer = /*#__PURE__*/ui.styled('div', {
|
|
1314
|
+
windth: '100%',
|
|
1274
1315
|
height: '$48',
|
|
1275
1316
|
borderRadius: '$5',
|
|
1276
|
-
flexGrow: 1,
|
|
1277
|
-
width: '70%',
|
|
1278
1317
|
backgroundColor: '$background',
|
|
1279
1318
|
border: '1px solid transparent',
|
|
1280
1319
|
position: 'relative',
|
|
@@ -1314,21 +1353,34 @@ function TokenInfo(props) {
|
|
|
1314
1353
|
color: "error",
|
|
1315
1354
|
size: 24
|
|
1316
1355
|
}), React__default.createElement(ui.AngleDownIcon, null));
|
|
1317
|
-
return React__default.createElement(Box, null, React__default.createElement(
|
|
1318
|
-
|
|
1319
|
-
},
|
|
1356
|
+
return React__default.createElement(Box, null, React__default.createElement(Container, {
|
|
1357
|
+
type: props.type === 'From' ? 'filled' : 'outlined'
|
|
1358
|
+
}, React__default.createElement("div", {
|
|
1359
|
+
className: "head"
|
|
1360
|
+
}, React__default.createElement(ui.Typography, {
|
|
1361
|
+
variant: "body2",
|
|
1362
|
+
color: "neutrals800"
|
|
1363
|
+
}, t(type)), props.type === 'From' ? React__default.createElement(Options, null, React__default.createElement("div", {
|
|
1320
1364
|
className: "balance",
|
|
1321
1365
|
onClick: () => {
|
|
1322
1366
|
if (tokenBalance !== '0') setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
1323
1367
|
}
|
|
1324
|
-
}, React__default.createElement(ui.Button, {
|
|
1325
|
-
variant: "ghost",
|
|
1326
|
-
size: "small"
|
|
1327
1368
|
}, React__default.createElement(ui.Typography, {
|
|
1328
|
-
variant: "
|
|
1329
|
-
|
|
1369
|
+
variant: "body3",
|
|
1370
|
+
color: "neutrals600"
|
|
1371
|
+
}, `${t('Balance')}: ${tokenBalance} ${fromToken?.symbol || ''}`), React__default.createElement(ui.Spacer, {
|
|
1372
|
+
size: 4
|
|
1373
|
+
}), React__default.createElement(ui.Button, {
|
|
1374
|
+
type: "primary",
|
|
1375
|
+
variant: "ghost",
|
|
1376
|
+
size: "compact"
|
|
1377
|
+
}, t('Max')))) : React__default.createElement(ui.Typography, {
|
|
1378
|
+
variant: "caption",
|
|
1379
|
+
color: "neutrals600"
|
|
1380
|
+
}, `$${numberToString(props.outputUsdValue)}`)), React__default.createElement("div", {
|
|
1330
1381
|
className: "form"
|
|
1331
1382
|
}, React__default.createElement(ui.Button, {
|
|
1383
|
+
className: "selectors",
|
|
1332
1384
|
onClick: () => {
|
|
1333
1385
|
navigate(`/${props.type.toLowerCase()}-chain`);
|
|
1334
1386
|
},
|
|
@@ -1340,11 +1392,11 @@ function TokenInfo(props) {
|
|
|
1340
1392
|
}) : React__default.createElement(ImagePlaceholder, null),
|
|
1341
1393
|
suffix: ItemSuffix,
|
|
1342
1394
|
align: "start",
|
|
1343
|
-
size: "large"
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1395
|
+
size: "large"
|
|
1396
|
+
}, loadingStatus === 'success' && chain ? chain.displayName : t('Chain')), React__default.createElement(ui.Spacer, {
|
|
1397
|
+
size: 12
|
|
1398
|
+
}), React__default.createElement(ui.Button, {
|
|
1399
|
+
className: "selectors",
|
|
1348
1400
|
onClick: () => {
|
|
1349
1401
|
navigate(`/${props.type.toLowerCase()}-token`);
|
|
1350
1402
|
},
|
|
@@ -1356,17 +1408,17 @@ function TokenInfo(props) {
|
|
|
1356
1408
|
}) : React__default.createElement(ImagePlaceholder, null),
|
|
1357
1409
|
suffix: ItemSuffix,
|
|
1358
1410
|
size: "large",
|
|
1359
|
-
align: "start"
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1411
|
+
align: "start"
|
|
1412
|
+
}, loadingStatus === 'success' && token ? token.symbol : t('Token')), React__default.createElement(ui.Spacer, {
|
|
1413
|
+
size: 12
|
|
1414
|
+
}), React__default.createElement("div", {
|
|
1415
|
+
className: "amount"
|
|
1416
|
+
}, props.type === 'From' ? React__default.createElement(ui.TextField, {
|
|
1364
1417
|
type: "number",
|
|
1365
1418
|
size: "large",
|
|
1366
1419
|
autoFocus: true,
|
|
1367
1420
|
placeholder: "0",
|
|
1368
1421
|
style: {
|
|
1369
|
-
width: '70%',
|
|
1370
1422
|
position: 'relative',
|
|
1371
1423
|
backgroundColor: '$background !important'
|
|
1372
1424
|
},
|
|
@@ -1377,23 +1429,16 @@ function TokenInfo(props) {
|
|
|
1377
1429
|
bottom: '2px'
|
|
1378
1430
|
}
|
|
1379
1431
|
}, React__default.createElement(ui.Typography, {
|
|
1380
|
-
variant: "caption"
|
|
1432
|
+
variant: "caption",
|
|
1433
|
+
color: "neutrals800"
|
|
1381
1434
|
}, `$${numberToString(inputUsdValue)}`)),
|
|
1382
1435
|
value: props.inputAmount || '',
|
|
1383
1436
|
onChange: props.type === 'From' ? event => {
|
|
1384
1437
|
props.onAmountChange(event.target.value);
|
|
1385
1438
|
} : undefined
|
|
1386
1439
|
}) : React__default.createElement(OutputContainer, null, React__default.createElement(ui.Typography, {
|
|
1387
|
-
variant: "
|
|
1388
|
-
}, bestRoute ? `≈ ${numberToString(props.outputAmount)}` : inputAmount ? '?' : '0')
|
|
1389
|
-
style: {
|
|
1390
|
-
position: 'absolute',
|
|
1391
|
-
right: '4px',
|
|
1392
|
-
bottom: '2px'
|
|
1393
|
-
}
|
|
1394
|
-
}, React__default.createElement(ui.Typography, {
|
|
1395
|
-
variant: "caption"
|
|
1396
|
-
}, `$${numberToString(props.outputUsdValue)}`))))));
|
|
1440
|
+
variant: "h4"
|
|
1441
|
+
}, bestRoute ? `≈ ${numberToString(props.outputAmount)}` : inputAmount ? '?' : '0'))))));
|
|
1397
1442
|
}
|
|
1398
1443
|
|
|
1399
1444
|
const Container$1 = /*#__PURE__*/theme.styled('div', {
|
|
@@ -1491,16 +1536,17 @@ const errorMessages = {
|
|
|
1491
1536
|
|
|
1492
1537
|
const Container$2 = /*#__PURE__*/ui.styled('div', {
|
|
1493
1538
|
display: 'flex',
|
|
1494
|
-
flexDirection: 'column'
|
|
1495
|
-
justifyContent: 'center',
|
|
1496
|
-
alignItems: 'center'
|
|
1539
|
+
flexDirection: 'column'
|
|
1497
1540
|
});
|
|
1498
|
-
const
|
|
1499
|
-
display: 'flex',
|
|
1500
|
-
justifyContent: 'center',
|
|
1501
|
-
alignItems: 'center',
|
|
1541
|
+
const FromContainer = /*#__PURE__*/ui.styled('div', {
|
|
1502
1542
|
position: 'relative',
|
|
1503
|
-
|
|
1543
|
+
paddingBottom: '$12'
|
|
1544
|
+
});
|
|
1545
|
+
const SwitchButtonContainer = /*#__PURE__*/ui.styled('div', {
|
|
1546
|
+
position: 'absolute',
|
|
1547
|
+
bottom: '-12px',
|
|
1548
|
+
left: '50%',
|
|
1549
|
+
transform: 'translate(-50%, 10%)'
|
|
1504
1550
|
});
|
|
1505
1551
|
const BestRouteContainer = /*#__PURE__*/ui.styled('div', {
|
|
1506
1552
|
width: '100%',
|
|
@@ -1516,7 +1562,6 @@ function Home(props) {
|
|
|
1516
1562
|
titleSize = 18,
|
|
1517
1563
|
titleWeight = 600
|
|
1518
1564
|
} = props;
|
|
1519
|
-
const waningMessage = '';
|
|
1520
1565
|
const isRouterInContext = reactRouterDom.useInRouterContext();
|
|
1521
1566
|
const navigate = reactRouterDom.useNavigate();
|
|
1522
1567
|
const [count, setCount] = React.useState(0);
|
|
@@ -1558,7 +1603,8 @@ function Home(props) {
|
|
|
1558
1603
|
swap
|
|
1559
1604
|
} = LimitErrorMessage(bestRoute);
|
|
1560
1605
|
const priceImpactCanNotBeComputed = !canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue);
|
|
1561
|
-
const
|
|
1606
|
+
const inputIsZero = inputAmount === '0';
|
|
1607
|
+
const swapButtonState = getSwapButtonState(loadingMetaStatus, accounts, fetchingBestRoute, bestRoute, hasLimitError(bestRoute), highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputIsZero);
|
|
1562
1608
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
1563
1609
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
1564
1610
|
return React__default.createElement(Container$2, null, React__default.createElement(Header, {
|
|
@@ -1566,7 +1612,7 @@ function Home(props) {
|
|
|
1566
1612
|
titleSize: titleSize,
|
|
1567
1613
|
titleWeight: titleWeight,
|
|
1568
1614
|
onClickRefresh: fetchBestRoute
|
|
1569
|
-
}), React__default.createElement(TokenInfo, {
|
|
1615
|
+
}), React__default.createElement(FromContainer, null, React__default.createElement(TokenInfo, {
|
|
1570
1616
|
type: "From",
|
|
1571
1617
|
chain: fromChain,
|
|
1572
1618
|
token: fromToken,
|
|
@@ -1576,14 +1622,14 @@ function Home(props) {
|
|
|
1576
1622
|
variant: "ghost",
|
|
1577
1623
|
onClick: swithFromAndTo
|
|
1578
1624
|
}, React__default.createElement(ui.VerticalSwapIcon, {
|
|
1579
|
-
size:
|
|
1625
|
+
size: 24
|
|
1580
1626
|
}), isRouterInContext && React__default.createElement(SwithFromAndTo, {
|
|
1581
1627
|
count: count
|
|
1582
|
-
}))), React__default.createElement(TokenInfo, {
|
|
1628
|
+
})))), React__default.createElement(TokenInfo, {
|
|
1583
1629
|
type: "To",
|
|
1584
1630
|
chain: toChain,
|
|
1585
1631
|
token: toToken,
|
|
1586
|
-
outputAmount: outputAmount,
|
|
1632
|
+
outputAmount: outputAmount ? new BigNumber__default(outputAmount) : new BigNumber__default(0),
|
|
1587
1633
|
outputUsdValue: outputUsdValue
|
|
1588
1634
|
}), showBestRoute && React__default.createElement(BestRouteContainer, null, React__default.createElement(ui.BestRoute, {
|
|
1589
1635
|
error: bestRouteError,
|
|
@@ -1592,11 +1638,9 @@ function Home(props) {
|
|
|
1592
1638
|
totalFee: numberToString(totalFeeInUsd, 0, 2),
|
|
1593
1639
|
feeWarning: highFee,
|
|
1594
1640
|
totalTime: secondsToString(totalArrivalTime(bestRoute))
|
|
1595
|
-
})), (errorMessage ||
|
|
1641
|
+
})), (errorMessage || hasLimitError(bestRoute)) && React__default.createElement(Alerts, null, errorMessage && React__default.createElement(ui.Alert, {
|
|
1596
1642
|
type: "error"
|
|
1597
|
-
}, React__default.createElement(ui.
|
|
1598
|
-
variant: "body2"
|
|
1599
|
-
}, errorMessage)), hasLimitError(bestRoute) && React__default.createElement(ui.Alert, {
|
|
1643
|
+
}, errorMessage), hasLimitError(bestRoute) && React__default.createElement(ui.Alert, {
|
|
1600
1644
|
type: "error",
|
|
1601
1645
|
title: `${swap?.swapperId} Limit`
|
|
1602
1646
|
}, React__default.createElement(React__default.Fragment, null, React__default.createElement(ui.Typography, {
|
|
@@ -1605,7 +1649,7 @@ function Home(props) {
|
|
|
1605
1649
|
variant: "body2"
|
|
1606
1650
|
}, "Yours: ", numberToString(swap?.fromAmount || null), swap?.from.symbol), React__default.createElement("br", null), React__default.createElement(ui.Typography, {
|
|
1607
1651
|
variant: "body2"
|
|
1608
|
-
}, recommendation)))
|
|
1652
|
+
}, recommendation)))), React__default.createElement(Footer, null, React__default.createElement(ui.Button, {
|
|
1609
1653
|
type: "primary",
|
|
1610
1654
|
align: "grow",
|
|
1611
1655
|
size: "large",
|
|
@@ -1647,14 +1691,11 @@ function AppRouter(_ref2) {
|
|
|
1647
1691
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(Router, Object.assign({}, props), children), isRouterInContext && React__default.createElement(UpdateUrl, null));
|
|
1648
1692
|
}
|
|
1649
1693
|
|
|
1650
|
-
const StyledButton = /*#__PURE__*/ui.styled(ui.Button, {
|
|
1651
|
-
marginTop: '$8'
|
|
1652
|
-
});
|
|
1653
1694
|
function ChangeSlippageButton() {
|
|
1654
1695
|
const navigate = reactRouterDom.useNavigate();
|
|
1655
|
-
return React__default.createElement(
|
|
1696
|
+
return React__default.createElement(ui.Button, {
|
|
1656
1697
|
type: "primary",
|
|
1657
|
-
variant: "
|
|
1698
|
+
variant: "outlined",
|
|
1658
1699
|
size: "small",
|
|
1659
1700
|
onClick: () => navigate(navigationRoutes.settings)
|
|
1660
1701
|
}, "Change Slippage");
|
|
@@ -1665,10 +1706,9 @@ function HighSlippageWarning(props) {
|
|
|
1665
1706
|
selectedSlippage
|
|
1666
1707
|
} = props;
|
|
1667
1708
|
return React__default.createElement(ui.Alert, {
|
|
1668
|
-
type: "warning"
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
}, "Caution, your slippage is high (=", selectedSlippage, "). Your trade may be front run.", React__default.createElement(ChangeSlippageButton, null)));
|
|
1709
|
+
type: "warning",
|
|
1710
|
+
footer: React__default.createElement(ChangeSlippageButton, null)
|
|
1711
|
+
}, "Caution, your slippage is high (=", selectedSlippage, "). Your trade may be front run.");
|
|
1672
1712
|
}
|
|
1673
1713
|
|
|
1674
1714
|
function ConfirmSwapExtraMessages(props) {
|
|
@@ -2196,7 +2236,7 @@ const ListContainer = /*#__PURE__*/ui.styled('div', {
|
|
|
2196
2236
|
gridTemplateColumns: ' repeat(2, minmax(0, 1fr))',
|
|
2197
2237
|
height: '450px',
|
|
2198
2238
|
alignContent: 'baseline',
|
|
2199
|
-
padding: '0
|
|
2239
|
+
padding: '0.5rem'
|
|
2200
2240
|
});
|
|
2201
2241
|
const AlertContainer = /*#__PURE__*/ui.styled('div', {
|
|
2202
2242
|
paddingBottom: '$16'
|
|
@@ -2249,14 +2289,182 @@ function WalletsPage(_ref) {
|
|
|
2249
2289
|
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2250
2290
|
}, React__default.createElement(React__default.Fragment, null, walletErrorMessage && React__default.createElement(AlertContainer, null, React__default.createElement(ui.Alert, {
|
|
2251
2291
|
type: "error"
|
|
2252
|
-
}, React__default.createElement(ui.
|
|
2253
|
-
variant: "body2"
|
|
2254
|
-
}, walletErrorMessage))), React__default.createElement(ListContainer, null, sortedWallets.map((wallet, index) => React__default.createElement(ui.Wallet, Object.assign({}, wallet, {
|
|
2292
|
+
}, walletErrorMessage)), React__default.createElement(ListContainer, null, sortedWallets.map((wallet, index) => React__default.createElement(ui.Wallet, Object.assign({}, wallet, {
|
|
2255
2293
|
key: `${index}-${wallet.type}`,
|
|
2256
2294
|
onClick: onSelectWallet
|
|
2257
2295
|
}))))));
|
|
2258
2296
|
}
|
|
2259
2297
|
|
|
2298
|
+
const Box$1 = /*#__PURE__*/ui.styled('div', {
|
|
2299
|
+
display: 'flex',
|
|
2300
|
+
flexDirection: 'column',
|
|
2301
|
+
width: '100%'
|
|
2302
|
+
});
|
|
2303
|
+
const Container$3 = /*#__PURE__*/ui.styled('div', {
|
|
2304
|
+
boxSizing: 'border-box',
|
|
2305
|
+
borderRadius: '$5',
|
|
2306
|
+
padding: '$8 $16 $16 $16',
|
|
2307
|
+
variants: {
|
|
2308
|
+
type: {
|
|
2309
|
+
filled: {
|
|
2310
|
+
backgroundColor: '$neutrals300'
|
|
2311
|
+
},
|
|
2312
|
+
outlined: {
|
|
2313
|
+
border: '1px solid $neutrals300'
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
},
|
|
2317
|
+
defaultVariants: {
|
|
2318
|
+
type: 'filled'
|
|
2319
|
+
},
|
|
2320
|
+
'.head': {
|
|
2321
|
+
display: 'flex',
|
|
2322
|
+
justifyContent: 'space-between',
|
|
2323
|
+
alignItems: 'center',
|
|
2324
|
+
minHeight: '32px'
|
|
2325
|
+
},
|
|
2326
|
+
'.form': {
|
|
2327
|
+
display: 'flex',
|
|
2328
|
+
width: '100%',
|
|
2329
|
+
padding: '$2 0',
|
|
2330
|
+
'.selectors': {
|
|
2331
|
+
width: '35%',
|
|
2332
|
+
'._text': {
|
|
2333
|
+
whiteSpace: 'nowrap',
|
|
2334
|
+
overflow: 'hidden',
|
|
2335
|
+
textOverflow: 'ellipsis'
|
|
2336
|
+
}
|
|
2337
|
+
},
|
|
2338
|
+
'.amount': {
|
|
2339
|
+
width: '30%'
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
});
|
|
2343
|
+
const StyledImage$1 = /*#__PURE__*/ui.styled('img', {
|
|
2344
|
+
width: '$24',
|
|
2345
|
+
maxHeight: '$24'
|
|
2346
|
+
});
|
|
2347
|
+
const ImagePlaceholder$1 = /*#__PURE__*/ui.styled('span', {
|
|
2348
|
+
width: '24px',
|
|
2349
|
+
height: '24px',
|
|
2350
|
+
backgroundColor: '$neutrals300',
|
|
2351
|
+
borderRadius: '99999px'
|
|
2352
|
+
});
|
|
2353
|
+
const OutputContainer$1 = /*#__PURE__*/ui.styled('div', {
|
|
2354
|
+
windth: '100%',
|
|
2355
|
+
height: '$48',
|
|
2356
|
+
borderRadius: '$5',
|
|
2357
|
+
backgroundColor: '$background',
|
|
2358
|
+
border: '1px solid transparent',
|
|
2359
|
+
position: 'relative',
|
|
2360
|
+
display: 'flex',
|
|
2361
|
+
alignItems: 'center',
|
|
2362
|
+
paddingLeft: '$8',
|
|
2363
|
+
paddingRight: '$8'
|
|
2364
|
+
});
|
|
2365
|
+
function TokenPreview(props) {
|
|
2366
|
+
const {
|
|
2367
|
+
chain,
|
|
2368
|
+
token,
|
|
2369
|
+
loadingStatus
|
|
2370
|
+
} = props;
|
|
2371
|
+
const {
|
|
2372
|
+
t
|
|
2373
|
+
} = reactI18next.useTranslation();
|
|
2374
|
+
const ItemSuffix = React__default.createElement("div", {
|
|
2375
|
+
style: {
|
|
2376
|
+
display: 'flex',
|
|
2377
|
+
justifyContent: 'center',
|
|
2378
|
+
alignItems: 'center'
|
|
2379
|
+
}
|
|
2380
|
+
}, loadingStatus === 'failed' && React__default.createElement(ui.InfoCircleIcon, {
|
|
2381
|
+
color: "error",
|
|
2382
|
+
size: 24
|
|
2383
|
+
}));
|
|
2384
|
+
return React__default.createElement(Box$1, null, React__default.createElement(Container$3, {
|
|
2385
|
+
type: 'outlined'
|
|
2386
|
+
}, React__default.createElement("div", {
|
|
2387
|
+
className: "head"
|
|
2388
|
+
}, React__default.createElement(ui.Typography, {
|
|
2389
|
+
variant: "body2",
|
|
2390
|
+
color: "neutrals800"
|
|
2391
|
+
}, props.label), React__default.createElement(ui.Typography, {
|
|
2392
|
+
variant: "caption",
|
|
2393
|
+
color: "neutrals600"
|
|
2394
|
+
}, `$${numberToString(props.usdValue)}`)), React__default.createElement("div", {
|
|
2395
|
+
className: "form"
|
|
2396
|
+
}, React__default.createElement(ui.Button, {
|
|
2397
|
+
className: "selectors",
|
|
2398
|
+
variant: "outlined",
|
|
2399
|
+
loading: loadingStatus === 'loading',
|
|
2400
|
+
prefix: loadingStatus === 'success' && chain ? React__default.createElement(StyledImage$1, {
|
|
2401
|
+
src: chain.logo
|
|
2402
|
+
}) : React__default.createElement(ImagePlaceholder$1, null),
|
|
2403
|
+
suffix: ItemSuffix,
|
|
2404
|
+
align: "start",
|
|
2405
|
+
size: "large"
|
|
2406
|
+
}, loadingStatus === 'success' && chain ? chain.displayName : t('Chain')), React__default.createElement(ui.Spacer, {
|
|
2407
|
+
size: 12
|
|
2408
|
+
}), React__default.createElement(ui.Button, {
|
|
2409
|
+
className: "selectors",
|
|
2410
|
+
variant: "outlined",
|
|
2411
|
+
loading: loadingStatus === 'loading',
|
|
2412
|
+
prefix: loadingStatus === 'success' && token ? React__default.createElement(StyledImage$1, {
|
|
2413
|
+
src: token.image
|
|
2414
|
+
}) : React__default.createElement(ImagePlaceholder$1, null),
|
|
2415
|
+
suffix: ItemSuffix,
|
|
2416
|
+
size: "large",
|
|
2417
|
+
align: "start"
|
|
2418
|
+
}, loadingStatus === 'success' && token ? token.symbol : t('Token')), React__default.createElement(ui.Spacer, {
|
|
2419
|
+
size: 12
|
|
2420
|
+
}), React__default.createElement("div", {
|
|
2421
|
+
className: "amount"
|
|
2422
|
+
}, React__default.createElement(OutputContainer$1, null, React__default.createElement(ui.Typography, {
|
|
2423
|
+
variant: "h4"
|
|
2424
|
+
}, props.amount))))));
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
const Container$4 = /*#__PURE__*/ui.styled('div', {
|
|
2428
|
+
display: 'flex',
|
|
2429
|
+
alignItems: 'center',
|
|
2430
|
+
justifyContent: 'space-between',
|
|
2431
|
+
padding: '$8',
|
|
2432
|
+
borderRadius: '$5',
|
|
2433
|
+
backgroundColor: '$neutrals300',
|
|
2434
|
+
color: '$neutrals800',
|
|
2435
|
+
fontSize: '$12',
|
|
2436
|
+
'.routes': {
|
|
2437
|
+
display: 'flex',
|
|
2438
|
+
alignItems: 'center'
|
|
2439
|
+
},
|
|
2440
|
+
'.fee': {
|
|
2441
|
+
display: 'flex',
|
|
2442
|
+
alignItems: 'center'
|
|
2443
|
+
}
|
|
2444
|
+
});
|
|
2445
|
+
function RoutesOverview(props) {
|
|
2446
|
+
if (!props.routes) return null;
|
|
2447
|
+
const swaps = props.routes.result?.swaps;
|
|
2448
|
+
return React__default.createElement(Container$4, null, React__default.createElement("div", {
|
|
2449
|
+
className: "routes"
|
|
2450
|
+
}, swaps?.map((swap, idx) => {
|
|
2451
|
+
const isLast = idx + 1 == swaps.length;
|
|
2452
|
+
return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
2453
|
+
className: "route"
|
|
2454
|
+
}, swap.from.symbol), React__default.createElement(ui.ChevronRightIcon, {
|
|
2455
|
+
size: 12
|
|
2456
|
+
}), isLast ? React__default.createElement("div", {
|
|
2457
|
+
className: "route"
|
|
2458
|
+
}, swap.to.symbol) : null);
|
|
2459
|
+
})), props.totalFee ? React__default.createElement("div", {
|
|
2460
|
+
className: "fee"
|
|
2461
|
+
}, React__default.createElement(ui.GasIcon, {
|
|
2462
|
+
size: 12
|
|
2463
|
+
}), React__default.createElement(ui.Spacer, {
|
|
2464
|
+
size: 4
|
|
2465
|
+
}), "$", props.totalFee) : null);
|
|
2466
|
+
}
|
|
2467
|
+
|
|
2260
2468
|
function ConfirmWalletsPage() {
|
|
2261
2469
|
const navigate = reactRouterDom.useNavigate();
|
|
2262
2470
|
const {
|
|
@@ -2264,7 +2472,8 @@ function ConfirmWalletsPage() {
|
|
|
2264
2472
|
} = useNavigateBack();
|
|
2265
2473
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
2266
2474
|
const {
|
|
2267
|
-
blockchains
|
|
2475
|
+
blockchains,
|
|
2476
|
+
tokens
|
|
2268
2477
|
} = useMetaStore.use.meta();
|
|
2269
2478
|
const accounts = useWalletsStore.use.accounts();
|
|
2270
2479
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
@@ -2287,20 +2496,52 @@ function ConfirmWalletsPage() {
|
|
|
2287
2496
|
const network = wallet;
|
|
2288
2497
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
2289
2498
|
};
|
|
2499
|
+
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2290
2500
|
return React__default.createElement(ui.ConfirmWallets, {
|
|
2291
2501
|
requiredWallets: getRequiredChains(bestRoute),
|
|
2292
2502
|
selectableWallets: selectableWallets,
|
|
2293
2503
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmWallets),
|
|
2294
|
-
swap: bestRoute,
|
|
2295
|
-
fromAmount: fromAmount,
|
|
2296
|
-
toAmount: toAmount,
|
|
2297
2504
|
onConfirm: () => navigate(navigationRoutes.confirmSwap, {
|
|
2298
2505
|
replace: true
|
|
2299
2506
|
}),
|
|
2300
2507
|
onChange: wallet => setSelectedWallet(wallet),
|
|
2301
2508
|
confirmDisabled: confirmDisabled,
|
|
2302
2509
|
handleConnectChain: wallet => handleConnectChain(wallet),
|
|
2303
|
-
isExperimentalChain: wallet => getKeplrCompatibleConnectedWallets(selectableWallets).length > 0 ? isExperimentalChain(blockchains, wallet) : false
|
|
2510
|
+
isExperimentalChain: wallet => getKeplrCompatibleConnectedWallets(selectableWallets).length > 0 ? isExperimentalChain(blockchains, wallet) : false,
|
|
2511
|
+
previewInputs: React__default.createElement(React__default.Fragment, null, React__default.createElement(TokenPreview, {
|
|
2512
|
+
chain: {
|
|
2513
|
+
displayName: firstStep?.from.blockchain || '',
|
|
2514
|
+
logo: firstStep?.from.blockchainLogo || ''
|
|
2515
|
+
},
|
|
2516
|
+
token: {
|
|
2517
|
+
symbol: firstStep?.from.symbol || '',
|
|
2518
|
+
image: firstStep?.from.logo || ''
|
|
2519
|
+
},
|
|
2520
|
+
usdValue: calcOutputUsdValue(fromAmount, firstStep?.from.usdPrice),
|
|
2521
|
+
amount: fromAmount,
|
|
2522
|
+
label: i18n.t('From'),
|
|
2523
|
+
loadingStatus: 'success'
|
|
2524
|
+
}), React__default.createElement(ui.Spacer, {
|
|
2525
|
+
size: 12,
|
|
2526
|
+
direction: "vertical"
|
|
2527
|
+
}), React__default.createElement(TokenPreview, {
|
|
2528
|
+
chain: {
|
|
2529
|
+
displayName: lastStep?.to.blockchain || '',
|
|
2530
|
+
logo: lastStep?.to.blockchainLogo || ''
|
|
2531
|
+
},
|
|
2532
|
+
token: {
|
|
2533
|
+
symbol: lastStep?.to.symbol || '',
|
|
2534
|
+
image: lastStep?.to.logo || ''
|
|
2535
|
+
},
|
|
2536
|
+
usdValue: calcOutputUsdValue(toAmount, lastStep?.to.usdPrice),
|
|
2537
|
+
amount: toAmount,
|
|
2538
|
+
label: i18n.t('To'),
|
|
2539
|
+
loadingStatus: 'success'
|
|
2540
|
+
})),
|
|
2541
|
+
previewRoutes: React__default.createElement(RoutesOverview, {
|
|
2542
|
+
routes: bestRoute,
|
|
2543
|
+
totalFee: numberToString(totalFeeInUsd, 0, 2)
|
|
2544
|
+
})
|
|
2304
2545
|
});
|
|
2305
2546
|
}
|
|
2306
2547
|
|
|
@@ -2337,16 +2578,20 @@ function SwapDetailsPage() {
|
|
|
2337
2578
|
swap
|
|
2338
2579
|
} = _ref;
|
|
2339
2580
|
return swap.requestId === selectedSwapRequestId;
|
|
2340
|
-
})
|
|
2581
|
+
});
|
|
2582
|
+
//TODO: implement swap cancellation (move queueManager logic to queueManager/rango-preset)
|
|
2583
|
+
const onCancel = () => {
|
|
2584
|
+
const swap = selectedSwap ? manager?.get(selectedSwap.id) : undefined;
|
|
2585
|
+
if (swap) queueManagerRangoPreset.cancelSwap(swap);
|
|
2586
|
+
};
|
|
2341
2587
|
return React__default.createElement(ui.SwapHistory, {
|
|
2342
2588
|
onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails),
|
|
2343
2589
|
//todo: move PendingSwap type to rango-types
|
|
2344
2590
|
//@ts-ignore
|
|
2345
|
-
pendingSwap: selectedSwap,
|
|
2591
|
+
pendingSwap: selectedSwap?.swap,
|
|
2346
2592
|
onCopy: handleCopy,
|
|
2347
2593
|
isCopied: isCopied,
|
|
2348
|
-
|
|
2349
|
-
onCancel: requestId => console.log(requestId)
|
|
2594
|
+
onCancel: onCancel
|
|
2350
2595
|
});
|
|
2351
2596
|
}
|
|
2352
2597
|
|
|
@@ -2501,7 +2746,7 @@ const globalStyles = /*#__PURE__*/ui.globalCss({
|
|
|
2501
2746
|
});
|
|
2502
2747
|
const globalFont = fontFamily => ui.globalCss({
|
|
2503
2748
|
'@import': ["url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')", "url('https://fonts.cdnfonts.com/css/times-new-roman')"],
|
|
2504
|
-
|
|
2749
|
+
body: {
|
|
2505
2750
|
fontFamily
|
|
2506
2751
|
}
|
|
2507
2752
|
})();
|
|
@@ -2527,16 +2772,16 @@ function useTheme(_ref) {
|
|
|
2527
2772
|
warning = '#F5A623',
|
|
2528
2773
|
success = '#0070F3',
|
|
2529
2774
|
fontFamily = 'Robot',
|
|
2530
|
-
borderRadius =
|
|
2775
|
+
borderRadius = 8
|
|
2531
2776
|
} = _ref;
|
|
2532
2777
|
const theme = useSettingsStore.use.theme();
|
|
2533
2778
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
2534
2779
|
const colors = {
|
|
2535
2780
|
neutrals200: '#FAFAFA',
|
|
2536
|
-
neutrals300: '#
|
|
2537
|
-
neutrals400: '#
|
|
2538
|
-
neutrals500: '#
|
|
2539
|
-
neutrals600: '#
|
|
2781
|
+
neutrals300: '#f2f2f2',
|
|
2782
|
+
neutrals400: '#dedede',
|
|
2783
|
+
neutrals500: '#cccccc',
|
|
2784
|
+
neutrals600: '#acacac',
|
|
2540
2785
|
neutrals700: '#444444',
|
|
2541
2786
|
neutrals800: '#333333',
|
|
2542
2787
|
neutrals900: '#111111',
|
|
@@ -2580,10 +2825,10 @@ function useTheme(_ref) {
|
|
|
2580
2825
|
neutrals200: '#111111',
|
|
2581
2826
|
neutrals300: '#333333',
|
|
2582
2827
|
neutrals400: '#444444',
|
|
2583
|
-
neutrals500: '#
|
|
2584
|
-
neutrals600: '#
|
|
2585
|
-
neutrals700: '#
|
|
2586
|
-
neutrals800: '#
|
|
2828
|
+
neutrals500: '#acacac',
|
|
2829
|
+
neutrals600: '#cccccc',
|
|
2830
|
+
neutrals700: '#dedede',
|
|
2831
|
+
neutrals800: '#f2f2f2',
|
|
2587
2832
|
neutrals900: '#FAFAFA',
|
|
2588
2833
|
foreground: background,
|
|
2589
2834
|
background: foreground
|
|
@@ -2643,8 +2888,9 @@ function useSelectLanguage() {
|
|
|
2643
2888
|
}
|
|
2644
2889
|
|
|
2645
2890
|
var swap = "SWAP";
|
|
2646
|
-
var From = "
|
|
2647
|
-
var To = "
|
|
2891
|
+
var From = "You sell";
|
|
2892
|
+
var To = "You receive";
|
|
2893
|
+
var Balance = "Balance";
|
|
2648
2894
|
var Max = "Max";
|
|
2649
2895
|
var Chain = "Chain";
|
|
2650
2896
|
var Token = "Token";
|
|
@@ -2656,12 +2902,13 @@ var en = {
|
|
|
2656
2902
|
"Powered By": "Powered By",
|
|
2657
2903
|
From: From,
|
|
2658
2904
|
To: To,
|
|
2905
|
+
Balance: Balance,
|
|
2659
2906
|
Max: Max,
|
|
2660
2907
|
Chain: Chain,
|
|
2661
2908
|
Token: Token,
|
|
2662
2909
|
Source: Source,
|
|
2663
2910
|
Destination: Destination,
|
|
2664
|
-
"Select Wallet": "
|
|
2911
|
+
"Select Wallet": "Connect Your Wallet"
|
|
2665
2912
|
};
|
|
2666
2913
|
|
|
2667
2914
|
var swap$1 = "TAKAS";
|
|
@@ -2683,7 +2930,7 @@ var tr = {
|
|
|
2683
2930
|
};
|
|
2684
2931
|
|
|
2685
2932
|
const languages = ['en', 'tr'];
|
|
2686
|
-
|
|
2933
|
+
i18n__default.use(Backend)
|
|
2687
2934
|
// detect user language
|
|
2688
2935
|
.use(LanguageDetector)
|
|
2689
2936
|
// pass the i18n instance to react-i18next.
|