Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(#1600): add support for previous governance action data #1804

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ changes.
- Add support for displaying protocol parameters governance actions [Issue 1601](https://github.com/IntersectMBO/govtool/issues/1601)
- Add SPO and CC committee total votes to gov actions [Issue 1704](https://github.com/IntersectMBO/govtool/issues/1704)
- Add support for hard fork initiation governance action details [Issue 1600](https://github.com/IntersectMBO/govtool/issues/1600)
- Add support for hard fork initiation previous governance action data [Issue 1600](https://github.com/IntersectMBO/govtool/issues/1600)

### Fixed

Expand Down
14 changes: 10 additions & 4 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ SELECT

when gov_action_proposal.type::text = 'HardForkInitiation' then
json_build_object(
'major', (description->'contents'->1->>'major')::int,
'minor', (description->'contents'->1->>'minor')::int
'major', (gov_action_proposal.description->'contents'->1->>'major')::int,
'minor', (gov_action_proposal.description->'contents'->1->>'minor')::int
)
else
null
Expand Down Expand Up @@ -83,7 +83,9 @@ SELECT
coalesce(Sum(ldd_pool.amount) FILTER (WHERE voting_procedure.vote::text = 'Abstain'), 0),
coalesce(Sum(ldd_cc.amount) FILTER (WHERE voting_procedure.vote::text = 'Yes'), 0),
coalesce(Sum(ldd_cc.amount) FILTER (WHERE voting_procedure.vote::text = 'No'), 0),
coalesce(Sum(ldd_cc.amount) FILTER (WHERE voting_procedure.vote::text = 'Abstain'), 0)
coalesce(Sum(ldd_cc.amount) FILTER (WHERE voting_procedure.vote::text = 'Abstain'), 0),
prev_gov_action.index as prev_gov_action_index,
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash
FROM
gov_action_proposal
LEFT JOIN treasury_withdrawal
Expand All @@ -106,6 +108,8 @@ FROM
AND ldd_pool.rn = 1
LEFT JOIN LatestDrepDistr ldd_cc ON ldd_cc.hash_id = voting_procedure.committee_voter
AND ldd_cc.rn = 1
LEFT JOIN gov_action_proposal AS prev_gov_action ON gov_action_proposal.prev_gov_action_proposal = prev_gov_action.id
LEFT JOIN tx AS prev_gov_action_tx ON prev_gov_action.tx_id = prev_gov_action_tx.id
WHERE (NOT ?
OR (concat(encode(creator_tx.hash, 'hex'), '#', gov_action_proposal.index) IN ?))
AND gov_action_proposal.expiration >(
Expand Down Expand Up @@ -136,4 +140,6 @@ GROUP BY
voting_anchor.url,
voting_anchor.data_hash,
always_no_confidence_voting_power.amount,
always_abstain_voting_power.amount)
always_abstain_voting_power.amount,
prev_gov_action.index,
prev_gov_action_tx.hash)
4 changes: 3 additions & 1 deletion govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ proposalToResponse timeZone Types.Proposal {..} =
proposalResponsePoolAbstainVotes = proposalPoolAbstainVotes,
proposalResponseCcYesVotes = proposalCcYesVotes,
proposalResponseCcNoVotes = proposalCcNoVotes,
proposalResponseCcAbstainVotes = proposalCcAbstainVotes
proposalResponseCcAbstainVotes = proposalCcAbstainVotes,
proposalResponsePrevGovActionIndex = proposalPrevGovActionIndex,
proposalResponsePrevGovActionTxHash = HexText <$> proposalPrevGovActionTxHash
}

voteToResponse :: Types.Vote -> VoteParams
Expand Down
56 changes: 30 additions & 26 deletions govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -476,31 +476,33 @@ instance ToSchema GovernanceActionReferences where

data ProposalResponse
= ProposalResponse
{ proposalResponseId :: Text
, proposalResponseTxHash :: HexText
, proposalResponseIndex :: Integer
, proposalResponseType :: GovernanceActionType
, proposalResponseDetails :: Maybe GovernanceActionDetails
, proposalResponseExpiryDate :: Maybe UTCTime
, proposalResponseExpiryEpochNo :: Maybe Integer
, proposalResponseCreatedDate :: UTCTime
, proposalResponseCreatedEpochNo :: Integer
, proposalResponseUrl :: Text
, proposalResponseMetadataHash :: HexText
, proposalResponseProtocolParams :: Maybe ProtocolParams
, proposalResponseTitle :: Maybe Text
, proposalResponseAbstract :: Maybe Text
, proposalResponseMotivation :: Maybe Text
, proposalResponseRationale :: Maybe Text
, proposalResponseDRepYesVotes :: Integer
, proposalResponseDRepNoVotes :: Integer
, proposalResponseDRepAbstainVotes :: Integer
, proposalResponsePoolYesVotes :: Integer
, proposalResponsePoolNoVotes :: Integer
, proposalResponsePoolAbstainVotes :: Integer
, proposalResponseCcYesVotes :: Integer
, proposalResponseCcNoVotes :: Integer
, proposalResponseCcAbstainVotes :: Integer
{ proposalResponseId :: Text
, proposalResponseTxHash :: HexText
, proposalResponseIndex :: Integer
, proposalResponseType :: GovernanceActionType
, proposalResponseDetails :: Maybe GovernanceActionDetails
, proposalResponseExpiryDate :: Maybe UTCTime
, proposalResponseExpiryEpochNo :: Maybe Integer
, proposalResponseCreatedDate :: UTCTime
, proposalResponseCreatedEpochNo :: Integer
, proposalResponseUrl :: Text
, proposalResponseMetadataHash :: HexText
, proposalResponseProtocolParams :: Maybe ProtocolParams
, proposalResponseTitle :: Maybe Text
, proposalResponseAbstract :: Maybe Text
, proposalResponseMotivation :: Maybe Text
, proposalResponseRationale :: Maybe Text
, proposalResponseDRepYesVotes :: Integer
, proposalResponseDRepNoVotes :: Integer
, proposalResponseDRepAbstainVotes :: Integer
, proposalResponsePoolYesVotes :: Integer
, proposalResponsePoolNoVotes :: Integer
, proposalResponsePoolAbstainVotes :: Integer
, proposalResponseCcYesVotes :: Integer
, proposalResponseCcNoVotes :: Integer
, proposalResponseCcAbstainVotes :: Integer
, proposalResponsePrevGovActionIndex :: Maybe Integer
, proposalResponsePrevGovActionTxHash :: Maybe HexText
}
deriving (Generic, Show)

Expand Down Expand Up @@ -531,7 +533,9 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
<> "\"poolAbstainVotes\": 0,"
<> "\"cCYesVotes\": 0,"
<> "\"cCNoVotes\": 0,"
<> "\"cCAbstainVotes\": 0}"
<> "\"cCAbstainVotes\": 0,"
<> "\"prevGovActionIndex\": 0,"
<> "\"prevGovActionTxHash\": \"47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\"}"

instance ToSchema ProposalResponse where
declareNamedSchema proxy = do
Expand Down
54 changes: 29 additions & 25 deletions govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,31 +106,33 @@ data DRepRegistration

data Proposal
= Proposal
{ proposalId :: Integer
, proposalTxHash :: Text
, proposalIndex :: Integer
, proposalType :: Text
, proposalDetails :: Maybe Value
, proposalExpiryDate :: Maybe LocalTime
, proposalExpiryEpochNo :: Maybe Integer
, proposalCreatedDate :: LocalTime
, proposalCreatedEpochNo :: Integer
, proposalUrl :: Text
, proposalDocHash :: Text
, proposalProtocolParams :: Maybe Value
, proposalTitle :: Maybe Text
, proposalAbstract :: Maybe Text
, proposalMotivation :: Maybe Text
, proposalRationale :: Maybe Text
, proposalDRepYesVotes :: Integer
, proposalDRepNoVotes :: Integer
, proposalDRepAbstainVotes :: Integer
, proposalPoolYesVotes :: Integer
, proposalPoolNoVotes :: Integer
, proposalPoolAbstainVotes :: Integer
, proposalCcYesVotes :: Integer
, proposalCcNoVotes :: Integer
, proposalCcAbstainVotes :: Integer
{ proposalId :: Integer
, proposalTxHash :: Text
, proposalIndex :: Integer
, proposalType :: Text
, proposalDetails :: Maybe Value
, proposalExpiryDate :: Maybe LocalTime
, proposalExpiryEpochNo :: Maybe Integer
, proposalCreatedDate :: LocalTime
, proposalCreatedEpochNo :: Integer
, proposalUrl :: Text
, proposalDocHash :: Text
, proposalProtocolParams :: Maybe Value
, proposalTitle :: Maybe Text
, proposalAbstract :: Maybe Text
, proposalMotivation :: Maybe Text
, proposalRationale :: Maybe Text
, proposalDRepYesVotes :: Integer
, proposalDRepNoVotes :: Integer
, proposalDRepAbstainVotes :: Integer
, proposalPoolYesVotes :: Integer
, proposalPoolNoVotes :: Integer
, proposalPoolAbstainVotes :: Integer
, proposalCcYesVotes :: Integer
, proposalCcNoVotes :: Integer
, proposalCcAbstainVotes :: Integer
, proposalPrevGovActionIndex :: Maybe Integer
, proposalPrevGovActionTxHash :: Maybe Text
}
deriving (Show)

Expand Down Expand Up @@ -162,6 +164,8 @@ instance FromRow Proposal where
<*> (floor @Scientific <$> field)
<*> (floor @Scientific <$> field)
<*> (floor @Scientific <$> field)
<*> field
<*> field

data TransactionStatus = TransactionConfirmed | TransactionUnconfirmed

Expand Down
Loading