|
|
@ -7,135 +7,159 @@ import QtQuick.Window 2.1; |
|
|
|
import Ethereum 1.0 |
|
|
|
import Ethereum 1.0 |
|
|
|
|
|
|
|
|
|
|
|
ApplicationWindow { |
|
|
|
ApplicationWindow { |
|
|
|
id: window |
|
|
|
id: window |
|
|
|
title: "Ethereum" |
|
|
|
title: "Ethereum" |
|
|
|
width: 900 |
|
|
|
width: 900 |
|
|
|
height: 600 |
|
|
|
height: 600 |
|
|
|
minimumHeight: 300 |
|
|
|
minimumHeight: 300 |
|
|
|
|
|
|
|
|
|
|
|
property alias url: webview.url |
|
|
|
property alias url: webview.url |
|
|
|
property alias webView: webview |
|
|
|
property alias webView: webview |
|
|
|
|
|
|
|
|
|
|
|
Item { |
|
|
|
Item { |
|
|
|
objectName: "root" |
|
|
|
objectName: "root" |
|
|
|
id: root |
|
|
|
id: root |
|
|
|
anchors.fill: parent |
|
|
|
anchors.fill: parent |
|
|
|
state: "inspectorShown" |
|
|
|
state: "inspectorShown" |
|
|
|
|
|
|
|
|
|
|
|
WebView { |
|
|
|
WebView { |
|
|
|
objectName: "webView" |
|
|
|
objectName: "webView" |
|
|
|
id: webview |
|
|
|
id: webview |
|
|
|
anchors.fill: parent |
|
|
|
anchors.fill: parent |
|
|
|
/* |
|
|
|
/* |
|
|
|
anchors { |
|
|
|
anchors { |
|
|
|
left: parent.left |
|
|
|
left: parent.left |
|
|
|
right: parent.right |
|
|
|
right: parent.right |
|
|
|
bottom: sizeGrip.top |
|
|
|
bottom: sizeGrip.top |
|
|
|
top: parent.top |
|
|
|
top: parent.top |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
onTitleChanged: { window.title = title } |
|
|
|
onTitleChanged: { window.title = title } |
|
|
|
experimental.preferences.javascriptEnabled: true |
|
|
|
experimental.preferences.javascriptEnabled: true |
|
|
|
experimental.preferences.navigatorQtObjectEnabled: true |
|
|
|
experimental.preferences.navigatorQtObjectEnabled: true |
|
|
|
experimental.preferences.developerExtrasEnabled: true |
|
|
|
experimental.preferences.developerExtrasEnabled: true |
|
|
|
experimental.userScripts: [ui.assetPath("ethereum.js")] |
|
|
|
experimental.userScripts: [ui.assetPath("ethereum.js")] |
|
|
|
experimental.onMessageReceived: { |
|
|
|
experimental.onMessageReceived: { |
|
|
|
//console.log("[onMessageReceived]: ", message.data) |
|
|
|
//console.log("[onMessageReceived]: ", message.data) |
|
|
|
var data = JSON.parse(message.data) |
|
|
|
// TODO move to messaging.js |
|
|
|
|
|
|
|
var data = JSON.parse(message.data) |
|
|
|
switch(data.call) { |
|
|
|
|
|
|
|
case "getBlockByNumber": |
|
|
|
try { |
|
|
|
var block = eth.getBlock("b9b56cf6f907fbee21db0cd7cbc0e6fea2fe29503a3943e275c5e467d649cb06") |
|
|
|
switch(data.call) { |
|
|
|
postData(data._seed, block) |
|
|
|
case "getBlockByNumber": |
|
|
|
break |
|
|
|
var block = eth.getBlock("b9b56cf6f907fbee21db0cd7cbc0e6fea2fe29503a3943e275c5e467d649cb06") |
|
|
|
case "getBlockByHash": |
|
|
|
postData(data._seed, block) |
|
|
|
var block = eth.getBlock("b9b56cf6f907fbee21db0cd7cbc0e6fea2fe29503a3943e275c5e467d649cb06") |
|
|
|
break |
|
|
|
postData(data._seed, block) |
|
|
|
case "getBlockByHash": |
|
|
|
break |
|
|
|
var block = eth.getBlock("b9b56cf6f907fbee21db0cd7cbc0e6fea2fe29503a3943e275c5e467d649cb06") |
|
|
|
case "createTx": |
|
|
|
postData(data._seed, block) |
|
|
|
if(data.args.length < 5) { |
|
|
|
break |
|
|
|
postData(data._seed, null) |
|
|
|
case "transact": |
|
|
|
} else { |
|
|
|
require(5) |
|
|
|
var tx = eth.createTx(data.args[0], data.args[1],data.args[2],data.args[3],data.args[4]) |
|
|
|
|
|
|
|
postData(data._seed, tx) |
|
|
|
// TODO this will change to 6 soon with sec being teh first argument |
|
|
|
} |
|
|
|
var tx = eth.transact(data.args[0], data.args[1],data.args[2],data.args[3],data.args[4]) |
|
|
|
break |
|
|
|
postData(data._seed, tx) |
|
|
|
case "getStorage": |
|
|
|
break |
|
|
|
if(data.args.length < 2) { |
|
|
|
case "create": |
|
|
|
postData(data._seed, null) |
|
|
|
postData(data._seed, null) |
|
|
|
} else { |
|
|
|
|
|
|
|
var stateObject = eth.getStateObject(data.args[0]) |
|
|
|
break |
|
|
|
var storage = stateObject.getStorage(data.args[1]) |
|
|
|
case "getStorage": |
|
|
|
postData(data._seed, storage) |
|
|
|
require(2); |
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
var stateObject = eth.getStateObject(data.args[0]) |
|
|
|
case "getKey": |
|
|
|
var storage = stateObject.getStorage(data.args[1]) |
|
|
|
var keys = eth.getKey() |
|
|
|
postData(data._seed, storage) |
|
|
|
postData(data._seed, keys) |
|
|
|
|
|
|
|
break |
|
|
|
break |
|
|
|
case "watch": |
|
|
|
case "getBalance": |
|
|
|
if(data.args.length > 0) { |
|
|
|
require(1); |
|
|
|
eth.watch(data.args[0]); |
|
|
|
|
|
|
|
} |
|
|
|
postData(data._seed, eth.getStateObject(data.args[0]).Value()); |
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
break |
|
|
|
} |
|
|
|
case "getKey": |
|
|
|
function postData(seed, data) { |
|
|
|
var keys = eth.getKey() |
|
|
|
webview.experimental.postMessage(JSON.stringify({data: data, _seed: seed})) |
|
|
|
postData(data._seed, keys) |
|
|
|
} |
|
|
|
break |
|
|
|
function postEvent(event, data) { |
|
|
|
case "watch": |
|
|
|
webview.experimental.postMessage(JSON.stringify({data: data, _event: event})) |
|
|
|
require(1) |
|
|
|
} |
|
|
|
eth.watch(data.args[0], data.args[1]); |
|
|
|
|
|
|
|
break |
|
|
|
function onNewBlockCb(block) { |
|
|
|
case "disconnect": |
|
|
|
postEvent("block:new", block) |
|
|
|
require(1) |
|
|
|
} |
|
|
|
postData(data._seed, null) |
|
|
|
function onObjectChangeCb(stateObject) { |
|
|
|
break; |
|
|
|
postEvent("object:change", stateObject) |
|
|
|
} |
|
|
|
} |
|
|
|
} catch(e) { |
|
|
|
} |
|
|
|
console.log(data.call + ": " + e) |
|
|
|
|
|
|
|
|
|
|
|
Rectangle { |
|
|
|
postData(data._seed, null); |
|
|
|
id: sizeGrip |
|
|
|
} |
|
|
|
color: "gray" |
|
|
|
} |
|
|
|
visible: false |
|
|
|
|
|
|
|
height: 10 |
|
|
|
function require(args, num) { |
|
|
|
anchors { |
|
|
|
if(args.length < num) { |
|
|
|
left: root.left |
|
|
|
throw("required argument count of "+num+" got "+args.length); |
|
|
|
right: root.right |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
y: Math.round(root.height * 2 / 3) |
|
|
|
function postData(seed, data) { |
|
|
|
|
|
|
|
webview.experimental.postMessage(JSON.stringify({data: data, _seed: seed})) |
|
|
|
MouseArea { |
|
|
|
} |
|
|
|
anchors.fill: parent |
|
|
|
function postEvent(event, data) { |
|
|
|
drag.target: sizeGrip |
|
|
|
webview.experimental.postMessage(JSON.stringify({data: data, _event: event})) |
|
|
|
drag.minimumY: 0 |
|
|
|
} |
|
|
|
drag.maximumY: root.height |
|
|
|
|
|
|
|
drag.axis: Drag.YAxis |
|
|
|
function onNewBlockCb(block) { |
|
|
|
} |
|
|
|
postEvent("block:new", block) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function onObjectChangeCb(stateObject) { |
|
|
|
WebView { |
|
|
|
postEvent("object:change", stateObject) |
|
|
|
id: inspector |
|
|
|
} |
|
|
|
visible: false |
|
|
|
} |
|
|
|
url: webview.experimental.remoteInspectorUrl |
|
|
|
|
|
|
|
anchors { |
|
|
|
Rectangle { |
|
|
|
left: root.left |
|
|
|
id: sizeGrip |
|
|
|
right: root.right |
|
|
|
color: "gray" |
|
|
|
top: sizeGrip.bottom |
|
|
|
visible: false |
|
|
|
bottom: root.bottom |
|
|
|
height: 10 |
|
|
|
} |
|
|
|
anchors { |
|
|
|
} |
|
|
|
left: root.left |
|
|
|
|
|
|
|
right: root.right |
|
|
|
states: [ |
|
|
|
} |
|
|
|
State { |
|
|
|
y: Math.round(root.height * 2 / 3) |
|
|
|
name: "inspectorShown" |
|
|
|
|
|
|
|
PropertyChanges { |
|
|
|
MouseArea { |
|
|
|
target: inspector |
|
|
|
anchors.fill: parent |
|
|
|
url: webview.experimental.remoteInspectorUrl |
|
|
|
drag.target: sizeGrip |
|
|
|
} |
|
|
|
drag.minimumY: 0 |
|
|
|
} |
|
|
|
drag.maximumY: root.height |
|
|
|
] |
|
|
|
drag.axis: Drag.YAxis |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WebView { |
|
|
|
|
|
|
|
id: inspector |
|
|
|
|
|
|
|
visible: false |
|
|
|
|
|
|
|
url: webview.experimental.remoteInspectorUrl |
|
|
|
|
|
|
|
anchors { |
|
|
|
|
|
|
|
left: root.left |
|
|
|
|
|
|
|
right: root.right |
|
|
|
|
|
|
|
top: sizeGrip.bottom |
|
|
|
|
|
|
|
bottom: root.bottom |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
states: [ |
|
|
|
|
|
|
|
State { |
|
|
|
|
|
|
|
name: "inspectorShown" |
|
|
|
|
|
|
|
PropertyChanges { |
|
|
|
|
|
|
|
target: inspector |
|
|
|
|
|
|
|
url: webview.experimental.remoteInspectorUrl |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|