diff --git a/CHANGELOG.md b/CHANGELOG.md index 88c975b44..38437d6bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,9 @@ changes. - Integrate frontend with metadata validation service [Issue 617](https://github.com/IntersectMBO/govtool/issues/617) ### Added + - addded latestTxHash to the `drep/info` and `drep/list` endpoints [Issue 627](https://github.com/IntersectMBO/govtool/issues/627) +- added `txHash` to `drep/getVotes` [Issue 626](https://github.com/IntersectMBO/govtool/issues/626) - added `epochNo` and `date` to `drep/getVotes` and `proposal/get` - Added `isRegisteredAsSoleVoter` and `wasRegisteredAsSoleVoter` fields to the drep/info response [Issue 212](https://github.com/IntersectMBO/govtool/issues/212) - Abandoning registration as DRep [Issue 151](https://github.com/IntersectMBO/govtool/issues/151) diff --git a/govtool/backend/sql/get-votes.sql b/govtool/backend/sql/get-votes.sql index 18ff422fd..1e9a49cfe 100644 --- a/govtool/backend/sql/get-votes.sql +++ b/govtool/backend/sql/get-votes.sql @@ -1,14 +1,15 @@ -select DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter) voting_procedure.gov_action_proposal_id, concat(encode(tx.hash,'hex'),'#',gov_action_proposal.index), encode(drep_hash.raw, 'hex'), voting_procedure.vote::text, voting_anchor.url, encode(voting_anchor.data_hash, 'hex'), block.epoch_no as epoch_no, block.time as time -from voting_procedure +select DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter) voting_procedure.gov_action_proposal_id, concat(encode(gov_action_tx.hash,'hex'),'#',gov_action_proposal.index), encode(drep_hash.raw, 'hex'), voting_procedure.vote::text, voting_anchor.url, encode(voting_anchor.data_hash, 'hex'), block.epoch_no as epoch_no, block.time as time, encode(vote_tx.hash, 'hex') as vote_tx_hash join gov_action_proposal on gov_action_proposal.id = voting_procedure.gov_action_proposal_id join drep_hash on drep_hash.id = voting_procedure.drep_voter left join voting_anchor on voting_anchor.id = voting_procedure.voting_anchor_id -join tx -on tx.id = gov_action_proposal.tx_id +join tx as gov_action_tx +on gov_action_tx.id = gov_action_proposal.tx_id +join tx as vote_tx +on vote_tx.id = voting_procedure.tx_id join block -on block.id = tx.block_id +on block.id = gov_action_tx.block_id where drep_hash.raw = decode(?, 'hex') order by voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter, voting_procedure.id desc diff --git a/govtool/backend/src/VVA/API.hs b/govtool/backend/src/VVA/API.hs index 08b067dd2..e5ef660a0 100644 --- a/govtool/backend/src/VVA/API.hs +++ b/govtool/backend/src/VVA/API.hs @@ -152,7 +152,8 @@ voteToResponse Types.Vote {..} = voteParamsUrl = voteUrl, voteParamsMetadataHash = HexText <$> voteDocHash, voteParamsEpochNo = voteEpochNo, - voteParamsDate = voteDate + voteParamsDate = voteDate, + voteParamsTxHash = HexText voteTxHash } diff --git a/govtool/backend/src/VVA/API/Types.hs b/govtool/backend/src/VVA/API/Types.hs index 8c1cb49d4..d1e2024ca 100644 --- a/govtool/backend/src/VVA/API/Types.hs +++ b/govtool/backend/src/VVA/API/Types.hs @@ -372,6 +372,7 @@ data VoteParams , voteParamsMetadataHash :: Maybe HexText , voteParamsEpochNo :: Integer , voteParamsDate :: UTCTime + , voteParamsTxHash :: HexText } deriving (Generic, Show) @@ -385,7 +386,8 @@ exampleVoteParams = <> "\"url\": \"https://vote.metadata.xyz\"," <> "\"metadataHash\": \"9af10e89979e51b8cdc827c963124a1ef4920d1253eef34a1d5cfe76438e3f11\"," <> "\"epochNo\": 0," - <> "\"date\": \"1970-01-01T00:00:00Z\"}" + <> "\"date\": \"1970-01-01T00:00:00Z\"," + <> "\"txHash\": \"47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\"}" instance ToSchema VoteParams where declareNamedSchema proxy = do diff --git a/govtool/backend/src/VVA/DRep.hs b/govtool/backend/src/VVA/DRep.hs index 9bc5c9e03..dd0422c4c 100644 --- a/govtool/backend/src/VVA/DRep.hs +++ b/govtool/backend/src/VVA/DRep.hs @@ -82,14 +82,14 @@ getVotes :: getVotes drepId selectedProposals = withPool $ \conn -> do results <- liftIO $ SQL.query conn getVotesSql (SQL.Only drepId) let proposalsToSelect = if null selectedProposals - then [ govActionId | (_, govActionId, _, _, _, _, _, _) <- results] + then [ govActionId | (_, govActionId, _, _, _, _, _, _, _) <- results] else selectedProposals proposals <- Proposal.getProposals (Just proposalsToSelect) let proposalMap = M.fromList $ map (\x -> (proposalId x, x)) proposals timeZone <- liftIO getCurrentTimeZone return - ([ Vote proposalId' drepId' vote' url' docHash' epochNo' (localTimeToUTC timeZone date') - | (proposalId', govActionId', drepId', vote', url', docHash', epochNo', date') <- results + ([ Vote proposalId' drepId' vote' url' docHash' epochNo' (localTimeToUTC timeZone date') voteTxHash' + | (proposalId', govActionId', drepId', vote', url', docHash', epochNo', date', voteTxHash') <- results , govActionId' `elem` proposalsToSelect ], proposals) diff --git a/govtool/backend/src/VVA/Types.hs b/govtool/backend/src/VVA/Types.hs index cc2f74f17..b913270d3 100644 --- a/govtool/backend/src/VVA/Types.hs +++ b/govtool/backend/src/VVA/Types.hs @@ -62,6 +62,7 @@ data Vote , voteDocHash :: Maybe Text , voteEpochNo :: Integer , voteDate :: UTCTime + , voteTxHash :: Text } data DRepInfo