Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
ethers-solc: add immutableReferences output selector
Browse files Browse the repository at this point in the history
It is a property on the deployed bytecode object
on the compiler output. This is the precursor for
`forge inspect <contract-name> immutableReferences`.
  • Loading branch information
tynes committed Jul 28, 2022
1 parent 61821cc commit 4f170a6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ethers-solc/src/artifacts/output_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ pub enum DeployedBytecodeOutputSelection {
SourceMap,
LinkReferences,
GeneratedSources,
ImmutableReferences,
}

impl Serialize for DeployedBytecodeOutputSelection {
Expand Down Expand Up @@ -465,6 +466,9 @@ impl fmt::Display for DeployedBytecodeOutputSelection {
DeployedBytecodeOutputSelection::GeneratedSources => {
f.write_str("evm.deployedBytecode.generatedSources")
}
DeployedBytecodeOutputSelection::ImmutableReferences => {
f.write_str("evm.deployedBytecode.immutableReferences")
}
}
}
}
Expand All @@ -487,6 +491,9 @@ impl FromStr for DeployedBytecodeOutputSelection {
"evm.deployedBytecode.generatedSources" => {
Ok(DeployedBytecodeOutputSelection::GeneratedSources)
}
"evm.deployedBytecode.immutableReferences" => {
Ok(DeployedBytecodeOutputSelection::ImmutableReferences)
}
s => Err(format!("Invalid deployedBytecode selection: {}", s)),
}
}
Expand Down Expand Up @@ -573,4 +580,12 @@ mod tests {
let s = serde_json::to_string(&empty).unwrap();
assert_eq!(s, r#"{"contract.sol":{"*":[]}}"#);
}

#[test]
fn deployed_bytecode_from_str() {
assert_eq!(
DeployedBytecodeOutputSelection::from_str("evm.deployedBytecode.immutableReferences").unwrap(),
DeployedBytecodeOutputSelection::ImmutableReferences
)
}
}

0 comments on commit 4f170a6

Please sign in to comment.