From 05201c4047f3c901e145e68cea300bf11dec42fe Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Thu, 11 May 2023 17:56:01 +0200 Subject: [PATCH] Assets: impl ContainsPair for asset and account IDs (#14119) * Assets impl ContainsPair for asset and account IDs * clap version --- substrate/frame/assets/src/lib.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index e6b59bba53..c25f33ae3e 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -202,7 +202,10 @@ impl AssetsCallback 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. @@ -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, I: 'static> AccountTouch for Pallet { @@ -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, I: 'static> ContainsPair for Pallet { + /// Check if an account with the given asset ID and account address exists. + fn contains(asset: &T::AssetId, who: &T::AccountId) -> bool { + Account::::contains_key(asset, who) + } + } } sp_core::generate_feature_enabled_macro!(runtime_benchmarks_enabled, feature = "runtime-benchmarks", $);