Skip to content

feat(stellar): add formatAssetIdentifier helper for uniform asset representations (closes #441) - #496

Open
Ranjeet2063 wants to merge 1 commit into
mergepay:mainfrom
Ranjeet2063:feat/stellar-asset-format-helper
Open

feat(stellar): add formatAssetIdentifier helper for uniform asset representations (closes #441)#496
Ranjeet2063 wants to merge 1 commit into
mergepay:mainfrom
Ranjeet2063:feat/stellar-asset-format-helper

Conversation

@Ranjeet2063

Copy link
Copy Markdown

Summary

Closes #441

Implements formatAssetIdentifier and parseAssetIdentifier in src/utils/stellar.ts to provide uniform string representations for Stellar native assets and credit assets across API responses, logging, and internal payloads.

Key Changes

  • Added formatAssetIdentifier(asset, issuer?):
    • Formats native assets (Asset.native(), "native", "XLM", { code: "native" }, { code: "XLM" }) strictly as "native".
    • Formats credit/issued assets (Asset, { code, issuer }, or code + issuer arguments) as "<code>:<issuer>".
    • Enforces strict validation: throws descriptive errors if asset parameter is missing or non-native assets lack an issuing account.
  • Added parseAssetIdentifier(identifier):
    • Parses "native" / "XLM" into { code: "XLM", issuer: null }.
    • Parses "<code>:<issuer>" into { code, issuer }.
  • Added complete unit test coverage in tests/stellar-asset-formatting.test.ts (18/18 tests passing).

Verification

  • npm test -- tests/stellar-asset-formatting.test.ts passed (18 tests passing).
  • npm run build completed with 0 TypeScript errors.
  • npm run lint passed with 0 errors.

Copilot AI lite review requested due to automatic review settings September 10, 2026 11:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Add helper function to format Stellar asset codes and issuers into standard representations

2 participants