From 9e6517da1bca526b7e0ce0e83213e9222b4ccbfe Mon Sep 17 00:00:00 2001 From: Greg B Date: Tue, 19 Nov 2024 18:15:35 +1100 Subject: [PATCH] For #307 - removed some _script=true conditions; utilizing bytecode flag value in more spots --- files/grest/rpc/transactions/tx_info.sql | 33 ++++++++++++------------ 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/files/grest/rpc/transactions/tx_info.sql b/files/grest/rpc/transactions/tx_info.sql index a1f258f..f27244b 100644 --- a/files/grest/rpc/transactions/tx_info.sql +++ b/files/grest/rpc/transactions/tx_info.sql @@ -109,7 +109,7 @@ BEGIN (CASE WHEN tx_out.inline_datum_id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT( - 'bytes', ENCODE(datum.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(datum.bytes, 'hex') ELSE NULL END, 'value', datum.value ) END @@ -118,7 +118,7 @@ BEGIN ELSE JSONB_BUILD_OBJECT( 'hash', ENCODE(script.hash, 'hex'), - 'bytes', ENCODE(script.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(script.bytes, 'hex') ELSE NULL END, 'value', script.json, 'type', script.type::text, 'size', script.serialised_size @@ -137,7 +137,7 @@ BEGIN LEFT JOIN datum ON _scripts IS TRUE AND datum.id = tx_out.inline_datum_id LEFT JOIN script ON _scripts IS TRUE AND script.id = tx_out.reference_script_id WHERE - (_inputs IS TRUE AND _scripts IS TRUE) + (_inputs IS TRUE) AND collateral_tx_in.tx_in_id = ANY(_tx_id_list) ), @@ -165,7 +165,7 @@ BEGIN (CASE WHEN tx_out.inline_datum_id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT( - 'bytes', ENCODE(datum.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(datum.bytes, 'hex') ELSE NULL END, 'value', datum.value ) END @@ -174,7 +174,7 @@ BEGIN ELSE JSONB_BUILD_OBJECT( 'hash', ENCODE(script.hash, 'hex'), - 'bytes', ENCODE(script.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(script.bytes, 'hex') ELSE NULL END, 'value', script.json, 'type', script.type::text, 'size', script.serialised_size @@ -193,7 +193,7 @@ BEGIN LEFT JOIN datum ON _scripts IS TRUE AND datum.id = tx_out.inline_datum_id LEFT JOIN script ON _scripts IS TRUE AND script.id = tx_out.reference_script_id WHERE - (_inputs IS TRUE AND _scripts IS TRUE) + (_inputs IS TRUE) AND reference_tx_in.tx_in_id = ANY(_tx_id_list) ), @@ -221,7 +221,7 @@ BEGIN (CASE WHEN tx_out.inline_datum_id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT( - 'bytes', ENCODE(datum.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(datum.bytes, 'hex') ELSE NULL END, 'value', datum.value ) END @@ -230,7 +230,7 @@ BEGIN ELSE JSONB_BUILD_OBJECT( 'hash', ENCODE(script.hash, 'hex'), - 'bytes', ENCODE(script.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(script.bytes, 'hex') ELSE NULL END, 'value', script.json, 'type', script.type::text, 'size', script.serialised_size @@ -263,7 +263,7 @@ BEGIN (CASE WHEN tx_out.inline_datum_id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT( - 'bytes', ENCODE(datum.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(datum.bytes, 'hex') ELSE NULL END, 'value', datum.value ) END @@ -272,7 +272,7 @@ BEGIN ELSE JSONB_BUILD_OBJECT( 'hash', ENCODE(script.hash, 'hex'), - 'bytes', ENCODE(script.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(script.bytes, 'hex') ELSE NULL END, 'value', script.json, 'type', script.type::text, 'size', script.serialised_size @@ -287,8 +287,7 @@ BEGIN LEFT JOIN stake_address AS sa ON tx_out.stake_address_id = sa.id LEFT JOIN datum ON _scripts IS TRUE AND datum.id = tx_out.inline_datum_id LEFT JOIN script ON _scripts IS TRUE AND script.id = tx_out.reference_script_id - WHERE _scripts IS TRUE - AND tx_out.tx_id = ANY(_tx_id_list) + WHERE tx_out.tx_id = ANY(_tx_id_list) ), _all_outputs AS ( @@ -315,7 +314,7 @@ BEGIN (CASE WHEN tx_out.inline_datum_id IS NULL THEN NULL ELSE JSONB_BUILD_OBJECT( - 'bytes', ENCODE(datum.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(datum.bytes, 'hex') ELSE NULL END, 'value', datum.value ) END @@ -324,7 +323,7 @@ BEGIN ELSE JSONB_BUILD_OBJECT( 'hash', ENCODE(script.hash, 'hex'), - 'bytes', ENCODE(script.bytes, 'hex'), + 'bytes', CASE WHEN _bytecode IS TRUE THEN ENCODE(script.bytes, 'hex') ELSE NULL END, 'value', script.json, 'type', script.type::text, 'size', script.serialised_size @@ -949,7 +948,7 @@ BEGIN 'asset_list', COALESCE(JSONB_AGG(asset_list) FILTER (WHERE asset_list IS NOT NULL), JSONB_BUILD_ARRAY()) ) AS tx_collateral_inputs FROM _all_collateral_inputs AS aci - WHERE (_inputs IS TRUE AND _scripts IS TRUE) AND aci.tx_id = atx.id + WHERE (_inputs IS TRUE) AND aci.tx_id = atx.id GROUP BY payment_addr_bech32, payment_addr_cred, stake_addr, aci.tx_hash, tx_index, value, datum_hash, inline_datum, reference_script ) AS tmp ), JSONB_BUILD_ARRAY()), @@ -970,7 +969,7 @@ BEGIN 'asset_list', asset_descr ) AS tx_collateral_outputs FROM _all_collateral_outputs AS aco - WHERE _scripts IS TRUE AND aco.tx_id = atx.id + WHERE aco.tx_id = atx.id GROUP BY payment_addr_bech32, payment_addr_cred, stake_addr, aco.tx_hash, tx_index, value, datum_hash, inline_datum, reference_script, asset_descr LIMIT 1 -- there can only be one collateral output ), @@ -993,7 +992,7 @@ BEGIN 'asset_list', COALESCE(JSONB_AGG(asset_list) FILTER (WHERE asset_list IS NOT NULL), JSONB_BUILD_ARRAY()) ) AS tx_reference_inputs FROM _all_reference_inputs AS ari - WHERE (_inputs IS TRUE AND _scripts IS TRUE) AND ari.tx_id = atx.id + WHERE (_inputs IS TRUE) AND ari.tx_id = atx.id GROUP BY payment_addr_bech32, payment_addr_cred, stake_addr, ari.tx_hash, tx_index, value, datum_hash, inline_datum, reference_script ) AS tmp ), JSONB_BUILD_ARRAY()),