feat: Stellar address validation utility (#166)#210
Merged
SudiptaPaul-31 merged 1 commit intoJun 28, 2026
Merged
Conversation
- Add lib/utils/stellar-address.ts with isValidStellarAddress and getStellarAddressError using StrKey.isValidEd25519PublicKey for proper checksum-aware validation via the Stellar SDK - Add 13 unit tests covering valid addresses, bad checksum, wrong prefix, non-string inputs, empty/whitespace, and error messages - Register new test file in vitest.config.ts - Add 'Run unit tests' step to CI workflow before build - Fix duplicate test:unit key in package.json (kept vitest run)
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
Closes #166
Implements a proper Stellar address validation utility using the Stellar SDK's
StrKey.isValidEd25519PublicKey, which decodes the Base32-encoded address and validates the checksum — far more robust than a simple length + prefix check.Changes
lib/utils/stellar-address.ts— new utility with two exports:isValidStellarAddress(address)— returnstruefor valid Stellar Ed25519 public keysgetStellarAddressError(address)— returns a descriptive error string ornulllib/utils/stellar-address.test.ts— 13 unit tests covering:null,undefined,number, object)getStellarAddressErrormessages for all casesvitest.config.ts— registered new test file.github/workflows/ci.yml— addedRun unit testsstep before buildpackage.json— removed duplicatetest:unitkeyTest results
CI
The CI workflow now runs
npm run test:uniton every PR before the build step.