@rango-dev/widget-embedded 0.1.16-next.0 → 0.1.16-next.10
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/QueueManager.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +2 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +6 -15
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +11 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +7 -0
- package/dist/types/wallets.d.ts.map +1 -0
- package/dist/utils/common.d.ts +0 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +2 -3
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +8 -9
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +11 -12
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +161 -197
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +161 -197
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +162 -198
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +10 -13
- package/src/QueueManager.tsx +4 -6
- package/src/components/AppRoutes.tsx +1 -1
- package/src/components/BottomLogo.tsx +1 -1
- package/src/components/Layout.tsx +27 -23
- package/src/components/RoutesOverview.tsx +2 -2
- package/src/components/TokenInfo.tsx +14 -13
- package/src/components/TokenPreview.tsx +6 -6
- package/src/hooks/useConfirmSwap.ts +2 -2
- package/src/hooks/useTheme.ts +42 -59
- package/src/index.tsx +144 -14
- package/src/pages/ConfirmSwapPage.tsx +27 -19
- package/src/pages/Home.tsx +5 -3
- package/src/pages/SettingsPage.tsx +3 -1
- package/src/store/bestRoute.ts +7 -7
- package/src/store/wallets.ts +32 -46
- package/src/types/config.ts +8 -1
- package/src/types/index.ts +1 -0
- package/src/types/wallets.ts +7 -0
- package/src/utils/common.ts +0 -21
- package/src/utils/routing.ts +2 -3
- package/src/utils/swap.ts +12 -11
- package/src/utils/wallets.ts +60 -63
- package/dist/App.d.ts +0 -9
- package/dist/App.d.ts.map +0 -1
- package/dist/lib.d.ts +0 -10
- package/dist/lib.d.ts.map +0 -1
- package/src/App.tsx +0 -123
- package/src/app.css +0 -12
- package/src/lib.tsx +0 -144
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletState, InfoCircleIcon, Typography, Button, Image, Spacer, styled, ChevronRightIcon, GasIcon, Alert, ConfirmSwap, LoadingFailedAlert, History, AngleDownIcon, TextField, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, Wallet, useCopyToClipboard, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
1
|
+
import { WalletState, InfoCircleIcon, Typography, Button, Image, Spacer, styled, ChevronRightIcon, GasIcon, Alert, ConfirmSwap, LoadingFailedAlert, History, AngleDownIcon, TextField, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, Wallet, useCopyToClipboard, SwapHistory, AddWalletIcon, globalCss, generateRangeColors, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
2
2
|
import React, { useRef, useEffect, Fragment, useState, useLayoutEffect, useMemo } from 'react';
|
|
3
3
|
import { useInRouterContext, MemoryRouter } from 'react-router';
|
|
4
4
|
import { PendingSwapNetworkStatus, useQueueManager, calculatePendingSwap, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap, makeQueueDefinition, checkWaitingForNetworkChange } from '@rango-dev/queue-manager-rango-preset';
|
|
@@ -29,24 +29,6 @@ function removeDuplicateFrom(array) {
|
|
|
29
29
|
function areEqual(array1, array2) {
|
|
30
30
|
return array1.length === array2.length && array1.every((v, i) => v === array2[i]);
|
|
31
31
|
}
|
|
32
|
-
function shadeColor(color, percent) {
|
|
33
|
-
var R = parseInt(color.substring(1, 3), 16);
|
|
34
|
-
var G = parseInt(color.substring(3, 5), 16);
|
|
35
|
-
var B = parseInt(color.substring(5, 7), 16);
|
|
36
|
-
R = R * (100 + percent) / 100;
|
|
37
|
-
G = G * (100 + percent) / 100;
|
|
38
|
-
B = B * (100 + percent) / 100;
|
|
39
|
-
R = R < 255 ? R : 255;
|
|
40
|
-
G = G < 255 ? G : 255;
|
|
41
|
-
B = B < 255 ? B : 255;
|
|
42
|
-
R = Math.round(R);
|
|
43
|
-
G = Math.round(G);
|
|
44
|
-
B = Math.round(B);
|
|
45
|
-
var RR = R.toString(16).length == 1 ? '0' + R.toString(16) : R.toString(16);
|
|
46
|
-
var GG = G.toString(16).length == 1 ? '0' + G.toString(16) : G.toString(16);
|
|
47
|
-
var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
|
|
48
|
-
return '#' + RR + GG + BB;
|
|
49
|
-
}
|
|
50
32
|
function debounce(fn, time) {
|
|
51
33
|
let timeoutId;
|
|
52
34
|
return wrapper;
|
|
@@ -310,8 +292,8 @@ function getStateWallet(state) {
|
|
|
310
292
|
return WalletState.DISCONNECTED;
|
|
311
293
|
}
|
|
312
294
|
}
|
|
295
|
+
const excludedWallets = [WalletType.UNKNOWN, WalletType.LEAP];
|
|
313
296
|
function getlistWallet(getState, getWalletInfo, list) {
|
|
314
|
-
const excludedWallets = [WalletType.UNKNOWN, WalletType.TERRA_STATION, WalletType.LEAP];
|
|
315
297
|
return list.filter(wallet => !excludedWallets.includes(wallet)).map(type => {
|
|
316
298
|
const {
|
|
317
299
|
name,
|
|
@@ -394,27 +376,27 @@ function getRequiredChains(route) {
|
|
|
394
376
|
});
|
|
395
377
|
return wallets;
|
|
396
378
|
}
|
|
397
|
-
function getSelectableWallets(
|
|
398
|
-
const
|
|
399
|
-
address:
|
|
400
|
-
walletType:
|
|
401
|
-
chain:
|
|
402
|
-
image: getWalletInfo(
|
|
403
|
-
name: getWalletInfo(
|
|
404
|
-
selected: !!selectedWallets.find(
|
|
379
|
+
function getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo) {
|
|
380
|
+
const selectableWallets = connectedWallets.map(connectedWallet => ({
|
|
381
|
+
address: connectedWallet.address,
|
|
382
|
+
walletType: connectedWallet.walletType,
|
|
383
|
+
chain: connectedWallet.chain,
|
|
384
|
+
image: getWalletInfo(connectedWallet.walletType).img,
|
|
385
|
+
name: getWalletInfo(connectedWallet.walletType).name,
|
|
386
|
+
selected: !!selectedWallets.find(selectedWallet => selectedWallet.chain === connectedWallet.chain && selectedWallet.walletType === connectedWallet.walletType)
|
|
405
387
|
}));
|
|
406
|
-
return
|
|
388
|
+
return selectableWallets;
|
|
407
389
|
}
|
|
408
|
-
function getBalanceFromWallet(
|
|
409
|
-
if (
|
|
410
|
-
const
|
|
411
|
-
if (
|
|
412
|
-
return
|
|
390
|
+
function getBalanceFromWallet(connectedWallets, chain, symbol, address) {
|
|
391
|
+
if (connectedWallets.length === 0) return null;
|
|
392
|
+
const selectedChainWallets = connectedWallets.filter(wallet => wallet.chain === chain);
|
|
393
|
+
if (selectedChainWallets.length === 0) return null;
|
|
394
|
+
return selectedChainWallets.map(wallet => wallet.balances?.find(balance => address !== null && balance.address === address || address === null && balance.address === address && balance.symbol === symbol) || null).filter(balance => balance !== null).sort((a, b) => parseFloat(b?.amount || '0') - parseFloat(a?.amount || '1')).find(() => true) || null;
|
|
413
395
|
}
|
|
414
|
-
function
|
|
415
|
-
return account.address ===
|
|
396
|
+
function isAccountAndWalletMatched(account, connectedWallet) {
|
|
397
|
+
return account.address === connectedWallet.address && account.chain === connectedWallet.chain && account.walletType === connectedWallet.walletType;
|
|
416
398
|
}
|
|
417
|
-
function makeBalanceFor(
|
|
399
|
+
function makeBalanceFor(wallet, retrivedBalance, tokens) {
|
|
418
400
|
const {
|
|
419
401
|
address,
|
|
420
402
|
blockChain: chain,
|
|
@@ -427,7 +409,7 @@ function makeBalanceFor(account, retrivedBalance, tokens) {
|
|
|
427
409
|
loading: false,
|
|
428
410
|
error: false,
|
|
429
411
|
explorerUrl,
|
|
430
|
-
walletType:
|
|
412
|
+
walletType: wallet.walletType,
|
|
431
413
|
balances: balances?.map(tokenBalance => ({
|
|
432
414
|
chain,
|
|
433
415
|
symbol: tokenBalance.asset.symbol,
|
|
@@ -441,16 +423,16 @@ function makeBalanceFor(account, retrivedBalance, tokens) {
|
|
|
441
423
|
})) || []
|
|
442
424
|
};
|
|
443
425
|
}
|
|
444
|
-
function
|
|
426
|
+
function resetConnectedWalletState(connectedWallet) {
|
|
445
427
|
return {
|
|
446
|
-
...
|
|
428
|
+
...connectedWallet,
|
|
447
429
|
loading: false,
|
|
448
430
|
error: true
|
|
449
431
|
};
|
|
450
432
|
}
|
|
451
|
-
const calculateWalletUsdValue =
|
|
433
|
+
const calculateWalletUsdValue = connectedWallet => {
|
|
452
434
|
const uniqueAccountAddresses = new Set();
|
|
453
|
-
const uniqueBalane =
|
|
435
|
+
const uniqueBalane = connectedWallet?.reduce((acc, current) => {
|
|
454
436
|
return acc.findIndex(i => i.address === current.address && i.chain === current.chain) === -1 ? [...acc, current] : acc;
|
|
455
437
|
}, []);
|
|
456
438
|
const modifiedWalletBlockchains = uniqueBalane?.map(chain => {
|
|
@@ -496,15 +478,15 @@ const getKeplrCompatibleConnectedWallets = selectableWallets => {
|
|
|
496
478
|
const connectedWalletTypes = new Set(selectableWallets.map(a => a.walletType.toString()));
|
|
497
479
|
return KEPLR_COMPATIBLE_WALLETS.filter(compatibleWallet => connectedWalletTypes.has(compatibleWallet));
|
|
498
480
|
};
|
|
499
|
-
function getTokensWithBalance(tokens,
|
|
481
|
+
function getTokensWithBalance(tokens, connectedWallets) {
|
|
500
482
|
return tokens.map(_ref2 => {
|
|
501
483
|
let {
|
|
502
484
|
balance,
|
|
503
485
|
...otherProps
|
|
504
486
|
} = _ref2;
|
|
505
|
-
const tokenAmount = numberToString(new BigNumber(getBalanceFromWallet(
|
|
487
|
+
const tokenAmount = numberToString(new BigNumber(getBalanceFromWallet(connectedWallets, otherProps.blockchain, otherProps.symbol, otherProps.address)?.amount || ZERO));
|
|
506
488
|
let tokenUsdValue = '';
|
|
507
|
-
if (otherProps.usdPrice) tokenUsdValue = numberToString(new BigNumber(getBalanceFromWallet(
|
|
489
|
+
if (otherProps.usdPrice) tokenUsdValue = numberToString(new BigNumber(getBalanceFromWallet(connectedWallets, otherProps.blockchain, otherProps.symbol, otherProps.address)?.amount || ZERO).multipliedBy(otherProps.usdPrice));
|
|
508
490
|
return {
|
|
509
491
|
...otherProps,
|
|
510
492
|
...(tokenAmount !== '0' && {
|
|
@@ -516,11 +498,11 @@ function getTokensWithBalance(tokens, balances) {
|
|
|
516
498
|
};
|
|
517
499
|
});
|
|
518
500
|
}
|
|
519
|
-
function getSortedTokens(chain, tokens,
|
|
501
|
+
function getSortedTokens(chain, tokens, connectedWallets, otherChainTokens) {
|
|
520
502
|
const fromChainEqueulsToToChain = chain?.name === otherChainTokens[0]?.name;
|
|
521
503
|
if (fromChainEqueulsToToChain) return otherChainTokens;
|
|
522
504
|
const filteredTokens = tokens.filter(token => token.blockchain === chain?.name);
|
|
523
|
-
return sortTokens(getTokensWithBalance(filteredTokens,
|
|
505
|
+
return sortTokens(getTokensWithBalance(filteredTokens, connectedWallets));
|
|
524
506
|
}
|
|
525
507
|
function tokensAreEqual(tokenA, tokenB) {
|
|
526
508
|
return tokenA?.blockchain === tokenB?.blockchain && tokenA?.symbol === tokenB?.symbol && tokenA?.address === tokenB?.address;
|
|
@@ -601,12 +583,12 @@ function LimitErrorMessage(bestRoute) {
|
|
|
601
583
|
recommendation
|
|
602
584
|
};
|
|
603
585
|
}
|
|
604
|
-
function getSwapButtonState(loadingMetaStatus,
|
|
586
|
+
function getSwapButtonState(loadingMetaStatus, connectedWallets, loading, bestRoute, hasLimitError, highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputAmount) {
|
|
605
587
|
if (loadingMetaStatus !== 'success') return {
|
|
606
588
|
title: 'Connect Wallet',
|
|
607
589
|
disabled: true
|
|
608
590
|
};
|
|
609
|
-
if (
|
|
591
|
+
if (connectedWallets.length == 0) return {
|
|
610
592
|
title: 'Connect Wallet',
|
|
611
593
|
disabled: false
|
|
612
594
|
};
|
|
@@ -818,14 +800,12 @@ function shouldRetrySwap(pendingSwap) {
|
|
|
818
800
|
}
|
|
819
801
|
|
|
820
802
|
const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector((set, get) => ({
|
|
821
|
-
|
|
822
|
-
balances: [],
|
|
803
|
+
connectedWallets: [],
|
|
823
804
|
selectedWallets: [],
|
|
824
805
|
connectWallet: accounts => {
|
|
825
806
|
const getOneOfWalletsDetails = get().getOneOfWalletsDetails;
|
|
826
807
|
set(state => ({
|
|
827
|
-
|
|
828
|
-
balances: state.balances.concat(accounts.map(account => ({
|
|
808
|
+
connectedWallets: state.connectedWallets.concat(accounts.map(account => ({
|
|
829
809
|
balances: [],
|
|
830
810
|
address: account.address,
|
|
831
811
|
chain: account.chain,
|
|
@@ -839,14 +819,13 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
839
819
|
},
|
|
840
820
|
disconnectWallet: walletType => {
|
|
841
821
|
set(state => ({
|
|
842
|
-
|
|
843
|
-
balances: state.balances.filter(balance => balance.walletType !== walletType),
|
|
822
|
+
connectedWallets: state.connectedWallets.filter(balance => balance.walletType !== walletType),
|
|
844
823
|
selectedWallets: state.selectedWallets.filter(wallet => wallet.walletType != walletType)
|
|
845
824
|
}));
|
|
846
825
|
},
|
|
847
826
|
initSelectedWallets: () => set(state => {
|
|
848
827
|
const requiredChains = getRequiredChains(useBestRouteStore.getState().bestRoute);
|
|
849
|
-
const connectedWallets = state.
|
|
828
|
+
const connectedWallets = state.connectedWallets;
|
|
850
829
|
const selectedWallets = [];
|
|
851
830
|
requiredChains.forEach(chain => {
|
|
852
831
|
const anyWalletSelected = !!state.selectedWallets.find(wallet => wallet.chain === chain);
|
|
@@ -871,14 +850,13 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
871
850
|
})
|
|
872
851
|
})),
|
|
873
852
|
clearConnectedWallet: () => set(() => ({
|
|
874
|
-
|
|
875
|
-
balances: [],
|
|
853
|
+
connectedWallets: [],
|
|
876
854
|
selectedWallets: []
|
|
877
855
|
})),
|
|
878
856
|
getOneOfWalletsDetails: async account => {
|
|
879
857
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
880
858
|
set(state => ({
|
|
881
|
-
|
|
859
|
+
connectedWallets: state.connectedWallets.map(balance => {
|
|
882
860
|
return balance.address === account.address && balance.chain === account.chain ? {
|
|
883
861
|
...balance,
|
|
884
862
|
loading: true
|
|
@@ -893,28 +871,28 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
893
871
|
const retrivedBalance = response.wallets[0];
|
|
894
872
|
if (retrivedBalance) {
|
|
895
873
|
set(state => ({
|
|
896
|
-
|
|
897
|
-
return
|
|
874
|
+
connectedWallets: state.connectedWallets.map(connectedWallet => {
|
|
875
|
+
return isAccountAndWalletMatched(account, connectedWallet) ? makeBalanceFor(account, retrivedBalance, tokens) : connectedWallet;
|
|
898
876
|
})
|
|
899
877
|
}));
|
|
900
878
|
} else throw new Error('Wallet not found');
|
|
901
879
|
} catch (error) {
|
|
902
880
|
set(state => ({
|
|
903
|
-
|
|
904
|
-
return
|
|
881
|
+
connectedWallets: state.connectedWallets.map(balance => {
|
|
882
|
+
return isAccountAndWalletMatched(account, balance) ? resetConnectedWalletState(balance) : balance;
|
|
905
883
|
})
|
|
906
884
|
}));
|
|
907
885
|
}
|
|
908
886
|
}
|
|
909
887
|
}))));
|
|
910
|
-
useWalletsStore.subscribe(state => state.
|
|
888
|
+
useWalletsStore.subscribe(state => state.connectedWallets, connectedWallets => {
|
|
911
889
|
useBestRouteStore.setState(_ref => {
|
|
912
890
|
let {
|
|
913
891
|
sourceTokens,
|
|
914
892
|
destinationTokens
|
|
915
893
|
} = _ref;
|
|
916
|
-
const sourceTokensWithBalance = getTokensWithBalance(sourceTokens,
|
|
917
|
-
const destinationTokensWithBalance = getTokensWithBalance(destinationTokens,
|
|
894
|
+
const sourceTokensWithBalance = getTokensWithBalance(sourceTokens, connectedWallets);
|
|
895
|
+
const destinationTokensWithBalance = getTokensWithBalance(destinationTokens, connectedWallets);
|
|
918
896
|
return {
|
|
919
897
|
sourceTokens: sortTokens(sourceTokensWithBalance),
|
|
920
898
|
destinationTokens: sortTokens(destinationTokensWithBalance)
|
|
@@ -923,7 +901,7 @@ useWalletsStore.subscribe(state => state.balances, balances => {
|
|
|
923
901
|
}, {
|
|
924
902
|
equalityFn: shallow
|
|
925
903
|
});
|
|
926
|
-
const fetchingBalanceSelector = state => !!state.
|
|
904
|
+
const fetchingBalanceSelector = state => !!state.connectedWallets.find(wallet => wallet.loading);
|
|
927
905
|
|
|
928
906
|
const getUsdValue = (token, amount) => new BigNumber(amount || ZERO).multipliedBy(token?.usdPrice || 0);
|
|
929
907
|
const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
@@ -967,8 +945,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
967
945
|
set(state => {
|
|
968
946
|
if (state.fromChain?.name === chain?.name) return {};
|
|
969
947
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
970
|
-
const
|
|
971
|
-
const sortedTokens = getSortedTokens(chain, tokens,
|
|
948
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
949
|
+
const sortedTokens = getSortedTokens(chain, tokens, connectedWallets, state.destinationTokens);
|
|
972
950
|
const fromToken = getDefaultToken(sortedTokens, state.toToken);
|
|
973
951
|
return {
|
|
974
952
|
fromChain: chain,
|
|
@@ -992,8 +970,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
992
970
|
set(state => {
|
|
993
971
|
if (state.toChain?.name === chain?.name) return {};
|
|
994
972
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
995
|
-
const
|
|
996
|
-
const sortedTokens = getSortedTokens(chain, tokens,
|
|
973
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
974
|
+
const sortedTokens = getSortedTokens(chain, tokens, connectedWallets, state.destinationTokens);
|
|
997
975
|
return {
|
|
998
976
|
toChain: chain,
|
|
999
977
|
destinationTokens: sortedTokens,
|
|
@@ -1025,7 +1003,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
1025
1003
|
tokens,
|
|
1026
1004
|
blockchains
|
|
1027
1005
|
} = useMetaStore.getState().meta;
|
|
1028
|
-
const
|
|
1006
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
1029
1007
|
const failedIndex = pendingSwap.status === 'failed' ? pendingSwap.steps.findIndex(s => s.status === 'failed') : null;
|
|
1030
1008
|
if (failedIndex === null || failedIndex < 0) return;
|
|
1031
1009
|
const firstStep = pendingSwap.steps[0];
|
|
@@ -1042,8 +1020,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
1042
1020
|
symbol: lastStep.toSymbol,
|
|
1043
1021
|
address: lastStep.toSymbolAddress
|
|
1044
1022
|
}));
|
|
1045
|
-
const sortedSourceTokens = getSortedTokens(fromChain, tokens,
|
|
1046
|
-
const sortedDestinationTokens = getSortedTokens(toChain, tokens,
|
|
1023
|
+
const sortedSourceTokens = getSortedTokens(fromChain, tokens, connectedWallets, []);
|
|
1024
|
+
const sortedDestinationTokens = getSortedTokens(toChain, tokens, connectedWallets, []);
|
|
1047
1025
|
const inputAmount = pendingSwap.inputAmount;
|
|
1048
1026
|
set({
|
|
1049
1027
|
fromChain,
|
|
@@ -1363,10 +1341,10 @@ const Container = /*#__PURE__*/styled('div', {
|
|
|
1363
1341
|
variants: {
|
|
1364
1342
|
type: {
|
|
1365
1343
|
filled: {
|
|
1366
|
-
backgroundColor: '$
|
|
1344
|
+
backgroundColor: '$neutral100'
|
|
1367
1345
|
},
|
|
1368
1346
|
outlined: {
|
|
1369
|
-
border: '1px solid $
|
|
1347
|
+
border: '1px solid $neutral100'
|
|
1370
1348
|
}
|
|
1371
1349
|
}
|
|
1372
1350
|
},
|
|
@@ -1402,14 +1380,14 @@ const Container = /*#__PURE__*/styled('div', {
|
|
|
1402
1380
|
const ImagePlaceholder = /*#__PURE__*/styled('span', {
|
|
1403
1381
|
width: '24px',
|
|
1404
1382
|
height: '24px',
|
|
1405
|
-
backgroundColor: '$
|
|
1383
|
+
backgroundColor: '$neutral100',
|
|
1406
1384
|
borderRadius: '99999px'
|
|
1407
1385
|
});
|
|
1408
1386
|
const OutputContainer = /*#__PURE__*/styled('div', {
|
|
1409
1387
|
windth: '100%',
|
|
1410
1388
|
height: '$48',
|
|
1411
1389
|
borderRadius: '$5',
|
|
1412
|
-
backgroundColor: '$
|
|
1390
|
+
backgroundColor: '$surface',
|
|
1413
1391
|
border: '1px solid transparent',
|
|
1414
1392
|
position: 'relative',
|
|
1415
1393
|
display: 'flex',
|
|
@@ -1443,10 +1421,10 @@ function TokenPreview(props) {
|
|
|
1443
1421
|
className: "head"
|
|
1444
1422
|
}, React.createElement(Typography, {
|
|
1445
1423
|
variant: "body2",
|
|
1446
|
-
color: "
|
|
1424
|
+
color: "neutral800"
|
|
1447
1425
|
}, props.label), React.createElement("div", null, percentageChange, props.usdValue && React.createElement(Typography, {
|
|
1448
1426
|
variant: "caption",
|
|
1449
|
-
color: "
|
|
1427
|
+
color: "neutral600",
|
|
1450
1428
|
className: "usd-value"
|
|
1451
1429
|
}, `$${numberToString(props.usdValue)}`))), React.createElement("div", {
|
|
1452
1430
|
className: "form"
|
|
@@ -1489,8 +1467,8 @@ const Container$1 = /*#__PURE__*/styled('div', {
|
|
|
1489
1467
|
justifyContent: 'space-between',
|
|
1490
1468
|
padding: '$8',
|
|
1491
1469
|
borderRadius: '$5',
|
|
1492
|
-
backgroundColor: '$
|
|
1493
|
-
color: '$
|
|
1470
|
+
backgroundColor: '$neutral100',
|
|
1471
|
+
color: '$neutral800',
|
|
1494
1472
|
fontSize: '$12',
|
|
1495
1473
|
'.routes': {
|
|
1496
1474
|
display: 'flex',
|
|
@@ -1550,7 +1528,7 @@ function useConfirmSwap() {
|
|
|
1550
1528
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
1551
1529
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1552
1530
|
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
1553
|
-
const
|
|
1531
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
1554
1532
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
1555
1533
|
const meta = useMetaStore.use.meta();
|
|
1556
1534
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
@@ -1589,7 +1567,7 @@ function useConfirmSwap() {
|
|
|
1589
1567
|
}
|
|
1590
1568
|
abortControllerRef.current = new AbortController();
|
|
1591
1569
|
setLoading(true);
|
|
1592
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount,
|
|
1570
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, connectedWallets, selectedWallets, disabledLiquiditySources, userSlippage, affiliateRef, initialRoute);
|
|
1593
1571
|
try {
|
|
1594
1572
|
const confiremedRoute = await httpService().getBestRoute(requestBody, {
|
|
1595
1573
|
signal: abortControllerRef.current?.signal
|
|
@@ -1833,7 +1811,7 @@ function ConfirmSwapPage() {
|
|
|
1833
1811
|
tokens
|
|
1834
1812
|
} = useMetaStore.use.meta();
|
|
1835
1813
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
1836
|
-
const
|
|
1814
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
1837
1815
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
1838
1816
|
const initSelectedWallets = useWalletsStore.use.initSelectedWallets();
|
|
1839
1817
|
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
@@ -1842,6 +1820,7 @@ function ConfirmSwapPage() {
|
|
|
1842
1820
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1843
1821
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
1844
1822
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1823
|
+
const [dbErrorMessage, setDbErrorMessage] = useState('');
|
|
1845
1824
|
const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
|
|
1846
1825
|
const {
|
|
1847
1826
|
manager
|
|
@@ -1866,7 +1845,7 @@ function ConfirmSwapPage() {
|
|
|
1866
1845
|
useEffect(() => {
|
|
1867
1846
|
initSelectedWallets();
|
|
1868
1847
|
}, []);
|
|
1869
|
-
const selectableWallets = getSelectableWallets(
|
|
1848
|
+
const selectableWallets = getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo);
|
|
1870
1849
|
const handleConnectChain = wallet => {
|
|
1871
1850
|
const network = wallet;
|
|
1872
1851
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
@@ -1876,21 +1855,25 @@ function ConfirmSwapPage() {
|
|
|
1876
1855
|
requiredWallets: getRequiredChains(bestRoute),
|
|
1877
1856
|
selectableWallets: selectableWallets,
|
|
1878
1857
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
1879
|
-
onConfirm: () => {
|
|
1880
|
-
confirmSwap?.().then(swap => {
|
|
1858
|
+
onConfirm: async () => {
|
|
1859
|
+
confirmSwap?.().then(async swap => {
|
|
1881
1860
|
if (swap) {
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1861
|
+
try {
|
|
1862
|
+
await manager?.create('swap', {
|
|
1863
|
+
swapDetails: swap
|
|
1864
|
+
}, {
|
|
1865
|
+
id: swap.requestId
|
|
1866
|
+
});
|
|
1867
|
+
setSelectedSwap(swap.requestId);
|
|
1868
|
+
navigate('/' + navigationRoutes.swaps + `/${swap.requestId}`, {
|
|
1869
|
+
replace: true
|
|
1870
|
+
});
|
|
1871
|
+
setTimeout(() => {
|
|
1872
|
+
setInputAmount('');
|
|
1873
|
+
}, 0);
|
|
1874
|
+
} catch (e) {
|
|
1875
|
+
setDbErrorMessage('Error: ' + e?.message);
|
|
1876
|
+
}
|
|
1894
1877
|
}
|
|
1895
1878
|
});
|
|
1896
1879
|
},
|
|
@@ -1937,7 +1920,7 @@ function ConfirmSwapPage() {
|
|
|
1937
1920
|
totalFee: numberToString(totalFeeInUsd, 0, 2)
|
|
1938
1921
|
}),
|
|
1939
1922
|
loading: fetchingConfirmedRoute,
|
|
1940
|
-
errors: ConfirmSwapErrors(errors),
|
|
1923
|
+
errors: dbErrorMessage ? [dbErrorMessage, ...ConfirmSwapErrors(errors)] : ConfirmSwapErrors(errors),
|
|
1941
1924
|
warnings: ConfirmSwapWarnings(warnings),
|
|
1942
1925
|
extraMessages: React.createElement(React.Fragment, null, loadingMetaStatus === 'failed' && React.createElement(LoadingFailedAlert, null), loadingMetaStatus === 'failed' && showHighSlippageWarning && React.createElement(Spacer, {
|
|
1943
1926
|
direction: "vertical"
|
|
@@ -2031,10 +2014,11 @@ const Container$2 = /*#__PURE__*/styled('div', {
|
|
|
2031
2014
|
variants: {
|
|
2032
2015
|
type: {
|
|
2033
2016
|
filled: {
|
|
2034
|
-
backgroundColor: '$
|
|
2017
|
+
backgroundColor: '$neutral100'
|
|
2035
2018
|
},
|
|
2036
2019
|
outlined: {
|
|
2037
|
-
border: '1px solid $
|
|
2020
|
+
border: '1px solid $neutral100',
|
|
2021
|
+
backgroundColor: '$surface'
|
|
2038
2022
|
}
|
|
2039
2023
|
}
|
|
2040
2024
|
},
|
|
@@ -2082,14 +2066,14 @@ const Options = /*#__PURE__*/styled('div', {
|
|
|
2082
2066
|
const ImagePlaceholder$1 = /*#__PURE__*/styled('span', {
|
|
2083
2067
|
width: '24px',
|
|
2084
2068
|
height: '24px',
|
|
2085
|
-
backgroundColor: '$
|
|
2069
|
+
backgroundColor: '$neutral100',
|
|
2086
2070
|
borderRadius: '99999px'
|
|
2087
2071
|
});
|
|
2088
2072
|
const OutputContainer$1 = /*#__PURE__*/styled('div', {
|
|
2089
2073
|
windth: '100%',
|
|
2090
2074
|
height: '$48',
|
|
2091
2075
|
borderRadius: '$5',
|
|
2092
|
-
backgroundColor: '$
|
|
2076
|
+
backgroundColor: '$surface',
|
|
2093
2077
|
border: '1px solid transparent',
|
|
2094
2078
|
position: 'relative',
|
|
2095
2079
|
display: 'flex',
|
|
@@ -2111,14 +2095,14 @@ function TokenInfo(props) {
|
|
|
2111
2095
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2112
2096
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
2113
2097
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
2114
|
-
const
|
|
2098
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
2115
2099
|
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
2116
2100
|
const navigate = useNavigate();
|
|
2117
2101
|
const {
|
|
2118
2102
|
t
|
|
2119
2103
|
} = useTranslation();
|
|
2120
|
-
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(
|
|
2121
|
-
const tokenBalanceReal = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(
|
|
2104
|
+
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(connectedWallets, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', 8) : '0';
|
|
2105
|
+
const tokenBalanceReal = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(connectedWallets, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', getBalanceFromWallet(connectedWallets, fromChain?.name, fromToken?.symbol, fromToken?.address)?.decimal) : '0';
|
|
2122
2106
|
const ItemSuffix = React.createElement("div", {
|
|
2123
2107
|
style: {
|
|
2124
2108
|
display: 'flex',
|
|
@@ -2135,7 +2119,7 @@ function TokenInfo(props) {
|
|
|
2135
2119
|
className: "head"
|
|
2136
2120
|
}, React.createElement(Typography, {
|
|
2137
2121
|
variant: "body2",
|
|
2138
|
-
color: "
|
|
2122
|
+
color: "neutral800"
|
|
2139
2123
|
}, t(type)), props.type === 'From' ? React.createElement(Options, null, React.createElement("div", {
|
|
2140
2124
|
className: "balance",
|
|
2141
2125
|
onClick: () => {
|
|
@@ -2143,7 +2127,7 @@ function TokenInfo(props) {
|
|
|
2143
2127
|
}
|
|
2144
2128
|
}, React.createElement(Typography, {
|
|
2145
2129
|
variant: "body3",
|
|
2146
|
-
color: "
|
|
2130
|
+
color: "neutral600"
|
|
2147
2131
|
}, `${t('Balance')}: ${tokenBalance} ${fromToken?.symbol || ''}`), React.createElement(Spacer, {
|
|
2148
2132
|
size: 4
|
|
2149
2133
|
}), React.createElement(Button, {
|
|
@@ -2157,7 +2141,7 @@ function TokenInfo(props) {
|
|
|
2157
2141
|
outputUsdValue: props.outputUsdValue
|
|
2158
2142
|
}), React.createElement("div", null, React.createElement(Typography, {
|
|
2159
2143
|
variant: "caption",
|
|
2160
|
-
color: "
|
|
2144
|
+
color: "neutral600"
|
|
2161
2145
|
}, `$${numberToString(props.outputUsdValue)}`)))), React.createElement("div", {
|
|
2162
2146
|
className: "form"
|
|
2163
2147
|
}, React.createElement(Button, {
|
|
@@ -2213,7 +2197,7 @@ function TokenInfo(props) {
|
|
|
2213
2197
|
}
|
|
2214
2198
|
}, React.createElement(Typography, {
|
|
2215
2199
|
variant: "caption",
|
|
2216
|
-
color: "
|
|
2200
|
+
color: "neutral800"
|
|
2217
2201
|
}, `$${numberToString(inputUsdValue)}`)),
|
|
2218
2202
|
value: props.inputAmount || '',
|
|
2219
2203
|
min: 0,
|
|
@@ -2249,7 +2233,7 @@ function BottomLogo() {
|
|
|
2249
2233
|
} = useTranslation();
|
|
2250
2234
|
return React.createElement(Container$3, null, React.createElement(Typography, {
|
|
2251
2235
|
variant: "caption",
|
|
2252
|
-
color: "$
|
|
2236
|
+
color: "$neutral600"
|
|
2253
2237
|
}, t('Powered By')), React.createElement(StyledAnchor, {
|
|
2254
2238
|
href: "https://rango.exchange",
|
|
2255
2239
|
target: "_blank"
|
|
@@ -2393,7 +2377,7 @@ function Home() {
|
|
|
2393
2377
|
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
2394
2378
|
const bestRouteError = useBestRouteStore.use.error();
|
|
2395
2379
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2396
|
-
const
|
|
2380
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
2397
2381
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
2398
2382
|
const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
|
|
2399
2383
|
const errorMessage = loadingMetaStatus === 'failed' ? errorMessages.genericServerError : bestRouteError;
|
|
@@ -2407,7 +2391,7 @@ function Home() {
|
|
|
2407
2391
|
swap
|
|
2408
2392
|
} = LimitErrorMessage(bestRoute);
|
|
2409
2393
|
const priceImpactCanNotBeComputed = !canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue);
|
|
2410
|
-
const swapButtonState = getSwapButtonState(loadingMetaStatus,
|
|
2394
|
+
const swapButtonState = getSwapButtonState(loadingMetaStatus, connectedWallets, fetchingBestRoute, bestRoute, hasLimitError(bestRoute), highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputAmount);
|
|
2411
2395
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2412
2396
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
2413
2397
|
useEffect(() => {
|
|
@@ -2567,7 +2551,8 @@ function SelectTokenPage(props) {
|
|
|
2567
2551
|
|
|
2568
2552
|
function SettingsPage(_ref) {
|
|
2569
2553
|
let {
|
|
2570
|
-
supportedSwappers
|
|
2554
|
+
supportedSwappers,
|
|
2555
|
+
singleTheme
|
|
2571
2556
|
} = _ref;
|
|
2572
2557
|
const slippage = useSettingsStore.use.slippage();
|
|
2573
2558
|
const setSlippage = useSettingsStore.use.setSlippage();
|
|
@@ -2609,6 +2594,7 @@ function SettingsPage(_ref) {
|
|
|
2609
2594
|
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2610
2595
|
liquiditySources: supportedUniqueSwappersGroups,
|
|
2611
2596
|
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2597
|
+
singleTheme: singleTheme,
|
|
2612
2598
|
customSlippage: customSlippage || NaN,
|
|
2613
2599
|
onCustomSlippageChange: setCustomSlippage,
|
|
2614
2600
|
minSlippage: MIN_SLIPPGAE,
|
|
@@ -2920,6 +2906,7 @@ function AppRoutes(props) {
|
|
|
2920
2906
|
}, {
|
|
2921
2907
|
path: navigationRoutes.settings,
|
|
2922
2908
|
element: React.createElement(SettingsPage, {
|
|
2909
|
+
singleTheme: config?.theme?.singleTheme,
|
|
2923
2910
|
supportedSwappers: config?.liquiditySources
|
|
2924
2911
|
})
|
|
2925
2912
|
}, {
|
|
@@ -2966,14 +2953,13 @@ function Layout(_ref) {
|
|
|
2966
2953
|
} = _ref;
|
|
2967
2954
|
const navigate = useNavigate();
|
|
2968
2955
|
const {
|
|
2969
|
-
|
|
2970
|
-
accounts,
|
|
2956
|
+
connectedWallets,
|
|
2971
2957
|
selectedWallets
|
|
2972
2958
|
} = useWalletsStore();
|
|
2973
2959
|
const {
|
|
2974
2960
|
getWalletInfo
|
|
2975
2961
|
} = useWallets();
|
|
2976
|
-
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(
|
|
2962
|
+
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2977
2963
|
const {
|
|
2978
2964
|
blockchains,
|
|
2979
2965
|
tokens
|
|
@@ -2984,7 +2970,7 @@ function Layout(_ref) {
|
|
|
2984
2970
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
2985
2971
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2986
2972
|
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
2987
|
-
const totalBalance = calculateWalletUsdValue(
|
|
2973
|
+
const totalBalance = calculateWalletUsdValue(connectedWallets);
|
|
2988
2974
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
2989
2975
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2990
2976
|
const fetchingBalance = useWalletsStore(fetchingBalanceSelector);
|
|
@@ -2992,20 +2978,24 @@ function Layout(_ref) {
|
|
|
2992
2978
|
t
|
|
2993
2979
|
} = useTranslation();
|
|
2994
2980
|
useEffect(() => {
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
2981
|
+
if (loadingMetaStatus === 'success') {
|
|
2982
|
+
const chain = blockchains.find(chain => chain.name === config?.to?.blockchain);
|
|
2983
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.to?.token || null));
|
|
2984
|
+
setToChain(chain || null);
|
|
2985
|
+
setToToken(token || null);
|
|
2986
|
+
}
|
|
2987
|
+
}, [config?.to?.token, config?.to?.blockchain, loadingMetaStatus]);
|
|
3000
2988
|
useEffect(() => {
|
|
3001
2989
|
setInputAmount(config?.amount?.toString() || '');
|
|
3002
2990
|
}, [config?.amount]);
|
|
3003
2991
|
useEffect(() => {
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
2992
|
+
if (loadingMetaStatus === 'success') {
|
|
2993
|
+
const chain = blockchains.find(chain => chain.name === config?.from?.blockchain);
|
|
2994
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.from?.token || null));
|
|
2995
|
+
setFromChain(chain || null);
|
|
2996
|
+
setFromToken(token || null);
|
|
2997
|
+
}
|
|
2998
|
+
}, [config?.from?.token, config?.from?.blockchain, loadingMetaStatus]);
|
|
3009
2999
|
useEffect(() => {
|
|
3010
3000
|
setAffiliateRef(config?.affiliateRef || null);
|
|
3011
3001
|
}, [config?.affiliateRef]);
|
|
@@ -3030,7 +3020,7 @@ function Layout(_ref) {
|
|
|
3030
3020
|
className: "balance"
|
|
3031
3021
|
}, React.createElement(Typography, {
|
|
3032
3022
|
variant: "body2"
|
|
3033
|
-
}, !
|
|
3023
|
+
}, !connectedWallets?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React.createElement(Spinner, null)))), React.createElement(AppRoutes, {
|
|
3034
3024
|
config: config
|
|
3035
3025
|
}));
|
|
3036
3026
|
}
|
|
@@ -3064,89 +3054,66 @@ function useTheme(_ref) {
|
|
|
3064
3054
|
const theme = useSettingsStore.use.theme();
|
|
3065
3055
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
3066
3056
|
const setTheme = useSettingsStore.use.setTheme();
|
|
3067
|
-
const
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
primary700: shadeColor(primary, -35),
|
|
3090
|
-
primary800: shadeColor(primary, -40),
|
|
3091
|
-
primary900: shadeColor(primary, -45),
|
|
3057
|
+
const light = themeColors?.light;
|
|
3058
|
+
const dark = themeColors?.dark;
|
|
3059
|
+
const neutral = light?.neutral || '#fafafa';
|
|
3060
|
+
const background = light?.background || '#fff';
|
|
3061
|
+
const foreground = light?.foreground || '#000';
|
|
3062
|
+
const darkColors = {
|
|
3063
|
+
...generateRangeColors('primary', 'dark', dark?.primary),
|
|
3064
|
+
...generateRangeColors('error', 'dark', dark?.error),
|
|
3065
|
+
...generateRangeColors('warning', 'dark', dark?.warning),
|
|
3066
|
+
...generateRangeColors('success', 'dark', dark?.success),
|
|
3067
|
+
...generateRangeColors('neutral', 'dark', dark?.neutral),
|
|
3068
|
+
surface: dark?.surface,
|
|
3069
|
+
background: dark?.background,
|
|
3070
|
+
foreground: dark?.foreground
|
|
3071
|
+
};
|
|
3072
|
+
const lightColors = {
|
|
3073
|
+
surface: light?.surface || '#fff',
|
|
3074
|
+
...generateRangeColors('primary', 'light', light?.primary || '#5FA425'),
|
|
3075
|
+
...generateRangeColors('error', 'light', light?.error || '#FF0000'),
|
|
3076
|
+
...generateRangeColors('warning', 'light', light?.warning || '#F5A623'),
|
|
3077
|
+
...generateRangeColors('success', 'light', light?.success || '#0070F3'),
|
|
3078
|
+
...generateRangeColors('neutral', 'light', neutral),
|
|
3092
3079
|
background,
|
|
3093
|
-
foreground
|
|
3094
|
-
error,
|
|
3095
|
-
error100: shadeColor(error, 50),
|
|
3096
|
-
error300: shadeColor(error, -10),
|
|
3097
|
-
error500: shadeColor(error, -20),
|
|
3098
|
-
error700: shadeColor(error, -30),
|
|
3099
|
-
warning,
|
|
3100
|
-
warning100: shadeColor(warning, 50),
|
|
3101
|
-
warning300: shadeColor(warning, -10),
|
|
3102
|
-
warning500: shadeColor(warning, -20),
|
|
3103
|
-
warning700: shadeColor(warning, -30),
|
|
3104
|
-
success,
|
|
3105
|
-
success100: shadeColor(success, 50),
|
|
3106
|
-
success300: shadeColor(success, -10),
|
|
3107
|
-
success500: shadeColor(success, -20),
|
|
3108
|
-
success700: shadeColor(success, -30)
|
|
3080
|
+
foreground
|
|
3109
3081
|
};
|
|
3110
3082
|
const customeLightTheme = createTheme({
|
|
3111
|
-
colors,
|
|
3083
|
+
colors: lightColors,
|
|
3112
3084
|
radii: {
|
|
3113
3085
|
5: `${borderRadius}px`
|
|
3114
3086
|
},
|
|
3115
3087
|
shadows: {
|
|
3116
|
-
s:
|
|
3088
|
+
s: `0px 3px 5px 3px ${light?.neutral || '#f0f2f5'} ,0px 6px 10px 3px ${light?.neutral || '#f0f2f5'}, 0px 1px 18px 3px ${light?.neutral || '#f0f2f5'}`
|
|
3117
3089
|
}
|
|
3118
3090
|
});
|
|
3119
3091
|
const customeDarkTheme = createTheme({
|
|
3120
3092
|
colors: {
|
|
3121
|
-
...
|
|
3122
|
-
|
|
3123
|
-
neutrals300: '#333333',
|
|
3124
|
-
neutrals400: '#444444',
|
|
3125
|
-
neutrals500: '#acacac',
|
|
3126
|
-
neutrals600: '#cccccc',
|
|
3127
|
-
neutrals700: '#dedede',
|
|
3128
|
-
neutrals800: '#f2f2f2',
|
|
3129
|
-
neutrals900: '#FAFAFA',
|
|
3093
|
+
...lightColors,
|
|
3094
|
+
...generateRangeColors('neutral', 'dark', '#111111'),
|
|
3130
3095
|
foreground: background,
|
|
3131
|
-
background: foreground
|
|
3096
|
+
background: foreground,
|
|
3097
|
+
surface: '#000',
|
|
3098
|
+
...JSON.parse(JSON.stringify(darkColors))
|
|
3132
3099
|
},
|
|
3133
3100
|
radii: {
|
|
3134
3101
|
5: `${borderRadius}px`
|
|
3135
3102
|
},
|
|
3136
3103
|
shadows: {
|
|
3137
|
-
s:
|
|
3104
|
+
s: `0px 3px 5px 3px ${dark?.neutral || '#222'}, 0px 6px 10px 3px ${dark?.neutral || '#222'}, 0px 1px 18px 3px ${dark?.neutral || '#222'}`
|
|
3138
3105
|
}
|
|
3139
3106
|
});
|
|
3140
|
-
const [OSTheme, setOSTheme] = useState(
|
|
3107
|
+
const [OSTheme, setOSTheme] = useState('light');
|
|
3141
3108
|
useEffect(() => {
|
|
3142
3109
|
(async () => {
|
|
3143
3110
|
await fetchMeta();
|
|
3144
3111
|
})();
|
|
3145
3112
|
const switchTheme = event => {
|
|
3146
|
-
if (event.matches) setOSTheme(
|
|
3113
|
+
if (event.matches) setOSTheme('dark');else setOSTheme('light');
|
|
3147
3114
|
};
|
|
3148
3115
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
3149
|
-
setOSTheme(
|
|
3116
|
+
setOSTheme('dark');
|
|
3150
3117
|
}
|
|
3151
3118
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', switchTheme);
|
|
3152
3119
|
return () => {
|
|
@@ -3165,7 +3132,7 @@ function useTheme(_ref) {
|
|
|
3165
3132
|
classList.add(`font_${fontFamily.replace(/ /g, '')}`);
|
|
3166
3133
|
}, [fontFamily]);
|
|
3167
3134
|
const getActiveTheme = () => {
|
|
3168
|
-
if (theme === 'auto') return OSTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
3135
|
+
if (theme === 'auto') return OSTheme === 'dark' ? customeDarkTheme : customeLightTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
3169
3136
|
};
|
|
3170
3137
|
return {
|
|
3171
3138
|
activeTheme: getActiveTheme()
|
|
@@ -3266,13 +3233,12 @@ function QueueManager(props) {
|
|
|
3266
3233
|
});
|
|
3267
3234
|
}, []);
|
|
3268
3235
|
const getOneOfWalletsDetails = useWalletsStore.use.getOneOfWalletsDetails();
|
|
3269
|
-
const accounts = useWalletsStore.use.accounts();
|
|
3270
3236
|
const {
|
|
3271
3237
|
blockchains
|
|
3272
3238
|
} = useMetaStore.use.meta();
|
|
3273
|
-
const
|
|
3239
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
3274
3240
|
const wallets = {
|
|
3275
|
-
blockchains:
|
|
3241
|
+
blockchains: connectedWallets.map(wallet => ({
|
|
3276
3242
|
accounts: [wallet],
|
|
3277
3243
|
name: wallet.chain
|
|
3278
3244
|
}))
|
|
@@ -3298,8 +3264,8 @@ function QueueManager(props) {
|
|
|
3298
3264
|
const outputAmount = data.step?.outputAmount || '';
|
|
3299
3265
|
const step = data.step || lastStep;
|
|
3300
3266
|
if (data.eventType === 'task_completed' || data.eventType === 'step_completed_with_output' && lastStep?.id !== data.step?.id || !!outputAmount) {
|
|
3301
|
-
const fromAccount =
|
|
3302
|
-
const toAccount = step?.fromBlockchain !== step?.toBlockchain &&
|
|
3267
|
+
const fromAccount = connectedWallets.find(account => account.chain === step?.fromBlockchain);
|
|
3268
|
+
const toAccount = step?.fromBlockchain !== step?.toBlockchain && connectedWallets.find(wallet => wallet.chain === step?.toBlockchain);
|
|
3303
3269
|
fromAccount && getOneOfWalletsDetails(fromAccount);
|
|
3304
3270
|
toAccount && getOneOfWalletsDetails(toAccount);
|
|
3305
3271
|
}
|
|
@@ -3321,10 +3287,7 @@ function QueueManager(props) {
|
|
|
3321
3287
|
state,
|
|
3322
3288
|
notifier
|
|
3323
3289
|
};
|
|
3324
|
-
return React.createElement(Provider
|
|
3325
|
-
//@ts-ignore
|
|
3326
|
-
, {
|
|
3327
|
-
//@ts-ignore
|
|
3290
|
+
return React.createElement(Provider, {
|
|
3328
3291
|
queuesDefs: [swapQueueDef],
|
|
3329
3292
|
context: context,
|
|
3330
3293
|
onPersistedDataLoaded: manager => {
|
|
@@ -3402,6 +3365,7 @@ const Widget = _ref => {
|
|
|
3402
3365
|
providers: providers,
|
|
3403
3366
|
onUpdateState: onUpdateState
|
|
3404
3367
|
}, React.createElement("div", {
|
|
3368
|
+
id: "swap-container",
|
|
3405
3369
|
className: activeTheme
|
|
3406
3370
|
}, React.createElement(QueueManager, null, React.createElement(SwapContainer, {
|
|
3407
3371
|
fixedHeight: currentPage !== navigationRoutes.home
|