fix(sdk): enforce native asset decimal precision (#259) - #348
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped to the reported bug, matches the acceptance criteria, and is backed by targeted boundary/regression tests.
Pull request overview
This PR fixes asset decimal validation in the SDK by applying the existing 7-decimal precision limit to native assets while preserving the 18-decimal limit for SAC assets, and adds regression coverage for the boundary conditions.
Changes:
- Use a type-specific maximum decimal precision (
MAX_STROOPS_DECIMALSfor native,MAX_TOKEN_DECIMALSfor SAC) duringdecimalsvalidation. - Update the thrown validation error message to reflect the correct maximum per asset type.
- Add tests covering lower/upper bounds for both asset types plus a SAC “above native limit” control.
File summaries
| File | Description |
|---|---|
| packages/sdk/src/asset-config.ts | Applies per-asset-type decimal precision caps during validation and reports the correct allowed range in errors. |
| packages/sdk/src/asset-config.test.ts | Adds boundary and regression tests to ensure native and SAC decimal limits are enforced as intended. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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 #259.
Uses the existing seven-decimal native limit and retains the 18-decimal SAC limit. Adds lower/upper boundary coverage for both asset types and a SAC-above-seven control.
Validation: SDK suite: 197 tests pass; SDK typecheck passes on the combined verification branch.