Skip to content

Commit

Permalink
Fix IDL struct (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanMarchetto authored Jun 25, 2023
1 parent 3d5feed commit 6e250fb
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crate/src/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,34 +96,40 @@ pub struct Instruction {
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Accounts {
pub(crate) name: String,
#[serde(default)]
#[serde(rename = "type")]
pub(crate) type_: Type,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Types {
pub(crate) name: String,
#[serde(default)]
#[serde(rename = "type")]
pub(crate) type_: Kind,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Event {
pub(crate) name: String,
#[serde(default)]
pub(crate) fields: Vec<Field>,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct ErrorDesc {
pub(crate) code: u64,
pub(crate) name: String,
#[serde(default)]
pub(crate) msg: String,
}

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct InstructionAccount {
pub(crate) name: String,
#[serde(default)]
pub(crate) isMut: bool,
#[serde(default)]
pub(crate) isSigner: bool,
#[serde(default)]
pub(crate) pda: PDA,
Expand All @@ -142,13 +148,31 @@ pub struct Type {
pub(crate) fields: Vec<TypeFields>,
}

impl Default for Type {
fn default() -> Self {
Type {
kind: "struct".to_string(),
fields: [].to_vec(),
}
}
}

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Kind {
pub(crate) kind: String,
#[serde(default)]
pub(crate) variants: Vec<Name>,
}

impl Default for Kind {
fn default() -> Self {
Kind {
kind: "struct".to_string(),
variants: [].to_vec(),
}
}
}

#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Field {
pub(crate) name: String,
Expand Down

0 comments on commit 6e250fb

Please sign in to comment.