Skip to content

Commit

Permalink
feat(new): add IsAudited template property.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwht committed May 25, 2024
1 parent 99f06fb commit 97e70be
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
10 changes: 6 additions & 4 deletions crates/pop-cli/src/commands/new/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![
Expand Down
28 changes: 21 additions & 7 deletions crates/pop-parachains/src/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 97e70be

Please sign in to comment.