-
Notifications
You must be signed in to change notification settings - Fork 46
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
fix(web): min-stake-check #1815
Conversation
WalkthroughThe pull request modifies the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
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 site configuration. |
✅ Deploy Preview for kleros-v2-testnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for kleros-v2-university ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Code Climate has analyzed commit 9df6816 and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
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: 0
🧹 Nitpick comments (1)
web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx (1)
270-272
: LGTM! Consider enhancing the user feedback.The changes correctly implement the minimum stake check by ensuring that the combined balance (
jurorBalance[2] + parsedAmount
) meets the court's minimum stake requirement. This prevents users from making invalid stake transactions.Consider setting a more descriptive error message when the button is disabled due to insufficient stake:
useEffect(() => { if (isPopupOpen) return; if (setStakeError || allowanceError) { setErrorMsg(parseWagmiError(setStakeError || allowanceError)); + } else if ( + action === ActionType.stake && + courtDetails && + jurorBalance && + parsedAmount !== 0n && + jurorBalance[2] + parsedAmount < BigInt(courtDetails?.court?.minStake) + ) { + setErrorMsg( + `Total stake would be below minimum requirement. Required: ${courtDetails.court.minStake}` + ); } }, [setStakeError, setErrorMsg, targetStake, allowanceError, isPopupOpen]);Also applies to: 290-290
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx
(2 hunks)
🧰 Additional context used
📓 Learnings (2)
📓 Common learnings
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.
web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx (1)
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.
Quality Gate passedIssues Measures |
✅ Deploy Preview for kleros-v2-testnet-devtools ready!
To edit notification comments on pull requests, go to your Netlify site 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.
lgtm
PR-Codex overview
This PR updates the logic in the
StakeWithdrawButton
component to include checks forjurorBalance
and modifies the conditions under which the button can be activated based on theparsedAmount
andcourtDetails
.Detailed summary
jurorBalance
in the condition.parsedAmount
is not zero and that the sum ofjurorBalance[2]
andparsedAmount
is less than the minimum stake fromcourtDetails
.jurorBalance
.Summary by CodeRabbit