@rango-dev/widget-embedded 0.17.1-next.3 → 0.17.1-next.31
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/QueueManager.d.ts +5 -2
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +0 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +1 -6
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +370 -56
- 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/ConfirmWalletsModal.types.d.ts +0 -2
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -4
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.types.d.ts +2 -2
- package/dist/components/Layout/Layout.types.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +1727 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +633 -3
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.types.d.ts +0 -1
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +157 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.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 +628 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +157 -0
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +942 -0
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +3 -9
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +0 -1
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -6
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.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/navigationRoutes.d.ts +1 -2
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +2 -1
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/containers/App/App.d.ts +3 -0
- package/dist/containers/App/App.d.ts.map +1 -0
- package/dist/containers/App/App.styles.d.ts +158 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -0
- package/dist/containers/App/index.d.ts +2 -0
- package/dist/containers/App/index.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +316 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +3 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts +6 -0
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.types.d.ts +11 -0
- package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -0
- package/dist/containers/Wallets/index.d.ts +2 -0
- package/dist/containers/Wallets/index.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.d.ts +5 -0
- package/dist/containers/Widget/Widget.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.types.d.ts +5 -0
- package/dist/containers/Widget/Widget.types.d.ts.map +1 -0
- package/dist/containers/Widget/index.d.ts +3 -0
- package/dist/containers/Widget/index.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts +6 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +20 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +21 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/index.d.ts +2 -0
- package/dist/containers/WidgetInfo/index.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts +5 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +7 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/index.d.ts +2 -0
- package/dist/containers/WidgetProvider/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +6 -3
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -1
- package/dist/hooks/useForceAutoConnect.d.ts +2 -0
- package/dist/hooks/useForceAutoConnect.d.ts.map +1 -0
- package/dist/hooks/useLanguage.d.ts +1 -1
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts +1 -3
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts +2 -2
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +3 -5
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +5 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +20 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +1 -6
- 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 +1 -2
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +1 -6
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -8
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +47 -0
- package/dist/store/AppStore.d.ts.map +1 -0
- package/dist/store/app.d.ts +41 -22
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/notification.d.ts +4 -3
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/quote.d.ts +23 -16
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +3 -2
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +3 -0
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +39 -0
- package/dist/store/slices/settings.d.ts.map +1 -0
- package/dist/store/ui.d.ts +2 -1
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +14 -9
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +38 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/swap.d.ts +4 -14
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +15 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +1 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +2 -1
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +2 -2
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/queue.d.ts +2 -2
- package/dist/utils/queue.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +1 -1
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +6 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +16 -7
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +7 -9
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/QueueManager.tsx +18 -17
- package/src/components/AppRouter.tsx +8 -32
- package/src/components/AppRoutes.tsx +57 -69
- package/src/components/BlockchainList/BlockchainList.styles.ts +2 -2
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +4 -4
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +12 -6
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +20 -21
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +0 -2
- package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
- package/src/components/HeaderButtons/HomeButtons.tsx +28 -18
- package/src/components/Layout/Layout.tsx +20 -7
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +14 -7
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +63 -60
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +17 -8
- package/src/components/NoResult/NoResult.helpers.ts +12 -12
- package/src/components/NoResult/NoResult.tsx +6 -6
- package/src/components/NotificationContent/NotificationContent.tsx +5 -3
- package/src/components/Quote/Quote.styles.ts +42 -12
- package/src/components/Quote/Quote.tsx +106 -37
- package/src/components/Quote/Quote.types.ts +0 -1
- package/src/components/Quote/QuoteSkeleton.tsx +1 -1
- package/src/components/Quote/QuoteSummary.styles.ts +9 -8
- package/src/components/Quote/QuoteSummary.tsx +2 -2
- package/src/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx +1 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +11 -4
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +8 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +13 -13
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +1 -0
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +3 -3
- package/src/components/Slippage/Slippage.tsx +3 -5
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +5 -7
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.styles.ts +37 -33
- package/src/components/SwapDetails/SwapDetails.tsx +33 -45
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +4 -3
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +1 -1
- package/src/components/SwapsGroup/SwapsGroup.styles.ts +10 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +3 -5
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.styles.ts +58 -37
- package/src/components/TokenList/TokenList.tsx +28 -23
- package/src/components/TokenList/TokenList.types.ts +3 -10
- package/src/components/TokenList/index.ts +0 -1
- package/src/components/UpdateUrl.tsx +23 -18
- package/src/components/WidgetEvents.tsx +4 -2
- package/src/constants/errors.ts +9 -5
- package/src/constants/index.ts +1 -0
- package/src/constants/navigationRoutes.ts +7 -8
- package/src/constants/searchParams.ts +1 -0
- package/src/containers/App/App.styles.ts +18 -0
- package/src/containers/App/App.tsx +52 -0
- package/src/containers/App/index.ts +1 -0
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +17 -1
- package/src/containers/QuoteInfo/QuoteInfo.tsx +44 -43
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +3 -0
- package/src/{Wallets.tsx → containers/Wallets/Wallets.tsx} +48 -34
- package/src/containers/Wallets/Wallets.types.ts +12 -0
- package/src/containers/Wallets/index.ts +1 -0
- package/src/containers/Widget/Widget.tsx +19 -0
- package/src/containers/Widget/Widget.types.ts +5 -0
- package/src/containers/Widget/index.ts +2 -0
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +64 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +62 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +21 -0
- package/src/containers/WidgetInfo/index.ts +1 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +28 -0
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +7 -0
- package/src/containers/WidgetProvider/index.ts +1 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +15 -11
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +25 -24
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +1 -1
- package/src/hooks/useForceAutoConnect.ts +27 -0
- package/src/hooks/useLanguage.ts +4 -5
- package/src/hooks/useNavigateBack.ts +3 -52
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +37 -7
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +60 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +78 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +15 -6
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +6 -1
- package/src/hooks/useSwapInput.ts +89 -30
- package/src/hooks/useSyncStoresWithConfig.ts +38 -22
- package/src/hooks/useTheme.ts +4 -5
- package/src/hooks/useWalletList.ts +3 -5
- package/src/index.ts +53 -5
- package/src/pages/ConfirmSwapPage.tsx +61 -41
- package/src/pages/HistoryPage.tsx +2 -7
- package/src/pages/Home.tsx +58 -88
- package/src/pages/LanguagePage.tsx +0 -5
- package/src/pages/LiquiditySourcePage.tsx +24 -37
- package/src/pages/SelectBlockchainPage.tsx +28 -21
- package/src/pages/SelectSwapItemsPage.tsx +10 -27
- package/src/pages/SettingsPage.tsx +28 -24
- package/src/pages/SwapDetailsPage.tsx +6 -7
- package/src/pages/ThemePage.tsx +2 -7
- package/src/pages/WalletsPage.tsx +4 -15
- package/src/services/httpService.ts +1 -1
- package/src/store/AppStore.tsx +41 -0
- package/src/store/app.ts +44 -6
- package/src/store/quote.ts +29 -26
- package/src/store/slices/config.ts +25 -15
- package/src/store/slices/data.ts +64 -29
- package/src/store/slices/settings.ts +168 -0
- package/src/store/wallets.ts +68 -37
- package/src/types/config.ts +50 -5
- package/src/types/swap.ts +4 -13
- package/src/types/wallets.ts +18 -1
- package/src/utils/colors.ts +2 -1
- package/src/utils/configs.ts +2 -1
- package/src/utils/date.ts +1 -1
- package/src/utils/meta.ts +8 -1
- package/src/utils/providers.ts +8 -5
- package/src/utils/queue.ts +2 -2
- package/src/utils/quote.ts +7 -7
- package/src/utils/settings.ts +17 -10
- package/src/utils/swap.ts +59 -55
- package/src/utils/time.ts +1 -1
- package/src/utils/wallets.ts +107 -149
- package/dist/Wallets.d.ts +0 -17
- package/dist/Wallets.d.ts.map +0 -1
- package/dist/Widget.d.ts +0 -9
- package/dist/Widget.d.ts.map +0 -1
- package/dist/store/meta.d.ts +0 -23
- package/dist/store/meta.d.ts.map +0 -1
- package/dist/store/settings.d.ts +0 -81
- package/dist/store/settings.d.ts.map +0 -1
- package/src/Widget.tsx +0 -119
- package/src/store/meta.ts +0 -39
- package/src/store/settings.ts +0 -158
package/src/utils/wallets.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
1
|
import type { ConnectedWallet, TokenBalance } from '../store/wallets';
|
|
3
|
-
import type { Wallet } from '../types';
|
|
2
|
+
import type { Balance, TokenHash, TokensBalance, Wallet } from '../types';
|
|
4
3
|
import type { WalletInfo as ModalWalletInfo } from '@rango-dev/ui';
|
|
5
4
|
import type {
|
|
5
|
+
Asset,
|
|
6
6
|
Network,
|
|
7
7
|
WalletInfo,
|
|
8
8
|
WalletState,
|
|
@@ -29,6 +29,12 @@ import BigNumber from 'bignumber.js';
|
|
|
29
29
|
import { isCosmosBlockchain } from 'rango-types';
|
|
30
30
|
|
|
31
31
|
import { ZERO } from '../constants/numbers';
|
|
32
|
+
import {
|
|
33
|
+
BALANCE_MAX_DECIMALS,
|
|
34
|
+
BALANCE_MIN_DECIMALS,
|
|
35
|
+
USD_VALUE_MAX_DECIMALS,
|
|
36
|
+
USD_VALUE_MIN_DECIMALS,
|
|
37
|
+
} from '../constants/routing';
|
|
32
38
|
import { EXCLUDED_WALLETS } from '../constants/wallets';
|
|
33
39
|
|
|
34
40
|
import { numberToString } from './numbers';
|
|
@@ -55,8 +61,11 @@ export function mapWalletTypesToWalletInfo(
|
|
|
55
61
|
return list
|
|
56
62
|
.filter((wallet) => !EXCLUDED_WALLETS.includes(wallet as WalletTypes))
|
|
57
63
|
.filter((wallet) => {
|
|
58
|
-
const { supportedChains,
|
|
59
|
-
|
|
64
|
+
const { supportedChains, isContractWallet } = getWalletInfo(wallet);
|
|
65
|
+
const { installed, network } = getState(wallet);
|
|
66
|
+
const filterContractWallets =
|
|
67
|
+
isContractWallet && (!installed || (!!chain && network !== chain));
|
|
68
|
+
if (filterContractWallets) {
|
|
60
69
|
return false;
|
|
61
70
|
}
|
|
62
71
|
if (chain) {
|
|
@@ -97,7 +106,8 @@ export function prepareAccountsForWalletStore(
|
|
|
97
106
|
wallet: WalletType,
|
|
98
107
|
accounts: string[],
|
|
99
108
|
evmBasedChains: string[],
|
|
100
|
-
supportedChainNames: Network[] | null
|
|
109
|
+
supportedChainNames: Network[] | null,
|
|
110
|
+
isContractWallet: boolean
|
|
101
111
|
): Wallet[] {
|
|
102
112
|
const result: Wallet[] = [];
|
|
103
113
|
|
|
@@ -151,21 +161,29 @@ export function prepareAccountsForWalletStore(
|
|
|
151
161
|
|
|
152
162
|
// If it's an evm network, we will add the address to all the evm chains.
|
|
153
163
|
if (isEvmBasedChain || isUnknownAndEvmBased) {
|
|
154
|
-
|
|
155
|
-
* all evm chains are not supported in wallets, so we are adding
|
|
156
|
-
* only to those that are supported by wallet.
|
|
157
|
-
*/
|
|
158
|
-
const evmChainsSupportedByWallet = supportedBlockchains.filter((chain) =>
|
|
159
|
-
evmBasedChains.includes(chain)
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
evmChainsSupportedByWallet.forEach((network) => {
|
|
164
|
+
if (isContractWallet) {
|
|
163
165
|
/*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
+
* for contract wallets like Safe wallet, we should add only account for the
|
|
167
|
+
* current connected blockchain not all of the supported blockchains
|
|
166
168
|
*/
|
|
167
169
|
addAccount(network, address.toLowerCase());
|
|
168
|
-
}
|
|
170
|
+
} else {
|
|
171
|
+
/*
|
|
172
|
+
* all evm chains are not supported in wallets, so we are adding
|
|
173
|
+
* only to those that are supported by wallet.
|
|
174
|
+
*/
|
|
175
|
+
const evmChainsSupportedByWallet = supportedBlockchains.filter(
|
|
176
|
+
(chain) => evmBasedChains.includes(chain)
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
evmChainsSupportedByWallet.forEach((network) => {
|
|
180
|
+
/*
|
|
181
|
+
* EVM addresses are not case sensitive.
|
|
182
|
+
* Some wallets like Binance-chain return some letters in uppercase which produces bugs in our wallet state.
|
|
183
|
+
*/
|
|
184
|
+
addAccount(network, address.toLowerCase());
|
|
185
|
+
});
|
|
186
|
+
}
|
|
169
187
|
} else {
|
|
170
188
|
addAccount(network, address);
|
|
171
189
|
}
|
|
@@ -206,43 +224,6 @@ export function getRequiredChains(quote: BestRouteResponse | null) {
|
|
|
206
224
|
|
|
207
225
|
type Blockchain = { name: string; accounts: ConnectedWallet[] };
|
|
208
226
|
|
|
209
|
-
export function getBalanceFromWallet(
|
|
210
|
-
connectedWallets: ConnectedWallet[],
|
|
211
|
-
chain: string,
|
|
212
|
-
symbol: string,
|
|
213
|
-
address: string | null
|
|
214
|
-
): TokenBalance | null {
|
|
215
|
-
if (connectedWallets.length === 0) {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const selectedChainWallets = connectedWallets.filter(
|
|
220
|
-
(wallet) => wallet.chain === chain
|
|
221
|
-
);
|
|
222
|
-
if (selectedChainWallets.length === 0) {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return (
|
|
227
|
-
selectedChainWallets
|
|
228
|
-
.map(
|
|
229
|
-
(wallet) =>
|
|
230
|
-
wallet.balances?.find(
|
|
231
|
-
(balance) =>
|
|
232
|
-
(address !== null && balance.address === address) ||
|
|
233
|
-
(address === null &&
|
|
234
|
-
balance.address === address &&
|
|
235
|
-
balance.symbol === symbol)
|
|
236
|
-
) || null
|
|
237
|
-
)
|
|
238
|
-
.filter((balance) => balance !== null)
|
|
239
|
-
.sort(
|
|
240
|
-
(a, b) => parseFloat(b?.amount || '0') - parseFloat(a?.amount || '1')
|
|
241
|
-
)
|
|
242
|
-
.find(() => true) || null
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
227
|
export function isAccountAndWalletMatched(
|
|
247
228
|
account: Wallet,
|
|
248
229
|
connectedWallet: ConnectedWallet
|
|
@@ -336,30 +317,6 @@ function numberWithThousandSeparator(number: string | number): string {
|
|
|
336
317
|
return parts.join('.');
|
|
337
318
|
}
|
|
338
319
|
|
|
339
|
-
export const sortTokens = (tokens: TokenWithBalance[]): TokenWithBalance[] => {
|
|
340
|
-
const walletConnected = !!tokens.some((token) => token.balance);
|
|
341
|
-
if (!walletConnected) {
|
|
342
|
-
return tokens
|
|
343
|
-
.filter((token) => !token.address)
|
|
344
|
-
.concat(
|
|
345
|
-
tokens.filter((token) => token.address && !token.isSecondaryCoin),
|
|
346
|
-
tokens.filter((token) => token.isSecondaryCoin)
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return tokens
|
|
351
|
-
.filter((token) => !!token.balance)
|
|
352
|
-
.sort(
|
|
353
|
-
(tokenA, tokenB) =>
|
|
354
|
-
parseFloat(tokenB.balance?.usdValue || '0') -
|
|
355
|
-
parseFloat(tokenA.balance?.usdValue || '0')
|
|
356
|
-
)
|
|
357
|
-
.concat(
|
|
358
|
-
tokens.filter((token) => !token.balance && !token.isSecondaryCoin),
|
|
359
|
-
tokens.filter((token) => !token.balance && token.isSecondaryCoin)
|
|
360
|
-
);
|
|
361
|
-
};
|
|
362
|
-
|
|
363
320
|
export const getUsdPrice = (
|
|
364
321
|
blockchain: string,
|
|
365
322
|
symbol: string,
|
|
@@ -403,98 +360,58 @@ export const getKeplrCompatibleConnectedWallets = (
|
|
|
403
360
|
);
|
|
404
361
|
};
|
|
405
362
|
|
|
406
|
-
export function
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
let tokenUsdValue = '';
|
|
423
|
-
if (otherProps.usdPrice) {
|
|
424
|
-
tokenUsdValue = numberToString(
|
|
425
|
-
new BigNumber(
|
|
426
|
-
getBalanceFromWallet(
|
|
427
|
-
connectedWallets,
|
|
428
|
-
otherProps.blockchain,
|
|
429
|
-
otherProps.symbol,
|
|
430
|
-
otherProps.address
|
|
431
|
-
)?.amount || ZERO
|
|
432
|
-
).multipliedBy(otherProps.usdPrice)
|
|
433
|
-
);
|
|
434
|
-
}
|
|
363
|
+
export function formatBalance(balance: Balance | null): Balance | null {
|
|
364
|
+
const formattedBalance: Balance | null = balance
|
|
365
|
+
? {
|
|
366
|
+
...balance,
|
|
367
|
+
amount: numberToString(
|
|
368
|
+
balance.amount,
|
|
369
|
+
BALANCE_MIN_DECIMALS,
|
|
370
|
+
BALANCE_MAX_DECIMALS
|
|
371
|
+
),
|
|
372
|
+
usdValue: numberToString(
|
|
373
|
+
balance.usdValue,
|
|
374
|
+
USD_VALUE_MIN_DECIMALS,
|
|
375
|
+
USD_VALUE_MAX_DECIMALS
|
|
376
|
+
),
|
|
377
|
+
}
|
|
378
|
+
: null;
|
|
435
379
|
|
|
436
|
-
|
|
437
|
-
...otherProps,
|
|
438
|
-
...(tokenAmount !== '0' && {
|
|
439
|
-
balance: { amount: tokenAmount, usdValue: tokenUsdValue },
|
|
440
|
-
}),
|
|
441
|
-
};
|
|
442
|
-
});
|
|
380
|
+
return formattedBalance;
|
|
443
381
|
}
|
|
444
382
|
|
|
445
|
-
export function
|
|
446
|
-
tokens:
|
|
447
|
-
|
|
383
|
+
export function sortTokensByBalance(
|
|
384
|
+
tokens: Token[],
|
|
385
|
+
getBalanceFor: (token: Token) => Balance | null
|
|
448
386
|
) {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
list.sort((tokenA, tokenB) => {
|
|
454
|
-
if (tokenA.balance?.usdValue && tokenB.balance?.usdValue) {
|
|
387
|
+
tokens.sort((token1, token2) => {
|
|
388
|
+
const token1Balance = getBalanceFor(token1);
|
|
389
|
+
const token2Balance = getBalanceFor(token2);
|
|
390
|
+
if (token1Balance?.usdValue && token2Balance?.usdValue) {
|
|
455
391
|
return (
|
|
456
|
-
parseFloat(
|
|
457
|
-
parseFloat(tokenA.balance.usdValue)
|
|
392
|
+
parseFloat(token2Balance.usdValue) - parseFloat(token1Balance.usdValue)
|
|
458
393
|
);
|
|
459
394
|
}
|
|
460
395
|
|
|
461
|
-
if (!
|
|
396
|
+
if (!token1Balance?.usdValue && token2Balance?.usdValue) {
|
|
462
397
|
return 1;
|
|
463
398
|
}
|
|
464
399
|
|
|
465
|
-
if (
|
|
400
|
+
if (token1Balance?.usdValue && !token2Balance?.usdValue) {
|
|
466
401
|
return -1;
|
|
467
402
|
}
|
|
468
403
|
|
|
469
|
-
if (!
|
|
404
|
+
if (!token1Balance?.usdValue && !token2Balance?.usdValue) {
|
|
470
405
|
return (
|
|
471
|
-
parseFloat(
|
|
472
|
-
parseFloat(
|
|
406
|
+
parseFloat(token2Balance?.amount || '0') -
|
|
407
|
+
parseFloat(token1Balance?.amount || '0')
|
|
473
408
|
);
|
|
474
409
|
}
|
|
475
410
|
|
|
476
411
|
return 0;
|
|
477
412
|
});
|
|
478
413
|
|
|
479
|
-
return
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
export function getSortedTokens(
|
|
483
|
-
chain: BlockchainMeta | null,
|
|
484
|
-
tokens: Token[],
|
|
485
|
-
connectedWallets: ConnectedWallet[],
|
|
486
|
-
otherChainTokens: TokenWithBalance[]
|
|
487
|
-
): TokenWithBalance[] {
|
|
488
|
-
const fromChainEqualsToToBlockchain =
|
|
489
|
-
chain?.name === otherChainTokens[0]?.name;
|
|
490
|
-
if (fromChainEqualsToToBlockchain) {
|
|
491
|
-
return otherChainTokens;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
const filteredTokens = tokens.filter(
|
|
495
|
-
(token) => token.blockchain === chain?.name
|
|
496
|
-
);
|
|
497
|
-
return sortTokens(getTokensWithBalance(filteredTokens, connectedWallets));
|
|
414
|
+
return tokens;
|
|
498
415
|
}
|
|
499
416
|
|
|
500
417
|
export function tokensAreEqual(
|
|
@@ -556,3 +473,44 @@ export function getAddress({
|
|
|
556
473
|
connectedWallet.chain === chain
|
|
557
474
|
)?.address;
|
|
558
475
|
}
|
|
476
|
+
|
|
477
|
+
export function createTokenHash(token: Asset): TokenHash {
|
|
478
|
+
return `${token.blockchain}-${token.symbol}-${token.address ?? ''}`;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export function makeTokensBalance(connectedWallets: ConnectedWallet[]) {
|
|
482
|
+
return connectedWallets
|
|
483
|
+
.flatMap((wallet) => wallet.balances)
|
|
484
|
+
.reduce((balances: TokensBalance, balance) => {
|
|
485
|
+
const currentBalance = {
|
|
486
|
+
amount: balance?.amount ?? '',
|
|
487
|
+
decimals: balance?.decimal ?? 0,
|
|
488
|
+
usdValue: balance?.usdPrice
|
|
489
|
+
? new BigNumber(balance?.usdPrice ?? ZERO)
|
|
490
|
+
.multipliedBy(balance?.amount)
|
|
491
|
+
.toString()
|
|
492
|
+
: '',
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
const tokenHash = balance
|
|
496
|
+
? createTokenHash({
|
|
497
|
+
symbol: balance.symbol,
|
|
498
|
+
blockchain: balance.chain,
|
|
499
|
+
address: balance.address,
|
|
500
|
+
})
|
|
501
|
+
: null;
|
|
502
|
+
|
|
503
|
+
const prevBalance = tokenHash ? balances[tokenHash] : null;
|
|
504
|
+
|
|
505
|
+
const shouldUpdateBalance =
|
|
506
|
+
tokenHash &&
|
|
507
|
+
(!prevBalance ||
|
|
508
|
+
(prevBalance && prevBalance.amount < currentBalance.amount));
|
|
509
|
+
|
|
510
|
+
if (shouldUpdateBalance) {
|
|
511
|
+
balances[tokenHash] = currentBalance;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
return balances;
|
|
515
|
+
}, {});
|
|
516
|
+
}
|
package/dist/Wallets.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { WidgetConfig } from './types';
|
|
2
|
-
import type { ProvidersOptions } from './utils/providers';
|
|
3
|
-
import type { EventHandler } from '@rango-dev/wallets-react';
|
|
4
|
-
import type { PropsWithChildren } from 'react';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
type OnConnectHandler = (key: string) => void;
|
|
7
|
-
interface WidgetContextInterface {
|
|
8
|
-
onConnectWallet(handler: OnConnectHandler): void;
|
|
9
|
-
}
|
|
10
|
-
export declare const WidgetContext: React.Context<WidgetContextInterface>;
|
|
11
|
-
export declare function WidgetWallets(props: PropsWithChildren<{
|
|
12
|
-
providers: WidgetConfig['wallets'];
|
|
13
|
-
options?: ProvidersOptions;
|
|
14
|
-
onUpdateState?: EventHandler;
|
|
15
|
-
}>): React.JSX.Element;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=Wallets.d.ts.map
|
package/dist/Wallets.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Wallets.d.ts","sourceRoot":"","sources":["../src/Wallets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI/C,OAAO,KAAgC,MAAM,OAAO,CAAC;AAUrD,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;AAC9C,UAAU,sBAAsB;IAC9B,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAClD;AAED,eAAO,MAAM,aAAa,uCAIxB,CAAC;AAEH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,iBAAiB,CAAC;IACvB,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B,CAAC,qBA+EH"}
|
package/dist/Widget.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { WidgetConfig } from './types';
|
|
2
|
-
import type { PropsWithChildren } from 'react';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
export type WidgetProps = {
|
|
5
|
-
config?: WidgetConfig;
|
|
6
|
-
};
|
|
7
|
-
export declare function Main(props: PropsWithChildren<WidgetProps>): React.JSX.Element;
|
|
8
|
-
export declare function Widget(props: PropsWithChildren<WidgetProps>): React.JSX.Element;
|
|
9
|
-
//# sourceMappingURL=Widget.d.ts.map
|
package/dist/Widget.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Widget.d.ts","sourceRoot":"","sources":["../src/Widget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAiCxE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,wBAAgB,IAAI,CAAC,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,qBAoDzD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,qBAsB3D"}
|
package/dist/store/meta.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
|
-
import type { MetaResponse } from 'rango-sdk';
|
|
3
|
-
export type LoadingStatus = 'loading' | 'success' | 'failed';
|
|
4
|
-
export interface MetaState {
|
|
5
|
-
meta: MetaResponse & {
|
|
6
|
-
tokens: TokenWithBalance[];
|
|
7
|
-
};
|
|
8
|
-
loadingStatus: LoadingStatus;
|
|
9
|
-
fetchMeta: () => Promise<void>;
|
|
10
|
-
}
|
|
11
|
-
export declare const useMetaStore: {
|
|
12
|
-
(): MetaState;
|
|
13
|
-
<U>(selector: (state: MetaState) => U, equals?: ((a: U, b: U) => boolean) | undefined): U;
|
|
14
|
-
} & import("zustand").StoreApi<MetaState> & {
|
|
15
|
-
use: {
|
|
16
|
-
meta: () => MetaResponse & {
|
|
17
|
-
tokens: TokenWithBalance[];
|
|
18
|
-
};
|
|
19
|
-
loadingStatus: () => LoadingStatus;
|
|
20
|
-
fetchMeta: () => () => Promise<void>;
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=meta.d.ts.map
|
package/dist/store/meta.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/store/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAO9C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,YAAY,GAAG;QAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA;KAAE,CAAC;IACpD,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,YAAY;;;;;;oBALQ,gBAAgB,EAAE;;;+BAEhC,QAAQ,IAAI,CAAC;;CAyB/B,CAAC"}
|
package/dist/store/settings.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { type Language } from '@rango-dev/ui';
|
|
2
|
-
export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
3
|
-
export interface SettingsState {
|
|
4
|
-
/** Keeping a history of blockchains that user has selected (in Swap process) */
|
|
5
|
-
preferredBlockchains: string[];
|
|
6
|
-
slippage: number;
|
|
7
|
-
customSlippage: number | null;
|
|
8
|
-
infiniteApprove: boolean;
|
|
9
|
-
disabledLiquiditySources: string[];
|
|
10
|
-
theme: ThemeMode;
|
|
11
|
-
language: Language;
|
|
12
|
-
affiliateRef: string | null;
|
|
13
|
-
affiliatePercent: number | null;
|
|
14
|
-
affiliateWallets: {
|
|
15
|
-
[key: string]: string;
|
|
16
|
-
} | null;
|
|
17
|
-
setSlippage: (slippage: number) => void;
|
|
18
|
-
setCustomSlippage: (customSlippage: number | null) => void;
|
|
19
|
-
toggleInfiniteApprove: () => void;
|
|
20
|
-
toggleLiquiditySource: (name: string) => void;
|
|
21
|
-
setTheme: (theme: ThemeMode) => void;
|
|
22
|
-
setLanguage: (language: Language) => void;
|
|
23
|
-
toggleAllLiquiditySources: (shouldReset?: boolean) => void;
|
|
24
|
-
setAffiliateRef: (affiliateRef: string | null) => void;
|
|
25
|
-
setAffiliatePercent: (affiliatePercent: number | null) => void;
|
|
26
|
-
setAffiliateWallets: (affiliateWallets: {
|
|
27
|
-
[key: string]: string;
|
|
28
|
-
} | null) => void;
|
|
29
|
-
addPreferredBlockchain: (blockchain: string) => void;
|
|
30
|
-
}
|
|
31
|
-
export declare const useSettingsStore: {
|
|
32
|
-
(): SettingsState;
|
|
33
|
-
<U>(selector: (state: SettingsState) => U, equals?: ((a: U, b: U) => boolean) | undefined): U;
|
|
34
|
-
} & Omit<Omit<import("zustand").StoreApi<SettingsState>, "persist"> & {
|
|
35
|
-
persist: {
|
|
36
|
-
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<SettingsState, SettingsState>>) => void;
|
|
37
|
-
clearStorage: () => void;
|
|
38
|
-
rehydrate: () => void | Promise<void>;
|
|
39
|
-
hasHydrated: () => boolean;
|
|
40
|
-
onHydrate: (fn: (state: SettingsState) => void) => () => void;
|
|
41
|
-
onFinishHydration: (fn: (state: SettingsState) => void) => () => void;
|
|
42
|
-
getOptions: () => Partial<import("zustand/middleware").PersistOptions<SettingsState, SettingsState>>;
|
|
43
|
-
};
|
|
44
|
-
}, "subscribe"> & {
|
|
45
|
-
subscribe: {
|
|
46
|
-
(listener: (selectedState: SettingsState, previousSelectedState: SettingsState) => void): () => void;
|
|
47
|
-
<U_1>(selector: (state: SettingsState) => U_1, listener: (selectedState: U_1, previousSelectedState: U_1) => void, options?: {
|
|
48
|
-
equalityFn?: ((a: U_1, b: U_1) => boolean) | undefined;
|
|
49
|
-
fireImmediately?: boolean | undefined;
|
|
50
|
-
} | undefined): () => void;
|
|
51
|
-
};
|
|
52
|
-
} & {
|
|
53
|
-
use: {
|
|
54
|
-
preferredBlockchains: () => string[];
|
|
55
|
-
slippage: () => number;
|
|
56
|
-
customSlippage: () => number | null;
|
|
57
|
-
infiniteApprove: () => boolean;
|
|
58
|
-
disabledLiquiditySources: () => string[];
|
|
59
|
-
theme: () => ThemeMode;
|
|
60
|
-
language: () => "en" | "es" | "ja" | "fr";
|
|
61
|
-
affiliateRef: () => string | null;
|
|
62
|
-
affiliatePercent: () => number | null;
|
|
63
|
-
affiliateWallets: () => {
|
|
64
|
-
[key: string]: string;
|
|
65
|
-
} | null;
|
|
66
|
-
setSlippage: () => (slippage: number) => void;
|
|
67
|
-
setCustomSlippage: () => (customSlippage: number | null) => void;
|
|
68
|
-
toggleInfiniteApprove: () => () => void;
|
|
69
|
-
toggleLiquiditySource: () => (name: string) => void;
|
|
70
|
-
setTheme: () => (theme: ThemeMode) => void;
|
|
71
|
-
setLanguage: () => (language: Language) => void;
|
|
72
|
-
toggleAllLiquiditySources: () => (shouldReset?: boolean) => void;
|
|
73
|
-
setAffiliateRef: () => (affiliateRef: string | null) => void;
|
|
74
|
-
setAffiliatePercent: () => (affiliatePercent: number | null) => void;
|
|
75
|
-
setAffiliateWallets: () => (affiliateWallets: {
|
|
76
|
-
[key: string]: string;
|
|
77
|
-
} | null) => void;
|
|
78
|
-
addPreferredBlockchain: () => (blockchain: string) => void;
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/store/settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAY9C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAEnD,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,iBAAiB,EAAE,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC3D,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACrC,WAAW,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IAC1C,yBAAyB,EAAE,CAAC,WAAW,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3D,eAAe,EAAE,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACvD,mBAAmB,EAAE,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/D,mBAAmB,EAAE,CACnB,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,IAAI,KAC/C,IAAI,CAAC;IACV,sBAAsB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCAfH,MAAM,KAAK,IAAI;kDACH,MAAM,GAAG,IAAI,KAAK,IAAI;2CAC7B,IAAI;4CACH,MAAM,KAAK,IAAI;gCAC3B,SAAS,KAAK,IAAI;sCACZ,QAAQ,KAAK,IAAI;wDACC,OAAO,KAAK,IAAI;8CAC1B,MAAM,GAAG,IAAI,KAAK,IAAI;sDACd,MAAM,GAAG,IAAI,KAAK,IAAI;;;qBAGzD,IAAI;mDAC4B,MAAM,KAAK,IAAI;;CAsHrD,CAAC"}
|
package/src/Widget.tsx
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import type { WidgetConfig } from './types';
|
|
2
|
-
import type { WalletType } from '@rango-dev/wallets-shared';
|
|
3
|
-
import type { PropsWithChildren } from 'react';
|
|
4
|
-
|
|
5
|
-
import { I18nManager, styled } from '@rango-dev/ui';
|
|
6
|
-
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
7
|
-
|
|
8
|
-
import { AppRouter } from './components/AppRouter';
|
|
9
|
-
import { AppRoutes } from './components/AppRoutes';
|
|
10
|
-
import { WidgetEvents } from './components/WidgetEvents';
|
|
11
|
-
import { globalFont } from './globalStyles';
|
|
12
|
-
import { useLanguage } from './hooks/useLanguage';
|
|
13
|
-
import { useTheme } from './hooks/useTheme';
|
|
14
|
-
import QueueManager from './QueueManager';
|
|
15
|
-
import { useAppStore } from './store/app';
|
|
16
|
-
import { useMetaStore } from './store/meta';
|
|
17
|
-
import { useNotificationStore } from './store/notification';
|
|
18
|
-
import { useSettingsStore } from './store/settings';
|
|
19
|
-
import { initConfig } from './utils/configs';
|
|
20
|
-
import { WidgetContext, WidgetWallets } from './Wallets';
|
|
21
|
-
|
|
22
|
-
const MainContainer = styled('div', {
|
|
23
|
-
width: '100%',
|
|
24
|
-
display: 'flex',
|
|
25
|
-
justifyContent: 'center',
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
fontFamily: '$widget',
|
|
28
|
-
boxSizing: 'border-box',
|
|
29
|
-
'& *, *::before, *::after': {
|
|
30
|
-
boxSizing: 'inherit',
|
|
31
|
-
listStyleType: 'none',
|
|
32
|
-
},
|
|
33
|
-
'& *:focus-visible': {
|
|
34
|
-
outlineColor: '$info500',
|
|
35
|
-
transition: 'none',
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
export type WidgetProps = {
|
|
40
|
-
config?: WidgetConfig;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export function Main(props: PropsWithChildren<WidgetProps>) {
|
|
44
|
-
const { config } = props;
|
|
45
|
-
globalFont();
|
|
46
|
-
|
|
47
|
-
const { activeTheme } = useTheme(config?.theme || {});
|
|
48
|
-
const { activeLanguage, changeLanguage } = useLanguage();
|
|
49
|
-
|
|
50
|
-
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] =
|
|
51
|
-
useState<string>('');
|
|
52
|
-
const [disconnectedWallet, setDisconnectedWallet] = useState<WalletType>();
|
|
53
|
-
const widgetContext = useContext(WidgetContext);
|
|
54
|
-
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
55
|
-
|
|
56
|
-
useMemo(() => {
|
|
57
|
-
if (config?.apiKey) {
|
|
58
|
-
initConfig({
|
|
59
|
-
API_KEY: config?.apiKey,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}, [config]);
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
void fetchMeta();
|
|
66
|
-
void useSettingsStore.persist.rehydrate();
|
|
67
|
-
void useNotificationStore.persist.rehydrate();
|
|
68
|
-
widgetContext.onConnectWallet(setLastConnectedWalletWithNetwork);
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (config?.language) {
|
|
73
|
-
changeLanguage(config.language);
|
|
74
|
-
}
|
|
75
|
-
}, [config?.language]);
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<I18nManager language={activeLanguage}>
|
|
79
|
-
<MainContainer id="swap-container" className={activeTheme()}>
|
|
80
|
-
<QueueManager>
|
|
81
|
-
<WidgetEvents />
|
|
82
|
-
<AppRouter
|
|
83
|
-
config={config}
|
|
84
|
-
lastConnectedWallet={lastConnectedWalletWithNetwork}
|
|
85
|
-
disconnectedWallet={disconnectedWallet}
|
|
86
|
-
clearDisconnectedWallet={() => {
|
|
87
|
-
setDisconnectedWallet(undefined);
|
|
88
|
-
}}>
|
|
89
|
-
<AppRoutes config={config} />
|
|
90
|
-
</AppRouter>
|
|
91
|
-
</QueueManager>
|
|
92
|
-
</MainContainer>
|
|
93
|
-
</I18nManager>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function Widget(props: PropsWithChildren<WidgetProps>) {
|
|
98
|
-
const { updateConfig, config } = useAppStore();
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
if (props.config) {
|
|
101
|
-
updateConfig(props.config);
|
|
102
|
-
}
|
|
103
|
-
}, [props.config]);
|
|
104
|
-
|
|
105
|
-
if (!props.config?.externalWallets) {
|
|
106
|
-
return (
|
|
107
|
-
<WidgetWallets
|
|
108
|
-
providers={config?.wallets}
|
|
109
|
-
options={{
|
|
110
|
-
walletConnectProjectId:
|
|
111
|
-
config?.walletConnectProjectId ||
|
|
112
|
-
props.config?.walletConnectProjectId,
|
|
113
|
-
}}>
|
|
114
|
-
<Main {...props} />
|
|
115
|
-
</WidgetWallets>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
return <Main {...props} />;
|
|
119
|
-
}
|
package/src/store/meta.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { TokenWithBalance } from '../components/TokenList';
|
|
2
|
-
import type { MetaResponse } from 'rango-sdk';
|
|
3
|
-
|
|
4
|
-
import { create } from 'zustand';
|
|
5
|
-
|
|
6
|
-
import { useAppStore } from './app';
|
|
7
|
-
import createSelectors from './selectors';
|
|
8
|
-
|
|
9
|
-
export type LoadingStatus = 'loading' | 'success' | 'failed';
|
|
10
|
-
|
|
11
|
-
export interface MetaState {
|
|
12
|
-
meta: MetaResponse & { tokens: TokenWithBalance[] };
|
|
13
|
-
loadingStatus: LoadingStatus;
|
|
14
|
-
fetchMeta: () => Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const useMetaStore = createSelectors(
|
|
18
|
-
create<MetaState>()((set) => ({
|
|
19
|
-
meta: { blockchains: [], popularTokens: [], swappers: [], tokens: [] },
|
|
20
|
-
loadingStatus: 'loading',
|
|
21
|
-
fetchMeta: async () => {
|
|
22
|
-
try {
|
|
23
|
-
await useAppStore.getState().fetch();
|
|
24
|
-
|
|
25
|
-
const state = useAppStore.getState();
|
|
26
|
-
const response: MetaResponse = {
|
|
27
|
-
blockchains: state.blockchains(),
|
|
28
|
-
tokens: state.tokens(),
|
|
29
|
-
popularTokens: state._popularTokens,
|
|
30
|
-
swappers: state._swappers,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
set({ meta: response, loadingStatus: 'success' });
|
|
34
|
-
} catch (error) {
|
|
35
|
-
set({ loadingStatus: 'failed' });
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
}))
|
|
39
|
-
);
|