Skip to content

Commit

Permalink
feat(tx/utxos): Add consumed_by_tx field
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Sep 11, 2024
1 parent 66e3866 commit 2cfc036
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Addded

- `/txs/{hash}/utxos`
- `consumed_by_tx` field
- `/epochs/{number}/parameters` and `/epochs/latest/parameters`
- `cost_models_raw` field, list variant of cost_models without name mapping

Expand Down
9 changes: 7 additions & 2 deletions src/sql/txs/txs_hash_utxos_2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ FROM (
encode(dat.bytes, 'hex') AS "inline_datum",
false AS "collateral",
encode(scr.hash, 'hex') AS "reference_script_hash",
txo.index AS "output_index"
txo.index AS "output_index",
(
SELECT encode(tx.hash, 'hex')
FROM tx WHERE tx.id = txo.consumed_by_tx_id
) AS "consumed_by_tx"
FROM tx
JOIN tx_out txo ON (txo.tx_id = tx.id)
LEFT JOIN datum dat ON (txo.inline_datum_id = dat.id)
Expand All @@ -35,7 +39,8 @@ FROM (
encode(dat.bytes, 'hex') AS "inline_datum",
true AS "collateral",
encode(scr.hash, 'hex') AS "reference_script_hash",
txo.index AS "output_index"
txo.index AS "output_index",
NULL as "consumed_by_tx"
FROM tx
JOIN collateral_tx_out txo ON (txo.tx_id = tx.id)
LEFT JOIN datum dat ON (txo.inline_datum_id = dat.id)
Expand Down

0 comments on commit 2cfc036

Please sign in to comment.