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

[#636] add references to all proposal related endpoints #667

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 @@ -16,6 +16,7 @@ changes.

- 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 `references` to all proposal related endpoints
- 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)
Expand Down
1 change: 1 addition & 0 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ SELECT
off_chain_vote_data.motivation,
off_chain_vote_data.rationale,
off_chain_vote_data.json,
off_chain_vote_data.json#>'{body, references}' as references,
coalesce(Sum(ldd.amount) FILTER (WHERE voting_procedure.vote::text = 'Yes'), 0) +(
CASE WHEN gov_action_proposal.type = 'NoConfidence' THEN
always_no_confidence_voting_power.amount
Expand Down
1 change: 1 addition & 0 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ proposalToResponse Types.Proposal {..} =
proposalResponseMotivation = proposalMotivaiton,
proposalResponseRationale = proposalRationale,
proposalResponseMetadata = GovernanceActionMetadata <$> proposalMetadata,
proposalResponseReferences = GovernanceActionReferences <$> proposalReferences,
proposalResponseYesVotes = proposalYesVotes,
proposalResponseNoVotes = proposalNoVotes,
proposalResponseAbstainVotes = proposalAbstainVotes
Expand Down
23 changes: 23 additions & 0 deletions govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,27 @@ instance ToSchema GovernanceActionMetadata where



newtype GovernanceActionReferences
= GovernanceActionReferences Value
deriving newtype (Show)

instance FromJSON GovernanceActionReferences where
parseJSON v@(Aeson.Array a) = pure (GovernanceActionReferences v)
parseJSON _ = fail "GovernanceActionReferences has to be an array"

instance ToJSON GovernanceActionReferences where
toJSON (GovernanceActionReferences g) = g

instance ToSchema GovernanceActionReferences where
declareNamedSchema _ = pure $ NamedSchema (Just "GovernanceActionReferences") $ mempty
& type_ ?~ OpenApiObject
& description ?~ "A Governance Action References"
& example
?~ toJSON
("[{\"uri\": \"google.com\", \"@type\": \"Other\", \"label\": \"example label\"}]" :: Text)



data ProposalResponse
= ProposalResponse
{ proposalResponseId :: Text
Expand All @@ -285,6 +306,7 @@ data ProposalResponse
, proposalResponseMotivation :: Maybe Text
, proposalResponseRationale :: Maybe Text
, proposalResponseMetadata :: Maybe GovernanceActionMetadata
, proposalResponseReferences :: Maybe GovernanceActionReferences
, proposalResponseYesVotes :: Integer
, proposalResponseNoVotes :: Integer
, proposalResponseAbstainVotes :: Integer
Expand All @@ -310,6 +332,7 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
<> "\"motivation\": \"Proposal Motivation\","
<> "\"rationale\": \"Proposal Rationale\","
<> "\"metadata\": {\"key\": \"value\"},"
<> "\"references\": [{\"uri\": \"google.com\", \"@type\": \"Other\", \"label\": \"example label\"}],"
<> "\"yesVotes\": 0,"
<> "\"noVotes\": 0,"
<> "\"abstainVotes\": 0}"
Expand Down
2 changes: 2 additions & 0 deletions govtool/backend/src/VVA/Proposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ getProposals mProposalIds = withPool $ \conn -> do
, motivation'
, rationale'
, metadataJson'
, references'
, yesVotes'
, noVotes'
, abstainVotes'
Expand All @@ -111,6 +112,7 @@ getProposals mProposalIds = withPool $ \conn -> do
motivation'
rationale'
metadataJson'
references'
(floor @Scientific yesVotes')
(floor @Scientific noVotes')
(floor @Scientific abstainVotes')
Expand Down
1 change: 1 addition & 0 deletions govtool/backend/src/VVA/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ data Proposal
, proposalMotivaiton :: Maybe Text
, proposalRationale :: Maybe Text
, proposalMetadata :: Maybe Value
, proposalReferences :: Maybe Value
, proposalYesVotes :: Integer
, proposalNoVotes :: Integer
, proposalAbstainVotes :: Integer
Expand Down
Loading