Source mirror · commit 369512f · 2026-10-26 · MIT · canonical repo: gitlab.com/jiapunk/upgrade-airlock
git clone https://upgrade-airlock.pages.dev/source/upgrade-airlock.git
upgrade-airlock / cre / veto / keys.ts
cre/veto/keys.ts13 lines · 1069 bytes
1// Approval keys looked up with AirlockAdmin.isApprovedCodehash (the approver registers them before the proposal):
2// - config proposals (kinds 1-3, R7): keccak256(abi.encode(uint8 kind, address target, uint256 value))
3// - upgrade with non-empty init data (R8): keccak256(abi.encode(bytes32 codehash, bytes32 keccak256(data)))
4// The second word is the proposal's dataHash, so the key is computable from getProposal alone: the workflow never
5// needs the init data itself (which can be larger than one log event or one chain read may carry).
6// - upgrade codehash (R5 strict, R9 exemption): the codehash itself
7import { type Address, encodeAbiParameters, type Hex, keccak256 } from 'viem'
8
9export const actionHash = (kind: number, target: Address, value: bigint): Hex =>
10 keccak256(encodeAbiParameters([{ type: 'uint8' }, { type: 'address' }, { type: 'uint256' }], [kind, target, value]))
11
12export const upgradeDataKey = (codehash: Hex, dataHash: Hex): Hex =>
13 keccak256(encodeAbiParameters([{ type: 'bytes32' }, { type: 'bytes32' }], [codehash, dataHash]))