alloy-rs / alloy-rs/core

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

Đang mở
#966 3 bình luận 2 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Rust
Star
967
Fork
274
Merge trung bình
1 ngày 21 giờ
Pull request đã merge (30 ngày)
15

Mô tả

### 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.