|
|
|
@ -21,7 +21,6 @@ |
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"fmt" |
|
|
|
|
"io/ioutil" |
|
|
|
|
"path" |
|
|
|
|
|
|
|
|
@ -29,7 +28,6 @@ import ( |
|
|
|
|
"github.com/ethereum/go-ethereum/eth" |
|
|
|
|
"github.com/ethereum/go-ethereum/ethutil" |
|
|
|
|
"github.com/ethereum/go-ethereum/event/filter" |
|
|
|
|
"github.com/ethereum/go-ethereum/javascript" |
|
|
|
|
"github.com/ethereum/go-ethereum/xeth" |
|
|
|
|
"github.com/obscuren/qml" |
|
|
|
|
) |
|
|
|
@ -49,15 +47,19 @@ type UiLib struct { |
|
|
|
|
// The main application window
|
|
|
|
|
win *qml.Window |
|
|
|
|
|
|
|
|
|
jsEngine *javascript.JSRE |
|
|
|
|
|
|
|
|
|
filterCallbacks map[int][]int |
|
|
|
|
filterManager *filter.FilterManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib { |
|
|
|
|
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath, libPath string) *UiLib { |
|
|
|
|
x := xeth.New(eth, nil) |
|
|
|
|
lib := &UiLib{XEth: x, engine: engine, eth: eth, assetPath: assetPath, jsEngine: javascript.NewJSRE(x), filterCallbacks: make(map[int][]int)} //, filters: make(map[int]*xeth.JSFilter)}
|
|
|
|
|
lib := &UiLib{ |
|
|
|
|
XEth: x, |
|
|
|
|
engine: engine, |
|
|
|
|
eth: eth, |
|
|
|
|
assetPath: assetPath, |
|
|
|
|
filterCallbacks: make(map[int][]int), |
|
|
|
|
} |
|
|
|
|
lib.filterManager = filter.NewFilterManager(eth.EventMux()) |
|
|
|
|
go lib.filterManager.Start() |
|
|
|
|
|
|
|
|
@ -76,19 +78,6 @@ func (self *UiLib) ImportTx(rlpTx string) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (self *UiLib) EvalJavascriptFile(path string) { |
|
|
|
|
self.jsEngine.LoadExtFile(path[7:]) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (self *UiLib) EvalJavascriptString(str string) string { |
|
|
|
|
value, err := self.jsEngine.Run(str) |
|
|
|
|
if err != nil { |
|
|
|
|
return err.Error() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return fmt.Sprintf("%v", value) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (ui *UiLib) Muted(content string) { |
|
|
|
|
component, err := ui.engine.LoadFile(ui.AssetPath("qml/muted.qml")) |
|
|
|
|
if err != nil { |
|
|
|
|