Skip to content

Commit

Permalink
refactor: pull repl settings up to top-level
Browse files Browse the repository at this point in the history
Instead of `project.repl.*` in the Clarinet.toml file, now it is
`repl.*`.
  • Loading branch information
obycode committed Feb 10, 2022
1 parent 9cf9a40 commit 57bf09d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/generate/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ history.txt
name = "{}"
authors = []
telemetry = {}
[project.repl.analysis]
[repl.analysis]
passes = ["check_checker"]
[project.repl.analysis.check_checker]
[repl.analysis.check_checker]
# If true, inputs are trusted after tx_sender has been checked.
trusted_sender = false
# If true, inputs are trusted after contract-caller has been checked.
Expand Down
2 changes: 1 addition & 1 deletion src/poke/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub fn load_session_settings(
"bns".to_string(),
];
settings.initial_deployer = initial_deployer;
settings.repl_settings = project_config.project.repl_settings.clone();
settings.repl_settings = project_config.repl_settings.clone();

Ok((settings, chain_config, project_config))
}
Expand Down
2 changes: 1 addition & 1 deletion src/runnner/deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod sessions {
});
}
settings.initial_deployer = initial_deployer;
settings.repl_settings = project_config.project.repl_settings;
settings.repl_settings = project_config.repl_settings;
settings.include_boot_contracts = vec![
"pox".to_string(),
format!("costs-v{}", settings.repl_settings.costs_version),
Expand Down
26 changes: 14 additions & 12 deletions src/types/project_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use toml::value::Value;
pub struct ProjectManifestFile {
project: ProjectConfigFile,
contracts: Option<Value>,
repl: Option<repl::SettingsFile>,
}

#[derive(Serialize, Deserialize, Debug)]
Expand All @@ -20,7 +21,6 @@ pub struct ProjectConfigFile {
description: Option<String>,
telemetry: Option<bool>,
requirements: Option<Value>,
repl: Option<repl::SettingsFile>,

// The fields below have been moved into repl above, but are kept here for
// backwards compatibility.
Expand All @@ -33,6 +33,7 @@ pub struct ProjectManifest {
pub project: ProjectConfig,
#[serde(serialize_with = "toml::ser::tables_last")]
pub contracts: BTreeMap<String, ContractConfig>,
pub repl_settings: repl::Settings,
}

#[derive(Serialize, Deserialize, Debug, Default)]
Expand All @@ -42,7 +43,6 @@ pub struct ProjectConfig {
pub description: String,
pub telemetry: bool,
pub requirements: Option<Vec<RequirementConfig>>,
pub repl_settings: repl::Settings,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default)]
Expand Down Expand Up @@ -152,7 +152,7 @@ impl ProjectManifest {
pub fn from_project_manifest_file(
project_manifest_file: ProjectManifestFile,
) -> ProjectManifest {
let mut project = ProjectConfig {
let project = ProjectConfig {
name: project_manifest_file.project.name.clone(),
requirements: None,
description: project_manifest_file
Expand All @@ -161,32 +161,34 @@ impl ProjectManifest {
.unwrap_or("".into()),
authors: project_manifest_file.project.authors.unwrap_or(vec![]),
telemetry: project_manifest_file.project.telemetry.unwrap_or(false),
repl_settings: if let Some(repl_settings) = project_manifest_file.project.repl {
repl::Settings::from(repl_settings)
} else {
repl::Settings::default()
},
};

let mut repl_settings = if let Some(repl_settings) = project_manifest_file.repl {
repl::Settings::from(repl_settings)
} else {
repl::Settings::default()
};

// Check for deprecated settings
if let Some(passes) = project_manifest_file.project.analysis {
println!(
"{}: use of 'project.analysis' in Clarinet.toml is deprecated; use project.repl.analysis.passes",
"{}: use of 'project.analysis' in Clarinet.toml is deprecated; use repl.analysis.passes",
yellow!("warning")
);
project.repl_settings.analysis.set_passes(passes);
repl_settings.analysis.set_passes(passes);
}
if let Some(costs_version) = project_manifest_file.project.costs_version {
println!(
"{}: use of 'project.costs_version' in Clarinet.toml is deprecated; use project.repl.costs_version",
"{}: use of 'project.costs_version' in Clarinet.toml is deprecated; use repl.costs_version",
yellow!("warning")
);
project.repl_settings.costs_version = costs_version;
repl_settings.costs_version = costs_version;
}

let mut config = ProjectManifest {
project,
contracts: BTreeMap::new(),
repl_settings,
};
let mut config_contracts = BTreeMap::new();
let mut config_requirements: Vec<RequirementConfig> = Vec::new();
Expand Down

0 comments on commit 57bf09d

Please sign in to comment.