x402
x402 copied to clipboard
feat: Implement Python V2 X402Client class
Description
This PR implements V2 X402Client for Python by following the TypeScript reference implementation and the proposed V2 Changelog.
Related to https://github.com/coinbase/x402/pull/482/
As per the TODO guidance, I have added new x402.core, and x402.client modules. Because there's already a V1 types.py file, I have added the new types module as x402.core.types.
Tests
============================================================================================================================== test session starts ===============================================================================================================================
platform linux -- Python 3.10.6, pytest-8.4.0, pluggy-1.6.0
rootdir: /root/x402/python/x402
configfile: pytest.ini
plugins: asyncio-1.0.0, anyio-4.9.0
asyncio: mode=auto, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 104 items
tests/client/test_x402_client.py ................. [ 16%]
tests/clients/test_base.py ....... [ 23%]
tests/clients/test_httpx.py ......... [ 31%]
tests/clients/test_requests.py .......... [ 41%]
tests/fastapi_tests/test_middleware.py ............ [ 52%]
tests/flask_tests/test_middleware.py ............ [ 64%]
tests/test_common.py ...... [ 70%]
tests/test_encoding.py ... [ 73%]
tests/test_exact.py ...... [ 78%]
tests/test_paywall.py .............. [ 92%]
tests/test_types.py ........ [100%]
============================================================================================================================== 104 passed in 0.76s ===============================================================================================================================
Checklist
- [x] I have formatted and linted my code
- [x] All new and existing tests pass
- [x] My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits
@marcosmmb is attempting to deploy a commit to the Coinbase Team on Vercel.
A member of the Team first needs to authorize it.