aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-11 22:24:35 +0800
committerobscuren <geffobscura@gmail.com>2014-08-11 22:24:35 +0800
commitc59d7a899b0ca121b3f982fa12405629109f1b47 (patch)
tree1859ac54e0f9948927287caeae863b730eb1fbd9
parentce8f24e57a3ba31d17c34db284bd3d9efa15e7d8 (diff)
downloaddexon-c59d7a899b0ca121b3f982fa12405629109f1b47.tar.gz
dexon-c59d7a899b0ca121b3f982fa12405629109f1b47.tar.zst
dexon-c59d7a899b0ca121b3f982fa12405629109f1b47.zip
Added open js option for repetitive tasks in ethereal
-rw-r--r--ethereal/assets/qml/wallet.qml20
-rw-r--r--ethereal/gui.go15
-rw-r--r--ethereum/cmd.go8
-rw-r--r--ethereum/repl/repl.go12
-rw-r--r--ethereum/repl/repl_darwin.go4
-rw-r--r--utils/vm_env.go4
6 files changed, 51 insertions, 12 deletions
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index e3ef148b0..e264d3f4c 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -63,6 +63,16 @@ ApplicationWindow {
txImportDialog.visible = true
}
}
+
+ MenuItem {
+ text: "Run JS file"
+ onTriggered: {
+ generalFileDialog.callback = function(path) {
+ eth.evalJavascriptFile(path)
+ }
+ generalFileDialog.open()
+ }
+ }
}
Menu {
@@ -452,6 +462,16 @@ ApplicationWindow {
onAccepted: {
}
}
+
+
+ FileDialog {
+ id: generalFileDialog
+ property var callback;
+ onAccepted: {
+ var path = this.fileUrl.toString()
+ callback.call(this, path)
+ }
+ }
FileDialog {
id: importDialog
diff --git a/ethereal/gui.go b/ethereal/gui.go
index 36e147ba9..d2363b5a9 100644
--- a/ethereal/gui.go
+++ b/ethereal/gui.go
@@ -18,6 +18,7 @@ import (
"github.com/ethereum/eth-go/ethreact"
"github.com/ethereum/eth-go/ethutil"
"github.com/ethereum/eth-go/ethwire"
+ "github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
)
@@ -47,6 +48,8 @@ type Gui struct {
config *ethutil.ConfigManager
miner *ethminer.Miner
+
+ jsEngine *javascript.JSRE
}
// Create GUI, but doesn't start it
@@ -58,7 +61,7 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIden
pub := ethpub.NewPEthereum(ethereum)
- return &Gui{eth: ethereum, txDb: db, pub: pub, logLevel: ethlog.LogLevel(logLevel), Session: session, open: false, clientIdentity: clientIdentity, config: config}
+ return &Gui{eth: ethereum, txDb: db, pub: pub, logLevel: ethlog.LogLevel(logLevel), Session: session, open: false, clientIdentity: clientIdentity, config: config, jsEngine: javascript.NewJSRE(ethereum)}
}
func (gui *Gui) Start(assetPath string) {
@@ -121,6 +124,9 @@ func (gui *Gui) Stop() {
gui.open = false
gui.win.Hide()
}
+
+ gui.jsEngine.Stop()
+
logger.Infoln("Stopped")
}
@@ -464,6 +470,13 @@ func (self *Gui) ImportTx(rlpTx string) {
self.eth.TxPool().QueueTransaction(tx)
}
+func (self *Gui) SearchChange(blockHash, address, storageAddress string) {
+}
+
+func (self *Gui) EvalJavascriptFile(path string) {
+ self.jsEngine.LoadExtFile(path[7:])
+}
+
func (gui *Gui) SetCustomIdentifier(customIdentifier string) {
gui.clientIdentity.SetCustomIdentifier(customIdentifier)
gui.config.Save("id", customIdentifier)
diff --git a/ethereum/cmd.go b/ethereum/cmd.go
index ff2b8409c..5ddc91619 100644
--- a/ethereum/cmd.go
+++ b/ethereum/cmd.go
@@ -1,11 +1,13 @@
package main
import (
+ "io/ioutil"
+ "os"
+
"github.com/ethereum/eth-go"
"github.com/ethereum/go-ethereum/ethereum/repl"
+ "github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/utils"
- "io/ioutil"
- "os"
)
func InitJsConsole(ethereum *eth.Ethereum) {
@@ -25,7 +27,7 @@ func ExecJsFile(ethereum *eth.Ethereum, InputFile string) {
if err != nil {
logger.Fatalln(err)
}
- re := ethrepl.NewJSRE(ethereum)
+ re := javascript.NewJSRE(ethereum)
utils.RegisterInterrupt(func(os.Signal) {
re.Stop()
})
diff --git a/ethereum/repl/repl.go b/ethereum/repl/repl.go
index 92d4ad86a..d08feb7b4 100644
--- a/ethereum/repl/repl.go
+++ b/ethereum/repl/repl.go
@@ -3,12 +3,14 @@ package ethrepl
import (
"bufio"
"fmt"
- "github.com/ethereum/eth-go"
- "github.com/ethereum/eth-go/ethlog"
- "github.com/ethereum/eth-go/ethutil"
"io"
"os"
"path"
+
+ "github.com/ethereum/eth-go"
+ "github.com/ethereum/eth-go/ethlog"
+ "github.com/ethereum/eth-go/ethutil"
+ "github.com/ethereum/go-ethereum/javascript"
)
var logger = ethlog.NewLogger("REPL")
@@ -19,7 +21,7 @@ type Repl interface {
}
type JSRepl struct {
- re *JSRE
+ re *javascript.JSRE
prompt string
@@ -34,7 +36,7 @@ func NewJSRepl(ethereum *eth.Ethereum) *JSRepl {
panic(err)
}
- return &JSRepl{re: NewJSRE(ethereum), prompt: "> ", history: hist}
+ return &JSRepl{re: javascript.NewJSRE(ethereum), prompt: "> ", history: hist}
}
func (self *JSRepl) Start() {
diff --git a/ethereum/repl/repl_darwin.go b/ethereum/repl/repl_darwin.go
index 3a91b0d44..4c07280f7 100644
--- a/ethereum/repl/repl_darwin.go
+++ b/ethereum/repl/repl_darwin.go
@@ -115,8 +115,8 @@ L:
}
func (self *JSRepl) PrintValue(v interface{}) {
- method, _ := self.re.vm.Get("prettyPrint")
- v, err := self.re.vm.ToValue(v)
+ method, _ := self.re.Vm.Get("prettyPrint")
+ v, err := self.re.Vm.ToValue(v)
if err == nil {
method.Call(method, v)
}
diff --git a/utils/vm_env.go b/utils/vm_env.go
index 2c40dd7b8..30568c421 100644
--- a/utils/vm_env.go
+++ b/utils/vm_env.go
@@ -1,9 +1,10 @@
package utils
import (
+ "math/big"
+
"github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethstate"
- "math/big"
)
type VMEnv struct {
@@ -29,5 +30,6 @@ func (self *VMEnv) PrevHash() []byte { return self.block.PrevHash }
func (self *VMEnv) Coinbase() []byte { return self.block.Coinbase }
func (self *VMEnv) Time() int64 { return self.block.Time }
func (self *VMEnv) Difficulty() *big.Int { return self.block.Difficulty }
+func (self *VMEnv) BlockHash() []byte { return self.block.Hash() }
func (self *VMEnv) Value() *big.Int { return self.value }
func (self *VMEnv) State() *ethstate.State { return self.state }