Skip to content

Commit

Permalink
Merge pull request #681 from blockscout/lok52/lookup-methods
Browse files Browse the repository at this point in the history
API template for additional actions added into verification
  • Loading branch information
lok52 authored Nov 15, 2023
2 parents a1db0d4 + 6fcd2c6 commit fe12b77
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ fn compile(
.field_attribute(
".blockscout.smartContractVerifier.v2.VerifyVyperMultiPartRequest.interfaces",
"#[serde(default)]"
)
.field_attribute(
".blockscout.smartContractVerifier.v2.VerifySolidityMultiPartRequest.post_actions",
"#[serde(default)]"
)
.field_attribute(
".blockscout.smartContractVerifier.v2.VerifySolidityStandardJsonRequest.post_actions",
"#[serde(default)]"
);
config.compile_protos(protos, includes)?;
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ message VerifySolidityMultiPartRequest {

/// An optional field to be filled by explorers
optional VerificationMetadata metadata = 8;

/// Additional actions the client wants the result to be returned.
/// Currently supports only: "lookup-methods" for Solidity contracts.
repeated string post_actions = 9;
}

message VerifySolidityStandardJsonRequest {
Expand All @@ -127,6 +131,10 @@ message VerifySolidityStandardJsonRequest {

/// An optional field to be filled by explorers
optional VerificationMetadata metadata = 5;

/// Additional actions the client wants the result to be returned.
/// Currently supports only: "lookup-methods" for Solidity contracts.
repeated string post_actions = 9;
}

message VerifyVyperMultiPartRequest {
Expand Down Expand Up @@ -190,6 +198,13 @@ message VerifyResponse {
repeated BytecodePart local_deployed_bytecode_parts = 2;
}
ExtraData extra_data = 4;

message PostActionResponses {
/// If requested, will contain the response for
/// 'lookup-methods' processing applied to the verified contract.
optional LookupMethodsResponse lookup_methods = 1;
}
PostActionResponses post_action_responses = 5;
}

message VerifySourcifyRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,27 @@ definitions:
localCreationInputParts:
type: array
items:
type: object
$ref: '#/definitions/ExtraDataBytecodePart'
description: |-
/ Creation transaction input resultant from local compilation
/ parsed and split on Main and Meta parts. Is empty for Sourcify verification.
localDeployedBytecodeParts:
type: array
items:
type: object
$ref: '#/definitions/ExtraDataBytecodePart'
description: |-
/ Deployed bytecode resultant from local compilation
/ parsed and split on Main and Meta parts. Is empty for Sourcify verification.
VerifyResponsePostActionResponses:
type: object
properties:
lookupMethods:
$ref: '#/definitions/v2LookupMethodsResponse'
description: |-
/ If requested, will contain the response for
/ 'lookup-methods' processing applied to the verified contract.
googlerpcStatus:
type: object
properties:
Expand All @@ -275,6 +285,7 @@ definitions:
details:
type: array
items:
type: object
$ref: '#/definitions/protobufAny'
protobufAny:
type: object
Expand Down Expand Up @@ -400,6 +411,8 @@ definitions:
$ref: '#/definitions/v2Source'
extraData:
$ref: '#/definitions/VerifyResponseExtraData'
postActionResponses:
$ref: '#/definitions/VerifyResponsePostActionResponses'
v2VerifyResponseStatus:
type: string
enum:
Expand Down Expand Up @@ -441,6 +454,13 @@ definitions:
metadata:
$ref: '#/definitions/v2VerificationMetadata'
title: / An optional field to be filled by explorers
postActions:
type: array
items:
type: string
description: |-
/ Additional actions the client wants the result to be returned.
/ Currently supports only: "lookup-methods" for Solidity contracts.
v2VerifySolidityStandardJsonRequest:
type: object
properties:
Expand All @@ -459,6 +479,13 @@ definitions:
metadata:
$ref: '#/definitions/v2VerificationMetadata'
title: / An optional field to be filled by explorers
postActions:
type: array
items:
type: string
description: |-
/ Additional actions the client wants the result to be returned.
/ Currently supports only: "lookup-methods" for Solidity contracts.
v2VerifySourcifyRequest:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ mod tests {
chain_id: Some("1".into()),
contract_address: Some("0xcafecafecafecafecafecafecafecafecafecafe".into()),
}),
post_actions: vec![],
};

let mut expected = VerificationRequest {
Expand Down Expand Up @@ -156,6 +157,7 @@ mod tests {
optimization_runs: None,
libraries: Default::default(),
metadata: None,
post_actions: vec![],
};

let verification_request: VerificationRequest =
Expand All @@ -181,6 +183,7 @@ mod tests {
optimization_runs: None,
libraries: Default::default(),
metadata: None,
post_actions: vec![],
};

let verification_request: VerificationRequest =
Expand All @@ -205,6 +208,7 @@ mod tests {
optimization_runs: None,
libraries: Default::default(),
metadata: None,
post_actions: vec![],
};

let verification_request: VerificationRequest =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ mod tests {
chain_id: Some("1".into()),
contract_address: Some("0xcafecafecafecafecafecafecafecafecafecafe".into())
}),
post_actions: vec![],
};
let input: CompilerInput = serde_json::from_str(&request.input).unwrap();

Expand Down Expand Up @@ -149,6 +150,7 @@ mod tests {
compiler_version: "v0.8.17+commit.8df45f5f".to_string(),
input: "{\"language\": \"Solidity\", \"sources\": {\"./src/contracts/Foo.sol\": {\"content\": \"pragma solidity ^0.8.2;\\n\\ncontract Foo {\\n function bar() external pure returns (uint256) {\\n return 42;\\n }\\n}\\n\"}}, \"settings\": {\"metadata\": {\"useLiteralContent\": true}, \"optimizer\": {\"enabled\": true, \"runs\": 200}, \"outputSelection\": {\"*\": {\"*\": [\"abi\", \"evm.bytecode\", \"evm.deployedBytecode\", \"evm.methodIdentifiers\"], \"\": [\"id\", \"ast\"]}}}}".to_string(),
metadata: None,
post_actions: vec![],
};

let verification_request: VerificationRequest =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::proto::{
verify_response::{ExtraData, Status},
verify_response::{ExtraData, PostActionResponses, Status},
Source, VerifyResponse,
};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -91,6 +91,9 @@ impl VerifyResponseWrapper {
status: Status::Success.into(),
source: Some(source),
extra_data: Some(extra_data),
post_action_responses: Some(PostActionResponses {
lookup_methods: None,
}),
}
.into()
}
Expand All @@ -101,6 +104,7 @@ impl VerifyResponseWrapper {
status: Status::Failure.into(),
source: None,
extra_data: None,
post_action_responses: None,
}
.into()
}
Expand Down Expand Up @@ -198,6 +202,9 @@ mod tests {
local_creation_input_parts: vec![],
local_deployed_bytecode_parts: vec![],
}),
post_action_responses: Some(PostActionResponses {
lookup_methods: None,
}),
};

assert_eq!(expected, response);
Expand All @@ -211,6 +218,7 @@ mod tests {
status: Status::Failure.into(),
source: None,
extra_data: None,
post_action_responses: None,
};
assert_eq!(expected, response);
}
Expand Down

0 comments on commit fe12b77

Please sign in to comment.