Skip to content

Fix/set contract label when create campaign#24

Merged
BigtoMantraDev merged 1 commit intomainfrom
fix/set-contract-label-when-create-campaign
Sep 18, 2025
Merged

Fix/set contract label when create campaign#24
BigtoMantraDev merged 1 commit intomainfrom
fix/set-contract-label-when-create-campaign

Conversation

@BigtoMantraDev
Copy link
Collaborator

@BigtoMantraDev BigtoMantraDev commented Sep 18, 2025

Description and Motivation

Related Issues


Checklist:

  • I have read MANTRA's contribution guidelines.
  • My pull request has a sound title and description (not something vague like Update index.md)
  • All existing and new tests are passing.
  • I updated/added relevant documentation.
  • The code is formatted properly just fmt.
  • Clippy doesn't report any issues just lint.

Summary by CodeRabbit

  • New Features
    • Added support to provide an optional label when creating a campaign. The label will be applied to the instantiated claimdrop contract.

@coderabbitai
Copy link

coderabbitai bot commented Sep 18, 2025

Walkthrough

A 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

Cohort / File(s) Summary of changes
Campaign params schema
packages/mantra-claimdrop-std/src/msg.rs
Added public field contract_label: Option<String> to CampaignParams, positioned after end_time. No other changes shown.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibble code like clover leaves, so neat,
A label sprouts where params meet.
Optional strings in fields now play,
To name the drops that hop our way.
Ears perked high—commit complete!
Tap-tap paws: ship it fleet. 🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Fix/set contract label when create campaign" directly references the primary change in the diff: adding and setting a contract_label in CampaignParams for campaign creation. It is concise and focused enough for a reviewer to understand the PR’s main intent. The phrasing is slightly awkward (slash and missing article) but remains understandable.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/set-contract-label-when-create-campaign

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.

❤️ Share

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

@BigtoMantraDev BigtoMantraDev self-assigned this Sep 18, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_label field to the CampaignParams struct
  • 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.

@BigtoMantraDev BigtoMantraDev force-pushed the fix/set-contract-label-when-create-campaign branch from b70ecae to 832f830 Compare September 18, 2025 07:45
@BigtoMantraDev BigtoMantraDev merged commit 794fe40 into main Sep 18, 2025
4 of 5 checks passed
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: 0

🧹 Nitpick comments (2)
packages/mantra-claimdrop-std/src/msg.rs (2)

291-293: Omit None on the wire for cleaner JSON

Skip serializing contract_label when it’s None to avoid emitting null and 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 for contract_label to avoid chain-level rejection

If 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 CampaignParams validations 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

📥 Commits

Reviewing files that changed from the base of the PR and between b70ecae and 832f830.

📒 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 gained contract_label — update dependents & bump major version

  • Change: packages/mantra-claimdrop-std/src/msg.rs — CampaignParams now has pub contract_label: Option<String>.
  • Repo scan: no struct-literal constructions of CampaignParams or uses of contract_label found; CreateCampaign still carries params: Box<CampaignParams>.
  • Action: update any downstream crates that construct CampaignParams via struct literals to add contract_label (e.g., contract_label: None) and publish a major version bump for mantra-claimdrop-std.

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.

2 participants