diff options
author | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-13 18:15:44 +0800 |
---|---|---|
committer | Marek Kotewicz <marek.kotewicz@gmail.com> | 2015-01-13 18:15:44 +0800 |
commit | 7595a5dfcbd8eb58e1ab384ea412877d0f387ef4 (patch) | |
tree | 810f509efaa4b4d1281d01edfa3e55e1777e0ba1 /dist/ethereum.js | |
parent | 9a9987aeed7d1f82dd6b80a5d0ef24dfe668e630 (diff) | |
download | go-tangerine-7595a5dfcbd8eb58e1ab384ea412877d0f387ef4.tar go-tangerine-7595a5dfcbd8eb58e1ab384ea412877d0f387ef4.tar.gz go-tangerine-7595a5dfcbd8eb58e1ab384ea412877d0f387ef4.tar.bz2 go-tangerine-7595a5dfcbd8eb58e1ab384ea412877d0f387ef4.tar.lz go-tangerine-7595a5dfcbd8eb58e1ab384ea412877d0f387ef4.tar.xz go-tangerine-7595a5dfcbd8eb58e1ab384ea412877d0f387ef4.tar.zst go-tangerine-7595a5dfcbd8eb58e1ab384ea412877d0f387ef4.zip |
removed padding calculation from ethereum.js, padding is always 32
Diffstat (limited to 'dist/ethereum.js')
-rw-r--r-- | dist/ethereum.js | 83 |
1 files changed, 24 insertions, 59 deletions
diff --git a/dist/ethereum.js b/dist/ethereum.js index 400a66815..e440823f6 100644 --- a/dist/ethereum.js +++ b/dist/ethereum.js @@ -55,47 +55,16 @@ var padLeft = function (string, chars) { return new Array(chars - string.length + 1).join("0") + string; }; -var calcBitPadding = function (type, expected) { - var value = type.slice(expected.length); - if (value === "") { - return 32; - } - return parseInt(value) / 8; -}; - -var calcBytePadding = function (type, expected) { - var value = type.slice(expected.length); - if (value === "") { - return 32; - } - return parseInt(value); -}; - -var calcRealPadding = function (type, expected) { - var value = type.slice(expected.length); - if (value === "") { - return 32; - } - var sizes = value.split('x'); - for (var padding = 0, i = 0; i < sizes; i++) { - padding += (sizes[i] / 8); - } - return padding; -}; - var setupInputTypes = function () { - var prefixedType = function (prefix, calcPadding) { + var prefixedType = function (prefix) { return function (type, value) { var expected = prefix; if (type.indexOf(expected) !== 0) { return false; } - var padding = calcPadding(type, expected); - if (padding > 32) - return false; // not allowed to be so big. - padding = 32; // override as per the new ABI. + var padding = 32; // override as per the new ABI. if (prefix === "string") return web3.fromAscii(value, padding).substr(2); @@ -111,13 +80,13 @@ var setupInputTypes = function () { }; }; - var namedType = function (name, padding, formatter) { + var namedType = function (name, formatter) { return function (type, value) { if (type !== name) { return false; } - padding = 32; //override as per the new ABI. + var padding = 32; //override as per the new ABI. return padLeft(formatter ? formatter(value) : value, padding * 2); }; @@ -128,14 +97,14 @@ var setupInputTypes = function () { }; return [ - prefixedType('uint', calcBitPadding), - prefixedType('int', calcBitPadding), - prefixedType('hash', calcBitPadding), - prefixedType('string', calcBytePadding), - prefixedType('real', calcRealPadding), - prefixedType('ureal', calcRealPadding), - namedType('address', 20), - namedType('bool', 1, formatBool), + prefixedType('uint'), + prefixedType('int'), + prefixedType('hash'), + prefixedType('string'), + prefixedType('real'), + prefixedType('ureal'), + namedType('address'), + namedType('bool', formatBool), ]; }; @@ -166,24 +135,20 @@ var toAbiInput = function (json, methodName, params) { var setupOutputTypes = function () { - var prefixedType = function (prefix, calcPadding) { + var prefixedType = function (prefix) { return function (type) { var expected = prefix; if (type.indexOf(expected) !== 0) { return -1; } - - var padding = calcPadding(type, expected); - if (padding > 32) - return -1; // not allowed to be so big. - padding = 32; // override as per the new ABI. + var padding = 32; // override as per the new ABI. return padding * 2; }; }; - var namedType = function (name, padding) { + var namedType = function (name) { return function (type) { - padding = 32; // override as per the new ABI. + var padding = 32; // override as per the new ABI. return name === type ? padding * 2 : -1; }; }; @@ -205,14 +170,14 @@ var setupOutputTypes = function () { }; return [ - { padding: prefixedType('uint', calcBitPadding), format: formatInt }, - { padding: prefixedType('int', calcBitPadding), format: formatInt }, - { padding: prefixedType('hash', calcBitPadding), format: formatHash }, - { padding: prefixedType('string', calcBytePadding), format: formatString }, - { padding: prefixedType('real', calcRealPadding), format: formatInt }, - { padding: prefixedType('ureal', calcRealPadding), format: formatInt }, - { padding: namedType('address', 20) }, - { padding: namedType('bool', 1), format: formatBool } + { padding: prefixedType('uint'), format: formatInt }, + { padding: prefixedType('int'), format: formatInt }, + { padding: prefixedType('hash'), format: formatHash }, + { padding: prefixedType('string'), format: formatString }, + { padding: prefixedType('real'), format: formatInt }, + { padding: prefixedType('ureal'), format: formatInt }, + { padding: namedType('address') }, + { padding: namedType('bool'), format: formatBool } ]; }; |