Skip to content

Commit 5563691

Browse files
authored
Prep 0.15.0 release: AccountID32 is unnamed struct and from_bytes to decode legacy types (#65)
1 parent c60521e commit 5563691

File tree

8 files changed

+30
-15
lines changed

8 files changed

+30
-15
lines changed

CHANGELOG.md

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

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

7+
## 0.15.0 (2025-11-20)
8+
9+
- Update to `scale-info-legacy` 0.4.0.
10+
- Tweak `AccountId32` types to be unnamed structs rather than tuple types, so that they get a path.
11+
- Add `legacy_types::from_bytes` to convert provided bytes into a `ChainTypeRegistry`, negating the need to include `serde_yaml` or whatever in other crates.
12+
713
## 0.14.0 (2025-11-19)
814

915
- Add Kusama RC types capable of decoding historic blocks.

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "frame-decode"
3-
version = "0.14.0"
3+
version = "0.15.0"
44
edition = "2024"
55
description = "Decode extrinsics and storage from Substrate based chains"
66
license = "Apache-2.0"
@@ -43,7 +43,7 @@ parity-scale-codec = { version = "3.6.12", default-features = false }
4343
scale-decode = { version = "0.16.0", default-features = false }
4444
scale-encode = { version = "0.10.0", default-features = false }
4545
scale-info = { version = "2.11.4", default-features = false }
46-
scale-info-legacy = { version = "0.3.2", default-features = false, optional = true }
46+
scale-info-legacy = { version = "0.4.0", default-features = false, optional = true }
4747
scale-type-resolver = "0.2.0"
4848
scale-value = { version = "0.18.0", default-features = false, optional = true }
4949
sp-crypto-hashing = { version = "0.1.0", default-features = false }
@@ -55,4 +55,4 @@ hex = "0.4.3"
5555
serde_yaml = "0.9"
5656
serde_json = "1"
5757
scale-value = "0.18.0"
58-
scale-info-legacy = "0.3.0"
58+
scale-info-legacy = "0.4.0"

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ pub mod custom_values {
165165
pub mod legacy_types {
166166
//! This module contains legacy types that can be used to decode pre-V14 blocks and storage.
167167
168+
use alloc::boxed::Box;
169+
type GenericError = Box<dyn core::error::Error + Send + Sync + 'static>;
170+
171+
/// Deserialize bytes into a [`scale_info_legacy::ChainTypeRegistry`].
172+
pub fn from_bytes(bytes: &[u8]) -> Result<scale_info_legacy::ChainTypeRegistry, GenericError> {
173+
let types = serde_yaml::from_slice(bytes)?;
174+
Ok(types)
175+
}
176+
168177
pub mod polkadot {
169178
//! Legacy types for Polkadot chains.
170179

src/utils/type_registry_from_metadata.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const _: () = {
151151
call_variants.push(Variant {
152152
index: c_idx as u8,
153153
name: call_name.to_owned(),
154-
fields: VariantDesc::StructOf(args)
154+
fields: VariantDesc::NamedStructOf(args)
155155
});
156156
}
157157

@@ -165,7 +165,7 @@ const _: () = {
165165
call_module_variants.push(Variant {
166166
index: calls_index,
167167
name: module_name.to_owned(),
168-
fields: VariantDesc::TupleOf(vec![call_enum_lookup_name])
168+
fields: VariantDesc::UnnamedStructOf(vec![call_enum_lookup_name])
169169
});
170170
}
171171

@@ -186,7 +186,7 @@ const _: () = {
186186
event_variants.push(Variant {
187187
index: e_idx as u8,
188188
name: event_name.to_owned(),
189-
fields: VariantDesc::TupleOf(args)
189+
fields: VariantDesc::UnnamedStructOf(args)
190190
});
191191
}
192192

@@ -200,7 +200,7 @@ const _: () = {
200200
event_module_variants.push(Variant {
201201
index: events_index,
202202
name: module_name.to_owned(),
203-
fields: VariantDesc::TupleOf(vec![event_enum_lookup_name])
203+
fields: VariantDesc::UnnamedStructOf(vec![event_enum_lookup_name])
204204
});
205205
}
206206

@@ -213,7 +213,7 @@ const _: () = {
213213
Variant {
214214
index: e_idx as u8,
215215
name: event_name.to_owned(),
216-
fields: VariantDesc::TupleOf(Vec::new())
216+
fields: VariantDesc::UnnamedStructOf(Vec::new())
217217
}
218218
}).collect();
219219

@@ -227,7 +227,7 @@ const _: () = {
227227
error_module_variants.push(Variant {
228228
index: errors_index,
229229
name: module_name.to_owned(),
230-
fields: VariantDesc::TupleOf(vec![error_enum_lookup_name])
230+
fields: VariantDesc::UnnamedStructOf(vec![error_enum_lookup_name])
231231
});
232232
}
233233
}

types/kusama_assethub_types.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ global:
12321232
approvals: Compact<u32>
12331233

12341234
Index: u32
1235-
AccountId32: "[u8; 32]"
1235+
AccountId32: [ "[u8; 32]" ]
12361236
AccountId: AccountId32
12371237
SessionIndex: u32
12381238
Bytes: Vec<u8>

types/kusama_relay_types.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ global:
770770
BalanceOf<T, I>: Balance
771771

772772
Index: u32
773-
AccountId32: "[u8; 32]"
773+
AccountId32: [ "[u8; 32]" ]
774774
AccountId: AccountId32
775775
SessionIndex: u32
776776
Bytes: Vec<u8>

types/polkadot_relay_types.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ global:
762762
BalanceOf<T, I>: Balance
763763

764764
Index: u32
765-
AccountId32: "[u8; 32]"
765+
AccountId32: [ "[u8; 32]" ]
766766
AccountId: AccountId32
767767
SessionIndex: u32
768768
Bytes: Vec<u8>

0 commit comments

Comments
 (0)