@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
package/src/pages/ThemePage.tsx
CHANGED
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
} from '@rango-dev/ui';
|
|
12
12
|
import React from 'react';
|
|
13
13
|
|
|
14
|
-
import { Layout } from '../components/Layout';
|
|
15
|
-
import { SettingsContainer } from '../components/SettingsContainer';
|
|
14
|
+
import { Layout, PageContainer } from '../components/Layout';
|
|
16
15
|
import { useAppStore } from '../store/AppStore';
|
|
17
16
|
|
|
18
17
|
type Theme = 'dark' | 'light' | 'auto';
|
|
@@ -70,7 +69,7 @@ export function ThemePage() {
|
|
|
70
69
|
header={{
|
|
71
70
|
title: i18n.t('Theme'),
|
|
72
71
|
}}>
|
|
73
|
-
<
|
|
72
|
+
<PageContainer>
|
|
74
73
|
<RadioRoot
|
|
75
74
|
onValueChange={(value) => setTheme(value as Theme)}
|
|
76
75
|
value={theme}>
|
|
@@ -85,7 +84,7 @@ export function ThemePage() {
|
|
|
85
84
|
items={themesList}
|
|
86
85
|
/>
|
|
87
86
|
</RadioRoot>
|
|
88
|
-
</
|
|
87
|
+
</PageContainer>
|
|
89
88
|
</Layout>
|
|
90
89
|
);
|
|
91
90
|
}
|
|
@@ -2,9 +2,9 @@ import type { WalletType } from '@rango-dev/wallets-shared';
|
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
import { styled, Typography, Wallet, WalletState } from '@rango-dev/ui';
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Layout } from '../components/Layout';
|
|
7
|
+
import { Layout, PageContainer } from '../components/Layout';
|
|
8
8
|
import { WalletModal } from '../components/WalletModal';
|
|
9
9
|
import { useWalletList } from '../hooks/useWalletList';
|
|
10
10
|
import { useAppStore } from '../store/AppStore';
|
|
@@ -20,7 +20,7 @@ const ListContainer = styled('div', {
|
|
|
20
20
|
height: '100%',
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const Container = styled(
|
|
23
|
+
const Container = styled(PageContainer, {
|
|
24
24
|
textAlign: 'center',
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -71,16 +71,15 @@ export function WalletsPage() {
|
|
|
71
71
|
{list.map((wallet, index) => {
|
|
72
72
|
const key = `wallet-${index}-${wallet.type}`;
|
|
73
73
|
return (
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
</Fragment>
|
|
74
|
+
<Wallet
|
|
75
|
+
key={key}
|
|
76
|
+
{...wallet}
|
|
77
|
+
container={getContainer()}
|
|
78
|
+
onClick={(type) => {
|
|
79
|
+
void handleClick(type);
|
|
80
|
+
}}
|
|
81
|
+
isLoading={fetchMetaStatus === 'loading'}
|
|
82
|
+
/>
|
|
84
83
|
);
|
|
85
84
|
})}
|
|
86
85
|
<WalletModal
|
package/src/store/slices/data.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { StateCreator } from 'zustand';
|
|
|
6
6
|
|
|
7
7
|
import { httpService as sdk } from '../../services/httpService';
|
|
8
8
|
import { containsText } from '../../utils/common';
|
|
9
|
+
import { isTokenExcludedInConfig } from '../../utils/configs';
|
|
9
10
|
import { sortLiquiditySourcesByGroupTitle } from '../../utils/settings';
|
|
10
11
|
import { tokensAreEqual } from '../../utils/wallets';
|
|
11
12
|
|
|
@@ -81,21 +82,18 @@ export const createDataSlice: StateCreator<
|
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
const config = get().config;
|
|
84
|
-
const
|
|
85
|
+
const supportedTokensConfig =
|
|
85
86
|
(options.type === 'source' ? config.from?.tokens : config.to?.tokens) ??
|
|
86
|
-
|
|
87
|
+
{};
|
|
87
88
|
const blockchains = get().blockchains({
|
|
88
89
|
type: options.type,
|
|
89
90
|
});
|
|
90
91
|
|
|
91
92
|
const list = tokensFromState
|
|
92
93
|
.filter((token) => {
|
|
93
|
-
// If there is a list of tokens in config, we only keep them.
|
|
94
94
|
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return tokensAreEqual(asset, token);
|
|
98
|
-
})
|
|
95
|
+
supportedTokensConfig &&
|
|
96
|
+
isTokenExcludedInConfig(token, supportedTokensConfig)
|
|
99
97
|
) {
|
|
100
98
|
return false;
|
|
101
99
|
}
|
|
@@ -15,7 +15,7 @@ export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
|
15
15
|
|
|
16
16
|
export interface SettingsSlice {
|
|
17
17
|
theme: ThemeMode;
|
|
18
|
-
language: Language;
|
|
18
|
+
language: Language | null;
|
|
19
19
|
disabledLiquiditySources: string[];
|
|
20
20
|
/** Keeping a history of blockchains that user has selected (in Swap process) */
|
|
21
21
|
preferredBlockchains: string[];
|
|
@@ -31,7 +31,7 @@ export interface SettingsSlice {
|
|
|
31
31
|
toggleInfiniteApprove: () => void;
|
|
32
32
|
toggleLiquiditySource: (name: string) => void;
|
|
33
33
|
setTheme: (theme: ThemeMode) => void;
|
|
34
|
-
setLanguage: (language: Language) => void;
|
|
34
|
+
setLanguage: (language: Language | null) => void;
|
|
35
35
|
toggleAllLiquiditySources: (
|
|
36
36
|
swappers: SwapperMeta[],
|
|
37
37
|
shouldReset?: boolean
|
|
@@ -53,7 +53,7 @@ export const createSettingsSlice: StateCreator<
|
|
|
53
53
|
> = (set, get) => ({
|
|
54
54
|
disabledLiquiditySources: [],
|
|
55
55
|
theme: 'auto',
|
|
56
|
-
language:
|
|
56
|
+
language: null,
|
|
57
57
|
preferredBlockchains: [],
|
|
58
58
|
slippage: DEFAULT_SLIPPAGE,
|
|
59
59
|
customSlippage: null,
|
package/src/types/config.ts
CHANGED
|
@@ -67,6 +67,19 @@ export type WidgetAffiliate = {
|
|
|
67
67
|
wallets?: { [key: string]: string };
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* `Tokens`
|
|
72
|
+
*
|
|
73
|
+
* @property {boolean} isExcluded - This is a boolean property capable of removing tokens from all or a blockchain.
|
|
74
|
+
* @property {Asset[]} tokens - The `tokens` property is an array of `Asset` objects that
|
|
75
|
+
* you could use that to limit tokens to some limited ones.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
export type Tokens = {
|
|
79
|
+
isExcluded: boolean;
|
|
80
|
+
tokens: Asset[];
|
|
81
|
+
};
|
|
82
|
+
|
|
70
83
|
/**
|
|
71
84
|
* `BlockchainAndTokenConfig`
|
|
72
85
|
*
|
|
@@ -75,8 +88,8 @@ export type WidgetAffiliate = {
|
|
|
75
88
|
* which is selected. e.g. {blockchain: 'BSC', symbol: 'BNB', address: null}
|
|
76
89
|
* @property {string[]} blockchains - An optional array of strings representing the supported
|
|
77
90
|
* blockchains. e.g. ['BSC','ETHEREUM']
|
|
78
|
-
* @property {Asset[]} tokens - The `tokens` property is an optional array of `Asset` objects
|
|
79
|
-
* you could use that to limit tokens to some limited ones.
|
|
91
|
+
* @property {Asset[] |{ [blockchain: string]: Tokens }} tokens - The `tokens` property is an optional object of `blockchain` objects or array of `Asset` objects
|
|
92
|
+
* that you could use that to limit tokens to some limited ones.
|
|
80
93
|
* @property {Asset} pinnedTokens - The `pinnedTokens` property is an optional array of `Asset` objects that
|
|
81
94
|
* you could use to pin tokens of your choice to the top of the token list.
|
|
82
95
|
*/
|
|
@@ -84,8 +97,8 @@ export type BlockchainAndTokenConfig = {
|
|
|
84
97
|
blockchain?: string;
|
|
85
98
|
token?: Asset;
|
|
86
99
|
blockchains?: string[];
|
|
87
|
-
tokens?: Asset[];
|
|
88
100
|
pinnedTokens?: Asset[];
|
|
101
|
+
tokens?: Asset[] | { [blockchain: string]: Tokens };
|
|
89
102
|
};
|
|
90
103
|
|
|
91
104
|
/**
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
type RouteEvent,
|
|
4
4
|
type Step,
|
|
5
5
|
type StepEvent,
|
|
6
|
-
StepExecutionBlockedEventStatus,
|
|
7
6
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
8
7
|
|
|
9
8
|
type NotificationRoute = {
|
|
@@ -25,9 +24,3 @@ export type Notification = Pick<Route, 'requestId'> & {
|
|
|
25
24
|
read: boolean;
|
|
26
25
|
route: NotificationRoute;
|
|
27
26
|
};
|
|
28
|
-
|
|
29
|
-
export const validBlockedStatuses: StepExecutionBlockedEventStatus[] = [
|
|
30
|
-
StepExecutionBlockedEventStatus.WAITING_FOR_CHANGE_WALLET_ACCOUNT,
|
|
31
|
-
StepExecutionBlockedEventStatus.WAITING_FOR_NETWORK_CHANGE,
|
|
32
|
-
StepExecutionBlockedEventStatus.WAITING_FOR_WALLET_CONNECT,
|
|
33
|
-
];
|
package/src/utils/configs.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import type { Tokens } from '../types';
|
|
2
|
+
import type { Asset, BlockchainMeta, Token } from 'rango-sdk';
|
|
3
|
+
|
|
1
4
|
import { RANGO_PUBLIC_API_KEY } from '../constants';
|
|
2
5
|
|
|
6
|
+
import { tokensAreEqual } from './wallets';
|
|
7
|
+
|
|
3
8
|
export interface Configs {
|
|
4
9
|
API_KEY: string;
|
|
5
10
|
BASE_URL?: string;
|
|
6
11
|
}
|
|
7
12
|
|
|
13
|
+
type TokensConfig =
|
|
14
|
+
| Asset[]
|
|
15
|
+
| {
|
|
16
|
+
[blockchain: string]: Tokens;
|
|
17
|
+
};
|
|
18
|
+
|
|
8
19
|
let configs: Configs = {
|
|
9
20
|
API_KEY: RANGO_PUBLIC_API_KEY,
|
|
10
21
|
};
|
|
@@ -38,3 +49,33 @@ export const DEFAULT_SECONDARY_RADIUS = 25;
|
|
|
38
49
|
export const DEFAULT_FONT_FAMILY = 'Roboto';
|
|
39
50
|
|
|
40
51
|
export const THEME_CLASS_NAME_PREFIX = `theme-widget`;
|
|
52
|
+
|
|
53
|
+
export const isTokenExcludedInConfig = (
|
|
54
|
+
token: Token | null,
|
|
55
|
+
tokensConfig?: TokensConfig
|
|
56
|
+
) => {
|
|
57
|
+
let result = false;
|
|
58
|
+
if (tokensConfig && token) {
|
|
59
|
+
if (Array.isArray(tokensConfig)) {
|
|
60
|
+
result = !tokensConfig.some((asset) => tokensAreEqual(asset, token));
|
|
61
|
+
} else if (!Array.isArray(tokensConfig) && tokensConfig[token.blockchain]) {
|
|
62
|
+
result = tokensConfig[token.blockchain].tokens.some((asset) =>
|
|
63
|
+
tokensAreEqual(asset, token)
|
|
64
|
+
);
|
|
65
|
+
const isExcluded = tokensConfig[token.blockchain].isExcluded;
|
|
66
|
+
return (!isExcluded && !result) || (isExcluded && result);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const isBlockchainExcludedInConfig = (
|
|
73
|
+
blockchain: BlockchainMeta | null,
|
|
74
|
+
blockchainsConfig?: string[]
|
|
75
|
+
) => {
|
|
76
|
+
return (
|
|
77
|
+
blockchain &&
|
|
78
|
+
blockchainsConfig &&
|
|
79
|
+
!blockchainsConfig.includes(blockchain.name)
|
|
80
|
+
);
|
|
81
|
+
};
|
package/src/utils/date.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GroupBy } from '../components/SwapsGroup/SwapsGroup.types';
|
|
2
2
|
import type { PendingSwap } from 'rango-types';
|
|
3
3
|
|
|
4
|
+
import { i18n } from '@lingui/core';
|
|
4
5
|
import dayjs from 'dayjs';
|
|
5
6
|
|
|
6
7
|
export const groupSwapsByDate: GroupBy = (swaps) => {
|
|
@@ -14,28 +15,28 @@ export const groupSwapsByDate: GroupBy = (swaps) => {
|
|
|
14
15
|
[
|
|
15
16
|
'today',
|
|
16
17
|
{
|
|
17
|
-
title: 'Today',
|
|
18
|
+
title: i18n.t('Today'),
|
|
18
19
|
swaps: [],
|
|
19
20
|
},
|
|
20
21
|
],
|
|
21
22
|
[
|
|
22
23
|
'week',
|
|
23
24
|
{
|
|
24
|
-
title: 'This week',
|
|
25
|
+
title: i18n.t('This week'),
|
|
25
26
|
swaps: [],
|
|
26
27
|
},
|
|
27
28
|
],
|
|
28
29
|
[
|
|
29
30
|
'month',
|
|
30
31
|
{
|
|
31
|
-
title: 'This month',
|
|
32
|
+
title: i18n.t('This month'),
|
|
32
33
|
swaps: [],
|
|
33
34
|
},
|
|
34
35
|
],
|
|
35
36
|
[
|
|
36
37
|
'year',
|
|
37
38
|
{
|
|
38
|
-
title: 'This year',
|
|
39
|
+
title: i18n.t('This year'),
|
|
39
40
|
swaps: [],
|
|
40
41
|
},
|
|
41
42
|
],
|
package/src/utils/quote.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
2
|
import type { QuoteError, QuoteWarning, Wallet } from '../types';
|
|
3
|
-
import type { PriceImpactWarningLevel } from '@rango-dev/ui';
|
|
3
|
+
import type { PriceImpactWarningLevel, Step } from '@rango-dev/ui';
|
|
4
4
|
import type {
|
|
5
5
|
SimulationAssetAndAmount,
|
|
6
6
|
SimulationValidationStatus,
|
|
@@ -336,3 +336,20 @@ export function getPriceImpact(
|
|
|
336
336
|
|
|
337
337
|
return percentageChange && percentageChange < 0 ? percentageChange : null;
|
|
338
338
|
}
|
|
339
|
+
|
|
340
|
+
export const getUniqueBlockchains = (steps: Step[]) => {
|
|
341
|
+
const set = new Set();
|
|
342
|
+
const result: { displayName: string; image: string }[] = [];
|
|
343
|
+
steps.forEach((step) => {
|
|
344
|
+
if (!set.has(step.from.chain.displayName)) {
|
|
345
|
+
set.add(step.from.chain.displayName);
|
|
346
|
+
result.push(step.from.chain);
|
|
347
|
+
}
|
|
348
|
+
if (!set.has(step.to.chain.displayName)) {
|
|
349
|
+
set.add(step.to.chain.displayName);
|
|
350
|
+
result.push(step.to.chain);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
return result;
|
|
355
|
+
};
|
package/src/utils/swap.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
+
import type { FeesGroup, NameOfFees } from '../constants/quote';
|
|
2
3
|
import type { FetchStatus } from '../store/slices/data';
|
|
3
4
|
import type {
|
|
4
5
|
ConvertedToken,
|
|
@@ -14,6 +15,7 @@ import type {
|
|
|
14
15
|
BestRouteResponse,
|
|
15
16
|
BlockchainMeta,
|
|
16
17
|
RecommendedSlippage,
|
|
18
|
+
SwapFee,
|
|
17
19
|
SwapResult,
|
|
18
20
|
Token,
|
|
19
21
|
} from 'rango-sdk';
|
|
@@ -328,6 +330,39 @@ export function getTotalFeeInUsd(
|
|
|
328
330
|
);
|
|
329
331
|
}
|
|
330
332
|
|
|
333
|
+
export function getUsdFee(fee: SwapFee): BigNumber {
|
|
334
|
+
let totalFeeInUsd = ZERO;
|
|
335
|
+
totalFeeInUsd = totalFeeInUsd.plus(
|
|
336
|
+
new BigNumber(fee.amount).multipliedBy(fee.price || 0)
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
return totalFeeInUsd;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export function getTotalFeesInUsd(fees: SwapFee[]): BigNumber {
|
|
343
|
+
return fees.reduce(
|
|
344
|
+
(totalFee: BigNumber, fee) => totalFee.plus(getUsdFee(fee)),
|
|
345
|
+
ZERO
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
export function getFeesGroup(swaps: SwapResult[]): FeesGroup {
|
|
349
|
+
return swaps.reduce(
|
|
350
|
+
(result, swap) => {
|
|
351
|
+
for (const fee of swap.fee) {
|
|
352
|
+
const name = fee.name as NameOfFees;
|
|
353
|
+
const feeGroup =
|
|
354
|
+
fee.expenseType !== 'DECREASE_FROM_OUTPUT'
|
|
355
|
+
? result.payable
|
|
356
|
+
: result.nonePayable;
|
|
357
|
+
|
|
358
|
+
feeGroup[name] = [...(feeGroup[name] || []), fee];
|
|
359
|
+
}
|
|
360
|
+
return result;
|
|
361
|
+
},
|
|
362
|
+
{ payable: {}, nonePayable: {} } as FeesGroup
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
|
|
331
366
|
export function hasHighFee(totalFeeInUsd: BigNumber | null) {
|
|
332
367
|
if (!totalFeeInUsd) {
|
|
333
368
|
return false;
|
package/src/utils/ui.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
2
|
import type { WidgetTheme } from '../types';
|
|
3
3
|
import type { createTheme } from '@rango-dev/ui';
|
|
4
|
+
import type React from 'react';
|
|
4
5
|
|
|
5
6
|
import {
|
|
6
7
|
theme as baseThemeTokens,
|
|
@@ -70,3 +71,22 @@ export function customizedThemeTokens(
|
|
|
70
71
|
dark,
|
|
71
72
|
};
|
|
72
73
|
}
|
|
74
|
+
|
|
75
|
+
export function joinList(
|
|
76
|
+
list: React.JSX.Element[],
|
|
77
|
+
divider: React.JSX.Element
|
|
78
|
+
) {
|
|
79
|
+
if (list.length <= 1) {
|
|
80
|
+
return list;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const output: React.JSX.Element[] = [];
|
|
84
|
+
list.forEach((item, index) => {
|
|
85
|
+
output.push(item);
|
|
86
|
+
if (index < list.length - 1) {
|
|
87
|
+
output.push(divider);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
return output;
|
|
92
|
+
}
|