Skip to content

Commit 37ea0a9

Browse files
committed
fix: add tx_index field to UTxORest
Signed-off-by: William Hankins <[email protected]>
1 parent 4b5579d commit 37ea0a9

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

modules/rest_blockfrost/src/handlers/accounts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ pub async fn handle_account_utxos_blockfrost(
824824
for (i, entry) in entries.into_iter().enumerate() {
825825
let tx_hash = hashes.tx_hashes.get(i).map(hex::encode).unwrap_or_default();
826826
let block_hash = hashes.block_hashes.get(i).map(hex::encode).unwrap_or_default();
827+
let tx_index = utxo_identifiers[i].tx_index();
827828
let output_index = utxo_identifiers.get(i).map(|id| id.output_index()).unwrap_or(0);
828829
let (data_hash, inline_datum) = match &entry.datum {
829830
Some(Datum::Hash(h)) => (Some(hex::encode(h)), None),
@@ -849,6 +850,7 @@ pub async fn handle_account_utxos_blockfrost(
849850
rest_response.push(UTxOREST {
850851
address: entry.address.to_string()?,
851852
tx_hash,
853+
tx_index,
852854
output_index,
853855
amount: entry.value.into(),
854856
block: block_hash,

modules/rest_blockfrost/src/handlers/addresses.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ pub async fn handle_address_utxos_blockfrost(
250250
for (i, entry) in entries.into_iter().enumerate() {
251251
let tx_hash = hex::encode(hashes.tx_hashes[i]);
252252
let block_hash = hex::encode(hashes.block_hashes[i]);
253+
let tx_index = utxo_identifiers[i].tx_index();
253254
let output_index = utxo_identifiers[i].output_index();
254255
let (data_hash, inline_datum) = match &entry.datum {
255256
Some(Datum::Hash(h)) => (Some(hex::encode(h)), None),
@@ -275,6 +276,7 @@ pub async fn handle_address_utxos_blockfrost(
275276
rest_response.push(UTxOREST {
276277
address: address_str.clone(),
277278
tx_hash,
279+
tx_index,
278280
output_index,
279281
amount: entry.value.into(),
280282
block: block_hash,

modules/rest_blockfrost/src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,7 @@ pub struct AccountAddressREST {
930930
pub struct UTxOREST {
931931
pub address: String,
932932
pub tx_hash: String,
933+
pub tx_index: u16,
933934
pub output_index: u16,
934935
pub amount: AmountList,
935936
pub block: String,

0 commit comments

Comments
 (0)