From 9fac73d999b0df62f73bed3c05c0b1e99ce3728a Mon Sep 17 00:00:00 2001 From: 0xKitsune <0xKitsune@protonmail.com> Date: Tue, 8 Mar 2022 16:32:23 -0500 Subject: [PATCH] updated yul abi injection. Now able to inject the abi, just need to overwrite the yul_artifact with the newly injected abi --- ethers-solc/src/artifact_output/mod.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ethers-solc/src/artifact_output/mod.rs b/ethers-solc/src/artifact_output/mod.rs index bbc09261..c12d7685 100644 --- a/ethers-solc/src/artifact_output/mod.rs +++ b/ethers-solc/src/artifact_output/mod.rs @@ -347,7 +347,7 @@ where /// relationship (1-N+). pub trait ArtifactOutput { /// Represents the artifact that will be stored for a `Contract` - type Artifact: Artifact + DeserializeOwned + Serialize + fmt::Debug; + type Artifact: Clone + Artifact + DeserializeOwned + Serialize + fmt::Debug; /// Handle the aggregated set of compiled contracts from the solc [`crate::CompilerOutput`]. /// @@ -514,7 +514,7 @@ pub trait ArtifactOutput { //the second value is the abi that will be injected into the yul artifact //the third value is the abi.sol file path to be removed from artifacts - let mut yul_abi_targets: HashMap = HashMap::new(); + let mut yul_abi_targets: HashMap = HashMap::new(); let mut artifacts = ArtifactsMap::new(); for (file, contracts) in contracts.as_ref().iter() { @@ -541,7 +541,7 @@ pub trait ArtifactOutput { target_file, ( artifact_name.to_string(), - contract.contract.abi.as_ref().unwrap(), + contract.contract.abi.as_ref().unwrap().abi.clone(), file.to_string(), ), ); @@ -564,11 +564,21 @@ pub trait ArtifactOutput { for (yul_target_path, artifact_tuple) in yul_abi_targets { //find the target yul entry with the target file path let mut _entries = artifacts.entry(yul_target_path).or_insert(BTreeMap::new()); - + //get the artifact file from the entry let artifact_file = &_entries.get(&artifact_tuple.0).unwrap()[0]; + //inject the abi into the yul artifact + let mut yul_artifact = &artifact_file.artifact; - //TODO: Update logic to get the ConfigurableContractArtifact and inject the abi - println!("{:?}", artifact_file.artifact); + // create a new artifact + let new_artifact = artifact_file.artifact.clone(); + //get the contract_abi of the new artifact + let mut contract_abi = new_artifact.into_inner().0; + + //set the contract abi to the corresponding .abi.sol file + contract_abi = Some(artifact_tuple.1); + + //TODO: Abi is injecting, now we just need to reassign the yul_artifact to be the new_artifact + println!("{:?}", contract_abi); println!("\n"); }