Skip to content

Commit

Permalink
Merge pull request #2962 from IntersectMBO/test
Browse files Browse the repository at this point in the history
GovTool - v2.0.11-patch4
  • Loading branch information
MSzalowski authored Feb 12, 2025
2 parents 610310f + bbed5d9 commit 8be0f19
Show file tree
Hide file tree
Showing 15 changed files with 757 additions and 138 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ changes.

- Add metadata url and hash to drep details [Issue 2911](https://github.com/IntersectMBO/govtool/issues/2911)
- Add CC votes percentages, not voted and Ratification threshold
- Add support for submitting all 7 governance action types [Issue 2258](https://github.com/IntersectMBO/govtool/issues/2258)

### Fixed

- Fix calculating votes counting for governance actions
- Fix crashing backend on unhandled missing proposal from vote [Issue 2920](https://github.com/IntersectMBO/govtool/issues/2920)
- Remove abstain votes (not auto abstain) from total DRep stake
- Fix counting committee members [Issue 2948](https://github.com/IntersectMBO/govtool/issues/2948)

### Changed

- Change threshold visual representation in governance action votes
- Resize governance action details columns
- Update @intersect.mbo/pdf-ui to v0.6.0

### Removed

Expand Down
113 changes: 85 additions & 28 deletions docs/GOVERNANCE_ACTION_SUBMISSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ interface GovernanceAction {
references: [{ label: string; uri: string }];
}

interface InfoProps {
hash: string;
type VotingAnchor = {
url: string;
hash: string;
}

interface TreasuryProps {
amount: string;
hash: string;
type InfoProps = VotingAnchor;

type TreasuryProps {
withdrawals: { receivingAddress: string; amount: string }[];
}
} & VotingAnchor;

type ProtocolParamsUpdate = {
adaPerUtxo: string;
Expand Down Expand Up @@ -77,14 +77,44 @@ type ProtocolParamsUpdate = {
treasuryGrowthRate: UnitInterval;
};

interface ProtocolParameterChangeProps {
type ProtocolParameterChangeProps {
prevGovernanceActionHash: string;
prevGovernanceActionIndex: number;
url: string;
hash: string;

protocolParamsUpdate: Partial<ProtocolParamsUpdate>;
}
} & VotingAnchor;

type HardForkInitiationProps = {
prevGovernanceActionHash: string;
prevGovernanceActionIndex: number;
major: number;
minor: number;
} & VotingAnchor;

type NewConstitutionProps = {
prevGovernanceActionHash: string;
prevGovernanceActionIndex: number;
constitutionUrl: string;
constitutionHash: string;
scriptHash: string;
} & VotingAnchor;

type UpdateCommitteeProps = {
prevGovernanceActionHash?: string;
prevGovernanceActionIndex?: number;
quorumThreshold: QuorumThreshold;
newCommittee?: CommitteeToAdd[];
removeCommittee?: string[];
} & VotingAnchor;

type CommitteeToAdd = {
expiryEpoch: number;
committee: string;
};

type QuorumThreshold = {
numerator: number;
denominator: number;
};

const createGovernanceActionJsonLD: (
governanceAction: GovernanceAction
Expand All @@ -100,6 +130,22 @@ const buildTreasuryGovernanceAction: (
treasuryProps: TreasuryProps
) => Promise<VotingProposalBuilder | undefined>;

const buildProtocolParameterChangeGovernanceAction: (
protocolParameterChangeProps: ProtocolParameterChangeProps
) => Promise<VotingProposalBuilder | undefined>;

const buildHardForkInitiationGovernanceAction: (
hardForkInitiationProps: HardForkInitiationProps
) => Promise<VotingProposalBuilder | undefined>;

const buildNewConstitutionGovernanceAction: (
newConstitutionProps: NewConstitutionProps
) => Promise<VotingProposalBuilder | undefined>;

const buildUpdateCommitteeGovernanceAction: (
updateCommitteeProps: UpdateCommitteeProps
) => Promise<VotingProposalBuilder | undefined>;

const buildSignSubmitConwayCertTx: (params: {
govActionBuilder: VotingProposalBuilder;
type: "createGovAction";
Expand Down Expand Up @@ -165,44 +211,37 @@ const {
buildNewInfoGovernanceAction,
buildProtocolParameterChangeGovernanceAction,
buildHardForkInitiationGovernanceAction,
buildTreasuryGovernanceAction,
buildNewConstitutionGovernanceAction,
buildUpdateCommitteeGovernanceAction,
buildNoConfidenceGovernanceAction,
} = useCardano();

// Info Governance Action
const govActionBuilder = await buildNewInfoGovernanceAction({ hash, url });
let govActionBuilder = await buildNewInfoGovernanceAction({ hash, url });

// sign and submit the transaction
await buildSignSubmitConwayCertTx({
govActionBuilder,
type: "createGovAction",
});
// And for the other type of governance actions:

// Treasury Governance Action
const { buildTreasuryGovernanceAction } = useCardano();
govActionBuilder = await buildNoConfidenceGovernanceAction({ hash, url });

// 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({
govActionBuilder = await buildTreasuryGovernanceAction({
hash,
url,
withdrawals: [{ amount, receivingAddress }],
});

// Protocol Parameter Change Governance Action
const { buildProtocolParameterChangeGovernanceAction } = useCardano();

// hash of the previous Governance Action, index of the previous Governance Action, url of the metadata, hash of the metadata, and the updated protocol parameters
const govActionBuilder = await buildProtocolParameterChangeGovernanceAction({
govActionBuilder = await buildProtocolParameterChangeGovernanceAction({
prevGovernanceActionHash,
prevGovernanceActionIndex,
url,
hash,
protocolParamsUpdate,
});

// Hard Fork Initiation Governance Action
const { buildHardForkInitiationGovernanceAction } = useCardano();

// 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
const govActionBuilder = await buildHardForkInitiationGovernanceAction({
govActionBuilder = await buildHardForkInitiationGovernanceAction({
prevGovernanceActionHash,
prevGovernanceActionIndex,
url,
Expand All @@ -211,6 +250,24 @@ const govActionBuilder = await buildHardForkInitiationGovernanceAction({
minor,
});

// hash of the previous Governance Action, index of the previous Governance Action, url of the metadata, hash of the metadata, and the constitution script hash
govActionBuilder = await buildNewConstitutionGovernanceAction({
prevGovernanceActionHash,
prevGovernanceActionIndex,
constitutionUrl,
constitutionHash,
scriptHash,
});

// hash of the previous Governance Action, index of the previous Governance Action, url of the metadata, hash of the metadata, and the quorum threshold and the new committee members
govActionBuilder = await buildUpdateCommitteeGovernanceAction({
prevGovernanceActionHash,
prevGovernanceActionIndex,
quorumThreshold,
newCommittee,
removeCommittee,
});

// sign and submit the transaction
await buildSignSubmitConwayCertTx({
govActionBuilder,
Expand Down
27 changes: 22 additions & 5 deletions govtool/backend/sql/get-network-metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ DRepDistr AS (
CurrentEpoch AS (
SELECT MAX(no) AS no FROM epoch
),
CommitteeMembers AS (
SELECT DISTINCT ON (cm.committee_hash_id)
cr.id,
block.time,
encode(cold_key_hash.raw, 'hex') cold_key,
encode(hot_key_hash.raw, 'hex') hot_key
FROM committee_registration cr
JOIN tx ON tx.id = cr.tx_id
JOIN block ON block.id = tx.block_id
JOIN committee_hash cold_key_hash ON cr.cold_key_id = cold_key_hash.id
JOIN committee_hash hot_key_hash ON cr.hot_key_id = hot_key_hash.id
JOIN committee_member cm ON cm.committee_hash_id = cold_key_hash.id OR cm.committee_hash_id = hot_key_hash.id
LEFT JOIN committee_de_registration cdr ON cdr.cold_key_id = cold_key_hash.id
CROSS JOIN CurrentEpoch
WHERE
cdr.id IS NULL AND cm.expiration_epoch > CurrentEpoch.no
),
NoOfCommitteeMembers AS (
SELECT COUNT(*) total FROM CommitteeMembers
),
ActiveDRepBoundaryEpoch AS (
SELECT epoch_no - drep_activity AS epoch_no FROM DRepActivity
),
Expand Down Expand Up @@ -187,9 +207,6 @@ AlwaysNoConfidenceVotingPower AS (
TotalDRepDistr AS (
SELECT SUM(COALESCE(amount, 0))::bigint total_drep_distr FROM drep_distr where epoch_no = (SELECT no from CurrentEpoch)
),
CommitteeMembersCount AS (
SELECT COUNT(*) AS no_of_committee_members FROM committee_member
),
LatestGovAction AS (
SELECT gap.id, gap.enacted_epoch
FROM gov_action_proposal gap
Expand Down Expand Up @@ -223,7 +240,7 @@ SELECT
AlwaysAbstainVotingPower.amount AS always_abstain_voting_power,
AlwaysNoConfidenceVotingPower.amount AS always_no_confidence_voting_power,
meta.network_name,
CommitteeMembersCount.no_of_committee_members,
NoOfCommitteeMembers.total no_of_committee_members,
CommitteeThreshold.quorum_numerator,
CommitteeThreshold.quorum_denominator
FROM CurrentEpoch
Expand All @@ -242,6 +259,6 @@ CROSS JOIN TotalActiveCIP119CompliantDReps
CROSS JOIN TotalRegisteredDirectVoters
CROSS JOIN AlwaysAbstainVotingPower
CROSS JOIN AlwaysNoConfidenceVotingPower
CROSS JOIN CommitteeMembersCount
CROSS JOIN NoOfCommitteeMembers
CROSS JOIN CommitteeThreshold
CROSS JOIN meta;
10 changes: 5 additions & 5 deletions govtool/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion govtool/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@hookform/resolvers": "^3.3.1",
"@intersect.mbo/govtool-outcomes-pillar-ui": "1.0.0",
"@intersect.mbo/intersectmbo.org-icons-set": "^1.0.8",
"@intersect.mbo/pdf-ui": "^0.5.11",
"@intersect.mbo/pdf-ui": "^0.6.0",
"@mui/icons-material": "^5.14.3",
"@mui/material": "^5.14.4",
"@rollup/plugin-babel": "^6.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export const CreateGovernanceActionForm = ({
type! as
| GovernanceActionType.InfoAction
| GovernanceActionType.TreasuryWithdrawals
| GovernanceActionType.NewCommittee
| GovernanceActionType.NewConstitution
| GovernanceActionType.NoConfidence
],
).some(
(field) => !watch(field as unknown as Parameters<typeof watch>[0]),
Expand All @@ -67,6 +70,9 @@ export const CreateGovernanceActionForm = ({
type! as
| GovernanceActionType.InfoAction
| GovernanceActionType.TreasuryWithdrawals
| GovernanceActionType.NewCommittee
| GovernanceActionType.NewConstitution
| GovernanceActionType.NoConfidence
],
).map(([key, field]) => {
const fieldProps = {
Expand Down
Loading

0 comments on commit 8be0f19

Please sign in to comment.