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

feat(wallet-dashboard): add feature flags for migration & supply increase vesting #3670

Merged
merged 16 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
6 changes: 6 additions & 0 deletions apps/apps-backend/src/features/features.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export class FeaturesController {
[Feature.AccountFinder]: {
defaultValue: false,
},
[Feature.WalletDashboardMigration]: {
defaultValue: false,
},
[Feature.WalletDashboardSupplyIncreaseVesting]: {
defaultValue: false,
},
},
dateUpdated: new Date().toISOString(),
};
Expand Down
2 changes: 2 additions & 0 deletions apps/core/src/constants/features.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ export enum Feature {
NetworkOutageOverride = 'network-outage-override',
ModuleSourceVerification = 'module-source-verification',
WalletEffectsOnlySharedTransaction = 'wallet-effects-only-shared-transaction',
StardustMigration = 'migration',
SupplyIncreaseVesting = 'supply-increase-vesting',
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@
import { PROTECTED_ROUTES } from '@/lib/constants/routes.constants';
import { IotaLogoMark } from '@iota/ui-icons';
import { SidebarItem } from './SidebarItem';
import { Feature } from '@iota/core';
import { useFeature } from '@growthbook/growthbook-react';

export function Sidebar() {
const featureFlags = {
Migrations: useFeature<boolean>(Feature.StardustMigration).value,
Vesting: useFeature<boolean>(Feature.SupplyIncreaseVesting).value,
};

const filteredRoutes = PROTECTED_ROUTES.filter(({ title }) => {
return title in featureFlags ? featureFlags[title as keyof typeof featureFlags] : true;
});

return (
<nav className="flex h-screen flex-col items-center gap-y-2xl bg-neutral-100 py-xl dark:bg-neutral-6">
<IotaLogoMark className="h-10 w-10 text-neutral-10 dark:text-neutral-92" />
<div className="flex flex-col gap-y-xs">
{PROTECTED_ROUTES.map((route) => (
{filteredRoutes.map((route) => (
<SidebarItem key={route.path} {...route} />
))}
</div>
Expand Down
15 changes: 15 additions & 0 deletions apps/wallet-dashboard/app/(protected)/migrations/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
'use client';

import { useFeature } from '@growthbook/growthbook-react';
import { Feature } from '@iota/core';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';

function MigrationDashboardPage(): JSX.Element {
const router = useRouter();
const stardustMigrationEnabled = useFeature<boolean>(Feature.StardustMigration).value;

useEffect(() => {
if (!stardustMigrationEnabled) {
router.push('/');
}
}, [stardustMigrationEnabled, router]);

return (
<div className="flex items-center justify-center pt-12">
<h1>MIGRATIONS</h1>
Expand Down
13 changes: 13 additions & 0 deletions apps/wallet-dashboard/app/(protected)/vesting/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
TimelockedStakedObjectsGrouped,
} from '@/lib/utils';
import { NotificationType } from '@/stores/notificationStore';
import { useFeature } from '@growthbook/growthbook-react';
import {
Feature,
TIMELOCK_IOTA_TYPE,
useGetActiveValidatorsInfo,
useGetAllOwnedObjects,
Expand All @@ -24,11 +26,14 @@ import {
import { useCurrentAccount, useIotaClient, useSignAndExecuteTransaction } from '@iota/dapp-kit';
import { IotaValidatorSummary } from '@iota/iota-sdk/client';
import { useQueryClient } from '@tanstack/react-query';
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';

function VestingDashboardPage(): JSX.Element {
const account = useCurrentAccount();
const queryClient = useQueryClient();
const iotaClient = useIotaClient();
const router = useRouter();
const { addNotification } = useNotifications();
const { openPopup, closePopup } = usePopups();
const { data: currentEpochMs } = useGetCurrentEpochStartTimestamp();
Expand All @@ -39,6 +44,8 @@ function VestingDashboardPage(): JSX.Element {
const { data: timelockedStakedObjects } = useGetTimelockedStakedObjects(account?.address || '');
const { mutateAsync: signAndExecuteTransaction } = useSignAndExecuteTransaction();

const supplyIncreaseVestingEnabled = useFeature<boolean>(Feature.SupplyIncreaseVesting).value;

const timelockedMapped = mapTimelockObjects(timelockedObjects || []);
const timelockedstakedMapped = formatDelegatedTimelockedStake(timelockedStakedObjects || []);

Expand Down Expand Up @@ -134,6 +141,12 @@ function VestingDashboardPage(): JSX.Element {
);
}

useEffect(() => {
if (!supplyIncreaseVestingEnabled) {
router.push('/');
}
}, [router, supplyIncreaseVestingEnabled]);

return (
<div className="flex flex-row">
<div className="flex w-1/2 flex-col items-center justify-center space-y-4 pt-12">
Expand Down
50 changes: 26 additions & 24 deletions apps/wallet-dashboard/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
import { Inter } from 'next/font/google';

import './globals.css';

import { GrowthBookProvider } from '@growthbook/growthbook-react';
import { IotaClientProvider, lightTheme, darkTheme, WalletProvider } from '@iota/dapp-kit';
import { getAllNetworks, getDefaultNetwork } from '@iota/iota-sdk/client';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React from 'react';

import '@iota/dapp-kit/dist/index.css';
import { Popup, PopupProvider } from '@/components/Popup';
import { growthbook } from '@/lib/utils';
import { Toaster } from 'react-hot-toast';

const inter = Inter({ subsets: ['latin'] });
growthbook.init();

export default function RootLayout({
children,
Expand All @@ -31,28 +32,29 @@ export default function RootLayout({
return (
<html lang="en">
<body className={inter.className} ref={bodyRef}>
<QueryClientProvider client={queryClient}>
<IotaClientProvider networks={allNetworks} defaultNetwork={defaultNetwork}>
<WalletProvider
autoConnect={true}
theme={[
{
variables: lightTheme,
},
{
selector: '.dark',
variables: darkTheme,
},
]}
>
<PopupProvider>
{children}
<Toaster />
<Popup />
</PopupProvider>
</WalletProvider>
</IotaClientProvider>
</QueryClientProvider>
<GrowthBookProvider growthbook={growthbook}>
<QueryClientProvider client={queryClient}>
<IotaClientProvider networks={allNetworks} defaultNetwork={defaultNetwork}>
<WalletProvider
theme={[
{
variables: lightTheme,
},
{
selector: '.dark',
variables: darkTheme,
},
]}
>
<PopupProvider>
{children}
<Toaster />
<Popup />
</PopupProvider>
</WalletProvider>
</IotaClientProvider>
</QueryClientProvider>
</GrowthBookProvider>
</body>
</html>
);
Expand Down
12 changes: 12 additions & 0 deletions apps/wallet-dashboard/lib/utils/growthbook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { GrowthBook } from '@growthbook/growthbook';
import { getAppsBackend } from '@iota/iota-sdk/client';

export const growthbook = new GrowthBook({
// If you want to develop locally, you can set the API host to this:
evavirseda marked this conversation as resolved.
Show resolved Hide resolved
apiHost: getAppsBackend(),
clientKey: process.env.NODE_ENV === 'production' ? 'production' : 'development',
enableDevMode: process.env.NODE_ENV === 'development',
});
1 change: 1 addition & 0 deletions apps/wallet-dashboard/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './vesting';
export * from './time';
export * from './timelock';
export * from './transaction';
export * from './growthbook';
2 changes: 2 additions & 0 deletions apps/wallet-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"node": ">= v18.17.0"
},
"dependencies": {
"@growthbook/growthbook": "^1.0.0",
"@growthbook/growthbook-react": "^1.0.0",
"@iota/apps-ui-kit": "workspace:*",
"@iota/core": "workspace:*",
"@iota/dapp-kit": "workspace:*",
Expand Down
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading