subxt_core/blocks/static_extrinsic.rs
1// Copyright 2019-2024 Parity Technologies (UK) Ltd.
2// This file is dual-licensed as Apache-2.0 or GPL-3.0.
3// see LICENSE for license details.
4
5use scale_decode::DecodeAsFields;
6
7/// Trait to uniquely identify the extrinsic's identity from the runtime metadata.
8///
9/// Generated API structures that represent an extrinsic implement this trait.
10///
11/// The trait is utilized to decode emitted extrinsics from a block, via obtaining the
12/// form of the `Extrinsic` from the metadata.
13pub trait StaticExtrinsic: DecodeAsFields {
14 /// Pallet name.
15 const PALLET: &'static str;
16 /// Call name.
17 const CALL: &'static str;
18
19 /// Returns true if the given pallet and call names match this extrinsic.
20 fn is_extrinsic(pallet: &str, call: &str) -> bool {
21 Self::PALLET == pallet && Self::CALL == call
22 }
23}