Skip to content

Commit

Permalink
op check l2 tx status
Browse files Browse the repository at this point in the history
  • Loading branch information
zkbenny committed Apr 12, 2024
1 parent 131834e commit 5313096
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/optimism/scripts/opstack-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,12 @@ async function checkL1TxStatus(hre, messenger, ethereumName, opChainName, l1TxHa
console.log(`L1 to l2 tx is executed 🥳`);
}

async function checkL2TxStatus(hre, messenger, ethereumName, opChainName, l2TxHash) {
const message = (await messenger.getMessagesByTransaction(l2TxHash)).pop();
const messageStatus = await messenger.getMessageStatus(message);
console.log(`L1 to l2 message status: ${messageStatus}`);
}

module.exports = {
getContractAddresses,
syncBatchRoot,
Expand All @@ -389,4 +395,5 @@ module.exports = {
encodeChangeFeeParams,
encodeL1ToL2Calldata,
checkL1TxStatus,
checkL2TxStatus,
};
11 changes: 11 additions & 0 deletions examples/optimism/scripts/optimismTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
encodeChangeFeeParams,
encodeL1ToL2Calldata,
checkL1TxStatus,
checkL2TxStatus,
} = require('./opstack-utils');
const { task, types } = require('hardhat/config');
require('dotenv').config();
Expand Down Expand Up @@ -143,3 +144,13 @@ task('checkL1TxStatus', 'Check the l1 tx status')
const { messenger, ethereumName, optimismName } = await initMessenger();
await checkL1TxStatus(hre, messenger, ethereumName, optimismName, l1TxHash);
});

task('checkL2TxStatus', 'Check the l2 tx status')
.addParam('l2TxHash', 'The l2 tx hash', undefined, types.string)
.setAction(async (taskArgs, hre) => {
const l2TxHash = taskArgs.l2TxHash;
console.log(`The l2 tx hash: ${l2TxHash}`);

const { messenger, ethereumName, optimismName } = await initMessenger();
await checkL2TxStatus(hre, messenger, ethereumName, optimismName, l2TxHash);
});

0 comments on commit 5313096

Please sign in to comment.