aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/assets/ext/ethereum.js
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-14 06:18:37 +0800
committerobscuren <geffobscura@gmail.com>2014-08-14 06:18:37 +0800
commit95ba340d07a02da40000d4bcf2b1bb24bd7856ef (patch)
tree79a067c70f5a1624c87b17c8efed02d160a0b0b8 /ethereal/assets/ext/ethereum.js
parentd518423b9c493bf5b42e6575db9a32106812e6bc (diff)
downloadgo-tangerine-95ba340d07a02da40000d4bcf2b1bb24bd7856ef.tar
go-tangerine-95ba340d07a02da40000d4bcf2b1bb24bd7856ef.tar.gz
go-tangerine-95ba340d07a02da40000d4bcf2b1bb24bd7856ef.tar.bz2
go-tangerine-95ba340d07a02da40000d4bcf2b1bb24bd7856ef.tar.lz
go-tangerine-95ba340d07a02da40000d4bcf2b1bb24bd7856ef.tar.xz
go-tangerine-95ba340d07a02da40000d4bcf2b1bb24bd7856ef.tar.zst
go-tangerine-95ba340d07a02da40000d4bcf2b1bb24bd7856ef.zip
Tweaks and fixes + added webview debugger
* Require better icons .. someone? :-)
Diffstat (limited to 'ethereal/assets/ext/ethereum.js')
-rw-r--r--ethereal/assets/ext/ethereum.js95
1 files changed, 81 insertions, 14 deletions
diff --git a/ethereal/assets/ext/ethereum.js b/ethereal/assets/ext/ethereum.js
index de6fb0255..9970c6379 100644
--- a/ethereal/assets/ext/ethereum.js
+++ b/ethereal/assets/ext/ethereum.js
@@ -2,30 +2,97 @@
window.eth = {
prototype: Object(),
+ mutan: function(code) {
+ },
+
+ toHex: function(str) {
+ var hex = "";
+ for(var i = 0; i < str.length; i++) {
+ var n = str.charCodeAt(i).toString(16);
+ hex += n.length < 2 ? '0' + n : n;
+ }
+
+ return hex;
+ },
+
+ toAscii: function(hex) {
+ // Find termination
+ var str = "";
+ var i = 0, l = hex.length;
+ for(; i < l; i+=2) {
+ var code = hex.charCodeAt(i)
+ if(code == 0) {
+ break;
+ }
+
+ str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
+ }
+
+ return str;
+ },
+
+ fromAscii: function(str, pad) {
+ if(pad === undefined) {
+ pad = 32
+ }
+
+ var hex = this.toHex(str);
+
+ while(hex.length < pad*2)
+ hex += "00";
+
+ return hex
+ },
+
+
// Retrieve block
//
// Either supply a number or a string. Type is determent for the lookup method
// string - Retrieves the block by looking up the hash
// number - Retrieves the block by looking up the block number
- getBlock: function(numberOrHash, cb) {
- var func;
- if(typeof numberOrHash == "string") {
- func = "getBlockByHash";
- } else {
- func = "getBlockByNumber";
- }
- postData({call: func, args: [numberOrHash]}, cb);
- },
+ getBlock: function(numberOrHash, cb) {
+ var func;
+ if(typeof numberOrHash == "string") {
+ func = "getBlockByHash";
+ } else {
+ func = "getBlockByNumber";
+ }
+ postData({call: func, args: [numberOrHash]}, cb);
+ },
// Create transaction
//
// Transact between two state objects
- transact: function(sec, recipient, value, gas, gasPrice, data, cb) {
- postData({call: "transact", args: [sec, recipient, value, gas, gasPrice, data]}, cb);
- },
+ transact: function(params, cb) {
+ if(params === undefined) {
+ params = {};
+ }
+
+ if(params.endowment !== undefined)
+ params.value = params.endowment;
+ if(params.code !== undefined)
+ params.data = params.code;
+
+ // Make sure everything is string
+ var fields = ["to", "from", "value", "gas", "gasPrice"];
+ for(var i = 0; i < fields.length; i++) {
+ if(params[fields[i]] === undefined) {
+ params[fields[i]] = "";
+ }
+ params[fields[i]] = params[fields[i]].toString();
+ }
+
+ var data;
+ if(typeof params.data === "object") {
+ data = "";
+ for(var i = 0; i < params.data.length; i++) {
+ data += params.data[i]
+ }
+ } else {
+ data = params.data;
+ }
- create: function(sec, value, gas, gasPrice, init, body, cb) {
- postData({call: "create", args: [sec, value, gas, gasPrice, init, body]}, cb);
+ postData({call: "transact", args: [params.from, params.to, params.value, params.gas, params.gasPrice, "0x"+data]}, cb);
},
getStorageAt: function(address, storageAddress, cb) {