Wrapper Generation with Array of Structs Parameter still an issue in 4.10.3
Opened this issue · 0 comments
I still have an issue with Array of Structs parameter on a method defined in an interface as reported and closed here:
#1723
The generated code does not match what is created by your example. I am using 4.10.3
Solidity:
pragma solidity ^0.8.7;
pragma experimental ABIEncoderV2;
interface IERC721CollectionV2 {
struct ItemParam {
string rarity;
uint256 price;
address beneficiary;
string metadata;
}
function initialize(
string memory _name,
string memory _symbol,
string memory _baseURI,
address _creator,
bool _shouldComplete,
bool _isApproved,
address _rarities,
ItemParam[] memory _items
) external;
The ItemParam class generated:
public static class ItemParam extends DynamicStruct {
public Utf8String rarity;
public Uint256 price;
public Address beneficiary;
public Utf8String metadata;
public ItemParam(Utf8String rarity, Uint256 price, Address beneficiary, Utf8String metadata) {
super(rarity, price, beneficiary, metadata);
this.rarity = rarity;
this.price = price;
this.beneficiary = beneficiary;
this.metadata = metadata;
}
}
The Initialize function generated:
public RemoteFunctionCall<TransactionReceipt> initialize(Utf8String _name, Utf8String _symbol, Utf8String _baseURI, Address _creator, Bool _shouldComplete, Bool _isApproved, Address _rarities, List<ItemParam> _items) {
final Function function = new Function(
FUNC_INITIALIZE,
Arrays.<Type>asList(_name, _symbol, _baseURI, _creator, _shouldComplete, _isApproved, _rarities, _items),
Collections.<TypeReference<?>>emptyList());
return executeRemoteCallTransaction(function);
}
Observations:
Your example looks very similar, but the obvious differences are that
1/ my struct is defined in an Interface
2/ my generated ItemParam class extends DynamicStruct, whereas your generated Pair class extends StaticStruct
3/ the generated Initialize method does not convert the Java List in the method signature to a type compatible with Arrays.asList so I end up with a build error:
IERC721CollectionV2.java:75: error: method asList in class Arrays cannot be applied to given types; Arrays.<Type>asList(_name, _symbol, _baseURI, _creator, _shouldComplete, _isApproved, _rarities, _items), ^ required: T[] found: Utf8String,Utf8String,Utf8String,Address,Bool,Bool,Address,List<ItemParam> reason: varargs mismatch; List<ItemParam> cannot be converted to Type where T is a type-variable: T extends Object declared in method <T>asList(T...)