From aba191841bb1e6ffa4e91bfe34f699b89335e91a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 May 2020 11:25:16 -0400 Subject: [PATCH 1/2] display account --- main.qml | 10 ++++++++-- src/applicationLogic.nim | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/main.qml b/main.qml index bab1e79bec..5194eb9da1 100644 --- a/main.qml +++ b/main.qml @@ -21,6 +21,7 @@ ApplicationWindow { id: tabBar width: 50 height: width *2 + spacing + currentIndex: 0 transformOrigin: Item.Top Layout.alignment: Qt.AlignLeft | Qt.AlignTop Layout.fillHeight: true @@ -141,9 +142,14 @@ ApplicationWindow { } - Item { + ColumnLayout { + anchors.fill: parent - } + RowLayout { + Layout.fillHeight: true + TextArea { id: accountsResult; Layout.fillWidth: true; text: logic.accountsResult; readOnly: true } + } + } Item { diff --git a/src/applicationLogic.nim b/src/applicationLogic.nim index 8483e57b72..7e6d954c58 100644 --- a/src/applicationLogic.nim +++ b/src/applicationLogic.nim @@ -17,6 +17,7 @@ QtObject: type ApplicationLogic* = ref object of QObject app: QApplication callResult: string + accountResult: string # Constructor proc newApplicationLogic*(app: QApplication): ApplicationLogic = @@ -58,6 +59,7 @@ QtObject: proc setCallResult(self: ApplicationLogic, callResult: string) {.slot.} = if self.callResult == callResult: return self.callResult = callResult + self.accountResult = "0x123" self.callResultChanged(callResult) proc `callResult=`*(self: ApplicationLogic, callResult: string) = self.setCallResult(callResult) @@ -74,3 +76,15 @@ QtObject: # proc onMessage*(self: ApplicationLogic, message: string) {.slot.} = # self.setCallResult(message) # echo "Received message: ", message + + proc accountResult*(self: ApplicationLogic): string {.slot.} = + result = self.accountResult + + proc setAccountResult(self: ApplicationLogic, accountResult: string) {.slot.} = + if self.accountResult == accountResult: return + self.accountResult = "0x123" + self.callResultChanged(callResult) + + QtProperty[string] accountsResult: + read = accountResult + notify = callResultChanged From 8a8e60cd29c509080f7a3c726c2e8a99d8aba982 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Fri, 8 May 2020 13:47:34 -0400 Subject: [PATCH 2/2] display main account --- main.qml | 2 +- src/applicationLogic.nim | 11 +++++++---- src/status.nim | 22 +++++++++++++--------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/main.qml b/main.qml index 5194eb9da1..dedd237d58 100644 --- a/main.qml +++ b/main.qml @@ -147,7 +147,7 @@ ApplicationWindow { RowLayout { 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 } } } diff --git a/src/applicationLogic.nim b/src/applicationLogic.nim index 7e6d954c58..3eeebe59d1 100644 --- a/src/applicationLogic.nim +++ b/src/applicationLogic.nim @@ -32,6 +32,7 @@ QtObject: 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() @@ -59,7 +60,6 @@ QtObject: proc setCallResult(self: ApplicationLogic, callResult: string) {.slot.} = if self.callResult == callResult: return self.callResult = callResult - self.accountResult = "0x123" self.callResultChanged(callResult) proc `callResult=`*(self: ApplicationLogic, callResult: string) = self.setCallResult(callResult) @@ -77,14 +77,17 @@ QtObject: # 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 = "0x123" - self.callResultChanged(callResult) + self.accountResult = accountResult + self.accountResultChanged(accountResult) - QtProperty[string] accountsResult: + QtProperty[string] accountResult: read = accountResult + write = setAccountResult notify = callResultChanged diff --git a/src/status.nim b/src/status.nim index ecf460dabf..5e918910d7 100644 --- a/src/status.nim +++ b/src/status.nim @@ -14,6 +14,18 @@ proc recreateDir(dirname: string) = 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 = "" @@ -24,7 +36,7 @@ proc subscribeToTest*() = "params": [] } result = $libstatus.callPrivateRPC($payload) - + payload = %* { "jsonrpc": "2.0", "id": 3, @@ -38,7 +50,6 @@ proc subscribeToTest*() = } result = $libstatus.callPrivateRPC($payload) - payload = %* { "jsonrpc": "2.0", "id": 4, @@ -59,8 +70,6 @@ proc subscribeToTest*() = } result = $libstatus.callPrivateRPC($payload) - - payload = %* { "jsonrpc": "2.0", "id": 3, @@ -71,11 +80,6 @@ proc subscribeToTest*() = } result = $libstatus.callPrivateRPC($payload) - - - - - proc setupNewAccount*() = # Deleting directories recreateDir(datadir)