1mod default_extrinsic_params;
12mod extrinsic_params;
13
14pub mod polkadot;
15pub mod substrate;
16pub mod transaction_extensions;
17
18use codec::{Decode, Encode};
19use core::fmt::Debug;
20use scale_decode::DecodeAsType;
21use scale_encode::EncodeAsType;
22use serde::{Serialize, de::DeserializeOwned};
23use subxt_metadata::Metadata;
24
25pub use default_extrinsic_params::{DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
26pub use extrinsic_params::{ExtrinsicParams, ExtrinsicParamsEncoder};
27pub use polkadot::{PolkadotConfig, PolkadotExtrinsicParams, PolkadotExtrinsicParamsBuilder};
28pub use substrate::{SubstrateConfig, SubstrateExtrinsicParams, SubstrateExtrinsicParamsBuilder};
29pub use transaction_extensions::TransactionExtension;
30
31pub trait Config: Sized + Send + Sync + 'static {
37 type AccountId: Debug + Clone + Encode + Decode + Serialize + Send;
39
40 type Address: Debug + Encode + From<Self::AccountId>;
42
43 type Signature: Debug + Clone + Encode + Decode + Send;
45
46 type Hasher: Debug + Clone + Copy + Hasher + Send + Sync;
48
49 type Header: Debug + Header<Hasher = Self::Hasher> + Sync + Send + DeserializeOwned + Clone;
51
52 type ExtrinsicParams: ExtrinsicParams<Self>;
54
55 type AssetId: Debug + Clone + Encode + DecodeAsType + EncodeAsType + Send;
57}
58
59pub type HashFor<T> = <<T as Config>::Hasher as Hasher>::Output;
61
62pub type ParamsFor<T> = <<T as Config>::ExtrinsicParams as ExtrinsicParams<T>>::Params;
64
65pub trait Hash:
67 Debug
68 + Copy
69 + Send
70 + Sync
71 + Decode
72 + AsRef<[u8]>
73 + Serialize
74 + DeserializeOwned
75 + Encode
76 + PartialEq
77 + Eq
78 + core::hash::Hash
79{
80}
81impl<T> Hash for T where
82 T: Debug
83 + Copy
84 + Send
85 + Sync
86 + Decode
87 + AsRef<[u8]>
88 + Serialize
89 + DeserializeOwned
90 + Encode
91 + PartialEq
92 + Eq
93 + core::hash::Hash
94{
95}
96
97pub trait Hasher {
100 type Output: Hash;
102
103 fn new(metadata: &Metadata) -> Self;
105
106 fn hash(&self, s: &[u8]) -> Self::Output;
108
109 fn hash_of<S: Encode>(&self, s: &S) -> Self::Output {
111 let out = s.encode();
112 self.hash(&out)
113 }
114}
115
116pub trait Header: Sized + Encode + Decode {
118 type Number: Into<u64>;
120 type Hasher: Hasher;
122
123 fn number(&self) -> Self::Number;
125
126 fn hash_with(&self, hasher: Self::Hasher) -> <Self::Hasher as Hasher>::Output {
128 hasher.hash_of(self)
129 }
130}