Skip to content

Commit

Permalink
gov_fix (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
timbrinded authored Mar 25, 2024
1 parent c3a29db commit 5d82cd9
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .changeset/perfect-boats-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@moonwall/types": patch
"@moonwall/util": patch
"@moonwall/cli": patch
---

Another minor gov fn
7 changes: 1 addition & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
"node": ">=20",
"pnpm": ">=7"
},
"files": [
"dist",
"bin",
"*.d.ts",
"*.mjs"
],
"files": ["dist", "bin", "*.d.ts", "*.mjs"],
"scripts": {
"clean": "rm -rf dist && rm -rf node_modules",
"build": "pnpm exec rm -rf dist && tsup src --format esm --no-splitting --sourcemap && pnpm generate-types",
Expand Down
61 changes: 61 additions & 0 deletions packages/cli/src/lib/governanceProcedures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,67 @@ export const instantFastTrack = async <
return proposalHash;
};

export const whiteListTrackNoSend = async <
Call extends SubmittableExtrinsic<ApiType>,
ApiType extends ApiTypes,
>(
context: DevModeContext,
proposal: string | Call
) => {
const proposalHash =
typeof proposal === "string" ? proposal : await notePreimage(context, proposal);

const proposalLen = (await context.pjsApi.query.preimage.requestStatusFor(proposalHash)).unwrap()
.asUnrequested.len;
const dispatchWLCall = context.pjsApi.tx.whitelist.dispatchWhitelistedCall(
proposalHash,
proposalLen,
{
refTime: 2_000_000_000,
proofSize: 100_000,
}
);

const wLPreimage = await notePreimage(context, dispatchWLCall);
const wLPreimageLen = dispatchWLCall.encodedLength - 2;
console.log(
`📝 DispatchWhitelistedCall preimage noted: ${wLPreimage.slice(0, 6)}...${wLPreimage.slice(
-4
)}, len: ${wLPreimageLen}`
);

const openGovProposal = await context.pjsApi.tx.referenda
.submit(
{
Origins: { whitelistedcaller: "WhitelistedCaller" },
},
{ Lookup: { hash: wLPreimage, len: wLPreimageLen } },
{ After: { After: 0 } }
)
.signAsync(faith);
const { result } = await context.createBlock(openGovProposal);

if (!result?.events) {
throw new Error("No events in block");
}

let proposalId: number | undefined;
filterAndApply(result.events, "referenda", ["Submitted"], (found) => {
proposalId = (found.event as any).data.index.toNumber();
});

if (typeof proposalId === "undefined") {
throw new Error("No proposal id found");
}

console.log(`🏛️ Referendum submitted with proposal id: ${proposalId}`);
await context.createBlock(context.pjsApi.tx.referenda.placeDecisionDeposit(proposalId));

const whitelistCall = context.pjsApi.tx.whitelist.whitelistCall(proposalHash);
await execOpenTechCommitteeProposal(context, whitelistCall);
return { proposalHash, whitelistedHash: wLPreimage };
};

// Uses WhitelistedOrigin track to quickly execute a call
export const whiteListedTrack = async <
Call extends SubmittableExtrinsic<ApiType>,
Expand Down
7 changes: 1 addition & 6 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@
"node": ">=20",
"pnpm": ">=7"
},
"files": [
"dist",
"bin",
"*.d.ts",
"*.mjs"
],
"files": ["dist", "bin", "*.d.ts", "*.mjs"],
"scripts": {
"clean": "rm -rf dist && rm -rf node_modules",
"build": "rm -rf dist && tsup src --format esm --no-splitting --sourcemap && pnpm generate-types",
Expand Down
7 changes: 1 addition & 6 deletions packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@
"node": ">=20",
"pnpm": ">=7"
},
"files": [
"dist",
"bin",
"*.d.ts",
"*.mjs"
],
"files": ["dist", "bin", "*.d.ts", "*.mjs"],
"scripts": {
"clean": "rm -rf dist && rm -rf node_modules",
"build": "pnpm exec rm -rf dist && tsup src --format esm --no-splitting --sourcemap && pnpm generate-types",
Expand Down

0 comments on commit 5d82cd9

Please sign in to comment.