I have a StorageNMap
#[pallet::storage]
#[pallet::getter(fn resources)]
/// Stores resource info
pub type Resources<T: Config> = StorageNMap<
_,
(
NMapKey<Blake2_128Concat, CollectionId>,
NMapKey<Blake2_128Concat, NftId>,
NMapKey<Blake2_128Concat, ResourceId>,
),
ResourceOf<T, T::PartsLimit>,
OptionQuery,
>;
I have a function that iterates through (CollectionId, NftId) with iter_prefix_values
where I need to find a matching condition. But once I match, I need the ResourceId itself (not the contents of the Resource). The Id isn't stored in the ResourceOf/Resource struct, though I could add it (though I'd rather not if I can get this key otherwise).
Here's the basic iteration matching
let resources_matching_base_iter =
pallet_rmrk_core::Resources::<T>::iter_prefix_values((item_collection_id, item_nft_id));
for resource in resources_matching_base_iter {
if <logic> {
<value_i_need> = resource.id;
}
}
This only works if I put the .id in the struct, which I could avoid if I could figure out how to get the keys itself from the iter_prefix_values
. Any ideas how, or if this would be possible?