2020-09-10 04:18:35 +00:00
|
|
|
import
|
|
|
|
os, strutils, strformat, chronicles, json_rpc/[rpcclient, rpcserver], nimcrypto/sysrand,
|
2020-09-11 07:49:45 +00:00
|
|
|
stew/byteutils,
|
2020-09-10 04:18:35 +00:00
|
|
|
libp2p/protobuf/minprotobuf,
|
|
|
|
eth/common as eth_common, eth/keys,
|
|
|
|
system,
|
2021-02-04 08:39:55 +00:00
|
|
|
options,
|
|
|
|
../wakunode2,
|
|
|
|
../waku_payload,
|
|
|
|
../jsonrpc/jsonrpc_types,
|
2022-08-12 10:15:51 +00:00
|
|
|
../../protocol/waku_filter,
|
2022-07-25 11:01:37 +00:00
|
|
|
../../protocol/waku_store,
|
2021-02-04 08:39:55 +00:00
|
|
|
../../../v1/node/rpc/hexstrings
|
2020-09-10 04:18:35 +00:00
|
|
|
|
|
|
|
from strutils import rsplit
|
|
|
|
template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0]
|
|
|
|
|
2021-02-04 08:39:55 +00:00
|
|
|
const sigWakuPath = sourceDir / "../jsonrpc/jsonrpc_callsigs.nim"
|
2020-09-10 04:18:35 +00:00
|
|
|
createRpcSigs(RpcHttpClient, sigWakuPath)
|
|
|
|
|
|
|
|
if paramCount() < 1:
|
|
|
|
echo "Please provide rpcPort as argument."
|
|
|
|
quit(1)
|
|
|
|
|
|
|
|
let rpcPort = Port(parseInt(paramStr(1)))
|
|
|
|
|
|
|
|
echo "Please enter your message:"
|
2020-09-11 07:49:45 +00:00
|
|
|
let raw_input = readLine(stdin)
|
|
|
|
let input = fmt"{raw_input}"
|
|
|
|
echo "Input is:", input
|
2020-09-10 04:18:35 +00:00
|
|
|
|
|
|
|
var node = newRpcHttpClient()
|
|
|
|
waitfor node.connect("localhost", rpcPort)
|
|
|
|
|
2020-10-28 05:19:07 +00:00
|
|
|
let pubSubTopic = "/waku/2/default-waku/proto"
|
2021-04-08 09:55:19 +00:00
|
|
|
let contentTopic = ContentTopic("/waku/2/default-content/proto")
|
2021-02-04 08:39:55 +00:00
|
|
|
let relayMessage = WakuRelayMessage(payload: input.toBytes(), contentTopic: some(contentTopic))
|
|
|
|
var res = waitfor node.post_waku_v2_relay_v1_message(pubSubTopic, relayMessage)
|
2020-09-11 07:49:45 +00:00
|
|
|
echo "Waku publish response: ", res
|