Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yeet staking banners #1734

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 0 additions & 74 deletions apps/extension/src/ui/apps/popup/components/StakingBanner.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 (
<div className="flex w-full flex-col gap-4">
{folder ? (
Expand All @@ -305,7 +296,6 @@ const Accounts = ({
<>
<AllAccountsHeader accounts={accounts} />
<NewFeaturesButton />
<StakingBanner addresses={addresses} />
</>
)}

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -19,47 +18,6 @@ import { useTokenBalancesSummary } from "../useTokenBalancesSummary"
import { NetworksLogoStack } from "./NetworksLogoStack"
import { usePortfolioNetworkIds } from "./usePortfolioNetworkIds"

const AssetRowStakingReminder = (props: ReturnType<typeof useShowStakingBanner>) => {
const { t } = useTranslation()

const { message, colours, handleClickStakingBanner, handleDismissStakingBanner } = props
const { token, summary } = useTokenBalancesSummary(props.balances)

if (!token || !summary) return null

return (
<div
className={classNames(
colours?.["text"],
colours?.["background"],
`flex h-[4.1rem] w-full cursor-pointer items-center justify-between rounded-t px-8 text-sm`,
)}
>
<button type="button" className="flex items-center gap-4" onClick={handleClickStakingBanner}>
<ZapIcon className="shrink-0" />{" "}
<div className="text-left">
<Trans
t={t}
components={{
Highlight: <span className="text-white" />,
LinkIcon: (
<span className="inline-flex shrink-0 flex-col justify-center">
<ExternalLinkIcon className="inline-block shrink-0" />
</span>
),
}}
defaults="<Highlight>Earn yield on your {{symbol}}.</Highlight> {{message}} <LinkIcon />"
values={{ symbol: token.symbol, message }}
/>
</div>
</button>
<button type="button" className="shrink-0">
<XIcon onClick={handleDismissStakingBanner} />
</button>
</div>
)
}

type AssetRowProps = {
balances: Balances
}
Expand All @@ -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 (
<div className="relative mb-4">
{stakingReminder.showBanner && <AssetRowStakingReminder {...stakingReminder} />}

<button
type="button"
className={classNames(
"text-body-secondary bg-grey-850 hover:bg-grey-800 group grid h-[6.6rem] w-full grid-cols-[40%_30%_30%] overflow-hidden text-left text-base",
stakingReminder.showBanner ? "rounded-b" : "rounded",
"text-body-secondary bg-grey-850 hover:bg-grey-800 group grid h-[6.6rem] w-full grid-cols-[40%_30%_30%] overflow-hidden rounded text-left text-base",
)}
onClick={handleClick}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@ import {
balancesHydrate$,
portfolioSelectedAccounts$,
remoteConfig$,
stakingBannerStore$,
usePortfolio,
} from "@ui/state"

import { usePortfolioNavigation } from "./usePortfolioNavigation"

const [usePreload] = bind(
combineLatest([
balancesHydrate$,
accounts$,
accountsCatalog$,
remoteConfig$,
stakingBannerStore$,
]),
combineLatest([balancesHydrate$, accounts$, accountsCatalog$, remoteConfig$]),
)

export const PortfolioContainer: FC<{ children: ReactNode; renderWhileLoading?: boolean }> = ({
Expand Down
48 changes: 0 additions & 48 deletions apps/extension/src/ui/domains/Staking/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,8 @@ import { Enum } from "@polkadot-api/substrate-bindings"
import { range } from "lodash"
import { Binary } from "polkadot-api"

import {
EVM_LSD_SUPPORTED_CHAINS,
EvmLsdSupportedChain,
NOM_POOL_SUPPORTED_CHAINS,
NomPoolSupportedChain,
StakingSupportedChain,
} from "@extension/core"
import { ScaleApi } from "@ui/util/scaleApi"

type Colours = {
text: string
background: string
}

export const colours: Record<StakingSupportedChain, Colours> = {
"polkadot": {
text: "text-[#cc2c75]",
background: "bg-[#260001]",
},
"kusama": {
text: "text-body-secondary",
background: "bg-[#303030]",
},
"aleph-zero": {
text: "text-[#e5ff57]",
background: "bg-[#2C2D30]",
},
"vara": {
text: "text-[#00a87a]",
background: "bg-[#002905]",
},
"avail": {
text: "text-[#D0E5FF]",
background: "bg-[#4E6786]",
},
"1": {
text: "text-[#8b93b4]",
background: "bg-[#151C2F]",
},
}

export const isNomPoolChain = (chainId: string): chainId is NomPoolSupportedChain =>
NOM_POOL_SUPPORTED_CHAINS.includes(chainId as NomPoolSupportedChain)

export const isEvmLsdChain = (networkId: string): networkId is EvmLsdSupportedChain =>
EVM_LSD_SUPPORTED_CHAINS.includes(networkId as EvmLsdSupportedChain)

export const isStakingSupportedChain = (chainId: string): chainId is StakingSupportedChain =>
isNomPoolChain(chainId) || isEvmLsdChain(chainId)

export const getStakingErasPerYear = (sapi: ScaleApi) => {
const MS_PER_YEAR = 1000n * 60n * 60n * 24n * 365n
const eraDuration = getStakingEraDurationMs(sapi)
Expand Down
46 changes: 0 additions & 46 deletions apps/extension/src/ui/domains/Staking/useShowStakingBanner.ts

This file was deleted.

Loading
Loading