Minor fixes and improvements to the ui

This commit is contained in:
obscuren 2014-05-27 16:09:04 +02:00
parent 2be9823010
commit a0f73c2703
4 changed files with 40 additions and 27 deletions

View File

@ -8,7 +8,7 @@ import Ethereum 1.0
ApplicationWindow { ApplicationWindow {
visible: false visible: false
title: "Debugger" title: "IceCream"
minimumWidth: 1280 minimumWidth: 1280
minimumHeight: 900 minimumHeight: 900
width: 1290 width: 1290
@ -58,9 +58,10 @@ ApplicationWindow {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
Label { Label {
text: "Data" text: "Arbitrary data"
} }
TextArea { TextArea {
id: rawDataField
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: 150 height: 150
@ -105,7 +106,7 @@ ApplicationWindow {
SplitView { SplitView {
orientation: Qt.Horizontal orientation: Qt.Horizontal
height: 300 height: 250
TableView { TableView {
id: stackTableView id: stackTableView
@ -149,16 +150,15 @@ ApplicationWindow {
} }
} }
} }
statusBar: StatusBar { toolBar: ToolBar {
RowLayout { RowLayout {
spacing: 5 spacing: 5
anchors.fill: parent
Button { Button {
property var enabled: true property var enabled: true
id: debugStart id: debugStart
onClicked: { onClicked: {
dbg.debug(txValue.text, txGas.text, txGasPrice.text, codeEditor.text) dbg.debug(txValue.text, txGas.text, txGasPrice.text, codeEditor.text, rawDataField.text)
} }
text: "Debug" text: "Debug"
} }

BIN
ethereal/assets/heart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -123,7 +123,7 @@ ApplicationWindow {
} }
Image { Image {
source: ui.assetPath("net.png") source: ui.assetPath("heart.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
@ -284,27 +284,14 @@ ApplicationWindow {
title: "Open QML Application" title: "Open QML Application"
onAccepted: { onAccepted: {
//ui.open(openAppDialog.fileUrl.toString()) //ui.open(openAppDialog.fileUrl.toString())
//ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html"))) //ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
ui.openHtml(openAppDialog.fileUrl.toString()) ui.openHtml(openAppDialog.fileUrl.toString())
} }
} }
statusBar: StatusBar { statusBar: StatusBar {
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
/*
Button {
property var enabled: true
id: connectButton
onClicked: {
if(this.enabled) {
ui.connect(this)
}
}
text: "Connect"
}
*/
Button { Button {
property var enabled: true property var enabled: true
@ -369,8 +356,8 @@ ApplicationWindow {
Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"} Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"}
Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"} Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"}
} }
}
} }
}
ListView { ListView {
model: singleBlock model: singleBlock
delegate: blockDetailsDelegate delegate: blockDetailsDelegate

View File

@ -5,6 +5,8 @@ import (
"github.com/ethereum/eth-go/ethchain" "github.com/ethereum/eth-go/ethchain"
"github.com/ethereum/eth-go/ethutil" "github.com/ethereum/eth-go/ethutil"
"github.com/go-qml/qml" "github.com/go-qml/qml"
"math/big"
"strings"
) )
type DebuggerWindow struct { type DebuggerWindow struct {
@ -39,11 +41,35 @@ func (self *DebuggerWindow) Show() {
}() }()
} }
func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) { 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)
}
func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, dataStr string) {
if !self.Db.done { if !self.Db.done {
self.Db.Q <- true 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() state := self.lib.eth.BlockChain().CurrentBlock.State()
defer func() { defer func() {
@ -52,7 +78,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
} }
}() }()
script, err := ethutil.Compile(data) script, err := ethutil.Compile(scriptStr)
if err != nil { if err != nil {
ethutil.Config.Log.Debugln(err) ethutil.Config.Log.Debugln(err)
@ -72,7 +98,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address()) account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
contract := ethchain.MakeContract(callerTx, state) contract := ethchain.MakeContract(callerTx, state)
callerClosure := ethchain.NewClosure(account, contract, contract.Init(), state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr)) callerClosure := ethchain.NewClosure(account, contract, script, state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))
block := self.lib.eth.BlockChain().CurrentBlock block := self.lib.eth.BlockChain().CurrentBlock
vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{ vm := ethchain.NewVm(state, self.lib.eth.StateManager(), ethchain.RuntimeVars{
@ -86,7 +112,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
self.Db.done = false self.Db.done = false
go func() { go func() {
callerClosure.Call(vm, contract.Init(), self.Db.halting) callerClosure.Call(vm, data, self.Db.halting)
state.Reset() state.Reset()