go-ethereum/ui/qt/filter.go

31 lines
583 B
Go
Raw Normal View History

package qt
import (
2014-12-04 03:28:02 -06:00
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/ui"
2015-01-28 07:51:54 -06:00
"github.com/obscuren/qml"
)
func NewFilterFromMap(object map[string]interface{}, eth core.Backend) *core.Filter {
filter := ui.NewFilterFromMap(object, eth)
2015-01-28 03:23:18 -06:00
if object["topics"] != nil {
filter.SetTopics(makeTopics(object["topics"]))
}
return filter
}
2015-01-28 03:23:18 -06:00
func makeTopics(v interface{}) (d [][]byte) {
if qList, ok := v.(*qml.List); ok {
2015-01-28 03:23:18 -06:00
var s []string
qList.Convert(&s)
2015-01-28 03:23:18 -06:00
d = ui.MakeTopics(s)
} else if str, ok := v.(string); ok {
d = ui.MakeTopics(str)
}
return
}