Skip to content

Commit 3a05ef7

Browse files
committed
[fix] authors case formatting for gov actions
1 parent 8188beb commit 3a05ef7

File tree

4 files changed

+29
-8
lines changed

4 files changed

+29
-8
lines changed

govtool/backend/sql/list-proposals.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,13 @@ SELECT
304304
COALESCE(cv.ccAbstainVotes, 0) cc_abstain_votes,
305305
prev_gov_action.index as prev_gov_action_index,
306306
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash,
307+
off_chain_vote_data.body,
307308
COALESCE(
308309
json_agg(
309310
json_build_object(
310311
'name', off_chain_vote_author.name,
311-
'witness_algorithm', off_chain_vote_author.witness_algorithm,
312-
'public_key', off_chain_vote_author.public_key,
312+
'witnessAlgorithm', off_chain_vote_author.witness_algorithm,
313+
'publicKey', off_chain_vote_author.public_key,
313314
'signature', off_chain_vote_author.signature
314315
)
315316
) FILTER (WHERE off_chain_vote_author.id IS NOT NULL),
@@ -367,4 +368,5 @@ GROUP BY
367368
off_chain_vote_gov_action_data.title,
368369
off_chain_vote_gov_action_data.abstract,
369370
off_chain_vote_gov_action_data.motivation,
370-
off_chain_vote_gov_action_data.rationale;
371+
off_chain_vote_gov_action_data.rationale,
372+
off_chain_vote_data.body;

govtool/backend/src/VVA/API.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ proposalToResponse timeZone Types.Proposal {..} =
245245
proposalResponseCcAbstainVotes = proposalCcAbstainVotes,
246246
proposalResponsePrevGovActionIndex = proposalPrevGovActionIndex,
247247
proposalResponsePrevGovActionTxHash = HexText <$> proposalPrevGovActionTxHash,
248+
proposalResponseBody = proposalBody,
248249
proposalResponseAuthors = ProposalAuthors <$> proposalAuthors
249250
}
250251

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ data ProposalResponse
401401
, proposalResponseCcAbstainVotes :: Integer
402402
, proposalResponsePrevGovActionIndex :: Maybe Integer
403403
, proposalResponsePrevGovActionTxHash :: Maybe HexText
404+
, proposalResponseBody :: Maybe Value
404405
, proposalResponseAuthors :: Maybe ProposalAuthors
405406
}
406407
deriving (Generic, Show)
@@ -422,18 +423,31 @@ instance ToSchema ProposalAuthors where
422423
& example ?~ toJSON
423424
[ object
424425
[ "name" .= ("Alice" :: Text)
425-
, "witness_algorithm" .= ("algo" :: Text)
426-
, "public_key" .= ("key" :: Text)
426+
, "witnessAlgorithm" .= ("algo" :: Text)
427+
, "publicKey" .= ("key" :: Text)
427428
, "signature" .= ("sig" :: Text)
428429
]
429430
, object
430431
[ "name" .= ("Bob" :: Text)
431-
, "witness_algorithm" .= ("algo2" :: Text)
432-
, "public_key" .= ("key2" :: Text)
432+
, "witnessAlgorithm" .= ("algo2" :: Text)
433+
, "publicKey" .= ("key2" :: Text)
433434
, "signature" .= ("sig2" :: Text)
434435
]
435436
]
436437

438+
exampleProposalAuthors :: Text
439+
exampleProposalAuthors =
440+
"[\
441+
\ {\"name\": \"Alice\",\
442+
\ \"witnessAlgorithm\": \"Ed25519\",\
443+
\ \"publicKey\": \"abcdef123456\",\
444+
\ \"signature\": \"deadbeef\"},\
445+
\ {\"name\": \"Bob\",\
446+
\ \"witnessAlgorithm\": \"Ed25519\",\
447+
\ \"publicKey\": \"123456abcdef\",\
448+
\ \"signature\": \"beefdead\"}\
449+
\]"
450+
437451
deriveJSON (jsonOptions "proposalResponse") ''ProposalResponse
438452

439453
exampleProposalResponse :: Text
@@ -463,7 +477,9 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
463477
<> "\"cCNoVotes\": 0,"
464478
<> "\"cCAbstainVotes\": 0,"
465479
<> "\"prevGovActionIndex\": 0,"
466-
<> "\"prevGovActionTxHash\": \"47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\"}"
480+
<> "\"prevGovActionTxHash\": \"47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\","
481+
<> "\"authors\": " <> exampleProposalAuthors
482+
<> "}"
467483

468484
instance ToSchema Value where
469485
declareNamedSchema _ = pure $ NamedSchema (Just "Value") $ mempty

govtool/backend/src/VVA/Types.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ data Proposal
208208
, proposalCcAbstainVotes :: Integer
209209
, proposalPrevGovActionIndex :: Maybe Integer
210210
, proposalPrevGovActionTxHash :: Maybe Text
211+
, proposalBody :: Maybe Value
211212
, proposalAuthors :: Maybe Value
212213
}
213214
deriving (Show)
@@ -242,6 +243,7 @@ instance FromRow Proposal where
242243
<*> (floor @Scientific <$> field) -- proposalCcAbstainVotes
243244
<*> field -- prevGovActionIndex
244245
<*> field -- prevGovActionTxHash
246+
<*> field -- proposalBody
245247
<*> field -- proposalAuthors
246248

247249
data TransactionStatus = TransactionStatus

0 commit comments

Comments
 (0)