Skip to content

Commit fb49e55

Browse files
committed
Fixed minor issues with filtering
1 parent 0eb1db0 commit fb49e55

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

ethereal/assets/ext/filter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ var Filter = function(options) {
33
this.seed = Math.floor(Math.random() * 1000000);
44
this.options = options;
55

6-
eth.registerFilter(options, this.seed);
6+
if(options == "chain") {
7+
eth.registerFilterString(options, this.seed);
8+
} else if(typeof options === "object") {
9+
eth.registerFilter(options, this.seed);
10+
}
711
};
812

913
Filter.prototype.changed = function(callback) {

ethereal/gui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIden
7272
if err != nil {
7373
fmt.Println(err)
7474
}
75-
fmt.Println(string(data))
75+
fmt.Println("plugins:", string(data))
7676

7777
json.Unmarshal([]byte(data), &gui.plugins)
7878

ethereal/ui_lib.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,20 @@ func (self *UiLib) RegisterFilter(object map[string]interface{}, seed int) {
169169
self.win.Root().Call("invokeFilterCallback", filter.MessagesToJson(messages), seed, callbackSeed)
170170
}
171171
}
172+
173+
}
174+
175+
func (self *UiLib) RegisterFilterString(typ string, seed int) {
176+
filter := &GuiFilter{ethpipe.NewJSFilterFromMap(nil, self.eth), seed}
177+
self.filters[seed] = filter
178+
179+
if typ == "chain" {
180+
filter.BlockCallback = func(block *ethchain.Block) {
181+
for _, callbackSeed := range self.filterCallbacks[seed] {
182+
self.win.Root().Call("invokeFilterCallback", "{}", seed, callbackSeed)
183+
}
184+
}
185+
}
172186
}
173187

174188
func (self *UiLib) RegisterFilterCallback(seed, cbSeed int) {
@@ -187,3 +201,51 @@ type GuiFilter struct {
187201
*ethpipe.JSFilter
188202
seed int
189203
}
204+
205+
func (self *UiLib) Transact(object map[string]interface{}) (*ethpipe.JSReceipt, error) {
206+
// Default values
207+
if object["from"] == nil {
208+
object["from"] = ""
209+
}
210+
if object["to"] == nil {
211+
object["to"] = ""
212+
}
213+
if object["value"] == nil {
214+
object["value"] = ""
215+
}
216+
if object["gas"] == nil {
217+
object["gas"] = ""
218+
}
219+
if object["gasPrice"] == nil {
220+
object["gasPrice"] = ""
221+
}
222+
223+
var dataStr string
224+
var data []string
225+
if list, ok := object["data"].(*qml.List); ok {
226+
list.Convert(&data)
227+
}
228+
229+
for _, str := range data {
230+
if ethutil.IsHex(str) {
231+
str = str[2:]
232+
233+
if len(str) != 64 {
234+
str = ethutil.LeftPadString(str, 64)
235+
}
236+
} else {
237+
str = ethutil.Bytes2Hex(ethutil.LeftPadBytes(ethutil.Big(str).Bytes(), 32))
238+
}
239+
240+
dataStr += str
241+
}
242+
243+
return self.JSPipe.Transact(
244+
object["from"].(string),
245+
object["to"].(string),
246+
object["value"].(string),
247+
object["gas"].(string),
248+
object["gasPrice"].(string),
249+
dataStr,
250+
)
251+
}

0 commit comments

Comments
 (0)