mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +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:
@@ -22,11 +22,7 @@ use super::*;
|
||||
impl<T: Config<I>, I: 'static> StoredMap<(T::AssetId, T::AccountId), T::Extra> for Pallet<T, I> {
|
||||
fn get(id_who: &(T::AssetId, T::AccountId)) -> T::Extra {
|
||||
let &(id, ref who) = id_who;
|
||||
if Account::<T, I>::contains_key(id, who) {
|
||||
Account::<T, I>::get(id, who).extra
|
||||
} else {
|
||||
Default::default()
|
||||
}
|
||||
Account::<T, I>::get(id, who).map(|a| a.extra).unwrap_or_default()
|
||||
}
|
||||
|
||||
fn try_mutate_exists<R, E: From<DispatchError>>(
|
||||
@@ -34,13 +30,13 @@ impl<T: Config<I>, I: 'static> StoredMap<(T::AssetId, T::AccountId), T::Extra> f
|
||||
f: impl FnOnce(&mut Option<T::Extra>) -> Result<R, E>,
|
||||
) -> Result<R, E> {
|
||||
let &(id, ref who) = id_who;
|
||||
let mut maybe_extra = Some(Account::<T, I>::get(id, who).extra);
|
||||
let mut maybe_extra = Account::<T, I>::get(id, who).map(|a| a.extra);
|
||||
let r = f(&mut maybe_extra)?;
|
||||
// They want to write some value or delete it.
|
||||
// If the account existed and they want to write a value, then we write.
|
||||
// If the account didn't exist and they want to delete it, then we let it pass.
|
||||
// Otherwise, we fail.
|
||||
Account::<T, I>::try_mutate_exists(id, who, |maybe_account| {
|
||||
Account::<T, I>::try_mutate(id, who, |maybe_account| {
|
||||
if let Some(extra) = maybe_extra {
|
||||
// They want to write a value. Let this happen only if the account actually exists.
|
||||
if let Some(ref mut account) = maybe_account {
|
||||
|
||||
Reference in New Issue
Block a user