From d4a91ad0e65d2d84aeb06582be1973454da3f370 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Wed, 7 Jun 2023 01:44:00 +0200 Subject: [PATCH] chore: rename to Alloy (#69) * chore: add `workspace.package.exclude` * chore: rename to alloy-rs * docs: update README.md * docs: update package descriptions * chore: rename to Alloy --- CONTRIBUTING.md | 38 +++--- Cargo.toml | 24 ++-- README.md | 125 +++++++++----------- crates/dyn-abi/Cargo.toml | 18 +-- crates/dyn-abi/README.md | 17 +-- crates/dyn-abi/src/eip712/coerce.rs | 2 +- crates/dyn-abi/src/eip712/resolver.rs | 6 +- crates/dyn-abi/src/eip712/typed_data.rs | 6 +- crates/dyn-abi/src/lib.rs | 4 +- crates/dyn-abi/src/token.rs | 4 +- crates/dyn-abi/src/type.rs | 8 +- crates/dyn-abi/src/value.rs | 6 +- crates/primitives/Cargo.toml | 18 +-- crates/primitives/README.md | 25 ++-- crates/primitives/src/bits/address.rs | 2 +- crates/primitives/src/bits/macros.rs | 14 +-- crates/primitives/src/bits/rlp.rs | 4 +- crates/primitives/src/bytes/mod.rs | 4 +- crates/primitives/src/bytes/rlp.rs | 4 +- crates/primitives/src/lib.rs | 2 +- crates/primitives/src/signed/int.rs | 2 +- crates/rlp-derive/Cargo.toml | 10 +- crates/rlp-derive/README.md | 2 +- crates/rlp-derive/src/de.rs | 28 ++--- crates/rlp-derive/src/en.rs | 40 +++---- crates/rlp/Cargo.toml | 16 +-- crates/rlp/README.md | 22 ++-- crates/rlp/src/lib.rs | 4 +- crates/rlp/tests/derive.rs | 2 +- crates/sol-macro/Cargo.toml | 10 +- crates/sol-macro/README.md | 9 +- crates/sol-macro/src/expand/mod.rs | 54 ++++----- crates/sol-macro/src/lib.rs | 12 +- crates/sol-types/Cargo.toml | 20 ++-- crates/sol-types/README.md | 11 +- crates/sol-types/src/coder/decoder.rs | 4 +- crates/sol-types/src/coder/encoder.rs | 4 +- crates/sol-types/src/coder/token.rs | 6 +- crates/sol-types/src/eip712.rs | 2 +- crates/sol-types/src/errors.rs | 2 +- crates/sol-types/src/lib.rs | 22 ++-- crates/sol-types/src/types/data_type.rs | 2 +- crates/sol-types/src/types/error.rs | 4 +- crates/sol-types/src/types/struct.rs | 2 +- crates/sol-types/src/types/type.rs | 4 +- crates/sol-types/src/util.rs | 2 +- crates/sol-types/tests/doc_function_like.rs | 4 +- crates/sol-types/tests/doc_structs.rs | 4 +- crates/sol-types/tests/doc_types.rs | 6 +- crates/sol-types/tests/macros.rs | 6 +- crates/sol-types/tests/sol.rs | 6 +- crates/sol-types/tests/ui/empty.rs | 2 +- crates/sol-types/tests/ui/error.rs | 2 +- crates/sol-types/tests/ui/function.rs | 2 +- crates/sol-types/tests/ui/ident.rs | 2 +- crates/sol-types/tests/ui/storage.rs | 2 +- crates/sol-types/tests/ui/type.rs | 2 +- crates/sol-types/tests/ui/type.stderr | 6 +- crates/sol-types/type_system.md | 24 ++-- crates/syn-solidity/Cargo.toml | 4 +- crates/syn-solidity/src/type.rs | 2 +- 61 files changed, 346 insertions(+), 355 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 65fb5fab0..ecd27d397 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,9 +1,9 @@ -# Contributing to ethers-rs +# Contributing to Alloy :balloon: Thanks for your help improving the project! We are so happy to have you! -There are opportunities to contribute to ethers-rs at any level. It doesn't +There are opportunities to contribute to Alloy at any level. It doesn't matter if you are just getting started with Rust or are the most weathered expert, we can use your help. @@ -19,7 +19,7 @@ please join us! ## Conduct -The ethers-rs project adheres to the [Rust Code of Conduct][coc]. This describes +The Alloy project adheres to the [Rust Code of Conduct][coc]. This describes the _minimum_ behavior expected from all contributors. Instances of violations of the Code of Conduct can be reported by contacting the project team at [james@prestwich](mailto:james@prestwi.ch). @@ -31,7 +31,7 @@ of the Code of Conduct can be reported by contacting the project team at For any issue, there are fundamentally three ways an individual can contribute: 1. By opening the issue for discussion: For instance, if you believe that you - have uncovered a bug in ethers-rs, creating a new issue in the ethers-rs + have uncovered a bug in Alloy, creating a new issue in the Alloy issue tracker is the way to report it. 2. By helping to triage the issue: This can be done by providing @@ -42,7 +42,7 @@ For any issue, there are fundamentally three ways an individual can contribute: 3. By helping to resolve the issue: Typically this is done either in the form of demonstrating that the issue reported is not a problem after all, or more often, by opening a Pull Request that changes some bit of something in - ethers-rs in a concrete and reviewable manner. + Alloy in a concrete and reviewable manner. **Anybody can participate in any stage of contribution**. We urge you to participate in the discussion around bugs and participate in reviewing PRs. @@ -57,7 +57,7 @@ PR that helps others avoid the problems that you encountered. ### Submitting a Bug Report -When opening a new issue in the ethers-rs issue tracker, users will be presented +When opening a new issue in the Alloy issue tracker, users will be presented with a [basic template][template] that should be filled in. If you believe that you have uncovered a bug, please fill out this form, following the template to the best of your ability. Do not worry if you cannot answer every detail, just @@ -69,7 +69,7 @@ test case we can use to recreate the problem on our own. If we cannot recreate the issue, it becomes impossible for us to fix. In order to rule out the possibility of bugs introduced by userland code, test -cases should be limited, as much as possible, to using only ethers-rs APIs. +cases should be limited, as much as possible, to using only Alloy APIs. See [How to create a Minimal, Complete, and Verifiable example][mcve]. @@ -101,12 +101,12 @@ In the majority of cases, issues are resolved by opening a Pull Request. The process for opening and reviewing a Pull Request is similar to that of opening and triaging issues, but carries with it a necessary review and approval workflow that ensures that the proposed changes meet the minimal quality and -functional guidelines of the ethers-rs project. +functional guidelines of the Alloy project. ## Pull Requests Pull Requests are the way concrete changes are made to the code, documentation, -and dependencies in the ethers-rs repository. +and dependencies in the Alloy repository. Even tiny pull requests (e.g., one character pull request fixing a typo in API documentation) are greatly appreciated. Before making a large change, it is @@ -118,7 +118,7 @@ merged. This section lists some commonly needed commands. -``` +```sh cargo check --all-features cargo +nightly fmt --all cargo build --all-features @@ -129,9 +129,9 @@ cargo +nightly clippy --all-features ### Tests If the change being proposed alters code (as opposed to only documentation for -example), it is either adding new functionality to ethers-rs or it is fixing +example), it is either adding new functionality to Alloy or it is fixing existing, broken functionality. In both of these cases, the pull request should -include one or more tests to ensure that ethers-rs does not regress in the +include one or more tests to ensure that Alloy does not regress in the future. #### Unit Tests @@ -221,9 +221,9 @@ however, will stay intact on the Pull Request page. ## Reviewing Pull Requests -**Any ethers-rs community member is welcome to review any pull request**. +**Any Alloy community member is welcome to review any pull request**. -All ethers-rs contributors who choose to review and provide feedback on Pull +All Alloy contributors who choose to review and provide feedback on Pull Requests have a responsibility to both the project and the individual making the contribution. Reviews and feedback must be helpful, insightful, and geared towards improving the contribution as opposed to simply blocking it. If there @@ -250,8 +250,8 @@ perfect grammar, or exact style matches. Do not succumb to that temptation. Focus first on the most significant aspects of the change: -1. Does this change make sense for ethers-rs? -2. Does this change make ethers-rs better, even if only incrementally? +1. Does this change make sense for Alloy? +2. Does this change make Alloy better, even if only incrementally? 3. Are there clear bugs or larger scale issues that need attending to? 4. Is the commit message readable and correct? If it contains a breaking change is it clear enough? @@ -268,7 +268,7 @@ change over time. The first impression you give to a new contributor never does. Nits (requests for small changes that are not essential) are fine, but try to avoid stalling the Pull Request. Most nits can typically be fixed by the -ethers-rs Collaborator landing the Pull Request but they can also be an +Alloy Collaborator landing the Pull Request but they can also be an opportunity for the contributor to learn a bit more about the project. It is always good to clearly indicate nits when you comment: e.g. @@ -282,8 +282,8 @@ with the appropriate reason to keep the conversation flow concise and relevant. Be aware that _how_ you communicate requests and reviews in your feedback can have a significant impact on the success of the Pull Request. Yes, we may land -a particular change that makes ethers-rs better, but the individual might just -not want to have anything to do with ethers-rs ever again. The goal is not just +a particular change that makes Alloy better, but the individual might just +not want to have anything to do with Alloy ever again. The goal is not just having good code. ### Abandoned or Stalled Pull Requests diff --git a/Cargo.toml b/Cargo.toml index 574734563..83b29080d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,16 @@ [workspace] -resolver = "2" members = ["crates/*"] +resolver = "2" [workspace.package] +version = "0.1.0" edition = "2021" -rust-version = "1.65" # Remember to update .clippy.toml and workflows/ci.yml -authors = [] +rust-version = "1.65" +authors = ["Alloy Contributors"] license = "MIT OR Apache-2.0" -homepage = "https://github.com/ethers-rs/core" -repository = "https://github.com/ethers-rs/core" +homepage = "https://github.com/alloy-rs/core" +repository = "https://github.com/alloy-rs/core" +exclude = ["benches/", "tests/"] [workspace.metadata.docs.rs] all-features = true @@ -16,12 +18,12 @@ rustdoc-args = ["--cfg", "docsrs"] [workspace.dependencies] # workspace crates -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-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 } +alloy-dyn-abi = { version = "0.1.0", path = "crates/dyn-abi", default-features = false } +alloy-primitives = { version = "0.1.0", path = "crates/primitives", default-features = false } +alloy-rlp = { version = "0.1.0", path = "crates/rlp", default-features = false } +alloy-rlp-derive = { version = "0.1.0", path = "crates/rlp-derive", default-features = false } +alloy-sol-macro = { version = "0.1.0", path = "crates/sol-macro", default-features = false } +alloy-sol-types = { version = "0.1.0", path = "crates/sol-types", default-features = false } syn-solidity = { version = "0.1.0", path = "crates/syn-solidity", default-features = false } ruint = { version = "1.8.0", git = "https://github.com/recmo/uint", default-features = false } diff --git a/README.md b/README.md index 80ce1387f..951821d4e 100644 --- a/README.md +++ b/README.md @@ -1,84 +1,75 @@ -

ethers-rs core

+# Alloy -This repository holds the core crates at the root of the the ethers-rs -ecosystem. These types and libraries will be used by revm, reth, ethers, and -foundry. +Core libraries at the root of the Rust Ethereum ecosystem. -## What's in the box? +[![Build Status][actions-badge]][actions-url] +[![Telegram chat][telegram-badge]][telegram-url] -This repository contains the following crates: - -- **ethers-rlp** - A Rust implementation of the Ethereum RLP encoding. -- **ethers-rlp-derive** - A derive macro for RLP encoding. -- **ethers-primitives** - Signed & unsigned integers, and fixed-sized - bytearrays. -- **ethers-sol-types** - Rust representation of Solidity types with ABI and - EIP-712 encoding. -- **ethers-sol-macro** - A macro for generating Rust representations of Solidity - types by parsing Solidity snippets. -- **ethers-dyn-abi** - ABI encoding and decoding of types that are not known at - runtime. -- **ethers-serde-helpers** - Serde helpers for the ethers crates (coming soon). - -## Developer Information - -No special actions needed. Clone the repo and make sure rust is installed - -### Build commands - -- `$ cargo clippy` -- `$ cargo clippy --no-default-features` -- `$ cargo clippy --all-features` +[actions-badge]: https://img.shields.io/github/actions/workflow/status/alloy-rs/core/ci.yml?branch=main&style=for-the-badge +[actions-url]: https://github.com/alloy-rs/core/actions?query=branch%3Amain +[telegram-badge]: https://img.shields.io/endpoint?color=neon&style=for-the-badge&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fethers_rs +[telegram-url]: https://t.me/ethers_rs -### Testing commands +## Overview -- `$ cargo test` -- `$ cargo test --no-default-features` -- `$ cargo test --all-features` - -### MSRV - -We do not guarantee a specific MSRV. We like to keep up-to-date and take -advantage of new features. - -### Features +This repository contains the following crates: -- `ethers-rlp/std` - `std` support for `ethers-rlp` Enabled by default. -- `ethers-primitives/rlp` - `rlp` support for `ethers-primitives` Enabled by - default. -- `ethers-primitives/serde` - `serde` support for `ethers-primitives` Enabled by - default. -- `ethers-sol-types/eip712-serde` - `serde` support for the `Eip712Domain` - struct. +- [`alloy-primitives`] - Primitive integer and byte types +- [`alloy-rlp`] - Implementation of [Ethereum RLP serialization][rlp] +- [`alloy-rlp-derive`] - Derive macros for `alloy-rlp` +- [`alloy-dyn-abi`] - Run-time ABI and [EIP-712] implementations +- [`alloy-sol-types`] - Compile-time ABI and [EIP-712] implementations +- [`alloy-sol-macro`] - The `sol!` procedural macro +- [`syn-solidity`] - [`syn`]-powered Solidity parser, used by `alloy-sol-macro` + +[`alloy-primitives`]: ./crates/alloy-primitives +[`alloy-rlp`]: ./crates/alloy-rlp +[`alloy-rlp-derive`]: ./crates/alloy-rlp-derive +[`alloy-sol-types`]: ./crates/alloy-sol-types +[`alloy-sol-macro`]: ./crates/alloy-sol-macro +[`alloy-dyn-abi`]: ./crates/alloy-dyn-abi +[`syn-solidity`]: ./crates/syn-solidity + +[rlp]: https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp +[EIP-712]: https://eips.ethereum.org/EIPS/eip-712 +[`syn`]: https://github.com/dtolnay/syn + +## Supported Rust Versions + + + +Alloy will keep a rolling MSRV (minimum supported rust version) policy of **at +least** 6 months. When increasing the MSRV, the new Rust version must have been +released at least six months ago. The current MSRV is 1.65.0. + +Note that the MSRV is not increased automatically, and only as part of a minor +release. ## Contributing Thanks for your help improving the project! We are so happy to have you! We have [a contributing guide](./CONTRIBUTING.md) to help you get involved in the -ethers-rs project. - -If you open a Pull Request, do not forget to add your changes in the -[CHANGELOG](./CHANGELOG.md). +Alloy project. Pull requests will not be merged unless CI passes, so please ensure that your -contribution follows the linting rules and passes clippy. :) +contribution follows the linting rules and passes clippy. -## Note on WASM and FFI bindings +## Note on WASM -You should be able to build a wasm app that uses ethers-rs. If ethers fails to -compile in WASM, please -[open an issue]. There is -currently no plan to provide an official JS/TS-accessible library interface. We -believe [viem](https://viem.sh) or [ethers.js](https://docs.ethers.io/v6/) -serves that need very well. +We provide full support for all the `wasm*-*` targets. If any crate does not +build on a WASM target, please [open an issue]. -Similarly, you should be able to build FFI bindings to ethers-rs. If ethers -fails to compile in c lib formats, please -[open an issue]. -There is currently no plan to provide official FFI bindings, and as ethers-rs is -not yet stable 1.0.0, its interface may change significantly between versions. +There is currently no plan to provide an official JS/TS-accessible library +interface, as we believe [viem] or [ethers.js] serve that need very well. -[open an issue]: https://github.com/ethers-rs/core/issues/new +[viem]: https://viem.sh +[ethers.js]: https://docs.ethers.io/v6/ +[open an issue]: https://github.com/alloy-rs/core/issues/new ## Note on `no_std` @@ -89,14 +80,10 @@ contribute upstream PRs to achieve it in ruint. ## Credits -These librarires would not have been possible without the great work done in: +None of these crates would have been possible without the great work done in: - [`ethers.js`](https://github.com/ethers-io/ethers.js/) - [`rust-web3`](https://github.com/tomusdrw/rust-web3/) - [`ethcontract-rs`](https://github.com/gnosis/ethcontract-rs/) - [`guac_rs`](https://github.com/althea-net/guac_rs/) - [`ruint`](https://github.com/recmo/uint) - -A lot of the code was inspired and adapted from them, to a unified and -opinionated interface, built with async/await and std futures from the ground -up. diff --git a/crates/dyn-abi/Cargo.toml b/crates/dyn-abi/Cargo.toml index d62b36d07..519b38ce5 100644 --- a/crates/dyn-abi/Cargo.toml +++ b/crates/dyn-abi/Cargo.toml @@ -1,25 +1,25 @@ [package] -name = "ethers-dyn-abi" -version = "0.1.0" -description = "Ethereum ABI encoding and decoding, with runtime typing" -readme = "README.md" +name = "alloy-dyn-abi" +description = "Run-time ABI and EIP-712 implementations" keywords = ["ethereum", "abi", "encoding", "EVM", "solidity"] -categories = ["encoding", "cryptography::cryptocurrencies"] +categories = ["no-std", "encoding", "cryptography::cryptocurrencies"] +homepage = "https://github.com/alloy-rs/core/tree/main/crates/dyn-abi" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true -homepage.workspace = true repository.workspace = true +exclude.workspace = true [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -ethers-sol-types = { workspace = true, features = ["eip712-serde"] } -ethers-primitives.workspace = true +alloy-sol-types = { workspace = true, features = ["eip712-serde"] } +alloy-primitives.workspace = true hex.workspace = true serde.workspace = true @@ -27,4 +27,4 @@ serde_json = { workspace = true, features = ["alloc"] } [features] default = ["std"] -std = ["ethers-sol-types/std", "ethers-primitives/std", "hex/std", "serde/std", "serde_json/std"] +std = ["alloy-sol-types/std", "alloy-primitives/std", "hex/std", "serde/std", "serde_json/std"] diff --git a/crates/dyn-abi/README.md b/crates/dyn-abi/README.md index 4c7a0ca13..e8680ebe3 100644 --- a/crates/dyn-abi/README.md +++ b/crates/dyn-abi/README.md @@ -1,7 +1,8 @@ -# ethers-dyn-abi +# alloy-dyn-abi -Dynamic Solidity type encoder: Run-time representation of Ethereum's type -system with ABI encoding & decoding. +Dynamic Solidity type encoder. + +Run-time representation of Ethereum's type system with ABI encoding & decoding. This library provides a runtime encoder/decoder for solidity types. It is intended to be used when the solidity type is not known at compile time. @@ -12,12 +13,12 @@ The dyanmic encoder/decoder is significantly more expensive, especially for complex types. It is also significantly more error prone, as the mapping between solidity types and rust types is not enforced by the compiler. -[abi]: https://docs.rs/ethers-sol-types/latest/ethers_sol_types/ +[abi]: https://docs.rs/alloy-sol-types/latest/alloy_sol_types/ ## Usage ```rust -use ethers_dyn_abi::{DynSolType, DynSolValue}; +use alloy_dyn_abi::{DynSolType, DynSolValue}; // parse a type from a string // limitation: custom structs cannot currently be parsed this way. @@ -47,7 +48,7 @@ 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_sol_types::TokenType`] trait. +the types implementing the [`alloy_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 @@ -55,8 +56,8 @@ 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 diff --git a/crates/dyn-abi/src/eip712/coerce.rs b/crates/dyn-abi/src/eip712/coerce.rs index 270c5bf3c..d212cf3c3 100644 --- a/crates/dyn-abi/src/eip712/coerce.rs +++ b/crates/dyn-abi/src/eip712/coerce.rs @@ -1,5 +1,5 @@ use crate::{no_std_prelude::*, DynAbiError, DynSolType, DynSolValue, Word}; -use ethers_primitives::{Address, I256, U256}; +use alloy_primitives::{Address, I256, U256}; /// Coerce a `serde_json::Value` to a `DynSolValue::Address` pub(crate) fn address(value: &serde_json::Value) -> Result { diff --git a/crates/dyn-abi/src/eip712/resolver.rs b/crates/dyn-abi/src/eip712/resolver.rs index bfebba093..a0e6a6ba6 100644 --- a/crates/dyn-abi/src/eip712/resolver.rs +++ b/crates/dyn-abi/src/eip712/resolver.rs @@ -6,9 +6,9 @@ use crate::{ DynAbiError, DynSolType, DynSolValue, }; use alloc::collections::{BTreeMap, BTreeSet}; +use alloy_primitives::{keccak256, B256}; +use alloy_sol_types::SolStruct; use core::{cmp::Ordering, fmt}; -use ethers_primitives::{keccak256, B256}; -use ethers_sol_types::SolStruct; use serde::{Deserialize, Deserializer, Serialize}; /// An EIP-712 property definition. @@ -492,7 +492,7 @@ impl Resolver { #[cfg(test)] mod test { - use ethers_sol_types::sol; + use alloy_sol_types::sol; use super::*; diff --git a/crates/dyn-abi/src/eip712/typed_data.rs b/crates/dyn-abi/src/eip712/typed_data.rs index 099944fec..2c490b188 100644 --- a/crates/dyn-abi/src/eip712/typed_data.rs +++ b/crates/dyn-abi/src/eip712/typed_data.rs @@ -5,8 +5,8 @@ use crate::{ DynAbiError, DynSolType, DynSolValue, }; use alloc::collections::BTreeMap; -use ethers_primitives::{keccak256, B256}; -use ethers_sol_types::{Eip712Domain, SolStruct}; +use alloy_primitives::{keccak256, B256}; +use alloy_sol_types::{Eip712Domain, SolStruct}; use serde::{Deserialize, Serialize}; /// Custom types for `TypedData` @@ -232,7 +232,7 @@ impl TypedData { #[cfg(test)] mod tests { use super::*; - use ethers_sol_types::sol; + use alloy_sol_types::sol; use serde_json::json; #[test] diff --git a/crates/dyn-abi/src/lib.rs b/crates/dyn-abi/src/lib.rs index ddf5829e0..4815b270d 100644 --- a/crates/dyn-abi/src/lib.rs +++ b/crates/dyn-abi/src/lib.rs @@ -1,5 +1,5 @@ // Copyright 2015-2020 Parity Technologies -// Copyright 2023-2023 Ethers-rs Team +// Copyright 2023-2023 Alloy Contributors // Licensed under the Apache License, Version 2.0 or the MIT license @@ -35,7 +35,7 @@ mod no_std_prelude { mod error; pub use error::DynAbiError; -pub use ethers_sol_types::{Decoder, Eip712Domain, Encoder, Error, Result, SolType, Word}; +pub use alloy_sol_types::{Decoder, Eip712Domain, Encoder, Error, Result, SolType, Word}; mod r#type; pub use r#type::DynSolType; diff --git a/crates/dyn-abi/src/token.rs b/crates/dyn-abi/src/token.rs index a738ccef4..ce5afd68f 100644 --- a/crates/dyn-abi/src/token.rs +++ b/crates/dyn-abi/src/token.rs @@ -1,8 +1,8 @@ use crate::{no_std_prelude::*, Decoder, Encoder, Error, Result, Word}; -use ethers_sol_types::token::{PackedSeqToken, TokenType, WordToken}; +use alloy_sol_types::token::{PackedSeqToken, TokenType, WordToken}; /// A dynamic token. Equivalent to an enum over all types implementing -/// [`ethers_sol_types::TokenType`] +/// [`alloy_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 diff --git a/crates/dyn-abi/src/type.rs b/crates/dyn-abi/src/type.rs index c820a9f72..5a8cc55b9 100644 --- a/crates/dyn-abi/src/type.rs +++ b/crates/dyn-abi/src/type.rs @@ -3,7 +3,7 @@ use crate::{ no_std_prelude::*, DynAbiError, DynSolValue, DynToken, Result, SolType, Word, }; -use ethers_sol_types::sol_data; +use alloy_sol_types::sol_data; #[derive(Debug, Clone, PartialEq, Eq)] struct StructProp { @@ -22,8 +22,8 @@ struct StructProp { /// /// # Example /// ``` -/// # use ethers_dyn_abi::{DynSolType, DynSolValue, Result}; -/// # use ethers_primitives::U256; +/// # use alloy_dyn_abi::{DynSolType, DynSolValue, Result}; +/// # use alloy_primitives::U256; /// # pub fn main() -> Result<()> { /// let my_type = DynSolType::Uint(256); /// let my_data: DynSolValue = U256::from(183).into(); @@ -394,7 +394,7 @@ impl DynSolType { mod test { use super::*; use crate::*; - use ethers_primitives::Address; + use alloy_primitives::Address; use serde_json::json; #[test] diff --git a/crates/dyn-abi/src/value.rs b/crates/dyn-abi/src/value.rs index 6da850382..c79d95bf5 100644 --- a/crates/dyn-abi/src/value.rs +++ b/crates/dyn-abi/src/value.rs @@ -1,5 +1,5 @@ use crate::{no_std_prelude::*, Word}; -use ethers_primitives::{Address, I256, U256}; +use alloy_primitives::{Address, I256, U256}; /// This type represents a Solidity value that has been decoded into rust. It /// is broadly similar to `serde_json::Value` in that it is an enum of possible @@ -252,9 +252,9 @@ macro_rules! impl_from_int { const _: () = assert!(BYTES <= 32); let mut word = if value.is_negative() { - ethers_primitives::B256::repeat_byte(0xff) + alloy_primitives::B256::repeat_byte(0xff) } else { - ethers_primitives::B256::default() + alloy_primitives::B256::default() }; word[32 - BYTES..].copy_from_slice(&value.to_be_bytes()); diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index de53296d1..e308f2077 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "ethers-primitives" -version = "0.1.0" -description = "Fundamental ethereum types shared by revm, reth and ethers" -readme = "README.md" +name = "alloy-primitives" +description = "Ethereum primitive types" keywords = ["ethereum", "ethers", "revm", "reth"] -categories = ["data-structures", "cryptography::cryptocurrencies"] +categories = ["no-std", "data-structures", "cryptography::cryptocurrencies"] +homepage = "https://github.com/alloy-rs/core/tree/main/crates/primitives" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true -homepage.workspace = true repository.workspace = true +exclude.workspace = true [package.metadata.docs.rs] all-features = true @@ -32,7 +32,7 @@ tiny-keccak = { workspace = true, features = ["keccak"] } derive_more.workspace = true # rlp -ethers-rlp = { workspace = true, optional = true } +alloy-rlp = { workspace = true, optional = true } # serde serde = { workspace = true, optional = true } @@ -48,8 +48,8 @@ serde_json.workspace = true [features] default = ["std", "rlp", "serde"] -std = ["bytes/std", "hex/std", "ethers-rlp?/std", "proptest?/std", "serde/std"] -rlp = ["dep:ethers-rlp", "ruint/fastrlp"] +std = ["bytes/std", "hex/std", "alloy-rlp?/std", "proptest?/std", "serde/std"] +rlp = ["dep:alloy-rlp", "ruint/fastrlp"] serde = ["dep:serde", "bytes/serde", "hex/serde", "ruint/serde"] arbitrary = [ "std", diff --git a/crates/primitives/README.md b/crates/primitives/README.md index 418a25ab4..4bcaf7e7e 100644 --- a/crates/primitives/README.md +++ b/crates/primitives/README.md @@ -1,29 +1,30 @@ -# ethers-types +# alloy-primitives -Fundamental types shared by [reth], [revm], [ethers], and [foundry]. +Primitive types shared by [alloy], [foundry], [revm], and [reth]. -[reth]: https://github.com/paradigmxyz/reth -[revm]: https://github.com/bluealloy/revm -[ethers]: https://github.com/ethers-rs/core +[alloy]: https://github.com/alloy-rs [foundry]: https://github.com/foundry-rs/foundry +[revm]: https://github.com/bluealloy/revm +[reth]: https://github.com/paradigmxyz/reth ## Types -- Unsigned integers re-exported from [ruint](https://docs.rs/ruint) +- Unsigned integers re-exported from [ruint](https://github.com/recmo/uint) - Signed integers, as a wrapper around `ruint` integers - Fixed-size byte arrays via [`FixedBytes`] - - a macro [`wrap_fixed_bytes`] for constructing named fixed bytes types - - [`Address`], which is a fixed-size byte array of 20 bytes, with EIP-55 and - EIP-1191 checksum support + - a macro [`wrap_fixed_bytes`] for constructing named fixed bytes types + - [`Address`], which is a fixed-size byte array of 20 bytes, with EIP-55 and + EIP-1191 checksum support ## Examples -This library has straightforward, basic, types. Usage is correspondingly simple. Please consult [the documentation][docs] for more information. +This library has straightforward, basic, types. Usage is correspondingly simple. +Please consult [the documentation][docs] for more information. -[docs]: https://docs.rs/ethers-types/latest/ethers-types/ +[docs]: https://docs.rs/alloy-types/latest/alloy-types/ ```rust -use ethers_primitives::{U256, Address, FixedBytes, I256}; +use alloy_primitives::{U256, Address, FixedBytes, I256}; // FixedBytes let n: FixedBytes<6> = "0x1234567890ab".parse().unwrap(); diff --git a/crates/primitives/src/bits/address.rs b/crates/primitives/src/bits/address.rs index 6c8d3896a..0361c2f70 100644 --- a/crates/primitives/src/bits/address.rs +++ b/crates/primitives/src/bits/address.rs @@ -184,7 +184,7 @@ impl Address { #[cfg(feature = "rlp")] pub fn create>(sender: T, nonce: u64) -> Address { fn create(sender: &[u8; 20], nonce: u64) -> Address { - use ethers_rlp::Encodable; + use alloy_rlp::Encodable; let mut out = alloc::vec::Vec::with_capacity(64); let buf = &mut out as &mut dyn bytes::BufMut; diff --git a/crates/primitives/src/bits/macros.rs b/crates/primitives/src/bits/macros.rs index 706560bb4..a864c3c69 100644 --- a/crates/primitives/src/bits/macros.rs +++ b/crates/primitives/src/bits/macros.rs @@ -7,7 +7,7 @@ /// # Example /// /// ``` -/// use ethers_primitives::wrap_fixed_bytes; +/// use alloy_primitives::wrap_fixed_bytes; /// /// // These hashes are the same length, and have the same functionality, but /// // are distinct types @@ -258,22 +258,22 @@ macro_rules! wrap_fixed_bytes { #[cfg(feature = "rlp")] macro_rules! impl_rlp { ($t:ty) => { - impl $crate::private::ethers_rlp::Decodable for $t { + impl $crate::private::alloy_rlp::Decodable for $t { #[inline] - fn decode(buf: &mut &[u8]) -> Result { - $crate::private::ethers_rlp::Decodable::decode(buf).map(Self) + fn decode(buf: &mut &[u8]) -> Result { + $crate::private::alloy_rlp::Decodable::decode(buf).map(Self) } } - impl $crate::private::ethers_rlp::Encodable for $t { + impl $crate::private::alloy_rlp::Encodable for $t { #[inline] fn length(&self) -> usize { - $crate::private::ethers_rlp::Encodable::length(&self.0) + $crate::private::alloy_rlp::Encodable::length(&self.0) } #[inline] fn encode(&self, out: &mut dyn bytes::BufMut) { - $crate::private::ethers_rlp::Encodable::encode(&self.0, out) + $crate::private::alloy_rlp::Encodable::encode(&self.0, out) } } }; diff --git a/crates/primitives/src/bits/rlp.rs b/crates/primitives/src/bits/rlp.rs index 35e419792..e6928193a 100644 --- a/crates/primitives/src/bits/rlp.rs +++ b/crates/primitives/src/bits/rlp.rs @@ -1,9 +1,9 @@ use super::FixedBytes; -use ethers_rlp::{impl_max_encoded_len, length_of_length, Decodable, Encodable}; +use alloy_rlp::{impl_max_encoded_len, length_of_length, Decodable, Encodable}; impl Decodable for FixedBytes { #[inline] - fn decode(buf: &mut &[u8]) -> Result { + fn decode(buf: &mut &[u8]) -> Result { Decodable::decode(buf).map(Self) } } diff --git a/crates/primitives/src/bytes/mod.rs b/crates/primitives/src/bytes/mod.rs index afc26beb4..d2cf0d5d5 100644 --- a/crates/primitives/src/bytes/mod.rs +++ b/crates/primitives/src/bytes/mod.rs @@ -166,7 +166,7 @@ impl Bytes { /// # Examples /// /// ``` - /// use ethers_primitives::Bytes; + /// use alloy_primitives::Bytes; /// /// let b = Bytes::new(); /// assert_eq!(&b[..], b""); @@ -184,7 +184,7 @@ impl Bytes { /// # Examples /// /// ``` - /// use ethers_primitives::Bytes; + /// use alloy_primitives::Bytes; /// /// let b = Bytes::from_static(b"hello"); /// assert_eq!(&b[..], b"hello"); diff --git a/crates/primitives/src/bytes/rlp.rs b/crates/primitives/src/bytes/rlp.rs index 60702bca5..f7e5d3d66 100644 --- a/crates/primitives/src/bytes/rlp.rs +++ b/crates/primitives/src/bytes/rlp.rs @@ -1,5 +1,5 @@ use super::Bytes; -use ethers_rlp::{Decodable, Encodable}; +use alloy_rlp::{Decodable, Encodable}; impl Encodable for Bytes { fn length(&self) -> usize { @@ -12,7 +12,7 @@ impl Encodable for Bytes { } impl Decodable for Bytes { - fn decode(buf: &mut &[u8]) -> Result { + fn decode(buf: &mut &[u8]) -> Result { Ok(Self(bytes::Bytes::decode(buf)?)) } } diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 47f681566..c0b0c3bd3 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -46,7 +46,7 @@ pub mod private { pub use getrandom; #[cfg(feature = "rlp")] - pub use ethers_rlp; + pub use alloy_rlp; #[cfg(feature = "serde")] pub use serde; diff --git a/crates/primitives/src/signed/int.rs b/crates/primitives/src/signed/int.rs index afc75b814..8f1e4ebd6 100644 --- a/crates/primitives/src/signed/int.rs +++ b/crates/primitives/src/signed/int.rs @@ -20,7 +20,7 @@ use ruint::Uint; /// # Usage /// /// ``` -/// # use ethers_primitives::I256; +/// # use alloy_primitives::I256; /// // Instantiate from a number /// let a = I256::unchecked_from(1); /// // Use `try_from` if you're not sure it'll fit diff --git a/crates/rlp-derive/Cargo.toml b/crates/rlp-derive/Cargo.toml index 6c649e137..2a7e9718e 100644 --- a/crates/rlp-derive/Cargo.toml +++ b/crates/rlp-derive/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "ethers-rlp-derive" -version = "0.1.0" -description = "Procedural macros for ethers-rlp" -readme = "README.md" +name = "alloy-rlp-derive" +description = "Derive macros for alloy-rlp" keywords = ["ethereum", "rlp", "serialization"] categories = ["encoding", "cryptography::cryptocurrencies"] +homepage = "https://github.com/alloy-rs/core/tree/main/crates/rlp-derive" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true -homepage.workspace = true repository.workspace = true +exclude.workspace = true [lib] proc-macro = true diff --git a/crates/rlp-derive/README.md b/crates/rlp-derive/README.md index 13869f43a..61399e0f9 100644 --- a/crates/rlp-derive/README.md +++ b/crates/rlp-derive/README.md @@ -1,7 +1,7 @@ ## RLP derive crate This crate provides derive macros for traits defined in -[`ethers-rlp`](https://docs.rs/ethers-rlp). See that crate's documentation for +[`alloy-rlp`](https://docs.rs/alloy-rlp). See that crate's documentation for more information. ### Provenance notes diff --git a/crates/rlp-derive/src/de.rs b/crates/rlp-derive/src/de.rs index 3f450b2a8..bffd8ef50 100644 --- a/crates/rlp-derive/src/de.rs +++ b/crates/rlp-derive/src/de.rs @@ -34,16 +34,16 @@ pub(crate) fn impl_decodable(ast: &syn::DeriveInput) -> Result { let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl(); let impl_block = quote! { - impl #impl_generics ethers_rlp::Decodable for #name #ty_generics #where_clause { - fn decode(mut buf: &mut &[u8]) -> Result { + impl #impl_generics alloy_rlp::Decodable for #name #ty_generics #where_clause { + fn decode(mut buf: &mut &[u8]) -> Result { let b = &mut &**buf; - let rlp_head = ethers_rlp::Header::decode(b)?; + let rlp_head = alloy_rlp::Header::decode(b)?; if !rlp_head.list { - return Err(ethers_rlp::DecodeError::UnexpectedString); + return Err(alloy_rlp::DecodeError::UnexpectedString); } - if ethers_rlp::Buf::remaining(b) < rlp_head.payload_length { - return Err(ethers_rlp::DecodeError::InputTooShort); + if alloy_rlp::Buf::remaining(b) < rlp_head.payload_length { + return Err(alloy_rlp::DecodeError::InputTooShort); } let started_len = b.len(); @@ -53,7 +53,7 @@ pub(crate) fn impl_decodable(ast: &syn::DeriveInput) -> Result { let consumed = started_len - b.len(); if consumed != rlp_head.payload_length { - return Err(ethers_rlp::DecodeError::ListLengthMismatch { + return Err(alloy_rlp::DecodeError::ListLengthMismatch { expected: rlp_head.payload_length, got: consumed, }); @@ -68,7 +68,7 @@ pub(crate) fn impl_decodable(ast: &syn::DeriveInput) -> Result { Ok(quote! { const _: () = { - extern crate ethers_rlp; + extern crate alloy_rlp; #impl_block }; }) @@ -87,16 +87,16 @@ pub(crate) fn impl_decodable_wrapper(ast: &syn::DeriveInput) -> Result Result { - Ok(Self(ethers_rlp::Decodable::decode(buf)?)) + impl #impl_generics alloy_rlp::Decodable for #name #ty_generics #where_clause { + fn decode(buf: &mut &[u8]) -> Result { + Ok(Self(alloy_rlp::Decodable::decode(buf)?)) } } }; Ok(quote! { const _: () = { - extern crate ethers_rlp; + extern crate alloy_rlp; #impl_block }; }) @@ -114,13 +114,13 @@ fn decodable_field(index: usize, field: &syn::Field, is_opt: bool) -> TokenStrea bytes::Buf::advance(b, 1); None } else { - Some(ethers_rlp::Decodable::decode(b)?) + Some(alloy_rlp::Decodable::decode(b)?) } } else { None }, } } else { - quote! { #ident: ethers_rlp::Decodable::decode(b)?, } + quote! { #ident: alloy_rlp::Decodable::decode(b)?, } } } diff --git a/crates/rlp-derive/src/en.rs b/crates/rlp-derive/src/en.rs index 5f2b6c9d3..5fe3b5181 100644 --- a/crates/rlp-derive/src/en.rs +++ b/crates/rlp-derive/src/en.rs @@ -45,23 +45,23 @@ pub(crate) fn impl_encodable(ast: &syn::DeriveInput) -> Result { let impl_block = quote! { trait E { - fn rlp_header(&self) -> ethers_rlp::Header; + fn rlp_header(&self) -> alloy_rlp::Header; } impl #impl_generics E for #name #ty_generics #where_clause { - fn rlp_header(&self) -> ethers_rlp::Header { - let mut rlp_head = ethers_rlp::Header { list: true, payload_length: 0 }; + fn rlp_header(&self) -> alloy_rlp::Header { + let mut rlp_head = alloy_rlp::Header { list: true, payload_length: 0 }; #(#length_stmts)* rlp_head } } - impl #impl_generics ethers_rlp::Encodable for #name #ty_generics #where_clause { + impl #impl_generics alloy_rlp::Encodable for #name #ty_generics #where_clause { fn length(&self) -> usize { let rlp_head = E::rlp_header(self); - return ethers_rlp::length_of_length(rlp_head.payload_length) + rlp_head.payload_length; + return alloy_rlp::length_of_length(rlp_head.payload_length) + rlp_head.payload_length; } - fn encode(&self, out: &mut dyn ethers_rlp::BufMut) { + fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { E::rlp_header(self).encode(out); #(#stmts)* } @@ -70,7 +70,7 @@ pub(crate) fn impl_encodable(ast: &syn::DeriveInput) -> Result { Ok(quote! { const _: () = { - extern crate ethers_rlp; + extern crate alloy_rlp; #impl_block }; }) @@ -93,11 +93,11 @@ pub(crate) fn impl_encodable_wrapper(ast: &syn::DeriveInput) -> Result usize { self.#ident.length() } - fn encode(&self, out: &mut dyn ethers_rlp::BufMut) { + fn encode(&self, out: &mut dyn alloy_rlp::BufMut) { self.#ident.encode(out) } } @@ -105,7 +105,7 @@ pub(crate) fn impl_encodable_wrapper(ast: &syn::DeriveInput) -> Result Result for #name {} - unsafe impl ethers_rlp::MaxEncodedLenAssoc for #name { - const LEN: usize = { ethers_rlp::const_add(ethers_rlp::length_of_length(#(#stmts)*), { #(#stmts)* }) }; + unsafe impl alloy_rlp::MaxEncodedLen<{ alloy_rlp::const_add(alloy_rlp::length_of_length(#(#stmts)*), #(#stmts)*) }> for #name {} + unsafe impl alloy_rlp::MaxEncodedLenAssoc for #name { + const LEN: usize = { alloy_rlp::const_add(alloy_rlp::length_of_length(#(#stmts)*), { #(#stmts)* }) }; } }; Ok(quote! { const _: () = { - extern crate ethers_rlp; + extern crate alloy_rlp; #impl_block }; }) @@ -154,9 +154,9 @@ fn encodable_length<'a>( quote! { 0 } }; - quote! { rlp_head.payload_length += &self.#ident.as_ref().map(|val| ethers_rlp::Encodable::length(val)).unwrap_or(#default); } + quote! { rlp_head.payload_length += &self.#ident.as_ref().map(|val| alloy_rlp::Encodable::length(val)).unwrap_or(#default); } } else { - quote! { rlp_head.payload_length += ethers_rlp::Encodable::length(&self.#ident); } + quote! { rlp_head.payload_length += alloy_rlp::Encodable::length(&self.#ident); } } } @@ -164,9 +164,9 @@ fn encodable_max_length(index: usize, field: &syn::Field) -> TokenStream { let fieldtype = &field.ty; if index == 0 { - quote! { <#fieldtype as ethers_rlp::MaxEncodedLenAssoc>::LEN } + quote! { <#fieldtype as alloy_rlp::MaxEncodedLenAssoc>::LEN } } else { - quote! { + <#fieldtype as ethers_rlp::MaxEncodedLenAssoc>::LEN } + quote! { + <#fieldtype as alloy_rlp::MaxEncodedLenAssoc>::LEN } } } @@ -181,7 +181,7 @@ fn encodable_field<'a>( if is_opt { let if_some_encode = quote! { if let Some(val) = self.#ident.as_ref() { - ethers_rlp::Encodable::encode(val, out) + alloy_rlp::Encodable::encode(val, out) } }; @@ -197,7 +197,7 @@ fn encodable_field<'a>( quote! { #if_some_encode } } } else { - quote! { ethers_rlp::Encodable::encode(&self.#ident, out); } + quote! { alloy_rlp::Encodable::encode(&self.#ident, out); } } } diff --git a/crates/rlp/Cargo.toml b/crates/rlp/Cargo.toml index 4811d4ad9..8f366037e 100644 --- a/crates/rlp/Cargo.toml +++ b/crates/rlp/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "ethers-rlp" -version = "0.1.0" -description = "A fast Rust implementation of the Ethereum RLP encoding" -readme = "README.md" +name = "alloy-rlp" +description = "Implementation of Ethereum RLP serialization" keywords = ["ethereum", "rlp", "serialization"] -categories = ["encoding", "cryptography::cryptocurrencies"] +categories = ["no-std", "encoding", "cryptography::cryptocurrencies"] +homepage = "https://github.com/alloy-rs/core/tree/main/crates/rlp" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true -homepage.workspace = true repository.workspace = true +exclude.workspace = true [package.metadata.docs.rs] all-features = true @@ -21,7 +21,7 @@ rustdoc-args = ["--cfg", "docsrs"] arrayvec.workspace = true bytes.workspace = true -ethers-rlp-derive = { workspace = true, optional = true } +alloy-rlp-derive = { workspace = true, optional = true } [dev-dependencies] hex-literal.workspace = true @@ -29,4 +29,4 @@ hex-literal.workspace = true [features] default = ["std", "derive"] std = ["arrayvec/std", "bytes/std"] -derive = ["dep:ethers-rlp-derive"] +derive = ["dep:alloy-rlp-derive"] diff --git a/crates/rlp/README.md b/crates/rlp/README.md index ad80ff939..206d852c5 100644 --- a/crates/rlp/README.md +++ b/crates/rlp/README.md @@ -1,4 +1,4 @@ -## ethers-rlp +# alloy-rlp This crate provides Ethereum RLP (de)serialization functionality. RLP is commonly used for Ethereum EL datastructures, and its documentation can be @@ -6,22 +6,22 @@ found [at ethereum.org][ref]. [ref]: https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/ -### Usage +## Usage We strongly recommend deriving RLP traits via the `RlpEncodable` and `RlpDecodable` derive macros. -Trait methods can then be accessed via the `Encodable` and `Decodable` -traits. +Trait methods can then be accessed via the `Encodable` and `Decodable` traits. -### Provenance note +## Provenance note -This crate was originally part of the -[reth](https://github.com/paradigmxyz/reth/) project. Maintenance has been -taken over by the ethers developers. +This crate was originally part of the [reth] project, as [`reth_rlp`]. -Forked from an earlier Apache licenced version of the `fastrlp` crate, before -it changed licence to GPL. NOTE: The Rust fastrlp implementation is itself a -port of the [Golang Apache licensed fastrlp][gofastrlp]. +This was forked from an earlier Apache-licensed version of the +[`fastrlp`] crate, before it changed licence to GPL. +The Rust `fastrlp` implementation is itself a port of the [Golang Apache-licensed fastrlp][gofastrlp]. +[reth]: https://github.com/paradigmxyz/reth +[`reth_rlp`]: https://github.com/paradigmxyz/reth/tree/main/crates/rlp +[`fastrlp`]: https://github.com/vorot93/fastrlp [gofastrlp]: https://github.com/umbracle/fastrlp diff --git a/crates/rlp/src/lib.rs b/crates/rlp/src/lib.rs index 47d89e197..ba0edc561 100644 --- a/crates/rlp/src/lib.rs +++ b/crates/rlp/src/lib.rs @@ -7,7 +7,7 @@ ## Usage Example ```rust -use ethers_rlp::{RlpEncodable, RlpDecodable, Decodable, Encodable}; +use alloy_rlp::{RlpEncodable, RlpDecodable, Decodable, Encodable}; #[derive(Debug, RlpEncodable, RlpDecodable, PartialEq)] pub struct MyStruct { @@ -62,6 +62,6 @@ pub use encode::{ pub use types::{Header, EMPTY_LIST_CODE, EMPTY_STRING_CODE}; #[cfg(feature = "derive")] -pub use ethers_rlp_derive::{ +pub use alloy_rlp_derive::{ RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWrapper, RlpMaxEncodedLen, }; diff --git a/crates/rlp/tests/derive.rs b/crates/rlp/tests/derive.rs index 490e2e558..8571e2a0e 100644 --- a/crates/rlp/tests/derive.rs +++ b/crates/rlp/tests/derive.rs @@ -1,6 +1,6 @@ #![cfg(feature = "derive")] -use ethers_rlp::*; +use alloy_rlp::*; #[derive(RlpEncodable, RlpDecodable, RlpMaxEncodedLen, PartialEq, Debug)] pub struct MyThing(#[rlp] [u8; 12]); diff --git a/crates/sol-macro/Cargo.toml b/crates/sol-macro/Cargo.toml index ec6c4bd3e..827a5d421 100644 --- a/crates/sol-macro/Cargo.toml +++ b/crates/sol-macro/Cargo.toml @@ -1,17 +1,17 @@ [package] -name = "ethers-sol-macro" -version = "0.1.0" -description = "Solidity to Rust proc-macro" -readme = "README.md" +name = "alloy-sol-macro" +description = "Solidity to Rust procedural macro" keywords = ["ethereum", "abi", "encoding", "evm", "solidity"] categories = ["encoding", "cryptography::cryptocurrencies"] +homepage = "https://github.com/alloy-rs/core/tree/main/crates/sol-macro" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true -homepage.workspace = true repository.workspace = true +exclude.workspace = true [lib] proc_macro = true diff --git a/crates/sol-macro/README.md b/crates/sol-macro/README.md index 3b2b0b5d1..3b952197b 100644 --- a/crates/sol-macro/README.md +++ b/crates/sol-macro/README.md @@ -1,8 +1,9 @@ -# ethers-sol-macro +# alloy-sol-macro -This crate provides the [`sol`][sol] proc macro, which parses Solidity syntax -to generate types that implement [`ethers-sol-types`] traits. +This crate provides the [`sol`][sol] procedural macro, which parses Solidity +syntax to generate types that implement [`alloy-sol-types`] traits. Refer to the [macro's documentation][sol] for more information. -[sol]: https://docs.rs/ethers-sol-macro/latest/ethers_sol_macro/macro.sol.html +[sol]: https://docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html +[`alloy-sol-types`]: ../sol-types diff --git a/crates/sol-macro/src/expand/mod.rs b/crates/sol-macro/src/expand/mod.rs index 96a1cb2ed..d8517eea4 100644 --- a/crates/sol-macro/src/expand/mod.rs +++ b/crates/sol-macro/src/expand/mod.rs @@ -28,13 +28,13 @@ pub fn expand_type(ty: &Type) -> TokenStream { fn rec_expand_type(ty: &Type, tokens: &mut TokenStream) { let tts = match *ty { Type::Address(span, _) => quote_spanned! {span=> - ::ethers_sol_types::sol_data::Address + ::alloy_sol_types::sol_data::Address }, - Type::Bool(span) => quote_spanned! {span=> ::ethers_sol_types::sol_data::Bool }, - Type::String(span) => quote_spanned! {span=> ::ethers_sol_types::sol_data::String }, + Type::Bool(span) => quote_spanned! {span=> ::alloy_sol_types::sol_data::Bool }, + Type::String(span) => quote_spanned! {span=> ::alloy_sol_types::sol_data::String }, Type::Bytes { span, size: None } => { - quote_spanned! {span=> ::ethers_sol_types::sol_data::Bytes } + quote_spanned! {span=> ::alloy_sol_types::sol_data::Bytes } } Type::Bytes { span, @@ -42,20 +42,20 @@ fn rec_expand_type(ty: &Type, tokens: &mut TokenStream) { } => { let size = Literal::u16_unsuffixed(size.get()); quote_spanned! {span=> - ::ethers_sol_types::sol_data::FixedBytes<#size> + ::alloy_sol_types::sol_data::FixedBytes<#size> } } Type::Int { span, size } => { let size = Literal::u16_unsuffixed(size.map(NonZeroU16::get).unwrap_or(256)); quote_spanned! {span=> - ::ethers_sol_types::sol_data::Int<#size> + ::alloy_sol_types::sol_data::Int<#size> } } Type::Uint { span, size } => { let size = Literal::u16_unsuffixed(size.map(NonZeroU16::get).unwrap_or(256)); quote_spanned! {span=> - ::ethers_sol_types::sol_data::Uint<#size> + ::alloy_sol_types::sol_data::Uint<#size> } } @@ -74,11 +74,11 @@ fn rec_expand_type(ty: &Type, tokens: &mut TokenStream) { let span = array.span(); if let Some(size) = &array.size { quote_spanned! {span=> - ::ethers_sol_types::sol_data::FixedArray<#ty, #size> + ::alloy_sol_types::sol_data::FixedArray<#ty, #size> } } else { quote_spanned! {span=> - ::ethers_sol_types::sol_data::Array<#ty> + ::alloy_sol_types::sol_data::Array<#ty> } } } @@ -91,7 +91,7 @@ fn expand_var(var: &VariableDeclaration) -> TokenStream { let VariableDeclaration { ty, name, .. } = var; let ty = expand_type(ty); quote! { - #name: <#ty as ::ethers_sol_types::SolType>::RustType + #name: <#ty as ::alloy_sol_types::SolType>::RustType } } @@ -169,18 +169,18 @@ impl Context { #converts #[automatically_derived] - impl ::ethers_sol_types::SolError for #name { + impl ::alloy_sol_types::SolError for #name { type Tuple = UnderlyingSolTuple; - type Token = ::TokenType; + type Token = ::TokenType; const SIGNATURE: &'static str = #signature; const SELECTOR: [u8; 4] = #selector; - fn to_rust(&self) -> ::RustType { + fn to_rust(&self) -> ::RustType { self.clone().into() } - fn from_rust(tuple: ::RustType) -> Self { + fn from_rust(tuple: ::RustType) -> Self { tuple.into() } @@ -239,18 +239,18 @@ impl Context { #converts #[automatically_derived] - impl ::ethers_sol_types::SolCall for #call_name { + impl ::alloy_sol_types::SolCall for #call_name { type Tuple = UnderlyingSolTuple; - type Token = ::TokenType; + type Token = ::TokenType; const SIGNATURE: &'static str = #signature; const SELECTOR: [u8; 4] = #selector; - fn to_rust(&self) -> ::RustType { + fn to_rust(&self) -> ::RustType { self.clone().into() } - fn from_rust(tuple: ::RustType) -> Self { + fn from_rust(tuple: ::RustType) -> Self { tuple.into() } @@ -294,7 +294,7 @@ impl Context { { let mut encoded = String::from(#encoded_type); #( - if let Some(s) = <#props_tys as ::ethers_sol_types::SolType>::eip712_encode_type() { + if let Some(s) = <#props_tys as ::alloy_sol_types::SolType>::eip712_encode_type() { encoded.push_str(&s); } )* @@ -310,11 +310,11 @@ impl Context { 1 => { let VariableDeclaration { ty, name, .. } = fields.first().unwrap(); let ty = expand_type(ty); - quote!(<#ty as ::ethers_sol_types::SolType>::eip712_data_word(&self.#name).0.to_vec()) + quote!(<#ty as ::alloy_sol_types::SolType>::eip712_data_word(&self.#name).0.to_vec()) } _ => quote! { [#( - <#props_tys as ::ethers_sol_types::SolType>::eip712_data_word(&self.#props).0, + <#props_tys as ::alloy_sol_types::SolType>::eip712_data_word(&self.#props).0, )*].concat() }, }; @@ -333,14 +333,14 @@ impl Context { #[allow(non_camel_case_types, non_snake_case, clippy::style)] const _: () = { - use ::ethers_sol_types::no_std_prelude::*; + use ::alloy_sol_types::no_std_prelude::*; #convert #[automatically_derived] - impl ::ethers_sol_types::SolStruct for #name { + impl ::alloy_sol_types::SolStruct for #name { type Tuple = UnderlyingSolTuple; - type Token = ::TokenType; + type Token = ::TokenType; const NAME: &'static str = #name_s; @@ -375,7 +375,7 @@ impl Context { } = udt; let ty = expand_type(ty); let tokens = quote! { - ::ethers_sol_types::define_udt! { + ::alloy_sol_types::define_udt! { #(#attrs)* #name, underlying: #ty, @@ -413,7 +413,7 @@ impl Context { "failed to resolve types after {RESOLVE_LIMIT} iterations.\n\ This is likely due to an infinitely recursive type definition.\n\ If you believe this is a bug, please file an issue at \ - https://github.com/ethers-rs/core/issues/new/choose" + https://github.com/alloy-rs/core/issues/new/choose" ); Err(syn::Error::new(proc_macro2::Span::call_site(), msg)) } @@ -557,7 +557,7 @@ fn from_into_tuples

(name: &Ident, fields: &Parameters

) -> TokenStream { quote! { type UnderlyingSolTuple = (#(#tys,)*); - type UnderlyingRustTuple = (#(<#tys2 as ::ethers_sol_types::SolType>::RustType,)*); + type UnderlyingRustTuple = (#(<#tys2 as ::alloy_sol_types::SolType>::RustType,)*); #[automatically_derived] impl ::core::convert::From<#name> for UnderlyingRustTuple { diff --git a/crates/sol-macro/src/lib.rs b/crates/sol-macro/src/lib.rs index 81e1b518f..da164ed68 100644 --- a/crates/sol-macro/src/lib.rs +++ b/crates/sol-macro/src/lib.rs @@ -1,7 +1,7 @@ -//! # ethers-sol-macro +//! # alloy-sol-macro //! //! This crate provides the [`sol`][sol!] procedural macro, which parses -//! Solidity syntax to generate types that implement [`ethers-sol-types`] +//! Solidity syntax to generate types that implement [`alloy-sol-types`] //! traits. //! //! Refer to the [macro's documentation][sol!] for more information. @@ -17,7 +17,7 @@ use proc_macro::TokenStream; mod expand; mod utils; -/// Parses Solidity syntax to generate types that implement [`ethers-sol-types`] +/// Parses Solidity syntax to generate types that implement [`alloy-sol-types`] /// traits. /// /// These types may then be used for safe [ABI] and [EIP-712] encoding and @@ -25,15 +25,15 @@ mod utils; /// /// [ABI]: https://docs.soliditylang.org/en/latest/abi-spec.html /// [EIP-712]: https://eips.ethereum.org/EIPS/eip-712 -/// [`ethers-sol-types`]: https://docs.rs/ethers-sol-types +/// [`alloy-sol-types`]: https://docs.rs/alloy-sol-types /// /// # Examples /// /// Note: the following examples cannot tested here because the generated code -/// references `ethers-sol-types`, so they are [tested in that crate][tests] and +/// references `alloy-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/sol-types/tests/ +/// [tests]: https://github.com/alloy-rs/core/tree/main/crates/sol-types/tests/ /// /// ## Structs and enums /// ```ignore diff --git a/crates/sol-types/Cargo.toml b/crates/sol-types/Cargo.toml index 18e0a3753..9f92524c2 100644 --- a/crates/sol-types/Cargo.toml +++ b/crates/sol-types/Cargo.toml @@ -1,25 +1,25 @@ [package] -name = "ethers-sol-types" -version = "0.1.0" -description = "Ethereum ABI encoding and decoding, with static typing" -readme = "README.md" +name = "alloy-sol-types" +description = "Compile-time ABI and EIP-712 implementations" keywords = ["ethereum", "abi", "encoding", "evm", "solidity"] -categories = ["encoding", "cryptography::cryptocurrencies"] +categories = ["no-std", "encoding", "cryptography::cryptocurrencies"] +homepage = "https://github.com/alloy-rs/core/tree/main/crates/sol-types" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true -homepage.workspace = true repository.workspace = true +exclude.workspace = true [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -ethers-primitives.workspace = true -ethers-sol-macro.workspace = true +alloy-primitives.workspace = true +alloy-sol-macro.workspace = true hex = { workspace = true, features = ["alloc"] } @@ -31,5 +31,5 @@ trybuild = "1.0" [features] default = ["std", "hex/alloc"] -std = ["ethers-primitives/std", "hex/std", "serde?/std"] -eip712-serde = ["dep:serde", "serde?/alloc", "ethers-primitives/serde"] +std = ["alloy-primitives/std", "hex/std", "serde?/std"] +eip712-serde = ["dep:serde", "serde?/alloc", "alloy-primitives/serde"] diff --git a/crates/sol-types/README.md b/crates/sol-types/README.md index 3251d8858..6328374ad 100644 --- a/crates/sol-types/README.md +++ b/crates/sol-types/README.md @@ -1,14 +1,13 @@ -# ethers-sol-types +# alloy-sol-types -Compile-time representation of Ethereum's type system with ABI coding and -EIP-712 support. +Compile-time representation of Ethereum's type system with ABI and EIP-712 +support. This crate provides a developer-friendly interface to Ethereum's type system, -by representing Solidity types. See [type_system.md] for a rundown, and the +by representing Solidity types. See [type_system.md](./type_system.md) for a rundown, and the [crate docs] for more information -[type_system.md]: https://github.com/ethers-rs/core/blob/main/crates/abi/type_system.md -[crate docs]: https://docs.rs/ethers-sol-types/latest/ethers_sol_types/ +[crate docs]: https://docs.rs/alloy-sol-types/latest/alloy_sol_types/ ### Features diff --git a/crates/sol-types/src/coder/decoder.rs b/crates/sol-types/src/coder/decoder.rs index d214a4c71..1e203be2d 100644 --- a/crates/sol-types/src/coder/decoder.rs +++ b/crates/sol-types/src/coder/decoder.rs @@ -1,5 +1,5 @@ // Copyright 2015-2020 Parity Technologies -// Copyright 2023-2023 Ethers-rs Team +// Copyright 2023-2023 Alloy Contributors // // Licensed under the Apache License, Version 2.0 or the MIT license @@ -243,7 +243,7 @@ pub fn decode_params(data: &[u8], validate: bool) -> Result { #[cfg(test)] mod tests { - use ethers_primitives::{Address, B256, U256}; + use alloy_primitives::{Address, B256, U256}; use hex_literal::hex; #[cfg(not(feature = "std"))] diff --git a/crates/sol-types/src/coder/encoder.rs b/crates/sol-types/src/coder/encoder.rs index c76d4a03c..bf397bb6f 100644 --- a/crates/sol-types/src/coder/encoder.rs +++ b/crates/sol-types/src/coder/encoder.rs @@ -1,5 +1,5 @@ // Copyright 2015-2020 Parity Technologies -// Copyright 2023-2023 Ethers-rs Team +// Copyright 2023-2023 Alloy Contributors // // Licensed under the Apache License, Version 2.0 or the MIT license @@ -166,7 +166,7 @@ pub fn encode_params(token: &T) -> Vec { #[cfg(test)] mod tests { - use ethers_primitives::{Address, U256}; + use alloy_primitives::{Address, U256}; use hex_literal::hex; #[cfg(not(feature = "std"))] diff --git a/crates/sol-types/src/coder/token.rs b/crates/sol-types/src/coder/token.rs index d28a69d8e..4591dcefe 100644 --- a/crates/sol-types/src/coder/token.rs +++ b/crates/sol-types/src/coder/token.rs @@ -1,5 +1,5 @@ // Copyright 2015-2020 Parity Technologies -// Copyright 2023-2023 Ethers-rs Team +// Copyright 2023-2023 Alloy Contributors // Licensed under the Apache License, Version 2.0 or the MIT license @@ -17,8 +17,8 @@ //! - Dynamic-length byte arrays `u8[]` use crate::{no_std_prelude::*, Decoder, Encoder, Result, Word}; +use alloy_primitives::{Address, U256}; use core::fmt; -use ethers_primitives::{Address, U256}; mod sealed { use super::*; @@ -642,7 +642,7 @@ impl TokenSeq for () { mod tests { use super::*; use crate::{sol_data, SolType}; - use ethers_primitives::B256; + use alloy_primitives::B256; macro_rules! assert_type_check { ($sol:ty, $token:expr $(,)?) => { diff --git a/crates/sol-types/src/eip712.rs b/crates/sol-types/src/eip712.rs index 4de5198de..438653edd 100644 --- a/crates/sol-types/src/eip712.rs +++ b/crates/sol-types/src/eip712.rs @@ -2,7 +2,7 @@ use crate::{ no_std_prelude::{Cow, String, Vec}, sol_data, SolType, }; -use ethers_primitives::{keccak256, Address, B256, U256}; +use alloy_primitives::{keccak256, Address, B256, U256}; /// Eip712 Domain attributes used in determining the domain separator; /// Unused fields are left out of the struct type. diff --git a/crates/sol-types/src/errors.rs b/crates/sol-types/src/errors.rs index a75a8e9ea..eed76580e 100644 --- a/crates/sol-types/src/errors.rs +++ b/crates/sol-types/src/errors.rs @@ -1,5 +1,5 @@ // Copyright 2015-2020 Parity Technologies -// Copyright 2023-2023 Ethers-rs Team +// Copyright 2023-2023 Alloy Contributors // Licensed under the Apache License, Version 2.0 or the MIT license diff --git a/crates/sol-types/src/lib.rs b/crates/sol-types/src/lib.rs index 6baf5f1e8..300557542 100644 --- a/crates/sol-types/src/lib.rs +++ b/crates/sol-types/src/lib.rs @@ -1,5 +1,5 @@ // Copyright 2015-2020 Parity Technologies -// Copyright 2023-2023 Ethers-rs Team +// Copyright 2023-2023 Alloy Contributors // Licensed under the Apache License, Version 2.0 or the MIT license @@ -24,8 +24,8 @@ //! `encode` and `decode` methods operate on objects implementing [`TokenType`]. //! //! ``` -//! use ethers_sol_types::{SolType, sol_data::*}; -//! # pub fn main() -> ethers_sol_types::Result<()> { +//! use alloy_sol_types::{SolType, sol_data::*}; +//! # pub fn main() -> alloy_sol_types::Result<()> { //! // Represent a Solidity type in rust //! type MySolType = FixedArray; //! @@ -54,8 +54,8 @@ //! The [`SolStruct`] trait primarily provides EIP-712 signing support. //! //! ``` -//! # use ethers_sol_types::{sol, SolStruct}; -//! # use ethers_primitives::U256; +//! # use alloy_sol_types::{sol, SolStruct}; +//! # use alloy_primitives::U256; //! // `sol!` allows you to define struct types! //! // You can just paste Solidity into the macro and it should work :) //! sol! { @@ -84,7 +84,7 @@ //! }; //! //! // The domain macro lets you easily define an EIP-712 domain object :) -//! let my_domain = ethers_sol_types::domain!( +//! let my_domain = alloy_sol_types::domain!( //! name: "MyDomain", //! version: "1", //! ); @@ -102,8 +102,8 @@ //! features! //! //! ``` -//! # use ethers_sol_types::{sol, sol_data, SolType}; -//! # use ethers_primitives::U256; +//! # use alloy_sol_types::{sol, sol_data, SolType}; +//! # use alloy_primitives::U256; //! // We also also support Solidity value types //! sol! { //! type MyValueType is uint256; @@ -169,10 +169,10 @@ pub mod no_std_prelude { } #[doc(inline)] -pub use ethers_sol_macro::sol; +pub use alloy_sol_macro::sol; /// The ABI word type. -pub type Word = ethers_primitives::B256; +pub type Word = alloy_primitives::B256; mod coder; pub use coder::{ @@ -193,7 +193,7 @@ pub use types::{ mod util; #[doc(hidden)] -pub use ethers_primitives::keccak256; +pub use alloy_primitives::keccak256; #[doc(hidden)] pub use util::just_ok; diff --git a/crates/sol-types/src/types/data_type.rs b/crates/sol-types/src/types/data_type.rs index 136d4b713..1af0985df 100644 --- a/crates/sol-types/src/types/data_type.rs +++ b/crates/sol-types/src/types/data_type.rs @@ -6,8 +6,8 @@ use crate::{ util, Result, SolType, Word, }; use alloc::borrow::Cow; +use alloy_primitives::{keccak256, Address as RustAddress, I256, U256}; use core::marker::PhantomData; -use ethers_primitives::{keccak256, Address as RustAddress, I256, U256}; /// Address - `address` #[derive(Copy, Clone, Debug)] diff --git a/crates/sol-types/src/types/error.rs b/crates/sol-types/src/types/error.rs index 348b65a69..89fa63734 100644 --- a/crates/sol-types/src/types/error.rs +++ b/crates/sol-types/src/types/error.rs @@ -3,8 +3,8 @@ use crate::{ token::{PackedSeqToken, TokenSeq, WordToken}, Result, SolType, }; +use alloy_primitives::U256; use core::fmt; -use ethers_primitives::U256; /// Solidity Error (a tuple with a selector) /// @@ -379,7 +379,7 @@ impl PanicKind { #[cfg(test)] mod test { use super::*; - use ethers_primitives::keccak256; + use alloy_primitives::keccak256; #[test] fn test_revert_encoding() { diff --git a/crates/sol-types/src/types/struct.rs b/crates/sol-types/src/types/struct.rs index 71d5f57c4..f08ca2090 100644 --- a/crates/sol-types/src/types/struct.rs +++ b/crates/sol-types/src/types/struct.rs @@ -3,7 +3,7 @@ use super::SolType; use crate::{no_std_prelude::*, token::TokenSeq, Eip712Domain, Result, Word}; -use ethers_primitives::{keccak256, B256}; +use alloy_primitives::{keccak256, B256}; type TupleFor = ::Tuple; type TupleTokenTypeFor = as SolType>::TokenType; diff --git a/crates/sol-types/src/types/type.rs b/crates/sol-types/src/types/type.rs index 35245243c..037e466c7 100644 --- a/crates/sol-types/src/types/type.rs +++ b/crates/sol-types/src/types/type.rs @@ -7,7 +7,7 @@ use crate::{no_std_prelude::*, token::TokenSeq, Result, TokenType, Word}; /// complex Solidity types. /// /// ``` -/// use ethers_sol_types::{SolType, sol_data::*}; +/// use alloy_sol_types::{SolType, sol_data::*}; /// /// type DynUint256Array = Array>; /// assert_eq!(&DynUint256Array::sol_type_name(), "uint256[]"); @@ -30,7 +30,7 @@ use crate::{no_std_prelude::*, token::TokenSeq, Result, TokenType, Word}; /// native Rust struct. /// /// ``` -/// ethers_sol_types::sol! { +/// alloy_sol_types::sol! { /// struct MyStruct { /// bool a; /// bytes2 b; diff --git a/crates/sol-types/src/util.rs b/crates/sol-types/src/util.rs index 0b8b0a278..722de4310 100644 --- a/crates/sol-types/src/util.rs +++ b/crates/sol-types/src/util.rs @@ -1,5 +1,5 @@ // Copyright 2015-2020 Parity Technologies -// Copyright 2023-2023 Ethers-rs Team +// Copyright 2023-2023 Alloy Contributors // // Licensed under the Apache License, Version 2.0 or the MIT license diff --git a/crates/sol-types/tests/doc_function_like.rs b/crates/sol-types/tests/doc_function_like.rs index 4ecf070f4..c7b1cb355 100644 --- a/crates/sol-types/tests/doc_function_like.rs +++ b/crates/sol-types/tests/doc_function_like.rs @@ -1,5 +1,5 @@ -use ethers_primitives::{keccak256, U256}; -use ethers_sol_types::{sol, SolCall, SolError}; +use alloy_primitives::{keccak256, U256}; +use alloy_sol_types::{sol, SolCall, SolError}; // Unnamed arguments will be given a name based on their position, // e.g. `_0`, `_1`... diff --git a/crates/sol-types/tests/doc_structs.rs b/crates/sol-types/tests/doc_structs.rs index 5b836b50f..213783801 100644 --- a/crates/sol-types/tests/doc_structs.rs +++ b/crates/sol-types/tests/doc_structs.rs @@ -1,5 +1,5 @@ -use ethers_primitives::{Address, U256}; -use ethers_sol_types::{sol, SolType}; +use alloy_primitives::{Address, U256}; +use alloy_sol_types::{sol, SolType}; use hex_literal::hex; // Struct definitions will generate a struct with the same name and fields. diff --git a/crates/sol-types/tests/doc_types.rs b/crates/sol-types/tests/doc_types.rs index f410ac220..f6a6b0ce8 100644 --- a/crates/sol-types/tests/doc_types.rs +++ b/crates/sol-types/tests/doc_types.rs @@ -1,5 +1,5 @@ -use ethers_primitives::Address; -use ethers_sol_types::{sol, SolType}; +use alloy_primitives::Address; +use alloy_sol_types::{sol, SolType}; // Type definition: generates a new struct that implements `SolType` sol! { @@ -9,7 +9,7 @@ sol! { // Type aliases type B32 = sol! { bytes32 }; // This is equivalent to the following: -// type B32 = ethers_sol_types::sol_data::Bytes<32>; +// type B32 = alloy_sol_types::sol_data::Bytes<32>; type SolArrayOf = sol! { T[] }; type SolTuple = sol! { tuple(address, bytes, string) }; diff --git a/crates/sol-types/tests/macros.rs b/crates/sol-types/tests/macros.rs index d3d6df465..d610f4e11 100644 --- a/crates/sol-types/tests/macros.rs +++ b/crates/sol-types/tests/macros.rs @@ -1,14 +1,14 @@ -use ethers_sol_types::{define_udt, domain}; +use alloy_sol_types::{define_udt, domain}; #[allow(clippy::missing_const_for_fn)] -fn ret_ok(_: T) -> ethers_sol_types::Result<()> { +fn ret_ok(_: T) -> alloy_sol_types::Result<()> { Ok(()) } define_udt!( /// My Sol UDT. MyUdt, - underlying: ethers_sol_types::sol_data::Bool, + underlying: alloy_sol_types::sol_data::Bool, type_check: ret_ok, ); diff --git a/crates/sol-types/tests/sol.rs b/crates/sol-types/tests/sol.rs index 24d485671..a3b06cbe9 100644 --- a/crates/sol-types/tests/sol.rs +++ b/crates/sol-types/tests/sol.rs @@ -1,5 +1,5 @@ -use ethers_primitives::{keccak256, Address, U256}; -use ethers_sol_types::{no_std_prelude::*, sol, SolCall, SolError, SolType}; +use alloy_primitives::{keccak256, Address, U256}; +use alloy_sol_types::{no_std_prelude::*, sol, SolCall, SolError, SolType}; sol! { struct MyStruct { @@ -65,7 +65,7 @@ fn no_std_proc_macro() { let mvt = MyValueType::from(U256::from(1)); assert_eq!( mvt.encode_single(), - ethers_sol_types::sol_data::Uint::<256>::encode_single(U256::from(1)) + alloy_sol_types::sol_data::Uint::<256>::encode_single(U256::from(1)) ); } diff --git a/crates/sol-types/tests/ui/empty.rs b/crates/sol-types/tests/ui/empty.rs index da68cf716..abb1833e1 100644 --- a/crates/sol-types/tests/ui/empty.rs +++ b/crates/sol-types/tests/ui/empty.rs @@ -1,4 +1,4 @@ -use ethers_sol_types::sol; +use alloy_sol_types::sol; sol! {} diff --git a/crates/sol-types/tests/ui/error.rs b/crates/sol-types/tests/ui/error.rs index 017cd8f87..3cea5d73b 100644 --- a/crates/sol-types/tests/ui/error.rs +++ b/crates/sol-types/tests/ui/error.rs @@ -1,4 +1,4 @@ -use ethers_sol_types::sol; +use alloy_sol_types::sol; sol! { error MissingParens1 diff --git a/crates/sol-types/tests/ui/function.rs b/crates/sol-types/tests/ui/function.rs index 5180f002a..e7dd69da3 100644 --- a/crates/sol-types/tests/ui/function.rs +++ b/crates/sol-types/tests/ui/function.rs @@ -1,4 +1,4 @@ -use ethers_sol_types::sol; +use alloy_sol_types::sol; sol! { function missingParens; diff --git a/crates/sol-types/tests/ui/ident.rs b/crates/sol-types/tests/ui/ident.rs index 367944865..ffc79a344 100644 --- a/crates/sol-types/tests/ui/ident.rs +++ b/crates/sol-types/tests/ui/ident.rs @@ -1,4 +1,4 @@ -use ethers_sol_types::sol; +use alloy_sol_types::sol; sol! { struct Reserved { diff --git a/crates/sol-types/tests/ui/storage.rs b/crates/sol-types/tests/ui/storage.rs index e5fff5b80..18e747aa7 100644 --- a/crates/sol-types/tests/ui/storage.rs +++ b/crates/sol-types/tests/ui/storage.rs @@ -1,4 +1,4 @@ -use ethers_sol_types::sol; +use alloy_sol_types::sol; sol! { struct BadMemoryStruct { diff --git a/crates/sol-types/tests/ui/type.rs b/crates/sol-types/tests/ui/type.rs index 087230ed0..c8e614f7f 100644 --- a/crates/sol-types/tests/ui/type.rs +++ b/crates/sol-types/tests/ui/type.rs @@ -1,4 +1,4 @@ -use ethers_sol_types::sol; +use alloy_sol_types::sol; sol! { struct BuiltinTypes { diff --git a/crates/sol-types/tests/ui/type.stderr b/crates/sol-types/tests/ui/type.stderr index 168dfe432..e7e8dc8f8 100644 --- a/crates/sol-types/tests/ui/type.stderr +++ b/crates/sol-types/tests/ui/type.stderr @@ -60,7 +60,7 @@ error: intX must be a multiple of 8 up to 256 error: failed to resolve types after 16 iterations. This is likely due to an infinitely recursive type definition. - If you believe this is a bug, please file an issue at https://github.com/ethers-rs/core/issues/new/choose + If you believe this is a bug, please file an issue at https://github.com/alloy-rs/core/issues/new/choose --> tests/ui/type.rs:214:1 | 214 | / sol! { @@ -110,7 +110,7 @@ error[E0412]: cannot find type `int_256` in this scope 210 | int_256 f; | ^^^^^^^ not found in this scope -error[E0277]: the trait bound `(Address, Address, ethers_sol_types::sol_data::String, Bool, ethers_sol_types::sol_data::Bytes, FixedBytes<1>, FixedBytes<2>, FixedBytes<3>, FixedBytes<4>, FixedBytes<5>, FixedBytes<6>, FixedBytes<7>, FixedBytes<8>, FixedBytes<9>, FixedBytes<10>, FixedBytes<11>, FixedBytes<12>, FixedBytes<13>, FixedBytes<14>, FixedBytes<15>, FixedBytes<16>, FixedBytes<17>, FixedBytes<18>, FixedBytes<19>, FixedBytes<20>, FixedBytes<21>, FixedBytes<22>, FixedBytes<23>, FixedBytes<24>, FixedBytes<25>, FixedBytes<26>, FixedBytes<27>, FixedBytes<28>, FixedBytes<29>, FixedBytes<30>, FixedBytes<31>, FixedBytes<32>, Int<256>, Int<8>, Int<16>, Int<24>, Int<32>, Int<40>, Int<48>, Int<56>, Int<64>, Int<72>, Int<80>, Int<88>, Int<96>, Int<104>, Int<112>, Int<120>, Int<128>, Int<136>, Int<144>, Int<152>, Int<160>, Int<168>, Int<176>, Int<184>, Int<192>, Int<200>, Int<208>, Int<216>, Int<224>, Int<232>, Int<240>, Int<248>, Int<256>, Uint<256>, Uint<8>, Uint<16>, Uint<24>, Uint<32>, Uint<40>, Uint<48>, Uint<56>, Uint<64>, Uint<72>, Uint<80>, Uint<88>, Uint<96>, Uint<104>, Uint<112>, Uint<120>, Uint<128>, Uint<136>, Uint<144>, Uint<152>, Uint<160>, Uint<168>, Uint<176>, Uint<184>, Uint<192>, Uint<200>, Uint<208>, Uint<216>, Uint<224>, Uint<232>, Uint<240>, Uint<248>, Uint<256>): SolStruct` is not satisfied +error[E0277]: the trait bound `(Address, Address, alloy_sol_types::sol_data::String, Bool, alloy_sol_types::sol_data::Bytes, FixedBytes<1>, FixedBytes<2>, FixedBytes<3>, FixedBytes<4>, FixedBytes<5>, FixedBytes<6>, FixedBytes<7>, FixedBytes<8>, FixedBytes<9>, FixedBytes<10>, FixedBytes<11>, FixedBytes<12>, FixedBytes<13>, FixedBytes<14>, FixedBytes<15>, FixedBytes<16>, FixedBytes<17>, FixedBytes<18>, FixedBytes<19>, FixedBytes<20>, FixedBytes<21>, FixedBytes<22>, FixedBytes<23>, FixedBytes<24>, FixedBytes<25>, FixedBytes<26>, FixedBytes<27>, FixedBytes<28>, FixedBytes<29>, FixedBytes<30>, FixedBytes<31>, FixedBytes<32>, Int<256>, Int<8>, Int<16>, Int<24>, Int<32>, Int<40>, Int<48>, Int<56>, Int<64>, Int<72>, Int<80>, Int<88>, Int<96>, Int<104>, Int<112>, Int<120>, Int<128>, Int<136>, Int<144>, Int<152>, Int<160>, Int<168>, Int<176>, Int<184>, Int<192>, Int<200>, Int<208>, Int<216>, Int<224>, Int<232>, Int<240>, Int<248>, Int<256>, Uint<256>, Uint<8>, Uint<16>, Uint<24>, Uint<32>, Uint<40>, Uint<48>, Uint<56>, Uint<64>, Uint<72>, Uint<80>, Uint<88>, Uint<96>, Uint<104>, Uint<112>, Uint<120>, Uint<128>, Uint<136>, Uint<144>, Uint<152>, Uint<160>, Uint<168>, Uint<176>, Uint<184>, Uint<192>, Uint<200>, Uint<208>, Uint<216>, Uint<224>, Uint<232>, Uint<240>, Uint<248>, Uint<256>): SolStruct` is not satisfied --> tests/ui/type.rs:3:1 | 3 | / sol! { @@ -120,7 +120,7 @@ error[E0277]: the trait bound `(Address, Address, ethers_sol_types::sol_data::St ... | 111 | | } 112 | | } - | |_^ the trait `SolStruct` is not implemented for `(Address, Address, ethers_sol_types::sol_data::String, Bool, ethers_sol_types::sol_data::Bytes, FixedBytes<1>, FixedBytes<2>, FixedBytes<3>, FixedBytes<4>, FixedBytes<5>, FixedBytes<6>, FixedBytes<7>, FixedBytes<8>, FixedBytes<9>, FixedBytes<10>, FixedBytes<11>, FixedBytes<12>, FixedBytes<13>, FixedBytes<14>, FixedBytes<15>, FixedBytes<16>, FixedBytes<17>, FixedBytes<18>, FixedBytes<19>, FixedBytes<20>, FixedBytes<21>, FixedBytes<22>, FixedBytes<23>, FixedBytes<24>, FixedBytes<25>, FixedBytes<26>, FixedBytes<27>, FixedBytes<28>, FixedBytes<29>, FixedBytes<30>, FixedBytes<31>, FixedBytes<32>, Int<256>, Int<8>, Int<16>, Int<24>, Int<32>, Int<40>, Int<48>, Int<56>, Int<64>, Int<72>, Int<80>, Int<88>, Int<96>, Int<104>, Int<112>, Int<120>, Int<128>, Int<136>, Int<144>, Int<152>, Int<160>, Int<168>, Int<176>, Int<184>, Int<192>, Int<200>, Int<208>, Int<216>, Int<224>, Int<232>, Int<240>, Int<248>, Int<256>, Uint<256>, Uint<8>, Uint<16>, Uint<24>, Uint<32>, Uint<40>, Uint<48>, Uint<56>, Uint<64>, Uint<72>, Uint<80>, Uint<88>, Uint<96>, Uint<104>, Uint<112>, Uint<120>, Uint<128>, Uint<136>, Uint<144>, Uint<152>, Uint<160>, Uint<168>, Uint<176>, Uint<184>, Uint<192>, Uint<200>, Uint<208>, Uint<216>, Uint<224>, Uint<232>, Uint<240>, Uint<248>, Uint<256>)` + | |_^ the trait `SolStruct` is not implemented for `(Address, Address, alloy_sol_types::sol_data::String, Bool, alloy_sol_types::sol_data::Bytes, FixedBytes<1>, FixedBytes<2>, FixedBytes<3>, FixedBytes<4>, FixedBytes<5>, FixedBytes<6>, FixedBytes<7>, FixedBytes<8>, FixedBytes<9>, FixedBytes<10>, FixedBytes<11>, FixedBytes<12>, FixedBytes<13>, FixedBytes<14>, FixedBytes<15>, FixedBytes<16>, FixedBytes<17>, FixedBytes<18>, FixedBytes<19>, FixedBytes<20>, FixedBytes<21>, FixedBytes<22>, FixedBytes<23>, FixedBytes<24>, FixedBytes<25>, FixedBytes<26>, FixedBytes<27>, FixedBytes<28>, FixedBytes<29>, FixedBytes<30>, FixedBytes<31>, FixedBytes<32>, Int<256>, Int<8>, Int<16>, Int<24>, Int<32>, Int<40>, Int<48>, Int<56>, Int<64>, Int<72>, Int<80>, Int<88>, Int<96>, Int<104>, Int<112>, Int<120>, Int<128>, Int<136>, Int<144>, Int<152>, Int<160>, Int<168>, Int<176>, Int<184>, Int<192>, Int<200>, Int<208>, Int<216>, Int<224>, Int<232>, Int<240>, Int<248>, Int<256>, Uint<256>, Uint<8>, Uint<16>, Uint<24>, Uint<32>, Uint<40>, Uint<48>, Uint<56>, Uint<64>, Uint<72>, Uint<80>, Uint<88>, Uint<96>, Uint<104>, Uint<112>, Uint<120>, Uint<128>, Uint<136>, Uint<144>, Uint<152>, Uint<160>, Uint<168>, Uint<176>, Uint<184>, Uint<192>, Uint<200>, Uint<208>, Uint<216>, Uint<224>, Uint<232>, Uint<240>, Uint<248>, Uint<256>)` | = help: the following other types implement trait `SolStruct`: ArrayTypes diff --git a/crates/sol-types/type_system.md b/crates/sol-types/type_system.md index 7b5ab0bb0..e13f740d8 100644 --- a/crates/sol-types/type_system.md +++ b/crates/sol-types/type_system.md @@ -23,7 +23,7 @@ this to be one of the fastest implementations for regular encoding/decoding. :) This crate works only with types known at compile-time. For types known only at runtime (including the eip712 `eth_signTypedData` json-rpc request), see the -`ethers-dyn-abi` crate. +`alloy-dyn-abi` crate. ### To what extent? @@ -44,8 +44,8 @@ defs into `SolCall` types, but may in the future. - All elementary, fixed-size, and non-fixed size [ABI types](https://docs.soliditylang.org/en/latest/abi-spec.html#types). - EXCEPT - - [`function` types](https://docs.soliditylang.org/en/v0.8.17/types.html#function-types). - - [`fixed`](https://docs.soliditylang.org/en/v0.8.17/types.html#fixed-point-numbers). + - [`function` types](https://docs.soliditylang.org/en/latest/types.html#function-types). + - [`fixed`](https://docs.soliditylang.org/en/latest/types.html#fixed-point-numbers). - Compound Solidity types @@ -55,17 +55,17 @@ defs into `SolCall` types, but may in the future. - User-defined Types - - [Structs](https://solidity-by-example.org/structs/) represented as a tuple - of the field types. - - [User-defined Value Types](https://blog.soliditylang.org/2021/09/27/user-defined-value-types/), encoded transparently. - - [Enums](https://docs.soliditylang.org/en/v0.8.17/types.html#enums) (TODO) - represented as `u8`. + - [Structs](https://solidity-by-example.org/structs/) represented as a tuple + of the field types. + - [User-defined Value Types](https://blog.soliditylang.org/2021/09/27/user-defined-value-types/), encoded transparently. + - [Enums](https://docs.soliditylang.org/en/latest/types.html#enums) (TODO) + represented as `u8`. - Externalized Types - - Function arguments and returns, represented as selector-prefixed tuples. - - [Errors](https://blog.soliditylang.org/2021/04/21/custom-errors/), - represented as selector-prefixed tuples - - Events (TODO) + - Function arguments and returns, represented as selector-prefixed tuples. + - [Errors](https://blog.soliditylang.org/2021/04/21/custom-errors/), + represented as selector-prefixed tuples + - Events (TODO) ## How? diff --git a/crates/syn-solidity/Cargo.toml b/crates/syn-solidity/Cargo.toml index 059a5d1be..933f77d56 100644 --- a/crates/syn-solidity/Cargo.toml +++ b/crates/syn-solidity/Cargo.toml @@ -1,17 +1,17 @@ [package] name = "syn-solidity" -version = "0.1.0" description = "syn-powered Solidity parser" -readme = "README.md" keywords = ["ethereum", "evm", "syn", "solidity", "ast"] categories = ["data-structures", "cryptography::cryptocurrencies"] homepage = "https://github.com/alloy-rs/core/tree/main/crates/syn-solidity" +version.workspace = true edition.workspace = true rust-version.workspace = true authors.workspace = true license.workspace = true repository.workspace = true +exclude.workspace = true [package.metadata.docs.rs] all-features = true diff --git a/crates/syn-solidity/src/type.rs b/crates/syn-solidity/src/type.rs index 6c83e257f..4d4c01134 100644 --- a/crates/syn-solidity/src/type.rs +++ b/crates/syn-solidity/src/type.rs @@ -196,7 +196,7 @@ impl SolTuple { } } -/// A custom type that implements `ethers_sol_types::SolidityType`. +/// A custom type that implements `alloy_sol_types::SolidityType`. #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub enum CustomType { /// A type that has not yet been resolved.