Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Cannot serialize/deserialize with variants in the ABI #43

Open
poplexity opened this issue Apr 21, 2020 · 1 comment
Open

Cannot serialize/deserialize with variants in the ABI #43

poplexity opened this issue Apr 21, 2020 · 1 comment

Comments

@poplexity
Copy link

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
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant