From 5fab725eee26bc8776be9d86e75fc88670300ce4 Mon Sep 17 00:00:00 2001 From: rdlrt <3169068+rdlrt@users.noreply.github.com> Date: Sat, 30 Nov 2024 17:10:45 +1100 Subject: [PATCH] Add view endpoint --- files/grest/rpc/assets/asset_utxos.sql | 2 +- files/grest/rpc/assets/policy_asset_addresses.sql | 6 +++--- files/grest/rpc/pool/pool_delegators.sql | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/files/grest/rpc/assets/asset_utxos.sql b/files/grest/rpc/assets/asset_utxos.sql index f957f0a2..2090c80f 100644 --- a/files/grest/rpc/assets/asset_utxos.sql +++ b/files/grest/rpc/assets/asset_utxos.sql @@ -66,7 +66,7 @@ BEGIN tx_out.index::smallint, a.address::text, tx_out.value::text, - grest.cip5_hex_to_stake_addr(sa.hash_raw)::text as stake_address, + sa.view::text as stake_address, ENCODE(a.payment_cred, 'hex') AS payment_cred, b.epoch_no, b.block_no, diff --git a/files/grest/rpc/assets/policy_asset_addresses.sql b/files/grest/rpc/assets/policy_asset_addresses.sql index 09bff22e..6d74c417 100644 --- a/files/grest/rpc/assets/policy_asset_addresses.sql +++ b/files/grest/rpc/assets/policy_asset_addresses.sql @@ -28,7 +28,7 @@ BEGIN SELECT atoc.ma_id, a.address, - grest.cip5_hex_to_stake_addr(sa.hash_raw)::varchar AS stake_address, + sa.view::varchar AS stake_address, atoc.quantity FROM grest.asset_tx_out_cache AS atoc LEFT JOIN multi_asset AS ma ON ma.id = atoc.ma_id @@ -48,7 +48,7 @@ BEGIN SELECT ENCODE(ma.name, 'hex') AS asset_name, a.address, - grest.cip5_hex_to_stake_addr(sa.hash_raw)::varchar AS stake_address, + sa.view::varchar AS stake_address, SUM(mto.quantity)::text FROM multi_asset AS ma LEFT JOIN ma_tx_out AS mto ON mto.ident = ma.id @@ -60,7 +60,7 @@ BEGIN GROUP BY ma.name, a.address, - sa.hash_raw; + sa.view; END IF; END; $$; diff --git a/files/grest/rpc/pool/pool_delegators.sql b/files/grest/rpc/pool/pool_delegators.sql index bd67bc67..a3504c45 100644 --- a/files/grest/rpc/pool/pool_delegators.sql +++ b/files/grest/rpc/pool/pool_delegators.sql @@ -115,6 +115,7 @@ BEGIN AND NOT EXISTS (SELECT null FROM stake_deregistration AS sd WHERE sd.addr_id = d.addr_id AND sd.tx_id > d.tx_id) -- AND NOT grest.is_dangling_delegation(d.id) AND NOT EXISTS (SELECT null FROM grest.stake_distribution_cache AS sdc WHERE sdc.stake_address_id = sa.id) + WHERE d.active_epoch_no > (SELECT MAX(no) FROM epoch) ) z, LATERAL grest.account_utxos(array[(SELECT grest.cip5_hex_to_stake_addr(z.stake_address_raw))], false) AS acc_info GROUP BY