whisky_provider/blockfrost/models/
transaction.rs

1use serde::{Deserialize, Serialize};
2
3use super::Asset;
4
5#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
6pub struct BlockfrostTxInfo {
7    /// Transaction hash
8    #[serde(rename = "hash")]
9    pub hash: String,
10    /// Block hash
11    #[serde(rename = "block")]
12    pub block: String,
13    /// Block number
14    #[serde(rename = "block_height")]
15    pub block_height: i32,
16    /// Block creation time in UNIX time
17    #[serde(rename = "block_time")]
18    pub block_time: i32,
19    /// Slot number
20    #[serde(rename = "slot")]
21    pub slot: i32,
22    /// Transaction index within the block
23    #[serde(rename = "index")]
24    pub index: i32,
25    #[serde(rename = "output_amount")]
26    pub output_amount: Vec<Asset>,
27    /// Fees of the transaction in Lovelaces
28    #[serde(rename = "fees")]
29    pub fees: String,
30    /// Deposit within the transaction in Lovelaces
31    #[serde(rename = "deposit")]
32    pub deposit: String,
33    /// Size of the transaction in Bytes
34    #[serde(rename = "size")]
35    pub size: i32,
36    /// Left (included) endpoint of the timelock validity intervals
37    #[serde(rename = "invalid_before", deserialize_with = "Option::deserialize")]
38    pub invalid_before: Option<String>,
39    /// Right (excluded) endpoint of the timelock validity intervals
40    #[serde(rename = "invalid_hereafter", deserialize_with = "Option::deserialize")]
41    pub invalid_hereafter: Option<String>,
42    /// Count of UTXOs within the transaction
43    #[serde(rename = "utxo_count")]
44    pub utxo_count: i32,
45    /// Count of the withdrawals within the transaction
46    #[serde(rename = "withdrawal_count")]
47    pub withdrawal_count: i32,
48    /// Count of the MIR certificates within the transaction
49    #[serde(rename = "mir_cert_count")]
50    pub mir_cert_count: i32,
51    /// Count of the delegations within the transaction
52    #[serde(rename = "delegation_count")]
53    pub delegation_count: i32,
54    /// Count of the stake keys (de)registration within the transaction
55    #[serde(rename = "stake_cert_count")]
56    pub stake_cert_count: i32,
57    /// Count of the stake pool registration and update certificates within the transaction
58    #[serde(rename = "pool_update_count")]
59    pub pool_update_count: i32,
60    /// Count of the stake pool retirement certificates within the transaction
61    #[serde(rename = "pool_retire_count")]
62    pub pool_retire_count: i32,
63    /// Count of asset mints and burns within the transaction
64    #[serde(rename = "asset_mint_or_burn_count")]
65    pub asset_mint_or_burn_count: i32,
66    /// Count of redeemers within the transaction
67    #[serde(rename = "redeemer_count")]
68    pub redeemer_count: i32,
69    /// True if contract script passed validation
70    #[serde(rename = "valid_contract")]
71    pub valid_contract: bool,
72}
73
74#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
75pub struct BlockfrostTxUtxo {
76    /// Transaction hash
77    #[serde(rename = "hash")]
78    pub hash: String,
79    #[serde(rename = "inputs")]
80    pub inputs: Vec<BlockfrostTxUtxoInputs>,
81    #[serde(rename = "outputs")]
82    pub outputs: Vec<BlockfrostTxUtxoOutputs>,
83}
84
85#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
86pub struct BlockfrostTxUtxoInputs {
87    /// Input address
88    #[serde(rename = "address")]
89    pub address: String,
90    #[serde(rename = "amount")]
91    pub amount: Vec<Asset>,
92    /// Hash of the UTXO transaction
93    #[serde(rename = "tx_hash")]
94    pub tx_hash: String,
95    /// UTXO index in the transaction
96    #[serde(rename = "output_index")]
97    pub output_index: i32,
98    /// The hash of the transaction output datum
99    #[serde(rename = "data_hash", deserialize_with = "Option::deserialize")]
100    pub data_hash: Option<String>,
101    /// CBOR encoded inline datum
102    #[serde(rename = "inline_datum", deserialize_with = "Option::deserialize")]
103    pub inline_datum: Option<String>,
104    /// The hash of the reference script of the input
105    #[serde(
106        rename = "reference_script_hash",
107        deserialize_with = "Option::deserialize"
108    )]
109    pub reference_script_hash: Option<String>,
110    /// Whether the input is a collateral consumed on script validation failure
111    #[serde(rename = "collateral")]
112    pub collateral: bool,
113    /// Whether the input is a reference transaction input
114    #[serde(rename = "reference", skip_serializing_if = "Option::is_none")]
115    pub reference: Option<bool>,
116}
117
118#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
119pub struct BlockfrostTxUtxoOutputs {
120    /// Output address
121    #[serde(rename = "address")]
122    pub address: String,
123    #[serde(rename = "amount")]
124    pub amount: Vec<Asset>,
125    /// UTXO index in the transaction
126    #[serde(rename = "output_index")]
127    pub output_index: i32,
128    /// The hash of the transaction output datum
129    #[serde(rename = "data_hash", deserialize_with = "Option::deserialize")]
130    pub data_hash: Option<String>,
131    /// CBOR encoded inline datum
132    #[serde(rename = "inline_datum", deserialize_with = "Option::deserialize")]
133    pub inline_datum: Option<String>,
134    /// Whether the output is a collateral output
135    #[serde(rename = "collateral")]
136    pub collateral: bool,
137    /// The hash of the reference script of the output
138    #[serde(
139        rename = "reference_script_hash",
140        deserialize_with = "Option::deserialize"
141    )]
142    pub reference_script_hash: Option<String>,
143    /// Transaction hash that consumed the UTXO or null for unconsumed UTXOs. Always null for collateral outputs.
144    pub consumed_by_tx: Option<Option<String>>,
145}