aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-10 07:51:56 +0800
committerobscuren <geffobscura@gmail.com>2015-01-10 07:51:56 +0800
commite3da85faedf21a3ddb73a0fa29decf65364e6c39 (patch)
tree516faf70a5346bec9016bbdd308b6bcc23d5bccb /ui
parent491c23a728e4f5cdedfa040aded6a6b136f6bee0 (diff)
downloaddexon-e3da85faedf21a3ddb73a0fa29decf65364e6c39.tar
dexon-e3da85faedf21a3ddb73a0fa29decf65364e6c39.tar.gz
dexon-e3da85faedf21a3ddb73a0fa29decf65364e6c39.tar.bz2
dexon-e3da85faedf21a3ddb73a0fa29decf65364e6c39.tar.lz
dexon-e3da85faedf21a3ddb73a0fa29decf65364e6c39.tar.xz
dexon-e3da85faedf21a3ddb73a0fa29decf65364e6c39.tar.zst
dexon-e3da85faedf21a3ddb73a0fa29decf65364e6c39.zip
Implemented filter for ws + fixes
* proper 0xhex * filters fixed * start of filter manager * accounts for ws. Closes #246
Diffstat (limited to 'ui')
-rw-r--r--ui/filter.go20
-rw-r--r--ui/qt/filter.go5
2 files changed, 15 insertions, 10 deletions
diff --git a/ui/filter.go b/ui/filter.go
index 88faad5ca..e0797dad2 100644
--- a/ui/filter.go
+++ b/ui/filter.go
@@ -5,6 +5,16 @@ import (
"github.com/ethereum/go-ethereum/ethutil"
)
+func fromHex(s string) []byte {
+ if len(s) > 1 {
+ if s[0:2] == "0x" {
+ s = s[2:]
+ }
+ return ethutil.Hex2Bytes(s)
+ }
+ return nil
+}
+
func NewFilterFromMap(object map[string]interface{}, eth core.EthManager) *core.Filter {
filter := core.NewFilter(eth)
@@ -20,12 +30,12 @@ func NewFilterFromMap(object map[string]interface{}, eth core.EthManager) *core.
if object["to"] != nil {
val := ethutil.NewValue(object["to"])
- filter.AddTo(ethutil.Hex2Bytes(val.Str()))
+ filter.AddTo(fromHex(val.Str()))
}
if object["from"] != nil {
val := ethutil.NewValue(object["from"])
- filter.AddFrom(ethutil.Hex2Bytes(val.Str()))
+ filter.AddFrom(fromHex(val.Str()))
}
if object["max"] != nil {
@@ -48,11 +58,11 @@ func NewFilterFromMap(object map[string]interface{}, eth core.EthManager) *core.
// Conversion methodn
func mapToAccountChange(m map[string]interface{}) (d core.AccountChange) {
if str, ok := m["id"].(string); ok {
- d.Address = ethutil.Hex2Bytes(str)
+ d.Address = fromHex(str)
}
if str, ok := m["at"].(string); ok {
- d.StateAddress = ethutil.Hex2Bytes(str)
+ d.StateAddress = fromHex(str)
}
return
@@ -62,7 +72,7 @@ func mapToAccountChange(m map[string]interface{}) (d core.AccountChange) {
// ["aabbccdd", {id: "ccddee", at: "11223344"}], "aabbcc", {id: "ccddee", at: "1122"}
func makeAltered(v interface{}) (d []core.AccountChange) {
if str, ok := v.(string); ok {
- d = append(d, core.AccountChange{ethutil.Hex2Bytes(str), nil})
+ d = append(d, core.AccountChange{fromHex(str), nil})
} else if obj, ok := v.(map[string]interface{}); ok {
d = append(d, mapToAccountChange(obj))
} else if slice, ok := v.([]interface{}); ok {
diff --git a/ui/qt/filter.go b/ui/qt/filter.go
index c68936401..423d5bd43 100644
--- a/ui/qt/filter.go
+++ b/ui/qt/filter.go
@@ -1,8 +1,6 @@
package qt
import (
- "fmt"
-
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/ui"
"gopkg.in/qml.v1"
@@ -23,13 +21,10 @@ func makeAltered(v interface{}) (d []core.AccountChange) {
var s []interface{}
qList.Convert(&s)
- fmt.Println(s)
-
d = makeAltered(s)
} else if qMap, ok := v.(*qml.Map); ok {
var m map[string]interface{}
qMap.Convert(&m)
- fmt.Println(m)
d = makeAltered(m)
}