alloy-rs / core

High-performance, well-tested & documented core libraries for Ethereum, in Rust

Home Page:https://alloy.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] sol! macro errors when using #[sol(rpc)] with an ABI

erikreppel opened this issue · comments

Component

sol! macro

What version of Alloy are you on?

alloy v0.1.0 (https://github.com/alloy-rs/alloy?rev=17633df#17633df0)

Operating System

macOS (Apple Silicon)

Describe the bug

When trying to use sol rpc with an abi

use alloy_sol_macro::sol;
use alloy_sol_types::{Eip712Domain, SolCall, SolEvent};

sol! {
    #[sol(rpc)]
    #[derive(Debug, Serialize, Deserialize, PartialEq)]
    IZoraPremintV2,
    "src/premints/zora_premint_v2/zora1155PremintExecutor.json"
}

Compile fails with the following error:

the trait bound `C: alloy::alloy_sol_types::SolCall` is not satisfied [E0277] Note: required by a bound in `alloy_contract::CallBuilder::<T, &'a P, std::marker::PhantomData<C>, N>::new_sol` Help: consider restricting type parameter `C`
the trait bound `E: alloy::alloy_sol_types::SolEvent` is not satisfied [E0277] Note: required by a bound in `alloy_contract::Event::<T, &'a P, E, N>::new_sol` Help: consider restricting type parameter `E`

ABI can be found here: https://gist.github.com/erikreppel/c717512e1ac866b57a422e72f3d165c6

Alloy version from Cargo.toml:

alloy = { git = "https://github.com/alloy-rs/alloy", rev = "17633df", features = [
    "sol-types",
    "network",
    "rpc-types-eth",
    "pubsub",
] }

alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "17633df", features = [
    "pubsub",
    "ws",
] }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "17633df", features = [
    "pubsub",
] }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "17633df", features = [
    "eip712",
] }
alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "17633df" }
alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "17633df" }
alloy-core = { git = "https://github.com/alloy-rs/core", rev = "7574bfc" }
alloy-sol-types = { git = "https://github.com/alloy-rs/core", rev = "7574bfc", features = ["eip712-serde"] }
alloy-primitives = { git = "https://github.com/alloy-rs/core", rev = "7574bfc", features = ["serde"] }
alloy-sol-macro = { git = "https://github.com/alloy-rs/core", rev = "7574bfc", features = ["json"] }


[patch.crates-io]
alloy-primitives = { git = "https://github.com/alloy-rs/core", rev = "7574bfc" }

You have 2 different versions of alloy-sol-types.

There is an unsatisfied bound if you use alloy_sol_macro directly as it will use your alloy-sol-types (git) from Cargo.toml, while alloy-contract wants a different alloy-sol-types (0.7.0).

You should just use alloy as a single dependency or add the remaining alloy-core crate patches.