diff --git a/.changeset/perfect-boats-yell.md b/.changeset/perfect-boats-yell.md new file mode 100644 index 00000000..004184f4 --- /dev/null +++ b/.changeset/perfect-boats-yell.md @@ -0,0 +1,7 @@ +--- +"@moonwall/types": patch +"@moonwall/util": patch +"@moonwall/cli": patch +--- + +Another minor gov fn diff --git a/packages/cli/package.json b/packages/cli/package.json index d68a31b1..f494f5e3 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -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", diff --git a/packages/cli/src/lib/governanceProcedures.ts b/packages/cli/src/lib/governanceProcedures.ts index d10aecd1..dc406ed4 100644 --- a/packages/cli/src/lib/governanceProcedures.ts +++ b/packages/cli/src/lib/governanceProcedures.ts @@ -78,6 +78,67 @@ export const instantFastTrack = async < return proposalHash; }; +export const whiteListTrackNoSend = async < + Call extends SubmittableExtrinsic, + 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, diff --git a/packages/types/package.json b/packages/types/package.json index 15882946..bdaf33f2 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -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", diff --git a/packages/util/package.json b/packages/util/package.json index a8a6c83f..fe7b81a0 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -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",