From f8c1a7f0a821d666b754975f58e22444ebb68831 Mon Sep 17 00:00:00 2001 From: jangko Date: Sun, 25 Jun 2023 08:40:15 +0700 Subject: [PATCH] fix rpc_sim receipt unmarshalling --- hive_integration/nodocker/rpc/client.nim | 16 +++++++++++++++- tests/test_tools_build.nim | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/hive_integration/nodocker/rpc/client.nim b/hive_integration/nodocker/rpc/client.nim index 81acdf2f7..1b6c9471a 100644 --- a/hive_integration/nodocker/rpc/client.nim +++ b/hive_integration/nodocker/rpc/client.nim @@ -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) diff --git a/tests/test_tools_build.nim b/tests/test_tools_build.nim index 512591b8b..0de3eeee1 100644 --- a/tests/test_tools_build.nim +++ b/tests/test_tools_build.nim @@ -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,