Skip to content

Commit f1fe93c

Browse files
committed
Use Long for block number
1 parent cd7e560 commit f1fe93c

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
@@ -60,7 +60,7 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Successful(t *testing.T) {
6060
if err != nil {
6161
t.Fatalf("could not read from response body: %v", err)
6262
}
63-
expected := "{\"data\":{\"block\":{\"number\":\"0x0\"}}}"
63+
expected := "{\"data\":{\"block\":{\"number\":0}}}"
6464
assert.Equal(t, expected, string(bodyBytes))
6565
}
6666

@@ -85,7 +85,7 @@ func TestGraphQLBlockSerialization(t *testing.T) {
8585
if err != nil {
8686
t.Fatalf("could not read from response body: %v", err)
8787
}
88-
expected := "{\"data\":{\"block\":{\"number\":\"0x0\",\"gasUsed\":0,\"gasLimit\":5000}}}"
88+
expected := "{\"data\":{\"block\":{\"number\":0,\"gasUsed\":0,\"gasLimit\":5000}}}"
8989
assert.Equal(t, expected, string(bodyBytes))
9090
}
9191

0 commit comments

Comments
 (0)