Skip to content

Commit

Permalink
docs: unhide and mention sol! wrappers (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored May 1, 2024
1 parent a697c4a commit a420416
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,8 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@v2
with:
Expand Down
3 changes: 1 addition & 2 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ pub use sol_types::sol;
#[doc(inline)]
pub use alloy_rlp as rlp;

/// [`sol!`](sol_types::sol!) macro wrapper to route imports to the correct crate.
/// [`sol!`](sol_types::sol!) `macro_rules!` wrapper to set import attributes.
///
/// See [`sol!`](sol_types::sol!) for the actual macro documentation.
#[cfg(all(not(doc), feature = "sol-types"))] // Show the actual macro in docs.
#[doc(hidden)]
#[macro_export]
macro_rules! sol {
($($t:tt)*) => {
Expand Down
6 changes: 3 additions & 3 deletions crates/dyn-abi/src/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use proptest::{
};

const DEPTH: u32 = 16;
const DESIZED_SIZE: u32 = 64;
const DESIRED_SIZE: u32 = 64;
const EXPECTED_BRANCH_SIZE: u32 = 32;

macro_rules! prop_oneof_cfg {
Expand Down Expand Up @@ -286,7 +286,7 @@ impl proptest::arbitrary::Arbitrary for DynSolType {

#[inline]
fn arbitrary() -> Self::Strategy {
Self::arbitrary_with((DEPTH, DESIZED_SIZE, EXPECTED_BRANCH_SIZE))
Self::arbitrary_with((DEPTH, DESIRED_SIZE, EXPECTED_BRANCH_SIZE))
}

fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
Expand Down Expand Up @@ -341,7 +341,7 @@ impl proptest::arbitrary::Arbitrary for DynSolValue {

#[inline]
fn arbitrary() -> Self::Strategy {
Self::arbitrary_with((DEPTH, DESIZED_SIZE, EXPECTED_BRANCH_SIZE))
Self::arbitrary_with((DEPTH, DESIRED_SIZE, EXPECTED_BRANCH_SIZE))
}

fn arbitrary_with(args: Self::Parameters) -> Self::Strategy {
Expand Down
8 changes: 4 additions & 4 deletions crates/dyn-abi/src/specifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use parser::{ParameterSpecifier, Parameters, RootType, TupleSpecifier, TypeSpeci
#[cfg(feature = "eip712")]
use alloy_json_abi::InternalType;

/// Trait for items that can be resolved to `DynSol_____`, i.e. they speicify
/// some Solidity interface item.
/// Trait for items that can be resolved to `DynSol_____`, i.e. they specify some Solidity interface
/// item.
///
/// The `Specifier` trait is implemented by types that can be resolved into
/// Solidity interace items, e.g. [`DynSolType`] or [`DynSolEvent`](crate::DynSolEvent).
/// The `Specifier` trait is implemented by types that can be resolved into Solidity interface
/// items, e.g. [`DynSolType`] or [`DynSolEvent`](crate::DynSolEvent).
///
/// ABI and related systems have many different ways of specifying Solidity interfaces.
/// This trait provides a single pattern for resolving those encodings into
Expand Down
2 changes: 1 addition & 1 deletion crates/json-abi/src/state_mutability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub mod serde_state_mutability_compat {
use super::*;
use serde::ser::SerializeStruct;

/// Deserializes a [`StateMutability`], compatibile with older JSON ABI versions.
/// Deserializes a [`StateMutability`], compatible with older JSON ABI versions.
///
/// See [the module-level documentation](self) for more information.
pub fn deserialize<'de, D: serde::Deserializer<'de>>(
Expand Down
2 changes: 1 addition & 1 deletion crates/sol-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository.workspace = true
exclude.workspace = true

[lib]
proc_macro = true
proc-macro = true

[package.metadata.docs.rs]
all-features = true
Expand Down
13 changes: 8 additions & 5 deletions crates/sol-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ mod verbatim;
/// for type-safe [ABI] and [EIP-712] serialization to interface with Ethereum
/// smart contracts.
///
/// Note that you will likely want to use this macro through a re-export in another crate,
/// as it will also set the correct paths for the required dependencies by using a `macro_rules!`
/// wrapper.
///
/// [ABI]: https://docs.soliditylang.org/en/latest/abi-spec.html
/// [EIP-712]: https://eips.ethereum.org/EIPS/eip-712
///
Expand Down Expand Up @@ -108,9 +112,9 @@ mod verbatim;
/// and its API is completely unstable and subject to change, so this feature is not yet
/// recommended for use.
///
/// Generates the following items inside of the `{name}` module:
/// - `struct {name}Instance<P: Provider> { ... }`
/// - `pub fn new(...) -> {name}Instance<P>` + getters and setters
/// Generates the following items inside of the `{contract_name}` module:
/// - `struct {contract_name}Instance<P: Provider> { ... }`
/// - `pub fn new(...) -> {contract_name}Instance<P>` + getters and setters
/// - `pub fn call_builder<C: SolCall>(&self, call: &C) -> SolCallBuilder<P, C>`, as a generic
/// way to call any function of the contract, even if not generated by the macro; prefer the
/// other methods when possible
Expand All @@ -134,8 +138,7 @@ mod verbatim;
/// - `alloy_sol_types = <path = ::alloy_sol_types>` (inner attribute only): specifies the path to
/// the required dependency [`alloy-sol-types`].
/// - `alloy_contract = <path = ::alloy_contract>` (inner attribute only): specifies the path to the
/// optional dependency [`alloy-contract`]. This is only used in combination with the `rpc`
/// attribute.
/// optional dependency [`alloy-contract`]. This is only used by the `rpc` attribute.
/// - `all_derives [ = <bool = false>]`: adds all possible `#[derive(...)]` attributes to all
/// generated types. May significantly increase compile times due to all the extra generated code.
/// This is the default behavior of [`abigen`]
Expand Down
2 changes: 1 addition & 1 deletion crates/sol-types/tests/macros/sol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ fn duplicate_attributes() {
address feeWallet
) public checkIsFeesValid(fees) checkIsFeesValid(fees2) checkIsAddressValid(owner) checkIsAddressValid(feeWallet) {
require(decimals >=8 && decimals <= 18, "[Validation] Not valid decimals");
require(supply > 0, "[Validation] inital supply should be greater than 0");
require(supply > 0, "[Validation] initial supply should be greater than 0");
require(owner != feeWallet, "[Validation] fee wallet and owner wallet cannot be same.");

_name = name;
Expand Down

0 comments on commit a420416

Please sign in to comment.