From 7db9a2edf1014b6134c7946b1a2de0c77ff3409d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Federico=20Rodr=C3=ADguez?= Date: Tue, 5 Nov 2024 14:01:13 -0300 Subject: [PATCH] feat: add FromStr to ZkSolcWarnings and ZkSolcErrors (#37) --- .../src/compilers/zksolc/settings.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/compilers/src/compilers/zksolc/settings.rs b/crates/compilers/src/compilers/zksolc/settings.rs index 9c6d6f47..76c228c5 100644 --- a/crates/compilers/src/compilers/zksolc/settings.rs +++ b/crates/compilers/src/compilers/zksolc/settings.rs @@ -36,6 +36,16 @@ pub enum ZkSolcWarning { TxOrigin, } +impl FromStr for ZkSolcWarning { + type Err = String; + fn from_str(s: &str) -> Result { + match s { + "txorigin" => Ok(Self::TxOrigin), + s => Err(format!("Unknown zksolc warning: {s}")), + } + } +} + /// `zksolc` errors that can be suppressed. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] @@ -46,6 +56,16 @@ pub enum ZkSolcError { SendTransfer, } +impl FromStr for ZkSolcError { + type Err = String; + fn from_str(s: &str) -> Result { + match s { + "sendtransfer" => Ok(Self::SendTransfer), + s => Err(format!("Unknown zksolc error: {s}")), + } + } +} + /// zksolc standard json input settings. See: /// https://docs.zksync.io/zk-stack/components/compiler/toolchain/solidity.html#standard-json for differences #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]