Merge branch 'master' into feat/style-kindof
This commit is contained in:
commit
b02d15a9bd
|
@ -8,7 +8,7 @@ Experiments calling status-go from nim, inspired in [nim-stratus](https://github
|
||||||
|
|
||||||
```
|
```
|
||||||
# linux
|
# linux
|
||||||
??? apt-get install nim ???
|
apt-get install nim
|
||||||
|
|
||||||
# macos
|
# macos
|
||||||
brew install nim
|
brew install nim
|
||||||
|
@ -26,6 +26,12 @@ export PATH=$PATH:/path/to/Qt/5.14.2/clang_64/bin
|
||||||
|
|
||||||
### 3. Clone and build DOtherside
|
### 3. Clone and build DOtherside
|
||||||
|
|
||||||
|
For Linux:
|
||||||
|
```
|
||||||
|
sudo apt-get install build-essential libgl1-mesa-dev
|
||||||
|
sudo apt-get install doxygen
|
||||||
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
git clone https://github.com/filcuc/DOtherSide
|
git clone https://github.com/filcuc/DOtherSide
|
||||||
cd DOtherSide
|
cd DOtherSide
|
||||||
|
|
7
main.qml
7
main.qml
|
@ -168,8 +168,13 @@ ApplicationWindow {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
Layout.fillHeight: true
|
||||||
|
TextArea { id: accountResult; Layout.fillWidth: true; text: logic.accountResult; readOnly: true }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
|
@ -1,10 +1,23 @@
|
||||||
import NimQml
|
import NimQml
|
||||||
import status
|
import status
|
||||||
|
import libstatus
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
var signalHandler: SignalCallback = proc(p0: cstring): void =
|
||||||
|
setupForeignThreadGc()
|
||||||
|
|
||||||
|
var jsonSignal = ($p0).parseJson
|
||||||
|
if $jsonSignal["type"].getStr == "messages.new":
|
||||||
|
echo $p0
|
||||||
|
|
||||||
|
tearDownForeignThreadGc()
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
type ApplicationLogic* = ref object of QObject
|
type ApplicationLogic* = ref object of QObject
|
||||||
app: QApplication
|
app: QApplication
|
||||||
callResult: string
|
callResult: string
|
||||||
|
accountResult: string
|
||||||
|
|
||||||
# Constructor
|
# Constructor
|
||||||
proc newApplicationLogic*(app: QApplication): ApplicationLogic =
|
proc newApplicationLogic*(app: QApplication): ApplicationLogic =
|
||||||
|
@ -13,10 +26,20 @@ QtObject:
|
||||||
result.callResult = "Use this tool to call JSONRPC methods"
|
result.callResult = "Use this tool to call JSONRPC methods"
|
||||||
result.setup()
|
result.setup()
|
||||||
|
|
||||||
|
status.setSignalHandler(signalHandler)
|
||||||
|
|
||||||
status.setupNewAccount()
|
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}")
|
||||||
|
|
||||||
|
result.accountResult = status.queryAccounts()
|
||||||
|
status.subscribeToTest()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ¯\_(ツ)_/¯ dunno what is this
|
# ¯\_(ツ)_/¯ dunno what is this
|
||||||
proc setup(self: ApplicationLogic) =
|
proc setup(self: ApplicationLogic) =
|
||||||
|
# discard status.onMessage(self.onMessage)
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
|
||||||
# ¯\_(ツ)_/¯ seems to be a method for garbage collection
|
# ¯\_(ツ)_/¯ seems to be a method for garbage collection
|
||||||
|
@ -47,5 +70,24 @@ QtObject:
|
||||||
notify = callResultChanged
|
notify = callResultChanged
|
||||||
|
|
||||||
proc onSend*(self: ApplicationLogic, inputJSON: string) {.slot.} =
|
proc onSend*(self: ApplicationLogic, inputJSON: string) {.slot.} =
|
||||||
self.setCallResult(status.callRPC(inputJSON))
|
self.setCallResult(status.callPrivateRPC(inputJSON))
|
||||||
echo "Done!: ", self.callResult
|
echo "Done!: ", self.callResult
|
||||||
|
|
||||||
|
# proc onMessage*(self: ApplicationLogic, message: string) {.slot.} =
|
||||||
|
# self.setCallResult(message)
|
||||||
|
# echo "Received message: ", message
|
||||||
|
|
||||||
|
proc accountResultChanged*(self: ApplicationLogic, callResult: string) {.signal.}
|
||||||
|
|
||||||
|
proc accountResult*(self: ApplicationLogic): string {.slot.} =
|
||||||
|
result = self.accountResult
|
||||||
|
|
||||||
|
proc setAccountResult(self: ApplicationLogic, accountResult: string) {.slot.} =
|
||||||
|
if self.accountResult == accountResult: return
|
||||||
|
self.accountResult = accountResult
|
||||||
|
self.accountResultChanged(accountResult)
|
||||||
|
|
||||||
|
QtProperty[string] accountResult:
|
||||||
|
read = accountResult
|
||||||
|
write = setAccountResult
|
||||||
|
notify = callResultChanged
|
||||||
|
|
|
@ -11,3 +11,11 @@ proc multiAccountStoreDerivedAccounts*(paramsJSON: cstring): cstring {.importc:
|
||||||
proc saveAccountAndLogin*(accountData: cstring, password: cstring, settingsJSON: cstring, configJSON: cstring, subaccountData: cstring): cstring {.importc: "SaveAccountAndLogin".}
|
proc saveAccountAndLogin*(accountData: cstring, password: cstring, settingsJSON: cstring, configJSON: cstring, subaccountData: cstring): cstring {.importc: "SaveAccountAndLogin".}
|
||||||
|
|
||||||
proc callRPC*(inputJSON: cstring): cstring {.importc: "CallRPC".}
|
proc callRPC*(inputJSON: cstring): cstring {.importc: "CallRPC".}
|
||||||
|
|
||||||
|
proc callPrivateRPC*(inputJSON: cstring): cstring {.importc: "CallPrivateRPC".}
|
||||||
|
|
||||||
|
proc addPeer*(peer: cstring): cstring {.importc: "AddPeer".}
|
||||||
|
|
||||||
|
type SignalCallback* = proc(eventMessage: cstring): void
|
||||||
|
|
||||||
|
proc setSignalEventCallback*(callback: SignalCallback) {.importc: "SetSignalEventCallback".}
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
--threads:on
|
--threads:on
|
||||||
|
--tlsEmulation:off
|
||||||
|
|
|
@ -11,6 +11,75 @@ proc recreateDir(dirname: string) =
|
||||||
removeDir(dirname)
|
removeDir(dirname)
|
||||||
createDir(dirname)
|
createDir(dirname)
|
||||||
|
|
||||||
|
proc setSignalHandler*(something: SignalCallback) =
|
||||||
|
libstatus.setSignalEventCallback(something)
|
||||||
|
|
||||||
|
proc queryAccounts*(): string =
|
||||||
|
var payload = %* {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"method": "eth_accounts",
|
||||||
|
"params": [
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
var response = $libstatus.callPrivateRPC($payload)
|
||||||
|
echo response
|
||||||
|
result = parseJson(response)["result"][0].getStr()
|
||||||
|
|
||||||
|
proc subscribeToTest*() =
|
||||||
|
var result = ""
|
||||||
|
|
||||||
|
var payload = %* {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 3,
|
||||||
|
"method": "wakuext_startMessenger",
|
||||||
|
"params": []
|
||||||
|
}
|
||||||
|
result = $libstatus.callPrivateRPC($payload)
|
||||||
|
|
||||||
|
payload = %* {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 3,
|
||||||
|
"method": "wakuext_loadFilters",
|
||||||
|
"params": [
|
||||||
|
[{
|
||||||
|
"ChatID":"test",
|
||||||
|
"OneToOne":false
|
||||||
|
}]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
result = $libstatus.callPrivateRPC($payload)
|
||||||
|
|
||||||
|
payload = %* {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 4,
|
||||||
|
"method": "wakuext_saveChat",
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"lastClockValue":0,
|
||||||
|
"color":"#51d0f0",
|
||||||
|
"name":"test",
|
||||||
|
"lastMessage":nil,
|
||||||
|
"active":true,
|
||||||
|
"id":"test",
|
||||||
|
"unviewedMessagesCount":0,
|
||||||
|
"chatType":2,
|
||||||
|
"timestamp":1588940692659
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
result = $libstatus.callPrivateRPC($payload)
|
||||||
|
|
||||||
|
payload = %* {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 3,
|
||||||
|
"method": "wakuext_chatMessages",
|
||||||
|
"params": [
|
||||||
|
"test", nil, 20
|
||||||
|
]
|
||||||
|
}
|
||||||
|
result = $libstatus.callPrivateRPC($payload)
|
||||||
|
|
||||||
proc setupNewAccount*() =
|
proc setupNewAccount*() =
|
||||||
# Deleting directories
|
# Deleting directories
|
||||||
recreateDir(datadir)
|
recreateDir(datadir)
|
||||||
|
@ -269,3 +338,12 @@ proc setupNewAccount*() =
|
||||||
|
|
||||||
proc callRPC*(inputJSON: string): string =
|
proc callRPC*(inputJSON: string): string =
|
||||||
return $libstatus.callRPC(inputJSON)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue