-
Notifications
You must be signed in to change notification settings - Fork 235
fix: add scalar for cosmos.Dec #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThis update enhances several protobuf schema files across various modules by adding or updating field options and imports. Specifically, it introduces Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ProtobufMessage
participant CosmosSDK
participant AminoEncoder
Client->>ProtobufMessage: Send/Receive message with decimal fields
ProtobufMessage->>CosmosSDK: Map decimal fields as cosmos.Dec (via scalar option)
ProtobufMessage->>AminoEncoder: Serialize fields (respect dont_omitempty = true)
CosmosSDK-->>Client: Return processed message
AminoEncoder-->>Client: Return encoded message
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (8)
x/distribution/types/distribution.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
x/dynamic-fee/types/types.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
x/move/types/tx.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
x/move/types/types.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
x/mstaking/types/staking.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
x/mstaking/types/tx.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
x/reward/types/query.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
x/reward/types/types.pb.go
is excluded by!**/*.pb.go
,!**/*.pb.go
📒 Files selected for processing (8)
proto/initia/distribution/v1/distribution.proto
(3 hunks)proto/initia/dynamicfee/v1/types.proto
(2 hunks)proto/initia/move/v1/tx.proto
(1 hunks)proto/initia/move/v1/types.proto
(6 hunks)proto/initia/mstaking/v1/staking.proto
(3 hunks)proto/initia/mstaking/v1/tx.proto
(1 hunks)proto/initia/reward/v1/query.proto
(2 hunks)proto/initia/reward/v1/types.proto
(3 hunks)
🧰 Additional context used
🪛 Buf (1.47.2)
proto/initia/mstaking/v1/staking.proto
4-4: import "amino/amino.proto": file does not exist
(COMPILE)
proto/initia/reward/v1/query.proto
4-4: import "amino/amino.proto": file does not exist
(COMPILE)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Run test and upload codecov
- GitHub Check: golangci-lint
- GitHub Check: Analyze (go)
🔇 Additional comments (15)
proto/initia/mstaking/v1/staking.proto (4)
23-25
: Best practice: Proper scalar and amino options for decimal fieldsAdding
(cosmos_proto.scalar) = "cosmos.Dec"
and(amino.dont_omitempty) = true
to decimal fields is a best practice for Cosmos SDK compatibility and Amino serialization. This ensures correct type mapping and prevents omission of zero values.
31-33
: Best practice: Consistent scalar and amino options for max_rateThe same options for
max_rate
as forrate
ensure uniform handling of decimal fields.
39-41
: Best practice: Consistent scalar and amino options for max_change_rateThe same options for
max_change_rate
as for other commission fields ensure uniform handling of decimal fields.
346-348
: Best practice: Consistent scalar and amino options for min_commission_rateThe same options for
min_commission_rate
as for other commission fields ensure uniform handling of decimal fields.proto/initia/mstaking/v1/tx.proto (1)
96-98
: Best practice: Proper scalar and amino options for commission_rateAdding
(cosmos_proto.scalar) = "cosmos.Dec"
and(amino.dont_omitempty) = true
to thecommission_rate
field is a best practice for Cosmos SDK compatibility and Amino serialization. This ensures correct type mapping and prevents omission of zero values.proto/initia/distribution/v1/distribution.proto (2)
22-23
: Best practice: Proper scalar and amino options for community_taxAdding
(cosmos_proto.scalar) = "cosmos.Dec"
and(amino.dont_omitempty) = true
to thecommunity_tax
field is a best practice for Cosmos SDK compatibility and Amino serialization.
40-41
: Best practice: Proper scalar and amino options for weightAdding
(cosmos_proto.scalar) = "cosmos.Dec"
and(amino.dont_omitempty) = true
to theweight
field is a best practice for Cosmos SDK compatibility and Amino serialization.proto/initia/move/v1/tx.proto (1)
312-313
: Best practice: Proper scalar and amino options for reward_weightAdding
(cosmos_proto.scalar) = "cosmos.Dec"
and(amino.dont_omitempty) = true
to thereward_weight
field is a best practice for Cosmos SDK compatibility and Amino serialization.proto/initia/reward/v1/query.proto (1)
51-52
: Best practice: Proper scalar and amino options for annual_provisionsAdding
(cosmos_proto.scalar) = "cosmos.Dec"
and(amino.dont_omitempty) = true
to theannual_provisions
field is a best practice for Cosmos SDK compatibility and Amino serialization.proto/initia/dynamicfee/v1/types.proto (2)
5-5
: Import ofcosmos_proto/cosmos.proto
is correct and necessary.This import is required for the new scalar annotations and is a standard practice in Cosmos SDK protobuf files.
17-17
: Addition of(cosmos_proto.scalar) = "cosmos.Dec"
is correct and improves type safety.Annotating decimal fields with the scalar option ensures proper type mapping in generated code and aligns with Cosmos SDK conventions.
Also applies to: 25-25, 33-33, 41-41
proto/initia/reward/v1/types.proto (2)
5-5
: Import ofcosmos_proto/cosmos.proto
is correct and required for scalar annotations.This is a necessary addition for the new field options.
29-30
: Scalar and Amino annotations for decimal fields are correct and improve serialization consistency.These annotations ensure proper type mapping and serialization behavior for decimal fields, aligning with Cosmos SDK and Amino standards.
Also applies to: 40-41
proto/initia/move/v1/types.proto (2)
5-5
: Import ofcosmos_proto/cosmos.proto
is correct and required for scalar annotations.This import is necessary for the new field options.
23-23
: Addition of(cosmos_proto.scalar) = "cosmos.Dec"
is correct and improves type mapping.These annotations ensure that decimal fields are properly mapped in generated code, following Cosmos SDK conventions.
Also applies to: 33-33, 55-55, 65-65
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #391 +/- ##
=======================================
Coverage 40.07% 40.07%
=======================================
Files 294 294
Lines 27511 27511
=======================================
Hits 11025 11025
Misses 14785 14785
Partials 1701 1701 🚀 New features to boost your workflow:
|
Description
https://docs.cosmos.network/main/build/building-modules/protobuf-annotations#scalar
Add
cosmos_scalar
for protogen clientsAuthor Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...