display main account

This commit is contained in:
Iuri Matias 2020-05-08 13:47:34 -04:00
parent aba191841b
commit 8a8e60cd29
3 changed files with 21 additions and 14 deletions

View File

@ -147,7 +147,7 @@ ApplicationWindow {
RowLayout { RowLayout {
Layout.fillHeight: true Layout.fillHeight: true
TextArea { id: accountsResult; Layout.fillWidth: true; text: logic.accountsResult; readOnly: true } TextArea { id: accountResult; Layout.fillWidth: true; text: logic.accountResult; readOnly: true }
} }
} }

View File

@ -32,6 +32,7 @@ QtObject:
discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443") discard status.addPeer("enode://2c8de3cbb27a3d30cbb5b3e003bc722b126f5aef82e2052aaef032ca94e0c7ad219e533ba88c70585ebd802de206693255335b100307645ab5170e88620d2a81@47.244.221.14:443")
echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}") echo status.callPrivateRPC("{\"jsonrpc\":\"2.0\", \"method\":\"wakuext_requestMessages\", \"params\":[{\"topics\": [\"0x7998f3c8\"]}], \"id\": 1}")
result.accountResult = status.queryAccounts()
status.subscribeToTest() status.subscribeToTest()
@ -59,7 +60,6 @@ QtObject:
proc setCallResult(self: ApplicationLogic, callResult: string) {.slot.} = proc setCallResult(self: ApplicationLogic, callResult: string) {.slot.} =
if self.callResult == callResult: return if self.callResult == callResult: return
self.callResult = callResult self.callResult = callResult
self.accountResult = "0x123"
self.callResultChanged(callResult) self.callResultChanged(callResult)
proc `callResult=`*(self: ApplicationLogic, callResult: string) = self.setCallResult(callResult) proc `callResult=`*(self: ApplicationLogic, callResult: string) = self.setCallResult(callResult)
@ -77,14 +77,17 @@ QtObject:
# self.setCallResult(message) # self.setCallResult(message)
# echo "Received message: ", message # echo "Received message: ", message
proc accountResultChanged*(self: ApplicationLogic, callResult: string) {.signal.}
proc accountResult*(self: ApplicationLogic): string {.slot.} = proc accountResult*(self: ApplicationLogic): string {.slot.} =
result = self.accountResult result = self.accountResult
proc setAccountResult(self: ApplicationLogic, accountResult: string) {.slot.} = proc setAccountResult(self: ApplicationLogic, accountResult: string) {.slot.} =
if self.accountResult == accountResult: return if self.accountResult == accountResult: return
self.accountResult = "0x123" self.accountResult = accountResult
self.callResultChanged(callResult) self.accountResultChanged(accountResult)
QtProperty[string] accountsResult: QtProperty[string] accountResult:
read = accountResult read = accountResult
write = setAccountResult
notify = callResultChanged notify = callResultChanged

View File

@ -14,6 +14,18 @@ proc recreateDir(dirname: string) =
proc setSignalHandler*(something: SignalCallback) = proc setSignalHandler*(something: SignalCallback) =
libstatus.setSignalEventCallback(something) 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*() = proc subscribeToTest*() =
var result = "" var result = ""
@ -24,7 +36,7 @@ proc subscribeToTest*() =
"params": [] "params": []
} }
result = $libstatus.callPrivateRPC($payload) result = $libstatus.callPrivateRPC($payload)
payload = %* { payload = %* {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"id": 3, "id": 3,
@ -38,7 +50,6 @@ proc subscribeToTest*() =
} }
result = $libstatus.callPrivateRPC($payload) result = $libstatus.callPrivateRPC($payload)
payload = %* { payload = %* {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"id": 4, "id": 4,
@ -59,8 +70,6 @@ proc subscribeToTest*() =
} }
result = $libstatus.callPrivateRPC($payload) result = $libstatus.callPrivateRPC($payload)
payload = %* { payload = %* {
"jsonrpc": "2.0", "jsonrpc": "2.0",
"id": 3, "id": 3,
@ -71,11 +80,6 @@ proc subscribeToTest*() =
} }
result = $libstatus.callPrivateRPC($payload) result = $libstatus.callPrivateRPC($payload)
proc setupNewAccount*() = proc setupNewAccount*() =
# Deleting directories # Deleting directories
recreateDir(datadir) recreateDir(datadir)