mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 09:11:02 +00:00
Fungibles and Non-Fungibles Create and Destroy Traits + Assets and Uniques Implementation (#9844)
* refactor `do_destroy` * destroy trait * refactor do_force_create * impl create trait * do not bleed weight into api * Do the same for uniques * add docs
This commit is contained in:
@@ -80,6 +80,41 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) fn do_destroy_class(
|
||||
class: T::ClassId,
|
||||
witness: DestroyWitness,
|
||||
maybe_check_owner: Option<T::AccountId>,
|
||||
) -> Result<DestroyWitness, DispatchError> {
|
||||
Class::<T, I>::try_mutate_exists(class, |maybe_details| {
|
||||
let class_details = maybe_details.take().ok_or(Error::<T, I>::Unknown)?;
|
||||
if let Some(check_owner) = maybe_check_owner {
|
||||
ensure!(class_details.owner == check_owner, Error::<T, I>::NoPermission);
|
||||
}
|
||||
ensure!(class_details.instances == witness.instances, Error::<T, I>::BadWitness);
|
||||
ensure!(
|
||||
class_details.instance_metadatas == witness.instance_metadatas,
|
||||
Error::<T, I>::BadWitness
|
||||
);
|
||||
ensure!(class_details.attributes == witness.attributes, Error::<T, I>::BadWitness);
|
||||
|
||||
for (instance, details) in Asset::<T, I>::drain_prefix(&class) {
|
||||
Account::<T, I>::remove((&details.owner, &class, &instance));
|
||||
}
|
||||
InstanceMetadataOf::<T, I>::remove_prefix(&class, None);
|
||||
ClassMetadataOf::<T, I>::remove(&class);
|
||||
Attribute::<T, I>::remove_prefix((&class,), None);
|
||||
T::Currency::unreserve(&class_details.owner, class_details.total_deposit);
|
||||
|
||||
Self::deposit_event(Event::Destroyed(class));
|
||||
|
||||
Ok(DestroyWitness {
|
||||
instances: class_details.instances,
|
||||
instance_metadatas: class_details.instance_metadatas,
|
||||
attributes: class_details.attributes,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn do_mint(
|
||||
class: T::ClassId,
|
||||
instance: T::InstanceId,
|
||||
|
||||
Reference in New Issue
Block a user