feat: add address validation to prevent saving invalid Ethereum addresses #50
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
Implements BUILD-1148 by adding comprehensive Ethereum address validation using viem's
isAddressfunction to prevent invalid address records from being saved to the database.Changes
✅ Add address validation utility (
src/utils/viem.ts)validateEthereumAddress()function that throws on invalid addressesisValidEthereumAddress()boolean helper functionisAddressfor robust validation (0x prefix, 42 chars, valid hex, EIP-55 checksum)✅ Update Users Service (
src/db/services/users-service.ts)createOrUpdateUser()- validates before adding addressessaveUserAddress()- validates before saving address recordsupdateAddressVerification()- validates before verification updatesgetUserByAddress()- validates lookup addresses✅ Update API Routes (
src/routes/users.ts)GET /address/:addressGET /address/:address/permissionsGET /verifications?address=...Validation Requirements
isAddressfunction as specifiedTest Results
Valid addresses accepted:
0x1234567890123456789012345678901234567890✅0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa✅Invalid addresses rejected:
0xgetuser1234567890123456789012345678901234❌ (non-hex chars)0xnonexistentaddress❌ (wrong length)invalid-address❌ (no 0x prefix)Test plan
🤖 Generated with Claude Code