Files
linea-monorepo/contracts/common/helpers/hashing.ts
kyzooghost e861b42699 [Fix] Update smart-contract-errors.yaml with script assistance (#809)
* fix

* added more errors to smart-contract-errors.toml

* cross-check against bytecode

* remove redundant comment
2025-03-25 20:34:49 +11:00

12 lines
510 B
TypeScript

import { ethers } from "ethers";
import { encodeData } from "./encoding";
export const generateKeccak256 = (types: string[], values: unknown[], opts: { encodePacked?: boolean }) =>
ethers.keccak256(encodeData(types, values, opts.encodePacked));
export const generateKeccak256ForString = (value: string) =>
generateKeccak256(["string"], [value], { encodePacked: true });
export const generateFunctionSelector = (functionSignature: string) =>
generateKeccak256ForString(functionSignature).slice(2, 10);