diff --git a/crates/compilers/src/compile/resolc/artifact_output/resolc_artifact_output.rs b/crates/compilers/src/compile/resolc/artifact_output/resolc_artifact_output.rs index 1e3d40c6..2f6125f2 100644 --- a/crates/compilers/src/compile/resolc/artifact_output/resolc_artifact_output.rs +++ b/crates/compilers/src/compile/resolc/artifact_output/resolc_artifact_output.rs @@ -64,9 +64,12 @@ impl From for CompactContractBytecode { impl From for CompactContract { fn from(value: ResolcContractArtifact) -> Self { - // See https://docs.soliditylang.org/en/develop/abi-spec.html let (standard_abi, compact_bytecode, _) = create_byte_code(&value); - Self { bin: Some(compact_bytecode.object.clone()), bin_runtime: Some(compact_bytecode.object), abi: Some(standard_abi) } + Self { + bin: Some(compact_bytecode.object.clone()), + bin_runtime: Some(compact_bytecode.object), + abi: Some(standard_abi) + } } } @@ -100,22 +103,7 @@ impl ResolcArtifactOutput { contract: Contract, source_file: Option<&SourceFile>, ) -> ResolcContractArtifact { - /* let Contract { - abi, - metadata, - userdoc, - devdoc, - ir, - storage_layout, - transient_storage_layout, - evm, - ewasm, - ir_optimized, - ir_optimized_ast, - } = contract; - let mut output = ResolcContractArtifact::default();*/ - todo!("Implement this function converting standard json to revive json"); - + todo!("Implement this function converting standard json to revive json") } } @@ -123,10 +111,12 @@ fn create_byte_code( value: &ResolcContractArtifact, ) -> (JsonAbi, CompactBytecode, CompactDeployedBytecode) { let binding = value.artifact.contracts.clone().unwrap(); - let parent_contract = - binding.values().last().and_then(|inner_map| inner_map.values().next()).unwrap(); - let abi_array: Vec = - serde_json::from_value(parent_contract.clone().abi.unwrap()).unwrap(); + let parent_contract = binding.values() + .last() + .and_then(|inner_map| inner_map.values().next()) + .unwrap(); + + let abi_array: Vec = serde_json::from_value(parent_contract.clone().abi.unwrap()).unwrap(); let mut standard_abi = JsonAbi { constructor: None, fallback: None, @@ -138,30 +128,29 @@ fn create_byte_code( for item in abi_array { match item["type"].as_str() { - Some("constructor") => { - standard_abi.constructor = serde_json::from_value(item).unwrap(); - } - Some("fallback") => { - standard_abi.fallback = serde_json::from_value(item).unwrap(); - } - Some("receive") => { - standard_abi.receive = serde_json::from_value(item).unwrap(); - } + Some("constructor") => standard_abi.constructor = serde_json::from_value(item).unwrap(), + Some("fallback") => standard_abi.fallback = serde_json::from_value(item).unwrap(), + Some("receive") => standard_abi.receive = serde_json::from_value(item).unwrap(), Some("function") => { let function: Function = serde_json::from_value(item).unwrap(); - standard_abi - .functions + standard_abi.functions .entry(function.name.clone()) .or_insert_with(Vec::new) .push(function); } Some("event") => { let event: Event = serde_json::from_value(item).unwrap(); - standard_abi.events.entry(event.name.clone()).or_insert_with(Vec::new).push(event); + standard_abi.events + .entry(event.name.clone()) + .or_insert_with(Vec::new) + .push(event); } Some("error") => { let error: alloy_json_abi::Error = serde_json::from_value(item).unwrap(); - standard_abi.errors.entry(error.name.clone()).or_insert_with(Vec::new).push(error); + standard_abi.errors + .entry(error.name.clone()) + .or_insert_with(Vec::new) + .push(error); } _ => continue, } @@ -173,8 +162,7 @@ fn create_byte_code( let raw_deployed_bytecode = binding.object.as_str(); let bytecode = BytecodeObject::Bytecode(Bytes::from(hex::decode(raw_bytecode).unwrap())); - let deployed_bytecode = - BytecodeObject::Bytecode(Bytes::from(hex::decode(raw_deployed_bytecode).unwrap())); + let deployed_bytecode = BytecodeObject::Bytecode(Bytes::from(hex::decode(raw_deployed_bytecode).unwrap())); let compact_bytecode = CompactBytecode { object: bytecode, @@ -192,4 +180,4 @@ fn create_byte_code( }; (standard_abi, compact_bytecode, compact_deployed_bytecode) -} +} \ No newline at end of file diff --git a/crates/compilers/src/compilers/mod.rs b/crates/compilers/src/compilers/mod.rs index 35b5dd75..edca2d7f 100644 --- a/crates/compilers/src/compilers/mod.rs +++ b/crates/compilers/src/compilers/mod.rs @@ -20,8 +20,8 @@ use std::{ }; pub mod multi; -pub mod solc; pub mod resolc; +pub mod solc; pub mod vyper; pub use vyper::*; diff --git a/crates/compilers/src/compilers/resolc/input.rs b/crates/compilers/src/compilers/resolc/input.rs index 08bf3bcb..2cd043fd 100644 --- a/crates/compilers/src/compilers/resolc/input.rs +++ b/crates/compilers/src/compilers/resolc/input.rs @@ -1,4 +1,4 @@ -use foundry_compilers_artifacts::{Source, Sources, SolcLanguage}; +use foundry_compilers_artifacts::{SolcLanguage, Source, Sources}; use semver::Version; use serde::{Deserialize, Serialize}; use std::path::{Path, PathBuf}; @@ -70,4 +70,4 @@ impl ResolcInput { fn new(language: SolcLanguage, sources: Sources, settings: ResolcSettings) -> Self { Self { language, sources, settings } } -} \ No newline at end of file +} diff --git a/crates/compilers/src/compilers/resolc/mod.rs b/crates/compilers/src/compilers/resolc/mod.rs index e0639e3b..686074d4 100644 --- a/crates/compilers/src/compilers/resolc/mod.rs +++ b/crates/compilers/src/compilers/resolc/mod.rs @@ -4,4 +4,4 @@ mod settings; pub use compiler::Resolc; pub use input::{ResolcInput, ResolcVersionedInput}; -pub use settings::{ResolcOptimizer, ResolcRestrictions, ResolcSettings}; \ No newline at end of file +pub use settings::{ResolcOptimizer, ResolcRestrictions, ResolcSettings}; diff --git a/crates/compilers/src/compilers/resolc/settings.rs b/crates/compilers/src/compilers/resolc/settings.rs index 40716709..fce2087d 100644 --- a/crates/compilers/src/compilers/resolc/settings.rs +++ b/crates/compilers/src/compilers/resolc/settings.rs @@ -80,4 +80,4 @@ impl CompilerSettings for ResolcSettings { fn with_include_paths(self, _include_paths: &BTreeSet) -> Self { self } -} \ No newline at end of file +}