Reject deposit/withdraw amounts with invalid decimal precision - #506
Merged
ONEONUORA merged 3 commits intoJul 28, 2026
Merged
Conversation
- Add deserialize_whole_number helper that rejects fractional micro-unit amounts (e.g. 1000.5) with a clear error message - Apply custom deserializer to DepositRequest.amount and WithdrawRequest.amount — Axum returns HTTP 422 on failure - Add integration tests asserting 422 for fractional inputs and non-422 for whole-number inputs on both endpoints Naira token amounts are integer micro-units; sub-unit fractions are unrepresentable on-chain and must be rejected at the API boundary.
|
@Keengfk Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@Keengfk |
Contributor
|
@Keengfk |
Contributor
|
@Keengfk |
ONEONUORA
approved these changes
Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reject deposit/withdrawal amounts with invalid decimal precision
Naira token amounts are stored and processed as integer micro-units — the
smallest indivisible denomination on-chain. Fractional values like 1000.5 are
meaningless at the contract level and were previously either silently truncated
by serde or surfaced as an unhelpful type error.
Changes
backend/src/api/yield.rs that accepts any JSON number but rejects it with a
clear domain-specific error if it has a fractional part (checked via
f64::fract() != 0.0)
— Axum returns HTTP 422 Unprocessable Entity on failure
Testing
Existing yield endpoint tests remain unchanged and continue to cover balance,
history, toggle-auto, deposit, and withdraw flows.
closes #478