aboutsummaryrefslogtreecommitdiffstats
path: root/lib/web3.js
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-14 17:50:34 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2015-01-14 17:50:34 +0800
commit8d1f96cc0aa608c319a48af5a3c2397b694d5930 (patch)
tree1907976796469318b9be61df0f0d1978c76975ec /lib/web3.js
parent422dc05bb054b86d72b313edc2e7cb79dfb70ba3 (diff)
downloadgo-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.tar.gz
go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.tar.zst
go-tangerine-8d1f96cc0aa608c319a48af5a3c2397b694d5930.zip
few comments
Diffstat (limited to 'lib/web3.js')
-rw-r--r--lib/web3.js30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/web3.js b/lib/web3.js
index 47decb8bd..25c2901a8 100644
--- a/lib/web3.js
+++ b/lib/web3.js
@@ -254,6 +254,7 @@ var web3 = {
return hex;
},
+ /// @returns ascii string representation of hex value prefixed with 0x
toAscii: function(hex) {
// Find termination
var str = "";
@@ -272,6 +273,7 @@ var web3 = {
return str;
},
+ /// @returns hex representation (prefixed by 0x) of ascii string
fromAscii: function(str, pad) {
pad = pad === undefined ? 0 : pad;
var hex = this.toHex(str);
@@ -280,14 +282,17 @@ var web3 = {
return "0x" + hex;
},
+ /// @returns decimal representaton of hex value prefixed by 0x
toDecimal: function (val) {
return hexToDec(val.substring(2));
},
+ /// @returns hex representation (prefixed by 0x) of decimal value
fromDecimal: function (val) {
return "0x" + decToHex(val);
},
+ /// used to transform value/string to eth string
toEth: function(str) {
var val = typeof str === "string" ? str.indexOf('0x') === 0 ? parseInt(str.substr(2), 16) : parseInt(str) : str;
var unit = 0;
@@ -311,24 +316,24 @@ var web3 = {
return s + ' ' + units[unit];
},
+ /// eth object prototype
eth: {
- prototype: Object(), // jshint ignore:line
watch: function (params) {
return new Filter(params, ethWatch);
}
},
- db: {
- prototype: Object() // jshint ignore:line
- },
+ /// db object prototype
+ db: {},
+ /// shh object prototype
shh: {
- prototype: Object(), // jshint ignore:line
watch: function (params) {
return new Filter(params, shhWatch);
}
},
+ /// used by filter to register callback with given id
on: function(event, id, cb) {
if(web3._events[event] === undefined) {
web3._events[event] = {};
@@ -338,6 +343,7 @@ var web3 = {
return this;
},
+ /// used by filter to unregister callback with given id
off: function(event, id) {
if(web3._events[event] !== undefined) {
delete web3._events[event][id];
@@ -346,6 +352,7 @@ var web3 = {
return this;
},
+ /// used to trigger callback registered by filter
trigger: function(event, id, data) {
var callbacks = web3._events[event];
if (!callbacks || !callbacks[id]) {
@@ -353,6 +360,11 @@ var web3 = {
}
var cb = callbacks[id];
cb(data);
+ },
+
+ /// @returns true if provider is installed
+ haveProvider: function() {
+ return !!web3.provider.provider;
}
};
@@ -375,7 +387,6 @@ var shhWatch = {
setupMethods(shhWatch, shhWatchMethods());
-
web3.provider = new ProviderManager();
web3.setProvider = function(provider) {
@@ -384,13 +395,6 @@ web3.setProvider = function(provider) {
web3.provider.sendQueued();
};
-/// returns true if provider is installed
-web3.haveProvider = function() {
- return !!web3.provider.provider;
-};
-
-
-
/// callled when there is new incoming message
function messageHandler(data) {
if(data._event !== undefined) {