From 4c6ba6091498593f6ebb2297526b1977b1ee42a0 Mon Sep 17 00:00:00 2001 From: Enrique Ortiz Date: Wed, 4 Oct 2023 15:33:36 +0900 Subject: [PATCH] chore: replace types --- src/artifact_output/mod.rs | 17 +++++++++-------- src/artifacts/bytecode.rs | 2 +- src/artifacts/contract.rs | 3 ++- src/artifacts/mod.rs | 4 ++-- src/artifacts/serde_helpers.rs | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/artifact_output/mod.rs b/src/artifact_output/mod.rs index c1dcbeb2..1f6459f3 100644 --- a/src/artifact_output/mod.rs +++ b/src/artifact_output/mod.rs @@ -12,7 +12,8 @@ use crate::{ sources::VersionedSourceFile, utils, HardhatArtifact, ProjectPathsConfig, SolFilesCache, SolcError, SolcIoError, }; -use ethers_core::{abi::Abi, types::Bytes}; +use alloy_json_abi::JsonAbi; +use alloy_primitives::Bytes; use semver::Version; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use std::{ @@ -426,7 +427,7 @@ impl Artifacts { /// A trait representation for a [`crate::Contract`] artifact pub trait Artifact { /// Returns the artifact's `Abi` and bytecode - fn into_inner(self) -> (Option, Option); + fn into_inner(self) -> (Option, Option); /// Turns the artifact into a container type for abi, compact bytecode and deployed bytecode fn into_compact_contract(self) -> CompactContract; @@ -435,10 +436,10 @@ pub trait Artifact { fn into_contract_bytecode(self) -> CompactContractBytecode; /// Returns the contents of this type as a single tuple of abi, bytecode and deployed bytecode - fn into_parts(self) -> (Option, Option, Option); + fn into_parts(self) -> (Option, Option, Option); /// Consumes the type and returns the [Abi] - fn into_abi(self) -> Option + fn into_abi(self) -> Option where Self: Sized, { @@ -461,7 +462,7 @@ pub trait Artifact { } /// Same as [`Self::into_parts()`] but returns `Err` if an element is `None` - fn try_into_parts(self) -> Result<(Abi, Bytes, Bytes)> + fn try_into_parts(self) -> Result<(JsonAbi, Bytes, Bytes)> where Self: Sized, { @@ -525,7 +526,7 @@ pub trait Artifact { } /// Returns the reference to the [Abi] if available - fn get_abi(&self) -> Option> { + fn get_abi(&self) -> Option> { self.get_contract_bytecode().abi } @@ -567,7 +568,7 @@ where T: Into + Into, for<'a> &'a T: Into>, { - fn into_inner(self) -> (Option, Option) { + fn into_inner(self) -> (Option, Option) { let artifact = self.into_compact_contract(); (artifact.abi, artifact.bin.and_then(|bin| bin.into_bytes())) } @@ -580,7 +581,7 @@ where self.into() } - fn into_parts(self) -> (Option, Option, Option) { + fn into_parts(self) -> (Option, Option, Option) { self.into_compact_contract().into_parts() } diff --git a/src/artifacts/bytecode.rs b/src/artifacts/bytecode.rs index 635aba3c..cd19b143 100644 --- a/src/artifacts/bytecode.rs +++ b/src/artifacts/bytecode.rs @@ -5,7 +5,7 @@ use crate::{ sourcemap::{self, SourceMap, SyntaxError}, utils, }; -use ethers_core::{abi::Address, types::Bytes}; +use alloy_primitives::{Address, Bytes}; use serde::{Deserialize, Serialize, Serializer}; use std::collections::BTreeMap; diff --git a/src/artifacts/contract.rs b/src/artifacts/contract.rs index 63acbc47..7461ecbe 100644 --- a/src/artifacts/contract.rs +++ b/src/artifacts/contract.rs @@ -7,7 +7,8 @@ use crate::artifacts::{ serde_helpers, DevDoc, Evm, Ewasm, LosslessAbi, LosslessMetadata, Offsets, StorageLayout, UserDoc, }; -use ethers_core::{abi::Contract as Abi, types::Bytes}; +use alloy_json_abi::JsonAbi as Abi; +use alloy_primitives::Bytes; use serde::{Deserialize, Serialize}; use std::{borrow::Cow, collections::BTreeMap, convert::TryFrom}; diff --git a/src/artifacts/mod.rs b/src/artifacts/mod.rs index fd8f5902..7467c075 100644 --- a/src/artifacts/mod.rs +++ b/src/artifacts/mod.rs @@ -2,7 +2,7 @@ use crate::{ compile::*, error::SolcIoError, remappings::Remapping, utils, ProjectPathsConfig, SolcError, }; -use ethers_core::abi::Abi; +use alloy_json_abi::JsonAbi as Abi; use md5::Digest; use semver::Version; use serde::{de::Visitor, Deserialize, Deserializer, Serialize, Serializer}; @@ -2270,7 +2270,7 @@ impl SourceFiles { mod tests { use super::*; use crate::AggregatedCompilerOutput; - use ethers_core::types::Address; + use alloy_primitives::Address; use std::{fs, path::PathBuf}; #[test] diff --git a/src/artifacts/serde_helpers.rs b/src/artifacts/serde_helpers.rs index a6e4197f..8cb483c6 100644 --- a/src/artifacts/serde_helpers.rs +++ b/src/artifacts/serde_helpers.rs @@ -1,6 +1,6 @@ //! serde helpers -use ethers_core::types::Bytes; +use alloy_primitives::Bytes; use serde::{Deserialize, Deserializer}; pub fn deserialize_bytes<'de, D>(d: D) -> Result