aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-20 18:42:49 +0800
committerobscuren <geffobscura@gmail.com>2014-08-20 18:42:49 +0800
commitfb49e5565ae7fe1d44180158aa982a96b7720fb5 (patch)
tree4ec1a12b486077fb79e00294e38c92167283f5c6 /ethereal
parent0eb1db0d179e07e9133e5d2d2df5efcbb68d9884 (diff)
downloaddexon-fb49e5565ae7fe1d44180158aa982a96b7720fb5.tar.gz
dexon-fb49e5565ae7fe1d44180158aa982a96b7720fb5.tar.zst
dexon-fb49e5565ae7fe1d44180158aa982a96b7720fb5.zip
Fixed minor issues with filtering
Diffstat (limited to 'ethereal')
-rw-r--r--ethereal/assets/ext/filter.js6
-rw-r--r--ethereal/gui.go2
-rw-r--r--ethereal/ui_lib.go62
3 files changed, 68 insertions, 2 deletions
diff --git a/ethereal/assets/ext/filter.js b/ethereal/assets/ext/filter.js
index 7af6f56e7..5c1c03aad 100644
--- a/ethereal/assets/ext/filter.js
+++ b/ethereal/assets/ext/filter.js
@@ -3,7 +3,11 @@ var Filter = function(options) {
this.seed = Math.floor(Math.random() * 1000000);
this.options = options;
- eth.registerFilter(options, this.seed);
+ if(options == "chain") {
+ eth.registerFilterString(options, this.seed);
+ } else if(typeof options === "object") {
+ eth.registerFilter(options, this.seed);
+ }
};
Filter.prototype.changed = function(callback) {
diff --git a/ethereal/gui.go b/ethereal/gui.go
index 3f989fe51..f450acde6 100644
--- a/ethereal/gui.go
+++ b/ethereal/gui.go
@@ -72,7 +72,7 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIden
if err != nil {
fmt.Println(err)
}
- fmt.Println(string(data))
+ fmt.Println("plugins:", string(data))
json.Unmarshal([]byte(data), &gui.plugins)
diff --git a/ethereal/ui_lib.go b/ethereal/ui_lib.go
index 7b2627c49..4b8210da6 100644
--- a/ethereal/ui_lib.go
+++ b/ethereal/ui_lib.go
@@ -169,6 +169,20 @@ func (self *UiLib) RegisterFilter(object map[string]interface{}, seed int) {
self.win.Root().Call("invokeFilterCallback", filter.MessagesToJson(messages), seed, callbackSeed)
}
}
+
+}
+
+func (self *UiLib) RegisterFilterString(typ string, seed int) {
+ filter := &GuiFilter{ethpipe.NewJSFilterFromMap(nil, self.eth), seed}
+ self.filters[seed] = filter
+
+ if typ == "chain" {
+ filter.BlockCallback = func(block *ethchain.Block) {
+ for _, callbackSeed := range self.filterCallbacks[seed] {
+ self.win.Root().Call("invokeFilterCallback", "{}", seed, callbackSeed)
+ }
+ }
+ }
}
func (self *UiLib) RegisterFilterCallback(seed, cbSeed int) {
@@ -187,3 +201,51 @@ type GuiFilter struct {
*ethpipe.JSFilter
seed int
}
+
+func (self *UiLib) Transact(object map[string]interface{}) (*ethpipe.JSReceipt, error) {
+ // Default values
+ if object["from"] == nil {
+ object["from"] = ""
+ }
+ if object["to"] == nil {
+ object["to"] = ""
+ }
+ if object["value"] == nil {
+ object["value"] = ""
+ }
+ if object["gas"] == nil {
+ object["gas"] = ""
+ }
+ if object["gasPrice"] == nil {
+ object["gasPrice"] = ""
+ }
+
+ var dataStr string
+ var data []string
+ if list, ok := object["data"].(*qml.List); ok {
+ list.Convert(&data)
+ }
+
+ for _, str := range data {
+ if ethutil.IsHex(str) {
+ str = str[2:]
+
+ if len(str) != 64 {
+ str = ethutil.LeftPadString(str, 64)
+ }
+ } else {
+ str = ethutil.Bytes2Hex(ethutil.LeftPadBytes(ethutil.Big(str).Bytes(), 32))
+ }
+
+ dataStr += str
+ }
+
+ return self.JSPipe.Transact(
+ object["from"].(string),
+ object["to"].(string),
+ object["value"].(string),
+ object["gas"].(string),
+ object["gasPrice"].(string),
+ dataStr,
+ )
+}