From a8409b0a8bfa7f8434ede495094fd8d892c28c91 Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 18 Aug 2014 01:35:42 +0200 Subject: [PATCH] Implementing new wallet views --- ethereal/assets/qml/views/history.qml | 7 ++- ethereal/assets/qml/views/info.qml | 2 +- ethereal/assets/qml/views/wallet.qml | 63 +++++++++++++++++++++ ethereal/assets/qml/wallet.qml | 78 ++++++++++++++++++++------ ethereal/assets/qml/webapp.qml | 26 ++++----- ethereal/assets/wallet.png | Bin 0 -> 1114 bytes ethereal/gui.go | 3 +- javascript/types.go | 6 +- 8 files changed, 147 insertions(+), 38 deletions(-) create mode 100644 ethereal/assets/qml/views/wallet.qml create mode 100644 ethereal/assets/wallet.png diff --git a/ethereal/assets/qml/views/history.qml b/ethereal/assets/qml/views/history.qml index 94ea29e61..d8c932f8f 100644 --- a/ethereal/assets/qml/views/history.qml +++ b/ethereal/assets/qml/views/history.qml @@ -11,14 +11,15 @@ Rectangle { property var title: "Transactions" property var menuItem - property var txModel: ListModel { - id: txModel - } id: historyView + visible: false anchors.fill: parent objectName: "transactionView" + property var txModel: ListModel { + id: txModel + } TableView { id: txTableView anchors.fill: parent diff --git a/ethereal/assets/qml/views/info.qml b/ethereal/assets/qml/views/info.qml index c12977cbe..c4486aa6c 100644 --- a/ethereal/assets/qml/views/info.qml +++ b/ethereal/assets/qml/views/info.qml @@ -29,7 +29,7 @@ Rectangle { text: "Address" } TextField { - text: eth.getKey().address + text: eth.key().address width: 500 } diff --git a/ethereal/assets/qml/views/wallet.qml b/ethereal/assets/qml/views/wallet.qml new file mode 100644 index 000000000..22b09640b --- /dev/null +++ b/ethereal/assets/qml/views/wallet.qml @@ -0,0 +1,63 @@ +import QtQuick 2.0 +import QtQuick.Controls 1.0; +import QtQuick.Layouts 1.0; +import QtQuick.Dialogs 1.0; +import QtQuick.Window 2.1; +import QtQuick.Controls.Styles 1.1 +import Ethereum 1.0 + +Rectangle { + id: root + property var title: "Wallet" + property var iconFile: "../wallet.png" + property var menuItem + + objectName: "walletView" + anchors.fill: parent + + function onReady() { + menuItem.secondary = eth.numberToHuman(eth.balanceAt(eth.key().address)) + + } + + ColumnLayout { + spacing: 10 + y: 40 + anchors { + left: parent.left + right: parent.right + } + + Text { + text: "Balance: " + eth.numberToHuman(eth.balanceAt(eth.key().address)) + font.pixelSize: 24 + anchors { + horizontalCenter: parent.horizontalCenter + } + } + + TableView { + id: txTableView + anchors { + left: parent.left + right: parent.right + } + TableViewColumn{ role: "num" ; title: "#" ; width: 30 } + TableViewColumn{ role: "from" ; title: "From" ; width: 280 } + TableViewColumn{ role: "to" ; title: "To" ; width: 280 } + TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 } + + model: ListModel { + id: txModel + Component.onCompleted: { + var messages = JSON.parse(eth.messages({latest: -1, from: "e6716f9544a56c530d868e4bfbacb172315bdead"})) + for(var i = 0; i < messages.length; i++) { + var message = messages[i]; + this.insert(0, {num: i, from: message.from, to: message.to, value: eth.numberToHuman(message.value)}) + } + } + } + } + + } +} diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml index d1039518b..89126f600 100644 --- a/ethereal/assets/qml/wallet.qml +++ b/ethereal/assets/qml/wallet.qml @@ -6,6 +6,7 @@ import QtQuick.Window 2.1; import QtQuick.Controls.Styles 1.1 import Ethereum 1.0 + ApplicationWindow { id: root @@ -30,12 +31,14 @@ ApplicationWindow { // Takes care of loading all default plugins Component.onCompleted: { - var historyView = addPlugin("./views/history.qml", {default: true}) - var newTxView = addPlugin("./views/transaction.qml", {default: true}) - var chainView = addPlugin("./views/chain.qml", {default: true}) - var infoView = addPlugin("./views/info.qml", {default: true}) - var pendingTxView = addPlugin("./views/pending_tx.qml", {default: true}) - var pendingTxView = addPlugin("./views/javascript.qml", {default: true}) + var walletView = addPlugin("./views/wallet.qml", {section: "ethereum"}) + + var historyView = addPlugin("./views/history.qml", {section: "legacy"}) + var newTxView = addPlugin("./views/transaction.qml", {section: "legacy"}) + var chainView = addPlugin("./views/chain.qml", {section: "legacy"}) + var infoView = addPlugin("./views/info.qml", {section: "legacy"}) + var pendingTxView = addPlugin("./views/pending_tx.qml", {section: "legacy"}) + var pendingTxView = addPlugin("./views/javascript.qml", {section: "legacy"}) // Call the ready handler gui.done() @@ -252,10 +255,10 @@ ApplicationWindow { function setView(view, menu) { for(var i = 0; i < views.length; i++) { - views[i][0].visible = false + views[i].view.visible = false - views[i][1].border.color = "#00000000" - views[i][1].color = "#00000000" + views[i].menuItem.border.color = "#00000000" + views[i].menuItem.color = "#00000000" } view.visible = true @@ -265,14 +268,21 @@ ApplicationWindow { function addComponent(component, options) { var view = mainView.createView(component, options) + if(!view.hasOwnProperty("iconFile")) { console.log("Could not load plugin. Property 'iconFile' not found on view."); return; } var menuItem = menu.createMenuItem(view.iconFile, view, options); + if(view.hasOwnProperty("menuItem")) { + view.menuItem = menuItem; + } + mainSplit.views.push({view: view, menuItem: menuItem}); - mainSplit.views.push([view, menuItem]); + if(view.hasOwnProperty("onReady")) { + view.onReady.call(view) + } return view } @@ -294,6 +304,7 @@ ApplicationWindow { property var view; property alias title: label.text + property alias icon: icon.source property alias secondary: secondary.text width: 180 @@ -310,11 +321,13 @@ ApplicationWindow { Image { id: icon + height: 20 + width: 20 anchors { left: parent.left verticalCenter: parent.verticalCenter + leftMargin: 3 } - source: "../pick.png" } Text { @@ -322,10 +335,10 @@ ApplicationWindow { anchors { left: icon.right verticalCenter: parent.verticalCenter + leftMargin: 3 } - text: "Chain" - font.bold: true + //font.bold: true color: "#0D0A01" font.pixelSize: 12 } @@ -355,15 +368,29 @@ ApplicationWindow { options = {}; } - if(options.default) { - var comp = menuItemTemplate.createObject(menuDefault) + var section; + switch(options.section) { + case "ethereum": + section = menuDefault; + break; + case "legacy": + section = menuLegacy; + break; + default: + section = menuApps; + break; } + + var comp = menuItemTemplate.createObject(section) comp.view = view comp.title = view.title + comp.icon = view.iconFile + /* if(view.secondary !== undefined) { comp.secondary = view.secondary } + */ return comp @@ -376,7 +403,7 @@ ApplicationWindow { ColumnLayout { id: menuColumn - y: 30 + y: 10 width: parent.width anchors.left: parent.left anchors.right: parent.right @@ -401,6 +428,25 @@ ApplicationWindow { } } + Text { + text: "LEGACY" + font.bold: true + anchors { + left: parent.left + leftMargin: 5 + } + color: "#888888" + } + + ColumnLayout { + id: menuLegacy + spacing: 3 + anchors { + left: parent.left + right: parent.right + } + } + Text { text: "APPS" font.bold: true diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml index 22e404cc8..ca6860036 100644 --- a/ethereal/assets/qml/webapp.qml +++ b/ethereal/assets/qml/webapp.qml @@ -142,39 +142,39 @@ ApplicationWindow { try { switch(data.call) { case "getCoinBase": - postData(data._seed, eth.getCoinBase()) + postData(data._seed, eth.coinBase()) break case "getIsListening": - postData(data._seed, eth.getIsListening()) + postData(data._seed, eth.isListening()) break case "getIsMining": - postData(data._seed, eth.getIsMining()) + postData(data._seed, eth.isMining()) break case "getPeerCount": - postData(data._seed, eth.getPeerCount()) + postData(data._seed, eth.peerCount()) break case "getTxCountAt": require(1) - postData(data._seed, eth.getTxCountAt(data.args[0])) + postData(data._seed, eth.txCountAt(data.args[0])) break case "getBlockByNumber": - var block = eth.getBlockByNumber(data.args[0]) + var block = eth.blockByNumber(data.args[0]) postData(data._seed, block) break case "getBlockByHash": - var block = eth.getBlockByHash(data.args[0]) + var block = eth.blockByHash(data.args[0]) postData(data._seed, block) break @@ -190,22 +190,22 @@ ApplicationWindow { case "getStorage": require(2); - var stateObject = eth.getStateObject(data.args[0]) - var storage = stateObject.getStorage(data.args[1]) + var stateObject = eth.stateObject(data.args[0]) + var storage = stateObject.storageAt(data.args[1]) postData(data._seed, storage) break case "getEachStorage": require(1); - var storage = JSON.parse(eth.getEachStorage(data.args[0])) + var storage = JSON.parse(eth.eachStorage(data.args[0])) postData(data._seed, storage) break case "getTransactionsFor": require(1); - var txs = eth.getTransactionsFor(data.args[0], true) + var txs = eth.transactionsFor(data.args[0], true) postData(data._seed, txs) break @@ -213,12 +213,12 @@ ApplicationWindow { case "getBalance": require(1); - postData(data._seed, eth.getStateObject(data.args[0]).value()); + postData(data._seed, eth.stateObject(data.args[0]).value()); break case "getKey": - var key = eth.getKey().privateKey; + var key = eth.key().privateKey; postData(data._seed, key) break diff --git a/ethereal/assets/wallet.png b/ethereal/assets/wallet.png new file mode 100644 index 0000000000000000000000000000000000000000..92c401e52c7a6cd0715d15a3db781754c2502b21 GIT binary patch literal 1114 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz#^NA%Cx&(BWL^R}oCO|{#S9GG z!XV7ZFl&wkP(fs7NJL45ua8x7ey(0(N`6wRUPW#JP&EUCO@$SZnVVXYs8ErclUHn2 zVXFjIVFhG^g!Ppaz)DK8ZIvQ?0~DO|i&7O#^-S~(l1AfjnEK zjFOT9D}DX)@^Za$W4-*MbbUihOG|wNBYh(yU7!lx;>x^|#0uTKVr7USFmqf|i<65o z3raHc^AtelCMM;Vme?vOfh>Xph&xL%(-1c06+^uR^q@XSM&D4+Kp$>4P^%3{)XKjo zGZknv$b36P8?Z_gF{nK@`XI}Z90TzwSQO}0J1!f2c(B=V`5aP@WME*L<>}%W62Wu3QbEqBqxd}F1es25UtI9 zI^n5*+PnVO)|SXD=ypj*S=6s(Vd%eHaVnTTO#F;9qqCZXbI5%U#zZ1_54{qgVy3wQXJk5i)8|WRa@AaYVr%K{XzP*3^(Zhjw3>;{US?Vfa3$vJ79ch@TUZfbXKB|~Jhy;}JG zYu*8uA9JkeyQwAjza`G=Rch)VPaBQKP0KiPJ5;tZExgzLWkcqy>xUnH=@&XO7Q|$`f=@_*dwg}r>H7hw^|)NAbi=q qEZ$;S!;C6!@qLqjUWtEx>xcMkfi0_;l5d>>Wq40lKbLh*2~7ZcbjkYw literal 0 HcmV?d00001 diff --git a/ethereal/gui.go b/ethereal/gui.go index 7a36a8b02..1765c3fb2 100644 --- a/ethereal/gui.go +++ b/ethereal/gui.go @@ -334,7 +334,6 @@ func (gui *Gui) readPreviousTransactions() { } func (gui *Gui) processBlock(block *ethchain.Block, initial bool) { - //name := ethpub.FindNameInNameReg(gui.eth.StateManager(), block.Coinbase) name := strings.Trim(gui.pipe.World().Config().Get("NameReg").Storage(block.Coinbase).Str(), "\x00") b := ethpipe.NewJSBlock(block) b.Name = name @@ -491,7 +490,7 @@ func (gui *Gui) setPeerInfo() { gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers)) gui.win.Root().Call("resetPeers") - for _, peer := range gui.pipe.GetPeers() { + for _, peer := range gui.pipe.Peers() { gui.win.Root().Call("addPeer", peer) } } diff --git a/javascript/types.go b/javascript/types.go index 3a11e644b..afa0a41c6 100644 --- a/javascript/types.go +++ b/javascript/types.go @@ -73,15 +73,15 @@ type JSEthereum struct { } func (self *JSEthereum) GetBlock(hash string) otto.Value { - return self.toVal(&JSBlock{self.JSPipe.GetBlockByHash(hash), self}) + return self.toVal(&JSBlock{self.JSPipe.BlockByHash(hash), self}) } func (self *JSEthereum) GetPeers() otto.Value { - return self.toVal(self.JSPipe.GetPeers()) + return self.toVal(self.JSPipe.Peers()) } func (self *JSEthereum) GetKey() otto.Value { - return self.toVal(self.JSPipe.GetKey()) + return self.toVal(self.JSPipe.Key()) } func (self *JSEthereum) GetStateObject(addr string) otto.Value {