feat: Connect to peer and call private RPC

This commit is contained in:
emizzle 2020-05-08 21:07:50 +10:00
parent ddb78fd536
commit dc99dfb99d
No known key found for this signature in database
GPG Key ID: 1FD4BAB3C37EE9BA
3 changed files with 23 additions and 1 deletions

View File

@ -14,9 +14,12 @@ QtObject:
result.setup()
status.setupNewAccount()
discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443")
echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}")
# ¯\_(ツ)_/¯ dunno what is this
proc setup(self: ApplicationLogic) =
# discard status.onMessage(self.onMessage)
self.QObject.setup
# ¯\_(ツ)_/¯ seems to be a method for garbage collection
@ -47,5 +50,9 @@ QtObject:
notify = callResultChanged
proc onSend*(self: ApplicationLogic, inputJSON: string) {.slot.} =
self.setCallResult(status.callRPC(inputJSON))
self.setCallResult(status.callPrivateRPC(inputJSON))
echo "Done!: ", self.callResult
# proc onMessage*(self: ApplicationLogic, message: string) {.slot.} =
# self.setCallResult(message)
# echo "Received message: ", message

View File

@ -11,3 +11,9 @@ proc multiAccountStoreDerivedAccounts*(paramsJSON: cstring): cstring {.importc:
proc saveAccountAndLogin*(accountData: cstring, password: cstring, settingsJSON: cstring, configJSON: cstring, subaccountData: cstring): cstring {.importc: "SaveAccountAndLogin".}
proc callRPC*(inputJSON: cstring): cstring {.importc: "CallRPC".}
proc callPrivateRPC*(inputJSON: cstring): cstring {.importc: "CallPrivateRPC".}
proc addPeer*(peer: cstring): cstring {.importc: "AddPeer".}
# proc setSignalEventCallback*(callback: proc): void {.importc: "SetSignalEventCallback".}

View File

@ -269,3 +269,12 @@ proc setupNewAccount*() =
proc callRPC*(inputJSON: string): string =
return $libstatus.callRPC(inputJSON)
proc callPrivateRPC*(inputJSON: string): string =
return $libstatus.callPrivateRPC(inputJSON)
proc addPeer*(peer: string): string =
return $libstatus.addPeer(peer)
# proc onMessage*(callback: proc(message: string)): void =
# $libstatus.setSignalEventCallback(callback)