Skip to content
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

add CommunityRules enum to CommunityMetadata #337

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion primitives/src/communities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,29 @@ impl Location {
}
}

#[derive(
Encode,
Decode,
Copy,
Clone,
PartialEq,
Eq,
Default,
RuntimeDebug,
PartialOrd,
Ord,
TypeInfo,
MaxEncodedLen,
)]
#[cfg_attr(feature = "serde_derive", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde_derive", serde(rename_all = "camelCase"))]
pub enum CommunityRules {
#[default]
LoCo,
LoCoLight,
BeeDance,
}

#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "serde_derive", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "serde_derive", serde(rename_all = "camelCase"))]
Expand Down Expand Up @@ -259,6 +282,8 @@ pub struct CommunityMetadata {
pub theme: Option<BoundedIpfsCid>,
/// optional link to a community site
pub url: Option<PalletString>,
/// rule set to be followed by community
pub rules: CommunityRules,
}

#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
Expand All @@ -282,8 +307,9 @@ impl CommunityMetadata {
assets: BoundedIpfsCid,
theme: Option<BoundedIpfsCid>,
url: Option<PalletString>,
rules: CommunityRules,
) -> Result<CommunityMetadata, CommunityMetadataError> {
let meta = CommunityMetadata { name, symbol, assets, theme, url };
let meta = CommunityMetadata { name, symbol, assets, theme, url, rules };
match meta.validate() {
Ok(()) => Ok(meta),
Err(e) => Err(e),
Expand Down Expand Up @@ -338,6 +364,7 @@ impl Default for CommunityMetadata {
.unwrap(),
theme: None,
url: Some(PalletString::from_str("DefaultUrl").unwrap()),
rules: CommunityRules::default(),
}
}
}
Expand Down
Loading