feat: migrate coordinator-api services and exchange CLI to use centralized aitbc package utilities
Some checks failed
Python Tests / test-python (push) Waiting to run
Security Scanning / security-scan (push) Waiting to run
Staking Tests / test-staking-integration (push) Blocked by required conditions
Staking Tests / test-staking-contract (push) Blocked by required conditions
Staking Tests / run-staking-test-runner (push) Blocked by required conditions
API Endpoint Tests / test-api-endpoints (push) Successful in 9s
CLI Tests / test-cli (push) Failing after 8s
Integration Tests / test-service-integration (push) Successful in 45s
Staking Tests / test-staking-service (push) Failing after 14m32s

- Replace logging.getLogger with aitbc.get_logger in analytics_service.py, staking_service.py, wallet_service.py
- Migrate payments.py from httpx to aitbc.AITBCHTTPClient for token escrow creation
- Add NetworkError exception handling in payments.py
- Remove async context manager and status code checks in favor of AITBCHTTPClient
- Update exchange.py CLI commands (create_pair, start_trading) to use
This commit is contained in:
aitbc
2026-04-24 23:37:21 +02:00
parent 3103debecf
commit 0ccd8ef995
5 changed files with 55 additions and 74 deletions

View File

@@ -590,23 +590,14 @@ def create_pair(ctx, pair: str, base_asset: str, quote_asset: str,
try:
http_client = AITBCHTTPClient(base_url="http://localhost:8001/api/v1", timeout=10)
response = http_client.post(
f"{config.coordinator_url}/v1/exchange/create-pair",
json=pair_data,
timeout=10
)
if response.status_code == 200:
result = response.json()
success(f"Trading pair '{pair}' created successfully!")
success(f"Pair ID: {result.get('pair_id')}")
output(result, ctx.obj['output_format'])
else:
error(f"Failed to create trading pair: {response.status_code}")
if response.text:
error(f"Error details: {response.text}")
except Exception as e:
result = http_client.post("/exchange/create-pair", json=pair_data)
success(f"Trading pair '{pair}' created successfully!")
success(f"Pair ID: {result.get('pair_id')}")
output(result, ctx.obj['output_format'])
except NetworkError as e:
error(f"Network error: {e}")
except Exception as e:
error(f"Error: {e}")
@exchange.command()
@@ -629,23 +620,14 @@ def start_trading(ctx, pair: str, exchange: Optional[str], order_type: tuple):
try:
http_client = AITBCHTTPClient(base_url="http://localhost:8001/api/v1", timeout=10)
response = http_client.post(
f"{config.coordinator_url}/v1/exchange/start-trading",
json=trading_data,
timeout=10
)
if response.status_code == 200:
result = response.json()
success(f"Trading started for pair '{pair}'!")
success(f"Order types: {', '.join(order_type)}")
output(result, ctx.obj['output_format'])
else:
error(f"Failed to start trading: {response.status_code}")
if response.text:
error(f"Error details: {response.text}")
except Exception as e:
result = http_client.post("/exchange/start-trading", json=trading_data)
success(f"Trading started for pair '{pair}'!")
success(f"Order types: {', '.join(order_type)}")
output(result, ctx.obj['output_format'])
except NetworkError as e:
error(f"Network error: {e}")
except Exception as e:
error(f"Error: {e}")
@exchange.command()