pallet_verify_signature/lib.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Transaction extension which validates a signature against a payload constructed from a call and
19//! the rest of the transaction extension pipeline.
20
21// Ensure we're `no_std` when compiling for Wasm.
22#![cfg_attr(not(feature = "std"), no_std)]
23
24#[cfg(feature = "runtime-benchmarks")]
25mod benchmarking;
26pub mod extension;
27#[cfg(test)]
28mod tests;
29pub mod weights;
30
31extern crate alloc;
32
33#[cfg(feature = "runtime-benchmarks")]
34pub use benchmarking::BenchmarkHelper;
35use codec::{Decode, Encode};
36pub use extension::VerifySignature;
37use frame_support::Parameter;
38pub use weights::WeightInfo;
39
40pub use pallet::*;
41
42#[frame_support::pallet]
43pub mod pallet {
44 use super::*;
45 use sp_runtime::traits::{IdentifyAccount, Verify};
46
47 #[pallet::pallet]
48 pub struct Pallet<T>(_);
49
50 /// Configuration trait.
51 #[pallet::config]
52 pub trait Config: frame_system::Config {
53 /// Signature type that the extension of this pallet can verify.
54 type Signature: Verify<Signer = Self::AccountIdentifier>
55 + Parameter
56 + Encode
57 + Decode
58 + Send
59 + Sync;
60 /// The account identifier used by this pallet's signature type.
61 type AccountIdentifier: IdentifyAccount<AccountId = Self::AccountId>;
62 /// Weight information for extrinsics in this pallet.
63 type WeightInfo: WeightInfo;
64 /// Helper to create a signature to be benchmarked.
65 #[cfg(feature = "runtime-benchmarks")]
66 type BenchmarkHelper: BenchmarkHelper<Self::Signature, Self::AccountId>;
67 }
68}