@unruggable/gateways
Version:
Trustless Ethereum Multichain CCIP-Read Gateway
13 lines (12 loc) • 600 B
JavaScript
import { ZeroHash } from 'ethers/constants';
import { ABI_CODER, NULL_CODE_HASH } from '../utils.mjs';
export const EMPTY_STORAGE_HASH = '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421'; // see: merkle.ts
export function isContract(proof, requireStorage = false) {
const codeHash = proof.keccakCodeHash ?? proof.codeHash;
return (codeHash !== NULL_CODE_HASH && // eoa
codeHash !== ZeroHash && // dne
(!requireStorage || proof.storageHash !== EMPTY_STORAGE_HASH));
}
export function encodeProof(proof) {
return ABI_CODER.encode(['bytes[]'], [proof]);
}