mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
use associated iterator types for InspectEnumerable (#12389)
* use associated iterator types for InspectEnumerable * Update frame/uniques/src/impl_nonfungibles.rs Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
use super::*;
|
||||
use frame_support::{
|
||||
storage::KeyPrefixIterator,
|
||||
traits::{tokens::nonfungibles::*, Get},
|
||||
BoundedSlice,
|
||||
};
|
||||
@@ -155,25 +156,31 @@ impl<T: Config<I>, I: 'static> Transfer<T::AccountId> for Pallet<T, I> {
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> InspectEnumerable<T::AccountId> for Pallet<T, I> {
|
||||
type CollectionsIterator = KeyPrefixIterator<<T as Config<I>>::CollectionId>;
|
||||
type ItemsIterator = KeyPrefixIterator<<T as Config<I>>::ItemId>;
|
||||
type OwnedIterator =
|
||||
KeyPrefixIterator<(<T as Config<I>>::CollectionId, <T as Config<I>>::ItemId)>;
|
||||
type OwnedInCollectionIterator = KeyPrefixIterator<<T as Config<I>>::ItemId>;
|
||||
|
||||
/// Returns an iterator of the collections in existence.
|
||||
///
|
||||
/// NOTE: iterating this list invokes a storage read per item.
|
||||
fn collections() -> Box<dyn Iterator<Item = Self::CollectionId>> {
|
||||
Box::new(CollectionMetadataOf::<T, I>::iter_keys())
|
||||
fn collections() -> Self::CollectionsIterator {
|
||||
CollectionMetadataOf::<T, I>::iter_keys()
|
||||
}
|
||||
|
||||
/// Returns an iterator of the items of a `collection` in existence.
|
||||
///
|
||||
/// NOTE: iterating this list invokes a storage read per item.
|
||||
fn items(collection: &Self::CollectionId) -> Box<dyn Iterator<Item = Self::ItemId>> {
|
||||
Box::new(ItemMetadataOf::<T, I>::iter_key_prefix(collection))
|
||||
fn items(collection: &Self::CollectionId) -> Self::ItemsIterator {
|
||||
ItemMetadataOf::<T, I>::iter_key_prefix(collection)
|
||||
}
|
||||
|
||||
/// Returns an iterator of the items of all collections owned by `who`.
|
||||
///
|
||||
/// NOTE: iterating this list invokes a storage read per item.
|
||||
fn owned(who: &T::AccountId) -> Box<dyn Iterator<Item = (Self::CollectionId, Self::ItemId)>> {
|
||||
Box::new(Account::<T, I>::iter_key_prefix((who,)))
|
||||
fn owned(who: &T::AccountId) -> Self::OwnedIterator {
|
||||
Account::<T, I>::iter_key_prefix((who,))
|
||||
}
|
||||
|
||||
/// Returns an iterator of the items of `collection` owned by `who`.
|
||||
@@ -182,7 +189,7 @@ impl<T: Config<I>, I: 'static> InspectEnumerable<T::AccountId> for Pallet<T, I>
|
||||
fn owned_in_collection(
|
||||
collection: &Self::CollectionId,
|
||||
who: &T::AccountId,
|
||||
) -> Box<dyn Iterator<Item = Self::ItemId>> {
|
||||
Box::new(Account::<T, I>::iter_key_prefix((who, collection)))
|
||||
) -> Self::OwnedInCollectionIterator {
|
||||
Account::<T, I>::iter_key_prefix((who, collection))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user