mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 18:01:04 +00:00
Insufficient asset quota and deposits (#10382)
* Allow asset accounts to exist by deposit * Place limit on consumers (and therefore freebie asset accounts) * Maximum number of assets * Fixes * Fixes * Formatting * Docs * Formatting * Destroyed assets are properly tidied * Update frame/assets/src/types.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Docs * Docs * Formatting * Docs * Docs * Fixes * Fixes Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -62,11 +62,11 @@ impl<T: Config<I>, I: 'static> ExtraMutator<T, I> {
|
||||
id: T::AssetId,
|
||||
who: impl sp_std::borrow::Borrow<T::AccountId>,
|
||||
) -> Option<ExtraMutator<T, I>> {
|
||||
if Account::<T, I>::contains_key(id, who.borrow()) {
|
||||
if let Some(a) = Account::<T, I>::get(id, who.borrow()) {
|
||||
Some(ExtraMutator::<T, I> {
|
||||
id,
|
||||
who: who.borrow().clone(),
|
||||
original: Account::<T, I>::get(id, who.borrow()).extra,
|
||||
original: a.extra,
|
||||
pending: None,
|
||||
})
|
||||
} else {
|
||||
@@ -77,13 +77,8 @@ impl<T: Config<I>, I: 'static> ExtraMutator<T, I> {
|
||||
/// Commit any changes to storage.
|
||||
pub fn commit(&mut self) -> Result<(), ()> {
|
||||
if let Some(extra) = self.pending.take() {
|
||||
Account::<T, I>::try_mutate_exists(self.id, self.who.borrow(), |maybe_account| {
|
||||
if let Some(ref mut account) = maybe_account {
|
||||
account.extra = extra;
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
Account::<T, I>::try_mutate(self.id, self.who.borrow(), |maybe_account| {
|
||||
maybe_account.as_mut().ok_or(()).map(|account| account.extra = extra)
|
||||
})
|
||||
} else {
|
||||
Ok(())
|
||||
@@ -93,13 +88,11 @@ impl<T: Config<I>, I: 'static> ExtraMutator<T, I> {
|
||||
/// Revert any changes, even those already committed by `self` and drop self.
|
||||
pub fn revert(mut self) -> Result<(), ()> {
|
||||
self.pending = None;
|
||||
Account::<T, I>::try_mutate_exists(self.id, self.who.borrow(), |maybe_account| {
|
||||
if let Some(ref mut account) = maybe_account {
|
||||
account.extra = self.original.clone();
|
||||
Ok(())
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
Account::<T, I>::try_mutate(self.id, self.who.borrow(), |maybe_account| {
|
||||
maybe_account
|
||||
.as_mut()
|
||||
.ok_or(())
|
||||
.map(|account| account.extra = self.original.clone())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user