Skip to content

PM-17: Feature Flag + Community Setting #13403

@mzparacha

Description

@mzparacha

Overview

Feature flag and community-level configuration for prediction markets.

Size: Medium
Depends on: PM-8 through PM-16
Blocks: nothing

Files to Create

  • libs/schemas/src/entities/community-prediction-market-settings.schemas.ts (or extend community schemas)

Files to Modify

  • packages/commonwealth/client/scripts/helpers/feature-flags.ts (add prediction_markets flag)
  • packages/commonwealth/client/vite.config.ts (expose FLAG_PREDICTION_MARKETS)
  • packages/commonwealth/server/config.ts (add FLAG_PREDICTION_MARKETS env var)

Acceptance Criteria

Feature Flag Setup

  • Feature flag FLAG_PREDICTION_MARKETS defined in feature-flags.ts using buildFlag
  • Flag exposed in vite.config.ts for frontend access
  • Flag toggleable per environment (dev/staging/prod)

UI Gating

All PM UI surfaces gated by useFlag('prediction_markets'):

  • Thread sidebar card (ViewThreadPage)
  • Thread creation button (NewThreadForm)
  • Explore page tab + AllTabContent section
  • Homepage + Community homepage sections
  • Sidebar navigation entries (governance + admin)
  • Routing (CommonDomainRoutes + CustomDomainRoutes)
  • Admin settings page
  • App page
  • Thread list badge/tag

Backend Behavior

  • API routes still functional when flag is off (flag only gates UI, not backend)

Community-Level Settings

  • Community-level setting: admin can enable/disable prediction markets per community
  • Default collateral token configurable per community (USDC default)

Implementation Pattern

Feature Flag Definition

// feature-flags.ts
export const predictionMarketsEnabled = buildFlag(
  'prediction_markets',
  false // default off
);

Frontend Usage

import { useFlag } from 'hooks/useFlag';

const Component = () => {
  const predictionMarketsEnabled = useFlag('prediction_markets');
  
  if (!predictionMarketsEnabled) return null;
  
  return <PredictionMarketsFeature />;
};

Community Settings Schema

// community-prediction-market-settings.schemas.ts
export const CommunityPredictionMarketSettings = z.object({
  enabled: z.boolean().default(false),
  default_collateral_token: z.string().default('USDC'),
  max_duration_days: z.number().min(1).max(90).default(90),
});

Related

Part of the Prediction Markets (Futarchy) Integration Plan. See common_knowledge/Prediction-Markets.md for full specification.

Metadata

Metadata

Assignees

Labels

ai-readyReady for AI implementationarea:uiFrontend/UI changespriority:highHigh priorityrisk:lowLow risk - safe for AItype:featureNew feature (creates feature/* branch)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions