Skip to content
Snippets Groups Projects
Unverified Commit 295165af authored by Muharem Ismailov's avatar Muharem Ismailov
Browse files

meta tx marker

parent 7bb21759
Branches
No related merge requests found
Pipeline #511479 waiting for manual action with stages
in 7 minutes and 55 seconds
......@@ -30929,6 +30929,7 @@ dependencies = [
"pallet-transaction-payment-rpc-runtime-api 28.0.0",
"pallet-treasury 27.0.0",
"pallet-utility 28.0.0",
"pallet-verify-signature",
"pallet-vesting 28.0.0",
"pallet-whitelist 27.0.0",
"pallet-xcm 7.0.0",
......
......@@ -97,6 +97,7 @@ pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
pallet-utility = { workspace = true }
pallet-verify-signature = { workspace = true }
pallet-vesting = { workspace = true }
pallet-whitelist = { workspace = true }
pallet-xcm = { workspace = true }
......
......@@ -1588,6 +1588,8 @@ impl OnSwap for SwapLeases {
}
pub type MetaTxExtension = (
pallet_verify_signature::VerifySignature<Runtime>,
pallet_meta_tx::MetaTxMarker<Runtime>,
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
......
......@@ -2357,6 +2357,8 @@ impl pallet_parameters::Config for Runtime {
}
pub type MetaTxExtension = (
pallet_verify_signature::VerifySignature<Runtime>,
pallet_meta_tx::MetaTxMarker<Runtime>,
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
......
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use super::*;
use sp_runtime::impl_tx_ext_default;
/// This type serves as a marker extension to differentiate meta-transactions from regular
/// transactions. It implements the `TransactionExtension` trait and carries constant implicit data
/// ("_meta_tx").
#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo, DebugNoBound)]
#[scale_info(skip_type_params(T))]
pub struct MetaTxMarker<T> {
_phantom: core::marker::PhantomData<T>,
}
impl<T> MetaTxMarker<T> {
/// Creates new `TransactionExtension` with implicit meta tx marked.
pub fn new() -> Self {
Self { _phantom: Default::default() }
}
}
impl<T: Config + Send + Sync> TransactionExtension<T::RuntimeCall> for MetaTxMarker<T> {
const IDENTIFIER: &'static str = "MetaTxMarker";
type Implicit = [u8; 8];
type Val = ();
type Pre = ();
fn implicit(&self) -> Result<Self::Implicit, TransactionValidityError> {
Ok(*b"_meta_tx")
}
fn weight(&self, _: &T::RuntimeCall) -> Weight {
Weight::zero()
}
impl_tx_ext_default!(T::RuntimeCall; validate prepare);
}
......@@ -62,6 +62,8 @@ pub mod weights;
pub use benchmarking::types::WeightlessExtension;
pub use pallet::*;
pub use weights::WeightInfo;
mod extension;
pub use extension::MetaTxMarker;
use core::ops::Add;
use frame_support::{
......
......@@ -76,6 +76,7 @@ mod tx_ext {
///
/// Helper type used to decode the part of the extension which should be signed.
pub type MetaTxBareExtension = (
MetaTxMarker<Runtime>,
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
......
......@@ -45,6 +45,7 @@ fn create_tx_bare_ext(account: AccountId) -> TxBareExtension {
pub fn create_meta_tx_bare_ext(account: AccountId) -> MetaTxBareExtension {
(
MetaTxMarker::new(),
frame_system::CheckNonZeroSender::<Runtime>::new(),
frame_system::CheckSpecVersion::<Runtime>::new(),
frame_system::CheckTxVersion::<Runtime>::new(),
......
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