plugeth/dist/ethereum.min.js

1 line
11 KiB
JavaScript
Raw Normal View History

2015-01-22 13:37:34 +00:00
require=function t(e,n,r){function i(a,f){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!f&&s)return s(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a<r.length;a++)i(r[a]);return i}({1:[function(t,e){var n=t("./web3");BigNumber.config({ROUNDING_MODE:BigNumber.ROUND_DOWN});var r=32,i=4,o=function(t,e){for(var n=!1,r=0;r<t.length&&!n;r++)n=e(t[r]);return n?r-1:-1},a=function(t,e){return o(t,function(t){return t.name===e})},f=function(t,e,n){return new Array(e-t.length+1).join(n?n:"0")+t},s=function(t){return function(e){return 0===e.indexOf(t)}},u=function(t){return function(e){return t===e}},c=function(t){return"[]"===t.slice(-2)},l=function(t){var e=2*r;return t instanceof BigNumber||"number"==typeof t?("number"==typeof t&&(t=new BigNumber(t)),t=t.round(),t.lessThan(0)&&(t=new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16).plus(t).plus(1)),t=t.toString(16)):t=0===t.indexOf("0x")?t.substr(2):"string"==typeof t?l(new BigNumber(t)):(+t).toString(16),f(t,e)},p=function(t){return n.fromAscii(t,r).substr(2)},h=function(t){return"000000000000000000000000000000000000000000000000000000000000000"+(t?"1":"0")},d=function(t){return l(new BigNumber(t).times(new BigNumber(2).pow(128)))},g=function(t,e){return c(t)||s("string")(t)?l(e.length):""},m=function(){return[{type:s("uint"),format:l},{type:s("int"),format:l},{type:s("hash"),format:l},{type:s("string"),format:p},{type:s("real"),format:d},{type:s("ureal"),format:d},{type:u("address"),format:l},{type:u("bool"),format:h}]},v=m(),b=function(t,e,n){var r="",i=a(t,e);if(-1!==i){var o=t[i];return o.inputs.forEach(function(t,e){r+=g(t.type,n[e])}),o.inputs.forEach(function(t,e){for(var i=!1,a=0;a<v.length&&!i;a++)i=v[a].type(o.inputs[e].type,n[e]);i||console.error("input parser does not support type: "+o.inputs[e].type);var f=v[a-1].format,s="";s=c(o.inputs[e].type)?n[e].reduce(function(t,e){return t+f(e)},""):f(n[e]),r+=s}),r}},y=function(t){return"1"===new BigNumber(t.substr(0,1),16).toString(2).substr(0,1)},_=function(t){return y(t)?new BigNumber(t,16).minus(new BigNumber("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",16)).minus(1):new BigNumber(t,16)},w=function(t){return new BigNumber(t,16)},N=function(t){return _(t).dividedBy(new BigNumber(2).pow(128))},x=function(t){return w(t).dividedBy(new BigNumber(2).pow(128))},B=function(t){return"0x"+t},A=function(t){return"0000000000000000000000000000000000000000000000000000000000000001"===t?!0:!1},S=function(t){return n.toAscii(t)},O=function(t){return"0x"+t.slice(t.length-40,t.length)},P=function(t){return c(t)||s("string")(t)?2*r:0},E=function(){return[{type:s("uint"),format:w},{type:s("int"),format:_},{type:s("hash"),format:B},{type:s("string"),format:S},{type:s("real"),format:N},{type:s("ureal"),format:x},{type:u("address"),format:O},{type:u("bool"),format:A}]},F=E(),k=function(t,e,n){var i=a(t,e);if(-1!==i){n=n.slice(2);var o=[],f=t[i],u=2*r,l=f.outputs.reduce(function(t,e){return t+P(e.type)},0),p=n.slice(0,l);return n=n.slice(l),f.outputs.forEach(function(t,e){for(var r=!1,i=0;i<F.length&&!r;i++)r=F[i].type(f.outputs[e].type);r||console.error("output parser does not support type: "+f.outputs[e].type);var a=F[i-1].format;if(c(f.outputs[e].type)){var l=w(p.slice(0,u));p=p.slice(u);for(var h=[],d=0;l>d;d++)h.push(a(n.slice(0,u))),n=n.slice(u);o.push(h)}else s("string")(f.outputs[e].type)?(p=p.slice(u),o.push(a(n.slice(0,u))),n=n.slice(u)):(o.push(a(n.slice(0,u))),n=n.slice(u))}),o}},T=function(t){var e=t.indexOf("(");return-1!==e?t.substr(0,e):t},D=function(t){var e=t.indexOf("(");return-1!==e?t.substr(e+1,t.length-1-(e+1)):""},M=function(t){var e={};return t.forEach(function(n){var r=T(n.name),i=D(n.name),o=function(){var e=Array.prototype.slice.call(arguments);return b(t,n.name,e)};void 0===e[r]&&(e[r]=o),e[r][i]=o}),e},