From 16f686df265c6cfad4ce0ebba55d803be77a3e24 Mon Sep 17 00:00:00 2001 From: Mark Tyneway Date: Thu, 28 Jul 2022 11:07:24 -0700 Subject: [PATCH] ethers-solc: add immutableReferences output selector (#1523) * ethers-solc: add immutableReferences output selector It is a property on the deployed bytecode object on the compiler output. This is the precursor for `forge inspect immutableReferences`. * chore: update changelog --- CHANGELOG.md | 1 + ethers-solc/src/artifacts/output_selection.rs | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fefd4112..86013cc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Unreleased +- Add `evm.deployedBytecode.immutableReferences` output selector [#1523](https://github.com/gakonst/ethers-rs/pull/1523) - Added `get_erc1155_token_transfer_events` function for etherscan client [#1503](https://github.com/gakonst/ethers-rs/pull/1503) - Add support for Geth `debug_traceTransaction` [#1469](https://github.com/gakonst/ethers-rs/pull/1469) - Use correct, new transaction type for `typool_content` RPC endpoint [#1501](https://github.com/gakonst/ethers-rs/pull/1501) diff --git a/ethers-solc/src/artifacts/output_selection.rs b/ethers-solc/src/artifacts/output_selection.rs index b5546350..a016b6ef 100644 --- a/ethers-solc/src/artifacts/output_selection.rs +++ b/ethers-solc/src/artifacts/output_selection.rs @@ -427,6 +427,7 @@ pub enum DeployedBytecodeOutputSelection { SourceMap, LinkReferences, GeneratedSources, + ImmutableReferences, } impl Serialize for DeployedBytecodeOutputSelection { @@ -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") + } } } } @@ -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)), } } @@ -573,4 +580,13 @@ 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 + ) + } }