#scale #decoding #codec #parity #encoding

no-std scale-info-legacy

Create type information that can be used to decode historic data from Substrate based chains

6 releases

0.2.2 Oct 23, 2024
0.2.1 Sep 27, 2024
0.2.0 Aug 9, 2024
0.1.1 Jul 30, 2024
0.0.1 Mar 14, 2024

#58 in #parity

Download history 116/week @ 2024-07-27 80/week @ 2024-08-03 42/week @ 2024-08-10 2/week @ 2024-08-17 1/week @ 2024-08-24 2/week @ 2024-08-31 23/week @ 2024-09-14 157/week @ 2024-09-21 98/week @ 2024-09-28 10/week @ 2024-10-05 5/week @ 2024-10-12 294/week @ 2024-10-19 27/week @ 2024-10-26 2/week @ 2024-11-02 22/week @ 2024-11-09

345 downloads per month
Used in frame-decode

Apache-2.0

135KB
2.5K SLoC

scale-info-legacy

This crate provides a set of types which build on each other. The ultimate goal is to be able to define the necessary type information needed to describe how historic Substrate types are SCALE encoded. The main types exposed here are as follows:

  • TypeRegistry: the lowest level type which one can populate with type information (via TypeRegistry::insert()) and then query to resolve some type name to the relevant information (via TypeRegistry::resolve_type()).
  • TypeRegistrySet: a set of the above, which will resolve types (via TypeRegistrySet::resolve_type()) by working through the inner type registries until it finds the relevant information (or doesn't find anything). This allows us to combine type registries in different ways to alter how we resolve things.
  • ChainTypeRegistry: this type is constructed by deserializing some JSON (or similar) which describes all of the types that we need to know about on a given chain. The main function here is ChainTypeRegistry::for_spec_version(), which returns a TypeRegistrySet for resolving types for the given spec version.

We also expose an InsertName, which is built by parsing type names like Vec<T> from strings, and used in TypeRegistry::insert() to insert types, and then LookupName, which is built by parsing type names like Vec<T>, u8; 32 and (bool, u32) and is used to lookup the corresponding type information via TypeRegistry::resolve_type() and similar. Finally, TypeShape is an enum used to describe the shape of the type inserted via TypeRegistry::insert(). This crate, like scale-info, can be used in conjunction with crates like:

  • scale-decode to decode SCALE encoded bytes into custom types based on this type information.
  • scale-encode to SCALE encode custom types into bytes based on this type information.
  • scale-value to SCALE encode or decode from a Value type (a bit like serde_json's Value type).

Dependencies

~1.4–2.2MB
~41K SLoC