refactor(domains): remove deprecated shim dirs + update remaining legacy imports (P4 cleanup)
This commit is contained in:
parent
757eefd227
commit
7bd204f9f5
8 changed files with 61 additions and 170 deletions
|
|
@ -46,7 +46,7 @@ def _get_tools() -> dict[str, Any]:
|
|||
|
||||
def _get_facilitator_count() -> int:
|
||||
try:
|
||||
from app.facilitators.base import get_registry
|
||||
from app.domains.billing.facilitators.base import get_registry
|
||||
|
||||
return len(get_registry().get_all())
|
||||
except Exception:
|
||||
|
|
@ -57,7 +57,7 @@ def _desc(tool_id: str, pricing: dict) -> str:
|
|||
d = pricing.get("description", "")
|
||||
if d and d != tool_id and len(d) > 10:
|
||||
return d
|
||||
FALLBACKS = {
|
||||
fallbacks = {
|
||||
"airdrop_check": "Verify airdrop legitimacy -- contract audit, distribution analysis, scam pattern detection. Know if an airdrop is real or a wallet drainer before connecting.",
|
||||
"airdrop_finder": "Discover active and upcoming airdrops across all major chains. Eligibility checks, value estimation, claim deadlines, and Sybil detection.",
|
||||
"all_in_one": "All-in-One Audit -- comprehensive security scan: rug pull, honeypot, clone detection, contract audit, and ownership analysis in a single call.",
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
"""billing — DEPRECATED shim. Use app.domains.billing.
|
||||
|
||||
Phase 4.1 of AUDIT-2026-Q3.md moved app/billing/ to app/domains/billing/.
|
||||
This shim re-exports the canonical surface and aliases submodules so that
|
||||
`from app.billing.x402.router import router` keeps working.
|
||||
|
||||
MIGRATION: replace `from app.billing.x402 import ...` with
|
||||
`from app.domains.billing.x402 import ...`.
|
||||
"""
|
||||
import sys as _sys
|
||||
from app.domains.billing import x402 as _x402
|
||||
from app.domains.billing.x402 import router as _router
|
||||
|
||||
# Public re-exports
|
||||
from app.domains.billing.x402 import ( # noqa: F401
|
||||
X402Enforcer,
|
||||
TOOL_PRICES,
|
||||
CHAIN_USDC,
|
||||
)
|
||||
|
||||
# Alias submodules so `from app.billing.x402.router import router` works
|
||||
_sys.modules["app.billing.x402"] = _x402
|
||||
_sys.modules["app.billing.x402.router"] = _router
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
"""domain - DEPRECATED shim. Use app.domains.
|
||||
|
||||
Phase 4.7 of AUDIT-2026-Q3.md renamed app/domain/ to app/domains/.
|
||||
This shim re-exports for legacy callers.
|
||||
"""
|
||||
import sys as _sys
|
||||
import importlib as _importlib
|
||||
|
||||
import app.domains as _new
|
||||
_sys.modules['app.domain'] = _new
|
||||
|
||||
_sys.modules['app.domain.alerts'] = _importlib.import_module('app.domains.alerts')
|
||||
_sys.modules['app.domain.auth'] = _importlib.import_module('app.domains.auth')
|
||||
_sys.modules['app.domain.billing'] = _importlib.import_module('app.domains.billing')
|
||||
_sys.modules['app.domain.databus'] = _importlib.import_module('app.domains.databus')
|
||||
_sys.modules['app.domain.labels'] = _importlib.import_module('app.domains.labels')
|
||||
_sys.modules['app.domain.news'] = _importlib.import_module('app.domains.news')
|
||||
_sys.modules['app.domain.reports'] = _importlib.import_module('app.domains.reports')
|
||||
_sys.modules['app.domain.scanner'] = _importlib.import_module('app.domains.scanner')
|
||||
_sys.modules['app.domain.telegram'] = _importlib.import_module('app.domains.telegram')
|
||||
_sys.modules['app.domain.threat'] = _importlib.import_module('app.domains.threat')
|
||||
_sys.modules['app.domain.token'] = _importlib.import_module('app.domains.token')
|
||||
_sys.modules['app.domain.tokens'] = _importlib.import_module('app.domains.tokens')
|
||||
_sys.modules['app.domain.wallet'] = _importlib.import_module('app.domains.wallet')
|
||||
_sys.modules['app.domain.x402'] = _importlib.import_module('app.domains.x402')
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
"""facilitators — DEPRECATED shim. Use app.domains.billing.facilitators.
|
||||
|
||||
Phase 4.1 of AUDIT-2026-Q3.md moved app/facilitators/ to
|
||||
app/domains/billing/facilitators/. This shim re-exports the public surface
|
||||
and aliases submodules so legacy imports like
|
||||
`from app.facilitators.base import Facilitator` keep working.
|
||||
|
||||
MIGRATION: replace `from app.facilitators.base import ...` with
|
||||
`from app.domains.billing.facilitators.base import ...`.
|
||||
"""
|
||||
import sys as _sys
|
||||
import importlib as _importlib
|
||||
|
||||
# Re-export public surface
|
||||
from app.domains.billing.facilitators import ( # noqa: F401
|
||||
Facilitator,
|
||||
FacilitatorRegistry,
|
||||
SettlementResult,
|
||||
VerificationResult,
|
||||
FacilitatorRouter,
|
||||
get_facilitator_router,
|
||||
)
|
||||
|
||||
# Alias submodules
|
||||
for _name in (
|
||||
"base", "config", "router",
|
||||
"asterpay", "bitcoin_selfverify", "cloudflare_x402", "coinbase_cdp",
|
||||
"eip7702", "merx_tron", "payai", "pieverse", "primev",
|
||||
"satoshi", "startup", "tron_selfverify", "x402_rs",
|
||||
):
|
||||
_sys.modules[f"app.facilitators.{_name}"] = _importlib.import_module(
|
||||
f"app.domains.billing.facilitators.{_name}"
|
||||
)
|
||||
|
|
@ -46,7 +46,7 @@ def _get_tools() -> dict[str, Any]:
|
|||
|
||||
def _get_facilitator_count() -> int:
|
||||
try:
|
||||
from app.facilitators.base import get_registry
|
||||
from app.domains.billing.facilitators.base import get_registry
|
||||
|
||||
return len(get_registry().get_all())
|
||||
except Exception:
|
||||
|
|
@ -57,7 +57,7 @@ def _desc(tool_id: str, pricing: dict) -> str:
|
|||
d = pricing.get("description", "")
|
||||
if d and d != tool_id and len(d) > 10:
|
||||
return d
|
||||
FALLBACKS = {
|
||||
fallbacks = {
|
||||
"airdrop_check": "Verify airdrop legitimacy -- contract audit, distribution analysis, scam pattern detection. Know if an airdrop is real or a wallet drainer before connecting.",
|
||||
"airdrop_finder": "Discover active and upcoming airdrops across all major chains. Eligibility checks, value estimation, claim deadlines, and Sybil detection.",
|
||||
"all_in_one": "All-in-One Audit -- comprehensive security scan: rug pull, honeypot, clone detection, contract audit, and ownership analysis in a single call.",
|
||||
|
|
@ -138,7 +138,7 @@ def _desc(tool_id: str, pricing: dict) -> str:
|
|||
"whale_accumulation": "Whale accumulation monitor -- detect when large wallets are building positions, track accumulation rate and entry timing.", # noqa: F601
|
||||
"whale_profile": "Whale profile -- deep analysis of a whale wallet: strategy classification, historical performance, holdings breakdown, and influence.", # noqa: F601
|
||||
}
|
||||
return FALLBACKS.get(
|
||||
return fallbacks.get(
|
||||
tool_id,
|
||||
f"{tool_id.replace('_', ' ').title()} -- real-time crypto intelligence and security analysis.",
|
||||
)
|
||||
|
|
@ -482,7 +482,11 @@ def _build_tools_list():
|
|||
cat = pricing.get("category", "analysis")
|
||||
cats[cat] = cats.get(cat, 0) + 1
|
||||
real_tool = TOOL_ALIASES.get(tool_id, tool_id)
|
||||
endpoint = f"/api/v1/x402-databus/{tool_id}" if tool_id in databus_ids else f"/api/v1/x402-tools/{real_tool}"
|
||||
endpoint = (
|
||||
f"/api/v1/x402-databus/{tool_id}"
|
||||
if tool_id in databus_ids
|
||||
else f"/api/v1/x402-tools/{real_tool}"
|
||||
)
|
||||
tools[tool_id] = {
|
||||
"name": tool_id, # MCP spec: name is the tool ID
|
||||
"description": _desc(tool_id, pricing),
|
||||
|
|
@ -492,7 +496,9 @@ def _build_tools_list():
|
|||
"trial_free": int(pricing.get("trial_free", 1)),
|
||||
"chains": sorted(chains_data.keys()),
|
||||
"endpoint": endpoint,
|
||||
"method": pricing.get("method", "POST") if isinstance(pricing.get("method"), str) else "POST",
|
||||
"method": pricing.get("method", "POST")
|
||||
if isinstance(pricing.get("method"), str)
|
||||
else "POST",
|
||||
"databus": tool_id in databus_ids,
|
||||
}
|
||||
|
||||
|
|
@ -540,7 +546,7 @@ async def mcp_tools_list(request: Request):
|
|||
"trials": remaining,
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
logger.debug("trial info fetch failed", exc_info=True)
|
||||
|
||||
return {
|
||||
"server": f"{SERVER_NAME} MCP v{SERVER_VERSION}",
|
||||
|
|
@ -844,7 +850,9 @@ async def mcp_jsonrpc(request: Request):
|
|||
}
|
||||
)
|
||||
result = (
|
||||
resp.json() if "application/json" in (resp.headers.get("content-type", "")) else {"data": resp.text}
|
||||
resp.json()
|
||||
if "application/json" in (resp.headers.get("content-type", ""))
|
||||
else {"data": resp.text}
|
||||
)
|
||||
return JSONResponse(
|
||||
{
|
||||
|
|
@ -915,7 +923,11 @@ async def mcp_call_tool(tool_id: str, request: Request):
|
|||
)
|
||||
|
||||
try:
|
||||
body = await request.json() if request.headers.get("content-type") == "application/json" else {}
|
||||
body = (
|
||||
await request.json()
|
||||
if request.headers.get("content-type") == "application/json"
|
||||
else {}
|
||||
)
|
||||
except Exception:
|
||||
body = {}
|
||||
|
||||
|
|
@ -952,7 +964,9 @@ async def mcp_call_tool(tool_id: str, request: Request):
|
|||
async with httpx.AsyncClient(timeout=45) as client:
|
||||
resp = await client.post(url, json=body, headers=headers)
|
||||
result = (
|
||||
resp.json() if "application/json" in (resp.headers.get("content-type", "")) else {"data": resp.text}
|
||||
resp.json()
|
||||
if "application/json" in (resp.headers.get("content-type", ""))
|
||||
else {"data": resp.text}
|
||||
)
|
||||
rh = {}
|
||||
for h in (
|
||||
|
|
|
|||
|
|
@ -1,41 +1,42 @@
|
|||
"""Backward-compat shim — moved to app.billing.x402.enforcement in P3B."""
|
||||
from app.billing.x402.enforcement import * # noqa: F401,F403
|
||||
from app.billing.x402.enforcement import ( # noqa: F401
|
||||
X402Enforcer,
|
||||
TOOL_PRICES,
|
||||
"""Backward-compat shim — moved to app.domains.billing.x402.enforcement in P3B."""
|
||||
|
||||
from app.domains.billing.x402.enforcement import * # noqa: F403
|
||||
from app.domains.billing.x402.enforcement import ( # noqa: F401
|
||||
CHAIN_USDC,
|
||||
EVM_PAY_TO,
|
||||
SECURITY_HEADERS,
|
||||
check_idempotency,
|
||||
check_trial,
|
||||
consume_trial,
|
||||
build_402_response,
|
||||
parse_x_pay_header,
|
||||
verify_payment,
|
||||
verify_payment_via_router,
|
||||
self_verify_evm_usdc,
|
||||
x402_enforcement_middleware,
|
||||
x402_discovery,
|
||||
get_trial_status,
|
||||
get_revenue,
|
||||
get_pricing_suggestions,
|
||||
request_refund,
|
||||
_ensure_tool_prices,
|
||||
SOL_PAY_TO,
|
||||
TOOL_PRICES,
|
||||
VERIFIER,
|
||||
X402Enforcer,
|
||||
_build_accepts_list,
|
||||
_build_bazaar_extension,
|
||||
_build_discovery_response,
|
||||
_build_extra,
|
||||
_build_resource_info,
|
||||
_detect_token_from_asset,
|
||||
_ensure_pay_addresses,
|
||||
_ensure_tool_prices,
|
||||
_ensure_verifier,
|
||||
_get_pay_to_address,
|
||||
_load_tool_prices,
|
||||
_build_accepts_list,
|
||||
_build_bazaar_extension,
|
||||
_build_resource_info,
|
||||
_build_discovery_response,
|
||||
_resolve_pay_to,
|
||||
_resolve_asset,
|
||||
_build_extra,
|
||||
_record_refundable_payment,
|
||||
_resolve_asset,
|
||||
_resolve_pay_to,
|
||||
_verify_refund_ownership,
|
||||
_detect_token_from_asset,
|
||||
build_402_response,
|
||||
check_idempotency,
|
||||
check_trial,
|
||||
consume_trial,
|
||||
get_pricing_suggestions,
|
||||
get_redis_async,
|
||||
EVM_PAY_TO,
|
||||
SOL_PAY_TO,
|
||||
VERIFIER,
|
||||
get_revenue,
|
||||
get_trial_status,
|
||||
parse_x_pay_header,
|
||||
request_refund,
|
||||
self_verify_evm_usdc,
|
||||
verify_payment,
|
||||
verify_payment_via_router,
|
||||
x402_discovery,
|
||||
x402_enforcement_middleware,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
"""x402_tools.py — DEPRECATED shim. Re-exports from app.billing.x402.
|
||||
"""x402_tools.py — DEPRECATED shim. Re-exports from app.domains.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
|
||||
`from app.domains.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):
|
||||
|
|
@ -25,8 +25,8 @@ Pre-existing issues surfaced (not introduced) by this refactor:
|
|||
home. Track: fix(f821).
|
||||
"""
|
||||
|
||||
from app.billing.x402.router import router
|
||||
from app.billing.x402.shared import (
|
||||
from app.domains.billing.x402.router import router
|
||||
from app.domains.billing.x402.shared import (
|
||||
BUNDLES,
|
||||
HUMAN_PAY_TO,
|
||||
HUMAN_PAYMENT_TOKENS,
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
"""scanners - DEPRECATED shim. Use app.domains.scanners.
|
||||
|
||||
Phase 4.8 of AUDIT-2026-Q3.md moved app/scanners/ to app/domains/scanners/.
|
||||
The 33 detection modules are IP and will be split to rmi-ip in Phase 6.
|
||||
|
||||
This shim aliases all submodules so legacy imports like
|
||||
`from app.scanners.bundle_detector import *` keep working.
|
||||
"""
|
||||
import sys as _sys
|
||||
import importlib as _importlib
|
||||
|
||||
_sys.modules["app.scanners.address_labeler"] = _importlib.import_module("app.domains.scanners.address_labeler")
|
||||
_sys.modules["app.scanners.block_zero_sniper"] = _importlib.import_module("app.domains.scanners.block_zero_sniper")
|
||||
_sys.modules["app.scanners.bundle_detector"] = _importlib.import_module("app.domains.scanners.bundle_detector")
|
||||
_sys.modules["app.scanners.bytecode_similarity"] = _importlib.import_module("app.domains.scanners.bytecode_similarity")
|
||||
_sys.modules["app.scanners.contract_authority"] = _importlib.import_module("app.domains.scanners.contract_authority")
|
||||
_sys.modules["app.scanners.contract_diff"] = _importlib.import_module("app.domains.scanners.contract_diff")
|
||||
_sys.modules["app.scanners.decompiler_analyzer"] = _importlib.import_module("app.domains.scanners.decompiler_analyzer")
|
||||
_sys.modules["app.scanners.dev_reputation"] = _importlib.import_module("app.domains.scanners.dev_reputation")
|
||||
_sys.modules["app.scanners.exchange_funder"] = _importlib.import_module("app.domains.scanners.exchange_funder")
|
||||
_sys.modules["app.scanners.flash_loan_detector"] = _importlib.import_module("app.domains.scanners.flash_loan_detector")
|
||||
_sys.modules["app.scanners.fund_flow_visualizer"] = _importlib.import_module("app.domains.scanners.fund_flow_visualizer")
|
||||
_sys.modules["app.scanners.gas_trace"] = _importlib.import_module("app.domains.scanners.gas_trace")
|
||||
_sys.modules["app.scanners.governance_attack"] = _importlib.import_module("app.domains.scanners.governance_attack")
|
||||
_sys.modules["app.scanners.guilt_association"] = _importlib.import_module("app.domains.scanners.guilt_association")
|
||||
_sys.modules["app.scanners.holder_analyzer"] = _importlib.import_module("app.domains.scanners.holder_analyzer")
|
||||
_sys.modules["app.scanners.honeypot_detector"] = _importlib.import_module("app.domains.scanners.honeypot_detector")
|
||||
_sys.modules["app.scanners.liquidity_verifier"] = _importlib.import_module("app.domains.scanners.liquidity_verifier")
|
||||
_sys.modules["app.scanners.metadata_fingerprint"] = _importlib.import_module("app.domains.scanners.metadata_fingerprint")
|
||||
_sys.modules["app.scanners.mev_detector"] = _importlib.import_module("app.domains.scanners.mev_detector")
|
||||
_sys.modules["app.scanners.oracle_manipulation"] = _importlib.import_module("app.domains.scanners.oracle_manipulation")
|
||||
_sys.modules["app.scanners.proxy_detector"] = _importlib.import_module("app.domains.scanners.proxy_detector")
|
||||
_sys.modules["app.scanners.pump_dump_detector"] = _importlib.import_module("app.domains.scanners.pump_dump_detector")
|
||||
_sys.modules["app.scanners.pumpfun_analyzer"] = _importlib.import_module("app.domains.scanners.pumpfun_analyzer")
|
||||
_sys.modules["app.scanners.pumpfun_enhanced"] = _importlib.import_module("app.domains.scanners.pumpfun_enhanced")
|
||||
_sys.modules["app.scanners.rag_citations"] = _importlib.import_module("app.domains.scanners.rag_citations")
|
||||
_sys.modules["app.scanners.sentiment_analyzer"] = _importlib.import_module("app.domains.scanners.sentiment_analyzer")
|
||||
_sys.modules["app.scanners.sentinel_pipeline"] = _importlib.import_module("app.domains.scanners.sentinel_pipeline")
|
||||
_sys.modules["app.scanners.sleep_cycle_scanner"] = _importlib.import_module("app.domains.scanners.sleep_cycle_scanner")
|
||||
_sys.modules["app.scanners.social_signals"] = _importlib.import_module("app.domains.scanners.social_signals")
|
||||
_sys.modules["app.scanners.social_velocity"] = _importlib.import_module("app.domains.scanners.social_velocity")
|
||||
_sys.modules["app.scanners.static_analyzer"] = _importlib.import_module("app.domains.scanners.static_analyzer")
|
||||
_sys.modules["app.scanners.wash_trading"] = _importlib.import_module("app.domains.scanners.wash_trading")
|
||||
Loading…
Add table
Add a link
Reference in a new issue