Changed typing in the yul_abi_targets data structure to use a contract instead of an abi, then during yul_abi injection, create an artifact from a contract
This commit is contained in:
parent
9fac73d999
commit
8790bf5fbf
|
@ -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<String, (String, Abi, String)> = HashMap::new();
|
||||
let mut yul_abi_targets: HashMap<String, (String, Contract, String)> = 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().abi.clone(),
|
||||
contract.contract.clone(),
|
||||
file.to_string(),
|
||||
),
|
||||
);
|
||||
|
@ -563,23 +563,14 @@ pub trait ArtifactOutput {
|
|||
//inject yul abis into target .yul artifacts
|
||||
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());
|
||||
let mut _entries = artifacts.entry(yul_target_path.clone()).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;
|
||||
|
||||
// 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");
|
||||
let yul_artifact =
|
||||
&self.contract_to_artifact(&yul_target_path, &artifact_tuple.0, artifact_tuple.1);
|
||||
}
|
||||
|
||||
Artifacts(artifacts)
|
||||
|
|
|
@ -1089,7 +1089,7 @@ impl TryFrom<ContractBytecode> for ContractBytecodeSome {
|
|||
|
||||
fn try_from(value: ContractBytecode) -> Result<Self, Self::Error> {
|
||||
if value.abi.is_none() || value.bytecode.is_none() || value.deployed_bytecode.is_none() {
|
||||
return Err(value)
|
||||
return Err(value);
|
||||
}
|
||||
Ok(value.unwrap())
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ impl TryFrom<CompactContract> for CompactContractSome {
|
|||
|
||||
fn try_from(value: CompactContract) -> Result<Self, Self::Error> {
|
||||
if value.abi.is_none() || value.bin.is_none() || value.bin_runtime.is_none() {
|
||||
return Err(value)
|
||||
return Err(value);
|
||||
}
|
||||
Ok(value.unwrap())
|
||||
}
|
||||
|
@ -1290,7 +1290,7 @@ impl<'a> TryFrom<CompactContractRef<'a>> for CompactContractRefSome<'a> {
|
|||
|
||||
fn try_from(value: CompactContractRef<'a>) -> Result<Self, Self::Error> {
|
||||
if value.abi.is_none() || value.bin.is_none() || value.bin_runtime.is_none() {
|
||||
return Err(value)
|
||||
return Err(value);
|
||||
}
|
||||
Ok(value.unwrap())
|
||||
}
|
||||
|
@ -1516,7 +1516,7 @@ impl CompactBytecode {
|
|||
address: Address,
|
||||
) -> bool {
|
||||
if !self.object.is_unlinked() {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
let file = file.as_ref();
|
||||
|
@ -1529,7 +1529,7 @@ impl CompactBytecode {
|
|||
self.link_references.insert(key, contracts);
|
||||
}
|
||||
if self.link_references.is_empty() {
|
||||
return self.object.resolve().is_some()
|
||||
return self.object.resolve().is_some();
|
||||
}
|
||||
}
|
||||
false
|
||||
|
@ -1601,7 +1601,7 @@ impl Bytecode {
|
|||
address: Address,
|
||||
) -> bool {
|
||||
if !self.object.is_unlinked() {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
|
||||
let file = file.as_ref();
|
||||
|
@ -1614,7 +1614,7 @@ impl Bytecode {
|
|||
self.link_references.insert(key, contracts);
|
||||
}
|
||||
if self.link_references.is_empty() {
|
||||
return self.object.resolve().is_some()
|
||||
return self.object.resolve().is_some();
|
||||
}
|
||||
}
|
||||
false
|
||||
|
@ -1629,7 +1629,7 @@ impl Bytecode {
|
|||
{
|
||||
for (file, lib, addr) in libs.into_iter() {
|
||||
if self.link(file, lib, addr) {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
|
@ -1643,7 +1643,7 @@ impl Bytecode {
|
|||
{
|
||||
for (name, addr) in libs.into_iter() {
|
||||
if self.link_fully_qualified(name, addr) {
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
|
@ -1776,8 +1776,8 @@ impl BytecodeObject {
|
|||
pub fn contains_fully_qualified_placeholder(&self, name: impl AsRef<str>) -> bool {
|
||||
if let BytecodeObject::Unlinked(unlinked) = self {
|
||||
let name = name.as_ref();
|
||||
unlinked.contains(&utils::library_hash_placeholder(name)) ||
|
||||
unlinked.contains(&utils::library_fully_qualified_placeholder(name))
|
||||
unlinked.contains(&utils::library_hash_placeholder(name))
|
||||
|| unlinked.contains(&utils::library_fully_qualified_placeholder(name))
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue