solana_idl_classic/
idl.rs1use serde::{Deserialize, Serialize};
2
3use super::{idl_type::IdlType, idl_type_definition::IdlTypeDefinition};
4use crate::{
5 idl_error_code::IdlErrorCode, idl_instruction::IdlInstruction,
6 idl_metadata::IdlMetadata,
7};
8
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
11pub struct Idl {
12 pub version: String,
14
15 pub name: String,
17
18 #[serde(skip_serializing_if = "Vec::is_empty", default)]
20 pub constants: Vec<IdlConst>,
21
22 pub instructions: Vec<IdlInstruction>,
24
25 #[serde(skip_serializing_if = "Option::is_none", default)]
27 pub state: Option<IdlState>,
28
29 #[serde(skip_serializing_if = "Vec::is_empty", default)]
31 pub accounts: Vec<IdlTypeDefinition>,
32
33 #[serde(skip_serializing_if = "Vec::is_empty", default)]
35 pub types: Vec<IdlTypeDefinition>,
36
37 #[serde(skip_serializing_if = "Option::is_none", default)]
39 pub events: Option<Vec<IdlEvent>>,
40
41 #[serde(skip_serializing_if = "Option::is_none", default)]
43 pub errors: Option<Vec<IdlErrorCode>>,
44
45 #[serde(skip_serializing_if = "Option::is_none", default)]
47 pub metadata: Option<IdlMetadata>,
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
52pub struct IdlConst {
53 pub name: String,
54 #[serde(rename = "type")]
55 pub ty: IdlType,
56 pub value: String,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
61pub struct IdlState {
62 #[serde(rename = "struct")]
63 pub strct: IdlTypeDefinition,
64 pub methods: Vec<IdlInstruction>,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
69pub struct IdlEvent {
70 pub name: String,
71 pub fields: Vec<IdlEventField>,
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
76pub struct IdlEventField {
77 pub name: String,
78 #[serde(rename = "type")]
79 pub ty: IdlType,
80 pub index: bool,
81}