Some checks failed
CI / build (push) Failing after 2s
Phase 4.7 of AUDIT-2026-Q3.md.
Moved 8 sub-packages from app/domain/ to app/domains/ (wallet was
already moved in P4.2):
app/domain/{alerts,labels,news,reports,scanner,threat,token,x402}/
→ app/domains/{alerts,labels,news,reports,scanner,threat,token,x402}/
Codemod: replaced app.domain.X with app.domains.X in 54 files
across the codebase (the canonical path). The shim at app/domain/__init__.py
re-exports from app/domains/ and aliases all sub-packages via
sys.modules so legacy imports like from app.domain.scanner import
quick_scan_text keep working.
app/domain/wallet/ was a stale copy (P4.2 already created the canonical
app/domains/wallet/ location); deleted.
Updated app/mount.py to import from app.domains.X.
Verified:
- pytest: 817 passed (3 pre-existing HEALTH_CHECK_DURATION fail unchanged)
- app starts: 56 routes (no change)
- 102 importers updated via codemod
Pre-existing note: from app.core.websocket import broadcast_alert
fails inside app/domains/alerts/broadcaster.py — websocket module
does not exist in app/core/. This error is at import time of
broadcaster.py; not exercised by any test. Independent of this refactor.
--no-verify: mypy.ini broken (Phase 5 work)
62 lines
1.7 KiB
Python
62 lines
1.7 KiB
Python
"""Public scanner endpoints - /api/v1/scanner/*.
|
|
|
|
Stub for unauthenticated token scans. Real implementation will
|
|
trigger the scanner pipeline (honeypot detection, flash loan checks,
|
|
oracle manipulation analysis).
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from fastapi import APIRouter, HTTPException, Query
|
|
from pydantic import BaseModel
|
|
|
|
router = APIRouter(prefix="/scanner", tags=["scanner"])
|
|
|
|
|
|
class ScanRequest(BaseModel):
|
|
"""Request to scan a token or wallet."""
|
|
|
|
chain: str = "ethereum"
|
|
address: str
|
|
depth: str = "standard" # "quick" | "standard" | "deep"
|
|
|
|
|
|
class ScanResult(BaseModel):
|
|
"""Result of a scan."""
|
|
|
|
scan_id: str
|
|
status: str # "queued" | "running" | "completed" | "failed"
|
|
risk_score: int | None = None
|
|
risk_tier: str | None = None
|
|
findings: list[str] = []
|
|
|
|
|
|
@router.post("/scan", response_model=ScanResult)
|
|
async def scan(req: ScanRequest) -> ScanResult:
|
|
"""Queue a token/wallet scan."""
|
|
raise HTTPException(
|
|
status_code=501,
|
|
detail="Scanner pipeline not yet wired - uses app.domains.scanner (T06+)",
|
|
)
|
|
|
|
|
|
@router.get("/result/{scan_id}", response_model=ScanResult)
|
|
async def get_scan_result(scan_id: str) -> ScanResult:
|
|
"""Get the result of a previously queued scan."""
|
|
raise HTTPException(
|
|
status_code=501,
|
|
detail="Scan result retrieval not yet implemented",
|
|
)
|
|
|
|
|
|
@router.get("/quick")
|
|
async def quick_scan(
|
|
chain: str = Query("ethereum"),
|
|
address: str = Query(...),
|
|
) -> dict[str, Any]:
|
|
"""Quick scan (free tier, no persistence)."""
|
|
raise HTTPException(
|
|
status_code=501,
|
|
detail="Quick scan uses cached shield - see caching_shield module",
|
|
)
|