git.delta.rocks / unique-network / refs/commits / 90bf3a397212

difftreelog

chore add using for `collator-selection`

Grigoriy Simonov2023-01-09parent: #0f4242c.patch.diff
in: master

1 file changed

modifiedruntime/common/identity.rsdiffbeforeafterboth
before · runtime/common/identity.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use scale_info::TypeInfo;18use codec::{Encode, Decode};19use up_common::types::AccountId;20use crate::RuntimeCall;2122use sp_runtime::{23	traits::{DispatchInfoOf, SignedExtension},24	transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},25};2627#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]28pub struct DisableIdentityCalls;2930impl SignedExtension for DisableIdentityCalls {31	type AccountId = AccountId;32	type Call = RuntimeCall;33	type AdditionalSigned = ();34	type Pre = ();3536	const IDENTIFIER: &'static str = "DisableIdentityCalls";3738	fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {39		Ok(())40	}4142	fn pre_dispatch(43		self,44		who: &Self::AccountId,45		call: &Self::Call,46		info: &DispatchInfoOf<Self::Call>,47		len: usize,48	) -> Result<Self::Pre, TransactionValidityError> {49		self.validate(who, call, info, len).map(|_| ())50	}5152	fn validate(53		&self,54		_who: &Self::AccountId,55		call: &Self::Call,56		_info: &DispatchInfoOf<Self::Call>,57		_len: usize,58	) -> TransactionValidity {59		match call {60			#[cfg(feature = "collator-selection")]61			RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),62			_ => Ok(ValidTransaction::default()),63		}64	}65}
after · runtime/common/identity.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use scale_info::TypeInfo;18use codec::{Encode, Decode};19use up_common::types::AccountId;20use crate::RuntimeCall;2122use sp_runtime::{23	traits::{DispatchInfoOf, SignedExtension},24	transaction_validity::{TransactionValidity, ValidTransaction, TransactionValidityError},25};26#[cfg(feature = "collator-selection")]27use sp_runtime::transaction_validity::InvalidTransaction;2829#[derive(Debug, Encode, Decode, PartialEq, Eq, Clone, TypeInfo)]30pub struct DisableIdentityCalls;3132impl SignedExtension for DisableIdentityCalls {33	type AccountId = AccountId;34	type Call = RuntimeCall;35	type AdditionalSigned = ();36	type Pre = ();3738	const IDENTIFIER: &'static str = "DisableIdentityCalls";3940	fn additional_signed(&self) -> Result<Self::AdditionalSigned, TransactionValidityError> {41		Ok(())42	}4344	fn pre_dispatch(45		self,46		who: &Self::AccountId,47		call: &Self::Call,48		info: &DispatchInfoOf<Self::Call>,49		len: usize,50	) -> Result<Self::Pre, TransactionValidityError> {51		self.validate(who, call, info, len).map(|_| ())52	}5354	fn validate(55		&self,56		_who: &Self::AccountId,57		call: &Self::Call,58		_info: &DispatchInfoOf<Self::Call>,59		_len: usize,60	) -> TransactionValidity {61		match call {62			#[cfg(feature = "collator-selection")]63			RuntimeCall::Identity(_) => Err(TransactionValidityError::Invalid(InvalidTransaction::Call)),64			_ => Ok(ValidTransaction::default()),65		}66	}67}