graphql: add support for retrieving the chain id (#21451)

This commit is contained in:
Shude Li 2020-08-25 16:38:56 +08:00 committed by GitHub
parent d13b8e5570
commit 341f451083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -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

View File

@ -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 {