graphql: encode Long values as hex (#26894)

This is a breaking GraphQL API change. All numeric values are now encoded as
hex strings. The motivation for this change is matching JSON-RPC outputs more
closely.

Numbers in query parameters are accepted as both decimal integers and hex strings.
This commit is contained in:
Sina Mahmoodi
2023-04-25 14:02:54 +02:00
committed by GitHub
parent 9a12cc99de
commit 2f98dd3838
3 changed files with 78 additions and 81 deletions
+11 -9
View File
@@ -28,7 +28,9 @@ const schema string = `
# Strings may be either decimal or 0x-prefixed hexadecimal. Output values are all
# 0x-prefixed hexadecimal.
scalar BigInt
# Long is a 64 bit unsigned integer.
# Long is a 64 bit unsigned integer. Input is accepted as either a JSON number or as a string.
# Strings may be either decimal or 0x-prefixed hexadecimal. Output values are all
# 0x-prefixed hexadecimal.
scalar Long
schema {
@@ -57,7 +59,7 @@ const schema string = `
# Log is an Ethereum event log.
type Log {
# Index is the index of this log in the block.
index: Int!
index: Long!
# Account is the account which generated this log - this will always
# be a contract account.
account(block: Long): Account!
@@ -83,7 +85,7 @@ const schema string = `
nonce: Long!
# Index is the index of this transaction in the parent block. This will
# be null if the transaction has not yet been mined.
index: Int
index: Long
# From is the account that sent this transaction - this will always be
# an externally owned account.
from(block: Long): Account!
@@ -138,7 +140,7 @@ const schema string = `
s: BigInt!
v: BigInt!
# Envelope transaction support
type: Int
type: Long
accessList: [AccessTuple!]
# Raw is the canonical encoding of the transaction.
# For legacy transactions, it returns the RLP encoding.
@@ -183,7 +185,7 @@ const schema string = `
transactionsRoot: Bytes32!
# TransactionCount is the number of transactions in this block. if
# transactions are not available for this block, this field will be null.
transactionCount: Int
transactionCount: Long
# StateRoot is the keccak256 hash of the state trie after this block was processed.
stateRoot: Bytes32!
# ReceiptsRoot is the keccak256 hash of the trie of transaction receipts in this block.
@@ -214,7 +216,7 @@ const schema string = `
totalDifficulty: BigInt!
# OmmerCount is the number of ommers (AKA uncles) associated with this
# block. If ommers are unavailable, this field will be null.
ommerCount: Int
ommerCount: Long
# Ommers is a list of ommer (AKA uncle) blocks associated with this block.
# If ommers are unavailable, this field will be null. Depending on your
# node, the transactions, transactionAt, transactionCount, ommers,
@@ -222,7 +224,7 @@ const schema string = `
ommers: [Block]
# OmmerAt returns the ommer (AKA uncle) at the specified index. If ommers
# are unavailable, or the index is out of bounds, this field will be null.
ommerAt(index: Int!): Block
ommerAt(index: Long!): Block
# OmmerHash is the keccak256 hash of all the ommers (AKA uncles)
# associated with this block.
ommerHash: Bytes32!
@@ -232,7 +234,7 @@ const schema string = `
# TransactionAt returns the transaction at the specified index. If
# transactions are unavailable for this block, or if the index is out of
# bounds, this field will be null.
transactionAt(index: Int!): Transaction
transactionAt(index: Long!): Transaction
# Logs returns a filtered set of logs from this block.
logs(filter: BlockFilterCriteria!): [Log!]!
# Account fetches an Ethereum account at the current block's state.
@@ -317,7 +319,7 @@ const schema string = `
# Pending represents the current pending state.
type Pending {
# TransactionCount is the number of transactions in the pending state.
transactionCount: Int!
transactionCount: Long!
# Transactions is a list of transactions in the current pending state.
transactions: [Transaction!]
# Account fetches an Ethereum account for the pending state.