stellar_xdr/curr/
transaction_conversions.rs1use super::{
2 FeeBumpTransaction, FeeBumpTransactionEnvelope, MuxedAccount, Preconditions, TimeBounds,
3 Transaction, TransactionEnvelope, TransactionExt, TransactionV0, TransactionV0Ext,
4 TransactionV1Envelope, Uint256, VecM,
5};
6
7impl From<Transaction> for TransactionEnvelope {
8 fn from(tx: Transaction) -> Self {
9 TransactionEnvelope::Tx(TransactionV1Envelope {
10 tx,
11 signatures: VecM::default(),
12 })
13 }
14}
15
16impl From<FeeBumpTransaction> for TransactionEnvelope {
17 fn from(tx: FeeBumpTransaction) -> Self {
18 TransactionEnvelope::TxFeeBump(FeeBumpTransactionEnvelope {
19 tx,
20 signatures: VecM::default(),
21 })
22 }
23}
24
25impl From<Uint256> for MuxedAccount {
26 fn from(ed25519: Uint256) -> Self {
27 MuxedAccount::Ed25519(ed25519)
28 }
29}
30
31impl From<TransactionV0Ext> for TransactionExt {
32 fn from(ext: TransactionV0Ext) -> Self {
33 match ext {
34 TransactionV0Ext::V0 => TransactionExt::V0,
35 }
36 }
37}
38
39impl From<Option<TimeBounds>> for Preconditions {
40 fn from(maybe_timebounds: Option<TimeBounds>) -> Self {
41 match maybe_timebounds {
42 None => Preconditions::None,
43 Some(timebounds) => Preconditions::Time(timebounds),
44 }
45 }
46}
47
48impl From<TransactionV0> for Transaction {
49 fn from(tx: TransactionV0) -> Self {
50 Transaction {
51 source_account: tx.source_account_ed25519.into(),
52 cond: tx.time_bounds.into(),
53 ext: tx.ext.into(),
54 fee: tx.fee,
55 memo: tx.memo,
56 operations: tx.operations,
57 seq_num: tx.seq_num,
58 }
59 }
60}
61
62impl From<&FeeBumpTransaction> for TransactionEnvelope {
63 fn from(tx: &FeeBumpTransaction) -> Self {
64 tx.clone().into()
65 }
66}
67
68impl From<&Transaction> for TransactionEnvelope {
69 fn from(tx: &Transaction) -> Self {
70 tx.clone().into()
71 }
72}
73
74impl From<&Uint256> for MuxedAccount {
75 fn from(ed25519: &Uint256) -> Self {
76 ed25519.clone().into()
77 }
78}
79
80impl From<&TransactionV0Ext> for TransactionExt {
81 fn from(ext: &TransactionV0Ext) -> Self {
82 ext.clone().into()
83 }
84}
85
86impl From<&Option<TimeBounds>> for Preconditions {
87 fn from(maybe_timebounds: &Option<TimeBounds>) -> Self {
88 maybe_timebounds.clone().into()
89 }
90}
91
92impl From<&TransactionV0> for Transaction {
93 fn from(tx: &TransactionV0) -> Self {
94 tx.clone().into()
95 }
96}