-
Notifications
You must be signed in to change notification settings - Fork 20
fix: improve decimal handling for enhanced accuracy in order processing #629
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
Conversation
WalkthroughAdded temporary debug/info logging in Starknet order creation and client build flows; refined a token decimals parameter type and adjusted downstream casts in Voyager event/transfer transformation code. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 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). (1)
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
services/voyager.go (1)
1052-1076: Validate tokenDecimals is a whole number and check int8 overflow risk before casting.The direct cast of
float64toint8at line 1076 introduces type safety and overflow concerns:
Silent truncation of fractional values: Token decimals represent discrete decimal places (e.g., 6, 18) and must be integers. The current code accepts float64 values without validating they are whole numbers. A value like 18.5 would pass the
tokenDecimals <= 0check and silently truncate to 18 when cast toint8.int8 overflow risk: Casting
float64toint8(range: -128 to 127) will produce undefined behavior for decimals ≥ 128. While uncommon, the Voyager API returning unexpected values could silently corrupt calculations.Fix: Validate that
tokenDecimalsis a whole number and either check the range before casting toint8or use a larger integer type likeintorint16.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
services/order/starknet.go(2 hunks)services/starknet/client.go(1 hunks)services/voyager.go(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
services/order/starknet.go (1)
utils/logger/logger.go (3)
WithFields(76-109)Fields(73-73)Errorf(141-146)
services/starknet/client.go (1)
utils/logger/logger.go (3)
WithFields(76-109)Fields(73-73)Infof(125-130)
⏰ 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). (1)
- GitHub Check: build-and-test
🔇 Additional comments (1)
services/starknet/client.go (1)
424-427: LGTM! Good observability enhancement.The INFO-level logging of order amount components before building the transaction request provides useful operational visibility without exposing sensitive data.
…improved accuracy
Description
References
Testing
Checklist
mainBy submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.
Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.