Description
When admins register a new SAC token, the on-chain registry trusts the declared decimals without verifying them. Add a self-test that calls the SAC's decimals() and rejects registration if the declared value does not match, preventing denomination mistakes that have caused real on-chain losses on other Stellar protocols.
Requirements and Context
- Cross-contract call inside
tokens.rs
- Mismatch returns
Error::TokenDecimalsMismatch
- Self-test runs on every register and on a manual
re_verify_token admin entrypoint
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b feature/token-decimals-self-test
- Implement changes
contracts/predictify-hybrid/src/tokens.rs
contracts/predictify-hybrid/src/custom_token_tests.rs
- Test and commit
cargo test -p predictify-hybrid token_decimals_self_test
- Cover edge cases
- Include test output and notes in the PR
Example commit message
feat: verify SAC decimals on token registration
Acceptance Criteria
Guidelines
- Validate auth, overflow, and storage TTL/archival
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
When admins register a new SAC token, the on-chain registry trusts the declared decimals without verifying them. Add a self-test that calls the SAC's
decimals()and rejects registration if the declared value does not match, preventing denomination mistakes that have caused real on-chain losses on other Stellar protocols.Requirements and Context
tokens.rsError::TokenDecimalsMismatchre_verify_tokenadmin entrypointSuggested Execution
contracts/predictify-hybrid/src/tokens.rscontracts/predictify-hybrid/src/custom_token_tests.rscargo test -p predictify-hybrid token_decimals_self_testExample commit message
Acceptance Criteria
re_verify_tokenis admin-gatedGuidelines