Skip to content

Commit

Permalink
chore: make language to be enum in zk VerificationSuccess
Browse files Browse the repository at this point in the history
  • Loading branch information
rimrakhimov committed Jul 10, 2024
1 parent ac7f0be commit 71d706e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,22 @@ message VerificationFailure {
}

message VerificationSuccess {
string file_name = 1;
string contract_name = 2;

message Compiler {
string compiler = 1;
string version = 2;
}

string file_name = 1;
string contract_name = 2;
Compiler zk_compiler = 3;
Compiler evm_compiler = 4;
string language = 5;

enum Language {
LANGUAGE_UNKNOWN = 0;
SOLIDITY = 1;
}
Language language = 5;

string compiler_settings = 6;
map <string, string> sources = 7;
string compilation_artifacts = 8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ definitions:
evmCompiler:
$ref: '#/definitions/solidityVerificationSuccessCompiler'
language:
type: string
$ref: '#/definitions/solidityVerificationSuccessLanguage'
compilerSettings:
type: string
sources:
Expand All @@ -478,6 +478,12 @@ definitions:
type: string
version:
type: string
solidityVerificationSuccessLanguage:
type: string
enum:
- LANGUAGE_UNKNOWN
- SOLIDITY
default: LANGUAGE_UNKNOWN
solidityVerifyStandardJsonRequest:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ fn process_verification_result(
match result {
Ok(result) => match zksync::choose_best_success(result.successes) {
Some(success) => {
let language = match result.language.as_str() {
"solidity" => verification_success::Language::Solidity,
language => {
return Err(Status::internal(format!(
"invalid language returned from verifier: {language}"
)))
}
};
let proto_success = VerificationSuccess {
file_name: success.file_path,
contract_name: success.contract_name,
Expand All @@ -120,7 +128,7 @@ fn process_verification_result(
compiler: result.evm_compiler,
version: result.evm_compiler_version.to_string(),
}),
language: result.language,
language: language.into(),
compiler_settings: result.compiler_settings.to_string(),
sources: result.sources,
compilation_artifacts: serde_json::Value::from(success.compilation_artifacts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl TestCase for StandardJson {
Input::deserialize(&self.input).expect("expected language field deserialization");
assert_eq!(
input.language.to_lowercase(),
success.language.to_lowercase(),
success.language().as_str_name().to_lowercase(),
"invalid language"
);
}
Expand Down

0 comments on commit 71d706e

Please sign in to comment.