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

feat: support offline mode #727

Merged
merged 2 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions cli/src/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ pub struct BuildArgs {
#[serde(skip)]
pub no_auto_detect: bool,

#[clap(
help = "if set to true, runs without accessing the network (missing solc versions will not be installed)",
long
)]
#[serde(skip)]
pub offline: bool,

#[clap(
help = "force recompilation of the project, deletes the cache and artifacts folders",
long
Expand Down Expand Up @@ -201,6 +208,10 @@ impl Provider for BuildArgs {
dict.insert("auto_detect_solc".to_string(), false.into());
}

if self.offline {
dict.insert("offline".to_string(), true.into());
}

if self.force {
dict.insert("force".to_string(), self.force.into());
}
Expand Down
1 change: 1 addition & 0 deletions cli/src/cmd/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl Cmd for FlattenArgs {
compiler: Default::default(),
ignored_error_codes: vec![],
no_auto_detect: false,
offline: false,
force: false,
hardhat,
libraries: vec![],
Expand Down
1 change: 1 addition & 0 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ gas_reports = ['*']
## Sets the concrete solc version to use, this overrides the `auto_detect_solc` value
# solc_version = '0.8.10'
auto_detect_solc = true
offline = false
optimizer = true
optimizer_runs = 200
verbosity = 0
Expand Down
9 changes: 9 additions & 0 deletions config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ pub struct Config {
pub solc_version: Option<Version>,
/// whether to autodetect the solc compiler version to use
pub auto_detect_solc: bool,
/// Offline mode, if set, network access (downloading solc) is disallowed.
///
/// Relationship with `auto_detect_solc`:
/// - if `auto_detect_solc = true` and `offline = true`, the required solc version(s) will
/// be auto detected but if the solc version is not installed, it will _not_ try to
/// install it
pub offline: bool,
/// Whether to activate optimizer
pub optimizer: bool,
/// Sets the optimizer runs
Expand Down Expand Up @@ -357,6 +364,7 @@ impl Config {
.solc_config(SolcConfig::builder().settings(self.solc_settings()?).build())
.ignore_error_codes(self.ignored_error_codes.clone())
.set_auto_detect(self.auto_detect_solc)
.set_offline(self.offline)
.set_cached(cached)
.set_no_artifacts(no_artifacts)
.build()?;
Expand Down Expand Up @@ -704,6 +712,7 @@ impl Default for Config {
gas_reports: vec!["*".to_string()],
solc_version: None,
auto_detect_solc: true,
offline: false,
optimizer: true,
optimizer_runs: 200,
optimizer_details: None,
Expand Down