This commit is contained in:
Johann 2022-03-09 21:18:33 -07:00
parent fb44b4aba3
commit 7624520ce9
1 changed files with 12 additions and 21 deletions

View File

@ -8,7 +8,7 @@ use crate::{
error::Result, error::Result,
utils, HardhatArtifact, ProjectPathsConfig, SolcError, utils, HardhatArtifact, ProjectPathsConfig, SolcError,
}; };
use ethers_core::{abi::{Abi, self}, types::Bytes}; use ethers_core::{abi::{Abi}, types::Bytes};
use semver::Version; use semver::Version;
use serde::{de::DeserializeOwned, Serialize}; use serde::{de::DeserializeOwned, Serialize};
use std::{ use std::{
@ -533,7 +533,6 @@ pub trait ArtifactOutput {
if is_yul_abi(artifact_path.clone()) { if is_yul_abi(artifact_path.clone()) {
//Add the target file path //Add the target file path
let target_file = file.as_str().replace(".abi.sol", ".yul"); let target_file = file.as_str().replace(".abi.sol", ".yul");
let artifact_name = name.as_str();
yul_abi_targets.insert( yul_abi_targets.insert(
target_file, target_file,
@ -564,25 +563,25 @@ pub trait ArtifactOutput {
} }
for mut yul_contract in yul_contracts { for mut yul_contract in yul_contracts {
for (yul_target_path, new_abi) in &yul_abi_targets { for (yul_target_path, needed_artifact_fragments) in &yul_abi_targets {
yul_contract.abi = new_abi.1.clone(); yul_contract.abi = needed_artifact_fragments.1.clone();
let new_artifact = self.contract_to_artifact(&yul_target_path, &new_abi.0, yul_contract.clone()); let new_artifact = self.contract_to_artifact(yul_target_path, &needed_artifact_fragments.0, yul_contract.clone());
let revised_artifact_file = ArtifactFile { let revised_artifact_file = ArtifactFile {
artifact: new_artifact, artifact: new_artifact,
file: new_abi.4.clone(), file: needed_artifact_fragments.4.clone(),
version: new_abi.2.clone(), version: needed_artifact_fragments.2.clone(),
}; };
let mut entries = BTreeMap::new(); let mut entries = BTreeMap::new();
let mut contracts = Vec::with_capacity(1); let mut contracts = Vec::with_capacity(1);
contracts.push(revised_artifact_file); contracts.push(revised_artifact_file);
entries.insert(new_abi.3.clone(), contracts); entries.insert(needed_artifact_fragments.3.clone(), contracts);
artifacts.insert(new_abi.0.clone(), entries); artifacts.insert(needed_artifact_fragments.0.clone(), entries);
} }
} }
@ -597,14 +596,10 @@ fn is_yul_abi(artifact_path: PathBuf) -> bool {
let artifact_file_name = artifact_path.into_os_string().into_string().unwrap(); let artifact_file_name = artifact_path.into_os_string().into_string().unwrap();
//parse the file extension //parse the file extension
let parsed_file_ext: Vec<&str> = artifact_file_name.split(".").collect::<Vec<&str>>(); let parsed_file_ext: Vec<&str> = artifact_file_name.split('.').collect::<Vec<&str>>();
//if the file extension contains .abi.sol //if the file extension contains .abi.sol
if parsed_file_ext[1] == "abi" { parsed_file_ext[1] == "abi"
true
} else {
false
}
} }
//check if .abi.sol in the file extension //check if .abi.sol in the file extension
@ -613,14 +608,10 @@ fn is_yul_artifact(artifact_path: PathBuf) -> bool {
let artifact_file_name = artifact_path.into_os_string().into_string().unwrap(); let artifact_file_name = artifact_path.into_os_string().into_string().unwrap();
//parse the file extension //parse the file extension
let parsed_file_ext: Vec<&str> = artifact_file_name.split(".").collect::<Vec<&str>>(); let parsed_file_ext: Vec<&str> = artifact_file_name.split('.').collect::<Vec<&str>>();
//if the file extension contains .abi.sol //if the file extension contains .abi.sol
if parsed_file_ext[1].split("/").collect::<Vec<&str>>()[0] == "yul" { parsed_file_ext[1].split('/').collect::<Vec<&str>>()[0] == "yul"
true
} else {
false
}
} }
/// An `Artifact` implementation that uses a compact representation /// An `Artifact` implementation that uses a compact representation