From 929b275cac7fe76c4bbc3efd9f1565809d6242f2 Mon Sep 17 00:00:00 2001 From: Philip Paetz Date: Tue, 6 Aug 2024 10:56:53 +0200 Subject: [PATCH] chore: add timelock operation id explainer --- src/utils/get-time-lock-id.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/utils/get-time-lock-id.ts b/src/utils/get-time-lock-id.ts index 5954f86..67e730f 100644 --- a/src/utils/get-time-lock-id.ts +++ b/src/utils/get-time-lock-id.ts @@ -1,7 +1,16 @@ -import { encodeAbiParameters, parseAbiParameters, keccak256 } from "viem"; +import { encodeAbiParameters, keccak256, parseAbiParameters } from "viem"; import { ProposalCreatedEvent } from "../types"; +/** + * Given a ProposalCreatedEvent, calculate the corresponding timelock operation ID. + * Governance Watchdogs need the timelock operation ID to veto queued proposals. + * + * The governor proposal ID and the timelock operation ID are not the same, which can + * be confusing. They use different hashing mechanisms to calculate their respective IDs: + * - Timelock Controller Operation IDs: https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/58fa0f81c4036f1a3b616fdffad2fd27e5d5ce21/contracts/governance/TimelockControllerUpgradeable.sol#L218 + * - Governor Proposal IDs: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/0a25c1940ca220686588c4af3ec526f725fe2582/contracts/governance/Governor.sol#L139 + */ export default function getProposalTimeLockId( event: ProposalCreatedEvent, ): string {