diff --git a/ethers/provider.nim b/ethers/provider.nim index 5e447de..9b5a171 100644 --- a/ethers/provider.nim +++ b/ethers/provider.nim @@ -46,7 +46,7 @@ type Block* = object number*: ?UInt256 timestamp*: UInt256 - hash*: array[32, byte] + hash*: ?array[32, byte] const EthersDefaultConfirmations* {.intdefine.} = 12 const EthersReceiptTimeoutBlks* {.intdefine.} = 50 # in blocks diff --git a/testmodule/testJsonRpcProvider.nim b/testmodule/testJsonRpcProvider.nim index 5f1dc25..3674c58 100644 --- a/testmodule/testJsonRpcProvider.nim +++ b/testmodule/testJsonRpcProvider.nim @@ -128,6 +128,20 @@ suite "JsonRpcProvider": check blk.number.isSome check blk.number.get.isZero + test "Conversion: missing block hash in Block isNone": + + var blkJson = %*{ + "subscription": "0x20", + "result":{ + "number": "0x1", + "hash": newJNull(), + "timestamp": "0x6285c293" + } + } + + var blk = Block.fromJson(blkJson["result"]) + check blk.hash.isNone + test "Conversion: missing block number in TransactionReceipt isNone": var txReceiptJson = %*{