Add correct Sign Extensions to Glutton parachain (#2656)

* add correct sign extensions

* remove warnings
This commit is contained in:
Ignacio Palacios
2023-05-31 11:49:33 +02:00
committed by GitHub
parent 0c5038e556
commit afed8139a3
@@ -46,15 +46,12 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
pub mod weights; pub mod weights;
pub mod xcm_config; pub mod xcm_config;
use codec::{Decode, Encode};
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use frame_support::unsigned::TransactionValidityError;
use scale_info::TypeInfo;
use sp_api::impl_runtime_apis; use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, create_runtime_str, generic,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, DispatchInfoOf}, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT},
transaction_validity::{TransactionSource, TransactionValidity}, transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, ApplyExtrinsicResult,
}; };
@@ -222,41 +219,6 @@ construct_runtime! {
} }
} }
/// Simple implementation which fails any transaction which is signed.
#[derive(Eq, PartialEq, Clone, Default, sp_core::RuntimeDebug, Encode, Decode, TypeInfo)]
pub struct DisallowSigned;
impl sp_runtime::traits::SignedExtension for DisallowSigned {
const IDENTIFIER: &'static str = "DisallowSigned";
type AccountId = AccountId;
type Call = RuntimeCall;
type AdditionalSigned = ();
type Pre = ();
fn additional_signed(
&self,
) -> sp_std::result::Result<(), sp_runtime::transaction_validity::TransactionValidityError> {
Ok(())
}
fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &DispatchInfoOf<Self::Call>,
len: usize,
) -> Result<Self::Pre, TransactionValidityError> {
self.validate(who, call, info, len).map(|_| ())
}
fn validate(
&self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &sp_runtime::traits::DispatchInfoOf<Self::Call>,
_len: usize,
) -> TransactionValidity {
let i = sp_runtime::transaction_validity::InvalidTransaction::BadProof;
Err(sp_runtime::transaction_validity::TransactionValidityError::Invalid(i))
}
}
/// Index of a transaction in the chain. /// Index of a transaction in the chain.
pub type Index = u32; pub type Index = u32;
/// A hash of some data used by the chain. /// A hash of some data used by the chain.
@@ -274,7 +236,15 @@ pub type SignedBlock = generic::SignedBlock<Block>;
/// BlockId type as expected by this runtime. /// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>; pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic. /// The SignedExtension to the basic transaction logic.
pub type SignedExtra = DisallowSigned; pub type SignedExtra = (
pallet_sudo::CheckOnlySudoAccount<Runtime>,
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>,
);
/// Unchecked extrinsic type as expected by this runtime. /// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>; generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;