From badb7d7ababdcc4a6633ff4d271dead4a5c0f28c Mon Sep 17 00:00:00 2001 From: damien Date: Mon, 1 Jul 2024 09:10:37 -0400 Subject: [PATCH] get_latest_record() --- src/get.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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), + } + }, + } +}