difftreelog
fix last_collection_idx
in: master
2 files changed
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -46,6 +46,10 @@
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
}
+ #[pallet::storage]
+ #[pallet::getter(fn collection_index)]
+ pub type CollectionIndex<T: Config> = StorageValue<_, RmrkCollectionId, ValueQuery>;
+
#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);
@@ -143,6 +147,8 @@
].into_iter()
)?;
+ <CollectionIndex<T>>::mutate(|n| *n += 1);
+
Self::deposit_event(Event::CollectionCreated {
issuer: sender,
collection_id: collection_id.0
@@ -378,6 +384,10 @@
.map_err(Self::map_common_err_to_proxy)
}
+ pub fn last_collection_idx() -> RmrkCollectionId {
+ <CollectionIndex<T>>::get()
+ }
+
pub fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {
let collection = <CollectionHandle<T>>::try_get(collection_id)
.map_err(|_| <Error<T>>::CollectionUnknown)?
runtime/common/src/runtime_apis.rsdiffbeforeafterboth142 RmrkTheme142 RmrkTheme143 > for Runtime {143 > for Runtime {144 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {144 fn last_collection_idx() -> Result<RmrkCollectionId, DispatchError> {145 Ok(<pallet_common::CreatedCollectionCount<Runtime>>::get().0) // todo storage from proxy pallet145 Ok(RmrkCore::last_collection_idx())146 }146 }147 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {147 fn collection_by_id(collection_id: RmrkCollectionId) -> Result<Option<RmrkCollectionInfo<AccountId>>, DispatchError> {148 // TODO decide on displacement to palettes -- does RMRK belong there, spread across common and nonfungible?148 // TODO decide on displacement to palettes -- does RMRK belong there, spread across common and nonfungible?