Skip to content

Commit a8409b0

Browse files
committed
Implementing new wallet views
1 parent 5ae3dee commit a8409b0

File tree

8 files changed

+147
-38
lines changed

8 files changed

+147
-38
lines changed

ethereal/assets/qml/views/history.qml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ Rectangle {
1111
property var title: "Transactions"
1212
property var menuItem
1313

14-
property var txModel: ListModel {
15-
id: txModel
16-
}
1714

1815
id: historyView
16+
visible: false
1917
anchors.fill: parent
2018
objectName: "transactionView"
2119

20+
property var txModel: ListModel {
21+
id: txModel
22+
}
2223
TableView {
2324
id: txTableView
2425
anchors.fill: parent

ethereal/assets/qml/views/info.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Rectangle {
2929
text: "Address"
3030
}
3131
TextField {
32-
text: eth.getKey().address
32+
text: eth.key().address
3333
width: 500
3434
}
3535

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import QtQuick 2.0
2+
import QtQuick.Controls 1.0;
3+
import QtQuick.Layouts 1.0;
4+
import QtQuick.Dialogs 1.0;
5+
import QtQuick.Window 2.1;
6+
import QtQuick.Controls.Styles 1.1
7+
import Ethereum 1.0
8+
9+
Rectangle {
10+
id: root
11+
property var title: "Wallet"
12+
property var iconFile: "../wallet.png"
13+
property var menuItem
14+
15+
objectName: "walletView"
16+
anchors.fill: parent
17+
18+
function onReady() {
19+
menuItem.secondary = eth.numberToHuman(eth.balanceAt(eth.key().address))
20+
21+
}
22+
23+
ColumnLayout {
24+
spacing: 10
25+
y: 40
26+
anchors {
27+
left: parent.left
28+
right: parent.right
29+
}
30+
31+
Text {
32+
text: "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.key().address))
33+
font.pixelSize: 24
34+
anchors {
35+
horizontalCenter: parent.horizontalCenter
36+
}
37+
}
38+
39+
TableView {
40+
id: txTableView
41+
anchors {
42+
left: parent.left
43+
right: parent.right
44+
}
45+
TableViewColumn{ role: "num" ; title: "#" ; width: 30 }
46+
TableViewColumn{ role: "from" ; title: "From" ; width: 280 }
47+
TableViewColumn{ role: "to" ; title: "To" ; width: 280 }
48+
TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 }
49+
50+
model: ListModel {
51+
id: txModel
52+
Component.onCompleted: {
53+
var messages = JSON.parse(eth.messages({latest: -1, from: "e6716f9544a56c530d868e4bfbacb172315bdead"}))
54+
for(var i = 0; i < messages.length; i++) {
55+
var message = messages[i];
56+
this.insert(0, {num: i, from: message.from, to: message.to, value: eth.numberToHuman(message.value)})
57+
}
58+
}
59+
}
60+
}
61+
62+
}
63+
}

ethereal/assets/qml/wallet.qml

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import QtQuick.Window 2.1;
66
import QtQuick.Controls.Styles 1.1
77
import Ethereum 1.0
88

9+
910
ApplicationWindow {
1011
id: root
1112

@@ -30,12 +31,14 @@ ApplicationWindow {
3031

3132
// Takes care of loading all default plugins
3233
Component.onCompleted: {
33-
var historyView = addPlugin("./views/history.qml", {default: true})
34-
var newTxView = addPlugin("./views/transaction.qml", {default: true})
35-
var chainView = addPlugin("./views/chain.qml", {default: true})
36-
var infoView = addPlugin("./views/info.qml", {default: true})
37-
var pendingTxView = addPlugin("./views/pending_tx.qml", {default: true})
38-
var pendingTxView = addPlugin("./views/javascript.qml", {default: true})
34+
var walletView = addPlugin("./views/wallet.qml", {section: "ethereum"})
35+
36+
var historyView = addPlugin("./views/history.qml", {section: "legacy"})
37+
var newTxView = addPlugin("./views/transaction.qml", {section: "legacy"})
38+
var chainView = addPlugin("./views/chain.qml", {section: "legacy"})
39+
var infoView = addPlugin("./views/info.qml", {section: "legacy"})
40+
var pendingTxView = addPlugin("./views/pending_tx.qml", {section: "legacy"})
41+
var pendingTxView = addPlugin("./views/javascript.qml", {section: "legacy"})
3942

4043
// Call the ready handler
4144
gui.done()
@@ -252,10 +255,10 @@ ApplicationWindow {
252255

253256
function setView(view, menu) {
254257
for(var i = 0; i < views.length; i++) {
255-
views[i][0].visible = false
258+
views[i].view.visible = false
256259

257-
views[i][1].border.color = "#00000000"
258-
views[i][1].color = "#00000000"
260+
views[i].menuItem.border.color = "#00000000"
261+
views[i].menuItem.color = "#00000000"
259262
}
260263
view.visible = true
261264

@@ -265,14 +268,21 @@ ApplicationWindow {
265268

266269
function addComponent(component, options) {
267270
var view = mainView.createView(component, options)
271+
268272
if(!view.hasOwnProperty("iconFile")) {
269273
console.log("Could not load plugin. Property 'iconFile' not found on view.");
270274
return;
271275
}
272276

273277
var menuItem = menu.createMenuItem(view.iconFile, view, options);
278+
if(view.hasOwnProperty("menuItem")) {
279+
view.menuItem = menuItem;
280+
}
281+
mainSplit.views.push({view: view, menuItem: menuItem});
274282

275-
mainSplit.views.push([view, menuItem]);
283+
if(view.hasOwnProperty("onReady")) {
284+
view.onReady.call(view)
285+
}
276286

277287
return view
278288
}
@@ -294,6 +304,7 @@ ApplicationWindow {
294304
property var view;
295305

296306
property alias title: label.text
307+
property alias icon: icon.source
297308
property alias secondary: secondary.text
298309

299310
width: 180
@@ -310,22 +321,24 @@ ApplicationWindow {
310321

311322
Image {
312323
id: icon
324+
height: 20
325+
width: 20
313326
anchors {
314327
left: parent.left
315328
verticalCenter: parent.verticalCenter
329+
leftMargin: 3
316330
}
317-
source: "../pick.png"
318331
}
319332

320333
Text {
321334
id: label
322335
anchors {
323336
left: icon.right
324337
verticalCenter: parent.verticalCenter
338+
leftMargin: 3
325339
}
326340

327-
text: "Chain"
328-
font.bold: true
341+
//font.bold: true
329342
color: "#0D0A01"
330343
font.pixelSize: 12
331344
}
@@ -355,15 +368,29 @@ ApplicationWindow {
355368
options = {};
356369
}
357370

358-
if(options.default) {
359-
var comp = menuItemTemplate.createObject(menuDefault)
371+
var section;
372+
switch(options.section) {
373+
case "ethereum":
374+
section = menuDefault;
375+
break;
376+
case "legacy":
377+
section = menuLegacy;
378+
break;
379+
default:
380+
section = menuApps;
381+
break;
360382
}
383+
384+
var comp = menuItemTemplate.createObject(section)
361385

362386
comp.view = view
363387
comp.title = view.title
388+
comp.icon = view.iconFile
389+
/*
364390
if(view.secondary !== undefined) {
365391
comp.secondary = view.secondary
366392
}
393+
*/
367394

368395
return comp
369396

@@ -376,7 +403,7 @@ ApplicationWindow {
376403

377404
ColumnLayout {
378405
id: menuColumn
379-
y: 30
406+
y: 10
380407
width: parent.width
381408
anchors.left: parent.left
382409
anchors.right: parent.right
@@ -401,6 +428,25 @@ ApplicationWindow {
401428
}
402429
}
403430

431+
Text {
432+
text: "LEGACY"
433+
font.bold: true
434+
anchors {
435+
left: parent.left
436+
leftMargin: 5
437+
}
438+
color: "#888888"
439+
}
440+
441+
ColumnLayout {
442+
id: menuLegacy
443+
spacing: 3
444+
anchors {
445+
left: parent.left
446+
right: parent.right
447+
}
448+
}
449+
404450
Text {
405451
text: "APPS"
406452
font.bold: true

ethereal/assets/qml/webapp.qml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,39 +142,39 @@ ApplicationWindow {
142142
try {
143143
switch(data.call) {
144144
case "getCoinBase":
145-
postData(data._seed, eth.getCoinBase())
145+
postData(data._seed, eth.coinBase())
146146

147147
break
148148

149149
case "getIsListening":
150-
postData(data._seed, eth.getIsListening())
150+
postData(data._seed, eth.isListening())
151151

152152
break
153153

154154
case "getIsMining":
155-
postData(data._seed, eth.getIsMining())
155+
postData(data._seed, eth.isMining())
156156

157157
break
158158

159159
case "getPeerCount":
160-
postData(data._seed, eth.getPeerCount())
160+
postData(data._seed, eth.peerCount())
161161

162162
break
163163

164164
case "getTxCountAt":
165165
require(1)
166-
postData(data._seed, eth.getTxCountAt(data.args[0]))
166+
postData(data._seed, eth.txCountAt(data.args[0]))
167167

168168
break
169169

170170
case "getBlockByNumber":
171-
var block = eth.getBlockByNumber(data.args[0])
171+
var block = eth.blockByNumber(data.args[0])
172172
postData(data._seed, block)
173173

174174
break
175175

176176
case "getBlockByHash":
177-
var block = eth.getBlockByHash(data.args[0])
177+
var block = eth.blockByHash(data.args[0])
178178
postData(data._seed, block)
179179

180180
break
@@ -190,35 +190,35 @@ ApplicationWindow {
190190
case "getStorage":
191191
require(2);
192192

193-
var stateObject = eth.getStateObject(data.args[0])
194-
var storage = stateObject.getStorage(data.args[1])
193+
var stateObject = eth.stateObject(data.args[0])
194+
var storage = stateObject.storageAt(data.args[1])
195195
postData(data._seed, storage)
196196

197197
break
198198

199199
case "getEachStorage":
200200
require(1);
201-
var storage = JSON.parse(eth.getEachStorage(data.args[0]))
201+
var storage = JSON.parse(eth.eachStorage(data.args[0]))
202202
postData(data._seed, storage)
203203

204204
break
205205

206206
case "getTransactionsFor":
207207
require(1);
208-
var txs = eth.getTransactionsFor(data.args[0], true)
208+
var txs = eth.transactionsFor(data.args[0], true)
209209
postData(data._seed, txs)
210210

211211
break
212212

213213
case "getBalance":
214214
require(1);
215215

216-
postData(data._seed, eth.getStateObject(data.args[0]).value());
216+
postData(data._seed, eth.stateObject(data.args[0]).value());
217217

218218
break
219219

220220
case "getKey":
221-
var key = eth.getKey().privateKey;
221+
var key = eth.key().privateKey;
222222

223223
postData(data._seed, key)
224224
break

ethereal/assets/wallet.png

1.09 KB
Loading

ethereal/gui.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ func (gui *Gui) readPreviousTransactions() {
334334
}
335335

336336
func (gui *Gui) processBlock(block *ethchain.Block, initial bool) {
337-
//name := ethpub.FindNameInNameReg(gui.eth.StateManager(), block.Coinbase)
338337
name := strings.Trim(gui.pipe.World().Config().Get("NameReg").Storage(block.Coinbase).Str(), "\x00")
339338
b := ethpipe.NewJSBlock(block)
340339
b.Name = name
@@ -491,7 +490,7 @@ func (gui *Gui) setPeerInfo() {
491490
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
492491

493492
gui.win.Root().Call("resetPeers")
494-
for _, peer := range gui.pipe.GetPeers() {
493+
for _, peer := range gui.pipe.Peers() {
495494
gui.win.Root().Call("addPeer", peer)
496495
}
497496
}

javascript/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ type JSEthereum struct {
7373
}
7474

7575
func (self *JSEthereum) GetBlock(hash string) otto.Value {
76-
return self.toVal(&JSBlock{self.JSPipe.GetBlockByHash(hash), self})
76+
return self.toVal(&JSBlock{self.JSPipe.BlockByHash(hash), self})
7777
}
7878

7979
func (self *JSEthereum) GetPeers() otto.Value {
80-
return self.toVal(self.JSPipe.GetPeers())
80+
return self.toVal(self.JSPipe.Peers())
8181
}
8282

8383
func (self *JSEthereum) GetKey() otto.Value {
84-
return self.toVal(self.JSPipe.GetKey())
84+
return self.toVal(self.JSPipe.Key())
8585
}
8686

8787
func (self *JSEthereum) GetStateObject(addr string) otto.Value {

0 commit comments

Comments
 (0)