@rango-dev/widget-embedded 0.20.1-next.2 → 0.20.1-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +169 -1
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +4 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +514 -1088
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +12 -0
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
- package/dist/components/CustomCollapsible/CustomCollapsible.d.ts +5 -0
- package/dist/components/CustomCollapsible/CustomCollapsible.d.ts.map +1 -0
- package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts +654 -0
- package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts.map +1 -0
- package/dist/components/CustomCollapsible/CustomCollapsible.types.d.ts +10 -0
- package/dist/components/CustomCollapsible/CustomCollapsible.types.d.ts.map +1 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +179 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +0 -2
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/HeaderButtons/RefreshButton.d.ts +6 -0
- package/dist/components/HeaderButtons/RefreshButton.d.ts.map +1 -0
- package/dist/components/Layout/Layout.d.ts +2 -3
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.helpers.d.ts +2 -0
- package/dist/components/Layout/Layout.helpers.d.ts.map +1 -0
- package/dist/components/Layout/Layout.styles.d.ts +14 -4
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.types.d.ts +6 -3
- package/dist/components/Layout/Layout.types.d.ts.map +1 -1
- package/dist/components/Layout/PageContainer.d.ts +166 -0
- package/dist/components/Layout/PageContainer.d.ts.map +1 -0
- package/dist/components/Layout/ScrollableArea.d.ts +164 -0
- package/dist/components/Layout/ScrollableArea.d.ts.map +1 -0
- package/dist/components/Layout/index.d.ts +2 -0
- package/dist/components/Layout/index.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +4 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +56 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.styles.d.ts +12 -0
- package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +16 -0
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +386 -2
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.types.d.ts +19 -0
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.d.ts +4 -0
- package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -0
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts +806 -0
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -0
- package/dist/components/Quote/QuoteSummary.d.ts.map +1 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +8 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
- package/dist/components/Quote/QuoteTrigger .d.ts +4 -0
- package/dist/components/Quote/QuoteTrigger .d.ts.map +1 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +16 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +40 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +20 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +16 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +4 -0
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +11 -156
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
- package/dist/components/SettingsContainer/index.d.ts +1 -1
- package/dist/components/SettingsContainer/index.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +20 -0
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +523 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +4 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +4 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +20 -0
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +68 -0
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts +16 -0
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/quote.d.ts +12 -0
- package/dist/constants/quote.d.ts.map +1 -0
- package/dist/containers/App/App.d.ts.map +1 -1
- package/dist/containers/App/App.styles.d.ts +4 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +10 -314
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -7
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +5 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
- package/dist/hooks/useLanguage.d.ts +2 -1
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +4 -4
- 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/LanguagePage.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +2 -2
- package/dist/store/app.d.ts +2 -2
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +2 -2
- package/dist/store/slices/settings.d.ts.map +1 -1
- package/dist/types/config.d.ts +16 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/notification.d.ts +1 -2
- package/dist/types/notification.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +8 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +5 -1
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +1 -1
- package/dist/utils/swap.d.ts +5 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/ui.d.ts +2 -0
- package/dist/utils/ui.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/components/BlockchainList/BlockchainList.styles.ts +4 -3
- package/src/components/BlockchainList/BlockchainList.tsx +1 -1
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +27 -96
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +25 -40
- package/src/components/CustomCollapsible/CustomCollapsible.styles.ts +75 -0
- package/src/components/CustomCollapsible/CustomCollapsible.tsx +55 -0
- package/src/components/CustomCollapsible/CustomCollapsible.types.ts +10 -0
- package/src/components/HeaderButtons/HeaderButtons.styles.ts +16 -1
- package/src/components/HeaderButtons/HeaderButtons.types.ts +0 -2
- package/src/components/HeaderButtons/HomeButtons.tsx +19 -33
- package/src/components/HeaderButtons/RefreshButton.tsx +81 -0
- package/src/components/Layout/Layout.helpers.ts +16 -0
- package/src/components/Layout/Layout.styles.ts +17 -31
- package/src/components/Layout/Layout.tsx +23 -21
- package/src/components/Layout/Layout.types.ts +9 -8
- package/src/components/Layout/PageContainer.tsx +24 -0
- package/src/components/Layout/ScrollableArea.tsx +11 -0
- package/src/components/Layout/index.ts +2 -0
- package/src/components/NotificationContent/NotificationContent.tsx +10 -1
- package/src/components/Quote/Quote.styles.ts +44 -5
- package/src/components/Quote/Quote.tsx +10 -77
- package/src/components/Quote/Quote.types.ts +22 -0
- package/src/components/Quote/QuoteCostDetails.styles.ts +50 -0
- package/src/components/Quote/QuoteCostDetails.tsx +218 -0
- package/src/components/Quote/QuoteSummary.tsx +3 -2
- package/src/components/Quote/QuoteTrigger .tsx +215 -0
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +0 -1
- package/src/components/SettingsContainer/SettingsContainer.style.ts +0 -5
- package/src/components/SettingsContainer/index.ts +0 -1
- package/src/components/Slippage/Slippage.tsx +5 -5
- package/src/components/Slippage/SlippageTooltipContent.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +12 -13
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +43 -3
- package/src/components/SwapDetails/SwapDetails.styles.ts +18 -6
- package/src/components/SwapDetails/SwapDetails.tsx +13 -5
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.tsx +13 -7
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +2 -0
- package/src/components/SwapsGroup/SwapsGroup.tsx +18 -7
- package/src/components/TokenList/TokenList.styles.ts +2 -0
- package/src/components/TokenList/TokenList.tsx +1 -1
- package/src/components/WidgetEvents.tsx +2 -14
- package/src/constants/index.ts +1 -0
- package/src/constants/quote.ts +23 -0
- package/src/containers/App/App.styles.ts +2 -0
- package/src/containers/App/App.tsx +1 -4
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -15
- package/src/containers/QuoteInfo/QuoteInfo.tsx +30 -77
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -7
- package/src/containers/Wallets/Wallets.tsx +11 -2
- package/src/containers/WidgetInfo/WidgetInfo.tsx +8 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +5 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +2 -1
- package/src/hooks/useLanguage.ts +6 -4
- package/src/hooks/useSwapInput.ts +6 -2
- package/src/hooks/useSyncStoresWithConfig.ts +17 -34
- package/src/index.ts +4 -2
- package/src/pages/ConfirmSwapPage.tsx +59 -50
- package/src/pages/HistoryPage.tsx +4 -11
- package/src/pages/Home.tsx +40 -38
- package/src/pages/LanguagePage.tsx +3 -4
- package/src/pages/LiquiditySourcePage.tsx +8 -6
- package/src/pages/SelectBlockchainPage.tsx +41 -41
- package/src/pages/SelectSwapItemsPage.tsx +45 -39
- package/src/pages/SettingsPage.tsx +3 -4
- package/src/pages/ThemePage.tsx +3 -4
- package/src/pages/WalletsPage.tsx +12 -13
- package/src/store/slices/data.ts +5 -7
- package/src/store/slices/settings.ts +3 -3
- package/src/types/config.ts +16 -3
- package/src/types/notification.ts +0 -7
- package/src/utils/configs.ts +41 -0
- package/src/utils/date.ts +5 -4
- package/src/utils/quote.ts +18 -1
- package/src/utils/swap.ts +35 -0
- package/src/utils/ui.ts +20 -0
|
@@ -51,6 +51,7 @@ export const Container = styled('div', {
|
|
|
51
51
|
display: 'flex',
|
|
52
52
|
flexDirection: 'column',
|
|
53
53
|
flexGrow: 1,
|
|
54
|
+
overflow: 'hidden',
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
export const Title = styled('div', {
|
|
@@ -68,6 +69,7 @@ export const List = styled('ul', {
|
|
|
68
69
|
padding: 0,
|
|
69
70
|
margin: 0,
|
|
70
71
|
listStyle: 'none',
|
|
72
|
+
|
|
71
73
|
'& li': {
|
|
72
74
|
alignItems: 'none',
|
|
73
75
|
|
|
@@ -278,7 +278,7 @@ export function TokenList(props: PropTypes) {
|
|
|
278
278
|
</Typography>
|
|
279
279
|
<Divider size={4} />
|
|
280
280
|
{fetchStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
|
|
281
|
-
{fetchStatus === 'success' && <List>{renderList()}</List>}
|
|
281
|
+
{fetchStatus === 'success' && <List as="ul">{renderList()}</List>}
|
|
282
282
|
</Container>
|
|
283
283
|
);
|
|
284
284
|
}
|
|
@@ -11,14 +11,12 @@ import { useEffect } from 'react';
|
|
|
11
11
|
import { useAppStore } from '../store/AppStore';
|
|
12
12
|
import { useNotificationStore } from '../store/notification';
|
|
13
13
|
import { useWalletsStore } from '../store/wallets';
|
|
14
|
-
import { validBlockedStatuses } from '../types/notification';
|
|
15
14
|
|
|
16
15
|
export function WidgetEvents() {
|
|
17
16
|
const tokens = useAppStore().tokens();
|
|
18
17
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
19
18
|
const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
|
|
20
19
|
const setNotification = useNotificationStore.use.setNotification();
|
|
21
|
-
const setAsRead = useNotificationStore.use.setAsRead();
|
|
22
20
|
const widgetEvents = useEvents();
|
|
23
21
|
|
|
24
22
|
useEffect(() => {
|
|
@@ -43,18 +41,8 @@ export function WidgetEvents() {
|
|
|
43
41
|
fromAccount && getWalletsDetails([fromAccount], tokens);
|
|
44
42
|
toAccount && getWalletsDetails([toAccount], tokens);
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
validBlockedStatuses.includes(event.status)) ||
|
|
49
|
-
event.type === StepEventType.FAILED
|
|
50
|
-
) {
|
|
51
|
-
setNotification(event, route);
|
|
52
|
-
} else if (
|
|
53
|
-
event.type === StepEventType.TX_EXECUTION ||
|
|
54
|
-
event.type === StepEventType.CHECK_STATUS
|
|
55
|
-
) {
|
|
56
|
-
setAsRead(route.requestId);
|
|
57
|
-
}
|
|
44
|
+
|
|
45
|
+
setNotification(event, route);
|
|
58
46
|
});
|
|
59
47
|
|
|
60
48
|
return () => widgetEvents.all.clear();
|
package/src/constants/index.ts
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SwapFee } from 'rango-sdk';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
|
|
5
|
+
export type NameOfFees =
|
|
6
|
+
| 'Swapper Fee'
|
|
7
|
+
| 'Affiliate Fee'
|
|
8
|
+
| 'Outbound network fee'
|
|
9
|
+
| 'Rango Fee'
|
|
10
|
+
| 'Network Fee';
|
|
11
|
+
|
|
12
|
+
export const NAME_OF_FEES: Record<NameOfFees, string> = {
|
|
13
|
+
'Network Fee': i18n.t('Network Fee'),
|
|
14
|
+
'Swapper Fee': i18n.t('Protocol Fee'),
|
|
15
|
+
'Affiliate Fee': i18n.t('Affiliate Fee'),
|
|
16
|
+
'Outbound network fee': i18n.t('Outbound Fee'),
|
|
17
|
+
'Rango Fee': i18n.t('Rango Fee'),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type FeesGroup = {
|
|
21
|
+
payable: { [key in NameOfFees]?: SwapFee[] };
|
|
22
|
+
nonePayable: { [key in NameOfFees]?: SwapFee[] };
|
|
23
|
+
};
|
|
@@ -20,7 +20,7 @@ export function Main() {
|
|
|
20
20
|
|
|
21
21
|
const { config } = useAppStore();
|
|
22
22
|
const { activeTheme } = useTheme(config?.theme || {});
|
|
23
|
-
const { activeLanguage
|
|
23
|
+
const { activeLanguage } = useLanguage();
|
|
24
24
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
25
25
|
useState<string>('');
|
|
26
26
|
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
@@ -30,9 +30,6 @@ export function Main() {
|
|
|
30
30
|
void useNotificationStore.persist.rehydrate();
|
|
31
31
|
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
32
32
|
}, []);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
changeLanguage(config?.language);
|
|
35
|
-
}, [config?.language]);
|
|
36
33
|
|
|
37
34
|
return (
|
|
38
35
|
<I18nManager language={activeLanguage}>
|
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
import { styled } from '@rango-dev/ui';
|
|
2
2
|
|
|
3
|
-
export const PositionTopAlerts = styled('div', {
|
|
4
|
-
paddingBottom: '$10',
|
|
5
|
-
});
|
|
6
|
-
|
|
7
3
|
export const QuoteContainer = styled('div', {
|
|
8
4
|
width: '100%',
|
|
9
5
|
'& .position-top__skeleton': {
|
|
10
6
|
paddingTop: '$10',
|
|
11
7
|
},
|
|
12
8
|
});
|
|
13
|
-
|
|
14
|
-
export const SkeletonContainer = styled('div', {
|
|
15
|
-
variants: {
|
|
16
|
-
paddingTop: {
|
|
17
|
-
true: {
|
|
18
|
-
paddingTop: '$10',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
9
|
export const FooterStepAlarm = styled('div', {
|
|
25
10
|
paddingBottom: '$15',
|
|
26
11
|
});
|
|
@@ -1,36 +1,16 @@
|
|
|
1
1
|
import type { PropTypes } from './QuoteInfo.types';
|
|
2
2
|
|
|
3
|
-
import { Divider } from '@rango-dev/ui';
|
|
4
3
|
import React from 'react';
|
|
5
4
|
|
|
6
5
|
import { Quote } from '../../components/Quote';
|
|
7
6
|
import { QuoteSkeleton } from '../../components/QuoteSkeleton';
|
|
8
|
-
import { QuoteWarningsAndErrors } from '../../components/QuoteWarningsAndErrors';
|
|
9
7
|
import { useQuoteStore } from '../../store/quote';
|
|
10
8
|
import { QuoteErrorType } from '../../types';
|
|
11
9
|
|
|
12
|
-
import {
|
|
13
|
-
PositionTopAlerts,
|
|
14
|
-
QuoteContainer,
|
|
15
|
-
SkeletonContainer,
|
|
16
|
-
} from './QuoteInfo.styles';
|
|
10
|
+
import { QuoteContainer } from './QuoteInfo.styles';
|
|
17
11
|
|
|
18
12
|
export function QuoteInfo(props: PropTypes) {
|
|
19
|
-
const {
|
|
20
|
-
quote,
|
|
21
|
-
type,
|
|
22
|
-
loading,
|
|
23
|
-
error,
|
|
24
|
-
warning,
|
|
25
|
-
refetchQuote,
|
|
26
|
-
showWarningModal,
|
|
27
|
-
onOpenWarningModal,
|
|
28
|
-
onCloseWarningModal,
|
|
29
|
-
onConfirmWarningModal,
|
|
30
|
-
onChangeSettings,
|
|
31
|
-
expanded = false,
|
|
32
|
-
alertPosition = 'bottom',
|
|
33
|
-
} = props;
|
|
13
|
+
const { quote, type, loading, error, warning, expanded = false } = props;
|
|
34
14
|
const { inputAmount, inputUsdValue, outputUsdValue, outputAmount } =
|
|
35
15
|
useQuoteStore();
|
|
36
16
|
|
|
@@ -41,59 +21,32 @@ export function QuoteInfo(props: PropTypes) {
|
|
|
41
21
|
|
|
42
22
|
const showQuote = !noResult && quote && quote.result && !loading;
|
|
43
23
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<Quote
|
|
73
|
-
quote={quote}
|
|
74
|
-
error={error}
|
|
75
|
-
warning={warning}
|
|
76
|
-
type={type}
|
|
77
|
-
expanded={expanded}
|
|
78
|
-
recommended={true}
|
|
79
|
-
input={{
|
|
80
|
-
value: inputAmount,
|
|
81
|
-
usdValue: inputUsdValue?.toString() ?? '',
|
|
82
|
-
}}
|
|
83
|
-
output={{
|
|
84
|
-
value: outputAmount?.toString() ?? '',
|
|
85
|
-
usdValue: outputUsdValue?.toString() ?? '',
|
|
86
|
-
}}
|
|
87
|
-
/>
|
|
88
|
-
</QuoteContainer>
|
|
89
|
-
) : null}
|
|
90
|
-
|
|
91
|
-
{alertPosition === 'bottom' && (
|
|
92
|
-
<>
|
|
93
|
-
{!warning && !error && <Divider size={16} />}
|
|
94
|
-
{quoteWarningsAndErrors}
|
|
95
|
-
</>
|
|
96
|
-
)}
|
|
97
|
-
</>
|
|
98
|
-
);
|
|
24
|
+
if (loading) {
|
|
25
|
+
return (
|
|
26
|
+
<QuoteContainer>
|
|
27
|
+
<QuoteSkeleton type={type} expanded={expanded} />
|
|
28
|
+
</QuoteContainer>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return showQuote ? (
|
|
33
|
+
<QuoteContainer>
|
|
34
|
+
<Quote
|
|
35
|
+
quote={quote}
|
|
36
|
+
error={error}
|
|
37
|
+
warning={warning}
|
|
38
|
+
type={type}
|
|
39
|
+
expanded={expanded}
|
|
40
|
+
recommended={true}
|
|
41
|
+
input={{
|
|
42
|
+
value: inputAmount,
|
|
43
|
+
usdValue: inputUsdValue?.toString() ?? '',
|
|
44
|
+
}}
|
|
45
|
+
output={{
|
|
46
|
+
value: outputAmount?.toString() ?? '',
|
|
47
|
+
usdValue: outputUsdValue?.toString() ?? '',
|
|
48
|
+
}}
|
|
49
|
+
/>
|
|
50
|
+
</QuoteContainer>
|
|
51
|
+
) : null;
|
|
99
52
|
}
|
|
@@ -10,11 +10,4 @@ export type PropTypes = {
|
|
|
10
10
|
warning: QuoteWarning | null;
|
|
11
11
|
autoScrollOnExpanding?: boolean;
|
|
12
12
|
expanded?: boolean;
|
|
13
|
-
alertPosition?: 'top' | 'bottom';
|
|
14
|
-
refetchQuote: () => void;
|
|
15
|
-
showWarningModal: boolean;
|
|
16
|
-
onOpenWarningModal: () => void;
|
|
17
|
-
onCloseWarningModal: () => void;
|
|
18
|
-
onConfirmWarningModal: () => void;
|
|
19
|
-
onChangeSettings: () => void;
|
|
20
13
|
};
|
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
PropTypes,
|
|
4
4
|
WidgetContextInterface,
|
|
5
5
|
} from './Wallets.types';
|
|
6
|
+
import type { Wallet } from '../../types/wallets';
|
|
6
7
|
import type { ProvidersOptions } from '../../utils/providers';
|
|
7
8
|
import type { EventHandler } from '@rango-dev/wallets-react';
|
|
8
9
|
import type { Network } from '@rango-dev/wallets-shared';
|
|
@@ -10,7 +11,7 @@ import type { PropsWithChildren } from 'react';
|
|
|
10
11
|
|
|
11
12
|
import { Events, Provider } from '@rango-dev/wallets-react';
|
|
12
13
|
import { isEvmBlockchain } from 'rango-sdk';
|
|
13
|
-
import React, { createContext, useEffect, useRef } from 'react';
|
|
14
|
+
import React, { createContext, useEffect, useRef, useState } from 'react';
|
|
14
15
|
|
|
15
16
|
import { useSyncStoresWithConfig } from '../../hooks/useSyncStoresWithConfig';
|
|
16
17
|
import { useWalletProviders } from '../../hooks/useWalletProviders';
|
|
@@ -34,6 +35,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
34
35
|
const walletOptions: ProvidersOptions = {
|
|
35
36
|
walletConnectProjectId: props.config?.walletConnectProjectId,
|
|
36
37
|
};
|
|
38
|
+
const [accounts, setAccounts] = useState<Wallet[]>([]);
|
|
37
39
|
const { providers } = useWalletProviders(props.config.wallets, walletOptions);
|
|
38
40
|
const { connectWallet, disconnectWallet } = useWalletsStore();
|
|
39
41
|
const onConnectWalletHandler = useRef<OnConnectHandler>();
|
|
@@ -66,7 +68,7 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
66
68
|
supportedChainNames,
|
|
67
69
|
meta.isContractWallet
|
|
68
70
|
);
|
|
69
|
-
|
|
71
|
+
setAccounts(data);
|
|
70
72
|
} else {
|
|
71
73
|
disconnectWallet(type);
|
|
72
74
|
}
|
|
@@ -99,6 +101,13 @@ function Main(props: PropsWithChildren<PropTypes>) {
|
|
|
99
101
|
props.onUpdateState(type, event, value, state, meta);
|
|
100
102
|
}
|
|
101
103
|
};
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (accounts.length) {
|
|
107
|
+
connectWallet(accounts, tokens);
|
|
108
|
+
}
|
|
109
|
+
}, [accounts, tokens]);
|
|
110
|
+
|
|
102
111
|
return (
|
|
103
112
|
<WidgetContext.Provider
|
|
104
113
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
@@ -3,7 +3,9 @@ import type { WidgetInfoContextInterface } from './WidgetInfo.types';
|
|
|
3
3
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
4
4
|
import React, { createContext, useContext } from 'react';
|
|
5
5
|
|
|
6
|
+
import { useLanguage } from '../../hooks/useLanguage';
|
|
6
7
|
import { useAppStore } from '../../store/AppStore';
|
|
8
|
+
import { useNotificationStore } from '../../store/notification';
|
|
7
9
|
import { useQuoteStore } from '../../store/quote';
|
|
8
10
|
import { useWalletsStore } from '../../store/wallets';
|
|
9
11
|
import { calculateWalletUsdValue } from '../../utils/wallets';
|
|
@@ -26,6 +28,8 @@ export function WidgetInfo(props: React.PropsWithChildren) {
|
|
|
26
28
|
const tokens = useAppStore().tokens();
|
|
27
29
|
const swappers = useAppStore().swappers();
|
|
28
30
|
const loadingStatus = useAppStore().fetchStatus;
|
|
31
|
+
const resetLanguage = useLanguage().resetLanguage;
|
|
32
|
+
const notifications = useNotificationStore().getUnreadNotifications();
|
|
29
33
|
|
|
30
34
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
31
35
|
const value = {
|
|
@@ -42,6 +46,10 @@ export function WidgetInfo(props: React.PropsWithChildren) {
|
|
|
42
46
|
swappers,
|
|
43
47
|
loadingStatus,
|
|
44
48
|
},
|
|
49
|
+
resetLanguage,
|
|
50
|
+
notifications: {
|
|
51
|
+
list: notifications,
|
|
52
|
+
},
|
|
45
53
|
};
|
|
46
54
|
|
|
47
55
|
return (
|
|
@@ -2,6 +2,7 @@ import type { WidgetHistory } from './WidgetInfo.helpers';
|
|
|
2
2
|
import type { FetchStatus } from '../../store/slices/data';
|
|
3
3
|
import type { ConnectedWallet } from '../../store/wallets';
|
|
4
4
|
import type { Wallet } from '../../types';
|
|
5
|
+
import type { Notification } from '../../types/notification';
|
|
5
6
|
import type { BlockchainMeta, SwapperMeta, Token } from 'rango-sdk';
|
|
6
7
|
|
|
7
8
|
export interface WidgetInfoContextInterface {
|
|
@@ -18,4 +19,8 @@ export interface WidgetInfoContextInterface {
|
|
|
18
19
|
swappers: SwapperMeta[];
|
|
19
20
|
loadingStatus: FetchStatus;
|
|
20
21
|
};
|
|
22
|
+
resetLanguage: () => void;
|
|
23
|
+
notifications: {
|
|
24
|
+
list: Notification[];
|
|
25
|
+
};
|
|
21
26
|
}
|
|
@@ -17,7 +17,8 @@ export function WidgetProvider(props: PropsWithChildren<PropTypes>) {
|
|
|
17
17
|
API_KEY: config?.apiKey || RANGO_PUBLIC_API_KEY,
|
|
18
18
|
BASE_URL: config?.apiUrl || DEFAULT_BASE_URL,
|
|
19
19
|
});
|
|
20
|
-
}, [config]);
|
|
20
|
+
}, [config.apiKey, config.apiUrl]);
|
|
21
|
+
|
|
21
22
|
return (
|
|
22
23
|
<WidgetWallets config={config} onUpdateState={onUpdateState}>
|
|
23
24
|
<QueueManager apiKey={config.apiKey}>
|
package/src/hooks/useLanguage.ts
CHANGED
|
@@ -9,18 +9,20 @@ interface UseLanguage {
|
|
|
9
9
|
languages: LanguageItem[];
|
|
10
10
|
defaultLanguage: Language;
|
|
11
11
|
activeLanguage: Language;
|
|
12
|
-
changeLanguage: (language?: Language) => void;
|
|
12
|
+
changeLanguage: (language?: Language | null) => void;
|
|
13
|
+
resetLanguage: () => void;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export function useLanguage(): UseLanguage {
|
|
16
|
-
const { setLanguage, language } = useAppStore();
|
|
17
|
+
const { setLanguage, language, config } = useAppStore();
|
|
17
18
|
const languages = LANGUAGES;
|
|
18
|
-
const defaultLanguage = DEFAULT_LANGUAGE;
|
|
19
|
+
const defaultLanguage = config?.language || DEFAULT_LANGUAGE;
|
|
19
20
|
|
|
20
21
|
return {
|
|
21
|
-
activeLanguage: language,
|
|
22
|
+
activeLanguage: language || defaultLanguage,
|
|
22
23
|
languages,
|
|
23
24
|
defaultLanguage,
|
|
24
25
|
changeLanguage: (language) => setLanguage(language || DEFAULT_LANGUAGE),
|
|
26
|
+
resetLanguage: () => setLanguage(null),
|
|
25
27
|
};
|
|
26
28
|
}
|
|
@@ -48,6 +48,7 @@ export function useSwapInput(): UseSwapInput {
|
|
|
48
48
|
toToken,
|
|
49
49
|
inputAmount,
|
|
50
50
|
inputUsdValue,
|
|
51
|
+
quote,
|
|
51
52
|
resetQuote,
|
|
52
53
|
setQuote,
|
|
53
54
|
} = useQuoteStore();
|
|
@@ -63,9 +64,9 @@ export function useSwapInput(): UseSwapInput {
|
|
|
63
64
|
const [error, setError] = useState<QuoteError | null>(null);
|
|
64
65
|
const [warning, setWarning] = useState<QuoteWarning | null>(null);
|
|
65
66
|
const userSlippage = customSlippage ?? slippage;
|
|
66
|
-
const
|
|
67
|
+
const tokensValueInvalid = !fromToken || !toToken;
|
|
67
68
|
const shouldSkipRequest =
|
|
68
|
-
|
|
69
|
+
tokensValueInvalid ||
|
|
69
70
|
tokensAreEqual(fromToken, toToken) ||
|
|
70
71
|
!isPositiveNumber(inputAmount);
|
|
71
72
|
|
|
@@ -153,6 +154,9 @@ export function useSwapInput(): UseSwapInput {
|
|
|
153
154
|
return;
|
|
154
155
|
}
|
|
155
156
|
if (shouldSkipRequest) {
|
|
157
|
+
if (quote) {
|
|
158
|
+
resetQuote();
|
|
159
|
+
}
|
|
156
160
|
return;
|
|
157
161
|
}
|
|
158
162
|
resetQuote();
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Asset } from 'rango-sdk';
|
|
2
2
|
|
|
3
|
-
import { useEffect, useLayoutEffect,
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef } from 'react';
|
|
4
4
|
|
|
5
5
|
import { useAppStore } from '../store/AppStore';
|
|
6
6
|
import { useQuoteStore } from '../store/quote';
|
|
7
|
+
import {
|
|
8
|
+
isBlockchainExcludedInConfig,
|
|
9
|
+
isTokenExcludedInConfig,
|
|
10
|
+
} from '../utils/configs';
|
|
7
11
|
import { tokensAreEqual } from '../utils/wallets';
|
|
8
12
|
|
|
9
13
|
export function useSyncStoresWithConfig() {
|
|
@@ -27,22 +31,10 @@ export function useSyncStoresWithConfig() {
|
|
|
27
31
|
const { setAffiliateRef, setAffiliatePercent, setAffiliateWallets } =
|
|
28
32
|
useAppStore();
|
|
29
33
|
|
|
30
|
-
const fromTokensConfig =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const fromBlockchainsConfig = useMemo(
|
|
35
|
-
() => config?.from?.blockchains,
|
|
36
|
-
[config?.from?.blockchains]
|
|
37
|
-
);
|
|
38
|
-
const toTokensConfig = useMemo(
|
|
39
|
-
() => config?.to?.tokens,
|
|
40
|
-
[config?.to?.tokens]
|
|
41
|
-
);
|
|
42
|
-
const toBlockchainsConfig = useMemo(
|
|
43
|
-
() => config?.to?.blockchains,
|
|
44
|
-
[config?.to?.blockchains]
|
|
45
|
-
);
|
|
34
|
+
const fromTokensConfig = config?.from?.tokens;
|
|
35
|
+
const fromBlockchainsConfig = config?.from?.blockchains;
|
|
36
|
+
const toTokensConfig = config?.to?.tokens;
|
|
37
|
+
const toBlockchainsConfig = config?.to?.blockchains;
|
|
46
38
|
const prevConfigFromToken = useRef<Asset | undefined>(undefined);
|
|
47
39
|
const prevConfigToToken = useRef<Asset | undefined>(undefined);
|
|
48
40
|
const prevConfigFromBlockchain = useRef<string | undefined>(undefined);
|
|
@@ -90,30 +82,21 @@ export function useSyncStoresWithConfig() {
|
|
|
90
82
|
]);
|
|
91
83
|
|
|
92
84
|
useEffect(() => {
|
|
93
|
-
if (fromToken
|
|
94
|
-
|
|
95
|
-
setFromToken({ token: null });
|
|
96
|
-
}
|
|
85
|
+
if (isTokenExcludedInConfig(fromToken, fromTokensConfig)) {
|
|
86
|
+
setFromToken({ token: null });
|
|
97
87
|
}
|
|
98
88
|
|
|
99
|
-
if (fromBlockchain
|
|
100
|
-
|
|
101
|
-
setFromBlockchain(null);
|
|
102
|
-
}
|
|
89
|
+
if (isBlockchainExcludedInConfig(fromBlockchain, fromBlockchainsConfig)) {
|
|
90
|
+
setFromBlockchain(null);
|
|
103
91
|
}
|
|
104
92
|
}, [fromTokensConfig, fromBlockchainsConfig]);
|
|
105
93
|
|
|
106
94
|
useEffect(() => {
|
|
107
|
-
if (toToken
|
|
108
|
-
|
|
109
|
-
setToToken({ token: null });
|
|
110
|
-
}
|
|
95
|
+
if (isTokenExcludedInConfig(toToken, toTokensConfig)) {
|
|
96
|
+
setFromToken({ token: null });
|
|
111
97
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (!toBlockchainsConfig.includes(toBlockchain.name)) {
|
|
115
|
-
setToBlockchain(null);
|
|
116
|
-
}
|
|
98
|
+
if (isBlockchainExcludedInConfig(toBlockchain, toBlockchainsConfig)) {
|
|
99
|
+
setToBlockchain(null);
|
|
117
100
|
}
|
|
118
101
|
}, [toTokensConfig, toBlockchainsConfig]);
|
|
119
102
|
|
package/src/index.ts
CHANGED
|
@@ -2,13 +2,13 @@ import type { WidgetProps } from './containers/Widget';
|
|
|
2
2
|
import type { ConnectedWallet } from './store/wallets';
|
|
3
3
|
import type {
|
|
4
4
|
BlockchainAndTokenConfig,
|
|
5
|
+
Tokens,
|
|
5
6
|
WidgetColors,
|
|
6
7
|
WidgetColorsKeys,
|
|
7
8
|
WidgetConfig,
|
|
8
9
|
WidgetTheme,
|
|
9
10
|
} from './types';
|
|
10
11
|
import type {
|
|
11
|
-
EventSeverity,
|
|
12
12
|
PendingSwapWithQueueID,
|
|
13
13
|
Route,
|
|
14
14
|
RouteEvent,
|
|
@@ -39,6 +39,7 @@ import type {
|
|
|
39
39
|
import type { PendingSwap, PendingSwapStep } from 'rango-types';
|
|
40
40
|
|
|
41
41
|
import {
|
|
42
|
+
EventSeverity,
|
|
42
43
|
MainEvents,
|
|
43
44
|
RouteEventType,
|
|
44
45
|
StepEventType,
|
|
@@ -86,6 +87,7 @@ export type {
|
|
|
86
87
|
StepOutputRevealedEvent,
|
|
87
88
|
HandleWalletsUpdate,
|
|
88
89
|
ConnectedWallet,
|
|
90
|
+
Tokens,
|
|
89
91
|
};
|
|
90
92
|
export {
|
|
91
93
|
Widget,
|
|
@@ -113,7 +115,6 @@ export type {
|
|
|
113
115
|
PendingSwapWithQueueID,
|
|
114
116
|
PendingSwapStep,
|
|
115
117
|
RouteExecutionEvents,
|
|
116
|
-
EventSeverity,
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
// Internal function and enum exports for Rango
|
|
@@ -123,4 +124,5 @@ export {
|
|
|
123
124
|
WalletEvents,
|
|
124
125
|
WalletTypes,
|
|
125
126
|
PendingSwapNetworkStatus,
|
|
127
|
+
EventSeverity,
|
|
126
128
|
};
|