Skip to content

Commit 1aa41e9

Browse files
authored
feat(#3619): CIP-129 support for gov_actions hashes in Live Voting (governance actions)
chore: update .gitignores to clarify tool version management file exclusion
2 parents e528f5f + f5ed371 commit 1aa41e9

File tree

9 files changed

+36
-10
lines changed

9 files changed

+36
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ changes.
1111
## [Unreleased]
1212

1313
### Added
14+
- Add CIP-129 support for gov_actions hashes in Live Voting (governance actions) [Issue 3619](https://github.com/IntersectMBO/govtool/issues/3619)
1415

1516
- Add maintenance ending banner [Issue 3647](https://github.com/IntersectMBO/govtool/issues/3647)
1617

govtool/backend/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# other
22
.vscode
33
dev-config.json
4+
5+
# Tool version management file (e.g., asdf version manager)
6+
.tool-versions

govtool/frontend/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@
66
/.lighthouseci
77
/yarn-error.log
88
.env
9-
coverage
9+
coverage
10+
11+
# Tool version management file (e.g., asdf version manager)
12+
.tool-versions

govtool/frontend/src/components/organisms/DashboardGovernanceActionDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ export const DashboardGovernanceActionDetails = () => {
9999

100100
useEffect(() => {
101101
const isProposalNotFound =
102-
(error as AxiosError)?.response?.data ===
103-
`Proposal with id: ${fullProposalId} not found`;
102+
error instanceof AxiosError &&
103+
error.response?.data.match(/Proposal with id: .* not found/);
104104
if (isProposalNotFound && fullProposalId) {
105105
navigate(
106106
OUTCOMES_PATHS.governanceActionOutcomes.replace(":id", fullProposalId),

govtool/frontend/src/pages/GovernanceActionDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ export const GovernanceActionDetails = () => {
9494

9595
useEffect(() => {
9696
const isProposalNotFound =
97-
(error as AxiosError)?.response?.data ===
98-
`Proposal with id: ${fullProposalId} not found`;
97+
error instanceof AxiosError &&
98+
error.response?.data.match(/Proposal with id: .* not found/);
9999
if (isProposalNotFound && fullProposalId) {
100100
navigate(
101101
OUTCOMES_PATHS.governanceActionOutcomes.replace(":id", fullProposalId),

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export const getProposal = async (
77
proposalId: string,
88
drepId?: string,
99
): Promise<VotedProposal> => {
10-
const isCIP129Identifier = proposalId.includes("gov_action");
10+
const isCIP129Identifier = proposalId.startsWith("gov_action");
1111
if (isCIP129Identifier) {
12-
const { txID } = decodeCIP129Identifier(proposalId);
13-
proposalId = txID;
12+
const { txID, index } = decodeCIP129Identifier(proposalId);
13+
proposalId = `${txID}#${parseInt(index, 16)}`;
1414
}
1515

1616
const encodedHash = encodeURIComponent(proposalId);

govtool/frontend/src/utils/getGovActionId.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ export const getShortenedGovActionId = (
99
const firstPart = txHash.slice(0, 4);
1010
const lastPart = txHash.slice(-4);
1111

12-
return `${firstPart}...${lastPart}#${index}`;
12+
return txHash.startsWith("gov_action")
13+
? `${firstPart}...${lastPart}`
14+
: `${firstPart}...${lastPart}#${index}`;
1315
};
1416

1517
export const getFullGovActionId = (txHash: string, index: number | string) =>
16-
`${txHash}#${index}`;
18+
(txHash.startsWith("gov_action") ? txHash : `${txHash}#${index}`);

govtool/frontend/src/utils/tests/getGovActionId.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ describe("getShortenedGovActionId", () => {
2828
const result = getShortenedGovActionId(txHash, index);
2929
expect(result).toBe("#1");
3030
});
31+
32+
it("should handle a hash starting with 'gov_action' correctly", () => {
33+
const txHash = "gov_action_1234567890abcdef";
34+
const index = 7;
35+
const result = getShortenedGovActionId(txHash, index);
36+
expect(result).toBe("gov_...cdef");
37+
});
3138
});
3239

3340
describe("getFullGovActionId", () => {
@@ -37,4 +44,11 @@ describe("getFullGovActionId", () => {
3744
const result = getFullGovActionId(txHash, index);
3845
expect(result).toBe("1234567890abcdef1234567890abcdef#10");
3946
});
47+
48+
it("should return the full id without index if txHash starts with 'gov_action'", () => {
49+
const txHash = "gov_action_1234567890abcdef";
50+
const index = 5;
51+
const result = getFullGovActionId(txHash, index);
52+
expect(result).toBe("gov_action_1234567890abcdef");
53+
});
4054
});

govtool/metadata-validation/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ pids
5454

5555
# Diagnostic reports (https://nodejs.org/api/report.html)
5656
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
57+
58+
# Tool version management file (e.g., asdf version manager)
59+
.tool-versions

0 commit comments

Comments
 (0)