EOSIO / eosio-java-android-abieos-serialization-provider

Pluggable serialization provider for EOSIO SDK for Java using ABIEOS
https://eosio.github.io/eosio-java-android-abieos-serialization-provider/
MIT License
11 stars 14 forks source link

Cannot serialize/deserialize with variants in the ABI #43

Open poplexity opened 4 years ago

poplexity commented 4 years ago

Here's a simple reproducer, a much more complicated ABI for the ESR library is also failing to de-serialize from hex using identical data from the javascript tests which are passing using eosjs Serialize, happy to provide that example as well.

I suspect that the abieos files being from over 1yr ago might be the issue and copying the latest abieos into this java SDK could resolve the issue (probably should also update the swift SDK)

The below example fails to serialize when using the foo type that uses a variant, but the bar type serializes/deserializes just fine.

    @Test
    public void testBug() throws SerializationProviderError {
        String abi = "{\n" +
                "    \"version\": \"eosio::abi/1.1\",\n" +
                "    \"structs\": [\n" +
                "        {\n" +
                "            \"name\": \"foo\",\n" +
                "            \"fields\": [\n" +
                "                {\n" +
                "                    \"name\": \"things\",\n" +
                "                    \"type\": \"variant_things\"\n" +
                "                }\n" +
                "            ]\n" +
                "        },\n" +
                "        {\n" +
                "            \"name\": \"bar\",\n" +
                "            \"fields\": [\n" +
                "                {\n" +
                "                    \"name\": \"baz\",\n" +
                "                    \"type\": \"string\"\n" +
                "                }\n" +
                "            ]\n" +
                "        }\n" +
                "\n" +
                "    ],\n" +
                "    \"variants\": [\n" +
                "        {\n" +
                "            \"name\": \"variant_things\",\n" +
                "            \"types\": [\n" +
                "                \"bar\",\n" +
                "                \"uint8\"\n" +
                "            ]\n" +
                "        }\n" +
                "    ]\n" +
                "}";

        AbiEosSerializationProviderImpl serializationProvider = new AbiEosSerializationProviderImpl();
        AbiEosSerializationObject serializationObject = new AbiEosSerializationObject("", null, "foo", abi);
        serializationObject.setJson("{\"things\":4}");
        serializationProvider.serialize(serializationObject);
        //serializationObject.setJson("{\"baz\":\"moo\"}");
        //String hexMoo = "036D6F6F";
        //serializationObject.setHex(hexMoo);
        //serializationProvider.deserialize(serializationObject);
    }
poplexity commented 4 years ago

As an update, I have applied the latest updates of abieos into this repository and the issue with variants still persists.