Skip to content

Commit 8712e7a

Browse files
committed
wip
1 parent c5b9232 commit 8712e7a

File tree

7 files changed

+54
-2
lines changed

7 files changed

+54
-2
lines changed

govtool/backend/sql/list-proposals.sql

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,18 @@ SELECT
303303
COALESCE(cv.ccNoVotes, 0) cc_no_votes,
304304
COALESCE(cv.ccAbstainVotes, 0) cc_abstain_votes,
305305
prev_gov_action.index as prev_gov_action_index,
306-
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash
306+
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash,
307+
COALESCE(
308+
json_agg(
309+
json_build_object(
310+
'name', off_chain_vote_author.name,
311+
'witness_algorithm', off_chain_vote_author.witness_algorithm,
312+
'public_key', off_chain_vote_author.public_key,
313+
'signature', off_chain_vote_author.signature
314+
)
315+
) FILTER (WHERE off_chain_vote_author.id IS NOT NULL),
316+
'[]'
317+
) authors
307318
FROM
308319
gov_action_proposal
309320
JOIN ActiveProposals ON gov_action_proposal.id = ActiveProposals.id
@@ -314,6 +325,7 @@ FROM
314325
LEFT JOIN block AS creator_block ON creator_block.id = creator_tx.block_id
315326
LEFT JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_id
316327
LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = voting_anchor.id
328+
lEFT JOIN off_chain_vote_author ON off_chain_vote_author.off_chain_vote_data_id = off_chain_vote_data.id
317329
LEFT JOIN off_chain_vote_gov_action_data ON off_chain_vote_gov_action_data.off_chain_vote_data_id = off_chain_vote_data.id
318330
LEFT JOIN param_proposal AS proposal_params ON gov_action_proposal.param_proposal = proposal_params.id
319331
LEFT JOIN cost_model AS cost_model ON proposal_params.cost_model_id = cost_model.id

govtool/backend/src/VVA/API.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,9 @@ proposalToResponse timeZone Types.Proposal {..} =
244244
proposalResponseCcNoVotes = proposalCcNoVotes,
245245
proposalResponseCcAbstainVotes = proposalCcAbstainVotes,
246246
proposalResponsePrevGovActionIndex = proposalPrevGovActionIndex,
247-
proposalResponsePrevGovActionTxHash = HexText <$> proposalPrevGovActionTxHash
247+
proposalResponsePrevGovActionTxHash = HexText <$> proposalPrevGovActionTxHash,
248+
proposalResponseAuthors = proposalAuthors
249+
-- proposalResponseAuthors = ProposalAuthors <$> proposalAuthors
248250
}
249251

250252
voteToResponse :: Types.Vote -> VoteParams

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,39 @@ data ProposalResponse
401401
, proposalResponseCcAbstainVotes :: Integer
402402
, proposalResponsePrevGovActionIndex :: Maybe Integer
403403
, proposalResponsePrevGovActionTxHash :: Maybe HexText
404+
, proposalResponseAuthors :: Maybe Value
404405
}
405406
deriving (Generic, Show)
406407

408+
-- newtype ProposalAuthors = ProposalAuthors { getProposalAuthors :: Value }
409+
-- deriving newtype (Show)
410+
411+
-- instance FromJSON ProposalAuthors where
412+
-- parseJSON v@(Array _) = pure $ ProposalAuthors v
413+
-- parseJSON _ = fail "ProposalAuthors must be a JSON array"
414+
415+
-- instance ToJSON ProposalAuthors where
416+
-- toJSON (ProposalAuthors v) = v
417+
418+
-- instance ToSchema ProposalAuthors where
419+
-- declareNamedSchema _ = pure $ NamedSchema (Just "ProposalAuthors") $ mempty
420+
-- & type_ ?~ OpenApiArray
421+
-- & description ?~ "A JSON array of proposal authors"
422+
-- & example ?~ toJSON
423+
-- [ object
424+
-- [ "name" .= ("Alice" :: Text)
425+
-- , "witness_algorithm" .= ("algo" :: Text)
426+
-- , "public_key" .= ("key" :: Text)
427+
-- , "signature" .= ("sig" :: Text)
428+
-- ]
429+
-- , object
430+
-- [ "name" .= ("Bob" :: Text)
431+
-- , "witness_algorithm" .= ("algo2" :: Text)
432+
-- , "public_key" .= ("key2" :: Text)
433+
-- , "signature" .= ("sig2" :: Text)
434+
-- ]
435+
-- ]
436+
407437
deriveJSON (jsonOptions "proposalResponse") ''ProposalResponse
408438

409439
exampleProposalResponse :: Text

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+
, proposalAuthors :: Maybe Value
211212
}
212213
deriving (Show)
213214

@@ -241,6 +242,7 @@ instance FromRow Proposal where
241242
<*> (floor @Scientific <$> field) -- proposalCcAbstainVotes
242243
<*> field -- prevGovActionIndex
243244
<*> field -- prevGovActionTxHash
245+
<*> field -- proposalAuthors
244246

245247
data TransactionStatus = TransactionStatus
246248
{ transactionConfirmed :: Bool

govtool/frontend/src/hooks/queries/useGetProposalQuery.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export const useGetProposalQuery = (proposalId: string, enabled?: boolean) => {
1616
},
1717
);
1818

19+
console.log('useGetProposalQuery', { proposalId, dRepID, data, isLoading, isRefetching, error });
20+
1921
return {
2022
data,
2123
isLoading,

govtool/frontend/src/pages/GovernanceActionDetails.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ export const GovernanceActionDetails = () => {
5757
(data ?? state)?.proposal as ProposalData,
5858
);
5959

60+
console.log('GovernanceActionDetails', { extendedProposal, data, state, untypedState });
61+
6062
useEffect(() => {
6163
if (data?.proposal) {
6264
setExtendedProposal(data.proposal);

govtool/frontend/src/services/requests/getProposal.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ export const getProposal = async (
1919
`/proposal/get/${encodedHash}?drepId=${drepId}`,
2020
);
2121

22+
console.log('-------------------getProposal', { proposalId, drepId, data });
23+
2224
return data;
2325
};

0 commit comments

Comments
 (0)