aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/assets/ext/ethereum.js
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-14 23:01:37 +0800
committerobscuren <geffobscura@gmail.com>2014-08-14 23:01:37 +0800
commit1fd69e956949671806b23b7ec1feec4f6c416a81 (patch)
treee807a5564dd81c75b550aeb12405d51f3704d125 /ethereal/assets/ext/ethereum.js
parent612b631823c0cb80f0e559c533b32b6890349761 (diff)
downloadgo-tangerine-1fd69e956949671806b23b7ec1feec4f6c416a81.tar
go-tangerine-1fd69e956949671806b23b7ec1feec4f6c416a81.tar.gz
go-tangerine-1fd69e956949671806b23b7ec1feec4f6c416a81.tar.bz2
go-tangerine-1fd69e956949671806b23b7ec1feec4f6c416a81.tar.lz
go-tangerine-1fd69e956949671806b23b7ec1feec4f6c416a81.tar.xz
go-tangerine-1fd69e956949671806b23b7ec1feec4f6c416a81.tar.zst
go-tangerine-1fd69e956949671806b23b7ec1feec4f6c416a81.zip
Implemented "messages"
Diffstat (limited to 'ethereal/assets/ext/ethereum.js')
-rw-r--r--ethereal/assets/ext/ethereum.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/ethereal/assets/ext/ethereum.js b/ethereal/assets/ext/ethereum.js
index 9970c6379..5b8fb54f3 100644
--- a/ethereal/assets/ext/ethereum.js
+++ b/ethereal/assets/ext/ethereum.js
@@ -95,6 +95,10 @@ window.eth = {
postData({call: "transact", args: [params.from, params.to, params.value, params.gas, params.gasPrice, "0x"+data]}, cb);
},
+ getMessages: function(filter, cb) {
+ postData({call: "messages", args: [filter]}, cb);
+ },
+
getStorageAt: function(address, storageAddress, cb) {
postData({call: "getStorage", args: [address, storageAddress]}, cb);
},
@@ -209,4 +213,33 @@ window.eth = {
}
window.eth._callbacks = {}
window.eth._onCallbacks = {}
+function postData(data, cb) {
+ data._seed = Math.floor(Math.random() * 1000000)
+ if(cb) {
+ eth._callbacks[data._seed] = cb;
+ }
+
+ if(data.args === undefined) {
+ data.args = [];
+ }
+
+ navigator.qt.postMessage(JSON.stringify(data));
+}
+navigator.qt.onmessage = function(ev) {
+ var data = JSON.parse(ev.data)
+
+ if(data._event !== undefined) {
+ eth.trigger(data._event, data.data);
+ } else {
+ if(data._seed) {
+ var cb = eth._callbacks[data._seed];
+ if(cb) {
+ cb.call(this, data.data)
+
+ // Remove the "trigger" callback
+ delete eth._callbacks[ev._seed];
+ }
+ }
+ }
+}