1mod default_extrinsic_params;
12mod extrinsic_params;
13mod refine_params;
14
15pub mod polkadot;
16pub mod signed_extensions;
17pub mod substrate;
18
19use codec::{Decode, Encode};
20use core::fmt::Debug;
21use scale_decode::DecodeAsType;
22use scale_encode::EncodeAsType;
23use serde::{de::DeserializeOwned, Serialize};
24
25pub use default_extrinsic_params::{DefaultExtrinsicParams, DefaultExtrinsicParamsBuilder};
26pub use extrinsic_params::{ExtrinsicParams, ExtrinsicParamsEncoder};
27pub use polkadot::{PolkadotConfig, PolkadotExtrinsicParams, PolkadotExtrinsicParamsBuilder};
28pub use refine_params::{RefineParams, RefineParamsData};
29pub use signed_extensions::SignedExtension;
30pub use substrate::{SubstrateConfig, SubstrateExtrinsicParams, SubstrateExtrinsicParamsBuilder};
31
32pub trait Config: Sized + Send + Sync + 'static {
38 type Hash: BlockHash;
40
41 type AccountId: Debug + Clone + Encode;
43
44 type Address: Debug + Encode + From<Self::AccountId>;
46
47 type Signature: Debug + Encode;
49
50 type Hasher: Debug + Hasher<Output = Self::Hash>;
52
53 type Header: Debug + Header<Hasher = Self::Hasher> + Sync + Send + DeserializeOwned;
55
56 type ExtrinsicParams: ExtrinsicParams<Self>;
58
59 type AssetId: Debug + Clone + Encode + DecodeAsType + EncodeAsType + Send;
61}
62
63pub type ParamsFor<T> = <<T as Config>::ExtrinsicParams as ExtrinsicParams<T>>::Params;
65
66pub trait BlockHash:
68 Debug
69 + Copy
70 + Send
71 + Sync
72 + Decode
73 + AsRef<[u8]>
74 + Serialize
75 + DeserializeOwned
76 + Encode
77 + PartialEq
78 + Eq
79 + core::hash::Hash
80{
81}
82impl<T> BlockHash for T where
83 T: Debug
84 + Copy
85 + Send
86 + Sync
87 + Decode
88 + AsRef<[u8]>
89 + Serialize
90 + DeserializeOwned
91 + Encode
92 + PartialEq
93 + Eq
94 + core::hash::Hash
95{
96}
97
98pub trait Hasher {
101 type Output;
103
104 fn hash(s: &[u8]) -> Self::Output;
106
107 fn hash_of<S: Encode>(s: &S) -> Self::Output {
109 let out = s.encode();
110 Self::hash(&out)
111 }
112}
113
114pub trait Header: Sized + Encode + Decode {
116 type Number: Into<u64>;
118 type Hasher: Hasher;
120
121 fn number(&self) -> Self::Number;
123
124 fn hash(&self) -> <Self::Hasher as Hasher>::Output {
126 Self::Hasher::hash_of(self)
127 }
128}