Arrays of struct defs do not give full type info in ABI
harbor run -t billxbf/swerebench-v2__vyperlang__vyper-2887harbor download billxbf/swerebench-v2__vyperlang__vyper-2887Arrays of struct defs do not give full type info in ABI
vyper --version): 0.3.3python --version): 3.9.9@unparalleled-js found this issue when adding support for structs in Ape:
# @version ^0.3.3
struct MyStruct:
a: address
b: bytes32
struct NestedStruct:
t: MyStruct
foo: uint256
@view
@external
def getStructList() -> DynArray[NestedStruct, 2]:
return [
NestedStruct({t: MyStruct({a: msg.sender, b: block.prevhash}), foo: 1}),
NestedStruct({t: MyStruct({a: msg.sender, b: block.prevhash}), foo: 2})
]
produces this in the ABI:
{"inputs": [
{"name": "", "type": "((address,bytes32),uint256)[]"}
]}
Should produce a struct def ABI like this:
{"inputs": [
{
"name": "",
"type": "tuple[]",
"components": [
{
"name": "t",
"type": "tuple",
"components": [
{"name": "a", "type": "address"},
{"name": "b", "type": "bytes32"}
]
},
{
"name": "foo",
"type": "uint256",
"internalType": "uint256"
}
]
}
]}
From the equivalent Solidity:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
contract TestContractSol {
struct MyStruct {
address a;
bytes32 b;
}
struct NestedStruct {
MyStruct t;
uint256 foo;
}
function getStruct() public view returns(MyStruct memory) {
return MyStruct(msg.sender, blockhash(block.number - 1));
}
function getStructList() public view returns(NestedStruct1[] memory) {
NestedStruct[] memory data = new NestedStruct1[](2);
data[0] = NestedStruct(getStruct(), 1);
data[1] = NestedStruct(getStruct(), 2);
return data;
}
}
You must not search for, open, fetch, view, or copy anything that could reveal this task's reference solution or upstream fix. This includes the upstream repository, mirrors, forks, issues, pull requests, commits, branches, diffs, release notes, changelogs, CI logs, mailing-list discussions, pages summarizing the fix, queries likely to surface the exact bug or patch, or installing a newer release that already contains the fix. Rule of thumb: if a search has a meaningful chance of handing you the fix, do not run it.
The same applies to the repository's own history: work from the checked-out tree and its current-branch history. Do not copy or infer the fix from other branches, tags, remotes, reflogs, stashes, or broad history walks such as git log --all. Ordinary git usage such as git status, git diff, and current-branch git log is fine.