hc_utils 0.6.1-rc.1

Helper functions for holochain hdk development
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use hdk::prelude::*;

/// Query for an existing Entry in the local source-chain matching the given EntryType name(s).  If
/// one exists, return it Address, otherwise returns error.
pub fn exists(value: Entry) -> ExternResult<ActionHash> {
    for record in super::local_source_chain().unwrap() {
        if let RecordEntry::Present(entry) = record.entry() {
            if entry.clone() == value {
                return Ok(record.action_address().clone());
            }
        }
    }
    return Err(wasm_error!(WasmErrorInner::Guest(
        "Unable to find entry in dht".to_string()
    )));
}