feat: function debug data in extra output (#1165)
* feat: support function debug data in output * chore: `ConfigurableArtifacts::output_selection` * chore: lint
This commit is contained in:
parent
2b2ec1101a
commit
6fcde371a3
|
@ -4,9 +4,12 @@ use crate::{
|
||||||
artifacts::{
|
artifacts::{
|
||||||
bytecode::{CompactBytecode, CompactDeployedBytecode},
|
bytecode::{CompactBytecode, CompactDeployedBytecode},
|
||||||
contract::{CompactContract, CompactContractBytecode, Contract},
|
contract::{CompactContract, CompactContractBytecode, Contract},
|
||||||
output_selection::{ContractOutputSelection, EvmOutputSelection, EwasmOutputSelection},
|
output_selection::{
|
||||||
CompactContractBytecodeCow, CompactEvm, DevDoc, Ewasm, GasEstimates, LosslessAbi, Metadata,
|
BytecodeOutputSelection, ContractOutputSelection, EvmOutputSelection,
|
||||||
Offsets, Settings, StorageLayout, UserDoc,
|
EwasmOutputSelection,
|
||||||
|
},
|
||||||
|
CompactContractBytecodeCow, DevDoc, Evm, Ewasm, FunctionDebugData, GasEstimates,
|
||||||
|
LosslessAbi, Metadata, Offsets, Settings, StorageLayout, UserDoc,
|
||||||
},
|
},
|
||||||
ArtifactOutput, SolcConfig, SolcError, SourceFile,
|
ArtifactOutput, SolcConfig, SolcError, SourceFile,
|
||||||
};
|
};
|
||||||
|
@ -32,6 +35,8 @@ pub struct ConfigurableContractArtifact {
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub method_identifiers: Option<BTreeMap<String, String>>,
|
pub method_identifiers: Option<BTreeMap<String, String>>,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
pub function_debug_data: Option<BTreeMap<String, FunctionDebugData>>,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub gas_estimates: Option<GasEstimates>,
|
pub gas_estimates: Option<GasEstimates>,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub metadata: Option<Metadata>,
|
pub metadata: Option<Metadata>,
|
||||||
|
@ -154,6 +159,7 @@ impl ConfigurableArtifacts {
|
||||||
/// Returns the output selection corresponding to this configuration
|
/// Returns the output selection corresponding to this configuration
|
||||||
pub fn output_selection(&self) -> Vec<ContractOutputSelection> {
|
pub fn output_selection(&self) -> Vec<ContractOutputSelection> {
|
||||||
let mut selection = ContractOutputSelection::basic();
|
let mut selection = ContractOutputSelection::basic();
|
||||||
|
|
||||||
if self.additional_values.ir {
|
if self.additional_values.ir {
|
||||||
selection.push(ContractOutputSelection::Ir);
|
selection.push(ContractOutputSelection::Ir);
|
||||||
}
|
}
|
||||||
|
@ -181,6 +187,12 @@ impl ConfigurableArtifacts {
|
||||||
if self.additional_values.ewasm || self.additional_files.ewasm {
|
if self.additional_values.ewasm || self.additional_files.ewasm {
|
||||||
selection.push(EwasmOutputSelection::All.into());
|
selection.push(EwasmOutputSelection::All.into());
|
||||||
}
|
}
|
||||||
|
if self.additional_values.function_debug_data {
|
||||||
|
selection.push(BytecodeOutputSelection::FunctionDebugData.into());
|
||||||
|
}
|
||||||
|
if self.additional_values.method_identifiers {
|
||||||
|
selection.push(EvmOutputSelection::MethodIdentifiers.into());
|
||||||
|
}
|
||||||
selection
|
selection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,6 +220,7 @@ impl ArtifactOutput for ConfigurableArtifacts {
|
||||||
let mut artifact_bytecode = None;
|
let mut artifact_bytecode = None;
|
||||||
let mut artifact_deployed_bytecode = None;
|
let mut artifact_deployed_bytecode = None;
|
||||||
let mut artifact_gas_estimates = None;
|
let mut artifact_gas_estimates = None;
|
||||||
|
let mut artifact_function_debug_data = None;
|
||||||
let mut artifact_method_identifiers = None;
|
let mut artifact_method_identifiers = None;
|
||||||
let mut artifact_assembly = None;
|
let mut artifact_assembly = None;
|
||||||
let mut artifact_storage_layout = None;
|
let mut artifact_storage_layout = None;
|
||||||
|
@ -247,17 +260,22 @@ impl ArtifactOutput for ConfigurableArtifacts {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(evm) = evm {
|
if let Some(evm) = evm {
|
||||||
let CompactEvm {
|
let Evm {
|
||||||
assembly,
|
assembly,
|
||||||
bytecode,
|
bytecode,
|
||||||
deployed_bytecode,
|
deployed_bytecode,
|
||||||
method_identifiers,
|
method_identifiers,
|
||||||
gas_estimates,
|
gas_estimates,
|
||||||
..
|
..
|
||||||
} = evm.into_compact();
|
} = evm;
|
||||||
|
|
||||||
artifact_bytecode = bytecode;
|
if self.additional_values.function_debug_data {
|
||||||
artifact_deployed_bytecode = deployed_bytecode;
|
artifact_function_debug_data =
|
||||||
|
bytecode.as_ref().map(|b| b.function_debug_data.clone());
|
||||||
|
}
|
||||||
|
|
||||||
|
artifact_bytecode = bytecode.map(Into::into);
|
||||||
|
artifact_deployed_bytecode = deployed_bytecode.map(Into::into);
|
||||||
|
|
||||||
if self.additional_values.gas_estimates {
|
if self.additional_values.gas_estimates {
|
||||||
artifact_gas_estimates = gas_estimates;
|
artifact_gas_estimates = gas_estimates;
|
||||||
|
@ -275,6 +293,7 @@ impl ArtifactOutput for ConfigurableArtifacts {
|
||||||
bytecode: artifact_bytecode,
|
bytecode: artifact_bytecode,
|
||||||
deployed_bytecode: artifact_deployed_bytecode,
|
deployed_bytecode: artifact_deployed_bytecode,
|
||||||
assembly: artifact_assembly,
|
assembly: artifact_assembly,
|
||||||
|
function_debug_data: artifact_function_debug_data,
|
||||||
method_identifiers: artifact_method_identifiers,
|
method_identifiers: artifact_method_identifiers,
|
||||||
gas_estimates: artifact_gas_estimates,
|
gas_estimates: artifact_gas_estimates,
|
||||||
metadata: artifact_metadata,
|
metadata: artifact_metadata,
|
||||||
|
@ -304,6 +323,7 @@ pub struct ExtraOutputValues {
|
||||||
pub ir: bool,
|
pub ir: bool,
|
||||||
pub ir_optimized: bool,
|
pub ir_optimized: bool,
|
||||||
pub ewasm: bool,
|
pub ewasm: bool,
|
||||||
|
pub function_debug_data: bool,
|
||||||
|
|
||||||
/// PRIVATE: This structure may grow, As such, constructing this structure should
|
/// PRIVATE: This structure may grow, As such, constructing this structure should
|
||||||
/// _always_ be done using a public constructor or update syntax:
|
/// _always_ be done using a public constructor or update syntax:
|
||||||
|
@ -336,6 +356,7 @@ impl ExtraOutputValues {
|
||||||
ir: true,
|
ir: true,
|
||||||
ir_optimized: true,
|
ir_optimized: true,
|
||||||
ewasm: true,
|
ewasm: true,
|
||||||
|
function_debug_data: true,
|
||||||
__non_exhaustive: (),
|
__non_exhaustive: (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,6 +401,9 @@ impl ExtraOutputValues {
|
||||||
EvmOutputSelection::GasEstimates => {
|
EvmOutputSelection::GasEstimates => {
|
||||||
config.gas_estimates = true;
|
config.gas_estimates = true;
|
||||||
}
|
}
|
||||||
|
EvmOutputSelection::ByteCode(BytecodeOutputSelection::FunctionDebugData) => {
|
||||||
|
config.function_debug_data = true;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
ContractOutputSelection::Ewasm(_) => {
|
ContractOutputSelection::Ewasm(_) => {
|
||||||
|
|
Loading…
Reference in New Issue