use crate::manifest::{ContractManifest, ManifestMethod};
pub(in super::super::super) fn find_manifest_entry_method(
manifest: &ContractManifest,
entry_offset: usize,
) -> Option<(&ManifestMethod, bool)> {
if let Some(method) = manifest
.abi
.methods
.iter()
.find(|method| offset_as_usize(method.offset) == Some(entry_offset))
{
return Some((method, true));
}
if manifest
.abi
.methods
.iter()
.any(|method| offset_as_usize(method.offset).is_some())
{
return None;
}
manifest.abi.methods.first().map(|method| (method, false))
}
pub(in super::super::super) fn offset_as_usize(offset: Option<i32>) -> Option<usize> {
offset.and_then(|v| usize::try_from(v).ok())
}