Skip to content

fix(wallet): validate new admin address format in TransferAdminModal - #1022

Open
mayborn005 wants to merge 1 commit into
Iris-IV:mainfrom
mayborn005:fix/issue-810-transfer-admin-address-validation
Open

fix(wallet): validate new admin address format in TransferAdminModal#1022
mayborn005 wants to merge 1 commit into
Iris-IV:mainfrom
mayborn005:fix/issue-810-transfer-admin-address-validation

Conversation

@mayborn005

Copy link
Copy Markdown

Summary

TransferAdminModal accepted 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 — add isValidStellarPublicKey(address), a non-throwing check that uses StrKey.isValidEd25519PublicKey to verify the G prefix, correct length, and checksum (the existing validateStellarAddress only checks prefix/length). Tolerates surrounding whitespace.
  • src/components/TransferAdminModal.tsx — when a newAdminAddress is supplied, validate it before submit: render an inline role="alert" error (reusing the existing Admin.invalidAddress translation) and keep the confirm button disabled until the address is well-formed. The fee-confirmation usage (no address) is unaffected.

Acceptance criteria

  • Validate the address is a syntactically valid Stellar public key (G…, correct checksum/length) before allowing submit
  • Show an inline error for invalid addresses
  • Add a test covering both valid and invalid address input

Tests

  • src/__tests__/components/TransferAdminModal.test.tsx (new) — valid key: no error, submit enabled after typing CONFIRM, onConfirm fires; invalid address: inline error shown, submit stays disabled, onConfirm never fires.
  • src/__tests__/unit/validators.test.ts — direct coverage of isValidStellarPublicKey for valid, whitespace-padded, empty, wrong-prefix, and bad-checksum inputs.

Valid test vectors are generated with StrKey.encodeEd25519PublicKey so they always carry a correct checksum.

Out of scope

Closes #810

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
@drips-wave

drips-wave Bot commented Jul 31, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Wallet] TransferAdminModal does not validate the new admin address format before submit

2 participants