Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename crates #45

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ repository = "https://github.com/ethers-rs/core"

[workspace.dependencies]
# workspace crates
ethers-abi-enc = { version = "0.1.0", path = "crates/abi", default-features = false }
ethers-dyn-abi = { version = "0.1.0", path = "crates/dyn-abi", default-features = false }
ethers-primitives = { version = "0.1.0", path = "crates/primitives", default-features = false }
ethers-rlp = { version = "0.1.0", path = "crates/rlp", default-features = false }
ethers-rlp-derive = { version = "0.1.0", path = "crates/rlp-derive", default-features = false }
ethers-sol-type = { version = "0.1.0", path = "crates/sol-type", default-features = false }
ethers-sol-macro = { version = "0.1.0", path = "crates/sol-macro", default-features = false }
ethers-sol-types = { version = "0.1.0", path = "crates/sol-types", default-features = false }

ruint = { version = "1.8.0", git = "https://github.com/recmo/uint", default-features = false }
ruint-macro = { version = "1.0.2", git = "https://github.com/recmo/uint", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions crates/dyn-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ homepage.workspace = true
repository.workspace = true

[dependencies]
ethers-abi-enc = { workspace = true, features = ["eip712-serde"] }
ethers-sol-types = { workspace = true, features = ["eip712-serde"] }
ethers-primitives.workspace = true

hex.workspace = true
Expand All @@ -23,4 +23,4 @@ serde_json = { workspace = true, features = ["alloc"] }

[features]
default = ["std"]
std = ["ethers-abi-enc/std", "ethers-primitives/std", "hex/std", "serde/std", "serde_json/std"]
std = ["ethers-sol-types/std", "ethers-primitives/std", "hex/std", "serde/std", "serde_json/std"]
6 changes: 3 additions & 3 deletions crates/dyn-abi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ The [`DynSolValue`] enum represents a solidity value, and describes the
rust shapes of possible solidity values. It is similar to, but not
equivalent to an enum over types used as [`crate::SolType::RustType`]. The
[`DynToken`] enum represents an ABI token, and is equivalent to an enum over
the types implementing the [`ethers_abi_enc::TokenType`] trait.
the types implementing the [`ethers_sol_types::TokenType`] trait.

Where the static encoding system encodes the expected type information into
the rust type system, the dynamic encoder/decoder encodes it as a concrete
instance of [`DynSolType`]. This type is used to tokenize and detokenize
[`DynSolValue`] instances. The [`std::str::FromStr`] impl is used to parse a
solidity type string into a [`DynSolType`] object.

- Tokenizing - `DynSolType + `DynSolValue`=`DynToken`
- Detokenizing -`DynSolType`+`DynToken`=`DynSolValue`
- Tokenizing - `DynSolType` + `DynSolValue` = `DynToken`
- Detokenizing - `DynSolType` + `DynToken` = `DynSolValue`

Users must manually handle the conversions between [`DynSolValue`] and their
own rust types. We provide several `From`implementations, but they fall
Expand Down
4 changes: 2 additions & 2 deletions crates/dyn-abi/src/eip712/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::{
};
use alloc::collections::{BTreeMap, BTreeSet};
use core::{cmp::Ordering, fmt};
use ethers_abi_enc::SolStruct;
use ethers_primitives::{keccak256, B256};
use ethers_sol_types::SolStruct;
use serde::{Deserialize, Deserializer, Serialize};

/// An EIP-712 property definition.
Expand Down Expand Up @@ -492,7 +492,7 @@ impl Resolver {

#[cfg(test)]
mod test {
use ethers_abi_enc::sol;
use ethers_sol_types::sol;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions crates/dyn-abi/src/eip712/typed_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::{
DynAbiError, DynSolType, DynSolValue,
};
use alloc::collections::BTreeMap;
use ethers_abi_enc::{Eip712Domain, SolStruct};
use ethers_primitives::{keccak256, B256};
use ethers_sol_types::{Eip712Domain, SolStruct};
use serde::{Deserialize, Serialize};

/// Custom types for `TypedData`
Expand Down Expand Up @@ -229,7 +229,7 @@ impl TypedData {
#[cfg(test)]
mod tests {
use super::*;
use ethers_abi_enc::sol;
use ethers_sol_types::sol;
use serde_json::json;

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/dyn-abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mod no_std_prelude {
mod error;
pub use error::DynAbiError;

pub use ethers_abi_enc::{Decoder, Eip712Domain, Encoder, Error, Result, SolType, Word};
pub use ethers_sol_types::{Decoder, Eip712Domain, Encoder, Error, Result, SolType, Word};

mod r#type;
pub use r#type::DynSolType;
Expand Down
4 changes: 2 additions & 2 deletions crates/dyn-abi/src/token.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{no_std_prelude::*, Decoder, Encoder, Error, Result, Word};
use ethers_abi_enc::token::{PackedSeqToken, TokenType, WordToken};
use ethers_sol_types::token::{PackedSeqToken, TokenType, WordToken};

/// A dynamic token. Equivalent to an enum over all types implementing
/// [`ethers_abi_enc::TokenType`]
/// [`ethers_sol_types::TokenType`]
// NOTE: do not derive `Hash` for this type. The derived version is not
// compatible with the current `PartialEq` implementation. If manually
// implementing `Hash`, ignore the `template` prop in the `DynSeq` variant
Expand Down
2 changes: 1 addition & 1 deletion crates/dyn-abi/src/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
no_std_prelude::*,
DynAbiError, DynSolValue, DynToken, Result, SolType, Word,
};
use ethers_abi_enc::sol_data;
use ethers_sol_types::sol_data;

#[derive(Debug, Clone, PartialEq, Eq)]
struct StructProp {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ethers-sol-type"
name = "ethers-sol-macro"
version = "0.1.0"
description = "Solidity to Rust proc-macro"
readme = "README.md"
Expand Down
4 changes: 2 additions & 2 deletions crates/sol-type/README.md → crates/sol-macro/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ethers-sol-macro

This crate provides the [`sol`][sol] proc macro, which parses Solidity syntax
to generate types that implement [`ethers-abi-enc`] traits.
to generate types that implement [`ethers-sol-types`] traits.

Refer to the [macro's documentation][sol] for more information.

[sol]: https://docs.rs/ethers-sol-type/latest/ethers_sol_type/macro.sol.html
[sol]: https://docs.rs/ethers-sol-macro/latest/ethers_sol_macro/macro.sol.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn from_into_tuples<P>(name: &Ident, fields: &Parameters<P>) -> TokenStream

quote! {
type UnderlyingSolTuple = (#(#tys,)*);
type UnderlyingRustTuple = (#(<#tys2 as ::ethers_abi_enc::SolType>::RustType,)*);
type UnderlyingRustTuple = (#(<#tys2 as ::ethers_sol_types::SolType>::RustType,)*);

#[automatically_derived]
impl From<#name> for UnderlyingRustTuple {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl ToTokens for VariableDeclaration {
fn to_tokens(&self, tokens: &mut TokenStream) {
let Self { ty, name, .. } = self;
tokens.extend(quote! {
#name: <#ty as ::ethers_abi_enc::SolType>::RustType
#name: <#ty as ::ethers_sol_types::SolType>::RustType
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ impl Error {
#converts

#[automatically_derived]
impl ::ethers_abi_enc::SolError for #name {
impl ::ethers_sol_types::SolError for #name {
type Tuple = UnderlyingSolTuple;
type Token = <UnderlyingSolTuple as ::ethers_abi_enc::SolType>::TokenType;
type Token = <UnderlyingSolTuple as ::ethers_sol_types::SolType>::TokenType;

const SIGNATURE: &'static str = #signature;
const SELECTOR: [u8; 4] = [#(#selector),*];

fn to_rust(&self) -> <Self::Tuple as ::ethers_abi_enc::SolType>::RustType {
fn to_rust(&self) -> <Self::Tuple as ::ethers_sol_types::SolType>::RustType {
self.clone().into()
}

fn from_rust(tuple: <Self::Tuple as ::ethers_abi_enc::SolType>::RustType) -> Self {
fn from_rust(tuple: <Self::Tuple as ::ethers_sol_types::SolType>::RustType) -> Self {
tuple.into()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,18 @@ impl Function {
#converts

#[automatically_derived]
impl ::ethers_abi_enc::SolCall for #call_name {
impl ::ethers_sol_types::SolCall for #call_name {
type Tuple = UnderlyingSolTuple;
type Token = <UnderlyingSolTuple as ::ethers_abi_enc::SolType>::TokenType;
type Token = <UnderlyingSolTuple as ::ethers_sol_types::SolType>::TokenType;

const SIGNATURE: &'static str = #signature;
const SELECTOR: [u8; 4] = [#(#selector),*];

fn to_rust(&self) -> <Self::Tuple as ::ethers_abi_enc::SolType>::RustType {
fn to_rust(&self) -> <Self::Tuple as ::ethers_sol_types::SolType>::RustType {
self.clone().into()
}

fn from_rust(tuple: <Self::Tuple as ::ethers_abi_enc::SolType>::RustType) -> Self {
fn from_rust(tuple: <Self::Tuple as ::ethers_sol_types::SolType>::RustType) -> Self {
tuple.into()
}

Expand Down
File renamed without changes.
21 changes: 11 additions & 10 deletions crates/sol-type/src/lib.rs → crates/sol-macro/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! # ethers-sol-type
//! # ethers-sol-macro
//!
//! This crate provides the [`sol`][sol!] procedural macro, which parses
//! Solidity syntax to generate types that implement [`ethers-abi-enc`] traits.
//! Solidity syntax to generate types that implement [`ethers-sol-types`]
//! traits.
//!
//! Refer to the [macro's documentation][sol!] for more information.

Expand All @@ -17,43 +18,43 @@ mod r#struct;
mod r#type;
mod udt;

/// Parses Solidity syntax to generate types that implement [`ethers-abi-enc`]
/// Parses Solidity syntax to generate types that implement [`ethers-sol-types`]
/// traits.
///
/// These types may then be used for safe [ABI] and [EIP-712] encoding and
/// decoding.
///
/// [ABI]: https://docs.soliditylang.org/en/latest/abi-spec.html
/// [EIP-712]: https://eips.ethereum.org/EIPS/eip-712
/// [`ethers-abi-enc`]: https://docs.rs/ethers-abi-enc
/// [`ethers-sol-types`]: https://docs.rs/ethers-sol-types
///
/// # Examples
///
/// Note: the following examples cannot tested here because the generated code
/// references `ethers-abi-enc`, so they are [tested in that crate][tests] and
/// references `ethers-sol-types`, so they are [tested in that crate][tests] and
/// included with `include_str!` in this doc instead.
///
/// [tests]: https://github.com/ethers-rs/core/tree/main/crates/abi/tests/
/// [tests]: https://github.com/ethers-rs/core/tree/main/crates/sol-types/tests/
///
/// Structs and enums:
///
/// ```ignore.
#[doc = include_str!("../../abi/tests/doc_structs.rs")]
#[doc = include_str!("../../sol-types/tests/doc_structs.rs")]
/// ```
///
/// UDVT and type aliases:
/// ```ignore.
#[doc = include_str!("../../abi/tests/doc_types.rs")]
#[doc = include_str!("../../sol-types/tests/doc_types.rs")]
/// ```
///
/// Functions, errors, and events:
/// ```ignore.
#[doc = include_str!("../../abi/tests/doc_function_like.rs")]
#[doc = include_str!("../../sol-types/tests/doc_function_like.rs")]
/// ```
///
/// Contracts/interfaces:
/// ```ignore.
#[doc = include_str!("../../abi/tests/doc_contracts.rs")]
#[doc = include_str!("../../sol-types/tests/doc_contracts.rs")]
/// ```
#[proc_macro]
pub fn sol(input: TokenStream) -> TokenStream {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Struct {
{
let mut encoded = String::from(#encoded_type);
#(
if let Some(s) = <#props_tys as ::ethers_abi_enc::SolType>::eip712_encode_type() {
if let Some(s) = <#props_tys as ::ethers_sol_types::SolType>::eip712_encode_type() {
encoded.push_str(&s);
}
)*
Expand All @@ -105,11 +105,11 @@ impl Struct {
0 => unreachable!(),
1 => {
let VariableDeclaration { ty, name, .. } = self.fields.first().unwrap();
quote!(<#ty as ::ethers_abi_enc::SolType>::eip712_data_word(&self.#name).0.to_vec())
quote!(<#ty as ::ethers_sol_types::SolType>::eip712_data_word(&self.#name).0.to_vec())
}
_ => quote! {
[#(
<#props_tys as ::ethers_abi_enc::SolType>::eip712_data_word(&self.#props).0,
<#props_tys as ::ethers_sol_types::SolType>::eip712_data_word(&self.#props).0,
)*].concat()
},
};
Expand All @@ -127,14 +127,14 @@ impl Struct {

#[allow(non_camel_case_types, non_snake_case)]
const _: () = {
use ::ethers_abi_enc::no_std_prelude::*;
use ::ethers_sol_types::no_std_prelude::*;

#convert

#[automatically_derived]
impl ::ethers_abi_enc::SolStruct for #name {
impl ::ethers_sol_types::SolStruct for #name {
type Tuple = UnderlyingSolTuple;
type Token = <UnderlyingSolTuple as ::ethers_abi_enc::SolType>::TokenType;
type Token = <UnderlyingSolTuple as ::ethers_sol_types::SolType>::TokenType;

const NAME: &'static str = #name_s;

Expand Down
20 changes: 10 additions & 10 deletions crates/sol-type/src/type.rs → crates/sol-macro/src/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ impl ToTokens for SolArray {
let span = self.span();
let expanded = if let Some(size) = &self.size {
quote_spanned! {span=>
::ethers_abi_enc::sol_data::FixedArray<#ty, #size>
::ethers_sol_types::sol_data::FixedArray<#ty, #size>
}
} else {
quote_spanned! {span=>
::ethers_abi_enc::sol_data::Array<#ty>
::ethers_sol_types::sol_data::Array<#ty>
}
};
tokens.extend(expanded);
Expand Down Expand Up @@ -215,7 +215,7 @@ impl SolTuple {
}
}

/// A custom type that implements `ethers_abi_enc::SolidityType`.
/// A custom type that implements `ethers_sol_types::SolidityType`.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum CustomType {
/// A type that has not yet been resolved.
Expand Down Expand Up @@ -438,33 +438,33 @@ impl Parse for Type {
impl ToTokens for Type {
fn to_tokens(&self, tokens: &mut TokenStream) {
let expanded = match *self {
Self::Address(span) => quote_spanned! {span=> ::ethers_abi_enc::sol_data::Address },
Self::Bool(span) => quote_spanned! {span=> ::ethers_abi_enc::sol_data::Bool },
Self::String(span) => quote_spanned! {span=> ::ethers_abi_enc::sol_data::String },
Self::Address(span) => quote_spanned! {span=> ::ethers_sol_types::sol_data::Address },
Self::Bool(span) => quote_spanned! {span=> ::ethers_sol_types::sol_data::Bool },
Self::String(span) => quote_spanned! {span=> ::ethers_sol_types::sol_data::String },

Self::Bytes { span, size: None } => {
quote_spanned! {span=> ::ethers_abi_enc::sol_data::Bytes }
quote_spanned! {span=> ::ethers_sol_types::sol_data::Bytes }
}
Self::Bytes {
span,
size: Some(size),
} => {
let size = Literal::u16_unsuffixed(size.get());
quote_spanned! {span=>
::ethers_abi_enc::sol_data::FixedBytes<#size>
::ethers_sol_types::sol_data::FixedBytes<#size>
}
}

Self::Int { span, size } => {
let size = Literal::u16_unsuffixed(size.map(NonZeroU16::get).unwrap_or(256));
quote_spanned! {span=>
::ethers_abi_enc::sol_data::Int<#size>
::ethers_sol_types::sol_data::Int<#size>
}
}
Self::Uint { span, size } => {
let size = Literal::u16_unsuffixed(size.map(NonZeroU16::get).unwrap_or(256));
quote_spanned! {span=>
::ethers_abi_enc::sol_data::Uint<#size>
::ethers_sol_types::sol_data::Uint<#size>
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl Udt {
pub fn to_tokens(&self, tokens: &mut TokenStream, attrs: &[Attribute]) {
let Self { name, ty, .. } = self;
tokens.extend(quote! {
::ethers_abi_enc::define_udt! {
::ethers_sol_types::define_udt! {
#(#attrs)*
#name,
underlying: #ty,
Expand Down
4 changes: 2 additions & 2 deletions crates/abi/Cargo.toml → crates/sol-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ethers-abi-enc"
name = "ethers-sol-types"
version = "0.1.0"
description = "Ethereum ABI encoding and decoding, with static typing"
readme = "README.md"
Expand All @@ -15,7 +15,7 @@ repository.workspace = true

[dependencies]
ethers-primitives.workspace = true
ethers-sol-type.workspace = true
ethers-sol-macro.workspace = true

hex = { workspace = true, features = ["alloc"] }

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading