Skip to content

Conversation

@phdargen
Copy link
Contributor

@phdargen phdargen commented Jan 16, 2026

Description

PR #900 introduced a dual class design for x402HTTPResourceServer to support async dynamic route hooks.

This PR follows the same strategy to also support async server/client/facilitator lifecycle hooks.
Async classes should be considered default offering the best features (i.e. async callbacks), with the Sync classes as fallback for codebases or frameworks that can't use async.

Requests client and flask middleware use the Sync classes
Httpx client and fastapi use the Async classes

Shared base logic of sync/async classes is refactored into X_base.py with sync/async specifics in X.py using generator based approach to reduce excessive code duplication.

Async (default) Sync Location
x402Client x402ClientSync client.py
x402ResourceServer x402ResourceServerSync server.py
x402Facilitator x402FacilitatorSync facilitator.py
x402HTTPResourceServer x402HTTPResourceServerSync http/x402_http_server.py
HTTPFacilitatorClient HTTPFacilitatorClientSync http/facilitator_client.py
x402HTTPClient x402HTTPClientSync http/x402_http_client.py

Other updates:

  • adds missing unit tests for core, http/clients and http/middleware
  • adds new integration test to verify HTTP client/server integration (async & sync)
  • adds new custom server example
  • adds new advanced server example showing how to use the paywall builder
  • updates and cleans-up all examples
  • adds utility function that takes care of html-safe escaping in paywall
  • added sdk READMEs and removed implementation plans

Tests

  • Manually tested all examples
  • e2e tests:
╔════════════════════════════════════════════════════════╗
║         Bazaar Discovery Extension Validation          ║
╚════════════════════════════════════════════════════════╝

📋 Expected Discoverable Endpoints: 5

═══════════════════════════════════════════════════════
                 Discovery Summary
═══════════════════════════════════════════════════════
Total Facilitators:          1
Facilitators with Bazaar:    1
Expected Endpoints:          5
Total Discovered Resources:  5

📍 python:
   Discovered: 5/5
   ✅ All expected endpoints discovered

═══════════════════════════════════════════════════════
✅ Discovery Validation: PASSED
═══════════════════════════════════════════════════════


🧹 Cleaning up...
  🛑 Stopping facilitator: python

📊 Test Summary
==============
✅ Passed: 7
❌ Failed: 0
📈 Total: 7

📋 Detailed Test Results
========================

✅ PASSED TESTS:

  # 1: httpx → fastapi → /protected
      Facilitator: python | Network: eip155:84532 | Tx: 2176556d56...
  # 2: httpx → fastapi → /protected-2
      Facilitator: python | Network: eip155:84532 | Tx: 56e8156df1...
  # 3: httpx → fastapi → /protected-svm
      Facilitator: python | Network: solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 | Tx: UATvrQnUas...
  # 4: requests → fastapi → /protected
      Facilitator: python | Network: eip155:84532 | Tx: 04a97d14e7...
  # 5: requests → fastapi → /protected-svm
      Facilitator: python | Network: solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 | Tx: 4PGH4WmVt1...
  # 6: httpx → flask → /protected
      Facilitator: python | Network: eip155:84532 | Tx: 953fae4950...
  # 7: httpx → flask → /protected-svm
      Facilitator: python | Network: solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 | Tx: 4w9N8Keonh...

📊 Breakdown by Facilitator:
   python          ✅ 7 / ❌ 0 (100%)

📊 Breakdown by Server:
   fastapi              ✅ 5 / ❌ 0 (100%)
   flask                ✅ 2 / ❌ 0 (100%)

📊 Breakdown by Client:
   httpx                ✅ 5 / ❌ 0 (100%)
   requests             ✅ 2 / ❌ 0 (100%)

📊 Protocol Family Breakdown:
   EVM: ✅ 4 / ❌ 0 / 📈 4 total
   SVM: ✅ 3 / ❌ 0 / 📈 3 total

Checklist

  • I have formatted and linted my code
  • All new and existing tests pass
  • My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits

@vercel
Copy link

vercel bot commented Jan 16, 2026

@phdargen is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added sdk Changes to core v2 packages examples Changes to examples python legacy Changes to legacy sdk or examples labels Jan 16, 2026
@vercel
Copy link

vercel bot commented Jan 16, 2026

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

@CarsonRoscoe CarsonRoscoe merged commit 2a6cbd9 into coinbase:feat/python-v2-sdk Jan 16, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples Changes to examples legacy Changes to legacy sdk or examples python sdk Changes to core v2 packages

Development

Successfully merging this pull request may close these issues.

2 participants