feat: migrate wallet validation from StarkNet to Stellar#264
Open
vicajohn wants to merge 1 commit intoStreamFi-x:devfrom
Open
feat: migrate wallet validation from StarkNet to Stellar#264vicajohn wants to merge 1 commit intoStreamFi-x:devfrom
vicajohn wants to merge 1 commit intoStreamFi-x:devfrom
Conversation
- Add Stellar address validation utility using @stellar/stellar-sdk - Update 13 API routes to validate Stellar public keys (56-char Base32) - Replace LOWER(wallet) SQL queries with exact match for Stellar addresses - Remove wallet.toLowerCase() normalization (Stellar keys are uppercase) - Return 400 error for invalid Stellar addresses with clear message Routes updated: - /api/users/wallet/[wallet], /api/users/register, /api/users/updates/[wallet] - /api/users/follow, /api/streams/[wallet], /api/streams/create - /api/streams/start, /api/streams/update, /api/streams/delete - /api/streams/delete-get, /api/streams/key, /api/fetch-username - /api/debug/user-stream
|
@vicajohn is attempting to deploy a commit to the david's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
please review |
Contributor
|
Great work on implementing Stellar address validation across the API routes! 👍 The implementation is clean and consistent across all 13 routes. However, I noticed one important gap: Issue: Missing Tests for Validation UtilityThe export function isValidStellarAddress(address: string): boolean {
return StrKey.isValidEd25519PublicKey(address);
}This function validates user input across all API routes, so it's essential to have comprehensive tests. Recommended FixPlease add a test file import { isValidStellarAddress } from '../stellar';
describe('isValidStellarAddress', () => {
it('should validate correct Stellar public keys', () => {
const validKey = 'GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H';
expect(isValidStellarAddress(validKey)).toBe(true);
});
it('should reject invalid keys', () => {
expect(isValidStellarAddress('INVALID_KEY')).toBe(false);
expect(isValidStellarAddress('')).toBe(false);
expect(isValidStellarAddress('0x1234...')).toBe(false); // Ethereum address
});
it('should reject keys with wrong prefix', () => {
const wrongPrefix = 'ABRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H';
expect(isValidStellarAddress(wrongPrefix)).toBe(false);
});
it('should reject keys with wrong length', () => {
expect(isValidStellarAddress('GBSHORT')).toBe(false);
expect(isValidStellarAddress('G' + 'A'.repeat(100))).toBe(false);
});
});Could you add these tests before we merge? Thanks! |
Contributor
|
hi @vicajohn please fix conflicts |
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.
Routes updated:
Description
Closes #issue_number_here
Changes proposed
What were you told to do?
What did you do?
Check List (Check all the applicable boxes)
🚨Please review the contribution guideline for this repository.
Screenshots/Videos