From 4016076efe0c99c29386a9a798302ca85492451d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Wed, 6 Nov 2024 16:41:46 +0100 Subject: [PATCH 1/2] feat(#2183): add support for CIP-129 governance identifiers --- CHANGELOG.md | 2 +- .../molecules/GovernanceActionCard.tsx | 17 ++++++++-- .../molecules/GovernanceVotedOnCard.tsx | 26 +++++++++++---- .../GovernanceActionDetailsCardData.tsx | 12 +++++++ govtool/frontend/src/i18n/locales/en.json | 1 + .../src/services/requests/getProposal.ts | 9 +++++- .../src/services/requests/getProposals.ts | 4 ++- .../src/stories/GovernanceAction.stories.ts | 15 +++++++-- .../GovernanceActionDetailsCard.stories.ts | 10 ++++++ .../frontend/src/utils/cip129identifier.ts | 32 +++++++++++++++++++ govtool/frontend/src/utils/getGovActionId.ts | 5 ++- govtool/frontend/src/utils/index.ts | 1 + .../src/utils/tests/cip129identifier.test.ts | 32 +++++++++++++++++++ 13 files changed, 151 insertions(+), 15 deletions(-) create mode 100644 govtool/frontend/src/utils/cip129identifier.ts create mode 100644 govtool/frontend/src/utils/tests/cip129identifier.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ba3b9154..f27a9be4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ changes. ### Added -- +- add support for CIP-129 governance identifiers [Issue 2183](https://github.com/IntersectMBO/govtool/issues/2183) ### Fixed diff --git a/govtool/frontend/src/components/molecules/GovernanceActionCard.tsx b/govtool/frontend/src/components/molecules/GovernanceActionCard.tsx index c70ede09a..c658b068f 100644 --- a/govtool/frontend/src/components/molecules/GovernanceActionCard.tsx +++ b/govtool/frontend/src/components/molecules/GovernanceActionCard.tsx @@ -11,6 +11,7 @@ import { import { useScreenDimension, useTranslation } from "@hooks"; import { + encodeCIP129Identifier, getFullGovActionId, getProposalTypeLabel, getProposalTypeNoEmptySpaces, @@ -53,6 +54,11 @@ export const GovernanceActionCard: FC = ({ ...props }) => { const { t } = useTranslation(); const govActionId = getFullGovActionId(txHash, index); + const cip129GovernanceActionId = encodeCIP129Identifier( + txHash, + index.toString(16).padStart(2, "0"), + "gov_action", + ); return ( = ({ ...props }) => { /> + diff --git a/govtool/frontend/src/components/molecules/GovernanceVotedOnCard.tsx b/govtool/frontend/src/components/molecules/GovernanceVotedOnCard.tsx index e47980920..cb5a4fd54 100644 --- a/govtool/frontend/src/components/molecules/GovernanceVotedOnCard.tsx +++ b/govtool/frontend/src/components/molecules/GovernanceVotedOnCard.tsx @@ -5,6 +5,7 @@ import { Button } from "@atoms"; import { PATHS } from "@consts"; import { useScreenDimension, useTranslation } from "@hooks"; import { + encodeCIP129Identifier, getFullGovActionId, getProposalTypeLabel, getProposalTypeNoEmptySpaces, @@ -43,6 +44,13 @@ export const GovernanceVotedOnCard = ({ votedProposal, inProgress }: Props) => { const { isMobile, screenWidth } = useScreenDimension(); const { t } = useTranslation(); + const govActionId = getFullGovActionId(txHash, index); + const cip129GovernanceActionId = encodeCIP129Identifier( + txHash, + index.toString(16).padStart(2, "0"), + "gov_action", + ); + return ( { /> + @@ -120,15 +135,12 @@ export const GovernanceVotedOnCard = ({ votedProposal, inProgress }: Props) => { >