@SuppressWarnings("unchecked")
    public static <T extends Type> T decodeDynamicArray(
            String input, int offset, TypeReference<T> typeReference) {

        int length = decodeUintAsInt(input, offset);

        BiFunction<List<T>, String, T> function =
                (elements, typeName) -> (T) new DynamicArray(AbiTypes.getType(typeName), elements);

        int valueOffset = offset + MAX_BYTE_LENGTH_FOR_HEX_STRING;

        return decodeArrayElements(input, valueOffset, typeReference, length, function);
    }
@Test
    public void testDynamicArrayOfDynamicArrays() throws Exception {
        assertEquals(
                TypeDecoder.decodeDynamicArray(
                        "0000000000000000000000000000000000000000000000000000000000000002"
                                + "0000000000000000000000000000000000000000000000000000000000000040"
                                + "00000000000000000000000000000000000000000000000000000000000000a0"
                                + "0000000000000000000000000000000000000000000000000000000000000001"
                                + "0000000000000000000000000000000000000000000000000000000000000000"
                                + "0000000000000000000000000000000000000000000000000000000000000000"
                                + "0000000000000000000000000000000000000000000000000000000000000001"
                                + "0000000000000000000000000000000000000000000000000000000000000001"
                                + "0000000000000000000000000000000000000000000000000000000000000000",
                        0,
                        new TypeReference<DynamicArray<DynamicArray<AbiV2TestFixture.Bar>>>() {}),
                new DynamicArray(
                        DynamicArray.class,
                        Arrays.asList(
                                new DynamicArray(
                                        AbiV2TestFixture.Bar.class,
                                        new AbiV2TestFixture.Bar(
                                                new Uint256(BigInteger.ZERO),
                                                new Uint256(BigInteger.ZERO))),
                                new DynamicArray(
                                        AbiV2TestFixture.Bar.class,
                                        new AbiV2TestFixture.Bar(
                                                new Uint256(BigInteger.ONE),
                                                new Uint256(BigInteger.ZERO))))));
    }