Skip to content

Commit 9367a31

Browse files
committed
sanitize EVM version for vyper
1 parent cb32f7f commit 9367a31

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

crates/artifacts/vyper/src/settings.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ use std::{
99
};
1010

1111
pub const VYPER_SEARCH_PATHS: Version = Version::new(0, 4, 0);
12+
pub const VYPER_BERLIN: Version = Version::new(0, 3, 0);
13+
pub const VYPER_PARIS: Version = Version::new(0, 3, 7);
14+
pub const VYPER_SHANGHAI: Version = Version::new(0, 3, 8);
15+
pub const VYPER_CANCUN: Version = Version::new(0, 3, 8);
1216

1317
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
1418
#[serde(rename_all = "lowercase")]
@@ -79,11 +83,29 @@ impl VyperSettings {
7983
}
8084

8185
self.sanitize_output_selection();
86+
self.normalize_evm_version(version);
8287
}
8388

8489
/// Sanitize the settings based on the compiler version.
8590
pub fn sanitized(mut self, version: &Version) -> Self {
8691
self.sanitize(version);
8792
self
8893
}
94+
95+
/// Adjusts the EVM version based on the compiler version.
96+
pub fn normalize_evm_version(&mut self, version: &Version) {
97+
if let Some(evm_version) = &mut self.evm_version {
98+
*evm_version = if *evm_version >= EvmVersion::Cancun && *version >= VYPER_CANCUN {
99+
EvmVersion::Cancun
100+
} else if *evm_version >= EvmVersion::Shanghai && *version >= VYPER_SHANGHAI {
101+
EvmVersion::Shanghai
102+
} else if *evm_version >= EvmVersion::Paris && *version >= VYPER_PARIS {
103+
EvmVersion::Paris
104+
} else if *evm_version >= EvmVersion::Berlin && *version >= VYPER_BERLIN {
105+
EvmVersion::Berlin
106+
} else {
107+
*evm_version
108+
};
109+
}
110+
}
89111
}

0 commit comments

Comments
 (0)