Encoding error for single item Enums
See original GitHub issueSubstrate encodes a single item Enum with an added leading zero while Polkadot encodes a single item Enum with an unnecessary (?) extra 255, breaking interchangeability between both ends.
hex::encode(some_single_item_enum.encode()); // Gives, for example, 001234
someSingleItemEnum.toHex(); // Gives 0x00ff1234
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
c# - Is Encoding not an enumeration? - Stack Overflow
No, it is not an enum. It is a class with static properties. Something like this: public class Encoding { public static Encoding...
Read more >Split error enums based on operations · Issue #205 - GitHub
Currently the source has one large enum for decoding and another for encoding. It likely would be cleaner if there were enums specific...
Read more >Serialization of enum with associated type | topolog's tech blog
When encoding an object we put all the properties to the container and then this container is being serialised to the binary data....
Read more >Splitting a JSON object into an enum and an associated object ...
Once the associated value is decoded, I can assign the appropriate enum case and associated value to self , and the decoding is...
Read more >Build Enumerations of Constants With Python's Enum
Providing a single source of truth and consistency throughout the code. Now that you know the basics of enumerations in programming and in ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The Address encoding is very explicit and has a special serialization, enum-like - the first byte indicates if it is an AccountId or AccountIndex. AccountId by itself will be without, since there is not “one or the other”.
TL;DR Address !== AccountId, these are distinct types
Ok, has a single-entry test added here - https://github.com/polkadot-js/api/pull/1670 - all encoded exactly as expected.