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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use alloc::{fmt, vec::Vec};
use codec::{Decode, Encode};
use crate::*;
pub trait RuntimeTraits: Clone + Encode + Decode + fmt::Debug {}
impl<T> RuntimeTraits for T where T: Clone + Encode + Decode + fmt::Debug {}
pub trait ChainApi {
type RuntimeCall: RuntimeTraits;
type RuntimeEvent: RuntimeTraits;
type DispatchInfo: RuntimeTraits;
type DispatchError: RuntimeTraits;
}
pub struct Call {
call: Vec<u8>,
}
impl Call {
pub fn new(call: Vec<u8>) -> Self {
Self { call }
}
pub fn encoded(&self) -> Encoded {
Encoded(self.call.clone())
}
pub fn submit(&self) -> Result<()> {
let runtime = polymesh_extension::new_instance();
Ok(runtime.call_runtime(self.into())?)
}
}
impl Encode for Call {
fn size_hint(&self) -> usize {
self.call.len()
}
fn encode_to<T: ::codec::Output + ?Sized>(&self, dest: &mut T) {
dest.write(&self.call);
}
}
impl fmt::Debug for Call {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.call.fmt(f)
}
}