aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/ui
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-05-28 22:19:58 +0800
committerMaran <maran.hidskes@gmail.com>2014-05-28 22:19:58 +0800
commit2114218ed8c9588d107f40ca2f3d7a836809b754 (patch)
treee0654b0ab3bde5bdb2a04c89c39db738c00a4e01 /ethereal/ui
parent198ef97108ec257d49a7b593a9c6fe49961319c0 (diff)
parent58032d60e748611b0610cf764743c6b8e5681a87 (diff)
downloaddexon-2114218ed8c9588d107f40ca2f3d7a836809b754.tar
dexon-2114218ed8c9588d107f40ca2f3d7a836809b754.tar.gz
dexon-2114218ed8c9588d107f40ca2f3d7a836809b754.tar.bz2
dexon-2114218ed8c9588d107f40ca2f3d7a836809b754.tar.lz
dexon-2114218ed8c9588d107f40ca2f3d7a836809b754.tar.xz
dexon-2114218ed8c9588d107f40ca2f3d7a836809b754.tar.zst
dexon-2114218ed8c9588d107f40ca2f3d7a836809b754.zip
Merge branch 'release/poc5-rc11'
Diffstat (limited to 'ethereal/ui')
-rw-r--r--ethereal/ui/debugger.go70
-rw-r--r--ethereal/ui/gui.go2
-rw-r--r--ethereal/ui/ui_lib.go22
3 files changed, 67 insertions, 27 deletions
diff --git a/ethereal/ui/debugger.go b/ethereal/ui/debugger.go
index 8b27c2fe5..342e3a7d0 100644
--- a/ethereal/ui/debugger.go
+++ b/ethereal/ui/debugger.go
@@ -9,6 +9,23 @@ import (
"strings"
)
+func formatData(data string) []byte {
+ if len(data) == 0 {
+ return nil
+ }
+ // Simple stupid
+ d := new(big.Int)
+ if data[0:1] == "\"" && data[len(data)-1:] == "\"" {
+ d.SetBytes([]byte(data[1 : len(data)-1]))
+ } else if data[:2] == "0x" {
+ d.SetBytes(ethutil.FromHex(data[2:]))
+ } else {
+ d.SetString(data, 0)
+ }
+
+ return ethutil.BigToBytes(d, 256)
+}
+
type DebuggerWindow struct {
win *qml.Window
engine *qml.Engine
@@ -41,21 +58,18 @@ func (self *DebuggerWindow) Show() {
}()
}
-func formatData(data string) []byte {
- if len(data) == 0 {
- return nil
- }
- // Simple stupid
- d := new(big.Int)
- if data[0:1] == "\"" && data[len(data)-1:] == "\"" {
- d.SetBytes([]byte(data[1 : len(data)-1]))
- } else if data[:2] == "0x" {
- d.SetBytes(ethutil.FromHex(data[2:]))
- } else {
- d.SetString(data, 0)
- }
+func (self *DebuggerWindow) SetCode(code string) {
+ self.win.Set("codeText", code)
+}
- return ethutil.BigToBytes(d, 256)
+func (self *DebuggerWindow) SetData(data string) {
+ self.win.Set("dataText", data)
+}
+func (self *DebuggerWindow) SetAsm(data string) {
+ dis := ethchain.Disassemble(ethutil.FromHex(data))
+ for _, str := range dis {
+ self.win.Root().Call("setAsm", str)
+ }
}
func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, dataStr string) {
@@ -63,22 +77,28 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
self.Db.Q <- true
}
- dataSlice := strings.Split(dataStr, "\n")
- var data []byte
- for _, dataItem := range dataSlice {
- d := formatData(dataItem)
- data = append(data, d...)
- }
-
- state := self.lib.eth.BlockChain().CurrentBlock.State()
-
defer func() {
if r := recover(); r != nil {
fmt.Println(r)
+ self.Db.done = true
}
}()
- script, err := ethutil.Compile(scriptStr)
+ data := ethutil.StringToByteFunc(dataStr, func(s string) (ret []byte) {
+ slice := strings.Split(dataStr, "\n")
+ for _, dataItem := range slice {
+ d := formatData(dataItem)
+ ret = append(ret, d...)
+ }
+ return
+ })
+
+ var err error
+ script := ethutil.StringToByteFunc(scriptStr, func(s string) (ret []byte) {
+ ret, err = ethutil.Compile(s)
+ return
+ })
+
if err != nil {
ethutil.Config.Log.Debugln(err)
@@ -91,11 +111,13 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
for _, str := range dis {
self.win.Root().Call("setAsm", str)
}
+
// Contract addr as test address
keyPair := ethutil.GetKeyRing().Get(0)
callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), script)
callerTx.Sign(keyPair.PrivateKey)
+ state := self.lib.eth.BlockChain().CurrentBlock.State()
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
contract := ethchain.MakeContract(callerTx, state)
callerClosure := ethchain.NewClosure(account, contract, script, state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 63ab028ab..32ff76b1a 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -54,7 +54,7 @@ func New(ethereum *eth.Ethereum) *Gui {
}
func (gui *Gui) Start(assetPath string) {
- const version = "0.5.0 RC10"
+ const version = "0.5.0 RC11"
defer gui.txDb.Close()
diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go
index 998392525..9c4301ffe 100644
--- a/ethereal/ui/ui_lib.go
+++ b/ethereal/ui/ui_lib.go
@@ -24,8 +24,9 @@ type UiLib struct {
connected bool
assetPath string
// The main application window
- win *qml.Window
- Db *Debugger
+ win *qml.Window
+ Db *Debugger
+ DbWindow *DebuggerWindow
}
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
@@ -88,9 +89,26 @@ func (ui *UiLib) ConnectToPeer(addr string) {
func (ui *UiLib) AssetPath(p string) string {
return path.Join(ui.assetPath, p)
}
+func (self *UiLib) StartDbWithContractAndData(contractHash, data string) {
+ dbWindow := NewDebuggerWindow(self)
+ object := self.eth.StateManager().CurrentState().GetStateObject(ethutil.FromHex(contractHash))
+ if len(object.Script()) > 0 {
+ dbWindow.SetCode("0x" + ethutil.Hex(object.Script()))
+ }
+ dbWindow.SetData(data)
+
+ dbWindow.Show()
+}
+
+func (self *UiLib) StartDbWithCode(code string) {
+ dbWindow := NewDebuggerWindow(self)
+ dbWindow.SetCode("0x" + code)
+ dbWindow.Show()
+}
func (self *UiLib) StartDebugger() {
dbWindow := NewDebuggerWindow(self)
+ //self.DbWindow = dbWindow
dbWindow.Show()
}