Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trim func, delegation, DRep name, GA state, URL validation, links; Fix metadata issues, DRep card, empty strings, URI validation; Update gov guide; Cleanup code #1255

Merged
merged 23 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
80df9c5
add trim func to file lenght for edit drep data and creat GA forms
Sworzen1 Jun 10, 2024
bf70682
add delegation on self when register a DRep
Sworzen1 Jun 10, 2024
c0da7cb
add drepname to dashboard delegaition card
Sworzen1 Jun 10, 2024
b46ff01
feat: create governance actions shared state
MSzalowski Jun 10, 2024
3d289c5
Merge pull request #1219 from IntersectMBO/1210-drep-registration-jso…
Sworzen1 Jun 11, 2024
092c9b6
add validation 128 bytes length for url
Sworzen1 Jun 10, 2024
ec04318
Merge pull request #1226 from IntersectMBO/fix/1180-bug-metadata-anch…
Sworzen1 Jun 11, 2024
cd05b52
Merge pull request #1227 from IntersectMBO/fix/1211-when-submitting-a…
Sworzen1 Jun 11, 2024
45a6888
cleanup code
Sworzen1 Jun 10, 2024
9eda619
Merge pull request #1228 from IntersectMBO/chore/cleanup-code
Sworzen1 Jun 11, 2024
87e1d6c
Merge pull request #1229 from IntersectMBO/fix/1207-dashboard-drep-ca…
Sworzen1 Jun 11, 2024
b57fc34
Merge pull request #1230 from IntersectMBO/feat/1213-create-governanc…
MSzalowski Jun 11, 2024
36584b9
fix: fix empty strings drep data validation
MSzalowski Jun 11, 2024
6086bef
docs: update buildSignSubmit parameters in gov action creation guide
MSzalowski Jun 11, 2024
a4e522f
Merge pull request #1239 from IntersectMBO/docs/fix-governance-action…
MSzalowski Jun 11, 2024
854ab5c
Merge pull request #1238 from IntersectMBO/fix/fix-empty-strings-drep…
MSzalowski Jun 11, 2024
acbc83f
add link to register/ edit drep and create GA
Sworzen1 Jun 11, 2024
9e3d52b
chore: add pdf enable toggle to every deployment workflow
MSzalowski Jun 11, 2024
2b34325
Merge pull request #1242 from IntersectMBO/fix/1076-bug-missing-link-…
Sworzen1 Jun 11, 2024
27f05ce
Merge pull request #1245 from IntersectMBO/chore/add-pdf-enable-toggl…
MSzalowski Jun 11, 2024
470b36a
fix: fix uri validation of metadatas
MSzalowski Jun 11, 2024
26a23fd
Merge pull request #1247 from IntersectMBO/fix/fix-uri-validation-of-…
MSzalowski Jun 11, 2024
f24c439
Merge pull request #1250 from IntersectMBO/develop
pmbinapps Jun 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/build-and-deploy-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ run-name: Deploy by @${{ github.actor }}
# That should be executed on create: tag event
on:
workflow_dispatch:
inputs:
isProposalDiscussionForumEnabled:
description: "Enable proposal discussion forum"
required: true
type: choice
default: "disabled"
options:
- "enabled"
- "disabled"

env:
ENVIRONMENT: "beta"
Expand Down Expand Up @@ -38,7 +47,7 @@ jobs:
SENTRY_IGNORE_API_RESOLUTION_ERROR: "1"
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: "false"
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{ inputs.isProposalDiscussionForumEnabled == 'enabled' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/build-and-deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ on:
push:
branches:
- staging
workflow_dispatch:
inputs:
isProposalDiscussionForumEnabled:
description: "Enable proposal discussion forum"
required: true
type: choice
default: "disabled"
options:
- "enabled"
- "disabled"

env:
ENVIRONMENT: "staging"
Expand Down Expand Up @@ -40,7 +50,7 @@ jobs:
SENTRY_IGNORE_API_RESOLUTION_ERROR: "1"
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: "false"
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{github.event_name == 'push' && 'false' || inputs.isProposalDiscussionForumEnabled == 'enabled'}}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/build-and-deploy-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ on:
push:
branches:
- test
workflow_dispatch:
inputs:
isProposalDiscussionForumEnabled:
description: "Enable proposal discussion forum"
required: true
type: choice
default: "disabled"
options:
- "enabled"
- "disabled"

env:
ENVIRONMENT: "test"
Expand Down Expand Up @@ -40,7 +50,7 @@ jobs:
SENTRY_IGNORE_API_RESOLUTION_ERROR: "1"
TRAEFIK_LE_EMAIL: "[email protected]"
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: "false"
IS_PROPOSAL_DISCUSSION_FORUM_ENABLED: ${{github.event_name == 'push' && 'false' || inputs.isProposalDiscussionForumEnabled == 'enabled'}}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ changes.
- Fix all the existing typescript errors [Issue 514](https://github.com/IntersectMBO/govtool/issues/514)
- Fix endless spinner on a dashboard [Issue 539](https://github.com/IntersectMBO/govtool/issues/539)
- Remove wrongly appended `Yourself` filter on DRep Directory [Issue 1028](https://github.com/IntersectMBO/govtool/issues/1028)
- Fix validation of uris in metadata [Issue 1011](https://github.com/IntersectMBO/govtool/issues/1011)

### Changed

Expand Down
101 changes: 101 additions & 0 deletions docs/GOVERNANCE_ACTION_SUBMISSION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# How to submit a Governance Action using GovTool

## Prerequisites

- Follow the steps of setting up the [GovTool Frontend](../govtool/frontend/README.md).
- Provide any backend that provides the Epoch params (for the wallet connection), can be the current [GovTool Backend](../govtool/backend/README.md).
- Have a wallet with the 50k of ADA to pay for the transaction and fee.

## Development guide

### Prerequisites

For creating the Governance Action, you need to consume 2 utility methods provided by `GovernanceActionProvided` (documented later within this document), and 3 exported from `CardanoProvider` wallet actions (2 for the 2 types of supported by GovTool Governance Actions and 1 for Signing and Submitting the transaction)

### Step 1: Create the Governance Action metadata object

Create the Governance Action object with the fields specified by [CIP-108](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0108), which are:

- title
- abstract
- motivation
- rationale
- references

(For the detailed documentation of the fields and their types, please refer to the [CIP-108](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0108))

### Step 2: Create the Governance Action JSON-LD

Using the `GovernanceActionProvider` provider, use the `createGovernanceActionJsonLd` method to create the JSON-LD object for the Governance Action.

Example:

```typescript
// When used within a GovernanceActionProvider
const { createGovernanceActionJsonLD } = useCreateGovernanceAction();

const jsonLd = createGovernanceActionJsonLD(governanceAction);
```

Type of the `jsonLd` object is `NodeObject` provided from the `jsonld` package by digitalbazaar ([ref](https://github.com/digitalbazaar/jsonld.js)).

### Step 3: Create the Governance Action Hash of the JSON-LD

Using the `GovernanceActionProvider` provider, use the `createGovernanceActionHash` method to create the hash of the JSON-LD object.

Example:

```typescript
// When used within a GovernanceActionProvider
const { createHash } = useCreateGovernanceAction();

const hash = createHash(jsonLd);
```

Type of the `hash` object is `string` (blake2b-256).

### Step 4: Validate the Governance Action hash and metadata

Validate the Governance Action hash and metadata using any backend that provides the Governance Action validation of the metadata against the provided hash.

### Step 5: Sign and Submit the Governance Action

Using the `CardanoProvider` provider, use the `buildSignSubmitConwayCertTx` method to sign and submit the Governance Action, and either the `buildNewInfoGovernanceAction` or `buildTreasuryGovernanceAction` method to build the transaction based on the Governance action type.

Example:

```typescript
// When used within a CardanoProvider
const { buildSignSubmitConwayCertTx, buildNewInfoGovernanceAction } =
useCardano();

// hash of the generated Governance Action metadata, url of the metadata
const govActionBuilder = await buildNewInfoGovernanceAction({ hash, url });

// sign and submit the transaction
await buildSignSubmitConwayCertTx({
govActionBuilder,
type: "createGovAction",
});

// or if you want to use the Treasury Governance Action
const { buildTreasuryGovernanceAction } = useCardano();

// hash of the generated Governance Action metadata, url of the metadata, amount of the transaction, receiving address is the stake key address
const govActionBuilder = await buildTreasuryGovernanceAction({
hash,
url,
amount,
receivingAddress,
});

// sign and submit the transaction
await buildSignSubmitConwayCertTx({
govActionBuilder,
type: "createGovAction",
});
```

### Step 6: Verify the Governance Action

`buildSignSubmitConwayCertTx` logs the transaction CBOR making it able to be tracked on the transactions tools such as cexplorer.
76 changes: 36 additions & 40 deletions govtool/frontend/src/components/molecules/DelegationAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,47 @@ import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos";

import { Typography } from "@atoms";
import { gray } from "@consts";
import { useTranslation } from "@hooks";

import { Card } from "./Card";
import { DirectVoterActionProps } from "./types";

export const DelegationAction = ({
dRepId,
drepName,
onCardClick,
sx,
}: DirectVoterActionProps) => {
const { t } = useTranslation();

return (
<Card
border
elevation={0}
sx={{
alignItems: "center",
backgroundColor: (theme) => theme.palette.neutralWhite,
borderColor: gray.c100,
display: "flex",
justifyContent: "space-between",
px: 1.5,
py: 1,
cursor: "pointer",
...sx,
}}
onCardClick={onCardClick}
>
<Box sx={{ width: "90%" }}>
<Typography fontWeight={600} variant="body2">
{t("dashboard.cards.drepName")}
</Typography>
<Typography
sx={{
mt: 0.5,
overflow: "hidden",
textOverflow: "ellipsis",
}}
variant="body2"
>
{dRepId}
</Typography>
</Box>
<ArrowForwardIosIcon color="primary" sx={{ height: 16, width: 24 }} />
</Card>
);
};
}: DirectVoterActionProps) => (
<Card
border
elevation={0}
sx={{
alignItems: "center",
backgroundColor: (theme) => theme.palette.neutralWhite,
borderColor: gray.c100,
display: "flex",
justifyContent: "space-between",
px: 1.5,
py: 1,
cursor: "pointer",
...sx,
}}
onCardClick={onCardClick}
>
<Box sx={{ width: "90%" }}>
<Typography fontWeight={600} variant="body2">
{drepName}
</Typography>
<Typography
sx={{
mt: 0.5,
overflow: "hidden",
textOverflow: "ellipsis",
}}
variant="body2"
>
{dRepId}
</Typography>
</Box>
<ArrowForwardIosIcon color="primary" sx={{ height: 16, width: 24 }} />
</Card>
);
1 change: 1 addition & 0 deletions govtool/frontend/src/components/molecules/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type StepProps = {

export type DirectVoterActionProps = {
dRepId: string;
drepName: string;
onCardClick: () => void;
sx?: SxProps;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import {
} from "@hooks";
import { Step } from "@molecules";
import { BgCard, ControlledField } from "@organisms";
import { URL_REGEX, openInNewTab } from "@utils";
import {
URL_REGEX,
ellipsizeText,
isValidURLLength,
openInNewTab,
} from "@utils";

type StorageInformationProps = {
setStep: Dispatch<SetStateAction<number>>;
Expand All @@ -31,7 +36,7 @@ export const StorageInformation = ({ setStep }: StorageInformationProps) => {
} = useCreateGovernanceActionForm(setStep);
const { screenWidth } = useScreenDimension();

const fileName = getValues("governance_action_type");
const fileName = getValues("governance_action_type") as string;

const openGuideAboutStoringInformation = () =>
openInNewTab(
Expand Down Expand Up @@ -94,7 +99,7 @@ export const StorageInformation = ({ setStep }: StorageInformationProps) => {
}}
variant="outlined"
>
{`${fileName}.jsonld`}
{`${ellipsizeText(fileName, 8)}.jsonld`}
</Button>
}
componentsLayoutStyles={{
Expand Down Expand Up @@ -131,6 +136,7 @@ export const StorageInformation = ({ setStep }: StorageInformationProps) => {
value: URL_REGEX,
message: t("createGovernanceAction.fields.validations.url"),
},
validate: isValidURLLength,
}}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import { Trans } from "react-i18next";

import { IMAGES, PATHS } from "@consts";
import { PendingTransaction } from "@context";
import { useTranslation } from "@hooks";
import { useGetDRepListInfiniteQuery, useTranslation } from "@hooks";
import { CurrentDelegation, VoterInfo } from "@models";
import {
DashboardActionCard,
DashboardActionCardProps,
DelegationAction,
} from "@molecules";
import { correctAdaFormat, formHexToBech32, openInNewTab } from "@utils";
import {
correctAdaFormat,
formHexToBech32,
getMetadataDataMissingStatusTranslation,
openInNewTab,
} from "@utils";
import {
AutomatedVotingOptionCurrentDelegation,
AutomatedVotingOptionDelegationId,
Expand All @@ -34,6 +39,16 @@ export const DelegateDashboardCard = ({
}: DelegateDashboardCardProps) => {
const navigate = useNavigate();
const { t } = useTranslation();
const { dRepData, isDRepListFetching } = useGetDRepListInfiniteQuery(
{
searchPhrase: currentDelegation?.dRepHash ?? delegateTx?.resourceId ?? "",
},
{
enabled: !!currentDelegation?.dRepHash || !!delegateTx?.resourceId,
},
);

const myDRepDelegationData = dRepData?.[0];

const learnMoreButton = {
children: t("learnMore"),
Expand Down Expand Up @@ -129,16 +144,28 @@ export const DelegateDashboardCard = ({
(!(currentDelegation?.dRepHash === dRepID) || voter?.isRegisteredAsDRep)
}
transactionId={
!(currentDelegation?.dRepHash === dRepID) || voter?.isRegisteredAsDRep
!(currentDelegation?.dRepHash === dRepID) ||
voter?.isRegisteredAsDRep ||
!voter?.isRegisteredAsSoleVoter
? delegateTx?.transactionHash ?? currentDelegation?.txHash
: undefined
}
{...cardProps}
>
{displayedDelegationId &&
(!(currentDelegation?.dRepHash === dRepID) ||
voter?.isRegisteredAsDRep) && (
voter?.isRegisteredAsDRep ||
!voter?.isRegisteredAsSoleVoter) && (
<DelegationAction
drepName={
isDRepListFetching
? "Loading..."
: myDRepDelegationData?.metadataStatus
? getMetadataDataMissingStatusTranslation(
myDRepDelegationData.metadataStatus,
)
: myDRepDelegationData?.dRepName ?? ""
}
dRepId={displayedDelegationId}
onCardClick={navigateToDRepDetails}
sx={{ mt: 1.5 }}
Expand Down
Loading
Loading