Skip to content

Commit b29a86c

Browse files
authored
Merge pull request #2454 from IntersectMBO/develop
chore: bump @intersect.mbo/pdf-ui to v0.5.2
2 parents d4c784c + 3b2b867 commit b29a86c

33 files changed

+5195
-7112
lines changed

.github/workflows/test_integration_playwright.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ jobs:
8383
NETWORK: ${{vars.NETWORK}}
8484
FAUCET_ADDRESS: ${{vars.FAUCET_ADDRESS}}
8585
CARDANOAPI_METADATA_URL: ${{vars.CARDANOAPI_METADATA_URL}}
86+
PROPOSAL_FAUCET_PAYMENT_PRIVATE: ${{secrets.PROPOSAL_FAUCET_PAYMENT_PRIVATE}}
87+
PROPOSAL_FAUCET_STAKE_PRIVATE: ${{secrets.PROPOSAL_FAUCET_STAKE_PRIVATE}}
8688

8789
publish-report:
8890
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ changes.
1616

1717
### Fixed
1818

19-
-
19+
- Fix fetching voting power of newly registerd DRep [Issue 2407](https://github.com/IntersectMBO/govtool/issues/2407)
20+
- Fix inconsistent voting status [Issue 1713](https://github.com/IntersectMBO/govtool/issues/1713)
2021

2122
### Changed
2223

govtool/backend/sql/get-network-metrics.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ SELECT
175175
total_gov_action_proposals.count as total_gov_action_proposals,
176176
total_drep_votes.count as total_drep_votes,
177177
total_registered_dreps.unique_registrations as total_registered_dreps,
178-
total_stake_controlled_by_dreps.total as total_stake_controlled_by_dreps,
178+
COALESCE(total_stake_controlled_by_dreps.total, 0) as total_stake_controlled_by_dreps,
179179
total_active_dreps.unique_active_drep_registrations as total_active_dreps,
180180
total_inactive_dreps.total_inactive_dreps as total_inactive_dreps,
181181
total_active_cip119_compliant_dreps.unique_active_cip119_compliant_drep_registrations as total_active_cip119_compliant_dreps,
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
select exists (select * from tx where tx.hash = decode(?, 'hex'))
1+
SELECT
2+
EXISTS (SELECT 1 FROM tx WHERE tx.hash = decode(?, 'hex')) AS tx_exists,
3+
COALESCE(
4+
(SELECT json_agg(voting_procedure.*)
5+
FROM voting_procedure
6+
JOIN tx ON voting_procedure.tx_id = tx.id
7+
WHERE tx.hash = decode(?, 'hex')
8+
), '[]'::json
9+
) AS voting_procedures;

govtool/backend/sql/get-voting-power.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
select sum(uv.value) as amount
1+
select coalesce(sum(uv.value), 0) as amount
22
from utxo_view uv
33
join delegation_vote dv on uv.stake_address_id = dv.addr_id
44
join drep_hash dh on dv.drep_hash_id = dh.id

govtool/backend/src/VVA/API.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Control.Exception (throw, throwIO)
1313
import Control.Monad.Except (runExceptT, throwError)
1414
import Control.Monad.Reader
1515

16-
import Data.Aeson (Value(..), Array, decode, encode, FromJSON, ToJSON)
16+
import Data.Aeson (Value(..), Array, decode, encode, FromJSON, ToJSON, toJSON)
1717
import Data.Bool (Bool)
1818
import Data.List (sortOn)
1919
import qualified Data.Map as Map
@@ -416,11 +416,11 @@ getCurrentEpochParams = do
416416

417417
getTransactionStatus :: App m => HexText -> m GetTransactionStatusResponse
418418
getTransactionStatus (unHexText -> transactionId) = do
419-
x <- Transaction.getTransactionStatus transactionId
420-
case x of
421-
Types.TransactionConfirmed -> return $ GetTransactionStatusResponse True
422-
Types.TransactionUnconfirmed -> return $ GetTransactionStatusResponse False
423-
419+
status <- Transaction.getTransactionStatus transactionId
420+
return $ GetTransactionStatusResponse $ case status of
421+
Just value -> Just $ toJSON value
422+
Nothing -> Nothing
423+
424424
throw500 :: App m => m ()
425425
throw500 = throwError $ CriticalError "intentional system break for testing purposes"
426426

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

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -651,29 +651,26 @@ instance ToSchema GetProposalResponse where
651651
?~ toJSON exampleGetProposalResponse
652652

653653
newtype GetTransactionStatusResponse
654-
= GetTransactionStatusResponse { getTransactionstatusResponseTransactionConfirmed :: Bool }
655-
deriving (Generic, Show)
654+
= GetTransactionStatusResponse { getTransactionStatusResponse :: Maybe Value }
655+
deriving newtype (Show)
656656

657+
instance FromJSON GetTransactionStatusResponse where
658+
parseJSON = pure . GetTransactionStatusResponse . Just
657659

658-
deriveJSON (jsonOptions "getTransactionstatusResponse") ''GetTransactionStatusResponse
660+
instance ToJSON GetTransactionStatusResponse where
661+
toJSON (GetTransactionStatusResponse Nothing) = Null
662+
toJSON (GetTransactionStatusResponse (Just status)) = toJSON status
659663

660664
exampleGetTransactionStatusResponse :: Text
661-
exampleGetTransactionStatusResponse = "{ \"transactionConfirmed\": True }"
665+
exampleGetTransactionStatusResponse =
666+
"{ \"transactionConfirmed\": True, \"votingProcedure\": {\"vote\": \"yes\"}}"
662667

663668
instance ToSchema GetTransactionStatusResponse where
664-
declareNamedSchema proxy = do
665-
NamedSchema name_ schema_ <-
666-
genericDeclareNamedSchema
667-
( fromAesonOptions $
668-
jsonOptions "getTransactionstatusResponse"
669-
)
670-
proxy
671-
return $
672-
NamedSchema name_ $
673-
schema_
674-
& description ?~ "GetTransactionStatus Response"
675-
& example
676-
?~ toJSON exampleGetTransactionStatusResponse
669+
declareNamedSchema _ = pure $ NamedSchema (Just "GetTransactionStatusResponse") $ mempty
670+
& type_ ?~ OpenApiObject
671+
& description ?~ "Transaction status encoded as JSON"
672+
& example
673+
?~ toJSON exampleGetTransactionStatusResponse
677674

678675
newtype DRepHash
679676
= DRepHash Text
@@ -923,4 +920,3 @@ instance ToSchema GetNetworkMetricsResponse where
923920
& description ?~ "GetNetworkMetricsResponse"
924921
& example
925922
?~ toJSON exampleGetNetworkMetricsResponse
926-

govtool/backend/src/VVA/Transaction.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import Data.Has (Has)
1515
import Data.String (fromString)
1616
import Data.Text (Text, pack, unpack)
1717
import qualified Data.Text.Encoding as Text
18+
import qualified Data.Text.IO as Text
19+
import Data.Maybe (fromMaybe)
1820

1921
import qualified Database.PostgreSQL.Simple as SQL
2022

@@ -31,10 +33,10 @@ getTransactionStatusSql = sqlFrom $(embedFile "sql/get-transaction-status.sql")
3133
getTransactionStatus ::
3234
(Has ConnectionPool r, Has VVAConfig r, MonadReader r m, MonadIO m, MonadError AppError m)
3335
=> Text
34-
-> m TransactionStatus
36+
-> m (Maybe TransactionStatus)
3537
getTransactionStatus transactionId = withPool $ \conn -> do
36-
result <- liftIO $ SQL.query conn getTransactionStatusSql (SQL.Only transactionId)
38+
result <- liftIO $ SQL.query conn getTransactionStatusSql (transactionId, transactionId)
3739
case result of
38-
[SQL.Only True] -> return TransactionConfirmed
39-
[SQL.Only False] -> return TransactionUnconfirmed
40-
x -> throwError $ CriticalError ("Expected exactly one result from get-transaction-status.sql but got " <> pack (show (length x)) <> " of them. This should never happen")
40+
[(transactionConfirmed, votingProcedure)] -> do
41+
return $ Just $ TransactionStatus transactionConfirmed votingProcedure
42+
_ -> return Nothing

govtool/backend/src/VVA/Types.hs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE OverloadedStrings #-}
12
{-# LANGUAGE ConstraintKinds #-}
23
{-# LANGUAGE FlexibleContexts #-}
34
{-# LANGUAGE FlexibleInstances #-}
@@ -14,7 +15,7 @@ import Control.Monad.Fail (MonadFail)
1415
import Control.Monad.IO.Class (MonadIO)
1516
import Control.Monad.Reader (MonadReader)
1617

17-
import Data.Aeson (Value)
18+
import Data.Aeson (Value, ToJSON (..), object, (.=))
1819
import qualified Data.Cache as Cache
1920
import Data.Has
2021
import Data.Pool (Pool)
@@ -184,7 +185,20 @@ instance FromRow Proposal where
184185
<*> field
185186
<*> field
186187

187-
data TransactionStatus = TransactionConfirmed | TransactionUnconfirmed
188+
data TransactionStatus = TransactionStatus
189+
{ transactionConfirmed :: Bool
190+
, votingProcedure :: Maybe Value
191+
}
192+
193+
instance FromRow TransactionStatus where
194+
fromRow = TransactionStatus <$> field <*> field
195+
196+
instance ToJSON TransactionStatus where
197+
toJSON TransactionStatus {transactionConfirmed, votingProcedure} =
198+
object
199+
[ "transactionConfirmed" .= transactionConfirmed
200+
, "votingProcedure" .= votingProcedure
201+
]
188202

189203
data CacheEnv
190204
= CacheEnv

0 commit comments

Comments
 (0)