mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-23 16:29:26 +00:00
graphql: add nil check in Transaction.Type() method (#33184)
Add nil check before calling tx.Type() to prevent panic when transaction is not found.
This commit is contained in:
parent
488d987fc4
commit
aa36bcd0aa
1 changed files with 3 additions and 0 deletions
|
|
@ -575,6 +575,9 @@ func (t *Transaction) getLogs(ctx context.Context, hash common.Hash) (*[]*Log, e
|
||||||
|
|
||||||
func (t *Transaction) Type(ctx context.Context) *hexutil.Uint64 {
|
func (t *Transaction) Type(ctx context.Context) *hexutil.Uint64 {
|
||||||
tx, _ := t.resolve(ctx)
|
tx, _ := t.resolve(ctx)
|
||||||
|
if tx == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
txType := hexutil.Uint64(tx.Type())
|
txType := hexutil.Uint64(tx.Type())
|
||||||
return &txType
|
return &txType
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue