openmina_core/transaction/
transaction_info.rs1use mina_p2p_messages::{
2 binprot::{
3 self,
4 macros::{BinProtRead, BinProtWrite},
5 },
6 v2::NonZeroCurvePoint,
7};
8use serde::{Deserialize, Serialize};
9
10use super::{Transaction, TransactionHash};
11
12#[derive(BinProtWrite, BinProtRead, Serialize, Deserialize, Debug, Clone)]
13pub struct TransactionInfo {
14 pub hash: TransactionHash,
15 pub fee_payer: NonZeroCurvePoint,
16 pub fee: u64,
17 pub nonce: u32,
18}
19
20impl From<&Transaction> for TransactionInfo {
21 fn from(tx: &Transaction) -> Self {
22 match tx {
23 Transaction::SignedCommand(tx) => Self {
24 hash: tx.hash().unwrap(),
25 fee_payer: tx.payload.common.fee_payer_pk.clone(),
26 fee: tx.payload.common.fee.as_u64(),
27 nonce: tx.payload.common.nonce.as_u32(),
28 },
29 Transaction::ZkappCommand(tx) => Self {
30 hash: tx.hash().unwrap(),
31 fee_payer: tx.fee_payer.body.public_key.clone(),
32 fee: tx.fee_payer.body.fee.as_u64(),
33 nonce: tx.fee_payer.body.nonce.as_u32(),
34 },
35 }
36 }
37}