diff --git a/src/get.rs b/src/get.rs index 6da8d8d..aa555d8 100644 --- a/src/get.rs +++ b/src/get.rs @@ -307,4 +307,21 @@ pub fn get_latest_entry(target: EntryHash, option: GetOptions) -> ExternResult ExternResult { + let Some(details) = get_details(action_hash, GetOptions::default())? + else { return zome_error!("Record not found")}; + match details { + Details::Entry(_) => zome_error!("Malformed details"), + Details::Record(element_details) => { + match element_details.updates.last() { + Some(update) => get_latest_record(update.action_address().clone()), + None => Ok(element_details.record), + } + }, + } +}