107 lines
2.5 KiB
Go
107 lines
2.5 KiB
Go
package arbitrum
|
|
|
|
import (
|
|
"math/big"
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
)
|
|
|
|
// L2MessageType represents different types of L2 messages
|
|
type L2MessageType int
|
|
|
|
const (
|
|
L2Unknown L2MessageType = iota
|
|
L2Transaction
|
|
L2BatchSubmission
|
|
L2StateUpdate
|
|
L2Withdrawal
|
|
L2Deposit
|
|
)
|
|
|
|
// L2Message represents an Arbitrum L2 message
|
|
type L2Message struct {
|
|
Type L2MessageType
|
|
MessageNumber *big.Int
|
|
Sender common.Address
|
|
Data []byte
|
|
Timestamp uint64
|
|
BlockNumber uint64
|
|
BlockHash common.Hash
|
|
TxHash common.Hash
|
|
TxCount int
|
|
BatchIndex *big.Int
|
|
L1BlockNumber uint64
|
|
GasUsed uint64
|
|
GasPrice *big.Int
|
|
|
|
// Parsed transaction data (if applicable)
|
|
ParsedTx *types.Transaction
|
|
InnerTxs []*types.Transaction // For batch transactions
|
|
}
|
|
|
|
// ArbitrumBlock represents an enhanced block with L2 specifics
|
|
type ArbitrumBlock struct {
|
|
*types.Block
|
|
L2Messages []*L2Message
|
|
SequencerInfo *SequencerInfo
|
|
BatchInfo *BatchInfo
|
|
}
|
|
|
|
// SequencerInfo contains sequencer-specific information
|
|
type SequencerInfo struct {
|
|
SequencerAddress common.Address
|
|
Timestamp uint64
|
|
BlockHash common.Hash
|
|
PrevBlockHash common.Hash
|
|
}
|
|
|
|
// BatchInfo contains batch transaction information
|
|
type BatchInfo struct {
|
|
BatchNumber *big.Int
|
|
BatchRoot common.Hash
|
|
TxCount uint64
|
|
L1SubmissionTx common.Hash
|
|
}
|
|
|
|
// L2TransactionReceipt extends the standard receipt with L2 data
|
|
type L2TransactionReceipt struct {
|
|
*types.Receipt
|
|
L2BlockNumber uint64
|
|
L2TxIndex uint64
|
|
RetryableTicket *RetryableTicket
|
|
GasUsedForL1 uint64
|
|
L1BatchNumber uint64
|
|
L1BlockNumber uint64
|
|
L1GasUsed uint64
|
|
L2GasUsed uint64
|
|
}
|
|
|
|
// RetryableTicket represents Arbitrum retryable tickets
|
|
type RetryableTicket struct {
|
|
TicketID common.Hash
|
|
From common.Address
|
|
To common.Address
|
|
Value *big.Int
|
|
MaxGas uint64
|
|
GasPriceBid *big.Int
|
|
Data []byte
|
|
ExpirationTime uint64
|
|
}
|
|
|
|
// DEXInteraction represents a parsed DEX interaction from L2 message
|
|
type DEXInteraction struct {
|
|
Protocol string
|
|
Router common.Address
|
|
Pool common.Address
|
|
TokenIn common.Address
|
|
TokenOut common.Address
|
|
AmountIn *big.Int
|
|
AmountOut *big.Int
|
|
Recipient common.Address
|
|
Deadline uint64
|
|
SlippageTolerance *big.Int
|
|
MessageNumber *big.Int
|
|
Timestamp uint64
|
|
}
|