@lifi/widget 2.0.0-beta.0 → 2.0.0-beta.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/App.d.ts +4 -3
- package/AppDrawer.d.ts +1 -1
- package/AppDrawer.js +2 -1
- package/AppProvider.js +1 -1
- package/README.md +11 -12
- package/cjs/App.d.ts +4 -3
- package/cjs/AppDrawer.d.ts +1 -1
- package/cjs/AppDrawer.js +2 -1
- package/cjs/AppProvider.js +1 -1
- package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -1
- package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
- package/cjs/components/ChainSelect/useChainSelect.js +6 -0
- package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -1
- package/cjs/components/GasMessage/GasMessage.js +1 -6
- package/cjs/components/Header/Header.js +2 -2
- package/cjs/components/Header/Header.style.d.ts +10 -3
- package/cjs/components/Header/Header.style.js +3 -0
- package/cjs/components/Header/NavigationHeader.js +23 -7
- package/cjs/components/Header/NavigationTabs.d.ts +1 -0
- package/cjs/components/Header/NavigationTabs.js +26 -0
- package/cjs/components/Header/NavigationTabs.style.d.ts +34 -0
- package/cjs/components/Header/NavigationTabs.style.js +61 -0
- package/cjs/components/Header/WalletHeader.d.ts +1 -0
- package/cjs/components/Header/WalletHeader.js +16 -9
- package/cjs/components/Header/useHeaderActionStore.js +0 -1
- package/cjs/components/Insurance/Insurance.js +2 -2
- package/cjs/components/Insurance/InsuranceCard.js +34 -12
- package/cjs/components/Insurance/InsuranceCollapsed.js +9 -11
- package/cjs/components/Insurance/index.d.ts +1 -0
- package/cjs/components/Insurance/index.js +1 -0
- package/cjs/components/Insurance/types.d.ts +12 -9
- package/cjs/components/NFT/NFT.js +2 -2
- package/cjs/components/NFT/types.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.js +2 -3
- package/cjs/components/SelectChainAndToken.js +8 -7
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +6 -3
- package/cjs/components/SendToWallet/SendToWallet.js +2 -2
- package/cjs/components/SmallAvatar.d.ts +1 -1
- package/cjs/components/Step/CircularProgress.d.ts +1 -1
- package/cjs/components/Step/Step.js +15 -5
- package/cjs/components/Step/StepList.d.ts +1 -1
- package/cjs/components/StepActions/StepActions.js +4 -20
- package/cjs/components/SwapButton/SwapButton.js +16 -4
- package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
- package/cjs/components/SwapInput/SwapInput.js +2 -2
- package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -3
- package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
- package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -2
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
- package/cjs/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
- package/cjs/components/Token/Token.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
- package/cjs/components/TokenList/TokenList.js +9 -4
- package/cjs/components/TokenList/TokenList.style.d.ts +5 -2
- package/cjs/components/TokenList/TokenList.style.js +20 -1
- package/cjs/components/TokenList/TokenListItem.d.ts +1 -1
- package/cjs/components/TokenList/TokenListItem.js +28 -5
- package/cjs/components/TokenList/VirtualizedTokenList.js +3 -3
- package/cjs/components/TokenList/types.d.ts +6 -3
- package/cjs/config/theme.js +15 -3
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +2 -1
- package/cjs/hooks/index.js +2 -1
- package/cjs/hooks/useContentHeight.js +3 -5
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFundsSufficiency.js +2 -2
- package/cjs/hooks/useGasRefuel.d.ts +1 -1
- package/cjs/hooks/useGasRefuel.js +5 -15
- package/cjs/hooks/useGasSufficiency.js +12 -3
- package/cjs/hooks/useInitializer.js +0 -1
- package/cjs/hooks/useProcessMessage.d.ts +2 -1
- package/cjs/hooks/useProcessMessage.js +27 -9
- package/cjs/hooks/useRouteExecution.js +6 -5
- package/cjs/hooks/useSwapOnly.d.ts +1 -0
- package/cjs/hooks/useSwapOnly.js +9 -0
- package/cjs/hooks/useSwapRoutes.d.ts +1 -2
- package/cjs/hooks/useSwapRoutes.js +32 -18
- package/cjs/hooks/useToken.d.ts +1 -1
- package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
- package/cjs/hooks/useTokenBalance.js +6 -7
- package/cjs/hooks/useTokenBalances.d.ts +5 -5
- package/cjs/hooks/useTokenBalances.js +4 -19
- package/cjs/hooks/useTokenSearch.d.ts +2 -2
- package/cjs/hooks/useTokens.d.ts +2 -2
- package/cjs/i18n/bn.json +8 -0
- package/cjs/i18n/en.json +30 -5
- package/cjs/i18n/fr.json +8 -0
- package/cjs/i18n/id.json +22 -7
- package/cjs/i18n/ko.json +22 -7
- package/cjs/i18n/pt.json +40 -12
- package/cjs/i18n/th.json +21 -6
- package/cjs/i18n/uk.json +45 -20
- package/cjs/i18n/zh.json +23 -8
- package/cjs/icons/InsuraceLogo.d.ts +1 -1
- package/cjs/icons/LiFiFullLogo.d.ts +1 -1
- package/cjs/icons/LiFiLogo.d.ts +1 -1
- package/cjs/icons/LiFiToolLogo.d.ts +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -1
- package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -1
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
- package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -1
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -1
- package/cjs/pages/SettingsPage/LanguageSelect.js +1 -1
- package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -1
- package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
- package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +15 -9
- package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
- package/cjs/pages/SwapPage/SwapPage.js +31 -10
- package/cjs/pages/SwapPage/TokenValueBottomSheet.js +7 -12
- package/cjs/pages/SwapPage/utils.d.ts +2 -0
- package/cjs/pages/SwapPage/utils.js +10 -0
- package/cjs/providers/I18nProvider/I18nProvider.js +3 -3
- package/cjs/providers/SDKProvider/SDKProvider.js +2 -0
- package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +107 -35
- package/cjs/providers/WalletProvider/index.d.ts +1 -1
- package/cjs/providers/WalletProvider/index.js +1 -1
- package/cjs/providers/WalletProvider/types.d.ts +4 -6
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -1
- package/cjs/stores/StoreProvider.d.ts +2 -2
- package/cjs/stores/StoreProvider.js +3 -2
- package/cjs/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/cjs/stores/routes/RouteExecutionStore.js +0 -1
- package/cjs/stores/settings/index.d.ts +1 -0
- package/cjs/stores/settings/index.js +1 -0
- package/cjs/stores/settings/types.d.ts +11 -0
- package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
- package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
- package/cjs/types/events.d.ts +9 -1
- package/cjs/types/events.js +1 -0
- package/cjs/types/token.d.ts +2 -2
- package/cjs/types/widget.d.ts +13 -8
- package/cjs/types/widget.js +4 -2
- package/cjs/utils/format.d.ts +1 -1
- package/cjs/utils/format.js +7 -12
- package/cjs/utils/wallet.d.ts +1 -1
- package/cjs/utils/wallet.js +3 -3
- package/components/ChainSelect/ChainSelect.d.ts +1 -1
- package/components/ChainSelect/ChainSelect.style.js +1 -1
- package/components/ChainSelect/useChainSelect.js +7 -1
- package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -1
- package/components/GasMessage/GasMessage.js +2 -7
- package/components/Header/Header.js +3 -3
- package/components/Header/Header.style.d.ts +10 -3
- package/components/Header/Header.style.js +3 -0
- package/components/Header/NavigationHeader.js +23 -7
- package/components/Header/NavigationTabs.d.ts +1 -0
- package/components/Header/NavigationTabs.js +22 -0
- package/components/Header/NavigationTabs.style.d.ts +34 -0
- package/components/Header/NavigationTabs.style.js +58 -0
- package/components/Header/WalletHeader.d.ts +1 -0
- package/components/Header/WalletHeader.js +14 -8
- package/components/Header/useHeaderActionStore.js +0 -1
- package/components/Insurance/Insurance.js +2 -2
- package/components/Insurance/InsuranceCard.js +37 -15
- package/components/Insurance/InsuranceCollapsed.js +9 -11
- package/components/Insurance/index.d.ts +1 -0
- package/components/Insurance/index.js +1 -0
- package/components/Insurance/types.d.ts +12 -9
- package/components/NFT/NFT.js +2 -2
- package/components/NFT/types.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.js +2 -3
- package/components/SelectChainAndToken.js +9 -8
- package/components/SelectTokenButton/SelectTokenButton.js +7 -4
- package/components/SendToWallet/SendToWallet.js +2 -2
- package/components/SmallAvatar.d.ts +1 -1
- package/components/Step/CircularProgress.d.ts +1 -1
- package/components/Step/Step.js +16 -6
- package/components/Step/StepList.d.ts +1 -1
- package/components/StepActions/StepActions.js +4 -20
- package/components/SwapButton/SwapButton.js +16 -4
- package/components/SwapInput/FormPriceHelperText.js +2 -2
- package/components/SwapInput/SwapInput.js +3 -3
- package/components/SwapInput/SwapInputEndAdornment.d.ts +1 -1
- package/components/SwapInput/SwapInputEndAdornment.js +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +21 -5
- package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
- package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
- package/components/SwapRoutes/SwapRoutes.js +1 -1
- package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -2
- package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
- package/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
- package/components/Token/Token.js +1 -1
- package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
- package/components/TokenList/TokenList.js +10 -5
- package/components/TokenList/TokenList.style.d.ts +5 -2
- package/components/TokenList/TokenList.style.js +21 -2
- package/components/TokenList/TokenListItem.d.ts +1 -1
- package/components/TokenList/TokenListItem.js +32 -9
- package/components/TokenList/VirtualizedTokenList.js +3 -3
- package/components/TokenList/types.d.ts +6 -3
- package/config/theme.js +15 -3
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +2 -1
- package/hooks/useContentHeight.js +4 -6
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFundsSufficiency.js +2 -2
- package/hooks/useGasRefuel.d.ts +1 -1
- package/hooks/useGasRefuel.js +5 -15
- package/hooks/useGasSufficiency.js +13 -4
- package/hooks/useInitializer.js +0 -1
- package/hooks/useProcessMessage.d.ts +2 -1
- package/hooks/useProcessMessage.js +27 -9
- package/hooks/useRouteExecution.js +6 -5
- package/hooks/useSwapOnly.d.ts +1 -0
- package/hooks/useSwapOnly.js +5 -0
- package/hooks/useSwapRoutes.d.ts +1 -2
- package/hooks/useSwapRoutes.js +32 -18
- package/hooks/useToken.d.ts +1 -1
- package/hooks/useTokenAddressBalance.d.ts +2 -2
- package/hooks/useTokenBalance.js +6 -7
- package/hooks/useTokenBalances.d.ts +5 -5
- package/hooks/useTokenBalances.js +4 -19
- package/hooks/useTokenSearch.d.ts +2 -2
- package/hooks/useTokens.d.ts +2 -2
- package/i18n/bn.json +8 -0
- package/i18n/en.json +30 -5
- package/i18n/fr.json +8 -0
- package/i18n/id.json +22 -7
- package/i18n/ko.json +22 -7
- package/i18n/pt.json +40 -12
- package/i18n/th.json +21 -6
- package/i18n/uk.json +45 -20
- package/i18n/zh.json +23 -8
- package/icons/InsuraceLogo.d.ts +1 -1
- package/icons/LiFiFullLogo.d.ts +1 -1
- package/icons/LiFiLogo.d.ts +1 -1
- package/icons/LiFiToolLogo.d.ts +1 -1
- package/index.d.ts +1 -1
- package/package.json +13 -13
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -1
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -1
- package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -1
- package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/pages/SettingsPage/GasPriceSelect.d.ts +1 -1
- package/pages/SettingsPage/LanguageSelect.js +1 -1
- package/pages/SettingsPage/SettingsPage.d.ts +1 -1
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -1
- package/pages/SettingsPage/SlippageInput.d.ts +1 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
- package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
- package/pages/SwapPage/StatusBottomSheet.js +18 -12
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
- package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
- package/pages/SwapPage/SwapPage.js +33 -12
- package/pages/SwapPage/TokenValueBottomSheet.js +8 -13
- package/pages/SwapPage/utils.d.ts +2 -0
- package/pages/SwapPage/utils.js +6 -0
- package/providers/I18nProvider/I18nProvider.js +3 -3
- package/providers/SDKProvider/SDKProvider.js +2 -0
- package/providers/SwapFormProvider/FormUpdater.js +3 -0
- package/providers/WalletProvider/WalletProvider.js +108 -36
- package/providers/WalletProvider/index.d.ts +1 -1
- package/providers/WalletProvider/index.js +1 -1
- package/providers/WalletProvider/types.d.ts +4 -6
- package/providers/WidgetProvider/WidgetProvider.js +2 -2
- package/stores/StoreProvider.d.ts +2 -2
- package/stores/StoreProvider.js +3 -2
- package/stores/routes/RouteExecutionStore.d.ts +1 -1
- package/stores/routes/RouteExecutionStore.js +0 -1
- package/stores/settings/index.d.ts +1 -0
- package/stores/settings/index.js +1 -0
- package/stores/settings/types.d.ts +11 -0
- package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
- package/stores/settings/useSplitSubvariantStore.js +37 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +9 -1
- package/types/events.js +1 -0
- package/types/token.d.ts +2 -2
- package/types/widget.d.ts +13 -8
- package/types/widget.js +4 -2
- package/utils/format.d.ts +1 -1
- package/utils/format.js +5 -10
- package/utils/wallet.d.ts +1 -1
- package/utils/wallet.js +1 -1
package/cjs/types/widget.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Signer } from '@ethersproject/abstract-signer';
|
|
2
|
-
import type { ChainKey, ConfigUpdate, Order, RouteOptions,
|
|
2
|
+
import type { BaseToken, ChainKey, ConfigUpdate, Order, RouteOptions, StaticToken } from '@lifi/sdk';
|
|
3
3
|
import type { Components, PaletteMode, PaletteOptions, Shape, Theme } from '@mui/material';
|
|
4
4
|
import type { TypographyOptions } from '@mui/material/styles/createTypography';
|
|
5
5
|
import type { CSSProperties, ReactNode, RefObject } from 'react';
|
|
6
6
|
import type { LanguageKey, LanguageResources } from '../providers';
|
|
7
7
|
export type WidgetVariant = 'default' | 'expandable' | 'drawer' | 'refuel' | 'nft';
|
|
8
|
+
export type WidgetSubvariant = 'default' | 'split';
|
|
8
9
|
export declare enum DisabledUI {
|
|
9
10
|
FromAmount = "fromAmount",
|
|
10
11
|
FromToken = "fromToken",
|
|
@@ -14,9 +15,13 @@ export declare enum DisabledUI {
|
|
|
14
15
|
export type DisabledUIType = `${DisabledUI}`;
|
|
15
16
|
export declare enum HiddenUI {
|
|
16
17
|
Appearance = "appearance",
|
|
18
|
+
DrawerButton = "drawerButton",
|
|
19
|
+
History = "history",
|
|
17
20
|
Language = "language",
|
|
18
21
|
PoweredBy = "poweredBy",
|
|
19
|
-
ToAddress = "toAddress"
|
|
22
|
+
ToAddress = "toAddress",
|
|
23
|
+
ToToken = "toToken",
|
|
24
|
+
WalletMenu = "walletMenu"
|
|
20
25
|
}
|
|
21
26
|
export type HiddenUIType = `${HiddenUI}`;
|
|
22
27
|
export declare enum RequiredUI {
|
|
@@ -34,7 +39,7 @@ export interface WidgetWalletManagement {
|
|
|
34
39
|
connect(): Promise<Signer>;
|
|
35
40
|
disconnect(): Promise<void>;
|
|
36
41
|
switchChain?(chainId: number): Promise<Signer>;
|
|
37
|
-
addToken?(token:
|
|
42
|
+
addToken?(token: StaticToken, chainId: number): Promise<void>;
|
|
38
43
|
addChain?(chainId: number): Promise<boolean>;
|
|
39
44
|
signer?: Signer;
|
|
40
45
|
}
|
|
@@ -72,10 +77,10 @@ export interface WidgetConfig {
|
|
|
72
77
|
slippage?: number;
|
|
73
78
|
insurance?: boolean;
|
|
74
79
|
variant?: WidgetVariant;
|
|
80
|
+
subvariant?: WidgetSubvariant;
|
|
75
81
|
appearance?: Appearance;
|
|
76
82
|
theme?: ThemeConfig;
|
|
77
83
|
containerStyle?: CSSProperties;
|
|
78
|
-
disableTelemetry?: boolean;
|
|
79
84
|
disabledUI?: DisabledUIType[];
|
|
80
85
|
hiddenUI?: HiddenUIType[];
|
|
81
86
|
requiredUI?: RequiredUIType[];
|
|
@@ -97,9 +102,9 @@ export interface WidgetConfig {
|
|
|
97
102
|
deny?: number[];
|
|
98
103
|
};
|
|
99
104
|
tokens?: {
|
|
100
|
-
featured?:
|
|
101
|
-
allow?:
|
|
102
|
-
deny?:
|
|
105
|
+
featured?: StaticToken[];
|
|
106
|
+
allow?: BaseToken[];
|
|
107
|
+
deny?: BaseToken[];
|
|
103
108
|
};
|
|
104
109
|
languages?: {
|
|
105
110
|
default?: LanguageKey;
|
|
@@ -107,7 +112,7 @@ export interface WidgetConfig {
|
|
|
107
112
|
deny?: LanguageKey[];
|
|
108
113
|
};
|
|
109
114
|
languageResources?: LanguageResources;
|
|
110
|
-
|
|
115
|
+
disableLanguageDetector?: boolean;
|
|
111
116
|
}
|
|
112
117
|
export type WidgetDrawerProps = {
|
|
113
118
|
elementRef?: RefObject<HTMLDivElement>;
|
package/cjs/types/widget.js
CHANGED
|
@@ -11,11 +11,13 @@ var DisabledUI;
|
|
|
11
11
|
var HiddenUI;
|
|
12
12
|
(function (HiddenUI) {
|
|
13
13
|
HiddenUI["Appearance"] = "appearance";
|
|
14
|
-
|
|
14
|
+
HiddenUI["DrawerButton"] = "drawerButton";
|
|
15
|
+
HiddenUI["History"] = "history";
|
|
15
16
|
HiddenUI["Language"] = "language";
|
|
16
17
|
HiddenUI["PoweredBy"] = "poweredBy";
|
|
17
18
|
HiddenUI["ToAddress"] = "toAddress";
|
|
18
|
-
|
|
19
|
+
HiddenUI["ToToken"] = "toToken";
|
|
20
|
+
HiddenUI["WalletMenu"] = "walletMenu";
|
|
19
21
|
})(HiddenUI = exports.HiddenUI || (exports.HiddenUI = {}));
|
|
20
22
|
var RequiredUI;
|
|
21
23
|
(function (RequiredUI) {
|
package/cjs/utils/format.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const formatTokenAmount: (amount?: string, decimals?: number, decimalPlaces?: number) => string;
|
|
7
7
|
export declare const formatSlippage: (slippage?: string, defaultValue?: string, returnInitial?: boolean) => string;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const formatInputAmount: (amount: string, returnInitial?: boolean) => string;
|
|
9
9
|
export declare const formatTokenPrice: (amount?: string, price?: string) => number;
|
package/cjs/utils/format.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatTokenPrice = exports.
|
|
3
|
+
exports.formatTokenPrice = exports.formatInputAmount = exports.formatSlippage = exports.formatTokenAmount = void 0;
|
|
4
4
|
const big_js_1 = require("big.js");
|
|
5
5
|
// JavaScript numbers use exponential notation for positive exponents of 21 and above. We need more.
|
|
6
6
|
big_js_1.default.PE = 42;
|
|
@@ -24,7 +24,7 @@ const formatTokenAmount = (amount = '0', decimals = 0, decimalPlaces = 3) => {
|
|
|
24
24
|
while (absAmount < 1 / 10 ** decimalPlaces) {
|
|
25
25
|
decimalPlaces++;
|
|
26
26
|
}
|
|
27
|
-
return (0, big_js_1.default)(
|
|
27
|
+
return (0, big_js_1.default)(parsedAmount).toFixed(decimalPlaces + 1, 0);
|
|
28
28
|
};
|
|
29
29
|
exports.formatTokenAmount = formatTokenAmount;
|
|
30
30
|
const formatSlippage = (slippage = '', defaultValue = '', returnInitial = false) => {
|
|
@@ -50,7 +50,7 @@ const formatSlippage = (slippage = '', defaultValue = '', returnInitial = false)
|
|
|
50
50
|
return parsedSlippage.toString();
|
|
51
51
|
};
|
|
52
52
|
exports.formatSlippage = formatSlippage;
|
|
53
|
-
const
|
|
53
|
+
const formatInputAmount = (amount, returnInitial = false) => {
|
|
54
54
|
if (!amount) {
|
|
55
55
|
return amount;
|
|
56
56
|
}
|
|
@@ -62,23 +62,18 @@ const formatAmount = (amount = '', returnInitial = false) => {
|
|
|
62
62
|
if (isNaN(Number(formattedAmount)) && !isNaN(parsedAmount)) {
|
|
63
63
|
return parsedAmount.toString();
|
|
64
64
|
}
|
|
65
|
-
if (isNaN(parsedAmount)) {
|
|
66
|
-
return '';
|
|
67
|
-
}
|
|
68
|
-
if (parsedAmount < 0) {
|
|
69
|
-
return Math.abs(parsedAmount).toString();
|
|
70
|
-
}
|
|
71
65
|
try {
|
|
72
|
-
|
|
66
|
+
const absFormattedAmount = (0, big_js_1.default)(formattedAmount).abs();
|
|
67
|
+
if (returnInitial) {
|
|
73
68
|
return formattedAmount;
|
|
74
69
|
}
|
|
70
|
+
return absFormattedAmount.toString();
|
|
75
71
|
}
|
|
76
72
|
catch {
|
|
77
73
|
return '';
|
|
78
74
|
}
|
|
79
|
-
return (0, big_js_1.default)(parsedAmount).toString();
|
|
80
75
|
};
|
|
81
|
-
exports.
|
|
76
|
+
exports.formatInputAmount = formatInputAmount;
|
|
82
77
|
const formatTokenPrice = (amount, price) => {
|
|
83
78
|
if (!amount || !price) {
|
|
84
79
|
return 0;
|
package/cjs/utils/wallet.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const shortenAddress: (address?: string) => string | null;
|
package/cjs/utils/wallet.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.shortenAddress = void 0;
|
|
4
|
+
const shortenAddress = (address) => address
|
|
5
5
|
? `${address.substring(0, 5)}...${address.substring(address.length - 4)}`
|
|
6
6
|
: null;
|
|
7
|
-
exports.
|
|
7
|
+
exports.shortenAddress = shortenAddress;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SwapFormTypeProps } from '../../providers';
|
|
2
|
-
export declare const ChainSelect: ({ formType }: SwapFormTypeProps) => JSX.Element;
|
|
2
|
+
export declare const ChainSelect: ({ formType }: SwapFormTypeProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -9,7 +9,7 @@ export const ChainCard = styled(Card)({
|
|
|
9
9
|
});
|
|
10
10
|
export const ChainContainer = styled(Box)(({ theme }) => ({
|
|
11
11
|
display: 'grid',
|
|
12
|
-
gridTemplateColumns: 'repeat(
|
|
12
|
+
gridTemplateColumns: 'repeat(auto-fit, minmax(52px, 1fr))',
|
|
13
13
|
gridAutoRows: '56px',
|
|
14
14
|
justifyContent: 'space-between',
|
|
15
15
|
gap: theme.spacing(1.5),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useController, useFormContext } from 'react-hook-form';
|
|
2
|
-
import { useChains } from '../../hooks';
|
|
2
|
+
import { useChains, useSwapOnly } from '../../hooks';
|
|
3
3
|
import { SwapFormKey, SwapFormKeyHelper } from '../../providers';
|
|
4
4
|
import { useChainOrder } from '../../stores';
|
|
5
5
|
export const useChainSelect = (formType) => {
|
|
@@ -8,6 +8,7 @@ export const useChainSelect = (formType) => {
|
|
|
8
8
|
const { setValue } = useFormContext();
|
|
9
9
|
const { chains, isLoading } = useChains();
|
|
10
10
|
const [chainOrder, setChainOrder] = useChainOrder();
|
|
11
|
+
const swapOnly = useSwapOnly();
|
|
11
12
|
const getChains = () => {
|
|
12
13
|
if (!chains) {
|
|
13
14
|
return [];
|
|
@@ -20,6 +21,11 @@ export const useChainSelect = (formType) => {
|
|
|
20
21
|
const setCurrentChain = (chainId) => {
|
|
21
22
|
onChange(chainId);
|
|
22
23
|
onBlur();
|
|
24
|
+
if (swapOnly) {
|
|
25
|
+
setValue(SwapFormKeyHelper.getChainKey('to'), chainId, {
|
|
26
|
+
shouldTouch: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
23
29
|
setValue(SwapFormKeyHelper.getTokenKey(formType), '');
|
|
24
30
|
setValue(SwapFormKeyHelper.getAmountKey(formType), '');
|
|
25
31
|
setValue(SwapFormKey.TokenSearchFilter, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const FundsSufficiencyMessage: () => JSX.Element;
|
|
1
|
+
export declare const FundsSufficiencyMessage: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Collapse } from '@mui/material';
|
|
3
|
-
import { useFundsSufficiency,
|
|
4
|
-
import { useSettings } from '../../stores';
|
|
3
|
+
import { useFundsSufficiency, useGasSufficiency } from '../../hooks';
|
|
5
4
|
import { FundsSufficiencyMessage } from './FundsSufficiencyMessage';
|
|
6
5
|
import { GasSufficiencyMessage } from './GasSufficiencyMessage';
|
|
7
6
|
export const GasMessage = ({ route, ...props }) => {
|
|
8
7
|
const { insufficientGas } = useGasSufficiency(route);
|
|
9
8
|
const { insufficientFunds } = useFundsSufficiency(route);
|
|
10
|
-
|
|
11
|
-
const { enabled, isLoading: isRefuelLoading } = useGasRefuel();
|
|
12
|
-
const enabledRefuel = enabled && enabledAutoRefuel;
|
|
13
|
-
const showGasSufficiencyMessage = insufficientGas?.length && !isRefuelLoading && !enabledRefuel;
|
|
14
|
-
return (_jsx(Collapse, { timeout: 225, in: Boolean(insufficientFunds || showGasSufficiencyMessage), unmountOnExit: true, mountOnEnter: true, children: _jsx(Box, { ...props, children: insufficientFunds ? (_jsx(FundsSufficiencyMessage, {})) : showGasSufficiencyMessage ? (_jsx(GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
|
|
9
|
+
return (_jsx(Collapse, { timeout: 225, in: Boolean(insufficientFunds || insufficientGas?.length), unmountOnExit: true, mountOnEnter: true, children: _jsx(Box, { ...props, children: insufficientFunds ? (_jsx(FundsSufficiencyMessage, {})) : insufficientGas?.length ? (_jsx(GasSufficiencyMessage, { insufficientGas: insufficientGas })) : null }) }));
|
|
15
10
|
};
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
3
|
import { useDefaultElementId } from '../../hooks';
|
|
4
4
|
import { useWidgetConfig } from '../../providers';
|
|
5
|
-
import {
|
|
5
|
+
import { ElementId, createElementId, stickyHeaderRoutes } from '../../utils';
|
|
6
6
|
import { Container } from './Header.style';
|
|
7
7
|
import { NavigationHeader } from './NavigationHeader';
|
|
8
8
|
import { WalletHeader } from './WalletHeader';
|
|
@@ -12,6 +12,6 @@ export const HeaderContainer = ({ children }) => {
|
|
|
12
12
|
return (_jsx(Container, { id: createElementId(ElementId.Header, elementId), sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)), children: children }));
|
|
13
13
|
};
|
|
14
14
|
export const Header = () => {
|
|
15
|
-
const { walletManagement } = useWidgetConfig();
|
|
16
|
-
return (_jsxs(HeaderContainer, { children: [!walletManagement ? _jsx(WalletHeader, {}) : null, _jsx(NavigationHeader, {})] }));
|
|
15
|
+
const { walletManagement, subvariant } = useWidgetConfig();
|
|
16
|
+
return (_jsxs(HeaderContainer, { children: [!walletManagement && subvariant !== 'split' ? _jsx(WalletHeader, {}) : null, _jsx(NavigationHeader, {})] }));
|
|
17
17
|
};
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const HeaderAppBar: import("@emotion/styled").StyledComponent<
|
|
2
|
+
export declare const HeaderAppBar: import("@emotion/styled").StyledComponent<{
|
|
3
3
|
classes?: Partial<import("@mui/material").AppBarClasses> | undefined;
|
|
4
4
|
color?: import("@mui/types").OverridableStringUnion<"transparent" | import("@mui/material").PropTypes.Color, import("@mui/material").AppBarPropsColorOverrides> | undefined;
|
|
5
5
|
enableColorOnDark?: boolean | undefined;
|
|
6
6
|
position?: "fixed" | "absolute" | "relative" | "static" | "sticky" | undefined;
|
|
7
7
|
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
8
|
-
} &
|
|
8
|
+
} & Omit<{
|
|
9
|
+
children?: import("react").ReactNode;
|
|
10
|
+
classes?: Partial<import("@mui/material").PaperClasses> | undefined;
|
|
11
|
+
elevation?: number | undefined;
|
|
12
|
+
square?: boolean | undefined;
|
|
13
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
14
|
+
variant?: import("@mui/types").OverridableStringUnion<"outlined" | "elevation", import("@mui/material").PaperPropsVariantOverrides> | undefined;
|
|
15
|
+
}, "classes" | "color" | "position"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & {
|
|
9
16
|
ref?: ((instance: HTMLElement | null) => void) | import("react").RefObject<HTMLElement> | null | undefined;
|
|
10
|
-
}, keyof import("@mui/material/OverridableComponent").CommonProps | "
|
|
17
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "color" | "children" | "sx" | "position" | "variant" | "square" | "elevation" | "enableColorOnDark"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
11
18
|
export declare const Container: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
|
|
12
19
|
children?: import("react").ReactNode;
|
|
13
20
|
component?: import("react").ElementType<any> | undefined;
|
|
@@ -7,12 +7,15 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { Route, Routes, useLocation } from 'react-router-dom';
|
|
8
8
|
import { useNavigateBack } from '../../hooks';
|
|
9
9
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
10
|
+
import { HiddenUI } from '../../types';
|
|
10
11
|
import { backButtonRoutes, navigationRoutes, navigationRoutesValues, } from '../../utils';
|
|
11
12
|
import { HeaderAppBar } from './Header.style';
|
|
13
|
+
import { NavigationTabs } from './NavigationTabs';
|
|
14
|
+
import { WalletMenuButton } from './WalletHeader';
|
|
12
15
|
import { useHeaderActionStore } from './useHeaderActionStore';
|
|
13
16
|
export const NavigationHeader = () => {
|
|
14
17
|
const { t } = useTranslation();
|
|
15
|
-
const { variant } = useWidgetConfig();
|
|
18
|
+
const { variant, subvariant, hiddenUI } = useWidgetConfig();
|
|
16
19
|
const { navigate, navigateBack } = useNavigateBack();
|
|
17
20
|
const { account } = useWallet();
|
|
18
21
|
const { element } = useHeaderActionStore();
|
|
@@ -22,6 +25,7 @@ export const NavigationHeader = () => {
|
|
|
22
25
|
: pathname;
|
|
23
26
|
const path = cleanedPathname.substring(cleanedPathname.lastIndexOf('/') + 1);
|
|
24
27
|
const hasPath = navigationRoutesValues.includes(path);
|
|
28
|
+
const splitSubvariant = subvariant === 'split' && !hasPath;
|
|
25
29
|
const handleHeaderTitle = () => {
|
|
26
30
|
switch (path) {
|
|
27
31
|
case navigationRoutes.selectWallet:
|
|
@@ -34,8 +38,12 @@ export const NavigationHeader = () => {
|
|
|
34
38
|
return t(`settings.enabledExchanges`);
|
|
35
39
|
case navigationRoutes.swapHistory:
|
|
36
40
|
return t(`header.swapHistory`);
|
|
37
|
-
case navigationRoutes.fromToken:
|
|
41
|
+
case navigationRoutes.fromToken: {
|
|
42
|
+
if (variant === 'nft') {
|
|
43
|
+
return t(`header.payWith`);
|
|
44
|
+
}
|
|
38
45
|
return t(`header.from`);
|
|
46
|
+
}
|
|
39
47
|
case navigationRoutes.toToken:
|
|
40
48
|
return t(`header.to`);
|
|
41
49
|
case navigationRoutes.fromChain:
|
|
@@ -46,10 +54,18 @@ export const NavigationHeader = () => {
|
|
|
46
54
|
return t(`header.routes`);
|
|
47
55
|
case navigationRoutes.activeSwaps:
|
|
48
56
|
return t(`header.activeSwaps`);
|
|
49
|
-
case navigationRoutes.swapExecution:
|
|
57
|
+
case navigationRoutes.swapExecution: {
|
|
58
|
+
if (variant === 'nft') {
|
|
59
|
+
return t(`header.purchase`);
|
|
60
|
+
}
|
|
50
61
|
return t(`header.swap`);
|
|
51
|
-
|
|
62
|
+
}
|
|
63
|
+
case navigationRoutes.swapDetails: {
|
|
64
|
+
if (variant === 'nft') {
|
|
65
|
+
return t(`header.purchaseDetails`);
|
|
66
|
+
}
|
|
52
67
|
return t(`header.swapDetails`);
|
|
68
|
+
}
|
|
53
69
|
default: {
|
|
54
70
|
switch (variant) {
|
|
55
71
|
case 'nft':
|
|
@@ -62,7 +78,7 @@ export const NavigationHeader = () => {
|
|
|
62
78
|
}
|
|
63
79
|
}
|
|
64
80
|
};
|
|
65
|
-
return (_jsxs(HeaderAppBar, { elevation: 0, children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: _jsx(ArrowBackIcon, {}) })) : null, _jsx(Typography, { fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true, children: handleHeaderTitle() }), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(Tooltip, { title: t(`header.swapHistory`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory), children: _jsx(ReceiptLongIcon, {}) }) })) : null, _jsx(Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", onClick: () => navigate(navigationRoutes.settings), sx: {
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsxs(HeaderAppBar, { elevation: 0, children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, { size: "medium", edge: "start", onClick: navigateBack, children: _jsx(ArrowBackIcon, {}) })) : null, splitSubvariant ? (_jsx(Box, { flex: 1, children: !hiddenUI?.includes(HiddenUI.WalletMenu) ? (_jsx(WalletMenuButton, {})) : null })) : (_jsx(Typography, { fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true, children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive && !hiddenUI?.includes(HiddenUI.History) ? (_jsx(Tooltip, { title: t(`header.swapHistory`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory), children: _jsx(ReceiptLongIcon, {}) }) })) : null, _jsx(Tooltip, { title: t(`header.settings`), enterDelay: 400, arrow: true, children: _jsx(IconButton, { size: "medium", onClick: () => navigate(navigationRoutes.settings), sx: {
|
|
82
|
+
marginRight: -1.25,
|
|
83
|
+
}, children: _jsx(SettingsIcon, {}) }) })] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] }), splitSubvariant ? _jsx(NavigationTabs, {}) : null] }));
|
|
68
84
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NavigationTabs: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext } from 'react-hook-form';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { SwapFormKey } from '../../providers';
|
|
5
|
+
import { useSplitSubvariantStore } from '../../stores';
|
|
6
|
+
import { HeaderAppBar } from './Header.style';
|
|
7
|
+
import { NavbarTab, NavbarTabs } from './NavigationTabs.style';
|
|
8
|
+
export const NavigationTabs = () => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const [state, setState] = useSplitSubvariantStore((state) => [
|
|
11
|
+
state.state,
|
|
12
|
+
state.setState,
|
|
13
|
+
]);
|
|
14
|
+
const { setValue } = useFormContext();
|
|
15
|
+
const handleChange = (_, value) => {
|
|
16
|
+
setValue(SwapFormKey.FromAmount, '');
|
|
17
|
+
setValue(SwapFormKey.FromToken, '');
|
|
18
|
+
setValue(SwapFormKey.ToToken, '');
|
|
19
|
+
setState(value === 0 ? 'swap' : 'bridge');
|
|
20
|
+
};
|
|
21
|
+
return (_jsx(HeaderAppBar, { elevation: 0, sx: { py: 1 }, children: _jsxs(NavbarTabs, { value: state === 'swap' ? 0 : 1, onChange: handleChange, "aria-label": "tabs", indicatorColor: "primary", children: [_jsx(NavbarTab, { label: t('header.swap'), disableRipple: true }), _jsx(NavbarTab, { label: t('header.bridge'), disableRipple: true })] }) }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StyledComponent } from '@emotion/styled';
|
|
3
|
+
import type { TabsProps } from '@mui/material';
|
|
4
|
+
export declare const NavbarTabs: StyledComponent<TabsProps>;
|
|
5
|
+
export declare const NavbarTab: StyledComponent<{
|
|
6
|
+
children?: null | undefined;
|
|
7
|
+
classes?: Partial<import("@mui/material").TabClasses> | undefined;
|
|
8
|
+
disabled?: boolean | undefined;
|
|
9
|
+
disableFocusRipple?: boolean | undefined;
|
|
10
|
+
icon?: string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
11
|
+
iconPosition?: "bottom" | "top" | "end" | "start" | undefined;
|
|
12
|
+
label?: import("react").ReactNode;
|
|
13
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
14
|
+
value?: any;
|
|
15
|
+
wrapped?: boolean | undefined;
|
|
16
|
+
} & Omit<{
|
|
17
|
+
action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
|
|
18
|
+
centerRipple?: boolean | undefined;
|
|
19
|
+
children?: import("react").ReactNode;
|
|
20
|
+
classes?: Partial<import("@mui/material").ButtonBaseClasses> | undefined;
|
|
21
|
+
disabled?: boolean | undefined;
|
|
22
|
+
disableRipple?: boolean | undefined;
|
|
23
|
+
disableTouchRipple?: boolean | undefined;
|
|
24
|
+
focusRipple?: boolean | undefined;
|
|
25
|
+
focusVisibleClassName?: string | undefined;
|
|
26
|
+
LinkComponent?: import("react").ElementType<any> | undefined;
|
|
27
|
+
onFocusVisible?: import("react").FocusEventHandler<any> | undefined;
|
|
28
|
+
sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
|
|
29
|
+
tabIndex?: number | undefined;
|
|
30
|
+
TouchRippleProps?: Partial<import("@mui/material/ButtonBase/TouchRipple").TouchRippleProps> | undefined;
|
|
31
|
+
touchRippleRef?: import("react").Ref<import("@mui/material/ButtonBase/TouchRipple").TouchRippleActions> | undefined;
|
|
32
|
+
}, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
33
|
+
ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
|
|
34
|
+
}, keyof import("@mui/material/OverridableComponent").CommonProps | "label" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "value" | "icon" | "iconPosition" | "wrapped"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Tab, Tabs, tabClasses, tabsClasses } from '@mui/material';
|
|
2
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
3
|
+
export const NavbarTabs = styled(Tabs)(({ theme }) => ({
|
|
4
|
+
backgroundColor: theme.palette.mode === 'dark'
|
|
5
|
+
? theme.palette.common.white
|
|
6
|
+
: alpha(theme.palette.common.black, 0.04),
|
|
7
|
+
borderRadius: theme.shape.borderRadius,
|
|
8
|
+
padding: theme.spacing(0.5),
|
|
9
|
+
flex: 1,
|
|
10
|
+
display: 'flex',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
height: 56,
|
|
13
|
+
[`.${tabsClasses.flexContainer}`]: {
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
},
|
|
16
|
+
[`.${tabsClasses.scroller}`]: {
|
|
17
|
+
overflow: 'initial !important',
|
|
18
|
+
},
|
|
19
|
+
[`.${tabsClasses.indicator}`]: {
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
top: '50%',
|
|
22
|
+
transform: 'translateY(-50%)',
|
|
23
|
+
height: 48,
|
|
24
|
+
backgroundColor: theme.palette.mode === 'dark'
|
|
25
|
+
? theme.palette.common.black
|
|
26
|
+
: theme.palette.common.white,
|
|
27
|
+
borderRadius: theme.shape.borderRadiusSecondary,
|
|
28
|
+
boxShadow: `0px 2px 4px ${alpha(theme.palette.common.black, 0.04)}`,
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
export const NavbarTab = styled(Tab, {
|
|
32
|
+
shouldForwardProp: (prop) => prop !== 'isDarkMode',
|
|
33
|
+
})(({ theme }) => ({
|
|
34
|
+
zIndex: 1,
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flex: 1,
|
|
37
|
+
justifyContent: 'center',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
textTransform: 'none',
|
|
41
|
+
height: 48,
|
|
42
|
+
minHeight: 48,
|
|
43
|
+
fontSize: '1rem',
|
|
44
|
+
fontWeight: 700,
|
|
45
|
+
color: theme.palette.mode === 'dark'
|
|
46
|
+
? theme.palette.common.white
|
|
47
|
+
: theme.palette.common.black,
|
|
48
|
+
textDecoration: 'none',
|
|
49
|
+
[`&.${tabClasses.selected}`]: {
|
|
50
|
+
color: theme.palette.mode === 'dark'
|
|
51
|
+
? theme.palette.common.white
|
|
52
|
+
: theme.palette.common.black,
|
|
53
|
+
backgroundColor: 'transparent',
|
|
54
|
+
},
|
|
55
|
+
[`.${tabClasses.iconWrapper}`]: {
|
|
56
|
+
margin: theme.spacing(0, 1, 0, 0),
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
@@ -10,34 +10,39 @@ import { useTranslation } from 'react-i18next';
|
|
|
10
10
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
11
11
|
import { useChain } from '../../hooks';
|
|
12
12
|
import { useWallet, useWidgetConfig } from '../../providers';
|
|
13
|
-
import { navigationRoutes,
|
|
13
|
+
import { navigationRoutes, shortenAddress } from '../../utils';
|
|
14
14
|
import { HeaderAppBar, WalletButton } from './Header.style';
|
|
15
15
|
import { WalletMenu } from './WalletMenu';
|
|
16
16
|
export const WalletHeader = () => {
|
|
17
|
+
return (_jsx(HeaderAppBar, { elevation: 0, sx: { justifyContent: 'flex-end' }, children: _jsx(WalletMenuButton, {}) }));
|
|
18
|
+
};
|
|
19
|
+
export const WalletMenuButton = () => {
|
|
17
20
|
const { account } = useWallet();
|
|
18
|
-
return
|
|
21
|
+
return account.isActive ? _jsx(ConnectedButton, {}) : _jsx(ConnectButton, {});
|
|
19
22
|
};
|
|
20
23
|
const ConnectButton = () => {
|
|
21
24
|
const { t } = useTranslation();
|
|
22
25
|
const { pathname } = useLocation();
|
|
23
|
-
const
|
|
26
|
+
const { walletManagement, subvariant } = useWidgetConfig();
|
|
24
27
|
const { connect: connectWallet } = useWallet();
|
|
25
28
|
const navigate = useNavigate();
|
|
26
29
|
const connect = async () => {
|
|
27
|
-
if (
|
|
30
|
+
if (walletManagement) {
|
|
28
31
|
await connectWallet();
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
31
34
|
navigate(navigationRoutes.selectWallet);
|
|
32
35
|
};
|
|
33
|
-
return (_jsx(WalletButton, { endIcon: _jsx(WalletIcon, {}), onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined, sx: {
|
|
34
|
-
marginRight: -1.25,
|
|
36
|
+
return (_jsx(WalletButton, { endIcon: subvariant !== 'split' ? _jsx(WalletIcon, {}) : undefined, startIcon: subvariant === 'split' ? _jsx(WalletIcon, {}) : undefined, onClick: !pathname.includes(navigationRoutes.selectWallet) ? connect : undefined, sx: {
|
|
37
|
+
marginRight: subvariant === 'split' ? 0 : -1.25,
|
|
38
|
+
marginLeft: subvariant === 'split' ? -1.25 : 0,
|
|
35
39
|
}, children: t(`button.connectWallet`) }));
|
|
36
40
|
};
|
|
37
41
|
const ConnectedButton = () => {
|
|
38
42
|
const { t } = useTranslation();
|
|
43
|
+
const { subvariant } = useWidgetConfig();
|
|
39
44
|
const { account, disconnect } = useWallet();
|
|
40
|
-
const walletAddress =
|
|
45
|
+
const walletAddress = shortenAddress(account.address);
|
|
41
46
|
const { chain } = useChain(account.chainId);
|
|
42
47
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
43
48
|
const handleClick = (event) => {
|
|
@@ -55,7 +60,8 @@ const ConnectedButton = () => {
|
|
|
55
60
|
handleClose();
|
|
56
61
|
};
|
|
57
62
|
return (_jsxs(_Fragment, { children: [_jsx(WalletButton, { endIcon: _jsx(ExpandMoreIcon, {}), startIcon: _jsx(Avatar, { src: chain?.logoURI, alt: chain?.key, sx: { width: 24, height: 24 }, children: chain?.name[0] }), sx: {
|
|
58
|
-
marginRight: -1.25,
|
|
63
|
+
marginRight: subvariant === 'split' ? 0 : -1.25,
|
|
64
|
+
marginLeft: subvariant === 'split' ? -1 : 0,
|
|
59
65
|
}, onClick: handleClick, children: walletAddress }), _jsxs(WalletMenu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, children: [_jsxs(MenuItem, { onClick: handleCopyAddress, children: [_jsx(ContentCopyIcon, {}), t(`button.copyAddress`)] }), _jsxs(MenuItem, { component: "a", onClick: handleClose, href: `${chain?.metamask.blockExplorerUrls[0]}address/${account.address}`, target: "_blank", children: [_jsx(OpenInNewIcon, {}), t(`button.viewOnExplorer`)] }), _jsx(Button, { onClick: handleDisconnect, fullWidth: true, startIcon: _jsx(PowerSettingsNewIcon, {}), sx: {
|
|
60
66
|
marginTop: 1,
|
|
61
67
|
}, children: t(`button.disconnect`) })] })] }));
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { RouteExecutionStatus } from '../../stores';
|
|
3
3
|
import { InsuranceCard } from './InsuranceCard';
|
|
4
4
|
import { InsuranceCollapsed } from './InsuranceCollapsed';
|
|
5
|
-
export const Insurance = ({ status, insurableRouteId,
|
|
6
|
-
return status === RouteExecutionStatus.Idle ? (_jsx(InsuranceCollapsed, {
|
|
5
|
+
export const Insurance = ({ status, insurableRouteId, onChange, ...props }) => {
|
|
6
|
+
return status === RouteExecutionStatus.Idle ? (_jsx(InsuranceCollapsed, { status: status, insurableRouteId: insurableRouteId, onChange: onChange, ...props })) : (_jsx(InsuranceCard, { status: status, ...props }));
|
|
7
7
|
};
|