Skip to content

Commit

Permalink
chore: replace types
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir committed Oct 4, 2023
1 parent f0e11cd commit 4c6ba60
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
17 changes: 9 additions & 8 deletions src/artifact_output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -426,7 +427,7 @@ impl<T> Artifacts<T> {
/// A trait representation for a [`crate::Contract`] artifact
pub trait Artifact {
/// Returns the artifact's `Abi` and bytecode
fn into_inner(self) -> (Option<Abi>, Option<Bytes>);
fn into_inner(self) -> (Option<JsonAbi>, Option<Bytes>);

/// Turns the artifact into a container type for abi, compact bytecode and deployed bytecode
fn into_compact_contract(self) -> CompactContract;
Expand All @@ -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<Abi>, Option<Bytes>, Option<Bytes>);
fn into_parts(self) -> (Option<JsonAbi>, Option<Bytes>, Option<Bytes>);

/// Consumes the type and returns the [Abi]
fn into_abi(self) -> Option<Abi>
fn into_abi(self) -> Option<JsonAbi>
where
Self: Sized,
{
Expand All @@ -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,
{
Expand Down Expand Up @@ -525,7 +526,7 @@ pub trait Artifact {
}

/// Returns the reference to the [Abi] if available
fn get_abi(&self) -> Option<Cow<Abi>> {
fn get_abi(&self) -> Option<Cow<JsonAbi>> {
self.get_contract_bytecode().abi
}

Expand Down Expand Up @@ -567,7 +568,7 @@ where
T: Into<CompactContractBytecode> + Into<CompactContract>,
for<'a> &'a T: Into<CompactContractBytecodeCow<'a>>,
{
fn into_inner(self) -> (Option<Abi>, Option<Bytes>) {
fn into_inner(self) -> (Option<JsonAbi>, Option<Bytes>) {
let artifact = self.into_compact_contract();
(artifact.abi, artifact.bin.and_then(|bin| bin.into_bytes()))
}
Expand All @@ -580,7 +581,7 @@ where
self.into()
}

fn into_parts(self) -> (Option<Abi>, Option<Bytes>, Option<Bytes>) {
fn into_parts(self) -> (Option<JsonAbi>, Option<Bytes>, Option<Bytes>) {
self.into_compact_contract().into_parts()
}

Expand Down
2 changes: 1 addition & 1 deletion src/artifacts/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/artifacts/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
4 changes: 2 additions & 2 deletions src/artifacts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/artifacts/serde_helpers.rs
Original file line number Diff line number Diff line change
@@ -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<Bytes, D::Error>
Expand Down

0 comments on commit 4c6ba60

Please sign in to comment.