feat: validate token decimals during create_vault#592
Merged
1nonlypiece merged 3 commits intoJun 2, 2026
Conversation
Add token_decimals validation in create_vault rejecting tokens with unsupported decimals in accountability_vault. Changes: - Add Error::UnsupportedTokenDecimals (error code 400) - Add MIN_TOKEN_DECIMALS=0 and MAX_TOKEN_DECIMALS=18 constants - Query token::Client::decimals() during create_vault - Reject tokens whose decimals fall outside [0, 18] - Cache validated decimals in persistent storage (TokenDecimals key) - Add get_token_decimals() query function - Add 6 unit tests covering: * Valid decimals: 0, 7, 17, 18 (boundary tests) * Invalid decimals: 19, 255 (rejection tests) * Decimals NOT cached on rejection - Document the bound and rationale in contracts/README.md - Document fixed-decimals assumption in src/services/soroban.ts Rationale: - Backend src/services/soroban.ts assumes fixed decimals contract - JavaScript Number (IEEE 754) loses precision above ~15 digits - Stellar ecosystem standardizes on 7 decimals - ERC-20 caps at 18 decimals - Prevents overflow attacks with extreme decimal values Refs: Disciplr-Org#491
|
@dextro172-ui 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! 🚀 |
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.
Closes #491
Add token_decimals validation in create_vault rejecting tokens with unsupported decimals in accountability_vault.
Changes:
Rationale: