iota_bridge_indexer/
types.rs1use iota_json_rpc_types::{
6 IotaTransactionBlockEffects, IotaTransactionBlockEvents, IotaTransactionBlockResponse,
7};
8use iota_types::digests::TransactionDigest;
9
10#[derive(Clone)]
11pub struct RetrievedTransaction {
12 pub tx_digest: TransactionDigest,
13 pub events: IotaTransactionBlockEvents,
14 pub checkpoint: u64,
15 pub timestamp_ms: u64,
16 pub effects: IotaTransactionBlockEffects,
17}
18
19impl TryFrom<IotaTransactionBlockResponse> for RetrievedTransaction {
20 type Error = anyhow::Error;
21 fn try_from(response: IotaTransactionBlockResponse) -> Result<Self, Self::Error> {
22 Ok(RetrievedTransaction {
23 tx_digest: response.digest,
24 events: response
25 .events
26 .ok_or(anyhow::anyhow!("missing events in responses"))?,
27 checkpoint: response
28 .checkpoint
29 .ok_or(anyhow::anyhow!("missing checkpoint in responses"))?,
30 timestamp_ms: response
31 .timestamp_ms
32 .ok_or(anyhow::anyhow!("missing timestamp_ms in responses"))?,
33 effects: response
34 .effects
35 .ok_or(anyhow::anyhow!("missing effects in responses"))?,
36 })
37 }
38}