Fix/set contract label when create campaign#24
Conversation
WalkthroughA new optional field, contract_label: Option, was added to the CampaignParams struct in packages/mantra-claimdrop-std/src/msg.rs. No other logic, validations, or control flow were modified. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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 |
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for setting an optional contract label when creating a claimdrop campaign. The change allows users to specify a custom label for the instantiated claimdrop contract to improve identification and management.
- Added an optional
contract_labelfield to theCampaignParamsstruct - Updated the package version from 1.1.3 to 1.1.4
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/mantra-claimdrop-std/src/msg.rs | Added optional contract_label field to CampaignParams struct |
| packages/mantra-claimdrop-std/Cargo.toml | Version bump from 1.1.3 to 1.1.4 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
b70ecae to
832f830
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/mantra-claimdrop-std/src/msg.rs (2)
291-293: Omit None on the wire for cleaner JSONSkip serializing
contract_labelwhen it’sNoneto avoid emittingnulland reduce payload size./// An optional label to be used for the instantiated claimdrop contract - pub contract_label: Option<String>, + #[serde(skip_serializing_if = "Option::is_none")] + pub contract_label: Option<String>,
291-293: Add basic validation forcontract_labelto avoid chain-level rejectionIf provided, validate non-empty (post-trim) and a sane length (e.g., 128 bytes) to match wasmd label expectations; otherwise users get opaque errors from the chain.
Add (outside this hunk):
// near other length limits const MAX_LABEL_LENGTH: usize = 128; impl CampaignParams { pub fn validate_contract_label(&self) -> Result<(), ContractError> { if let Some(label) = &self.contract_label { let trimmed = label.trim(); ensure!( !trimmed.is_empty(), ContractError::InvalidCampaignParam { param: "contract_label".to_string(), reason: "cannot be empty when provided".to_string(), } ); ensure!( trimmed.len() <= MAX_LABEL_LENGTH, ContractError::InvalidCampaignParam { param: "contract_label".to_string(), reason: format!("cannot be longer than {} bytes", MAX_LABEL_LENGTH), } ); } Ok(()) } }Please ensure this new validation is invoked wherever other
CampaignParamsvalidations run.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
packages/mantra-claimdrop-std/src/msg.rs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Lints
🔇 Additional comments (1)
packages/mantra-claimdrop-std/src/msg.rs (1)
291-293: Public API break: CampaignParams gainedcontract_label— update dependents & bump major version
- Change: packages/mantra-claimdrop-std/src/msg.rs —
CampaignParamsnow haspub contract_label: Option<String>.- Repo scan: no struct-literal constructions of
CampaignParamsor uses ofcontract_labelfound;CreateCampaignstill carriesparams: Box<CampaignParams>.- Action: update any downstream crates that construct
CampaignParamsvia struct literals to addcontract_label(e.g.,contract_label: None) and publish a major version bump for mantra-claimdrop-std.
Description and Motivation
Related Issues
Checklist:
Update index.md)just fmt.just lint.Summary by CodeRabbit