Skip to content

Commit

Permalink
fix(pallet-assets-freezer): fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
pandres95 committed Apr 3, 2024
1 parent 4ae1c4f commit 3cce169
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
13 changes: 7 additions & 6 deletions substrate/frame/assets-freezer/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ impl<T: Config<I>, I: 'static> FrozenBalance<AssetIdOf<T, I>, AccountIdOf<T>, As
}

/// Implement [`frame_support::traits::fungibles::Inspect`] as it is bound by
/// [`frame_support::traits::fungibles::InspectFreeze`] and [`frame_support::traits::fungibles::MutateFreeze`].
/// To do so, we'll re-export all of `pallet-assets` implementation of the same trait.
/// [`frame_support::traits::fungibles::InspectFreeze`] and
/// [`frame_support::traits::fungibles::MutateFreeze`]. To do so, we'll re-export all of
/// `pallet-assets` implementation of the same trait.
impl<T: Config<I>, I: 'static> Inspect<AccountIdOf<T>> for Pallet<T, I> {
type AssetId = AssetIdOf<T, I>;
type Balance = AssetBalanceOf<T, I>;
Expand Down Expand Up @@ -104,11 +105,11 @@ impl<T: Config<I>, I: 'static> InspectFreeze<AccountIdOf<T>> for Pallet<T, I> {

fn can_freeze(asset: Self::AssetId, id: &Self::Id, who: &AccountIdOf<T>) -> bool {
let freezes = Freezes::<T, I>::get(asset, who);
freezes.len()
< T::MaxFreezes::get()
freezes.len() <
T::MaxFreezes::get()
.try_into()
.expect("MaxFreezes is the same type as S within Freezes<S>; qed")
|| freezes.into_iter().any(|i| i.id == *id)
.expect("MaxFreezes is the same type as S within Freezes<S>; qed") ||
freezes.into_iter().any(|i| i.id == *id)
}
}

Expand Down
5 changes: 3 additions & 2 deletions substrate/frame/assets-freezer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
//!
//! - Pallet hooks that implement custom logic to let `pallet-assets` know whether an balance is
//! frozen for an account on a given asset (see: [`pallet_assets::FrozenBalance`]).
//! - An implementation of the fungibles [inspect][`frame_support::traits::fungibles::InspectFreeze`]
//! and the [mutation][`frame_support::traits::fungibles::InspectFreeze`] APIs for freezes.
//! - An implementation of the fungibles
//! [inspect][`frame_support::traits::fungibles::InspectFreeze`] and the
//! [mutation][`frame_support::traits::fungibles::InspectFreeze`] APIs for freezes.
#![cfg_attr(not(feature = "std"), no_std)]

Expand Down
6 changes: 4 additions & 2 deletions substrate/frame/assets-freezer/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use frame_support::pallet_prelude::{Decode, Encode, MaxEncodedLen, RuntimeDebug, TypeInfo};
use frame_support::traits::fungibles::Inspect;
use frame_support::{
pallet_prelude::{Decode, Encode, MaxEncodedLen, RuntimeDebug, TypeInfo},
traits::fungibles::Inspect,
};

pub type AssetIdOf<T, I> = <pallet_assets::Pallet<T, I> as Inspect<AccountIdOf<T>>>::AssetId;
pub type AssetBalanceOf<T, I> = <pallet_assets::Pallet<T, I> as Inspect<AccountIdOf<T>>>::Balance;
Expand Down

0 comments on commit 3cce169

Please sign in to comment.