From 0d42a9f8414a8413a15fd8b7f18e88d12b89f413 Mon Sep 17 00:00:00 2001 From: doordashcon Date: Thu, 20 Nov 2025 12:30:45 -0300 Subject: [PATCH] add AssetCategoryManager --- substrate/frame/treasury/src/lib.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/substrate/frame/treasury/src/lib.rs b/substrate/frame/treasury/src/lib.rs index 06dfd0e93e7b3..6bfa137e7b428 100644 --- a/substrate/frame/treasury/src/lib.rs +++ b/substrate/frame/treasury/src/lib.rs @@ -195,6 +195,11 @@ pub enum PaymentState { Failed, } +pub enum SpendAsset { + Specific(AssetKind), + Category(BoundedVec>), // e.g., "USD*", "EUR*" +} + /// Info regarding an approved treasury spend. #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] #[derive( @@ -209,8 +214,9 @@ pub enum PaymentState { TypeInfo, )] pub struct SpendStatus { - // The kind of asset to be spent. - pub asset_kind: AssetKind, + pub asset: SpendAsset, + // The kind of asset to be spent. + //pub asset_kind: AssetKind, /// The asset amount of the spend. pub amount: AssetBalance, /// The beneficiary of the spend. @@ -223,6 +229,17 @@ pub struct SpendStatus, } +/// Trait for managing asset categories +pub trait AssetCategoryManager { + type AssetKind; + + /// Get all assets in a category + fn assets_in_category(category: &[u8]) -> Vec; + + /// Optional: Check if an asset belongs to a category + fn is_asset_in_category(asset: &Self::AssetKind, category: &[u8]) -> bool; +} + /// Index of an approved treasury spend. pub type SpendIndex = u32; @@ -318,6 +335,8 @@ pub mod pallet { /// Provider for the block number. Normally this is the `frame_system` pallet. type BlockNumberProvider: BlockNumberProvider; + + type AssetCategories: AssetCategoryManager; } #[pallet::extra_constants]