Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Assets: impl ContainsPair for asset and account IDs (#14119)
Browse files Browse the repository at this point in the history
* Assets impl ContainsPair for asset and account IDs

* clap version
  • Loading branch information
muharem authored May 11, 2023
1 parent a87e56f commit c09f0bc
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ impl<AssetId, AccountId> AssetsCallback<AssetId, AccountId> for () {}
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::{pallet_prelude::*, traits::AccountTouch};
use frame_support::{
pallet_prelude::*,
traits::{AccountTouch, ContainsPair},
};
use frame_system::pallet_prelude::*;

/// The current storage version.
Expand Down Expand Up @@ -1645,7 +1648,7 @@ pub mod pallet {
}
}

/// Implements [AccountTouch] trait.
/// Implements [`AccountTouch`] trait.
/// Note that a depositor can be any account, without any specific privilege.
/// This implementation is supposed to be used only for creation of system accounts.
impl<T: Config<I>, I: 'static> AccountTouch<T::AssetId, T::AccountId> for Pallet<T, I> {
Expand All @@ -1659,6 +1662,14 @@ pub mod pallet {
Self::do_touch(asset, who, depositor, false)
}
}

/// Implements [`ContainsPair`] trait for a pair of asset and account IDs.
impl<T: Config<I>, I: 'static> ContainsPair<T::AssetId, T::AccountId> for Pallet<T, I> {
/// Check if an account with the given asset ID and account address exists.
fn contains(asset: &T::AssetId, who: &T::AccountId) -> bool {
Account::<T, I>::contains_key(asset, who)
}
}
}

sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $);

0 comments on commit c09f0bc

Please sign in to comment.