feat: x402 v2 SDK, AssetRegistry, and E2E Test Suite#7
Closed
feat: x402 v2 SDK, AssetRegistry, and E2E Test Suite#7
Conversation
- Deprecate existing bofai SDKs (python/x402-deprecated, typescript/packages/x402-deprecated) with deprecation warnings - Fork coinbase Python SDK v2.3.0 as bankofai.x402 with src/bankofai/x402 namespace layout - Fork coinbase TypeScript SDK v2.6.0 as @bankofai/x402-* (20 packages: core, http/*, mechanisms/*, etc.) - Fork coinbase legacy v1 packages as @bankofai/x402-*-legacy - Fork examples and e2e tests with updated package references - Update .gitignore to exclude build artifacts and agent config - All Python tests pass (677 passed), all TypeScript builds and tests pass (40/40 tasks)
Add AssetRegistry class (TS + Python) that maps (network, symbol) to token metadata, enabling B-form shorthand where developers specify assets: ["USDT", "USDC"] instead of manual addresses/decimals. - New AssetRegistry with built-in tokens for EVM (eip155:1/56/97) and TRON (mainnet/shasta/nile) networks - convertMoney utility for Money → smallest-unit conversion - Global singleton (globalAssetRegistry / global_asset_registry) - ResourceConfig and PaymentOption gain optional assets field - x402ResourceServer auto-expands B-form to D-form PaymentRequirements - 25 TS + 25 Python unit tests for registry and conversion
- Fix import ordering in __init__.py - Remove unused AssetInfo import in server_base.py - Collapse unnecessary multi-line expressions per ruff format
Internal test tokens no longer needed in the built-in registry.
This reverts commit b22c5d5.
feat: add AssetRegistry for multi-asset symbol-based token lookup
…t SDKs Verify the existing v1/v2 auto-detection and routing behavior end-to-end without modifying source code. Covers client payload creation, HTTP header encoding, round-tripper flow, and mixed v1+v2 scheme registration. Python (25 new test cases): - Unit: v1 payload creation (async+sync), auto-adaptive routing, v1 hooks - Integration: parameterized sync/async v1 flow, auto-adaptive routing, HTTP layer - HTTP: v1 handle_402, v1 round-tripper with X-PAYMENT header TypeScript (16 new test cases): - Unit: v1 payload creation, auto-adaptive v1/v2 routing, version isolation - HTTP: v1/v2 header encoding, body parsing, settle response, priority tests
The assets field from PaymentOption was not forwarded to ResourceConfig in buildPaymentRequirementsFromOptions, causing AssetRegistry-based price resolution to never trigger via the HTTP middleware path.
Project only has Python + TypeScript SDKs. Coinbase Go SDK compatibility tests will be added in a separate test directory later.
…runner Previously the hardcoded check at startup required SVM env vars even when running EVM-only tests (e.g. --families=evm). Move validation after scenario filtering so only variables for the actually-tested protocol families are required.
…LU token Migrate all e2e test infrastructure to BSC Testnet (eip155:97) using DHLU token (0x375cADdd2cB68cE82e3D9B075D551067a7b4B816, decimals: 6, EIP712 name="DA HULU", version="1"). DHLU supports EIP-3009, EIP-2612, and ERC-20 approval, enabling all payment transfer methods with a single token. - Update v2 servers (express, hono, next, fastapi, flask) with pre-parsed DHLU price objects (also fixes permit2 endpoints that had extra at wrong level when using $0.001 shorthand) - Update MCP servers (TypeScript, Python) with DHLU price config - Update facilitators (TypeScript, Python) RPC URLs and network IDs - Update clients (fetch, axios, mcp-typescript) chain references - Update legacy servers/clients to use bsc-testnet network name - Update permit2-approval script for BSC Testnet + DHLU
boboliu-1010
pushed a commit
that referenced
this pull request
Apr 24, 2026
- solutions.md #7: BSC testnet has no EIP-2612 permit-capable token. Captures why exact_permit_testnet returns 404 and lists the options (Sepolia / custom test token / rely on unit suites), so the next person doesn't rediscover it. - solutions.md #8: integration runner doesn't expand ${VAR:-default}. Captures the os.path.expandvars limitation that caused the testnet scenarios to silently break on a literal fallback string. - testnet/README.md: add "Current status" table with today's verified BSC tx hash as evidence, and a "Gotchas" section linking back to solutions #7 / #8, the tx-hash regex, and the log locations. No code change — just freezing today's testnet run state so future attempts start from known ground. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
boboliu-1010
pushed a commit
that referenced
this pull request
Apr 24, 2026
…anisms Permit-family facilitator mechanisms (EVM exact_permit, TRON exact_permit, TRON exact_gasfree) all inherit BaseExactPermitFacilitatorMechanism which requires a base_fee: dict[str, int] allow-list at construction time. examples/facilitator/server.py was constructing them without base_fee, so every token in every registry was reported Unsupported and every testnet run of the permit/gasfree tiers silently returned HTTP 404. - server.py now reads FACILITATOR_BASE_FEE as a JSON dict and passes it to all three permit/gasfree mechanism constructors; logs a clear warning when a permit/gasfree scheme is registered without it. - testnet scenario configs now forward FACILITATOR_BASE_FEE into the facilitator subprocess. - .env.example / README updated. - docs/solutions.md #7 corrected — the earlier entry blaming BSC testnet USDT for not implementing EIP-2612 was a misdiagnosis; USDT does implement permit. The real cause was the missing base_fee config. Verified live 2026-04-24: - exact_permit_testnet: BSC tx 0xfc8b32decb99d02cdfc684d3f6f1c7c0a91c8b0ff1f632f98d86d9f334198a23 (USDT permit + transferFrom, block 103475005) - exact_gasfree_testnet: fee_quote / verify / settle all traverse; final settle reports insufficient balance in the derived GasFree custodial wallet when it isn't funded — structural path end-to-end works. Regression: 217 pytest + 51 vitest + 8 mock e2e all green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the second generation (v2) of the x402 SDK, modularized and ported to the
bankofainamespace. It also adds a comprehensive E2E testing framework, asset registry, and extensive examples.Key Changes
Verification