- Rust engine: real bootstrap/wiring preflight (guardrail-agent), execution layer (retry/router/pre-trade/post-trade/reconciliation), guardrail-doctor diagnostics with allowlist-drift guard. - guardrail-cli: extracted pure helpers into util.rs (split in progress). - 6 Track-2 skills + ensemble; python-lab analytics (regime/drawdown/montecarlo/dossier/ensemble/journal/seed); clients (ts/py/go/mcp/langchain/web-lite/proof-verifier); alert relay; scenarios; helm/k8s/compose; docs. - dashboard/vercel.json + docs/VERCEL_DEPLOY.md for Vercel deployment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
32 lines
871 B
Python
32 lines
871 B
Python
"""Web3 utilities — BSC-aware Web3 factory."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from web3 import Web3
|
|
|
|
|
|
def create_web3(rpc_url: str = "") -> Web3:
|
|
"""Create a Web3 instance with BSC POA middleware auto-injected.
|
|
|
|
Args:
|
|
rpc_url: RPC endpoint URL. If empty, uses BSC Testnet default.
|
|
|
|
Returns:
|
|
Web3 instance ready for BSC operations.
|
|
"""
|
|
if not rpc_url:
|
|
rpc_url = "https://data-seed-prebsc-2-s2.binance.org:8545"
|
|
w3 = Web3(Web3.HTTPProvider(rpc_url))
|
|
try:
|
|
from web3.middleware import ExtraDataToPOAMiddleware
|
|
|
|
w3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0)
|
|
except ImportError:
|
|
try:
|
|
from web3.middleware import geth_poa_middleware
|
|
|
|
w3.middleware_onion.inject(geth_poa_middleware, layer=0)
|
|
except ImportError:
|
|
pass
|
|
return w3
|