mirror of https://github.com/status-im/op-geth.git
Implementing new wallet views
This commit is contained in:
parent
5ae3deea86
commit
a8409b0a8b
|
@ -11,14 +11,15 @@ Rectangle {
|
||||||
property var title: "Transactions"
|
property var title: "Transactions"
|
||||||
property var menuItem
|
property var menuItem
|
||||||
|
|
||||||
property var txModel: ListModel {
|
|
||||||
id: txModel
|
|
||||||
}
|
|
||||||
|
|
||||||
id: historyView
|
id: historyView
|
||||||
|
visible: false
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
objectName: "transactionView"
|
objectName: "transactionView"
|
||||||
|
|
||||||
|
property var txModel: ListModel {
|
||||||
|
id: txModel
|
||||||
|
}
|
||||||
TableView {
|
TableView {
|
||||||
id: txTableView
|
id: txTableView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -29,7 +29,7 @@ Rectangle {
|
||||||
text: "Address"
|
text: "Address"
|
||||||
}
|
}
|
||||||
TextField {
|
TextField {
|
||||||
text: eth.getKey().address
|
text: eth.key().address
|
||||||
width: 500
|
width: 500
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: "<b>Balance</b>: " + 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)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import QtQuick.Window 2.1;
|
||||||
import QtQuick.Controls.Styles 1.1
|
import QtQuick.Controls.Styles 1.1
|
||||||
import Ethereum 1.0
|
import Ethereum 1.0
|
||||||
|
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
@ -30,12 +31,14 @@ ApplicationWindow {
|
||||||
|
|
||||||
// Takes care of loading all default plugins
|
// Takes care of loading all default plugins
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
var historyView = addPlugin("./views/history.qml", {default: true})
|
var walletView = addPlugin("./views/wallet.qml", {section: "ethereum"})
|
||||||
var newTxView = addPlugin("./views/transaction.qml", {default: true})
|
|
||||||
var chainView = addPlugin("./views/chain.qml", {default: true})
|
var historyView = addPlugin("./views/history.qml", {section: "legacy"})
|
||||||
var infoView = addPlugin("./views/info.qml", {default: true})
|
var newTxView = addPlugin("./views/transaction.qml", {section: "legacy"})
|
||||||
var pendingTxView = addPlugin("./views/pending_tx.qml", {default: true})
|
var chainView = addPlugin("./views/chain.qml", {section: "legacy"})
|
||||||
var pendingTxView = addPlugin("./views/javascript.qml", {default: true})
|
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
|
// Call the ready handler
|
||||||
gui.done()
|
gui.done()
|
||||||
|
@ -252,10 +255,10 @@ ApplicationWindow {
|
||||||
|
|
||||||
function setView(view, menu) {
|
function setView(view, menu) {
|
||||||
for(var i = 0; i < views.length; i++) {
|
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].menuItem.border.color = "#00000000"
|
||||||
views[i][1].color = "#00000000"
|
views[i].menuItem.color = "#00000000"
|
||||||
}
|
}
|
||||||
view.visible = true
|
view.visible = true
|
||||||
|
|
||||||
|
@ -265,14 +268,21 @@ ApplicationWindow {
|
||||||
|
|
||||||
function addComponent(component, options) {
|
function addComponent(component, options) {
|
||||||
var view = mainView.createView(component, options)
|
var view = mainView.createView(component, options)
|
||||||
|
|
||||||
if(!view.hasOwnProperty("iconFile")) {
|
if(!view.hasOwnProperty("iconFile")) {
|
||||||
console.log("Could not load plugin. Property 'iconFile' not found on view.");
|
console.log("Could not load plugin. Property 'iconFile' not found on view.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var menuItem = menu.createMenuItem(view.iconFile, view, options);
|
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
|
return view
|
||||||
}
|
}
|
||||||
|
@ -294,6 +304,7 @@ ApplicationWindow {
|
||||||
property var view;
|
property var view;
|
||||||
|
|
||||||
property alias title: label.text
|
property alias title: label.text
|
||||||
|
property alias icon: icon.source
|
||||||
property alias secondary: secondary.text
|
property alias secondary: secondary.text
|
||||||
|
|
||||||
width: 180
|
width: 180
|
||||||
|
@ -310,11 +321,13 @@ ApplicationWindow {
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: icon
|
id: icon
|
||||||
|
height: 20
|
||||||
|
width: 20
|
||||||
anchors {
|
anchors {
|
||||||
left: parent.left
|
left: parent.left
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
|
leftMargin: 3
|
||||||
}
|
}
|
||||||
source: "../pick.png"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
|
@ -322,10 +335,10 @@ ApplicationWindow {
|
||||||
anchors {
|
anchors {
|
||||||
left: icon.right
|
left: icon.right
|
||||||
verticalCenter: parent.verticalCenter
|
verticalCenter: parent.verticalCenter
|
||||||
|
leftMargin: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
text: "Chain"
|
//font.bold: true
|
||||||
font.bold: true
|
|
||||||
color: "#0D0A01"
|
color: "#0D0A01"
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
}
|
}
|
||||||
|
@ -355,15 +368,29 @@ ApplicationWindow {
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options.default) {
|
var section;
|
||||||
var comp = menuItemTemplate.createObject(menuDefault)
|
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.view = view
|
||||||
comp.title = view.title
|
comp.title = view.title
|
||||||
|
comp.icon = view.iconFile
|
||||||
|
/*
|
||||||
if(view.secondary !== undefined) {
|
if(view.secondary !== undefined) {
|
||||||
comp.secondary = view.secondary
|
comp.secondary = view.secondary
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return comp
|
return comp
|
||||||
|
|
||||||
|
@ -376,7 +403,7 @@ ApplicationWindow {
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: menuColumn
|
id: menuColumn
|
||||||
y: 30
|
y: 10
|
||||||
width: parent.width
|
width: parent.width
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
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 {
|
||||||
text: "APPS"
|
text: "APPS"
|
||||||
font.bold: true
|
font.bold: true
|
||||||
|
|
|
@ -142,39 +142,39 @@ ApplicationWindow {
|
||||||
try {
|
try {
|
||||||
switch(data.call) {
|
switch(data.call) {
|
||||||
case "getCoinBase":
|
case "getCoinBase":
|
||||||
postData(data._seed, eth.getCoinBase())
|
postData(data._seed, eth.coinBase())
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getIsListening":
|
case "getIsListening":
|
||||||
postData(data._seed, eth.getIsListening())
|
postData(data._seed, eth.isListening())
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getIsMining":
|
case "getIsMining":
|
||||||
postData(data._seed, eth.getIsMining())
|
postData(data._seed, eth.isMining())
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getPeerCount":
|
case "getPeerCount":
|
||||||
postData(data._seed, eth.getPeerCount())
|
postData(data._seed, eth.peerCount())
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getTxCountAt":
|
case "getTxCountAt":
|
||||||
require(1)
|
require(1)
|
||||||
postData(data._seed, eth.getTxCountAt(data.args[0]))
|
postData(data._seed, eth.txCountAt(data.args[0]))
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getBlockByNumber":
|
case "getBlockByNumber":
|
||||||
var block = eth.getBlockByNumber(data.args[0])
|
var block = eth.blockByNumber(data.args[0])
|
||||||
postData(data._seed, block)
|
postData(data._seed, block)
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getBlockByHash":
|
case "getBlockByHash":
|
||||||
var block = eth.getBlockByHash(data.args[0])
|
var block = eth.blockByHash(data.args[0])
|
||||||
postData(data._seed, block)
|
postData(data._seed, block)
|
||||||
|
|
||||||
break
|
break
|
||||||
|
@ -190,22 +190,22 @@ ApplicationWindow {
|
||||||
case "getStorage":
|
case "getStorage":
|
||||||
require(2);
|
require(2);
|
||||||
|
|
||||||
var stateObject = eth.getStateObject(data.args[0])
|
var stateObject = eth.stateObject(data.args[0])
|
||||||
var storage = stateObject.getStorage(data.args[1])
|
var storage = stateObject.storageAt(data.args[1])
|
||||||
postData(data._seed, storage)
|
postData(data._seed, storage)
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getEachStorage":
|
case "getEachStorage":
|
||||||
require(1);
|
require(1);
|
||||||
var storage = JSON.parse(eth.getEachStorage(data.args[0]))
|
var storage = JSON.parse(eth.eachStorage(data.args[0]))
|
||||||
postData(data._seed, storage)
|
postData(data._seed, storage)
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getTransactionsFor":
|
case "getTransactionsFor":
|
||||||
require(1);
|
require(1);
|
||||||
var txs = eth.getTransactionsFor(data.args[0], true)
|
var txs = eth.transactionsFor(data.args[0], true)
|
||||||
postData(data._seed, txs)
|
postData(data._seed, txs)
|
||||||
|
|
||||||
break
|
break
|
||||||
|
@ -213,12 +213,12 @@ ApplicationWindow {
|
||||||
case "getBalance":
|
case "getBalance":
|
||||||
require(1);
|
require(1);
|
||||||
|
|
||||||
postData(data._seed, eth.getStateObject(data.args[0]).value());
|
postData(data._seed, eth.stateObject(data.args[0]).value());
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
case "getKey":
|
case "getKey":
|
||||||
var key = eth.getKey().privateKey;
|
var key = eth.key().privateKey;
|
||||||
|
|
||||||
postData(data._seed, key)
|
postData(data._seed, key)
|
||||||
break
|
break
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -334,7 +334,6 @@ func (gui *Gui) readPreviousTransactions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) processBlock(block *ethchain.Block, initial bool) {
|
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")
|
name := strings.Trim(gui.pipe.World().Config().Get("NameReg").Storage(block.Coinbase).Str(), "\x00")
|
||||||
b := ethpipe.NewJSBlock(block)
|
b := ethpipe.NewJSBlock(block)
|
||||||
b.Name = name
|
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("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
|
||||||
|
|
||||||
gui.win.Root().Call("resetPeers")
|
gui.win.Root().Call("resetPeers")
|
||||||
for _, peer := range gui.pipe.GetPeers() {
|
for _, peer := range gui.pipe.Peers() {
|
||||||
gui.win.Root().Call("addPeer", peer)
|
gui.win.Root().Call("addPeer", peer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,15 +73,15 @@ type JSEthereum struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSEthereum) GetBlock(hash string) otto.Value {
|
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 {
|
func (self *JSEthereum) GetPeers() otto.Value {
|
||||||
return self.toVal(self.JSPipe.GetPeers())
|
return self.toVal(self.JSPipe.Peers())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSEthereum) GetKey() otto.Value {
|
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 {
|
func (self *JSEthereum) GetStateObject(addr string) otto.Value {
|
||||||
|
|
Loading…
Reference in New Issue