encode_storage_key_suffix_to

Function encode_storage_key_suffix_to 

Source
pub fn encode_storage_key_suffix_to<Info, Resolver, Keys>(
    pallet_name: &str,
    storage_entry: &str,
    keys: Keys,
    info: &Info,
    type_resolver: &Resolver,
    out: &mut Vec<u8>,
) -> Result<(), StorageKeyEncodeError>
where Keys: IntoEncodableValues, Info: StorageTypeInfo, Info::TypeId: Clone + Debug, Resolver: TypeResolver<TypeId = Info::TypeId>,
Expand description

Encode the end part of a storage key (ie everything except for the prefix that can be encoded via encode_storage_key_prefix) for a given pallet and storage entry and a set of keys that are each able to be encoded via scale_encode::EncodeAsType.

This is the same as encode_storage_key_suffix, but can be handed a Vec to encode the bytes to.

Prefer encode_storage_key_to if you need to encode the entire storage key at once and not just the suffix.

ยงExample

use frame_decode::storage::{ encode_storage_key_prefix, encode_storage_key_suffix_to };
use frame_metadata::RuntimeMetadata;
use parity_scale_codec::Decode;

let metadata_bytes = std::fs::read("artifacts/metadata_10000000_9180.scale").unwrap();
let RuntimeMetadata::V14(metadata) = RuntimeMetadata::decode(&mut &*metadata_bytes).unwrap() else { return };


let account_id = [0u8; 32];

let mut key = Vec::new();

// Write the suffix to the provided vec:
let encoded_key_suffix = encode_storage_key_suffix_to(
    "System",
    "Account",
    &[account_id],
    &metadata,
    &metadata.types,
    &mut key
).unwrap();