cddl-codegen
cddl-codegen copied to clipboard
Single element array members are treated as multiple
foo = [
single: [uint]
]
is treated as:
foo = [
single: [* uint]
]
As per the CDDL RFC:
If no occurrence indicator is specified, the group entry is to occur exactly once (as if 1*1 were specified)
You can work around this by doing:
single_uint = [uint]
foo = [
single: single_uint
]
but it's not ideal. Ideally the fix would make this totally invisible to end-users and have Foo::single be of type uint directly with the array part just being a serialization detail.
#210 addresses this for basic groups but the issue remains for other types e.g. [uint]. This is lower priority because the only time we've seen single element arrays like this in Cardano was for basic groups.