diff options
author | Maran <maran.hidskes@gmail.com> | 2014-05-05 20:17:20 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-05-05 20:17:20 +0800 |
commit | cb9ca992debfcef83f79b2c606955e6688880694 (patch) | |
tree | 91133b39f56ab5292a538a353ab3c55c3b951383 /ethereal/assets | |
parent | e94e5ac75dbbc4ec52228ae11377a4fa71ab95ab (diff) | |
parent | 91824af46b59b7af84c7591236fe8b34b667ddb8 (diff) | |
download | go-tangerine-cb9ca992debfcef83f79b2c606955e6688880694.tar.gz go-tangerine-cb9ca992debfcef83f79b2c606955e6688880694.tar.zst go-tangerine-cb9ca992debfcef83f79b2c606955e6688880694.zip |
Merge branch 'develop' into feature/rpc
Diffstat (limited to 'ethereal/assets')
-rw-r--r-- | ethereal/assets/ethereum.js | 29 | ||||
-rw-r--r-- | ethereal/assets/qml/webapp.qml | 19 | ||||
-rw-r--r-- | ethereal/assets/samplecoin/samplecoin.html | 22 |
3 files changed, 53 insertions, 17 deletions
diff --git a/ethereal/assets/ethereum.js b/ethereal/assets/ethereum.js index 64a7ff47c..8f1a60300 100644 --- a/ethereal/assets/ethereum.js +++ b/ethereal/assets/ethereum.js @@ -40,6 +40,10 @@ window.eth = { postData({call: "getBalance", args: [address]}, cb); }, + getSecretToAddress: function(sec, cb) { + postData({call: "getSecretToAddress", args: [sec]}, cb); + }, + watch: function(address, storageAddrOrCb, cb) { var ev; if(cb === undefined) { @@ -101,7 +105,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 +119,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 +135,7 @@ function debug(/**/) { } } + postData({call:"debug", args:[msg]}) document.getElementById("debug").innerHTML += "<br>" + msg } @@ -146,8 +162,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 +233,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..d02c9a82e 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) @@ -81,8 +81,9 @@ ApplicationWindow { break case "getKey": - var keys = eth.getKey() - postData(data._seed, keys) + var key = eth.getKey().privateKey; + + postData(data._seed, key) break case "watch": require(1) @@ -98,6 +99,14 @@ ApplicationWindow { window[key] = data.args[key]; } } + break; + case "getSecretToAddress": + require(1) + postData(data._seed, eth.secretToAddress(data.args[0])) + break; + case "debug": + console.log(data.args[0]); + break; } } catch(e) { console.log(data.call + ": " + e) @@ -124,7 +133,9 @@ ApplicationWindow { function onObjectChangeCb(stateObject) { postEvent("object:"+stateObject.address(), stateObject) } - function onStorageChangeCb() { + function onStorageChangeCb(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..c1ee941a2 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,24 +19,24 @@ 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.getKey(function(keyPair) { - mAddr = keyPair.privateKey; + eth.set({width: 500}); - eth.getStorageAt(jefcoinAddr, keyPair.address, function(storage) { - document.querySelector("#current-amount").innerHTML = storage; - }); + eth.getKey(function(sec) { + eth.getSecretToAddress(sec, function(addr) { + mAddr = addr; - eth.watch(jefcoinAddr, function(stateObject) { - eth.getStorageAt(jefcoinAddr, keyPair.address, function(storage) { + eth.getStorageAt(jefcoinAddr, addr, function(storage) { document.querySelector("#current-amount").innerHTML = storage; }); + + eth.watch(jefcoinAddr, addr, function(addr, value) { + document.querySelector("#current-amount").innerHTML = value + }); }); }); } |