From cbf7497e93841102361528fc1e5ea04734bbaeda Mon Sep 17 00:00:00 2001 From: Chid Gilovitz Date: Tue, 10 Dec 2024 10:33:00 +0800 Subject: [PATCH] chore: yeet staking banners (#1734) --- .../apps/popup/components/StakingBanner.tsx | 74 --------- .../pages/Portfolio/PortfolioAccounts.tsx | 10 -- .../AssetsTable/DashboardAssetRow.tsx | 53 +------ .../domains/Portfolio/PortfolioContainer.tsx | 9 +- .../src/ui/domains/Staking/helpers.ts | 48 ------ .../domains/Staking/useShowStakingBanner.ts | 46 ------ .../ui/domains/Staking/useStakingBanner.tsx | 135 ----------------- .../ui/hooks/__tests__/useAppState.spec.ts | 7 - apps/extension/src/ui/state/index.ts | 1 - apps/extension/src/ui/state/stakingBanner.ts | 8 - .../src/domains/app/popupSummaries.ts | 5 +- .../src/domains/app/store.app.ts | 4 - .../src/domains/staking/constants.ts | 39 ----- .../src/domains/staking/helpers.ts | 11 -- .../domains/staking/store.StakingBanners.ts | 15 -- .../src/domains/staking/types.ts | 4 - .../src/domains/staking/utils.ts | 143 ------------------ packages/extension-core/src/index.ts | 6 - packages/extension-core/src/types/domains.ts | 1 - 19 files changed, 5 insertions(+), 614 deletions(-) delete mode 100644 apps/extension/src/ui/apps/popup/components/StakingBanner.tsx delete mode 100644 apps/extension/src/ui/domains/Staking/useShowStakingBanner.ts delete mode 100644 apps/extension/src/ui/domains/Staking/useStakingBanner.tsx delete mode 100644 apps/extension/src/ui/state/stakingBanner.ts delete mode 100644 packages/extension-core/src/domains/staking/constants.ts delete mode 100644 packages/extension-core/src/domains/staking/helpers.ts delete mode 100644 packages/extension-core/src/domains/staking/store.StakingBanners.ts delete mode 100644 packages/extension-core/src/domains/staking/types.ts delete mode 100644 packages/extension-core/src/domains/staking/utils.ts diff --git a/apps/extension/src/ui/apps/popup/components/StakingBanner.tsx b/apps/extension/src/ui/apps/popup/components/StakingBanner.tsx deleted file mode 100644 index 44b449d001..0000000000 --- a/apps/extension/src/ui/apps/popup/components/StakingBanner.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import { ExternalLinkIcon, XIcon, ZapIcon } from "@talismn/icons" -import { MouseEventHandler, Suspense, useCallback, useMemo } from "react" -import { Trans, useTranslation } from "react-i18next" - -import { TALISMAN_WEB_APP_STAKING_URL } from "@extension/shared" -import { SuspenseTracker } from "@talisman/components/SuspenseTracker" -import { useStakingBanner } from "@ui/domains/Staking/useStakingBanner" -import { useAnalytics } from "@ui/hooks/useAnalytics" - -export const StakingBannerInner = ({ addresses }: { addresses: string[] }) => { - const { showStakingBanner, dismissStakingBanner } = useStakingBanner() - const { genericEvent } = useAnalytics() - const { t } = useTranslation() - - const showNomPoolStakingBanner = useMemo( - () => showStakingBanner({ addresses }), - [addresses, showStakingBanner], - ) - - const handleClickStakingBanner = useCallback(() => { - window.open(TALISMAN_WEB_APP_STAKING_URL) - genericEvent("open web app staking from banner", { from: "popup" }) - }, [genericEvent]) - - const handleDismissStakingBanner: MouseEventHandler = useCallback( - (e) => { - e.preventDefault() - e.stopPropagation() - dismissStakingBanner() - genericEvent("dismiss staking banner", { from: "popup" }) - }, - [genericEvent, dismissStakingBanner], - ) - - return ( - <> - {showNomPoolStakingBanner && ( - - )} - - ) -} - -export const StakingBanner = ({ addresses }: { addresses: string[] }) => ( - }> - - -) diff --git a/apps/extension/src/ui/apps/popup/pages/Portfolio/PortfolioAccounts.tsx b/apps/extension/src/ui/apps/popup/pages/Portfolio/PortfolioAccounts.tsx index 24dd9adf05..7252975df8 100644 --- a/apps/extension/src/ui/apps/popup/pages/Portfolio/PortfolioAccounts.tsx +++ b/apps/extension/src/ui/apps/popup/pages/Portfolio/PortfolioAccounts.tsx @@ -28,7 +28,6 @@ import { api } from "@ui/api" import { AnalyticsPage, sendAnalyticsEvent } from "@ui/api/analytics" import { AllAccountsHeader } from "@ui/apps/popup/components/AllAccountsHeader" import { NewFeaturesButton } from "@ui/apps/popup/components/NewFeaturesButton" -import { StakingBanner } from "@ui/apps/popup/components/StakingBanner" import { AccountFolderIcon } from "@ui/domains/Account/AccountFolderIcon" import { AccountIconCopyAddressButton } from "@ui/domains/Account/AccountIconCopyAddressButton" import { AccountsLogoStack } from "@ui/domains/Account/AccountsLogoStack" @@ -183,9 +182,6 @@ const AccountButton: FC<{ option: AccountAccountOption }> = ({ option }) => { ) } -const accountTypeGuard = (option: AccountOption): option is AccountAccountOption => - option.type === "account" - const AccountsToolbar = () => { const { t } = useTranslation() const navigate = useNavigate() @@ -292,11 +288,6 @@ const Accounts = ({ const hasPortfolioOptions = portfolioOptions.length > 0 const hasWatchedOptions = watchedOptions.length > 0 - const addresses = useMemo( - () => portfolioOptions.filter(accountTypeGuard).map(({ address }) => address), - [portfolioOptions], - ) - return (
{folder ? ( @@ -305,7 +296,6 @@ const Accounts = ({ <> - )} diff --git a/apps/extension/src/ui/domains/Portfolio/AssetsTable/DashboardAssetRow.tsx b/apps/extension/src/ui/domains/Portfolio/AssetsTable/DashboardAssetRow.tsx index b038083fee..9c28abab46 100644 --- a/apps/extension/src/ui/domains/Portfolio/AssetsTable/DashboardAssetRow.tsx +++ b/apps/extension/src/ui/domains/Portfolio/AssetsTable/DashboardAssetRow.tsx @@ -1,13 +1,12 @@ -import { ExternalLinkIcon, XIcon, ZapFastIcon, ZapIcon } from "@talismn/icons" +import { ZapFastIcon } from "@talismn/icons" import { classNames } from "@talismn/util" import { useCallback } from "react" -import { Trans, useTranslation } from "react-i18next" +import { useTranslation } from "react-i18next" import { Balances } from "@extension/core" import { Fiat } from "@ui/domains/Asset/Fiat" import { BondPillButton } from "@ui/domains/Staking/Bond/BondPillButton" import { useBondButton } from "@ui/domains/Staking/Bond/useBondButton" -import { useShowStakingBanner } from "@ui/domains/Staking/useShowStakingBanner" import { useAnalytics } from "@ui/hooks/useAnalytics" import { useBalancesStatus } from "@ui/hooks/useBalancesStatus" import { useNavigateWithQuery } from "@ui/hooks/useNavigateWithQuery" @@ -19,47 +18,6 @@ import { useTokenBalancesSummary } from "../useTokenBalancesSummary" import { NetworksLogoStack } from "./NetworksLogoStack" import { usePortfolioNetworkIds } from "./usePortfolioNetworkIds" -const AssetRowStakingReminder = (props: ReturnType) => { - const { t } = useTranslation() - - const { message, colours, handleClickStakingBanner, handleDismissStakingBanner } = props - const { token, summary } = useTokenBalancesSummary(props.balances) - - if (!token || !summary) return null - - return ( -
- - -
- ) -} - type AssetRowProps = { balances: Balances } @@ -84,19 +42,14 @@ export const AssetRow = ({ balances }: AssetRowProps) => { const { canBondNomPool } = useBondButton({ tokenId: token?.id, balances }) - const stakingReminder = useShowStakingBanner(balances) - if (!token || !summary) return null return (
- {stakingReminder.showBanner && } -