feat: add AssetRegistry for multi-asset symbol-based token lookup#3
Merged
feat: add AssetRegistry for multi-asset symbol-based token lookup#3
Conversation
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.
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
AssetRegistryclass (Python + TypeScript) for symbol-based token lookup across networks (TRON, BSC, Ethereum, etc.)x402ResourceServerto auto-resolve token address, decimals, and EIP-712 domain fields fromconfig.assetsymbolChanges
registry.pywithAssetRegistry,AssetInfo,convert_money,global_asset_registry; integrated intoserver_base.py; exported from__init__.pyregistry/assetRegistry.tswith equivalent implementation; integrated intox402ResourceServer.ts; exported fromcore/index.tstest_asset_registry.py) and TypeScript (assetRegistry.test.ts)Test plan
pytest tests/unit/core/test_asset_registry.py)pnpm testinpackages/core)