graphql: validate block params (#27876)

Block takes a number and a hash. The spec is unclear on what should happen in this case, leaving it an implemenation detail. With this change, we return an error in case both number and hash are passed in.
pull/27680/merge
Sina Mahmoodi 1 year ago committed by GitHub
parent 86d7f5aeee
commit 5e89ff4d6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      graphql/graphql.go

@ -1217,6 +1217,9 @@ func (r *Resolver) Block(ctx context.Context, args struct {
Number *Long
Hash *common.Hash
}) (*Block, error) {
if args.Number != nil && args.Hash != nil {
return nil, errors.New("only one of number or hash must be specified")
}
var numberOrHash rpc.BlockNumberOrHash
if args.Number != nil {
if *args.Number < 0 {

Loading…
Cancel
Save