Fabiana Cecin ce918b0819
chore: replace Option with Opt (#4035)
* change all usage of std.options.Option[T] to results.Opt[T]
* fix broken apps and examples (to validate refactor)
* removed all std/options code added for libp2p v2 migration
* add broker Opt codec to persistency/backend_comm.nim
* add a readValue overload for Opt[T] in tools/confutils/cli_args.nim
* keep Option where required (Presto, confutils' config_file.nim)
* Change generateRlnProof error handling
* Fix imports
2026-07-16 14:02:17 -03:00

21 lines
517 B
Nim

import std/[json, strutils]
import results
proc getProtoInt64*(node: JsonNode, key: string): Result[Opt[int64], string] =
try:
let (value, ok) =
if node.hasKey(key):
if node[key].kind == JString:
(parseBiggestInt(node[key].getStr()), true)
else:
(node[key].getBiggestInt(), true)
else:
(0, false)
if ok:
return ok(Opt.some(value))
return ok(Opt.none(int64))
except CatchableError:
return err("Invalid int64 value in `" & key & "`")