Skip to content

Commit ecc2c60

Browse files
committed
Implemented QML message filtering
1 parent a8409b0 commit ecc2c60

File tree

5 files changed

+673
-464
lines changed

5 files changed

+673
-464
lines changed

ethereal/assets/ext/filter.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var Filter = function(eth, options) {
2+
this.callbacks = {};
3+
this.seed = Math.floor(Math.random() * 1000000);
4+
this.eth = eth;
5+
6+
eth.registerFilter(options, this.seed);
7+
};
8+
9+
Filter.prototype.changed = function(callback) {
10+
var cbseed = Math.floor(Math.random() * 1000000);
11+
this.eth.registerFilterCallback(this.seed, cbseed);
12+
13+
var self = this;
14+
message.connect(function(messages, seed, callbackSeed) {
15+
if(seed == self.seed && callbackSeed == cbseed) {
16+
callback.call(self, messages);
17+
}
18+
});
19+
};
20+
21+
Filter.prototype.uninstall = function() {
22+
eth.uninstallFilter(this.seed)
23+
}

ethereal/assets/qml/views/wallet.qml

Lines changed: 120 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,145 @@ Rectangle {
1717

1818
function onReady() {
1919
menuItem.secondary = eth.numberToHuman(eth.balanceAt(eth.key().address))
20+
}
2021

22+
ListModel {
23+
id: denomModel
24+
ListElement { text: "Wei" ; zeros: "" }
25+
ListElement { text: "Ada" ; zeros: "000" }
26+
ListElement { text: "Babbage" ; zeros: "000000" }
27+
ListElement { text: "Shannon" ; zeros: "000000000" }
28+
ListElement { text: "Szabo" ; zeros: "000000000000" }
29+
ListElement { text: "Finney" ; zeros: "000000000000000" }
30+
ListElement { text: "Ether" ; zeros: "000000000000000000" }
31+
ListElement { text: "Einstein" ;zeros: "000000000000000000000" }
32+
ListElement { text: "Douglas" ; zeros: "000000000000000000000000000000000000000000" }
2133
}
2234

2335
ColumnLayout {
2436
spacing: 10
2537
y: 40
26-
anchors {
27-
left: parent.left
28-
right: parent.right
29-
}
38+
anchors.fill: parent
3039

3140
Text {
41+
id: balance
3242
text: "<b>Balance</b>: " + eth.numberToHuman(eth.balanceAt(eth.key().address))
3343
font.pixelSize: 24
3444
anchors {
3545
horizontalCenter: parent.horizontalCenter
46+
top: parent.top
47+
topMargin: 20
3648
}
3749
}
3850

39-
TableView {
40-
id: txTableView
51+
Rectangle {
52+
id: newTxPane
53+
color: "#ececec"
54+
border.color: "#cccccc"
55+
border.width: 1
4156
anchors {
57+
top: balance.bottom
58+
topMargin: 10
4259
left: parent.left
60+
leftMargin: 5
4361
right: parent.right
62+
rightMargin: 5
63+
}
64+
height: 100
65+
66+
RowLayout {
67+
id: amountFields
68+
spacing: 10
69+
anchors {
70+
top: parent.top
71+
topMargin: 20
72+
left: parent.left
73+
leftMargin: 20
74+
}
75+
76+
Text {
77+
text: "Ξ "
78+
}
79+
80+
// There's something off with the row layout where textfields won't listen to the width setting
81+
Rectangle {
82+
width: 50
83+
height: 20
84+
TextField {
85+
id: txValue
86+
width: parent.width
87+
placeholderText: "0.00"
88+
}
89+
}
90+
91+
ComboBox {
92+
id: valueDenom
93+
currentIndex: 6
94+
model: denomModel
95+
}
96+
4497
}
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)})
98+
99+
RowLayout {
100+
id: toFields
101+
spacing: 10
102+
anchors {
103+
top: amountFields.bottom
104+
topMargin: 5
105+
left: parent.left
106+
leftMargin: 20
107+
}
108+
109+
Text {
110+
text: "To"
111+
}
112+
113+
Rectangle {
114+
width: 200
115+
height: 20
116+
TextField {
117+
id: txTo
118+
width: parent.width
119+
placeholderText: "Address or name"
120+
}
121+
}
122+
123+
Button {
124+
text: "Send"
125+
onClicked: {
126+
var value = txValue.text + denomModel.get(valueDenom.currentIndex).zeros;
127+
var gasPrice = "10000000000000"
128+
var res = eth.transact(eth.key().privateKey, txTo.text, value, "500", gasPrice, "")
129+
console.log(res)
130+
}
131+
}
132+
}
133+
}
134+
135+
Rectangle {
136+
anchors {
137+
left: parent.left
138+
right: parent.right
139+
top: newTxPane.bottom
140+
topMargin: 10
141+
bottom: parent.bottom
142+
}
143+
TableView {
144+
id: txTableView
145+
anchors.fill : parent
146+
TableViewColumn{ role: "num" ; title: "#" ; width: 30 }
147+
TableViewColumn{ role: "from" ; title: "From" ; width: 280 }
148+
TableViewColumn{ role: "to" ; title: "To" ; width: 280 }
149+
TableViewColumn{ role: "value" ; title: "Amount" ; width: 100 }
150+
151+
model: ListModel {
152+
id: txModel
153+
Component.onCompleted: {
154+
var messages = JSON.parse(eth.messages({latest: -1, from: "e6716f9544a56c530d868e4bfbacb172315bdead"}))
155+
for(var i = 0; i < messages.length; i++) {
156+
var message = messages[i];
157+
this.insert(0, {num: i, from: message.from, to: message.to, value: eth.numberToHuman(message.value)})
158+
}
57159
}
58160
}
59161
}

0 commit comments

Comments
 (0)