-
Notifications
You must be signed in to change notification settings - Fork 7
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
Overall improvements in node admin for HOPRd 2.1.5 #640
Conversation
Warning Rate limit exceeded@mjadach-iv has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 0 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces several modifications across multiple components. The Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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 (
|
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
🧹 Outside diff range and nitpick comments (6)
src/components/Modal/node/AddAliasModal.tsx (2)
31-31
: Consider memoizing derived arrays for better performance.The arrays
aliasesArr
andaliasPeerIdsArr
are derived from thealiases
object on every render. Consider usinguseMemo
to prevent unnecessary recalculations.- const aliasesArr = aliases ? Object.keys(aliases) : []; - const aliasPeerIdsArr = aliases ? Object.values(aliases) : []; + const aliasesArr = useMemo(() => (aliases ? Object.keys(aliases) : []), [aliases]); + const aliasPeerIdsArr = useMemo(() => (aliases ? Object.values(aliases) : []), [aliases]);Also applies to: 34-35
163-165
: Consider enhancing the error message with more details.While the error feedback is good, it could be more helpful by showing which alias is already using this Peer ID.
- helperText={duplicatePeerId ? 'This Peer Id already has an alias!' : ''} + helperText={duplicatePeerId ? `This Peer ID is already aliased as "${Object.keys(aliases || {}).find(key => aliases[key] === peerId)}"` : ''}src/components/Modal/node/WithdrawModal.tsx (3)
110-110
: Consider refactoring for better maintainabilityThe current implementation duplicates logic between HOPR and NATIVE currency handling.
Consider simplifying the code:
const setMaxAmount = () => { - if (currency === 'HOPR' && hoprBalance.formatted) { - set_amount(hoprBalance.formatted); - set_maxAmount(hoprBalance.formatted); - } else if (currency === 'NATIVE' && nativeBalance.formatted) { - set_amount(nativeBalance.formatted); - set_maxAmount(nativeBalance.formatted); - } + const balance = currency === 'HOPR' ? hoprBalance : nativeBalance; + if (balance.formatted) { + set_amount(balance.formatted); + set_maxAmount(balance.formatted); + } };Also applies to: 113-113
204-215
: Consider using numeric comparison for balance checksString comparison with "0" could be fragile. Consider using numeric comparison for better reliability.
- disabled={!nativeBalance.value || nativeBalance.value === "0"} + disabled={!nativeBalance.value || BigInt(nativeBalance.value) === BigInt(0)} - disabled={!hoprBalance.value || hoprBalance.value === "0"} + disabled={!hoprBalance.value || BigInt(hoprBalance.value) === BigInt(0)}
235-235
: Consider standardizing address shorteningThe current implementation has hardcoded indices and inconsistent fallback format.
Consider creating a reusable utility:
const shortenAddress = (address: string) => address ? `${address.slice(0, 6)}...${address.slice(-4)}` : '';Then use it consistently:
- placeholder={ safeAddress ? `${safeAddress.substring(0,6)}...${safeAddress.substring(38)}` : "0x4f5a...1728" } + placeholder={ safeAddress ? shortenAddress(safeAddress) : shortenAddress("0x4f5a1728") }src/pages/node/info/index.tsx (1)
328-338
: Consider adding type safety checks for ticket price formattingThe current implementation assumes ticketPrice is always a valid string for BigInt conversion. Consider adding validation to handle potential edge cases.
- <td>{ticketPrice ? formatEther(BigInt(ticketPrice as string)) : '-'} wxHOPR</td> + <td> + {ticketPrice ? ( + try { + formatEther(BigInt(ticketPrice as string)) + } catch (e) { + console.error('Invalid ticket price format:', e); + return '-'; + } + ) : '-'} wxHOPR + </td>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
src/components/Modal/node/AddAliasModal.tsx
(4 hunks)src/components/Modal/node/WithdrawModal.tsx
(4 hunks)src/pages/node/info/index.tsx
(2 hunks)src/pages/node/tickets.tsx
(0 hunks)
💤 Files with no reviewable changes (1)
- src/pages/node/tickets.tsx
🔇 Additional comments (8)
src/components/Modal/node/AddAliasModal.tsx (4)
43-47
: LGTM! Good addition of duplicate peer ID validation.
The validation logic correctly prevents users from creating multiple aliases for the same peer ID.
66-66
: LGTM! Proper state cleanup.
Good practice to reset the validation state when closing the modal.
181-181
: LGTM! Comprehensive form validation.
The button's disabled state correctly accounts for all invalid input conditions, including the new duplicate peer ID check.
Line range hint 1-194
: Verify consistent validation patterns across other modal components.
Let's ensure other components that handle peer IDs implement similar validation patterns for consistency.
src/components/Modal/node/WithdrawModal.tsx (3)
79-79
: LGTM: Robust validation implementation
The new validation checks effectively prevent invalid withdrawals with proper precision handling using parseEther
.
Also applies to: 86-86, 91-93
242-247
: LGTM: Comprehensive button validation
The validation checks effectively prevent invalid withdrawals by ensuring all required conditions are met.
229-229
: Consider adding decimal place validation
While step="any"
allows flexible input, consider adding validation for maximum decimal places based on token precision.
src/pages/node/info/index.tsx (1)
68-68
: LGTM: Redux selector implementation is correct
The state management follows Redux best practices with proper selector usage.
Changelog:
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
These updates improve user experience by providing clearer feedback and more robust functionality across the application.