op-geth/ui/qt/filter.go

31 lines
586 B
Go
Raw Normal View History

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