mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 08:51:09 +00:00
Allow to clear attributes via traits (#13055)
This commit is contained in:
@@ -237,6 +237,49 @@ impl<T: Config<I>, I: 'static> Mutate<<T as SystemConfig>::AccountId, ItemConfig
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
fn clear_attribute(
|
||||
collection: &Self::CollectionId,
|
||||
item: &Self::ItemId,
|
||||
key: &[u8],
|
||||
) -> DispatchResult {
|
||||
Self::do_clear_attribute(
|
||||
None,
|
||||
*collection,
|
||||
Some(*item),
|
||||
AttributeNamespace::Pallet,
|
||||
Self::construct_attribute_key(key.to_vec())?,
|
||||
)
|
||||
}
|
||||
|
||||
fn clear_typed_attribute<K: Encode>(
|
||||
collection: &Self::CollectionId,
|
||||
item: &Self::ItemId,
|
||||
key: &K,
|
||||
) -> DispatchResult {
|
||||
key.using_encoded(|k| {
|
||||
<Self as Mutate<T::AccountId, ItemConfig>>::clear_attribute(collection, item, k)
|
||||
})
|
||||
}
|
||||
|
||||
fn clear_collection_attribute(collection: &Self::CollectionId, key: &[u8]) -> DispatchResult {
|
||||
Self::do_clear_attribute(
|
||||
None,
|
||||
*collection,
|
||||
None,
|
||||
AttributeNamespace::Pallet,
|
||||
Self::construct_attribute_key(key.to_vec())?,
|
||||
)
|
||||
}
|
||||
|
||||
fn clear_typed_collection_attribute<K: Encode>(
|
||||
collection: &Self::CollectionId,
|
||||
key: &K,
|
||||
) -> DispatchResult {
|
||||
key.using_encoded(|k| {
|
||||
<Self as Mutate<T::AccountId, ItemConfig>>::clear_collection_attribute(collection, k)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> Transfer<T::AccountId> for Pallet<T, I> {
|
||||
|
||||
@@ -1012,6 +1012,22 @@ fn validate_deposit_required_setting() {
|
||||
assert_eq!(Balances::reserved_balance(1), 0);
|
||||
assert_eq!(Balances::reserved_balance(2), 3);
|
||||
assert_eq!(Balances::reserved_balance(3), 3);
|
||||
|
||||
assert_ok!(
|
||||
<Nfts as Mutate<<Test as SystemConfig>::AccountId, ItemConfig>>::clear_attribute(
|
||||
&0,
|
||||
&0,
|
||||
&[3],
|
||||
)
|
||||
);
|
||||
assert_eq!(
|
||||
attributes(0),
|
||||
vec![
|
||||
(Some(0), AttributeNamespace::CollectionOwner, bvec![0], bvec![0]),
|
||||
(Some(0), AttributeNamespace::ItemOwner, bvec![1], bvec![0]),
|
||||
(Some(0), AttributeNamespace::Account(3), bvec![2], bvec![0]),
|
||||
]
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user