Skip to content

Commit c9c419b

Browse files
committed
feat(#2258): add support for submitting all governance action types
1 parent b96c61f commit c9c419b

File tree

4 files changed

+378
-66
lines changed

4 files changed

+378
-66
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ changes.
1212

1313
### Added
1414

15-
-
15+
- Add support for submitting all 7 governance action types [Issue 2258](https://github.com/IntersectMBO/govtool/issues/2258)
1616

1717
### Fixed
1818

docs/GOVERNANCE_ACTION_SUBMISSION.md

Lines changed: 85 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ interface GovernanceAction {
3333
references: [{ label: string; uri: string }];
3434
}
3535

36-
interface InfoProps {
37-
hash: string;
36+
type VotingAnchor = {
3837
url: string;
38+
hash: string;
3939
}
4040

41-
interface TreasuryProps {
42-
amount: string;
43-
hash: string;
41+
type InfoProps = VotingAnchor;
42+
43+
type TreasuryProps {
4444
withdrawals: { receivingAddress: string; amount: string }[];
45-
}
45+
} & VotingAnchor;
4646

4747
type ProtocolParamsUpdate = {
4848
adaPerUtxo: string;
@@ -77,14 +77,44 @@ type ProtocolParamsUpdate = {
7777
treasuryGrowthRate: UnitInterval;
7878
};
7979

80-
interface ProtocolParameterChangeProps {
80+
type ProtocolParameterChangeProps {
8181
prevGovernanceActionHash: string;
8282
prevGovernanceActionIndex: number;
83-
url: string;
84-
hash: string;
85-
8683
protocolParamsUpdate: Partial<ProtocolParamsUpdate>;
87-
}
84+
} & VotingAnchor;
85+
86+
type HardForkInitiationProps = {
87+
prevGovernanceActionHash: string;
88+
prevGovernanceActionIndex: number;
89+
major: number;
90+
minor: number;
91+
} & VotingAnchor;
92+
93+
type NewConstitutionProps = {
94+
prevGovernanceActionHash: string;
95+
prevGovernanceActionIndex: number;
96+
constitutionUrl: string;
97+
constitutionHash: string;
98+
scriptHash: string;
99+
} & VotingAnchor;
100+
101+
type UpdateCommitteeProps = {
102+
prevGovernanceActionHash?: string;
103+
prevGovernanceActionIndex?: number;
104+
quorumThreshold: QuorumThreshold;
105+
newCommittee?: CommitteeToAdd[];
106+
removeCommittee?: string[];
107+
} & VotingAnchor;
108+
109+
type CommitteeToAdd = {
110+
expiryEpoch: number;
111+
committee: string;
112+
};
113+
114+
type QuorumThreshold = {
115+
numerator: number;
116+
denominator: number;
117+
};
88118

89119
const createGovernanceActionJsonLD: (
90120
governanceAction: GovernanceAction
@@ -100,6 +130,22 @@ const buildTreasuryGovernanceAction: (
100130
treasuryProps: TreasuryProps
101131
) => Promise<VotingProposalBuilder | undefined>;
102132

133+
const buildProtocolParameterChangeGovernanceAction: (
134+
protocolParameterChangeProps: ProtocolParameterChangeProps
135+
) => Promise<VotingProposalBuilder | undefined>;
136+
137+
const buildHardForkInitiationGovernanceAction: (
138+
hardForkInitiationProps: HardForkInitiationProps
139+
) => Promise<VotingProposalBuilder | undefined>;
140+
141+
const buildNewConstitutionGovernanceAction: (
142+
newConstitutionProps: NewConstitutionProps
143+
) => Promise<VotingProposalBuilder | undefined>;
144+
145+
const buildUpdateCommitteeGovernanceAction: (
146+
updateCommitteeProps: UpdateCommitteeProps
147+
) => Promise<VotingProposalBuilder | undefined>;
148+
103149
const buildSignSubmitConwayCertTx: (params: {
104150
govActionBuilder: VotingProposalBuilder;
105151
type: "createGovAction";
@@ -165,44 +211,37 @@ const {
165211
buildNewInfoGovernanceAction,
166212
buildProtocolParameterChangeGovernanceAction,
167213
buildHardForkInitiationGovernanceAction,
214+
buildTreasuryGovernanceAction,
215+
buildNewConstitutionGovernanceAction,
216+
buildUpdateCommitteeGovernanceAction,
217+
buildNoConfidenceGovernanceAction,
168218
} = useCardano();
169219

170220
// Info Governance Action
171-
const govActionBuilder = await buildNewInfoGovernanceAction({ hash, url });
221+
let govActionBuilder = await buildNewInfoGovernanceAction({ hash, url });
172222

173-
// sign and submit the transaction
174-
await buildSignSubmitConwayCertTx({
175-
govActionBuilder,
176-
type: "createGovAction",
177-
});
223+
// And for the other type of governance actions:
178224

179-
// Treasury Governance Action
180-
const { buildTreasuryGovernanceAction } = useCardano();
225+
govActionBuilder = await buildNoConfidenceGovernanceAction({ hash, url });
181226

182227
// hash of the generated Governance Action metadata, url of the metadata, amount of the transaction, receiving address is the stake key address
183-
const govActionBuilder = await buildTreasuryGovernanceAction({
228+
govActionBuilder = await buildTreasuryGovernanceAction({
184229
hash,
185230
url,
186231
withdrawals: [{ amount, receivingAddress }],
187232
});
188233

189-
// Protocol Parameter Change Governance Action
190-
const { buildProtocolParameterChangeGovernanceAction } = useCardano();
191-
192234
// 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
193-
const govActionBuilder = await buildProtocolParameterChangeGovernanceAction({
235+
govActionBuilder = await buildProtocolParameterChangeGovernanceAction({
194236
prevGovernanceActionHash,
195237
prevGovernanceActionIndex,
196238
url,
197239
hash,
198240
protocolParamsUpdate,
199241
});
200242

201-
// Hard Fork Initiation Governance Action
202-
const { buildHardForkInitiationGovernanceAction } = useCardano();
203-
204243
// 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
205-
const govActionBuilder = await buildHardForkInitiationGovernanceAction({
244+
govActionBuilder = await buildHardForkInitiationGovernanceAction({
206245
prevGovernanceActionHash,
207246
prevGovernanceActionIndex,
208247
url,
@@ -211,6 +250,24 @@ const govActionBuilder = await buildHardForkInitiationGovernanceAction({
211250
minor,
212251
});
213252

253+
// 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
254+
govActionBuilder = await buildNewConstitutionGovernanceAction({
255+
prevGovernanceActionHash,
256+
prevGovernanceActionIndex,
257+
constitutionUrl,
258+
constitutionHash,
259+
scriptHash,
260+
});
261+
262+
// 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
263+
govActionBuilder = await buildUpdateCommitteeGovernanceAction({
264+
prevGovernanceActionHash,
265+
prevGovernanceActionIndex,
266+
quorumThreshold,
267+
newCommittee,
268+
removeCommittee,
269+
});
270+
214271
// sign and submit the transaction
215272
await buildSignSubmitConwayCertTx({
216273
govActionBuilder,

0 commit comments

Comments
 (0)