fix(wallet): validate new admin address format in TransferAdminModal - #1022
Open
mayborn005 wants to merge 1 commit into
Open
fix(wallet): validate new admin address format in TransferAdminModal#1022mayborn005 wants to merge 1 commit into
mayborn005 wants to merge 1 commit into
Conversation
TransferAdminModal previously accepted the target address without a client-side format check, so an invalid Stellar public key only failed after a Freighter signature prompt and a wasted transaction attempt. - Add isValidStellarPublicKey() to utils/validators, using StrKey to verify the G-prefix, length, and checksum (not just prefix/length). - Validate newAdminAddress in the modal: show an inline error and keep the confirm button disabled until a well-formed address is supplied. - Cover valid and invalid address input at both the validator and the modal (inline error + gated submit) level. Closes Iris-IV#810
|
@mayborn005 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Auto-review failed (API error). Leaving PR for human review. |
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
TransferAdminModalaccepted the target Stellar address without validating its format client-side. An invalid value only failed after a Freighter signature prompt and a wasted transaction attempt. This adds up-front validation with an inline error.Changes
src/utils/validators.ts— addisValidStellarPublicKey(address), a non-throwing check that usesStrKey.isValidEd25519PublicKeyto verify theGprefix, correct length, and checksum (the existingvalidateStellarAddressonly checks prefix/length). Tolerates surrounding whitespace.src/components/TransferAdminModal.tsx— when anewAdminAddressis supplied, validate it before submit: render an inlinerole="alert"error (reusing the existingAdmin.invalidAddresstranslation) and keep the confirm button disabled until the address is well-formed. The fee-confirmation usage (no address) is unaffected.Acceptance criteria
Tests
src/__tests__/components/TransferAdminModal.test.tsx(new) — valid key: no error, submit enabled after typing CONFIRM,onConfirmfires; invalid address: inline error shown, submit stays disabled,onConfirmnever fires.src/__tests__/unit/validators.test.ts— direct coverage ofisValidStellarPublicKeyfor valid, whitespace-padded, empty, wrong-prefix, and bad-checksum inputs.Valid test vectors are generated with
StrKey.encodeEd25519PublicKeyso they always carry a correct checksum.Out of scope
Closes #810