Skip to content

Commit

Permalink
refactor: eliminate duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 committed Apr 20, 2024
1 parent bbb68d1 commit d3d0091
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
14 changes: 14 additions & 0 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,18 @@ pub mod proxy {
Self::Any
}
}

impl ProxyType {
pub fn is_superset(s: &ProxyType, o: &ProxyType) -> bool {
match (s, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
(ProxyType::Assets, ProxyType::AssetOwner) => true,
(ProxyType::Assets, ProxyType::AssetManager) => true,
(ProxyType::NonTransfer, ProxyType::Collator) => true,
_ => false,
}
}
}
}
10 changes: 1 addition & 9 deletions runtime/devnet/src/proxy_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
}

fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
(ProxyType::Assets, ProxyType::AssetOwner) => true,
(ProxyType::Assets, ProxyType::AssetManager) => true,
(ProxyType::NonTransfer, ProxyType::Collator) => true,
_ => false,
}
ProxyType::is_superset(self, o)
}
}

Expand Down
10 changes: 1 addition & 9 deletions runtime/testnet/src/proxy_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
}

fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
(ProxyType::Assets, ProxyType::AssetOwner) => true,
(ProxyType::Assets, ProxyType::AssetManager) => true,
(ProxyType::NonTransfer, ProxyType::Collator) => true,
_ => false,
}
ProxyType::is_superset(self, o)
}
}

Expand Down

0 comments on commit d3d0091

Please sign in to comment.