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") let hex = await client.eth_getTransactionCount(ethAddressStr(address), "latest")
result = parseHexInt(hex.string).AccountNonce 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.} = proc txReceipt*(client: RpcClient, txHash: Hash256): Future[Option[Receipt]] {.async.} =
let rr = await client.eth_getTransactionReceipt(txHash) let rr = await client.eth_getTransactionReceipt(txHash)
if rr.isNone: if rr.isNone:
@ -59,7 +73,7 @@ proc txReceipt*(client: RpcClient, txHash: Hash256): Future[Option[Receipt]] {.a
hash : rc.root.get(Hash256()), hash : rc.root.get(Hash256()),
cumulativeGasUsed: parseHexInt(rc.cumulativeGasUsed.string).GasInt, cumulativeGasUsed: parseHexInt(rc.cumulativeGasUsed.string).GasInt,
bloom : BloomFilter(rc.logsBloom), bloom : BloomFilter(rc.logsBloom),
logs : rc.logs logs : toLogs(rc.logs)
) )
result = some(rec) result = some(rec)

View File

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