import { invalidV3Input, unavailableV3Read, V3_UINT } from '../../../_lib/http';
import { requireV3X402Release } from '../../../x402/_lib/release';

export async function GET(
  _request: Request,
  context: { params: Promise<{ proposalId: string }> | { proposalId: string } },
): Promise<Response> {
  const closed = requireV3X402Release();
  if (closed) return closed;
  const { proposalId } = await context.params;
  if (!V3_UINT.test(proposalId)) return invalidV3Input('invalid_proposal_id', 'Proposal ID must be an unsigned decimal integer');
  return unavailableV3Read({
    route: '/api/v3/governance/proposals/:proposalId',
    resource: `/api/v3/governance/proposals/${proposalId}`,
    code: 'v3_governance_reader_unconfigured',
    message: 'The V3 governance deployment and proposal reader are not configured',
  });
}
