mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-07-17 18:19:36 +00:00
* 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
21 lines
517 B
Nim
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 & "`")
|