Reject negative amounts on payable calls - #36
Conversation
A value like -1 passes parseEther and reached writeContract, where the serializer fails with a raw BigInt error. Negative amounts now get the same clear message as any other unreadable input.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟡 Changes recommended
The current negative check still allows inputs like “-0” to be accepted (parses to 0) and also introduces duplicated error-string logic that should be consolidated for correctness/consistency.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves input validation for payable contract writes by rejecting negative value amounts earlier, so users see a clear, field-specific error instead of a downstream BigInt serialization failure.
Changes:
- Adds a negative-amount guard for parsed payable
valuebefore callingwriteContract.
File summaries
| File | Description |
|---|---|
| src/components/simple-grid/layout/ExecutionSection.tsx | Adds validation to reject negative payable value inputs prior to contract execution. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (sendValue < 0n) { | ||
| throw new Error( | ||
| `Could not read "${rawValue}" as an amount. Use decimal ETH (0.1) or hex wei (0x...).`, | ||
| ); | ||
| } |
A value like
-1passesparseEtherand reachedwriteContract, where the serializer fails with a raw BigInt error instead of the field's own message. Negative amounts now get the same clear error as any other unreadable input.