Skip to content
Snippets Groups Projects
Commit f971474e authored by Nathaniel Bajo's avatar Nathaniel Bajo Committed by Christian Langenbacher
Browse files

Add view functions to Proxy pallet for runtime-specific type configuration #7297 (#7320)


Solves https://github.com/paritytech/polkadot-sdk/issues/7297

I added a ProxyApi runtime API to the Proxy pallet with two methods:

check_permissions: Checks if a RuntimeCall passes a ProxyType's
InstanceFilter.
is_superset: Verifies if one ProxyType includes another.




Polkadot address: 121HJWZtD13GJQPD82oEj3gSeHqsRYm1mFgRALu4L96kfPD1

---------

Co-authored-by: default avatarBastian Köcher <git@kchr.de>
Co-authored-by: default avatarBastian Köcher <info@kchr.de>
parent 5988794a
No related merge requests found
......@@ -41,3 +41,4 @@ substrate.code-workspace
target/
*.scale
justfile
rustc-ice-*
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
......@@ -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<T: Config> Pallet<T> {
/// Check if a `RuntimeCall` is allowed for a given `ProxyType`.
pub fn check_permissions(
call: <T as Config>::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<T: Config> Pallet<T> {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment