From 05e5d59b8c51ac5f1feeac2a2f3b60f31bacb118 Mon Sep 17 00:00:00 2001 From: aitbc Date: Tue, 28 Apr 2026 18:09:49 +0200 Subject: [PATCH] Update market buy handler to use new GPU buy endpoint --- cli/handlers/market.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cli/handlers/market.py b/cli/handlers/market.py index b5560cfd..7ecd166a 100644 --- a/cli/handlers/market.py +++ b/cli/handlers/market.py @@ -287,21 +287,22 @@ def handle_market_gpu_list(args, default_coordinator_url, output_format): def handle_market_buy(args, default_coordinator_url, read_password, render_mapping): """Handle marketplace buy command via coordinator API.""" coordinator_url = getattr(args, 'rpc_url', default_coordinator_url) or default_coordinator_url - + if not args.item or not args.wallet: print("Error: --item and --wallet are required") sys.exit(1) - - # Submit purchase to coordinator API (no blockchain transaction needed for now) + + # Submit purchase to coordinator API purchase_data = { - "item_id": args.item, - "wallet": args.wallet, - "action": "buy" + "buyer_id": args.wallet, + "gpu_id": args.item, + "duration_hours": 1.0, + "payment_method": "blockchain" } - + print(f"Submitting purchase to {coordinator_url}...") try: - response = requests.post(f"{coordinator_url}/v1/marketplace/buy", json=purchase_data, timeout=30) + response = requests.post(f"{coordinator_url}/v1/marketplace/gpu/buy", json=purchase_data, timeout=30) if response.status_code in (200, 201): result = response.json() print("Purchase submitted successfully")