mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 16:21:06 +00:00
Add proper test Custom values (#1147)
* add proper tests for custom values * remove try operators * use sustrate compat for import of hash * add license and hex * add script to artifacts.sh * custom values with ids not in metadata can be accessed in static interface * fmt and clippy * access bytes of custom values directly, even if type id wrong * final fixes * removing substrate-compat flag from ui tests * Update subxt/src/custom_values/custom_values_client.rs Co-authored-by: James Wilson <james@jsdw.me> * remove types access in type generator * 2 extra lines --------- Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
@@ -405,15 +405,22 @@ pub fn get_custom_metadata_hash(custom_metadata: &CustomMetadata) -> [u8; HASH_L
|
||||
}
|
||||
|
||||
/// Obtain the hash of some custom value in the metadata including it's name/key.
|
||||
///
|
||||
/// If the `custom_value` has a type id that is not present in the metadata,
|
||||
/// only the name and bytes are used for hashing.
|
||||
pub fn get_custom_value_hash(
|
||||
custom_value: &CustomValueMetadata,
|
||||
cache: &mut HashMap<u32, CachedHash>,
|
||||
) -> [u8; HASH_LEN] {
|
||||
concat_and_hash3(
|
||||
&hash(custom_value.name.as_bytes()),
|
||||
&get_type_hash(custom_value.types, custom_value.type_id(), cache),
|
||||
&hash(custom_value.bytes()),
|
||||
)
|
||||
let name_hash = hash(custom_value.name.as_bytes());
|
||||
if custom_value.types.resolve(custom_value.type_id()).is_none() {
|
||||
hash(&name_hash)
|
||||
} else {
|
||||
concat_and_hash2(
|
||||
&name_hash,
|
||||
&get_type_hash(custom_value.types, custom_value.type_id(), cache),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Obtain the hash for a specific storage item, or an error if it's not found.
|
||||
|
||||
Reference in New Issue
Block a user