difftreelog
feat sponsored approvals
in: master
2 files changed
pallets/nft/src/lib.rsdiffbeforeafterboth147147148 /// Variable metadata sponsoring148 /// Variable metadata sponsoring149 /// Collection id (controlled?2), token id (controlled?2)149 /// Collection id (controlled?2), token id (controlled?2)150 pub VariableMetaDataBasket get(fn variable_meta_data_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber> = None;150 pub VariableMetaDataBasket get(fn variable_meta_data_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;151 /// Approval sponsoring152 pub NftApproveBasket get(fn nft_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option<T::BlockNumber>;153 pub FungibleApproveBasket get(fn fungible_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;154 pub RefungibleApproveBasket get(fn refungible_approve_basket): nmap hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId, hasher(twox_64_concat) T::AccountId => Option<T::BlockNumber>;151 }155 }152}156}153157252 <ReFungibleTransferBasket<T>>::remove_prefix(collection_id, None);256 <ReFungibleTransferBasket<T>>::remove_prefix(collection_id, None);253257254 <VariableMetaDataBasket<T>>::remove_prefix(collection_id, None);258 <VariableMetaDataBasket<T>>::remove_prefix(collection_id, None);259 <NftApproveBasket<T>>::remove_prefix(collection_id, None);260 <FungibleApproveBasket<T>>::remove_prefix(collection_id, None);261 <RefungibleApproveBasket<T>>::remove_prefix((collection_id,), None);255262256 Ok(())263 Ok(())257 }264 }592 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {599 pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo {593 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);600 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);594601595 dispatch_call::<T, _>(collection_id, |d| d.burn_item(sender, item_id, value))602 let post_info = dispatch_call::<T, _>(collection_id, |d| d.burn_item(sender, item_id, value))?;603 if value == 1 {604 <NftTransferBasket<T>>::remove(collection_id, item_id);605 <NftApproveBasket<T>>::remove(collection_id, item_id);606 }607 // Those maps should be cleared only if token disappears completly, need to move this part of logic to pallets?608 // <FungibleApproveBasket<T>>::remove(collection_id, sender.as_sub());609 // <RefungibleApproveBasket<T>>::remove((collection_id, item_id, sender.as_sub()));610 Ok(post_info)596 }611 }597612598 /// Destroys a concrete instance of NFT on behalf of the owner613 /// Destroys a concrete instance of NFT on behalf of the ownerprimitives/nft/src/lib.rsdiffbeforeafterboth54pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;54pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;55pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;55pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5;5657pub const SPONSOR_APPROVE_TIMEOUT: u32 = 5;565857// Schema limits59// Schema limits58pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 1024;60pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 1024;259261260 // Timeouts for item types in passed blocks262 // Timeouts for item types in passed blocks261 pub sponsor_transfer_timeout: Option<u32>,263 pub sponsor_transfer_timeout: Option<u32>,264 pub sponsor_approve_timeout: Option<u32>,262 pub owner_can_transfer: Option<bool>,265 pub owner_can_transfer: Option<bool>,263 pub owner_can_destroy: Option<bool>,266 pub owner_can_destroy: Option<bool>,264 pub transfers_enabled: Option<bool>,267 pub transfers_enabled: Option<bool>,285 .unwrap_or(default)288 .unwrap_or(default)286 .min(MAX_SPONSOR_TIMEOUT)289 .min(MAX_SPONSOR_TIMEOUT)287 }290 }291 pub fn sponsor_approve_timeout(&self) -> u32 {292 self.sponsor_approve_timeout293 .unwrap_or(SPONSOR_APPROVE_TIMEOUT)294 .min(MAX_SPONSOR_TIMEOUT)295 }288 pub fn owner_can_transfer(&self) -> bool {296 pub fn owner_can_transfer(&self) -> bool {289 self.owner_can_transfer.unwrap_or(true)297 self.owner_can_transfer.unwrap_or(true)290 }298 }