forked from cerc-io/plugeth
Hooked up the Block Explorer to the Debugger so we can instantly debug made transactions
This commit is contained in:
parent
aaeb268522
commit
1eda1d25b0
@ -340,8 +340,8 @@ ApplicationWindow {
|
|||||||
id: popup
|
id: popup
|
||||||
visible: false
|
visible: false
|
||||||
property var block
|
property var block
|
||||||
width: 800
|
width: root.width
|
||||||
height: 280
|
height: 240
|
||||||
x: root.x
|
x: root.x
|
||||||
y: root.y + root.height
|
y: root.y + root.height
|
||||||
Component{
|
Component{
|
||||||
@ -389,17 +389,27 @@ ApplicationWindow {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
var tx = transactionModel.get(row)
|
var tx = transactionModel.get(row)
|
||||||
if(tx.data) {
|
if(tx.data) {
|
||||||
popup.showContractData(tx.data)
|
popup.showContractData(tx)
|
||||||
}else{
|
}else{
|
||||||
popup.height = 230
|
popup.height = 230
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function showContractData(data) {
|
|
||||||
contractData.text = data
|
function showContractData(tx) {
|
||||||
|
txDetailsDebugButton.tx = tx
|
||||||
|
if(tx.createsContract) {
|
||||||
|
contractData.text = tx.data
|
||||||
|
contractLabel.text = "<h4> Transaction created contract " + tx.address + "</h4>"
|
||||||
|
}else{
|
||||||
|
contractLabel.text = "<h4> Transaction ran contract " + tx.address + "</h4>"
|
||||||
|
contractData.text = tx.rawData
|
||||||
|
}
|
||||||
popup.height = 400
|
popup.height = 400
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
id: txDetails
|
||||||
width: popup.width
|
width: popup.width
|
||||||
height: 300
|
height: 300
|
||||||
anchors.left: listViewThing.left
|
anchors.left: listViewThing.left
|
||||||
@ -411,6 +421,22 @@ ApplicationWindow {
|
|||||||
id: contractLabel
|
id: contractLabel
|
||||||
anchors.leftMargin: 10
|
anchors.leftMargin: 10
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
|
property var tx
|
||||||
|
id: txDetailsDebugButton
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.rightMargin: 10
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 10
|
||||||
|
text: "Debug contract"
|
||||||
|
onClicked: {
|
||||||
|
if(tx.createsContract){
|
||||||
|
ui.startDbWithCode(tx.rawData)
|
||||||
|
}else {
|
||||||
|
ui.startDbWithContractAndData(tx.address, tx.rawData)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
TextArea {
|
TextArea {
|
||||||
id: contractData
|
id: contractData
|
||||||
text: "Contract"
|
text: "Contract"
|
||||||
@ -437,7 +463,7 @@ ApplicationWindow {
|
|||||||
transactionModel.insert(0, block.txs.get(i))
|
transactionModel.insert(0, block.txs.get(i))
|
||||||
}
|
}
|
||||||
if(block.txs.get(0).data){
|
if(block.txs.get(0).data){
|
||||||
popup.showContractData(block.txs.get(0).data)
|
popup.showContractData(block.txs.get(0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
txView.forceActiveFocus()
|
txView.forceActiveFocus()
|
||||||
|
@ -65,6 +65,12 @@ func (self *DebuggerWindow) SetCode(code string) {
|
|||||||
func (self *DebuggerWindow) SetData(data string) {
|
func (self *DebuggerWindow) SetData(data string) {
|
||||||
self.win.Set("dataText", data)
|
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) {
|
func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, dataStr string) {
|
||||||
if !self.Db.done {
|
if !self.Db.done {
|
||||||
|
@ -2,6 +2,7 @@ package ethui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bitbucket.org/kardianos/osext"
|
"bitbucket.org/kardianos/osext"
|
||||||
|
"encoding/hex"
|
||||||
"github.com/ethereum/eth-go"
|
"github.com/ethereum/eth-go"
|
||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
@ -24,8 +25,9 @@ type UiLib struct {
|
|||||||
connected bool
|
connected bool
|
||||||
assetPath string
|
assetPath string
|
||||||
// The main application window
|
// The main application window
|
||||||
win *qml.Window
|
win *qml.Window
|
||||||
Db *Debugger
|
Db *Debugger
|
||||||
|
DbWindow *DebuggerWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
|
func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
|
||||||
@ -88,9 +90,26 @@ func (ui *UiLib) ConnectToPeer(addr string) {
|
|||||||
func (ui *UiLib) AssetPath(p string) string {
|
func (ui *UiLib) AssetPath(p string) string {
|
||||||
return path.Join(ui.assetPath, p)
|
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" + hex.EncodeToString(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() {
|
func (self *UiLib) StartDebugger() {
|
||||||
dbWindow := NewDebuggerWindow(self)
|
dbWindow := NewDebuggerWindow(self)
|
||||||
|
//self.DbWindow = dbWindow
|
||||||
|
|
||||||
dbWindow.Show()
|
dbWindow.Show()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user