-
Notifications
You must be signed in to change notification settings - Fork 795
Abigen fails with some nested structs #538
Comments
this is an edge case that This can be resolved with:
|
IMO if we can avoid parsing altogether that'd be great. So let's try the second solution? |
I'm unfortunately still affected by this issue. As a first step towards fixing it I was trying to find a place in ethers-rs where the failing example could be added as a (regression) test, but I didn't succeed. If that even makes sense, is there a place where it would make sense to add this? And in the meantime I'm also wondering if anyone was aware of any workarounds. This seems to affect most of my contracts with nested structs. |
I was looking at the code below and wouldn't the example above be parsed as a function in the edit: I might get it now that the ABI at that point is already incorrect? ethers-rs/ethers-contract/ethers-contract-derive/src/call.rs Lines 29 to 62 in 24f9bd0
|
thanks for the follow up. workaround currently would be to define the input as tuple |
the parser is really not ideal and now that we've |
Thanks for the replies. In terms of workarounds for contracts in development, I noticed that sometimes the failures can be avoided by reordering the fields in the structs. The example above compiles if the order of the fields in use ethers::prelude::abigen;
abigen!(
Test,
r#"[
struct Outer {uint256[] arr; Inner inner;}
struct Inner {uint256 inner;}
function myfun(Outer calldata a)
]"#,
); |
Probably not very useful but in case someone is hitting a similar issue some more information and a reduced real world example (where I can't find a workaround) below. I'm not sure this is hitting the same problem. The last ethers commit I can expand the abigen macro with is 071a416 , the commit where it started breaking is fb4d9a9. Fails with
pragma solidity ^0.8.0;
contract Example {
struct EncKey {
uint256 x;
uint256 y;
uint256 t;
uint256 z;
}
struct AuditMemo {
EncKey ephemeral;
uint256[] data;
}
struct TransferNote {
AuditMemo auditMemo;
uint256[] inputsNullifiers;
uint256[] outputCommitments;
}
struct Transaction {
TransferNote note;
}
struct Block {
uint64 blockHeight;
Transaction[] txns;
Transaction[] burnTxns;
}
function submitBlock(
Block memory newBlock
) public {
}
} |
thanks for these, |
Hello, I've come across this github issue when attempting to use
The solidity source code for this is available at https://github.com/mudgen/diamond-3-hardhat/blob/main/contracts/interfaces/IDiamondCut.sol. |
thanks, it appears there are some |
Version
Platform
Linux lulus 5.10.75 #1-NixOS SMP Wed Oct 20 09:45:06 UTC 2021 x86_64 GNU/Linux
Description
Some combinations of nested structs and arrays are not handled correctly by the
abigen
.Example:
I expected to see this happen:
cargo check
succeeds.Instead, this happened:
The text was updated successfully, but these errors were encountered: