Parsing Issue with Custom Type in `Constants` view
See original GitHub issueThere seems to be some parsing error when using a custom struct in the constants
tab of the Polkadot JS Apps.
There might be a bug in Polkadot JS Apps, but in general here is the steps to get what I think you want.
We have a custom type:
#[derive(Encode, Decode)]
struct Rule {
name: Vec<u8>,
version: u32,
ops: Vec<u32>,
}
We place a const
in the decl_module
so it exposes it in the metadata:
/// Rules for the PoE
const rule: Rule = Rule {
name: b"rule 1".to_vec(),
version: 1,
ops: vec![2]
};
Then we start our chain. In Polkadot JS Apps, I register a new custom type:
{
"Rule": {
"name": "Vec<u8>",
"version": "u32",
"ops": "Vec<u32>"
}
}
Then I go look at the constants in the pallet:

It seems it does not correctly detect the length prefix. When i parse the bytes on my own, it works:

Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
parsing - How can I handle previously declared constants ...
Now consider the following situation, where the default value of bar is a constant defined previously in the same file: int BAZ =...
Read more >Parsing error: "parserOptions.project" has been set for @ ...
When using eslint on a sub module that is currently not used by any other module, the following type of error message is...
Read more >Parse Custom Code
CodeImporter class, parses the custom code, but does not re-parse the custom code if the custom code has been parsed previously and neither...
Read more >Text Parsing Node Properties
You can create custom entity types by defining linguistic rules and referencing a custom file within SAS Text Miner. If SAS Visual Text ......
Read more >argparse — Parser for command-line options, arguments ...
formatter_class - A class for customizing the help output. prefix_chars - The set of characters that prefix optional arguments (default: '-')
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
can confirm it is fixed
thanks!
Should be in apps in around 20 mins - if that doesn’t solve it, can re-open, but should be correct now. (Should have been fixed originally instead of hacked around for bytes-only)
Yes, as expected, the above based on the original API logic wouldn’t have parse correctly. (And your test was incorrect as well since it worked with partial data, i.e. the hex outputs never include the full picture, here is an additional length prefix in-front since it comes in as
Vec<u8>
in the metadata. So the UI actually did the correct thing based on what it was fed, and it was fed something wrong. And when it displayed, it also dropped the hex, which is then what you used as an input)