tendermint/abci/response/
deliver_tx.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use bytes::Bytes;
use serde::Serialize;

use super::super::{Code, Event};
use crate::prelude::*;

#[doc = include_str!("../doc/response-delivertx.md")]
#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize)]
pub struct DeliverTx {
    /// The response code.
    ///
    /// This code should be `0` only if the transaction is fully valid. However,
    /// invalid transactions included in a block will still be executed against
    /// the application state.
    pub code: Code,
    /// Result bytes, if any.
    pub data: Bytes,
    /// The output of the application's logger.
    ///
    /// **May be non-deterministic**.
    pub log: String,
    /// Additional information.
    ///
    /// **May be non-deterministic**.
    pub info: String,
    /// Amount of gas requested for the transaction.
    pub gas_wanted: i64,
    /// Amount of gas consumed by the transaction.
    pub gas_used: i64,
    /// Events that occurred while executing the transaction.
    pub events: Vec<Event>,
    /// The namespace for the `code`.
    pub codespace: String,
}

// =============================================================================
// Protobuf conversions
// =============================================================================

mod v0_34 {
    use super::DeliverTx;
    use tendermint_proto::v0_34 as pb;
    use tendermint_proto::Protobuf;

    impl From<DeliverTx> for pb::abci::ResponseDeliverTx {
        fn from(deliver_tx: DeliverTx) -> Self {
            Self {
                code: deliver_tx.code.into(),
                data: deliver_tx.data,
                log: deliver_tx.log,
                info: deliver_tx.info,
                gas_wanted: deliver_tx.gas_wanted,
                gas_used: deliver_tx.gas_used,
                events: deliver_tx.events.into_iter().map(Into::into).collect(),
                codespace: deliver_tx.codespace,
            }
        }
    }

    impl TryFrom<pb::abci::ResponseDeliverTx> for DeliverTx {
        type Error = crate::Error;

        fn try_from(deliver_tx: pb::abci::ResponseDeliverTx) -> Result<Self, Self::Error> {
            Ok(Self {
                code: deliver_tx.code.into(),
                data: deliver_tx.data,
                log: deliver_tx.log,
                info: deliver_tx.info,
                gas_wanted: deliver_tx.gas_wanted,
                gas_used: deliver_tx.gas_used,
                events: deliver_tx
                    .events
                    .into_iter()
                    .map(TryInto::try_into)
                    .collect::<Result<_, _>>()?,
                codespace: deliver_tx.codespace,
            })
        }
    }

    impl Protobuf<pb::abci::ResponseDeliverTx> for DeliverTx {}
}

mod v0_37 {
    use super::DeliverTx;
    use tendermint_proto::v0_37 as pb;
    use tendermint_proto::Protobuf;

    impl From<DeliverTx> for pb::abci::ResponseDeliverTx {
        fn from(deliver_tx: DeliverTx) -> Self {
            Self {
                code: deliver_tx.code.into(),
                data: deliver_tx.data,
                log: deliver_tx.log,
                info: deliver_tx.info,
                gas_wanted: deliver_tx.gas_wanted,
                gas_used: deliver_tx.gas_used,
                events: deliver_tx.events.into_iter().map(Into::into).collect(),
                codespace: deliver_tx.codespace,
            }
        }
    }

    impl TryFrom<pb::abci::ResponseDeliverTx> for DeliverTx {
        type Error = crate::Error;

        fn try_from(deliver_tx: pb::abci::ResponseDeliverTx) -> Result<Self, Self::Error> {
            Ok(Self {
                code: deliver_tx.code.into(),
                data: deliver_tx.data,
                log: deliver_tx.log,
                info: deliver_tx.info,
                gas_wanted: deliver_tx.gas_wanted,
                gas_used: deliver_tx.gas_used,
                events: deliver_tx
                    .events
                    .into_iter()
                    .map(TryInto::try_into)
                    .collect::<Result<_, _>>()?,
                codespace: deliver_tx.codespace,
            })
        }
    }

    impl Protobuf<pb::abci::ResponseDeliverTx> for DeliverTx {}
}