Skip to content

Commit ccb4ed5

Browse files
authored
chore: expect camelCase JSON for libwaku store queries (#3366)
1 parent 25d30d4 commit ccb4ed5

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

library/waku_thread/inter_thread_communication/requests/protocols/store_request.nim

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,50 +24,49 @@ func fromJsonNode(
2424
T: type StoreRequest, jsonContent: JsonNode
2525
): Result[StoreQueryRequest, string] =
2626
var contentTopics: seq[string]
27-
if jsonContent.contains("content_topics"):
27+
if jsonContent.contains("contentTopics"):
2828
contentTopics = collect(newSeq):
29-
for cTopic in jsonContent["content_topics"].getElems():
29+
for cTopic in jsonContent["contentTopics"].getElems():
3030
cTopic.getStr()
3131

3232
var msgHashes: seq[WakuMessageHash]
33-
if jsonContent.contains("message_hashes"):
34-
for hashJsonObj in jsonContent["message_hashes"].getElems():
33+
if jsonContent.contains("messageHashes"):
34+
for hashJsonObj in jsonContent["messageHashes"].getElems():
3535
let hash = hashJsonObj.getStr().hexToHash().valueOr:
3636
return err("Failed converting message hash hex string to bytes: " & error)
3737
msgHashes.add(hash)
3838

3939
let pubsubTopic =
40-
if jsonContent.contains("pubsub_topic"):
41-
some(jsonContent["pubsub_topic"].getStr())
40+
if jsonContent.contains("pubsubTopic"):
41+
some(jsonContent["pubsubTopic"].getStr())
4242
else:
4343
none(string)
4444

4545
let paginationCursor =
46-
if jsonContent.contains("pagination_cursor"):
47-
let hash = jsonContent["pagination_cursor"].getStr().hexToHash().valueOr:
48-
return
49-
err("Failed converting pagination_cursor hex string to bytes: " & error)
46+
if jsonContent.contains("paginationCursor"):
47+
let hash = jsonContent["paginationCursor"].getStr().hexToHash().valueOr:
48+
return err("Failed converting paginationCursor hex string to bytes: " & error)
5049
some(hash)
5150
else:
5251
none(WakuMessageHash)
5352

54-
let paginationForwardBool = jsonContent["pagination_forward"].getBool()
53+
let paginationForwardBool = jsonContent["paginationForward"].getBool()
5554
let paginationForward =
5655
if paginationForwardBool: PagingDirection.FORWARD else: PagingDirection.BACKWARD
5756

5857
let paginationLimit =
59-
if jsonContent.contains("pagination_limit"):
60-
some(uint64(jsonContent["pagination_limit"].getInt()))
58+
if jsonContent.contains("paginationLimit"):
59+
some(uint64(jsonContent["paginationLimit"].getInt()))
6160
else:
6261
none(uint64)
6362

64-
let startTime = ?jsonContent.getProtoInt64("time_start")
65-
let endTime = ?jsonContent.getProtoInt64("time_end")
63+
let startTime = ?jsonContent.getProtoInt64("timeStart")
64+
let endTime = ?jsonContent.getProtoInt64("timeEnd")
6665

6766
return ok(
6867
StoreQueryRequest(
69-
requestId: jsonContent["request_id"].getStr(),
70-
includeData: jsonContent["include_data"].getBool(),
68+
requestId: jsonContent["requestId"].getStr(),
69+
includeData: jsonContent["includeData"].getBool(),
7170
pubsubTopic: pubsubTopic,
7271
contentTopics: contentTopics,
7372
startTime: startTime,

0 commit comments

Comments
 (0)