Skip to content

Commit 82845d9

Browse files
authored
Merge pull request #3844 from IntersectMBO/develop
v2.0.27.1
2 parents 477c293 + 38653e5 commit 82845d9

File tree

14 files changed

+164
-631
lines changed

14 files changed

+164
-631
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ changes.
2525

2626
### Changed
2727
- Adjust top menu (navbar) layout when wallet is not connected [Issue-3682](https://github.com/IntersectMBO/govtool/issues/3682)
28+
- Unification of sections 'Receiving Address' and 'Amount' in Treasury Withdrawal Governance Action [Issue-3828](https://github.com/IntersectMBO/govtool/issues/3828)
2829

2930
### Removed
3031

govtool/backend/sql/list-proposals.sql

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,19 @@ SELECT
306306
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash,
307307
off_chain_vote_data.json as json_content,
308308
COALESCE(
309-
json_agg(
310-
json_build_object(
311-
'name', off_chain_vote_author.name,
312-
'witnessAlgorithm', off_chain_vote_author.witness_algorithm,
313-
'publicKey', off_chain_vote_author.public_key,
314-
'signature', off_chain_vote_author.signature
315-
)
316-
) FILTER (WHERE off_chain_vote_author.id IS NOT NULL),
317-
'[]'
318-
) authors
309+
(
310+
SELECT jsonb_agg(
311+
jsonb_build_object(
312+
'name', author_elem->>'name',
313+
'publicKey', author_elem->'witness'->>'publicKey',
314+
'signature', author_elem->'witness'->>'signature',
315+
'witnessAlgorithm', author_elem->'witness'->>'witnessAlgorithm'
316+
)
317+
)
318+
FROM jsonb_array_elements(off_chain_vote_data.json->'authors') AS author_elem
319+
),
320+
'[]'::jsonb
321+
) AS authors
319322
FROM
320323
gov_action_proposal
321324
JOIN ActiveProposals ON gov_action_proposal.id = ActiveProposals.id
@@ -326,7 +329,6 @@ FROM
326329
LEFT JOIN block AS creator_block ON creator_block.id = creator_tx.block_id
327330
LEFT JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_id
328331
LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = voting_anchor.id
329-
lEFT JOIN off_chain_vote_author ON off_chain_vote_author.off_chain_vote_data_id = off_chain_vote_data.id
330332
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
331333
LEFT JOIN param_proposal AS proposal_params ON gov_action_proposal.param_proposal = proposal_params.id
332334
LEFT JOIN cost_model AS cost_model ON proposal_params.cost_model_id = cost_model.id
Lines changed: 17 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import { Box } from "@mui/material";
21
import { useTranslation } from "react-i18next";
32

4-
import { Typography, CopyButton } from "@atoms";
53
import { correctVoteAdaFormat } from "@utils";
6-
7-
import { useScreenDimension } from "@/hooks";
4+
import { GovernanceActionCardElement } from "./GovernanceActionCardElement";
85

96
type Props = {
107
receivingAddress: string;
@@ -16,87 +13,22 @@ export const GovernanceActionCardTreasuryWithdrawalElement = ({
1613
amount,
1714
}: Props) => {
1815
const { t } = useTranslation();
19-
const { isMobile } = useScreenDimension();
16+
2017
return (
21-
<Box
22-
sx={{
23-
display: "flex",
24-
mb: "4px",
25-
flexDirection: "column",
26-
}}
27-
>
28-
<Box sx={{ display: "flex", flexDirection: isMobile ? "column" : "row" }}>
29-
<Typography
30-
data-testid="receiving-address-label"
31-
sx={{
32-
width: "160px",
33-
fontSize: 14,
34-
fontWeight: 600,
35-
lineHeight: "20px",
36-
color: "neutralGray",
37-
}}
38-
>
39-
{t("govActions.receivingAddress")}
40-
</Typography>
41-
<Box
42-
sx={{
43-
display: "flex",
44-
alignItems: "center",
45-
overflow: "hidden",
46-
flexDirection: "row",
47-
}}
48-
>
49-
<Typography
50-
data-testid="receiving-address"
51-
sx={{
52-
ml: isMobile ? 0 : 8,
53-
color: "primaryBlue",
54-
fontSize: 16,
55-
fontWeight: 400,
56-
lineHeight: "20px",
57-
whiteSpace: "nowrap",
58-
overflow: "hidden",
59-
textOverflow: "ellipsis",
60-
}}
61-
>
62-
{receivingAddress}
63-
</Typography>
64-
<Box ml={1}>
65-
<CopyButton text={receivingAddress} variant="blueThin" />
66-
</Box>
67-
</Box>
68-
</Box>
69-
<Box
70-
sx={{
71-
display: "flex",
72-
flexDirection: isMobile ? "column" : "row",
73-
mt: "6px",
74-
}}
75-
>
76-
<Typography
77-
sx={{
78-
width: "160px",
79-
fontSize: 14,
80-
fontWeight: 600,
81-
lineHeight: "20px",
82-
color: "neutralGray",
83-
}}
84-
data-testid="amount-label"
85-
>
86-
{t("govActions.amount")}
87-
</Typography>
88-
<Typography
89-
data-testid="amount"
90-
sx={{
91-
ml: isMobile ? 0 : 8,
92-
fontSize: 16,
93-
fontWeight: 400,
94-
lineHeight: "20px",
95-
}}
96-
>
97-
{correctVoteAdaFormat(amount) ?? 0}
98-
</Typography>
99-
</Box>
100-
</Box>
18+
<>
19+
<GovernanceActionCardElement
20+
label={t("govActions.receivingAddress")}
21+
text={receivingAddress}
22+
textVariant="oneLine"
23+
dataTestId="receiving-address-label"
24+
isCopyButton
25+
/>
26+
<GovernanceActionCardElement
27+
label={t("govActions.amount")}
28+
text={`₳ ${correctVoteAdaFormat(amount) ?? 0}`}
29+
textVariant="oneLine"
30+
dataTestId="amount"
31+
/>
32+
</>
10133
);
10234
};

tests/govtool-frontend/playwright/lib/constants/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const proposal06AuthFile = ".auth/proposal06.json";
2020
export const proposal07AuthFile = ".auth/proposal07.json";
2121
export const proposal08AuthFile = ".auth/proposal08.json";
2222
export const proposal09AuthFile = ".auth/proposal09.json";
23+
export const proposal10AuthFile = ".auth/proposal10.json";
2324

2425
export const proposalSubmissionAuthFile = ".auth/proposalSubmission.json";
2526

tests/govtool-frontend/playwright/lib/constants/docsUrl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const ABSTAIN_VOTE_DOC_URL = `${environments.docsUrl}/using-govtool/deleg
99
export const SIGNAL_NO_CONFIDENCE_VOTE_DOC_URL = `${environments.docsUrl}/using-govtool/delegating/signal-no-confidence-on-every-vote`;
1010
export const FAQS_DOC_URL = `${environments.docsUrl}/faqs`;
1111
export const GUIDES_DOC_URL = `${environments.docsUrl}/using-govtool`;
12-
export const PRIVACY_POLICY = `https://docs.intersectmbo.org/legal/policies-and-conditions/privacy-policy`;
13-
export const TERMS_AND_CONDITIONS = `https://docs.intersectmbo.org/legal/policies-and-conditions/terms-of-use`;
12+
export const PRIVACY_POLICY = `https://docs.intersectmbo.org/legal/policies-and-conditions/intersect-members-policies/privacy-policy`;
13+
export const TERMS_AND_CONDITIONS = `https://docs.intersectmbo.org/legal/policies-and-conditions/intersect-internal-policies/terms-of-use`;
1414
export const HELP_DOC_URL = `${environments.docsUrl}/support`;
1515
export const BOOTSTRAP_DOC_URL = `${environments.docsUrl}/faqs/bootstrapping-phase`;

tests/govtool-frontend/playwright/lib/constants/staticWallets.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ export const proposal06Wallet: StaticWallet = staticWallets[15];
2525
export const proposal07Wallet: StaticWallet = staticWallets[16];
2626
export const proposal08Wallet: StaticWallet = staticWallets[17];
2727
export const proposal09Wallet: StaticWallet = staticWallets[18];
28+
export const proposal10Wallet: StaticWallet = staticWallets[19];
2829

29-
export const budgetProposal01Wallet: StaticWallet = staticWallets[19];
30-
export const budgetProposal02Wallet: StaticWallet = staticWallets[20];
31-
export const budgetProposal03Wallet: StaticWallet = staticWallets[21];
32-
export const budgetProposal04Wallet: StaticWallet = staticWallets[22];
33-
export const budgetProposal05Wallet: StaticWallet = staticWallets[23];
30+
export const budgetProposal01Wallet: StaticWallet = staticWallets[20];
31+
export const budgetProposal02Wallet: StaticWallet = staticWallets[21];
32+
export const budgetProposal03Wallet: StaticWallet = staticWallets[22];
33+
export const budgetProposal04Wallet: StaticWallet = staticWallets[23];
34+
export const budgetProposal05Wallet: StaticWallet = staticWallets[24];
3435

3536
export const adaHolderWallets = [
3637
adaHolder01Wallet,

tests/govtool-frontend/playwright/lib/helpers/auth.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import {
1313
proposal07Wallet,
1414
proposal08Wallet,
1515
proposal09Wallet,
16+
proposal10Wallet,
1617
} from "@constants/staticWallets";
1718
import {
1819
proposal05AuthFile,
1920
proposal07AuthFile,
2021
proposal08AuthFile,
2122
proposal09AuthFile,
23+
proposal10AuthFile,
2224
} from "@constants/auth";
2325

2426
interface CreateUserProps {
@@ -122,5 +124,10 @@ export const getDraftProposalWalletAndState = (proposalType: string) => {
122124
storageState: proposal09AuthFile,
123125
wallet: proposal09Wallet,
124126
};
127+
case ProposalType.hardFork:
128+
return {
129+
storageState: proposal10AuthFile,
130+
wallet: proposal10Wallet,
131+
};
125132
}
126133
};

tests/govtool-frontend/playwright/lib/pages/proposalSubmissionPage.ts

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const formErrors = {
3030
constitutionalUrl: "prop-constitution-url-text-error",
3131
guardrailsScriptUrl: "prop-guardrails-script-url-input-error",
3232
link: "link-0-url-input-error",
33+
majorError: "major-error",
34+
minorError: "minor-error",
3335
};
3436

3537
export default class ProposalSubmissionPage {
@@ -61,6 +63,7 @@ export default class ProposalSubmissionPage {
6163
readonly motionOfNoConfidenceBtn = this.page.getByTestId(
6264
"motion of no confidence-button"
6365
);
66+
readonly hardForkBtn = this.page.getByTestId("hard fork-button");
6467
readonly editSubmissionButton = this.page.getByTestId(
6568
"edit-submission-button"
6669
);
@@ -101,6 +104,12 @@ export default class ProposalSubmissionPage {
101104
readonly closeDraftSuccessModalBtn = this.page.getByTestId("close-button");
102105
readonly linkTextInput = this.page.getByTestId("link-0-text-input");
103106
readonly linkUrlInput = this.page.getByTestId("link-0-url-input");
107+
readonly previousGAHashInput = this.page.getByTestId(
108+
"previous-ga-hash-input"
109+
);
110+
readonly previousGAIdInput = this.page.getByTestId("previous-ga-id-input");
111+
readonly majorInput = this.page.getByTestId("major-input");
112+
readonly minorInput = this.page.getByTestId("minor-input");
104113

105114
// content
106115
readonly governanceActionTypeContent = this.page.getByTestId(
@@ -125,6 +134,8 @@ export default class ProposalSubmissionPage {
125134
);
126135
readonly linkTextContent = this.page.getByTestId("link-0-text-content");
127136
readonly linkUrlContent = this.page.getByTestId("link-0-url-content");
137+
readonly majorVersionContent = this.page.getByTestId("major-version-content");
138+
readonly minorVersionContent = this.page.getByTestId("minor-version-content");
128139

129140
constructor(private readonly page: Page) {}
130141

@@ -172,9 +183,14 @@ export default class ProposalSubmissionPage {
172183
if (governanceProposal.proposal_links != null) {
173184
await this.fillProposalLinks(governanceProposal.proposal_links);
174185
}
186+
187+
if (governanceProposal.gov_action_type_id == 4) {
188+
await this.fillHardForkFields(governanceProposal);
189+
}
175190
}
176191

177192
async fillupForm(governanceProposal: ProposalCreateRequest) {
193+
console.log(governanceProposal.gov_action_type_id);
178194
await this.governanceActionType.click();
179195

180196
if (governanceProposal.gov_action_type_id === 0) {
@@ -186,8 +202,10 @@ export default class ProposalSubmissionPage {
186202
if (governanceProposal.has_guardrails) {
187203
await this.guardrailsScriptCheckbox.click();
188204
}
189-
} else {
205+
} else if (governanceProposal.gov_action_type_id === 3) {
190206
await this.motionOfNoConfidenceBtn.click();
207+
} else {
208+
await this.hardForkBtn.click();
191209
}
192210

193211
await this.fillupFormWithTypeSelected(governanceProposal);
@@ -238,6 +256,11 @@ export default class ProposalSubmissionPage {
238256
}
239257
}
240258

259+
async fillHardForkFields(hardForkProposal: ProposalCreateRequest) {
260+
await this.minorInput.fill(hardForkProposal.prop_min_version.toString());
261+
await this.majorInput.fill(hardForkProposal.prop_major_version.toString());
262+
}
263+
241264
async getAllDrafts() {
242265
await expect(
243266
this.page.locator('[data-testid^="draft-"][data-testid$="-card"]')
@@ -345,6 +368,27 @@ export default class ProposalSubmissionPage {
345368
}).toBeHidden();
346369
}
347370

371+
if (governanceProposal.gov_action_type_id === 4) {
372+
const isMajorErrorVisible = await this.page
373+
.getByTestId(formErrors.majorError)
374+
.isVisible();
375+
const isMinorErrorVisible = await this.page
376+
.getByTestId(formErrors.minorError)
377+
.isVisible();
378+
379+
await expect(this.page.getByTestId(formErrors.majorError), {
380+
message: isMajorErrorVisible
381+
? "Major version error should be hidden"
382+
: "Major version error is correctly hidden",
383+
}).toBeHidden();
384+
385+
await expect(this.page.getByTestId(formErrors.minorError), {
386+
message: isMinorErrorVisible
387+
? "Minor version error should be hidden"
388+
: "Minor version error is correctly hidden",
389+
}).toBeHidden();
390+
}
391+
348392
await expect(this.page.getByTestId(formErrors.link), {
349393
message:
350394
isLinkErrorVisible &&
@@ -457,6 +501,11 @@ export default class ProposalSubmissionPage {
457501
}).toBeVisible();
458502
}
459503

504+
if (governanceProposal.gov_action_type_id === 4) {
505+
await expect(this.page.getByTestId(formErrors.majorError)).toBeVisible();
506+
await expect(this.page.getByTestId(formErrors.minorError)).toBeVisible();
507+
}
508+
460509
await expect(this.continueBtn).toBeDisabled();
461510
}
462511

@@ -512,6 +561,15 @@ export default class ProposalSubmissionPage {
512561
}
513562
}
514563
}
564+
if (proposalType == ProposalType.hardFork) {
565+
proposal.prop_min_version = faker.number
566+
.float({ min: 0, max: 100 })
567+
.toString();
568+
proposal.prop_major_version = faker.number
569+
.float({ min: 0, max: 100 })
570+
.toString();
571+
}
572+
515573
return proposal;
516574
}
517575

@@ -546,6 +604,12 @@ export default class ProposalSubmissionPage {
546604
proposal.prop_guardrails_script_url = invalid.url();
547605
proposal.prop_guardrails_script_hash = faker.string.alphanumeric(64);
548606
}
607+
608+
if (proposalType === ProposalType.hardFork) {
609+
proposal.prop_min_version = invalid.amount();
610+
proposal.prop_major_version = invalid.amount();
611+
}
612+
549613
return proposal;
550614
}
551615

tests/govtool-frontend/playwright/lib/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export enum ProposalType {
8383
treasury = "Treasury requests",
8484
updatesToTheConstitution = "Updates to the Constitution",
8585
motionOfNoConfedence = "Motion of No Confidence",
86+
hardFork = "Hard fork",
8687
}
8788

8889
export enum BootstrapGovernanceActionType {
@@ -195,6 +196,8 @@ export type ProposalCreateRequest = {
195196
prop_guardrails_script_hash?: string;
196197
has_guardrails?: boolean;
197198
is_draft: boolean;
199+
prop_min_version?: string;
200+
prop_major_version?: string;
198201
};
199202
export type ProposedGovAction = {
200203
id: number;

0 commit comments

Comments
 (0)