-
Notifications
You must be signed in to change notification settings - Fork 51
fix: withdraw amounts fix #2105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
❌ Deploy Preview for kleros-v2-university failed. Why did it fail? →
|
✅ Deploy Preview for kleros-v2-testnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for kleros-v2-testnet-devtools ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughComputes a new maxWithdrawAmount from jurorBalance (min(pending, total-locked)), exposes a formatted parsedMaxWithdrawAmount, replaces parsedStake usages with it, updates withdrawal validation and error messaging, and adds the new value to effect dependencies. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as InputDisplay
participant State as jurorBalance
participant Validator
User->>UI: Enter amount or click "Withdraw all"
UI->>State: Read jurorBalance [total, locked, pending] (or absent)
State-->>UI: jurorBalance values / undefined
UI->>UI: Compute maxWithdrawAmount = min(pending, total - locked) || 0
UI->>Validator: Validate requested amount ≤ maxWithdrawAmount
alt amount ≤ maxWithdrawAmount
Validator-->>UI: Valid
UI-->>User: Enable withdraw action
else amount > maxWithdrawAmount
Validator-->>UI: Invalid (error text shown)
UI-->>User: Show "Insufficient available amount to withdraw this amount."
end
note right of UI: "Withdraw all" fills parsedMaxWithdrawAmount
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for kleros-v2-neo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx (2)
95-97
: Message reads a bit awkward; tighten phrasing.The validation is correct. Consider a clearer copy:
- setErrorMsg("Insufficient available amount to withdraw this amount"); + setErrorMsg("Insufficient withdrawable amount.");
113-117
: UI swap to max-withdrawable looks right; avoid shadowing prop name.The display/update behavior is correct. Minor readability nit: the local
const amount = …
shadows theamount
prop.- <StyledLabel - onClick={() => { - const amount = isStaking ? parsedBalance : parsedMaxWithdrawAmount; - setAmount(amount); - }} - > + <StyledLabel + onClick={() => { + const allAmount = isStaking ? parsedBalance : parsedMaxWithdrawAmount; + setAmount(allAmount); + }} + >
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx
(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2024-12-09T12:36:59.441Z
Learnt from: Harman-singh-waraich
PR: kleros/kleros-v2#1775
File: web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx:0-0
Timestamp: 2024-12-09T12:36:59.441Z
Learning: In the `StakeWithdrawButton` component, the transaction flow logic is tightly linked to component updates, so extracting it into a custom hook does not provide significant benefits.
Applied to files:
web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx
📚 Learning: 2024-11-19T16:31:08.965Z
Learnt from: jaybuidl
PR: kleros/kleros-v2#1746
File: contracts/config/courts.v2.mainnet-neo.json:167-170
Timestamp: 2024-11-19T16:31:08.965Z
Learning: In `contracts/config/courts.v2.mainnet-neo.json`, the `minStake` parameter is denominated in PNK, not ETH.
Applied to files:
web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: Redirect rules - kleros-v2-testnet-devtools
- GitHub Check: Redirect rules - kleros-v2-university
- GitHub Check: Redirect rules - kleros-v2-testnet
- GitHub Check: Redirect rules - kleros-v2-testnet
- GitHub Check: Header rules - kleros-v2-testnet-devtools
- GitHub Check: Header rules - kleros-v2-university
- GitHub Check: Header rules - kleros-v2-testnet
- GitHub Check: Header rules - kleros-v2-testnet
- GitHub Check: Pages changed - kleros-v2-testnet-devtools
- GitHub Check: Pages changed - kleros-v2-testnet
- GitHub Check: Pages changed - kleros-v2-testnet
- GitHub Check: Pages changed - kleros-v2-university
- GitHub Check: Analyze (javascript)
- GitHub Check: contracts-testing
🔇 Additional comments (1)
web/src/pages/Courts/CourtDetails/StakePanel/InputDisplay.tsx (1)
108-108
: Good call adding the new cap to dependencies.Including
maxWithdrawAmount
ensures validation updates when the cap changes. Looks correct given other direct uses ofjurorBalance
in the effect.
|
PR-Codex overview
This PR focuses on enhancing the
InputDisplay
component by calculating the maximum withdrawable amount for jurors and updating related error messages and displayed values accordingly.Detailed summary
maxWithdrawAmount
calculation based onjurorBalance
.parsedStake
withparsedMaxWithdrawAmount
in labels and logic.maxWithdrawAmount
to the dependency array inuseEffect
.Summary by CodeRabbit