Skip to content
Open
Show file tree
Hide file tree
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
74 changes: 72 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions hyperstack-idl/src/analysis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Analysis utilities

pub mod connect;
pub mod relations;
pub mod pda_graph;
pub mod relations;
pub mod type_graph;

pub use connect::*;
pub use relations::*;
pub use pda_graph::*;
pub use relations::*;
pub use type_graph::*;
6 changes: 1 addition & 5 deletions hyperstack-idl/src/analysis/pda_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ pub fn extract_pda_graph(idl: &IdlSpec) -> Vec<PdaNode> {
for ix in &idl.instructions {
for acc in &ix.accounts {
if let Some(pda) = &acc.pda {
let seeds = pda
.seeds
.iter()
.map(extract_seed_info)
.collect();
let seeds = pda.seeds.iter().map(extract_seed_info).collect();

nodes.push(PdaNode {
account_name: acc.name.clone(),
Expand Down
6 changes: 3 additions & 3 deletions hyperstack-idl/src/discriminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn compute_discriminator(namespace: &str, name: &str) -> [u8; 8] {
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_discriminator_global_initialize() {
// Known Anchor discriminator for "global:initialize"
Expand All @@ -38,15 +38,15 @@ mod tests {
assert_eq!(disc.len(), 8);
assert!(disc.iter().any(|&b| b != 0));
}

#[test]
fn test_discriminator_consistency() {
// Same inputs always produce same output
let disc1 = compute_discriminator("global", "deposit");
let disc2 = compute_discriminator("global", "deposit");
assert_eq!(disc1, disc2);
}

#[test]
fn test_discriminator_different_names() {
// Different names produce different discriminators
Expand Down
30 changes: 27 additions & 3 deletions hyperstack-idl/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,44 @@ impl std::fmt::Display for IdlSearchError {
input,
section,
suggestions,
..
available,
} => {
write!(f, "Not found: '{}' in {}", input, section)?;
if !suggestions.is_empty() {
write!(f, ". Did you mean: {}?", suggestions[0].candidate)?;
} else if !available.is_empty() {
let preview = available
.iter()
.take(5)
.cloned()
.collect::<Vec<_>>()
.join(", ");
write!(f, ". {}: {}", available_label(section), preview)?;
}
Ok(())
}
IdlSearchError::ParseError { path, source } => {
write!(f, "Parse error in {}: {}", path, source)
write!(f, "Failed to parse '{}': {}", path, source)
}
IdlSearchError::InvalidPath { path } => {
write!(
f,
"Invalid path '{}'. Expected a Rust path like foo::bar::Baz",
path
)
}
IdlSearchError::InvalidPath { path } => write!(f, "Invalid path: {}", path),
}
}
}

impl std::error::Error for IdlSearchError {}

fn available_label(section: &str) -> String {
if section.starts_with("instruction fields") {
"Available instruction fields".to_string()
} else if section.starts_with("account fields") {
"Available account fields".to_string()
} else {
format!("Available {}", section)
}
}
Loading
Loading