aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ethereal/assets/ext/ethereum.js33
-rw-r--r--ethereal/assets/qml/wallet.qml55
-rw-r--r--ethereal/assets/qml/webapp.qml8
-rw-r--r--ethereal/ext_app.go52
-rw-r--r--ethereal/gui.go14
5 files changed, 133 insertions, 29 deletions
diff --git a/ethereal/assets/ext/ethereum.js b/ethereal/assets/ext/ethereum.js
index 9970c6379..5b8fb54f3 100644
--- a/ethereal/assets/ext/ethereum.js
+++ b/ethereal/assets/ext/ethereum.js
@@ -95,6 +95,10 @@ window.eth = {
postData({call: "transact", args: [params.from, params.to, params.value, params.gas, params.gasPrice, "0x"+data]}, cb);
},
+ getMessages: function(filter, cb) {
+ postData({call: "messages", args: [filter]}, cb);
+ },
+
getStorageAt: function(address, storageAddress, cb) {
postData({call: "getStorage", args: [address, storageAddress]}, cb);
},
@@ -209,4 +213,33 @@ window.eth = {
}
window.eth._callbacks = {}
window.eth._onCallbacks = {}
+function postData(data, cb) {
+ data._seed = Math.floor(Math.random() * 1000000)
+ if(cb) {
+ eth._callbacks[data._seed] = cb;
+ }
+
+ if(data.args === undefined) {
+ data.args = [];
+ }
+
+ navigator.qt.postMessage(JSON.stringify(data));
+}
+navigator.qt.onmessage = function(ev) {
+ var data = JSON.parse(ev.data)
+
+ if(data._event !== undefined) {
+ eth.trigger(data._event, data.data);
+ } else {
+ if(data._seed) {
+ var cb = eth._callbacks[data._seed];
+ if(cb) {
+ cb.call(this, data.data)
+
+ // Remove the "trigger" callback
+ delete eth._callbacks[ev._seed];
+ }
+ }
+ }
+}
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index 769edfc6a..b35500209 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -98,7 +98,7 @@ ApplicationWindow {
MenuItem {
text: "Debugger"
shortcut: "Ctrl+d"
- onTriggered: ui.startDebugger()
+ onTriggered: eth.startDebugger()
}
MenuItem {
@@ -282,9 +282,10 @@ ApplicationWindow {
/*
Component {
id: menuItemTemplate
- Rectangle {
+
+ RowLayout {
property var view;
- property var source;
+ property alias source: icon.source;
property alias title: title.text
height: 25
@@ -295,11 +296,9 @@ ApplicationWindow {
right: parent.right
}
- Label {
- id: title
- y: parent.height / 2 - this.height / 2
- x: 5
- font.pixelSize: 10
+ Image {
+ id: icon
+ //anchors.horizontalCenter: parent.horizontalCenter
}
MouseArea {
@@ -309,21 +308,32 @@ ApplicationWindow {
}
}
- Image {
- id: closeButton
- y: parent.height / 2 - this.height / 2
- visible: false
-
- source: "../close.png"
- anchors {
- right: parent.right
- rightMargin: 5
+ Rectangle {
+ color: "#bbbbbb"
+ Label {
+ id: title
+ y: parent.height / 2 - this.height / 2
+ //x: 5
+ font.pixelSize: 10
}
- MouseArea {
- anchors.fill: parent
- onClicked: {
- console.log("should close")
+
+ Image {
+ id: closeButton
+ y: parent.height / 2 - this.height / 2
+ visible: false
+
+ source: "../close.png"
+ anchors {
+ right: parent.right
+ rightMargin: 5
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ console.log("should close")
+ }
}
}
}
@@ -331,7 +341,6 @@ ApplicationWindow {
}
*/
-
function createMenuItem(icon, view, options) {
if(options === undefined) {
options = {};
@@ -340,8 +349,8 @@ ApplicationWindow {
var comp = menuItemTemplate.createObject(menuColumn)
comp.view = view
comp.source = icon
+ //comp.title = options.title
/*
- comp.title = options.title
if(options.canClose) {
//comp.closeButton.visible = options.canClose
}
diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml
index a0ec52752..48b410787 100644
--- a/ethereal/assets/qml/webapp.qml
+++ b/ethereal/assets/qml/webapp.qml
@@ -238,6 +238,14 @@ ApplicationWindow {
break;
+ case "messages":
+ require(1);
+
+ var messages = JSON.parse(eth.getMessages(data.args[0]))
+ postData(data._seed, messages)
+
+ break
+
case "debug":
console.log(data.args[0]);
break;
diff --git a/ethereal/ext_app.go b/ethereal/ext_app.go
index 697630504..4533b2438 100644
--- a/ethereal/ext_app.go
+++ b/ethereal/ext_app.go
@@ -1,11 +1,14 @@
package main
import (
+ "encoding/json"
+
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethstate"
"github.com/ethereum/eth-go/ethutil"
+ "github.com/ethereum/go-ethereum/javascript"
"github.com/go-qml/qml"
)
@@ -24,6 +27,7 @@ type AppContainer interface {
type ExtApplication struct {
*ethpub.PEthereum
+ eth ethchain.EthManager
blockChan chan ethreact.Event
changeChan chan ethreact.Event
@@ -38,6 +42,7 @@ type ExtApplication struct {
func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
app := &ExtApplication{
ethpub.NewPEthereum(lib.eth),
+ lib.eth,
make(chan ethreact.Event, 100),
make(chan ethreact.Event, 100),
make(chan bool),
@@ -130,3 +135,50 @@ func (app *ExtApplication) Watch(addr, storageAddr string) {
app.registeredEvents = append(app.registeredEvents, event)
}
+
+func (self *ExtApplication) GetMessages(object map[string]interface{}) string {
+ filter := ethchain.NewFilter(self.eth)
+
+ if object["earliest"] != nil {
+ earliest := object["earliest"]
+ if e, ok := earliest.(string); ok {
+ filter.SetEarliestBlock(ethutil.Hex2Bytes(e))
+ } else {
+ filter.SetEarliestBlock(earliest)
+ }
+ }
+
+ if object["latest"] != nil {
+ latest := object["latest"]
+ if l, ok := latest.(string); ok {
+ filter.SetLatestBlock(ethutil.Hex2Bytes(l))
+ } else {
+ filter.SetLatestBlock(latest)
+ }
+ }
+ if object["to"] != nil {
+ filter.AddTo(ethutil.Hex2Bytes(object["to"].(string)))
+ }
+ if object["from"] != nil {
+ filter.AddFrom(ethutil.Hex2Bytes(object["from"].(string)))
+ }
+ if object["max"] != nil {
+ filter.SetMax(object["max"].(int))
+ }
+ if object["skip"] != nil {
+ filter.SetSkip(object["skip"].(int))
+ }
+
+ messages := filter.Find()
+ var msgs []javascript.JSMessage
+ for _, m := range messages {
+ msgs = append(msgs, javascript.NewJSMessage(m))
+ }
+
+ b, err := json.Marshal(msgs)
+ if err != nil {
+ return "{\"error\":" + err.Error() + "}"
+ }
+
+ return string(b)
+}
diff --git a/ethereal/gui.go b/ethereal/gui.go
index d191f67d0..276c1a348 100644
--- a/ethereal/gui.go
+++ b/ethereal/gui.go
@@ -515,11 +515,13 @@ func (gui *Gui) Printf(format string, v ...interface{}) {
// Print function that logs directly to the GUI
func (gui *Gui) printLog(s string) {
- str := strings.TrimRight(s, "\n")
- lines := strings.Split(str, "\n")
+ /*
+ str := strings.TrimRight(s, "\n")
+ lines := strings.Split(str, "\n")
- view := gui.getObjectByName("infoView")
- for _, line := range lines {
- view.Call("addLog", line)
- }
+ view := gui.getObjectByName("infoView")
+ for _, line := range lines {
+ view.Call("addLog", line)
+ }
+ */
}