[R-3] Change error for token amount invalid#834
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe L2TokenRegistry system refactors error handling by introducing a new ZeroTokenAmount error. The interface declaration is added, the calculateTokenAmount implementation updated to throw this error instead of InvalidPrice, and a test added to verify the error condition when ethAmount is zero. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
contracts/contracts/l2/system/L2TokenRegistry.sol (1)
403-416: Update documentation to mention the new error condition.The function documentation states it will revert if token is not registered or priceRatio is not set, but doesn't mention the new
ZeroTokenAmounterror condition.Consider updating line 415 to:
- * - Will revert if token is not registered or priceRatio is not set + * - Will revert if token is not registered, priceRatio is not set, or calculated tokenAmount is zero
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
contracts/contracts/l2/system/IL2TokenRegistry.sol(1 hunks)contracts/contracts/l2/system/L2TokenRegistry.sol(1 hunks)contracts/contracts/test/L2TokenRegistry.t.sol(1 hunks)
⏰ 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). (3)
- GitHub Check: test
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (rust)
🔇 Additional comments (3)
contracts/contracts/l2/system/IL2TokenRegistry.sol (1)
68-68: LGTM! Clear and descriptive error declaration.The new
ZeroTokenAmounterror improves error specificity for the token amount calculation edge case.contracts/contracts/l2/system/L2TokenRegistry.sol (1)
435-435: LGTM! More specific error improves clarity.The change from
InvalidPricetoZeroTokenAmountbetter describes the condition being checked. The error at line 427 correctly continues to useInvalidPricefor the unset ratio case.contracts/contracts/test/L2TokenRegistry.t.sol (1)
614-624: LGTM! Test properly validates the new error condition.The test correctly verifies that
calculateTokenAmountreverts withZeroTokenAmount()when called withethAmount = 0. The test setup and assertion are appropriate.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.