Skip to content

Commit 5fe163e

Browse files
committed
upgrade arbitrum sdk to v4
1 parent 02497f6 commit 5fe163e

File tree

8 files changed

+64
-49
lines changed

8 files changed

+64
-49
lines changed

examples/arbitrum/package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/arbitrum/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"ethers": "^5.1.2"
1010
},
1111
"dependencies": {
12-
"@arbitrum/sdk": "^3.1.13",
12+
"@arbitrum/sdk": "^4.0.3",
1313
"dotenv": "^16.4.1"
1414
}
1515
}

examples/arbitrum/scripts/changeFeeParams.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const { providers, Wallet, utils } = require('ethers');
22
const { readDeployContract, getLogName } = require('../../../script/utils');
33
const logName = require('../../../script/deploy_log_name');
4-
const { L1TransactionReceipt, L1ToL2MessageStatus } = require('@arbitrum/sdk');
5-
const { L1ToL2MessageGasEstimator } = require('@arbitrum/sdk/dist/lib/message/L1ToL2MessageGasEstimator');
4+
const { ParentTransactionReceipt, ParentToChildMessageStatus, ParentToChildMessageGasEstimator } = require('@arbitrum/sdk');
65
const { getBaseFee } = require('@arbitrum/sdk/dist/lib/utils/lib');
76
const { task } = require('hardhat/config');
87

@@ -19,7 +18,7 @@ task('changeFeeParams', 'Change fee params for zkLink').setAction(async (taskArg
1918
/**
2019
* Now we can query the required gas params using the estimateAll method in Arbitrum SDK
2120
*/
22-
const l1ToL2MessageGasEstimate = new L1ToL2MessageGasEstimator(l2Provider);
21+
const l1ToL2MessageGasEstimate = new ParentToChildMessageGasEstimator(l2Provider);
2322

2423
const l1WalletAddress = await l1Wallet.getAddress();
2524
const l1WalletBalance = utils.formatEther(await l1Wallet.getBalance());
@@ -110,21 +109,21 @@ task('changeFeeParams', 'Change fee params for zkLink').setAction(async (taskArg
110109
console.log(`The l1 tx hash: ${l1TxHash}`);
111110
const forwardMessageReceipt = await l1Tx.wait();
112111

113-
const l1TxReceipt = new L1TransactionReceipt(forwardMessageReceipt);
112+
const l1TxReceipt = new ParentTransactionReceipt(forwardMessageReceipt);
114113

115114
/**
116115
* In principle, a single L1 txn can trigger any number of L1-to-L2 messages (each with its own sequencer number).
117116
* In this case, we know our txn triggered only one
118117
* Here, We check if our L1 to L2 message is redeemed on L2
119118
*/
120-
const messages = await l1TxReceipt.getL1ToL2Messages(l2Wallet);
119+
const messages = await l1TxReceipt.getParentToChildMessages(l2Wallet);
121120
const message = messages[0];
122121
console.log('Waiting for the L2 execution of the transaction. This may take up to 10-15 minutes ⏰');
123122
const messageResult = await message.waitForStatus();
124123
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}`);
127126
} 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]}`);
129128
}
130129
});

examples/arbitrum/scripts/governance.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
const { providers } = require('ethers');
22
const { readDeployContract } = require('../../../script/utils');
33
const logName = require('../../../script/deploy_log_name');
4-
const { L1ToL2MessageGasEstimator } = require('@arbitrum/sdk/dist/lib/message/L1ToL2MessageGasEstimator');
54
const { getBaseFee } = require('@arbitrum/sdk/dist/lib/utils/lib');
65
const { task, types } = require('hardhat/config');
76
const { zkLinkConfig } = require('../../../script/zklink_config');
8-
const { L1TransactionReceipt, L1ToL2MessageStatus } = require('@arbitrum/sdk');
7+
const { ParentTransactionReceipt, ParentToChildMessageStatus, ChildTransactionReceipt, ChildToParentMessageStatus, ParentToChildMessageGasEstimator } = require('@arbitrum/sdk');
98

109
require('dotenv').config();
1110

@@ -59,7 +58,7 @@ task('encodeL1ToL2Calldata', 'Encode call data for l1 to l2')
5958
/**
6059
* Now we can query the required gas params using the estimateAll method in Arbitrum SDK
6160
*/
62-
const l1ToL2MessageGasEstimate = new L1ToL2MessageGasEstimator(l2Provider);
61+
const l1ToL2MessageGasEstimate = new ParentToChildMessageGasEstimator(l2Provider);
6362

6463
/**
6564
* 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')
110109

111110
const l1Provider = new providers.JsonRpcProvider(process.env.L1RPC);
112111
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));
114113

115114
/**
116115
* In principle, a single L1 txn can trigger any number of L1-to-L2 messages (each with its own sequencer number).
117116
* In this case, we know our txn triggered only one
118117
* Here, We check if our L1 to L2 message is redeemed on L2
119118
*/
120-
const messages = await l1TxReceipt.getL1ToL2Messages(l2Provider);
119+
const messages = await l1TxReceipt.getParentToChildMessages(l2Provider);
121120
const message = messages[0];
122121
console.log('Waiting for the L2 execution of the transaction. This may take up to 10-15 minutes ⏰');
123122
const messageResult = await message.waitForStatus();
124123
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}`);
127126
} 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]}`);
129128
}
130129
});
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+
});

examples/arbitrum/scripts/setSecondaryGateway.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const { providers, Wallet, utils } = require('ethers');
22
const { readDeployContract, getLogName, readDeployLogField } = require('../../../script/utils');
33
const logName = require('../../../script/deploy_log_name');
4-
const { L1TransactionReceipt, L1ToL2MessageStatus } = require('@arbitrum/sdk');
5-
const { L1ToL2MessageGasEstimator } = require('@arbitrum/sdk/dist/lib/message/L1ToL2MessageGasEstimator');
4+
const { ParentTransactionReceipt, ParentToChildMessageStatus, ParentToChildMessageGasEstimator } = require('@arbitrum/sdk');
65
const { getBaseFee } = require('@arbitrum/sdk/dist/lib/utils/lib');
76
const { task, types } = require('hardhat/config');
87

@@ -80,7 +79,7 @@ task('setSecondaryGateway', 'Send secondary gateway')
8079
/**
8180
* Now we can query the required gas params using the estimateAll method in Arbitrum SDK
8281
*/
83-
const l1ToL2MessageGasEstimate = new L1ToL2MessageGasEstimator(l2Provider);
82+
const l1ToL2MessageGasEstimate = new ParentToChildMessageGasEstimator(l2Provider);
8483

8584
const l1WalletAddress = await l1Wallet.getAddress();
8685
const l1WalletBalance = utils.formatEther(await l1Wallet.getBalance());
@@ -136,21 +135,21 @@ task('setSecondaryGateway', 'Send secondary gateway')
136135
console.log(`The l1 tx hash: ${l1TxHash}`);
137136
const arbitratorReceipt = await l1Tx.wait();
138137

139-
const l1TxReceipt = new L1TransactionReceipt(arbitratorReceipt);
138+
const l1TxReceipt = new ParentTransactionReceipt(arbitratorReceipt);
140139

141140
/**
142141
* In principle, a single L1 txn can trigger any number of L1-to-L2 messages (each with its own sequencer number).
143142
* In this case, we know our txn triggered only one
144143
* Here, We check if our L1 to L2 message is redeemed on L2
145144
*/
146-
const messages = await l1TxReceipt.getL1ToL2Messages(l2Wallet);
145+
const messages = await l1TxReceipt.getParentToChildMessages(l2Wallet);
147146
const message = messages[0];
148147
console.log('Waiting for the L2 execution of the transaction. This may take up to 10-15 minutes ⏰');
149148
const messageResult = await message.waitForStatus();
150149
const status = messageResult.status;
151-
if (status === L1ToL2MessageStatus.REDEEMED) {
152-
console.log(`L2 retryable ticket is executed 🥳 ${messageResult.l2TxReceipt.transactionHash}`);
150+
if (status === ParentToChildMessageStatus.REDEEMED) {
151+
console.log(`L2 retryable ticket is executed 🥳 ${messageResult.childTxReceipt.transactionHash}`);
153152
} else {
154-
console.log(`L2 retryable ticket is failed with status ${L1ToL2MessageStatus[status]}`);
153+
console.log(`L2 retryable ticket is failed with status ${ParentToChildMessageStatus[status]}`);
155154
}
156155
});

examples/arbitrum/scripts/setValidator.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const { providers, Wallet, utils } = require('ethers');
22
const { readDeployContract, getLogName } = require('../../../script/utils');
33
const logName = require('../../../script/deploy_log_name');
4-
const { L1TransactionReceipt, L1ToL2MessageStatus } = require('@arbitrum/sdk');
5-
const { L1ToL2MessageGasEstimator } = require('@arbitrum/sdk/dist/lib/message/L1ToL2MessageGasEstimator');
4+
const { ParentTransactionReceipt, ParentToChildMessageStatus, ParentToChildMessageGasEstimator } = require('@arbitrum/sdk');
65
const { getBaseFee } = require('@arbitrum/sdk/dist/lib/utils/lib');
76
const { task, types } = require('hardhat/config');
87

@@ -26,7 +25,7 @@ task('setValidator', 'Set validator for zkLink')
2625
/**
2726
* Now we can query the required gas params using the estimateAll method in Arbitrum SDK
2827
*/
29-
const l1ToL2MessageGasEstimate = new L1ToL2MessageGasEstimator(l2Provider);
28+
const l1ToL2MessageGasEstimate = new ParentToChildMessageGasEstimator(l2Provider);
3029

3130
const l1WalletAddress = await l1Wallet.getAddress();
3231
const l1WalletBalance = utils.formatEther(await l1Wallet.getBalance());
@@ -120,21 +119,21 @@ task('setValidator', 'Set validator for zkLink')
120119
console.log(`The l1 tx hash: ${l1TxHash}`);
121120
const forwardMessageReceipt = await l1Tx.wait();
122121

123-
const l1TxReceipt = new L1TransactionReceipt(forwardMessageReceipt);
122+
const l1TxReceipt = new ParentTransactionReceipt(forwardMessageReceipt);
124123

125124
/**
126125
* In principle, a single L1 txn can trigger any number of L1-to-L2 messages (each with its own sequencer number).
127126
* In this case, we know our txn triggered only one
128127
* Here, We check if our L1 to L2 message is redeemed on L2
129128
*/
130-
const messages = await l1TxReceipt.getL1ToL2Messages(l2Wallet);
129+
const messages = await l1TxReceipt.getParentToChildMessages(l2Wallet);
131130
const message = messages[0];
132131
console.log('Waiting for the L2 execution of the transaction. This may take up to 10-15 minutes ⏰');
133132
const messageResult = await message.waitForStatus();
134133
const status = messageResult.status;
135-
if (status === L1ToL2MessageStatus.REDEEMED) {
136-
console.log(`L2 retryable ticket is executed 🥳 ${messageResult.l2TxReceipt.transactionHash}`);
134+
if (status === ParentToChildMessageStatus.REDEEMED) {
135+
console.log(`L2 retryable ticket is executed 🥳 ${messageResult.childTxReceipt.transactionHash}`);
137136
} else {
138-
console.log(`L2 retryable ticket is failed with status ${L1ToL2MessageStatus[status]}`);
137+
console.log(`L2 retryable ticket is failed with status ${ParentToChildMessageStatus[status]}`);
139138
}
140139
});

examples/arbitrum/scripts/syncBatchRoot.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const { providers, Wallet, utils } = require('ethers');
22
const { readDeployContract, getLogName } = require('../../../script/utils');
33
const logName = require('../../../script/deploy_log_name');
4-
const { L1TransactionReceipt, L1ToL2MessageStatus } = require('@arbitrum/sdk');
5-
const { L1ToL2MessageGasEstimator } = require('@arbitrum/sdk/dist/lib/message/L1ToL2MessageGasEstimator');
4+
const { ParentTransactionReceipt, ParentToChildMessageStatus, ParentToChildMessageGasEstimator } = require('@arbitrum/sdk');
65
const { getBaseFee } = require('@arbitrum/sdk/dist/lib/utils/lib');
76
const { task, types } = require('hardhat/config');
87

@@ -32,7 +31,7 @@ task('syncBatchRoot', 'Send batch root from arbitrator to zkLink')
3231
/**
3332
* Now we can query the required gas params using the estimateAll method in Arbitrum SDK
3433
*/
35-
const l1ToL2MessageGasEstimate = new L1ToL2MessageGasEstimator(l2Provider);
34+
const l1ToL2MessageGasEstimate = new ParentToChildMessageGasEstimator(l2Provider);
3635

3736
const l1WalletAddress = await l1Wallet.getAddress();
3837
const l1WalletBalance = utils.formatEther(await l1Wallet.getBalance());
@@ -126,21 +125,21 @@ task('syncBatchRoot', 'Send batch root from arbitrator to zkLink')
126125
console.log(`The l1 tx hash: ${l1TxHash}`);
127126
const forwardMessageReceipt = await l1Tx.wait();
128127

129-
const l1TxReceipt = new L1TransactionReceipt(forwardMessageReceipt);
128+
const l1TxReceipt = new ParentTransactionReceipt(forwardMessageReceipt);
130129

131130
/**
132131
* In principle, a single L1 txn can trigger any number of L1-to-L2 messages (each with its own sequencer number).
133132
* In this case, we know our txn triggered only one
134133
* Here, We check if our L1 to L2 message is redeemed on L2
135134
*/
136-
const messages = await l1TxReceipt.getL1ToL2Messages(l2Wallet);
135+
const messages = await l1TxReceipt.getParentToChildMessages(l2Wallet);
137136
const message = messages[0];
138137
console.log('Waiting for the L2 execution of the transaction. This may take up to 10-15 minutes ⏰');
139138
const messageResult = await message.waitForStatus();
140139
const status = messageResult.status;
141-
if (status === L1ToL2MessageStatus.REDEEMED) {
142-
console.log(`L2 retryable ticket is executed 🥳 ${messageResult.l2TxReceipt.transactionHash}`);
140+
if (status === ParentToChildMessageStatus.REDEEMED) {
141+
console.log(`L2 retryable ticket is executed 🥳 ${messageResult.childTxReceipt.transactionHash}`);
143142
} else {
144-
console.log(`L2 retryable ticket is failed with status ${L1ToL2MessageStatus[status]}`);
143+
console.log(`L2 retryable ticket is failed with status ${ParentToChildMessageStatus[status]}`);
145144
}
146145
});

examples/arbitrum/scripts/syncL2Requests.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { providers, Wallet, utils } = require('ethers');
22
const { readDeployContract } = require('../../../script/utils');
33
const logName = require('../../../script/deploy_log_name');
4-
const { L2TransactionReceipt, L2ToL1MessageStatus } = require('@arbitrum/sdk');
4+
const { ChildTransactionReceipt, ChildToParentMessageStatus } = require('@arbitrum/sdk');
55
const { task, types } = require('hardhat/config');
66

77
require('dotenv').config();
@@ -44,21 +44,21 @@ task('syncL2Requests', 'Send sync point from zkLink to arbitrator')
4444
/**
4545
* First, let's find the Arbitrum txn from the txn hash provided
4646
*/
47-
const l2Receipt = new L2TransactionReceipt(syncL2RequestsReceipt);
47+
const l2Receipt = new ChildTransactionReceipt(syncL2RequestsReceipt);
4848

4949
/**
5050
* Note that in principle, a single transaction could trigger any number of outgoing messages; the common case will be there's only one.
5151
* For the sake of this script, we assume there's only one / just grad the first one.
5252
*/
53-
const messages = await l2Receipt.getL2ToL1Messages(l1Wallet);
53+
const messages = await l2Receipt.getChildToParentMessages(l1Wallet);
5454
const l2ToL1Msg = messages[0];
5555

5656
/**
5757
* Check if already executed
5858
*/
5959
const msgStatus = await l2ToL1Msg.status(l2Provider);
6060
console.log(`Message status: ${msgStatus}`);
61-
if ((await l2ToL1Msg.status(l2Provider)) === L2ToL1MessageStatus.EXECUTED) {
61+
if ((await l2ToL1Msg.status(l2Provider)) === ChildToParentMessageStatus.EXECUTED) {
6262
console.log(`Message already executed! Nothing else to do here`);
6363
return;
6464
}

0 commit comments

Comments
 (0)