Skip to content

Commit 324a265

Browse files
authored
Merge pull request #3284 from IntersectMBO/staging
GovTool - v2.0.18
2 parents 4253b82 + 77c131c commit 324a265

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+587
-183
lines changed

.github/workflows/test_backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162

163163
publish-status:
164164
runs-on: ubuntu-latest
165-
if: always()
165+
if: always() && needs.backend-tests.result != 'skipped'
166166
needs: [backend-tests, publish-report]
167167
steps:
168168
- uses: actions/checkout@v4

.github/workflows/test_integration_playwright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202

203203
publish-status:
204204
runs-on: ubuntu-latest
205-
if: always()
205+
if: always() && needs.integration-tests.result != 'skipped'
206206
needs: [integration-tests, publish-report]
207207
steps:
208208
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,26 @@ changes.
1818

1919
### Removed
2020

21-
## [v2.0.17](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.17) 2025-03-18
21+
## [v2.0.18](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.18) 2025-03-26
22+
23+
### Added
24+
25+
- Add redirection to outcomes when proposal is not found [Issue 3230](https://github.com/IntersectMBO/govtool/issues/3230)
26+
- Add DRep voting power list endpoint [Issue 3263](https://github.com/IntersectMBO/govtool/issues/3263)
27+
- Add DRep given name to the voting power list endpoint [Issue 3273](https://github.com/IntersectMBO/govtool/issues/3273)
28+
- Add DRep voting power list query to PDF Pillar [Issue 3277](https://github.com/IntersectMBO/govtool/issues/3277)
29+
30+
### Fixed
31+
32+
- Fix post-vote navigation to governance action list [Issue 3242](https://github.com/IntersectMBO/govtool/issues/3242)
2233

34+
### Changed
35+
36+
- Bump CSL to v14 [Issue 3037](https://github.com/IntersectMBO/govtool/issues/3037)
37+
38+
### Removed
39+
40+
## [v2.0.17](https://github.com/IntersectMBO/govtool/releases/tag/v2.0.17) 2025-03-18
2341

2442
### Added
2543

govtool/backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
44
WORKDIR /src
55
COPY . .
66
RUN cabal build
7-
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.17/x/vva-be/build/vva-be/vva-be /usr/local/bin
7+
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.18/x/vva-be/build/vva-be/vva-be /usr/local/bin

govtool/backend/Dockerfile.qovery

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM $BASE_IMAGE_REPO:$BASE_IMAGE_TAG
44
WORKDIR /src
55
COPY . .
66
RUN cabal build
7-
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.17/x/vva-be/build/vva-be/vva-be /usr/local/bin
7+
RUN cp dist-newstyle/build/x86_64-linux/ghc-9.2.7/vva-be-2.0.18/x/vva-be/build/vva-be/vva-be /usr/local/bin
88

99
# Expose the necessary port
1010
EXPOSE 9876

govtool/backend/app/Main.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ startApp vvaConfig sentryService = do
124124
networkMetricsCache <- newCache
125125
networkInfoCache <- newCache
126126
networkTotalStakeCache <- newCache
127+
dRepVotingPowerListCache <- newCache
127128
return $ CacheEnv
128129
{ proposalListCache
129130
, getProposalCache
@@ -137,6 +138,7 @@ startApp vvaConfig sentryService = do
137138
, networkMetricsCache
138139
, networkInfoCache
139140
, networkTotalStakeCache
141+
, dRepVotingPowerListCache
140142
}
141143

142144
let connectionString = encodeUtf8 (dbSyncConnectionString $ getter vvaConfig)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
WITH LatestExistingVotingAnchor AS (
2+
SELECT
3+
subquery.drep_registration_id,
4+
subquery.drep_hash_id,
5+
subquery.voting_anchor_id,
6+
subquery.url,
7+
subquery.metadata_hash,
8+
subquery.ocvd_id
9+
FROM (
10+
SELECT
11+
dr.id AS drep_registration_id,
12+
dr.drep_hash_id,
13+
va.id AS voting_anchor_id,
14+
va.url,
15+
encode(va.data_hash, 'hex') AS metadata_hash,
16+
ocvd.id AS ocvd_id,
17+
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn
18+
FROM
19+
drep_registration dr
20+
JOIN voting_anchor va ON dr.voting_anchor_id = va.id
21+
JOIN off_chain_vote_data ocvd ON va.id = ocvd.voting_anchor_id
22+
WHERE
23+
ocvd.voting_anchor_id IS NOT NULL
24+
) subquery
25+
WHERE
26+
subquery.rn = 1
27+
)
28+
SELECT DISTINCT ON (raw)
29+
view,
30+
encode(raw, 'hex') AS hash_raw,
31+
COALESCE(dd.amount, 0) AS voting_power,
32+
ocvdd.given_name
33+
FROM drep_hash dh
34+
LEFT JOIN drep_distr dd ON dh.id = dd.hash_id AND dd.epoch_no = (SELECT MAX(no) from epoch)
35+
LEFT JOIN LatestExistingVotingAnchor leva ON leva.drep_hash_id = dh.id
36+
LEFT JOIN off_chain_vote_data ocvd ON ocvd.id = leva.ocvd_id
37+
LEFT JOIN off_chain_vote_drep_data ocvdd ON ocvdd.off_chain_vote_data_id = ocvd.id
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
WITH LatestExistingVotingAnchor AS (
2+
SELECT
3+
subquery.drep_registration_id,
4+
subquery.drep_hash_id,
5+
subquery.voting_anchor_id,
6+
subquery.url,
7+
subquery.metadata_hash,
8+
subquery.ocvd_id
9+
FROM (
10+
SELECT
11+
dr.id AS drep_registration_id,
12+
dr.drep_hash_id,
13+
va.id AS voting_anchor_id,
14+
va.url,
15+
encode(va.data_hash, 'hex') AS metadata_hash,
16+
ocvd.id AS ocvd_id,
17+
ROW_NUMBER() OVER (PARTITION BY dr.drep_hash_id ORDER BY dr.tx_id DESC) AS rn
18+
FROM
19+
drep_registration dr
20+
JOIN voting_anchor va ON dr.voting_anchor_id = va.id
21+
JOIN off_chain_vote_data ocvd ON va.id = ocvd.voting_anchor_id
22+
WHERE
23+
ocvd.voting_anchor_id IS NOT NULL
24+
) subquery
25+
WHERE
26+
subquery.rn = 1
27+
)
28+
SELECT DISTINCT ON (raw)
29+
view,
30+
encode(raw, 'hex') AS hash_raw,
31+
COALESCE(dd.amount, 0) AS voting_power,
32+
ocvdd.given_name
33+
FROM drep_hash dh
34+
LEFT JOIN drep_distr dd ON dh.id = dd.hash_id AND dd.epoch_no = (SELECT MAX(no) from epoch)
35+
LEFT JOIN LatestExistingVotingAnchor leva ON leva.drep_hash_id = dh.id
36+
LEFT JOIN off_chain_vote_data ocvd ON ocvd.id = leva.ocvd_id
37+
LEFT JOIN off_chain_vote_drep_data ocvdd ON ocvdd.off_chain_vote_data_id = ocvd.id
38+
WHERE view = ? OR encode(raw, 'hex') = ?

govtool/backend/src/VVA/API.hs

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Control.Monad.Reader
1515

1616
import Data.Aeson (Value(..), Array, decode, encode, ToJSON, toJSON)
1717
import Data.Bool (Bool)
18-
import Data.List (sortOn)
18+
import Data.List (sortOn, sort)
1919
import qualified Data.Map as Map
2020
import Data.Maybe (Maybe (Nothing), catMaybes, fromMaybe, mapMaybe)
2121
import Data.Ord (Down (..))
@@ -64,6 +64,9 @@ type VVAApi =
6464
:> QueryParam "search" Text
6565
:> Get '[JSON] [VoteResponse]
6666
:<|> "drep" :> "info" :> Capture "drepId" HexText :> Get '[JSON] DRepInfoResponse
67+
:<|> "drep" :> "voting-power-list"
68+
:> QueryParams "identifiers" Text
69+
:> Get '[JSON] [DRepVotingPowerListResponse]
6770
:<|> "ada-holder" :> "get-current-delegation" :> Capture "stakeKey" HexText :> Get '[JSON] (Maybe DelegationResponse)
6871
:<|> "ada-holder" :> "get-voting-power" :> Capture "stakeKey" HexText :> Get '[JSON] Integer
6972
:<|> "proposal" :> "list"
@@ -87,6 +90,7 @@ server = drepList
8790
:<|> getVotingPower
8891
:<|> getVotes
8992
:<|> drepInfo
93+
:<|> drepVotingPowerList
9094
:<|> getCurrentDelegation
9195
:<|> getStakeKeyVotingPower
9296
:<|> listProposals
@@ -283,18 +287,20 @@ getVotes (unHexText -> dRepId) selectedTypes sortMode mSearch = do
283287
CacheEnv {dRepGetVotesCache} <- asks vvaCache
284288
(votes, proposals) <- cacheRequest dRepGetVotesCache dRepId $ DRep.getVotes dRepId []
285289

286-
let voteMap = Map.fromList $ map (\vote@Types.Vote {..} -> (voteProposalId, vote)) votes
287-
288-
processedProposals <- filter (isProposalSearchedFor mSearch) <$> mapSortAndFilterProposals selectedTypes sortMode proposals
289-
290+
let voteMapByTxHash = Map.fromList $
291+
map (\vote -> (pack $ Prelude.takeWhile (/= '#') (unpack $ Types.voteGovActionId vote), vote)) votes
292+
293+
processedProposals <- filter (isProposalSearchedFor mSearch) <$>
294+
mapSortAndFilterProposals selectedTypes sortMode proposals
295+
290296
return $
291297
[ VoteResponse
292298
{ voteResponseVote = voteToResponse vote
293299
, voteResponseProposal = proposalResponse
294300
}
295-
| proposalResponse@ProposalResponse{proposalResponseId} <- processedProposals
296-
, let proposalIdInt = read (unpack proposalResponseId) :: Int
297-
, Just vote <- [Map.lookup (toInteger proposalIdInt) voteMap]
301+
| proposalResponse <- processedProposals
302+
, let txHash = unHexText (proposalResponseTxHash proposalResponse)
303+
, Just vote <- [Map.lookup txHash voteMapByTxHash]
298304
]
299305

300306
drepInfo :: App m => HexText -> m DRepInfoResponse
@@ -324,6 +330,25 @@ drepInfo (unHexText -> dRepId) = do
324330
, dRepInfoResponseImageHash = HexText <$> dRepInfoImageHash
325331
}
326332

333+
drepVotingPowerList :: App m => [Text] -> m [DRepVotingPowerListResponse]
334+
drepVotingPowerList identifiers = do
335+
CacheEnv {dRepVotingPowerListCache} <- asks vvaCache
336+
337+
let cacheKey = Text.intercalate "," (sort identifiers)
338+
339+
results <- cacheRequest dRepVotingPowerListCache cacheKey $
340+
DRep.getDRepsVotingPowerList identifiers
341+
342+
return $ map toDRepVotingPowerListResponse results
343+
where
344+
toDRepVotingPowerListResponse Types.DRepVotingPowerList{..} =
345+
DRepVotingPowerListResponse
346+
{ drepVotingPowerListResponseView = drepView
347+
, drepVotingPowerListResponseHashRaw = HexText drepHashRaw
348+
, drepVotingPowerListResponseVotingPower = drepVotingPower
349+
, drepVotingPowerListResponseGivenName = drepGivenName
350+
}
351+
327352
getCurrentDelegation :: App m => HexText -> m (Maybe DelegationResponse)
328353
getCurrentDelegation (unHexText -> stakeKey) = do
329354
CacheEnv {adaHolderGetCurrentDelegationCache} <- asks vvaCache

govtool/backend/src/VVA/API/Types.hs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,37 @@ instance ToSchema DRepInfoResponse where
622622
& example
623623
?~ toJSON exampleDRepInfoResponse
624624

625+
data DRepVotingPowerListResponse
626+
= DRepVotingPowerListResponse
627+
{ drepVotingPowerListResponseView :: Text
628+
, drepVotingPowerListResponseHashRaw :: HexText
629+
, drepVotingPowerListResponseVotingPower :: Integer
630+
, drepVotingPowerListResponseGivenName :: Maybe Text
631+
}
632+
deriving (Generic, Show)
633+
634+
deriveJSON (jsonOptions "drepVotingPowerListResponse") ''DRepVotingPowerListResponse
635+
636+
exampleDRepVotingPowerListResponse :: Text
637+
exampleDRepVotingPowerListResponse =
638+
"{\"view\": \"drep1qq5n7k0r0ff6lf4qvndw9t7vmdqa9y3q9qtjq879rrk9vcjcdy8a4xf92mqsajf9u3nrsh3r6zrp29kuydmfq45fz88qpzmjkc\","
639+
<> "\"hashRaw\": \"9af10e89979e51b8cdc827c963124a1ef4920d1253eef34a1d5cfe76438e3f11\","
640+
<> "\"votingPower\": 1000000,"
641+
<> "\"givenName\": \"John Doe\"}"
642+
643+
instance ToSchema DRepVotingPowerListResponse where
644+
declareNamedSchema proxy = do
645+
NamedSchema name_ schema_ <-
646+
genericDeclareNamedSchema
647+
( fromAesonOptions $ jsonOptions "drepVotingPowerListResponse" )
648+
proxy
649+
return $
650+
NamedSchema name_ $
651+
schema_
652+
& description ?~ "DRep Voting Power List Response"
653+
& example
654+
?~ toJSON exampleDRepVotingPowerListResponse
655+
625656
data GetProposalResponse
626657
= GetProposalResponse
627658
{ getProposalResponseVote :: Maybe VoteParams

0 commit comments

Comments
 (0)