Skip to content

Commit 6ebf10d

Browse files
committed
Use Long for block number
1 parent a99b602 commit 6ebf10d

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

graphql/graphql.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ var (
4343

4444
type Long uint64
4545

46-
func (b Long) String() string {
47-
return string(b)
48-
}
49-
5046
// ImplementsGraphQLType returns true if Long implements the provided GraphQL type.
5147
func (b Long) ImplementsGraphQLType(name string) bool { return name == "Long" }
5248

@@ -442,13 +438,13 @@ func (b *Block) resolveReceipts(ctx context.Context) ([]*types.Receipt, error) {
442438
return b.receipts, nil
443439
}
444440

445-
func (b *Block) Number(ctx context.Context) (hexutil.Uint64, error) {
441+
func (b *Block) Number(ctx context.Context) (Long, error) {
446442
header, err := b.resolveHeader(ctx)
447443
if err != nil {
448-
return 0, err
444+
return Long(0), err
449445
}
450446

451-
return hexutil.Uint64(header.Number.Uint64()), nil
447+
return Long(header.Number.Uint64()), nil
452448
}
453449

454450
func (b *Block) Hash(ctx context.Context) (common.Hash, error) {

graphql/graphql_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Successful(t *testing.T) {
6565
if err != nil {
6666
t.Fatalf("could not read from response body: %v", err)
6767
}
68-
expected := "{\"data\":{\"block\":{\"number\":\"0x0\"}}}"
68+
expected := "{\"data\":{\"block\":{\"number\":0}}}"
6969
assert.Equal(t, 200, resp.StatusCode)
7070
assert.Equal(t, expected, string(bodyBytes))
7171
}
@@ -91,7 +91,7 @@ func TestGraphQLBlockSerialization(t *testing.T) {
9191
if err != nil {
9292
t.Fatalf("could not read from response body: %v", err)
9393
}
94-
expected := "{\"data\":{\"block\":{\"number\":\"0x0\",\"gasUsed\":0,\"gasLimit\":5000}}}"
94+
expected := "{\"data\":{\"block\":{\"number\":0,\"gasUsed\":0,\"gasLimit\":11500000}}}"
9595
assert.Equal(t, expected, string(bodyBytes))
9696
}
9797

0 commit comments

Comments
 (0)