-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add timelock-id in notifications (#13)
This adds the timelock ID to the discord/telegram notification messages so that it can be used by members of the watchdog group to veto a proposal if needed. Discord <img width="543" alt="Screenshot 2024-08-05 at 14 48 03" src="https://github.com/user-attachments/assets/0b625587-b62a-48ec-94f4-51e35be71f7d"> Telegram ![image](https://github.com/user-attachments/assets/97fae6e7-b35e-4e84-96bd-a12c3b006a1b) --------- Co-authored-by: Philip Paetz <philip.paetz@me.com>
- Loading branch information
Showing
6 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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 { | ||
const { targets, values, calldatas, description } = event.args; | ||
const descriptionHash = keccak256(Buffer.from(description)); | ||
|
||
return keccak256( | ||
encodeAbiParameters( | ||
parseAbiParameters("address[], uint256[], bytes[], uint256, bytes32"), | ||
// _timelockIds[proposalId] = _timelock.hashOperationBatch(targets, values, calldatas, 0, descriptionHash); | ||
[targets, values, calldatas, 0n, descriptionHash], | ||
), | ||
); | ||
} |