From d5d1e503652cc6c53a265404d8fdda53fad58fa8 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 25 Sep 2014 10:32:54 +0200 Subject: [PATCH 1/6] Support multiple promises as data or mixed with non promises --- mist/assets/ext/html_messaging.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/mist/assets/ext/html_messaging.js b/mist/assets/ext/html_messaging.js index efb950b4b234..0bedba99749f 100644 --- a/mist/assets/ext/html_messaging.js +++ b/mist/assets/ext/html_messaging.js @@ -92,19 +92,19 @@ promises.push(params.from.then(function(_from) { params.from = _from; })); } - if(isPromise(params.data)) { - promises.push(params.data.then(function(_code) { params.data = _code; })); - } else { - if(typeof params.data === "object") { - data = ""; - for(var i = 0; i < params.data.length; i++) { - data += params.data[i] - } - } else { - data = params.data; - } - } - + if(typeof params.data !== "object" || isPromise(params.data)) { + params.data = [params.data] + } + + var data = params.data; + for(var i = 0; i < params.data.length; i++) { + if(isPromise(params.data[i])) { + var promise = params.data[i]; + var _i = i; + promises.push(promise.then(function(_arg) { params.data[_i] = _arg; })); + } + } + // Make sure everything is string var fields = ["value", "gas", "gasPrice"]; for(var i = 0; i < fields.length; i++) { @@ -117,6 +117,7 @@ // Load promises then call the last "transact". return Q.all(promises).then(function() { return new Promise(function(resolve, reject) { + params.data = params.data.join(""); postData({call: "transact", args: params}, function(data) { if(data[1]) reject(data[0]); @@ -458,6 +459,7 @@ g_seed++; + console.log(data) navigator.qt.postMessage(JSON.stringify(data)); } From dc944f75186bbee08ad8cd1dad8a296dc71f99bc Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 25 Sep 2014 10:33:05 +0200 Subject: [PATCH 2/6] Added some lookup helper methods for name reg --- mist/assets/qml/views/jeffcoin/jeffcoin.qml | 8 ++++++- mist/assets/qml/views/wallet.qml | 4 +++- mist/ui_lib.go | 26 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/mist/assets/qml/views/jeffcoin/jeffcoin.qml b/mist/assets/qml/views/jeffcoin/jeffcoin.qml index 6506b53b86ff..23502d334460 100644 --- a/mist/assets/qml/views/jeffcoin/jeffcoin.qml +++ b/mist/assets/qml/views/jeffcoin/jeffcoin.qml @@ -22,6 +22,8 @@ Rectangle { var me = eth.key().address; if((to == me|| from == me) && message.input.length == 128) { + var to = eth.lookupName(to) + var from = eth.lookupName(from) txModel.insert(0, {confirmations: blockNumber - message.number, from: from, to: to, value: value}) } } @@ -151,7 +153,11 @@ Rectangle { Button { text: "Send" onClicked: { - eth.transact({from: eth.key().privateKey, to:address, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]}) + var lookup = eth.lookupAddress(address) + if(lookup.length == 0) + lookup = address + + eth.transact({from: eth.key().privateKey, to:lookup, gas: "9000", gasPrice: "10000000000000", data: ["0x"+txTo.text, txValue.text]}) } } } diff --git a/mist/assets/qml/views/wallet.qml b/mist/assets/qml/views/wallet.qml index a3a4a6e7caca..a57e7869ab21 100644 --- a/mist/assets/qml/views/wallet.qml +++ b/mist/assets/qml/views/wallet.qml @@ -160,7 +160,9 @@ Rectangle { function addTxs(messages) { for(var i = 0; i < messages.length; i++) { var message = messages.get(i); - txModel.insert(0, {num: txModel.count, from: message.from, to: message.to, value: eth.numberToHuman(message.value)}) + var to = eth.lookupName(message.to); + var from = eth.lookupName(message.from); + txModel.insert(0, {num: txModel.count, from: from, to: to, value: eth.numberToHuman(message.value)}) } } } diff --git a/mist/ui_lib.go b/mist/ui_lib.go index e1963aa86f14..e77336c908e9 100644 --- a/mist/ui_lib.go +++ b/mist/ui_lib.go @@ -71,6 +71,32 @@ func (self *UiLib) LookupDomain(domain string) string { } } +func (self *UiLib) LookupName(addr string) string { + var ( + nameReg = self.World().Config().Get("NameReg") + lookup = nameReg.Storage(ethutil.Hex2Bytes(addr)) + ) + + if lookup.Len() != 0 { + return strings.Trim(lookup.Str(), "\x00") + } + + return addr +} + +func (self *UiLib) LookupAddress(name string) string { + var ( + nameReg = self.World().Config().Get("NameReg") + lookup = nameReg.Storage(ethutil.RightPadBytes([]byte(name), 32)) + ) + + if lookup.Len() != 0 { + return ethutil.Bytes2Hex(lookup.Bytes()) + } + + return "" +} + func (self *UiLib) PastPeers() *ethutil.List { return ethutil.NewList(eth.PastPeers()) } From cf999c46220829a5b240e09f11e29748fe94ec35 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 26 Sep 2014 13:34:06 +0200 Subject: [PATCH 3/6] Cleaned up --- mist/assets/debugger/debugger.qml | 2 +- mist/assets/ext/html_messaging.js | 1 - mist/assets/qml/views/info.qml | 41 +++++-------------------------- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/mist/assets/debugger/debugger.qml b/mist/assets/debugger/debugger.qml index 8d54b5b5d01f..b30d20e6b30e 100644 --- a/mist/assets/debugger/debugger.qml +++ b/mist/assets/debugger/debugger.qml @@ -357,7 +357,7 @@ ApplicationWindow { anchors.right: parent.right model: ListModel { ListElement { text: "Snippets" ; value: "" } - ListElement { text: "Call Contract" ; value: "var[2] in;\nvar ret;\n\nin[0] = \"arg1\"\nin[1] = 0xdeadbeef\n\nvar success = call(0x0c542ddea93dae0c2fcb2cf175f03ad80d6be9a0, 0, 7000, in, ret)\n\nreturn ret" } + ListElement { text: "Call Contract" ; value: "var[2] in = { \"arg1\", 0xdeadbeef };\nvar ret;\n\nvar success = call(0x0c542ddea93dae0c2fcb2cf175f03ad80d6be9a0, 0, 7000, in, ret)\n\nreturn ret" } } onCurrentIndexChanged: { if(currentIndex != 0) { diff --git a/mist/assets/ext/html_messaging.js b/mist/assets/ext/html_messaging.js index 0bedba99749f..1f941814831e 100644 --- a/mist/assets/ext/html_messaging.js +++ b/mist/assets/ext/html_messaging.js @@ -459,7 +459,6 @@ g_seed++; - console.log(data) navigator.qt.postMessage(JSON.stringify(data)); } diff --git a/mist/assets/qml/views/info.qml b/mist/assets/qml/views/info.qml index 8a1d4d84ae47..158e2c9609f1 100644 --- a/mist/assets/qml/views/info.qml +++ b/mist/assets/qml/views/info.qml @@ -121,40 +121,7 @@ Rectangle { } } - Slider { - id: logLevelSlider - value: gui.getLogLevelInt() - anchors { - right: parent.right - top: parent.top - bottom: parent.bottom - - rightMargin: 5 - leftMargin: 5 - topMargin: 5 - bottomMargin: 5 - } - - orientation: Qt.Vertical - maximumValue: 5 - stepSize: 1 - - onValueChanged: { - gui.setLogLevel(value) - } - } - } - - property var logModel: ListModel { - id: logModel - } - - /* - RowLayout { - id: logLayout - width: parent.width - height: 200 - anchors.bottom: parent.bottom + /* TableView { id: logView headerVisible: false @@ -169,6 +136,7 @@ Rectangle { model: logModel } + */ Slider { id: logLevelSlider @@ -193,7 +161,10 @@ Rectangle { } } } - */ + + property var logModel: ListModel { + id: logModel + } function addDebugMessage(message){ debuggerLog.append({value: message}) From 7a5b279459d5a52242b88f2e8ffce62c2c30babb Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 26 Sep 2014 13:35:48 +0200 Subject: [PATCH 4/6] Version bump --- README.md | 2 +- ethereum/main.go | 2 +- mist/gui.go | 2 +- mist/main.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 85906d436487..364e04c767c0 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Status](http://cpt-obvious.ethercasts.com:8010/buildstatusimage?builder=go-ether Ethereum Go Client © 2014 Jeffrey Wilcke. -Current state: Proof of Concept 0.6.6. +Current state: Proof of Concept 0.6.7. For the development package please see the [eth-go package](https://github.com/ethereum/eth-go). diff --git a/ethereum/main.go b/ethereum/main.go index 8cc043a4ffa2..6521188ff62b 100644 --- a/ethereum/main.go +++ b/ethereum/main.go @@ -13,7 +13,7 @@ import ( const ( ClientIdentifier = "Ethereum(G)" - Version = "0.6.6" + Version = "0.6.7" ) var logger = ethlog.NewLogger("CLI") diff --git a/mist/gui.go b/mist/gui.go index 299a441c0759..299c053d2350 100644 --- a/mist/gui.go +++ b/mist/gui.go @@ -500,7 +500,7 @@ func (gui *Gui) setStatsPane() { runtime.ReadMemStats(&memStats) statsPane := gui.getObjectByName("statsPane") - statsPane.Set("text", fmt.Sprintf(`###### Mist 0.6.5 (%s) ####### + statsPane.Set("text", fmt.Sprintf(`###### Mist 0.6.7 (%s) ####### eth %d (p2p = %d) diff --git a/mist/main.go b/mist/main.go index 094246c1a500..6e4554352776 100644 --- a/mist/main.go +++ b/mist/main.go @@ -12,7 +12,7 @@ import ( const ( ClientIdentifier = "Mist" - Version = "0.6.6" + Version = "0.6.7" ) var ethereum *eth.Ethereum From b2dc19155f8378f24cf9cc3c31e844b9daf59d84 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 26 Sep 2014 13:38:40 +0200 Subject: [PATCH 5/6] Renamed wallet to main --- mist/assets/qml/{wallet.qml => main.qml} | 0 mist/gui.go | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename mist/assets/qml/{wallet.qml => main.qml} (100%) diff --git a/mist/assets/qml/wallet.qml b/mist/assets/qml/main.qml similarity index 100% rename from mist/assets/qml/wallet.qml rename to mist/assets/qml/main.qml diff --git a/mist/gui.go b/mist/gui.go index 299c053d2350..45ef66624d0e 100644 --- a/mist/gui.go +++ b/mist/gui.go @@ -172,7 +172,7 @@ func (gui *Gui) Stop() { } func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) { - component, err := gui.engine.LoadFile(gui.uiLib.AssetPath("qml/wallet.qml")) + component, err := gui.engine.LoadFile(gui.uiLib.AssetPath("qml/main.qml")) if err != nil { return nil, err } From 2b8eae9810d67136812a4e9e9a822db47cc45a54 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 26 Sep 2014 13:45:18 +0200 Subject: [PATCH 6/6] Added protocol caps to window --- mist/assets/qml/main.qml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mist/assets/qml/main.qml b/mist/assets/qml/main.qml index 885d09116d23..0ee063f179dd 100644 --- a/mist/assets/qml/main.qml +++ b/mist/assets/qml/main.qml @@ -739,7 +739,7 @@ ApplicationWindow { function addPeer(peer) { // We could just append the whole peer object but it cries if you try to alter them - peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), latency: peer.latency, version: peer.version}) + peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), latency: peer.latency, version: peer.version, caps: peer.caps}) } function resetPeers(){ @@ -782,10 +782,11 @@ ApplicationWindow { id: peerTable model: peerModel TableViewColumn{width: 100; role: "ip" ; title: "IP" } - TableViewColumn{width: 60; role: "port" ; title: "Port" } + TableViewColumn{width: 60; role: "port" ; title: "Port" } TableViewColumn{width: 140; role: "lastResponse"; title: "Last event" } TableViewColumn{width: 100; role: "latency"; title: "Latency" } TableViewColumn{width: 260; role: "version" ; title: "Version" } + TableViewColumn{width: 80; role: "caps" ; title: "Capabilities" } } } }