From 20f02e3f69ae34198426efc89d90e0682aa50b28 Mon Sep 17 00:00:00 2001 From: Danny Delott Date: Tue, 11 Feb 2025 15:35:18 -0800 Subject: [PATCH] Pull Hyperdrive Miles out of feature flag --- apps/hyperdrive-trading/src/routeTree.gen.ts | 342 +++++++++--------- .../src/ui/base/components/MultiSelect.tsx | 10 +- .../src/ui/portfolio/Portfolio.tsx | 12 +- .../ui/rewards/hooks/useClaimableRewards.ts | 12 +- 4 files changed, 189 insertions(+), 187 deletions(-) diff --git a/apps/hyperdrive-trading/src/routeTree.gen.ts b/apps/hyperdrive-trading/src/routeTree.gen.ts index 33328f2c5..91b9dc756 100644 --- a/apps/hyperdrive-trading/src/routeTree.gen.ts +++ b/apps/hyperdrive-trading/src/routeTree.gen.ts @@ -10,229 +10,229 @@ // Import Routes -import { Route as rootRoute } from './ui/routes/__root' -import { Route as RestrictedcountriesImport } from './ui/routes/restricted_countries' -import { Route as PortfolioImport } from './ui/routes/portfolio' -import { Route as PointsmarketsImport } from './ui/routes/points_markets' -import { Route as MintImport } from './ui/routes/mint' -import { Route as IneligibleImport } from './ui/routes/ineligible' -import { Route as ErrorImport } from './ui/routes/error' -import { Route as ChainlogImport } from './ui/routes/chainlog' -import { Route as IndexImport } from './ui/routes/index' -import { Route as MarketChainIdAddressImport } from './ui/routes/market.$chainId.$address' +import { Route as rootRoute } from "./ui/routes/__root"; +import { Route as ChainlogImport } from "./ui/routes/chainlog"; +import { Route as ErrorImport } from "./ui/routes/error"; +import { Route as IndexImport } from "./ui/routes/index"; +import { Route as IneligibleImport } from "./ui/routes/ineligible"; +import { Route as MarketChainIdAddressImport } from "./ui/routes/market.$chainId.$address"; +import { Route as MintImport } from "./ui/routes/mint"; +import { Route as PointsmarketsImport } from "./ui/routes/points_markets"; +import { Route as PortfolioImport } from "./ui/routes/portfolio"; +import { Route as RestrictedcountriesImport } from "./ui/routes/restricted_countries"; // Create/Update Routes const RestrictedcountriesRoute = RestrictedcountriesImport.update({ - id: '/restricted_countries', - path: '/restricted_countries', + id: "/restricted_countries", + path: "/restricted_countries", getParentRoute: () => rootRoute, -} as any) +} as any); const PortfolioRoute = PortfolioImport.update({ - id: '/portfolio', - path: '/portfolio', + id: "/portfolio", + path: "/portfolio", getParentRoute: () => rootRoute, -} as any) +} as any); const PointsmarketsRoute = PointsmarketsImport.update({ - id: '/points_markets', - path: '/points_markets', + id: "/points_markets", + path: "/points_markets", getParentRoute: () => rootRoute, -} as any) +} as any); const MintRoute = MintImport.update({ - id: '/mint', - path: '/mint', + id: "/mint", + path: "/mint", getParentRoute: () => rootRoute, -} as any) +} as any); const IneligibleRoute = IneligibleImport.update({ - id: '/ineligible', - path: '/ineligible', + id: "/ineligible", + path: "/ineligible", getParentRoute: () => rootRoute, -} as any) +} as any); const ErrorRoute = ErrorImport.update({ - id: '/error', - path: '/error', + id: "/error", + path: "/error", getParentRoute: () => rootRoute, -} as any) +} as any); const ChainlogRoute = ChainlogImport.update({ - id: '/chainlog', - path: '/chainlog', + id: "/chainlog", + path: "/chainlog", getParentRoute: () => rootRoute, -} as any) +} as any); const IndexRoute = IndexImport.update({ - id: '/', - path: '/', + id: "/", + path: "/", getParentRoute: () => rootRoute, -} as any) +} as any); const MarketChainIdAddressRoute = MarketChainIdAddressImport.update({ - id: '/market/$chainId/$address', - path: '/market/$chainId/$address', + id: "/market/$chainId/$address", + path: "/market/$chainId/$address", getParentRoute: () => rootRoute, -} as any) +} as any); // Populate the FileRoutesByPath interface -declare module '@tanstack/react-router' { +declare module "@tanstack/react-router" { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexImport - parentRoute: typeof rootRoute - } - '/chainlog': { - id: '/chainlog' - path: '/chainlog' - fullPath: '/chainlog' - preLoaderRoute: typeof ChainlogImport - parentRoute: typeof rootRoute - } - '/error': { - id: '/error' - path: '/error' - fullPath: '/error' - preLoaderRoute: typeof ErrorImport - parentRoute: typeof rootRoute - } - '/ineligible': { - id: '/ineligible' - path: '/ineligible' - fullPath: '/ineligible' - preLoaderRoute: typeof IneligibleImport - parentRoute: typeof rootRoute - } - '/mint': { - id: '/mint' - path: '/mint' - fullPath: '/mint' - preLoaderRoute: typeof MintImport - parentRoute: typeof rootRoute - } - '/points_markets': { - id: '/points_markets' - path: '/points_markets' - fullPath: '/points_markets' - preLoaderRoute: typeof PointsmarketsImport - parentRoute: typeof rootRoute - } - '/portfolio': { - id: '/portfolio' - path: '/portfolio' - fullPath: '/portfolio' - preLoaderRoute: typeof PortfolioImport - parentRoute: typeof rootRoute - } - '/restricted_countries': { - id: '/restricted_countries' - path: '/restricted_countries' - fullPath: '/restricted_countries' - preLoaderRoute: typeof RestrictedcountriesImport - parentRoute: typeof rootRoute - } - '/market/$chainId/$address': { - id: '/market/$chainId/$address' - path: '/market/$chainId/$address' - fullPath: '/market/$chainId/$address' - preLoaderRoute: typeof MarketChainIdAddressImport - parentRoute: typeof rootRoute - } + "/": { + id: "/"; + path: "/"; + fullPath: "/"; + preLoaderRoute: typeof IndexImport; + parentRoute: typeof rootRoute; + }; + "/chainlog": { + id: "/chainlog"; + path: "/chainlog"; + fullPath: "/chainlog"; + preLoaderRoute: typeof ChainlogImport; + parentRoute: typeof rootRoute; + }; + "/error": { + id: "/error"; + path: "/error"; + fullPath: "/error"; + preLoaderRoute: typeof ErrorImport; + parentRoute: typeof rootRoute; + }; + "/ineligible": { + id: "/ineligible"; + path: "/ineligible"; + fullPath: "/ineligible"; + preLoaderRoute: typeof IneligibleImport; + parentRoute: typeof rootRoute; + }; + "/mint": { + id: "/mint"; + path: "/mint"; + fullPath: "/mint"; + preLoaderRoute: typeof MintImport; + parentRoute: typeof rootRoute; + }; + "/points_markets": { + id: "/points_markets"; + path: "/points_markets"; + fullPath: "/points_markets"; + preLoaderRoute: typeof PointsmarketsImport; + parentRoute: typeof rootRoute; + }; + "/portfolio": { + id: "/portfolio"; + path: "/portfolio"; + fullPath: "/portfolio"; + preLoaderRoute: typeof PortfolioImport; + parentRoute: typeof rootRoute; + }; + "/restricted_countries": { + id: "/restricted_countries"; + path: "/restricted_countries"; + fullPath: "/restricted_countries"; + preLoaderRoute: typeof RestrictedcountriesImport; + parentRoute: typeof rootRoute; + }; + "/market/$chainId/$address": { + id: "/market/$chainId/$address"; + path: "/market/$chainId/$address"; + fullPath: "/market/$chainId/$address"; + preLoaderRoute: typeof MarketChainIdAddressImport; + parentRoute: typeof rootRoute; + }; } } // Create and export the route tree export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/chainlog': typeof ChainlogRoute - '/error': typeof ErrorRoute - '/ineligible': typeof IneligibleRoute - '/mint': typeof MintRoute - '/points_markets': typeof PointsmarketsRoute - '/portfolio': typeof PortfolioRoute - '/restricted_countries': typeof RestrictedcountriesRoute - '/market/$chainId/$address': typeof MarketChainIdAddressRoute + "/": typeof IndexRoute; + "/chainlog": typeof ChainlogRoute; + "/error": typeof ErrorRoute; + "/ineligible": typeof IneligibleRoute; + "/mint": typeof MintRoute; + "/points_markets": typeof PointsmarketsRoute; + "/portfolio": typeof PortfolioRoute; + "/restricted_countries": typeof RestrictedcountriesRoute; + "/market/$chainId/$address": typeof MarketChainIdAddressRoute; } export interface FileRoutesByTo { - '/': typeof IndexRoute - '/chainlog': typeof ChainlogRoute - '/error': typeof ErrorRoute - '/ineligible': typeof IneligibleRoute - '/mint': typeof MintRoute - '/points_markets': typeof PointsmarketsRoute - '/portfolio': typeof PortfolioRoute - '/restricted_countries': typeof RestrictedcountriesRoute - '/market/$chainId/$address': typeof MarketChainIdAddressRoute + "/": typeof IndexRoute; + "/chainlog": typeof ChainlogRoute; + "/error": typeof ErrorRoute; + "/ineligible": typeof IneligibleRoute; + "/mint": typeof MintRoute; + "/points_markets": typeof PointsmarketsRoute; + "/portfolio": typeof PortfolioRoute; + "/restricted_countries": typeof RestrictedcountriesRoute; + "/market/$chainId/$address": typeof MarketChainIdAddressRoute; } export interface FileRoutesById { - __root__: typeof rootRoute - '/': typeof IndexRoute - '/chainlog': typeof ChainlogRoute - '/error': typeof ErrorRoute - '/ineligible': typeof IneligibleRoute - '/mint': typeof MintRoute - '/points_markets': typeof PointsmarketsRoute - '/portfolio': typeof PortfolioRoute - '/restricted_countries': typeof RestrictedcountriesRoute - '/market/$chainId/$address': typeof MarketChainIdAddressRoute + __root__: typeof rootRoute; + "/": typeof IndexRoute; + "/chainlog": typeof ChainlogRoute; + "/error": typeof ErrorRoute; + "/ineligible": typeof IneligibleRoute; + "/mint": typeof MintRoute; + "/points_markets": typeof PointsmarketsRoute; + "/portfolio": typeof PortfolioRoute; + "/restricted_countries": typeof RestrictedcountriesRoute; + "/market/$chainId/$address": typeof MarketChainIdAddressRoute; } export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath + fileRoutesByFullPath: FileRoutesByFullPath; fullPaths: - | '/' - | '/chainlog' - | '/error' - | '/ineligible' - | '/mint' - | '/points_markets' - | '/portfolio' - | '/restricted_countries' - | '/market/$chainId/$address' - fileRoutesByTo: FileRoutesByTo + | "/" + | "/chainlog" + | "/error" + | "/ineligible" + | "/mint" + | "/points_markets" + | "/portfolio" + | "/restricted_countries" + | "/market/$chainId/$address"; + fileRoutesByTo: FileRoutesByTo; to: - | '/' - | '/chainlog' - | '/error' - | '/ineligible' - | '/mint' - | '/points_markets' - | '/portfolio' - | '/restricted_countries' - | '/market/$chainId/$address' + | "/" + | "/chainlog" + | "/error" + | "/ineligible" + | "/mint" + | "/points_markets" + | "/portfolio" + | "/restricted_countries" + | "/market/$chainId/$address"; id: - | '__root__' - | '/' - | '/chainlog' - | '/error' - | '/ineligible' - | '/mint' - | '/points_markets' - | '/portfolio' - | '/restricted_countries' - | '/market/$chainId/$address' - fileRoutesById: FileRoutesById + | "__root__" + | "/" + | "/chainlog" + | "/error" + | "/ineligible" + | "/mint" + | "/points_markets" + | "/portfolio" + | "/restricted_countries" + | "/market/$chainId/$address"; + fileRoutesById: FileRoutesById; } export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - ChainlogRoute: typeof ChainlogRoute - ErrorRoute: typeof ErrorRoute - IneligibleRoute: typeof IneligibleRoute - MintRoute: typeof MintRoute - PointsmarketsRoute: typeof PointsmarketsRoute - PortfolioRoute: typeof PortfolioRoute - RestrictedcountriesRoute: typeof RestrictedcountriesRoute - MarketChainIdAddressRoute: typeof MarketChainIdAddressRoute + IndexRoute: typeof IndexRoute; + ChainlogRoute: typeof ChainlogRoute; + ErrorRoute: typeof ErrorRoute; + IneligibleRoute: typeof IneligibleRoute; + MintRoute: typeof MintRoute; + PointsmarketsRoute: typeof PointsmarketsRoute; + PortfolioRoute: typeof PortfolioRoute; + RestrictedcountriesRoute: typeof RestrictedcountriesRoute; + MarketChainIdAddressRoute: typeof MarketChainIdAddressRoute; } const rootRouteChildren: RootRouteChildren = { @@ -245,11 +245,11 @@ const rootRouteChildren: RootRouteChildren = { PortfolioRoute: PortfolioRoute, RestrictedcountriesRoute: RestrictedcountriesRoute, MarketChainIdAddressRoute: MarketChainIdAddressRoute, -} +}; export const routeTree = rootRoute ._addFileChildren(rootRouteChildren) - ._addFileTypes() + ._addFileTypes(); /* ROUTE_MANIFEST_START { diff --git a/apps/hyperdrive-trading/src/ui/base/components/MultiSelect.tsx b/apps/hyperdrive-trading/src/ui/base/components/MultiSelect.tsx index a45fa8f8b..0e7626152 100644 --- a/apps/hyperdrive-trading/src/ui/base/components/MultiSelect.tsx +++ b/apps/hyperdrive-trading/src/ui/base/components/MultiSelect.tsx @@ -102,7 +102,7 @@ export function MultiSelect({ title={selected.length ? "Deselect all" : "Select all"} onClick={() => onChange( - selected.length ? [] : options.map(({ value }) => value) + selected.length ? [] : options.map(({ value }) => value), ) } > @@ -112,7 +112,7 @@ export function MultiSelect({ { "!fill-aquamarine opacity-100 group-hover:-translate-y-1 group-hover:!opacity-0": selected.length, - } + }, )} /> ({ { "group-hover:translate-y-0 group-hover:opacity-100": selected.length, - } + }, )} /> @@ -141,9 +141,9 @@ export function MultiSelect({ onChange( isSelected ? selected.filter( - (optionValue) => optionValue !== option.value + (optionValue) => optionValue !== option.value, ) - : [...selected, option.value] + : [...selected, option.value], ); }} className="group flex min-w-max cursor-pointer items-center justify-between gap-3 whitespace-nowrap pl-4 pr-2 text-left" diff --git a/apps/hyperdrive-trading/src/ui/portfolio/Portfolio.tsx b/apps/hyperdrive-trading/src/ui/portfolio/Portfolio.tsx index 3c1e4b546..e93be7308 100644 --- a/apps/hyperdrive-trading/src/ui/portfolio/Portfolio.tsx +++ b/apps/hyperdrive-trading/src/ui/portfolio/Portfolio.tsx @@ -1,7 +1,6 @@ import { Navigate, useNavigate, useSearch } from "@tanstack/react-router"; import { ReactElement } from "react"; import { Tabs } from "src/ui/base/components/Tabs/Tabs"; -import { useFeatureFlag } from "src/ui/base/featureFlags/featureFlags"; import { OpenLongsContainer } from "src/ui/portfolio/longs/LongsContainer"; import { LpAndWithdrawalSharesContainer } from "src/ui/portfolio/lp/LpAndWithdrawalSharesContainer"; import { RewardsContainer } from "src/ui/portfolio/rewards/RewardsContainer"; @@ -28,8 +27,6 @@ export function Portfolio(): ReactElement { const navigate = useNavigate({ from: PORTFOLIO_ROUTE }); - const { isFlagEnabled: isPortfolioRewardsFeatureFlagEnabled } = - useFeatureFlag("portfolio-rewards"); const tabs = [ { id: "longs", @@ -61,9 +58,7 @@ export function Portfolio(): ReactElement { }); }, }, - ]; - if (isPortfolioRewardsFeatureFlagEnabled) { - tabs.push({ + { id: "rewards", content: , label: "Rewards", @@ -72,8 +67,9 @@ export function Portfolio(): ReactElement { search: (prev) => ({ ...prev, position: "rewards" }), }); }, - }); - } + }, + ]; + return (
{!accountFromRoute && connectedAccount ? ( diff --git a/apps/hyperdrive-trading/src/ui/rewards/hooks/useClaimableRewards.ts b/apps/hyperdrive-trading/src/ui/rewards/hooks/useClaimableRewards.ts index ac11efc5d..12cc97c23 100644 --- a/apps/hyperdrive-trading/src/ui/rewards/hooks/useClaimableRewards.ts +++ b/apps/hyperdrive-trading/src/ui/rewards/hooks/useClaimableRewards.ts @@ -5,6 +5,7 @@ import { makeQueryKey2 } from "src/base/makeQueryKey"; import { rewardsFork } from "src/chains/rewardsFork"; import { ClaimableReward } from "src/rewards/ClaimableReward"; import { HyperdriveRewardsApi } from "src/rewards/generated/HyperdriveRewardsApi"; +import { useFeatureFlag } from "src/ui/base/featureFlags/featureFlags"; import { Address, Hash } from "viem"; import { gnosis } from "viem/chains"; import { usePublicClient } from "wagmi"; @@ -19,6 +20,8 @@ export function useClaimableRewards({ } { const publicClient = usePublicClient(); const queryEnabled = !!account && !!publicClient; + const { isFlagEnabled: isHyperdriveApiRewardsEnabled } = + useFeatureFlag("portfolio-rewards"); const { data: rewards, status: rewardsStatus } = useQuery({ queryKey: makeQueryKey2({ namespace: "rewards", @@ -28,10 +31,13 @@ export function useClaimableRewards({ enabled: queryEnabled, queryFn: queryEnabled ? async () => { - const hyperdriveRewards = await fetchHyperdriveRewardApi(account); - const mileRewards = await fetchMileRewards(account); - const allRewards = [...hyperdriveRewards, ...mileRewards]; + + const allRewards = [...mileRewards]; + if (isHyperdriveApiRewardsEnabled) { + const hyperdriveRewards = await fetchHyperdriveRewardApi(account); + allRewards.push(...hyperdriveRewards); + } return allRewards; }