-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix WrapperOpaque max encded len and type info #9881
Conversation
@ascjones maybe you can review this one ? I forgot to declare the correct type info of the type |
frame/support/src/traits/misc.rs
Outdated
// Note: this can be improved if `T::max_encoded_len` is small. | ||
// E.g. if T max encoded len is 4, then the compact encoding of its encoded length is 1. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this comment here?
The point of this is to return the max encoded length?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes but I think we can be more precise in certain situation, I finally did the more precise implementation 5f07186
bot merge |
Trying merge. |
ah sorry I didn't see you asked review of ascjones, I'll ping him and ensure he get to see it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This type is potentially useful and universal enough to promote to parity-scale-codec
and scale-info
as a built-in.
.type_params(vec![TypeParameter::new("T", Some(meta_type::<T>()))]) | ||
.composite( | ||
Fields::unnamed() | ||
.field(|f| f.compact::<u32>().type_name("EncodedLengthOfT")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need type_name
here. It is optional and is used for the name of the type of the field as it appears in the code, in order to identify alias usage. E.g. where the concrete type is u128
the type_name
would be Balance
for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I'll do another PR with this removed
No description provided.