--- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -147,7 +147,11 @@ /// Variable metadata sponsoring /// Collection id (controlled?2), token id (controlled?2) - pub VariableMetaDataBasket get(fn variable_meta_data_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option = None; + pub VariableMetaDataBasket get(fn variable_meta_data_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option; + /// Approval sponsoring + pub NftApproveBasket get(fn nft_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(blake2_128_concat) TokenId => Option; + pub FungibleApproveBasket get(fn fungible_approve_basket): double_map hasher(blake2_128_concat) CollectionId, hasher(twox_64_concat) T::AccountId => Option; + 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; } } @@ -252,6 +256,9 @@ >::remove_prefix(collection_id, None); >::remove_prefix(collection_id, None); + >::remove_prefix(collection_id, None); + >::remove_prefix(collection_id, None); + >::remove_prefix((collection_id,), None); Ok(()) } @@ -592,7 +599,15 @@ pub fn burn_item(origin, collection_id: CollectionId, item_id: TokenId, value: u128) -> DispatchResultWithPostInfo { let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?); - dispatch_call::(collection_id, |d| d.burn_item(sender, item_id, value)) + let post_info = dispatch_call::(collection_id, |d| d.burn_item(sender, item_id, value))?; + if value == 1 { + >::remove(collection_id, item_id); + >::remove(collection_id, item_id); + } + // Those maps should be cleared only if token disappears completly, need to move this part of logic to pallets? + // >::remove(collection_id, sender.as_sub()); + // >::remove((collection_id, item_id, sender.as_sub())); + Ok(post_info) } /// Destroys a concrete instance of NFT on behalf of the owner --- a/primitives/nft/src/lib.rs +++ b/primitives/nft/src/lib.rs @@ -54,6 +54,8 @@ pub const FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5; pub const REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT: u32 = 5; +pub const SPONSOR_APPROVE_TIMEOUT: u32 = 5; + // Schema limits pub const OFFCHAIN_SCHEMA_LIMIT: u32 = 1024; pub const VARIABLE_ON_CHAIN_SCHEMA_LIMIT: u32 = 1024; @@ -259,6 +261,7 @@ // Timeouts for item types in passed blocks pub sponsor_transfer_timeout: Option, + pub sponsor_approve_timeout: Option, pub owner_can_transfer: Option, pub owner_can_destroy: Option, pub transfers_enabled: Option, @@ -285,6 +288,11 @@ .unwrap_or(default) .min(MAX_SPONSOR_TIMEOUT) } + pub fn sponsor_approve_timeout(&self) -> u32 { + self.sponsor_approve_timeout + .unwrap_or(SPONSOR_APPROVE_TIMEOUT) + .min(MAX_SPONSOR_TIMEOUT) + } pub fn owner_can_transfer(&self) -> bool { self.owner_can_transfer.unwrap_or(true) }