Skip to content
Snippets Groups Projects
Commit f31e3083 authored by Éloïs's avatar Éloïs
Browse files

fix(proxy): some calls should never be authorized from proxy

parent 52ebb5ef
No related branches found
No related tags found
No related merge requests found
...@@ -159,19 +159,25 @@ impl Contains<Call> for BaseCallFilter { ...@@ -159,19 +159,25 @@ impl Contains<Call> for BaseCallFilter {
)] )]
#[allow(clippy::unnecessary_cast)] #[allow(clippy::unnecessary_cast)]
pub enum ProxyType { pub enum ProxyType {
Any = 0, AlmostAny = 0,
TransferOnly = 1, TransferOnly = 1,
CancelProxy = 2, CancelProxy = 2,
} }
impl Default for ProxyType { impl Default for ProxyType {
fn default() -> Self { fn default() -> Self {
Self::Any Self::AlmostAny
} }
} }
impl frame_support::traits::InstanceFilter<Call> for ProxyType { impl frame_support::traits::InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool { fn filter(&self, c: &Call) -> bool {
match self { match self {
ProxyType::Any => true, ProxyType::AlmostAny => {
// Some calls are never authorized from a proxied account
!matches!(
c,
Call::Cert(..) | Call::Identity(..) | Call::SmithsCert(..)
)
}
ProxyType::TransferOnly => { ProxyType::TransferOnly => {
matches!(c, Call::Balances(..) | Call::UniversalDividend(..)) matches!(c, Call::Balances(..) | Call::UniversalDividend(..))
} }
......
...@@ -181,20 +181,26 @@ impl Contains<Call> for BaseCallFilter { ...@@ -181,20 +181,26 @@ impl Contains<Call> for BaseCallFilter {
)] )]
#[allow(clippy::unnecessary_cast)] #[allow(clippy::unnecessary_cast)]
pub enum ProxyType { pub enum ProxyType {
Any = 0, AlmostAny = 0,
TransferOnly = 1, TransferOnly = 1,
CancelProxy = 2, CancelProxy = 2,
SmithsCollectivePropose = 3, SmithsCollectivePropose = 3,
} }
impl Default for ProxyType { impl Default for ProxyType {
fn default() -> Self { fn default() -> Self {
Self::Any Self::AlmostAny
} }
} }
impl frame_support::traits::InstanceFilter<Call> for ProxyType { impl frame_support::traits::InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool { fn filter(&self, c: &Call) -> bool {
match self { match self {
ProxyType::Any => true, ProxyType::AlmostAny => {
// Some calls are never authorized from a proxied account
!matches!(
c,
Call::Cert(..) | Call::Identity(..) | Call::SmithsCert(..)
)
}
ProxyType::TransferOnly => { ProxyType::TransferOnly => {
matches!(c, Call::Balances(..) | Call::UniversalDividend(..)) matches!(c, Call::Balances(..) | Call::UniversalDividend(..))
} }
......
...@@ -71,7 +71,7 @@ fn verify_pallet_indices() { ...@@ -71,7 +71,7 @@ fn verify_pallet_indices() {
#[test] #[test]
fn verify_proxy_type_indices() { fn verify_proxy_type_indices() {
assert_eq!(ProxyType::Any as u8, 0); assert_eq!(ProxyType::AlmostAny as u8, 0);
} }
#[test] #[test]
......
...@@ -160,19 +160,25 @@ impl Contains<Call> for BaseCallFilter { ...@@ -160,19 +160,25 @@ impl Contains<Call> for BaseCallFilter {
)] )]
#[allow(clippy::unnecessary_cast)] #[allow(clippy::unnecessary_cast)]
pub enum ProxyType { pub enum ProxyType {
Any = 0, AlmostAny = 0,
TransferOnly = 1, TransferOnly = 1,
CancelProxy = 2, CancelProxy = 2,
} }
impl Default for ProxyType { impl Default for ProxyType {
fn default() -> Self { fn default() -> Self {
Self::Any Self::AlmostAny
} }
} }
impl frame_support::traits::InstanceFilter<Call> for ProxyType { impl frame_support::traits::InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool { fn filter(&self, c: &Call) -> bool {
match self { match self {
ProxyType::Any => true, ProxyType::AlmostAny => {
// Some calls are never authorized from a proxied account
!matches!(
c,
Call::Cert(..) | Call::Identity(..) | Call::SmithsCert(..)
)
}
ProxyType::TransferOnly => { ProxyType::TransferOnly => {
matches!(c, Call::Balances(..) | Call::UniversalDividend(..)) matches!(c, Call::Balances(..) | Call::UniversalDividend(..))
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment