Skip to content

Reject negative amounts on payable calls - #36

Merged
Timidan merged 1 commit into
masterfrom
fix/reject-negative-value
Sep 8, 2026
Merged

Reject negative amounts on payable calls#36
Timidan merged 1 commit into
masterfrom
fix/reject-negative-value

Conversation

@Timidan

@Timidan Timidan commented Sep 8, 2026

Copy link
Copy Markdown
Owner

A value like -1 passes parseEther and reached writeContract, 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.

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.
Copilot AI lite review requested due to automatic review settings September 8, 2026 02:08
@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
web3-toolkit Building Building Preview Sep 8, 2026 2:08am UTC

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T02:10:54.849571Z f0b4e20 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Timidan
Timidan merged commit 5527e64 into master Sep 8, 2026
2 of 3 checks passed
@Timidan
Timidan deleted the fix/reject-negative-value branch September 8, 2026 02:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 value before calling writeContract.
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.

Comment on lines +548 to +552
if (sendValue < 0n) {
throw new Error(
`Could not read "${rawValue}" as an amount. Use decimal ETH (0.1) or hex wei (0x...).`,
);
}
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.

2 participants