Skip to content

Commit

Permalink
chore: add new solidity warning code (#7007)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Feb 3, 2024
1 parent 2cb8757 commit 51ccfdb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/config/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ impl Error for FoundryConfigError {
pub enum SolidityErrorCode {
/// Warning that SPDX license identifier not provided in source file
SpdxLicenseNotProvided,
/// Warning: Visibility for constructor is ignored. If you want the contract to be
/// non-deployable, making it "abstract" is sufficient
VisibilityForConstructorIsIgnored,
/// Warning that contract code size exceeds 24576 bytes (a limit introduced in Spurious
/// Dragon).
ContractExceeds24576Bytes,
Expand Down Expand Up @@ -158,6 +161,7 @@ impl SolidityErrorCode {
SolidityErrorCode::Unreachable => "unreachable",
SolidityErrorCode::PragmaSolidity => "pragma-solidity",
SolidityErrorCode::Other(code) => return Err(*code),
SolidityErrorCode::VisibilityForConstructorIsIgnored => "constructor-visibility",
};
Ok(s)
}
Expand All @@ -180,6 +184,7 @@ impl From<SolidityErrorCode> for u64 {
SolidityErrorCode::Unreachable => 5740,
SolidityErrorCode::PragmaSolidity => 3420,
SolidityErrorCode::ContractInitCodeSizeExceeds49152Bytes => 3860,
SolidityErrorCode::VisibilityForConstructorIsIgnored => 2462,
SolidityErrorCode::Other(code) => code,
}
}
Expand Down Expand Up @@ -212,6 +217,7 @@ impl FromStr for SolidityErrorCode {
"virtual-interfaces" => SolidityErrorCode::InterfacesExplicitlyVirtual,
"missing-receive-ether" => SolidityErrorCode::PayableNoReceiveEther,
"same-varname" => SolidityErrorCode::DeclarationSameNameAsAnother,
"constructor-visibility" => SolidityErrorCode::VisibilityForConstructorIsIgnored,
_ => return Err(format!("Unknown variant {s}")),
};

Expand All @@ -236,6 +242,7 @@ impl From<u64> for SolidityErrorCode {
6321 => SolidityErrorCode::UnnamedReturnVariable,
3420 => SolidityErrorCode::PragmaSolidity,
5740 => SolidityErrorCode::Unreachable,
2462 => SolidityErrorCode::VisibilityForConstructorIsIgnored,
other => SolidityErrorCode::Other(other),
}
}
Expand Down

0 comments on commit 51ccfdb

Please sign in to comment.