Skip to content

Commit

Permalink
feat: add doc strings getter to FullABIFunction (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
hal3e authored May 27, 2024
1 parent c80a52c commit 8ab2888
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/abi/full_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
};

use crate::{
error::{error, Result},
error::{error, Error, Result},
utils::TypePath,
};

Expand Down Expand Up @@ -121,6 +121,20 @@ impl FullABIFunction {
self.attributes.iter().any(|attr| attr.name == "payable")
}

pub fn doc_strings(&self) -> Result<Vec<String>> {
self.attributes
.iter()
.filter(|attr| attr.name == "doc-comment")
.map(|attr| {
(attr.arguments.len() == 1)
.then_some(attr.arguments[0].clone())
.ok_or_else(|| {
Error("`doc-comment` attribute must have one argument".to_string())
})
})
.collect::<Result<Vec<String>>>()
}

pub fn from_counterpart(
abi_function: &ABIFunction,
types: &HashMap<usize, TypeDeclaration>,
Expand Down

0 comments on commit 8ab2888

Please sign in to comment.