Location
components/TokenSelector.tsx:35 (regex); component-wide (test coverage)
Description
Two related gaps in the same file:
- The address-validation regex
/^[GC][A-Z0-9]{55}$/ accepts characters (0, 1, 8, 9) that can never appear in a valid Stellar StrKey address (base32, RFC4648 alphabet A-Z2-7), deferring the real error to a much worse network-level failure message. It also accepts a G-prefixed (account) address for a field that, per its purpose (selecting a token contract), should only accept C-prefixed (contract) addresses.
- This component has real async data-fetching, abort-handling, and error-branching logic, but no corresponding test file at all, unlike most comparable components in
components/stream/.
Why it matters
Users get a confusing late-stage RPC error instead of immediate client-side validation feedback, and could paste an account address into a token-contract field with no warning. The complete lack of tests is exactly why this regex bug went unnoticed.
Suggested fix
Fix the regex to /^C[A-Z2-7]{55}$/ (contract addresses only, correct alphabet), or use the Stellar SDK's own StrKey validation helpers. Add components/TokenSelector.test.tsx covering valid/invalid address input, loading state, abort/cancellation on rapid re-selection, error display, and a regression test for this exact regex bug.
Acceptance criteria
Location
components/TokenSelector.tsx:35(regex); component-wide (test coverage)Description
Two related gaps in the same file:
/^[GC][A-Z0-9]{55}$/accepts characters (0,1,8,9) that can never appear in a valid Stellar StrKey address (base32, RFC4648 alphabetA-Z2-7), deferring the real error to a much worse network-level failure message. It also accepts aG-prefixed (account) address for a field that, per its purpose (selecting a token contract), should only acceptC-prefixed (contract) addresses.components/stream/.Why it matters
Users get a confusing late-stage RPC error instead of immediate client-side validation feedback, and could paste an account address into a token-contract field with no warning. The complete lack of tests is exactly why this regex bug went unnoticed.
Suggested fix
Fix the regex to
/^C[A-Z2-7]{55}$/(contract addresses only, correct alphabet), or use the Stellar SDK's ownStrKeyvalidation helpers. Addcomponents/TokenSelector.test.tsxcovering valid/invalid address input, loading state, abort/cancellation on rapid re-selection, error display, and a regression test for this exact regex bug.Acceptance criteria
C...) addressesTokenSelector.test.tsxexists with meaningful coverage of the async/validation/error paths, including a regression test for the regex fix