Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update messageDataParser.ts #519

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions src/lib/message/messageDataParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,31 @@ export class SubmitRetryableMessageDataParser {
*/
public parse(eventData: string) {
// decode the data field - is been packed so we cant decode the bytes field this way
// refer to ArbitrumSubmitRetryableTx here: https://github.com/OffchainLabs/go-ethereum/blob/18256c2dfcce8fd567aa05e03fbc11a4c17aa550/core/types/arb_types.go#L283
const parsed = defaultAbiCoder.decode(
[
'uint256', // dest
'uint256', // l2 call balue
'uint256', // msg val
'uint256', // max submission
'uint256', // excess fee refund addr
'uint256', // call value refund addr
'uint256', // max gas
'uint256', // gas price bid
'uint256', // data length
'uint256', // RetryTo
'uint256', // RetryValue
'uint256', // DepositValue
'uint256', // MaxSubmissionFee
'uint256', // FeeRefundAddr
'uint256', // Beneficiary
'uint256', // Gas
'uint256', // GasFeeCap
'uint256', // DataLength
],
eventData
) as BigNumber[]

const addressFromBigNumber = (bn: BigNumber) =>
getAddress(hexZeroPad(bn.toHexString(), 20))

const destAddress = addressFromBigNumber(parsed[0])
const l2CallValue = parsed[1]
const l1Value = parsed[2]
const retryTo = addressFromBigNumber(parsed[0])
const retryValue = parsed[1]
const depositValue = parsed[2]
const maxSubmissionFee = parsed[3]
const excessFeeRefundAddress = addressFromBigNumber(parsed[4])
const callValueRefundAddress = addressFromBigNumber(parsed[5])
const feeRefundAddr = addressFromBigNumber(parsed[4])
const beneficiary = addressFromBigNumber(parsed[5])
const gasLimit = parsed[6]
const maxFeePerGas = parsed[7]
const callDataLength = parsed[8]
Expand All @@ -44,12 +45,12 @@ export class SubmitRetryableMessageDataParser {
eventData.substring(eventData.length - callDataLength.mul(2).toNumber())

return {
destAddress,
l2CallValue,
l1Value,
retryTo,
retryValue,
depositValue,
maxSubmissionFee: maxSubmissionFee,
excessFeeRefundAddress,
callValueRefundAddress,
feeRefundAddr,
beneficiary,
gasLimit,
maxFeePerGas,
data,
Expand Down