Comparing version 0.12.1 to 0.12.2
{ | ||
"name": "web3", | ||
"namespace": "ethereum", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "Ethereum Compatible JavaScript API", | ||
@@ -6,0 +6,0 @@ "main": [ |
@@ -81,3 +81,3 @@ /* | ||
var formatInputString = function (value) { | ||
var result = utils.fromAscii(value).substr(2); | ||
var result = utils.fromUtf8(value).substr(2); | ||
var length = result.length / 2; | ||
@@ -219,3 +219,3 @@ var l = Math.floor((result.length + 63) / 64); | ||
var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2; | ||
return utils.toAscii(param.dynamicPart().substr(64, length)); | ||
return utils.toUtf8(param.dynamicPart().substr(64, length)); | ||
}; | ||
@@ -222,0 +222,0 @@ |
@@ -22,3 +22,3 @@ var f = require('./formatters'); | ||
this._inputFormatter = f.formatInputInt; | ||
this._outputFormatter = f.formatOutputInt; | ||
this._outputFormatter = f.formatOutputUInt; | ||
}; | ||
@@ -25,0 +25,0 @@ |
@@ -33,3 +33,3 @@ /* | ||
console.warn('if you need to hash hex value, you can do \'sha3("0xfff", true)\''); | ||
str = utils.toAscii(str); | ||
str = utils.toUtf8(str); | ||
} | ||
@@ -36,0 +36,0 @@ |
@@ -17,3 +17,3 @@ /* | ||
*/ | ||
/** | ||
/** | ||
* @file utils.js | ||
@@ -26,3 +26,3 @@ * @author Marek Kotewicz <marek@ethdev.com> | ||
* Utils | ||
* | ||
* | ||
* @module utils | ||
@@ -33,3 +33,3 @@ */ | ||
* Utility functions | ||
* | ||
* | ||
* @class [utils] utils | ||
@@ -41,2 +41,3 @@ * @constructor | ||
var BigNumber = require('bignumber.js'); | ||
var utf8 = require('utf8'); | ||
@@ -96,6 +97,27 @@ var unitMap = { | ||
/** | ||
* Should be called to get sting from it's hex representation | ||
* TODO: it should be called toUTF8 | ||
/** | ||
* Should be called to get utf8 from it's hex representation | ||
* | ||
* @method toUtf8 | ||
* @param {String} string in hex | ||
* @returns {String} ascii string representation of hex value | ||
*/ | ||
var toUtf8 = function(hex) { | ||
// Find termination | ||
var str = ""; | ||
var i = 0, l = hex.length; | ||
if (hex.substring(0, 2) === '0x') { | ||
i = 2; | ||
} | ||
for (; i < l; i+=2) { | ||
var code = parseInt(hex.substr(i, 2), 16); | ||
str += String.fromCharCode(code); | ||
} | ||
return utf8.decode(str); | ||
}; | ||
/** | ||
* Should be called to get ascii from it's hex representation | ||
* | ||
* @method toAscii | ||
@@ -117,14 +139,15 @@ * @param {String} string in hex | ||
return decodeURIComponent(escape(str)); // jshint ignore:line | ||
return str; | ||
}; | ||
/** | ||
* Shold be called to get hex representation (prefixed by 0x) of ascii string | ||
* Shold be called to get hex representation (prefixed by 0x) of utf8 string | ||
* | ||
* @method toHexNative | ||
* @method fromUtf8 | ||
* @param {String} string | ||
* @param {Number} optional padding | ||
* @returns {String} hex representation of input string | ||
*/ | ||
var toHexNative = function(str) { | ||
str = unescape(encodeURIComponent(str)); // jshint ignore:line | ||
var fromUtf8 = function(str) { | ||
str = utf8.encode(str); | ||
var hex = ""; | ||
@@ -136,7 +159,7 @@ for(var i = 0; i < str.length; i++) { | ||
return hex; | ||
return "0x" + hex; | ||
}; | ||
/** | ||
* Shold be called to get hex representation (prefixed by 0x) of ascii string | ||
* Shold be called to get hex representation (prefixed by 0x) of ascii string | ||
* | ||
@@ -148,7 +171,10 @@ * @method fromAscii | ||
*/ | ||
var fromAscii = function(str, pad) { | ||
pad = pad === undefined ? 0 : pad; | ||
var hex = toHexNative(str); | ||
while (hex.length < pad*2) | ||
hex += "00"; | ||
var fromAscii = function(str) { | ||
var hex = ""; | ||
for(var i = 0; i < str.length; i++) { | ||
var code = str.charCodeAt(i); | ||
var n = code.toString(16); | ||
hex += n.length < 2 ? '0' + n : n; | ||
} | ||
return "0x" + hex; | ||
@@ -175,3 +201,3 @@ }; | ||
* Should be called to get display name of contract function | ||
* | ||
* | ||
* @method extractDisplayName | ||
@@ -182,3 +208,3 @@ * @param {String} name of function/event | ||
var extractDisplayName = function (name) { | ||
var length = name.indexOf('('); | ||
var length = name.indexOf('('); | ||
return length !== -1 ? name.substr(0, length) : name; | ||
@@ -238,3 +264,3 @@ }; | ||
if (isObject(val)) | ||
return fromAscii(JSON.stringify(val)); | ||
return fromUtf8(JSON.stringify(val)); | ||
@@ -282,3 +308,3 @@ // if its a negative number, pass it through fromDecimal | ||
* - ether -- -- | ||
* - kether einstein grand | ||
* - kether einstein grand | ||
* - mether | ||
@@ -296,3 +322,3 @@ * - gether | ||
return isBigNumber(number) ? returnValue : returnValue.toString(10); | ||
return isBigNumber(number) ? returnValue : returnValue.toString(10); | ||
}; | ||
@@ -306,3 +332,3 @@ | ||
* - kwei femtoether ada | ||
* - mwei picoether babbage | ||
* - mwei picoether babbage | ||
* - gwei nanoether shannon nano | ||
@@ -312,3 +338,3 @@ * - -- microether szabo micro | ||
* - ether -- -- | ||
* - kether einstein grand | ||
* - kether einstein grand | ||
* - mether | ||
@@ -326,3 +352,3 @@ * - gether | ||
return isBigNumber(number) ? returnValue : returnValue.toString(10); | ||
return isBigNumber(number) ? returnValue : returnValue.toString(10); | ||
}; | ||
@@ -346,3 +372,3 @@ | ||
} | ||
return new BigNumber(number.toString(10), 10); | ||
@@ -399,3 +425,3 @@ }; | ||
} | ||
if (/^[0-9a-f]{40}$/.test(address)) { | ||
@@ -414,3 +440,3 @@ return '0x' + address; | ||
* @param {Object} | ||
* @return {Boolean} | ||
* @return {Boolean} | ||
*/ | ||
@@ -424,3 +450,3 @@ var isBigNumber = function (object) { | ||
* Returns true if object is string, otherwise false | ||
* | ||
* | ||
* @method isString | ||
@@ -476,3 +502,3 @@ * @param {Object} | ||
var isArray = function (object) { | ||
return object instanceof Array; | ||
return object instanceof Array; | ||
}; | ||
@@ -482,3 +508,3 @@ | ||
* Returns true if given string is valid json object | ||
* | ||
* | ||
* @method isJson | ||
@@ -502,3 +528,5 @@ * @param {String} | ||
fromDecimal: fromDecimal, | ||
toUtf8: toUtf8, | ||
toAscii: toAscii, | ||
fromUtf8: fromUtf8, | ||
fromAscii: fromAscii, | ||
@@ -523,2 +551,1 @@ transformToFullName: transformToFullName, | ||
}; | ||
{ | ||
"version": "0.12.1" | ||
"version": "0.12.2" | ||
} |
@@ -114,3 +114,5 @@ /* | ||
web3.toAscii = utils.toAscii; | ||
web3.toUtf8 = utils.toUtf8; | ||
web3.fromAscii = utils.fromAscii; | ||
web3.fromUtf8 = utils.fromUtf8; | ||
web3.toDecimal = utils.toDecimal; | ||
@@ -117,0 +119,0 @@ web3.fromDecimal = utils.fromDecimal; |
@@ -47,3 +47,3 @@ /* | ||
else | ||
return utils.fromAscii(value); | ||
return utils.fromUtf8(value); | ||
}; | ||
@@ -50,0 +50,0 @@ |
@@ -224,3 +224,3 @@ /* | ||
post.topics = post.topics.map(function(topic){ | ||
return utils.fromAscii(topic); | ||
return utils.fromUtf8(topic); | ||
}); | ||
@@ -245,3 +245,3 @@ | ||
post.payloadRaw = post.payload; | ||
post.payload = utils.toAscii(post.payload); | ||
post.payload = utils.toUtf8(post.payload); | ||
@@ -257,3 +257,3 @@ if (utils.isJson(post.payload)) { | ||
post.topics = post.topics.map(function(topic){ | ||
return utils.toAscii(topic); | ||
return utils.toUtf8(topic); | ||
}); | ||
@@ -260,0 +260,0 @@ |
@@ -149,3 +149,3 @@ /* | ||
Iban.prototype.isValid = function () { | ||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30})$/.test(this._iban) && | ||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) && | ||
mod9710(iso13616Prepare(this._iban)) === 1; | ||
@@ -152,0 +152,0 @@ }; |
/* jshint ignore:start */ | ||
Package.describe({ | ||
name: 'ethereum:web3', | ||
version: '0.12.1', | ||
version: '0.12.2', | ||
summary: 'Ethereum JavaScript API, middleware to talk to a ethreum node over RPC', | ||
@@ -6,0 +6,0 @@ git: 'https://github.com/ethereum/ethereum.js', |
{ | ||
"name": "web3", | ||
"namespace": "ethereum", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"description": "Ethereum JavaScript API, middleware to talk to a ethereum node over RPC", | ||
@@ -13,2 +13,3 @@ "main": "./index.js", | ||
"crypto-js": "^3.1.4", | ||
"utf8": "^2.1.1", | ||
"xmlhttprequest": "*" | ||
@@ -15,0 +16,0 @@ }, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2338444
41597
4
+ Addedutf8@^2.1.1
+ Addedutf8@2.1.2(transitive)