Skip to content

Commit

Permalink
add CommunityRules enum to CommunityMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Jul 26, 2023
1 parent 14f07b2 commit 1e1ceb0
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion primitives/src/communities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,30 @@ 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 +283,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 +308,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 +365,7 @@ impl Default for CommunityMetadata {
.unwrap(),
theme: None,
url: Some(PalletString::from_str("DefaultUrl").unwrap()),
rules: CommunityRules::default(),
}
}
}
Expand Down

0 comments on commit 1e1ceb0

Please sign in to comment.