fix logic

This commit is contained in:
Pramurta Sinha 2025-06-29 23:02:35 +05:30
parent d5658fdd1e
commit 4a2ddc34de
No known key found for this signature in database
GPG key ID: 5E534A7841E0F2F4
3 changed files with 35 additions and 11 deletions

View file

@ -35,6 +35,7 @@ var (
ErrUnexpectedProtection = errors.New("transaction type does not supported EIP-155 protected signatures") ErrUnexpectedProtection = errors.New("transaction type does not supported EIP-155 protected signatures")
ErrInvalidTxType = errors.New("transaction type not valid in this context") ErrInvalidTxType = errors.New("transaction type not valid in this context")
ErrTxTypeNotSupported = errors.New("transaction type not supported") 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") ErrGasFeeCapTooLow = errors.New("fee cap less than base fee")
errShortTypedTx = errors.New("typed transaction too short") errShortTypedTx = errors.New("typed transaction too short")
errInvalidYParity = errors.New("'yParity' field must be 0 or 1") errInvalidYParity = errors.New("'yParity' field must be 0 or 1")

View file

@ -508,7 +508,7 @@ func (tx *Transaction) UnmarshalJSON(input []byte) error {
} }
case L1MessageTxType: case L1MessageTxType:
return nil return ErrL1MessageTxTypeNotSupported
default: default:
return ErrTxTypeNotSupported return ErrTxTypeNotSupported

View file

@ -132,7 +132,7 @@ func (ec *Client) BlockReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumb
type rpcBlock struct { type rpcBlock struct {
Hash *common.Hash `json:"hash"` Hash *common.Hash `json:"hash"`
Transactions []rpcTransaction `json:"transactions"` Transactions rpcTransactions `json:"transactions"`
UncleHashes []common.Hash `json:"uncles"` UncleHashes []common.Hash `json:"uncles"`
Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"` Withdrawals []*types.Withdrawal `json:"withdrawals,omitempty"`
} }
@ -270,6 +270,29 @@ func (tx *rpcTransaction) UnmarshalJSON(msg []byte) error {
return json.Unmarshal(msg, &tx.txExtraInfo) 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. // 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) { func (ec *Client) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error) {
var json *rpcTransaction var json *rpcTransaction