encode_storage_key_suffix

Function encode_storage_key_suffix 

Source
pub fn encode_storage_key_suffix<Info, Resolver, Keys>(
    pallet_name: &str,
    storage_entry: &str,
    keys: Keys,
    info: &Info,
    type_resolver: &Resolver,
) -> Result<Vec<u8>, 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_to, but returns the encoded key as a Vec<u8>, rather than accepting a mutable output buffer.

Prefer encode_storage_key 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 };
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];

// System.Account needs only one key to point at a specific value; the account ID.
// We just fake an account ID for this example  by providing 32 0 bytes, but anything
// which would `scale_encode::EncodeAsType` into 32 bytes would work.
let encoded_key_suffix = encode_storage_key_suffix(
    "System",
    "Account",
    &[account_id],
    &metadata,
    &metadata.types,
).unwrap();