From 3835458412901b02b6b7e6116afc13ff1ad7bba5 Mon Sep 17 00:00:00 2001 From: Emil Ivanichkov Date: Fri, 19 Apr 2024 14:51:08 +0300 Subject: [PATCH] feat(SNM): Install `waku sendMessage` command --- src/status_node_manager.nim | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/status_node_manager.nim b/src/status_node_manager.nim index 939ea3d..cfb0b13 100644 --- a/src/status_node_manager.nim +++ b/src/status_node_manager.nim @@ -112,6 +112,20 @@ proc doWakuHandshakeExport(config: StatusNodeManagerConfig, WakuExportHandshakeRequestData(exportFile: $config.handshakeFile) waitFor wakuExportHandshake(wakuClient, requestData) +proc doWakuSendMessage(config: StatusNodeManagerConfig, + wakuClient: var RestClientRef) = + let contentTopic = if config.contentTopic.isSome: + config.contentTopic.get + else: + defaultWakuContentTopic + + let requestData = WakuSendMessageRequestData( + message: config.message, + contentTopic: contentTopic + ) + + waitFor wakuSendMessage(wakuClient, requestData) + proc doWakuCommand(config: StatusNodeManagerConfig, rng: ref HmacDrbgContext) = var wakuClient = RestClientRef.new(initTAddress(config.restAddress, config.restPort)) @@ -121,7 +135,7 @@ proc doWakuCommand(config: StatusNodeManagerConfig, rng: ref HmacDrbgContext) = of WakuCommand.exportHandshake: doWakuHandshakeExport(config, wakuClient) of WakuCommand.sendMessage: - discard + doWakuSendMessage(config, wakuClient) when isMainModule: setupLogLevel(LogLevel.NOTICE)