Skip to content

Commit 8ebec92

Browse files
committed
feat: finish update to x402
1 parent 8e5e860 commit 8ebec92

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

  • internal/embed/skills/buy-x402/scripts

internal/embed/skills/buy-x402/scripts/buy.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,9 +1327,12 @@ def _reconcile_purchase_autorefill(pr, live_status, signer_address):
13271327
# None — we only update the price when we get an unambiguous fresh
13281328
# quote so a transient seller error never silently rewrites the cap.
13291329
endpoint = spec.get("endpoint") or ""
1330+
live_extensions = {}
13301331
if endpoint:
13311332
try:
13321333
live = _probe_endpoint(_normalize_endpoint(endpoint), spec.get("model") or "")
1334+
if live:
1335+
live_extensions = live.get("extensions", {}) or {}
13331336
if live and live.get("accepts"):
13341337
live_amount = str(
13351338
live["accepts"][0].get("maxAmountRequired")
@@ -1390,6 +1393,7 @@ def _reconcile_purchase_autorefill(pr, live_status, signer_address):
13901393
asset,
13911394
refill_count,
13921395
payment=payment_req,
1396+
extensions=live_extensions,
13931397
)
13941398
try:
13951399
updated_auths = _build_active_auth_pool(existing_auths, live_status, new_auths)
@@ -2213,7 +2217,8 @@ def cmd_pay(url, method="GET", data=None, kind="http", network=None, timeout=Non
22132217
)
22142218

22152219
print(f"Pre-signing 1 payment authorization for {price} on {chain} ...")
2216-
auths = _presign_auths(signer_address, pay_to, price, chain, usdc_addr, 1, payment=payment)
2220+
auths = _presign_auths(signer_address, pay_to, price, chain, usdc_addr, 1, payment=payment,
2221+
extensions=pricing.get("extensions", {}) or {})
22172222
if not auths:
22182223
print("Failed to pre-sign payment.", file=sys.stderr)
22192224
sys.exit(1)
@@ -2390,7 +2395,8 @@ def cmd_pay_agent(url, messages=None, model_id=None, network=None, timeout=None,
23902395
)
23912396

23922397
print(f"Pre-signing 1 payment authorization for {price} on {chain} ...")
2393-
auths = _presign_auths(signer_address, pay_to, price, chain, usdc_addr, 1, payment=payment)
2398+
auths = _presign_auths(signer_address, pay_to, price, chain, usdc_addr, 1, payment=payment,
2399+
extensions=pricing.get("extensions", {}) or {})
23942400
if not auths:
23952401
print("Failed to pre-sign payment.", file=sys.stderr)
23962402
sys.exit(1)

0 commit comments

Comments
 (0)