Merged
Conversation
By default, parity-scale-codec does not provide Encode/Decode impls for an owned String. This is only provided under the "full" feature which is not used by the substrate runtime, because it should not be used for consensus critical code. So in order for the CompactForm to be integrated into the substrate runtime, or wherever the "full" feature cannot be used, then we must parameterize the `String` type so that it can be both an `&'static str` on the runtime side where it is encoded, and a `String` in client/consuming code where it is decoded.
Add a `compact` member to `Field` to indicate it is `scale_codec::Compact`
…ncoded/decoded as a SCALE Compact type
Add test that illustrates the registry in the presence of compact types.
Add a macro to cleanup boilerplate
dvdplm
commented
Jan 18, 2021
…andle-Compact-types
ascjones
reviewed
Jan 29, 2021
…andle-Compact-types
…andle-Compact-types
Robbepop
approved these changes
Feb 2, 2021
Contributor
Robbepop
left a comment
There was a problem hiding this comment.
LGTM
One nit pick that should be handled as a follow-up PR.
| .push(parse_quote!(#ty : ::scale::HasCompact)); | ||
| where_clause | ||
| .predicates | ||
| .push(parse_quote!(<#ty as ::scale::HasCompact>::Type : ::scale_info::TypeInfo + 'static)); |
Contributor
There was a problem hiding this comment.
I think our use of ::scale is becoming a problem. ink! imports parity-scale-codec crate as scale but from what I remember Substrate imports it as codec. We need a solution that works for both. Probably Basti's https://crates.io/crates/proc-macro-crate could help here. For now I am fine and we can fix this later.
There was a problem hiding this comment.
this also seem to break primitive-types: paritytech/parity-common#519
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Update the derive macro to handle the
#[codec(compact)attribute fromparity-scale-codecusing a newTypeDefCompactvariant similarly to #48.Closes #8
Supersedes #42