-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathevent_abi.rs
More file actions
39 lines (35 loc) · 933 Bytes
/
event_abi.rs
File metadata and controls
39 lines (35 loc) · 933 Bytes
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
use super::*;
use alloc::{
string::{String, ToString},
vec::Vec,
};
#[derive(Clone, Debug, PartialEq)]
pub struct EventInputAbi {
pub arg_name: String,
pub type_name: TypeName,
pub indexed: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub struct EventAbi {
pub docs: Vec<String>,
pub identifier: String,
pub inputs: Vec<EventInputAbi>,
}
impl EventAbi {
/// Used in code generation.
pub fn new(docs: &[&str], identifier: &str) -> Self {
EventAbi {
docs: docs.iter().map(|s| s.to_string()).collect(),
identifier: identifier.to_string(),
inputs: Vec::new(),
}
}
/// Used in code generation.
pub fn add_input<T: TypeAbi>(&mut self, arg_name: &str, indexed: bool) {
self.inputs.push(EventInputAbi {
arg_name: arg_name.to_string(),
type_name: T::type_name(),
indexed,
});
}
}