mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
premix: fixes premix parser dan graphql_downloader
premix parser: - fix incorrect tx type comparison - fix chainId parser to support both graphql and json returned data graphql_downloadse: - allow downloader to skip parsing transactions
This commit is contained in:
parent
8e26acc4eb
commit
8552dda7bb
@ -53,6 +53,7 @@ query getBlock($blockNumber: Long!) {
|
|||||||
address
|
address
|
||||||
storageKeys
|
storageKeys
|
||||||
}
|
}
|
||||||
|
index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +69,7 @@ proc fromJson(_: type ChainId, n: JsonNode, name: string): ChainId =
|
|||||||
fromJson(n, name, chainId)
|
fromJson(n, name, chainId)
|
||||||
ChainId(chainId)
|
ChainId(chainId)
|
||||||
|
|
||||||
proc requestBlock*(blockNumber: BlockNumber): Block =
|
proc requestBlock*(blockNumber: BlockNumber, parseTx = true): Block =
|
||||||
let address = initTAddress("127.0.0.1:8545")
|
let address = initTAddress("127.0.0.1:8545")
|
||||||
let clientRes = GraphqlHttpClientRef.new(address)
|
let clientRes = GraphqlHttpClientRef.new(address)
|
||||||
if clientRes.isErr:
|
if clientRes.isErr:
|
||||||
@ -92,6 +93,7 @@ proc requestBlock*(blockNumber: BlockNumber): Block =
|
|||||||
let chainId = ChainId.fromJson(n["data"], "chainID")
|
let chainId = ChainId.fromJson(n["data"], "chainID")
|
||||||
result.header = parseBlockHeader(nh)
|
result.header = parseBlockHeader(nh)
|
||||||
|
|
||||||
|
if parseTx:
|
||||||
let txs = nh["transactions"]
|
let txs = nh["transactions"]
|
||||||
for txn in txs:
|
for txn in txs:
|
||||||
var tx = parseTransaction(txn)
|
var tx = parseTransaction(txn)
|
||||||
|
@ -84,6 +84,13 @@ proc fromJson*[T](n: JsonNode, name: string, x: var Option[T]) =
|
|||||||
n.fromJson(name, val)
|
n.fromJson(name, val)
|
||||||
x = some(val)
|
x = some(val)
|
||||||
|
|
||||||
|
proc fromJson*(n: JsonNode, name: string, x: var TxType) =
|
||||||
|
let node = n[name]
|
||||||
|
if node.kind == JInt:
|
||||||
|
x = TxType(node.getInt)
|
||||||
|
else:
|
||||||
|
x = hexToInt(node.getStr(), int).TxType
|
||||||
|
|
||||||
proc parseBlockHeader*(n: JsonNode): BlockHeader =
|
proc parseBlockHeader*(n: JsonNode): BlockHeader =
|
||||||
n.fromJson "parentHash", result.parentHash
|
n.fromJson "parentHash", result.parentHash
|
||||||
n.fromJson "sha3Uncles", result.ommersHash
|
n.fromJson "sha3Uncles", result.ommersHash
|
||||||
@ -130,14 +137,17 @@ proc parseTransaction*(n: JsonNode): Transaction =
|
|||||||
n.fromJson "s", tx.S
|
n.fromJson "s", tx.S
|
||||||
|
|
||||||
if n["type"].kind != JNull:
|
if n["type"].kind != JNull:
|
||||||
tx.txType = TxType(n["type"].getInt)
|
n.fromJson "type", tx.txType
|
||||||
|
|
||||||
if tx.txType == TxEip1559:
|
if tx.txType >= TxEip1559:
|
||||||
n.fromJson "maxPriorityFeePerGas", tx.maxPriorityFee
|
n.fromJson "maxPriorityFeePerGas", tx.maxPriorityFee
|
||||||
n.fromJson "maxFeePerGas", tx.maxFee
|
n.fromJson "maxFeePerGas", tx.maxFee
|
||||||
|
|
||||||
if tx.txType == TxEip2930:
|
if tx.txType >= TxEip2930:
|
||||||
# chainId is set from top level query
|
if n.hasKey("chainId"):
|
||||||
|
let id = hexToInt(n["chainId"].getStr(), int)
|
||||||
|
tx.chainId = ChainId(id)
|
||||||
|
|
||||||
let accessList = n["accessList"]
|
let accessList = n["accessList"]
|
||||||
if accessList.len > 0:
|
if accessList.len > 0:
|
||||||
for acn in accessList:
|
for acn in accessList:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user