CLI migration: - Migrate 11 CLI files from old import pattern to centralized aitbc imports - wallet.py, exchange.py, gpu_marketplace.py, exchange_island.py, monitor.py, cross_chain.py - aitbc_cli.py, handlers (account.py, bridge.py, pool_hub.py), utils (wallet_daemon_client.py) - Replace 'from aitbc.aitbc_logging import' with 'from aitbc import get_logger' - Replace 'from aitbc.http_client import' with 'from aitbc import AITBCHTTPClient' - Replace 'from aitbc.exceptions import' with 'from aitbc import NetworkError' Packages migration: - aitbc-sdk: receipts.py - migrate from httpx to AITBCHTTPClient - aitbc-agent-sdk: 5 files - migrate logging to get_logger - agent.py, compute_provider.py, compute_consumer.py, swarm_coordinator.py, platform_builder.py
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
"""Account handlers."""
|
|
|
|
import json
|
|
import sys
|
|
|
|
from aitbc import AITBCHTTPClient, NetworkError
|
|
|
|
|
|
def handle_account_get(args, default_rpc_url, output_format):
|
|
"""Handle account get command."""
|
|
rpc_url = args.rpc_url or default_rpc_url
|
|
chain_id = getattr(args, "chain_id", None)
|
|
|
|
if not args.address:
|
|
print("Error: --address is required")
|
|
sys.exit(1)
|
|
|
|
print(f"Getting account {args.address} from {rpc_url}...")
|
|
try:
|
|
params = {}
|
|
if chain_id:
|
|
params["chain_id"] = chain_id
|
|
|
|
http_client = AITBCHTTPClient(base_url=rpc_url, timeout=10)
|
|
account = http_client.get(f"/rpc/account/{args.address}", params=params)
|
|
if output_format(args) == "json":
|
|
print(json.dumps(account, indent=2))
|
|
else:
|
|
render_mapping(f"Account {args.address}:", account)
|
|
except NetworkError as e:
|
|
print(f"Error getting account: {e}")
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
print(f"Error getting account: {e}")
|
|
sys.exit(1)
|