--- a/pallets/fungible/src/lib.rs +++ b/pallets/fungible/src/lib.rs @@ -403,13 +403,20 @@ )?; } + let updated_balances = data + .into_iter() + .map(|(user, amount)| { + let updated_balance = >::get((collection.id, &user)) + .checked_add(amount) + .ok_or(ArithmeticError::Overflow)?; + Ok((user, amount, updated_balance)) + }) + .collect::, DispatchError>>()?; + // ========= >::insert(collection.id, total_supply); - for (user, amount) in data { - let updated_balance = >::get((collection.id, &user)) - .checked_add(amount) - .ok_or(ArithmeticError::Overflow)?; + for (user, amount, updated_balance) in updated_balances { >::insert((collection.id, &user), updated_balance); >::nest_if_sent_to_token_unchecked( &user,