Merge pull request #9 from status-im/display_accounts

Display accounts
This commit is contained in:
Iuri Matias 2020-05-08 13:48:33 -04:00 committed by GitHub
commit 23139cc9a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 11 deletions

View File

@ -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,8 +142,13 @@ ApplicationWindow {
}
Item {
ColumnLayout {
anchors.fill: parent
RowLayout {
Layout.fillHeight: true
TextArea { id: accountResult; Layout.fillWidth: true; text: logic.accountResult; readOnly: true }
}
}
Item {

View File

@ -17,6 +17,7 @@ QtObject:
type ApplicationLogic* = ref object of QObject
app: QApplication
callResult: string
accountResult: string
# Constructor
proc newApplicationLogic*(app: QApplication): ApplicationLogic =
@ -31,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()
@ -74,3 +76,18 @@ QtObject:
# 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

View File

@ -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 = ""
@ -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)