fix(stellar): consolidate address validation and truncate helpers (#18, #3) - #93
Open
ghzhost wants to merge 1 commit into
Open
fix(stellar): consolidate address validation and truncate helpers (#18, #3)#93ghzhost wants to merge 1 commit into
ghzhost wants to merge 1 commit into
Conversation
…ellarSend#18, StellarSend#3) - Use StrKey.isValidEd25519PublicKey in lib/stellar.ts for rigorous checksum validation - Guard truncateAddress against short strings to prevent overlapping substring duplication - Re-export consolidated helpers from utils/stellar.ts for backward compatibility - Use isValidStellarAddress in utils/validation.ts validateRecipient - Update tests for invalid checksum validation and short-string truncation
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
Consolidates duplicated Stellar utility functions across
src/utils/stellar.tsandsrc/lib/stellar.tsand fixes weak address validation insrc/utils/validation.ts.Closes #18, Closes #3.
Changes
isValidStellarAddress:StrKey.isValidEd25519PublicKey(address)insrc/lib/stellar.tsto strictly validate Base32 Ed25519 checksums instead of weaker format or error-prone constructors.validateRecipientinsrc/utils/validation.tsto useisValidStellarAddressinstead of naive string length / prefix checks.truncateAddress:if (address.length <= chars * 2) return address) insrc/lib/stellar.tsto prevent overlapping substring duplication when inputs are shorter than2 * chars.isValidStellarAddress,truncateAddress,formatAmount,formatXLM,formatUSD) fromsrc/utils/stellar.tsto avoid breaking changes across existing consumer components.AddContact.tsximport to canonical@/lib/stellar.stellar.test.tsandvalidation.test.tsfor invalid checksum public keys and short-string truncation edge cases.Verification