WIP integrating new frame-decode and working out new storage APIS

This commit is contained in:
James Wilson
2025-09-24 16:38:48 +01:00
parent 9080b0b2ae
commit 9d5c1d5a24
21 changed files with 695 additions and 633 deletions
+13 -23
View File
@@ -6,7 +6,7 @@
use crate::{
CustomMetadata, CustomValueMetadata, ExtrinsicMetadata, Metadata, PalletMetadata,
RuntimeApiMetadata, RuntimeApiMethodMetadata, StorageEntryMetadata, StorageEntryType,
RuntimeApiMetadata, RuntimeApiMethodMetadata, StorageEntryMetadata,
ViewFunctionMetadata,
};
use alloc::vec::Vec;
@@ -290,29 +290,19 @@ fn get_extrinsic_hash(registry: &PortableRegistry, extrinsic: &ExtrinsicMetadata
fn get_storage_entry_hash(registry: &PortableRegistry, entry: &StorageEntryMetadata) -> Hash {
let mut bytes = concat_and_hash3(
&hash(entry.name.as_bytes()),
// Cloning 'entry.modifier' should essentially be a copy.
&[entry.modifier as u8; HASH_LEN],
&hash(&entry.default),
&get_type_hash(registry, entry.info.value_id),
&hash(entry.info.default_value.as_ref().map(|b| &**b).unwrap_or_default())
);
match &entry.entry_type {
StorageEntryType::Plain(ty) => concat_and_hash2(&bytes, &get_type_hash(registry, *ty)),
StorageEntryType::Map {
hashers,
key_ty,
value_ty,
} => {
for hasher in hashers {
// Cloning the hasher should essentially be a copy.
bytes = concat_and_hash2(&bytes, &[*hasher as u8; HASH_LEN]);
}
concat_and_hash3(
&bytes,
&get_type_hash(registry, *key_ty),
&get_type_hash(registry, *value_ty),
)
}
for key in &*entry.info.keys {
bytes = concat_and_hash3(
&bytes,
&[key.hasher as u8; HASH_LEN],
&get_type_hash(registry, key.key_id),
)
}
bytes
}
fn get_custom_metadata_hash(custom_metadata: &CustomMetadata) -> Hash {
@@ -382,7 +372,7 @@ pub fn get_runtime_api_hash(runtime_api: &RuntimeApiMethodMetadata) -> Hash {
bytes = concat_and_hash3(
&bytes,
&hash(input.name.as_bytes()),
&get_type_hash(registry, input.ty),
&get_type_hash(registry, input.id),
);
}
@@ -419,7 +409,7 @@ pub fn get_view_function_hash(view_function: &ViewFunctionMetadata) -> Hash {
bytes = concat_and_hash3(
&bytes,
&hash(input.name.as_bytes()),
&get_type_hash(registry, input.ty),
&get_type_hash(registry, input.id),
);
}