From 97e70be40f3bd9bec00c136ea2320041f9753559 Mon Sep 17 00:00:00 2001 From: Peter White Date: Fri, 24 May 2024 18:54:16 -0600 Subject: [PATCH] feat(new): add IsAudited template property. --- crates/pop-cli/src/commands/new/parachain.rs | 10 ++++--- crates/pop-parachains/src/templates.rs | 28 +++++++++++++++----- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/crates/pop-cli/src/commands/new/parachain.rs b/crates/pop-cli/src/commands/new/parachain.rs index 0cbac620..0a57ac73 100644 --- a/crates/pop-cli/src/commands/new/parachain.rs +++ b/crates/pop-cli/src/commands/new/parachain.rs @@ -193,10 +193,12 @@ fn generate_parachain_from_template( .unwrap_or_default() ))?; - // warn about audit status and licensing - warning(format!("NOTE: the resulting parachain is not guaranteed to be audited or reviewed for security vulnerabilities.\n{}", - style(format!("Please consult the source repository at {} to assess production suitability and licensing restrictions.", template.repository_url()?)) - .dim()))?; + if !template.is_audited() { + // warn about audit status and licensing + warning(format!("NOTE: the resulting parachain is not guaranteed to be audited or reviewed for security vulnerabilities.\n{}", + style(format!("Please consult the source repository at {} to assess production suitability and licensing restrictions.", template.repository_url()?)) + .dim()))?; + } // add next steps let mut next_steps = vec![ diff --git a/crates/pop-parachains/src/templates.rs b/crates/pop-parachains/src/templates.rs index ce6c9587..f036ffc3 100644 --- a/crates/pop-parachains/src/templates.rs +++ b/crates/pop-parachains/src/templates.rs @@ -85,7 +85,7 @@ pub enum Template { props( Provider = "Pop", Repository = "https://github.com/r0gue-io/base-parachain", - Network = "./network.toml", + Network = "./network.toml" ) )] Standard, @@ -96,7 +96,7 @@ pub enum Template { props( Provider = "Pop", Repository = "https://github.com/r0gue-io/assets-parachain", - Network = "./network.toml", + Network = "./network.toml" ) )] Assets, @@ -107,7 +107,7 @@ pub enum Template { props( Provider = "Pop", Repository = "https://github.com/r0gue-io/contracts-parachain", - Network = "./network.toml", + Network = "./network.toml" ) )] Contracts, @@ -118,7 +118,7 @@ pub enum Template { props( Provider = "Pop", Repository = "https://github.com/r0gue-io/evm-parachain", - Network = "./network.toml", + Network = "./network.toml" ) )] EVM, @@ -130,7 +130,7 @@ pub enum Template { props( Provider = "Parity", Repository = "https://github.com/paritytech/substrate-contracts-node", - Network = "./zombienet.toml", + Network = "./zombienet.toml" ) )] ParityContracts, @@ -141,7 +141,7 @@ pub enum Template { props( Provider = "Parity", Repository = "https://github.com/paritytech/frontier-parachain-template", - Network = "./zombienet-config.toml", + Network = "./zombienet-config.toml" ) )] ParityFPT, @@ -156,7 +156,8 @@ pub enum Template { Provider = "Test", Repository = "", Network = "", - SupportedVersions = "v1.0.0,v2.0.0" + SupportedVersions = "v1.0.0,v2.0.0", + IsAudited = "true" ) )] TestTemplate01, @@ -204,6 +205,10 @@ impl Template { // if `SupportedVersion` is None, then all versions are supported. Otherwise, ensure version is present. self.supported_versions().map_or(true, |versions| versions.contains(&version)) } + + pub fn is_audited(&self) -> bool { + self.get_str("IsAudited").map_or(false, |s| s == "true") + } } #[derive(Error, Debug)] @@ -353,4 +358,13 @@ mod tests { // will be true because an empty SupportedVersions defaults to all assert_eq!(template.is_supported_version("v1.0.0"), true); } + + #[test] + fn test_is_audited() { + let template = Template::TestTemplate01; + assert_eq!(template.is_audited(), true); + + let template = Template::TestTemplate02; + assert_eq!(template.is_audited(), false); + } }