aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/assets
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-05 17:56:05 +0800
committerobscuren <geffobscura@gmail.com>2014-05-05 17:56:05 +0800
commitdd45197bcd174e16adc3b738bf390cc3018a5a28 (patch)
tree13db37ed9ca5358c60f08cf4bd1a3ebb0ca0e22a /ethereal/assets
parent2582d719b2a8a3facac4410dd9a2ddaf5000f038 (diff)
downloaddexon-dd45197bcd174e16adc3b738bf390cc3018a5a28.tar
dexon-dd45197bcd174e16adc3b738bf390cc3018a5a28.tar.gz
dexon-dd45197bcd174e16adc3b738bf390cc3018a5a28.tar.bz2
dexon-dd45197bcd174e16adc3b738bf390cc3018a5a28.tar.lz
dexon-dd45197bcd174e16adc3b738bf390cc3018a5a28.tar.xz
dexon-dd45197bcd174e16adc3b738bf390cc3018a5a28.tar.zst
dexon-dd45197bcd174e16adc3b738bf390cc3018a5a28.zip
Added storage watch
Diffstat (limited to 'ethereal/assets')
-rw-r--r--ethereal/assets/ethereum.js26
-rw-r--r--ethereal/assets/qml/webapp.qml16
-rw-r--r--ethereal/assets/samplecoin/samplecoin.html12
3 files changed, 43 insertions, 11 deletions
diff --git a/ethereal/assets/ethereum.js b/ethereal/assets/ethereum.js
index 64a7ff47c..e83d252b2 100644
--- a/ethereal/assets/ethereum.js
+++ b/ethereal/assets/ethereum.js
@@ -36,6 +36,7 @@ window.eth = {
postData({call: "getKey"}, cb);
},
+
getBalanceAt: function(address, cb) {
postData({call: "getBalance", args: [address]}, cb);
},
@@ -101,7 +102,13 @@ window.eth = {
var callbacks = eth._onCallbacks[event];
if(callbacks !== undefined) {
for(var i = 0; i < callbacks.length; i++) {
- callbacks[i](data);
+ // Figure out whether the returned data was an array
+ // array means multiple return arguments (multiple params)
+ if(data instanceof Array) {
+ callbacks[i].apply(this, data);
+ } else {
+ callbacks[i].call(this, data);
+ }
}
}
},
@@ -109,6 +116,11 @@ window.eth = {
window.eth._callbacks = {}
window.eth._onCallbacks = {}
+function hello() {
+ debug("hello")
+ window.dataTest = true;
+}
+
function debug(/**/) {
var args = arguments;
var msg = ""
@@ -120,6 +132,7 @@ function debug(/**/) {
}
}
+ postData({call:"debug", args:[msg]})
document.getElementById("debug").innerHTML += "<br>" + msg
}
@@ -146,8 +159,14 @@ navigator.qt.onmessage = function(ev) {
if(data._seed) {
var cb = eth._callbacks[data._seed];
if(cb) {
- // Call the callback
- cb(data.data);
+ // Figure out whether the returned data was an array
+ // array means multiple return arguments (multiple params)
+ if(data.data instanceof Array) {
+ cb.apply(this, data.data)
+ } else {
+ cb.call(this, data.data)
+ }
+
// Remove the "trigger" callback
delete eth._callbacks[ev._seed];
}
@@ -211,3 +230,4 @@ String.prototype.hex2bin = function() {
String.prototype.num2bin = function() {
return ("0x"+parseInt(this).toString(16)).bin()
}
+
diff --git a/ethereal/assets/qml/webapp.qml b/ethereal/assets/qml/webapp.qml
index 4bac12ef0..2267ab4bf 100644
--- a/ethereal/assets/qml/webapp.qml
+++ b/ethereal/assets/qml/webapp.qml
@@ -41,7 +41,7 @@ ApplicationWindow {
experimental.preferences.developerExtrasEnabled: true
experimental.userScripts: [ui.assetPath("ethereum.js")]
experimental.onMessageReceived: {
- //console.log("[onMessageReceived]: ", message.data)
+ console.log("[onMessageReceived]: ", message.data)
// TODO move to messaging.js
var data = JSON.parse(message.data)
@@ -98,6 +98,15 @@ ApplicationWindow {
window[key] = data.args[key];
}
}
+ break;
+ case "debug":
+ console.log(data.args[0]);
+ break;
+ case "test":
+ console.log("in")
+ webview.experimental.evaluateJavaScript("hello()")
+ console.log("out")
+ break;
}
} catch(e) {
console.log(data.call + ": " + e)
@@ -124,7 +133,10 @@ ApplicationWindow {
function onObjectChangeCb(stateObject) {
postEvent("object:"+stateObject.address(), stateObject)
}
- function onStorageChangeCb() {
+ function onStorageChangeCb(storageObject) {
+ console.log("storage object cb", storageObject)
+ var ev = ["storage", storageObject.stateAddress, storageObject.address].join(":");
+ postEvent(ev, [storageObject.address, storageObject.value])
}
}
diff --git a/ethereal/assets/samplecoin/samplecoin.html b/ethereal/assets/samplecoin/samplecoin.html
index 02e2bd6ea..fb0c22c7f 100644
--- a/ethereal/assets/samplecoin/samplecoin.html
+++ b/ethereal/assets/samplecoin/samplecoin.html
@@ -5,9 +5,11 @@
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="bootstrap-theme.min.css">
<link rel="stylesheet" href="samplecoin.css">
+<script src="promise.min.js"></script>
<meta name="viewport" content="minimum-scale=1; maximum-scale=1; initial-scale=1;">
<script type="text/javascript">
+
var jefcoinAddr = "3dff537f51350239abc95c76a5864aa605259e7d"
var mAddr = ""
@@ -17,12 +19,12 @@ function createTransaction() {
var data = (("0x"+addr).pad(32) + amount.pad(32)).unbin()
eth.transact(mAddr, jefcoinAddr, 0, "10000000", "250", data, function(receipt) {
- debug("received tx hash:", receipt)
+ debug("received tx hash:", reciept.address)
})
}
function init() {
- eth.set({width: 500})
+ eth.set({width: 500});
eth.getKey(function(keyPair) {
mAddr = keyPair.privateKey;
@@ -31,10 +33,8 @@ function init() {
document.querySelector("#current-amount").innerHTML = storage;
});
- eth.watch(jefcoinAddr, function(stateObject) {
- eth.getStorageAt(jefcoinAddr, keyPair.address, function(storage) {
- document.querySelector("#current-amount").innerHTML = storage;
- });
+ eth.watch(jefcoinAddr, keyPair.address, function(addr, value) {
+ document.querySelector("#current-amount").innerHTML = value
});
});
}