git.delta.rocks / unique-network / refs/commits / d364b895afdd

difftreelog

fix last_collection_idx

Daniel Shiposha2022-05-24parent: #cf884d8.patch.diff
in: master

2 files changed

modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
46 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;46 type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
47 }47 }
48
49 #[pallet::storage]
50 #[pallet::getter(fn collection_index)]
51 pub type CollectionIndex<T: Config> = StorageValue<_, RmrkCollectionId, ValueQuery>;
4852
49 #[pallet::pallet]53 #[pallet::pallet]
50 #[pallet::generate_store(pub(super) trait Store)]54 #[pallet::generate_store(pub(super) trait Store)]
143 ].into_iter()147 ].into_iter()
144 )?;148 )?;
149
150 <CollectionIndex<T>>::mutate(|n| *n += 1);
145151
146 Self::deposit_event(Event::CollectionCreated {152 Self::deposit_event(Event::CollectionCreated {
147 issuer: sender,153 issuer: sender,
378 .map_err(Self::map_common_err_to_proxy)384 .map_err(Self::map_common_err_to_proxy)
379 }385 }
386
387 pub fn last_collection_idx() -> RmrkCollectionId {
388 <CollectionIndex<T>>::get()
389 }
380390
381 pub fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {391 pub fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {
382 let collection = <CollectionHandle<T>>::try_get(collection_id)392 let collection = <CollectionHandle<T>>::try_get(collection_id)
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
142 RmrkTheme142 RmrkTheme
143 > 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?