Skip to content

Commit 7d4ba80

Browse files
authored
Prep 0.16.1 release: expose ToTypeRegitry (#73)
1 parent 630c20e commit 7d4ba80

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog].
44

55
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/
66

7+
## 0.16.1 (2025-12-03)
8+
9+
- Expose the `crate::helpers::ToTypeRegistry` trait so that inputs to `crate::helpers::type_registry_from_metadata` can be named. Make it sealed so that others cannot rely on it.
10+
711
## 0.16.0 (2025-11-26)
812

913
- Add a flag to `StorageInfo` which can be set in order to tell `frame-decode` to use the old version of V9 storage hashers when decoding storage keys. We need to manually toggle this flag when using metadata produced by runtimes prior to [this change](https://github.com/paritytech/substrate/commit/bbb363f4320b4a72e059c0fca96af42296d5a6bf#diff-aa7bc120d701816def0f2a5eb469212d2b7021d2fc9d3b284f843f3f8089e91a), which altered the storage hashers (and thus their encoding/decoding). Kusama prior to spec version 1032 is one such case when this needs to be toggled.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "frame-decode"
3-
version = "0.16.0"
3+
version = "0.16.1"
44
edition = "2024"
55
description = "Decode extrinsics and storage from Substrate based chains"
66
license = "Apache-2.0"

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,9 @@ pub mod helpers {
225225
IntoEncodableValues, decode_with_error_tracing,
226226
};
227227
#[cfg(feature = "legacy")]
228-
pub use crate::utils::{type_registry_from_metadata, type_registry_from_metadata_any};
228+
pub use crate::utils::{
229+
ToTypeRegistry, type_registry_from_metadata, type_registry_from_metadata_any,
230+
};
229231

230232
/// An alias to [`scale_decode::visitor::decode_with_visitor`]. This can be used to decode the byte ranges
231233
/// given back from functions like [`crate::extrinsics::decode_extrinsic`] or

src/utils.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ pub use decode_with_error_tracing::{DecodeErrorTrace, decode_with_error_tracing}
2626
pub use either::Either;
2727
#[cfg(feature = "legacy")]
2828
pub use type_registry_from_metadata::{
29-
type_registry_from_metadata, type_registry_from_metadata_any,
29+
ToTypeRegistry, type_registry_from_metadata, type_registry_from_metadata_any,
3030
};
3131

32-
// We don't want to expose these traits at the moment, but want to test them.
33-
#[cfg(all(test, feature = "legacy"))]
34-
pub use type_registry_from_metadata::ToTypeRegistry;
35-
3632
/// A utility function to unwrap the `DecodeDifferent` enum found in earlier metadata versions.
3733
#[cfg(feature = "legacy")]
3834
pub fn as_decoded<A, B>(item: &frame_metadata::decode_different::DecodeDifferent<A, B>) -> &B {

src/utils/type_registry_from_metadata.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,19 @@ pub fn type_registry_from_metadata_any(
6060
}
6161

6262
#[cfg(feature = "legacy")]
63-
pub trait ToTypeRegistry {
63+
/// This is used with the [`type_registry_from_metadata`] helper function to extract types from the
64+
/// metadata. It is not intended to be implemented on anything else.
65+
pub trait ToTypeRegistry: sealed::Sealed {
66+
/// Return a type registry.
6467
fn to_type_registry(
6568
&self,
6669
) -> Result<scale_info_legacy::TypeRegistry, scale_info_legacy::lookup_name::ParseError>;
6770
}
6871

72+
mod sealed {
73+
pub trait Sealed {}
74+
}
75+
6976
#[cfg(feature = "legacy")]
7077
const _: () = {
7178
use super::as_decoded;
@@ -79,6 +86,7 @@ const _: () = {
7986

8087
macro_rules! impl_for_v8_to_v13 {
8188
($path:path $(, $builtin_index:ident)?) => {
89+
impl sealed::Sealed for $path {}
8290
impl ToTypeRegistry for $path {
8391
fn to_type_registry(&self) -> Result<scale_info_legacy::TypeRegistry, scale_info_legacy::lookup_name::ParseError> {
8492
let metadata = self;

0 commit comments

Comments
 (0)