diff --git a/ncli/ncli_testnet.nim b/ncli/ncli_testnet.nim index 91e0b92c7e..49b5d82aef 100644 --- a/ncli/ncli_testnet.nim +++ b/ncli/ncli_testnet.nim @@ -8,7 +8,7 @@ {.push raises: [].} import - std/[json, options], + std/[json, options, times], chronos, bearssl/rand, chronicles, confutils, stint, json_serialization, web3, eth/keys, eth/p2p/discoveryv5/random2, stew/[io2, byteutils], json_rpc/jsonmarshal, @@ -333,6 +333,22 @@ func createDepositContractSnapshot( depositContractState: merkleizer.toDepositContractState, blockHeight: blockHeight) +proc writeValue*(writer: var JsonWriter, value: DateTime) = + writer.writeValue($value) + +proc readValue*(reader: var JsonReader, value: var DateTime) = + let s = reader.readValue(string) + try: + value = parse(s, "YYYY-MM-dd HH:mm:ss'.'fffzzz", utc()) + except CatchableError: + raiseUnexpectedValue(reader, "Invalid date time") + +proc writeValue*(writer: var JsonWriter, value: IoErrorCode) = + writer.writeValue(distinctBase value) + +proc readValue*(reader: var JsonReader, value: var IoErrorCode) = + IoErrorCode reader.readValue(distinctBase IoErrorCode) + proc createEnr(rng: var HmacDrbgContext, dataDir: string, netKeyFile: string,