Skip to content

Commit

Permalink
feat: add cost-models table to proposal params
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Oct 22, 2024
1 parent 9f59086 commit e9e4142
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion backend/src/proposal/proposal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class ProposalService {
createdEpochNo: govActionProposal.epoch_no,
url: govActionProposal.url,
metadataHash: govActionProposal.metadata_hash,
protocolParams: govActionProposal.row_to_json,
protocolParams: govActionProposal.proposal_params,
title: govActionProposal.title,
abstract: govActionProposal.abstract,
motivation: govActionProposal.motivation,
Expand Down
14 changes: 12 additions & 2 deletions backend/src/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ SELECT
creator_block.epoch_no,
voting_anchor.url,
encode(voting_anchor.data_hash, 'hex') AS metadata_hash,
ROW_TO_JSON(proposal_params),
jsonb_set(
ROW_TO_JSON(proposal_params)::jsonb,
'{cost_model}',
CASE
WHEN cost_model.id IS NOT NULL THEN
ROW_TO_JSON(cost_model)::jsonb
ELSE
'null'::jsonb
END
) AS proposal_params,
off_chain_vote_gov_action_data.title,
off_chain_vote_gov_action_data.abstract,
off_chain_vote_gov_action_data.motivation,
Expand All @@ -73,7 +82,7 @@ SELECT
) AS yes_votes,
COALESCE(SUM(ldd_drep.amount) FILTER (WHERE voting_procedure.vote::text = 'No'), 0) + (
CASE WHEN gov_action_proposal.type = 'NoConfidence' THEN
0
0`
ELSE
always_no_confidence_voting_power.amount
END
Expand All @@ -98,6 +107,7 @@ FROM
JOIN block AS creator_block ON creator_block.id = creator_tx.block_id
LEFT JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_id
LEFT JOIN param_proposal AS proposal_params ON gov_action_proposal.param_proposal = proposal_params.id
LEFT JOIN cost_model AS cost_model ON proposal_params.cost_model_id = cost_model.id
LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = voting_anchor.id
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
LEFT JOIN voting_procedure ON voting_procedure.gov_action_proposal_id = gov_action_proposal.id
Expand Down
2 changes: 1 addition & 1 deletion backend/src/types/proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export type RawQueryGovernanceActionProposalType = {
epoch_no: number;
url: string;
encode: string;
row_to_json: any;
proposal_params: any;
metadata_hash: string;
title: string | null;
abstract: string | null;
Expand Down

0 comments on commit e9e4142

Please sign in to comment.