Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Refactor to read idl from target folder instead of parsing source #16

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,18 @@ impl WithPath<Config> {
.collect())
}

// TODO: this should read idl dir instead of parsing source.
pub fn read_all_programs(&self) -> Result<Vec<Program>> {
let mut r = vec![];
for path in self.get_program_list()? {
let cargo = Manifest::from_path(&path.join("Cargo.toml"))?;
let lib_name = cargo.lib_name()?;
let version = cargo.version();
let idl = anchor_syn::idl::file::parse(
path.join("src/lib.rs"),
version,
self.features.seeds,
false,
false,
)?;

let idl_filepath = format!("target/idl/{}.json", lib_name);
let idl = fs::read(idl_filepath)
.ok()
.map(|bytes| serde_json::from_reader(&*bytes))
.transpose()?;

r.push(Program {
lib_name,
path,
Expand Down