web3j icon indicating copy to clipboard operation
web3j copied to clipboard

When I call Contract.excuteCall, how do I receive the response of [{a:[]}, {a:[]}]

Open JzyCccccc opened this issue 4 years ago • 2 comments

When I call Contract.excuteCall, how do I receive the response of [{a:[]}, {a:[]}]

Issue_description

this is my code

    //request
    final Function function = new Function(FUNC_XXX,
            Arrays.<Type>asList(new DynamicArray<Uint256>(
                    Uint256.class,
                    org.web3j.abi.Utils.typeMap(ids, Uint256.class)),
            new org.web3j.abi.datatypes.Address(160, param1),
            new org.web3j.abi.datatypes.Address(160, param2)),
            Collections.<TypeReference<?>>singletonList(new TypeReference<DynamicArray<StructA>>() {
            }));
    return new RemoteFunctionCall<List>(function,
            new Callable<List>() {
                @Override
                @SuppressWarnings("unchecked")
                public List call() throws Exception {
                    List<Type> result = (List<Type>) executeCallSingleValueReturn(function, List.class);
                    return convertToNative(result);
                }
            });

    // struct
    class StructA(
        val array: DynamicArray<Uint256>
    ) : DynamicStruct(
        array)

This is the exception I encountered:

Caused by: java.lang.UnsupportedOperationException: Array types must be wrapped in a TypeReference at org.web3j.abi.TypeDecoder.decode(TypeDecoder.java:114) at org.web3j.abi.TypeDecoder.decode(TypeDecoder.java:122) at org.web3j.abi.TypeDecoder.decodeDynamicParameterFromStruct(TypeDecoder.java:590) at org.web3j.abi.TypeDecoder.decodeDynamicStructElements(TypeDecoder.java:546) at org.web3j.abi.TypeDecoder.decodeDynamicStruct(TypeDecoder.java:472) at org.web3j.abi.TypeDecoder.decodeArrayElements(TypeDecoder.java:666) at org.web3j.abi.TypeDecoder.decodeDynamicArray(TypeDecoder.java:456) at org.web3j.abi.DefaultFunctionReturnDecoder.build(DefaultFunctionReturnDecoder.java:100) at org.web3j.abi.DefaultFunctionReturnDecoder.decodeFunctionResult(DefaultFunctionReturnDecoder.java:52) at org.web3j.abi.FunctionReturnDecoder.decode(FunctionReturnDecoder.java:49) at org.web3j.tx.Contract.executeCall(Contract.java:295) at org.web3j.tx.Contract.executeCallSingleValueReturn(Contract.java:301) at org.web3j.tx.Contract.executeCallSingleValueReturn(Contract.java:312)

Ask for help~~~

JzyCccccc avatar Oct 17 '21 08:10 JzyCccccc

same error. any one have idea on this?

xiaoshengaimm avatar Jan 29 '22 03:01 xiaoshengaimm

same error

cooaer avatar Jun 01 '22 15:06 cooaer