Skip to content

SorobanPanel and TransactionPanel use unsafe unknown cast on FormEvent handler #581

Description

@k-deejah

Problem

src/components/SorobanPanel.tsx line 87 attaches the form's invoke handler to a button onClick via an unsafe cast:

onClick={invoke as unknown as React.MouseEventHandler}

invoke is typed async function invoke(e: React.FormEvent) and calls e.preventDefault(). When triggered via onClick it receives a MouseEvent, not a FormEvent. The cast through unknown silences a real TypeScript error instead of fixing it.

The identical anti-pattern appears in src/components/TransactionPanel.tsx on the Send Payment button — onClick={submit as unknown as React.MouseEventHandler} — where submit is also a FormEvent handler.

Both forms already have onSubmit wired correctly. The onClick override is entirely redundant, creates a runtime type mismatch, and means the e.preventDefault() call inside each handler operates on the wrong event type.

Solution

Remove the onClick prop from both buttons and change them to type="submit" so they trigger the parent <form onSubmit> natively. This is the correct HTML pattern and eliminates the cast entirely.

// Before
<Button onClick={invoke as unknown as React.MouseEventHandler}>

// After
<Button type="submit">

Acceptance Criteria

  • SorobanPanel.tsx Invoke button uses type="submit" with no onClick override
  • TransactionPanel.tsx Send Payment button uses type="submit" with no onClick override
  • No as unknown as casts remain in either component file
  • tsc --noEmit passes with no new type errors after the change
  • Forms submit correctly on button click and on Enter key press in any field

Note for Contributors: If you're assigned to this issue, write a clear and detailed description for your pull request. Explain what was changed, why it was needed, how it was implemented, and include any relevant testing or screenshots where applicable.

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't workingtypescriptType errors, unsafe casts, or missing types

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions