fix: convert proto enum values via *ToJSON/*FromJSON for REST and serialization consistency#158
fix: convert proto enum values via *ToJSON/*FromJSON for REST and serialization consistency#158
Conversation
…ialization consistency
WalkthroughUpdates enum field serialization across REST API and governance modules to use JSON string representations. The Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches. Re-running this action after a short time may resolve the issue. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/client/rest/api/MstakingAPI.ts`:
- Line 68: The request builder in MstakingAPI.ts currently uses a truthy check
for the enum param (e.g., "{ ...params, status: status ?
bondStatusToJSON(status) : undefined }") which drops valid enum value 0; change
the conditional to an explicit undefined/null check (e.g., check status !==
undefined and status !== null) so bondStatusToJSON(status) is used for valid
numeric values including 0; apply the same fix to the other occurrence that uses
the same truthy pattern around bondStatusToJSON.
In `@src/core/mstaking/Validator.ts`:
- Line 193: The Validator.Amino/Validator.Data types currently force status:
string which breaks callers passing numeric enum values; update the status
property type to accept both string and numeric enum inputs (e.g., string |
number) so Validator.fromAmino and any callers (see Validator.fromAmino and
bondStatusFromJSON usage) remain compatible with numeric status values; adjust
both occurrences of status in the Validator type definitions accordingly and
ensure Validator.fromAmino continues to call bondStatusFromJSON to normalize the
value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7b4a8609-ec78-4cac-a96e-08a30ebeb873
📒 Files selected for processing (6)
src/client/rest/api/MstakingAPI.spec.tssrc/client/rest/api/MstakingAPI.tssrc/core/gov/Vote.tssrc/core/gov/msgs/MsgVote.tssrc/core/gov/msgs/MsgVoteLegacy.tssrc/core/mstaking/Validator.ts
*ToJSON()/*FromJSON()conversion in MstakingAPI query params, Validator, MsgVote, MsgVoteLegacy, and WeightedVoteOptionSummary by CodeRabbit
Tests
Refactor