Skip to content

[Bug] sol! type not found with free-standing struct #966

Open
@DaniPopes

Description

@DaniPopes

Component

sol! macro

What version of Alloy are you on?

alloy-core 1.2.0

Operating System

None

Describe the bug

Handler.json:

[
    {
        "type": "function",
        "name": "handle",
        "inputs": [
            {
                "name": "foobar",
                "type": "tuple",
                "internalType": "struct IHandler.FooBar",
                "components": [
                    {
                        "name": "foo",
                        "type": "tuple",
                        "internalType": "struct Foo",
                        "components": [
                            {
                                "name": "newNumber",
                                "type": "uint256",
                                "internalType": "uint256"
                            }
                        ]
                    }
                ]
            }
        ],
        "outputs": [],
        "stateMutability": "nonpayable"
    }
]

Output:

error[E0412]: cannot find type `Foo` in this scope
 --> src/main.rs:3:1
  |
3 | / sol!(
4 | |     #[allow(missing_docs)]
5 | |     #[sol(rpc)]
6 | |     Handler,
7 | |     "../contracts/out/Handler.sol/Handler.json"
8 | | );
  | |_^ not found in this scope
  |
  = help: consider importing this struct:
          crate::Handler::Foo
  = note: this error originates in the macro `$crate::sol_types::sol` which comes from the expansion of the macro `sol` (in Nightly builds, run with -Z macro-backtrace for more info)

Originally reported by @kziemianek in #967

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions