-
Notifications
You must be signed in to change notification settings - Fork 25
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
Showing
10 changed files
with
120 additions
and
88 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
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
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
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,24 +1,20 @@ | ||
CREATE OR REPLACE FUNCTION grest.drep_list() | ||
RETURNS TABLE ( | ||
drep_id character varying, | ||
hex text, | ||
has_script boolean, | ||
drep_id text, | ||
registered boolean | ||
) | ||
LANGUAGE sql STABLE | ||
AS $$ | ||
SELECT | ||
DISTINCT ON (dh.view) dh.view AS drep_id, | ||
ENCODE(dh.raw, 'hex')::text AS hex, | ||
dh.has_script AS has_script, | ||
SELECT DISTINCT ON (dh.raw) | ||
grest.cip129_hex_to_drep_id(dh.raw, dh.has_script) AS drep_id, | ||
(CASE | ||
WHEN coalesce(dr.deposit, 0) >= 0 THEN TRUE | ||
ELSE FALSE | ||
END) AS registered | ||
FROM public.drep_hash AS dh | ||
INNER JOIN public.drep_registration AS dr ON dh.id = dr.drep_hash_id | ||
ORDER BY | ||
dh.view, dr.tx_id DESC; | ||
dh.raw, dr.tx_id DESC; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.asset_list IS 'Get a raw listing of all active delegated representatives, aka DReps'; --noqa: LT01 |
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,36 +1,44 @@ | ||
CREATE OR REPLACE FUNCTION grest.drep_metadata(_drep_ids text []) | ||
RETURNS TABLE ( | ||
drep_id character varying, | ||
hex text, | ||
url text, | ||
drep_id text, | ||
url character varying, | ||
hash text, | ||
json jsonb, | ||
bytes text, | ||
warning text, | ||
language text, | ||
comment text, | ||
warning character varying, | ||
language character varying, | ||
comment character varying, | ||
is_valid boolean | ||
) | ||
LANGUAGE sql STABLE | ||
LANGUAGE plpgsql | ||
AS $$ | ||
SELECT | ||
DISTINCT ON (dh.view) dh.view AS drep_id, | ||
ENCODE(dh.raw, 'hex')::text AS hex, | ||
va.url, | ||
ENCODE(va.data_hash, 'hex') AS hash, | ||
ocvd.json, | ||
ENCODE(ocvd.bytes,'hex')::text AS bytes, | ||
ocvd.warning AS warning, | ||
ocvd.language AS language, | ||
ocvd.comment AS comment, | ||
COALESCE(is_valid, true) AS is_valid | ||
FROM public.drep_hash AS dh | ||
INNER JOIN public.drep_registration AS dr ON dh.id = dr.drep_hash_id | ||
LEFT JOIN public.voting_anchor AS va ON dr.voting_anchor_id = va.id | ||
LEFT JOIN public.off_chain_vote_data AS ocvd ON va.id = ocvd.voting_anchor_id | ||
WHERE dh.view = ANY(_drep_ids) | ||
ORDER BY | ||
dh.view, dr.tx_id DESC; | ||
DECLARE | ||
drep_ids_raw hash28type[]; | ||
BEGIN | ||
|
||
SELECT INTO drep_ids_raw ARRAY_AGG(DECODE(grest.cip129_drep_id_to_hex(n), 'hex')) FROM UNNEST(_drep_ids) AS n; | ||
|
||
RETURN QUERY ( | ||
SELECT DISTINCT ON (dh.raw) | ||
grest.cip129_hex_to_drep_id(dh.raw, dh.has_script) AS drep_id, | ||
va.url, | ||
ENCODE(va.data_hash, 'hex') AS hash, | ||
ocvd.json, | ||
ENCODE(ocvd.bytes,'hex')::text AS bytes, | ||
ocvd.warning AS warning, | ||
ocvd.language AS language, | ||
ocvd.comment AS comment, | ||
COALESCE(ocvd.is_valid, true) AS is_valid | ||
FROM public.drep_hash AS dh | ||
INNER JOIN public.drep_registration AS dr ON dh.id = dr.drep_hash_id | ||
LEFT JOIN public.voting_anchor AS va ON dr.voting_anchor_id = va.id | ||
LEFT JOIN public.off_chain_vote_data AS ocvd ON va.id = ocvd.voting_anchor_id | ||
WHERE dh.raw = ANY(drep_ids_raw) | ||
ORDER BY | ||
dh.raw, dr.tx_id DESC | ||
); | ||
|
||
END; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.drep_metadata IS 'Get bulk DRep metadata from bech32 formatted DRep IDs'; -- noqa: LT01 |
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
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
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
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
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