2014-08-17 18:35:42 -05:00
|
|
|
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"
|
2014-09-18 04:27:55 -05:00
|
|
|
property var iconSource: "../facet.png"
|
2014-08-17 18:35:42 -05:00
|
|
|
property var menuItem
|
|
|
|
|
|
|
|
objectName: "walletView"
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
function onReady() {
|
2014-12-02 15:23:20 -06:00
|
|
|
setBalance()
|
|
|
|
}
|
|
|
|
|
|
|
|
function setBalance() {
|
|
|
|
balance.text = "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.key().address))
|
|
|
|
if(menuItem)
|
|
|
|
menuItem.secondaryTitle = eth.numberToHuman(eth.balanceAt(eth.key().address))
|
2014-08-20 03:00:02 -05:00
|
|
|
}
|
2014-08-17 18:35:42 -05:00
|
|
|
|
2014-08-20 03:00:02 -05:00
|
|
|
ListModel {
|
|
|
|
id: denomModel
|
|
|
|
ListElement { text: "Wei" ; zeros: "" }
|
|
|
|
ListElement { text: "Ada" ; zeros: "000" }
|
|
|
|
ListElement { text: "Babbage" ; zeros: "000000" }
|
|
|
|
ListElement { text: "Shannon" ; zeros: "000000000" }
|
|
|
|
ListElement { text: "Szabo" ; zeros: "000000000000" }
|
|
|
|
ListElement { text: "Finney" ; zeros: "000000000000000" }
|
|
|
|
ListElement { text: "Ether" ; zeros: "000000000000000000" }
|
|
|
|
ListElement { text: "Einstein" ;zeros: "000000000000000000000" }
|
|
|
|
ListElement { text: "Douglas" ; zeros: "000000000000000000000000000000000000000000" }
|
2014-08-17 18:35:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
spacing: 10
|
|
|
|
y: 40
|
2014-08-20 03:00:02 -05:00
|
|
|
anchors.fill: parent
|
2014-08-17 18:35:42 -05:00
|
|
|
|
|
|
|
Text {
|
2014-08-20 03:00:02 -05:00
|
|
|
id: balance
|
2014-08-17 18:35:42 -05:00
|
|
|
font.pixelSize: 24
|
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
2014-08-20 03:00:02 -05:00
|
|
|
top: parent.top
|
|
|
|
topMargin: 20
|
2014-08-17 18:35:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-20 03:00:02 -05:00
|
|
|
Rectangle {
|
|
|
|
id: newTxPane
|
|
|
|
color: "#ececec"
|
|
|
|
border.color: "#cccccc"
|
|
|
|
border.width: 1
|
2014-08-17 18:35:42 -05:00
|
|
|
anchors {
|
2014-08-20 03:00:02 -05:00
|
|
|
top: balance.bottom
|
|
|
|
topMargin: 10
|
2014-08-17 18:35:42 -05:00
|
|
|
left: parent.left
|
2014-08-20 03:00:02 -05:00
|
|
|
leftMargin: 5
|
2014-08-17 18:35:42 -05:00
|
|
|
right: parent.right
|
2014-08-20 03:00:02 -05:00
|
|
|
rightMargin: 5
|
|
|
|
}
|
|
|
|
height: 100
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: amountFields
|
|
|
|
spacing: 10
|
|
|
|
anchors {
|
|
|
|
top: parent.top
|
|
|
|
topMargin: 20
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: 20
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: "Ξ "
|
|
|
|
}
|
|
|
|
|
|
|
|
// There's something off with the row layout where textfields won't listen to the width setting
|
|
|
|
Rectangle {
|
|
|
|
width: 50
|
|
|
|
height: 20
|
|
|
|
TextField {
|
|
|
|
id: txValue
|
|
|
|
width: parent.width
|
|
|
|
placeholderText: "0.00"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ComboBox {
|
|
|
|
id: valueDenom
|
|
|
|
currentIndex: 6
|
|
|
|
model: denomModel
|
|
|
|
}
|
|
|
|
|
2014-08-17 18:35:42 -05:00
|
|
|
}
|
2014-08-20 03:00:02 -05:00
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: toFields
|
|
|
|
spacing: 10
|
|
|
|
anchors {
|
|
|
|
top: amountFields.bottom
|
|
|
|
topMargin: 5
|
|
|
|
left: parent.left
|
|
|
|
leftMargin: 20
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
text: "To"
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
width: 200
|
|
|
|
height: 20
|
|
|
|
TextField {
|
|
|
|
id: txTo
|
|
|
|
width: parent.width
|
|
|
|
placeholderText: "Address or name"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: "Send"
|
|
|
|
onClicked: {
|
|
|
|
var value = txValue.text + denomModel.get(valueDenom.currentIndex).zeros;
|
|
|
|
var gasPrice = "10000000000000"
|
2014-08-20 06:36:32 -05:00
|
|
|
var res = eth.transact({from: eth.key().privateKey, to: txTo.text, value: value, gas: "500", gasPrice: gasPrice})
|
2014-08-20 03:00:02 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
right: parent.right
|
|
|
|
top: newTxPane.bottom
|
|
|
|
topMargin: 10
|
|
|
|
bottom: parent.bottom
|
|
|
|
}
|
|
|
|
TableView {
|
|
|
|
id: txTableView
|
|
|
|
anchors.fill : parent
|
|
|
|
TableViewColumn{ role: "num" ; title: "#" ; width: 30 }
|
2014-12-04 10:09:47 -06:00
|
|
|
TableViewColumn{ role: "from" ; title: "From" ; width: 340 }
|
|
|
|
TableViewColumn{ role: "to" ; title: "To" ; width: 340 }
|
2014-08-20 03:00:02 -05:00
|
|
|
TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 }
|
|
|
|
|
|
|
|
model: ListModel {
|
|
|
|
id: txModel
|
|
|
|
Component.onCompleted: {
|
2014-12-04 09:44:43 -06:00
|
|
|
var me = eth.key().address;
|
|
|
|
var filterTo = ethx.watch({latest: -1, to: me});
|
|
|
|
var filterFrom = ethx.watch({latest: -1, from: me});
|
|
|
|
filterTo.changed(addTxs)
|
|
|
|
filterFrom.changed(addTxs)
|
|
|
|
|
|
|
|
addTxs(filterTo.messages())
|
|
|
|
addTxs(filterFrom.messages())
|
2014-08-25 06:13:46 -05:00
|
|
|
}
|
2014-09-07 17:50:25 -05:00
|
|
|
|
2014-08-25 06:13:46 -05:00
|
|
|
function addTxs(messages) {
|
2014-12-02 15:23:20 -06:00
|
|
|
setBalance()
|
|
|
|
|
2014-08-20 03:00:02 -05:00
|
|
|
for(var i = 0; i < messages.length; i++) {
|
2014-09-13 17:13:47 -05:00
|
|
|
var message = messages.get(i);
|
2014-09-25 03:33:05 -05:00
|
|
|
var to = eth.lookupName(message.to);
|
2014-12-04 09:44:43 -06:00
|
|
|
var from;
|
|
|
|
if(message.from.length == 0) {
|
|
|
|
from = "- MINED -";
|
|
|
|
} else {
|
|
|
|
from = eth.lookupName(message.from);
|
|
|
|
}
|
2014-09-25 03:33:05 -05:00
|
|
|
txModel.insert(0, {num: txModel.count, from: from, to: to, value: eth.numberToHuman(message.value)})
|
2014-08-20 03:00:02 -05:00
|
|
|
}
|
2014-08-17 18:35:42 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|