sui_bridge_indexer/
types.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use sui_json_rpc_types::{
5    SuiTransactionBlockEffects, SuiTransactionBlockEvents, SuiTransactionBlockResponse,
6};
7use sui_types::digests::TransactionDigest;
8
9#[derive(Clone)]
10pub struct RetrievedTransaction {
11    pub tx_digest: TransactionDigest,
12    pub events: SuiTransactionBlockEvents,
13    pub checkpoint: u64,
14    pub timestamp_ms: u64,
15    pub effects: SuiTransactionBlockEffects,
16}
17
18impl TryFrom<SuiTransactionBlockResponse> for RetrievedTransaction {
19    type Error = anyhow::Error;
20    fn try_from(response: SuiTransactionBlockResponse) -> Result<Self, Self::Error> {
21        Ok(RetrievedTransaction {
22            tx_digest: response.digest,
23            events: response
24                .events
25                .ok_or(anyhow::anyhow!("missing events in responses"))?,
26            checkpoint: response
27                .checkpoint
28                .ok_or(anyhow::anyhow!("missing checkpoint in responses"))?,
29            timestamp_ms: response
30                .timestamp_ms
31                .ok_or(anyhow::anyhow!("missing timestamp_ms in responses"))?,
32            effects: response
33                .effects
34                .ok_or(anyhow::anyhow!("missing effects in responses"))?,
35        })
36    }
37}