@lifi/widget 1.0.0
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 -0
- package/App.js +18 -0
- package/AppDrawer.d.ts +14 -0
- package/AppDrawer.js +34 -0
- package/AppDrawer.style.d.ts +49 -0
- package/AppDrawer.style.js +52 -0
- package/AppProvider.d.ts +6 -0
- package/AppProvider.js +12 -0
- package/LICENSE.md +21 -0
- package/components/AppContainer.d.ts +5 -0
- package/components/AppContainer.js +53 -0
- package/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/components/BottomSheet/BottomSheet.js +42 -0
- package/components/BottomSheet/index.d.ts +2 -0
- package/components/BottomSheet/index.js +2 -0
- package/components/BottomSheet/types.d.ts +10 -0
- package/components/BottomSheet/types.js +1 -0
- package/components/Card/Card.d.ts +8 -0
- package/components/Card/Card.js +8 -0
- package/components/Card/CardContainer.d.ts +11 -0
- package/components/Card/CardContainer.js +16 -0
- package/components/Card/CardHeader.d.ts +18 -0
- package/components/Card/CardHeader.js +20 -0
- package/components/Card/CardTitle.d.ts +14 -0
- package/components/Card/CardTitle.js +9 -0
- package/components/Card/index.d.ts +4 -0
- package/components/Card/index.js +4 -0
- package/components/Header/Header.d.ts +2 -0
- package/components/Header/Header.js +17 -0
- package/components/Header/Header.style.d.ts +22 -0
- package/components/Header/Header.style.js +21 -0
- package/components/Header/NavigationHeader.d.ts +2 -0
- package/components/Header/NavigationHeader.js +46 -0
- package/components/Header/WalletHeader.d.ts +2 -0
- package/components/Header/WalletHeader.js +28 -0
- package/components/Header/index.d.ts +1 -0
- package/components/Header/index.js +1 -0
- package/components/Input.d.ts +1 -0
- package/components/Input.js +14 -0
- package/components/LiFiLogo.d.ts +5 -0
- package/components/LiFiLogo.js +7 -0
- package/components/PoweredBy.d.ts +2 -0
- package/components/PoweredBy.js +14 -0
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.d.ts +7 -0
- package/components/ProgressToNextUpdate/ProgressToNextUpdate.js +49 -0
- package/components/ProgressToNextUpdate/index.d.ts +1 -0
- package/components/ProgressToNextUpdate/index.js +1 -0
- package/components/ReverseTokensButton/ReverseTokensButton.d.ts +4 -0
- package/components/ReverseTokensButton/ReverseTokensButton.js +24 -0
- package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +29 -0
- package/components/ReverseTokensButton/ReverseTokensButton.style.js +14 -0
- package/components/ReverseTokensButton/index.d.ts +1 -0
- package/components/ReverseTokensButton/index.js +1 -0
- package/components/Select.d.ts +3 -0
- package/components/Select.js +27 -0
- package/components/SelectChainAndToken.d.ts +3 -0
- package/components/SelectChainAndToken.js +19 -0
- package/components/SelectTokenButton/SelectTokenButton.d.ts +5 -0
- package/components/SelectTokenButton/SelectTokenButton.js +29 -0
- package/components/SelectTokenButton/SelectTokenButton.style.d.ts +28 -0
- package/components/SelectTokenButton/SelectTokenButton.style.js +31 -0
- package/components/SelectTokenButton/index.d.ts +1 -0
- package/components/SelectTokenButton/index.js +1 -0
- package/components/StepActions/StepActions.d.ts +13 -0
- package/components/StepActions/StepActions.js +49 -0
- package/components/StepActions/StepActions.style.d.ts +20 -0
- package/components/StepActions/StepActions.style.js +56 -0
- package/components/StepActions/index.d.ts +1 -0
- package/components/StepActions/index.js +1 -0
- package/components/StepActions/types.d.ts +6 -0
- package/components/StepActions/types.js +1 -0
- package/components/StepToken.d.ts +6 -0
- package/components/StepToken.js +21 -0
- package/components/SwapButton/ButtonTooltip.d.ts +4 -0
- package/components/SwapButton/ButtonTooltip.js +3 -0
- package/components/SwapButton/SwapButton.d.ts +2 -0
- package/components/SwapButton/SwapButton.js +77 -0
- package/components/SwapButton/SwapButton.style.d.ts +65 -0
- package/components/SwapButton/SwapButton.style.js +20 -0
- package/components/SwapButton/index.d.ts +1 -0
- package/components/SwapButton/index.js +1 -0
- package/components/SwapInProgress/SwapInProgress.d.ts +3 -0
- package/components/SwapInProgress/SwapInProgress.js +22 -0
- package/components/SwapInProgress/SwapInProgress.style.d.ts +43 -0
- package/components/SwapInProgress/SwapInProgress.style.js +15 -0
- package/components/SwapInProgress/index.d.ts +1 -0
- package/components/SwapInProgress/index.js +1 -0
- package/components/SwapInput/FormPriceHelperText.d.ts +5 -0
- package/components/SwapInput/FormPriceHelperText.js +27 -0
- package/components/SwapInput/SwapInput.d.ts +3 -0
- package/components/SwapInput/SwapInput.js +43 -0
- package/components/SwapInput/SwapInput.style.d.ts +21 -0
- package/components/SwapInput/SwapInput.style.js +30 -0
- package/components/SwapInput/SwapInputAdornment.d.ts +2 -0
- package/components/SwapInput/SwapInputAdornment.js +23 -0
- package/components/SwapInput/SwapInputAdornment.style.d.ts +34 -0
- package/components/SwapInput/SwapInputAdornment.style.js +22 -0
- package/components/SwapInput/index.d.ts +1 -0
- package/components/SwapInput/index.js +1 -0
- package/components/SwapRouteCard/SwapRouteCard.d.ts +4 -0
- package/components/SwapRouteCard/SwapRouteCard.js +34 -0
- package/components/SwapRouteCard/SwapRouteCard.style.d.ts +36 -0
- package/components/SwapRouteCard/SwapRouteCard.style.js +71 -0
- package/components/SwapRouteCard/index.d.ts +1 -0
- package/components/SwapRouteCard/index.js +1 -0
- package/components/SwapRouteCard/types.d.ts +7 -0
- package/components/SwapRouteCard/types.js +1 -0
- package/components/SwapRoutes/SwapRoutes.d.ts +3 -0
- package/components/SwapRoutes/SwapRoutes.js +33 -0
- package/components/SwapRoutes/SwapRoutes.style.d.ts +11 -0
- package/components/SwapRoutes/SwapRoutes.style.js +9 -0
- package/components/SwapRoutes/SwapRoutesUpdateProgress.d.ts +3 -0
- package/components/SwapRoutes/SwapRoutesUpdateProgress.js +24 -0
- package/components/SwapRoutes/index.d.ts +1 -0
- package/components/SwapRoutes/index.js +1 -0
- package/components/Switch.d.ts +1 -0
- package/components/Switch.js +53 -0
- package/components/TextFitter/TextFitter.d.ts +3 -0
- package/components/TextFitter/TextFitter.js +44 -0
- package/components/TextFitter/index.d.ts +1 -0
- package/components/TextFitter/index.js +1 -0
- package/components/TextFitter/types.d.ts +12 -0
- package/components/TextFitter/types.js +1 -0
- package/components/TokenList/TokenList.d.ts +3 -0
- package/components/TokenList/TokenList.js +58 -0
- package/components/TokenList/TokenList.style.d.ts +32 -0
- package/components/TokenList/TokenList.style.js +22 -0
- package/components/TokenList/TokenListItem.d.ts +4 -0
- package/components/TokenList/TokenListItem.js +24 -0
- package/components/TokenList/index.d.ts +1 -0
- package/components/TokenList/index.js +1 -0
- package/components/TokenList/types.d.ts +16 -0
- package/components/TokenList/types.js +1 -0
- package/components/TokenList/utils.d.ts +15 -0
- package/components/TokenList/utils.js +10 -0
- package/config/env.d.ts +12 -0
- package/config/env.js +19 -0
- package/config/queryClient.d.ts +2 -0
- package/config/queryClient.js +25 -0
- package/config/rpcs.d.ts +1 -0
- package/config/rpcs.js +20 -0
- package/config/theme.d.ts +27 -0
- package/config/theme.js +126 -0
- package/hooks/index.d.ts +15 -0
- package/hooks/index.js +15 -0
- package/hooks/useBridges.d.ts +1 -0
- package/hooks/useBridges.js +12 -0
- package/hooks/useChain.d.ts +4 -0
- package/hooks/useChain.js +13 -0
- package/hooks/useChains.d.ts +101 -0
- package/hooks/useChains.js +39 -0
- package/hooks/useContentHeight.d.ts +1 -0
- package/hooks/useContentHeight.js +15 -0
- package/hooks/useDebouncedWatch.d.ts +1 -0
- package/hooks/useDebouncedWatch.js +27 -0
- package/hooks/useExchanges.d.ts +1 -0
- package/hooks/useExchanges.js +12 -0
- package/hooks/useHasSufficientBalance.d.ts +5 -0
- package/hooks/useHasSufficientBalance.js +59 -0
- package/hooks/useRouteExecution/index.d.ts +3 -0
- package/hooks/useRouteExecution/index.js +3 -0
- package/hooks/useRouteExecution/types.d.ts +15 -0
- package/hooks/useRouteExecution/types.js +1 -0
- package/hooks/useRouteExecution/useRouteExecution.d.ts +8 -0
- package/hooks/useRouteExecution/useRouteExecution.js +132 -0
- package/hooks/useRouteExecution/useRouteStore.d.ts +17 -0
- package/hooks/useRouteExecution/useRouteStore.js +71 -0
- package/hooks/useScrollableContainer.d.ts +2 -0
- package/hooks/useScrollableContainer.js +24 -0
- package/hooks/useSettings/index.d.ts +2 -0
- package/hooks/useSettings/index.js +2 -0
- package/hooks/useSettings/types.d.ts +5 -0
- package/hooks/useSettings/types.js +1 -0
- package/hooks/useSettings/useSettingsStore.d.ts +13 -0
- package/hooks/useSettings/useSettingsStore.js +22 -0
- package/hooks/useSwapRoutes.d.ts +8 -0
- package/hooks/useSwapRoutes.js +101 -0
- package/hooks/useToken.d.ts +4 -0
- package/hooks/useToken.js +13 -0
- package/hooks/useTokenBalance.d.ts +7 -0
- package/hooks/useTokenBalance.js +46 -0
- package/hooks/useTokenBalances.d.ts +7 -0
- package/hooks/useTokenBalances.js +54 -0
- package/hooks/useTokens.d.ts +5 -0
- package/hooks/useTokens.js +24 -0
- package/i18n/en/translation.json +138 -0
- package/i18n/index.d.ts +144 -0
- package/i18n/index.js +20 -0
- package/i18n/react-i18next.d.ts +9 -0
- package/index.d.ts +5 -0
- package/index.js +9 -0
- package/lifi.d.ts +2 -0
- package/lifi.js +10 -0
- package/package.json +55 -0
- package/pages/MainPage/MainPage.d.ts +2 -0
- package/pages/MainPage/MainPage.js +11 -0
- package/pages/MainPage/MainPage.style.d.ts +11 -0
- package/pages/MainPage/MainPage.style.js +8 -0
- package/pages/MainPage/SendToRecipientForm.d.ts +2 -0
- package/pages/MainPage/SendToRecipientForm.js +20 -0
- package/pages/MainPage/index.d.ts +1 -0
- package/pages/MainPage/index.js +1 -0
- package/pages/SelectTokenPage/ChainSelect.d.ts +2 -0
- package/pages/SelectTokenPage/ChainSelect.js +25 -0
- package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
- package/pages/SelectTokenPage/SearchTokenInput.js +17 -0
- package/pages/SelectTokenPage/SearchTokenInput.style.d.ts +1 -0
- package/pages/SelectTokenPage/SearchTokenInput.style.js +5 -0
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +5 -0
- package/pages/SelectTokenPage/SelectTokenPage.js +16 -0
- package/pages/SelectTokenPage/index.d.ts +2 -0
- package/pages/SelectTokenPage/index.js +2 -0
- package/pages/SelectTokenPage/types.d.ts +4 -0
- package/pages/SelectTokenPage/types.js +5 -0
- package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
- package/pages/SelectWalletPage/SelectWalletPage.js +68 -0
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +46 -0
- package/pages/SelectWalletPage/SelectWalletPage.style.js +27 -0
- package/pages/SelectWalletPage/index.d.ts +1 -0
- package/pages/SelectWalletPage/index.js +1 -0
- package/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
- package/pages/SettingsPage/AdvancedPreferences.js +19 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.d.ts +2 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +20 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +33 -0
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.js +16 -0
- package/pages/SettingsPage/EnabledBridgesSelect.d.ts +2 -0
- package/pages/SettingsPage/EnabledBridgesSelect.js +15 -0
- package/pages/SettingsPage/EnabledExchangesSelect.d.ts +2 -0
- package/pages/SettingsPage/EnabledExchangesSelect.js +15 -0
- package/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
- package/pages/SettingsPage/GasPriceSelect.js +13 -0
- package/pages/SettingsPage/RoutePrioritySelect.d.ts +2 -0
- package/pages/SettingsPage/RoutePrioritySelect.js +13 -0
- package/pages/SettingsPage/SettingsPage.d.ts +1 -0
- package/pages/SettingsPage/SettingsPage.js +10 -0
- package/pages/SettingsPage/SlippageInput.d.ts +1 -0
- package/pages/SettingsPage/SlippageInput.js +28 -0
- package/pages/SettingsPage/index.d.ts +1 -0
- package/pages/SettingsPage/index.js +1 -0
- package/pages/SwapPage/CircularProgress.d.ts +4 -0
- package/pages/SwapPage/CircularProgress.js +20 -0
- package/pages/SwapPage/CircularProgress.style.d.ts +6 -0
- package/pages/SwapPage/CircularProgress.style.js +51 -0
- package/pages/SwapPage/ExecutionItem.d.ts +6 -0
- package/pages/SwapPage/ExecutionItem.js +21 -0
- package/pages/SwapPage/ExecutionItem.style.d.ts +39 -0
- package/pages/SwapPage/ExecutionItem.style.js +5 -0
- package/pages/SwapPage/StatusBottomSheet.d.ts +3 -0
- package/pages/SwapPage/StatusBottomSheet.js +79 -0
- package/pages/SwapPage/StatusBottomSheet.style.d.ts +25 -0
- package/pages/SwapPage/StatusBottomSheet.style.js +32 -0
- package/pages/SwapPage/StepDivider.d.ts +2 -0
- package/pages/SwapPage/StepDivider.js +6 -0
- package/pages/SwapPage/StepDivider.style.d.ts +11 -0
- package/pages/SwapPage/StepDivider.style.js +8 -0
- package/pages/SwapPage/StepItem.d.ts +7 -0
- package/pages/SwapPage/StepItem.js +29 -0
- package/pages/SwapPage/StepTimer.d.ts +5 -0
- package/pages/SwapPage/StepTimer.js +59 -0
- package/pages/SwapPage/SwapPage.d.ts +2 -0
- package/pages/SwapPage/SwapPage.js +22 -0
- package/pages/SwapPage/SwapPage.style.d.ts +44 -0
- package/pages/SwapPage/SwapPage.style.js +12 -0
- package/pages/SwapPage/index.d.ts +1 -0
- package/pages/SwapPage/index.js +1 -0
- package/pages/SwapPage/utils.d.ts +6 -0
- package/pages/SwapPage/utils.js +85 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.d.ts +3 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.js +24 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.style.d.ts +11 -0
- package/pages/SwapRoutesPage/SwapRoutesPage.style.js +6 -0
- package/pages/SwapRoutesPage/index.d.ts +1 -0
- package/pages/SwapRoutesPage/index.js +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.d.ts +2 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +20 -0
- package/providers/SwapFormProvider/index.d.ts +2 -0
- package/providers/SwapFormProvider/index.js +2 -0
- package/providers/SwapFormProvider/types.d.ts +44 -0
- package/providers/SwapFormProvider/types.js +24 -0
- package/providers/ThemeProvider/ThemeProvider.d.ts +2 -0
- package/providers/ThemeProvider/ThemeProvider.js +33 -0
- package/providers/ThemeProvider/index.d.ts +1 -0
- package/providers/ThemeProvider/index.js +1 -0
- package/providers/WalletProvider/WalletProvider.d.ts +4 -0
- package/providers/WalletProvider/WalletProvider.js +89 -0
- package/providers/WalletProvider/index.d.ts +2 -0
- package/providers/WalletProvider/index.js +2 -0
- package/providers/WalletProvider/types.d.ts +17 -0
- package/providers/WalletProvider/types.js +1 -0
- package/providers/WidgetProvider/WidgetProvider.d.ts +4 -0
- package/providers/WidgetProvider/WidgetProvider.js +44 -0
- package/providers/WidgetProvider/index.d.ts +2 -0
- package/providers/WidgetProvider/index.js +2 -0
- package/providers/WidgetProvider/types.d.ts +8 -0
- package/providers/WidgetProvider/types.js +1 -0
- package/react-app-env.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/widget.d.ts +41 -0
- package/types/widget.js +1 -0
- package/utils/colors.d.ts +2 -0
- package/utils/colors.js +3 -0
- package/utils/deepClone.d.ts +1 -0
- package/utils/deepClone.js +3 -0
- package/utils/elements.d.ts +4 -0
- package/utils/elements.js +5 -0
- package/utils/format.d.ts +9 -0
- package/utils/format.js +76 -0
- package/utils/input.d.ts +1 -0
- package/utils/input.js +24 -0
- package/utils/routes.d.ts +10 -0
- package/utils/routes.js +9 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TokenAmount } from '@lifinance/sdk';
|
|
2
|
+
import { SwapFormDirection } from '../../providers/SwapFormProvider';
|
|
3
|
+
export interface TokenListProps {
|
|
4
|
+
formType: SwapFormDirection;
|
|
5
|
+
height: number;
|
|
6
|
+
onClick?(): void;
|
|
7
|
+
}
|
|
8
|
+
export interface TokenListItemBaseProps {
|
|
9
|
+
onClick?(token: string): void;
|
|
10
|
+
size: number;
|
|
11
|
+
start: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TokenListItemProps extends TokenListItemBaseProps {
|
|
14
|
+
showBalance?: boolean;
|
|
15
|
+
token: TokenAmount;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TokenAmount } from '@lifinance/sdk';
|
|
2
|
+
export declare const tokenAmountMock: TokenAmount;
|
|
3
|
+
export declare const skeletonKey = "skeleton";
|
|
4
|
+
export declare const createTokenAmountSkeletons: () => {
|
|
5
|
+
address: string;
|
|
6
|
+
name: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
blockNumber?: number | undefined;
|
|
9
|
+
symbol: string;
|
|
10
|
+
decimals: number;
|
|
11
|
+
chainId: number;
|
|
12
|
+
coinKey?: import("@lifinance/sdk").CoinKey | undefined;
|
|
13
|
+
priceUSD?: string | undefined;
|
|
14
|
+
logoURI?: string | undefined;
|
|
15
|
+
}[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const tokenAmountMock = {
|
|
2
|
+
address: '-1x0',
|
|
3
|
+
amount: '',
|
|
4
|
+
chainId: -1,
|
|
5
|
+
decimals: 0,
|
|
6
|
+
name: '',
|
|
7
|
+
symbol: '',
|
|
8
|
+
};
|
|
9
|
+
export const skeletonKey = 'skeleton';
|
|
10
|
+
export const createTokenAmountSkeletons = () => Array.from({ length: 3 }).map((_, index) => (Object.assign(Object.assign({}, tokenAmountMock), { address: `${tokenAmountMock.address}-${index}`, name: `${skeletonKey}-${index}` })));
|
package/config/env.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const env: {
|
|
2
|
+
LIFI_API_URL: string;
|
|
3
|
+
LIFI_RPC_URL_MAINNET: string;
|
|
4
|
+
LIFI_RPC_URL_ROPSTEN: string;
|
|
5
|
+
LIFI_RPC_URL_RINKEBY: string;
|
|
6
|
+
LIFI_RPC_URL_GORLI: string;
|
|
7
|
+
LIFI_RPC_URL_KOVAN: string;
|
|
8
|
+
LIFI_RPC_URL_ARBITRUM_RINKEBY: string;
|
|
9
|
+
LIFI_RPC_URL_OPTIMISM_KOVAN: string;
|
|
10
|
+
LIFI_RPC_URL_POLYGON_MUMBAI: string;
|
|
11
|
+
LIFI_RPC_URL_BSC_TESTNET: string;
|
|
12
|
+
};
|
package/config/env.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const env = {
|
|
2
|
+
LIFI_API_URL: 'https://li.quest/v1/',
|
|
3
|
+
// RPC - Mainnet (overwrites)
|
|
4
|
+
LIFI_RPC_URL_MAINNET: 'https://speedy-nodes-nyc.moralis.io/5ed6053dc39eba789ff466c9/eth/mainnet',
|
|
5
|
+
// LIFI_RPC_URL_POLYGON:
|
|
6
|
+
// LIFI_RPC_URL_BSC:
|
|
7
|
+
// LIFI_RPC_URL_XDAI:
|
|
8
|
+
// LIFI_RPC_URL_FANTOM:
|
|
9
|
+
// LIFI_RPC_URL_ARBITRUM:
|
|
10
|
+
// RPC - Testnet (overwrites)
|
|
11
|
+
LIFI_RPC_URL_ROPSTEN: 'https://ropsten.infura.io/v3/c7fe4abb5bbc466cb56038efbb0b9930',
|
|
12
|
+
LIFI_RPC_URL_RINKEBY: 'https://rinkeby.infura.io/v3/c7fe4abb5bbc466cb56038efbb0b9930',
|
|
13
|
+
LIFI_RPC_URL_GORLI: 'https://goerli.infura.io/v3/c7fe4abb5bbc466cb56038efbb0b9930',
|
|
14
|
+
LIFI_RPC_URL_KOVAN: 'https://kovan.infura.io/v3/c7fe4abb5bbc466cb56038efbb0b9930',
|
|
15
|
+
LIFI_RPC_URL_ARBITRUM_RINKEBY: 'https://arbitrum-rinkeby.infura.io/v3/c7fe4abb5bbc466cb56038efbb0b9930',
|
|
16
|
+
LIFI_RPC_URL_OPTIMISM_KOVAN: 'https://optimism-kovan.infura.io/v3/c7fe4abb5bbc466cb56038efbb0b9930',
|
|
17
|
+
LIFI_RPC_URL_POLYGON_MUMBAI: 'https://rpc-mumbai.maticvigil.com/v1/e4dadaac060844094a667194c20f79cc9bb0bc59',
|
|
18
|
+
LIFI_RPC_URL_BSC_TESTNET: 'https://data-seed-prebsc-1-s2.binance.org:8545',
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { QueryClient } from 'react-query';
|
|
2
|
+
export const queryClient = new QueryClient({
|
|
3
|
+
defaultOptions: {
|
|
4
|
+
queries: {
|
|
5
|
+
enabled: true,
|
|
6
|
+
staleTime: 3600000,
|
|
7
|
+
cacheTime: Infinity,
|
|
8
|
+
refetchInterval: false,
|
|
9
|
+
refetchIntervalInBackground: false,
|
|
10
|
+
refetchOnWindowFocus: true,
|
|
11
|
+
refetchOnReconnect: true,
|
|
12
|
+
refetchOnMount: true,
|
|
13
|
+
retryOnMount: true,
|
|
14
|
+
// suspense: true,
|
|
15
|
+
onError: (error) => {
|
|
16
|
+
//
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
mutations: {
|
|
20
|
+
onError: (error) => {
|
|
21
|
+
//
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
package/config/rpcs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getRpcs: () => Record<number, string[]>;
|
package/config/rpcs.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChainId } from '@lifinance/sdk';
|
|
2
|
+
import { env } from './env';
|
|
3
|
+
const rpcs = {
|
|
4
|
+
[ChainId.ETH]: [env.LIFI_RPC_URL_MAINNET],
|
|
5
|
+
// [ChainId.POL]: [env.LIFI_RPC_URL_POLYGON],
|
|
6
|
+
// [ChainId.BSC]: [env.LIFI_RPC_URL_BSC],
|
|
7
|
+
// [ChainId.DAI]: [env.LIFI_RPC_URL_XDAI],
|
|
8
|
+
// [ChainId.FTM]: [env.LIFI_RPC_URL_FANTOM],
|
|
9
|
+
// [ChainId.ARB]: [env.LIFI_RPC_URL_ARBITRUM],
|
|
10
|
+
// Testnet
|
|
11
|
+
[ChainId.ROP]: [env.LIFI_RPC_URL_ROPSTEN],
|
|
12
|
+
[ChainId.RIN]: [env.LIFI_RPC_URL_RINKEBY],
|
|
13
|
+
[ChainId.GOR]: [env.LIFI_RPC_URL_GORLI],
|
|
14
|
+
[ChainId.KOV]: [env.LIFI_RPC_URL_KOVAN],
|
|
15
|
+
[ChainId.ARBT]: [env.LIFI_RPC_URL_ARBITRUM_RINKEBY],
|
|
16
|
+
[ChainId.OPTT]: [env.LIFI_RPC_URL_OPTIMISM_KOVAN],
|
|
17
|
+
[ChainId.MUM]: [env.LIFI_RPC_URL_POLYGON_MUMBAI],
|
|
18
|
+
[ChainId.BSCT]: [env.LIFI_RPC_URL_BSC_TESTNET],
|
|
19
|
+
};
|
|
20
|
+
export const getRpcs = () => Object.fromEntries(Object.entries(rpcs).filter(([_, value]) => !value));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PaletteMode } from '@mui/material';
|
|
3
|
+
import { ThemeConfig } from '../types';
|
|
4
|
+
declare module '@mui/material/styles' {
|
|
5
|
+
interface TypographyVariants {
|
|
6
|
+
'@supports (font-variation-settings: normal)': React.CSSProperties;
|
|
7
|
+
}
|
|
8
|
+
interface TypographyVariantsOptions {
|
|
9
|
+
'@supports (font-variation-settings: normal)'?: React.CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
interface Shape {
|
|
12
|
+
borderRadius: number;
|
|
13
|
+
borderRadiusSecondary: number;
|
|
14
|
+
}
|
|
15
|
+
interface Theme {
|
|
16
|
+
shape: Shape;
|
|
17
|
+
}
|
|
18
|
+
interface ThemeOptions {
|
|
19
|
+
shape?: Partial<Shape>;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
declare module '@mui/material/Typography' {
|
|
23
|
+
interface TypographyPropsVariantOverrides {
|
|
24
|
+
'@supports (font-variation-settings: normal)': true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export declare const createTheme: (mode: PaletteMode, theme?: ThemeConfig) => import("@mui/material").Theme;
|
package/config/theme.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { alpha, createTheme as createMuiTheme, darken, lighten, } from '@mui/material/styles';
|
|
2
|
+
const palette = {
|
|
3
|
+
primary: {
|
|
4
|
+
main: '#3F49E1',
|
|
5
|
+
light: lighten('#3F49E1', 0.5),
|
|
6
|
+
dark: darken('#3F49E1', 0.2),
|
|
7
|
+
},
|
|
8
|
+
secondary: {
|
|
9
|
+
main: '#F5B5FF',
|
|
10
|
+
light: lighten('#F5B5FF', 0.5),
|
|
11
|
+
dark: darken('#F5B5FF', 0.2),
|
|
12
|
+
},
|
|
13
|
+
success: {
|
|
14
|
+
main: '#0AA65B',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export const createTheme = (mode, theme = {}) => {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
19
|
+
return createMuiTheme({
|
|
20
|
+
typography: Object.assign({ fontFamily: 'Inter var, Inter, sans-serif' }, theme.typography),
|
|
21
|
+
palette: Object.assign(Object.assign(Object.assign({ mode }, palette), { primary: {
|
|
22
|
+
main: (_c = (_b = (_a = theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) !== null && _c !== void 0 ? _c : palette.primary.main,
|
|
23
|
+
light: lighten((_f = (_e = (_d = theme.palette) === null || _d === void 0 ? void 0 : _d.primary) === null || _e === void 0 ? void 0 : _e.main) !== null && _f !== void 0 ? _f : palette.primary.main, 0.5),
|
|
24
|
+
dark: darken((_j = (_h = (_g = theme.palette) === null || _g === void 0 ? void 0 : _g.primary) === null || _h === void 0 ? void 0 : _h.main) !== null && _j !== void 0 ? _j : palette.primary.main, 0.2),
|
|
25
|
+
}, secondary: {
|
|
26
|
+
main: (_m = (_l = (_k = theme.palette) === null || _k === void 0 ? void 0 : _k.secondary) === null || _l === void 0 ? void 0 : _l.main) !== null && _m !== void 0 ? _m : palette.secondary.main,
|
|
27
|
+
light: lighten((_q = (_p = (_o = theme.palette) === null || _o === void 0 ? void 0 : _o.secondary) === null || _p === void 0 ? void 0 : _p.main) !== null && _q !== void 0 ? _q : palette.secondary.main, 0.5),
|
|
28
|
+
dark: darken((_t = (_s = (_r = theme.palette) === null || _r === void 0 ? void 0 : _r.secondary) === null || _s === void 0 ? void 0 : _s.main) !== null && _t !== void 0 ? _t : palette.secondary.main, 0.2),
|
|
29
|
+
} }), (mode === 'light'
|
|
30
|
+
? {
|
|
31
|
+
text: {
|
|
32
|
+
primary: '#000',
|
|
33
|
+
secondary: '#52575b',
|
|
34
|
+
},
|
|
35
|
+
grey: {
|
|
36
|
+
100: '#F4F5F6',
|
|
37
|
+
200: '#EFF1F2',
|
|
38
|
+
300: '#E3E7E9',
|
|
39
|
+
400: '#C6C9CD',
|
|
40
|
+
500: '#AEB3B7',
|
|
41
|
+
600: '#798086',
|
|
42
|
+
700: '#57595C',
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
: {
|
|
46
|
+
background: {
|
|
47
|
+
paper: '#212121',
|
|
48
|
+
},
|
|
49
|
+
})),
|
|
50
|
+
shape: Object.assign({ borderRadius: 12, borderRadiusSecondary: 6 }, theme.shape),
|
|
51
|
+
breakpoints: {
|
|
52
|
+
values: {
|
|
53
|
+
xs: 0,
|
|
54
|
+
sm: 392,
|
|
55
|
+
md: 900,
|
|
56
|
+
lg: 1200,
|
|
57
|
+
xl: 1536,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
components: {
|
|
61
|
+
MuiScopedCssBaseline: {
|
|
62
|
+
styleOverrides: {
|
|
63
|
+
root: Object.assign(Object.assign({ fontFamily: 'Inter, sans-serif' }, theme.typography), { '@supports (font-variation-settings: normal)': Object.assign({ fontFamily: 'Inter var, sans-serif' }, theme.typography) }),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
MuiButton: {
|
|
67
|
+
styleOverrides: mode === 'dark'
|
|
68
|
+
? {
|
|
69
|
+
outlined: {
|
|
70
|
+
color: palette.primary.light,
|
|
71
|
+
borderColor: palette.primary.light,
|
|
72
|
+
'&:hover': {
|
|
73
|
+
backgroundColor: alpha(palette.primary.light, 0.08),
|
|
74
|
+
borderColor: palette.primary.light,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
text: {
|
|
78
|
+
color: palette.primary.light,
|
|
79
|
+
'&:hover': {
|
|
80
|
+
backgroundColor: alpha(palette.primary.light, 0.08),
|
|
81
|
+
borderColor: palette.primary.light,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
: undefined,
|
|
86
|
+
},
|
|
87
|
+
MuiIconButton: {
|
|
88
|
+
styleOverrides: {
|
|
89
|
+
root: {
|
|
90
|
+
color: 'inherit',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
MuiAvatar: {
|
|
95
|
+
styleOverrides: {
|
|
96
|
+
root: {
|
|
97
|
+
height: 32,
|
|
98
|
+
width: 32,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
MuiListItemAvatar: {
|
|
103
|
+
styleOverrides: {
|
|
104
|
+
root: {
|
|
105
|
+
minWidth: 48,
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
MuiListItemText: {
|
|
110
|
+
styleOverrides: {
|
|
111
|
+
primary: ({ theme }) => ({
|
|
112
|
+
fontWeight: '500',
|
|
113
|
+
fontSize: '1.125rem',
|
|
114
|
+
lineHeight: '1.2778',
|
|
115
|
+
color: theme.palette.text.primary,
|
|
116
|
+
}),
|
|
117
|
+
secondary: ({ theme }) => ({
|
|
118
|
+
fontWeight: '400',
|
|
119
|
+
fontSize: '0.75rem',
|
|
120
|
+
color: theme.palette.text.secondary,
|
|
121
|
+
}),
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
};
|
package/hooks/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './useBridges';
|
|
2
|
+
export * from './useChain';
|
|
3
|
+
export * from './useChains';
|
|
4
|
+
export * from './useContentHeight';
|
|
5
|
+
export * from './useDebouncedWatch';
|
|
6
|
+
export * from './useExchanges';
|
|
7
|
+
export * from './useHasSufficientBalance';
|
|
8
|
+
export * from './useRouteExecution';
|
|
9
|
+
export * from './useScrollableContainer';
|
|
10
|
+
export * from './useSettings';
|
|
11
|
+
export * from './useSwapRoutes';
|
|
12
|
+
export * from './useToken';
|
|
13
|
+
export * from './useTokenBalance';
|
|
14
|
+
export * from './useTokenBalances';
|
|
15
|
+
export * from './useTokens';
|
package/hooks/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './useBridges';
|
|
2
|
+
export * from './useChain';
|
|
3
|
+
export * from './useChains';
|
|
4
|
+
export * from './useContentHeight';
|
|
5
|
+
export * from './useDebouncedWatch';
|
|
6
|
+
export * from './useExchanges';
|
|
7
|
+
export * from './useHasSufficientBalance';
|
|
8
|
+
export * from './useRouteExecution';
|
|
9
|
+
export * from './useScrollableContainer';
|
|
10
|
+
export * from './useSettings';
|
|
11
|
+
export * from './useSwapRoutes';
|
|
12
|
+
export * from './useToken';
|
|
13
|
+
export * from './useTokenBalance';
|
|
14
|
+
export * from './useTokenBalances';
|
|
15
|
+
export * from './useTokens';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useBridges: () => string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useQuery } from 'react-query';
|
|
3
|
+
import { LiFi } from '../lifi';
|
|
4
|
+
export const useBridges = () => {
|
|
5
|
+
const { data } = useQuery(['bridges'], ({ signal }) => LiFi.getPossibilities({ include: ['bridges'] }, { signal }));
|
|
6
|
+
const bridges = useMemo(() => {
|
|
7
|
+
var _a;
|
|
8
|
+
const bridges = (_a = data === null || data === void 0 ? void 0 : data.bridges) === null || _a === void 0 ? void 0 : _a.map((bridge) => bridge.tool).map((bridegTool) => bridegTool.split('-')[0]);
|
|
9
|
+
return Array.from(new Set(bridges));
|
|
10
|
+
}, [data === null || data === void 0 ? void 0 : data.bridges]);
|
|
11
|
+
return bridges;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useChains } from './useChains';
|
|
3
|
+
export const useChain = (chainId) => {
|
|
4
|
+
const { chains, isLoading } = useChains();
|
|
5
|
+
const chain = useMemo(() => {
|
|
6
|
+
const chain = chains === null || chains === void 0 ? void 0 : chains.find((chain) => chain.id === chainId);
|
|
7
|
+
return chain;
|
|
8
|
+
}, [chainId, chains]);
|
|
9
|
+
return {
|
|
10
|
+
chain,
|
|
11
|
+
isLoading,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export declare const useChains: () => {
|
|
2
|
+
error: unknown;
|
|
3
|
+
isError: true;
|
|
4
|
+
isLoading: false;
|
|
5
|
+
isLoadingError: true;
|
|
6
|
+
isRefetchError: false;
|
|
7
|
+
isSuccess: false;
|
|
8
|
+
status: "error";
|
|
9
|
+
dataUpdatedAt: number;
|
|
10
|
+
errorUpdatedAt: number;
|
|
11
|
+
failureCount: number;
|
|
12
|
+
errorUpdateCount: number;
|
|
13
|
+
isFetched: boolean;
|
|
14
|
+
isFetchedAfterMount: boolean;
|
|
15
|
+
isFetching: boolean;
|
|
16
|
+
isPaused: boolean;
|
|
17
|
+
isPlaceholderData: boolean;
|
|
18
|
+
isPreviousData: boolean;
|
|
19
|
+
isRefetching: boolean;
|
|
20
|
+
isStale: boolean;
|
|
21
|
+
refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("@lifinance/types").EVMChain[], unknown>>;
|
|
22
|
+
remove: () => void;
|
|
23
|
+
fetchStatus: import("react-query").FetchStatus;
|
|
24
|
+
chains: import("@lifinance/types").EVMChain[] | undefined;
|
|
25
|
+
getChainById: (chainId: number) => import("@lifinance/types").EVMChain | undefined;
|
|
26
|
+
} | {
|
|
27
|
+
error: null;
|
|
28
|
+
isError: false;
|
|
29
|
+
isLoading: true;
|
|
30
|
+
isLoadingError: false;
|
|
31
|
+
isRefetchError: false;
|
|
32
|
+
isSuccess: false;
|
|
33
|
+
status: "loading";
|
|
34
|
+
dataUpdatedAt: number;
|
|
35
|
+
errorUpdatedAt: number;
|
|
36
|
+
failureCount: number;
|
|
37
|
+
errorUpdateCount: number;
|
|
38
|
+
isFetched: boolean;
|
|
39
|
+
isFetchedAfterMount: boolean;
|
|
40
|
+
isFetching: boolean;
|
|
41
|
+
isPaused: boolean;
|
|
42
|
+
isPlaceholderData: boolean;
|
|
43
|
+
isPreviousData: boolean;
|
|
44
|
+
isRefetching: boolean;
|
|
45
|
+
isStale: boolean;
|
|
46
|
+
refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("@lifinance/types").EVMChain[], unknown>>;
|
|
47
|
+
remove: () => void;
|
|
48
|
+
fetchStatus: import("react-query").FetchStatus;
|
|
49
|
+
chains: import("@lifinance/types").EVMChain[] | undefined;
|
|
50
|
+
getChainById: (chainId: number) => import("@lifinance/types").EVMChain | undefined;
|
|
51
|
+
} | {
|
|
52
|
+
error: unknown;
|
|
53
|
+
isError: true;
|
|
54
|
+
isLoading: false;
|
|
55
|
+
isLoadingError: false;
|
|
56
|
+
isRefetchError: true;
|
|
57
|
+
isSuccess: false;
|
|
58
|
+
status: "error";
|
|
59
|
+
dataUpdatedAt: number;
|
|
60
|
+
errorUpdatedAt: number;
|
|
61
|
+
failureCount: number;
|
|
62
|
+
errorUpdateCount: number;
|
|
63
|
+
isFetched: boolean;
|
|
64
|
+
isFetchedAfterMount: boolean;
|
|
65
|
+
isFetching: boolean;
|
|
66
|
+
isPaused: boolean;
|
|
67
|
+
isPlaceholderData: boolean;
|
|
68
|
+
isPreviousData: boolean;
|
|
69
|
+
isRefetching: boolean;
|
|
70
|
+
isStale: boolean;
|
|
71
|
+
refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("@lifinance/types").EVMChain[], unknown>>;
|
|
72
|
+
remove: () => void;
|
|
73
|
+
fetchStatus: import("react-query").FetchStatus;
|
|
74
|
+
chains: import("@lifinance/types").EVMChain[] | undefined;
|
|
75
|
+
getChainById: (chainId: number) => import("@lifinance/types").EVMChain | undefined;
|
|
76
|
+
} | {
|
|
77
|
+
error: null;
|
|
78
|
+
isError: false;
|
|
79
|
+
isLoading: false;
|
|
80
|
+
isLoadingError: false;
|
|
81
|
+
isRefetchError: false;
|
|
82
|
+
isSuccess: true;
|
|
83
|
+
status: "success";
|
|
84
|
+
dataUpdatedAt: number;
|
|
85
|
+
errorUpdatedAt: number;
|
|
86
|
+
failureCount: number;
|
|
87
|
+
errorUpdateCount: number;
|
|
88
|
+
isFetched: boolean;
|
|
89
|
+
isFetchedAfterMount: boolean;
|
|
90
|
+
isFetching: boolean;
|
|
91
|
+
isPaused: boolean;
|
|
92
|
+
isPlaceholderData: boolean;
|
|
93
|
+
isPreviousData: boolean;
|
|
94
|
+
isRefetching: boolean;
|
|
95
|
+
isStale: boolean;
|
|
96
|
+
refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("@lifinance/types").EVMChain[], unknown>>;
|
|
97
|
+
remove: () => void;
|
|
98
|
+
fetchStatus: import("react-query").FetchStatus;
|
|
99
|
+
chains: import("@lifinance/types").EVMChain[] | undefined;
|
|
100
|
+
getChainById: (chainId: number) => import("@lifinance/types").EVMChain | undefined;
|
|
101
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { useCallback } from 'react';
|
|
22
|
+
import { useQuery } from 'react-query';
|
|
23
|
+
import { LiFi } from '../lifi';
|
|
24
|
+
import { useWidgetConfig } from '../providers/WidgetProvider';
|
|
25
|
+
export const useChains = () => {
|
|
26
|
+
const { enabledChains } = useWidgetConfig();
|
|
27
|
+
const _a = useQuery(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const chains = yield LiFi.getChains();
|
|
29
|
+
return chains.filter((chain) => enabledChains.includes(chain.id));
|
|
30
|
+
})), { data } = _a, other = __rest(_a, ["data"]);
|
|
31
|
+
const getChainById = useCallback((chainId) => {
|
|
32
|
+
const chain = data === null || data === void 0 ? void 0 : data.find((chain) => chain.id === chainId);
|
|
33
|
+
// if (!chain) {
|
|
34
|
+
// throw new Error('Chain not found or chainId is invalid.');
|
|
35
|
+
// }
|
|
36
|
+
return chain;
|
|
37
|
+
}, [data]);
|
|
38
|
+
return Object.assign({ chains: data, getChainById }, other);
|
|
39
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useContentHeight: () => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ElementId } from '../utils/elements';
|
|
3
|
+
export const useContentHeight = () => {
|
|
4
|
+
const [contentHeight] = useState(() => {
|
|
5
|
+
const headerElement = document.getElementById(ElementId.Header);
|
|
6
|
+
const containerElement = document.getElementById(ElementId.ScrollableContainer);
|
|
7
|
+
if (!containerElement || !headerElement) {
|
|
8
|
+
throw Error(`Can't find ${ElementId.ScrollableContainer} or ${ElementId.Header} id.`);
|
|
9
|
+
}
|
|
10
|
+
const { height: containerHeight } = containerElement.getBoundingClientRect();
|
|
11
|
+
const { height: headerHeight } = headerElement.getBoundingClientRect();
|
|
12
|
+
return containerHeight - headerHeight;
|
|
13
|
+
});
|
|
14
|
+
return contentHeight;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDebouncedWatch: (name: any, delay: number) => any;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useWatch } from 'react-hook-form';
|
|
3
|
+
export const useDebouncedWatch = (name, delay) => {
|
|
4
|
+
const watchedValue = useWatch({
|
|
5
|
+
name,
|
|
6
|
+
});
|
|
7
|
+
const [debouncedValue, setDebouncedValue] = useState(watchedValue);
|
|
8
|
+
const isMounted = useRef(false);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (isMounted.current) {
|
|
11
|
+
const hasWatchedValue = Array.isArray(watchedValue)
|
|
12
|
+
? watchedValue.some((value) => value)
|
|
13
|
+
: watchedValue;
|
|
14
|
+
if (hasWatchedValue) {
|
|
15
|
+
const handler = setTimeout(() => {
|
|
16
|
+
setDebouncedValue(watchedValue);
|
|
17
|
+
}, delay);
|
|
18
|
+
return () => clearTimeout(handler);
|
|
19
|
+
}
|
|
20
|
+
setDebouncedValue(watchedValue);
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
isMounted.current = true;
|
|
24
|
+
return undefined;
|
|
25
|
+
}, [delay, watchedValue]);
|
|
26
|
+
return debouncedValue;
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useExchanges: () => string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useQuery } from 'react-query';
|
|
3
|
+
import { LiFi } from '../lifi';
|
|
4
|
+
export const useExchanges = () => {
|
|
5
|
+
const { data } = useQuery(['exchanges'], ({ signal }) => LiFi.getPossibilities({ include: ['exchanges'] }, { signal }));
|
|
6
|
+
const exchanges = useMemo(() => {
|
|
7
|
+
var _a;
|
|
8
|
+
const exchanges = (_a = data === null || data === void 0 ? void 0 : data.exchanges) === null || _a === void 0 ? void 0 : _a.map((exchange) => exchange.tool).map((exchangeTool) => exchangeTool.split('-')[0]);
|
|
9
|
+
return Array.from(new Set(exchanges));
|
|
10
|
+
}, [data === null || data === void 0 ? void 0 : data.exchanges]);
|
|
11
|
+
return exchanges;
|
|
12
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { isSwapStep } from '@lifinance/sdk';
|
|
2
|
+
import Big from 'big.js';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useWatch } from 'react-hook-form';
|
|
5
|
+
import { SwapFormKeyHelper } from '../providers/SwapFormProvider';
|
|
6
|
+
import { useCurrentRoute } from './useRouteExecution';
|
|
7
|
+
import { useTokenBalances } from './useTokenBalances';
|
|
8
|
+
export const useHasSufficientBalance = () => {
|
|
9
|
+
var _a;
|
|
10
|
+
const [route] = useCurrentRoute();
|
|
11
|
+
const [fromChainId, toChainId] = useWatch({
|
|
12
|
+
name: [
|
|
13
|
+
SwapFormKeyHelper.getChainKey('from'),
|
|
14
|
+
SwapFormKeyHelper.getChainKey('to'),
|
|
15
|
+
],
|
|
16
|
+
});
|
|
17
|
+
const lastStep = route === null || route === void 0 ? void 0 : route.steps.at(-1);
|
|
18
|
+
const { tokens: fromChainTokenBalances } = useTokenBalances(fromChainId);
|
|
19
|
+
const { tokens: toChainTokenBalances } = useTokenBalances((_a = lastStep === null || lastStep === void 0 ? void 0 : lastStep.action.fromChainId) !== null && _a !== void 0 ? _a : toChainId);
|
|
20
|
+
const hasGasBalanceOnStartChain = useMemo(() => {
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const token = (_a = route === null || route === void 0 ? void 0 : route.steps[0].estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].token;
|
|
23
|
+
if (!token) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
const balance = Big((_c = (_b = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === token.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
|
|
27
|
+
const requiredAmount = route.steps
|
|
28
|
+
.filter((step) => step.action.fromChainId === route.fromChainId)
|
|
29
|
+
.reduce((big, step) => { var _a; return big.plus(Big(((_a = step.estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].amount) || 0)); }, Big(0))
|
|
30
|
+
.div(Math.pow(10, token.decimals));
|
|
31
|
+
return balance.gt(0) && balance.gte(requiredAmount);
|
|
32
|
+
}, [fromChainTokenBalances, route]);
|
|
33
|
+
const hasGasOnCrossChain = useMemo(() => {
|
|
34
|
+
var _a, _b, _c, _d, _e, _f;
|
|
35
|
+
const token = (_a = lastStep === null || lastStep === void 0 ? void 0 : lastStep.estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].token;
|
|
36
|
+
if (!token || !isSwapStep(lastStep)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const balance = Big((_c = (_b = toChainTokenBalances === null || toChainTokenBalances === void 0 ? void 0 : toChainTokenBalances.find((t) => t.address === token.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
|
|
40
|
+
const gasEstimate = (_d = lastStep.estimate.gasCosts) === null || _d === void 0 ? void 0 : _d[0].amount;
|
|
41
|
+
const requiredAmount = Big(gasEstimate || 0).div(Math.pow(10, ((_f = (_e = lastStep.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].token.decimals) !== null && _f !== void 0 ? _f : 0)));
|
|
42
|
+
return balance.gt(0) && balance.gte(requiredAmount);
|
|
43
|
+
}, [lastStep, toChainTokenBalances]);
|
|
44
|
+
const hasSufficientBalance = useMemo(() => {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
if (!route) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
const balance = Big((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === route.fromToken.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
|
|
50
|
+
return Big(route.fromAmount)
|
|
51
|
+
.div(Math.pow(10, ((_c = route.fromToken.decimals) !== null && _c !== void 0 ? _c : 0)))
|
|
52
|
+
.lte(balance);
|
|
53
|
+
}, [fromChainTokenBalances, route]);
|
|
54
|
+
return {
|
|
55
|
+
hasGasBalanceOnStartChain,
|
|
56
|
+
hasGasOnCrossChain,
|
|
57
|
+
hasSufficientBalance,
|
|
58
|
+
};
|
|
59
|
+
};
|