-
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.
Vote endpoints now return proposal hash and voting hashes (#297)
added cert_index param to proposal votes endpoint, spec updates ## Description Vote list endpoints now return proposal_tx_hash of the proposal and vote_tx_hash of the vote, and blocktime has been corrected to be that of the latter. One of the endpoints had cert_index parameter in implementation but was missing from API specs. Ordering changed from block time to tx id as can have multiple voting transactions within same block in theory. ## Where should the reviewer start? <!--- Describe where reviewer should start testing --> ## Motivation and context <!--- Why is this change required? What problem does it solve? --> ## Which issue it fixes? <!--- Link to issue: Closes #issue-number --> ## How has this been tested? <!--- Describe how you tested changes --> --------- Co-authored-by: Greg B <adahoskinson@gmail.com> Co-authored-by: RdLrT <3169068+rdlrt@users.noreply.github.com>
- Loading branch information
1 parent
f73007d
commit c70aaa4
Showing
9 changed files
with
48 additions
and
26 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,25 +1,28 @@ | ||
CREATE OR REPLACE FUNCTION grest.committee_votes(_committee_hash text) | ||
RETURNS TABLE ( | ||
tx_hash text, | ||
proposal_tx_hash text, | ||
cert_index integer, | ||
vote_tx_hash text, | ||
block_time integer, | ||
vote text | ||
) | ||
LANGUAGE sql STABLE | ||
AS $$ | ||
SELECT | ||
ENCODE(tx.hash, 'hex')::text AS tx_hash, | ||
ENCODE(prop_tx.hash, 'hex')::text AS proposal_tx_hash, | ||
gap.index AS cert_index, | ||
ENCODE(vote_tx.hash, 'hex')::text AS vote_tx_hash, | ||
EXTRACT(EPOCH FROM b.time)::integer AS block_time, | ||
vp.vote | ||
FROM public.committee_hash AS ch | ||
INNER JOIN public.voting_procedure AS vp ON ch.id = vp.committee_voter | ||
INNER JOIN public.gov_action_proposal AS gap ON vp.gov_action_proposal_id = gap.id | ||
INNER JOIN public.tx ON gap.tx_id = tx.id | ||
INNER JOIN public.block AS b ON tx.block_id = b.id | ||
INNER JOIN public.tx prop_tx ON gap.tx_id = prop_tx.id | ||
INNER JOIN public.tx vote_tx on vp.tx_id = vote_tx.id | ||
INNER JOIN public.block AS b ON vote_tx.block_id = b.id | ||
WHERE ch.raw = DECODE(_committee_hash, 'hex') | ||
ORDER BY | ||
block_time DESC; | ||
vote_tx.id DESC; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.committee_votes IS 'Get all committee votes cast by given committee member or collective'; -- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
CREATE OR REPLACE FUNCTION grest.drep_votes(_drep_id text) | ||
RETURNS TABLE ( | ||
tx_hash text, | ||
proposal_tx_hash text, | ||
cert_index integer, | ||
vote_tx_hash text, | ||
block_time integer, | ||
vote text | ||
) | ||
LANGUAGE sql STABLE | ||
AS $$ | ||
SELECT | ||
ENCODE(tx.hash, 'hex')::text AS tx_hash, | ||
ENCODE(prop_tx.hash, 'hex')::text AS proposal_tx_hash, | ||
gap.index AS cert_index, | ||
ENCODE(vote_tx.hash, 'hex')::text AS vote_tx_hash, | ||
EXTRACT(EPOCH FROM b.time)::integer AS block_time, | ||
vp.vote | ||
FROM public.drep_hash AS dh | ||
INNER JOIN public.voting_procedure AS vp ON dh.id = vp.drep_voter | ||
INNER JOIN public.gov_action_proposal AS gap ON vp.gov_action_proposal_id = gap.id | ||
INNER JOIN public.tx ON gap.tx_id = tx.id | ||
INNER JOIN public.block AS b ON tx.block_id = b.id | ||
INNER JOIN public.tx prop_tx ON gap.tx_id = prop_tx.id | ||
INNER JOIN public.tx vote_tx on vp.tx_id = vote_tx.id | ||
INNER JOIN public.block AS b ON vote_tx.block_id = b.id | ||
WHERE dh.view = _drep_id | ||
ORDER BY | ||
block_time DESC; | ||
vote_tx.id DESC; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.drep_votes IS 'Get all DRep votes cast from specified DRep ID'; -- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
CREATE OR REPLACE FUNCTION grest.pool_votes(_pool_bech32 text) | ||
RETURNS TABLE ( | ||
tx_hash text, | ||
proposal_tx_hash text, | ||
cert_index integer, | ||
vote_tx_hash text, | ||
block_time integer, | ||
vote text | ||
) | ||
LANGUAGE sql STABLE | ||
AS $$ | ||
SELECT | ||
ENCODE(tx.hash, 'hex')::text AS tx_hash, | ||
ENCODE(prop_tx.hash, 'hex')::text AS proposal_tx_hash, | ||
gap.index AS cert_index, | ||
ENCODE(vote_tx.hash, 'hex')::text AS vote_tx_hash, | ||
EXTRACT(EPOCH FROM b.time)::integer AS block_time, | ||
vp.vote | ||
FROM public.pool_hash ph | ||
INNER JOIN public.voting_procedure AS vp ON ph.id = vp.pool_voter | ||
INNER JOIN public.gov_action_proposal AS gap ON vp.gov_action_proposal_id = gap.id | ||
INNER JOIN public.tx ON gap.tx_id = tx.id | ||
INNER JOIN public.block AS b ON tx.block_id = b.id | ||
INNER JOIN public.tx prop_tx ON gap.tx_id = prop_tx.id | ||
INNER JOIN public.tx vote_tx on vp.tx_id = vote_tx.id | ||
INNER JOIN public.block AS b ON vote_tx.block_id = b.id | ||
WHERE ph.view = _pool_bech32 | ||
ORDER BY | ||
block_time DESC; | ||
vote_tx.id DESC; | ||
$$; | ||
|
||
COMMENT ON FUNCTION grest.pool_votes IS 'Get all SPO votes cast for a given pool'; -- 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