mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2024-12-24 12:27:17 +00:00
remove jsre from mist
This commit is contained in:
parent
da44097800
commit
31ffca6d8a
@ -158,105 +158,6 @@ ApplicationWindow {
|
||||
|
||||
|
||||
|
||||
menuBar: MenuBar {
|
||||
Menu {
|
||||
title: "File"
|
||||
MenuItem {
|
||||
text: "New tab"
|
||||
shortcut: "Ctrl+t"
|
||||
onTriggered: {
|
||||
activeView(catalog.view, catalog.menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
MenuSeparator {}
|
||||
|
||||
MenuItem {
|
||||
text: "Import key"
|
||||
shortcut: "Ctrl+i"
|
||||
onTriggered: {
|
||||
generalFileDialog.show(true, function(path) {
|
||||
gui.importKey(path)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: "Export keys"
|
||||
shortcut: "Ctrl+e"
|
||||
onTriggered: {
|
||||
generalFileDialog.show(false, function(path) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: "Generate key"
|
||||
shortcut: "Ctrl+k"
|
||||
onTriggered: gui.generateKey()
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
title: "Developer"
|
||||
MenuItem {
|
||||
text: "Import Tx"
|
||||
onTriggered: {
|
||||
txImportDialog.visible = true
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: "Run JS file"
|
||||
onTriggered: {
|
||||
generalFileDialog.show(true, function(path) {
|
||||
eth.evalJavascriptFile(path)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: "Dump state"
|
||||
onTriggered: {
|
||||
generalFileDialog.show(false, function(path) {
|
||||
// Empty hash for latest
|
||||
gui.dumpState("", path)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
MenuSeparator {}
|
||||
}
|
||||
|
||||
Menu {
|
||||
title: "Network"
|
||||
MenuItem {
|
||||
text: "Add Peer"
|
||||
shortcut: "Ctrl+p"
|
||||
onTriggered: {
|
||||
addPeerWin.visible = true
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: "Show Peers"
|
||||
shortcut: "Ctrl+e"
|
||||
onTriggered: {
|
||||
peerWindow.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
title: "Help"
|
||||
MenuItem {
|
||||
text: "About"
|
||||
onTriggered: {
|
||||
aboutWin.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
property var blockModel: ListModel {
|
||||
id: blockModel
|
||||
|
@ -25,9 +25,7 @@ import "C"
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"sort"
|
||||
@ -99,7 +97,7 @@ func NewWindow(ethereum *eth.Ethereum) *Gui {
|
||||
return gui
|
||||
}
|
||||
|
||||
func (gui *Gui) Start(assetPath string) {
|
||||
func (gui *Gui) Start(assetPath, libPath string) {
|
||||
defer gui.txDb.Close()
|
||||
|
||||
guilogger.Infoln("Starting GUI")
|
||||
@ -117,7 +115,7 @@ func (gui *Gui) Start(assetPath string) {
|
||||
// Create a new QML engine
|
||||
gui.engine = qml.NewEngine()
|
||||
context := gui.engine.Context()
|
||||
gui.uiLib = NewUiLib(gui.engine, gui.eth, assetPath)
|
||||
gui.uiLib = NewUiLib(gui.engine, gui.eth, assetPath, libPath)
|
||||
gui.whisper = qwhisper.New(gui.eth.Whisper())
|
||||
|
||||
// Expose the eth library and the ui library to QML
|
||||
@ -292,25 +290,6 @@ func (self *Gui) getObjectByName(objectName string) qml.Object {
|
||||
return self.win.Root().ObjectByName(objectName)
|
||||
}
|
||||
|
||||
func loadJavascriptAssets(gui *Gui) (jsfiles string) {
|
||||
for _, fn := range []string{"ext/q.js", "ext/eth.js/main.js", "ext/eth.js/qt.js", "ext/setup.js"} {
|
||||
f, err := os.Open(gui.uiLib.AssetPath(fn))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
jsfiles += string(content)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (gui *Gui) SendCommand(cmd ServEv) {
|
||||
gui.serviceEvents <- cmd
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ func init() {
|
||||
utils.NodeKeyFileFlag,
|
||||
utils.RPCListenAddrFlag,
|
||||
utils.RPCPortFlag,
|
||||
utils.JSpathFlag,
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +112,7 @@ func run(ctx *cli.Context) {
|
||||
gui := NewWindow(ethereum)
|
||||
utils.RegisterInterrupt(func(os.Signal) { gui.Stop() })
|
||||
// gui blocks the main thread
|
||||
gui.Start(ctx.GlobalString(assetPathFlag.Name))
|
||||
gui.Start(ctx.GlobalString(assetPathFlag.Name), ctx.GlobalString(utils.JSpathFlag.Name))
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user