Skip to content

Comments

feat: update to chain v1.18 + generation fixes#9

Open
gorgos wants to merge 5 commits intodevfrom
feat/update-injective-std
Open

feat: update to chain v1.18 + generation fixes#9
gorgos wants to merge 5 commits intodevfrom
feat/update-injective-std

Conversation

@gorgos
Copy link
Member

@gorgos gorgos commented Feb 9, 2026

Summary by CodeRabbit

  • New Features

    • Chainlink Data Streams oracle support: new queries and messaging for Chainlink feeds
    • Bridge rate‑limiting: configure per‑token limits and manage rate‑limit rules
    • Permissions: contract and EVM hook configuration for namespace-level access control
  • Improvements

    • More flexible enum (de)serialization for better interoperability
    • Wider hashing/equality support across protocol types for improved compatibility and collection usage

@gorgos gorgos requested a review from jbernal87 February 9, 2026 00:27
@coderabbitai
Copy link

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

Bumps package/submodule; adds a generic enum_i32 serde deserializer; adds widespread Hash derives and removes many clippy allow attrs across generated protobuf types; introduces new Injective types (Chainlink data streams, Peggy rate-limits, JailReason, permissions fields); and updates proto-build transformers for enhanced serde aliasing.

Changes

Cohort / File(s) Summary
Versioning & Submodule
packages/injective-std/Cargo.toml, dependencies/injective-core
Bump injective-std version (1.16.4-1 → 1.18.0) and update submodule pointer.
Serde additions
packages/injective-std/src/serde/mod.rs
Add public enum_i32 module: generic deserializer that accepts integer or string enum representations.
Shim updates
packages/injective-std/src/shim.rs
Add Hash to derives for protobuf wrapper types (Timestamp, Duration, Any).
Proto-build & transformers
packages/proto-build-injective/src/transform.rs, packages/proto-build-injective/src/transformers.rs
Add transformers (allow_serde_enum_str_or_int, serde_alias_is_perpetual); emit serde rename/alias for enums; restrict int-as-string handling to 64-bit types; narrow type URL discovery.
CometBFT / ABCI / consensus types
packages/injective-std/src/types/cometbft/...
Widespread addition of Hash derives, removal of many #[allow(clippy::derive_partial_eq_without_eq)], and migration of many enum fields to enum_i32 deserialization. Review serde paths and hashing implications.
Cosmos & CosmWasm generated types
packages/injective-std/src/types/cosmos/..., packages/injective-std/src/types/cosmwasm/...
Add Hash broadly across bank/auth/gov/params/staking/wasm types; remove clippy allows; switch many enum (de)serializers to enum_i32; add enum rename/alias attributes.
Injective modules (features & types)
packages/injective-std/src/types/injective/...
Add Hash widely; introduce Chainlink data streams types/queries/events; add Peggy rate-limiting types (RateLimit, BridgeTransfer, MsgCreate/Update/RemoveRateLimit); add JailReason enum; change permissions (wasm_hook → wasm_hook + evm_hook) and tokenfactory/wasmx message field updates. Review new fields, deprecated Band items, and backward compatibility.
Many other generated modules
packages/injective-std/src/types/... (multiple files)
Numerous repetitive updates: add Hash to derives, remove clippy allow attrs, and adjust enum serde handling across many generated modules. Expect many small, similar changes per file.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Poem

🐇 I hopped through crates and protobuf plains,
I added Hash to types and tuned serde veins.
Chainlink whispers, Peggy counts the pace,
Enums read names or numbers with grace.
Version bumped — I bounded off, nose to race!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: update to chain v1.18 + generation fixes' accurately reflects the main objective: upgrading to chain v1.18 and applying generation/serialization improvements (Hash derives, enum deserialization changes).
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/update-injective-std

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/injective-std/src/types/cometbft/rpc/grpc/v1beta1.rs (1)

18-25: ⚠️ Potential issue | 🟠 Major

ResponseBroadcastTx is missing Hash unlike its sibling types.

This struct doesn't derive Hash while RequestPing, RequestBroadcastTx, and ResponsePing do. The nested field types (ResponseCheckTx, ResponseDeliverTx) also don't implement Hash, preventing ResponseBroadcastTx from deriving it. To add Hash here, the nested types must derive it first.

🧹 Nitpick comments (5)
packages/injective-std/src/types/injective/auction/v1beta1.rs (1)

84-105: Consider deriving Hash for the remaining message types in this module.

EventAuctionStart and QueryCurrentAuctionBasketResponse still lack Hash while adjacent message types now include it. If the intent is module-wide hashability, aligning these two improves API consistency.

Suggested patch
-#[derive(Clone, PartialEq, Eq, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
+#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
 pub struct EventAuctionStart {
-#[derive(Clone, PartialEq, Eq, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
+#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
 pub struct QueryCurrentAuctionBasketResponse {

Also applies to: 162-188

packages/proto-build-injective/src/transformers.rs (1)

772-794: Add tests for enum renames + enum deserializer injection.

The new enum rename logic and allow_serde_enum_str_or_int helper aren’t covered by tests yet. Please add targeted tests to lock in serde rename/alias emission and the enum deserializer attribute insertion to avoid regressions.

packages/injective-std/src/types/injective/peggy/v1.rs (1)

765-795: Consider deriving Hash for RateLimit to match other public types.
Most public Peggy structs now derive Hash; adding it here avoids trait-bound surprises when RateLimit is used in HashMap/HashSet.

♻️ Suggested change
-#[derive(Clone, PartialEq, Eq, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
+#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
 pub struct RateLimit {
packages/injective-std/src/types/cosmos/auth/module/v1.rs (1)

3-15: Consider adding Hash to Module for consistency.

Now that ModuleAccountPermission derives Hash, the Module struct could also derive Hash since all its fields would be hashable (String, Vec<ModuleAccountPermission>, String). This would maintain consistency with the PR's goal of expanding Hash derives across types.

♻️ Optional: Add Hash to Module
-#[derive(Clone, PartialEq, Eq, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
+#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message, ::serde::Serialize, ::serde::Deserialize, ::schemars::JsonSchema, CosmwasmExt)]
packages/injective-std/src/types/cometbft/abci/v1beta1.rs (1)

576-594: Missing serde attributes on some response_apply_snapshot_chunk::Result variants.

The variants Retry, RetrySnapshot, and RejectSnapshot (lines 589-593) lack the #[serde(rename)] and #[serde(alias)] attributes that other variants in this enum have. This creates an inconsistency where Unknown, Accept, and Abort serialize/deserialize with uppercase names and PascalCase aliases, while the remaining variants use default serde behavior.

If this is intentional for backward compatibility, please disregard. Otherwise, consider adding the missing attributes for consistency:

♻️ Suggested fix for consistency
         /// Retry chunk (combine with refetch and reject)
+        #[serde(rename = "RETRY")]
+        #[serde(alias = "Retry")]
         Retry = 3,
         /// Retry snapshot (combine with refetch and reject)
+        #[serde(rename = "RETRY_SNAPSHOT")]
+        #[serde(alias = "RetrySnapshot")]
         RetrySnapshot = 4,
         /// Reject this snapshot, try others
+        #[serde(rename = "REJECT_SNAPSHOT")]
+        #[serde(alias = "RejectSnapshot")]
         RejectSnapshot = 5,

Comment on lines 253 to 255
#[prost(enumeration = "ClaimType", tag = "1")]
#[serde(
serialize_with = "crate::serde::as_str::serialize",
deserialize_with = "crate::serde::as_str::deserialize"
)]
#[serde(deserialize_with = "crate::serde::enum_i32::deserialize::<ClaimType, _>")]
pub attestation_type: i32,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

rg -n "enum_i32::(de|ser)erialize" -g '*.rs'

Repository: InjectiveLabs/injective-rust

Length of output: 54


🏁 Script executed:

rg -n "EventAttestationObserved|EventValidatorJailed" -g '*.rs'

Repository: InjectiveLabs/injective-rust

Length of output: 527


🏁 Script executed:

wc -l packages/injective-std/src/types/injective/peggy/v1.rs

Repository: InjectiveLabs/injective-rust

Length of output: 131


🏁 Script executed:

sed -n '251,260p' packages/injective-std/src/types/injective/peggy/v1.rs

Repository: InjectiveLabs/injective-rust

Length of output: 527


🏁 Script executed:

sed -n '629,640p' packages/injective-std/src/types/injective/peggy/v1.rs

Repository: InjectiveLabs/injective-rust

Length of output: 564


🏁 Script executed:

find . -type f -name "*.rs" -path "*/serde/*" | head -20

Repository: InjectiveLabs/injective-rust

Length of output: 113


🏁 Script executed:

cat packages/injective-std/src/serde/mod.rs

Repository: InjectiveLabs/injective-rust

Length of output: 2687


Add serialize helper for enum_i32 fields to match deserialization contract.
The enum_i32 serde helper only implements deserialize, not serialize. This causes JSON output to emit numeric i32 values instead of string enum names. Applies to both attestation_type in EventAttestationObserved (line 254) and reason in EventValidatorJailed (line 632). If the API expects string names for these enums, add a matching serialize_with helper (or extend the enum_i32 module to provide one), similar to the as_str module pattern used for other fields.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
packages/proto-build-injective/src/transformers.rs (2)

163-288: Consider extracting common field transformation logic.

Multiple transformer functions (allow_serde_int_as_str, allow_serde_enum_str_or_int, serde_alias_id_with_uppercased, serde_alias_is_perpetual) share identical boilerplate for iterating fields and rebuilding the struct. A helper could reduce duplication.

♻️ Optional: Extract a field transformation helper
fn transform_struct_fields<F>(s: ItemStruct, f: F) -> ItemStruct
where
    F: FnMut(syn::Field) -> syn::Field,
{
    let fields_vec: Vec<syn::Field> = s.fields.clone().into_iter().map(f).collect();
    let fields_named: syn::FieldsNamed = parse_quote! { { #(`#fields_vec`,)* } };
    syn::ItemStruct {
        fields: syn::Fields::Named(fields_named),
        ..s
    }
}

// Usage:
pub fn serde_alias_is_perpetual(s: ItemStruct) -> ItemStruct {
    transform_struct_fields(s, |mut field| {
        if let Some(ident) = &field.ident {
            if ident == "is_perpetual" {
                let serde_alias: syn::Attribute = parse_quote! {
                    #[serde(alias = "isPerpetual")]
                };
                field.attrs.push(serde_alias);
            }
        }
        field
    })
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/proto-build-injective/src/transformers.rs` around lines 163 - 288,
Several transformer functions (allow_serde_int_as_str,
allow_serde_enum_str_or_int, serde_alias_id_with_uppercased,
serde_alias_is_perpetual) duplicate the same fields iteration and struct rebuild
boilerplate; extract a helper like transform_struct_fields(s: ItemStruct, f:
impl FnMut(syn::Field) -> syn::Field) -> ItemStruct that clones fields, maps the
provided closure over each field, rebuilds syn::FieldsNamed and returns a new
ItemStruct, then refactor each transformer to call this helper and move the
per-field mutation logic (adding serde attributes, checking types/idents, etc.)
into the closure (use field.attrs.push or append as appropriate) so the core
iteration/reconstruction is shared.

264-288: Consider generalizing to handle all is_* fields.

This function only handles is_perpetual. If other is_* fields may need similar camelCase aliasing in the future, consider generalizing:

♻️ Optional: Generalize to handle any `is_*` field
-pub fn serde_alias_is_perpetual(s: ItemStruct) -> ItemStruct {
+pub fn serde_alias_is_fields(s: ItemStruct) -> ItemStruct {
     let fields_vec = s
         .fields
         .clone()
         .into_iter()
         .map(|mut field| {
             if let Some(ident) = &field.ident {
-                if ident == "is_perpetual" {
+                let ident_str = ident.to_string();
+                if ident_str.starts_with("is_") {
+                    // Convert is_foo to isFoo
+                    let camel = format!("is{}", ident_str[3..].to_upper_camel_case());
                     let serde_alias: syn::Attribute = parse_quote! {
-                        #[serde(alias = "isPerpetual")]
+                        #[serde(alias = `#camel`)]
                     };
                     field.attrs.append(&mut vec![serde_alias]);
                 }
             }
             field
         })
         .collect::<Vec<syn::Field>>();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/proto-build-injective/src/transformers.rs` around lines 264 - 288,
The serde_alias_is_perpetual function currently only adds a #[serde(alias =
"isPerpetual")] for the field named "is_perpetual"; change it to handle any
field whose identifier starts with "is_" by computing a camelCase alias from the
snake_case ident (e.g. "is_perpetual_option" -> "isPerpetualOption") and adding
#[serde(alias = "<camelCase>"] to that field's attrs. Update the mapping in
serde_alias_is_perpetual (where fields_vec is built and the code checks
field.ident) to: check ident.as_ref().to_string().starts_with("is_"), compute
the alias string by splitting on '_' and capitalizing subsequent segments, skip
adding the alias if it already exists, and append the new serde alias attribute
to field.attrs; leave other code (fields_named, fields, and returning
syn::ItemStruct) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/proto-build-injective/src/transformers.rs`:
- Around line 163-288: Several transformer functions (allow_serde_int_as_str,
allow_serde_enum_str_or_int, serde_alias_id_with_uppercased,
serde_alias_is_perpetual) duplicate the same fields iteration and struct rebuild
boilerplate; extract a helper like transform_struct_fields(s: ItemStruct, f:
impl FnMut(syn::Field) -> syn::Field) -> ItemStruct that clones fields, maps the
provided closure over each field, rebuilds syn::FieldsNamed and returns a new
ItemStruct, then refactor each transformer to call this helper and move the
per-field mutation logic (adding serde attributes, checking types/idents, etc.)
into the closure (use field.attrs.push or append as appropriate) so the core
iteration/reconstruction is shared.
- Around line 264-288: The serde_alias_is_perpetual function currently only adds
a #[serde(alias = "isPerpetual")] for the field named "is_perpetual"; change it
to handle any field whose identifier starts with "is_" by computing a camelCase
alias from the snake_case ident (e.g. "is_perpetual_option" ->
"isPerpetualOption") and adding #[serde(alias = "<camelCase>"] to that field's
attrs. Update the mapping in serde_alias_is_perpetual (where fields_vec is built
and the code checks field.ident) to: check
ident.as_ref().to_string().starts_with("is_"), compute the alias string by
splitting on '_' and capitalizing subsequent segments, skip adding the alias if
it already exists, and append the new serde alias attribute to field.attrs;
leave other code (fields_named, fields, and returning syn::ItemStruct)
unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant