@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
|
@@ -37,24 +37,6 @@ function removeDuplicateFrom(array) {
|
|
|
37
37
|
function areEqual(array1, array2) {
|
|
38
38
|
return array1.length === array2.length && array1.every((v, i) => v === array2[i]);
|
|
39
39
|
}
|
|
40
|
-
function shadeColor(color, percent) {
|
|
41
|
-
var R = parseInt(color.substring(1, 3), 16);
|
|
42
|
-
var G = parseInt(color.substring(3, 5), 16);
|
|
43
|
-
var B = parseInt(color.substring(5, 7), 16);
|
|
44
|
-
R = R * (100 + percent) / 100;
|
|
45
|
-
G = G * (100 + percent) / 100;
|
|
46
|
-
B = B * (100 + percent) / 100;
|
|
47
|
-
R = R < 255 ? R : 255;
|
|
48
|
-
G = G < 255 ? G : 255;
|
|
49
|
-
B = B < 255 ? B : 255;
|
|
50
|
-
R = Math.round(R);
|
|
51
|
-
G = Math.round(G);
|
|
52
|
-
B = Math.round(B);
|
|
53
|
-
var RR = R.toString(16).length == 1 ? '0' + R.toString(16) : R.toString(16);
|
|
54
|
-
var GG = G.toString(16).length == 1 ? '0' + G.toString(16) : G.toString(16);
|
|
55
|
-
var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
|
|
56
|
-
return '#' + RR + GG + BB;
|
|
57
|
-
}
|
|
58
40
|
function debounce(fn, time) {
|
|
59
41
|
let timeoutId;
|
|
60
42
|
return wrapper;
|
|
@@ -318,8 +300,8 @@ function getStateWallet(state) {
|
|
|
318
300
|
return ui.WalletState.DISCONNECTED;
|
|
319
301
|
}
|
|
320
302
|
}
|
|
303
|
+
const excludedWallets = [walletsShared.WalletType.UNKNOWN, walletsShared.WalletType.LEAP];
|
|
321
304
|
function getlistWallet(getState, getWalletInfo, list) {
|
|
322
|
-
const excludedWallets = [walletsShared.WalletType.UNKNOWN, walletsShared.WalletType.TERRA_STATION, walletsShared.WalletType.LEAP];
|
|
323
305
|
return list.filter(wallet => !excludedWallets.includes(wallet)).map(type => {
|
|
324
306
|
const {
|
|
325
307
|
name,
|
|
@@ -402,27 +384,27 @@ function getRequiredChains(route) {
|
|
|
402
384
|
});
|
|
403
385
|
return wallets;
|
|
404
386
|
}
|
|
405
|
-
function getSelectableWallets(
|
|
406
|
-
const
|
|
407
|
-
address:
|
|
408
|
-
walletType:
|
|
409
|
-
chain:
|
|
410
|
-
image: getWalletInfo(
|
|
411
|
-
name: getWalletInfo(
|
|
412
|
-
selected: !!selectedWallets.find(
|
|
387
|
+
function getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo) {
|
|
388
|
+
const selectableWallets = connectedWallets.map(connectedWallet => ({
|
|
389
|
+
address: connectedWallet.address,
|
|
390
|
+
walletType: connectedWallet.walletType,
|
|
391
|
+
chain: connectedWallet.chain,
|
|
392
|
+
image: getWalletInfo(connectedWallet.walletType).img,
|
|
393
|
+
name: getWalletInfo(connectedWallet.walletType).name,
|
|
394
|
+
selected: !!selectedWallets.find(selectedWallet => selectedWallet.chain === connectedWallet.chain && selectedWallet.walletType === connectedWallet.walletType)
|
|
413
395
|
}));
|
|
414
|
-
return
|
|
396
|
+
return selectableWallets;
|
|
415
397
|
}
|
|
416
|
-
function getBalanceFromWallet(
|
|
417
|
-
if (
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
420
|
-
return
|
|
398
|
+
function getBalanceFromWallet(connectedWallets, chain, symbol, address) {
|
|
399
|
+
if (connectedWallets.length === 0) return null;
|
|
400
|
+
const selectedChainWallets = connectedWallets.filter(wallet => wallet.chain === chain);
|
|
401
|
+
if (selectedChainWallets.length === 0) return null;
|
|
402
|
+
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;
|
|
421
403
|
}
|
|
422
|
-
function
|
|
423
|
-
return account.address ===
|
|
404
|
+
function isAccountAndWalletMatched(account, connectedWallet) {
|
|
405
|
+
return account.address === connectedWallet.address && account.chain === connectedWallet.chain && account.walletType === connectedWallet.walletType;
|
|
424
406
|
}
|
|
425
|
-
function makeBalanceFor(
|
|
407
|
+
function makeBalanceFor(wallet, retrivedBalance, tokens) {
|
|
426
408
|
const {
|
|
427
409
|
address,
|
|
428
410
|
blockChain: chain,
|
|
@@ -435,7 +417,7 @@ function makeBalanceFor(account, retrivedBalance, tokens) {
|
|
|
435
417
|
loading: false,
|
|
436
418
|
error: false,
|
|
437
419
|
explorerUrl,
|
|
438
|
-
walletType:
|
|
420
|
+
walletType: wallet.walletType,
|
|
439
421
|
balances: balances?.map(tokenBalance => ({
|
|
440
422
|
chain,
|
|
441
423
|
symbol: tokenBalance.asset.symbol,
|
|
@@ -449,16 +431,16 @@ function makeBalanceFor(account, retrivedBalance, tokens) {
|
|
|
449
431
|
})) || []
|
|
450
432
|
};
|
|
451
433
|
}
|
|
452
|
-
function
|
|
434
|
+
function resetConnectedWalletState(connectedWallet) {
|
|
453
435
|
return {
|
|
454
|
-
...
|
|
436
|
+
...connectedWallet,
|
|
455
437
|
loading: false,
|
|
456
438
|
error: true
|
|
457
439
|
};
|
|
458
440
|
}
|
|
459
|
-
const calculateWalletUsdValue =
|
|
441
|
+
const calculateWalletUsdValue = connectedWallet => {
|
|
460
442
|
const uniqueAccountAddresses = new Set();
|
|
461
|
-
const uniqueBalane =
|
|
443
|
+
const uniqueBalane = connectedWallet?.reduce((acc, current) => {
|
|
462
444
|
return acc.findIndex(i => i.address === current.address && i.chain === current.chain) === -1 ? [...acc, current] : acc;
|
|
463
445
|
}, []);
|
|
464
446
|
const modifiedWalletBlockchains = uniqueBalane?.map(chain => {
|
|
@@ -504,15 +486,15 @@ const getKeplrCompatibleConnectedWallets = selectableWallets => {
|
|
|
504
486
|
const connectedWalletTypes = new Set(selectableWallets.map(a => a.walletType.toString()));
|
|
505
487
|
return walletsShared.KEPLR_COMPATIBLE_WALLETS.filter(compatibleWallet => connectedWalletTypes.has(compatibleWallet));
|
|
506
488
|
};
|
|
507
|
-
function getTokensWithBalance(tokens,
|
|
489
|
+
function getTokensWithBalance(tokens, connectedWallets) {
|
|
508
490
|
return tokens.map(_ref2 => {
|
|
509
491
|
let {
|
|
510
492
|
balance,
|
|
511
493
|
...otherProps
|
|
512
494
|
} = _ref2;
|
|
513
|
-
const tokenAmount = numberToString(new BigNumber__default(getBalanceFromWallet(
|
|
495
|
+
const tokenAmount = numberToString(new BigNumber__default(getBalanceFromWallet(connectedWallets, otherProps.blockchain, otherProps.symbol, otherProps.address)?.amount || ZERO));
|
|
514
496
|
let tokenUsdValue = '';
|
|
515
|
-
if (otherProps.usdPrice) tokenUsdValue = numberToString(new BigNumber__default(getBalanceFromWallet(
|
|
497
|
+
if (otherProps.usdPrice) tokenUsdValue = numberToString(new BigNumber__default(getBalanceFromWallet(connectedWallets, otherProps.blockchain, otherProps.symbol, otherProps.address)?.amount || ZERO).multipliedBy(otherProps.usdPrice));
|
|
516
498
|
return {
|
|
517
499
|
...otherProps,
|
|
518
500
|
...(tokenAmount !== '0' && {
|
|
@@ -524,11 +506,11 @@ function getTokensWithBalance(tokens, balances) {
|
|
|
524
506
|
};
|
|
525
507
|
});
|
|
526
508
|
}
|
|
527
|
-
function getSortedTokens(chain, tokens,
|
|
509
|
+
function getSortedTokens(chain, tokens, connectedWallets, otherChainTokens) {
|
|
528
510
|
const fromChainEqueulsToToChain = chain?.name === otherChainTokens[0]?.name;
|
|
529
511
|
if (fromChainEqueulsToToChain) return otherChainTokens;
|
|
530
512
|
const filteredTokens = tokens.filter(token => token.blockchain === chain?.name);
|
|
531
|
-
return sortTokens(getTokensWithBalance(filteredTokens,
|
|
513
|
+
return sortTokens(getTokensWithBalance(filteredTokens, connectedWallets));
|
|
532
514
|
}
|
|
533
515
|
function tokensAreEqual(tokenA, tokenB) {
|
|
534
516
|
return tokenA?.blockchain === tokenB?.blockchain && tokenA?.symbol === tokenB?.symbol && tokenA?.address === tokenB?.address;
|
|
@@ -609,12 +591,12 @@ function LimitErrorMessage(bestRoute) {
|
|
|
609
591
|
recommendation
|
|
610
592
|
};
|
|
611
593
|
}
|
|
612
|
-
function getSwapButtonState(loadingMetaStatus,
|
|
594
|
+
function getSwapButtonState(loadingMetaStatus, connectedWallets, loading, bestRoute, hasLimitError, highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputAmount) {
|
|
613
595
|
if (loadingMetaStatus !== 'success') return {
|
|
614
596
|
title: 'Connect Wallet',
|
|
615
597
|
disabled: true
|
|
616
598
|
};
|
|
617
|
-
if (
|
|
599
|
+
if (connectedWallets.length == 0) return {
|
|
618
600
|
title: 'Connect Wallet',
|
|
619
601
|
disabled: false
|
|
620
602
|
};
|
|
@@ -826,14 +808,12 @@ function shouldRetrySwap(pendingSwap) {
|
|
|
826
808
|
}
|
|
827
809
|
|
|
828
810
|
const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.create()( /*#__PURE__*/middleware.subscribeWithSelector((set, get) => ({
|
|
829
|
-
|
|
830
|
-
balances: [],
|
|
811
|
+
connectedWallets: [],
|
|
831
812
|
selectedWallets: [],
|
|
832
813
|
connectWallet: accounts => {
|
|
833
814
|
const getOneOfWalletsDetails = get().getOneOfWalletsDetails;
|
|
834
815
|
set(state => ({
|
|
835
|
-
|
|
836
|
-
balances: state.balances.concat(accounts.map(account => ({
|
|
816
|
+
connectedWallets: state.connectedWallets.concat(accounts.map(account => ({
|
|
837
817
|
balances: [],
|
|
838
818
|
address: account.address,
|
|
839
819
|
chain: account.chain,
|
|
@@ -847,14 +827,13 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
847
827
|
},
|
|
848
828
|
disconnectWallet: walletType => {
|
|
849
829
|
set(state => ({
|
|
850
|
-
|
|
851
|
-
balances: state.balances.filter(balance => balance.walletType !== walletType),
|
|
830
|
+
connectedWallets: state.connectedWallets.filter(balance => balance.walletType !== walletType),
|
|
852
831
|
selectedWallets: state.selectedWallets.filter(wallet => wallet.walletType != walletType)
|
|
853
832
|
}));
|
|
854
833
|
},
|
|
855
834
|
initSelectedWallets: () => set(state => {
|
|
856
835
|
const requiredChains = getRequiredChains(useBestRouteStore.getState().bestRoute);
|
|
857
|
-
const connectedWallets = state.
|
|
836
|
+
const connectedWallets = state.connectedWallets;
|
|
858
837
|
const selectedWallets = [];
|
|
859
838
|
requiredChains.forEach(chain => {
|
|
860
839
|
const anyWalletSelected = !!state.selectedWallets.find(wallet => wallet.chain === chain);
|
|
@@ -879,14 +858,13 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
879
858
|
})
|
|
880
859
|
})),
|
|
881
860
|
clearConnectedWallet: () => set(() => ({
|
|
882
|
-
|
|
883
|
-
balances: [],
|
|
861
|
+
connectedWallets: [],
|
|
884
862
|
selectedWallets: []
|
|
885
863
|
})),
|
|
886
864
|
getOneOfWalletsDetails: async account => {
|
|
887
865
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
888
866
|
set(state => ({
|
|
889
|
-
|
|
867
|
+
connectedWallets: state.connectedWallets.map(balance => {
|
|
890
868
|
return balance.address === account.address && balance.chain === account.chain ? {
|
|
891
869
|
...balance,
|
|
892
870
|
loading: true
|
|
@@ -901,28 +879,28 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
901
879
|
const retrivedBalance = response.wallets[0];
|
|
902
880
|
if (retrivedBalance) {
|
|
903
881
|
set(state => ({
|
|
904
|
-
|
|
905
|
-
return
|
|
882
|
+
connectedWallets: state.connectedWallets.map(connectedWallet => {
|
|
883
|
+
return isAccountAndWalletMatched(account, connectedWallet) ? makeBalanceFor(account, retrivedBalance, tokens) : connectedWallet;
|
|
906
884
|
})
|
|
907
885
|
}));
|
|
908
886
|
} else throw new Error('Wallet not found');
|
|
909
887
|
} catch (error) {
|
|
910
888
|
set(state => ({
|
|
911
|
-
|
|
912
|
-
return
|
|
889
|
+
connectedWallets: state.connectedWallets.map(balance => {
|
|
890
|
+
return isAccountAndWalletMatched(account, balance) ? resetConnectedWalletState(balance) : balance;
|
|
913
891
|
})
|
|
914
892
|
}));
|
|
915
893
|
}
|
|
916
894
|
}
|
|
917
895
|
}))));
|
|
918
|
-
useWalletsStore.subscribe(state => state.
|
|
896
|
+
useWalletsStore.subscribe(state => state.connectedWallets, connectedWallets => {
|
|
919
897
|
useBestRouteStore.setState(_ref => {
|
|
920
898
|
let {
|
|
921
899
|
sourceTokens,
|
|
922
900
|
destinationTokens
|
|
923
901
|
} = _ref;
|
|
924
|
-
const sourceTokensWithBalance = getTokensWithBalance(sourceTokens,
|
|
925
|
-
const destinationTokensWithBalance = getTokensWithBalance(destinationTokens,
|
|
902
|
+
const sourceTokensWithBalance = getTokensWithBalance(sourceTokens, connectedWallets);
|
|
903
|
+
const destinationTokensWithBalance = getTokensWithBalance(destinationTokens, connectedWallets);
|
|
926
904
|
return {
|
|
927
905
|
sourceTokens: sortTokens(sourceTokensWithBalance),
|
|
928
906
|
destinationTokens: sortTokens(destinationTokensWithBalance)
|
|
@@ -931,7 +909,7 @@ useWalletsStore.subscribe(state => state.balances, balances => {
|
|
|
931
909
|
}, {
|
|
932
910
|
equalityFn: shallow.shallow
|
|
933
911
|
});
|
|
934
|
-
const fetchingBalanceSelector = state => !!state.
|
|
912
|
+
const fetchingBalanceSelector = state => !!state.connectedWallets.find(wallet => wallet.loading);
|
|
935
913
|
|
|
936
914
|
const getUsdValue = (token, amount) => new BigNumber__default(amount || ZERO).multipliedBy(token?.usdPrice || 0);
|
|
937
915
|
const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.create()( /*#__PURE__*/middleware.subscribeWithSelector(set => ({
|
|
@@ -975,8 +953,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
975
953
|
set(state => {
|
|
976
954
|
if (state.fromChain?.name === chain?.name) return {};
|
|
977
955
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
978
|
-
const
|
|
979
|
-
const sortedTokens = getSortedTokens(chain, tokens,
|
|
956
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
957
|
+
const sortedTokens = getSortedTokens(chain, tokens, connectedWallets, state.destinationTokens);
|
|
980
958
|
const fromToken = getDefaultToken(sortedTokens, state.toToken);
|
|
981
959
|
return {
|
|
982
960
|
fromChain: chain,
|
|
@@ -1000,8 +978,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
1000
978
|
set(state => {
|
|
1001
979
|
if (state.toChain?.name === chain?.name) return {};
|
|
1002
980
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
1003
|
-
const
|
|
1004
|
-
const sortedTokens = getSortedTokens(chain, tokens,
|
|
981
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
982
|
+
const sortedTokens = getSortedTokens(chain, tokens, connectedWallets, state.destinationTokens);
|
|
1005
983
|
return {
|
|
1006
984
|
toChain: chain,
|
|
1007
985
|
destinationTokens: sortedTokens,
|
|
@@ -1033,7 +1011,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
1033
1011
|
tokens,
|
|
1034
1012
|
blockchains
|
|
1035
1013
|
} = useMetaStore.getState().meta;
|
|
1036
|
-
const
|
|
1014
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
1037
1015
|
const failedIndex = pendingSwap.status === 'failed' ? pendingSwap.steps.findIndex(s => s.status === 'failed') : null;
|
|
1038
1016
|
if (failedIndex === null || failedIndex < 0) return;
|
|
1039
1017
|
const firstStep = pendingSwap.steps[0];
|
|
@@ -1050,8 +1028,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
1050
1028
|
symbol: lastStep.toSymbol,
|
|
1051
1029
|
address: lastStep.toSymbolAddress
|
|
1052
1030
|
}));
|
|
1053
|
-
const sortedSourceTokens = getSortedTokens(fromChain, tokens,
|
|
1054
|
-
const sortedDestinationTokens = getSortedTokens(toChain, tokens,
|
|
1031
|
+
const sortedSourceTokens = getSortedTokens(fromChain, tokens, connectedWallets, []);
|
|
1032
|
+
const sortedDestinationTokens = getSortedTokens(toChain, tokens, connectedWallets, []);
|
|
1055
1033
|
const inputAmount = pendingSwap.inputAmount;
|
|
1056
1034
|
set({
|
|
1057
1035
|
fromChain,
|
|
@@ -1371,10 +1349,10 @@ const Container = /*#__PURE__*/ui.styled('div', {
|
|
|
1371
1349
|
variants: {
|
|
1372
1350
|
type: {
|
|
1373
1351
|
filled: {
|
|
1374
|
-
backgroundColor: '$
|
|
1352
|
+
backgroundColor: '$neutral100'
|
|
1375
1353
|
},
|
|
1376
1354
|
outlined: {
|
|
1377
|
-
border: '1px solid $
|
|
1355
|
+
border: '1px solid $neutral100'
|
|
1378
1356
|
}
|
|
1379
1357
|
}
|
|
1380
1358
|
},
|
|
@@ -1410,14 +1388,14 @@ const Container = /*#__PURE__*/ui.styled('div', {
|
|
|
1410
1388
|
const ImagePlaceholder = /*#__PURE__*/ui.styled('span', {
|
|
1411
1389
|
width: '24px',
|
|
1412
1390
|
height: '24px',
|
|
1413
|
-
backgroundColor: '$
|
|
1391
|
+
backgroundColor: '$neutral100',
|
|
1414
1392
|
borderRadius: '99999px'
|
|
1415
1393
|
});
|
|
1416
1394
|
const OutputContainer = /*#__PURE__*/ui.styled('div', {
|
|
1417
1395
|
windth: '100%',
|
|
1418
1396
|
height: '$48',
|
|
1419
1397
|
borderRadius: '$5',
|
|
1420
|
-
backgroundColor: '$
|
|
1398
|
+
backgroundColor: '$surface',
|
|
1421
1399
|
border: '1px solid transparent',
|
|
1422
1400
|
position: 'relative',
|
|
1423
1401
|
display: 'flex',
|
|
@@ -1451,10 +1429,10 @@ function TokenPreview(props) {
|
|
|
1451
1429
|
className: "head"
|
|
1452
1430
|
}, React__default.createElement(ui.Typography, {
|
|
1453
1431
|
variant: "body2",
|
|
1454
|
-
color: "
|
|
1432
|
+
color: "neutral800"
|
|
1455
1433
|
}, props.label), React__default.createElement("div", null, percentageChange, props.usdValue && React__default.createElement(ui.Typography, {
|
|
1456
1434
|
variant: "caption",
|
|
1457
|
-
color: "
|
|
1435
|
+
color: "neutral600",
|
|
1458
1436
|
className: "usd-value"
|
|
1459
1437
|
}, `$${numberToString(props.usdValue)}`))), React__default.createElement("div", {
|
|
1460
1438
|
className: "form"
|
|
@@ -1497,8 +1475,8 @@ const Container$1 = /*#__PURE__*/ui.styled('div', {
|
|
|
1497
1475
|
justifyContent: 'space-between',
|
|
1498
1476
|
padding: '$8',
|
|
1499
1477
|
borderRadius: '$5',
|
|
1500
|
-
backgroundColor: '$
|
|
1501
|
-
color: '$
|
|
1478
|
+
backgroundColor: '$neutral100',
|
|
1479
|
+
color: '$neutral800',
|
|
1502
1480
|
fontSize: '$12',
|
|
1503
1481
|
'.routes': {
|
|
1504
1482
|
display: 'flex',
|
|
@@ -1558,7 +1536,7 @@ function useConfirmSwap() {
|
|
|
1558
1536
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
1559
1537
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1560
1538
|
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
1561
|
-
const
|
|
1539
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
1562
1540
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
1563
1541
|
const meta = useMetaStore.use.meta();
|
|
1564
1542
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
@@ -1597,7 +1575,7 @@ function useConfirmSwap() {
|
|
|
1597
1575
|
}
|
|
1598
1576
|
abortControllerRef.current = new AbortController();
|
|
1599
1577
|
setLoading(true);
|
|
1600
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount,
|
|
1578
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, connectedWallets, selectedWallets, disabledLiquiditySources, userSlippage, affiliateRef, initialRoute);
|
|
1601
1579
|
try {
|
|
1602
1580
|
const confiremedRoute = await httpService().getBestRoute(requestBody, {
|
|
1603
1581
|
signal: abortControllerRef.current?.signal
|
|
@@ -1841,7 +1819,7 @@ function ConfirmSwapPage() {
|
|
|
1841
1819
|
tokens
|
|
1842
1820
|
} = useMetaStore.use.meta();
|
|
1843
1821
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
1844
|
-
const
|
|
1822
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
1845
1823
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
1846
1824
|
const initSelectedWallets = useWalletsStore.use.initSelectedWallets();
|
|
1847
1825
|
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
@@ -1850,6 +1828,7 @@ function ConfirmSwapPage() {
|
|
|
1850
1828
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1851
1829
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
1852
1830
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1831
|
+
const [dbErrorMessage, setDbErrorMessage] = React.useState('');
|
|
1853
1832
|
const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
|
|
1854
1833
|
const {
|
|
1855
1834
|
manager
|
|
@@ -1874,7 +1853,7 @@ function ConfirmSwapPage() {
|
|
|
1874
1853
|
React.useEffect(() => {
|
|
1875
1854
|
initSelectedWallets();
|
|
1876
1855
|
}, []);
|
|
1877
|
-
const selectableWallets = getSelectableWallets(
|
|
1856
|
+
const selectableWallets = getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo);
|
|
1878
1857
|
const handleConnectChain = wallet => {
|
|
1879
1858
|
const network = wallet;
|
|
1880
1859
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
@@ -1884,21 +1863,25 @@ function ConfirmSwapPage() {
|
|
|
1884
1863
|
requiredWallets: getRequiredChains(bestRoute),
|
|
1885
1864
|
selectableWallets: selectableWallets,
|
|
1886
1865
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
1887
|
-
onConfirm: () => {
|
|
1888
|
-
confirmSwap?.().then(swap => {
|
|
1866
|
+
onConfirm: async () => {
|
|
1867
|
+
confirmSwap?.().then(async swap => {
|
|
1889
1868
|
if (swap) {
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1869
|
+
try {
|
|
1870
|
+
await manager?.create('swap', {
|
|
1871
|
+
swapDetails: swap
|
|
1872
|
+
}, {
|
|
1873
|
+
id: swap.requestId
|
|
1874
|
+
});
|
|
1875
|
+
setSelectedSwap(swap.requestId);
|
|
1876
|
+
navigate('/' + navigationRoutes.swaps + `/${swap.requestId}`, {
|
|
1877
|
+
replace: true
|
|
1878
|
+
});
|
|
1879
|
+
setTimeout(() => {
|
|
1880
|
+
setInputAmount('');
|
|
1881
|
+
}, 0);
|
|
1882
|
+
} catch (e) {
|
|
1883
|
+
setDbErrorMessage('Error: ' + e?.message);
|
|
1884
|
+
}
|
|
1902
1885
|
}
|
|
1903
1886
|
});
|
|
1904
1887
|
},
|
|
@@ -1945,7 +1928,7 @@ function ConfirmSwapPage() {
|
|
|
1945
1928
|
totalFee: numberToString(totalFeeInUsd, 0, 2)
|
|
1946
1929
|
}),
|
|
1947
1930
|
loading: fetchingConfirmedRoute,
|
|
1948
|
-
errors: ConfirmSwapErrors(errors),
|
|
1931
|
+
errors: dbErrorMessage ? [dbErrorMessage, ...ConfirmSwapErrors(errors)] : ConfirmSwapErrors(errors),
|
|
1949
1932
|
warnings: ConfirmSwapWarnings(warnings),
|
|
1950
1933
|
extraMessages: React__default.createElement(React__default.Fragment, null, loadingMetaStatus === 'failed' && React__default.createElement(ui.LoadingFailedAlert, null), loadingMetaStatus === 'failed' && showHighSlippageWarning && React__default.createElement(ui.Spacer, {
|
|
1951
1934
|
direction: "vertical"
|
|
@@ -2039,10 +2022,11 @@ const Container$2 = /*#__PURE__*/ui.styled('div', {
|
|
|
2039
2022
|
variants: {
|
|
2040
2023
|
type: {
|
|
2041
2024
|
filled: {
|
|
2042
|
-
backgroundColor: '$
|
|
2025
|
+
backgroundColor: '$neutral100'
|
|
2043
2026
|
},
|
|
2044
2027
|
outlined: {
|
|
2045
|
-
border: '1px solid $
|
|
2028
|
+
border: '1px solid $neutral100',
|
|
2029
|
+
backgroundColor: '$surface'
|
|
2046
2030
|
}
|
|
2047
2031
|
}
|
|
2048
2032
|
},
|
|
@@ -2090,14 +2074,14 @@ const Options = /*#__PURE__*/ui.styled('div', {
|
|
|
2090
2074
|
const ImagePlaceholder$1 = /*#__PURE__*/ui.styled('span', {
|
|
2091
2075
|
width: '24px',
|
|
2092
2076
|
height: '24px',
|
|
2093
|
-
backgroundColor: '$
|
|
2077
|
+
backgroundColor: '$neutral100',
|
|
2094
2078
|
borderRadius: '99999px'
|
|
2095
2079
|
});
|
|
2096
2080
|
const OutputContainer$1 = /*#__PURE__*/ui.styled('div', {
|
|
2097
2081
|
windth: '100%',
|
|
2098
2082
|
height: '$48',
|
|
2099
2083
|
borderRadius: '$5',
|
|
2100
|
-
backgroundColor: '$
|
|
2084
|
+
backgroundColor: '$surface',
|
|
2101
2085
|
border: '1px solid transparent',
|
|
2102
2086
|
position: 'relative',
|
|
2103
2087
|
display: 'flex',
|
|
@@ -2119,14 +2103,14 @@ function TokenInfo(props) {
|
|
|
2119
2103
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2120
2104
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
2121
2105
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
2122
|
-
const
|
|
2106
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
2123
2107
|
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
2124
2108
|
const navigate = reactRouterDom.useNavigate();
|
|
2125
2109
|
const {
|
|
2126
2110
|
t
|
|
2127
2111
|
} = reactI18next.useTranslation();
|
|
2128
|
-
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(
|
|
2129
|
-
const tokenBalanceReal = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(
|
|
2112
|
+
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(connectedWallets, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', 8) : '0';
|
|
2113
|
+
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';
|
|
2130
2114
|
const ItemSuffix = React__default.createElement("div", {
|
|
2131
2115
|
style: {
|
|
2132
2116
|
display: 'flex',
|
|
@@ -2143,7 +2127,7 @@ function TokenInfo(props) {
|
|
|
2143
2127
|
className: "head"
|
|
2144
2128
|
}, React__default.createElement(ui.Typography, {
|
|
2145
2129
|
variant: "body2",
|
|
2146
|
-
color: "
|
|
2130
|
+
color: "neutral800"
|
|
2147
2131
|
}, t(type)), props.type === 'From' ? React__default.createElement(Options, null, React__default.createElement("div", {
|
|
2148
2132
|
className: "balance",
|
|
2149
2133
|
onClick: () => {
|
|
@@ -2151,7 +2135,7 @@ function TokenInfo(props) {
|
|
|
2151
2135
|
}
|
|
2152
2136
|
}, React__default.createElement(ui.Typography, {
|
|
2153
2137
|
variant: "body3",
|
|
2154
|
-
color: "
|
|
2138
|
+
color: "neutral600"
|
|
2155
2139
|
}, `${t('Balance')}: ${tokenBalance} ${fromToken?.symbol || ''}`), React__default.createElement(ui.Spacer, {
|
|
2156
2140
|
size: 4
|
|
2157
2141
|
}), React__default.createElement(ui.Button, {
|
|
@@ -2165,7 +2149,7 @@ function TokenInfo(props) {
|
|
|
2165
2149
|
outputUsdValue: props.outputUsdValue
|
|
2166
2150
|
}), React__default.createElement("div", null, React__default.createElement(ui.Typography, {
|
|
2167
2151
|
variant: "caption",
|
|
2168
|
-
color: "
|
|
2152
|
+
color: "neutral600"
|
|
2169
2153
|
}, `$${numberToString(props.outputUsdValue)}`)))), React__default.createElement("div", {
|
|
2170
2154
|
className: "form"
|
|
2171
2155
|
}, React__default.createElement(ui.Button, {
|
|
@@ -2221,7 +2205,7 @@ function TokenInfo(props) {
|
|
|
2221
2205
|
}
|
|
2222
2206
|
}, React__default.createElement(ui.Typography, {
|
|
2223
2207
|
variant: "caption",
|
|
2224
|
-
color: "
|
|
2208
|
+
color: "neutral800"
|
|
2225
2209
|
}, `$${numberToString(inputUsdValue)}`)),
|
|
2226
2210
|
value: props.inputAmount || '',
|
|
2227
2211
|
min: 0,
|
|
@@ -2257,7 +2241,7 @@ function BottomLogo() {
|
|
|
2257
2241
|
} = reactI18next.useTranslation();
|
|
2258
2242
|
return React__default.createElement(Container$3, null, React__default.createElement(ui.Typography, {
|
|
2259
2243
|
variant: "caption",
|
|
2260
|
-
color: "$
|
|
2244
|
+
color: "$neutral600"
|
|
2261
2245
|
}, t('Powered By')), React__default.createElement(StyledAnchor, {
|
|
2262
2246
|
href: "https://rango.exchange",
|
|
2263
2247
|
target: "_blank"
|
|
@@ -2401,7 +2385,7 @@ function Home() {
|
|
|
2401
2385
|
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
2402
2386
|
const bestRouteError = useBestRouteStore.use.error();
|
|
2403
2387
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2404
|
-
const
|
|
2388
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
2405
2389
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
2406
2390
|
const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
|
|
2407
2391
|
const errorMessage = loadingMetaStatus === 'failed' ? errorMessages.genericServerError : bestRouteError;
|
|
@@ -2415,7 +2399,7 @@ function Home() {
|
|
|
2415
2399
|
swap
|
|
2416
2400
|
} = LimitErrorMessage(bestRoute);
|
|
2417
2401
|
const priceImpactCanNotBeComputed = !canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue);
|
|
2418
|
-
const swapButtonState = getSwapButtonState(loadingMetaStatus,
|
|
2402
|
+
const swapButtonState = getSwapButtonState(loadingMetaStatus, connectedWallets, fetchingBestRoute, bestRoute, hasLimitError(bestRoute), highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputAmount);
|
|
2419
2403
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2420
2404
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
2421
2405
|
React.useEffect(() => {
|
|
@@ -2575,7 +2559,8 @@ function SelectTokenPage(props) {
|
|
|
2575
2559
|
|
|
2576
2560
|
function SettingsPage(_ref) {
|
|
2577
2561
|
let {
|
|
2578
|
-
supportedSwappers
|
|
2562
|
+
supportedSwappers,
|
|
2563
|
+
singleTheme
|
|
2579
2564
|
} = _ref;
|
|
2580
2565
|
const slippage = useSettingsStore.use.slippage();
|
|
2581
2566
|
const setSlippage = useSettingsStore.use.setSlippage();
|
|
@@ -2617,6 +2602,7 @@ function SettingsPage(_ref) {
|
|
|
2617
2602
|
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2618
2603
|
liquiditySources: supportedUniqueSwappersGroups,
|
|
2619
2604
|
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2605
|
+
singleTheme: singleTheme,
|
|
2620
2606
|
customSlippage: customSlippage || NaN,
|
|
2621
2607
|
onCustomSlippageChange: setCustomSlippage,
|
|
2622
2608
|
minSlippage: MIN_SLIPPGAE,
|
|
@@ -2928,6 +2914,7 @@ function AppRoutes(props) {
|
|
|
2928
2914
|
}, {
|
|
2929
2915
|
path: navigationRoutes.settings,
|
|
2930
2916
|
element: React__default.createElement(SettingsPage, {
|
|
2917
|
+
singleTheme: config?.theme?.singleTheme,
|
|
2931
2918
|
supportedSwappers: config?.liquiditySources
|
|
2932
2919
|
})
|
|
2933
2920
|
}, {
|
|
@@ -2974,14 +2961,13 @@ function Layout(_ref) {
|
|
|
2974
2961
|
} = _ref;
|
|
2975
2962
|
const navigate = reactRouterDom.useNavigate();
|
|
2976
2963
|
const {
|
|
2977
|
-
|
|
2978
|
-
accounts,
|
|
2964
|
+
connectedWallets,
|
|
2979
2965
|
selectedWallets
|
|
2980
2966
|
} = useWalletsStore();
|
|
2981
2967
|
const {
|
|
2982
2968
|
getWalletInfo
|
|
2983
2969
|
} = walletsCore.useWallets();
|
|
2984
|
-
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(
|
|
2970
|
+
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2985
2971
|
const {
|
|
2986
2972
|
blockchains,
|
|
2987
2973
|
tokens
|
|
@@ -2992,7 +2978,7 @@ function Layout(_ref) {
|
|
|
2992
2978
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
2993
2979
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2994
2980
|
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
2995
|
-
const totalBalance = calculateWalletUsdValue(
|
|
2981
|
+
const totalBalance = calculateWalletUsdValue(connectedWallets);
|
|
2996
2982
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
2997
2983
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2998
2984
|
const fetchingBalance = useWalletsStore(fetchingBalanceSelector);
|
|
@@ -3000,20 +2986,24 @@ function Layout(_ref) {
|
|
|
3000
2986
|
t
|
|
3001
2987
|
} = reactI18next.useTranslation();
|
|
3002
2988
|
React.useEffect(() => {
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
2989
|
+
if (loadingMetaStatus === 'success') {
|
|
2990
|
+
const chain = blockchains.find(chain => chain.name === config?.to?.blockchain);
|
|
2991
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.to?.token || null));
|
|
2992
|
+
setToChain(chain || null);
|
|
2993
|
+
setToToken(token || null);
|
|
2994
|
+
}
|
|
2995
|
+
}, [config?.to?.token, config?.to?.blockchain, loadingMetaStatus]);
|
|
3008
2996
|
React.useEffect(() => {
|
|
3009
2997
|
setInputAmount(config?.amount?.toString() || '');
|
|
3010
2998
|
}, [config?.amount]);
|
|
3011
2999
|
React.useEffect(() => {
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3000
|
+
if (loadingMetaStatus === 'success') {
|
|
3001
|
+
const chain = blockchains.find(chain => chain.name === config?.from?.blockchain);
|
|
3002
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.from?.token || null));
|
|
3003
|
+
setFromChain(chain || null);
|
|
3004
|
+
setFromToken(token || null);
|
|
3005
|
+
}
|
|
3006
|
+
}, [config?.from?.token, config?.from?.blockchain, loadingMetaStatus]);
|
|
3017
3007
|
React.useEffect(() => {
|
|
3018
3008
|
setAffiliateRef(config?.affiliateRef || null);
|
|
3019
3009
|
}, [config?.affiliateRef]);
|
|
@@ -3038,7 +3028,7 @@ function Layout(_ref) {
|
|
|
3038
3028
|
className: "balance"
|
|
3039
3029
|
}, React__default.createElement(ui.Typography, {
|
|
3040
3030
|
variant: "body2"
|
|
3041
|
-
}, !
|
|
3031
|
+
}, !connectedWallets?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React__default.createElement(ui.Spinner, null)))), React__default.createElement(AppRoutes, {
|
|
3042
3032
|
config: config
|
|
3043
3033
|
}));
|
|
3044
3034
|
}
|
|
@@ -3072,89 +3062,66 @@ function useTheme(_ref) {
|
|
|
3072
3062
|
const theme = useSettingsStore.use.theme();
|
|
3073
3063
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
3074
3064
|
const setTheme = useSettingsStore.use.setTheme();
|
|
3075
|
-
const
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
primary700: shadeColor(primary, -35),
|
|
3098
|
-
primary800: shadeColor(primary, -40),
|
|
3099
|
-
primary900: shadeColor(primary, -45),
|
|
3065
|
+
const light = themeColors?.light;
|
|
3066
|
+
const dark = themeColors?.dark;
|
|
3067
|
+
const neutral = light?.neutral || '#fafafa';
|
|
3068
|
+
const background = light?.background || '#fff';
|
|
3069
|
+
const foreground = light?.foreground || '#000';
|
|
3070
|
+
const darkColors = {
|
|
3071
|
+
...ui.generateRangeColors('primary', 'dark', dark?.primary),
|
|
3072
|
+
...ui.generateRangeColors('error', 'dark', dark?.error),
|
|
3073
|
+
...ui.generateRangeColors('warning', 'dark', dark?.warning),
|
|
3074
|
+
...ui.generateRangeColors('success', 'dark', dark?.success),
|
|
3075
|
+
...ui.generateRangeColors('neutral', 'dark', dark?.neutral),
|
|
3076
|
+
surface: dark?.surface,
|
|
3077
|
+
background: dark?.background,
|
|
3078
|
+
foreground: dark?.foreground
|
|
3079
|
+
};
|
|
3080
|
+
const lightColors = {
|
|
3081
|
+
surface: light?.surface || '#fff',
|
|
3082
|
+
...ui.generateRangeColors('primary', 'light', light?.primary || '#5FA425'),
|
|
3083
|
+
...ui.generateRangeColors('error', 'light', light?.error || '#FF0000'),
|
|
3084
|
+
...ui.generateRangeColors('warning', 'light', light?.warning || '#F5A623'),
|
|
3085
|
+
...ui.generateRangeColors('success', 'light', light?.success || '#0070F3'),
|
|
3086
|
+
...ui.generateRangeColors('neutral', 'light', neutral),
|
|
3100
3087
|
background,
|
|
3101
|
-
foreground
|
|
3102
|
-
error,
|
|
3103
|
-
error100: shadeColor(error, 50),
|
|
3104
|
-
error300: shadeColor(error, -10),
|
|
3105
|
-
error500: shadeColor(error, -20),
|
|
3106
|
-
error700: shadeColor(error, -30),
|
|
3107
|
-
warning,
|
|
3108
|
-
warning100: shadeColor(warning, 50),
|
|
3109
|
-
warning300: shadeColor(warning, -10),
|
|
3110
|
-
warning500: shadeColor(warning, -20),
|
|
3111
|
-
warning700: shadeColor(warning, -30),
|
|
3112
|
-
success,
|
|
3113
|
-
success100: shadeColor(success, 50),
|
|
3114
|
-
success300: shadeColor(success, -10),
|
|
3115
|
-
success500: shadeColor(success, -20),
|
|
3116
|
-
success700: shadeColor(success, -30)
|
|
3088
|
+
foreground
|
|
3117
3089
|
};
|
|
3118
3090
|
const customeLightTheme = ui.createTheme({
|
|
3119
|
-
colors,
|
|
3091
|
+
colors: lightColors,
|
|
3120
3092
|
radii: {
|
|
3121
3093
|
5: `${borderRadius}px`
|
|
3122
3094
|
},
|
|
3123
3095
|
shadows: {
|
|
3124
|
-
s:
|
|
3096
|
+
s: `0px 3px 5px 3px ${light?.neutral || '#f0f2f5'} ,0px 6px 10px 3px ${light?.neutral || '#f0f2f5'}, 0px 1px 18px 3px ${light?.neutral || '#f0f2f5'}`
|
|
3125
3097
|
}
|
|
3126
3098
|
});
|
|
3127
3099
|
const customeDarkTheme = ui.createTheme({
|
|
3128
3100
|
colors: {
|
|
3129
|
-
...
|
|
3130
|
-
|
|
3131
|
-
neutrals300: '#333333',
|
|
3132
|
-
neutrals400: '#444444',
|
|
3133
|
-
neutrals500: '#acacac',
|
|
3134
|
-
neutrals600: '#cccccc',
|
|
3135
|
-
neutrals700: '#dedede',
|
|
3136
|
-
neutrals800: '#f2f2f2',
|
|
3137
|
-
neutrals900: '#FAFAFA',
|
|
3101
|
+
...lightColors,
|
|
3102
|
+
...ui.generateRangeColors('neutral', 'dark', '#111111'),
|
|
3138
3103
|
foreground: background,
|
|
3139
|
-
background: foreground
|
|
3104
|
+
background: foreground,
|
|
3105
|
+
surface: '#000',
|
|
3106
|
+
...JSON.parse(JSON.stringify(darkColors))
|
|
3140
3107
|
},
|
|
3141
3108
|
radii: {
|
|
3142
3109
|
5: `${borderRadius}px`
|
|
3143
3110
|
},
|
|
3144
3111
|
shadows: {
|
|
3145
|
-
s:
|
|
3112
|
+
s: `0px 3px 5px 3px ${dark?.neutral || '#222'}, 0px 6px 10px 3px ${dark?.neutral || '#222'}, 0px 1px 18px 3px ${dark?.neutral || '#222'}`
|
|
3146
3113
|
}
|
|
3147
3114
|
});
|
|
3148
|
-
const [OSTheme, setOSTheme] = React.useState(
|
|
3115
|
+
const [OSTheme, setOSTheme] = React.useState('light');
|
|
3149
3116
|
React.useEffect(() => {
|
|
3150
3117
|
(async () => {
|
|
3151
3118
|
await fetchMeta();
|
|
3152
3119
|
})();
|
|
3153
3120
|
const switchTheme = event => {
|
|
3154
|
-
if (event.matches) setOSTheme(
|
|
3121
|
+
if (event.matches) setOSTheme('dark');else setOSTheme('light');
|
|
3155
3122
|
};
|
|
3156
3123
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
3157
|
-
setOSTheme(
|
|
3124
|
+
setOSTheme('dark');
|
|
3158
3125
|
}
|
|
3159
3126
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', switchTheme);
|
|
3160
3127
|
return () => {
|
|
@@ -3173,7 +3140,7 @@ function useTheme(_ref) {
|
|
|
3173
3140
|
classList.add(`font_${fontFamily.replace(/ /g, '')}`);
|
|
3174
3141
|
}, [fontFamily]);
|
|
3175
3142
|
const getActiveTheme = () => {
|
|
3176
|
-
if (theme === 'auto') return OSTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
3143
|
+
if (theme === 'auto') return OSTheme === 'dark' ? customeDarkTheme : customeLightTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
3177
3144
|
};
|
|
3178
3145
|
return {
|
|
3179
3146
|
activeTheme: getActiveTheme()
|
|
@@ -3274,13 +3241,12 @@ function QueueManager(props) {
|
|
|
3274
3241
|
});
|
|
3275
3242
|
}, []);
|
|
3276
3243
|
const getOneOfWalletsDetails = useWalletsStore.use.getOneOfWalletsDetails();
|
|
3277
|
-
const accounts = useWalletsStore.use.accounts();
|
|
3278
3244
|
const {
|
|
3279
3245
|
blockchains
|
|
3280
3246
|
} = useMetaStore.use.meta();
|
|
3281
|
-
const
|
|
3247
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
3282
3248
|
const wallets = {
|
|
3283
|
-
blockchains:
|
|
3249
|
+
blockchains: connectedWallets.map(wallet => ({
|
|
3284
3250
|
accounts: [wallet],
|
|
3285
3251
|
name: wallet.chain
|
|
3286
3252
|
}))
|
|
@@ -3306,8 +3272,8 @@ function QueueManager(props) {
|
|
|
3306
3272
|
const outputAmount = data.step?.outputAmount || '';
|
|
3307
3273
|
const step = data.step || lastStep;
|
|
3308
3274
|
if (data.eventType === 'task_completed' || data.eventType === 'step_completed_with_output' && lastStep?.id !== data.step?.id || !!outputAmount) {
|
|
3309
|
-
const fromAccount =
|
|
3310
|
-
const toAccount = step?.fromBlockchain !== step?.toBlockchain &&
|
|
3275
|
+
const fromAccount = connectedWallets.find(account => account.chain === step?.fromBlockchain);
|
|
3276
|
+
const toAccount = step?.fromBlockchain !== step?.toBlockchain && connectedWallets.find(wallet => wallet.chain === step?.toBlockchain);
|
|
3311
3277
|
fromAccount && getOneOfWalletsDetails(fromAccount);
|
|
3312
3278
|
toAccount && getOneOfWalletsDetails(toAccount);
|
|
3313
3279
|
}
|
|
@@ -3329,10 +3295,7 @@ function QueueManager(props) {
|
|
|
3329
3295
|
state,
|
|
3330
3296
|
notifier
|
|
3331
3297
|
};
|
|
3332
|
-
return React__default.createElement(queueManagerReact.Provider
|
|
3333
|
-
//@ts-ignore
|
|
3334
|
-
, {
|
|
3335
|
-
//@ts-ignore
|
|
3298
|
+
return React__default.createElement(queueManagerReact.Provider, {
|
|
3336
3299
|
queuesDefs: [swapQueueDef],
|
|
3337
3300
|
context: context,
|
|
3338
3301
|
onPersistedDataLoaded: manager => {
|
|
@@ -3410,6 +3373,7 @@ const Widget = _ref => {
|
|
|
3410
3373
|
providers: providers,
|
|
3411
3374
|
onUpdateState: onUpdateState
|
|
3412
3375
|
}, React__default.createElement("div", {
|
|
3376
|
+
id: "swap-container",
|
|
3413
3377
|
className: activeTheme
|
|
3414
3378
|
}, React__default.createElement(QueueManager, null, React__default.createElement(ui.SwapContainer, {
|
|
3415
3379
|
fixedHeight: currentPage !== navigationRoutes.home
|