Skip to content

feat: add network-aware Stellar asset registry and validation layer (Closes #23) - #78

Merged
El-swaggerito merged 1 commit into
Axionvera:mainfrom
deepak0x:feature/issue-23-asset-registry
Jul 28, 2026
Merged

feat: add network-aware Stellar asset registry and validation layer (Closes #23)#78
El-swaggerito merged 1 commit into
Axionvera:mainfrom
deepak0x:feature/issue-23-asset-registry

Conversation

@deepak0x

Copy link
Copy Markdown
Contributor

Description

Implements a network-aware Stellar asset registry and validation layer (issue #23) on top of the existing assets.ts primitives and shared StellarAssetSchema.

What changed

  • packages/types/src/index.ts — added the ASSET_UNSUPPORTED StellarErrorCode so unsupported assets get a typed, user-safe error.
  • packages/stellar-kit/src/assetRegistry.ts (new):
    • AssetSupport (supported | testnetOnly | unsupported) and RegistryEntry/AssetRegistry types.
    • createAssetRegistry(entries) — builds a keyed registry (native XLM always supported implicitly).
    • lookupAsset(asset, network, registry?) — returns the support state + typed ASSET_UNSUPPORTED error; never throws.
    • validateAssetOnNetwork(asset, network, registry?) — structure + network support; throws ASSET_INVALID / ASSET_UNSUPPORTED.
    • checkAssetOnNetwork(asset, network, registry?) — safe, no-throw variant.
    • DEFAULT_TESTNET_REGISTRY — MVP defaulting to safe testnet examples (native XLM + a demo testnet USDC).
  • packages/stellar-kit/src/index.ts — exports the registry module.
  • packages/stellar-kit/test/assetRegistry.test.ts (new) — 11 tests: native always supported, testnet asset on testnet, testnet-only on mainnet → testnetOnly, unregistered → unsupported, invalid structure → ASSET_INVALID, safe checkAssetOnNetwork, and custom mainnet registry.
  • examples/assets-registry.testnet.json — fixture showing the testnet registry shape.
  • apps/web/app/assets/page.tsx (new) — UI: check any asset string against a selected network, see the support state / ASSET_UNSUPPORTED message, and list registered assets.
  • docs/asset-registry.md — registry reference + configuration guidance.

Verification

  • packages/stellar-kit full suite: 138 tests passing (11 new for the registry).
  • packages/stellar-kit builds; web app typechecks clean.
  • Native + issued assets represented; network-specific support handled; unsupported assets return typed errors; test/UI/docs included.

Acceptance criteria

  • Native and issued assets are represented.
  • Network-specific asset support is handled (testnet-only → testnetOnly).
  • Unsupported assets return typed errors (ASSET_UNSUPPORTED).
  • Payment/anchor utilities can use the shared asset layer (registry sits on the shared StellarAssetSchema/assets.ts primitives they already consume).
  • Tests cover native, issued, invalid, and unsupported assets.
  • Documentation explains asset configuration.
  • MVP defaults to safe testnet examples.

Notes

  • The MVP ships only testnet demo assets; production mainnet lists are supplied via a custom registry (documented).
  • No secrets involved — issuers are public Stellar accounts (generated testnet key for the demo USDC).

@El-swaggerito
El-swaggerito merged commit 915f330 into Axionvera:main Jul 28, 2026
1 check passed
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.

2 participants