fix rpc_sim receipt unmarshalling

This commit is contained in:
jangko 2023-06-25 08:40:15 +07:00
parent 39402ea8d3
commit f8c1a7f0a8
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 16 additions and 2 deletions

View File

@ -46,6 +46,20 @@ proc nonceAt*(client: RpcClient, address: EthAddress): Future[AccountNonce] {.as
let hex = await client.eth_getTransactionCount(ethAddressStr(address), "latest")
result = parseHexInt(hex.string).AccountNonce
func toTopics(list: openArray[Hash256]): seq[Topic] =
result = newSeqOfCap[Topic](list.len)
for x in list:
result.add x.data
func toLogs(list: openArray[FilterLog]): seq[Log] =
result = newSeqOfCap[Log](list.len)
for x in list:
result.add Log(
address: x.address,
data: x.data,
topics: toTopics(x.topics)
)
proc txReceipt*(client: RpcClient, txHash: Hash256): Future[Option[Receipt]] {.async.} =
let rr = await client.eth_getTransactionReceipt(txHash)
if rr.isNone:
@ -59,7 +73,7 @@ proc txReceipt*(client: RpcClient, txHash: Hash256): Future[Option[Receipt]] {.a
hash : rc.root.get(Hash256()),
cumulativeGasUsed: parseHexInt(rc.cumulativeGasUsed.string).GasInt,
bloom : BloomFilter(rc.logsBloom),
logs : rc.logs
logs : toLogs(rc.logs)
)
result = some(rec)

View File

@ -20,7 +20,7 @@ import
../premix/regress,
./tracerTestGen,
./persistBlockTestGen,
../hive_integration/nodocker/consensus/extract_consensus_data,
../hive_integration/nodocker/rpc/rpc_sim,
../hive_integration/nodocker/consensus/consensus_sim,
../hive_integration/nodocker/graphql/graphql_sim,
../hive_integration/nodocker/engine/engine_sim,