@rango-dev/widget-embedded 0.31.1-next.3 → 0.32.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/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 +4 -4
- 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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { WalletInfoWithExtra } from '../types';
|
|
2
|
+
import type { Namespace, WalletType } from '@rango-dev/wallets-shared';
|
|
2
3
|
|
|
3
4
|
import { i18n } from '@lingui/core';
|
|
4
5
|
import {
|
|
@@ -8,11 +9,14 @@ import {
|
|
|
8
9
|
styled,
|
|
9
10
|
Typography,
|
|
10
11
|
Wallet,
|
|
12
|
+
WalletState,
|
|
11
13
|
} from '@rango-dev/ui';
|
|
12
14
|
import React, { useState } from 'react';
|
|
13
15
|
|
|
14
16
|
import { Layout, PageContainer } from '../components/Layout';
|
|
15
|
-
import {
|
|
17
|
+
import { WalletDerivationPathModal } from '../components/WalletDerivationPathModal';
|
|
18
|
+
import { WalletModal } from '../components/WalletModal';
|
|
19
|
+
import { WalletNamespacesModal } from '../components/WalletNamespacesModal';
|
|
16
20
|
import { useWalletList } from '../hooks/useWalletList';
|
|
17
21
|
import { useAppStore } from '../store/AppStore';
|
|
18
22
|
import { useUiStore } from '../store/ui';
|
|
@@ -22,6 +26,21 @@ import {
|
|
|
22
26
|
filterWalletsByCategory,
|
|
23
27
|
} from '../utils/wallets';
|
|
24
28
|
|
|
29
|
+
interface NamespacesModalState {
|
|
30
|
+
open: boolean;
|
|
31
|
+
providerType: string;
|
|
32
|
+
providerImage: string;
|
|
33
|
+
availableNamespaces?: Namespace[];
|
|
34
|
+
singleNamespace?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface DerivationPathModalState {
|
|
38
|
+
open: boolean;
|
|
39
|
+
providerType: string;
|
|
40
|
+
providerImage: string;
|
|
41
|
+
namespace: Namespace;
|
|
42
|
+
}
|
|
43
|
+
|
|
25
44
|
const ListContainer = styled('div', {
|
|
26
45
|
display: 'flex',
|
|
27
46
|
justifyContent: 'center',
|
|
@@ -35,17 +54,73 @@ const Container = styled(PageContainer, {
|
|
|
35
54
|
textAlign: 'center',
|
|
36
55
|
});
|
|
37
56
|
|
|
57
|
+
export const TIME_TO_CLOSE_MODAL = 3_000;
|
|
58
|
+
export const TIME_TO_IGNORE_MODAL = 300;
|
|
59
|
+
|
|
38
60
|
export function WalletsPage() {
|
|
39
61
|
const { fetchStatus: fetchMetaStatus } = useAppStore();
|
|
40
62
|
const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
|
|
41
63
|
const blockchains = useAppStore().blockchains();
|
|
42
64
|
const { config } = useAppStore();
|
|
43
65
|
|
|
44
|
-
const [
|
|
45
|
-
|
|
66
|
+
const [openModal, setOpenModal] = useState(false);
|
|
67
|
+
const [namespacesModalState, setNamespacesModalState] =
|
|
68
|
+
useState<NamespacesModalState | null>(null);
|
|
69
|
+
const [derivationPathModalState, setDerivationPathModalState] =
|
|
70
|
+
useState<DerivationPathModalState | null>(null);
|
|
71
|
+
const [selectedWalletType, setSelectedWalletType] = useState<WalletType>('');
|
|
72
|
+
let modalTimerId: ReturnType<typeof setTimeout> | null = null;
|
|
46
73
|
const isActiveTab = useUiStore.use.isActiveTab();
|
|
47
74
|
|
|
48
|
-
const { list } =
|
|
75
|
+
const { list, handleClick, error, disconnectConnectingWallets } =
|
|
76
|
+
useWalletList({
|
|
77
|
+
onBeforeConnect: (type) => {
|
|
78
|
+
modalTimerId = setTimeout(() => {
|
|
79
|
+
setOpenModal(true);
|
|
80
|
+
setSelectedWalletType(type);
|
|
81
|
+
}, TIME_TO_IGNORE_MODAL);
|
|
82
|
+
},
|
|
83
|
+
onConnect: (type) => {
|
|
84
|
+
if (modalTimerId) {
|
|
85
|
+
clearTimeout(modalTimerId);
|
|
86
|
+
}
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
if (selectedWalletType === type) {
|
|
89
|
+
setOpenModal(false);
|
|
90
|
+
}
|
|
91
|
+
}, TIME_TO_CLOSE_MODAL);
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const handleCloseWalletModal = () => {
|
|
96
|
+
disconnectConnectingWallets();
|
|
97
|
+
setOpenModal(false);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const handleCloseNamespaceModal = () => {
|
|
101
|
+
if (namespacesModalState) {
|
|
102
|
+
setNamespacesModalState({
|
|
103
|
+
...namespacesModalState,
|
|
104
|
+
open: false,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const handleCloseDerivationPathModal = () => {
|
|
110
|
+
if (derivationPathModalState) {
|
|
111
|
+
setDerivationPathModalState({
|
|
112
|
+
...derivationPathModalState,
|
|
113
|
+
open: false,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const selectedWallet = list.find(
|
|
119
|
+
(wallet) => wallet.type === selectedWalletType
|
|
120
|
+
);
|
|
121
|
+
const selectedWalletImage = selectedWallet?.image || '';
|
|
122
|
+
const selectedWalletState =
|
|
123
|
+
selectedWallet?.state || WalletState.NOT_INSTALLED;
|
|
49
124
|
|
|
50
125
|
const filteredBlockchains = filterBlockchainsByWalletTypes(list, blockchains);
|
|
51
126
|
const activeCategoriesCount = getCategoriesCount(filteredBlockchains);
|
|
@@ -58,7 +133,67 @@ export function WalletsPage() {
|
|
|
58
133
|
return;
|
|
59
134
|
}
|
|
60
135
|
|
|
61
|
-
|
|
136
|
+
if (
|
|
137
|
+
!!wallet.namespaces?.length &&
|
|
138
|
+
wallet.state === WalletState.DISCONNECTED
|
|
139
|
+
) {
|
|
140
|
+
if (wallet.namespaces.length > 1) {
|
|
141
|
+
setNamespacesModalState({
|
|
142
|
+
open: true,
|
|
143
|
+
providerType: wallet.type,
|
|
144
|
+
providerImage: wallet.image,
|
|
145
|
+
availableNamespaces: wallet.namespaces,
|
|
146
|
+
singleNamespace: wallet.singleNamespace,
|
|
147
|
+
});
|
|
148
|
+
} else if (wallet.needsDerivationPath) {
|
|
149
|
+
setDerivationPathModalState({
|
|
150
|
+
open: true,
|
|
151
|
+
providerType: wallet.type,
|
|
152
|
+
providerImage: wallet.image,
|
|
153
|
+
namespace: wallet.namespaces[0],
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
void handleClick(wallet.type);
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
void handleClick(wallet.type);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const handleConfirmNamespaces = (selectedNamespaces: Namespace[]) => {
|
|
164
|
+
const wallet = filteredWallets.find(
|
|
165
|
+
(wallet) => wallet.type === namespacesModalState?.providerType
|
|
166
|
+
);
|
|
167
|
+
if (
|
|
168
|
+
wallet?.singleNamespace && // Currently we support derivation path only for single namespace wallets
|
|
169
|
+
wallet?.needsDerivationPath &&
|
|
170
|
+
selectedNamespaces[0]
|
|
171
|
+
) {
|
|
172
|
+
setDerivationPathModalState({
|
|
173
|
+
open: true,
|
|
174
|
+
providerType: wallet.type,
|
|
175
|
+
providerImage: wallet.image,
|
|
176
|
+
namespace: selectedNamespaces[0],
|
|
177
|
+
});
|
|
178
|
+
} else {
|
|
179
|
+
void handleClick(
|
|
180
|
+
namespacesModalState?.providerType as string,
|
|
181
|
+
selectedNamespaces.map((namespace) => ({
|
|
182
|
+
namespace,
|
|
183
|
+
}))
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
handleCloseNamespaceModal();
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
const handleDerivationPathConfirm = (derivationPath: string) => {
|
|
190
|
+
if (derivationPath && derivationPathModalState?.namespace) {
|
|
191
|
+
void handleClick(derivationPathModalState.providerType, [
|
|
192
|
+
{ namespace: derivationPathModalState.namespace, derivationPath },
|
|
193
|
+
]);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
handleCloseDerivationPathModal();
|
|
62
197
|
};
|
|
63
198
|
|
|
64
199
|
return (
|
|
@@ -95,11 +230,28 @@ export function WalletsPage() {
|
|
|
95
230
|
/>
|
|
96
231
|
);
|
|
97
232
|
})}
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
onClose={
|
|
101
|
-
|
|
102
|
-
}
|
|
233
|
+
<WalletModal
|
|
234
|
+
open={!!openModal}
|
|
235
|
+
onClose={handleCloseWalletModal}
|
|
236
|
+
image={selectedWalletImage}
|
|
237
|
+
state={selectedWalletState}
|
|
238
|
+
error={error}
|
|
239
|
+
/>
|
|
240
|
+
<WalletNamespacesModal
|
|
241
|
+
open={!!namespacesModalState?.open}
|
|
242
|
+
onClose={handleCloseNamespaceModal}
|
|
243
|
+
onConfirm={handleConfirmNamespaces}
|
|
244
|
+
image={namespacesModalState?.providerImage}
|
|
245
|
+
availableNamespaces={namespacesModalState?.availableNamespaces}
|
|
246
|
+
singleNamespace={namespacesModalState?.singleNamespace}
|
|
247
|
+
/>
|
|
248
|
+
<WalletDerivationPathModal
|
|
249
|
+
open={!!derivationPathModalState?.open}
|
|
250
|
+
selectedNamespace={derivationPathModalState?.namespace}
|
|
251
|
+
type={derivationPathModalState?.providerType}
|
|
252
|
+
image={derivationPathModalState?.providerImage}
|
|
253
|
+
onClose={handleCloseDerivationPathModal}
|
|
254
|
+
onConfirm={handleDerivationPathConfirm}
|
|
103
255
|
/>
|
|
104
256
|
</ListContainer>
|
|
105
257
|
</Container>
|
package/src/store/app.ts
CHANGED
package/src/store/quote.ts
CHANGED
|
@@ -21,7 +21,10 @@ import {
|
|
|
21
21
|
WidgetEvents,
|
|
22
22
|
} from '../types';
|
|
23
23
|
import { isPositiveNumber } from '../utils/numbers';
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
getQuoteFromTokenUsdPrice,
|
|
26
|
+
getQuoteToTokenUsdPrice,
|
|
27
|
+
} from '../utils/quote';
|
|
25
28
|
import { calcOutputUsdValue } from '../utils/swap';
|
|
26
29
|
|
|
27
30
|
import createSelectors from './selectors';
|
|
@@ -125,6 +128,8 @@ export const useQuoteStore = createSelectors(
|
|
|
125
128
|
set((state) => {
|
|
126
129
|
let outputAmount: BigNumber | null = null;
|
|
127
130
|
let outputUsdValue: BigNumber = ZERO;
|
|
131
|
+
|
|
132
|
+
let inputUsdValue = state.inputUsdValue;
|
|
128
133
|
if (!isPositiveNumber(state.inputAmount)) {
|
|
129
134
|
return {};
|
|
130
135
|
}
|
|
@@ -132,8 +137,12 @@ export const useQuoteStore = createSelectors(
|
|
|
132
137
|
outputAmount = !!quote?.outputAmount
|
|
133
138
|
? new BigNumber(quote?.outputAmount)
|
|
134
139
|
: null;
|
|
140
|
+
inputUsdValue = calcOutputUsdValue(
|
|
141
|
+
state.inputAmount,
|
|
142
|
+
getQuoteFromTokenUsdPrice(quote) || state.fromToken?.usdPrice
|
|
143
|
+
);
|
|
135
144
|
outputUsdValue = calcOutputUsdValue(
|
|
136
|
-
quote
|
|
145
|
+
quote.outputAmount,
|
|
137
146
|
getQuoteToTokenUsdPrice(quote) || state.toToken?.usdPrice
|
|
138
147
|
);
|
|
139
148
|
}
|
|
@@ -142,6 +151,7 @@ export const useQuoteStore = createSelectors(
|
|
|
142
151
|
...(!!quote && {
|
|
143
152
|
outputAmount,
|
|
144
153
|
outputUsdValue,
|
|
154
|
+
inputUsdValue,
|
|
145
155
|
}),
|
|
146
156
|
};
|
|
147
157
|
}),
|
package/src/store/slices/data.ts
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
// We keep all the received data from server in this slice
|
|
2
2
|
|
|
3
3
|
import type { ConfigSlice } from './config';
|
|
4
|
+
import type { SettingsSlice } from './settings';
|
|
4
5
|
import type { CachedEntries } from '../../services/cacheService';
|
|
5
6
|
import type { Balance, Blockchain, TokenHash } from '../../types';
|
|
6
|
-
import type { Asset, BlockchainMeta, SwapperMeta, Token } from 'rango-sdk';
|
|
7
7
|
import type { StateCreator } from 'zustand';
|
|
8
8
|
|
|
9
|
+
import {
|
|
10
|
+
type Asset,
|
|
11
|
+
type BlockchainMeta,
|
|
12
|
+
type SwapperMeta,
|
|
13
|
+
type Token,
|
|
14
|
+
} from 'rango-sdk';
|
|
15
|
+
|
|
16
|
+
import { ACTIVE_BLOCKCHAINS_FOR_CUSTOM_TOKENS } from '../../constants/customTokens';
|
|
9
17
|
import { cacheService } from '../../services/cacheService';
|
|
10
18
|
import { httpService as sdk } from '../../services/httpService';
|
|
11
19
|
import { compareWithSearchFor, containsText } from '../../utils/common';
|
|
12
20
|
import { createTokenHash, isTokenNative } from '../../utils/meta';
|
|
13
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
addCustomTokensToSupportedTokens,
|
|
23
|
+
sortLiquiditySourcesByGroupTitle,
|
|
24
|
+
} from '../../utils/settings';
|
|
14
25
|
import { areTokensEqual, compareTokenBalance } from '../../utils/wallets';
|
|
15
|
-
import {
|
|
26
|
+
import {
|
|
27
|
+
getSupportedBlockchainsFromConfig,
|
|
28
|
+
matchTokensFromConfigWithMeta,
|
|
29
|
+
} from '../utils';
|
|
16
30
|
|
|
17
31
|
type BlockchainOptions = {
|
|
18
|
-
type?: 'source' | 'destination';
|
|
32
|
+
type?: 'source' | 'destination' | 'custom-token';
|
|
19
33
|
};
|
|
20
34
|
|
|
21
35
|
type TokenOptions = {
|
|
@@ -45,7 +59,7 @@ export interface DataSlice {
|
|
|
45
59
|
}
|
|
46
60
|
|
|
47
61
|
export const createDataSlice: StateCreator<
|
|
48
|
-
DataSlice & ConfigSlice,
|
|
62
|
+
DataSlice & ConfigSlice & SettingsSlice,
|
|
49
63
|
[],
|
|
50
64
|
[],
|
|
51
65
|
DataSlice
|
|
@@ -67,8 +81,30 @@ export const createDataSlice: StateCreator<
|
|
|
67
81
|
if (!options || !options?.type) {
|
|
68
82
|
return blockchainsFromState;
|
|
69
83
|
}
|
|
70
|
-
|
|
71
84
|
const config = get().config;
|
|
85
|
+
|
|
86
|
+
if (options.type === 'custom-token') {
|
|
87
|
+
const supportedBlockchainsFromConfig = getSupportedBlockchainsFromConfig({
|
|
88
|
+
config,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
let supportedBlockchains: BlockchainMeta[] = blockchainsFromState;
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* Supported blockchains can be configured and be limited.
|
|
95
|
+
* In this case, we only keep those active blockchains which exist in config.
|
|
96
|
+
*/
|
|
97
|
+
if (supportedBlockchainsFromConfig.length > 0) {
|
|
98
|
+
supportedBlockchains = supportedBlockchains.filter((blockchain) =>
|
|
99
|
+
supportedBlockchainsFromConfig.includes(blockchain.name)
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return supportedBlockchains.filter((blockchain) =>
|
|
104
|
+
ACTIVE_BLOCKCHAINS_FOR_CUSTOM_TOKENS.includes(blockchain.type)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
72
108
|
const supportedBlockchainsFromConfig =
|
|
73
109
|
(options.type === 'source'
|
|
74
110
|
? config.from?.blockchains
|
|
@@ -88,7 +124,12 @@ export const createDataSlice: StateCreator<
|
|
|
88
124
|
return list;
|
|
89
125
|
},
|
|
90
126
|
tokens: (options) => {
|
|
91
|
-
const {
|
|
127
|
+
const {
|
|
128
|
+
_tokensMapByTokenHash,
|
|
129
|
+
_tokensMapByBlockchainName,
|
|
130
|
+
config,
|
|
131
|
+
_customTokens,
|
|
132
|
+
} = get();
|
|
92
133
|
const tokensFromState = Array.from(_tokensMapByTokenHash.values());
|
|
93
134
|
const blockchainsMapByName = get()._blockchainsMapByName;
|
|
94
135
|
if (!options || !options.type) {
|
|
@@ -117,6 +158,12 @@ export const createDataSlice: StateCreator<
|
|
|
117
158
|
cacheService.set(cacheKey, supportedTokens);
|
|
118
159
|
}
|
|
119
160
|
|
|
161
|
+
supportedTokens = addCustomTokensToSupportedTokens(
|
|
162
|
+
supportedTokens,
|
|
163
|
+
_customTokens,
|
|
164
|
+
config.features
|
|
165
|
+
);
|
|
166
|
+
|
|
120
167
|
const blockchains = get().blockchains({
|
|
121
168
|
type: options.type,
|
|
122
169
|
});
|
|
@@ -217,8 +264,14 @@ export const createDataSlice: StateCreator<
|
|
|
217
264
|
},
|
|
218
265
|
findToken: (asset) => {
|
|
219
266
|
const tokensMapByHashToken = get()._tokensMapByTokenHash;
|
|
267
|
+
const customTokens = get().customTokens();
|
|
220
268
|
const tokenHash = createTokenHash(asset);
|
|
221
|
-
|
|
269
|
+
let token = tokensMapByHashToken.get(tokenHash);
|
|
270
|
+
if (!token) {
|
|
271
|
+
token = customTokens.find(
|
|
272
|
+
(customToken) => createTokenHash(customToken) === tokenHash
|
|
273
|
+
);
|
|
274
|
+
}
|
|
222
275
|
return token;
|
|
223
276
|
},
|
|
224
277
|
isTokenPinned: (token, type) => {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ConfigSlice } from './config';
|
|
2
|
+
import type { DataSlice } from './data';
|
|
2
3
|
import type { WidgetConfig } from '../../types';
|
|
3
|
-
import type { SwapperMeta } from 'rango-sdk';
|
|
4
|
+
import type { SwapperMeta, Token } from 'rango-sdk';
|
|
4
5
|
import type { StateCreator } from 'zustand';
|
|
5
6
|
|
|
6
7
|
import { type Language } from '@rango-dev/ui';
|
|
@@ -10,6 +11,7 @@ import { DEFAULT_LANGUAGE } from '../../constants/languages';
|
|
|
10
11
|
import { DEFAULT_SLIPPAGE } from '../../constants/swapSettings';
|
|
11
12
|
import { removeDuplicateFrom } from '../../utils/common';
|
|
12
13
|
import { isFeatureHidden } from '../../utils/settings';
|
|
14
|
+
import { getSupportedBlockchainsFromConfig } from '../utils';
|
|
13
15
|
|
|
14
16
|
export type ThemeMode = 'auto' | 'dark' | 'light';
|
|
15
17
|
|
|
@@ -25,6 +27,7 @@ export interface SettingsSlice {
|
|
|
25
27
|
affiliateRef: string | null;
|
|
26
28
|
affiliatePercent: number | null;
|
|
27
29
|
affiliateWallets: { [key: string]: string } | null;
|
|
30
|
+
_customTokens: Token[];
|
|
28
31
|
|
|
29
32
|
setSlippage: (slippage: number) => void;
|
|
30
33
|
setCustomSlippage: (customSlippage: number | null) => void;
|
|
@@ -43,10 +46,13 @@ export interface SettingsSlice {
|
|
|
43
46
|
) => void;
|
|
44
47
|
addPreferredBlockchain: (blockchain: string) => void;
|
|
45
48
|
updateSettings: (config: WidgetConfig) => void;
|
|
49
|
+
setCustomToken: (token: Token) => void;
|
|
50
|
+
deleteCustomToken: (token: Token) => void;
|
|
51
|
+
customTokens: () => Token[];
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
export const createSettingsSlice: StateCreator<
|
|
49
|
-
SettingsSlice & ConfigSlice,
|
|
55
|
+
SettingsSlice & DataSlice & ConfigSlice,
|
|
50
56
|
[],
|
|
51
57
|
[],
|
|
52
58
|
SettingsSlice
|
|
@@ -61,6 +67,7 @@ export const createSettingsSlice: StateCreator<
|
|
|
61
67
|
affiliateRef: null,
|
|
62
68
|
affiliatePercent: null,
|
|
63
69
|
affiliateWallets: null,
|
|
70
|
+
_customTokens: [],
|
|
64
71
|
|
|
65
72
|
addPreferredBlockchain: (blockchain) => {
|
|
66
73
|
const currentPreferredBlockchains = get().preferredBlockchains;
|
|
@@ -93,6 +100,7 @@ export const createSettingsSlice: StateCreator<
|
|
|
93
100
|
set(() => ({
|
|
94
101
|
slippage: slippage,
|
|
95
102
|
})),
|
|
103
|
+
|
|
96
104
|
setCustomSlippage: (customSlippage) =>
|
|
97
105
|
set(() => ({
|
|
98
106
|
customSlippage: customSlippage,
|
|
@@ -131,6 +139,7 @@ export const createSettingsSlice: StateCreator<
|
|
|
131
139
|
set((state) => ({
|
|
132
140
|
infiniteApprove: !state.infiniteApprove,
|
|
133
141
|
})),
|
|
142
|
+
|
|
134
143
|
toggleLiquiditySource: (name) =>
|
|
135
144
|
set((state) => {
|
|
136
145
|
if (state.disabledLiquiditySources.includes(name)) {
|
|
@@ -177,4 +186,28 @@ export const createSettingsSlice: StateCreator<
|
|
|
177
186
|
}),
|
|
178
187
|
});
|
|
179
188
|
},
|
|
189
|
+
setCustomToken: (token) =>
|
|
190
|
+
set((state) => ({
|
|
191
|
+
_customTokens: [token, ...state._customTokens],
|
|
192
|
+
})),
|
|
193
|
+
deleteCustomToken: (token) =>
|
|
194
|
+
set((state) => ({
|
|
195
|
+
_customTokens: state._customTokens.filter(
|
|
196
|
+
(customToken) => customToken.address !== token.address
|
|
197
|
+
),
|
|
198
|
+
})),
|
|
199
|
+
customTokens: () => {
|
|
200
|
+
const config = get().config;
|
|
201
|
+
|
|
202
|
+
const customTokens = get()._customTokens;
|
|
203
|
+
const supportedBlockchainsFromConfig = getSupportedBlockchainsFromConfig({
|
|
204
|
+
config,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
return !supportedBlockchainsFromConfig.length
|
|
208
|
+
? customTokens
|
|
209
|
+
: customTokens.filter((token) =>
|
|
210
|
+
supportedBlockchainsFromConfig.includes(token.blockchain)
|
|
211
|
+
);
|
|
212
|
+
},
|
|
180
213
|
});
|
package/src/store/utils/data.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
BlockchainAndTokenConfig,
|
|
3
|
+
TokenHash,
|
|
4
|
+
WidgetConfig,
|
|
5
|
+
} from '../../types';
|
|
2
6
|
import type { DataSlice } from '../slices/data';
|
|
3
7
|
import type { Asset, Token } from 'rango-sdk';
|
|
4
8
|
|
|
@@ -115,3 +119,24 @@ export function matchTokensFromConfigWithMeta(params: {
|
|
|
115
119
|
|
|
116
120
|
return Object.values(result);
|
|
117
121
|
}
|
|
122
|
+
|
|
123
|
+
export function getSupportedBlockchainsFromConfig(params: {
|
|
124
|
+
config: WidgetConfig;
|
|
125
|
+
}): string[] {
|
|
126
|
+
const { config } = params;
|
|
127
|
+
const configFromBlockchains = config.from?.blockchains || [];
|
|
128
|
+
const configToBlockchains = config.to?.blockchains || [];
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
* Empty array means all blockchains. So if any of to or from has an empty array,
|
|
132
|
+
* it means all blockchains is available to use and there is no limitation from config.
|
|
133
|
+
*/
|
|
134
|
+
if (!configFromBlockchains.length || !configToBlockchains.length) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
const blockchains = [...configFromBlockchains, ...configToBlockchains];
|
|
138
|
+
|
|
139
|
+
const supportedBlockchains = new Set(blockchains);
|
|
140
|
+
|
|
141
|
+
return Array.from(supportedBlockchains);
|
|
142
|
+
}
|
package/src/store/wallets.ts
CHANGED
|
@@ -220,13 +220,13 @@ export const useWalletsStore = createSelectors(
|
|
|
220
220
|
findToken
|
|
221
221
|
),
|
|
222
222
|
loading: false,
|
|
223
|
-
error: false,
|
|
224
223
|
}
|
|
225
224
|
: connectedWallet;
|
|
226
225
|
}
|
|
227
226
|
);
|
|
228
227
|
|
|
229
228
|
const balances = makeTokensBalance(connectedWallets);
|
|
229
|
+
|
|
230
230
|
return {
|
|
231
231
|
loading: false,
|
|
232
232
|
balances,
|
package/src/types/config.ts
CHANGED
|
@@ -139,7 +139,8 @@ export type Features = Partial<
|
|
|
139
139
|
| 'language'
|
|
140
140
|
| 'connectWalletButton'
|
|
141
141
|
| 'notification'
|
|
142
|
-
| 'liquiditySource'
|
|
142
|
+
| 'liquiditySource'
|
|
143
|
+
| 'customTokens',
|
|
143
144
|
'visible' | 'hidden'
|
|
144
145
|
>
|
|
145
146
|
> &
|
|
@@ -198,7 +199,9 @@ export type TrezorManifest = {
|
|
|
198
199
|
* - 'liquiditySource': Visibility state for liquidity source.
|
|
199
200
|
* - 'connectWalletButton': Visibility state for the wallet connect icon.
|
|
200
201
|
* - 'language': Visibility state for the language.
|
|
202
|
+
* - 'customTokens': Visibility state for the custom tokens.
|
|
201
203
|
* - 'experimentalRoute': Enablement state for the experimental route.
|
|
204
|
+
*
|
|
202
205
|
* @property {WidgetVariant} variant
|
|
203
206
|
* If it is expanded, multiple routes will show up on the home page;
|
|
204
207
|
* If it is full-expanded, multiple routes will show up on the home page with full routes;
|
package/src/utils/meta.ts
CHANGED
|
@@ -57,5 +57,16 @@ export function isTokenNative(
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export function createTokenHash(asset: Asset): TokenHash {
|
|
60
|
-
return `${asset.blockchain}-${asset.symbol}-${
|
|
60
|
+
return `${asset.blockchain.toLowerCase()}-${asset.symbol.toLowerCase()}-${(
|
|
61
|
+
asset.address ?? ''
|
|
62
|
+
).toLowerCase()}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function isValidTokenAddress(
|
|
66
|
+
chain: BlockchainMeta,
|
|
67
|
+
address: string
|
|
68
|
+
): boolean {
|
|
69
|
+
const regex = chain.addressPatterns;
|
|
70
|
+
const valid = regex.filter((r) => new RegExp(r).test(address)).length > 0;
|
|
71
|
+
return valid;
|
|
61
72
|
}
|
package/src/utils/quote.ts
CHANGED
|
@@ -25,12 +25,12 @@ import BigNumber from 'bignumber.js';
|
|
|
25
25
|
import { HIGH_PRIORITY_TAGS } from '../constants/quote';
|
|
26
26
|
import { HIGHT_PRICE_IMPACT, LOW_PRICE_IMPACT } from '../constants/routing';
|
|
27
27
|
import { HIGH_SLIPPAGE } from '../constants/swapSettings';
|
|
28
|
-
import { getUsdValue } from '../store/quote';
|
|
29
28
|
import { QuoteWarningType } from '../types';
|
|
30
29
|
|
|
31
30
|
import { areEqual } from './common';
|
|
32
31
|
import { createTokenHash, findBlockchain } from './meta';
|
|
33
32
|
import {
|
|
33
|
+
calcOutputUsdValue,
|
|
34
34
|
checkSlippageWarnings,
|
|
35
35
|
getMinRequiredSlippage,
|
|
36
36
|
getPercentageChange,
|
|
@@ -46,6 +46,13 @@ export function getQuoteToTokenUsdPrice(
|
|
|
46
46
|
return swaps[swaps.length - 1].to.usdPrice;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
export function getQuoteFromTokenUsdPrice(
|
|
50
|
+
quote: SelectedQuote | null
|
|
51
|
+
): number | null | undefined {
|
|
52
|
+
const swaps = quote?.swaps || [];
|
|
53
|
+
return swaps[0].from.usdPrice;
|
|
54
|
+
}
|
|
55
|
+
|
|
49
56
|
export function isNumberOfSwapsChanged(
|
|
50
57
|
quoteA: SelectedQuote,
|
|
51
58
|
quoteB: SelectedQuote
|
|
@@ -198,8 +205,14 @@ export function generateQuoteWarnings(
|
|
|
198
205
|
}
|
|
199
206
|
): QuoteWarning | null {
|
|
200
207
|
const { fromToken, toToken, findToken, userSlippage } = params;
|
|
201
|
-
const inputUsdValue =
|
|
202
|
-
|
|
208
|
+
const inputUsdValue = calcOutputUsdValue(
|
|
209
|
+
quote.requestAmount,
|
|
210
|
+
getQuoteFromTokenUsdPrice(quote) || fromToken?.usdPrice
|
|
211
|
+
);
|
|
212
|
+
const outputUsdValue = calcOutputUsdValue(
|
|
213
|
+
quote.outputAmount,
|
|
214
|
+
getQuoteToTokenUsdPrice(quote) || toToken?.usdPrice
|
|
215
|
+
);
|
|
203
216
|
|
|
204
217
|
if (!!quote && inputUsdValue && outputUsdValue) {
|
|
205
218
|
const priceImpact = getPriceImpact(
|
package/src/utils/settings.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Features } from '../types';
|
|
2
|
-
import type { SwapperMeta, SwapperType } from 'rango-sdk';
|
|
2
|
+
import type { SwapperMeta, SwapperType, Token } from 'rango-sdk';
|
|
3
3
|
|
|
4
4
|
import { removeDuplicateFrom } from './common';
|
|
5
5
|
|
|
@@ -75,3 +75,15 @@ export function isFeatureHidden(feature: keyof Features, features?: Features) {
|
|
|
75
75
|
export function isFeatureEnabled(feature: keyof Features, features?: Features) {
|
|
76
76
|
return features?.[feature] === 'enabled';
|
|
77
77
|
}
|
|
78
|
+
|
|
79
|
+
export const addCustomTokensToSupportedTokens = (
|
|
80
|
+
supportedTokens: Token[],
|
|
81
|
+
customTokens: Token[],
|
|
82
|
+
features?: Features
|
|
83
|
+
) => {
|
|
84
|
+
const isCustomTokensHidden = isFeatureHidden('customTokens', features);
|
|
85
|
+
|
|
86
|
+
return isCustomTokensHidden
|
|
87
|
+
? supportedTokens
|
|
88
|
+
: supportedTokens.concat(customTokens);
|
|
89
|
+
};
|
package/src/utils/swap.ts
CHANGED
|
@@ -31,7 +31,6 @@ import {
|
|
|
31
31
|
import BigNumber from 'bignumber.js';
|
|
32
32
|
import { PendingSwapNetworkStatus } from 'rango-types';
|
|
33
33
|
|
|
34
|
-
import { isValidAddress } from '../components/ConfirmWalletsModal/ConfirmWallets.helpers';
|
|
35
34
|
import { errorMessages } from '../constants/errors';
|
|
36
35
|
import { swapButtonTitles } from '../constants/messages';
|
|
37
36
|
import { ZERO } from '../constants/numbers';
|
|
@@ -42,7 +41,7 @@ import {
|
|
|
42
41
|
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
43
42
|
} from '../constants/routing';
|
|
44
43
|
|
|
45
|
-
import { getBlockchainShortNameFor } from './meta';
|
|
44
|
+
import { getBlockchainShortNameFor, isValidTokenAddress } from './meta';
|
|
46
45
|
import { numberToString } from './numbers';
|
|
47
46
|
import { getPriceImpact, getRequiredBalanceOfWallet } from './quote';
|
|
48
47
|
import { getQuoteWallets } from './wallets';
|
|
@@ -250,13 +249,14 @@ export function canComputePriceImpact(
|
|
|
250
249
|
inputAmount: string,
|
|
251
250
|
usdValue: BigNumber | null
|
|
252
251
|
) {
|
|
252
|
+
const inputAmountNumber = parseFloat(inputAmount || '0');
|
|
253
|
+
|
|
253
254
|
return !(
|
|
255
|
+
quote &&
|
|
254
256
|
(!usdValue || usdValue.lte(ZERO)) &&
|
|
255
|
-
|
|
256
|
-
!!inputAmount &&
|
|
257
|
+
inputAmount &&
|
|
257
258
|
inputAmount !== '0' &&
|
|
258
|
-
|
|
259
|
-
!!quote
|
|
259
|
+
inputAmountNumber !== 0
|
|
260
260
|
);
|
|
261
261
|
}
|
|
262
262
|
|
|
@@ -748,7 +748,7 @@ export function isConfirmSwapDisabled(
|
|
|
748
748
|
|
|
749
749
|
const customDestinationIsValid =
|
|
750
750
|
customDestination && lastStepToBlockchain
|
|
751
|
-
?
|
|
751
|
+
? isValidTokenAddress(lastStepToBlockchain, customDestination)
|
|
752
752
|
: false;
|
|
753
753
|
|
|
754
754
|
return (
|