|
1 | 1 | const { providers } = require('ethers'); |
2 | 2 | const { readDeployContract } = require('../../../script/utils'); |
3 | 3 | const logName = require('../../../script/deploy_log_name'); |
4 | | -const { L1ToL2MessageGasEstimator } = require('@arbitrum/sdk/dist/lib/message/L1ToL2MessageGasEstimator'); |
5 | 4 | const { getBaseFee } = require('@arbitrum/sdk/dist/lib/utils/lib'); |
6 | 5 | const { task, types } = require('hardhat/config'); |
7 | 6 | const { zkLinkConfig } = require('../../../script/zklink_config'); |
8 | | -const { L1TransactionReceipt, L1ToL2MessageStatus } = require('@arbitrum/sdk'); |
| 7 | +const { ParentTransactionReceipt, ParentToChildMessageStatus, ChildTransactionReceipt, ChildToParentMessageStatus, ParentToChildMessageGasEstimator } = require('@arbitrum/sdk'); |
9 | 8 |
|
10 | 9 | require('dotenv').config(); |
11 | 10 |
|
@@ -59,7 +58,7 @@ task('encodeL1ToL2Calldata', 'Encode call data for l1 to l2') |
59 | 58 | /** |
60 | 59 | * Now we can query the required gas params using the estimateAll method in Arbitrum SDK |
61 | 60 | */ |
62 | | - const l1ToL2MessageGasEstimate = new L1ToL2MessageGasEstimator(l2Provider); |
| 61 | + const l1ToL2MessageGasEstimate = new ParentToChildMessageGasEstimator(l2Provider); |
63 | 62 |
|
64 | 63 | /** |
65 | 64 | * The estimateAll method gives us the following values for sending an L1->L2 message |
@@ -110,21 +109,40 @@ task('checkL1TxStatus', 'Check the l1 tx status') |
110 | 109 |
|
111 | 110 | const l1Provider = new providers.JsonRpcProvider(process.env.L1RPC); |
112 | 111 | const l2Provider = new providers.JsonRpcProvider(process.env.L2RPC); |
113 | | - const l1TxReceipt = new L1TransactionReceipt(await l1Provider.getTransactionReceipt(l1TxHash)); |
| 112 | + const l1TxReceipt = new ParentTransactionReceipt(await l1Provider.getTransactionReceipt(l1TxHash)); |
114 | 113 |
|
115 | 114 | /** |
116 | 115 | * In principle, a single L1 txn can trigger any number of L1-to-L2 messages (each with its own sequencer number). |
117 | 116 | * In this case, we know our txn triggered only one |
118 | 117 | * Here, We check if our L1 to L2 message is redeemed on L2 |
119 | 118 | */ |
120 | | - const messages = await l1TxReceipt.getL1ToL2Messages(l2Provider); |
| 119 | + const messages = await l1TxReceipt.getParentToChildMessages(l2Provider); |
121 | 120 | const message = messages[0]; |
122 | 121 | console.log('Waiting for the L2 execution of the transaction. This may take up to 10-15 minutes ⏰'); |
123 | 122 | const messageResult = await message.waitForStatus(); |
124 | 123 | const status = messageResult.status; |
125 | | - if (status === L1ToL2MessageStatus.REDEEMED) { |
126 | | - console.log(`L2 retryable ticket is executed 🥳 ${messageResult.l2TxReceipt.transactionHash}`); |
| 124 | + if (status === ParentToChildMessageStatus.REDEEMED) { |
| 125 | + console.log(`L2 retryable ticket is executed 🥳 ${messageResult.childTxReceipt.transactionHash}`); |
127 | 126 | } else { |
128 | | - console.log(`L2 retryable ticket is failed with status ${L1ToL2MessageStatus[status]}`); |
| 127 | + console.log(`L2 retryable ticket is failed with status ${ParentToChildMessageStatus[status]}`); |
129 | 128 | } |
130 | 129 | }); |
| 130 | + |
| 131 | +task('checkL2TxStatus', 'Check the l2 tx status') |
| 132 | + .addParam('l2TxHash', 'The l2 tx hash', undefined, types.string) |
| 133 | + .setAction(async (taskArgs) => { |
| 134 | + const l2TxHash = taskArgs.l2TxHash; |
| 135 | + console.log(`The l2 tx hash: ${l2TxHash}`); |
| 136 | + |
| 137 | + const l1Provider = new providers.JsonRpcProvider(process.env.L1RPC); |
| 138 | + const l2Provider = new providers.JsonRpcProvider(process.env.L2RPC); |
| 139 | + const txReceipt = await l2Provider.getTransactionReceipt( |
| 140 | + l2TxHash, |
| 141 | + ); |
| 142 | + const arbL2Receipt = new ChildTransactionReceipt(txReceipt); |
| 143 | + const l2ToL1Msg = ( |
| 144 | + await arbL2Receipt.getChildToParentMessages(l1Provider) |
| 145 | + ).pop(); |
| 146 | + const msgStatus = await l2ToL1Msg.status(l2Provider); |
| 147 | + console.log(`The l2 message status: ${ChildToParentMessageStatus[msgStatus]}`); |
| 148 | + }); |
0 commit comments