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: add FromStr to ZkSolcWarnings and ZkSolcErrors #37

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
20 changes: 20 additions & 0 deletions crates/compilers/src/compilers/zksolc/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ pub enum ZkSolcWarning {
TxOrigin,
}

impl FromStr for ZkSolcWarning {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
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")]
Expand All @@ -46,6 +56,16 @@ pub enum ZkSolcError {
SendTransfer,
}

impl FromStr for ZkSolcError {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
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)]
Expand Down