Skip to content

Commit

Permalink
Apply Fixes from testing on non-mainnet networks: (#173)
Browse files Browse the repository at this point in the history
- Fix Asset Info Cache to not rely on being able to decode policy ID (bad data on IO repo)
  - Handle Pool_list to check metadata entries that have not been populated in pool_offline_data (closes #109 from Koios point of view)
  - Fix pool_updates to use pmr_id instead of pool_offline_data.id (wasnt reported earlier, but the endpoint was showing wrong data)
  - Update account_info_cached description to clarify it is effective for registered accounts
  • Loading branch information
rdlrt committed Mar 13, 2023
1 parent 669b392 commit 055344f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
6 changes: 3 additions & 3 deletions files/grest/rpc/01_cached_tables/asset_info_cache.sql
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ BEGIN
WHERE
CASE WHEN _asset_info_cache_last_tx_id IS NOT NULL AND _asset_id_list IS NOT NULL
THEN
mtm.id = any(_asset_id_list)
mtm.ident = any(_asset_id_list)
AND mtm.tx_id > _asset_info_cache_last_tx_id
ELSE TRUE
END
Expand Down Expand Up @@ -145,11 +145,11 @@ BEGIN
INNER JOIN tx ON tx.id = mtm.tx_id
INNER JOIN block b ON b.id = tx.block_id
INNER JOIN tx_meta tm ON tm.ident = ma.id
LEFT JOIN grest.asset_registry_cache arc ON DECODE(arc.asset_policy, 'hex') = ma.policy AND DECODE(arc.asset_name, 'hex') = ma.name
LEFT JOIN grest.asset_registry_cache arc ON arc.asset_policy = ENCODE(ma.policy,'hex') AND arc.asset_name = encode(ma.name,'hex')
WHERE
CASE WHEN _asset_info_cache_last_tx_id IS NOT NULL AND _asset_id_list IS NOT NULL
THEN
mtm.id = any(_asset_id_list)
mtm.ident = any(_asset_id_list)
ELSE TRUE
END
GROUP BY ma.id, arc.decimals, tm.first_mint_tx_id, tm.first_mint_keys, tm.last_mint_tx_id, tm.last_mint_keys
Expand Down
25 changes: 18 additions & 7 deletions files/grest/rpc/pool/pool_list.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE FUNCTION grest.pool_list ()
CREATE OR REPLACE FUNCTION grest.pool_list ()
RETURNS TABLE (
pool_id_bech32 character varying,
ticker character varying)
Expand All @@ -10,24 +10,35 @@ BEGIN
RETURN QUERY (
WITH
-- Get last pool update for each pool
_pool_updates AS (
_pool_list AS (
SELECT
DISTINCT ON (pic.pool_id_bech32) pool_id_bech32,
pod.ticker_name,
pic.pool_status
pool_status
FROM
grest.pool_info_cache AS pic
ORDER BY
pic.pool_id_bech32,
pic.tx_id DESC
),
_pool_meta AS (
SELECT
DISTINCT ON (pic.pool_id_bech32) pool_id_bech32,
pod.ticker_name
FROM
grest.pool_info_cache AS pic
LEFT JOIN public.pool_offline_data AS pod ON pod.pmr_id = pic.meta_id
WHERE pod.ticker_name IS NOT NULL
ORDER BY
pic.pool_id_bech32,
pic.tx_id DESC
)

SELECT
pool_id_bech32,
ticker_name
pl.pool_id_bech32,
pm.ticker_name
FROM
_pool_updates
_pool_list AS pl
LEFT JOIN _pool_meta AS pm ON pl.pool_id_bech32 = pm.pool_id_bech32
WHERE
pool_status != 'retired'

Expand Down
2 changes: 1 addition & 1 deletion files/grest/rpc/pool/pool_updates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BEGIN
retiring_epoch
FROM
grest.pool_info_cache pic
LEFT JOIN public.pool_offline_data pod ON pod.id = pic.meta_id
LEFT JOIN public.pool_offline_data pod ON pod.pmr_id = pic.meta_id
WHERE
_pool_bech32 IS NULL
OR
Expand Down
2 changes: 1 addition & 1 deletion specs/results/koiosapi-guild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ paths:
"404":
$ref: "#/components/responses/NotFound"
summary: Account Information (Cached)
description: Get the cached account information for given stake addresses
description: Get the cached account information for given stake addresses, effective for registered accounts
/account_rewards: #RPC
post:
tags:
Expand Down
2 changes: 1 addition & 1 deletion specs/results/koiosapi-mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ paths:
"404":
$ref: "#/components/responses/NotFound"
summary: Account Information (Cached)
description: Get the cached account information for given stake addresses
description: Get the cached account information for given stake addresses, effective for registered accounts
/account_rewards: #RPC
post:
tags:
Expand Down
2 changes: 1 addition & 1 deletion specs/results/koiosapi-preprod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ paths:
"404":
$ref: "#/components/responses/NotFound"
summary: Account Information (Cached)
description: Get the cached account information for given stake addresses
description: Get the cached account information for given stake addresses, effective for registered accounts
/account_rewards: #RPC
post:
tags:
Expand Down
2 changes: 1 addition & 1 deletion specs/results/koiosapi-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ paths:
"404":
$ref: "#/components/responses/NotFound"
summary: Account Information (Cached)
description: Get the cached account information for given stake addresses
description: Get the cached account information for given stake addresses, effective for registered accounts
/account_rewards: #RPC
post:
tags:
Expand Down
2 changes: 1 addition & 1 deletion specs/templates/api-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ paths:
"404":
$ref: "#/components/responses/NotFound"
summary: Account Information (Cached)
description: Get the cached account information for given stake addresses
description: Get the cached account information for given stake addresses, effective for registered accounts
/account_rewards: #RPC
post:
tags:
Expand Down

0 comments on commit 055344f

Please sign in to comment.