Skip to content

feat: add AssetRegistry for multi-asset symbol-based token lookup#3

Merged
Hades-Ye merged 10 commits intodev/v2from
feat/asset-registry
Mar 10, 2026
Merged

feat: add AssetRegistry for multi-asset symbol-based token lookup#3
Hades-Ye merged 10 commits intodev/v2from
feat/asset-registry

Conversation

@Hades-Ye
Copy link
Copy Markdown
Contributor

Summary

  • Add AssetRegistry class (Python + TypeScript) for symbol-based token lookup across networks (TRON, BSC, Ethereum, etc.)
  • Integrate registry into x402ResourceServer to auto-resolve token address, decimals, and EIP-712 domain fields from config.asset symbol
  • Pre-register common stablecoins (USDT, USDC) with correct contract addresses and metadata for supported networks

Changes

  • Python: registry.py with AssetRegistry, AssetInfo, convert_money, global_asset_registry; integrated into server_base.py; exported from __init__.py
  • TypeScript: registry/assetRegistry.ts with equivalent implementation; integrated into x402ResourceServer.ts; exported from core/index.ts
  • Tests: Unit tests for both Python (test_asset_registry.py) and TypeScript (assetRegistry.test.ts)

Test plan

  • Python unit tests pass (pytest tests/unit/core/test_asset_registry.py)
  • TypeScript unit tests pass (pnpm test in packages/core)

Hades-Ye added 10 commits March 9, 2026 22:13
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.
@Hades-Ye Hades-Ye merged commit 9dbc485 into dev/v2 Mar 10, 2026
7 checks passed
@Hades-Ye Hades-Ye deleted the feat/asset-registry branch March 10, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant