docs: add guideline to avoid Rust keywords as field names#148
docs: add guideline to avoid Rust keywords as field names#148saiintbrisson merged 1 commit intodevfrom
Conversation
Added explicit rules to both CLAUDE.md and CONTRIBUTING.md prohibiting the use of Rust keywords (type, use, trait, impl, etc.) as struct field names, especially in public APIs. Problem: Rust keywords require the r# prefix (e.g., r#type), which causes serialization inconsistencies across language bindings: - Polkadot.js converts to r_type or rType - Serde serializes as type - Creates confusion and breaks API consistency Solution: Use alternative names like kind, variant, scope, category, or mode instead. This guideline applies to all public structs, especially those in api crates and types exposed to external clients. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughAdds a new CLI crate to the workspace with actions for agents, balances, keys, namespaces, and staking; introduces an action framework and key management with encryption; updates codegen to emit fee estimation methods; refactors tests to use named account helpers; makes minor logic/style tweaks across pallets and tooling; updates Rust toolchain. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant CLI as torus-cli
participant Ctx as CliActionContext
participant Act as Action<A>
participant Net as TorusClient
User->>CLI: Parse args (clap)
CLI->>Ctx: Build context (json/testnet/dry-run)
CLI->>Act: A::create(ctx, params)
alt dry-run
CLI->>Act: estimate_fee(ctx)
CLI-->>User: Print DryRunResponse { fee }
else execute
CLI->>Act: confirmation_phrase(ctx)
CLI->>Ctx: confirm(desc)
CLI->>Act: execute(ctx)
Act->>Net: network call(s) (mainnet/testnet)
Act-->>CLI: ResponseData
CLI-->>User: Output (JSON or Display)
end
sequenceDiagram
autonumber
participant Gen as Codegen
participant API as Generated API
participant Signer as Signer<Keypair>
participant Node as Substrate Node
Gen->>API: Emit call(), wait(), and call_fee() for signed calls
User->>API: call_fee(args..., signer)
API->>Node: create_signed(call, signer).partial_fee_estimate()
Node-->>API: u128 fee
API-->>User: fee estimate
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Summary
Added explicit rules to both
CLAUDE.mdandCONTRIBUTING.mdprohibiting the use of Rust keywords (type,use,trait,impl, etc.) as struct field names, especially in public APIs.Addresses: https://github.com/renlabs-dev/torus-substrate/pull/140/files#r2337166593
Problem
Rust keywords require the
r#prefix (e.g.,r#type), which causes serialization inconsistencies across language bindings:r_typeorrTypetypeSolution
Use alternative names like
kind,variant,scope,category, ormodeinstead. This guideline applies to all public structs, especially those inapicrates and types exposed to external clients.Changes
CLAUDE.mdwith strict rules for AI code generationCONTRIBUTING.mdfor human developersTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation
Chores