@rango-dev/widget-embedded 0.1.10-next.100 → 0.1.10-next.114
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/App.d.ts.map +1 -1
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +6 -1
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/HeaderButtons.d.ts +4 -1
- package/dist/components/HeaderButtons.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts +9 -0
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -0
- package/dist/components/TokenPreview.d.ts +1 -1
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/warnings/BalanceWarnings.d.ts.map +1 -1
- package/dist/components/warnings/MinRequiredSlippage.d.ts +1 -1
- package/dist/components/warnings/MinRequiredSlippage.d.ts.map +1 -1
- package/dist/constants/navigationRoutes.d.ts +0 -1
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/HistoryPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -0
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +2 -0
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +14 -0
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/routing.d.ts +1 -1
- package/dist/types/swap.d.ts +6 -0
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/date.d.ts +3 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/routing.d.ts +1 -0
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +16 -5
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +4 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +1039 -709
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +1039 -709
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +1048 -718
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +12 -11
- package/readme.md +1 -2
- package/src/App.tsx +30 -5
- package/src/QueueManager.tsx +5 -2
- package/src/components/AppRouter.tsx +24 -13
- package/src/components/AppRoutes.tsx +15 -12
- package/src/components/HeaderButtons.tsx +9 -2
- package/src/components/Layout.tsx +37 -5
- package/src/components/SwapDetailsPlaceholder.tsx +32 -0
- package/src/components/TokenPreview.tsx +7 -4
- package/src/components/UpdateUrl.tsx +1 -3
- package/src/components/warnings/BalanceWarnings.tsx +1 -0
- package/src/components/warnings/MinRequiredSlippage.tsx +9 -4
- package/src/constants/navigationRoutes.ts +0 -1
- package/src/globalStyles.ts +2 -1
- package/src/hooks/useConfirmSwap.ts +2 -1
- package/src/hooks/useNavigateBack.ts +3 -3
- package/src/lib.tsx +25 -3
- package/src/pages/ConfirmSwapPage.tsx +128 -20
- package/src/pages/HistoryPage.tsx +4 -4
- package/src/pages/Home.tsx +19 -8
- package/src/pages/LiquiditySourcesPage.tsx +2 -0
- package/src/pages/SelectTokenPage.tsx +3 -1
- package/src/pages/SettingsPage.tsx +3 -0
- package/src/pages/SwapDetailsPage.tsx +142 -6
- package/src/pages/WalletsPage.tsx +27 -8
- package/src/store/bestRoute.ts +110 -12
- package/src/store/ui.ts +4 -0
- package/src/store/wallets.ts +4 -1
- package/src/types/routing.ts +1 -1
- package/src/types/swap.ts +7 -0
- package/src/utils/common.ts +14 -0
- package/src/utils/date.ts +62 -0
- package/src/utils/routing.ts +23 -13
- package/src/utils/swap.ts +101 -10
- package/src/utils/time.ts +52 -0
- package/src/utils/wallets.ts +5 -2
- package/dist/components/Header.d.ts +0 -10
- package/dist/components/Header.d.ts.map +0 -1
- package/dist/pages/ConfirmWalletsPage.d.ts +0 -3
- package/dist/pages/ConfirmWalletsPage.d.ts.map +0 -1
- package/src/components/Header.tsx +0 -37
- package/src/pages/ConfirmWalletsPage.tsx +0 -127
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { css, styled, Typography } from '@rango-dev/ui';
|
|
3
|
-
import { HeaderButtons } from './HeaderButtons';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
|
|
6
|
-
export const HeaderContainer = styled('div', {
|
|
7
|
-
display: 'flex',
|
|
8
|
-
justifyContent: 'space-between',
|
|
9
|
-
alignItems: 'center',
|
|
10
|
-
width: '100%',
|
|
11
|
-
padding: '$16 0',
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export interface PropTypes {
|
|
15
|
-
onClickRefresh: () => void;
|
|
16
|
-
title?: string;
|
|
17
|
-
titleSize?: number;
|
|
18
|
-
titleWeight?: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function Header(props: PropTypes) {
|
|
22
|
-
const { onClickRefresh, title, titleSize, titleWeight } = props;
|
|
23
|
-
const { t } = useTranslation();
|
|
24
|
-
const titleStyle = css({
|
|
25
|
-
fontSize: `${titleSize}px !important`,
|
|
26
|
-
fontWeight: `${titleWeight} !important`,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<HeaderContainer>
|
|
31
|
-
<Typography variant="h4" className={titleStyle()}>
|
|
32
|
-
{title ? t(title.toLocaleLowerCase()) : ''}
|
|
33
|
-
</Typography>
|
|
34
|
-
<HeaderButtons onClickRefresh={onClickRefresh} />
|
|
35
|
-
</HeaderContainer>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import { ConfirmWallets } from '@rango-dev/ui';
|
|
3
|
-
import { useNavigate } from 'react-router-dom';
|
|
4
|
-
import { useBestRouteStore } from '../store/bestRoute';
|
|
5
|
-
import { useWalletsStore } from '../store/wallets';
|
|
6
|
-
import { useWallets } from '@rango-dev/wallets-core';
|
|
7
|
-
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
8
|
-
import {
|
|
9
|
-
getKeplrCompatibleConnectedWallets,
|
|
10
|
-
getRequiredChains,
|
|
11
|
-
getSelectableWallets,
|
|
12
|
-
isExperimentalChain,
|
|
13
|
-
} from '../utils/wallets';
|
|
14
|
-
import {
|
|
15
|
-
calcOutputUsdValue,
|
|
16
|
-
getTotalFeeInUsd,
|
|
17
|
-
requiredWallets,
|
|
18
|
-
} from '../utils/swap';
|
|
19
|
-
import { decimalNumber, numberToString } from '../utils/numbers';
|
|
20
|
-
import { useMetaStore } from '../store/meta';
|
|
21
|
-
import { Network, WalletType } from '@rango-dev/wallets-shared';
|
|
22
|
-
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
23
|
-
import { TokenPreview } from '../components/TokenPreview';
|
|
24
|
-
// @ts-ignore // TODO: fix error in tsc build
|
|
25
|
-
import { t } from 'i18next';
|
|
26
|
-
import { Spacer } from '@rango-dev/ui';
|
|
27
|
-
import RoutesOverview from '../components/RoutesOverview';
|
|
28
|
-
|
|
29
|
-
export function ConfirmWalletsPage() {
|
|
30
|
-
const navigate = useNavigate();
|
|
31
|
-
const { navigateBackFrom } = useNavigateBack();
|
|
32
|
-
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
33
|
-
|
|
34
|
-
const { blockchains, tokens } = useMetaStore.use.meta();
|
|
35
|
-
const accounts = useWalletsStore.use.accounts();
|
|
36
|
-
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
37
|
-
const initSelectedWallets = useWalletsStore.use.initSelectedWallets();
|
|
38
|
-
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
39
|
-
|
|
40
|
-
const { getWalletInfo, connect } = useWallets();
|
|
41
|
-
const confirmDisabled = !requiredWallets(bestRoute).every((chain) =>
|
|
42
|
-
selectedWallets.map((wallet) => wallet.chain).includes(chain)
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const firstStep = bestRoute?.result?.swaps[0];
|
|
46
|
-
const lastStep =
|
|
47
|
-
bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1];
|
|
48
|
-
|
|
49
|
-
const fromAmount = decimalNumber(firstStep?.fromAmount, 3);
|
|
50
|
-
const toAmount = decimalNumber(lastStep?.toAmount, 3);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
initSelectedWallets();
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
|
-
const selectableWallets = getSelectableWallets(
|
|
56
|
-
accounts,
|
|
57
|
-
selectedWallets,
|
|
58
|
-
getWalletInfo
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const handleConnectChain = (wallet: string) => {
|
|
62
|
-
const network = wallet as Network;
|
|
63
|
-
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(
|
|
64
|
-
(compatibleWallet: WalletType) => connect?.(compatibleWallet, network)
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<ConfirmWallets
|
|
72
|
-
requiredWallets={getRequiredChains(bestRoute)}
|
|
73
|
-
selectableWallets={selectableWallets}
|
|
74
|
-
onBack={navigateBackFrom.bind(null, navigationRoutes.confirmWallets)}
|
|
75
|
-
onConfirm={() =>
|
|
76
|
-
navigate(navigationRoutes.confirmSwap, { replace: true })
|
|
77
|
-
}
|
|
78
|
-
onChange={(wallet) => setSelectedWallet(wallet)}
|
|
79
|
-
confirmDisabled={confirmDisabled}
|
|
80
|
-
handleConnectChain={(wallet) => handleConnectChain(wallet)}
|
|
81
|
-
isExperimentalChain={(wallet) =>
|
|
82
|
-
getKeplrCompatibleConnectedWallets(selectableWallets).length > 0
|
|
83
|
-
? isExperimentalChain(blockchains, wallet)
|
|
84
|
-
: false
|
|
85
|
-
}
|
|
86
|
-
previewInputs={
|
|
87
|
-
<>
|
|
88
|
-
<TokenPreview
|
|
89
|
-
chain={{
|
|
90
|
-
displayName: firstStep?.from.blockchain || '',
|
|
91
|
-
logo: firstStep?.from.blockchainLogo || '',
|
|
92
|
-
}}
|
|
93
|
-
token={{
|
|
94
|
-
symbol: firstStep?.from.symbol || '',
|
|
95
|
-
image: firstStep?.from.logo || '',
|
|
96
|
-
}}
|
|
97
|
-
usdValue={calcOutputUsdValue(fromAmount, firstStep?.from.usdPrice)}
|
|
98
|
-
amount={fromAmount}
|
|
99
|
-
label={t('From')}
|
|
100
|
-
loadingStatus={'success'}
|
|
101
|
-
/>
|
|
102
|
-
<Spacer size={12} direction="vertical" />
|
|
103
|
-
<TokenPreview
|
|
104
|
-
chain={{
|
|
105
|
-
displayName: lastStep?.to.blockchain || '',
|
|
106
|
-
logo: lastStep?.to.blockchainLogo || '',
|
|
107
|
-
}}
|
|
108
|
-
token={{
|
|
109
|
-
symbol: lastStep?.to.symbol || '',
|
|
110
|
-
image: lastStep?.to.logo || '',
|
|
111
|
-
}}
|
|
112
|
-
usdValue={calcOutputUsdValue(toAmount, lastStep?.to.usdPrice)}
|
|
113
|
-
amount={toAmount}
|
|
114
|
-
label={t('To')}
|
|
115
|
-
loadingStatus={'success'}
|
|
116
|
-
/>
|
|
117
|
-
</>
|
|
118
|
-
}
|
|
119
|
-
previewRoutes={
|
|
120
|
-
<RoutesOverview
|
|
121
|
-
routes={bestRoute}
|
|
122
|
-
totalFee={numberToString(totalFeeInUsd, 0, 2)}
|
|
123
|
-
/>
|
|
124
|
-
}
|
|
125
|
-
/>
|
|
126
|
-
);
|
|
127
|
-
}
|