Skip to main content

iota_types/
messages_safe_client.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2024 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5use iota_sdk_types::TransactionEvents;
6
7use crate::{
8    effects::SignedTransactionEffects,
9    transaction::{CertifiedTransaction, SignedTransaction, TransactionEnvelope},
10};
11
12/// This enum represents all possible states of a response returned from
13/// the safe client. Note that [struct SignedTransaction] and
14/// [struct SignedTransactionEffects] are represented as an Envelope
15/// instead of an VerifiedEnvelope. This is because the verification is
16/// now performed by the authority aggregator as an aggregated signature,
17/// instead of in SafeClient.
18#[derive(Clone, Debug)]
19pub enum PlainTransactionInfoResponse {
20    Signed(SignedTransaction),
21    ExecutedWithCert(
22        CertifiedTransaction,
23        SignedTransactionEffects,
24        TransactionEvents,
25    ),
26    ExecutedWithoutCert(
27        TransactionEnvelope,
28        SignedTransactionEffects,
29        TransactionEvents,
30    ),
31}
32
33impl PlainTransactionInfoResponse {
34    pub fn is_executed(&self) -> bool {
35        match self {
36            PlainTransactionInfoResponse::Signed(_) => false,
37            PlainTransactionInfoResponse::ExecutedWithCert(_, _, _)
38            | PlainTransactionInfoResponse::ExecutedWithoutCert(_, _, _) => true,
39        }
40    }
41}