1use crate::{
11 client::ClientState,
12 config::{Config, HashFor},
13 error::ExtrinsicParamsError,
14};
15use alloc::vec::Vec;
16use core::any::Any;
17
18pub trait ExtrinsicParams<T: Config>: ExtrinsicParamsEncoder + Sized + Send + 'static {
22 type Params: Params<T>;
26
27 fn new(client: &ClientState<T>, params: Self::Params) -> Result<Self, ExtrinsicParamsError>;
29}
30
31pub trait ExtrinsicParamsEncoder: 'static {
35 fn encode_value_to(&self, _v: &mut Vec<u8>) {}
45
46 fn encode_signer_payload_value_to(&self, v: &mut Vec<u8>) {
49 self.encode_value_to(v);
50 }
51
52 fn encode_implicit_to(&self, _v: &mut Vec<u8>) {}
57
58 fn inject_signature(&mut self, _account_id: &dyn Any, _signature: &dyn Any) {}
72}
73
74pub trait Params<T: Config> {
78 fn inject_account_nonce(&mut self, _nonce: u64) {}
80 fn inject_block(&mut self, _number: u64, _hash: HashFor<T>) {}
82}
83
84impl<T: Config> Params<T> for () {}
85
86macro_rules! impl_tuples {
87 ($($ident:ident $index:tt),+) => {
88 impl <Conf: Config, $($ident : Params<Conf>),+> Params<Conf> for ($($ident,)+){
89 fn inject_account_nonce(&mut self, nonce: u64) {
90 $(self.$index.inject_account_nonce(nonce);)+
91 }
92
93 fn inject_block(&mut self, number: u64, hash: HashFor<Conf>) {
94 $(self.$index.inject_block(number, hash);)+
95 }
96 }
97 }
98}
99
100#[rustfmt::skip]
101const _: () = {
102 impl_tuples!(A 0);
103 impl_tuples!(A 0, B 1);
104 impl_tuples!(A 0, B 1, C 2);
105 impl_tuples!(A 0, B 1, C 2, D 3);
106 impl_tuples!(A 0, B 1, C 2, D 3, E 4);
107 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5);
108 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6);
109 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7);
110 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8);
111 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9);
112 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10);
113 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11);
114 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12);
115 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13);
116 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14);
117 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15);
118 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16);
119 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17);
120 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17, S 18);
121 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17, S 18, T 19);
122 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17, S 18, T 19, U 20);
123 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17, S 18, T 19, U 20, V 21);
124 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17, S 18, T 19, U 20, V 21, W 22);
125 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17, S 18, T 19, U 20, V 21, W 22, X 23);
126 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17, S 18, T 19, U 20, V 21, W 22, X 23, Y 24);
127 impl_tuples!(A 0, B 1, C 2, D 3, E 4, F 5, G 6, H 7, I 8, J 9, K 10, L 11, M 12, N 13, O 14, P 15, Q 16, R 17, S 18, T 19, U 20, V 21, W 22, X 23, Y 24, Z 25);
128};