Skip to content

Commit e6799a3

Browse files
pcarranzavtmigone
authored andcommitted
fix: some more details with the Nitro changes in the CLI
1 parent 022154a commit e6799a3

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

cli/commands/bridge/to-l1.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import { getAddressBook } from '../../address-book'
44
import { getProvider, sendTransaction, toGRT } from '../../network'
55
import { chainIdIsL2 } from '../../utils'
66
import { loadAddressBookContract } from '../../contracts'
7-
import {
8-
L2TransactionReceipt,
9-
getL2Network,
10-
L2ToL1MessageStatus,
11-
L2ToL1MessageWriter,
12-
} from '@arbitrum/sdk'
7+
import { L2TransactionReceipt, L2ToL1MessageStatus, L2ToL1MessageWriter } from '@arbitrum/sdk'
138
import { L2GraphTokenGateway } from '../../../build/types/L2GraphTokenGateway'
149
import { BigNumber } from 'ethers'
1510
import { JsonRpcProvider } from '@ethersproject/providers'
@@ -99,9 +94,7 @@ export const startSendToL1 = async (cli: CLIEnvironment, cliArgs: CLIArgs): Prom
9994
params,
10095
)
10196
const l2Receipt = new L2TransactionReceipt(receipt)
102-
const l2ToL1Message = (
103-
await l2Receipt.getL2ToL1Messages(cli.wallet, await getL2Network(l2Provider))
104-
)[0]
97+
const l2ToL1Message = (await l2Receipt.getL2ToL1Messages(cli.wallet))[0]
10598

10699
logger.info(`The transaction generated an L2 to L1 message in outbox with eth block number:`)
107100
logger.info(l2ToL1Message.event.ethBlockNum.toString())
@@ -157,9 +150,7 @@ export const finishSendToL1 = async (
157150

158151
const l2Receipt = new L2TransactionReceipt(receipt)
159152
logger.info(`Getting L2 to L1 message...`)
160-
const l2ToL1Message = (
161-
await l2Receipt.getL2ToL1Messages(cli.wallet, await getL2Network(l2Provider))
162-
)[0]
153+
const l2ToL1Message = (await l2Receipt.getL2ToL1Messages(cli.wallet))[0]
163154

164155
if (wait) {
165156
const retryDelayMs = cliArgs.retryDelaySeconds ? cliArgs.retryDelaySeconds * 1000 : 60000

cli/commands/bridge/to-l2.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { loadEnv, CLIArgs, CLIEnvironment } from '../../env'
22
import { logger } from '../../logging'
33
import { getProvider, sendTransaction, toGRT } from '../../network'
4-
import { utils } from 'ethers'
4+
import { BigNumber, utils } from 'ethers'
55
import { parseEther } from '@ethersproject/units'
66
import {
77
L1TransactionReceipt,
@@ -32,7 +32,12 @@ const checkAndRedeemMessage = async (l1ToL2Message: L1ToL2MessageWriter) => {
3232
logAutoRedeemReason(autoRedeemRec)
3333
logger.info('Attempting to redeem...')
3434
await l1ToL2Message.redeem()
35-
l2TxHash = (await l1ToL2Message.getSuccessfulRedeem()).transactionHash
35+
const redeemAttempt = await l1ToL2Message.getSuccessfulRedeem()
36+
if (redeemAttempt.status == L1ToL2MessageStatus.REDEEMED) {
37+
l2TxHash = redeemAttempt.l2TxReceipt ? redeemAttempt.l2TxReceipt.transactionHash : 'null'
38+
} else {
39+
throw new Error(`Unexpected L1ToL2MessageStatus after redeem attempt: ${res.status}`)
40+
}
3641
} else if (res.status != L1ToL2MessageStatus.REDEEMED) {
3742
throw new Error(`Unexpected L1ToL2MessageStatus ${res.status}`)
3843
}
@@ -72,18 +77,19 @@ export const sendToL2 = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<v
7277
logger.info('Estimating retryable ticket gas:')
7378
const baseFee = (await cli.wallet.provider.getBlock('latest')).baseFeePerGas
7479
const gasEstimator = new L1ToL2MessageGasEstimator(l2Provider)
75-
const gasParams = await gasEstimator.estimateMessage(
80+
const gasParams = await gasEstimator.estimateAll(
7681
gateway.address,
7782
l2Dest,
7883
depositCalldata,
7984
parseEther('0'),
80-
baseFee,
85+
baseFee as BigNumber,
8186
gateway.address,
8287
gateway.address,
88+
cli.wallet.provider,
8389
)
84-
const maxGas = gasParams.maxGasBid
85-
const gasPriceBid = gasParams.maxGasPriceBid
86-
const maxSubmissionPrice = gasParams.maxSubmissionPriceBid
90+
const maxGas = gasParams.gasLimit
91+
const gasPriceBid = gasParams.maxFeePerGas
92+
const maxSubmissionPrice = gasParams.maxSubmissionFee
8793
logger.info(
8894
`Using max gas: ${maxGas}, gas price bid: ${gasPriceBid}, max submission price: ${maxSubmissionPrice}`,
8995
)
@@ -100,7 +106,7 @@ export const sendToL2 = async (cli: CLIEnvironment, cliArgs: CLIArgs): Promise<v
100106
value: ethValue,
101107
})
102108
const l1Receipt = new L1TransactionReceipt(receipt)
103-
const l1ToL2Message = await l1Receipt.getL1ToL2Message(cli.wallet.connect(l2Provider))
109+
const l1ToL2Message = await l1Receipt.getL1ToL2Messages(cli.wallet.connect(l2Provider))[0]
104110

105111
logger.info('Waiting for message to propagate to L2...')
106112
try {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"ethers": "^5.6.0"
1616
},
1717
"devDependencies": {
18-
"@arbitrum/sdk": "^3.0.0-beta.5",
18+
"@arbitrum/sdk": "^3.0.0-beta.6",
1919
"@commitlint/cli": "^13.2.1",
2020
"@commitlint/config-conventional": "^13.2.0",
2121
"@defi-wonderland/smock": "^2.0.7",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# yarn lockfile v1
33

44

5-
"@arbitrum/sdk@^3.0.0-beta.5":
6-
version "3.0.0-beta.5"
7-
resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-3.0.0-beta.5.tgz#ef1c81de58db9e76defb4a1971274316a375133b"
8-
integrity sha512-qeNdK7es4uKRFciz4zznPEnGRZaAHkrwNqUN1F4U6d4i8olhK0KMdSodx2ZjajBvVVwOo5kFsw5ocAaTvkf28g==
5+
"@arbitrum/sdk@^3.0.0-beta.6":
6+
version "3.0.0-beta.6"
7+
resolved "https://registry.yarnpkg.com/@arbitrum/sdk/-/sdk-3.0.0-beta.6.tgz#a36c3e39a7358396b5533f3288125107da6ae59e"
8+
integrity sha512-kPCfgj72MeyVcIXQKoztLO29UTcpSbXFzc/S0oDgVNNcHcXp1hWUJqqkVRg0O43P2yKjZRT/I94K0Nj2nZNiiQ==
99
dependencies:
1010
"@ethersproject/address" "^5.0.8"
1111
"@ethersproject/bignumber" "^5.1.1"

0 commit comments

Comments
 (0)