-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1967514
commit 21e9d2b
Showing
1 changed file
with
24 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; | ||
|