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 serde::{Deserialize, Serialize};
use crate::{
idl_error_code::IdlErrorCode, idl_instruction::IdlInstruction, idl_metadata::IdlMetadata,
};
use super::{idl_type::IdlType, idl_type_definition::IdlTypeDefinition};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct Idl {
pub version: String,
pub name: String,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub constants: Vec<IdlConst>,
pub instructions: Vec<IdlInstruction>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub state: Option<IdlState>,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub accounts: Vec<IdlTypeDefinition>,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub types: Vec<IdlTypeDefinition>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub events: Option<Vec<IdlEvent>>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub errors: Option<Vec<IdlErrorCode>>,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub metadata: Option<IdlMetadata>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct IdlConst {
pub name: String,
#[serde(rename = "type")]
pub ty: IdlType,
pub value: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct IdlState {
#[serde(rename = "struct")]
pub strct: IdlTypeDefinition,
pub methods: Vec<IdlInstruction>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct IdlEvent {
pub name: String,
pub fields: Vec<IdlEventField>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct IdlEventField {
pub name: String,
#[serde(rename = "type")]
pub ty: IdlType,
pub index: bool,
}