alloy-rs / alloy-rs/core

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

Offen
#966 3 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
Rust
Sterne
967
Forks
274
Ø Merge
1 T. 21 Std.
Gemergte PRs (30 T.)
15

Beschreibung

### Component

sol! macro

### What version of Alloy are you on?

alloy-core 1.2.0

### Operating System

None

### Describe the bug

Handler.json:

```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 https://github.com/alloy-rs/core/issues/967

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.