Skip to content

Commit

Permalink
✅ add cargo test for program_client
Browse files Browse the repository at this point in the history
  • Loading branch information
lukacan committed Feb 7, 2024
1 parent 01d5070 commit 1efa8e4
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 41 deletions.
14 changes: 0 additions & 14 deletions crates/client/src/idl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,11 @@ pub enum Error {
MissingOrInvalidProgramItems(&'static str),
}

#[doc = r"Stores module name and it`s visibility"]
struct ModPub {
pub mod_name: String,
pub is_pub: bool,
}

#[doc = r"Stores important information for obtaining full path for custom types"]
struct FullPathFinder {
target_item_name: String,
current_module: String,
Expand Down Expand Up @@ -186,41 +184,30 @@ impl<'ast> syn::visit::Visit<'ast> for FullPathFinder {
}
}

#[doc = r"Wrapper through all programs specified within the Solana project"]
#[derive(Debug)]
pub struct Idl {
pub programs: Vec<IdlProgram>,
}

#[doc = r"Name struct for corresponding program"]
#[derive(Debug)]
pub struct IdlName {
pub snake_case: String,
pub upper_camel_case: String,
}

#[doc = r"IdlProgram struct which is generated for each program"]
#[doc = r"within the project"]
#[derive(Debug)]
pub struct IdlProgram {
pub name: IdlName,
pub id: String,
pub instruction_account_pairs: Vec<(IdlInstruction, IdlAccountGroup)>,
}

#[doc = r"IdlInstruction struct contains IdlName of struct"]
#[doc = r"and corresponding Vector of parameters with their "]
#[doc = r"types, for custom types such as Struct or Enum,"]
#[doc = r" full path is obtained"]
#[derive(Debug)]
pub struct IdlInstruction {
pub name: IdlName,
pub parameters: Vec<(String, String)>,
}

#[doc = r"IdlAccountGroup struct contains IdlName of struct"]
#[doc = r"(within Anchor framework perspective - Context), and"]
#[doc = r"corresponding Accounts with the types"]
#[derive(Debug)]
pub struct IdlAccountGroup {
pub name: IdlName,
Expand Down Expand Up @@ -656,7 +643,6 @@ pub async fn parse_to_idl_program(name: String, code: &str) -> Result<IdlProgram
})
}

#[doc = r"Recursively looks for '__client_accounts_' modules"]
fn set_account_modules(account_modules: &mut Vec<syn::ItemMod>, item_module: syn::ItemMod) {
if item_module
.ident
Expand Down
Loading

0 comments on commit 1efa8e4

Please sign in to comment.