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

export async function GET(
  _request: Request,
  context: { params: Promise<{ bondId: string }> | { bondId: string } },
): Promise<Response> {
  const closed = requireV3X402Release();
  if (closed) return closed;
  const { bondId } = await context.params;
  if (!V3_UINT.test(bondId)) return invalidV3Input('invalid_bond_id', 'Bond ID must be an unsigned decimal integer');
  return unavailableV3Read({
    route: '/api/v3/bonds/:bondId',
    resource: `/api/v3/bonds/${safePathSegment(bondId)}`,
    code: 'v3_bond_reader_unconfigured',
    message: 'Canonical V3 bond deployments and the bond read adapter are not configured',
  });
}
