Commit 40d72ff4 authored by obscuren's avatar obscuren

.

parent efadfbfb
...@@ -8,1005 +8,1005 @@ import Ethereum 1.0 ...@@ -8,1005 +8,1005 @@ 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: parent.bottom anchors.bottom: parent.bottom
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))
} }
} }
} }
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
} }
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: 200 height: 200
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
TableViewColumn{ role: "description" ; title: "log" } TableViewColumn{ role: "description" ; title: "log" }
model: logModel model: logModel
} }
} }
/* /*
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
Component{ Component{
id: blockDetailsDelegate id: blockDetailsDelegate
Rectangle { Rectangle {
color: "#252525" color: "#252525"
width: popup.width width: popup.width
height: 200 height: 200
Column { Column {
anchors.leftMargin: 10 anchors.leftMargin: 10
anchors.topMargin: 5 anchors.topMargin: 5
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
Text { text: '<h3>Block details</h3>'; color: "#F2F2F2"} Text { text: '<h3>Block details</h3>'; color: "#F2F2F2"}
Text { text: '<b>Block number:</b> ' + number; color: "#F2F2F2"} Text { text: '<b>Block number:</b> ' + number; color: "#F2F2F2"}
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
anchors.top: parent.top anchors.top: parent.top
height: 70 height: 70
anchors.leftMargin: 20 anchors.leftMargin: 20
id: listViewThing id: listViewThing
Layout.maximumHeight: 40 Layout.maximumHeight: 40
} }
TableView { TableView {
id: txView id: txView
anchors.top: listViewThing.bottom anchors.top: listViewThing.bottom
anchors.topMargin: 50 anchors.topMargin: 50
width: parent.width width: parent.width
TableViewColumn{width: 90; role: "value" ; title: "Value" } TableViewColumn{width: 90; role: "value" ; title: "Value" }
TableViewColumn{width: 200; role: "hash" ; title: "Hash" } TableViewColumn{width: 200; role: "hash" ; title: "Hash" }
TableViewColumn{width: 200; role: "sender" ; title: "Sender" } TableViewColumn{width: 200; role: "sender" ; title: "Sender" }
TableViewColumn{width: 200;role: "address" ; title: "Receiver" } TableViewColumn{width: 200;role: "address" ; title: "Receiver" }
TableViewColumn{width: 60; role: "gas" ; title: "Gas" } TableViewColumn{width: 60; role: "gas" ; title: "Gas" }
TableViewColumn{width: 60; role: "gasPrice" ; title: "Gas Price" } TableViewColumn{width: 60; role: "gasPrice" ; title: "Gas Price" }
TableViewColumn{width: 60; role: "isContract" ; title: "Contract" } TableViewColumn{width: 60; role: "isContract" ; title: "Contract" }
model: transactionModel model: transactionModel
onClicked: { onClicked: {
var tx = transactionModel.get(row) var tx = transactionModel.get(row)
if(tx.data) { if(tx.data) {
popup.showContractData(tx) popup.showContractData(tx)
}else{ }else{
popup.height = 230 popup.height = 230
} }
} }
} }
function showContractData(tx) { function showContractData(tx) {
txDetailsDebugButton.tx = tx txDetailsDebugButton.tx = tx
if(tx.createsContract) { if(tx.createsContract) {
contractData.text = tx.data contractData.text = tx.data
contractLabel.text = "<h4> Transaction created contract " + tx.address + "</h4>" contractLabel.text = "<h4> Transaction created contract " + tx.address + "</h4>"
}else{ }else{
contractLabel.text = "<h4> Transaction ran contract " + tx.address + "</h4>" contractLabel.text = "<h4> Transaction ran contract " + tx.address + "</h4>"
contractData.text = tx.rawData contractData.text = tx.rawData
} }
popup.height = 400 popup.height = 400
} }
Rectangle { Rectangle {
id: txDetails id: txDetails
width: popup.width width: popup.width
height: 300 height: 300
anchors.left: listViewThing.left anchors.left: listViewThing.left
anchors.top: txView.bottom anchors.top: txView.bottom
Label { Label {
text: "<h4>Contract data</h4>" text: "<h4>Contract data</h4>"
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
id: contractLabel id: contractLabel
anchors.leftMargin: 10 anchors.leftMargin: 10
} }
Button { Button {
property var tx property var tx
id: txDetailsDebugButton id: txDetailsDebugButton
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: 10 anchors.rightMargin: 10
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 10 anchors.topMargin: 10
text: "Debug contract" text: "Debug contract"
onClicked: { onClicked: {
if(tx.createsContract){ if(tx.createsContract){
ui.startDbWithCode(tx.rawData) ui.startDbWithCode(tx.rawData)
}else { }else {
ui.startDbWithContractAndData(tx.address, tx.rawData) ui.startDbWithContractAndData(tx.address, tx.rawData)
} }
} }
} }
TextArea { TextArea {
id: contractData id: contractData
text: "Contract" text: "Contract"
anchors.top: contractLabel.bottom anchors.top: contractLabel.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.bottom: popup.bottom anchors.bottom: popup.bottom
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.insert(0, {description: str}) logModel.insert(0, {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, "500", "1000000", "") var res = eth.transact(txSimpleRecipient.text, txSimpleValue.text, "500", "1000000", "")
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"
} }
} }
} }
} }
} }
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