aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/ui_lib.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethereal/ui_lib.go')
-rw-r--r--ethereal/ui_lib.go62
1 files changed, 62 insertions, 0 deletions
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,
+ )
+}