Skip to content

Commit

Permalink
Merge pull request #1822 from IntersectMBO/feat/hf-ppc-treasury-gov-a…
Browse files Browse the repository at this point in the history
…ctions-support

feat: HF, PPC and guardrails script support for Governance Action builders
  • Loading branch information
MSzalowski authored Aug 26, 2024
2 parents 7958259 + 9c552a0 commit cfd5ff2
Show file tree
Hide file tree
Showing 7 changed files with 377 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ changes.
- Add support for hard fork initiation previous governance action data [Issue 1600](https://github.com/IntersectMBO/govtool/issues/1600)
- Add support for CIP-119 on the backend and metadata validation [Issue 1758](https://github.com/IntersectMBO/govtool/issues/1758)
- Add support for CIP-119 on the frontend [Issue 1760](https://github.com/IntersectMBO/govtool/issues/1758)
- Add support for HF Initiation and Protocol Parameter Change governance action builders [Issue 1600](https://github.com/IntersectMBO/govtool/issues/1600) & [Issue 1601](https://github.com/IntersectMBO/govtool/issues/1601)

### Fixed

Expand Down
91 changes: 85 additions & 6 deletions docs/GOVERNANCE_ACTION_SUBMISSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ For creating the Governance Action, you need to consume 2 utility methods provid
### Types

```typescript
import { VotingProposalBuilder } from "@emurgo/cardano-serialization-lib-nodejs";
import {
VotingProposalBuilder,
Costmdls,
DrepVotingThresholds,
ExUnitPrices,
UnitInterval,
ExUnits,
PoolVotingThresholds,
} from "@emurgo/cardano-serialization-lib-nodejs";

interface GovernanceAction {
title: string;
Expand All @@ -37,6 +45,48 @@ interface TreasuryProps {
url: string;
}

type ProtocolParamsUpdate = {
adaPerUtxo: string;
collateralPercentage: number;
committeeTermLimit: number;
costModels: Costmdls;
drepDeposit: string;
drepInactivityPeriod: number;
drepVotingThresholds: DrepVotingThresholds;
executionCosts: ExUnitPrices;
expansionRate: UnitInterval;
governanceActionDeposit: string;
governanceActionValidityPeriod: number;
keyDeposit: string;
maxBlockBodySize: number;
maxBlockExUnits: ExUnits;
maxBlockHeaderSize: number;
maxCollateralInputs: number;
maxEpoch: number;
maxTxExUnits: ExUnits;
maxTxSize: number;
maxValueSize: number;
minCommitteeSize: number;
minPoolCost: string;
minFeeA: string;
minFeeB: string;
nOpt: number;
poolDeposit: string;
poolPledgeInfluence: UnitInterval;
poolVotingThresholds: PoolVotingThresholds;
refScriptCoinsPerByte: UnitInterval;
treasuryGrowthRate: UnitInterval;
};

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

protocolParamsUpdate: Partial<ProtocolParamsUpdate>;
}

const createGovernanceActionJsonLD: (
governanceAction: GovernanceAction
) => NodeObject;
Expand Down Expand Up @@ -111,10 +161,14 @@ Example:

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

// hash of the generated Governance Action metadata, url of the metadata
const {
buildSignSubmitConwayCertTx,
buildNewInfoGovernanceAction,
buildProtocolParameterChangeGovernanceAction,
buildHardForkInitiationGovernanceAction,
} = useCardano();

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

// sign and submit the transaction
Expand All @@ -123,7 +177,7 @@ await buildSignSubmitConwayCertTx({
type: "createGovAction",
});

// or if you want to use the Treasury Governance Action
// 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
Expand All @@ -134,6 +188,31 @@ const govActionBuilder = await buildTreasuryGovernanceAction({
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({
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({
prevGovernanceActionHash,
prevGovernanceActionIndex,
url,
hash,
major,
minor,
});

// sign and submit the transaction
await buildSignSubmitConwayCertTx({
govActionBuilder,
Expand Down
3 changes: 3 additions & 0 deletions govtool/frontend/src/consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ export const CEXPLORER_BASE_URLS = {
testnet: "https://testnet.cexplorer.io",
mainnet: "https://cexplorer.io",
};

export const GUARDRAIL_SCRIPT =
"59082f59082c0101003232323232323232323232323232323232323232323232323232323232323232323232323232323232323225932325333573466e1d2000001180098121bab357426ae88d55cf001054ccd5cd19b874801000460042c6aae74004dd51aba1357446ae88d55cf1baa325333573466e1d200a35573a00226ae84d5d11aab9e0011637546ae84d5d11aba235573c6ea800642b26006003149a2c8a4c3021801c0052000c00e0070018016006901e40608058c00e00290016007003800c00b0034830268320306007001800600690406d6204e00060001801c0052004c00e007001801600690404001e0006007001800600690404007e00060001801c0052006c00e006023801c006001801a4101000980018000600700148023003801808e0070018006006904827600060001801c005200ac00e0070018016006904044bd4060c00e003000c00d2080ade204c000c0003003800a4019801c00e003002c00d2080cab5ee0180c100d1801c005200ec00e0060238000c00e00290086007003800c00b003483d00e0306007001800600690500fe00040243003800a4025803c00c01a0103003800a4029803c00e003002c00cc07520d00f8079801c006001801980ea4120078001800060070014805b00780180360070018006006603e900a4038c0003003800a4041801c00c04601a3003800a4045801c00e003002c00d20f02e80c1801c006001801a4190cb80010090c00e00290126000c00e0029013600b003803c00e003002c00cc0752032c000c00e003000c00cc075200ac000c0006007007801c006005801980ea418170058001801c006001801980ea41209d80018000c0003003800a4051802c00e007003011c00e003000c00d2080e89226c000c0006007003801808e007001800600690406c4770b7e000600030000c00e0029015600b003801c00c047003800c00300348202e2e1cb00030001801c00e006023801c006001801a410181f905540580018000c0003003800a4059801c00c047003800c00300348203000700030000c00e00290176007003800c00b003483200603060070018006006904801e00040243003800a4061801c00c0430001801c0052032c016006003801801e00600780180140100c00e002901a600b003001c00c00f003003c00c00f003002c00c007003001c00c007003803c00e003002c00c0560184014802000c00e002901b6007003800c00b003480030034801b0001801c006001801a4029800180006007001480e3003801c006005801a4001801a40498000c00e003000c00d20ca04c00080486007001480eb00380180860070018006006900f600060001801c005203cc00e006015801c006001801a4101012bcf138c09800180006007001480fb003801805600700180060069040505bc3f482e00060001801c0052040c00e0070018016006900d4060c00e003000c00d204ac000c0003003800a4085801c00c04601630000000000200f003006c00e003000c00c05a0166000200f003005c00e003000c00c057003010c0006000200f003800c00b003012c00cc05d2028c0004008801c01e007001801600602380010043000400e003000c00c04b003011c0006000800c00b00300d8049001801600601d801980924190038000801c0060010066000801c00600900f6000800c00b003480030034820225eb0001003800c003003483403f0003000400c023000400e003000c00d208094ebdc03c000c001003009c001003300f4800b0004006005801a40058001001801401c6014900518052402860169004180424008600a900a180324005003480030001806240cc6016900d18052402460129004180424004600e900018032400c6014446666aae7c004a0005003328009aab9d0019aab9e0011aba100298019aba200224c6012444a6520071300149a4432005225900689802a4d2219002912c998099bad0020068ac99807002800c4cc03001c00e300244cc03001c02a3002012c801460012218010c00888004c004880094cc8c0040048848c8cc0088c00888c00800c8c00888c00400c8d4cc01001000cd400c0044888cc00c896400a300090999804c00488ccd5cd19b87002001800400a01522333573466e2000800600100291199ab9a33712004003000801488ccd5cd19b89002001801400244666ae68cdc4001000c00a001225333573466e240080044004400a44a666ae68cdc4801000880108008004dd6801484cc010004dd6001484c8ccc02a002452005229003912999ab9a3370e0080042666ae68cdc3801800c00200430022452005229003911980899b820040013370400400648a400a45200722333573466e20cdc100200099b82002003800400880648a400a45200722333573466e24cdc100200099b82002003801400091480148a400e44666ae68cdc419b8200400133704004007002800122593300e0020018800c400922593300e00200188014400400233323357346ae8cd5d10009198051bad357420066eb4d5d08011aba2001268001bac00214800c8ccd5cd1aba3001800400a444b26600c0066ae8400626600a0046ae8800630020c0148894ccd5cd19b87480000045854ccd5cd19b88001480004cc00ccdc0a400000466e05200000113280099b8400300199b840020011980200100098021112999ab9a3370e9000000880109980180099b860020012223300622590018c002443200522323300d225900189804803488564cc0140080322600800318010004b20051900991111111001a3201322222222005448964ce402e444444440100020018c00a30000002225333573466e1c00800460002a666ae68cdc48010008c010600445200522900391199ab9a3371266e08010004cdc1001001c0020041191800800918011198010010009";
Loading

0 comments on commit cfd5ff2

Please sign in to comment.