Skip to content

Commit

Permalink
pool_metadata rpc update
Browse files Browse the repository at this point in the history
  • Loading branch information
dostrelith678 committed Jul 27, 2021
1 parent 1967514 commit 21e9d2b
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions files/grest/rpc/pool/pool_metadata.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
CREATE OR REPLACE FUNCTION grest.pool_metadata(_pool_bech32 text)
RETURNS JSON STABLE LANGUAGE PLPGSQL AS $$
CREATE OR REPLACE FUNCTION grest.pool_metadata (_pool_bech32 text)
RETURNS json STABLE
LANGUAGE PLPGSQL
AS $$
BEGIN
RETURN ( SELECT json_build_object(
'meta_url', pmd.url,
'meta_hash', encode(pmd.hash::bytea, 'hex')
)
FROM public.pool_meta_data AS pmd
WHERE pmd.id = (SELECT id from public.pool_hash where view=_pool_bech32)
);
END; $$;
RETURN (
SELECT
json_build_object('meta_url', pmd.url, 'meta_hash', encode(pmd.hash::bytea, 'hex'))
FROM
public.pool_metadata_ref AS pmd
WHERE
pmd.pool_id = (
SELECT
id
FROM
public.pool_hash
WHERE
VIEW = _pool_bech32)
ORDER BY
pmd.registered_tx_id DESC
LIMIT 1);
END;
$$;

COMMENT ON FUNCTION grest.pool_metadata IS 'Get pool metadata url and hash';

0 comments on commit 21e9d2b

Please sign in to comment.