viem
Version:
39 lines • 1.68 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildProveWithdrawal = void 0;
const getBlock_js_1 = require("../../../actions/public/getBlock.js");
const getProof_js_1 = require("../../../actions/public/getProof.js");
const contracts_js_1 = require("../contracts.js");
const getWithdrawalHashStorageSlot_js_1 = require("../utils/getWithdrawalHashStorageSlot.js");
const outputRootProofVersion = '0x0000000000000000000000000000000000000000000000000000000000000000';
async function buildProveWithdrawal(client, args) {
const { account, chain = client.chain, output, withdrawal } = args;
const { withdrawalHash } = withdrawal;
const { l2BlockNumber } = output;
const slot = (0, getWithdrawalHashStorageSlot_js_1.getWithdrawalHashStorageSlot)({ withdrawalHash });
const [proof, block] = await Promise.all([
(0, getProof_js_1.getProof)(client, {
address: contracts_js_1.contracts.l2ToL1MessagePasser.address,
storageKeys: [slot],
blockNumber: l2BlockNumber,
}),
(0, getBlock_js_1.getBlock)(client, {
blockNumber: l2BlockNumber,
}),
]);
return {
account,
l2OutputIndex: output.outputIndex,
outputRootProof: {
latestBlockhash: block.hash,
messagePasserStorageRoot: proof.storageHash,
stateRoot: block.stateRoot,
version: outputRootProofVersion,
},
targetChain: chain,
withdrawalProof: proof.storageProof[0].proof,
withdrawal,
};
}
exports.buildProveWithdrawal = buildProveWithdrawal;
//# sourceMappingURL=buildProveWithdrawal.js.map