mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-13 15:36:58 +00:00
deploy: 2fe6935623966d46f621a239e19cc37fabd1735c
This commit is contained in:
parent
056c5ee277
commit
b2f8f62f8f
@ -1 +1 @@
|
||||
1616406285
|
||||
1616426036
|
@ -2,7 +2,7 @@
|
||||
|
||||
# libtool - Provide generalized library-building support services.
|
||||
# Generated automatically by config.status (libbacktrace) version-unused
|
||||
# Libtool was configured on host fv-az231-860:
|
||||
# Libtool was configured on host fv-az182-952:
|
||||
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
|
||||
#
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
|
||||
|
@ -138,7 +138,10 @@ proc `%`*(value: waku_protocol.Topic): JsonNode =
|
||||
result = %("0x" & value.toHex)
|
||||
|
||||
proc `%`*(value: seq[byte]): JsonNode =
|
||||
result = %("0x" & value.toHex)
|
||||
if value.len > 0:
|
||||
result = %("0x" & value.toHex)
|
||||
else:
|
||||
result = newJArray()
|
||||
|
||||
# Helpers for the fromJson procs
|
||||
|
||||
@ -210,12 +213,6 @@ proc fromJson*(n: JsonNode, argName: string, result: var waku_protocol.Topic) =
|
||||
# Following procs currently required only for testing, the `createRpcSigs` macro
|
||||
# requires it as it will convert the JSON results back to the original Nim
|
||||
# types, but it needs the `fromJson` calls for those specific Nim types to do so
|
||||
proc fromJson*(n: JsonNode, argName: string, result: var seq[byte]) =
|
||||
n.kind.expect(JString, argName)
|
||||
let hexStr = n.getStr()
|
||||
if not hexStr.isValidHexData:
|
||||
raise newException(ValueError, invalidMsg(argName) & " as a hex data \"" & hexStr & "\"")
|
||||
result = hexToSeqByte(hexStr)
|
||||
|
||||
proc fromJson*(n: JsonNode, argName: string, result: var Hash256) =
|
||||
n.kind.expect(JString, argName)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import
|
||||
std/options,
|
||||
std/[options, json, sequtils],
|
||||
eth/keys,
|
||||
../../../v1/node/rpc/hexstrings,
|
||||
../../protocol/waku_store/waku_store_types,
|
||||
@ -8,6 +8,16 @@ import
|
||||
|
||||
export hexstrings
|
||||
|
||||
## Json marshalling
|
||||
|
||||
proc `%`*(value: WakuMessage): JsonNode =
|
||||
## This ensures that seq[byte] fields are marshalled to hex-format JStrings
|
||||
## (as defined in `hexstrings.nim`) rather than the default JArray[JInt]
|
||||
let jObj = newJObject()
|
||||
for k, v in value.fieldPairs:
|
||||
jObj[k] = %v
|
||||
return jObj
|
||||
|
||||
## Conversion tools
|
||||
## Since the Waku v2 JSON-RPC API has its own defined types,
|
||||
## we need to convert between these and the types for the Nim API
|
||||
|
Loading…
x
Reference in New Issue
Block a user