UNPKG

@unruggable/gateways

Version:

Trustless Ethereum Multichain CCIP-Read Gateway

81 lines (80 loc) 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ROLLUP_ABI = void 0; exports.isInclusionProof = isInclusionProof; exports.isContract = isContract; exports.encodeProof = encodeProof; const abi_1 = require("ethers/abi"); const utils_js_1 = require("../utils.cjs"); const utils_1 = require("ethers/utils"); exports.ROLLUP_ABI = new abi_1.Interface([ // ZkEvmV2.sol `function currentL2BlockNumber() view returns (uint256)`, `function stateRootHashes(uint256 l2BlockNumber) view returns (bytes32)`, `function shnarfFinalBlockNumbers(bytes32 shnarf) external view returns (uint256)`, // ILineaRollup.sol `event DataFinalized( uint256 indexed lastBlockFinalized, bytes32 indexed startingRootHash, bytes32 indexed finalRootHash, bool withProof )`, `event DataFinalizedV3( uint256 indexed startBlockNumber, uint256 indexed endBlockNumber, bytes32 indexed shnarf, bytes32 parentStateRootHash, bytes32 finalStateRootHash )`, `event DataSubmittedV3( bytes32 parentShnarf, bytes32 indexed shnarf, bytes32 finalStateRootHash )`, `function submitBlobs( ( uint256 dataEvaluationClaim, bytes kzgCommitment, bytes kzgProof, bytes32 finalStateRootHash, bytes32 snarkHash, )[] blobSubmissionData, bytes32 parentShnarf, bytes32 finalBlobShnarf ) external`, // IZkEvmV2.sol `event BlocksVerificationDone( uint256 indexed lastBlockFinalized, bytes32 startingRootHash, bytes32 finalRootHash )`, ]); function isInclusionProof(proof) { return 'leafIndex' in proof; } //const NULL_CODE_HASH = '0x0134373b65f439c874734ff51ea349327c140cde2e47a933146e6f9f2ad8eb17'; // mimc(ZeroHash) function isContract(accountProof) { return (isInclusionProof(accountProof) && // https://github.com/Consensys/linea-monorepo/blob/a001342170768a22988a29b2dca8601199c6e205/contracts/contracts/lib/SparseMerkleProof.sol#L23 (0, utils_1.dataSlice)(accountProof.proof.value, 128, 160) !== utils_js_1.NULL_CODE_HASH); } function encodeProof(proof) { const T = '(uint256, bytes, bytes[])'; return utils_js_1.ABI_CODER.encode([T, T], isInclusionProof(proof) ? [ [proof.leafIndex, proof.proof.value, proof.proof.proofRelatedNodes], [0, '0x', []], ] : [ [ proof.leftLeafIndex, proof.leftProof.value, proof.leftProof.proofRelatedNodes, ], [ proof.rightLeafIndex, proof.rightProof.value, proof.rightProof.proofRelatedNodes, ], ]); }