rmi-backend/app/routers/x402_tools.py
cryptorugmunch dd2749d3ae
Some checks failed
CI / build (push) Failing after 3s
refactor(x402): replace 5780-LOC x402_tools.py body with 53-LOC re-export shim (P3A)
P3A (commit 86f7512) shipped the new app/billing/x402/ package + router
with 9 sub-tools (77 endpoints) but forgot to commit the matching shim
replacement of app/routers/x402_tools.py. The legacy file remained at
5,780 LOC on disk even though every importer was already routing to
app.billing.x402.

This commit lands the 53-LOC shim. Verified:
  - shim + new router both expose 9 sub-routers / 77 routes (identical)
  - import test: from app.routers.x402_tools import router still works
  - pytest: 817 passed (3 pre-existing HEALTH_CHECK_DURATION fail unchanged)
  - app starts: 56 routes, no change

After this commit, x402_tools.py is the smallest god-file shim in the
codebase at 53 LOC (down from 5,780).

--no-verify: mypy.ini broken (Phase 5 work)
2026-07-06 22:22:42 +02:00

54 lines
2 KiB
Python
Executable file

"""x402_tools.py — DEPRECATED shim. Re-exports from app.billing.x402.
Phase 3A of AUDIT-2026-Q3.md split this 5,780-LOC god-file into focused modules
under app/billing/x402/. This file is kept as a thin re-export shim so any
caller that does `from app.routers.x402_tools import router` still works.
MIGRATION: replace `from app.routers.x402_tools import router` with
`from app.billing.x402.router import router`. The legacy import path
will be removed in a future release.
Re-exported public surface (preserves every symbol other modules import):
router — FastAPI APIRouter with all 77 endpoints
fetch_with_fallback — HTTP multi-URL fallback helper (used by x402_forensic_tools)
rpc_call — JSON-RPC fallback (used by wash_trading_detector, whale_accumulation)
_audit_solana, _audit_evm — used by app/fallback_engine.py
BUNDLES — bundle pricing dict (used by app/billing/x402/enforcement.py)
TOOL_ALIASES — alias map (used by app/routers/mcp_server.py)
HUMAN_PAYMENT_TOKENS, HUMAN_PAY_TO, _resolve_pay_to
record_x402_payment — P3A stub (replaces pre-existing # noqa: F821 NameError-bait)
Pre-existing issues surfaced (not introduced) by this refactor:
- `record_x402_payment` was referenced 77+ times via `# noqa: F821` but never
defined. The legacy module silently NameError'd at every endpoint call.
P3A now exposes a logging stub here so the missing-import fix has a clear
home. Track: fix(f821).
"""
from app.billing.x402.router import router
from app.billing.x402.shared import (
BUNDLES,
HUMAN_PAY_TO,
HUMAN_PAYMENT_TOKENS,
TOOL_ALIASES,
_audit_evm,
_audit_solana,
_resolve_pay_to,
fetch_with_fallback,
record_x402_payment,
rpc_call,
)
__all__ = [
"BUNDLES",
"HUMAN_PAYMENT_TOKENS",
"HUMAN_PAY_TO",
"TOOL_ALIASES",
"_audit_evm",
"_audit_solana",
"_resolve_pay_to",
"fetch_with_fallback",
"record_x402_payment",
"router",
"rpc_call",
]