1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use codec::{Decode, Encode, Output};
use frame_support::{sp_std::vec::Vec, RuntimeDebug};
use crate::{CallEncoder, PalletCall, PalletCallEncoder};
pub const POLKADOT_PALLET_UTILITY_INDEX: u8 = 26u8;
pub const KUSAMA_PALLET_UTILITY_INDEX: u8 = 24u8;
pub trait UtilityCallEncoder: PalletCallEncoder {}
impl<'a, 'b, Config> Encode for CallEncoder<'a, 'b, UtilityCall, Config>
where
Config: UtilityCallEncoder,
{
fn encode_to<T: Output + ?Sized>(&self, dest: &mut T) {
dest.push_byte(self.call.pallet_call_index());
self.call.encode_to(dest)
}
}
#[derive(Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
pub enum UtilityCall {
#[codec(index = 1)]
AsDerivative(u16, Vec<u8>),
#[codec(index = 2)]
BatchAll(Vec<Vec<u8>>),
}
impl PalletCall for UtilityCall {
fn pallet_call_index(&self) -> u8 {
match self {
UtilityCall::AsDerivative(_, _) => 1,
UtilityCall::BatchAll(_) => 2,
}
}
}