@rango-dev/widget-embedded 0.31.1-next.3 → 0.32.1
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/CHANGELOG.md +9 -0
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +4 -1
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.types.d.ts +1 -0
- package/dist/components/BlockchainList/BlockchainList.types.d.ts.map +1 -1
- package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.d.ts +4 -0
- package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.d.ts.map +1 -0
- package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.styles.d.ts +483 -0
- package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.styles.d.ts.map +1 -0
- package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.types.d.ts +12 -0
- package/dist/components/BlockchainSelectorButton/BlockchainSelectorButton.types.d.ts.map +1 -0
- package/dist/components/BlockchainSelectorButton/index.d.ts +2 -0
- package/dist/components/BlockchainSelectorButton/index.d.ts.map +1 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -0
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +11 -0
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +3 -0
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
- package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts +4 -0
- package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts.map +1 -1
- package/dist/components/CustomDestination/CustomDestination.d.ts.map +1 -1
- package/dist/components/CustomDestination/CustomDestination.styles.d.ts +5 -2
- package/dist/components/CustomDestination/CustomDestination.styles.d.ts.map +1 -1
- package/dist/components/CustomTokenModal/CustomTokenModal.d.ts +4 -0
- package/dist/components/CustomTokenModal/CustomTokenModal.d.ts.map +1 -0
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts +3 -0
- package/dist/components/CustomTokenModal/CustomTokenModal.helpers.d.ts.map +1 -0
- package/dist/components/CustomTokenModal/CustomTokenModal.styles.d.ts +323 -0
- package/dist/components/CustomTokenModal/CustomTokenModal.styles.d.ts.map +1 -0
- package/dist/components/CustomTokenModal/CustomTokenModal.types.d.ts +9 -0
- package/dist/components/CustomTokenModal/CustomTokenModal.types.d.ts.map +1 -0
- package/dist/components/CustomTokenModal/index.d.ts +2 -0
- package/dist/components/CustomTokenModal/index.d.ts.map +1 -0
- package/dist/components/FilterSelector/FilterSelector.style.d.ts +6 -0
- package/dist/components/FilterSelector/FilterSelector.style.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +8 -0
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts +6 -0
- package/dist/components/HistoryGroupedList/HistoryGroupedList.styles.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts +4 -0
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/Layout/PageContainer.d.ts +1 -0
- package/dist/components/Layout/PageContainer.d.ts.map +1 -1
- package/dist/components/Layout/ScrollableArea.d.ts +1 -0
- package/dist/components/Layout/ScrollableArea.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +1 -0
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +14 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
- package/dist/components/NoResult/NoResult.styles.d.ts +4 -0
- package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +22 -1
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts +5 -0
- package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +2 -0
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +4 -0
- package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +10 -0
- package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +5 -0
- package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +4 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
- package/dist/components/Quotes/Quotes.styles.d.ts +3 -0
- package/dist/components/Quotes/Quotes.styles.d.ts.map +1 -1
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts +2 -1
- package/dist/components/RefreshModal/RefreshModal.styles.d.ts.map +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +1 -0
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +3 -0
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +5 -0
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +15 -0
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +3 -0
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +2 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwitchFromAndTo/SwitchFromAndTo.styles.d.ts +2 -0
- package/dist/components/SwitchFromAndTo/SwitchFromAndTo.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +18 -0
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +5 -2
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.d.ts +4 -0
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.d.ts.map +1 -0
- package/dist/components/{WalletStatefulConnect/DerivationPath.styles.d.ts → WalletDerivationPathModal/WalletDerivationPathModal.styles.d.ts} +3 -1
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.styles.d.ts.map +1 -0
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.types.d.ts +10 -0
- package/dist/components/WalletDerivationPathModal/WalletDerivationPathModal.types.d.ts.map +1 -0
- package/dist/components/WalletDerivationPathModal/index.d.ts +2 -0
- package/dist/components/WalletDerivationPathModal/index.d.ts.map +1 -0
- package/dist/components/WalletModal/WalletModal.d.ts +4 -0
- package/dist/components/WalletModal/WalletModal.d.ts.map +1 -0
- package/dist/components/WalletModal/WalletModal.types.d.ts +10 -0
- package/dist/components/WalletModal/WalletModal.types.d.ts.map +1 -0
- package/dist/components/WalletModal/WalletModalContent.d.ts +4 -0
- package/dist/components/WalletModal/WalletModalContent.d.ts.map +1 -0
- package/dist/components/{WalletStatefulConnect/ConnectStatus.styles.d.ts → WalletModal/WalletModalContent.styles.d.ts} +5 -1
- package/dist/components/{WalletStatefulConnect/ConnectStatus.styles.d.ts.map → WalletModal/WalletModalContent.styles.d.ts.map} +1 -1
- package/dist/components/WalletModal/index.d.ts +2 -0
- package/dist/components/WalletModal/index.d.ts.map +1 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts +4 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.d.ts.map +1 -0
- package/dist/components/{WalletStatefulConnect/Namespaces.styles.d.ts → WalletNamespacesModal/WalletNamespacesModal.styles.d.ts} +2 -1
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.styles.d.ts.map +1 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.types.d.ts +10 -0
- package/dist/components/WalletNamespacesModal/WalletNamespacesModal.types.d.ts.map +1 -0
- package/dist/components/WalletNamespacesModal/index.d.ts +2 -0
- package/dist/components/WalletNamespacesModal/index.d.ts.map +1 -0
- package/dist/constants/customTokens.d.ts +2 -0
- package/dist/constants/customTokens.d.ts.map +1 -0
- package/dist/constants/navigationRoutes.d.ts +2 -0
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +1 -0
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/containers/App/App.styles.d.ts +1 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -1
- package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts +2 -0
- package/dist/containers/ExpandedQuotes/ExpandedQuotes.styles.d.ts.map +1 -1
- package/dist/containers/Inputs/Inputs.styles.d.ts +2 -0
- package/dist/containers/Inputs/Inputs.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +3 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
- package/dist/containers/Settings/Lists.d.ts.map +1 -1
- package/dist/hooks/useFetchCustomToken.d.ts +16 -0
- package/dist/hooks/useFetchCustomToken.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncUrlAndStore/useSyncUrlAndStore.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -0
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts +14 -11
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/AddCustomTokenPage.d.ts +3 -0
- package/dist/pages/AddCustomTokenPage.d.ts.map +1 -0
- package/dist/pages/CustomTokensPage.d.ts +3 -0
- package/dist/pages/CustomTokensPage.d.ts.map +1 -0
- package/dist/pages/SelectBlockchainPage.d.ts +2 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +2 -0
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +2 -0
- package/dist/store/AppStore.d.ts.map +1 -1
- package/dist/store/app.d.ts +2 -0
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +4 -3
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +7 -2
- package/dist/store/slices/settings.d.ts.map +1 -1
- package/dist/store/utils/data.d.ts +4 -1
- package/dist/store/utils/data.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -0
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +1 -0
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +3 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.build.json +1 -1
- package/package.json +5 -5
- package/src/components/AppRoutes.tsx +30 -0
- package/src/components/BlockchainList/BlockchainList.styles.ts +3 -1
- package/src/components/BlockchainList/BlockchainList.tsx +26 -17
- package/src/components/BlockchainList/BlockchainList.types.ts +1 -0
- package/src/components/BlockchainSelectorButton/BlockchainSelectorButton.styles.ts +49 -0
- package/src/components/BlockchainSelectorButton/BlockchainSelectorButton.tsx +47 -0
- package/src/components/BlockchainSelectorButton/BlockchainSelectorButton.types.ts +11 -0
- package/src/components/BlockchainSelectorButton/index.ts +1 -0
- package/src/components/ConfirmWalletsModal/WalletList.tsx +243 -52
- package/src/components/CustomDestination/CustomDestination.tsx +5 -3
- package/src/components/CustomTokenModal/CustomTokenModal.helpers.ts +19 -0
- package/src/components/CustomTokenModal/CustomTokenModal.styles.ts +57 -0
- package/src/components/CustomTokenModal/CustomTokenModal.tsx +92 -0
- package/src/components/CustomTokenModal/CustomTokenModal.types.ts +9 -0
- package/src/components/CustomTokenModal/index.ts +1 -0
- package/src/components/HeaderButtons/WalletButton.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +113 -23
- package/src/components/TokenList/TokenList.styles.ts +1 -0
- package/src/components/TokenList/TokenList.tsx +76 -51
- package/src/components/TokenList/TokenList.types.ts +5 -2
- package/src/components/{WalletStatefulConnect/DerivationPath.tsx → WalletDerivationPathModal/WalletDerivationPathModal.tsx} +36 -18
- package/src/components/WalletDerivationPathModal/WalletDerivationPathModal.types.tsx +10 -0
- package/src/components/WalletDerivationPathModal/index.ts +1 -0
- package/src/components/WalletModal/WalletModal.tsx +25 -0
- package/src/components/WalletModal/WalletModal.types.ts +11 -0
- package/src/components/{WalletStatefulConnect/ConnectStatus.tsx → WalletModal/WalletModalContent.tsx} +5 -13
- package/src/components/WalletModal/index.ts +1 -0
- package/src/components/{WalletStatefulConnect/Namespaces.tsx → WalletNamespacesModal/WalletNamespacesModal.tsx} +27 -9
- package/src/components/{WalletStatefulConnect/Namespaces.types.tsx → WalletNamespacesModal/WalletNamespacesModal.types.tsx} +5 -2
- package/src/components/WalletNamespacesModal/index.ts +1 -0
- package/src/constants/customTokens.ts +6 -0
- package/src/constants/navigationRoutes.ts +2 -0
- package/src/constants/searchParams.ts +3 -0
- package/src/containers/Settings/Lists.tsx +25 -1
- package/src/hooks/useFetchCustomToken.ts +114 -0
- package/src/hooks/useSwapInput.ts +8 -3
- package/src/hooks/useSyncUrlAndStore/useSyncUrlAndStore.ts +6 -1
- package/src/hooks/useTheme.ts +5 -1
- package/src/hooks/useWalletList.ts +53 -22
- package/src/pages/AddCustomTokenPage.tsx +210 -0
- package/src/pages/CustomTokensPage.tsx +184 -0
- package/src/pages/HistoryPage.tsx +2 -2
- package/src/pages/LiquiditySourcePage.tsx +2 -2
- package/src/pages/SelectBlockchainPage.tsx +15 -8
- package/src/pages/SelectSwapItemsPage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +162 -10
- package/src/store/app.ts +1 -0
- package/src/store/quote.ts +12 -2
- package/src/store/slices/data.ts +61 -8
- package/src/store/slices/settings.ts +35 -2
- package/src/store/utils/data.ts +26 -1
- package/src/store/wallets.ts +1 -1
- package/src/types/config.ts +4 -1
- package/src/utils/meta.ts +12 -1
- package/src/utils/quote.ts +16 -3
- package/src/utils/settings.ts +13 -1
- package/src/utils/swap.ts +7 -7
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +0 -3
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +0 -1
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts +0 -11
- package/dist/components/StatefulConnectModal/StatefulConnectModal.d.ts.map +0 -1
- package/dist/components/StatefulConnectModal/helpers.d.ts +0 -10
- package/dist/components/StatefulConnectModal/helpers.d.ts.map +0 -1
- package/dist/components/StatefulConnectModal/index.d.ts +0 -2
- package/dist/components/StatefulConnectModal/index.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ConnectStatus.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/ConnectStatus.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ConnectStatus.types.d.ts +0 -8
- package/dist/components/WalletStatefulConnect/ConnectStatus.types.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/DerivationPath.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/DerivationPath.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.styles.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/DerivationPath.types.d.ts +0 -6
- package/dist/components/WalletStatefulConnect/DerivationPath.types.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts +0 -8
- package/dist/components/WalletStatefulConnect/ExperimentalChain.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts +0 -8
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts +0 -6
- package/dist/components/WalletStatefulConnect/ExperimentalChainStatus.types.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts +0 -4
- package/dist/components/WalletStatefulConnect/Namespaces.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/Namespaces.helpers.d.ts +0 -3
- package/dist/components/WalletStatefulConnect/Namespaces.helpers.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/Namespaces.styles.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts +0 -7
- package/dist/components/WalletStatefulConnect/Namespaces.types.d.ts.map +0 -1
- package/dist/components/WalletStatefulConnect/index.d.ts +0 -5
- package/dist/components/WalletStatefulConnect/index.d.ts.map +0 -1
- package/dist/hooks/useStatefulConnect/index.d.ts +0 -5
- package/dist/hooks/useStatefulConnect/index.d.ts.map +0 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts +0 -25
- package/dist/hooks/useStatefulConnect/useStatefulConnect.d.ts.map +0 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.helpers.d.ts +0 -8
- package/dist/hooks/useStatefulConnect/useStatefulConnect.helpers.d.ts.map +0 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts +0 -9
- package/dist/hooks/useStatefulConnect/useStatefulConnect.state.d.ts.map +0 -1
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts +0 -43
- package/dist/hooks/useStatefulConnect/useStatefulConnect.types.d.ts.map +0 -1
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +0 -10
- package/src/components/StatefulConnectModal/StatefulConnectModal.tsx +0 -168
- package/src/components/StatefulConnectModal/helpers.ts +0 -23
- package/src/components/StatefulConnectModal/index.ts +0 -1
- package/src/components/WalletStatefulConnect/ConnectStatus.types.ts +0 -11
- package/src/components/WalletStatefulConnect/DerivationPath.helpers.ts +0 -23
- package/src/components/WalletStatefulConnect/DerivationPath.types.ts +0 -6
- package/src/components/WalletStatefulConnect/ExperimentalChain.tsx +0 -36
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.helpers.ts +0 -53
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.tsx +0 -35
- package/src/components/WalletStatefulConnect/ExperimentalChainStatus.types.ts +0 -5
- package/src/components/WalletStatefulConnect/Namespaces.helpers.ts +0 -9
- package/src/components/WalletStatefulConnect/index.ts +0 -4
- package/src/hooks/useStatefulConnect/index.ts +0 -9
- package/src/hooks/useStatefulConnect/useStatefulConnect.helpers.ts +0 -13
- package/src/hooks/useStatefulConnect/useStatefulConnect.state.ts +0 -45
- package/src/hooks/useStatefulConnect/useStatefulConnect.ts +0 -232
- package/src/hooks/useStatefulConnect/useStatefulConnect.types.ts +0 -56
- /package/src/components/{WalletStatefulConnect/DerivationPath.styles.ts → WalletDerivationPathModal/WalletDerivationPathModal.styles.ts} +0 -0
- /package/src/components/{WalletStatefulConnect/ConnectStatus.styles.ts → WalletModal/WalletModalContent.styles.ts} +0 -0
- /package/src/components/{WalletStatefulConnect/Namespaces.styles.ts → WalletNamespacesModal/WalletNamespacesModal.styles.ts} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PropTypes } from './WalletModal.types';
|
|
2
|
+
|
|
3
|
+
import { Divider } from '@rango-dev/ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import { WIDGET_UI_ID } from '../../constants';
|
|
7
|
+
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
8
|
+
|
|
9
|
+
import { ModalContent } from './WalletModalContent';
|
|
10
|
+
|
|
11
|
+
export function WalletModal(props: PropTypes) {
|
|
12
|
+
const { open, onClose, ...otherProps } = props;
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<WatermarkedModal
|
|
16
|
+
open={open}
|
|
17
|
+
onClose={onClose}
|
|
18
|
+
container={
|
|
19
|
+
document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
|
|
20
|
+
}>
|
|
21
|
+
<ModalContent {...otherProps} />
|
|
22
|
+
<Divider direction="vertical" size={32} />
|
|
23
|
+
</WatermarkedModal>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WalletState } from '@rango-dev/ui';
|
|
2
|
+
|
|
3
|
+
export interface PropTypes {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
image: string;
|
|
7
|
+
state: WalletState;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type ModalContentProps = Pick<PropTypes, 'state' | 'error' | 'image'>;
|
|
@@ -1,26 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ModalContentProps } from './WalletModal.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
import { Image, MessageBox, WalletState } from '@rango-dev/ui';
|
|
5
|
-
import { useWallets } from '@rango-dev/wallets-react';
|
|
6
5
|
import React from 'react';
|
|
7
6
|
|
|
8
|
-
import { mapStatusToWalletState } from '../../utils/wallets';
|
|
9
|
-
|
|
10
7
|
import {
|
|
11
8
|
LogoContainer,
|
|
12
9
|
Spinner,
|
|
13
10
|
WalletImageContainer,
|
|
14
|
-
} from './
|
|
15
|
-
|
|
16
|
-
export function ConnectStatus(props: ConnectStatusProps) {
|
|
17
|
-
// See `wallet` notes on its type definition
|
|
18
|
-
const { wallet, error } = props;
|
|
19
|
-
const { type, image } = wallet;
|
|
20
|
-
const { state } = useWallets();
|
|
21
|
-
const walletState = mapStatusToWalletState(state(type));
|
|
11
|
+
} from './WalletModalContent.styles';
|
|
22
12
|
|
|
23
|
-
|
|
13
|
+
export function ModalContent(props: ModalContentProps) {
|
|
14
|
+
const { state, image, error } = props;
|
|
15
|
+
if (state === WalletState.CONNECTED) {
|
|
24
16
|
return (
|
|
25
17
|
<MessageBox
|
|
26
18
|
type="success"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WalletModal } from './WalletModal';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { PropTypes } from './
|
|
1
|
+
import type { PropTypes } from './WalletNamespacesModal.types';
|
|
2
2
|
import type { Namespace } from '@rango-dev/wallets-shared';
|
|
3
|
+
import type { BlockchainMeta } from 'rango-sdk';
|
|
3
4
|
|
|
4
5
|
import { i18n } from '@lingui/core';
|
|
5
6
|
import {
|
|
@@ -15,15 +16,27 @@ import {
|
|
|
15
16
|
import { namespaces } from '@rango-dev/wallets-shared';
|
|
16
17
|
import React, { useMemo, useState } from 'react';
|
|
17
18
|
|
|
19
|
+
import { WIDGET_UI_ID } from '../../constants';
|
|
18
20
|
import { useAppStore } from '../../store/AppStore';
|
|
21
|
+
import { WatermarkedModal } from '../common/WatermarkedModal';
|
|
19
22
|
import { WalletImageContainer } from '../HeaderButtons/HeaderButtons.styles';
|
|
23
|
+
import {
|
|
24
|
+
LogoContainer,
|
|
25
|
+
Spinner,
|
|
26
|
+
} from '../WalletModal/WalletModalContent.styles';
|
|
27
|
+
|
|
28
|
+
import { NamespaceList } from './WalletNamespacesModal.styles';
|
|
20
29
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
const getBlockchainLogo = (
|
|
31
|
+
blockchains: BlockchainMeta[],
|
|
32
|
+
blockchainName: string
|
|
33
|
+
) => {
|
|
34
|
+
return blockchains.find((blockchain) => blockchain.name === blockchainName)
|
|
35
|
+
?.logo;
|
|
36
|
+
};
|
|
24
37
|
|
|
25
|
-
export function
|
|
26
|
-
const { singleNamespace, availableNamespaces
|
|
38
|
+
export function WalletNamespacesModal(props: PropTypes) {
|
|
39
|
+
const { singleNamespace, availableNamespaces } = props;
|
|
27
40
|
|
|
28
41
|
const [selectedNamespaces, setSelectedNamespaces] = useState<Namespace[]>([]);
|
|
29
42
|
|
|
@@ -63,7 +76,12 @@ export function Namespaces(props: PropTypes) {
|
|
|
63
76
|
};
|
|
64
77
|
|
|
65
78
|
return (
|
|
66
|
-
|
|
79
|
+
<WatermarkedModal
|
|
80
|
+
open={props.open}
|
|
81
|
+
onClose={props.onClose}
|
|
82
|
+
container={
|
|
83
|
+
document.getElementById(WIDGET_UI_ID.SWAP_BOX_ID) || document.body
|
|
84
|
+
}>
|
|
67
85
|
<Divider size={20} />
|
|
68
86
|
<MessageBox
|
|
69
87
|
type="info"
|
|
@@ -74,7 +92,7 @@ export function Namespaces(props: PropTypes) {
|
|
|
74
92
|
icon={
|
|
75
93
|
<LogoContainer>
|
|
76
94
|
<WalletImageContainer>
|
|
77
|
-
<Image src={
|
|
95
|
+
<Image src={props.image} size={45} />
|
|
78
96
|
</WalletImageContainer>
|
|
79
97
|
<Spinner />
|
|
80
98
|
</LogoContainer>
|
|
@@ -114,6 +132,6 @@ export function Namespaces(props: PropTypes) {
|
|
|
114
132
|
onClick={() => props.onConfirm(selectedNamespaces)}>
|
|
115
133
|
{i18n.t('Confirm')}
|
|
116
134
|
</Button>
|
|
117
|
-
|
|
135
|
+
</WatermarkedModal>
|
|
118
136
|
);
|
|
119
137
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import type { NeedsNamespacesState } from '../../hooks/useStatefulConnect';
|
|
2
1
|
import type { Namespace } from '@rango-dev/wallets-shared';
|
|
3
2
|
|
|
4
3
|
export interface PropTypes {
|
|
4
|
+
open: boolean;
|
|
5
|
+
image?: string;
|
|
6
|
+
onClose: () => void;
|
|
5
7
|
onConfirm: (namespaces: Namespace[]) => void;
|
|
6
|
-
|
|
8
|
+
availableNamespaces?: Namespace[];
|
|
9
|
+
singleNamespace?: boolean;
|
|
7
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WalletNamespacesModal } from './WalletNamespacesModal';
|
|
@@ -4,6 +4,8 @@ export const navigationRoutes = {
|
|
|
4
4
|
toSwap: 'to-swap',
|
|
5
5
|
blockchains: 'blockchains',
|
|
6
6
|
settings: 'settings',
|
|
7
|
+
customTokens: 'custom-tokens',
|
|
8
|
+
addCustomTokens: 'add-custom-tokens',
|
|
7
9
|
liquiditySources: 'liquidity-sources',
|
|
8
10
|
bridges: 'bridges',
|
|
9
11
|
exchanges: 'exchanges',
|
|
@@ -5,6 +5,9 @@ export enum SearchParams {
|
|
|
5
5
|
TO_TOKEN = 'toToken',
|
|
6
6
|
FROM_AMOUNT = 'fromAmount',
|
|
7
7
|
AUTO_CONNECT = 'autoConnect',
|
|
8
|
+
|
|
9
|
+
// This is for custom tokens
|
|
10
|
+
BLOCKCHAIN = 'blockchain',
|
|
8
11
|
/*
|
|
9
12
|
* dApps can transmit liquidity sources as a search parameter,
|
|
10
13
|
* and these take precedence over widget configurations
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
styled,
|
|
21
21
|
Switch,
|
|
22
22
|
Tabs,
|
|
23
|
+
TargetIcon,
|
|
23
24
|
Tooltip,
|
|
24
25
|
Typography,
|
|
25
26
|
} from '@rango-dev/ui';
|
|
@@ -97,9 +98,11 @@ export function SettingsLists() {
|
|
|
97
98
|
const {
|
|
98
99
|
config: { features },
|
|
99
100
|
} = useAppStore();
|
|
101
|
+
const customTokens = useAppStore().customTokens();
|
|
100
102
|
const isThemeHidden = isFeatureHidden('theme', features);
|
|
101
103
|
const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
|
|
102
104
|
const isLanguageHidden = isFeatureHidden('language', features);
|
|
105
|
+
const isCustomTokensHidden = isFeatureHidden('customTokens', features);
|
|
103
106
|
|
|
104
107
|
const infiniteApprove = useAppStore().infiniteApprove;
|
|
105
108
|
const toggleInfiniteApprove = useAppStore().toggleInfiniteApprove;
|
|
@@ -185,6 +188,25 @@ export function SettingsLists() {
|
|
|
185
188
|
onClick: () => navigate(navigationRoutes.exchanges),
|
|
186
189
|
};
|
|
187
190
|
|
|
191
|
+
const customTokensItem = {
|
|
192
|
+
id: 'custom-tokens-item',
|
|
193
|
+
title: (
|
|
194
|
+
<Typography variant="title" size="xmedium">
|
|
195
|
+
{i18n.t('Custom Tokens')}
|
|
196
|
+
</Typography>
|
|
197
|
+
),
|
|
198
|
+
end: (
|
|
199
|
+
<>
|
|
200
|
+
<Typography variant="body" size="medium">
|
|
201
|
+
{`${customTokens.length}`}
|
|
202
|
+
</Typography>
|
|
203
|
+
<Divider direction="horizontal" size={8} />
|
|
204
|
+
<ChevronRightIcon color="black" />
|
|
205
|
+
</>
|
|
206
|
+
),
|
|
207
|
+
start: <TargetIcon color="gray" size={16} />,
|
|
208
|
+
onClick: () => navigate(navigationRoutes.customTokens),
|
|
209
|
+
};
|
|
188
210
|
const languageItem = {
|
|
189
211
|
id: 'language-item',
|
|
190
212
|
title: (
|
|
@@ -261,7 +283,9 @@ export function SettingsLists() {
|
|
|
261
283
|
const settingItems: ListPropTypes['items'] = isLiquidityHidden
|
|
262
284
|
? []
|
|
263
285
|
: [bridgeItem, exchangeItem];
|
|
264
|
-
|
|
286
|
+
if (!isCustomTokensHidden) {
|
|
287
|
+
settingItems.push(customTokensItem);
|
|
288
|
+
}
|
|
265
289
|
if (!isLanguageHidden) {
|
|
266
290
|
settingItems.push(languageItem);
|
|
267
291
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Token } from 'rango-sdk';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { useAppStore } from '../store/AppStore';
|
|
7
|
+
import { getConfig } from '../utils/configs';
|
|
8
|
+
|
|
9
|
+
type ErrorType = {
|
|
10
|
+
title: string;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface UseFetchCustomToken {
|
|
15
|
+
fetchCustomToken: ({
|
|
16
|
+
blockchain,
|
|
17
|
+
tokenAddress,
|
|
18
|
+
}: {
|
|
19
|
+
blockchain: string;
|
|
20
|
+
tokenAddress: string;
|
|
21
|
+
}) => Promise<Token>;
|
|
22
|
+
loading: boolean;
|
|
23
|
+
error?: ErrorType;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function useFetchCustomToken(): UseFetchCustomToken {
|
|
27
|
+
const [loading, setLoading] = useState(false);
|
|
28
|
+
const [error, setError] = useState<undefined | ErrorType>(undefined);
|
|
29
|
+
const { findToken } = useAppStore();
|
|
30
|
+
const customTokens = useAppStore().customTokens();
|
|
31
|
+
|
|
32
|
+
function produceErrorMessage(
|
|
33
|
+
type: 'duplicated' | 'not-found' | 'token-exist',
|
|
34
|
+
blockchain?: string
|
|
35
|
+
) {
|
|
36
|
+
switch (type) {
|
|
37
|
+
case 'duplicated':
|
|
38
|
+
return {
|
|
39
|
+
title: i18n.t('Duplicate Token'),
|
|
40
|
+
message: i18n.t(
|
|
41
|
+
'The address you entered is duplicate, please enter a new address.'
|
|
42
|
+
),
|
|
43
|
+
};
|
|
44
|
+
case 'token-exist':
|
|
45
|
+
return {
|
|
46
|
+
title: i18n.t('Token Already Exists'),
|
|
47
|
+
message: i18n.t(
|
|
48
|
+
`There's no need to add this token again because it already exists and is supported by us.`
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
case 'not-found':
|
|
52
|
+
return {
|
|
53
|
+
title: i18n.t('Token Not Found'),
|
|
54
|
+
message: i18n.t(
|
|
55
|
+
`Sorry, no token was found on ${blockchain} blockchain with the provided address. please make sure you have entered the right token address.`
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const fetchCustomToken: UseFetchCustomToken['fetchCustomToken'] = async ({
|
|
62
|
+
blockchain,
|
|
63
|
+
tokenAddress,
|
|
64
|
+
}) => {
|
|
65
|
+
setLoading(true);
|
|
66
|
+
try {
|
|
67
|
+
// Check for duplicate token in customTokens
|
|
68
|
+
const isDuplicate = customTokens.some(
|
|
69
|
+
(token) => token.address?.toLowerCase() === tokenAddress.toLowerCase()
|
|
70
|
+
);
|
|
71
|
+
if (isDuplicate) {
|
|
72
|
+
const errorMessage = produceErrorMessage('duplicated');
|
|
73
|
+
setError(errorMessage);
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const res = await fetch(
|
|
78
|
+
`${getConfig('BASE_URL')}/meta/token?apiKey=${getConfig(
|
|
79
|
+
'API_KEY'
|
|
80
|
+
)}&blockchain=${blockchain}&address=${tokenAddress}`
|
|
81
|
+
);
|
|
82
|
+
const contentType = res.headers.get('content-type');
|
|
83
|
+
const response =
|
|
84
|
+
contentType &&
|
|
85
|
+
contentType.includes('application/json') &&
|
|
86
|
+
(await res.json());
|
|
87
|
+
if (!response || response.error) {
|
|
88
|
+
const errorMessage = produceErrorMessage('not-found', blockchain);
|
|
89
|
+
setError(errorMessage);
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Check if token is already in the system
|
|
94
|
+
const isTokenFound = findToken({
|
|
95
|
+
blockchain: response.blockchain,
|
|
96
|
+
address: response.address,
|
|
97
|
+
symbol: response.symbol,
|
|
98
|
+
});
|
|
99
|
+
if (isTokenFound) {
|
|
100
|
+
const errorMessage = produceErrorMessage('token-exist');
|
|
101
|
+
setError(errorMessage);
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return response;
|
|
106
|
+
} catch (error: any) {
|
|
107
|
+
setError(undefined);
|
|
108
|
+
throw new Error(error.message);
|
|
109
|
+
} finally {
|
|
110
|
+
setLoading(false);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return { fetchCustomToken, loading, error };
|
|
114
|
+
}
|
|
@@ -11,6 +11,8 @@ import { isPositiveNumber } from '../utils/numbers';
|
|
|
11
11
|
import {
|
|
12
12
|
generateQuoteWarnings,
|
|
13
13
|
getDefaultQuote,
|
|
14
|
+
getQuoteFromTokenUsdPrice,
|
|
15
|
+
getQuoteToTokenUsdPrice,
|
|
14
16
|
sortQuotesBy,
|
|
15
17
|
} from '../utils/quote';
|
|
16
18
|
import { isFeatureEnabled } from '../utils/settings';
|
|
@@ -146,12 +148,15 @@ export function useSwapInput({
|
|
|
146
148
|
requestId: quote?.requestId || '',
|
|
147
149
|
swaps: quote?.swaps,
|
|
148
150
|
});
|
|
149
|
-
|
|
151
|
+
const outputUsdValue =
|
|
152
|
+
getQuoteToTokenUsdPrice(quote) || toToken?.usdPrice;
|
|
153
|
+
const inputUsdValue =
|
|
154
|
+
getQuoteFromTokenUsdPrice(quote) || fromToken?.usdPrice;
|
|
150
155
|
const quoteWarning =
|
|
151
156
|
quote &&
|
|
152
157
|
generateQuoteWarnings(quote, {
|
|
153
|
-
fromToken,
|
|
154
|
-
toToken,
|
|
158
|
+
fromToken: { ...fromToken, usdPrice: inputUsdValue },
|
|
159
|
+
toToken: { ...toToken, usdPrice: outputUsdValue },
|
|
155
160
|
userSlippage,
|
|
156
161
|
findToken,
|
|
157
162
|
});
|
|
@@ -54,6 +54,8 @@ export function useSyncUrlAndStore() {
|
|
|
54
54
|
const clientUrl = searchParams.get(SearchParams.CLIENT_URL);
|
|
55
55
|
const liquiditySources = searchParams.get(SearchParams.LIQUIDITY_SOURCES);
|
|
56
56
|
|
|
57
|
+
const blockchain = searchParams.get(SearchParams.BLOCKCHAIN);
|
|
58
|
+
|
|
57
59
|
return {
|
|
58
60
|
fromAmount,
|
|
59
61
|
fromBlockchain,
|
|
@@ -64,6 +66,7 @@ export function useSyncUrlAndStore() {
|
|
|
64
66
|
clientUrl,
|
|
65
67
|
liquiditySources,
|
|
66
68
|
utmQueryParams,
|
|
69
|
+
blockchain,
|
|
67
70
|
};
|
|
68
71
|
};
|
|
69
72
|
|
|
@@ -79,7 +82,8 @@ export function useSyncUrlAndStore() {
|
|
|
79
82
|
};
|
|
80
83
|
|
|
81
84
|
useEffect(() => {
|
|
82
|
-
const { autoConnect, clientUrl, utmQueryParams } =
|
|
85
|
+
const { autoConnect, clientUrl, utmQueryParams, blockchain } =
|
|
86
|
+
getUrlSearchParams();
|
|
83
87
|
if (isInRouterContext && fetchMetaStatus === 'success') {
|
|
84
88
|
updateUrlSearchParams({
|
|
85
89
|
[SearchParams.FROM_BLOCKCHAIN]: fromBlockchain?.name,
|
|
@@ -89,6 +93,7 @@ export function useSyncUrlAndStore() {
|
|
|
89
93
|
[SearchParams.FROM_AMOUNT]: inputAmount,
|
|
90
94
|
[SearchParams.AUTO_CONNECT]: autoConnect ?? undefined,
|
|
91
95
|
[SearchParams.CLIENT_URL]: clientUrl ?? undefined,
|
|
96
|
+
[SearchParams.BLOCKCHAIN]: blockchain ?? undefined,
|
|
92
97
|
[SearchParams.LIQUIDITY_SOURCES]: campaignMode
|
|
93
98
|
? liquiditySourcesParamsRef.current
|
|
94
99
|
: undefined,
|
package/src/hooks/useTheme.ts
CHANGED
|
@@ -93,8 +93,12 @@ export function useTheme(props: WidgetTheme) {
|
|
|
93
93
|
if (theme === 'auto') {
|
|
94
94
|
return OSTheme === 'dark' ? darkClassNames : lightClassNames;
|
|
95
95
|
}
|
|
96
|
+
|
|
96
97
|
return theme === 'dark' ? darkClassNames : lightClassNames;
|
|
97
98
|
};
|
|
98
99
|
|
|
99
|
-
return {
|
|
100
|
+
return {
|
|
101
|
+
activeTheme: getActiveTheme,
|
|
102
|
+
mode: theme === 'auto' ? OSTheme : theme,
|
|
103
|
+
};
|
|
100
104
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { WalletInfoWithExtra } from '../types';
|
|
2
1
|
import type { WalletInfo } from '@rango-dev/ui';
|
|
2
|
+
import type { NamespaceData, WalletType } from '@rango-dev/wallets-shared';
|
|
3
3
|
import type { BlockchainMeta } from 'rango-sdk';
|
|
4
4
|
|
|
5
5
|
import { WalletState } from '@rango-dev/ui';
|
|
@@ -9,10 +9,11 @@ import {
|
|
|
9
9
|
KEPLR_COMPATIBLE_WALLETS,
|
|
10
10
|
WalletTypes,
|
|
11
11
|
} from '@rango-dev/wallets-shared';
|
|
12
|
-
import { useCallback, useEffect } from 'react';
|
|
12
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
13
13
|
|
|
14
14
|
import { useAppStore } from '../store/AppStore';
|
|
15
15
|
import { useWalletsStore } from '../store/wallets';
|
|
16
|
+
import { isSingleWalletActive } from '../utils/common';
|
|
16
17
|
import { configWalletsToWalletName } from '../utils/providers';
|
|
17
18
|
import {
|
|
18
19
|
hashWalletsState,
|
|
@@ -21,33 +22,26 @@ import {
|
|
|
21
22
|
sortWalletsBasedOnConnectionState,
|
|
22
23
|
} from '../utils/wallets';
|
|
23
24
|
|
|
24
|
-
import { useStatefulConnect } from './useStatefulConnect/useStatefulConnect';
|
|
25
|
-
|
|
26
25
|
const ALL_SUPPORTED_WALLETS = Object.values(WalletTypes);
|
|
27
26
|
|
|
28
27
|
interface Params {
|
|
29
28
|
chain?: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
list: WalletInfoWithExtra[];
|
|
34
|
-
terminateConnectingWallets: () => void;
|
|
29
|
+
onBeforeConnect?: (walletType: string) => void;
|
|
30
|
+
onConnect?: (walletType: string) => void;
|
|
31
|
+
onError?: (error?: string) => void;
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* now it only has a method to disconnect the wallets that has `connecting` status. This is useful for exiting page and terminating wallet connection.
|
|
42
|
-
*
|
|
35
|
+
* gets list of wallets with their information and an action for handling click callback fo UI
|
|
36
|
+
* we need to share the logic of rendering list of wallets and handle clicking on them in different places
|
|
37
|
+
* you can use this list whenever you need to show the list of wallets and needed callbacks
|
|
43
38
|
*/
|
|
44
|
-
export function useWalletList(params
|
|
45
|
-
const { chain } = params
|
|
39
|
+
export function useWalletList(params: Params) {
|
|
40
|
+
const { chain, onBeforeConnect, onConnect, onError } = params;
|
|
46
41
|
const { config } = useAppStore();
|
|
47
|
-
const { state, getWalletInfo } = useWallets();
|
|
42
|
+
const { state, disconnect, getWalletInfo, connect } = useWallets();
|
|
48
43
|
const { connectedWallets } = useWalletsStore();
|
|
49
44
|
const blockchains = useAppStore().blockchains();
|
|
50
|
-
const { handleDisconnect } = useStatefulConnect();
|
|
51
45
|
|
|
52
46
|
/** It can be what has been set by widget config or as a fallback we use all the supported wallets by our library */
|
|
53
47
|
const listAvailableWalletTypes =
|
|
@@ -73,6 +67,7 @@ export function useWalletList(params?: Params): API {
|
|
|
73
67
|
: wallets;
|
|
74
68
|
|
|
75
69
|
const sortedWallets = sortWalletsBasedOnConnectionState(wallets);
|
|
70
|
+
const [error, setError] = useState('');
|
|
76
71
|
|
|
77
72
|
const isExperimentalChainNotAdded = (walletType: string) =>
|
|
78
73
|
!connectedWallets.find(
|
|
@@ -81,18 +76,51 @@ export function useWalletList(params?: Params): API {
|
|
|
81
76
|
connectedWallet.chain === chain
|
|
82
77
|
);
|
|
83
78
|
|
|
84
|
-
const
|
|
79
|
+
const handleClick = async (
|
|
80
|
+
type: WalletType,
|
|
81
|
+
namespaces?: NamespaceData[]
|
|
82
|
+
) => {
|
|
83
|
+
const wallet = state(type);
|
|
84
|
+
try {
|
|
85
|
+
if (error) {
|
|
86
|
+
setError('');
|
|
87
|
+
}
|
|
88
|
+
if (wallet.connected) {
|
|
89
|
+
await disconnect(type);
|
|
90
|
+
} else {
|
|
91
|
+
if (isSingleWalletActive(wallets, config.multiWallets)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
onBeforeConnect?.(type);
|
|
95
|
+
await connect(type, undefined, namespaces);
|
|
96
|
+
onConnect?.(type);
|
|
97
|
+
}
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
|
+
} catch (e: any) {
|
|
100
|
+
onError?.(e?.message);
|
|
101
|
+
setError('Error: ' + e?.message);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const disconnectConnectingWallets = useCallback(() => {
|
|
85
106
|
const connectingWallets =
|
|
86
107
|
wallets?.filter((wallet) => wallet.state === WalletState.CONNECTING) ||
|
|
87
108
|
[];
|
|
88
109
|
for (const wallet of connectingWallets) {
|
|
89
|
-
void
|
|
110
|
+
void disconnect(wallet.type);
|
|
90
111
|
}
|
|
91
112
|
}, [hashWalletsState(wallets)]);
|
|
92
113
|
|
|
114
|
+
const disconnectWallet = async (type: WalletType) => {
|
|
115
|
+
const wallet = state(type);
|
|
116
|
+
if (wallet.connected) {
|
|
117
|
+
await disconnect(type);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
93
121
|
useEffect(() => {
|
|
94
122
|
return () => {
|
|
95
|
-
|
|
123
|
+
disconnectConnectingWallets();
|
|
96
124
|
};
|
|
97
125
|
}, []);
|
|
98
126
|
|
|
@@ -147,6 +175,9 @@ export function useWalletList(params?: Params): API {
|
|
|
147
175
|
list: sortedWallets.filter(
|
|
148
176
|
(wallet) => !shouldExcludeWallet(wallet.type, chain ?? '', blockchains)
|
|
149
177
|
),
|
|
150
|
-
|
|
178
|
+
error,
|
|
179
|
+
handleClick,
|
|
180
|
+
disconnectConnectingWallets,
|
|
181
|
+
disconnectWallet,
|
|
151
182
|
};
|
|
152
183
|
}
|