UNPKG

@morpho-org/midnight-sdk

Version:

Viem-based package for Morpho Midnight that exports protocol utilities, fetch helpers, and Midnight API utilities under a dedicated API subpath.

23 lines (22 loc) • 871 B
import { concat, keccak256 } from "viem"; /** * Hashes EIP-712 digest parts as `keccak256(0x1901 || domainSeparator || structHash)`. * * Use this when the domain separator and struct hash are already available and * rebuilding full typed-data values would duplicate protocol-specific type maps. * * @param domainSeparator - EIP-712 domain separator hash. * @param structHash - EIP-712 struct hash. * @returns Canonical EIP-712 digest. * @example * ```ts * import { eip712Digest } from "@morpho-org/midnight-sdk"; * * const digest = eip712Digest( * "0x0000000000000000000000000000000000000000000000000000000000000001", * "0x0000000000000000000000000000000000000000000000000000000000000002", * ); * console.log(digest); * ``` */ export const eip712Digest = (domainSeparator, structHash) => keccak256(concat(["0x1901", domainSeparator, structHash]));