diff --git a/core/types/transaction.go b/core/types/transaction.go index ee90dded73..63d6f939e0 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -31,15 +31,16 @@ import ( ) var ( - ErrInvalidSig = errors.New("invalid transaction v, r, s values") - ErrUnexpectedProtection = errors.New("transaction type does not supported EIP-155 protected signatures") - ErrInvalidTxType = errors.New("transaction type not valid in this context") - ErrTxTypeNotSupported = errors.New("transaction type not supported") - ErrGasFeeCapTooLow = errors.New("fee cap less than base fee") - errShortTypedTx = errors.New("typed transaction too short") - errInvalidYParity = errors.New("'yParity' field must be 0 or 1") - errVYParityMismatch = errors.New("'v' and 'yParity' fields do not match") - errVYParityMissing = errors.New("missing 'yParity' or 'v' field in transaction") + ErrInvalidSig = errors.New("invalid transaction v, r, s values") + ErrUnexpectedProtection = errors.New("transaction type does not supported EIP-155 protected signatures") + ErrInvalidTxType = errors.New("transaction type not valid in this context") + ErrTxTypeNotSupported = errors.New("transaction type not supported") + ErrL1MessageTxTypeNotSupported = errors.New("l1 message transaction type not supported") + ErrGasFeeCapTooLow = errors.New("fee cap less than base fee") + errShortTypedTx = errors.New("typed transaction too short") + errInvalidYParity = errors.New("'yParity' field must be 0 or 1") + errVYParityMismatch = errors.New("'v' and 'yParity' fields do not match") + errVYParityMissing = errors.New("missing 'yParity' or 'v' field in transaction") ) // Transaction types. diff --git a/core/types/transaction_marshalling.go b/core/types/transaction_marshalling.go index 42f11a8766..76515b7574 100644 --- a/core/types/transaction_marshalling.go +++ b/core/types/transaction_marshalling.go @@ -508,7 +508,7 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error { } case L1MessageTxType: - return nil + return ErrL1MessageTxTypeNotSupported default: return ErrTxTypeNotSupported diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go index 1195929f7d..fd18f20419 100644 --- a/ethclient/ethclient.go +++ b/ethclient/ethclient.go @@ -132,7 +132,7 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb type rpcBlock struct { Hash *common.Hash `json:"hash"` - Transactions []rpcTransaction `json:"transactions"` + Transactions rpcTransactions `json:"transactions"` UncleHashes []common.Hash `json:"uncles"` Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` } @@ -270,6 +270,29 @@ func (tx *rpcTransaction) UnmarshalJSON(msg []byte) error { return json.Unmarshal(msg, &tx.txExtraInfo) } +type rpcTransactions []rpcTransaction + +func (txs *rpcTransactions) UnmarshalJSON(msg []byte) error { + var rawTxs []json.RawMessage + if err := json.Unmarshal(msg, &rawTxs); err != nil { + return err + } + + var parsedTxs []rpcTransaction + for _, tx := range rawTxs { + var parsedTx rpcTransaction + if err := json.Unmarshal(tx, &parsedTx); err != nil { + if err == types.ErrL1MessageTxTypeNotSupported { + continue + } + return err + } + parsedTxs = append(parsedTxs, parsedTx) + } + *txs = parsedTxs + return nil +} + // TransactionByHash returns the transaction with the given hash. func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error) { var json *rpcTransaction