From 341f4510830f169653f47a3428037c612fdd0e36 Mon Sep 17 00:00:00 2001 From: Shude Li Date: Tue, 25 Aug 2020 16:38:56 +0800 Subject: [PATCH] graphql: add support for retrieving the chain id (#21451) --- graphql/graphql.go | 4 ++++ graphql/schema.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/graphql/graphql.go b/graphql/graphql.go index 1479ae7fdb..559da8aaaa 100644 --- a/graphql/graphql.go +++ b/graphql/graphql.go @@ -1044,6 +1044,10 @@ func (r *Resolver) ProtocolVersion(ctx context.Context) (int32, error) { return int32(r.backend.ProtocolVersion()), nil } +func (r *Resolver) ChainID(ctx context.Context) (hexutil.Big, error) { + return hexutil.Big(*r.backend.ChainConfig().ChainID), nil +} + // SyncState represents the synchronisation status returned from the `syncing` accessor. type SyncState struct { progress ethereum.SyncProgress diff --git a/graphql/schema.go b/graphql/schema.go index 5dec10db20..d7b253f227 100644 --- a/graphql/schema.go +++ b/graphql/schema.go @@ -314,6 +314,8 @@ const schema string = ` protocolVersion: Int! # Syncing returns information on the current synchronisation state. syncing: SyncState + # ChainID returns the current chain ID for transaction replay protection. + chainID: BigInt! } type Mutation {