Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use product_common::bindings::utils::parse_wasm_object_id;
use product_common::bindings::WasmObjectID;
use product_common::core_client::CoreClientReadOnly;
use wasm_bindgen::prelude::*;

use notarization::core::types::OnChainNotarization;
use notarization::error::Error;
use crate::wasm_notarization::WasmOnChainNotarization;
use crate::wasm_types::{WasmLockMetadata, WasmNotarizationMethod, WasmState};

/// A client to interact with Notarization objects on the IOTA ledger.
Expand Down Expand Up @@ -112,6 +114,26 @@ impl WasmNotarizationClientReadOnly {
self.0.chain_id().to_string()
}

/// Retrieves the [`OnChainNotarization`] of a notarized object.
///
/// This method returns the on-chain notarization object for the given object ID.
///
/// # Arguments
///
/// * `notarized_object_id`: The [`ObjectID`] of the notarized object.
///
/// # Returns
/// A `Result` containing the [`OnChainNotarization`] or an [`Error`].
#[wasm_bindgen(js_name = getNotarizationById)]
Comment thread
itsyaasir marked this conversation as resolved.
pub async fn get_notarization_by_id(&self, notarized_object_id: WasmObjectID) -> Result<WasmOnChainNotarization> {
let notarized_object_id = parse_wasm_object_id(&notarized_object_id)?;
self.0
.get_notarization_by_id(notarized_object_id).await.map_err(wasm_error)
.wasm_result()
.map(Into::into)
}


/// Retrieves the timestamp of the last state change for a notarization.
///
/// # Arguments
Expand Down
19 changes: 18 additions & 1 deletion notarization-rs/src/client/read_only.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ use serde::de::DeserializeOwned;
use super::network_id;
use crate::core::move_utils;
use crate::core::operations::{NotarizationImpl, NotarizationOperations};
use crate::core::types::{Data, LockMetadata, NotarizationMethod, State};
use crate::core::transactions::get_object_ref_by_id_with_bcs;
use crate::core::types::{Data, LockMetadata, NotarizationMethod, OnChainNotarization, State};
use crate::error::Error;
use crate::iota_interaction_adapter::IotaClientAdapter;
use crate::package;
Expand Down Expand Up @@ -167,6 +168,22 @@ impl NotarizationClientReadOnly {
Self::new_internal(client, network).await
}

/// Retrieves the [`OnChainNotarization`] of a notarized object.
///
/// This method returns the on-chain notarization object for the given object ID.
///
/// # Arguments
///
/// * `notarized_object_id`: The [`ObjectID`] of the notarized object.
///
/// # Returns
/// A `Result` containing the [`OnChainNotarization`] or an [`Error`].
pub async fn get_notarization_by_id(&self, notarized_object_id: ObjectID) -> Result<OnChainNotarization, Error> {
let notarization_object = get_object_ref_by_id_with_bcs(self, &notarized_object_id).await?;

Ok(notarization_object)
}

/// Retrieves the `last_state_change_at` timestamp of a notarized object.
///
/// This timestamp indicates the time of the most recent state change for the object.
Expand Down
Loading