Commit f802e176 authored by obscuren's avatar obscuren

merge

parents 8fab7ce3 44db1a1e
...@@ -5,7 +5,7 @@ Ethereum ...@@ -5,7 +5,7 @@ Ethereum
Ethereum Go Client © 2014 Jeffrey Wilcke. Ethereum Go Client © 2014 Jeffrey Wilcke.
Current state: Proof of Concept 5.0 RC10. Current state: Proof of Concept 5.0 RC11.
For the development package please see the [eth-go package](https://github.com/ethereum/eth-go). For the development package please see the [eth-go package](https://github.com/ethereum/eth-go).
......
...@@ -8,1006 +8,1004 @@ import Ethereum 1.0 ...@@ -8,1006 +8,1004 @@ import Ethereum 1.0
ApplicationWindow { ApplicationWindow {
id: root id: root
width: 900 width: 900
height: 600 height: 600
minimumHeight: 300 minimumHeight: 300
title: "Ethereal" title: "Ethereal"
MenuBar { MenuBar {
Menu { Menu {
title: "File" title: "File"
MenuItem { MenuItem {
text: "Import App" text: "Import App"
shortcut: "Ctrl+o" shortcut: "Ctrl+o"
onTriggered: openAppDialog.open() onTriggered: openAppDialog.open()
} }
} }
Menu { Menu {
title: "Tools" title: "Tools"
MenuItem { MenuItem {
text: "Muted" text: "Muted"
shortcut: "Ctrl+e" shortcut: "Ctrl+e"
onTriggered: ui.muted("") onTriggered: ui.muted("")
} }
MenuItem { MenuItem {
text: "Debugger" text: "Debugger"
shortcut: "Ctrl+d" shortcut: "Ctrl+d"
onTriggered: ui.startDebugger() onTriggered: ui.startDebugger()
} }
} }
Menu { Menu {
title: "Network" title: "Network"
MenuItem { MenuItem {
text: "Add Peer" text: "Add Peer"
shortcut: "Ctrl+p" shortcut: "Ctrl+p"
onTriggered: { onTriggered: {
addPeerWin.visible = true addPeerWin.visible = true
} }
} }
MenuItem { MenuItem {
text: "Start" text: "Start"
onTriggered: ui.connect() onTriggered: ui.connect()
} }
} }
Menu { Menu {
title: "Help" title: "Help"
MenuItem { MenuItem {
text: "About" text: "About"
onTriggered: { onTriggered: {
aboutWin.visible = true aboutWin.visible = true
} }
} }
} }
} }
property var blockModel: ListModel { property var blockModel: ListModel {
id: blockModel id: blockModel
} }
function setView(view) { function setView(view) {
networkView.visible = false networkView.visible = false
historyView.visible = false historyView.visible = false
newTxView.visible = false newTxView.visible = false
infoView.visible = false infoView.visible = false
view.visible = true view.visible = true
//root.title = "Ethereal - " = view.title //root.title = "Ethereal - " = view.title
} }
SplitView { SplitView {
anchors.fill: parent anchors.fill: parent
resizing: false resizing: false
Rectangle { Rectangle {
id: menu id: menu
Layout.minimumWidth: 80 Layout.minimumWidth: 80
Layout.maximumWidth: 80 Layout.maximumWidth: 80
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.top: parent.top anchors.top: parent.top
//color: "#D9DDE7" //color: "#D9DDE7"
color: "#252525" color: "#252525"
ColumnLayout { ColumnLayout {
y: 50 y: 50
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: 200 height: 200
Image { Image {
source: ui.assetPath("tx.png") source: ui.assetPath("tx.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
setView(historyView) setView(historyView)
} }
} }
} }
Image { Image {
source: ui.assetPath("new.png") source: ui.assetPath("new.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
setView(newTxView) setView(newTxView)
} }
} }
} }
Image { Image {
source: ui.assetPath("net.png") source: ui.assetPath("net.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
setView(networkView) setView(networkView)
} }
} }
} }
Image { Image {
source: ui.assetPath("heart.png") source: ui.assetPath("heart.png")
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
setView(infoView) setView(infoView)
} }
} }
} }
} }
} }
Rectangle { Rectangle {
id: mainView id: mainView
color: "#00000000" color: "#00000000"
anchors.right: parent.right anchors.right: parent.right
anchors.left: menu.right anchors.left: menu.right
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.top: parent.top anchors.top: parent.top
property var txModel: ListModel { property var txModel: ListModel {
id: txModel id: txModel
} }
Rectangle { Rectangle {
id: historyView id: historyView
anchors.fill: parent anchors.fill: parent
property var title: "Transactions" property var title: "Transactions"
TableView { TableView {
id: txTableView id: txTableView
anchors.fill: parent anchors.fill: parent
TableViewColumn{ role: "inout" ; title: "" ; width: 40 } TableViewColumn{ role: "inout" ; title: "" ; width: 40 }
TableViewColumn{ role: "value" ; title: "Value" ; width: 100 } TableViewColumn{ role: "value" ; title: "Value" ; width: 100 }
TableViewColumn{ role: "address" ; title: "Address" ; width: 430 } TableViewColumn{ role: "address" ; title: "Address" ; width: 430 }
TableViewColumn{ role: "contract" ; title: "Contract" ; width: 100 } TableViewColumn{ role: "contract" ; title: "Contract" ; width: 100 }
model: txModel model: txModel
} }
} }
Rectangle { Rectangle {
id: newTxView id: newTxView
property var title: "New transaction" property var title: "New transaction"
visible: false visible: false
anchors.fill: parent anchors.fill: parent
color: "#00000000" color: "#00000000"
TabView{ TabView{
anchors.fill: parent anchors.fill: parent
anchors.rightMargin: 5 anchors.rightMargin: 5
anchors.leftMargin: 5 anchors.leftMargin: 5
anchors.topMargin: 5 anchors.topMargin: 5
anchors.bottomMargin: 5 anchors.bottomMargin: 5
id: newTransactionTab id: newTransactionTab
Component.onCompleted:{ Component.onCompleted:{
addTab("Simple send", newTransaction) addTab("Simple send", newTransaction)
addTab("Contracts", newContract) addTab("Contracts", newContract)
} }
} }
} }
Rectangle { Rectangle {
id: networkView id: networkView
property var title: "Network" property var title: "Network"
visible: false visible: false
anchors.fill: parent anchors.fill: parent
TableView { TableView {
id: blockTable id: blockTable
width: parent.width width: parent.width
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: logView.top anchors.bottom: logView.top
TableViewColumn{ role: "number" ; title: "#" ; width: 100 } TableViewColumn{ role: "number" ; title: "#" ; width: 100 }
TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 } TableViewColumn{ role: "hash" ; title: "Hash" ; width: 560 }
TableViewColumn{ role: "txAmount" ; title: "Tx amount" ; width: 100 } TableViewColumn{ role: "txAmount" ; title: "Tx amount" ; width: 100 }
model: blockModel model: blockModel
onDoubleClicked: { onDoubleClicked: {
popup.visible = true popup.visible = true
popup.setDetails(blockModel.get(row)) popup.setDetails(blockModel.get(row))
} }
} }
property var logModel: ListModel { property var logModel: ListModel {
id: logModel id: logModel
} }
TableView { TableView {
id: logView id: logView
width: parent.width width: parent.width
height: 150 height: 150
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
TableViewColumn{ role: "description" ; title: "log" } TableViewColumn{ role: "description" ; title: "log" }
model: logModel model: logModel
} }
} }
Rectangle { Rectangle {
id: infoView id: infoView
property var title: "Information" property var title: "Information"
visible: false visible: false
color: "#00000000" color: "#00000000"
anchors.fill: parent anchors.fill: parent
Label { Label {
id: addressLabel id: addressLabel
text: "Address" text: "Address"
anchors { anchors {
margins: 5 margins: 5
top: parent.top top: parent.top
left: parent.left left: parent.left
} }
} }
TextField { TextField {
anchors { anchors {
margins: 5 margins: 5
left: addressLabel.right left: addressLabel.right
top: parent.top top: parent.top
} }
text: pub.getKey().address text: pub.getKey().address
width: 500 width: 500
} }
} }
/* /*
signal addPlugin(string name) signal addPlugin(string name)
Component { Component {
id: pluginWindow id: pluginWindow
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
Label { Label {
id: pluginTitle id: pluginTitle
anchors.centerIn: parent anchors.centerIn: parent
text: "Hello world" text: "Hello world"
} }
Component.onCompleted: setView(this) Component.onCompleted: setView(this)
} }
} }
onAddPlugin: { onAddPlugin: {
var pluginWin = pluginWindow.createObject(mainView) var pluginWin = pluginWindow.createObject(mainView)
console.log(pluginWin) console.log(pluginWin)
pluginWin.pluginTitle.text = "Test" pluginWin.pluginTitle.text = "Test"
} }
*/ */
} }
} }
FileDialog { FileDialog {
id: openAppDialog id: openAppDialog
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 { Button {
property var enabled: true property var enabled: true
id: debuggerWindow id: debuggerWindow
onClicked: { onClicked: {
ui.startDebugger() ui.startDebugger()
} }
text: "Debugger" text: "Debugger"
} }
Button { Button {
id: importAppButton id: importAppButton
anchors.left: debuggerWindow.right anchors.left: debuggerWindow.right
anchors.leftMargin: 5 anchors.leftMargin: 5
onClicked: openAppDialog.open() onClicked: openAppDialog.open()
text: "Import App" text: "Import App"
} }
Label { Label {
anchors.left: importAppButton.right anchors.left: importAppButton.right
anchors.leftMargin: 5 anchors.leftMargin: 5
id: walletValueLabel id: walletValueLabel
} }
Label { Label {
anchors.right: peerImage.left anchors.right: peerImage.left
anchors.rightMargin: 5 anchors.rightMargin: 5
id: peerLabel id: peerLabel
font.pixelSize: 8 font.pixelSize: 8
text: "0 / 0" text: "0 / 0"
} }
Image { Image {
id: peerImage id: peerImage
anchors.right: parent.right anchors.right: parent.right
width: 10; height: 10 width: 10; height: 10
source: ui.assetPath("network.png") source: ui.assetPath("network.png")
} }
} }
} }
Window { Window {
id: popup id: popup
visible: false visible: false
property var block property var block
width: root.width width: root.width
height: 240 height: 240
x: root.x Component{
y: root.y + root.height id: blockDetailsDelegate
Component{ Rectangle {
id: blockDetailsDelegate color: "#252525"
Rectangle { width: popup.width
color: "#252525" height: 200
width: popup.width Column {
height: 200 anchors.leftMargin: 10
Column { anchors.topMargin: 5
anchors.leftMargin: 10 anchors.top: parent.top
anchors.topMargin: 5 anchors.left: parent.left
anchors.top: parent.top Text { text: '<h3>Block details</h3>'; color: "#F2F2F2"}
anchors.left: parent.left Text { text: '<b>Block number:</b> ' + number; color: "#F2F2F2"}
Text { text: '<h3>Block details</h3>'; color: "#F2F2F2"} Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"}
Text { text: '<b>Block number:</b> ' + number; color: "#F2F2F2"} Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"}
Text { text: '<b>Hash:</b> ' + hash; color: "#F2F2F2"} }
Text { text: '<b>Block found at:</b> ' + prettyTime; color: "#F2F2F2"} }
} }
} ListView {
} model: singleBlock
ListView { delegate: blockDetailsDelegate
model: singleBlock anchors.top: parent.top
delegate: blockDetailsDelegate height: 70
anchors.top: parent.top anchors.leftMargin: 20
height: 70 id: listViewThing
anchors.leftMargin: 20 Layout.maximumHeight: 40
id: listViewThing }
Layout.maximumHeight: 40 TableView {
} id: txView
TableView { anchors.top: listViewThing.bottom
id: txView anchors.topMargin: 50
anchors.top: listViewThing.bottom width: parent.width
anchors.topMargin: 50
width: parent.width TableViewColumn{width: 90; role: "value" ; title: "Value" }
TableViewColumn{width: 200; role: "hash" ; title: "Hash" }
TableViewColumn{width: 90; role: "value" ; title: "Value" } TableViewColumn{width: 200; role: "sender" ; title: "Sender" }
TableViewColumn{width: 200; role: "hash" ; title: "Hash" } TableViewColumn{width: 200;role: "address" ; title: "Receiver" }
TableViewColumn{width: 200; role: "sender" ; title: "Sender" } TableViewColumn{width: 60; role: "gas" ; title: "Gas" }
TableViewColumn{width: 200;role: "address" ; title: "Receiver" } TableViewColumn{width: 60; role: "gasPrice" ; title: "Gas Price" }
TableViewColumn{width: 60; role: "gas" ; title: "Gas" } TableViewColumn{width: 60; role: "isContract" ; title: "Contract" }
TableViewColumn{width: 60; role: "gasPrice" ; title: "Gas Price" }
TableViewColumn{width: 60; role: "isContract" ; title: "Contract" } model: transactionModel
onClicked: {
model: transactionModel var tx = transactionModel.get(row)
onClicked: { if(tx.data) {
var tx = transactionModel.get(row) popup.showContractData(tx)
if(tx.data) { }else{
popup.showContractData(tx) popup.height = 230
}else{ }
popup.height = 230 }
} }
}
} function showContractData(tx) {
txDetailsDebugButton.tx = tx
function showContractData(tx) { if(tx.createsContract) {
txDetailsDebugButton.tx = tx contractData.text = tx.data
if(tx.createsContract) { contractLabel.text = "<h4> Transaction created contract " + tx.address + "</h4>"
contractData.text = tx.data }else{
contractLabel.text = "<h4> Transaction created contract " + tx.address + "</h4>" contractLabel.text = "<h4> Transaction ran contract " + tx.address + "</h4>"
}else{ contractData.text = tx.rawData
contractLabel.text = "<h4> Transaction ran contract " + tx.address + "</h4>" }
contractData.text = tx.rawData popup.height = 400
} }
popup.height = 400
} Rectangle {
id: txDetails
Rectangle { width: popup.width
id: txDetails height: 300
width: popup.width anchors.left: listViewThing.left
height: 300 anchors.top: txView.bottom
anchors.left: listViewThing.left Label {
anchors.top: txView.bottom text: "<h4>Contract data</h4>"
Label { anchors.top: parent.top
text: "<h4>Contract data</h4>" anchors.left: parent.left
anchors.top: parent.top id: contractLabel
anchors.left: parent.left anchors.leftMargin: 10
id: contractLabel }
anchors.leftMargin: 10 Button {
} property var tx
Button { id: txDetailsDebugButton
property var tx anchors.right: parent.right
id: txDetailsDebugButton anchors.rightMargin: 10
anchors.right: parent.right anchors.top: parent.top
anchors.rightMargin: 10 anchors.topMargin: 10
anchors.top: parent.top text: "Debug contract"
anchors.topMargin: 10 onClicked: {
text: "Debug contract" if(tx.createsContract){
onClicked: { ui.startDbWithCode(tx.rawData)
if(tx.createsContract){ }else {
ui.startDbWithCode(tx.rawData) ui.startDbWithContractAndData(tx.address, tx.rawData)
}else { }
ui.startDbWithContractAndData(tx.address, tx.rawData) }
} }
} TextArea {
} id: contractData
TextArea { text: "Contract"
id: contractData anchors.top: contractLabel.bottom
text: "Contract" anchors.left: parent.left
anchors.top: contractLabel.bottom anchors.bottom: popup.bottom
anchors.left: parent.left wrapMode: Text.Wrap
wrapMode: Text.Wrap width: parent.width - 30
width: parent.width - 30 height: 80
height: 80 anchors.leftMargin: 10
anchors.leftMargin: 10 }
} }
} property var transactionModel: ListModel {
property var transactionModel: ListModel { id: transactionModel
id: transactionModel }
} property var singleBlock: ListModel {
property var singleBlock: ListModel { id: singleBlock
id: singleBlock }
} function setDetails(block){
function setDetails(block){ singleBlock.set(0,block)
singleBlock.set(0,block) popup.height = 230
popup.height = 230 transactionModel.clear()
transactionModel.clear() if(block.txs != undefined){
if(block.txs != undefined){ for(var i = 0; i < block.txs.count; ++i) {
for(var i = 0; i < block.txs.count; ++i) { 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))
popup.showContractData(block.txs.get(0)) }
} }
} txView.forceActiveFocus()
txView.forceActiveFocus() }
} }
}
Window {
Window { id: addPeerWin
id: addPeerWin visible: false
visible: false minimumWidth: 230
minimumWidth: 230 maximumWidth: 230
maximumWidth: 230 maximumHeight: 50
maximumHeight: 50 minimumHeight: 50
minimumHeight: 50
TextField {
TextField { id: addrField
id: addrField anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left
anchors.left: parent.left anchors.leftMargin: 10
anchors.leftMargin: 10 placeholderText: "address:port"
placeholderText: "address:port" onAccepted: {
onAccepted: { ui.connectToPeer(addrField.text)
ui.connectToPeer(addrField.text) addPeerWin.visible = false
addPeerWin.visible = false }
} }
} Button {
Button { anchors.left: addrField.right
anchors.left: addrField.right anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: 5
anchors.leftMargin: 5 text: "Add"
text: "Add" onClicked: {
onClicked: { ui.connectToPeer(addrField.text)
ui.connectToPeer(addrField.text) addPeerWin.visible = false
addPeerWin.visible = false }
} }
} Component.onCompleted: {
Component.onCompleted: { addrField.focus = true
addrField.focus = true }
} }
}
Window {
Window { id: aboutWin
id: aboutWin visible: false
visible: false title: "About"
title: "About" minimumWidth: 350
minimumWidth: 350 maximumWidth: 350
maximumWidth: 350 maximumHeight: 200
maximumHeight: 200 minimumHeight: 200
minimumHeight: 200
Image {
Image { id: aboutIcon
id: aboutIcon height: 150
height: 150 width: 150
width: 150 fillMode: Image.PreserveAspectFit
fillMode: Image.PreserveAspectFit smooth: true
smooth: true source: ui.assetPath("facet.png")
source: ui.assetPath("facet.png") x: 10
x: 10 y: 10
y: 10 }
}
Text {
Text { anchors.left: aboutIcon.right
anchors.left: aboutIcon.right anchors.leftMargin: 10
anchors.leftMargin: 10 font.pointSize: 12
font.pointSize: 12 text: "<h2>Ethereal</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Maran Hidskes<br>"
text: "<h2>Ethereal</h2><br><h3>Development</h3>Jeffrey Wilcke<br>Maran Hidskes<br>" }
}
}
}
ApplicationWindow {
ApplicationWindow { id: debugWindow
id: debugWindow visible: false
visible: false title: "Debugger"
title: "Debugger" minimumWidth: 600
minimumWidth: 600 minimumHeight: 600
minimumHeight: 600 width: 800
width: 800 height: 600
height: 600
Item {
Item { id: keyHandler
id: keyHandler focus: true
focus: true Keys.onPressed: {
Keys.onPressed: { if (event.key == Qt.Key_Space) {
if (event.key == Qt.Key_Space) { ui.next()
ui.next() }
} }
} }
} SplitView {
SplitView { anchors.fill: parent
anchors.fill: parent property var asmModel: ListModel {
property var asmModel: ListModel { id: asmModel
id: asmModel }
} TableView {
TableView { id: asmTableView
id: asmTableView width: 200
width: 200 TableViewColumn{ role: "value" ; title: "" ; width: 100 }
TableViewColumn{ role: "value" ; title: "" ; width: 100 } model: asmModel
model: asmModel }
}
Rectangle {
Rectangle { anchors.left: asmTableView.right
anchors.left: asmTableView.right anchors.right: parent.right
anchors.right: parent.right SplitView {
SplitView { orientation: Qt.Vertical
orientation: Qt.Vertical anchors.fill: parent
anchors.fill: parent
TableView {
TableView { property var memModel: ListModel {
property var memModel: ListModel { id: memModel
id: memModel }
} height: parent.height/2
height: parent.height/2 width: parent.width
width: parent.width TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50}
TableViewColumn{ id:mnumColmn ; role: "num" ; title: "#" ; width: 50} TableViewColumn{ role: "value" ; title: "Memory" ; width: 750}
TableViewColumn{ role: "value" ; title: "Memory" ; width: 750} model: memModel
model: memModel }
}
SplitView {
SplitView { orientation: Qt.Horizontal
orientation: Qt.Horizontal id: debugSplitView
id: debugSplitView TableView {
TableView { property var debuggerLog: ListModel {
property var debuggerLog: ListModel { id: debuggerLog
id: debuggerLog }
} TableViewColumn{ role: "value"; title: "Debug messages" }
TableViewColumn{ role: "value"; title: "Debug messages" } model: debuggerLog
model: debuggerLog }
} TableView {
TableView { property var stackModel: ListModel {
property var stackModel: ListModel { id: stackModel
id: stackModel }
} height: parent.height/2
height: parent.height/2 width: parent.width
width: parent.width TableViewColumn{ role: "value" ; title: "Stack" ; width: debugSplitView.width }
TableViewColumn{ role: "value" ; title: "Stack" ; width: debugSplitView.width } model: stackModel
model: stackModel }
} }
} }
} }
} }
} statusBar: StatusBar {
statusBar: StatusBar { RowLayout {
RowLayout { anchors.fill: parent
anchors.fill: parent Button {
Button { property var enabled: true
property var enabled: true id: debugNextButton
id: debugNextButton onClicked: {
onClicked: { ui.next()
ui.next() }
} text: "Next"
text: "Next" }
} }
} }
} }
}
function setAsm(asm) {
function setAsm(asm) { asmModel.append({asm: asm})
asmModel.append({asm: asm}) }
}
function setInstruction(num) {
function setInstruction(num) { asmTableView.selection.clear()
asmTableView.selection.clear() asmTableView.selection.select(num-1)
asmTableView.selection.select(num-1) }
}
function clearAsm() {
function clearAsm() { asmModel.clear()
asmModel.clear() }
}
function setMem(mem) {
function setMem(mem) { memModel.append({num: mem.num, value: mem.value})
memModel.append({num: mem.num, value: mem.value}) }
} function clearMem(){
function clearMem(){ memModel.clear()
memModel.clear() }
}
function setStack(stack) {
function setStack(stack) { stackModel.append({value: stack})
stackModel.append({value: stack}) }
} function addDebugMessage(message){
function addDebugMessage(message){ console.log("WOOP:")
console.log("WOOP:") debuggerLog.append({value: message})
debuggerLog.append({value: message}) }
}
function clearStack() {
function clearStack() { stackModel.clear()
stackModel.clear() }
}
function loadPlugin(name) {
function loadPlugin(name) { console.log("Loading plugin" + name)
console.log("Loading plugin" + name) mainView.addPlugin(name)
mainView.addPlugin(name) }
}
function setWalletValue(value) {
function setWalletValue(value) { walletValueLabel.text = value
walletValueLabel.text = value }
}
function addTx(tx, inout) {
function addTx(tx, inout) { var isContract
var isContract if (tx.contract == true){
if (tx.contract == true){ isContract = "Yes"
isContract = "Yes" }else{
}else{ isContract = "No"
isContract = "No" }
} txModel.insert(0, {inout: inout, hash: tx.hash, address: tx.address, value: tx.value, contract: isContract})
txModel.insert(0, {inout: inout, hash: tx.hash, address: tx.address, value: tx.value, contract: isContract}) }
}
function addBlock(block, initial) {
function addBlock(block, initial) { var txs = JSON.parse(block.transactions);
var txs = JSON.parse(block.transactions); var amount = 0
var amount = 0 if(initial == undefined){
if(initial == undefined){ initial = false
initial = false }
}
if(txs != null){
if(txs != null){ amount = txs.length
amount = txs.length }
}
if(initial){
if(initial){ blockModel.append({number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
blockModel.append({number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) }else{
}else{ blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)})
blockModel.insert(0, {number: block.number, hash: block.hash, txs: txs, txAmount: amount, time: block.time, prettyTime: convertToPretty(block.time)}) }
} }
}
function addLog(str) {
function addLog(str) { if(str.len != 0) {
if(str.len != 0) { logModel.append({description: str})
logModel.append({description: str}) }
} }
}
function setPeers(text) {
function setPeers(text) { peerLabel.text = text
peerLabel.text = text }
} function convertToPretty(unixTs){
function convertToPretty(unixTs){ var a = new Date(unixTs*1000);
var a = new Date(unixTs*1000); var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var year = a.getFullYear();
var year = a.getFullYear(); var month = months[a.getMonth()];
var month = months[a.getMonth()]; var date = a.getDate();
var date = a.getDate(); var hour = a.getHours();
var hour = a.getHours(); var min = a.getMinutes();
var min = a.getMinutes(); var sec = a.getSeconds();
var sec = a.getSeconds(); var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ; return time;
return time; }
} // *******************************************
// ******************************************* // Components
// Components // *******************************************
// *******************************************
// New Contract component
// New Contract component Component {
Component { id: newContract
id: newContract Column {
Column { id: mainContractColumn
id: mainContractColumn function contractFormReady(){
function contractFormReady(){ if(codeView.text.length > 0 && txValue.text.length > 0 && txGas.text.length > 0 && txGasPrice.length > 0) {
if(codeView.text.length > 0 && txValue.text.length > 0 && txGas.text.length > 0 && txGasPrice.length > 0) { txButton.state = "READY"
txButton.state = "READY" }else{
}else{ txButton.state = "NOTREADY"
txButton.state = "NOTREADY" }
} }
} states: [
states: [ State{
State{ name: "ERROR"
name: "ERROR" PropertyChanges { target: txResult; visible:true}
PropertyChanges { target: txResult; visible:true} PropertyChanges { target: codeView; visible:true}
PropertyChanges { target: codeView; visible:true} },
}, State {
State { name: "DONE"
name: "DONE" PropertyChanges { target: txValue; visible:false}
PropertyChanges { target: txValue; visible:false} PropertyChanges { target: txGas; visible:false}
PropertyChanges { target: txGas; visible:false} PropertyChanges { target: txGasPrice; visible:false}
PropertyChanges { target: txGasPrice; visible:false} PropertyChanges { target: codeView; visible:false}
PropertyChanges { target: codeView; visible:false} PropertyChanges { target: txButton; visible:false}
PropertyChanges { target: txButton; visible:false} PropertyChanges { target: txDataLabel; visible:false}
PropertyChanges { target: txDataLabel; visible:false}
PropertyChanges { target: txResult; visible:true}
PropertyChanges { target: txResult; visible:true} PropertyChanges { target: txOutput; visible:true}
PropertyChanges { target: txOutput; visible:true} PropertyChanges { target: newTxButton; visible:true}
PropertyChanges { target: newTxButton; visible:true} },
}, State {
State { name: "SETUP"
name: "SETUP" PropertyChanges { target: txValue; visible:true; text: ""}
PropertyChanges { target: txValue; visible:true; text: ""} PropertyChanges { target: txGas; visible:true; text: ""}
PropertyChanges { target: txGas; visible:true; text: ""} PropertyChanges { target: txGasPrice; visible:true; text: ""}
PropertyChanges { target: txGasPrice; visible:true; text: ""} PropertyChanges { target: codeView; visible:true; text: ""}
PropertyChanges { target: codeView; visible:true; text: ""} PropertyChanges { target: txButton; visible:true}
PropertyChanges { target: txButton; visible:true} PropertyChanges { target: txDataLabel; visible:true}
PropertyChanges { target: txDataLabel; visible:true}
PropertyChanges { target: txResult; visible:false}
PropertyChanges { target: txResult; visible:false} PropertyChanges { target: txOutput; visible:false}
PropertyChanges { target: txOutput; visible:false} PropertyChanges { target: newTxButton; visible:false}
PropertyChanges { target: newTxButton; visible:false} }
} ]
] width: 400
width: 400 spacing: 5
spacing: 5 anchors.left: parent.left
anchors.left: parent.left anchors.top: parent.top
anchors.top: parent.top anchors.leftMargin: 5
anchors.leftMargin: 5 anchors.topMargin: 5
anchors.topMargin: 5
TextField {
TextField { id: txValue
id: txValue width: 200
width: 200 placeholderText: "Amount"
placeholderText: "Amount" validator: RegExpValidator { regExp: /\d*/ }
validator: RegExpValidator { regExp: /\d*/ } onTextChanged: {
onTextChanged: { contractFormReady()
contractFormReady() }
} }
} TextField {
TextField { id: txGas
id: txGas width: 200
width: 200 validator: RegExpValidator { regExp: /\d*/ }
validator: RegExpValidator { regExp: /\d*/ } placeholderText: "Gas"
placeholderText: "Gas" onTextChanged: {
onTextChanged: { contractFormReady()
contractFormReady() }
} }
} TextField {
TextField { id: txGasPrice
id: txGasPrice width: 200
width: 200 placeholderText: "Gas price"
placeholderText: "Gas price" validator: RegExpValidator { regExp: /\d*/ }
validator: RegExpValidator { regExp: /\d*/ } onTextChanged: {
onTextChanged: { contractFormReady()
contractFormReady() }
} }
}
Row {
Row { id: rowContract
id: rowContract ExclusiveGroup { id: contractTypeGroup }
ExclusiveGroup { id: contractTypeGroup } RadioButton {
RadioButton { id: createContractRadio
id: createContractRadio text: "Create contract"
text: "Create contract" checked: true
checked: true exclusiveGroup: contractTypeGroup
exclusiveGroup: contractTypeGroup onClicked: {
onClicked: { txFuelRecipient.visible = false
txFuelRecipient.visible = false txDataLabel.text = "Contract code"
txDataLabel.text = "Contract code" }
} }
} RadioButton {
RadioButton { id: runContractRadio
id: runContractRadio text: "Run contract"
text: "Run contract" exclusiveGroup: contractTypeGroup
exclusiveGroup: contractTypeGroup onClicked: {
onClicked: { txFuelRecipient.visible = true
txFuelRecipient.visible = true txDataLabel.text = "Contract arguments"
txDataLabel.text = "Contract arguments" }
} }
} }
}
Label {
Label { id: txDataLabel
id: txDataLabel text: "Contract code"
text: "Contract code" }
}
TextArea {
TextArea { id: codeView
id: codeView height: 300
height: 300 anchors.topMargin: 5
anchors.topMargin: 5 Layout.fillWidth: true
Layout.fillWidth: true width: parent.width /2
width: parent.width /2 onTextChanged: {
onTextChanged: { contractFormReady()
contractFormReady() }
} }
}
TextField {
TextField { id: txFuelRecipient
id: txFuelRecipient placeholderText: "Contract address"
placeholderText: "Contract address" validator: RegExpValidator { regExp: /[a-f0-9]{40}/ }
validator: RegExpValidator { regExp: /[a-f0-9]{40}/ } visible: false
visible: false width: 530
width: 530 }
}
Button {
Button { id: txButton
id: txButton /* enabled: false */
/* enabled: false */ states: [
states: [ State {
State { name: "READY"
name: "READY" PropertyChanges { target: txButton; /*enabled: true*/}
PropertyChanges { target: txButton; /*enabled: true*/} },
}, State {
State { name: "NOTREADY"
name: "NOTREADY" PropertyChanges { target: txButton; /*enabled:false*/}
PropertyChanges { target: txButton; /*enabled:false*/} }
} ]
] text: "Send"
text: "Send" onClicked: {
onClicked: { //this.enabled = false
//this.enabled = false var res = eth.create(txFuelRecipient.text, txValue.text, txGas.text, txGasPrice.text, codeView.text)
var res = eth.create(txFuelRecipient.text, txValue.text, txGas.text, txGasPrice.text, codeView.text) if(res[1]) {
if(res[1]) { txResult.text = "Your contract <b>could not</b> be send over the network:\n<b>"
txResult.text = "Your contract <b>could not</b> be send over the network:\n<b>" txResult.text += res[1].error()
txResult.text += res[1].error() txResult.text += "</b>"
txResult.text += "</b>" mainContractColumn.state = "ERROR"
mainContractColumn.state = "ERROR" } else {
} else { txResult.text = "Your transaction has been submitted:\n"
txResult.text = "Your transaction has been submitted:\n" txOutput.text = res[0].address
txOutput.text = res[0].address mainContractColumn.state = "DONE"
mainContractColumn.state = "DONE" }
} }
} }
} Text {
Text { id: txResult
id: txResult visible: false
visible: false }
} TextField {
TextField { id: txOutput
id: txOutput visible: false
visible: false width: 530
width: 530 }
} Button {
Button { id: newTxButton
id: newTxButton visible: false
visible: false text: "Create an other contract"
text: "Create an other contract" onClicked: {
onClicked: { this.visible = false
this.visible = false txResult.text = ""
txResult.text = "" txOutput.text = ""
txOutput.text = "" mainContractColumn.state = "SETUP"
mainContractColumn.state = "SETUP" }
} }
}
Button {
Button { id: debugButton
id: debugButton text: "Debug"
text: "Debug" onClicked: {
onClicked: { var res = ui.debugTx("", txValue.text, txGas.text, txGasPrice.text, codeView.text)
var res = ui.debugTx("", txValue.text, txGas.text, txGasPrice.text, codeView.text) debugWindow.visible = true
debugWindow.visible = true }
} }
} }
} }
}
// New Transaction component
// New Transaction component Component {
Component { id: newTransaction
id: newTransaction Column {
Column { id: simpleSendColumn
id: simpleSendColumn states: [
states: [ State{
State{ name: "ERROR"
name: "ERROR" },
}, State {
State { name: "DONE"
name: "DONE" PropertyChanges { target: txSimpleValue; visible:false}
PropertyChanges { target: txSimpleValue; visible:false} PropertyChanges { target: txSimpleRecipient; visible:false}
PropertyChanges { target: txSimpleRecipient; visible:false} PropertyChanges { target:newSimpleTxButton; visible:false}
PropertyChanges { target:newSimpleTxButton; visible:false}
PropertyChanges { target: txSimpleResult; visible:true}
PropertyChanges { target: txSimpleResult; visible:true} PropertyChanges { target: txSimpleOutput; visible:true}
PropertyChanges { target: txSimpleOutput; visible:true} PropertyChanges { target:newSimpleTxButton; visible:true}
PropertyChanges { target:newSimpleTxButton; visible:true} },
}, State {
State { name: "SETUP"
name: "SETUP" PropertyChanges { target: txSimpleValue; visible:true; text: ""}
PropertyChanges { target: txSimpleValue; visible:true; text: ""} PropertyChanges { target: txSimpleRecipient; visible:true; text: ""}
PropertyChanges { target: txSimpleRecipient; visible:true; text: ""} PropertyChanges { target: txSimpleButton; visible:true}
PropertyChanges { target: txSimpleButton; visible:true} PropertyChanges { target:newSimpleTxButton; visible:false}
PropertyChanges { target:newSimpleTxButton; visible:false} }
} ]
] spacing: 5
spacing: 5 anchors.leftMargin: 5
anchors.leftMargin: 5 anchors.topMargin: 5
anchors.topMargin: 5 anchors.top: parent.top
anchors.top: parent.top anchors.left: parent.left
anchors.left: parent.left
function checkFormState(){
function checkFormState(){ if(txSimpleRecipient.text.length == 40 && txSimpleValue.text.length > 0) {
if(txSimpleRecipient.text.length == 40 && txSimpleValue.text.length > 0) { txSimpleButton.state = "READY"
txSimpleButton.state = "READY" }else{
}else{ txSimpleButton.state = "NOTREADY"
txSimpleButton.state = "NOTREADY" }
} }
}
TextField {
TextField { id: txSimpleRecipient
id: txSimpleRecipient placeholderText: "Recipient address"
placeholderText: "Recipient address" Layout.fillWidth: true
Layout.fillWidth: true validator: RegExpValidator { regExp: /[a-f0-9]{40}/ }
validator: RegExpValidator { regExp: /[a-f0-9]{40}/ } width: 530
width: 530 onTextChanged: { checkFormState() }
onTextChanged: { checkFormState() } }
} TextField {
TextField { id: txSimpleValue
id: txSimpleValue width: 200
width: 200 placeholderText: "Amount"
placeholderText: "Amount" anchors.rightMargin: 5
anchors.rightMargin: 5 validator: RegExpValidator { regExp: /\d*/ }
validator: RegExpValidator { regExp: /\d*/ } onTextChanged: { checkFormState() }
onTextChanged: { checkFormState() } }
} Button {
Button { id: txSimpleButton
id: txSimpleButton /*enabled: false*/
/*enabled: false*/ states: [
states: [ State {
State { name: "READY"
name: "READY" PropertyChanges { target: txSimpleButton; /*enabled: true*/}
PropertyChanges { target: txSimpleButton; /*enabled: true*/} },
}, State {
State { name: "NOTREADY"
name: "NOTREADY" PropertyChanges { target: txSimpleButton; /*enabled: false*/}
PropertyChanges { target: txSimpleButton; /*enabled: false*/} }
} ]
] text: "Send"
text: "Send" onClicked: {
onClicked: { //this.enabled = false
//this.enabled = false var res = eth.transact(txSimpleRecipient.text, txSimpleValue.text,"","","")
var res = eth.transact(txSimpleRecipient.text, txSimpleValue.text,"","","") if(res[1]) {
if(res[1]) { txSimpleResult.text = "There has been an error broadcasting your transaction:" + res[1].error()
txSimpleResult.text = "There has been an error broadcasting your transaction:" + res[1].error() } else {
} else { txSimpleResult.text = "Your transaction has been broadcasted over the network.\nYour transaction id is:"
txSimpleResult.text = "Your transaction has been broadcasted over the network.\nYour transaction id is:" txSimpleOutput.text = res[0].hash
txSimpleOutput.text = res[0].hash this.visible = false
this.visible = false simpleSendColumn.state = "DONE"
simpleSendColumn.state = "DONE" }
} }
} }
} Text {
Text { id: txSimpleResult
id: txSimpleResult visible: false
visible: false
}
} TextField {
TextField { id: txSimpleOutput
id: txSimpleOutput visible: false
visible: false width: 530
width: 530 }
} Button {
Button { id: newSimpleTxButton
id: newSimpleTxButton visible: false
visible: false text: "Create an other transaction"
text: "Create an other transaction" onClicked: {
onClicked: { this.visible = false
this.visible = false simpleSendColumn.state = "SETUP"
simpleSendColumn.state = "SETUP" }
} }
} }
} }
}
} }
...@@ -54,7 +54,7 @@ func New(ethereum *eth.Ethereum) *Gui { ...@@ -54,7 +54,7 @@ func New(ethereum *eth.Ethereum) *Gui {
} }
func (gui *Gui) Start(assetPath string) { func (gui *Gui) Start(assetPath string) {
const version = "0.5.0 RC10" const version = "0.5.0 RC11"
defer gui.txDb.Close() defer gui.txDb.Close()
......
...@@ -2,7 +2,6 @@ package ethui ...@@ -2,7 +2,6 @@ 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"
...@@ -94,9 +93,9 @@ func (self *UiLib) StartDbWithContractAndData(contractHash, data string) { ...@@ -94,9 +93,9 @@ func (self *UiLib) StartDbWithContractAndData(contractHash, data string) {
dbWindow := NewDebuggerWindow(self) dbWindow := NewDebuggerWindow(self)
object := self.eth.StateManager().CurrentState().GetStateObject(ethutil.FromHex(contractHash)) object := self.eth.StateManager().CurrentState().GetStateObject(ethutil.FromHex(contractHash))
if len(object.Script()) > 0 { if len(object.Script()) > 0 {
dbWindow.SetCode("0x" + hex.EncodeToString(object.Script())) dbWindow.SetCode("0x" + ethutil.Hex(object.Script()))
} }
dbWindow.SetData(data) dbWindow.SetData("0x" + data)
dbWindow.Show() dbWindow.Show()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment