@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.
27 lines (26 loc) • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.eip712Digest = void 0;
const viem_1 = require("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);
* ```
*/
const eip712Digest = (domainSeparator, structHash) => (0, viem_1.keccak256)((0, viem_1.concat)(["0x1901", domainSeparator, structHash]));
exports.eip712Digest = eip712Digest;