From 0926b1e6f4aa27d5840a63fc35f051f2489486c9 Mon Sep 17 00:00:00 2001 From: Delweng Date: Wed, 9 Aug 2023 23:57:57 +0800 Subject: [PATCH] graphql: add yParity field for transactions (#27882) Co-authored-by: Felix Lange --- graphql/graphql.go | 10 ++++++++++ graphql/schema.go | 1 + 2 files changed, 11 insertions(+) diff --git a/graphql/graphql.go b/graphql/graphql.go index b407ab425f184..7aa427b458bf7 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -566,6 +566,16 @@ func (t *Transaction) V(ctx context.Context) hexutil.Big { return hexutil.Big(*v) } +func (t *Transaction) YParity(ctx context.Context) (*hexutil.Uint64, error) { + tx, _ := t.resolve(ctx) + if tx == nil || tx.Type() == types.LegacyTxType { + return nil, nil + } + v, _, _ := tx.RawSignatureValues() + ret := hexutil.Uint64(v.Int64()) + return &ret, nil +} + func (t *Transaction) Raw(ctx context.Context) (hexutil.Bytes, error) { tx, _ := t.resolve(ctx) if tx == nil { diff --git a/graphql/schema.go b/graphql/schema.go index a4eeb47daddfc..5de5bad305e85 100644 --- a/graphql/schema.go +++ b/graphql/schema.go @@ -151,6 +151,7 @@ const schema string = ` r: BigInt! s: BigInt! v: BigInt! + yParity: Long # Envelope transaction support type: Long accessList: [AccessTuple!]