diff --git a/.gitignore b/.gitignore index d482876570857..4fe0701fde684 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ substrate.code-workspace target/ *.scale justfile +rustc-ice-* diff --git a/prdoc/pr_7320.prdoc b/prdoc/pr_7320.prdoc new file mode 100644 index 0000000000000..fe918a332118f --- /dev/null +++ b/prdoc/pr_7320.prdoc @@ -0,0 +1,14 @@ +title: Add view functions to Proxy pallet for runtime-specific type configuration. + +doc: +- audience: Runtime User + description: |- + Adds two view functions to `pallet-proxy`: + `check_permissions`: Checks if a given RuntimeCall is allowed for a specific ProxyType + using the InstanceFilter trait. + `is_superset`: Checks if one ProxyType is a superset of another ProxyType by comparing + them using the PartialOrd trait. + +crates: + - name: pallet-proxy + bump: minor diff --git a/substrate/frame/proxy/src/lib.rs b/substrate/frame/proxy/src/lib.rs index cc21db7469b20..1fe9772617221 100644 --- a/substrate/frame/proxy/src/lib.rs +++ b/substrate/frame/proxy/src/lib.rs @@ -37,7 +37,7 @@ extern crate alloc; use alloc::{boxed::Box, vec}; use frame::{ prelude::*, - traits::{Currency, ReservableCurrency}, + traits::{Currency, InstanceFilter, ReservableCurrency}, }; pub use pallet::*; pub use weights::WeightInfo; @@ -590,6 +590,22 @@ pub mod pallet { ), ValueQuery, >; + + #[pallet::view_functions_experimental] + impl Pallet { + /// Check if a `RuntimeCall` is allowed for a given `ProxyType`. + pub fn check_permissions( + call: ::RuntimeCall, + proxy_type: T::ProxyType, + ) -> bool { + proxy_type.filter(&call) + } + + /// Check if one `ProxyType` is a subset of another `ProxyType`. + pub fn is_superset(to_check: T::ProxyType, against: T::ProxyType) -> bool { + to_check.is_superset(&against) + } + } } impl Pallet {