Skip to content

Commit 8b48865

Browse files
authored
Merge pull request #3805 from IntersectMBO/develop
v2.0.26
2 parents a9c21e3 + 8ff3272 commit 8b48865

File tree

16 files changed

+225
-48
lines changed

16 files changed

+225
-48
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ changes.
1313
### Added
1414

1515
- Preserve maintenance ending banner state on the wallet connection change [Issue 3681](https://github.com/IntersectMBO/govtool/issues/3681)
16+
- Add authors for Live Voting Governance Actions [Issue 3745](https://github.com/IntersectMBO/govtool/issues/3745)
1617

1718
### Fixed
1819

docs/GOVERNANCE_ACTION_SUBMISSION.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const buildProtocolParameterChangeGovernanceAction: (
134134
protocolParameterChangeProps: ProtocolParameterChangeProps
135135
) => Promise<VotingProposalBuilder | undefined>;
136136

137-
const buildHardForkInitiationGovernanceAction: (
137+
const buildHardForkGovernanceAction: (
138138
hardForkInitiationProps: HardForkInitiationProps
139139
) => Promise<VotingProposalBuilder | undefined>;
140140

@@ -210,7 +210,7 @@ const {
210210
buildSignSubmitConwayCertTx,
211211
buildNewInfoGovernanceAction,
212212
buildProtocolParameterChangeGovernanceAction,
213-
buildHardForkInitiationGovernanceAction,
213+
buildHardForkGovernanceAction,
214214
buildTreasuryGovernanceAction,
215215
buildNewConstitutionGovernanceAction,
216216
buildUpdateCommitteeGovernanceAction,
@@ -241,7 +241,7 @@ govActionBuilder = await buildProtocolParameterChangeGovernanceAction({
241241
});
242242

243243
// hash of the previous Governance Action, index of the previous Governance Action, url of the metadata, hash of the metadata, and the major and minor numbers of the hard fork initiation
244-
govActionBuilder = await buildHardForkInitiationGovernanceAction({
244+
govActionBuilder = await buildHardForkGovernanceAction({
245245
prevGovernanceActionHash,
246246
prevGovernanceActionIndex,
247247
url,

govtool/backend/sql/list-proposals.sql

Lines changed: 14 additions & 2 deletions
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+
'witnessAlgorithm', off_chain_vote_author.witness_algorithm,
312+
'publicKey', 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
@@ -355,4 +367,4 @@ GROUP BY
355367
off_chain_vote_gov_action_data.title,
356368
off_chain_vote_gov_action_data.abstract,
357369
off_chain_vote_gov_action_data.motivation,
358-
off_chain_vote_gov_action_data.rationale;
370+
off_chain_vote_gov_action_data.rationale;

govtool/backend/src/VVA/API.hs

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

250251
voteToResponse :: Types.Vote -> VoteParams

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

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,52 @@ data ProposalResponse
401401
, proposalResponseCcAbstainVotes :: Integer
402402
, proposalResponsePrevGovActionIndex :: Maybe Integer
403403
, proposalResponsePrevGovActionTxHash :: Maybe HexText
404+
, proposalResponseAuthors :: Maybe ProposalAuthors
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+
, "witnessAlgorithm" .= ("algo" :: Text)
426+
, "publicKey" .= ("key" :: Text)
427+
, "signature" .= ("sig" :: Text)
428+
]
429+
, object
430+
[ "name" .= ("Bob" :: Text)
431+
, "witnessAlgorithm" .= ("algo2" :: Text)
432+
, "publicKey" .= ("key2" :: Text)
433+
, "signature" .= ("sig2" :: Text)
434+
]
435+
]
436+
437+
exampleProposalAuthors :: Text
438+
exampleProposalAuthors =
439+
"[\
440+
\ {\"name\": \"Alice\",\
441+
\ \"witnessAlgorithm\": \"Ed25519\",\
442+
\ \"publicKey\": \"abcdef123456\",\
443+
\ \"signature\": \"deadbeef\"},\
444+
\ {\"name\": \"Bob\",\
445+
\ \"witnessAlgorithm\": \"Ed25519\",\
446+
\ \"publicKey\": \"123456abcdef\",\
447+
\ \"signature\": \"beefdead\"}\
448+
\]"
449+
407450
deriveJSON (jsonOptions "proposalResponse") ''ProposalResponse
408451

409452
exampleProposalResponse :: Text
@@ -433,7 +476,9 @@ exampleProposalResponse = "{ \"id\": \"proposalId123\","
433476
<> "\"cCNoVotes\": 0,"
434477
<> "\"cCAbstainVotes\": 0,"
435478
<> "\"prevGovActionIndex\": 0,"
436-
<> "\"prevGovActionTxHash\": \"47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\"}"
479+
<> "\"prevGovActionTxHash\": \"47c14a128cd024f1b990c839d67720825921ad87ed875def42641ddd2169b39c\","
480+
<> "\"authors\": " <> exampleProposalAuthors
481+
<> "}"
437482

438483
instance ToSchema Value where
439484
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+
, 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/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

govtool/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@hookform/resolvers": "^3.3.1",
3030
"@intersect.mbo/govtool-outcomes-pillar-ui": "v1.4.3",
3131
"@intersect.mbo/intersectmbo.org-icons-set": "^1.0.8",
32-
"@intersect.mbo/pdf-ui": "0.7.0-beta-36",
32+
"@intersect.mbo/pdf-ui": "1.0.2-beta",
3333
"@mui/icons-material": "^5.14.3",
3434
"@mui/material": "^5.14.4",
3535
"@rollup/plugin-babel": "^6.0.4",

govtool/frontend/src/components/atoms/Link.tsx

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@ import { NavLink } from "react-router-dom";
33
import { Typography } from "@mui/material";
44
import { useCardano } from "@context";
55

6+
const FONT_SIZE = {
7+
small: 14,
8+
big: 22,
9+
};
10+
611
type LinkProps = {
712
dataTestId?: string;
813
isConnectWallet?: boolean;
914
label: React.ReactNode;
1015
navTo: string;
11-
onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
16+
onClick?: (event: MouseEvent<HTMLElement>) => void;
1217
size?: "small" | "big";
1318
};
1419

@@ -24,10 +29,7 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
2429
} = props;
2530
const { disconnectWallet } = useCardano();
2631

27-
const fontSize = {
28-
small: 14,
29-
big: 22,
30-
}[size];
32+
const fontSize = FONT_SIZE[size];
3133

3234
return (
3335
<NavLink
@@ -57,3 +59,40 @@ export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
5759
);
5860
},
5961
);
62+
63+
// This component is used as a placeholder for links that do not navigate anywhere,
64+
// but with the same styling as the Link component.
65+
export const FakeLink = forwardRef<HTMLElement, Omit<LinkProps, "navTo">>(
66+
(props, ref) => {
67+
const {
68+
dataTestId,
69+
isConnectWallet,
70+
label,
71+
size = "small",
72+
onClick,
73+
} = props;
74+
const { disconnectWallet } = useCardano();
75+
76+
const fontSize = FONT_SIZE[size];
77+
78+
return (
79+
<Typography
80+
data-testid={dataTestId}
81+
onClick={(e) => {
82+
e.preventDefault();
83+
if (!isConnectWallet) disconnectWallet();
84+
if (onClick) onClick(e);
85+
}}
86+
ref={ref}
87+
sx={{
88+
cursor: "pointer",
89+
fontSize,
90+
fontWeight: 500,
91+
color: "textBlack",
92+
}}
93+
>
94+
{label}
95+
</Typography>
96+
);
97+
},
98+
);

govtool/frontend/src/components/molecules/GovernanceActionCardElement.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useModal } from "@/context";
1515

1616
type BaseProps = {
1717
label: string;
18-
text?: string | number;
18+
text?: React.ReactNode;
1919
dataTestId?: string;
2020
isSliderCard?: boolean;
2121
tooltipProps?: Omit<TooltipProps, "children">;
@@ -108,7 +108,7 @@ export const GovernanceActionCardElement = ({
108108
...(isSemiTransparent && { opacity: 0.75 }),
109109
}}
110110
>
111-
{isMarkdown ? removeMarkdown(text) : text}
111+
{typeof text === "string" && isMarkdown ? removeMarkdown(text) : text}
112112
</Typography>
113113
);
114114

0 commit comments

Comments
 (0)